1 // © 2016 and later: Unicode, Inc. and others.
2 // License & terms of use: http://www.unicode.org/copyright.html
4 *******************************************************************************
6 * Copyright (C) 1999-2015, International Business Machines
7 * Corporation and others. All Rights Reserved.
9 *******************************************************************************
10 * file name: SimpleFontInstance.cpp
12 * created on: 03/30/2006
13 * created by: Eric R. Mader
16 #include "unicode/utypes.h"
17 #include "unicode/uchar.h"
19 #include "layout/LETypes.h"
20 #include "layout/LEFontInstance.h"
23 #include "CanonShaping.h"
26 #include "SimpleFontInstance.h"
28 SimpleFontInstance::SimpleFontInstance(float pointSize
, LEErrorCode
&status
)
29 : fPointSize(pointSize
), fAscent(0), fDescent(0)
31 if (LE_FAILURE(status
)) {
35 fAscent
= (le_int32
) yUnitsToPoints(2000.0);
36 fDescent
= (le_int32
) yUnitsToPoints(600.0);
41 SimpleFontInstance::~SimpleFontInstance()
46 const void *SimpleFontInstance::getFontTable(LETag tableTag
, size_t &length
) const
48 length
= -1; // unknown for this test.
50 if (tableTag
== LE_GSUB_TABLE_TAG
) {
51 return CanonShaping::glyphSubstitutionTable
;
54 if (tableTag
== LE_GDEF_TABLE_TAG
) {
55 return CanonShaping::glyphDefinitionTable
;
61 void SimpleFontInstance::getGlyphAdvance(LEGlyphID glyph
, LEPoint
&advance
) const
64 if (u_getCombiningClass((UChar32
) glyph
) == 0) {
65 advance
.fX
= xUnitsToPoints(2048);
70 (void)glyph
; // Suppress unused parameter compiler warning.
71 advance
.fX
= xUnitsToPoints(2048);
77 le_int32
SimpleFontInstance::getUnitsPerEM() const
82 le_int32
SimpleFontInstance::getAscent() const
87 le_int32
SimpleFontInstance::getDescent() const
92 le_int32
SimpleFontInstance::getLeading() const
97 // We really want to inherit this method from the superclass, but some compilers
98 // issue a warning if we don't implement it...
99 LEGlyphID
SimpleFontInstance::mapCharToGlyph(LEUnicode32 ch
, const LECharMapper
*mapper
, le_bool filterZeroWidth
) const
101 return LEFontInstance::mapCharToGlyph(ch
, mapper
, filterZeroWidth
);
104 // We really want to inherit this method from the superclass, but some compilers
105 // issue a warning if we don't implement it...
106 LEGlyphID
SimpleFontInstance::mapCharToGlyph(LEUnicode32 ch
, const LECharMapper
*mapper
) const
108 return LEFontInstance::mapCharToGlyph(ch
, mapper
);
111 LEGlyphID
SimpleFontInstance::mapCharToGlyph(LEUnicode32 ch
) const
113 return (LEGlyphID
) ch
;
116 float SimpleFontInstance::getXPixelsPerEm() const
121 float SimpleFontInstance::getYPixelsPerEm() const
126 float SimpleFontInstance::getScaleFactorX() const
131 float SimpleFontInstance::getScaleFactorY() const
136 le_bool
SimpleFontInstance::getGlyphPoint(LEGlyphID
/*glyph*/, le_int32
/*pointNumber*/, LEPoint
&/*point*/) const