• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  *******************************************************************************
3  *
4  *   © 2016 and later: Unicode, Inc. and others.
5  *   License & terms of use: http://www.unicode.org/copyright.html#License
6  *
7  *******************************************************************************
8  *******************************************************************************
9  *
10  *   Copyright (C) 1999-2013, International Business Machines
11  *   Corporation and others.  All Rights Reserved.
12  *
13  *******************************************************************************
14  *   file name:  SimpleFontInstance.cpp
15  *
16  *   created on: 03/30/2006
17  *   created by: Eric R. Mader
18  */
19 
20 #include "unicode/utypes.h"
21 #include "unicode/uchar.h"
22 
23 #include "layout/LETypes.h"
24 #include "layout/LEFontInstance.h"
25 
26 #include "layout/CanonShaping.h"
27 #include "SimpleFontInstance.h"
28 
SimpleFontInstance(float pointSize,LEErrorCode & status)29 SimpleFontInstance::SimpleFontInstance(float pointSize, LEErrorCode &status)
30     : fPointSize(pointSize), fAscent(0), fDescent(0)
31 {
32     if (LE_FAILURE(status)) {
33         return;
34     }
35 
36     fAscent  = (le_int32) yUnitsToPoints(2000.0);
37     fDescent = (le_int32) yUnitsToPoints(600.0);
38 
39     return;
40 }
41 
~SimpleFontInstance()42 SimpleFontInstance::~SimpleFontInstance()
43 {
44     // nothing to do...
45 }
46 
getFontTable(LETag tableTag) const47 const void *SimpleFontInstance::getFontTable(LETag tableTag) const
48 {
49     if (tableTag == LE_GSUB_TABLE_TAG) {
50         return CanonShaping::glyphSubstitutionTable;
51     }
52 
53     if (tableTag == LE_GDEF_TABLE_TAG) {
54         return CanonShaping::glyphDefinitionTable;
55     }
56 
57     return NULL;
58 }
59 
getGlyphAdvance(LEGlyphID glyph,LEPoint & advance) const60 void SimpleFontInstance::getGlyphAdvance(LEGlyphID glyph, LEPoint &advance) const
61 {
62 #if 0
63     if (u_getCombiningClass((UChar32) glyph) == 0) {
64         advance.fX = xUnitsToPoints(2048);
65     } else {
66         advance.fX = 0;
67     }
68 #else
69     advance.fX = xUnitsToPoints(2048);
70 #endif
71 
72     advance.fY = 0;
73 }
74 
getUnitsPerEM() const75 le_int32 SimpleFontInstance::getUnitsPerEM() const
76 {
77     return 2048;
78 }
79 
getAscent() const80 le_int32 SimpleFontInstance::getAscent() const
81 {
82     return fAscent;
83 }
84 
getDescent() const85 le_int32 SimpleFontInstance::getDescent() const
86 {
87     return fDescent;
88 }
89 
getLeading() const90 le_int32 SimpleFontInstance::getLeading() const
91 {
92     return 0;
93 }
94 
95 // We really want to inherit this method from the superclass, but some compilers
96 // issue a warning if we don't implement it...
mapCharToGlyph(LEUnicode32 ch,const LECharMapper * mapper,le_bool filterZeroWidth) const97 LEGlyphID SimpleFontInstance::mapCharToGlyph(LEUnicode32 ch, const LECharMapper *mapper, le_bool filterZeroWidth) const
98 {
99     return LEFontInstance::mapCharToGlyph(ch, mapper, filterZeroWidth);
100 }
101 
102 // We really want to inherit this method from the superclass, but some compilers
103 // issue a warning if we don't implement it...
mapCharToGlyph(LEUnicode32 ch,const LECharMapper * mapper) const104 LEGlyphID SimpleFontInstance::mapCharToGlyph(LEUnicode32 ch, const LECharMapper *mapper) const
105 {
106     return LEFontInstance::mapCharToGlyph(ch, mapper);
107 }
108 
mapCharToGlyph(LEUnicode32 ch) const109 LEGlyphID SimpleFontInstance::mapCharToGlyph(LEUnicode32 ch) const
110 {
111     return (LEGlyphID) ch;
112 }
113 
getXPixelsPerEm() const114 float SimpleFontInstance::getXPixelsPerEm() const
115 {
116     return fPointSize;
117 }
118 
getYPixelsPerEm() const119 float SimpleFontInstance::getYPixelsPerEm() const
120 {
121     return fPointSize;
122 }
123 
getScaleFactorX() const124 float SimpleFontInstance::getScaleFactorX() const
125 {
126     return 1.0;
127 }
128 
getScaleFactorY() const129 float SimpleFontInstance::getScaleFactorY() const
130 {
131     return 1.0;
132 }
133 
getGlyphPoint(LEGlyphID,le_int32,LEPoint &) const134 le_bool SimpleFontInstance::getGlyphPoint(LEGlyphID /*glyph*/, le_int32 /*pointNumber*/, LEPoint &/*point*/) const
135 {
136     return FALSE;
137 }
138 
139