os/textandloc/fontservices/textshaperplugin/IcuSource/layout/LEFontInstance.h
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
sl@0
     1
sl@0
     2
/*
sl@0
     3
 *
sl@0
     4
 * (C) Copyright IBM Corp. 1998-2005 - All Rights Reserved
sl@0
     5
 *
sl@0
     6
 */
sl@0
     7
sl@0
     8
#ifndef __LEFONTINSTANCE_H
sl@0
     9
#define __LEFONTINSTANCE_H
sl@0
    10
sl@0
    11
#include "LETypes.h"
sl@0
    12
/**
sl@0
    13
 * \file 
sl@0
    14
 * \brief C++ API: Layout Engine Font Instance object
sl@0
    15
 */
sl@0
    16
sl@0
    17
U_NAMESPACE_BEGIN
sl@0
    18
sl@0
    19
/**
sl@0
    20
 * Instances of this class are used by <code>LEFontInstance::mapCharsToGlyphs</code> and
sl@0
    21
 * <code>LEFontInstance::mapCharToGlyph</code> to adjust character codes before the character
sl@0
    22
 * to glyph mapping process. Examples of this are filtering out control characters
sl@0
    23
 * and character mirroring - replacing a character which has both a left and a right
sl@0
    24
 * hand form with the opposite form.
sl@0
    25
 *
sl@0
    26
 * @stable ICU 3.2
sl@0
    27
 */
sl@0
    28
class LECharMapper /* not : public UObject because this is an interface/mixin class */
sl@0
    29
{
sl@0
    30
public:
sl@0
    31
    /**
sl@0
    32
     * Destructor.
sl@0
    33
     * @stable ICU 3.2
sl@0
    34
     */
sl@0
    35
    virtual inline ~LECharMapper() {};
sl@0
    36
sl@0
    37
    /**
sl@0
    38
     * This method does the adjustments.
sl@0
    39
     *
sl@0
    40
     * @param ch - the input character
sl@0
    41
     *
sl@0
    42
     * @return the adjusted character
sl@0
    43
     *
sl@0
    44
     * @stable ICU 2.8
sl@0
    45
     */
sl@0
    46
    virtual LEUnicode32 mapChar(LEUnicode32 ch) const = 0;
sl@0
    47
};
sl@0
    48
sl@0
    49
/**
sl@0
    50
 * This is a forward reference to the class which holds the per-glyph
sl@0
    51
 * storage.
sl@0
    52
 *
sl@0
    53
 * @draft ICU 3.0
sl@0
    54
 */
sl@0
    55
class LEGlyphStorage;
sl@0
    56
sl@0
    57
/**
sl@0
    58
 * This is a virtual base class that serves as the interface between a LayoutEngine
sl@0
    59
 * and the platform font environment. It allows a LayoutEngine to access font tables, do
sl@0
    60
 * character to glyph mapping, and obtain metrics information without knowing any platform
sl@0
    61
 * specific details. There are also a few utility methods for converting between points,
sl@0
    62
 * pixels and funits. (font design units)
sl@0
    63
 *
sl@0
    64
 * An instance of an <code>LEFontInstance</code> represents a font at a particular point
sl@0
    65
 * size. Each instance can represent either a single physical font, or a composite font.
sl@0
    66
 * A composite font is a collection of physical fonts, each of which contains a subset of
sl@0
    67
 * the characters contained in the composite font.
sl@0
    68
 *
sl@0
    69
 * Note: with the exception of <code>getSubFont</code>, the methods in this class only
sl@0
    70
 * make sense for a physical font. If you have an <code>LEFontInstance</code> which
sl@0
    71
 * represents a composite font you should only call the methods below which have
sl@0
    72
 * an <code>LEGlyphID</code>, an <code>LEUnicode</code> or an <code>LEUnicode32</code>
sl@0
    73
 * as one of the arguments because these can be used to select a particular subfont.
sl@0
    74
 *
sl@0
    75
 * Subclasses which implement composite fonts should supply an implementation of these
sl@0
    76
 * methods with some default behavior such as returning constant values, or using the
sl@0
    77
 * values from the first subfont.
sl@0
    78
 *
sl@0
    79
 * @draft ICU 3.0
sl@0
    80
 */
