summaryrefslogtreecommitdiff
path: root/Build/source/libs/freetype/freetype-1.5/docs/apirefx.txt
blob: 19bc7d9feb3fd0b605c138113a40b1d6c9eef7bb (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
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
                        The FreeType Engine

                    Extension Library Reference


                -----------------------------------


  Table of Contents:

    I. Engine extensions
      1. kerning (ftxkern)
      2. PostScript names (ftxpost)
      3. TrueType Open (ftxopen)
         a. The `BASE' table (baseline data)
         b. The `GDEF' table (glyph definitions)
         c. The `GPOS' table (glyph positions)
         d. The `GSUB' table (glyph substitions)
         e. The `JSTF' table (justification data)
         f. auxiliary functions
      4. embedded bitmaps (ftxsbit)

    II. API extensions
      1. cmap iteration (ftxcmap)
      2. internationalized error messages (ftxerr18)
      3. access to the `gasp' table (ftxgasp)
      4. fast retrieval of glyph widths and heights (ftxwidth)

    III. Error codes


                        --------------------


Please read the file  `user.txt' for an introduction into FreeType's
extension  mechanism  and  the  difference between  engine  and  API
extensions.


I. Engine extensions
====================

To use  engine extensions you have  to compile the  library with the
macro TT_CONFIG_OPTION_EXTEND_ENGINE.  By default, this macro is set
and all engine extensions are linked to the FreeType library.


 1. kerning (ftxkern)
 --------------------

  TT_Init_Kerning_Extension( TT_Engine  engine )

    Initializes the kerning extension for a given engine.  This must
    be called  just after the  engine creation, and before  any face
    object allocation.  Example:

      TT_Init_FreeType( &engine );
      TT_Init_Kerning_Extension( engine );

  ..................................................................

  TT_Get_Kerning_Directory( TT_Face      face,
                            TT_Kerning*  directory )

    Queries the  kerning directory  found in a  face object.   If no
    kerning  table  is  found   in  the  TrueType  file,  the  error
    TT_Err_Table_Is_Missing will be returned.

    You  can  access  the  subtables  through the  pointers  of  the
    directory.  However, by default, the directory is only loaded if
    a  face object  is created.   You must  load the  subtables that
    interest you with a call to TT_Load_Kerning_Table().

    The  layout of  all kerning  structures is  defined in  the file
    `lib/extend/ftxkern.h'.   Formats 0  and  2 (as  defined in  the
    Microsoft TrueType specification) are exposed by this API.

    NOTE:

      This function  must be called after the  kerning extension has
      been initialized.

  ..................................................................

  TT_Load_Kerning_Table( TT_Face    face,
                         TT_UShort  kernIndex )

    Loads the kerning subtable number `kern_index' into memory.  The
    subtable can  be accessed through  the pointers provided  by the
    kerning  directory,  obtained  from   a  call  to  the  function
    TT_Get_Kerning_Directory().

    Note that the interpretation of  the kerning data is left to the
    client  application.  Read the  TrueType specification  for more
    information on kerning encoding.

    NOTE 1:

      This function must be  called after the kerning extension were
      initialized.

    NOTE 2:

      An example can be found in the file `test/ftstrtto.c'.


