1 /* otf.h -- Header file for libotf (OpenType font library).
3 Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
4 National Institute of Advanced Industrial Science and Technology (AIST)
5 Registration Number H15PRO167
7 This file is part of libotf.
9 Libotf is free software; you can redistribute it and/or modify it
10 under the terms of the GNU Lesser General Public License as published
11 by the Free Software Foundation; either version 2.1 of the License, or
12 (at your option) any later version.
14 Libotf is distributed in the hope that it will be useful, but WITHOUT
15 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
16 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
17 License for more details.
19 You should have received a copy of the GNU Lesser General Public
20 License along with this library, in a file named COPYING; if not,
21 write to the Free Software Foundation, Inc., 59 Temple Place, Suite
22 330, Boston, MA 02111-1307, USA. */
31 /* Version name of this library. */
32 #define LIBOTF_VERSION "0.9.10"
34 /* Major version number. */
35 #define LIBOTF_MAJOR_VERSION 0
36 /* Minor version number. */
37 #define LIBOTF_MINOR_VERSION 9
38 /* Release (i.e. patch level) number. */
39 #define LIBOTF_RELEASE_NUMBER 10
44 (1) Structures for OTF Layout tables and OTF itself
49 (1-5) Structures common to GDEF, GSUB, and GPOS
51 (1-7) Structures for ScriptList, FeatureList, and LookupList
52 (1-8) Structures common to GSUB and GPOS
55 (1-11) Structure for OTF
57 (2) API for reading OTF
58 (2-1) OTF_open(), OTF_open_ft_face()
61 (2-4) OTF_check_table()
63 (3) API for driving OTF
64 (3-1) Structure for glyph string
65 (3-2) OTF_drive_cmap()
66 (3-3) OTF_drive_gdef()
67 (3-4) OTF_drive_gsub()
68 (3-5) OTF_drive_gpos()
69 (3-6) OTF_drive_tables()
70 (3-7) OTF_get_unicode()
71 (3-8) OTF_drive_gsub_alternate()
72 (3-9) OTF_iterate_on_feature()
74 (4) API for error handling
83 /*** (1) Structures for OTF Layout tables and OTF itself */
85 /*** (1-1) Basic types */
87 typedef unsigned OTF_Tag;
88 typedef unsigned OTF_GlyphID;
89 typedef unsigned OTF_Offset;
98 /*** (1-2) "head" table */
102 OTF_Fixed TableVersionNumber;
103 OTF_Fixed fontRevision;
104 unsigned checkSumAdjustment;
105 unsigned magicNumber;
111 /*** (1-3) "name" table */
122 /* If nonzero, NAME is an ASCII string. */
127 #define OTF_max_nameID 23
134 OTF_NameRecord *nameRecord;
135 char *name[OTF_max_nameID + 1];
139 /*** (1-4) "cmap" table */
143 unsigned char glyphIdArray[256];
144 } OTF_EncodingSubtable0;
151 unsigned idRangeOffset;
156 unsigned short subHeaderKeys[256];
158 OTF_cmapSubHeader *subHeaders;
160 OTF_GlyphID *glyphIndexArray;
161 } OTF_EncodingSubtable2;
168 unsigned idRangeOffset;
174 unsigned searchRange;
175 unsigned entrySelector;
177 OTF_cmapSegment *segments;
179 unsigned *glyphIdArray;
180 } OTF_EncodingSubtable4;
186 unsigned *glyphIdArray;
187 } OTF_EncodingSubtable6;
191 unsigned startCharCode;
192 unsigned endCharCode;
193 unsigned startGlyphID;
198 unsigned char is32[8192];
200 OTF_cmapGroup *Groups;
201 } OTF_EncodingSubtable8;
205 unsigned startCharCode;
208 } OTF_EncodingSubtable10;
213 OTF_cmapGroup *Groups;
214 } OTF_EncodingSubtable12;
218 unsigned unicodeValue;
219 unsigned short glyphID;
224 unsigned startUnicodeValue;
225 unsigned short additionalCount;
226 } OTF_UnicodeValueRange;
230 unsigned varSelector;
231 unsigned defaultUVSOffset;
232 unsigned nonDefaultUVSOffset;
234 unsigned numUnicodeValueRanges;
235 OTF_UnicodeValueRange *unicodeValueRanges;
237 unsigned numUVSMappings;
238 OTF_UVSMapping *uvsMappings;
239 } OTF_VariationSelectorRecord;
244 OTF_VariationSelectorRecord *Records;
245 } OTF_EncodingSubtable14;
253 OTF_EncodingSubtable0 *f0;
254 OTF_EncodingSubtable2 *f2;
255 OTF_EncodingSubtable4 *f4;
256 OTF_EncodingSubtable6 *f6;
257 OTF_EncodingSubtable8 *f8;
258 OTF_EncodingSubtable10 *f10;
259 OTF_EncodingSubtable12 *f12;
260 OTF_EncodingSubtable14 *f14;
262 } OTF_EncodingSubtable;
269 OTF_EncodingSubtable subtable;
270 } OTF_EncodingRecord;
276 OTF_EncodingRecord *EncodingRecord;
277 /* Mapping table: Unicode->GlyphID (for BMP only) */
278 unsigned short *unicode_table;
279 /* Maximum Glyph ID that corresponds to a Unicode character. */
281 /* Mapping table: GlyphID->Unicode */
282 unsigned short *decode_table;
283 /* Index of the EncodingRecord for Unicode->GlyphID mapping.
284 -1 means that the font supports only Unicode BMP characters. */
289 /*** (1-5) Structures common to GDEF, GSUB, GPOS */
295 unsigned StartCoverageIndex;
301 unsigned CoverageFormat;
304 OTF_GlyphID *GlyphArray;
305 OTF_RangeRecord *RangeRecord;
314 unsigned DeltaFormat;
323 } OTF_ClassRangeRecord;
328 unsigned ClassFormat;
331 OTF_GlyphID StartGlyph;
333 unsigned *ClassValueArray;
336 unsigned ClassRangeCount;
337 OTF_ClassRangeRecord *ClassRangeRecord;
343 /*** (1-6) "GDEF" table */
348 OTF_Offset GlyphClassDef;
349 OTF_Offset AttachList;
350 OTF_Offset LigCaretList;
351 OTF_Offset MarkAttachClassDef;
354 enum OTF_GlyphClassDef
357 OTF_GlyphClassBase = 1,
358 OTF_GlyphClassLigature = 2,
359 OTF_GlyphClassMark = 3,
360 OTF_GlyphClassComponent = 4
367 unsigned *PointIndex;
372 OTF_Coverage Coverage;
374 OTF_AttachPoint *AttachPoint;
380 unsigned CaretValueFormat; /* 1, 2, or 3 */
386 unsigned CaretValuePoint;
390 OTF_DeviceTable DeviceTable;
399 OTF_CaretValue *CaretValue;
404 OTF_Coverage Coverage;
405 unsigned LigGlyphCount;
406 OTF_LigGlyph *LigGlyph;
411 OTF_GDEFHeader header;
412 OTF_ClassDef glyph_class_def;
413 OTF_AttachList attach_list;
414 OTF_LigCaretList lig_caret_list;
415 OTF_ClassDef mark_attach_class_def;
419 /*** (1-7) Structures for ScriptList, FeatureList, and LookupList */
421 /*** The structure hierarchy
448 SubTable.gsub[] or SubTable.gpos[]
454 OTF_Offset LookupOrder;
455 unsigned ReqFeatureIndex;
456 unsigned FeatureCount;
457 unsigned *FeatureIndex;
470 OTF_Offset DefaultLangSysOffset;
471 OTF_LangSys DefaultLangSys;
472 unsigned LangSysCount;
473 OTF_LangSysRecord *LangSysRecord;
474 OTF_LangSys *LangSys;
480 unsigned ScriptCount;
488 OTF_Offset FeatureParams;
489 unsigned LookupCount;
490 unsigned *LookupListIndex;
496 unsigned FeatureCount;
497 OTF_Feature *Feature;
500 typedef struct OTF_LookupSubTableGSUB OTF_LookupSubTableGSUB;
501 typedef struct OTF_LookupSubTableGPOS OTF_LookupSubTableGPOS;
503 enum OTF_LookupFlagBit
505 OTF_RightToLeft = 0x0001,
506 OTF_IgnoreBaseGlyphs = 0x0002,
507 OTF_IgnoreLigatures = 0x0004,
508 OTF_IgnoreMarks = 0x0008,
509 OTF_Reserved = 0x00F0,
510 OTF_MarkAttachmentType = 0xFF00
513 #define OTF_LookupFlagIgnoreMask \
514 (OTF_IgnoreBaseGlyphs | OTF_IgnoreLigatures | OTF_IgnoreMarks)
521 unsigned SubTableCount;
522 OTF_Offset *SubTableOffset;
524 OTF_LookupSubTableGSUB *gsub;
525 OTF_LookupSubTableGPOS *gpos;
532 unsigned LookupCount;
537 /*** (1-8) Structures common to GSUB and GPOS */
539 /* For SubstLookupRecord (GSUB) and PosLookupRecord (GPOS). */
543 unsigned SequenceIndex;
544 unsigned LookupListIndex;
551 unsigned LookupCount;
552 OTF_GlyphID *Input; /* [<GlyphCount> - 1] */
553 OTF_LookupRecord *LookupRecord; /* [<LookupCount>] */
560 OTF_Rule *Rule; /* [<RuleCount>] */
567 unsigned LookupCount;
568 unsigned *Class; /* [<GlyphCount> - 1] */
569 OTF_LookupRecord *LookupRecord; /* [<LookupCount>] */
575 unsigned ClassRuleCnt;
576 OTF_ClassRule *ClassRule; /* [<ClassRuleCnt>] */
582 unsigned BacktrackGlyphCount;
583 OTF_GlyphID *Backtrack;
584 unsigned InputGlyphCount;
586 unsigned LookaheadGlyphCount;
587 OTF_GlyphID *LookAhead;
588 unsigned LookupCount;
589 OTF_LookupRecord *LookupRecord;
595 unsigned ChainRuleCount;
596 OTF_ChainRule *ChainRule;
602 unsigned BacktrackGlyphCount;
604 unsigned InputGlyphCount;
606 unsigned LookaheadGlyphCount;
608 unsigned LookupCount;
609 OTF_LookupRecord *LookupRecord;
610 } OTF_ChainClassRule;
615 unsigned ChainClassRuleCnt;
616 OTF_ChainClassRule *ChainClassRule;
620 /* Common to OTF_GSUB/GPOS_Context1/2/3. */
624 unsigned RuleSetCount;
625 OTF_RuleSet *RuleSet; /* [<RuleSetCount>] */
630 OTF_ClassDef ClassDef;
631 unsigned ClassSetCnt;
632 OTF_ClassSet *ClassSet; /* [<ClassSetCnt>] */
638 unsigned LookupCount;
639 OTF_Coverage *Coverage; /* [<GlyphCount>] */
640 OTF_LookupRecord *LookupRecord; /* [<LookupCount>] */
644 /* Common to OTF_GSUB/GPOS_ChainContext1/2/3. */
648 unsigned ChainRuleSetCount;
649 OTF_ChainRuleSet *ChainRuleSet;
654 OTF_ClassDef BacktrackClassDef;
655 OTF_ClassDef InputClassDef;
656 OTF_ClassDef LookaheadClassDef;
657 unsigned ChainClassSetCnt;
658 OTF_ChainClassSet *ChainClassSet;
663 unsigned BacktrackGlyphCount;
664 OTF_Coverage *Backtrack;
665 unsigned InputGlyphCount;
667 unsigned LookaheadGlyphCount;
668 OTF_Coverage *LookAhead;
669 unsigned LookupCount;
670 OTF_LookupRecord *LookupRecord;
673 /* Common to OTF_GSUB/GPOS. */
678 OTF_ScriptList ScriptList;
679 OTF_FeatureList FeatureList;
680 OTF_LookupList LookupList;
683 /*** (1-9) "GSUB" table */
693 OTF_GlyphID *Substitute;
696 typedef struct OTF_Sequence OTF_Sequence;
700 unsigned SequenceCount;
701 OTF_Sequence *Sequence;
702 } OTF_GSUB_Multiple1;
708 OTF_GlyphID *Substitute;
711 typedef struct OTF_AlternateSet OTF_AlternateSet;
715 unsigned AlternateSetCount;
716 OTF_AlternateSet *AlternateSet;
717 } OTF_GSUB_Alternate1;
719 struct OTF_AlternateSet
723 OTF_GlyphID *Alternate;
726 typedef struct OTF_LigatureSet OTF_LigatureSet;
727 typedef struct OTF_Ligature OTF_Ligature;
731 unsigned LigSetCount;
732 OTF_LigatureSet *LigatureSet;
733 } OTF_GSUB_Ligature1;
735 struct OTF_LigatureSet
738 unsigned LigatureCount;
739 OTF_Ligature *Ligature;
745 OTF_GlyphID LigGlyph;
747 OTF_GlyphID *Component;
750 typedef OTF_Context1 OTF_GSUB_Context1;
752 typedef OTF_Context2 OTF_GSUB_Context2;
754 typedef OTF_Context3 OTF_GSUB_Context3;
756 typedef OTF_ChainContext1 OTF_GSUB_ChainContext1;
758 typedef OTF_ChainContext2 OTF_GSUB_ChainContext2;
760 typedef OTF_ChainContext3 OTF_GSUB_ChainContext3;
764 unsigned ExtensionLookupType;
765 unsigned ExtensionOffset;
766 OTF_LookupSubTableGSUB *ExtensionSubtable;
767 } OTF_GSUB_Extension1;
771 unsigned BacktrackGlyphCount;
772 OTF_Coverage *Backtrack;
773 unsigned LookaheadGlyphCount;
774 OTF_Coverage *LookAhead;
776 OTF_GlyphID *Substitute;
777 } OTF_GSUB_ReverseChain1;
779 struct OTF_LookupSubTableGSUB
782 OTF_Coverage Coverage;
785 OTF_GSUB_Single1 single1;
786 OTF_GSUB_Single2 single2;
788 OTF_GSUB_Multiple1 multiple1;
790 OTF_GSUB_Alternate1 alternate1;
792 OTF_GSUB_Ligature1 ligature1;
794 OTF_GSUB_Context1 context1;
795 OTF_GSUB_Context2 context2;
796 OTF_GSUB_Context3 context3;
798 OTF_GSUB_ChainContext1 chain_context1;
799 OTF_GSUB_ChainContext2 chain_context2;
800 OTF_GSUB_ChainContext3 chain_context3;
802 OTF_GSUB_Extension1 extension1;
804 OTF_GSUB_ReverseChain1 reverse_chain1;
808 typedef OTF_GSUB_GPOS OTF_GSUB;
810 /*** (1-10) "GPOS" table */
814 OTF_XPlacement = 0x0001,
815 OTF_YPlacement = 0x0002,
816 OTF_XAdvance = 0x0004,
817 OTF_YAdvance = 0x0008,
818 OTF_XPlaDevice = 0x0010,
819 OTF_YPlaDevice = 0x0020,
820 OTF_XAdvDevice = 0x0040,
821 OTF_YAdvDevice = 0x0080
830 OTF_DeviceTable XPlaDevice;
831 OTF_DeviceTable YPlaDevice;
832 OTF_DeviceTable XAdvDevice;
833 OTF_DeviceTable YAdvDevice;
839 unsigned AnchorFormat;
844 unsigned AnchorPoint;
847 OTF_DeviceTable XDeviceTable;
848 OTF_DeviceTable YDeviceTable;
856 OTF_Anchor MarkAnchor;
863 OTF_MarkRecord *MarkRecord;
868 unsigned ValueFormat;
869 OTF_ValueRecord Value;
874 unsigned ValueFormat;
876 OTF_ValueRecord *Value; /* [<ValueCount>] */
881 OTF_GlyphID SecondGlyph;
882 OTF_ValueRecord Value1;
883 OTF_ValueRecord Value2;
884 } OTF_PairValueRecord;
889 unsigned PairValueCount;
890 OTF_PairValueRecord *PairValueRecord;
895 unsigned ValueFormat1;
896 unsigned ValueFormat2;
897 unsigned PairSetCount;
898 OTF_PairSet *PairSet;
903 OTF_ValueRecord Value1;
904 OTF_ValueRecord Value2;
909 OTF_Class2Record *Class2Record;
914 unsigned ValueFormat1;
915 unsigned ValueFormat2;
916 OTF_ClassDef ClassDef1;
917 OTF_ClassDef ClassDef2;
918 unsigned Class1Count;
919 unsigned Class2Count;
920 OTF_Class1Record *Class1Record; /* size: <Class1Count> */
925 OTF_Anchor EntryAnchor;
926 OTF_Anchor ExitAnchor;
927 } OTF_EntryExitRecord;
931 unsigned EntryExitCount;
932 OTF_EntryExitRecord *EntryExitRecord;
944 OTF_AnchorRecord *AnchorRecord;
949 OTF_Coverage BaseCoverage;
951 OTF_MarkArray MarkArray;
952 OTF_AnchorArray BaseArray;
953 } OTF_GPOS_MarkBase1;
957 OTF_Anchor *LigatureAnchor; /* [<ClassCount>] */
958 } OTF_ComponentRecord;
963 unsigned ComponentCount;
964 OTF_ComponentRecord *ComponentRecord; /* [<ComponentCount>] */
965 } OTF_LigatureAttach;
970 unsigned LigatureCount;
971 OTF_LigatureAttach *LigatureAttach; /* [<LiagureCount>] */
976 OTF_Coverage LigatureCoverage;
978 OTF_MarkArray MarkArray;
979 OTF_LigatureArray LigatureArray;
984 OTF_Coverage Mark2Coverage;
986 OTF_MarkArray Mark1Array;
987 OTF_AnchorArray Mark2Array;
988 } OTF_GPOS_MarkMark1;
990 typedef OTF_Context1 OTF_GPOS_Context1;
992 typedef OTF_Context2 OTF_GPOS_Context2;
994 typedef OTF_Context3 OTF_GPOS_Context3;
996 typedef OTF_ChainContext1 OTF_GPOS_ChainContext1;
998 typedef OTF_ChainContext2 OTF_GPOS_ChainContext2;
1000 typedef OTF_ChainContext3 OTF_GPOS_ChainContext3;
1004 unsigned ExtensionLookupType;
1005 unsigned ExtensionOffset;
1006 OTF_LookupSubTableGPOS *ExtensionSubtable;
1007 } OTF_GPOS_Extension1;
1010 struct OTF_LookupSubTableGPOS
1013 OTF_Coverage Coverage;
1016 OTF_GPOS_Single1 single1;
1017 OTF_GPOS_Single2 single2;
1019 OTF_GPOS_Pair1 pair1;
1020 OTF_GPOS_Pair2 pair2;
1022 OTF_GPOS_Cursive1 cursive1;
1024 OTF_GPOS_MarkBase1 mark_base1;
1026 OTF_GPOS_MarkLig1 mark_lig1;
1028 OTF_GPOS_MarkMark1 mark_mark1;
1030 OTF_GPOS_Context1 context1;
1031 OTF_GPOS_Context2 context2;
1032 OTF_GPOS_Context3 context3;
1034 OTF_GPOS_ChainContext1 chain_context1;
1035 OTF_GPOS_ChainContext2 chain_context2;
1036 OTF_GPOS_ChainContext3 chain_context3;
1038 OTF_GPOS_Extension1 extension1;
1042 typedef OTF_GSUB_GPOS OTF_GPOS;
1044 /*** (1-11) Structure for OTF */
1048 OTF_Fixed sfnt_version;
1050 unsigned searchRange;
1051 unsigned enterSelector;
1052 unsigned rangeShift;
1062 } OTF_TableDirectory;
1064 typedef struct OTF_InternalData OTF_InternalData;
1069 OTF_OffsetTable offset_table;
1070 OTF_TableDirectory *table_dirs;
1077 /* The following tables are not yet supported. */
1078 /* OTF_BASE *base; */
1079 /* OTF_JSTF *jstf; */
1080 OTF_InternalData *internal_data;
1084 /*** (2) API for reading OTF */
1086 /*** (2-1) otf_open () */
1091 The OTF_open() function reads the OpenType font file whose name is
1092 $NAME, and return a pointer to the structure of type OTF.
1094 It setups these member of the structure OTF:
1095 filename, offset_table, table_dirs
1097 If the file can't be read or the file contains invalid data, NULL
1098 is returned, and the variable OTF_error is set to one of the
1105 See also OTF_get_table() and OTF_close(). */
1107 extern OTF *OTF_open (const char *name);
1109 #include <ft2build.h>
1110 #include FT_FREETYPE_H
1112 extern OTF *OTF_open_ft_face (FT_Face face);
1115 /*** (2-2) OTF_close () */
1120 The OTF_close() function closes the OpenType font $OTF which must
1121 be what the OTF_open() function returned.
1123 See also OTF_open(). */
1125 extern void OTF_close (OTF *otf);
1128 /*** (2-3) OTF_get_table () */
1131 Get OpenType font table
1133 The OTF_get_table() function setups one of the OTF table specified
1134 by $NAME in the OpenType font $OTF.
1136 $NAME must be one of "head", "name", "cmap", "GDEF", "GSUB", and
1137 "GPOS", and a member of the same name is setup.
1139 If the table is successfully setup, return 0. Otherwise, return
1140 -1, and set the variable OTF_error to OTF_ERROR_TABLE.
1142 See also OTF_open(). */
1144 extern int OTF_get_table (OTF *otf, const char *name);
1146 /*** (2-4) OTF_check_table () */
1149 Check the existence of OpenType font table
1151 The OTF_check_table() function checks if the the OTF table
1152 specified by $NAME exists in OpenType font $OTF.
1154 If the table exists, return 0, else return -1.
1156 See also OTF_open(). */
1158 extern int OTF_check_table (OTF *otf, const char *name);
1160 /*** (2-5) OTF_get_scripts () */
1163 Get supported scripts.
1165 The OTF_get_scripts() function setups OTF_ScriptList of GSUB (if
1166 $GSUBP is nonzero) or GPOS (if $GSUBP is zero) table of the
1169 If the table is successfully setup, return 0. Otherwise, retrun
1170 -1, and set the variable OTF_error to OTF_ERROR_TABLE. */
1172 extern int OTF_get_scripts (OTF *otf, int gsubp);
1174 /*** (2-6) OTF_get_features () */
1177 Get supported features.
1179 The OTF_get_features() function setups OTF_FeatureList of GSUB (if
1180 $GSUBP is nonzero) or GPOS (if $GSUBP is zero) table of the
1183 If the table is successfully setup, return 0. Otherwise, retrun
1184 -1, and set the variable OTF_error to OTF_ERROR_TABLE. */
1186 extern int OTF_get_features (OTF *otf, int gsubp);
1188 /*** (2-7) OTF_check_features */
1191 Check supported features.
1193 The OTF_check_features() function checks if or not the OpenType
1194 font $OTF has, for $SCRIPT and $LANGUAGE, all features in the
1195 array $FEATURES. The array size is $N_FEATURES. If $LANGUAGE is
1196 zero or $OTF doesn't have LangSys for $SCRIPT, the default LangSys
1199 If $OTF has all the features, return 1. Otherwise, return 0. If
1200 an error occurs, return -1, and set the variable OTF_error to
1203 extern int OTF_check_features (OTF *otf, int gsubp,
1204 OTF_Tag script, OTF_Tag language,
1205 const OTF_Tag *features, int n_features);
1207 /*** (3) API for driving OTF */
1209 /*** (3-1) Structure for glyph string */
1212 The structure OTF_Glyph contains information about each glyph in
1213 the structure OTF_GlyphString. */
1217 /** The first two members must be set by a clinet before calling the
1218 function OTF_drive_XXX(). **/
1220 /* Character code of the glyph. The value less than 32 is treated
1221 as a place-holder in a glyph string, and OTF_drive_XXX ()
1222 function just ignore the glyph as if it doesn't exist. */
1225 /* Glyph ID of the glyph. If the value is 0, the library gets a
1226 correct value from the above character code via cmap if such a
1227 glyph is available in the font.
1229 The functions OTF_drive_gpos2 and OTF_driver_gpos_with_log may
1230 insert a glyph whose glyph_id is 0 but positioning_type is
1231 positive. It is not an actual glyph but just contains
1232 positioning information that should be accumulated to the
1233 positioning information of the previous glyphs. */
1234 OTF_GlyphID glyph_id;
1236 /* GlyphClass of the glyph. The value is extracted from the GDEF
1238 enum OTF_GlyphClassDef GlyphClass;
1240 /* MarkAttachClassDef of the glyph. The value is extracted from the
1242 unsigned MarkAttachClass;
1244 /* The lowest 4-bit is a positioning format type of the glyph. The
1245 value specifies how the glyph positioning information is encoded
1246 in the member <f>. If the value is N, the union member fN, is
1247 used. If the value is zero, the glyph has no positioning
1248 information, i.e. it should be drawn at the normal position.
1250 OTF_drive_gsub, OTF_drive_gsub_alternate, OTF_drive_gpos, and
1251 OTF_drive_gpos2 always sets the higher bits to zero.
1253 OTF_drive_gsub_with_log and OTF_drive_gpos_with_log sets the
1254 higher 16-bit (i.e. 5th to 20th bits) to the index number of the
1255 lastly applied feature on the glyph plus one. If no feature was
1256 applied, those bits are zero. */
1257 unsigned int positioning_type;
1263 enum OTF_ValueFormat format;
1264 OTF_ValueRecord *value;
1267 enum OTF_ValueFormat format;
1268 OTF_ValueRecord *value;
1271 OTF_Anchor *entry_anchor;
1272 OTF_Anchor *exit_anchor;
1275 OTF_Anchor *mark_anchor;
1276 OTF_Anchor *base_anchor;
1279 OTF_Anchor *mark_anchor;
1280 OTF_Anchor *ligature_anchor;
1283 OTF_Anchor *mark1_anchor;
1284 OTF_Anchor *mark2_anchor;
1290 The structure OTF_GlyphString contains an array of glyphs (type
1291 OTF_Glyph). It is used as arguments of otf_drive_XXX(). */
1295 /* How many glyphs are allocated at the memory pointed by the member
1298 /* How many glyphs contain valid information. */
1300 /* Array of glyphs. It must be allocated by malloc(). The
1301 functions otf_drive_XXX() may reallocate it and increase the
1302 members <size> and <used>. */
1307 /*** (3-2) OTF_drive_cmap() */
1310 Process glyph string by Unicode-based cmap table.
1312 The OTF_drive_cmap() function looks up a Unicode-based cmap table
1313 of OpenType font $OTF, and setup the member <glyph_id> of all
1314 glhphs in the glyph string $GSTRING if the value of the member is
1317 extern int OTF_drive_cmap (OTF *otf, OTF_GlyphString *gstring);
1320 Process glyph string by a specific cmap table.
1322 The OTF_drive_cmap2() function looks up a cmap table (whose
1323 Platform-ID is $PLATFORM_ID an Encoding-ID is $ENCODING_ID) of
1324 OpenType font $OTF, and setup the member <glyph_id> of all glhphs
1325 in the glyph string $GSTRING if the value of the member is not
1328 extern int OTF_drive_cmap2 (OTF *otf, OTF_GlyphString *gstring,
1329 int platform_id, int encoding_id);
1333 Store variable glyphs of character C in the array CODE. The array
1334 size must be 256. The Nth element of CODE is the glyph corresponding
1335 to the variation selector (N + 1). The return value is the number
1336 of variation glyphs. */
1338 extern int OTF_get_variation_glyphs (OTF *otf, int c, OTF_GlyphID code[256]);
1341 /*** (3-3) OTF_drive_gdef() */
1344 Process glyph string by GDEF table.
1346 The OTF_drive_gdef() function looks up the GDEF table of OpenType
1347 font $OTF, and setup members <GlyphClass> and <MarkAttachClass> of
1348 all glhphs in the glyph string $GSTRING. */
1350 extern int OTF_drive_gdef (OTF *otf, OTF_GlyphString *gstring);
1353 /*** (3-4) OTF_drive_gsub() */
1356 Process glyph string by GSUB table.
1358 The OTF_drive_gsub() function looks up the GSUB table of OpenType
1359 font $OTF, and by using features the font has for script $SCRIPT
1360 and language system $LANGSYS, update member <glyphs> of the glyph
1361 string $GSTRING. It may substitute, delete, insert glyphs in that
1362 array. $FEATURES is a list of features to apply. This doesn't
1363 perform a lookup of type 3 (Alternate Substitution). For that,
1364 use OTF_drive_gsub_alternate(). */
1366 extern int OTF_drive_gsub (OTF *otf, OTF_GlyphString *gstring,
1367 const char *script, const char *language,
1368 const char *features);
1371 Process glyph string by GSUB table with log.
1373 This is like OTF_drive_gsub(), but records which feature is
1374 applied to each glyph in the higher bits of `positioning_type'
1375 member of OTF_Glyph. */
1377 extern int OTF_drive_gsub_with_log (OTF *otf, OTF_GlyphString *gstring,
1378 const char *script, const char *language,
1379 const char *features);
1382 /*** (3-5) OTF_drive_gpos() */
1385 Process glyph string by GPOS table.
1387 The OTF_drive_gpos() function is deprecated. Use
1388 OTF_drive_gpos2() instread. */
1390 extern int OTF_drive_gpos (OTF *otf, OTF_GlyphString *gstring,
1391 const char *script, const char *language,
1392 const char *features);
1395 Process glyph string by GPOS table.
1397 The OTF_drive_gpos2() function looks up the GPOS table of $OTF of
1398 OpenType font $OTF, and by using features the font has for script
1399 $SCRIPT and language system $LANGSYS, setup members
1400 <positioning_type> and <f> of all glhphs in the glyph string
1401 $GSTRING. $FEATURES is a list of features to apply. */
1403 extern int OTF_drive_gpos2 (OTF *otf, OTF_GlyphString *gstring,
1404 const char *script, const char *language,
1405 const char *features);
1408 Process glyph string by GPOS table with log.
1410 This is like OTF_drive_pos_2(), but records which feature is
1411 applied to each glyph in the higher bits of `positioning_type'
1412 member of OTF_Glyph. */
1414 extern int OTF_drive_gpos_with_log (OTF *otf, OTF_GlyphString *gstring,
1415 const char *script, const char *language,
1416 const char *features);
1419 /*** (3-6) OTF_drive_tables() */
1422 Process glyph string by cmap, GDEF, GSUB, and GPOS tables.
1424 The OTF_drive_tables() function calls OTF_drive_cmap(),
1425 OTF_drive_gdef(), OTF_drive_gsub(), and OTF_drive_gpos() in this
1426 order, and update the glyphs string GSTRING. */
1428 extern int OTF_drive_tables (OTF *otf, OTF_GlyphString *gstring,
1429 const char *script, const char *language,
1430 const char *gsub_features,
1431 const char *gpos_features);
1434 /*** (3-7) OTF_get_unicode() */
1437 Return Unicode code point corresponding to the glyph-id CODE.
1440 extern int OTF_get_unicode (OTF *otf, OTF_GlyphID code);
1442 /*** (3-8) OTF_drive_gsub_alternate() */
1445 Find alternate glyphs.
1447 This is like OTF_drive_gsub(), but perform only a lookup of type 3
1448 (Alternate Substituion). */
1450 extern int OTF_drive_gsub_alternate (OTF *otf, OTF_GlyphString *gstring,
1451 const char *script, const char *language,
1452 const char *features);
1454 /*** (3-9) OTF_iterate_on_feature() */
1455 typedef int (*OTF_Feature_Callback) (OTF *otf, const char *feature,
1458 extern int OTF_iterate_gsub_feature (OTF *otf, OTF_Feature_Callback callback,
1459 const char *script, const char *language,
1460 const char *feature);
1462 /*** (4) API for error handling ***/
1464 /*** (4-1) Error codes ***/
1467 Global variable holding an error code.
1469 The variable OTF_error is set to one of OTF_ERROR_XXX macros when
1470 an error is detected in the OTF library. */
1471 extern int OTF_error;
1474 Memory allocation error
1476 This error indicates that the library couldn't allocate
1478 #define OTF_ERROR_MEMORY 1
1483 This error indicates that the library fails in opening, reading,
1484 or seeking an OTF file. */
1485 #define OTF_ERROR_FILE 2
1488 Invalid table contents
1490 This error indicates that an OTF file contains invalid data. */
1491 #define OTF_ERROR_TABLE 3
1496 See the function otf_drive_cmap() for more detail. */
1497 #define OTF_ERROR_CMAP_DRIVE 4
1502 See the function OTF_drive_gdef() for more detail. */
1503 #define OTF_ERROR_GDEF_DRIVE 5
1508 See the function OTF_drive_gsub() for more detail. */
1509 #define OTF_ERROR_GSUB_DRIVE 6
1514 See the function OTF_drive_gpos() for more detail. */
1515 #define OTF_ERROR_GPOS_DRIVE 7
1518 FT_Face access error.
1520 This error indicates that the library fails in accessing Sfnt
1521 tables via FT_Face. */
1522 #define OTF_ERROR_FT_FACE 8
1525 /*** (4-2) OTF_perror() */
1528 Print an OTF error message
1530 The OTF_perror() function produces a message on the standard error
1531 output, describing the last error encountered during a call to the
1532 OTF library function. If $PREFIX is not NULL, it is printed
1533 first, followed by a colon and a blank. Then the message and a
1536 extern void OTF_perror (const char *prefix);
1539 /*** (5) API miscellaneous ***/
1542 Return OTF tag of a specified name string.
1544 The OTF_tag() function returns OTF tag of name $NAME. If $NAME is
1545 NULL, return 0. Otherwise, $NAME must be at least 4-byte length.
1546 Only the first 4 characters are took into an account. */
1548 extern OTF_Tag OTF_tag (const char *name);
1551 Convert OTF tag to name string.
1553 The OTF_tag_name() function converts OTF tag $TAG to a 5-byte name
1554 string (including the terminating NULL), and store it in $NAME.
1555 At least 5-byte space must be at $NAME. */
1557 extern void OTF_tag_name (OTF_Tag tag, char *name);
1559 extern int OTF_put_data (OTF *otf, char *id, void *data,
1560 void (*freer) (void *data));
1562 extern void *OTF_get_data (OTF *otf, char *id);
1568 #endif /* not _OTF_H_ */