~ubuntu-branches/ubuntu/gutsy/icu/gutsy

« back to all changes in this revision

Viewing changes to source/layout/LayoutEngine.h

  • Committer: Package Import Robot
  • Author(s): Matthias Klose
  • Date: 2005-05-21 22:44:31 UTC
  • mfrom: (2.1.1 warty)
  • Revision ID: package-import@ubuntu.com-20050521224431-r7rktfhnu1n4tf1g
Tags: 2.1-2.1
Rename icu-doc to icu21-doc. icu-doc is built by the icu28 package.

Show diffs side-by-side

added added

removed removed

Lines of Context:
64
64
class U_LAYOUT_API LayoutEngine
65
65
{
66
66
protected:
67
 
        /**
68
 
         * The number of glyphs in the output
69
 
         */
 
67
    /**
 
68
     * The number of glyphs in the output
 
69
     */
70
70
    le_int32 fGlyphCount;
71
71
 
72
 
        /**
73
 
         * The output glyph array
74
 
         */
 
72
    /**
 
73
     * The output glyph array
 
74
     */
75
75
    LEGlyphID *fGlyphs;
76
76
 
77
 
        /**
78
 
         * The character index array. One entry for each output glyph, giving the index
79
 
         * in the input character array of the character which corresponds to this glyph.
80
 
         */
 
77
    /**
 
78
     * The character index array. One entry for each output glyph, giving the index
 
79
     * in the input character array of the character which corresponds to this glyph.
 
80
     */
81
81
    le_int32 *fCharIndices;
82
82
 
83
 
        /**
84
 
         * The glyph position array. There are two entries for each glyph giving the
85
 
         * X and Y positions of the glyph. Thus, for glyph i, the X position is at index
86
 
         * 2i, and the Y position is at index 2i + 1. There are also two entries for the
87
 
         * X and Y position of the advance of the last glyph.
88
 
         */
 
83
    /**
 
84
     * The glyph position array. There are two entries for each glyph giving the
 
85
     * X and Y positions of the glyph. Thus, for glyph i, the X position is at index
 
86
     * 2i, and the Y position is at index 2i + 1. There are also two entries for the
 
87
     * X and Y position of the advance of the last glyph.
 
88
     */
89
89
    float *fPositions;
90
90
 
91
 
        /**
92
 
         * The font instance for the text font.
93
 
         *
94
 
         * @see LEFontInstance
95
 
         */
 
91
    /**
 
92
     * The font instance for the text font.
 
93
     *
 
94
     * @see LEFontInstance
 
95
     */
96
96
    const LEFontInstance *fFontInstance;
97
97
 
98
 
        /**
99
 
         * The script code for the text
100
 
         *
101
 
         * @see ScriptAndLanguageTags.h for script codes.
102
 
         */
 
98
    /**
 
99
     * The script code for the text
 
100
     *
 
101
     * @see ScriptAndLanguageTags.h for script codes.
 
102
     */
103
103
    le_int32 fScriptCode;
104
104
 
105
 
        /**
106
 
         * The langauge code for the text
107
 
         *
108
 
         * @see ScriptAndLanguageTags.h for language codes.
109
 
         */
 
105
    /**
 
106
     * The langauge code for the text
 
107
     *
 
108
     * @see ScriptAndLanguageTags.h for language codes.
 
109
     */
110
110
    le_int32 fLanguageCode;
111
111
 
112
 
        /**
113
 
         * This constructs an instance for a given font, script and language. Subclass constructors
114
 
         * must call this constructor.
115
 
         *
116
 
         * @param fontInstance - the font for the text
117
 
         * @param scriptCode - the script for the text
118
 
         * @param langaugeCode - the language for the text
119
 
         *
120
 
         * @see LEFontInstance
121
 
         * @see ScriptAndLanguageTags.h
122
 
         */
 
112
    /**
 
113
     * This constructs an instance for a given font, script and language. Subclass constructors
 
114
     * must call this constructor.
 
115
     *
 
116
     * @param fontInstance - the font for the text
 
117
     * @param scriptCode - the script for the text
 
118
     * @param langaugeCode - the language for the text
 
119
     *
 
120
     * @see LEFontInstance
 
121
     * @see ScriptAndLanguageTags.h
 
122
     */
123
123
    LayoutEngine(const LEFontInstance *fontInstance, le_int32 scriptCode, le_int32 languageCode);
124
124
 
125
125
    /**
126
 
         * This overrides the default no argument constructor to make it
127
 
         * difficult for clients to call it. Clients are expected to call
128
 
         * layoutEngineFactory.
129
 
         */
 
126
     * This overrides the default no argument constructor to make it
 
127
     * difficult for clients to call it. Clients are expected to call
 
128
     * layoutEngineFactory.
 
129
     */
130
130
    LayoutEngine();
131
131
 
132
 
        /**
133
 
         * This method does the glyph processing. It converts an array of characters
134
 
         * into an array of glyph indices and character indices. The characters to be
135
 
         * processed are passed in a surrounding context. The context is specified as
136
 
         * a starting address and a maximum character count. An offset and a count are
137
 
         * used to specify the characters to be processed.
138
 
         *
139
 
         * The default implementation of this method only does character to glyph mapping.
140
 
         * Subclasses needing more elaborate glyph processing must override this method.
141
 
         *
142
 
         * Input parameters:
143
 
         * @param chars - the character context
144
 
         * @param offset - the offset of the first character to process
145
 
         * @param count - the number of characters to process
146
 
         * @param max - the number of characters in the context.
147
 
         * @param rightToLeft - true if the text is in a right to left directional run
148
 
         *
149
 
         * Output parameters:
150
 
         * @param glyphs - the glyph index array
151
 
         * @param charIndices - the character index array
152
 
         * @param success - set to an error code if the operation fails
153
 
         *
154
 
         * @return the number of glyphs in the glyph index array
155
 
         */
 
132
    /**
 
133
     * This method does the glyph processing. It converts an array of characters
 
134
     * into an array of glyph indices and character indices. The characters to be
 
135
     * processed are passed in a surrounding context. The context is specified as
 
136
     * a starting address and a maximum character count. An offset and a count are
 
137
     * used to specify the characters to be processed.
 
138
     *
 
139
     * The default implementation of this method only does character to glyph mapping.
 
140
     * Subclasses needing more elaborate glyph processing must override this method.
 
141
     *
 
142
     * Input parameters:
 
143
     * @param chars - the character context
 
144
     * @param offset - the offset of the first character to process
 
145
     * @param count - the number of characters to process
 
146
     * @param max - the number of characters in the context.
 
147
     * @param rightToLeft - true if the text is in a right to left directional run
 
148
     *
 
149
     * Output parameters:
 
150
     * @param glyphs - the glyph index array
 
151
     * @param charIndices - the character index array
 
152
     * @param success - set to an error code if the operation fails
 
153
     *
 
154
     * @return the number of glyphs in the glyph index array
 
155
     */
156
156
    virtual le_int32 computeGlyphs(const LEUnicode chars[], le_int32 offset, le_int32 count, le_int32 max, le_bool rightToLeft, LEGlyphID *&glyphs, le_int32 *&charIndices, LEErrorCode &success);
157
157
 
158
 
        /**
159
 
         * This method does basic glyph positioning. The default implementation positions
160
 
         * the glyphs based on their advance widths. This is sufficient for most uses. It
161
 
         * is not expected that many subclasses will override this method.
162
 
         *
163
 
         * Input parameters:
164
 
         * @param glyphs - the input glyph array
165
 
         * @param glyphCount - the number of glyphs in the glyph array
166
 
         * @param x - the starting X position
167
 
         * @param y - the starting Y position
168
 
         *
169
 
         * Output parameters:
170
 
         * @param positions - the output X and Y positions (two entries per glyph)
171
 
         */
 
158
    /**
 
159
     * This method does basic glyph positioning. The default implementation positions
 
160
     * the glyphs based on their advance widths. This is sufficient for most uses. It
 
161
     * is not expected that many subclasses will override this method.
 
162
     *
 
163
     * Input parameters:
 
164
     * @param glyphs - the input glyph array
 
165
     * @param glyphCount - the number of glyphs in the glyph array
 
166
     * @param x - the starting X position
 
167
     * @param y - the starting Y position
 
168
     *
 
169
     * Output parameters:
 
170
     * @param positions - the output X and Y positions (two entries per glyph)
 
171
     */
172
172
    virtual void positionGlyphs(const LEGlyphID glyphs[], le_int32 glyphCount, float x, float y, float *&positions, LEErrorCode &success);
173
173
 
174
 
        /**
175
 
         * This method does positioning adjustments like accent positioning and
176
 
         * kerning. The default implementation does nothing. Subclasses needing
177
 
         * position adjustments must override this method.
178
 
         *
179
 
         * Note that this method has both characters and glyphs as input so that
180
 
         * it can use the character codes to determine glyph types if that information
181
 
         * isn't directly available. (e.g. Some Arabic OpenType fonts don't have a GDEF
182
 
         * table)
183
 
         *
184
 
         * @param chars - the input character context
185
 
         * @param offset - the offset of the first character to process
186
 
         * @param count - the number of characters to process
187
 
         * @param reverse - true if the glyphs in the glyph array have been reordered
188
 
         * @param glyphs - the input glyph array
189
 
         * @param glyphCount - the number of glyphs
190
 
         * @param positions - the position array, will be updated as needed
191
 
         * @param success - output parameter set to an error code if the operation fails
192
 
         *
193
 
         * Note: the positions are passed as a plain array because this method should
194
 
         * not need to reallocate them.
195
 
         */
 
174
    /**
 
175
     * This method does positioning adjustments like accent positioning and
 
176
     * kerning. The default implementation does nothing. Subclasses needing
 
177
     * position adjustments must override this method.
 
178
     *
 
179
     * Note that this method has both characters and glyphs as input so that
 
180
     * it can use the character codes to determine glyph types if that information
 
181
     * isn't directly available. (e.g. Some Arabic OpenType fonts don't have a GDEF
 
182
     * table)
 
183
     *
 
184
     * @param chars - the input character context
 
185
     * @param offset - the offset of the first character to process
 
186
     * @param count - the number of characters to process
 
187
     * @param reverse - true if the glyphs in the glyph array have been reordered
 
188
     * @param glyphs - the input glyph array
 
189
     * @param glyphCount - the number of glyphs
 
190
     * @param positions - the position array, will be updated as needed
 
191
     * @param success - output parameter set to an error code if the operation fails
 
192
     *
 
193
     * Note: the positions are passed as a plain array because this method should
 
194
     * not need to reallocate them.
 
195
     */
196
196
    virtual void adjustGlyphPositions(const LEUnicode chars[], le_int32 offset, le_int32 count, le_bool reverse, LEGlyphID glyphs[], le_int32 glyphCount, float positions[], LEErrorCode &success)
197
197
    {
198
 
                if (LE_FAILURE(success)) {
199
 
                        return;
200
 
                }
 
198
        if (LE_FAILURE(success)) {
 
199
            return;
 
200
        }
201
201
 
202
 
                if (chars == NULL || glyphs == NULL || positions == NULL || offset < 0 || count < 0) {
203
 
                        success = LE_ILLEGAL_ARGUMENT_ERROR;
204
 
                        return;
205
 
                }
 
202
        if (chars == NULL || glyphs == NULL || positions == NULL || offset < 0 || count < 0) {
 
203
            success = LE_ILLEGAL_ARGUMENT_ERROR;
 
204
            return;
 
205
        }
206
206
 
207
207
        // default is no adjustments
208
 
                return;
 
208
        return;
209
209
    };
210
210
 
211
 
        /**
212
 
         * This method gets a table from the font associated with
213
 
         * the text. The default implementation gets the table from
214
 
         * the font instance. Subclasses which need to get the tables
215
 
         * some other way must override this method.
216
 
         * 
217
 
         * @param tableTag - the four byte table tag.
218
 
         *
219
 
         * @return the address of the table.
220
 
         */
 
211
    /**
 
212
     * This method gets a table from the font associated with
 
213
     * the text. The default implementation gets the table from
 
214
     * the font instance. Subclasses which need to get the tables
 
215
     * some other way must override this method.
 
216
     * 
 
217
     * @param tableTag - the four byte table tag.
 
218
     *
 
219
     * @return the address of the table.
 
220
     */
221
221
    virtual const void *getFontTable(LETag tableTag) const;
222
222
 
223
 
        /**
224
 
         * This method does character to glyph mapping. The default implementation
225
 
         * uses the font instance to do the mapping. It will allocate the glyph and
226
 
         * character index arrays if they're not already allocated. If it allocates the
227
 
         * character index array, it will fill it it.
228
 
         *
229
 
         * This method supports right to left
230
 
         * text with the ability to store the glyphs in reverse order, and by supporting
231
 
         * character mirroring, which will replace a character which has a left and right
232
 
         * form, such as parens, with the opposite form before mapping it to a glyph index.
233
 
         *
234
 
         * Input parameters:
235
 
         * @param chars - the input character context
236
 
         * @param offset - the offset of the first character to be mapped
237
 
         * @param count - the number of characters to be mapped
238
 
         * @param reverse - if true, the output will be in reverse order
239
 
         * @param mirror - if true, do character mirroring
240
 
         *
241
 
         * Output parameters:
242
 
         * @param glyphs - the glyph array
243
 
         * @param charIndices - the character index array
244
 
         * @param success - set to an error code if the operation fails
245
 
         *
246
 
         * @see LEFontInstance
247
 
         */
 
223
    /**
 
224
     * This method does character to glyph mapping. The default implementation
 
225
     * uses the font instance to do the mapping. It will allocate the glyph and
 
226
     * character index arrays if they're not already allocated. If it allocates the
 
227
     * character index array, it will fill it it.
 
228
     *
 
229
     * This method supports right to left
 
230
     * text with the ability to store the glyphs in reverse order, and by supporting
 
231
     * character mirroring, which will replace a character which has a left and right
 
232
     * form, such as parens, with the opposite form before mapping it to a glyph index.
 
233
     *
 
234
     * Input parameters:
 
235
     * @param chars - the input character context
 
236
     * @param offset - the offset of the first character to be mapped
 
237
     * @param count - the number of characters to be mapped
 
238
     * @param reverse - if true, the output will be in reverse order
 
239
     * @param mirror - if true, do character mirroring
 
240
     *
 
241
     * Output parameters:
 
242
     * @param glyphs - the glyph array
 
243
     * @param charIndices - the character index array
 
244
     * @param success - set to an error code if the operation fails
 
245
     *
 
246
     * @see LEFontInstance
 
247
     */
248
248
    virtual void mapCharsToGlyphs(const LEUnicode chars[], le_int32 offset, le_int32 count, le_bool reverse, le_bool mirror, LEGlyphID *&glyphs, le_int32 *&charIndices, LEErrorCode &success);
249
249
 
250
 
        /**
251
 
         * This is a convenience method that forces the advance width of mark
252
 
         * glyphs to be zero, which is required for proper selection and highlighting.
253
 
         * 
254
 
         * @param glyphs - the glyph array
255
 
         * @param glyphCount - the number of glyphs
256
 
         * @param reverse - true if the glyph array has been reordered
257
 
         * @param markFilter - used to identify mark glyphs
258
 
         * @param positions - the glyph position array - updated as required
259
 
         * @param success - output parameter set to an error code if the operation fails
260
 
         *
261
 
         * @see LEGlyphFilter
262
 
         */
 
250
    /**
 
251
     * This is a convenience method that forces the advance width of mark
 
252
     * glyphs to be zero, which is required for proper selection and highlighting.
 
253
     * 
 
254
     * @param glyphs - the glyph array
 
255
     * @param glyphCount - the number of glyphs
 
256
     * @param reverse - true if the glyph array has been reordered
 
257
     * @param markFilter - used to identify mark glyphs
 
258
     * @param positions - the glyph position array - updated as required
 
259
     * @param success - output parameter set to an error code if the operation fails
 
260
     *
 
261
     * @see LEGlyphFilter
 
262
     */
263
263
    static void adjustMarkGlyphs(const LEGlyphID glyphs[], le_int32 glyphCount, le_bool reverse, LEGlyphFilter *markFilter, float positions[], LEErrorCode &success);
264
264
 
265
265
public:
266
 
        /**
267
 
         * The destructor. It will free any storage allocated for the
268
 
         * glyph, character index and position arrays by calling the reset
269
 
         * method. It is declared virtual so that it will be invoked by the
270
 
         * subclass destructors.
271
 
         */
 
266
    /**
 
267
     * The destructor. It will free any storage allocated for the
 
268
     * glyph, character index and position arrays by calling the reset
 
269
     * method. It is declared virtual so that it will be invoked by the
 
270
     * subclass destructors.
 
271
     */
272
272
    virtual ~LayoutEngine();
273
273
 
274
 
        /**
275
 
         * This method will invoke the layout steps in their correct order by calling
276
 
         * the computeGlyphs, positionGlyphs and adjustGlyphPosition methods.. It will
277
 
         * compute the glyph, character index and position arrays.
278
 
         *
279
 
         * @param chars - the input character context
280
 
         * @param offset - the offset of the first character to process
281
 
         * @param count - the number of characters to process
282
 
         * @param max - the number of characters in the input context
283
 
         * @param rightToLeft - true if the characers are in a right to left directional run
284
 
         * @param x - the initial X position
285
 
         * @param y - the initial Y position
286
 
         * @param success - output parameter set to an error code if the operation fails
287
 
         *
288
 
         * @return the number of glyphs in the glyph array
289
 
         *
290
 
         * Note; the glyph, character index and position array can be accessed
291
 
         * using the getter method below.
292
 
         */
 
274
    /**
 
275
     * This method will invoke the layout steps in their correct order by calling
 
276
     * the computeGlyphs, positionGlyphs and adjustGlyphPosition methods.. It will
 
277
     * compute the glyph, character index and position arrays.
 
278
     *
 
279
     * @param chars - the input character context
 
280
     * @param offset - the offset of the first character to process
 
281
     * @param count - the number of characters to process
 
282
     * @param max - the number of characters in the input context
 
283
     * @param rightToLeft - true if the characers are in a right to left directional run
 
284
     * @param x - the initial X position
 
285
     * @param y - the initial Y position
 
286
     * @param success - output parameter set to an error code if the operation fails
 
287
     *
 
288
     * @return the number of glyphs in the glyph array
 
289
     *
 
290
     * Note; the glyph, character index and position array can be accessed
 
291
     * using the getter method below.
 
292
     */
293
293
    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);
