2000-11-14 21:22:14 +00:00
|
|
|
|
|
|
|
/*
|
2003-05-16 17:43:44 +00:00
|
|
|
* @(#)LEFontInstance.h 1.3 00/03/15
|
2000-11-14 21:22:14 +00:00
|
|
|
*
|
2003-06-03 20:58:22 +00:00
|
|
|
* (C) Copyright IBM Corp. 1998-2003 - All Rights Reserved
|
2000-11-14 21:22:14 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __LEFONTINSTANCE_H
|
|
|
|
#define __LEFONTINSTANCE_H
|
|
|
|
|
|
|
|
#include "LETypes.h"
|
|
|
|
|
2001-10-16 00:39:01 +00:00
|
|
|
U_NAMESPACE_BEGIN
|
|
|
|
|
2000-11-14 21:22:14 +00:00
|
|
|
/**
|
|
|
|
* Instances of this class are used by LEFontInstance::mapCharsToGlyphs and
|
|
|
|
* LEFontInstance::mapCharToGlyph to adjust character codes before the character
|
2003-05-13 23:02:45 +00:00
|
|
|
* to glyph mapping process. Examples of this are filtering out control characters
|
2000-11-14 21:22:14 +00:00
|
|
|
* and character mirroring - replacing a character which has both a left and a right
|
|
|
|
* hand form with the opposite form.
|
2002-08-14 00:18:01 +00:00
|
|
|
*
|
|
|
|
* @draft ICU 2.2
|
2000-11-14 21:22:14 +00:00
|
|
|
*/
|
2003-05-13 23:02:45 +00:00
|
|
|
class LECharMapper /* not : public UObject because this is an interface/mixin class */
|
|
|
|
{
|
2000-11-14 21:22:14 +00:00
|
|
|
public:
|
2002-10-04 20:45:31 +00:00
|
|
|
/**
|
|
|
|
* Destructor.
|
|
|
|
* @draft ICU 2.4
|
|
|
|
*/
|
|
|
|
virtual inline ~LECharMapper() {};
|
|
|
|
|
2002-04-02 03:33:42 +00:00
|
|
|
/**
|
|
|
|
* This method does the adjustments.
|
|
|
|
*
|
2003-05-13 23:02:45 +00:00
|
|
|
* @param ch - the input character
|
2002-04-02 03:33:42 +00:00
|
|
|
*
|
|
|
|
* @return the adjusted character
|
2002-08-14 00:18:01 +00:00
|
|
|
*
|
|
|
|
* @draft ICU 2.2
|
2002-04-02 03:33:42 +00:00
|
|
|
*/
|
2000-12-21 01:18:44 +00:00
|
|
|
virtual LEUnicode32 mapChar(LEUnicode32 ch) const = 0;
|
2000-11-14 21:22:14 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
2003-05-16 17:43:44 +00:00
|
|
|
* This is a virtual base class that serves as the interface between a LayoutEngine
|
2000-11-14 21:22:14 +00:00
|
|
|
* and the platform font environment. It allows a LayoutEngine to access font tables, do
|
|
|
|
* character to glyph mapping, and obtain metrics information without knowing any platform
|
|
|
|
* specific details. There are also a few utility methods for converting between points,
|
|
|
|
* pixels and funits. (font design units)
|
|
|
|
*
|
2003-05-13 23:02:45 +00:00
|
|
|
* An instance of an <code>LEFontInstance</code> represents a font at a particular point
|
|
|
|
* size. Each instance can represent either a single physical font, or a composite font.
|
|
|
|
* A composite font is a collection of physical fonts, each of which contains a subset of
|
|
|
|
* the characters contained in the composite font.
|
2002-08-14 00:18:01 +00:00
|
|
|
*
|
2003-05-13 23:02:45 +00:00
|
|
|
* Note: with the exception of <code>getSubFont</code>, the methods in this class only
|
|
|
|
* make sense for a physical font. If you have an <code>LEFontInstance</code> which
|
|
|
|
* represents a composite font you should only call the methods below which have
|
|
|
|
* an <code>LEGlyphID</code>, an <code>LEUnicode</code> or an <code>LEUnicode32</code>
|
|
|
|
* as one of the arguments because these can be used to select a particular subfont.
|
|
|
|
*
|
2003-05-16 17:43:44 +00:00
|
|
|
* Subclasses which implement composite fonts should supply an implementation of these
|
2003-05-13 23:02:45 +00:00
|
|
|
* methods with some default behavior such as returning constant values, or using the
|
|
|
|
* values from the first subfont.
|
|
|
|
*
|
|
|
|
* @draft ICU 2.6
|
2000-11-14 21:22:14 +00:00
|
|
|
*/
|
2003-05-13 23:02:45 +00:00
|
|
|
class U_LAYOUT_API LEFontInstance : public UObject
|
|
|
|
{
|
2000-11-14 21:22:14 +00:00
|
|
|
public:
|
|
|
|
|
2002-04-02 03:33:42 +00:00
|
|
|
/**
|
|
|
|
* This virtual destructor is here so that the subclass
|
|
|
|
* destructors can be invoked through the base class.
|
2002-08-14 00:18:01 +00:00
|
|
|
*
|
|
|
|
* @draft ICU 2.2
|
2002-04-02 03:33:42 +00:00
|
|
|
*/
|
2002-10-04 20:45:31 +00:00
|
|
|
virtual inline ~LEFontInstance() {};
|
2000-11-14 21:22:14 +00:00
|
|
|
|
2003-03-03 22:54:57 +00:00
|
|
|
/**
|
2003-05-13 23:02:45 +00:00
|
|
|
* Get a physical font which can render the given text. For composite fonts,
|
2003-05-16 17:43:44 +00:00
|
|
|
* if there is no single physical font which can render all of the text,
|
|
|
|
* return a physical font which can render an initial substring of the text,
|
|
|
|
* and set the <code>offset</code> parameter to the end of that substring.
|
|
|
|
*
|
|
|
|
* Internally, the LayoutEngine works with runs of text all in the same
|
|
|
|
* font and script, so it is best to call this method with text which is
|
|
|
|
* in a single script, passing the script code in as a hint. If you don't
|
|
|
|
* know the script of the text, you can use zero, which is the script code
|
|
|
|
* for characters used in more than one script.
|
|
|
|
*
|
|
|
|
* The default implementation of this method is intended for instances of
|
|
|
|
* <code>LEFontInstance</code> which represent a physical font. It returns
|
|
|
|
* <code>this</code> and indicates that the entire string can be rendered.
|
|
|
|
*
|
|
|
|
* This method will return a valid <code>LEFontInstance</code> unless you
|
|
|
|
* have passed illegal parameters, or an internal error has been encountered.
|
|
|
|
* For composite fonts, it may return the warning <code>LE_NO_SUBFONT_WARNING</code>
|
|
|
|
* to indicate that the returned font may not be able to render all of
|
|
|
|
* the text. Whenever a valid font is returned, the <code>offset</code> parameter
|
|
|
|
* will be advanced by at least one.
|
|
|
|
*
|
|
|
|
* Subclasses which implement composite fonts must override this method.
|
|
|
|
* Where it makes sense, they should use the script code as a hint to render
|
|
|
|
* characters from the COMMON script in the font which is used for the given
|
|
|
|
* script. For example, if the input text is a series of Arabic words separated
|
|
|
|
* by spaces, and the script code passed in is <code>arabScriptCode</code> you
|
|
|
|
* should return the font used for Arabic characters for all of the input text,
|
|
|
|
* including the spaces. If, on the other hand, the input text contains characters
|
|
|
|
* which cannot be rendered by the font used for Arabic characters, but which can
|
|
|
|
* be rendered by another font, you should return that font for those characters.
|
2003-05-13 23:02:45 +00:00
|
|
|
*
|
|
|
|
* @param chars - the array of Unicode characters.
|
2003-05-16 17:43:44 +00:00
|
|
|
* @param offset - a pointer to the starting offset in the text. On exit this
|
|
|
|
* will be set the the limit offset of the text which can be
|
|
|
|
* rendered using the returned font.
|
2003-05-13 23:02:45 +00:00
|
|
|
* @param limit - the limit offset for the input text.
|
|
|
|
* @param script - the script hint.
|
|
|
|
* @param success - set to an error code if the arguments are illegal, or no font
|
|
|
|
* can be returned for some reason. May also be set to
|
2003-05-16 17:43:44 +00:00
|
|
|
* <code>LE_NO_SUBFONT_WARNING</code> if the subfont which
|
|
|
|
* was returned cannot render all of the text.
|
2003-05-13 23:02:45 +00:00
|
|
|
*
|
|
|
|
* @return an <code>LEFontInstance</code> for the sub font which can render the characters, or
|
|
|
|
* <code>NULL</code> if there is an error.
|
|
|
|
*
|
2003-05-16 17:43:44 +00:00
|
|
|
* @see LEScripts.h
|
|
|
|
*
|
2003-03-03 22:54:57 +00:00
|
|
|
* @draft ICU 2.6
|
|
|
|
*/
|
2003-05-16 17:43:44 +00:00
|
|
|
virtual const LEFontInstance *getSubFont(const LEUnicode chars[], le_int32 *offset, le_int32 limit, le_int32 script, LEErrorCode &success) const;
|
2003-03-03 22:54:57 +00:00
|
|
|
|
2002-04-02 03:33:42 +00:00
|
|
|
//
|
2000-11-14 21:22:14 +00:00
|
|
|
// Font file access
|
2002-04-02 03:33:42 +00:00
|
|
|
//
|
2000-11-14 21:22:14 +00:00
|
|
|
|
2002-04-02 03:33:42 +00:00
|
|
|
/**
|
2003-05-13 23:02:45 +00:00
|
|
|
* This method reads a table from the font. Note that in general,
|
|
|
|
* it only makes sense to call this method on an <code>LEFontInstance</code>
|
|
|
|
* which represents a physical font - i.e. one which has been returned by
|
|
|
|
* <code>getSubFont()</code>. This is because each subfont in a composite font
|
|
|
|
* will have different tables, and there's no way to know which subfont to access.
|
|
|
|
*
|
2003-05-16 17:43:44 +00:00
|
|
|
* Subclasses which represent composite fonts should always return <code>NULL</code>.
|
2002-04-02 03:33:42 +00:00
|
|
|
*
|
2003-05-13 23:02:45 +00:00
|
|
|
* @param tableTag - the four byte table tag. (e.g. 'cmap')
|
2002-04-02 03:33:42 +00:00
|
|
|
*
|
2003-05-13 23:02:45 +00:00
|
|
|
* @return the address of the table in memory, or <code>NULL</code>
|
|
|
|
* if the table doesn't exist.
|
2002-08-14 00:18:01 +00:00
|
|
|
*
|
|
|
|
* @draft ICU 2.2
|
2002-04-02 03:33:42 +00:00
|
|
|
*/
|
2000-12-21 01:18:44 +00:00
|
|
|
virtual const void *getFontTable(LETag tableTag) const = 0;
|
2000-11-14 21:22:14 +00:00
|
|
|
|
2002-04-02 03:33:42 +00:00
|
|
|
/**
|
|
|
|
* This method is used to determine if the font can
|
|
|
|
* render the given character. This can usually be done
|
|
|
|
* by looking the character up in the font's character
|
|
|
|
* to glyph mapping.
|
|
|
|
*
|
2003-05-16 17:43:44 +00:00
|
|
|
* The default implementation of this method will return
|
|
|
|
* <code>true</code> if <code>mapCharToGlyph(ch)</code>
|
|
|
|
* returns a non-zero value.
|
|
|
|
*
|
2002-04-02 03:33:42 +00:00
|
|
|
* @param ch - the character to be tested
|
|
|
|
*
|
|
|
|
* @return true if the font can render ch.
|
2002-08-14 00:18:01 +00:00
|
|
|
*
|
2003-03-03 22:54:57 +00:00
|
|
|
* @draft ICU 2.6
|
2002-04-02 03:33:42 +00:00
|
|
|
*/
|
2003-03-03 22:54:57 +00:00
|
|
|
virtual le_bool canDisplay(LEUnicode32 ch) const;
|
2000-11-14 21:22:14 +00:00
|
|
|
|
2002-04-02 03:33:42 +00:00
|
|
|
/**
|
|
|
|
* This method returns the number of design units in
|
|
|
|
* the font's EM square.
|
|
|
|
*
|
|
|
|
* @return the number of design units pre EM.
|
2002-08-14 00:18:01 +00:00
|
|
|
*
|
|
|
|
* @draft ICU 2.2
|
2002-04-02 03:33:42 +00:00
|
|
|
*/
|
2000-12-21 01:18:44 +00:00
|
|
|
virtual le_int32 getUnitsPerEM() const = 0;
|
2000-11-14 21:22:14 +00:00
|
|
|
|
2002-04-02 03:33:42 +00:00
|
|
|
/**
|
2003-03-03 22:54:57 +00:00
|
|
|
* This method maps an array of character codes to an array of glyph
|
2002-04-02 03:33:42 +00:00
|
|
|
* indices, using the font's character to glyph map.
|
|
|
|
*
|
|
|
|
* @param chars - the character array
|
2003-05-13 23:02:45 +00:00
|
|
|
* @param offset - the index of the first character
|
|
|
|
* @param count - the number of characters
|
2002-04-02 03:33:42 +00:00
|
|
|
* @param reverse - if true, store the glyph indices in reverse order.
|
|
|
|
* @param mapper - the character mapper.
|
|
|
|
* @param glyphs - the output glyph array
|
|
|
|
*
|
|
|
|
* @see LECharMapper
|
2002-08-14 00:18:01 +00:00
|
|
|
*
|
2003-03-03 22:54:57 +00:00
|
|
|
* @draft ICU 2.6
|
|
|
|
*/
|
|
|
|
virtual void mapCharsToGlyphs(const LEUnicode chars[], le_int32 offset, le_int32 count, le_bool reverse, const LECharMapper *mapper, LEGlyphID glyphs[]) const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This method maps a single character to a glyph index, using the
|
2003-05-13 23:02:45 +00:00
|
|
|
* font's character to glyph map. The default implementation of this
|
2003-03-03 22:54:57 +00:00
|
|
|
* method calls the mapper, and then calls <code>mapCharToGlyph(mappedCh)</code>.
|
|
|
|
*
|
|
|
|
* @param ch - the character
|
|
|
|
* @param mapper - the character mapper
|
|
|
|
*
|
|
|
|
* @return the glyph index
|
|
|
|
*
|
2003-05-13 23:02:45 +00:00
|
|
|
* @see LECharMapper
|
|
|
|
*
|
2003-03-12 23:51:42 +00:00
|
|
|
* @draft ICU 2.6
|
2002-04-02 03:33:42 +00:00
|
|
|
*/
|
2003-03-03 22:54:57 +00:00
|
|
|
virtual LEGlyphID mapCharToGlyph(LEUnicode32 ch, const LECharMapper *mapper) const;
|
2000-11-14 21:22:14 +00:00
|
|
|
|
2002-04-02 03:33:42 +00:00
|
|
|
/**
|
|
|
|
* This method maps a single character to a glyph index, using the
|
2003-05-13 23:02:45 +00:00
|
|
|
* font's character to glyph map. There is no default implementation
|
|
|
|
* of this method because it requires information about the platform
|
|
|
|
* font implementation.
|
2002-04-02 03:33:42 +00:00
|
|
|
*
|
|
|
|
* @param ch - the character
|
|
|
|
*
|
|
|
|
* @return the glyph index
|
|
|
|
*
|
2003-03-12 23:51:42 +00:00
|
|
|
* @draft ICU 2.6
|
2002-04-02 03:33:42 +00:00
|
|
|
*/
|
2003-03-03 22:54:57 +00:00
|
|
|
virtual LEGlyphID mapCharToGlyph(LEUnicode32 ch) const = 0;
|
2000-11-14 21:22:14 +00:00
|
|
|
|
2002-04-02 03:33:42 +00:00
|
|
|
//
|
2000-11-14 21:22:14 +00:00
|
|
|
// Metrics
|
2002-04-02 03:33:42 +00:00
|
|
|
//
|
2000-11-14 21:22:14 +00:00
|
|
|
|
2002-04-02 03:33:42 +00:00
|
|
|
/**
|
|
|
|
* This method gets the X and Y advance of a particular glyph, in pixels.
|
|
|
|
*
|
|
|
|
* @param glyph - the glyph index
|
|
|
|
* @param advance - the X and Y pixel values will be stored here
|
2002-08-14 00:18:01 +00:00
|
|
|
*
|
|
|
|
* @draft ICU 2.2
|
2002-04-02 03:33:42 +00:00
|
|
|
*/
|
2000-12-21 01:18:44 +00:00
|
|
|
virtual void getGlyphAdvance(LEGlyphID glyph, LEPoint &advance) const = 0;
|
2000-11-14 21:22:14 +00:00
|
|
|
|
2002-04-02 03:33:42 +00:00
|
|
|
/**
|
|
|
|
* This method gets the hinted X and Y pixel coordinates of a particular
|
|
|
|
* point in the outline of the given glyph.
|
|
|
|
*
|
|
|
|
* @param glyph - the glyph index
|
|
|
|
* @param pointNumber - the number of the point
|
|
|
|
* @param point - the point's X and Y pixel values will be stored here
|
|
|
|
*
|
|
|
|
* @return true if the point coordinates could be stored.
|
2002-08-14 00:18:01 +00:00
|
|
|
*
|
|
|
|
* @draft ICU 2.2
|
2002-04-02 03:33:42 +00:00
|
|
|
*/
|
2000-12-21 01:18:44 +00:00
|
|
|
virtual le_bool getGlyphPoint(LEGlyphID glyph, le_int32 pointNumber, LEPoint &point) const = 0;
|
2000-11-14 21:22:14 +00:00
|
|
|
|
|
|
|
/**
|
2002-04-02 03:33:42 +00:00
|
|
|
* This method returns the width of the font's EM square
|
|
|
|
* in pixels.
|
|
|
|
*
|
|
|
|
* @return the pixel width of the EM square
|
2002-08-14 00:18:01 +00:00
|
|
|
*
|
|
|
|
* @draft ICU 2.2
|
2002-04-02 03:33:42 +00:00
|
|
|
*/
|
2000-12-21 01:18:44 +00:00
|
|
|
virtual float getXPixelsPerEm() const = 0;
|
2000-11-14 21:22:14 +00:00
|
|
|
|
|
|
|
/**
|
2002-04-02 03:33:42 +00:00
|
|
|
* This method returns the height of the font's EM square
|
|
|
|
* in pixels.
|
|
|
|
*
|
|
|
|
* @return the pixel height of the EM square
|
2002-08-14 00:18:01 +00:00
|
|
|
*
|
|
|
|
* @draft ICU 2.2
|
2002-04-02 03:33:42 +00:00
|
|
|
*/
|
2000-12-21 01:18:44 +00:00
|
|
|
virtual float getYPixelsPerEm() const = 0;
|
2000-11-14 21:22:14 +00:00
|
|
|
|
|
|
|
/**
|
2002-04-02 03:33:42 +00:00
|
|
|
* This method converts font design units in the
|
|
|
|
* X direction to points.
|
|
|
|
*
|
|
|
|
* @param xUnits - design units in the X direction
|
|
|
|
*
|
|
|
|
* @return points in the X direction
|
2002-08-14 00:18:01 +00:00
|
|
|
*
|
2003-03-03 22:54:57 +00:00
|
|
|
* @draft ICU 2.6
|
2002-04-02 03:33:42 +00:00
|
|
|
*/
|
2003-03-03 22:54:57 +00:00
|
|
|
virtual float xUnitsToPoints(float xUnits) const;
|
2000-11-14 21:22:14 +00:00
|
|
|
|
|
|
|
/**
|
2002-04-02 03:33:42 +00:00
|
|
|
* This method converts font design units in the
|
|
|
|
* Y direction to points.
|
|
|
|
*
|
|
|
|
* @param yUnits - design units in the Y direction
|
|
|
|
*
|
|
|
|
* @return points in the Y direction
|
2002-08-14 00:18:01 +00:00
|
|
|
*
|
2003-03-03 22:54:57 +00:00
|
|
|
* @draft ICU 2.6
|
2002-04-02 03:33:42 +00:00
|
|
|
*/
|
2003-03-03 22:54:57 +00:00
|
|
|
virtual float yUnitsToPoints(float yUnits) const;
|
2000-11-14 21:22:14 +00:00
|
|
|
|
|
|
|
/**
|
2002-04-02 03:33:42 +00:00
|
|
|
* This method converts font design units to points.
|
|
|
|
*
|
|
|
|
* @param units - X and Y design units
|
|
|
|
* @param points - set to X and Y points
|
2002-08-14 00:18:01 +00:00
|
|
|
*
|
2003-03-03 22:54:57 +00:00
|
|
|
* @draft ICU 2.6
|
2002-04-02 03:33:42 +00:00
|
|
|
*/
|
2003-03-03 22:54:57 +00:00
|
|
|
virtual void unitsToPoints(LEPoint &units, LEPoint &points) const;
|
2000-11-14 21:22:14 +00:00
|
|
|
|
|
|
|
/**
|
2002-04-02 03:33:42 +00:00
|
|
|
* This method converts pixels in the
|
|
|
|
* X direction to font design units.
|
|
|
|
*
|
|
|
|
* @param xPixels - pixels in the X direction
|
|
|
|
*
|
|
|
|
* @return font design units in the X direction
|
2002-08-14 00:18:01 +00:00
|
|
|
*
|
2003-03-03 22:54:57 +00:00
|
|
|
* @draft ICU 2.6
|
2002-04-02 03:33:42 +00:00
|
|
|
*/
|
2003-03-03 22:54:57 +00:00
|
|
|
virtual float xPixelsToUnits(float xPixels) const;
|
2000-11-14 21:22:14 +00:00
|
|
|
|
|
|
|
/**
|
2002-04-02 03:33:42 +00:00
|
|
|
* This method converts pixels in the
|
|
|
|
* Y direction to font design units.
|
|
|
|
*
|
|
|
|
* @param yPixels - pixels in the Y direction
|
|
|
|
*
|
|
|
|
* @return font design units in the Y direction
|
2002-08-14 00:18:01 +00:00
|
|
|
*
|
2003-03-12 23:51:42 +00:00
|
|
|
* @draft ICU 2.6
|
2002-04-02 03:33:42 +00:00
|
|
|
*/
|
2003-03-03 22:54:57 +00:00
|
|
|
virtual float yPixelsToUnits(float yPixels) const;
|
2000-11-14 21:22:14 +00:00
|
|
|
|
|
|
|
/**
|
2002-04-02 03:33:42 +00:00
|
|
|
* This method converts pixels to font design units.
|
|
|
|
*
|
|
|
|
* @param pixels - X and Y pixel
|
|
|
|
* @param units - set to X and Y font design units
|
2002-08-14 00:18:01 +00:00
|
|
|
*
|
2003-03-03 22:54:57 +00:00
|
|
|
* @draft ICU 2.6
|
2002-04-02 03:33:42 +00:00
|
|
|
*/
|
2003-03-03 22:54:57 +00:00
|
|
|
virtual void pixelsToUnits(LEPoint &pixels, LEPoint &units) const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the X scale factor from the font's transform. The default
|
|
|
|
* implementation of <code>transformFunits()</code> will call this method.
|
|
|
|
*
|
|
|
|
* @return the X scale factor.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @see transformFunits
|
|
|
|
*
|
|
|
|
* @draft ICU 2.6
|
|
|
|
*/
|
|
|
|
virtual float getScaleFactorX() const = 0;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the Y scale factor from the font's transform. The default
|
|
|
|
* implementation of <code>transformFunits()</code> will call this method.
|
|
|
|
*
|
|
|
|
* @return the Yscale factor.
|
|
|
|
*
|
|
|
|
* @see transformFunits
|
|
|
|
*
|
|
|
|
* @draft ICU 2.6
|
|
|
|
*/
|
|
|
|
virtual float getScaleFactorY() const = 0;
|
2000-11-14 21:22:14 +00:00
|
|
|
|
2002-04-02 03:33:42 +00:00
|
|
|
/**
|
|
|
|
* This method transforms an X, Y point in font design units to a
|
2003-03-03 22:54:57 +00:00
|
|
|
* pixel coordinate, applying the font's transform. The default
|
|
|
|
* implementation of this method calls <code>getScaleFactorX()</code>
|
|
|
|
* and <code>getScaleFactorY()</code>.
|
2002-04-02 03:33:42 +00:00
|
|
|
*
|
|
|
|
* @param xFunits - the X coordinate in font design units
|
|
|
|
* @param yFunits - the Y coordinate in font design units
|
|
|
|
* @param pixels - the tranformed co-ordinate in pixels
|
2002-08-14 00:18:01 +00:00
|
|
|
*
|
2003-03-03 22:54:57 +00:00
|
|
|
* @see getScaleFactorX
|
|
|
|
* @see getScaleFactorY
|
|
|
|
*
|
|
|
|
* @draft ICU 2.6
|
2002-04-02 03:33:42 +00:00
|
|
|
*/
|
2003-03-03 22:54:57 +00:00
|
|
|
virtual void transformFunits(float xFunits, float yFunits, LEPoint &pixels) const;
|
2000-11-14 21:22:14 +00:00
|
|
|
|
2002-04-02 03:33:42 +00:00
|
|
|
/**
|
|
|
|
* This is a convenience method used to convert
|
|
|
|
* values in a 16.16 fixed point format to floating point.
|
|
|
|
*
|
|
|
|
* @param fixed - the fixed point value
|
|
|
|
*
|
|
|
|
* @return the floating point value
|
2002-08-14 00:18:01 +00:00
|
|
|
*
|
|
|
|
* @draft ICU 2.2
|
2002-04-02 03:33:42 +00:00
|
|
|
*/
|
2003-03-03 22:54:57 +00:00
|
|
|
static float fixedToFloat(le_int32 fixed);
|
2000-11-14 21:22:14 +00:00
|
|
|
|
2002-04-02 03:33:42 +00:00
|
|
|
/**
|
|
|
|
* This is a convenience method used to convert
|
|
|
|
* floating point values to 16.16 fixed point format.
|
|
|
|
*
|
|
|
|
* @param theFloat - the floating point value
|
|
|
|
*
|
|
|
|
* @return the fixed point value
|
2002-12-18 23:59:55 +00:00
|
|
|
*
|
|
|
|
* @draft ICU 2.2
|
2002-04-02 03:33:42 +00:00
|
|
|
*/
|
2003-03-03 22:54:57 +00:00
|
|
|
static le_int32 floatToFixed(float theFloat);
|
|
|
|
|
|
|
|
//
|
|
|
|
// These methods won't ever be called by the LayoutEngine,
|
2003-05-13 23:02:45 +00:00
|
|
|
// but are useful for clients of <code>LEFontInstance</code> who
|
2003-03-03 22:54:57 +00:00
|
|
|
// need to render text.
|
|
|
|
//
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the font's ascent.
|
|
|
|
*
|
2003-05-16 17:43:44 +00:00
|
|
|
* @return the font's ascent, in points. This value
|
|
|
|
* will always be positive.
|
2003-03-03 22:54:57 +00:00
|
|
|
*
|
|
|
|
* @draft ICU 2.6
|
|
|
|
*/
|
|
|
|
virtual le_int32 getAscent() const = 0;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the font's descent.
|
|
|
|
*
|
2003-05-16 17:43:44 +00:00
|
|
|
* @return the font's descent, in points. This value
|
|
|
|
* will always be positive.
|
2003-03-03 22:54:57 +00:00
|
|
|
*
|
|
|
|
* @draft ICU 2.6
|
|
|
|
*/
|
|
|
|
virtual le_int32 getDescent() const = 0;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the font's leading.
|
|
|
|
*
|
2003-05-16 17:43:44 +00:00
|
|
|
* @return the font's leading, in points. This value
|
|
|
|
* will always be positive.
|
2003-03-03 22:54:57 +00:00
|
|
|
*
|
|
|
|
* @draft ICU 2.6
|
|
|
|
*/
|
|
|
|
virtual le_int32 getLeading() const = 0;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the line height required to display text in
|
2003-05-16 17:43:44 +00:00
|
|
|
* this font. The default implementation of this method
|
|
|
|
* returns the sum of the ascent, descent, and leading.
|
2003-03-03 22:54:57 +00:00
|
|
|
*
|
2003-05-16 17:43:44 +00:00
|
|
|
* @return the line height, in points. This vaule will
|
|
|
|
* always be positive.
|
2003-03-03 22:54:57 +00:00
|
|
|
*
|
|
|
|
* @draft ICU 2.6
|
|
|
|
*/
|
|
|
|
virtual le_int32 getLineHeight() const;
|
2000-11-14 21:22:14 +00:00
|
|
|
|
2003-05-13 23:02:45 +00:00
|
|
|
/**
|
|
|
|
* ICU "poor man's RTTI", returns a UClassID for the actual class.
|
|
|
|
*
|
2003-05-16 17:43:44 +00:00
|
|
|
* @draft ICU 2.6
|
2003-05-13 23:02:45 +00:00
|
|
|
*/
|
|
|
|
virtual inline UClassID getDynamicClassID() const { return getStaticClassID(); }
|
2003-03-03 22:54:57 +00:00
|
|
|
|
2003-05-13 23:02:45 +00:00
|
|
|
/**
|
|
|
|
* ICU "poor man's RTTI", returns a UClassID for this class.
|
|
|
|
*
|
2003-05-16 17:43:44 +00:00
|
|
|
* @draft ICU 2.6
|
2003-05-13 23:02:45 +00:00
|
|
|
*/
|
|
|
|
static inline UClassID getStaticClassID() { return (UClassID)&fgClassID; }
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The address of this static class variable serves as this class's ID
|
|
|
|
* for ICU "poor man's RTTI".
|
|
|
|
*/
|
|
|
|
static const char fgClassID;
|
|
|
|
};
|
2003-03-03 22:54:57 +00:00
|
|
|
|
|
|
|
inline le_bool LEFontInstance::canDisplay(LEUnicode32 ch) const
|
|
|
|
{
|
2003-06-06 18:47:12 +00:00
|
|
|
return LE_GET_GLYPH(mapCharToGlyph(ch)) != 0;
|
2003-03-03 22:54:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
inline float LEFontInstance::xUnitsToPoints(float xUnits) const
|
|
|
|
{
|
|
|
|
return (xUnits * getXPixelsPerEm()) / (float) getUnitsPerEM();
|
|
|
|
}
|
|
|
|
|
|
|
|
inline float LEFontInstance::yUnitsToPoints(float yUnits) const
|
|
|
|
{
|
|
|
|
return (yUnits * getYPixelsPerEm()) / (float) getUnitsPerEM();
|
|
|
|
}
|
|
|
|
|
|
|
|
inline void LEFontInstance::unitsToPoints(LEPoint &units, LEPoint &points) const
|
|
|
|
{
|
|
|
|
points.fX = xUnitsToPoints(units.fX);
|
|
|
|
points.fY = yUnitsToPoints(units.fY);
|
|
|
|
}
|
|
|
|
|
|
|
|
inline float LEFontInstance::xPixelsToUnits(float xPixels) const
|
|
|
|
{
|
|
|
|
return (xPixels * getUnitsPerEM()) / (float) getXPixelsPerEm();
|
|
|
|
}
|
|
|
|
|
|
|
|
inline float LEFontInstance::yPixelsToUnits(float yPixels) const
|
|
|
|
{
|
|
|
|
return (yPixels * getUnitsPerEM()) / (float) getYPixelsPerEm();
|
|
|
|
}
|
|
|
|
|
|
|
|
inline void LEFontInstance::pixelsToUnits(LEPoint &pixels, LEPoint &units) const
|
|
|
|
{
|
|
|
|
units.fX = xPixelsToUnits(pixels.fX);
|
|
|
|
units.fY = yPixelsToUnits(pixels.fY);
|
|
|
|
}
|
|
|
|
|
|
|
|
inline void LEFontInstance::transformFunits(float xFunits, float yFunits, LEPoint &pixels) const
|
|
|
|
{
|
|
|
|
pixels.fX = xUnitsToPoints(xFunits) * getScaleFactorX();
|
|
|
|
pixels.fY = yUnitsToPoints(yFunits) * getScaleFactorY();
|
|
|
|
}
|
|
|
|
|
|
|
|
inline float LEFontInstance::fixedToFloat(le_int32 fixed)
|
|
|
|
{
|
|
|
|
return (float) (fixed / 65536.0);
|
|
|
|
}
|
|
|
|
|
|
|
|
inline le_int32 LEFontInstance::floatToFixed(float theFloat)
|
|
|
|
{
|
|
|
|
return (le_int32) (theFloat * 65536.0);
|
|
|
|
}
|
|
|
|
|
|
|
|
inline le_int32 LEFontInstance::getLineHeight() const
|
|
|
|
{
|
|
|
|
return getAscent() + getDescent() + getLeading();
|
|
|
|
}
|
|
|
|
|
2001-10-16 00:39:01 +00:00
|
|
|
U_NAMESPACE_END
|
2000-11-14 21:22:14 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
|