1/* 2 ******************************************************************************* 3 * 4 * © 2016 and later: Unicode, Inc. and others. 5 * License & terms of use: http://www.unicode.org/copyright.html 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 29SimpleFontInstance::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 42SimpleFontInstance::~SimpleFontInstance() 43{ 44 // nothing to do... 45} 46 47const 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 60void 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 75le_int32 SimpleFontInstance::getUnitsPerEM() const 76{ 77 return 2048; 78} 79 80le_int32 SimpleFontInstance::getAscent() const 81{ 82 return fAscent; 83} 84 85le_int32 SimpleFontInstance::getDescent() const 86{ 87 return fDescent; 88} 89 90le_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... 97LEGlyphID 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... 104LEGlyphID SimpleFontInstance::mapCharToGlyph(LEUnicode32 ch, const LECharMapper *mapper) const 105{ 106 return LEFontInstance::mapCharToGlyph(ch, mapper); 107} 108 109LEGlyphID SimpleFontInstance::mapCharToGlyph(LEUnicode32 ch) const 110{ 111 return (LEGlyphID) ch; 112} 113 114float SimpleFontInstance::getXPixelsPerEm() const 115{ 116 return fPointSize; 117} 118 119float SimpleFontInstance::getYPixelsPerEm() const 120{ 121 return fPointSize; 122} 123 124float SimpleFontInstance::getScaleFactorX() const 125{ 126 return 1.0; 127} 128 129float SimpleFontInstance::getScaleFactorY() const 130{ 131 return 1.0; 132} 133 134le_bool SimpleFontInstance::getGlyphPoint(LEGlyphID /*glyph*/, le_int32 /*pointNumber*/, LEPoint &/*point*/) const 135{ 136 return false; 137} 138 139