summaryrefslogtreecommitdiff
path: root/include/freetype/ftlayout.h
blob: e6fe4bf8e79653ff26727ec7de30ea1ed6a247be (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
/***************************************************************************/
/*                                                                         */
/*  ftltypes.h                                                             */
/*                                                                         */
/*    FreeType Layout API  (specification)                                 */    
/*                                                                         */
/*  Copyright 2003 by                                                      */
/*  Masatake YAMATO and Redhat K.K.                                        */
/*                                                                         */
/*  This file may only be used,                                            */
/*  modified, and distributed under the terms of the FreeType project      */
/*  license, LICENSE.TXT.  By continuing to use, modify, or distribute     */
/*  this file you indicate that you have read the license and              */
/*  understand and accept it fully.                                        */
/*                                                                         */
/***************************************************************************/

/***************************************************************************/
/* Development of the code in this file is support of                      */
/* Information-technology Promotion Agency, Japan.                         */
/***************************************************************************/

#ifndef __FTL_LAYOUT_H_
#define __FTL_LAYOUT_H_

#include <ft2build.h>
#include FT_FREETYPE_H

FT_BEGIN_HEADER

  /*************************************************************************/
  /*                                                                       */
  /* <Section>                                                             */
  /*    text_layout                                                        */
  /*                                                                       */
  /* <Title>                                                               */
  /*    Text Layout                                                        */
  /*                                                                       */
  /* <Abstract>                                                            */
  /*    Generic text layout functions.                                     */
  /*                                                                       */
  /* <Description>                                                         */
  /*    The following types and functions are used in text layout.         */
  /*    FTLayout is a layout engine stacked on FreeType2.  Currently       */
  /*    TrueTypeGX/AAT is supported as a file format.  OpenType is also    */
  /*    supported, but highly experimental.                                */
  /*    FTLayout provides an abstract interface which is shared by a       */
  /*    layout engine(GXLayout) for TrueTypeGX/AAT and a layout engine     */
  /*    (OTLayout)for OpenType for glyph substitution, one of the text     */
  /*    layout function.                                                   */
  /*                                                                       */
  /*************************************************************************/

  /*************************************************************************/
  /*                                                                       */
  /* <Type>                                                                */
  /*    FTL_FeaturesRequest                                                */
  /*                                                                       */
  /* <Description>                                                         */
  /*    An opaque data type to specify which font features are used in     */
  /*    text layout.                                                       */
  /*                                                                       */
  /*    Use @FTL_New_FeaturesRequest to create from a face and             */
  /*    @FTL_Done_FeaturesRequest to discard. The way to specify the font  */
  /*    features' settting depenes on the concrete font engine behind the  */
  /*    face.                                                              */
  /*                                                                       */
  typedef struct FTL_FeaturesRequestRec_ * FTL_FeaturesRequest;

  /*************************************************************************/
  /*                                                                       */
  /* <Type>                                                                */
  /*    FTL_GlyphArray                                                   */
  /*                                                                       */
  /* <Description>                                                         */
  /*    Data type represents glyphs array used in glyph substitution.      */
  /*    See @FTL_GlyphRec for more detail.                                 */
  /*                                                                       */
  typedef struct FTL_GlyphArrayRec_    * FTL_GlyphArray;

  /*************************************************************************/
  /*                                                                       */
  /* <Enum>                                                                */
  /*   FTL_EngineType                                                      */
  /*                                                                       */
  /* <Description>                                                         */
  /*   An enumeration representing the concrete text layout engine type.   */
  /*   You can get the value for a given face, use @FTL_Query_EngineType.  */
  /*                                                                       */
  /* <Values>                                                              */
  /*   FTL_NO_ENGINE ::                                                    */
  /*     No text layout engine behind the face.                            */
  /*                                                                       */
  /*   FTL_OPENTYPE_ENGINE ::                                              */
  /*     OpneType layout engine. You should use the interface declared in  */
  /*     otlayout.h.                                                       */
  /*                                                                       */
  /*   FTL_TRUETYPEGX_ENGINE ::                                            */
  /*     TrueTypeGX/AAT layout engine. You should use the interface        */
  /*     declared in gxlayout.h.                                           */
  /*                                                                       */
  typedef enum
  {
    FTL_NO_ENGINE         = 0,
    FTL_OPENTYPE_ENGINE   = 1,		/* Use otlayout.h */
    FTL_TRUETYPEGX_ENGINE = 2		/* Use gxlayout.h */
  } FTL_EngineType;

  /*************************************************************************/
  /*                                                                       */
  /* <Enum>                                                                */
  /*    FTL_Direction                                                      */
  /*                                                                       */
  /* <Description>                                                         */
  /*    An enumeration representing the text layout direction.             */
  /*                                                                       */
  /*    You can set the direction value to a features request by           */
  /*    @FTL_Set_FeaturesRequest_Direction. You can get the direction      */
  /*    value from a features request by                                   */
  /*    @FTL_Get_FeaturesRequest_Direction.                                */
  /*                                                                       */
  /* <Values>                                                              */
  /*   FTL_HORIZONTAL ::                                                   */
  /*     Value representing horizontal writing.                            */
  /*                                                                       */
  /*   FTL_VERTICAL ::                                                     */
  /*     Value representing vertical writing.                              */
  /*                                                                       */      
  typedef enum 
  { 
    FTL_HORIZONTAL = 0,  
    FTL_VERTICAL   = 1
  } FTL_Direction;

  /*************************************************************************/
  /*                                                                       */
  /* <Struct>                                                              */
  /*   FTL_GlyphRec                                                        */
  /*                                                                       */
  /* <Description>                                                         */
  /*    Data type represents a glyph id used in glyph substitution.        */
  /*                                                                       */
  /* <Fields>                                                              */
  /*    gid     :: The glyph id. If gid is 0xFFFF, this element in an      */
  /*               glyph array should be ignored.                          */
  /*                                                                       */
  /*    ot_prop :: Glyph's property used in OTLayout substitution.         */
  /*                       GXLayout does not use this field.               */
  /*                                                                       */
  typedef struct FTL_GlyphRec_
  {
    FT_UShort gid;
    FT_UShort reserved1;
    FT_ULong  ot_prop;
    FT_ULong  reserved2;
  } FTL_GlyphRec, * FTL_Glyph;

  /*************************************************************************/
  /*                                                                       */
  /* <Struct>                                                              */
  /*   FTL_Glyph_ArrayRec_                                                 */
  /*                                                                       */
  /* <Description>                                                         */
  /*    Data type represents glyphs array used in glyph substitution.      */
  /*                                                                       */
  /*    This data type is used as input and output arguments for           */
  /*    @FTL_Substitute_Glyphs.                                            */
  /*    @FTL_New_Glyphs_Array allocates 0 length FTL_GlyphRec object.      */
  /*    @FTL_Set_Glyphs_Array_Length sets the length of FTL_GlyphRec       */
  /*    object. You have to set the length to create an input glyph array  */
  /*    for substitution.                                                  */
  /*                                                                       */
  /* <Fields>                                                              */
  /*    memory    :: The current memory object which handles the glyph     */
  /*                 arrray.                                               */
  /*                                                                       */
  /*    glyphs    :: Glyphs ids' array.                                    */
  /*                                                                       */
  /*    length    :: The valid length of glyphs.                           */
  /*                                                                       */
  /*    allocated :: The allocation size of glyphs. The client should not  */
  /*                 refer this field.                                     */
  /*                                                                       */
  typedef struct FTL_GlyphArrayRec_
  {
    FT_Memory   memory;
    FTL_Glyph   glyphs;
    /* FT_ULong    pos; */
    FT_ULong    reserved1;
    FT_ULong    length;
    FT_ULong    allocated;
  } FTL_GlyphArrayRec;


  /*************************************************************************/
  /*                                                                       */
  /* <Function>                                                            */
  /*    FTL_Query_EngineType                                               */
  /*                                                                       */
  /* <Description>                                                         */
  /*    Returns the text layout engine type behind a face.                 */
  /*                                                                       */
  /* <Input>                                                               */
  /*    face        :: The target face.                                    */
  /*                                                                       */
  /* <Output>                                                              */
  /*    engine_type :: The type of text layout engine for the face.        */
  /*                                                                       */
  /* <Return>                                                              */
  /*    FreeType error code.  0 means success.                             */
  /*                                                                       */
  FT_EXPORT( FT_Error )
  FTL_Query_EngineType                  ( FT_Face face, 
					  FTL_EngineType * engine_type);

  /*************************************************************************/
  /*                                                                       */
  /* <Function>                                                            */
  /*    FTL_New_FeaturesRequest                                            */
  /*                                                                       */
  /* <Description>                                                         */
  /*    Creates a new features request for a face.                         */
  /*                                                                       */
  /* <Input>                                                               */
  /*    face    :: The target face.                                        */
  /*                                                                       */
  /* <Output>                                                              */
  /*    request :: A features request for a face.                          */
  /*                                                                       */
  /* <Return>                                                              */
  /*    FreeType error code.  0 means success.                             */
  /*                                                                       */
  /* <Note>                                                                */
  /*    When the target face is discarded by @FT_Done_Face, all features   */
  /*    requests corresponding to the face are also discardeded            */
  /*    automatically.                                                     */
  /*                                                                       */
  FT_EXPORT( FT_Error )
  FTL_New_FeaturesRequest               ( FT_Face face, 
					  FTL_FeaturesRequest* request);

  /*************************************************************************/
  /*                                                                       */
  /* <Function>                                                            */
  /*    FTL_Done_FeaturesRequest                                           */
  /*                                                                       */
  /* <Description>                                                         */
  /*    Discards a features request.                                       */
  /*                                                                       */
  /* <Input>                                                               */
  /*    request :: A features request.                                     */
  /*                                                                       */
  /* <Return>                                                              */
  /*    FreeType error code.  0 means success.                             */
  /*                                                                       */
  FT_EXPORT( FT_Error )
  FTL_Done_FeaturesRequest              ( FTL_FeaturesRequest request );

  /*************************************************************************/
  /*                                                                       */
  /* <Function>                                                            */
  /*    FTL_Activate_FeaturesRequest                                       */
  /*                                                                       */
  /* <Description>                                                         */
  /*    Even though it is possible to create serveral features request     */
  /*    object for a given face (see @FTL_New_FeaturesRequest),            */
  /*    @FTL_Substitute_Glyphs only use the last activated request.        */
  /*    With this function, a features request can be activated.           */
  /*                                                                       */
  /* <Input>                                                               */
  /*    request :: A features request to be activated.                     */
  /*                                                                       */
  /* <Return>                                                              */
  /*    FreeType error code.  0 means success.                             */
  /*                                                                       */
  FT_EXPORT ( FT_Error )
  FTL_Activate_FeaturesRequest          ( FTL_FeaturesRequest request );

  /*************************************************************************/
  /*                                                                       */
  /* <Function>                                                            */
  /*    FTL_Copy_FeaturesRequest                                           */
  /*                                                                       */
  /* <Description>                                                         */
  /*    Copy the setting of one features request to another.               */ 
  /*                                                                       */
  /* <Input>                                                               */
  /*    from :: The source features request.                               */
  /*                                                                       */
  /* <Output>                                                              */
  /*    to   :: The destination features request. This must be created by  */
  /*            @FTL_New_FeaturesRequest before copying.                   */
  /* <Return>                                                              */
  /*    FreeType error code.  0 means success.                             */
  /*                                                                       */
  /* <Note>                                                                */
  /*    from and to must be created from the same face.                    */
  /*                                                                       */
  FT_EXPORT( FT_Error )
  FTL_Copy_FeaturesRequest              ( FTL_FeaturesRequest from,  
					  FTL_FeaturesRequest to );

  /*************************************************************************/
  /*                                                                       */
  /* <Function>                                                            */
  /*    FTL_Reset_FeaturesRequest                                          */
  /*                                                                       */
  /* <Description>                                                         */
  /*    Resets the settings of a features request. In other word set a     */ 
  /*    features request to default settings.                              */
  /*                                                                       */
  /* <Input>                                                               */
  /*    request :: A features request to be reseted.                       */
  /*                                                                       */
  /* <Return>                                                              */
  /*    FreeType error code.  0 means success.                             */
  /*                                                                       */
  FT_EXPORT( FT_Error )
  FTL_Reset_FeaturesRequest             ( FTL_FeaturesRequest request );


  /*************************************************************************/
  /*                                                                       */
  /* <Function>                                                            */
  /*    FTL_Get_FeaturesRequest_Direction                                  */
  /*                                                                       */
  /* <Description>                                                         */
  /*    Returns the writing direction in a features request.               */ 
  /*                                                                       */
  /* <Input>                                                               */
  /*    request :: A features request.                                     */
  /*                                                                       */
  /* <Return>                                                              */
  /*    The writing direction.                                             */
  /*                                                                       */
  FT_EXPORT ( FTL_Direction )
  FTL_Get_FeaturesRequest_Direction     ( FTL_FeaturesRequest request );

  /*************************************************************************/
  /*                                                                       */
  /* <Function>                                                            */
  /*    FTL_Set_FeaturesRequest_Direction                                  */
  /*                                                                       */
  /* <Description>                                                         */
  /*    Sets the writing direction to a features request.                   */ 
  /*                                                                       */
  /* <Input>                                                               */
  /*    request   :: A features request.                                   */
  /*                                                                       */
  /*    direction :: Writing direction.                                    */
  /*                                                                       */
  FT_EXPORT ( void )
  FTL_Set_FeaturesRequest_Direction     ( FTL_FeaturesRequest request,  
					  FTL_Direction direction);

  /*************************************************************************/
  /*                                                                       */
  /* <Function>                                                            */
  /*    FTL_New_Glyphs_Array                                               */
  /*                                                                       */
  /* <Description>                                                         */
  /*    Creates an empty glyphs array.                                     */
  /*                                                                       */
  /* <Input>                                                               */
  /*    momory ::  A memory object from which a glyphs array is allocated. */
  /*                                                                       */
  /* <Output>                                                              */
  /*    garray ::  A glyphs array.                                         */
  /*                                                                       */
  /* <Return>                                                              */
  /*    FreeType error code.  0 means success.                             */
  /*                                                                       */
  /* <Note>                                                                */
  /*    The lengoth of newly allocated glyphs array is 0. Set the length   */
  /*    by @FTL_Set_Glyphs_Array_Length after allocating if you need.      */
  /*                                                                       */
  FT_EXPORT( FT_Error )
  FTL_New_Glyphs_Array                  ( FT_Memory memory,
					  FTL_GlyphArray * garray );

  /*************************************************************************/
  /*                                                                       */
  /* <Function>                                                            */
  /*    FTL_Set_Glyphs_Array_Length                                        */
  /*                                                                       */
  /* <Description>                                                         */
  /*    Sets the length of a glyphs array.                                  */
  /*                                                                       */
  /* <Input>                                                               */
  /*    length ::  New glyphs array length.                                */
  /*                                                                       */
  /* <InOut>                                                               */
  /*    garray ::  A glyphs array.                                         */
  /*                                                                       */
  /* <Return>                                                              */
  /*    FreeType error code.  0 means success.                             */
  /*                                                                       */
  FT_EXPORT( FT_Error )
  FTL_Set_Glyphs_Array_Length           ( FTL_GlyphArray garray,
					  FT_ULong new_length );

  /*************************************************************************/
  /*                                                                       */
  /* <Function>                                                            */
  /*    FTL_Copy_Glyphs_Array                                              */
  /*                                                                       */
  /* <Description>                                                         */
  /*    Copies glyphs array.                                               */
  /*                                                                       */
  /* <Input>                                                               */
  /*    in  ::  The source glyphs array.                                   */
  /*                                                                       */
  /* <Output>                                                              */
  /*    out ::  The destination glyphs array.                              */
  /*                                                                       */
  /* <Return>                                                              */
  /*    FreeType error code.  0 means success.                             */
  /*                                                                       */
  FT_EXPORT( FT_Error )
  FTL_Copy_Glyphs_Array                 ( FTL_GlyphArray in,
					  FTL_GlyphArray out );

  /*************************************************************************/
  /*                                                                       */
  /* <Function>                                                            */
  /*    FTL_Done_Glyphs_Array                                              */
  /*                                                                       */
  /* <Description>                                                         */
  /*    Discards a glyphs array.                                           */
  /*                                                                       */
  /* <Input>                                                               */
  /*    garray  ::  A glyphs array.                                        */
  /*                                                                       */
  /* <Return>                                                              */
  /*    FreeType error code.  0 means success.                             */
  /*                                                                       */
  FT_EXPORT( FT_Error )
  FTL_Done_Glyphs_Array                 ( FTL_GlyphArray garray );


  /*************************************************************************/
  /*                                                                       */
  /* <Function>                                                            */
  /*    FTL_Substitute_Glyphs                                              */
  /*                                                                       */
  /* <Description>                                                         */
  /*    Substitutes glyphs based on the rule specified by the current      */
  /*    activated features request.                                        */
  /*                                                                       */
  /* <Input>                                                               */
  /*    face ::  A face which has substitution tables.                     */
  /*                                                                       */
  /*    in   ::  Input glyphs array.                                       */  
  /*                                                                       */
  /* <Output>                                                              */
  /*    out  ::  Output(substituted) glyphs array. The length of glyphs    */
  /*             are automatically extended.                               */
  /* <Return>                                                              */
  /*    FreeType error code.  0 means success.                             */
  /*                                                                       */
  FT_EXPORT( FT_Error )
  FTL_Substitute_Glyphs                 ( FT_Face face,
					  FTL_GlyphArray in,
					  FTL_GlyphArray out );

  /*************************************************************************/
  /*                                                                       */
  /* <Function>                                                            */
  /*    FTL_Get_LigatureCaret_Count                                        */
  /*                                                                       */
  /* <Description>                                                         */
  /*    Returns the number of ligature divisions for a given glyph.        */
  /*                                                                       */
  /* <Input>                                                               */
  /*    face    :: A face.                                                 */
  /*                                                                       */
  /*    glyphID :: The target glyph's id.                                  */
  /*                                                                       */
  /* <Return>                                                              */
  /*    The number of ligature divisions. If the glyph is not ligatured    */
  /*    glyph, returns 0.                                                  */
  /*                                                                       */
  FT_EXPORT( FT_UShort )
  FTL_Get_LigatureCaret_Count           ( FT_Face face, FT_UShort glyphID );

  /*************************************************************************/
  /*                                                                       */
  /* <Function>                                                            */
  /*    FTL_Get_LigatureCaret_Division                                     */
  /*                                                                       */
  /* <Description>                                                         */
  /*    Returns the point of Nth ligature divisions for a given glyph.     */
  /*                                                                       */
  /* <Input>                                                               */
  /*    face    :: A face.                                                 */
  /*                                                                       */
  /*    glyphID :: The target glyph's id.                                  */
  /*                                                                       */
  /*    nth     :: The index of ligature divisions.                        */
  /*                                                                       */
  /* <Return>                                                              */
  /*    The point of a ligature division. If the glyph is not ligatured    */
  /*    glyph, returns 0.                                                  */
  /*                                                                       */
  FT_EXPORT( FT_UShort )
  FTL_Get_LigatureCaret_Division        ( FT_Face face, 
					  FT_UShort glyphID, 
					  FT_UShort nth );

FT_END_HEADER

#endif	/* Not def: __FTL_LAYOUT_H_ */


/* END */