294
294
 
295
 
        /**
296
 
         * This method returns the number of glyphs in the glyph array. Note
297
 
         * that the number of glyphs will be greater than or equal to the number
298
 
         * of characters used to create the LayoutEngine.
299
 
         *
300
 
         * @return the number of glyphs in the glyph array
301
 
         */
302
 
        le_int32 getGlyphCount() const
303
 
        {
304
 
                return fGlyphCount;
305
 
        };
 
295
    /**
 
296
     * This method returns the number of glyphs in the glyph array. Note
 
297
     * that the number of glyphs will be greater than or equal to the number
 
298
     * of characters used to create the LayoutEngine.
 
299
     *
 
300
     * @return the number of glyphs in the glyph array
 
301
     */
 
302
    le_int32 getGlyphCount() const
 
303
    {
 
304
        return fGlyphCount;
 
305
    };
306
306
 
307
 
        /**
308
 
         * This method copies the glyph array into a caller supplied array.
309
 
         * The caller must ensure that the array is large enough to hold all
310
 
         * the glyphs.
311
 
         *
312
 
         * @param glyphs - the destiniation glyph array
313
 
         * @param success - set to an error code if the operation fails
314
 
         */
 
307
    /**
 
308
     * This method copies the glyph array into a caller supplied array.
 
309
     * The caller must ensure that the array is large enough to hold all
 
310
     * the glyphs.
 
311
     *
 
312
     * @param glyphs - the destiniation glyph array
 
313
     * @param success - set to an error code if the operation fails
 
314
     */
