#include <LayoutEngine.h>
Inheritance diagram for LayoutEngine:
Public Member Functions | |
virtual | ~LayoutEngine () |
The destructor. | |
virtual le_int32 | layoutChars (const LEUnicode chars[], le_int32 offset, le_int32 count, le_int32 max, le_bool rightToLeft, float x, float y, LEErrorCode &success) |
This method will invoke the layout steps in their correct order by calling the computeGlyphs, positionGlyphs and adjustGlyphPosition methods. | |
le_int32 | getGlyphCount () const |
This method returns the number of glyphs in the glyph array. | |
void | getGlyphs (LEGlyphID glyphs[], LEErrorCode &success) const |
This method copies the glyph array into a caller supplied array. | |
virtual void | getGlyphs (le_uint32 glyphs[], le_uint32 extraBits, LEErrorCode &success) const |
This method copies the glyph array into a caller supplied array, ORing in extra bits. | |
void | getCharIndices (le_int32 charIndices[], LEErrorCode &success) const |
This method copies the character index array into a caller supplied array. | |
void | getCharIndices (le_int32 charIndices[], le_int32 indexBase, LEErrorCode &success) const |
This method copies the character index array into a caller supplied array. | |
void | getGlyphPositions (float positions[], LEErrorCode &success) const |
This method copies the position array into a caller supplied array. | |
void | getGlyphPosition (le_int32 glyphIndex, float &x, float &y, LEErrorCode &success) const |
This method returns the X and Y position of the glyph at the given index. | |
virtual void | reset () |
This method frees the glyph, character index and position arrays so that the LayoutEngine can be reused to layout a different characer array. | |
virtual UClassID | getDynamicClassID () const |
ICU "poor man's RTTI", returns a UClassID for the actual class. | |
Static Public Member Functions | |
static LayoutEngine * | layoutEngineFactory (const LEFontInstance *fontInstance, le_int32 scriptCode, le_int32 languageCode, LEErrorCode &success) |
This method returns a LayoutEngine capable of laying out text in the given font, script and langauge. | |
static LayoutEngine * | layoutEngineFactory (const LEFontInstance *fontInstance, le_int32 scriptCode, le_int32 languageCode, le_int32 typo_flags, LEErrorCode &success) |
Override of existing call that provides flags to control typography. | |
static UClassID | getStaticClassID () |
ICU "poor man's RTTI", returns a UClassID for this class. | |
Protected Member Functions | |
LayoutEngine (const LEFontInstance *fontInstance, le_int32 scriptCode, le_int32 languageCode, le_int32 typoFlags) | |
This constructs an instance for a given font, script and language. | |
LayoutEngine () | |
This overrides the default no argument constructor to make it difficult for clients to call it. | |
virtual le_int32 | characterProcessing (const LEUnicode chars[], le_int32 offset, le_int32 count, le_int32 max, le_bool rightToLeft, LEUnicode *&outChars, LEGlyphStorage &glyphStorage, LEErrorCode &success) |
This method does any required pre-processing to the input characters. | |
virtual le_int32 | computeGlyphs (const LEUnicode chars[], le_int32 offset, le_int32 count, le_int32 max, le_bool rightToLeft, LEGlyphStorage &glyphStorage, LEErrorCode &success) |
This method does the glyph processing. | |
virtual void | positionGlyphs (LEGlyphStorage &glyphStorage, float x, float y, LEErrorCode &success) |
This method does basic glyph positioning. | |
virtual void | adjustGlyphPositions (const LEUnicode chars[], le_int32 offset, le_int32 count, le_bool reverse, LEGlyphStorage &glyphStorage, LEErrorCode &success) |
This method does positioning adjustments like accent positioning and kerning. | |
virtual const void * | getFontTable (LETag tableTag) const |
This method gets a table from the font associated with the text. | |
virtual void | mapCharsToGlyphs (const LEUnicode chars[], le_int32 offset, le_int32 count, le_bool reverse, le_bool mirror, le_bool filterZeroWidth, LEGlyphStorage &glyphStorage, LEErrorCode &success) |
This method does character to glyph mapping. | |
Static Protected Member Functions | |
static void | adjustMarkGlyphs (LEGlyphStorage &glyphStorage, LEGlyphFilter *markFilter, LEErrorCode &success) |
This is a convenience method that forces the advance width of mark glyphs to be zero, which is required for proper selection and highlighting. | |
static void | adjustMarkGlyphs (const LEUnicode chars[], le_int32 charCount, le_bool reverse, LEGlyphStorage &glyphStorage, LEGlyphFilter *markFilter, LEErrorCode &success) |
This is a convenience method that forces the advance width of mark glyphs to be zero, which is required for proper selection and highlighting. | |
Protected Attributes | |
LEGlyphStorage * | fGlyphStorage |
The object which holds the glyph storage. | |
const LEFontInstance * | fFontInstance |
The font instance for the text font. | |
le_int32 | fScriptCode |
The script code for the text. | |
le_int32 | fLanguageCode |
The langauge code for the text. | |
le_int32 | fTypoFlags |
The typographic control flags. |
The text must all be in a single font, script, and language. An instance of a LayoutEngine can be created by calling the layoutEngineFactory method. Fonts are identified by instances of the LEFontInstance class. Script and language codes are identified by integer codes, which are defined in ScriptAndLanuageTags.h.
Note that this class is not public API. It is declared public so that it can be exported from the library that it is a part of.
The input to the layout process is an array of characters in logical order, and a starting X, Y position for the text. The output is an array of glyph indices, an array of character indices for the glyphs, and an array of glyph positions. These arrays are protected members of LayoutEngine which can be retreived by a public method. The reset method can be called to free these arrays so that the LayoutEngine can be reused.
The layout process is done in three steps. There is a protected virtual method for each step. These methods have a default implementation which only does character to glyph mapping and default positioning using the glyph's advance widths. Subclasses can override these methods for more advanced layout. There is a public method which invokes the steps in the correct order.
The steps are:
1) Glyph processing - character to glyph mapping and any other glyph processing such as ligature substitution and contextual forms.
2) Glyph positioning - position the glyphs based on their advance widths.
3) Glyph position adjustments - adjustment of glyph positions for kerning, accent placement, etc.
NOTE: in all methods below, output parameters are references to pointers so the method can allocate and free the storage as needed. All storage allocated in this way is owned by the object which created it, and will be freed when it is no longer needed, or when the object's destructor is invoked.
ScriptAndLanguageTags.h
Definition at line 67 of file LayoutEngine.h.
|
This constructs an instance for a given font, script and language. Subclass constructors must call this constructor.
|
|
This overrides the default no argument constructor to make it difficult for clients to call it. Clients are expected to call layoutEngineFactory.
|
|
The destructor. It will free any storage allocated for the glyph, character index and position arrays by calling the reset method. It is declared virtual so that it will be invoked by the subclass destructors.
|
|
This method does positioning adjustments like accent positioning and kerning. The default implementation does nothing. Subclasses needing position adjustments must override this method. Note that this method has both characters and glyphs as input so that it can use the character codes to determine glyph types if that information isn't directly available. (e.g. Some Arabic OpenType fonts don't have a GDEF table)
|
|
This is a convenience method that forces the advance width of mark glyphs to be zero, which is required for proper selection and highlighting. This method uses the input characters to identify marks. This is required in cases where the font does not contain enough information to identify them based on the glyph IDs.
|
|
This is a convenience method that forces the advance width of mark glyphs to be zero, which is required for proper selection and highlighting.
|
|
This method does any required pre-processing to the input characters. It may generate output characters that differ from the input charcters due to insertions, deletions, or reorderings. In such cases, it will also generate an output character index array reflecting these changes. Subclasses must override this method. Input parameters:
|
|
This method does the glyph processing. It converts an array of characters into an array of glyph indices and character indices. The characters to be processed are passed in a surrounding context. The context is specified as a starting address and a maximum character count. An offset and a count are used to specify the characters to be processed. The default implementation of this method only does character to glyph mapping. Subclasses needing more elaborate glyph processing must override this method. Input parameters:
|
|
This method copies the character index array into a caller supplied array. The caller must ensure that the array is large enough to hold a character index for each glyph.
|
|
This method copies the character index array into a caller supplied array. The caller must ensure that the array is large enough to hold a character index for each glyph.
|
|
ICU "poor man's RTTI", returns a UClassID for the actual class.
Implements UObject. |
|
This method gets a table from the font associated with the text. The default implementation gets the table from the font instance. Subclasses which need to get the tables some other way must override this method.
|
|
This method returns the number of glyphs in the glyph array. Note that the number of glyphs will be greater than or equal to the number of characters used to create the LayoutEngine.
|
|
This method returns the X and Y position of the glyph at the given index. Input parameters:
|
|
This method copies the position array into a caller supplied array. The caller must ensure that the array is large enough to hold an X and Y position for each glyph, plus an extra X and Y for the advance of the last glyph.
|
|
This method copies the glyph array into a caller supplied array, ORing in extra bits. (This functionality is needed by the JDK, which uses 32 bits pre glyph idex, with the high 16 bits encoding the composite font slot number)
|
|
This method copies the glyph array into a caller supplied array. The caller must ensure that the array is large enough to hold all the glyphs.
|
|
ICU "poor man's RTTI", returns a UClassID for this class.
|
|
This method will invoke the layout steps in their correct order by calling the computeGlyphs, positionGlyphs and adjustGlyphPosition methods. It will compute the glyph, character index and position arrays.
Note: If you call this method more than once, you must call the reset() method first to free the glyph, character index and position arrays allocated by the previous call.
|
|
Override of existing call that provides flags to control typography.
|
|
This method returns a LayoutEngine capable of laying out text in the given font, script and langauge. Note that the LayoutEngine returned may be a subclass of LayoutEngine.
|
|
This method does character to glyph mapping. The default implementation uses the font instance to do the mapping. It will allocate the glyph and character index arrays if they're not already allocated. If it allocates the character index array, it will fill it it. This method supports right to left text with the ability to store the glyphs in reverse order, and by supporting character mirroring, which will replace a character which has a left and right form, such as parens, with the opposite form before mapping it to a glyph index. Input parameters:
|
|
This method does basic glyph positioning. The default implementation positions the glyphs based on their advance widths. This is sufficient for most uses. It is not expected that many subclasses will override this method. Input parameters:
|
|
This method frees the glyph, character index and position arrays so that the LayoutEngine can be reused to layout a different characer array. (This method is also called by the destructor)
|
|
The font instance for the text font.
Definition at line 83 of file LayoutEngine.h. |
|
The object which holds the glyph storage.
Definition at line 74 of file LayoutEngine.h. |
|
The langauge code for the text.
Definition at line 101 of file LayoutEngine.h. |
|
The script code for the text.
Definition at line 92 of file LayoutEngine.h. |
|
The typographic control flags.
Definition at line 108 of file LayoutEngine.h. |