sl@0
    81
class U_LAYOUT_API LEFontInstance : public UObject
sl@0
    82
{
sl@0
    83
public:
sl@0
    84
sl@0
    85
    /**
sl@0
    86
     * This virtual destructor is here so that the subclass
sl@0
    87
     * destructors can be invoked through the base class.
sl@0
    88
     *
sl@0
    89
     * @stable ICU 2.8
sl@0
    90
     */
sl@0
    91
    virtual inline ~LEFontInstance() {};
sl@0
    92
sl@0
    93
    /**
sl@0
    94
     * Get a physical font which can render the given text. For composite fonts,
sl@0
    95
     * if there is no single physical font which can render all of the text,
sl@0
    96
     * return a physical font which can render an initial substring of the text,
sl@0
    97
     * and set the <code>offset</code> parameter to the end of that substring.
sl@0
    98
     *
sl@0
    99
     * Internally, the LayoutEngine works with runs of text all in the same
sl@0
   100
     * font and script, so it is best to call this method with text which is
sl@0
   101
     * in a single script, passing the script code in as a hint. If you don't
sl@0
   102
     * know the script of the text, you can use zero, which is the script code
sl@0
   103
     * for characters used in more than one script.
sl@0
   104
     *
sl@0
   105
     * The default implementation of this method is intended for instances of
sl@0
   106
     * <code>LEFontInstance</code> which represent a physical font. It returns
sl@0
   107
     * <code>this</code> and indicates that the entire string can be rendered.
sl@0
   108
     *
sl@0
   109
     * This method will return a valid <code>LEFontInstance</code> unless you
sl@0
   110
     * have passed illegal parameters, or an internal error has been encountered. 
sl@0
   111
     * For composite fonts, it may return the warning <code>LE_NO_SUBFONT_WARNING</code>
sl@0
   112
     * to indicate that the returned font may not be able to render all of
sl@0
   113
     * the text. Whenever a valid font is returned, the <code>offset</code> parameter
sl@0
   114
     * will be advanced by at least one.
sl@0
   115
     *
sl@0
   116
     * Subclasses which implement composite fonts must override this method.
sl@0
   117
     * Where it makes sense, they should use the script code as a hint to render
sl@0
   118
     * characters from the COMMON script in the font which is used for the given
sl@0
   119
     * script. For example, if the input text is a series of Arabic words separated
sl@0
   120
     * by spaces, and the script code passed in is <code>arabScriptCode</code> you
sl@0
   121
     * should return the font used for Arabic characters for all of the input text,
sl@0
   122
     * including the spaces. If, on the other hand, the input text contains characters
sl@0
   123
     * which cannot be rendered by the font used for Arabic characters, but which can
sl@0
   124
     * be rendered by another font, you should return that font for those characters.
sl@0
   125
     *
sl@0
   126
     * @param chars   - the array of Unicode characters.
sl@0
   127
     * @param offset  - a pointer to the starting offset in the text. On exit this
sl@0
   128
     *                  will be set the the limit offset of the text which can be
sl@0
   129
     *                  rendered using the returned font.
sl@0
   130
     * @param limit   - the limit offset for the input text.
sl@0
   131
     * @param script  - the script hint.
sl@0
   132
     * @param success - set to an error code if the arguments are illegal, or no font
sl@0
   133
     *                  can be returned for some reason. May also be set to
sl@0
   134
     *                  <code>LE_NO_SUBFONT_WARNING</code> if the subfont which
sl@0
   135
     *                  was returned cannot render all of the text.
sl@0
   136
     *
sl@0
   137
     * @return an <code>LEFontInstance</code> for the sub font which can render the characters, or
sl@0
   138
     *         <code>NULL</code> if there is an error.
sl@0
   139
     *
sl@0
   140
     * @see LEScripts.h
sl@0
   141
     *
sl@0
   142
     * @stable ICU 3.2
sl@0
   143
     */
sl@0
   144
    virtual const LEFontInstance *getSubFont(const LEUnicode chars[], le_int32 *offset, le_int32 limit, le_int32 script, LEErrorCode &success) const;
sl@0
   145
sl@0
   146
    //
sl@0
   147
    // Font file access
sl@0
   148
    //
sl@0
   149
sl@0
   150
    /**
sl@0
   151
     * This method reads a table from the font. Note that in general,
sl@0
   152
     * it only makes sense to call this method on an <code>LEFontInstance</code>
sl@0
   153
     * which represents a physical font - i.e. one which has been returned by
sl@0
   154
     * <code>getSubFont()</code>. This is because each subfont in a composite font
sl@0
   155
     * will have different tables, and there's no way to know which subfont to access.
sl@0
   156
     *
sl@0
   157
     * Subclasses which represent composite fonts should always return <code>NULL</code>.
sl@0
   158
     *
sl@0
   159
     * @param tableTag - the four byte table tag. (e.g. 'cmap') 
sl@0
   160
     *
sl@0
   161
     * @return the address of the table in memory, or <code>NULL</code>
sl@0
   162
     *         if the table doesn't exist.
sl@0
   163
     *
sl@0
   164
     * @stable ICU 2.8
sl@0
   165
     */
sl@0
   166
    virtual const void *getFontTable(LETag tableTag) const = 0;
sl@0
   167
sl@0
   168
    /**
sl@0
   169
     * This method is used to determine if the font can
sl@0
   170
     * render the given character. This can usually be done
sl@0
   171
     * by looking the character up in the font's character
sl@0
   172
     * to glyph mapping.
sl@0
   173
     *
sl@0
   174
     * The default implementation of this method will return
sl@0
   175
     * <code>TRUE</code> if <code>mapCharToGlyph(ch)</code>
sl@0
   176
     * returns a non-zero value.
sl@0
   177
     *
sl@0
   178
     * @param ch - the character to be tested
sl@0
   179
     *
sl@0
   180
     * @return <code>TRUE</code> if the font can render ch.
sl@0
   181
     *
sl@0
   182
     * @stable ICU 3.2
sl@0
   183
     */
sl@0
   184
    virtual inline le_bool canDisplay(LEUnicode32 ch) const;
sl@0
   185
sl@0
   186
    /**
sl@0
   187
     * This method returns the number of design units in
sl@0
   188
     * the font's EM square.
sl@0
   189
     *
sl@0
   190
     * @return the number of design units pre EM.
sl@0
   191
     *
sl@0
   192
     * @stable ICU 2.8
sl@0
   193
     */
sl@0
   194
    virtual le_int32 getUnitsPerEM() const = 0;
sl@0
   195
sl@0
   196
    /**
sl@0
   197
     * This method maps an array of character codes to an array of glyph
sl@0
   198
     * indices, using the font's character to glyph map.
sl@0
   199
     *
sl@0
   200
     * The default implementation iterates over all of the characters and calls
sl@0
   201
     * <code>mapCharToGlyph(ch, mapper)</code> on each one. It also handles surrogate
sl@0
   202
     * characters, storing the glyph ID for the high surrogate, and a deleted glyph (0xFFFF)
sl@0
   203
     * for the low surrogate.
sl@0
   204
     *
sl@0
   205
     * Most sublcasses will not need to implement this method.
sl@0
   206
     *
sl@0
   207
     * @param chars - the character array
sl@0
   208
     * @param offset - the index of the first character
sl@0
   209
     * @param count - the number of characters
sl@0
   210
     * @param reverse - if <code>TRUE</code>, store the glyph indices in reverse order.
sl@0
   211
     * @param mapper - the character mapper.
sl@0
   212
     * @param glyphStorage - the object which contains the output glyph array
sl@0
   213
     *
sl@0
   214
     * @see LECharMapper
sl@0
   215
     *
sl@0
   216
     * @draft ICU 3.0
sl@0
   217
     */
sl@0
   218
    virtual void mapCharsToGlyphs(const LEUnicode chars[], le_int32 offset, le_int32 count, le_bool reverse, const LECharMapper *mapper, LEGlyphStorage &glyphStorage) const;
sl@0
   219
sl@0
   220
    /**
sl@0
   221
     * This method maps a single character to a glyph index, using the
sl@0
   222
     * font's character to glyph map. The default implementation of this
sl@0
   223
     * method calls the mapper, and then calls <code>mapCharToGlyph(mappedCh)</code>.
sl@0
   224
     *
sl@0
   225
     * @param ch - the character
sl@0
   226
     * @param mapper - the character mapper
sl@0
   227
     *
sl@0
   228
     * @return the glyph index
sl@0
   229
     *
sl@0
   230
     * @see LECharMapper
sl@0
   231
     *
sl@0
   232
     * @stable ICU 3.2
sl@0
   233
     */
sl@0
   234
    virtual LEGlyphID mapCharToGlyph(LEUnicode32 ch, const LECharMapper *mapper) const;
sl@0
   235
sl@0
   236
    /**
sl@0
   237
     * This method maps a single character to a glyph index, using the
sl@0
   238
     * font's character to glyph map. There is no default implementation
sl@0
   239
     * of this method because it requires information about the platform
sl@0
   240
     * font implementation.
sl@0
   241
     *
sl@0
   242
     * @param ch - the character
sl@0
   243
     *
sl@0
   244
     * @return the glyph index
sl@0
   245
     *
sl@0
   246
     * @stable ICU 3.2
sl@0
   247
     */
sl@0
   248
    virtual LEGlyphID mapCharToGlyph(LEUnicode32 ch) const = 0;
sl@0
   249
sl@0
   250
    //
sl@0
   251
    // Metrics
sl@0
   252
    //
sl@0
   253
sl@0
   254
    /**
sl@0
   255
     * This method gets the X and Y advance of a particular glyph, in pixels.
sl@0
   256
     *
sl@0
   257
     * @param glyph - the glyph index
sl@0
   258
     * @param advance - the X and Y pixel values will be stored here
sl@0
   259
     *
sl@0
   260
     * @stable ICU 3.2
sl@0
   261
     */
sl@0
   262
    virtual void getGlyphAdvance(LEGlyphID glyph, LEPoint &advance) const = 0;
sl@0
   263
sl@0
   264
    /**
sl@0
   265
     * This method gets the hinted X and Y pixel coordinates of a particular
sl@0
   266
     * point in the outline of the given glyph.
sl@0
   267
     *
sl@0
   268
     * @param glyph - the glyph index
sl@0
   269
     * @param pointNumber - the number of the point
sl@0
   270
     * @param point - the point's X and Y pixel values will be stored here
sl@0
   271
     *
sl@0
   272
     * @return <code>TRUE</code> if the point coordinates could be stored.
sl@0
   273
     *
sl@0
   274
     * @stable ICU 2.8
sl@0
   275
     */
sl@0
   276
    virtual le_bool getGlyphPoint(LEGlyphID glyph, le_int32 pointNumber, LEPoint &point) const = 0;
sl@0
   277
sl@0
   278
    /**
sl@0
   279
     * This method returns the width of the font's EM square
sl@0
   280
     * in pixels.
sl@0
   281
     *
sl@0
   282
     * @return the pixel width of the EM square
sl@0
   283
     *
sl@0
   284
     * @stable ICU 2.8
sl@0
   285
     */
sl@0
   286
    virtual float getXPixelsPerEm() const = 0;
sl@0
   287
sl@0
   288
    /**
sl@0
   289
     * This method returns the height of the font's EM square
sl@0
   290
     * in pixels.
sl@0
   291
     *
sl@0
   292
     * @return the pixel height of the EM square
sl@0
   293
     *
sl@0
   294
     * @stable ICU 2.8
sl@0
   295
     */
sl@0
   296
    virtual float getYPixelsPerEm() const = 0;
sl@0
   297
sl@0
   298
    /**
sl@0
   299
     * This method converts font design units in the
sl@0
   300
     * X direction to points.
sl@0
   301
     *
sl@0
   302
     * @param xUnits - design units in the X direction
sl@0
   303
     *
sl@0
   304
     * @return points in the X direction
sl@0
   305
     *
sl@0
   306
     * @stable ICU 3.2
sl@0
   307
     */
sl@0
   308
    virtual inline float xUnitsToPoints(float xUnits) const;
sl@0
   309
sl@0
   310
    /**
sl@0
   311
     * This method converts font design units in the
sl@0
   312
     * Y direction to points.
sl@0
   313
     *
sl@0
   314
     * @param yUnits - design units in the Y direction
sl@0
   315
     *
sl@0
   316
     * @return points in the Y direction
sl@0
   317
     *
sl@0
   318
     * @stable ICU 3.2
sl@0
   319
     */
sl@0
   320
    virtual inline float yUnitsToPoints(float yUnits) const;
sl@0
   321
sl@0
   322
    /**
sl@0
   323
     * This method converts font design units to points.
sl@0
   324
     *
sl@0
   325
     * @param units - X and Y design units
sl@0
   326
     * @param points - set to X and Y points
sl@0
   327
     *
sl@0
   328
     * @stable ICU 3.2
sl@0
   329
     */
sl@0
   330
    virtual inline void unitsToPoints(LEPoint &units, LEPoint &points) const;
sl@0
   331
sl@0
   332
    /**
sl@0
   333
     * This method converts pixels in the
sl@0
   334
     * X direction to font design units.
sl@0
   335
     *
sl@0
   336
     * @param xPixels - pixels in the X direction
sl@0
   337
     *
sl@0
   338
     * @return font design units in the X direction
sl@0
   339
     *
sl@0
   340
     * @stable ICU 3.2
sl@0
   341
     */
sl@0
   342
    virtual inline float xPixelsToUnits(float xPixels) const;
sl@0
   343
sl@0
   344
    /**
sl@0
   345
     * This method converts pixels in the
sl@0
   346
     * Y direction to font design units.
sl@0
   347
     *
sl@0
   348
     * @param yPixels - pixels in the Y direction
sl@0
   349
     *
sl@0
   350
     * @return font design units in the Y direction
sl@0
   351
     *
sl@0
   352
     * @stable ICU 3.2
sl@0
   353
     */
sl@0
   354
    virtual inline float yPixelsToUnits(float yPixels) const;
sl@0
   355
sl@0
   356
    /**
sl@0
   357
     * This method converts pixels to font design units.
sl@0
   358
     *
sl@0
   359
     * @param pixels - X and Y pixel
sl@0
   360
     * @param units - set to X and Y font design units
sl@0
   361
     *
sl@0
   362
     * @stable ICU 3.2
sl@0
   363
     */
sl@0
   364
    virtual inline void pixelsToUnits(LEPoint &pixels, LEPoint &units) const;
sl@0
   365
sl@0
   366
    /**
sl@0
   367
     * Get the X scale factor from the font's transform. The default
sl@0
   368
     * implementation of <code>transformFunits()</code> will call this method.
sl@0
   369
     *
sl@0
   370
     * @return the X scale factor.
sl@0
   371
     *
sl@0
   372
     *
sl@0
   373
     * @see transformFunits
sl@0
   374
     *
sl@0
   375
     * @stable ICU 3.2
sl@0
   376
     */
sl@0
   377
    virtual float getScaleFactorX() const = 0;
sl@0
   378
sl@0
   379
    /**
sl@0
   380
     * Get the Y scale factor from the font's transform. The default
sl@0
   381
     * implementation of <code>transformFunits()</code> will call this method.
sl@0
   382
     *
sl@0
   383
     * @return the Yscale factor.
sl@0
   384
     *
sl@0
   385
     * @see transformFunits
sl@0
   386
     *
sl@0
   387
     * @stable ICU 3.2
sl@0
   388
     */
sl@0
   389
    virtual float getScaleFactorY() const = 0;
sl@0
   390
sl@0
   391
    /**
sl@0
   392
     * This method transforms an X, Y point in font design units to a
sl@0
   393
     * pixel coordinate, applying the font's transform. The default
sl@0
   394
     * implementation of this method calls <code>getScaleFactorX()</code>
sl@0
   395
     * and <code>getScaleFactorY()</code>.
sl@0
   396
     *
sl@0
   397
     * @param xFunits - the X coordinate in font design units
sl@0
   398
     * @param yFunits - the Y coordinate in font design units
sl@0
   399
     * @param pixels - the tranformed co-ordinate in pixels
sl@0
   400
     *
sl@0
   401
     * @see getScaleFactorX
sl@0
   402
     * @see getScaleFactorY
sl@0
   403
     *
sl@0
   404
     * @stable ICU 3.2
sl@0
   405
     */
sl@0
   406
    virtual inline void transformFunits(float xFunits, float yFunits, LEPoint &pixels) const;
sl@0
   407
sl@0
   408
    /**
sl@0
   409
     * This is a convenience method used to convert
sl@0
   410
     * values in a 16.16 fixed point format to floating point.
sl@0
   411
     *
sl@0
   412
     * @param fixed - the fixed point value
sl@0
   413
     *
sl@0
   414
     * @return the floating point value
sl@0
   415
     *
sl@0
   416
     * @stable ICU 2.8
sl@0
   417
     */
sl@0
   418
    static inline float fixedToFloat(le_int32 fixed);
sl@0
   419
sl@0
   420
    /**
sl@0
   421
     * This is a convenience method used to convert
sl@0
   422
     * floating point values to 16.16 fixed point format.
sl@0
   423
     *
sl@0
   424
     * @param theFloat - the floating point value
sl@0
   425
     *
sl@0
   426
     * @return the fixed point value
sl@0
   427
     *
sl@0
   428
     * @stable ICU 2.8
sl@0
   429
     */
sl@0
   430
    static inline le_int32 floatToFixed(float theFloat);
sl@0
   431
sl@0
   432
    //
sl@0
   433
    // These methods won't ever be called by the LayoutEngine,
sl@0
   434
    // but are useful for clients of <code>LEFontInstance</code> who
sl@0
   435
    // need to render text.
sl@0
   436
    //
sl@0
   437
sl@0
   438
    /**
sl@0
   439
     * Get the font's ascent.
sl@0
   440
     *
sl@0
   441
     * @return the font's ascent, in points. This value
sl@0
   442
     * will always be positive.
sl@0
   443
     *
sl@0
   444
     * @stable ICU 3.2
sl@0
   445
     */
sl@0
   446
    virtual le_int32 getAscent() const = 0;
sl@0
   447
sl@0
   448
    /**
sl@0
   449
     * Get the font's descent.
sl@0
   450
     *
sl@0
   451
     * @return the font's descent, in points. This value
sl@0
   452
     * will always be positive.
sl@0
   453
     *
sl@0
   454
     * @stable ICU 3.2
sl@0
   455
     */
sl@0
   456
    virtual le_int32 getDescent() const = 0;
sl@0
   457
sl@0
   458
    /**
sl@0
   459
     * Get the font's leading.
sl@0
   460
     *
sl@0
   461
     * @return the font's leading, in points. This value
sl@0
   462
     * will always be positive.
sl@0
   463
     *
sl@0
   464
     * @stable ICU 3.2
sl@0
   465
     */
sl@0
   466
    virtual le_int32 getLeading() const = 0;
sl@0
   467
sl@0
   468
    /**
sl@0
   469
     * Get the line height required to display text in
sl@0
   470
     * this font. The default implementation of this method
sl@0
   471
     * returns the sum of the ascent, descent, and leading.
sl@0
   472
     *
sl@0
   473
     * @return the line height, in points. This vaule will
sl@0
   474
     * always be positive.
sl@0
   475
     *
sl@0
   476
     * @stable ICU 3.2
sl@0
   477
     */
sl@0
   478
    virtual le_int32 getLineHeight() const;
sl@0
   479
sl@0
   480
    /**
sl@0
   481
     * ICU "poor man's RTTI", returns a UClassID for the actual class.
sl@0
   482
     *
sl@0
   483
     * @stable ICU 3.2
sl@0
   484
     */
sl@0
   485
    virtual UClassID getDynamicClassID() const;
sl@0
   486
sl@0
   487
    /**
sl@0
   488
     * ICU "poor man's RTTI", returns a UClassID for this class.
sl@0
   489
     *
sl@0
   490
     * @stable ICU 3.2
sl@0
   491
     */
sl@0
   492
    static UClassID getStaticClassID();
sl@0
   493
sl@0
   494
};
sl@0
   495