315
315
    void getGlyphs(LEGlyphID glyphs[], LEErrorCode &success) const
316
316
    {
317
 
                if (LE_FAILURE(success)) {
318
 
                        return;
319
 
                }
320
 
 
321
 
                if (glyphs == NULL) {
322
 
                        success = LE_ILLEGAL_ARGUMENT_ERROR;
323
 
                        return;
324
 
                }
325
 
 
326
 
                if (fGlyphs == NULL) {
327
 
                        success = LE_NO_LAYOUT_ERROR;
328
 
                }
 
317
        if (LE_FAILURE(success)) {
 
318
            return;
 
319
        }
 
320
 
 
321
        if (glyphs == NULL) {
 
322
            success = LE_ILLEGAL_ARGUMENT_ERROR;
 
323
            return;
 
324
        }
 
325
 
 
326
        if (fGlyphs == NULL) {
 
327
            success = LE_NO_LAYOUT_ERROR;
 
328
        }
329
329
 
330
330
        LE_ARRAY_COPY(glyphs, fGlyphs, fGlyphCount);
331
331
    };
332
332
 
333
 
        /**
334
 
         * This method copies the glyph array into a caller supplied array,
335
 
         * ORing in extra bits. (This functionality is needed by the JDK,
336
 
         * which uses 32 bits pre glyph idex, with the high 16 bits encoding
337
 
         * the composite font slot number)
338
 
         *
339
 
         * @param glyphs - the destination (32 bit) glyph array
340
 
         * @param extraBits - this value will be ORed with each glyph index
341
 
         * @param success - set to an error code if the operation fails
342
 
         */
 
