LEFontInstance.h

Go to the documentation of this file.
00001 
00002 /*
00003  *
00004  * (C) Copyright IBM Corp. 1998-2005 - 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 inline ~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 inline ~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 
00166     virtual const void *getFontTable(LETag tableTag) const = 0;
00167 
00184     virtual inline le_bool canDisplay(LEUnicode32 ch) const;
00185 
00194     virtual le_int32 getUnitsPerEM() const = 0;
00195 
00218     virtual void mapCharsToGlyphs(const LEUnicode chars[], le_int32 offset, le_int32 count, le_bool reverse, const LECharMapper *mapper, LEGlyphStorage &glyphStorage) const;
00219 
00234     virtual LEGlyphID mapCharToGlyph(LEUnicode32 ch, const LECharMapper *mapper) const;
00235 
00248     virtual LEGlyphID mapCharToGlyph(LEUnicode32 ch) const = 0;
00249 
00250     //
00251     // Metrics
00252     //
00253 
00262     virtual void getGlyphAdvance(LEGlyphID glyph, LEPoint &advance) const = 0;
00263 
00276     virtual le_bool getGlyphPoint(LEGlyphID glyph, le_int32 pointNumber, LEPoint &point) const = 0;
00277 
00286     virtual float getXPixelsPerEm() const = 0;
00287 
00296     virtual float getYPixelsPerEm() const = 0;
00297 
00308     virtual inline float xUnitsToPoints(float xUnits) const;
00309 
00320     virtual inline float yUnitsToPoints(float yUnits) const;
00321 
00330     virtual inline void unitsToPoints(LEPoint &units, LEPoint &points) const;
00331 
00342     virtual inline float xPixelsToUnits(float xPixels) const;
00343 
00354     virtual inline float yPixelsToUnits(float yPixels) const;
00355 
00364     virtual inline void pixelsToUnits(LEPoint &pixels, LEPoint &units) const;
00365 
00377     virtual float getScaleFactorX() const = 0;
00378 
00389     virtual float getScaleFactorY() const = 0;
00390 
00406     virtual inline void transformFunits(float xFunits, float yFunits, LEPoint &pixels) const;
00407 
00418     static inline float fixedToFloat(le_int32 fixed);
00419 
00430     static inline le_int32 floatToFixed(float theFloat);
00431 
00432     //
00433     // These methods won't ever be called by the LayoutEngine,
00434     // but are useful for clients of <code>LEFontInstance</code> who
00435     // need to render text.
00436     //
00437 
00446     virtual le_int32 getAscent() const = 0;
00447 
00456     virtual le_int32 getDescent() const = 0;
00457 
00466     virtual le_int32 getLeading() const = 0;
00467 
00478     virtual le_int32 getLineHeight() const;
00479 
00485     virtual UClassID getDynamicClassID() const;
00486 
00492     static UClassID getStaticClassID();
00493 
00494 };
00495 
00496 inline le_bool LEFontInstance::canDisplay(LEUnicode32 ch) const
00497 {
00498     return LE_GET_GLYPH(mapCharToGlyph(ch)) != 0;
00499 }
00500 
00501 inline float LEFontInstance::xUnitsToPoints(float xUnits) const
00502 {
00503     return (xUnits * getXPixelsPerEm()) / (float) getUnitsPerEM();
00504 }
00505 
00506 inline float LEFontInstance::yUnitsToPoints(float yUnits) const
00507 {
00508     return (yUnits * getYPixelsPerEm()) / (float) getUnitsPerEM();
00509 }
00510 
00511 inline void LEFontInstance::unitsToPoints(LEPoint &units, LEPoint &points) const
00512 {
00513     points.fX = xUnitsToPoints(units.fX);
00514     points.fY = yUnitsToPoints(units.fY);
00515 }
00516 
00517 inline float LEFontInstance::xPixelsToUnits(float xPixels) const
00518 {
00519     return (xPixels * getUnitsPerEM()) / (float) getXPixelsPerEm();
00520 }
00521 
00522 inline float LEFontInstance::yPixelsToUnits(float yPixels) const
00523 {
00524     return (yPixels * getUnitsPerEM()) / (float) getYPixelsPerEm();
00525 }
00526 
00527 inline void LEFontInstance::pixelsToUnits(LEPoint &pixels, LEPoint &units) const
00528 {
00529     units.fX = xPixelsToUnits(pixels.fX);
00530     units.fY = yPixelsToUnits(pixels.fY);
00531 }
00532 
00533 inline void LEFontInstance::transformFunits(float xFunits, float yFunits, LEPoint &pixels) const
00534 {
00535     pixels.fX = xUnitsToPoints(xFunits) * getScaleFactorX();
00536     pixels.fY = yUnitsToPoints(yFunits) * getScaleFactorY();
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 inline le_int32 LEFontInstance::getLineHeight() const
00550 {
00551     return getAscent() + getDescent() + getLeading();
00552 }
00553 
00554 U_NAMESPACE_END
00555 #endif
00556 
00557 

Generated on Tue Sep 13 11:08:15 2005 for ICU 3.4 by  doxygen 1.4.4