sl@0
   496
inline le_bool LEFontInstance::canDisplay(LEUnicode32 ch) const
sl@0
   497
{
sl@0
   498
    return LE_GET_GLYPH(mapCharToGlyph(ch)) != 0;
sl@0
   499
}
sl@0
   500
sl@0
   501
inline float LEFontInstance::xUnitsToPoints(float xUnits) const
sl@0
   502
{
sl@0
   503
    return (xUnits * getXPixelsPerEm()) / (float) getUnitsPerEM();
sl@0
   504
}
sl@0
   505
sl@0
   506
inline float LEFontInstance::yUnitsToPoints(float yUnits) const
sl@0
   507
{
sl@0
   508
    return (yUnits * getYPixelsPerEm()) / (float) getUnitsPerEM();
sl@0
   509
}
sl@0
   510
sl@0
   511
inline void LEFontInstance::unitsToPoints(LEPoint &units, LEPoint &points) const
sl@0
   512
{
sl@0
   513
    points.fX = xUnitsToPoints(units.fX);
sl@0
   514
    points.fY = yUnitsToPoints(units.fY);
sl@0
   515
}
sl@0
   516
sl@0
   517
inline float LEFontInstance::xPixelsToUnits(float xPixels) const
sl@0
   518
{
sl@0
   519
    return (xPixels * getUnitsPerEM()) / (float) getXPixelsPerEm();
sl@0
   520
}
sl@0
   521