333
    /**
 
334
     * This method copies the glyph array into a caller supplied array,
 
335
     * ORing in extra bits. (This functionality is needed by the JDK,
 
336
     * which uses 32 bits pre glyph idex, with the high 16 bits encoding
 
337
     * the composite font slot number)
 
338
     *
 
339
     * @param glyphs - the destination (32 bit) glyph array
 
340
     * @param extraBits - this value will be ORed with each glyph index
 
341
     * @param success - set to an error code if the operation fails
 
342
     */
343
343
    virtual void getGlyphs(le_uint32 glyphs[], le_uint32 extraBits, LEErrorCode &success) const;
344
344
 
345
 
        /**
346
 
         * This method copies the character index array into a caller supplied array.
347
 
         * The caller must ensure that the array is large enough to hold a
348
 
         * character index for each glyph.
349
 
         *
350
 
         * @param charIndices - the destiniation character index array
351
 
         * @param success - set to an error code if the operation fails
352
 
         */
 
345
    /**
 
346
     * This method copies the character index array into a caller supplied array.
 
347
     * The caller must ensure that the array is large enough to hold a
 
348
     * character index for each glyph.
 
349
     *
 
350
     * @param charIndices - the destiniation character index array
 
351
     * @param success - set to an error code if the operation fails
 
352
     */
