1/* 2 ******************************************************************************* 3 * 4 * Copyright (C) 1999-2015, International Business Machines 5 * Corporation and others. All Rights Reserved. 6 * 7 ******************************************************************************* 8 * file name: SimpleFontInstance.cpp 9 * 10 * created on: 03/30/2006 11 * created by: Eric R. Mader 12 */ 13 14#include "unicode/utypes.h" 15#include "unicode/uchar.h" 16 17#include "layout/LETypes.h" 18#include "layout/LEFontInstance.h" 19 20#ifndef USING_ICULEHB 21#include "CanonShaping.h" 22#endif 23 24#include "SimpleFontInstance.h" 25 26SimpleFontInstance::SimpleFontInstance(float pointSize, LEErrorCode &status) 27 : fPointSize(pointSize), fAscent(0), fDescent(0) 28{ 29 if (LE_FAILURE(status)) { 30 return; 31 } 32 33 fAscent = (le_int32) yUnitsToPoints(2000.0); 34 fDescent = (le_int32) yUnitsToPoints(600.0); 35 36 return; 37} 38 39SimpleFontInstance::~SimpleFontInstance() 40{ 41 // nothing to do... 42} 43 44const void *SimpleFontInstance::getFontTable(LETag tableTag, size_t &length) const 45{ 46 length = -1; // unknown for this test. 47#ifndef USING_ICULEHB 48 if (tableTag == LE_GSUB_TABLE_TAG) { 49 return CanonShaping::glyphSubstitutionTable; 50 } 51 52 if (tableTag == LE_GDEF_TABLE_TAG) { 53 return CanonShaping::glyphDefinitionTable; 54 } 55#endif 56 return NULL; 57} 58 59void SimpleFontInstance::getGlyphAdvance(LEGlyphID glyph, LEPoint &advance) const 60{ 61#if 0 62 if (u_getCombiningClass((UChar32) glyph) == 0) { 63 advance.fX = xUnitsToPoints(2048); 64 } else { 65 advance.fX = 0; 66 } 67#else 68 (void)glyph; // Suppress unused parameter compiler warning. 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