====================================================================


 2. PostScript names (ftxpost)
 -----------------------------

  TT_Init_Post_Extension( TT_Engine  engine )

    Initializes the PostScript name extension to load the PostScript
    glyph names given in the `post' table.  This must be called just
    after  creation  of  the  engine,  and before  any  face  object
    allocation.  See description of TT_Get_PS_Name() for an example.

  ..................................................................

  TT_Load_PS_Names( TT_Face   face,
                    TT_Post*  post )

    Loads the PostScript glyph names into memory.  This must be done
    before  TT_Get_PS_Name() is  called.  In  case of  error, either
    TT_Err_Invalid_Post_Table or TT_Err_Invalid_Post_Table_Format is
    returned.  See description of TT_Get_PS_Name() for an example.

  ..................................................................

  TT_Get_PS_Name( TT_Face      face,
                  TT_UShort    index,
                  TT_String**  PSname )

    Get  the PostScript  glyph  name  for a  given  glyph index.   A
    pointer to the name is returned in `PSname'.  Example:

      ...
      TT_Post  post;
      char*    PSname;

      ...
      TT_Init_Post_Extension( engine );
      TT_Load_PS_Names( face, &post );

      ...
      TT_Get_PS_Name( face, index, &PSname );


    NOTE 1:

      You must  not alter the PostScript glyph  name string returned
      in `PSname'.

    NOTE 2:

      Some standard names sometimes present some variations, as:

          Omega vs. Ohm
          Delta vs. increment
          macron vs. overscore
          mu vs. mu1
          periodcentered vs. middot

      We always return  the first  listed name,  which correspond to
      the  last version  of the TrueType  specifications  (which did
      vary in the past on this respect).  You may have to adjust the
      source (in  lib/extend/ftxpost.c)  in order to interface  with
      some old applications.


====================================================================


 3. TrueType Open (ftxopen)
 --------------------------

  Please note that TrueType Open specific error codes have the
  prefix `TTO_Err_' instead of `TT_Err_'.

  a. The `BASE' table (baseline data)

    Not yet supported.

  b. The `GDEF' table (glyph definitions)

    TT_Init_GDEF_Extension( TT_Engine  engine )

      Initializes the  GDEF extension  to load the  glyph definition
      data  given in  the `GDEF'  table.  This  must be  called just
      after  creation of  the  engine, and  before  any face  object
      allocation.  See the file `ftstrtto.c' for an example.

    ................................................................

    TT_Load_GDEF_Table( TT_Face          face,
                        TTO_GDEFHeader*  gdef )

      Loads  the GDEF  table into  `gdef' for  a given  face `face'.
      This must  be done before  any queries about  glyph properties
      with TT_GSUB_Get_Property().   Returns TT_Err_Table_Missing if
      there is no GDEF table in the font.

    ................................................................

    TT_GDEF_Get_Glyph_Property( TTO_GDEFHeader*  gdef,
                                TT_UShort        glyphID,
                                TT_UShort*       property )

      Use  this function  to get  glyph properties  in  the variable
      `property' for  the glyph with  index `glyphID' stored  in the
      `gdef'  table.   This data  is  essential  for  many fonts  to
      correctly apply contextual  substitution (both GSUB and GPOS).
      As a special case, zero is assigned to `property' if `gdef' is
      NULL or  the glyph has  no special glyph property  assigned to
      it.   The  other return  values  of  `property' are  TTO_BASE,
      TTO_LIGATURE,  TTO_MARK, and  TTO_COMPONENT; you  can directly
      apply the `LookupFlag' mask to check for certain properties:

        TTO_GDEFHeader*  gdef;
        TTO_Lookup*      lo;
        TT_UShort        glyph_ID;
        TT_UShort        p;      


        TT_GDEF_Get_Property( gdef, glyph_ID, &p );

        if ( p & lo->LookupFlag )
          return TTO_Err_Not_Covered;

      Usually, you  don't need to  take care of glyph  properties by
      yourself since TT_GSUB_Apply_String() will  do this for you by
      calling TT_GDEF_Get_Property().

      Some  fonts need  GDEF-like  data  even if  no  GDEF table  is
      provided  (for example,  the Arabic  script  needs information
      which glyphs are  base glyphs and which are  mark glyphs).  In
      such cases, you  should use TT_GDEF_Build_ClassDefinition() to
      build the necessary  structures so that TT_GDEF_Get_Property()
      returns meaningful values.

      See also TT_Load_GSUB_Table() and TT_Load_GPOS_Table().

    ................................................................

    TT_GDEF_Build_ClassDefinition( TTO_GDEFHeader*  gdef,
                                   TT_UShort        num_glyphs,
                                   TT_UShort        glyph_count,
                                   TT_UShort*       glyph_array,
                                   TT_UShort*       class_array )

      Fills    a    `gdef'    structure    with   data    to    make
      TT_GDEF_Get_Property()   work  in  case   no  GDEF   table  is
      available.  `num_glyphs' is the  number of glyphs in the font.

      `glyph_count' is the number  of glyphs resp.  class values (as
      specified  in  the GDEF  specification)  given  in the  arrays
      `glyph_array'  and  `class_array',  respectively.   The  glyph
      indices in  `glyph_array' must be all different  and sorted in
      ascending  order;  the   function  expects  that  glyph  index
      `glyph_array[n]' has its class value in `class_array[n]'.

      Note that mark  attach classes as defined in  OpenType 1.2 are
      not supported for constructed GDEF tables.

      See `arabic.c' for an example.


  c. The `GPOS' table (glyph positionings)

    For glyph  positioning, a data  object of type  TTO_GPOS_Data is
    used.   The `x_pos'  and `y_pos'  fields contain  offsets  to be
    added to the glyph's  position; `x_advance' and `y_advance' hold
    values to be added to the horizonal and vertical advance widths,
    respectively.   If   `new_advance'  is  TRUE,   `x_advance'  and
    `y_advance'  are absolute,  i.e.,  they won't  be  added to  the
    original  glyph's value  but  rather replace  them.  All  offset
    values are given as fractional pixels.

    To position marks, `back' holds  the number of glyphs to go back
    for applying `x_pos' and `y_pos' (advance values are always zero
    in this case).  If the target glyph itself has a non-zero `back'
    value,  it is  necessary to  repeat this  process --  the offset
    values have to be accumulated then.

    As a consequence, it is necessary to track glyph positions.

      struct TTO_GPOS_Data_
      {
        TT_Pos     x_pos;
        TT_Pos     y_pos;
        TT_Pos     x_advance;
        TT_Pos     y_advance;
        TT_UShort  back;
        TT_Bool    new_advance;
      };

      typedef struct TTO_GPOS_Data_  TTO_GPOS_Data;

    Here some pseudo code to demonstrate the needed algorithm:

      TT_GSUB_Apply_String()
      TT_GPOS_Apply_String()
      collect_glyph_positions()  /* don't advance for marks */
                                 /* take care of kerning    */
                                 /* apply GPOS data         */

      for all glyphs do
      {
        if `back' == 0
          render_glyph_at_current_position()
        else
        {
          search_base_glyph()
          render_glyph_at_base_glyph_position()
        }
      }

    A real example can be found in ftstrtto.c.  Please note that the
    code in this test program  is not optimized; using a glyph cache
    could improve speed considerably.

    Contrary  to GSUB  handling,  GPOS needs  data  from the  glyphs
    itself.  Some formats of anchor tables (used e.g. to attach mark
    glyphs  to  base glyphs)  and  device  tables  refer to  contour
    points,  and   cursive  connections  need   advance  values  and
    dimensions of  the glyphs  if used vertically  (vertical cursive
    connections have  not been implemented  yet -- this is  the only
    omission of GPOS support currently).

    Two hooks  are defined to  get this data:  TTO_GlyphFunction and
    TTO_MMFunction.   The  former  defaults to  TT_Load_Glyph()  and
    should be replaced with a  similar function which caches data if
    necessary,  the  latter (to  access  data  from Multiple  Master
    fonts) defaults to an error message.

    GPOS handling must always be done *after* GSUB handling!

    ................................................................

    TT_Init_GPOS_Extension( TT_Engine  engine )

      Initializes the  GPOS extension to load  the glyph positioning
      data  given in  the `GPOS'  table.  This  must be  called just
      after  creation of  the  engine, and  before  any face  object
      allocation.   See the  files `ftstrtto.c'  and  `ftdump.c' for
      detailed examples.

    ................................................................

    TT_Load_GPOS_Table( TT_Face          face,
                        TTO_GPOSHeader*  gpos,
                        TTO_GDEFHeader*  gdef )

      Loads  the GPOS  table into  `gpos' for  a given  face `face'.
      This must  be done  before any queries  about or  selection of
      scripts,      languages,      and      features.       Returns
      TT_Err_Table_Missing if there is no GPOS table in the font.

      `gdef' should  contain a pointer to an  associated GDEF table,
      either  a  native  one  loaded  with  TT_Load_GDEF_Table()  or
      emulated  with TT_GDEF_Build_ClassDefinition().  If  `gdef' is
      set to NULL, no GDEF data will be used.

    ................................................................

    TT_GPOS_Select_Script( TTO_GPOSHeader*  gpos,
                           TT_ULong         script_tag,
                           TT_UShort*       script_index )

      This  function sets  the script  index of  a given  script tag
      `script_tag' in the variable `script_index' for the GPOS table
      `gpos'.  Returns TTO_Err_Not_Covered  if the script tag cannot
      be found.  The  available script tags can be  queried with the
      function TT_GPOS_Query_Scripts().

    ................................................................

    TT_GPOS_Select_Language( TTO_GPOSHeader*  gpos,
                             TT_ULong         language_tag,
                             TT_UShort        script_index,
                             TT_UShort*       language_index,
                             TT_UShort*       req_feature_index )

      This function sets the language  index of a given language tag
      `language_tag' and script index `script_index' in the variable
      `language_index'   for  the   GPOS   table  `gpos'.    Returns
      TTO_Err_Not_Covered if the language  tag cannot be found.  The
      available  language  tags can  be  queried  with the  function
      TT_GPOS_Query_Languages().

      Additionally,  the  index of  the  required  feature for  this
      language system is returned in `req_feature_index'; it must be
      later registered for use with TT_GPOS_Add_Feature().

    ................................................................

    TT_GPOS_Select_Feature( TTO_GPOSHeader*  gpos,
                            TT_ULong         feature_tag,
                            TT_UShort        script_index,
                            TT_UShort        language_index,
                            TT_UShort*       feature_index )

      This  function  sets  the  feature  index  of  a  feature  tag
      `feature_tag', script index `script_index', and language index
      `language_index' in the  variable `feature_index' for the GPOS
      table `gpos'.  Returns  TTO_Err_Not_Covered if the feature tag
      cannot be  found.  The available  feature tags can  be queried
      with    the   function    TT_GPOS_Query_Features().    Setting
      language_index to 0xFFFF selects the default language system.

    ................................................................

    TT_GPOS_Query_Scripts( TTO_GPOSHeader*  gpos,
                           TT_ULong**       script_tag_list )

      Returns  the available  script  tags for  a  given GPOS  table
      `gpos' in the array `script_tag_list'.  The array can be later
      deallocated with free().

    ................................................................

    TT_GPOS_Query_Languages( TTO_GPOSHeader*  gpos,
                             TT_UShort        script_index,
                             TT_ULong**       language_tag_list )

      Returns  the available language  tags for  a given  GPOS table
      `gpos'   and  script   index  `script_index'   in   the  array
      `language_tag_list'.  The array  can be later deallocated with
      free().

    ................................................................

    TT_GPOS_Query_Features( TTO_GPOSHeader*  gpos,
                            TT_UShort        script_index,
                            TT_UShort        language_index,
                            TT_ULong**       feature_tag_list )

      Returns  the available  feature tags  for a  given  GPOS table
      `gpos',  script  index   `script_index',  and  language  index
      `language_index' in the array `feature_tag_list'.  If language
      index is  set to 0xFFFF,  the values for the  default language
      system are returned.  The  array can be later deallocated with
      free().

    ................................................................

    TT_GPOS_Add_Feature( TTO_GPOSHeader*  gpos,
                         TT_UShort        feature_index,
                         TT_UShort        property )

      To  prepare  a  call  to TT_GPOS_Apply_String()  which  should
      process  a given  feature with  index `feature_index'  and the
      property `property', you must  use this function.  Its task is
      to  mark the  lookup tables  used by  the feature  for further
      processing.

      `property'  defines a  relationship between  the  input string
      object and the specific  feature.  The client must handle this
      variable as a bit field, i.e., up to 16 user properties can be
      defined.  If `property' is set to ALL_GLYPHS (0xFFFF, the only
      predefined value),  or if the  input string object has  no set
      bits  in the `properties'  field, the  feature applies  to all
      glyphs.  If bit `x' is  set in `property', the feature applies
      only  to  glyphs  which  have  bit  `x'  not  set  in  glyph's
      `properties'   field  in   the  input   string   object.   See
      TT_GPOS_Apply_String() for an example.

      Returns TT_Err_Invalid_Argument in case of error.

    ................................................................

    TT_GPOS_Clear_Features( TTO_GPOSHeader*  gpos )

      Clears the  list of used  features and properties.   No lookup
      tables will be processed.

    ................................................................

    TT_GPOS_Register_Glyph_Function( TTO_GPOSHeader*    gpos,
                                     TTO_GlyphFunction  gfunc );

      Installs  a  function  `gfunc'   which  loads  a  glyph.   Its
      parameters are the same as  in a call to TT_Load_Glyph() -- if
      no   glyph   loading   function   will  be   registered   with
      TTO_GPOS_Register_Glyph_Function(),  TT_Load_Glyph()  will  be
      called indeed.  The  purpose of this function is  to provide a
      hook  for   caching  glyph  outlines  and   sbits  (using  the
      instance's generic pointer to hold the data).

      If for some  reason no outline data is  available (e.g. for an
      embedded bitmap glyph), _glyph->outline.n_points should be set
      to zero.  _glyph can be computed with

        _glyph = HANDLE_Glyph( glyph )

      `gfunc' is defined as 

        typedef TT_Error
                (*TTO_GlyphFunction)(TT_Instance  instance,
                                     TT_Glyph     glyph,
                                     TT_UShort    glyphIndex,
                                     TT_UShort    loadFlags );

    ................................................................

    TT_GPOS_Register_MM_Function( TTO_GPOSHeader*  gpos,
                                  TTO_MMFunction   mmfunc,
                                  void*            data );

      Installs  a function  `mmfunc' which  accesses  the PostScript
      interpreter.   Multiple Master  fonts need  this  interface to
      convert a metric ID (as stored in an OpenType font version 1.2
      or higher) into a metric value.

      `data' points  to a user-defined  structure which will  not be
      used by the  GPOS extension itself.  It is  passed directly to
      `mmfunc', which is defined as

        typedef TT_Error
                (*TTO_MMFunction)(TT_Instance  instance,
                                  TT_UShort    metric_id,
                                  TT_Pos*      metric_value,
                                  void*        data );

      `metric_value'  must  be  returned  as  a  scaled  value  (but
      shouldn't be rounded).

    ................................................................

    TT_GPOS_Apply_String( TT_Instance       instance,
                          TT_Glyph          glyph,
                          TTO_GPOSHeader*   gpos,
                          TT_Bool           load_flags,
                          TTO_GSUB_String*  in,
                          TTO_GPOS_Data**   out,
                          TT_Bool           dvi,
                          TT_Bool           r2l )

      This  is the  very  function which  handles glyph  positioning
      according to  the features set  up with TT_GPOS_Add_Feature(),
      using both GPOS and GDEF data (if defined).  A TTO_GSUB_String
      object `in' (see the  next section for a complete description)
      and a  TTO_GPOS_Data object array pointer  `out' (as described
      above)  are  taken  for  input and  output;  after  successful
      excecution, the GPOS data can  been found in `out'.  Note that
      the `out' array has in->length elements.

      `instance', `glyph',  and `load_flags' are  directly forwarded
      to      the      glyph      function      registered      with
      TTO_GPOS_Register_Glyph_Function().   Note   that  glyphs  are
      always loaded as scaled.

      If `dvi' is TRUE, `glyph'  is ignored completely.  Use this to
      get device independent positioning values.

      The parameter  `r2l' should  be set to  TRUE if you  process a
      right-to-left  script like  Arabic.   It is  used for  cursive
      connections only to compute correct advance values.

      Example:

        /* We assume that the feature `xxxx' has index 5, and  */
        /* feature `yyyy' has index 8, applying only to glyphs */
        /* with the property `FINAL_GLYPHS' set (0x1000 is an  */
        /* ad-hoc value just for this example).                */

        /* The order of calls to TT_GPOS_Add_Feature() is not  */
        /* significant.                                        */

        #define FINAL_GLYPHS  0x1000

        TTO_GPOS_DATA*  gd = NULL;


        TT_GPOS_Clear_Features( &gpos );
        TT_GPOS_Add_Feature( &gpos, 8, FINAL_GLYPHS );
        TT_GPOS_Add_Feature( &gpos, 5, ALL_GLYPHS );

        TT_GSUB_Apply_String( &gsub, &in, &out );
        TT_GPOS_Apply_String( instance, glyph, &gpos,
                              TTLOAD_HINT_GLYPH,
                              &out, &gd, 0, 0 );

      You  must  initialize the  `gd'  pointer  to NULL;  allocation
      necessary for  the `gd'  array will be  handled automatically.
      If necessary, you can use free() to deallocate `gd'.


  d. The `GSUB' table (glyph substitions)

    For glyph substitution, a  string object of type TTO_GSUB_String
    is used.   The field  `length' holds the  length of  the string,
    `pos' points to the actual position in the glyph string `string'
    (for  input strings)  resp. the  position where  the substituted
    glyphs should be placed at (for output strings).

    Within the  `properties' array (which must always  have the same
    length as `string' if set), you can define properties for glyphs
    -- `string[n]' is associated  with `properties[n]'.  The idea is
    that  some  features  apply  to  specific glyphs  only.   As  an
    example, the  `fina' feature for  Arabic applies only  to glyphs
    which  appear at  the end  of  a word  (strictly speaking,  this
    feature is used  only for glyphs which have  a `final' property;
    such glyphs can occur in the middle of a word also under certain
    circumstances which  is dependent on Arabic  script rules).  The
    relationship between properties and  features can be set up with
    the function  TT_GSUB_Add_Feature().  If `properties'  is set to
    NULL, all  selected features  apply to all  glyphs in  the given
    string object.  If `properties' is non-NULL, the elements of the
    array  are treated as  bit fields.   A set  flag means  that the
    corresponding  feature (as  set  with the  TT_GSUB_Add_Feature()
    function) should not  be applied to the particular  glyph.  As a
    consequence,  a zero  value for  these  16 bits  means that  all
    features should be  applied, and a value of  0xFFFF implies that
    no feature at all should be used for the glyph.

    The field `allocated'  is for internal use only  and must not be
    modified.   If its  value is  larger than  zero, you  should use
    free()  to   deallocate  the   memory  used  by   `string'  (and
    `properties'   if  set)   in  case   you  want   to   destroy  a
    TTO_GSUB_String object (memory  for `string' and `properties' is
    allocated  automatically  e.g.   by  TT_GSUB_Apply_String()  for
    output string objects).

      struct  TTO_GSUB_String_
      {
        TT_ULong    length;
        TT_ULong    pos;
        TT_ULong    allocated;
        TT_UShort*  string;
        TT_UShort*  properties;
      };

      typedef struct TTO_GSUB_String_  TTO_GSUB_String;

    Note  that the `string'  field must  contain glyph  indices, not
    character codes.

    For  initializing an  input string  object, you  should  set the
    `length', `string',  and `properties' fields (the  last one only
    if necessary) to appropriate values.  `pos' has to be set to the
    position  where the substitution  lookups should  start (usually
    zero).  The `allocated' field will be ignored.

    For  initializing an  output string  object, all  fields (except
    `length' which  will be  ignored) must be  set to zero.   If you
    want to  reuse the object, set  `pos' to the  position where the
    substituted glyphs should be placed at (usually zero), but don't
    touch the `allocated', `string', and `properties' fields.

    ................................................................

    TT_Init_GSUB_Extension( TT_Engine  engine )

      Initializes the GSUB extension  to load the glyph substitution
      data  given in  the `GSUB'  table.  This  must be  called just
      after  creation of  the  engine, and  before  any face  object
      allocation.   See the  files `ftstrtto.c'  and  `ftdump.c' for
      detailed examples.

    ................................................................

    TT_Load_GSUB_Table( TT_Face          face,
                        TTO_GSUBHeader*  gsub,
                        TTO_GDEFHeader*  gdef )

      Loads  the GSUB  table into  `gsub' for  a given  face `face'.
      This must  be done  before any queries  about or  selection of
      scripts,      languages,      and      features.       Returns
      TT_Err_Table_Missing if there is no GSUB table in the font.

      `gdef' should  contain a pointer to an  associated GDEF table,
      either  a  native  one  loaded  with  TT_Load_GDEF_Table()  or
      emulated  with TT_GDEF_Build_ClassDefinition().  If  `gdef' is
      set to NULL, no GDEF data will be used.

    ................................................................

    TT_GSUB_Select_Script( TTO_GSUBHeader*  gsub,
                           TT_ULong         script_tag,
                           TT_UShort*       script_index )

      This  function sets  the script  index of  a given  script tag
      `script_tag' in the variable `script_index' for the GSUB table
      `gsub'.  Returns TTO_Err_Not_Covered  if the script tag cannot
      be found.  The  available script tags can be  queried with the
      function TT_GSUB_Query_Scripts().

    ................................................................

    TT_GSUB_Select_Language( TTO_GSUBHeader*  gsub,
                             TT_ULong         language_tag,
                             TT_UShort        script_index,
                             TT_UShort*       language_index,
                             TT_UShort*       req_feature_index )

      This function sets the language  index of a given language tag
      `language_tag' and script index `script_index' in the variable
      `language_index'   for  the   GSUB   table  `gsub'.    Returns
      TTO_Err_Not_Covered if the language  tag cannot be found.  The
      available  language  tags can  be  queried  with the  function
      TT_GSUB_Query_Languages().

      Additionally,  the  index of  the  required  feature for  this
      language system is returned in `req_feature_index'; it must be
      later registered for use with TT_GSUB_Add_Feature().

    ................................................................

    TT_GSUB_Select_Feature( TTO_GSUBHeader*  gsub,
                            TT_ULong         feature_tag,
                            TT_UShort        script_index,
                            TT_UShort        language_index,
                            TT_UShort*       feature_index )

      This  function  sets  the  feature  index  of  a  feature  tag
      `feature_tag', script index `script_index', and language index
      `language_index' in the  variable `feature_index' for the GSUB
      table `gsub'.  Returns  TTO_Err_Not_Covered if the feature tag
      cannot be  found.  The available  feature tags can  be queried
      with    the   function    TT_GSUB_Query_Features().    Setting
      language_index to 0xFFFF selects the default language system.

    ................................................................

    TT_GSUB_Query_Scripts( TTO_GSUBHeader*  gsub,
                           TT_ULong**       script_tag_list )

      Returns  the available  script  tags for  a  given GSUB  table
      `gsub' in the array `script_tag_list'.  The array can be later
      deallocated with free().

    ................................................................

    TT_GSUB_Query_Languages( TTO_GSUBHeader*  gsub,
                             TT_UShort        script_index,
                             TT_ULong**       language_tag_list )

      Returns  the available language  tags for  a given  GSUB table
      `gsub'   and  script   index  `script_index'   in   the  array
      `language_tag_list'.  The array  can be later deallocated with
      free().

    ................................................................

    TT_GSUB_Query_Features( TTO_GSUBHeader*  gsub,
                            TT_UShort        script_index,
                            TT_UShort        language_index,
                            TT_ULong**       feature_tag_list )

      Returns  the available  feature tags  for a  given  GSUB table
      `gsub',  script  index   `script_index',  and  language  index
      `language_index' in the array `feature_tag_list'.  If language
      index is  set to 0xFFFF,  the values for the  default language
      system are returned.  The  array can be later deallocated with
      free().

    ................................................................

    TT_GSUB_Add_Feature( TTO_GSUBHeader*  gsub,
                         TT_UShort        feature_index,
                         TT_UShort        property )

      To  prepare  a  call  to TT_GSUB_Apply_String()  which  should
      process  a given  feature with  index `feature_index'  and the
      property `property', you must  use this function.  Its task is
      to  mark the  lookup tables  used by  the feature  for further
      processing.

      `property'  defines a  relationship between  the  input string
      object and the specific  feature.  The client must handle this
      variable as a bit field, i.e., up to 16 user properties can be
      defined.  If `property' is set to ALL_GLYPHS (0xFFFF, the only
      predefined value),  or if the  input string object has  no set
      bits  in the `properties'  field, the  feature applies  to all
      glyphs.  If bit `x' is  set in `property', the feature applies
      only  to  glyphs  which  have  bit  `x'  not  set  in  glyph's
      `properties'   field  in   the  input   string   object.   See
      TT_GSUB_Apply_String() for an example.

      Returns TT_Err_Invalid_Argument in case of error.

    ................................................................

    TT_GSUB_Clear_Features( TTO_GSUBHeader*  gsub )

      Clears the  list of used  features and properties.   No lookup
      tables will be processed.

    ................................................................

    TT_GSUB_Register_Alternate_Function( TTO_GSUBHeader*  gsub,
                                         TTO_AltFunction  altfunc,
                                         void*            data )

      Installs   a    callback   function   to    handle   alternate
      substitutions.  `data' is a  generic pointer to a user-defined
      structure  which will  be  completely ignored  by the  ftxopen
      extension.  `altfunc' is a function pointer defined as

        typedef TT_UShort
                (*TTO_AltFunction)(TT_ULong    pos,
                                   TT_UShort   glyphID,
                                   TT_UShort   num_alternates,
                                   TT_UShort*  alternates,
                                   void*       data );

      If TT_GSUB_Apply_String() encounters an alternate lookup while
      processing  the  input  string,  it  will  call  the  function
      `altfunc'  to find out  which alternate  glyph it  should use.
      `pos' gives the position in the string, `glyphID' the glyph ID
      of  the glyph  to be  replaced  with an  alternate glyph,  and
      `num_alternates'  the  number   of  alternate  glyphs  in  the
      `alternates'  array.   A pointer  to  the user-defined  `data'
      structure is  also available.  `altfunc' must  return an index
      into `alternates'.

      If `altfunc' is NULL or  if this function isn't called at all,
      TT_GSUB_Apply_String()  will always  use  the first  alternate
      glyph.

      Please note that theoretically  an alternate lookup can happen
      during any other lookup!  For example, a lookup chain like

        single subst -> alternate subst -> ligature subst

      *is* possible  (albeit rather unlikely).  Thus  be warned that
      `pos' does not necessarily reflect  the position of a glyph to
      be  displayed at  all, nor  does `glyphID'  specifies  a glyph
      which will be in the final output string.

    ................................................................

    TT_GSUB_Apply_String( TTO_GSUBHeader*   gsub,
                          TTO_GSUB_String*  in,
                          TTO_GSUB_String*  out )

      This  is the  very function  which handles  glyph substitution
      according to  the features set  up with TT_GSUB_Add_Feature(),
      using   both   GSUB  and   GDEF   data   (if  defined).    Two
      TTO_GSUB_String  objects `in' and  `out' (as  described above)
      are taken  for input and output;  after successful excecution,
      the  converted  glyph string  can  been  found  in `out',  and
      `out.length'  gives the  actual  length of  the output  string
      (counted from the begin of the array).

      Example:

        /* We assume that the feature `xxxx' has index 5, and  */
        /* feature `yyyy' has index 8, applying only to glyphs */
        /* with the property `FINAL_GLYPHS' set (0x1000 is an  */
        /* ad-hoc value just for this example).                */

        /* The order of calls to TT_GSUB_Add_Feature() is not  */
        /* significant.                                        */

        #define FINAL_GLYPHS  0x1000

        TT_GSUB_Clear_Features( &gsub );
        TT_GSUB_Add_Feature( &gsub, 8, FINAL_GLYPHS );
        TT_GSUB_Add_Feature( &gsub, 5, ALL_GLYPHS );

        TT_GSUB_Apply_String( &gsub, &in, &out );

      You must initialize both `in' and `out' structures; allocation
      necessary for the `out' object will be handled automatically.

      In  case you  don't register  a function  to  handle alternate
      substitutions  (GSUB  lookup 3),  always  the first  alternate
      glyph will be used.  See TT_GSUB_Register_Alternate_Function()
      above for more details.


  e. The `JSTF' table (justification data)

    Not yet supported.


  f. auxiliary functions

    TT_GSUB_Add_String( TTO_GSUB_String*  in,
                        TT_UShort         num_in,
                        TTO_GSUB_String*  out,
                        TT_UShort         num_out,
                        TT_UShort*        glyph_data,
                        TT_UShort         component,
                        TT_UShort         ligID )

      This function  copies `num_out' elements  from `glyph_data' to
      `out', advancing  the array pointer  in the `in'  structure by
      `num_in' elements, and in `out' by `num_out' elements.  If the
      string (resp.  the properties) array  in `out' is empty or too
      small,  it  allocates   resp.   reallocates  the  string  (and
      properties)  array.  Finally,  it sets  the `length'  field of
      `out' equal to `pos' of the `out' structure.

      The properties (if defined)  for all replaced glyphs are taken
      from the glyph at position `in->pos'.

      If `component'  is 0xFFFF, the  value `in->component[in->pos]'
      will be  copied `num_out' times,  otherwise `component' itself
      will be used to fill `out->component'.

      If `ligID' is 0xFFFF, the value `in->lig_IDs[in->pos]' will be
      copied `num_out' times, otherwise  `ligID' itself will be used
      to fill `out->ligIDs'.

      TT_GSUB_Add_String()       is      normally       used      in
      TT_GSUB_Apply_String(); you will need  it for the special case
      to skip some glyphs (i.e.,  copy glyphs directly from the `in'
      to the `out' object), bypassing a possible GSUB substitution.

      Here an example which copies one glyph:

        TT_GSUB_Add_String( in, 1,
                            out, 1,
                            &in->string[in->pos],
                            0xFFFF, 0xFFFF );


====================================================================

 
 4. embedded bitmaps (ftxsbit)
 -----------------------------

  TT_Init_SBit_Extension( TT_Engine  engine )

    Initializes  the embedded  bitmap extension  to load  the bitmap
    glyphs given in the various sbit tables: `EBLC', `bloc', `EBDT',
    and `bdat'  (`bloc' and `bdat'  tables are only in  Apple fonts;
    the  former is equivalent  to `EBLC',  the latter  equivalent to
    `EBDT').  This must be called just after creation of the engine,
    and  before  any face  object  allocation.   See description  of
    TT_Load_Glyph_Bitmap() for an example.

  ..................................................................

  TT_Get_Face_Bitmaps( TT_Face   face,
                       TT_EBLC*  eblc_table )

    Loads the `EBLC' (resp. `bloc')  table from a font file into the
    `eblc_table' structure.   Use this function  for testing whether
    embedded bitmaps are available or not.

    This function returns  TT_Err_Table_Missing if the font contains
    no embedded  bitmaps.  All fields  in `eblc_table' will  then be
    set to 0.

  ..................................................................

  TT_New_SBit_Image( TT_SBit_Image**  image )

    Allocates  a  new  embedded  bitmap  container,  pointed  to  by
    `image'.

  ..................................................................

  void  TT_Done_SBit_Image( TT_SBit_Image*  image )
  ^^^^

    Releases the embedded bitmap container `image'.

  ..................................................................

  TT_Get_SBit_Strike( TT_Face          face,
                      TT_Instance      instance,
                      TT_SBit_Strike*  strike )

    Loads a  suitable strike (i.e.  bitmap sizetable)  for the given
    instance.  Will return TT_Err_Invalid_PPem if there is no strike
    for the current x_ppem and y_ppem values.

  ..................................................................

  TT_Load_Glyph_Bitmap( TT_Face         face,
                        TT_Instance     instance,
                        TT_UShort       glyph_index,
                        TT_SBit_Image*  bitmap );

    Loads a glyph  bitmap for a given glyph  index `glyph_index' (in
    face `face'  and instance  `instance') into `bitmap'.   It calls
    TT_Get_SBit_Strike() internally for  checking the current x_ppem
    and y_ppem values.

    This function  returns an error  if there is no  embedded bitmap
    for the glyph at the given instance.

    Example (omitting the error handling):

      ...
      TT_SBit_Image*  bitmap;

      ...
      TT_Init_SBit_Extension( engine );
      TT_New_SBit_Image( &bitmap );
      ...
      TT_Load_Glyph_Bitmap( face, instance, glyph_index, bitmap );



--------------------------------------------------------------------
--------------------------------------------------------------------



II. API extensions
==================

To use  API extensions, simply  compile the specific  extension file
and  link  it to  the  library or  your  program.   By default,  all
extensions described below are linked to the library.


 1. cmap iteration (ftxcmap)
 ---------------------------

  TT_Long  TT_CharMap_First( TT_CharMap  charMap,
  ^^^^^^^                    TT_UShort*  glyph_index )

    Returns the first valid character  code in a given character map
    `charMap'.  Also  returns the corresponding glyph  index (in the
    parameter `*glyph_index').  In case  of failure, -1 is returned,
    and `*glyph_index' is undefined.

  ..................................................................

  TT_Long  TT_CharMap_Next( TT_CharMap  charMap,
  ^^^^^^^                   TT_ULong    last_char,
                            TT_UShort*  glyph_index )

    Returns the next  valid character code in a  given character map
    `charMap'   which  follows   `last_char'.    Also  returns   the
    corresponding glyph index (in the parameter `*glyph_index').  In
    case of failure, -1 is returned, and `glyph_index' is undefined.

  ..................................................................

  TT_Long  TT_CharMap_Last( TT_CharMap  charMap,
  ^^^^^^^                   TT_UShort*  glyph_index )

    Returns the last  valid character code in a  given character map
    `charMap'.  Also  returns the corresponding glyph  index (in the
    parameter `*glyph_index').  In case  of failure, -1 is returned,
    and `*glyph_index' is undefined.


====================================================================


 2. internationalized error messages (ftxerr18)
 ----------------------------------------------

  This extension  provides internationalized error  strings from the
  various  error  messages.   It   uses  the  `gettext'  package  if
  available  or  returns English/American  message  strings if  not.
  Currently,  the gettext  package  is only  available on  UNIX-like
  systems like Linux (and on similarly inspired  systems, like DJGPP
  or MinGW); this means that  for other platforms only English error
  strings are returned.

  If  the gettext  package is  found on  your system,  the configure
  script  automatically includes it  by default.  In case  you don't
  want to use  it, or if you encounter  some problems compiling this
  file,  try to  disable nls  support by  configuring  FreeType with
  `./configure --disable-nls'.

  Please read the gettext info files for more information how to set
  up   your  system   for  internationalized   messages.    A  short
  introduction is also given in the file `i18n.txt'.


  TT_String*  TT_ErrToString18( TT_Error  i )
  ^^^^^^^^^^

    This function  returns an  error string for  a given  error code
    `i'.   The  type `TT_String'  usually  defaults  to `char';  see
    apiref.txt for more details.

    An  example how  to use  this function  (in connection  with the
    gettext interface) is given in test/ftdump.c or test/fterror.c.


====================================================================


 3. access to the `gasp' table (ftxgasp)
 ---------------------------------------

  The `gasp' table  is currently loaded by the  core engine, but the
  standard API doesn't give access to it.


  TT_Get_Face_Gasp_Flags( TT_Face    face,
                          TT_UShort  point_size,
                          TT_Bool*   grid_fit,
                          TT_Bool*   smooth_font )

    This function returns for a given `point_size' the values of the
    gasp  flags `grid_fit' and  `smooth_font'.  The  returned values
    are booleans (where 0 = NO, and 1 = YES).

    Note that this function  will return TT_Err_Table_Missing if the
    font file doesn't contain any gasp table.


====================================================================


 4. fast retrieval of glyph widths and heights (ftxwidth)
 --------------------------------------------------------

  This extension  is used  to parse the  `glyf' table of  a TrueType
  file in  order to  extract the  bounding box of  a given  range of
  glyphs.

  The  bounding box  is  then used  to  build font  unit widths  and
  heights that are returned in two parallel arrays.

  This extension is needed by the FreeType/2 OS/2 Font Driver.


  TT_Get_Face_Widths( TT_Face     face,
                      TT_UShort   first_glyph,
                      TT_UShort   last_glyph,
                      TT_UShort*  widths,
                      TT_UShort*  heights )

    Returns  the widths (in  array `widths')  and heights  (in array
    `heights') of  a glyph range  which starts at  `first_glyph' and
    ends at `last_glyph'.  All  returned values are returned in font
    units.   If  either `widths'  or  `heights'  is  set to  a  NULL
    pointer, no data will be returned for that particular array.

    Note: TT_Get_Face_Widths() does *not* allocate the two arrays!



--------------------------------------------------------------------
--------------------------------------------------------------------



III. Error Messages
===================

  Most functions return an error  code, typed to TT_Error.  A return
  value of zero indicates no error.  The error values are defined in
  the  various  extension header  files  (e.g.  ftxkern.h).  In  the
  following  table, the prefix  `TT_Err_' is  omitted, e.g.  `Ok' ->
  `TT_Err_Ok'.


  Error   Unprefixed               Error
  Code    Macro Name               Description
  ------------------------------------------------------------------

  0x0A00  Invalid_Kerning_Table_Format
                                   An invalid kerning subtable
                                   format was found in this font.

  0x0A01  Invalid_Kerning_Table    A kerning table contains illegal
                                   glyph indices.

  0x0B00  Invalid_Post_Table_Format
                                   The post table format specified
                                   in the font is invalid.

  0x0B01  Invalid_Post_Table       The post table contains illegal
                                   entries.


  Here the TrueType  Open error codes.  In the  following table, the
  prefix `TTO_Err_' is omitted.


  Error   Unprefixed               Error
  Code    Macro Name               Description
  ------------------------------------------------------------------
  0x1000  Invalid_SubTable_Format  The TrueType Open subtable format
                                   specified in the font is invalid.

  0x1001  Invalid_SubTable         A TrueType Open subtable contains
                                   illegal entries.

  0x1002  Not_Covered              The requested feature, glyph,
                                   etc. isn't covered by the actual
                                   function.

  0x1003  Too_Many_Nested_Contexts
                                   A loop in the contextual lookup
                                   tables (either GSUB or GPOS) has
                                   been detected.

  0x1004  No_MM_Interpreter        The interface to a PostScript
                                   interpreter with Multiple Master
                                   font support is missing.

  0x1010  Invalid_GSUB_SubTable_Format
                                   The GSUB subtable format
                                   specified in the font is invalid.

  0x1011  Invalid_GSUB_SubTable    The GSUB subtable contains
                                   illegal entries.

  0x1020  Invalid_GPOS_SubTable_Format
                                   The GPOS subtable format
                                   specified in the font is invalid.

  0x1021  Invalid_GPOS_SubTable    The GPOS subtable contains
                                   illegal entries.

  0x1030  Invalid_GDEF_SubTable_Format
                                   The GDEF subtable format
                                   specified in the font is invalid.

  0x1031  Invalid_GDEF_SubTable    The GDEF subtable contains
                                   illegal entries.


--- end of apirefx.txt ---