353
353
    void getCharIndices(le_int32 charIndices[], LEErrorCode &success) const
354
354
    {
355
 
                if LE_FAILURE(success) {
356
 
                        return;
357
 
                }
358
 
 
359
 
                if (charIndices == NULL) {
360
 
                        success = LE_ILLEGAL_ARGUMENT_ERROR;
361
 
                        return;
362
 
                }
363
 
 
364
 
                if (fCharIndices == NULL) {
365
 
                        success = LE_NO_LAYOUT_ERROR;
366
 
                        return;
367
 
                }
 
355
        if LE_FAILURE(success) {
 
356
            return;
 
357
        }
 
358
 
 
359
        if (charIndices == NULL) {
 
360
            success = LE_ILLEGAL_ARGUMENT_ERROR;
 
361
            return;
 
362
        }
 
363
 
 
364
        if (fCharIndices == NULL) {
 
365
            success = LE_NO_LAYOUT_ERROR;
 
366
            return;
 
367
        }
368
368
 
369
369
        LE_ARRAY_COPY(charIndices, fCharIndices, fGlyphCount);
370
370
    };
371
371
 
372
 
        /**
373
 
         * This method copies the character index array into a caller supplied array.
374
 
         * The caller must ensure that the array is large enough to hold a
375
 
         * character index for each glyph.
376
 
         *
377
 
         * @param charIndices - the destiniation character index array
378
 
         * @param indexBase - an offset which will be added to each index
379
 
         * @param success - set to an error code if the operation fails
380
 
         */
 
