1ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru/*
28393335b955da7340c9f19b1b4b2d6c0c2c04be7Craig Cornelius * (C) Copyright IBM Corp. and others 1998-2013 - All Rights Reserved
3ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */
4ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
5ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#ifndef __LAYOUTENGINE_H
6ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#define __LAYOUTENGINE_H
7ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
8ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#include "LETypes.h"
9ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
10ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru/**
11ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * \file
12ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * \brief C++ API: Virtual base class for complex text layout.
13ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */
14ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
15ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste QueruU_NAMESPACE_BEGIN
16ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
17ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queruclass LEFontInstance;
18ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queruclass LEGlyphFilter;
19ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queruclass LEGlyphStorage;
20ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
21ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru/**
22ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * This is a virtual base class used to do complex text layout. The text must all
23ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * be in a single font, script, and language. An instance of a LayoutEngine can be
24ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * created by calling the layoutEngineFactory method. Fonts are identified by
25ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * instances of the LEFontInstance class. Script and language codes are identified
26ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * by integer codes, which are defined in ScriptAndLanuageTags.h.
27ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *
28ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Note that this class is not public API. It is declared public so that it can be
29ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * exported from the library that it is a part of.
30ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *
31ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * The input to the layout process is an array of characters in logical order,
32ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * and a starting X, Y position for the text. The output is an array of glyph indices,
33ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * an array of character indices for the glyphs, and an array of glyph positions.
34ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * These arrays are protected members of LayoutEngine which can be retreived by a
35ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * public method. The reset method can be called to free these arrays so that the
36ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * LayoutEngine can be reused.
37ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *
38ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * The layout process is done in three steps. There is a protected virtual method
39ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * for each step. These methods have a default implementation which only does
40ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * character to glyph mapping and default positioning using the glyph's advance
41ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * widths. Subclasses can override these methods for more advanced layout.
42ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * There is a public method which invokes the steps in the correct order.
43ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *
44ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * The steps are:
45ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *
46ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 1) Glyph processing - character to glyph mapping and any other glyph processing
47ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *    such as ligature substitution and contextual forms.
48ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *
49ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 2) Glyph positioning - position the glyphs based on their advance widths.
50ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *
51ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 3) Glyph position adjustments - adjustment of glyph positions for kerning,
52ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *    accent placement, etc.
53ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *
54ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * NOTE: in all methods below, output parameters are references to pointers so
55ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * the method can allocate and free the storage as needed. All storage allocated
56ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * in this way is owned by the object which created it, and will be freed when it
57ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * is no longer needed, or when the object's destructor is invoked.
58ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *
59ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @see LEFontInstance
60ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @see ScriptAndLanguageTags.h
61ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *
62ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @stable ICU 2.8
63ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */
64ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queruclass U_LAYOUT_API LayoutEngine : public UObject {
65b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2clairehopublic:
66103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius#ifndef U_HIDE_INTERNAL_API
678393335b955da7340c9f19b1b4b2d6c0c2c04be7Craig Cornelius    /** @internal Flag to request kerning. Use LE_Kerning_FEATURE_FLAG instead. */
68b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho    static const le_int32 kTypoFlagKern;
698393335b955da7340c9f19b1b4b2d6c0c2c04be7Craig Cornelius    /** @internal Flag to request ligatures. Use LE_Ligatures_FEATURE_FLAG instead. */
708393335b955da7340c9f19b1b4b2d6c0c2c04be7Craig Cornelius    static const le_int32 kTypoFlagLiga;
71103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius#endif  /* U_HIDE_INTERNAL_API */
72b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho
73ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queruprotected:
74ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    /**
75ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * The object which holds the glyph storage
76ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     *
77ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @internal
78ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     */
79ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    LEGlyphStorage *fGlyphStorage;
80ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
81ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    /**
82ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * The font instance for the text font.
83ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     *
84ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @see LEFontInstance
85ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     *
86ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @internal
87ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     */
88ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    const LEFontInstance *fFontInstance;
89ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
90ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    /**
91ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * The script code for the text
92ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     *
93ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @see ScriptAndLanguageTags.h for script codes.
94ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     *
95ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @internal
96ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     */
97ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    le_int32 fScriptCode;
98ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
99ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    /**
100ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * The langauge code for the text
101ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     *
102ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @see ScriptAndLanguageTags.h for language codes.
103ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     *
104ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @internal
105ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     */
106ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    le_int32 fLanguageCode;
107ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
108ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    /**
109ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * The typographic control flags
110ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     *
111ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @internal
112ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     */
113ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    le_int32 fTypoFlags;
114ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
115ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    /**
116ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * <code>TRUE</code> if <code>mapCharsToGlyphs</code> should replace ZWJ / ZWNJ with a glyph
117ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * with no contours.
118ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     *
119ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @internal
120ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     */
121ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    le_bool fFilterZeroWidth;
122ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
123103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius#ifndef U_HIDE_INTERNAL_API
124ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    /**
125ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * This constructs an instance for a given font, script and language. Subclass constructors
126ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * must call this constructor.
127ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     *
128ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @param fontInstance - the font for the text
129ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @param scriptCode - the script for the text
130ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @param languageCode - the language for the text
131b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho     * @param typoFlags - the typographic control flags for the text (a bitfield).  Use kTypoFlagKern
132b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho     * if kerning is desired, kTypoFlagLiga if ligature formation is desired.  Others are reserved.
13385bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho     * @param success - set to an error code if the operation fails
134ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     *
135ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @see LEFontInstance
136ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @see ScriptAndLanguageTags.h
137ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     *
138ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @internal
139ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     */
140b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho    LayoutEngine(const LEFontInstance *fontInstance,
141b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho                 le_int32 scriptCode,
142b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho                 le_int32 languageCode,
14385bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho                 le_int32 typoFlags,
14485bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho                 LEErrorCode &success);
145103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius#endif  /* U_HIDE_INTERNAL_API */
146ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
147103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius    // Do not enclose the protected default constructor with #ifndef U_HIDE_INTERNAL_API
148103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius    // or else the compiler will create a public default constructor.
149ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    /**
150ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * This overrides the default no argument constructor to make it
151ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * difficult for clients to call it. Clients are expected to call
152ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * layoutEngineFactory.
153ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     *
154ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @internal
155ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     */
156ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    LayoutEngine();
157ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
158ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    /**
159ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * This method does any required pre-processing to the input characters. It
160ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * may generate output characters that differ from the input charcters due to
161ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * insertions, deletions, or reorderings. In such cases, it will also generate an
162ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * output character index array reflecting these changes.
163ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     *
164ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * Subclasses must override this method.
165ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     *
166ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * Input parameters:
167ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @param chars - the input character context
168ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @param offset - the index of the first character to process
169ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @param count - the number of characters to process
170ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @param max - the number of characters in the input context
171ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @param rightToLeft - TRUE if the characters are in a right to left directional run
172ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @param outChars - the output character array, if different from the input
173ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @param glyphStorage - the object that holds the per-glyph storage. The character index array may be set.
174ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @param success - set to an error code if the operation fails
175ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     *
176ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @return the output character count (input character count if no change)
177ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     *
178ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @internal
179ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     */
180ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    virtual le_int32 characterProcessing(const LEUnicode chars[], le_int32 offset, le_int32 count, le_int32 max, le_bool rightToLeft,
181ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            LEUnicode *&outChars, LEGlyphStorage &glyphStorage, LEErrorCode &success);
182ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
183ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    /**
184ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * This method does the glyph processing. It converts an array of characters
185ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * into an array of glyph indices and character indices. The characters to be
186ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * processed are passed in a surrounding context. The context is specified as
187ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * a starting address and a maximum character count. An offset and a count are
188ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * used to specify the characters to be processed.
189ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     *
190ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * The default implementation of this method only does character to glyph mapping.
191ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * Subclasses needing more elaborate glyph processing must override this method.
192ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     *
193ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * Input parameters:
194ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @param chars - the character context
195ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @param offset - the offset of the first character to process
196ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @param count - the number of characters to process
197ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @param max - the number of characters in the context.
198ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @param rightToLeft - TRUE if the text is in a right to left directional run
199ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @param glyphStorage - the object which holds the per-glyph storage. The glyph and char indices arrays
200ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     *                       will be set.
201ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     *
202ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * Output parameters:
203ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @param success - set to an error code if the operation fails
204ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     *
205ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @return the number of glyphs in the glyph index array
206ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     *
207ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @internal
208ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     */
209ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    virtual le_int32 computeGlyphs(const LEUnicode chars[], le_int32 offset, le_int32 count, le_int32 max, le_bool rightToLeft, LEGlyphStorage &glyphStorage, LEErrorCode &success);
210ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
211ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    /**
212ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * This method does basic glyph positioning. The default implementation positions
213ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * the glyphs based on their advance widths. This is sufficient for most uses. It
214ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * is not expected that many subclasses will override this method.
215ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     *
216ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * Input parameters:
217ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @param glyphStorage - the object which holds the per-glyph storage. The glyph position array will be set.
218ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @param x - the starting X position
219ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @param y - the starting Y position
220ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @param success - set to an error code if the operation fails
221ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     *
222ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @internal
223ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     */
224ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    virtual void positionGlyphs(LEGlyphStorage &glyphStorage, float x, float y, LEErrorCode &success);
225ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
226ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    /**
227ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * This method does positioning adjustments like accent positioning and
228ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * kerning. The default implementation does nothing. Subclasses needing
229ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * position adjustments must override this method.
230ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     *
231ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * Note that this method has both characters and glyphs as input so that
232ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * it can use the character codes to determine glyph types if that information
233ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * isn't directly available. (e.g. Some Arabic OpenType fonts don't have a GDEF
234ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * table)
235ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     *
236ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @param chars - the input character context
237ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @param offset - the offset of the first character to process
238ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @param count - the number of characters to process
239ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @param reverse - <code>TRUE</code> if the glyphs in the glyph array have been reordered
240ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @param glyphStorage - the object which holds the per-glyph storage. The glyph positions will be
241ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     *                       adjusted as needed.
242ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @param success - output parameter set to an error code if the operation fails
243ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     *
244ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @internal
245ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     */
246ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    virtual void adjustGlyphPositions(const LEUnicode chars[], le_int32 offset, le_int32 count, le_bool reverse, LEGlyphStorage &glyphStorage, LEErrorCode &success);
247ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
248ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    /**
249ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * This method gets a table from the font associated with
250ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * the text. The default implementation gets the table from
251ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * the font instance. Subclasses which need to get the tables
252ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * some other way must override this method.
253ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     *
254ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @param tableTag - the four byte table tag.
25559d709d503bab6e2b61931737e662dd293b40578ccornelius     * @param length - length to use
256ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     *
257ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @return the address of the table.
258ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     *
259ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @internal
260ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     */
26159d709d503bab6e2b61931737e662dd293b40578ccornelius    virtual const void *getFontTable(LETag tableTag, size_t &length) const;
26259d709d503bab6e2b61931737e662dd293b40578ccornelius
26359d709d503bab6e2b61931737e662dd293b40578ccornelius    /**
26459d709d503bab6e2b61931737e662dd293b40578ccornelius     * @deprecated
26559d709d503bab6e2b61931737e662dd293b40578ccornelius     */
26659d709d503bab6e2b61931737e662dd293b40578ccornelius    virtual const void *getFontTable(LETag tableTag) const { size_t ignored; return getFontTable(tableTag, ignored); }
267ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
268ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    /**
269ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * This method does character to glyph mapping. The default implementation
270ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * uses the font instance to do the mapping. It will allocate the glyph and
271ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * character index arrays if they're not already allocated. If it allocates the
272ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * character index array, it will fill it it.
273ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     *
274ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * This method supports right to left
275ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * text with the ability to store the glyphs in reverse order, and by supporting
276ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * character mirroring, which will replace a character which has a left and right
277ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * form, such as parens, with the opposite form before mapping it to a glyph index.
278ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     *
279ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * Input parameters:
280ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @param chars - the input character context
281ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @param offset - the offset of the first character to be mapped
282ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @param count - the number of characters to be mapped
283ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @param reverse - if <code>TRUE</code>, the output will be in reverse order
284ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @param mirror - if <code>TRUE</code>, do character mirroring
285ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @param glyphStorage - the object which holds the per-glyph storage. The glyph and char
286ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     *                       indices arrays will be filled in.
287ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @param success - set to an error code if the operation fails
288ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     *
289ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @see LEFontInstance
290ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     *
291ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @internal
292ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     */
293ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    virtual void mapCharsToGlyphs(const LEUnicode chars[], le_int32 offset, le_int32 count, le_bool reverse, le_bool mirror, LEGlyphStorage &glyphStorage, LEErrorCode &success);
294ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
295103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius#ifndef U_HIDE_INTERNAL_API
296ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    /**
297ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * This is a convenience method that forces the advance width of mark
298ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * glyphs to be zero, which is required for proper selection and highlighting.
299ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     *
300ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @param glyphStorage - the object containing the per-glyph storage. The positions array will be modified.
301ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @param markFilter - used to identify mark glyphs
302ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @param success - output parameter set to an error code if the operation fails
303ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     *
304ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @see LEGlyphFilter
305ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     *
306ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @internal
307ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     */
308ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    static void adjustMarkGlyphs(LEGlyphStorage &glyphStorage, LEGlyphFilter *markFilter, LEErrorCode &success);
309ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
310ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
311ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    /**
312ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * This is a convenience method that forces the advance width of mark
313ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * glyphs to be zero, which is required for proper selection and highlighting.
314ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * This method uses the input characters to identify marks. This is required in
315ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * cases where the font does not contain enough information to identify them based
316ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * on the glyph IDs.
317ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     *
318ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @param chars - the array of input characters
319ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @param charCount - the number of input characers
320ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @param glyphStorage - the object containing the per-glyph storage. The positions array will be modified.
321ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @param reverse - <code>TRUE</code> if the glyph array has been reordered
322ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @param markFilter - used to identify mark glyphs
323ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @param success - output parameter set to an error code if the operation fails
324ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     *
325ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @see LEGlyphFilter
326ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     *
327ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @internal
328ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     */
329ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    static void adjustMarkGlyphs(const LEUnicode chars[], le_int32 charCount, le_bool reverse, LEGlyphStorage &glyphStorage, LEGlyphFilter *markFilter, LEErrorCode &success);
330103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius#endif  /* U_HIDE_INTERNAL_API */
331ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
332ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Querupublic:
333ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    /**
334ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * The destructor. It will free any storage allocated for the
335ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * glyph, character index and position arrays by calling the reset
336ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * method. It is declared virtual so that it will be invoked by the
337ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * subclass destructors.
338ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     *
339ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @stable ICU 2.8
340ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     */
341ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    virtual ~LayoutEngine();
342ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
343ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    /**
344ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * This method will invoke the layout steps in their correct order by calling
345ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * the computeGlyphs, positionGlyphs and adjustGlyphPosition methods. It will
346ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * compute the glyph, character index and position arrays.
347ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     *
348ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @param chars - the input character context
349ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @param offset - the offset of the first character to process
350ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @param count - the number of characters to process
351ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @param max - the number of characters in the input context
352ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @param rightToLeft - TRUE if the characers are in a right to left directional run
353ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @param x - the initial X position
354ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @param y - the initial Y position
355ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @param success - output parameter set to an error code if the operation fails
356ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     *
357ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @return the number of glyphs in the glyph array
358ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     *
359ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * Note: The glyph, character index and position array can be accessed
360ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * using the getter methods below.
361ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     *
362ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * Note: If you call this method more than once, you must call the reset()
363ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * method first to free the glyph, character index and position arrays
364ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * allocated by the previous call.
365ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     *
366ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @stable ICU 2.8
367ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     */
368ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    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);
369ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
370ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    /**
371ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * This method returns the number of glyphs in the glyph array. Note
372ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * that the number of glyphs will be greater than or equal to the number
373ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * of characters used to create the LayoutEngine.
374ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     *
375ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @return the number of glyphs in the glyph array
376ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     *
377ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @stable ICU 2.8
378ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     */
379ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    le_int32 getGlyphCount() const;
380ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
381ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    /**
382ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * This method copies the glyph array into a caller supplied array.
383ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * The caller must ensure that the array is large enough to hold all
384ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * the glyphs.
385ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     *
386ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @param glyphs - the destiniation glyph array
387ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @param success - set to an error code if the operation fails
388ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     *
389ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @stable ICU 2.8
390ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     */
391ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    void getGlyphs(LEGlyphID glyphs[], LEErrorCode &success) const;
392ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
393ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    /**
394ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * This method copies the glyph array into a caller supplied array,
395ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * ORing in extra bits. (This functionality is needed by the JDK,
396ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * which uses 32 bits pre glyph idex, with the high 16 bits encoding
397ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * the composite font slot number)
398ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     *
399ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @param glyphs - the destination (32 bit) glyph array
400ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @param extraBits - this value will be ORed with each glyph index
401ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @param success - set to an error code if the operation fails
402ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     *
403ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @stable ICU 2.8
404ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     */
405ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    virtual void getGlyphs(le_uint32 glyphs[], le_uint32 extraBits, LEErrorCode &success) const;
406ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
407ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    /**
408ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * This method copies the character index array into a caller supplied array.
409ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * The caller must ensure that the array is large enough to hold a
410ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * character index for each glyph.
411ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     *
412ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @param charIndices - the destiniation character index array
413ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @param success - set to an error code if the operation fails
414ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     *
415ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @stable ICU 2.8
416ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     */
417ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    void getCharIndices(le_int32 charIndices[], LEErrorCode &success) const;
418ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
419ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    /**
420ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * This method copies the character index array into a caller supplied array.
421ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * The caller must ensure that the array is large enough to hold a
422ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * character index for each glyph.
423ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     *
424ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @param charIndices - the destiniation character index array
425ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @param indexBase - an offset which will be added to each index
426ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @param success - set to an error code if the operation fails
427ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     *
428ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @stable ICU 2.8
429ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     */
430ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    void getCharIndices(le_int32 charIndices[], le_int32 indexBase, LEErrorCode &success) const;
431ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
432ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    /**
433ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * This method copies the position array into a caller supplied array.
434ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * The caller must ensure that the array is large enough to hold an
435ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * X and Y position for each glyph, plus an extra X and Y for the
436ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * advance of the last glyph.
437ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     *
438ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @param positions - the destiniation position array
439ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @param success - set to an error code if the operation fails
440ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     *
441ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @stable ICU 2.8
442ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     */
443ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    void getGlyphPositions(float positions[], LEErrorCode &success) const;
444ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
445ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    /**
446ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * This method returns the X and Y position of the glyph at
447ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * the given index.
448ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     *
449ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * Input parameters:
450ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @param glyphIndex - the index of the glyph
451ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     *
452ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * Output parameters:
453ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @param x - the glyph's X position
454ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @param y - the glyph's Y position
455ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @param success - set to an error code if the operation fails
456ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     *
457ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @stable ICU 2.8
458ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     */
459ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    void getGlyphPosition(le_int32 glyphIndex, float &x, float &y, LEErrorCode &success) const;
460ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
461ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    /**
462ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * This method frees the glyph, character index and position arrays
463ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * so that the LayoutEngine can be reused to layout a different
464ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * characer array. (This method is also called by the destructor)
465ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     *
466ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @stable ICU 2.8
467ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     */
468ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    virtual void reset();
469ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
470ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    /**
471ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * This method returns a LayoutEngine capable of laying out text
472ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * in the given font, script and langauge. Note that the LayoutEngine
473ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * returned may be a subclass of LayoutEngine.
474ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     *
475ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @param fontInstance - the font of the text
476ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @param scriptCode - the script of the text
477ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @param languageCode - the language of the text
478ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @param success - output parameter set to an error code if the operation fails
479ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     *
480ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @return a LayoutEngine which can layout text in the given font.
481ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     *
482ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @see LEFontInstance
483ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     *
484ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @stable ICU 2.8
485ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     */
486ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    static LayoutEngine *layoutEngineFactory(const LEFontInstance *fontInstance, le_int32 scriptCode, le_int32 languageCode, LEErrorCode &success);
487ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
488ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    /**
489ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * Override of existing call that provides flags to control typography.
490ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @stable ICU 3.4
491ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     */
492ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    static LayoutEngine *layoutEngineFactory(const LEFontInstance *fontInstance, le_int32 scriptCode, le_int32 languageCode, le_int32 typo_flags, LEErrorCode &success);
493ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
494ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    /**
495ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * ICU "poor man's RTTI", returns a UClassID for the actual class.
496ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     *
497ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @stable ICU 2.8
498ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     */
499ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    virtual UClassID getDynamicClassID() const;
500ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
501ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    /**
502ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * ICU "poor man's RTTI", returns a UClassID for this class.
503ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     *
504ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @stable ICU 2.8
505ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     */
506ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    static UClassID getStaticClassID();
507ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
508ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru};
509ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
510ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste QueruU_NAMESPACE_END
511ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#endif
512