ICU 55.1  55.1
LEFontInstance.h
Go to the documentation of this file.
1 
2 /*
3  *
4  * (C) Copyright IBM Corp. 1998-2015 - All Rights Reserved
5  *
6  */
7 
8 #ifndef __LEFONTINSTANCE_H
9 #define __LEFONTINSTANCE_H
10 
11 #include "LETypes.h"
18 
28 class LECharMapper /* not : public UObject because this is an interface/mixin class */
29 {
30 public:
35  virtual ~LECharMapper();
36 
46  virtual LEUnicode32 mapChar(LEUnicode32 ch) const = 0;
47 };
48 
55 class LEGlyphStorage;
56 
82 {
83 public:
84 
91  virtual ~LEFontInstance();
92 
144  virtual const LEFontInstance *getSubFont(const LEUnicode chars[], le_int32 *offset, le_int32 limit, le_int32 script, LEErrorCode &success) const;
145 
146  //
147  // Font file access
148  //
149 
165  virtual const void* getFontTable(LETag tableTag, size_t &length) const = 0;
166 
183  virtual le_bool canDisplay(LEUnicode32 ch) const;
184 
193  virtual le_int32 getUnitsPerEM() const = 0;
194 
218  virtual void mapCharsToGlyphs(const LEUnicode chars[], le_int32 offset, le_int32 count, le_bool reverse, const LECharMapper *mapper, le_bool filterZeroWidth, LEGlyphStorage &glyphStorage) const;
219 
235  virtual LEGlyphID mapCharToGlyph(LEUnicode32 ch, const LECharMapper *mapper, le_bool filterZeroWidth) const;
236 
251  virtual LEGlyphID mapCharToGlyph(LEUnicode32 ch, const LECharMapper *mapper) const;
252 
265  virtual LEGlyphID mapCharToGlyph(LEUnicode32 ch) const = 0;
266 
267  //
268  // Metrics
269  //
270 
279  virtual void getGlyphAdvance(LEGlyphID glyph, LEPoint &advance) const = 0;
280 
293  virtual le_bool getGlyphPoint(LEGlyphID glyph, le_int32 pointNumber, LEPoint &point) const = 0;
294 
303  virtual float getXPixelsPerEm() const = 0;
304 
313  virtual float getYPixelsPerEm() const = 0;
314 
325  virtual float xUnitsToPoints(float xUnits) const;
326 
337  virtual float yUnitsToPoints(float yUnits) const;
338 
347  virtual void unitsToPoints(LEPoint &units, LEPoint &points) const;
348 
359  virtual float xPixelsToUnits(float xPixels) const;
360 
371  virtual float yPixelsToUnits(float yPixels) const;
372 
381  virtual void pixelsToUnits(LEPoint &pixels, LEPoint &units) const;
382 
394  virtual float getScaleFactorX() const = 0;
395 
406  virtual float getScaleFactorY() const = 0;
407 
423  virtual void transformFunits(float xFunits, float yFunits, LEPoint &pixels) const;
424 
435  static inline float fixedToFloat(le_int32 fixed);
436 
447  static inline le_int32 floatToFixed(float theFloat);
448 
449  //
450  // These methods won't ever be called by the LayoutEngine,
451  // but are useful for clients of <code>LEFontInstance</code> who
452  // need to render text.
453  //
454 
463  virtual le_int32 getAscent() const = 0;
464 
473  virtual le_int32 getDescent() const = 0;
474 
483  virtual le_int32 getLeading() const = 0;
484 
495  virtual le_int32 getLineHeight() const;
496 
502  virtual UClassID getDynamicClassID() const;
503 
510 
511 };
512 
513 inline float LEFontInstance::fixedToFloat(le_int32 fixed)
514 {
515  return (float) (fixed / 65536.0);
516 }
517 
518 inline le_int32 LEFontInstance::floatToFixed(float theFloat)
519 {
520  return (le_int32) (theFloat * 65536.0);
521 }
522 
524 #endif
icu::LEFontInstance::getYPixelsPerEm
virtual float getYPixelsPerEm() const =0
This method returns the height of the font's EM square in pixels.
icu::LEFontInstance::getLineHeight
virtual le_int32 getLineHeight() const
Get the line height required to display text in this font.
icu::LEFontInstance::unitsToPoints
virtual void unitsToPoints(LEPoint &units, LEPoint &points) const
This method converts font design units to points.
icu::LEFontInstance::mapCharToGlyph
virtual LEGlyphID mapCharToGlyph(LEUnicode32 ch, const LECharMapper *mapper) const
This method maps a single character to a glyph index, using the font's character to glyph map.
icu::LEFontInstance::mapCharToGlyph
virtual LEGlyphID mapCharToGlyph(LEUnicode32 ch, const LECharMapper *mapper, le_bool filterZeroWidth) const
This method maps a single character to a glyph index, using the font's character to glyph map.
icu::LEFontInstance::xPixelsToUnits
virtual float xPixelsToUnits(float xPixels) const
This method converts pixels in the X direction to font design units.
LETag
le_uint32 LETag
Used for four character tags.
Definition: LETypes.h:93
LEUnicode32
UChar32 LEUnicode32
Used to represent 32-bit Unicode code points.
Definition: LETypes.h:230
icu::LEFontInstance::getScaleFactorY
virtual float getScaleFactorY() const =0
Get the Y scale factor from the font's transform.
icu::LECharMapper
Instances of this class are used by LEFontInstance::mapCharsToGlyphs and LEFontInstance::mapCharToGly...
Definition: LEFontInstance.h:29
le_int32
int32_t le_int32
A type used for signed, 32-bit integers.
Definition: LETypes.h:34
icu::LECharMapper::~LECharMapper
virtual ~LECharMapper()
Destructor.
icu::LEFontInstance::mapCharToGlyph
virtual LEGlyphID mapCharToGlyph(LEUnicode32 ch) const =0
This method maps a single character to a glyph index, using the font's character to glyph map.
icu::LEFontInstance::getXPixelsPerEm
virtual float getXPixelsPerEm() const =0
This method returns the width of the font's EM square in pixels.
icu::LEFontInstance::yPixelsToUnits
virtual float yPixelsToUnits(float yPixels) const
This method converts pixels in the Y direction to font design units.
icu::LEFontInstance::getStaticClassID
static UClassID getStaticClassID()
ICU "poor man's RTTI", returns a UClassID for this class.
icu::LEFontInstance::pixelsToUnits
virtual void pixelsToUnits(LEPoint &pixels, LEPoint &units) const
This method converts pixels to font design units.
icu::LEFontInstance::canDisplay
virtual le_bool canDisplay(LEUnicode32 ch) const
This method is used to determine if the font can render the given character.
U_LAYOUT_API
#define U_LAYOUT_API
Set to export library symbols from inside the layout engine library, and to import them from outside.
Definition: utypes.h:359
le_bool
UBool le_bool
A type used for boolean values.
Definition: LETypes.h:77
icu::LEFontInstance::~LEFontInstance
virtual ~LEFontInstance()
This virtual destructor is here so that the subclass destructors can be invoked through the base clas...
icu::UObject
UObject is the common ICU "boilerplate" class.
Definition: uobject.h:221
UClassID
void * UClassID
UClassID is used to identify classes without using the compiler's RTTI.
Definition: uobject.h:91
icu::LEFontInstance::transformFunits
virtual void transformFunits(float xFunits, float yFunits, LEPoint &pixels) const
This method transforms an X, Y point in font design units to a pixel coordinate, applying the font's ...
LEPoint
Used to hold a pair of (x, y) values which represent a point.
Definition: LETypes.h:247
LEErrorCode
LEErrorCode
Error codes returned by the LayoutEngine.
Definition: LETypes.h:687
icu::LEFontInstance::getUnitsPerEM
virtual le_int32 getUnitsPerEM() const =0
This method returns the number of design units in the font's EM square.
icu::LEFontInstance::getGlyphPoint
virtual le_bool getGlyphPoint(LEGlyphID glyph, le_int32 pointNumber, LEPoint &point) const =0
This method gets the hinted X and Y pixel coordinates of a particular point in the outline of the giv...
icu::LEFontInstance::yUnitsToPoints
virtual float yUnitsToPoints(float yUnits) const
This method converts font design units in the Y direction to points.
icu::LEFontInstance::getDynamicClassID
virtual UClassID getDynamicClassID() const
ICU "poor man's RTTI", returns a UClassID for the actual class.
icu::LEFontInstance::mapCharsToGlyphs
virtual void mapCharsToGlyphs(const LEUnicode chars[], le_int32 offset, le_int32 count, le_bool reverse, const LECharMapper *mapper, le_bool filterZeroWidth, LEGlyphStorage &glyphStorage) const
This method maps an array of character codes to an array of glyph indices, using the font's character...
icu::LEFontInstance::xUnitsToPoints
virtual float xUnitsToPoints(float xUnits) const
This method converts font design units in the X direction to points.
icu::LEFontInstance::getScaleFactorX
virtual float getScaleFactorX() const =0
Get the X scale factor from the font's transform.
icu::LEFontInstance::getGlyphAdvance
virtual void getGlyphAdvance(LEGlyphID glyph, LEPoint &advance) const =0
This method gets the X and Y advance of a particular glyph, in pixels.
LEUnicode
UChar LEUnicode
Used to represent 16-bit Unicode code points.
Definition: LETypes.h:238
icu::LEFontInstance
This is a virtual base class that serves as the interface between a LayoutEngine and the platform fon...
Definition: LEFontInstance.h:82
icu::LEFontInstance::getSubFont
virtual const LEFontInstance * getSubFont(const LEUnicode chars[], le_int32 *offset, le_int32 limit, le_int32 script, LEErrorCode &success) const
Get a physical font which can render the given text.
icu::LEFontInstance::getAscent
virtual le_int32 getAscent() const =0
Get the font's ascent.
icu::LEFontInstance::getFontTable
virtual const void * getFontTable(LETag tableTag, size_t &length) const =0
This method reads a table from the font.
icu::LECharMapper::mapChar
virtual LEUnicode32 mapChar(LEUnicode32 ch) const =0
This method does the adjustments.
U_NAMESPACE_END
#define U_NAMESPACE_END
This is used to end a declaration of a public ICU C++ API.
Definition: uversion.h:130
U_NAMESPACE_BEGIN
#define U_NAMESPACE_BEGIN
This is used to begin a declaration of a public ICU C++ API.
Definition: uversion.h:129
icu::LEFontInstance::getLeading
virtual le_int32 getLeading() const =0
Get the font's leading.
icu::LEGlyphStorage
This class encapsulates the per-glyph storage used by the ICU LayoutEngine.
Definition: LEGlyphStorage.h:35
LETypes.h
C API: Basic definitions for the ICU LayoutEngine.
LEGlyphID
le_uint32 LEGlyphID
Used for glyph indices.
Definition: LETypes.h:112
icu::LEFontInstance::getDescent
virtual le_int32 getDescent() const =0
Get the font's descent.