372
    /**
 
373
     * This method copies the character index array into a caller supplied array.
 
374
     * The caller must ensure that the array is large enough to hold a
 
375
     * character index for each glyph.
 
376
     *
 
377
     * @param charIndices - the destiniation character index array
 
378
     * @param indexBase - an offset which will be added to each index
 
379
     * @param success - set to an error code if the operation fails
 
380
     */
381
381
    void getCharIndices(le_int32 charIndices[], le_int32 indexBase, LEErrorCode &success) const;
382
382
 
383
 
        /**
384
 
         * This method copies the position array into a caller supplied array.
385
 
         * The caller must ensure that the array is large enough to hold an
386
 
         * X and Y position for each glyph, plus an extra X and Y for the
387
 
         * advance of the last glyph.
388
 
         *
389
 
         * @param glyphs - the destiniation position array
390
 
         * @param success - set to an error code if the operation fails
391
 
         */
 
383
    /**
 
384
     * This method copies the position array into a caller supplied array.
 
385
     * The caller must ensure that the array is large enough to hold an
 
386
     * X and Y position for each glyph, plus an extra X and Y for the
 
387
     * advance of the last glyph.
 
388
     *
 
389
     * @param glyphs - the destiniation position array
 
390
     * @param success - set to an error code if the operation fails
 
391
     */
