ICU 4.8.1.1
4.8.1.1
|
00001 00002 /* 00003 * 00004 * (C) Copyright IBM Corp. 1998-2012 - All Rights Reserved 00005 * 00006 */ 00007 00008 #ifndef __LEFONTINSTANCE_H 00009 #define __LEFONTINSTANCE_H 00010 00011 #include "LETypes.h" 00017 U_NAMESPACE_BEGIN 00018 00028 class LECharMapper /* not : public UObject because this is an interface/mixin class */ 00029 { 00030 public: 00035 virtual ~LECharMapper(); 00036 00046 virtual LEUnicode32 mapChar(LEUnicode32 ch) const = 0; 00047 }; 00048 00055 class LEGlyphStorage; 00056 00081 class U_LAYOUT_API LEFontInstance : public UObject 00082 { 00083 public: 00084 00091 virtual ~LEFontInstance(); 00092 00144 virtual const LEFontInstance *getSubFont(const LEUnicode chars[], le_int32 *offset, le_int32 limit, le_int32 script, LEErrorCode &success) const; 00145 00146 // 00147 // Font file access 00148 // 00149 00170 virtual const void *getFontTable(LETag tableTag) const = 0; 00171 00191 virtual const void* getFontTable(LETag tableTag, size_t &length) const { length=-1; return getFontTable(tableTag); } /* -1 = unknown length */ 00192 00209 virtual le_bool canDisplay(LEUnicode32 ch) const; 00210 00219 virtual le_int32 getUnitsPerEM() const = 0; 00220 00244 virtual void mapCharsToGlyphs(const LEUnicode chars[], le_int32 offset, le_int32 count, le_bool reverse, const LECharMapper *mapper, le_bool filterZeroWidth, LEGlyphStorage &glyphStorage) const; 00245 00261 virtual LEGlyphID mapCharToGlyph(LEUnicode32 ch, const LECharMapper *mapper, le_bool filterZeroWidth) const; 00262 00277 virtual LEGlyphID mapCharToGlyph(LEUnicode32 ch, const LECharMapper *mapper) const; 00278 00291 virtual LEGlyphID mapCharToGlyph(LEUnicode32 ch) const = 0; 00292 00293 // 00294 // Metrics 00295 // 00296 00305 virtual void getGlyphAdvance(LEGlyphID glyph, LEPoint &advance) const = 0; 00306 00319 virtual le_bool getGlyphPoint(LEGlyphID glyph, le_int32 pointNumber, LEPoint &point) const = 0; 00320 00329 virtual float getXPixelsPerEm() const = 0; 00330 00339 virtual float getYPixelsPerEm() const = 0; 00340 00351 virtual float xUnitsToPoints(float xUnits) const; 00352 00363 virtual float yUnitsToPoints(float yUnits) const; 00364 00373 virtual void unitsToPoints(LEPoint &units, LEPoint &points) const; 00374 00385 virtual float xPixelsToUnits(float xPixels) const; 00386 00397 virtual float yPixelsToUnits(float yPixels) const; 00398 00407 virtual void pixelsToUnits(LEPoint &pixels, LEPoint &units) const; 00408 00420 virtual float getScaleFactorX() const = 0; 00421 00432 virtual float getScaleFactorY() const = 0; 00433 00449 virtual void transformFunits(float xFunits, float yFunits, LEPoint &pixels) const; 00450 00461 static inline float fixedToFloat(le_int32 fixed); 00462 00473 static inline le_int32 floatToFixed(float theFloat); 00474 00475 // 00476 // These methods won't ever be called by the LayoutEngine, 00477 // but are useful for clients of <code>LEFontInstance</code> who 00478 // need to render text. 00479 // 00480 00489 virtual le_int32 getAscent() const = 0; 00490 00499 virtual le_int32 getDescent() const = 0; 00500 00509 virtual le_int32 getLeading() const = 0; 00510 00521 virtual le_int32 getLineHeight() const; 00522 00528 virtual UClassID getDynamicClassID() const; 00529 00535 static UClassID getStaticClassID(); 00536 00537 }; 00538 00539 inline float LEFontInstance::fixedToFloat(le_int32 fixed) 00540 { 00541 return (float) (fixed / 65536.0); 00542 } 00543 00544 inline le_int32 LEFontInstance::floatToFixed(float theFloat) 00545 { 00546 return (le_int32) (theFloat * 65536.0); 00547 } 00548 00549 U_NAMESPACE_END 00550 #endif 00551 00552