sl@0
   522
inline float LEFontInstance::yPixelsToUnits(float yPixels) const
sl@0
   523
{
sl@0
   524
    return (yPixels * getUnitsPerEM()) / (float) getYPixelsPerEm();
sl@0
   525
}
sl@0
   526
sl@0
   527
inline void LEFontInstance::pixelsToUnits(LEPoint &pixels, LEPoint &units) const
sl@0
   528
{
sl@0
   529
    units.fX = xPixelsToUnits(pixels.fX);
sl@0
   530
    units.fY = yPixelsToUnits(pixels.fY);
sl@0
   531
}
sl@0
   532
sl@0
   533
inline void LEFontInstance::transformFunits(float xFunits, float yFunits, LEPoint &pixels) const
sl@0
   534
{
sl@0
   535
    pixels.fX = xUnitsToPoints(xFunits) * getScaleFactorX();
sl@0
   536
    pixels.fY = yUnitsToPoints(yFunits) * getScaleFactorY();
sl@0
   537
}
sl@0
   538
sl@0
   539
inline float LEFontInstance::fixedToFloat(le_int32 fixed)
sl@0
   540
{
sl@0
   541
    return (float) (fixed / 65536.0);
sl@0
   542
}
sl@0
   543
sl@0
   544
inline le_int32 LEFontInstance::floatToFixed(float theFloat)
sl@0
   545
{
sl@0
   546
    return (le_int32) (theFloat * 65536.0);
sl@0
   547
}
sl@0
   548
sl@0
   549
inline le_int32 LEFontInstance::getLineHeight() const
sl@0
   550
{
sl@0
   551
    return getAscent() + getDescent() + getLeading();
sl@0
   552
}
sl@0
   553
sl@0
   554
U_NAMESPACE_END
sl@0
   555
#endif
sl@0
   556
sl@0
   557