392
392
    void getGlyphPositions(float positions[], LEErrorCode &success) const
393
393
    {
394
 
                if LE_FAILURE(success) {
395
 
                        return;
396
 
                }
397
 
 
398
 
                if (positions == NULL) {
399
 
                        success = LE_ILLEGAL_ARGUMENT_ERROR;
400
 
                        return;
401
 
                }
402
 
 
403
 
                if (fPositions == NULL) {
404
 
                        success = LE_NO_LAYOUT_ERROR;
405
 
                        return;
406
 
                }
 
394
        if LE_FAILURE(success) {
 
395
            return;
 
396
        }
 
397
 
 
398
        if (positions == NULL) {
 
399
            success = LE_ILLEGAL_ARGUMENT_ERROR;
 
400
            return;
 
401
        }
 
402
 
 
403
        if (fPositions == NULL) {
 
404
            success = LE_NO_LAYOUT_ERROR;
 
405
            return;
 
406
        }
407
407
 
408
408
        LE_ARRAY_COPY(positions, fPositions, fGlyphCount * 2 + 2);
409
409
    };
410
410
 
411
 
        /**
412
 
         * This method returns the X and Y position of the glyph at
413
 
         * the given index.
414
 
         *
415
 
         * Input parameters:
416
 
         * @param glyphIndex - the index of the glyph
417
 
         *
418
 
         * Output parameters:
419
 
         * @param x - the glyph's X position
420
 
         * @param y - the glyph's Y position
421
 
         * @param success - set to an error code if the operation fails
422
 
         *
423
 
         */
 
