ICU 50.1.2  50.1.2
LEFontInstance.h
Go to the documentation of this file.
1 
2 /*
3  *
4  * (C) Copyright IBM Corp. 1998-2013 - All Rights Reserved
5  *
6  */
7 
8 #ifndef __LEFONTINSTANCE_H
9 #define __LEFONTINSTANCE_H
10 
11 #include "LETypes.h"
12 
23 #ifndef LE_CONFIG_FONTINSTANCE_LENGTH
24 #define LE_CONFIG_FONTINSTANCE_LENGTH 0
25 #endif
26 
27 
29 
39 class LECharMapper /* not : public UObject because this is an interface/mixin class */
40 {
41 public:
46  virtual ~LECharMapper();
47 
57  virtual LEUnicode32 mapChar(LEUnicode32 ch) const = 0;
58 };
59 
66 class LEGlyphStorage;
67 
93 {
94 public:
95 
102  virtual ~LEFontInstance();
103 
155  virtual const LEFontInstance *getSubFont(const LEUnicode chars[], le_int32 *offset, le_int32 limit, le_int32 script, LEErrorCode &success) const;
156 
157  //
158  // Font file access
159  //
160 
177  virtual const void *getFontTable(LETag tableTag) const = 0;
178 
179 
180 #if LE_CONFIG_FONTINSTANCE_LENGTH
181 
198  virtual const void* getFontTable(LETag tableTag, size_t &length) const { length=-1; return getFontTable(tableTag); } /* -1 = unknown length */
199 #endif
200 
217  virtual le_bool canDisplay(LEUnicode32 ch) const;
218 
227  virtual le_int32 getUnitsPerEM() const = 0;
228 
252  virtual void mapCharsToGlyphs(const LEUnicode chars[], le_int32 offset, le_int32 count, le_bool reverse, const LECharMapper *mapper, le_bool filterZeroWidth, LEGlyphStorage &glyphStorage) const;
253 
269  virtual LEGlyphID mapCharToGlyph(LEUnicode32 ch, const LECharMapper *mapper, le_bool filterZeroWidth) const;
270 
285  virtual LEGlyphID mapCharToGlyph(LEUnicode32 ch, const LECharMapper *mapper) const;
286 
299  virtual LEGlyphID mapCharToGlyph(LEUnicode32 ch) const = 0;
300 
301  //
302  // Metrics
303  //
304 
313  virtual void getGlyphAdvance(LEGlyphID glyph, LEPoint &advance) const = 0;
314 
327  virtual le_bool getGlyphPoint(LEGlyphID glyph, le_int32 pointNumber, LEPoint &point) const = 0;
328 
337  virtual float getXPixelsPerEm() const = 0;
338 
347  virtual float getYPixelsPerEm() const = 0;
348 
359  virtual float xUnitsToPoints(float xUnits) const;
360 
371  virtual float yUnitsToPoints(float yUnits) const;
372 
381  virtual void unitsToPoints(LEPoint &units, LEPoint &points) const;
382 
393  virtual float xPixelsToUnits(float xPixels) const;
394 
405  virtual float yPixelsToUnits(float yPixels) const;
406 
415  virtual void pixelsToUnits(LEPoint &pixels, LEPoint &units) const;
416 
428  virtual float getScaleFactorX() const = 0;
429 
440  virtual float getScaleFactorY() const = 0;
441 
457  virtual void transformFunits(float xFunits, float yFunits, LEPoint &pixels) const;
458 
469  static inline float fixedToFloat(le_int32 fixed);
470 
481  static inline le_int32 floatToFixed(float theFloat);
482 
483  //
484  // These methods won't ever be called by the LayoutEngine,
485  // but are useful for clients of <code>LEFontInstance</code> who
486  // need to render text.
487  //
488 
497  virtual le_int32 getAscent() const = 0;
498 
507  virtual le_int32 getDescent() const = 0;
508 
517  virtual le_int32 getLeading() const = 0;
518 
529  virtual le_int32 getLineHeight() const;
530 
536  virtual UClassID getDynamicClassID() const;
537 
543  static UClassID getStaticClassID();
544 
545 };
546 
547 inline float LEFontInstance::fixedToFloat(le_int32 fixed)
548 {
549  return (float) (fixed / 65536.0);
550 }
551 
552 inline le_int32 LEFontInstance::floatToFixed(float theFloat)
553 {
554  return (le_int32) (theFloat * 65536.0);
555 }
556 
558 #endif
559 
560