Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Search  

LEFontInstance.h

Go to the documentation of this file.
00001 
00002 /*
00003  * @(#)LEFontInstance.h 1.3 00/03/15
00004  *
00005  * (C) Copyright IBM Corp. 1998-2003 - All Rights Reserved
00006  *
00007  */
00008 
00009 #ifndef __LEFONTINSTANCE_H
00010 #define __LEFONTINSTANCE_H
00011 
00012 #include "LETypes.h"
00013 
00014 U_NAMESPACE_BEGIN
00015 
00025 class LECharMapper /* not : public UObject because this is an interface/mixin class */
00026 {
00027 public:
00032     virtual inline ~LECharMapper() {};
00033 
00043     virtual LEUnicode32 mapChar(LEUnicode32 ch) const = 0;
00044 };
00045 
00070 class U_LAYOUT_API LEFontInstance : public UObject
00071 {
00072 public:
00073 
00080     virtual inline ~LEFontInstance() {};
00081 
00133     virtual const LEFontInstance *getSubFont(const LEUnicode chars[], le_int32 *offset, le_int32 limit, le_int32 script, LEErrorCode &success) const;
00134 
00135     //
00136     // Font file access
00137     //
00138 
00155     virtual const void *getFontTable(LETag tableTag) const = 0;
00156 
00173     virtual le_bool canDisplay(LEUnicode32 ch) const;
00174 
00183     virtual le_int32 getUnitsPerEM() const = 0;
00184 
00200     virtual void mapCharsToGlyphs(const LEUnicode chars[], le_int32 offset, le_int32 count, le_bool reverse, const LECharMapper *mapper, LEGlyphID glyphs[]) const;
00201 
00216     virtual LEGlyphID mapCharToGlyph(LEUnicode32 ch, const LECharMapper *mapper) const;
00217 
00230     virtual LEGlyphID mapCharToGlyph(LEUnicode32 ch) const = 0;
00231 
00232     //
00233     // Metrics
00234     //
00235 
00244     virtual void getGlyphAdvance(LEGlyphID glyph, LEPoint &advance) const = 0;
00245 
00258     virtual le_bool getGlyphPoint(LEGlyphID glyph, le_int32 pointNumber, LEPoint &point) const = 0;
00259 
00268     virtual float getXPixelsPerEm() const = 0;
00269 
00278     virtual float getYPixelsPerEm() const = 0;
00279 
00290     virtual float xUnitsToPoints(float xUnits) const;
00291 
00302     virtual float yUnitsToPoints(float yUnits) const;
00303 
00312     virtual void unitsToPoints(LEPoint &units, LEPoint &points) const;
00313 
00324     virtual float xPixelsToUnits(float xPixels) const;
00325 
00336     virtual float yPixelsToUnits(float yPixels) const;
00337 
00346     virtual void pixelsToUnits(LEPoint &pixels, LEPoint &units) const;
00347 
00359     virtual float getScaleFactorX() const = 0;
00360 
00371     virtual float getScaleFactorY() const = 0;
00372 
00388     virtual void transformFunits(float xFunits, float yFunits, LEPoint &pixels) const;
00389 
00400     static float fixedToFloat(le_int32 fixed);
00401 
00412     static le_int32 floatToFixed(float theFloat);
00413 
00414     //
00415     // These methods won't ever be called by the LayoutEngine,
00416     // but are useful for clients of <code>LEFontInstance</code> who
00417     // need to render text.
00418     //
00419 
00428     virtual le_int32 getAscent() const = 0;
00429 
00438     virtual le_int32 getDescent() const = 0;
00439 
00448     virtual le_int32 getLeading() const = 0;
00449 
00460     virtual le_int32 getLineHeight() const;
00461 
00467     virtual inline UClassID getDynamicClassID() const { return getStaticClassID(); }
00468 
00474     static inline UClassID getStaticClassID() { return (UClassID)&fgClassID; }
00475 
00476 private:
00477 
00482     static const char fgClassID;
00483 };
00484 
00485 inline le_bool LEFontInstance::canDisplay(LEUnicode32 ch) const
00486 {
00487     return LE_GET_GLYPH(mapCharToGlyph(ch)) != 0;
00488 }
00489 
00490 inline float LEFontInstance::xUnitsToPoints(float xUnits) const
00491 {
00492     return (xUnits * getXPixelsPerEm()) / (float) getUnitsPerEM();
00493 }
00494 
00495 inline float LEFontInstance::yUnitsToPoints(float yUnits) const
00496 {
00497     return (yUnits * getYPixelsPerEm()) / (float) getUnitsPerEM();
00498 }
00499 
00500 inline void LEFontInstance::unitsToPoints(LEPoint &units, LEPoint &points) const
00501 {
00502     points.fX = xUnitsToPoints(units.fX);
00503     points.fY = yUnitsToPoints(units.fY);
00504 }
00505 
00506 inline float LEFontInstance::xPixelsToUnits(float xPixels) const
00507 {
00508     return (xPixels * getUnitsPerEM()) / (float) getXPixelsPerEm();
00509 }
00510 
00511 inline float LEFontInstance::yPixelsToUnits(float yPixels) const
00512 {
00513     return (yPixels * getUnitsPerEM()) / (float) getYPixelsPerEm();
00514 }
00515 
00516 inline void LEFontInstance::pixelsToUnits(LEPoint &pixels, LEPoint &units) const
00517 {
00518     units.fX = xPixelsToUnits(pixels.fX);
00519     units.fY = yPixelsToUnits(pixels.fY);
00520 }
00521 
00522 inline void LEFontInstance::transformFunits(float xFunits, float yFunits, LEPoint &pixels) const
00523 {
00524     pixels.fX = xUnitsToPoints(xFunits) * getScaleFactorX();
00525     pixels.fY = yUnitsToPoints(yFunits) * getScaleFactorY();
00526 }
00527 
00528 inline float LEFontInstance::fixedToFloat(le_int32 fixed)
00529 {
00530     return (float) (fixed / 65536.0);
00531 }
00532 
00533 inline le_int32 LEFontInstance::floatToFixed(float theFloat)
00534 {
00535     return (le_int32) (theFloat * 65536.0);
00536 }
00537 
00538 inline le_int32 LEFontInstance::getLineHeight() const
00539 {
00540     return getAscent() + getDescent() + getLeading();
00541 }
00542 
00543 U_NAMESPACE_END
00544 #endif
00545 
00546 

Generated on Mon Nov 24 14:35:32 2003 for ICU 2.8 by doxygen1.2.11.1 written by Dimitri van Heesch, © 1997-2001