411
    /**
 
412
     * This method returns the X and Y position of the glyph at
 
413
     * the given index.
 
414
     *
 
415
     * Input parameters:
 
416
     * @param glyphIndex - the index of the glyph
 
417
     *
 
418
     * Output parameters:
 
419
     * @param x - the glyph's X position
 
420
     * @param y - the glyph's Y position
 
421
     * @param success - set to an error code if the operation fails
 
422
     *
 
423
     */
424
424
    void getGlyphPosition(le_int32 glyphIndex, float &x, float &y, LEErrorCode &success) const
425
425
    {
426
 
                if (LE_FAILURE(success)) {
427
 
                        return;
428
 
                }
429
 
 
430
 
                if (glyphIndex > fGlyphCount) {
431
 
                        success = LE_INDEX_OUT_OF_BOUNDS_ERROR;
432
 
                        return;
433
 
                }
434
 
 
435
 
                if (fPositions == NULL) {
436
 
                        success = LE_NO_LAYOUT_ERROR;
437
 
                        return;
438
 
                }
 
426
        if (LE_FAILURE(success)) {
 
427
            return;
 
428
        }
 
429
 
 
430
        if (glyphIndex > fGlyphCount) {
 
431
            success = LE_INDEX_OUT_OF_BOUNDS_ERROR;
 
432
            return;
 
433
        }
 
434
 
 
435
        if (fPositions == NULL) {
 
436
            success = LE_NO_LAYOUT_ERROR;
 
437
            return;
 
438
        }
439
439
 
440
440
        x = fPositions[glyphIndex * 2];
441
 
                y = fPositions[glyphIndex * 2 + 1];
 
441
        y = fPositions[glyphIndex * 2 + 1];
442
442
    };
443
443
 
444
 
        /**
445
 
         * This method frees the glyph, character index and position arrays
446
 
         * so that the LayoutEngine can be reused to layout a different
447
 
         * characer array. (This method is also called by the destructor)
448
 
         */
 
444
    /**
 
445
     * This method frees the glyph, character index and position arrays
 
446
     * so that the LayoutEngine can be reused to layout a different
 
447
     * characer array. (This method is also called by the destructor)
 
448
     */
449
449
    virtual void reset();
450
 
    
451
 
        /**
452
 
         * This method returns a LayoutEngine capable of laying out text
453
 
         * in the given font, script and langauge. Note that the LayoutEngine
454
 
         * returned may be a subclass of LayoutEngine.
455
 
         *
456
 
         * @param fontInstance - the font of the text
457
 
         * @param scriptCode - the script of the text
458
 
         * @param langaugeCode - the language of the text
459
 
         * @param success - output parameter set to an error code if the operation fails
460
 
         *
461
 
         * @return a LayoutEngine which can layout text in the given font.
462
 
         *
463
 
         * @see LEFontInstance
464
 
         */
 
450
 
 
451
    /**
 
452
     * This method returns a LayoutEngine capable of laying out text
 
453
     * in the given font, script and langauge. Note that the LayoutEngine
 
454
     * returned may be a subclass of LayoutEngine.
 
455
     *
 
456
     * @param fontInstance - the font of the text
 
457
     * @param scriptCode - the script of the text
 
458
     * @param langaugeCode - the language of the text
 
459
     * @param success - output parameter set to an error code if the operation fails
 
460
     *
 
461
     * @return a LayoutEngine which can layout text in the given font.
 
462
     *
 
463
     * @see LEFontInstance
 
464
     */
465
465
    static LayoutEngine *layoutEngineFactory(const LEFontInstance *fontInstance, le_int32 scriptCode, le_int32 languageCode, LEErrorCode &success);
466
 
    
 
466
 
467
467
};
468
468
 
469
469
U_NAMESPACE_END