1 /* otf.h -- Header file for libotf (OpenType font library).
3 Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009
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;
280 /* Mapping table: GlyphID->Unicode */
281 unsigned short *decode_table;
282 /* Index of the EncodingRecord for Unicode->GlyphID mapping.
283 -1 means that the font supports only Unicode BMP characters. */
288 /*** (1-5) Structures common to GDEF, GSUB, GPOS */
294 unsigned StartCoverageIndex;
300 unsigned CoverageFormat;
303 OTF_GlyphID *GlyphArray;
304 OTF_RangeRecord *RangeRecord;
313 unsigned DeltaFormat;
322 } OTF_ClassRangeRecord;
327 unsigned ClassFormat;
330 OTF_GlyphID StartGlyph;
332 unsigned *ClassValueArray;
335 unsigned ClassRangeCount;
336 OTF_ClassRangeRecord *ClassRangeRecord;
342 /*** (1-6) "GDEF" table */
347 OTF_Offset GlyphClassDef;
348 OTF_Offset AttachList;
349 OTF_Offset LigCaretList;
350 OTF_Offset MarkAttachClassDef;
353 enum OTF_GlyphClassDef
356 OTF_GlyphClassBase = 1,
357 OTF_GlyphClassLigature = 2,
358 OTF_GlyphClassMark = 3,
359 OTF_GlyphClassComponent = 4
366 unsigned *PointIndex;
371 OTF_Coverage Coverage;
373 OTF_AttachPoint *AttachPoint;
379 unsigned CaretValueFormat; /* 1, 2, or 3 */
385 unsigned CaretValuePoint;
389 OTF_DeviceTable DeviceTable;
398 OTF_CaretValue *CaretValue;
403 OTF_Coverage Coverage;
404 unsigned LigGlyphCount;
405 OTF_LigGlyph *LigGlyph;
410 OTF_GDEFHeader header;
411 OTF_ClassDef glyph_class_def;
412 OTF_AttachList attach_list;
413 OTF_LigCaretList lig_caret_list;
414 OTF_ClassDef mark_attach_class_def;
418 /*** (1-7) Structures for ScriptList, FeatureList, and LookupList */
420 /*** The structure hierarchy
447 SubTable.gsub[] or SubTable.gpos[]
453 OTF_Offset LookupOrder;
454 unsigned ReqFeatureIndex;
455 unsigned FeatureCount;
456 unsigned *FeatureIndex;
469 OTF_Offset DefaultLangSysOffset;
470 OTF_LangSys DefaultLangSys;
471 unsigned LangSysCount;
472 OTF_LangSysRecord *LangSysRecord;
473 OTF_LangSys *LangSys;
479 unsigned ScriptCount;
487 OTF_Offset FeatureParams;
488 unsigned LookupCount;
489 unsigned *LookupListIndex;
495 unsigned FeatureCount;
496 OTF_Feature *Feature;
499 typedef struct OTF_LookupSubTableGSUB OTF_LookupSubTableGSUB;
500 typedef struct OTF_LookupSubTableGPOS OTF_LookupSubTableGPOS;
502 enum OTF_LookupFlagBit
504 OTF_RightToLeft = 0x0001,
505 OTF_IgnoreBaseGlyphs = 0x0002,
506 OTF_IgnoreLigatures = 0x0004,
507 OTF_IgnoreMarks = 0x0008,
508 OTF_Reserved = 0x00F0,
509 OTF_MarkAttachmentType = 0xFF00
512 #define OTF_LookupFlagIgnoreMask \
513 (OTF_IgnoreBaseGlyphs | OTF_IgnoreLigatures | OTF_IgnoreMarks)
520 unsigned SubTableCount;
521 OTF_Offset *SubTableOffset;
523 OTF_LookupSubTableGSUB *gsub;
524 OTF_LookupSubTableGPOS *gpos;
531 unsigned LookupCount;
536 /*** (1-8) Structures common to GSUB and GPOS */
538 /* For SubstLookupRecord (GSUB) and PosLookupRecord (GPOS). */
542 unsigned SequenceIndex;
543 unsigned LookupListIndex;
550 unsigned LookupCount;
551 OTF_GlyphID *Input; /* [<GlyphCount> - 1] */
552 OTF_LookupRecord *LookupRecord; /* [<LookupCount>] */
559 OTF_Rule *Rule; /* [<RuleCount>] */
566 unsigned LookupCount;
567 unsigned *Class; /* [<GlyphCount> - 1] */
568 OTF_LookupRecord *LookupRecord; /* [<LookupCount>] */
574 unsigned ClassRuleCnt;
575 OTF_ClassRule *ClassRule; /* [<ClassRuleCnt>] */
581 unsigned BacktrackGlyphCount;
582 OTF_GlyphID *Backtrack;
583 unsigned InputGlyphCount;
585 unsigned LookaheadGlyphCount;
586 OTF_GlyphID *LookAhead;
587 unsigned LookupCount;
588 OTF_LookupRecord *LookupRecord;
594 unsigned ChainRuleCount;
595 OTF_ChainRule *ChainRule;
601 unsigned BacktrackGlyphCount;
603 unsigned InputGlyphCount;
605 unsigned LookaheadGlyphCount;
607 unsigned LookupCount;
608 OTF_LookupRecord *LookupRecord;
609 } OTF_ChainClassRule;
614 unsigned ChainClassRuleCnt;
615 OTF_ChainClassRule *ChainClassRule;
619 /* Common to OTF_GSUB/GPOS_Context1/2/3. */
623 unsigned RuleSetCount;
624 OTF_RuleSet *RuleSet; /* [<RuleSetCount>] */
629 OTF_ClassDef ClassDef;
630 unsigned ClassSetCnt;
631 OTF_ClassSet *ClassSet; /* [<ClassSetCnt>] */
637 unsigned LookupCount;
638 OTF_Coverage *Coverage; /* [<GlyphCount>] */
639 OTF_LookupRecord *LookupRecord; /* [<LookupCount>] */
643 /* Common to OTF_GSUB/GPOS_ChainContext1/2/3. */
647 unsigned ChainRuleSetCount;
648 OTF_ChainRuleSet *ChainRuleSet;
653 OTF_ClassDef BacktrackClassDef;
654 OTF_ClassDef InputClassDef;
655 OTF_ClassDef LookaheadClassDef;
656 unsigned ChainClassSetCnt;
657 OTF_ChainClassSet *ChainClassSet;
662 unsigned BacktrackGlyphCount;
663 OTF_Coverage *Backtrack;
664 unsigned InputGlyphCount;
666 unsigned LookaheadGlyphCount;
667 OTF_Coverage *LookAhead;
668 unsigned LookupCount;
669 OTF_LookupRecord *LookupRecord;
672 /* Common to OTF_GSUB/GPOS. */
677 OTF_ScriptList ScriptList;
678 OTF_FeatureList FeatureList;
679 OTF_LookupList LookupList;
682 /*** (1-9) "GSUB" table */
692 OTF_GlyphID *Substitute;
695 typedef struct OTF_Sequence OTF_Sequence;
699 unsigned SequenceCount;
700 OTF_Sequence *Sequence;
701 } OTF_GSUB_Multiple1;
707 OTF_GlyphID *Substitute;
710 typedef struct OTF_AlternateSet OTF_AlternateSet;
714 unsigned AlternateSetCount;
715 OTF_AlternateSet *AlternateSet;
716 } OTF_GSUB_Alternate1;
718 struct OTF_AlternateSet
722 OTF_GlyphID *Alternate;
725 typedef struct OTF_LigatureSet OTF_LigatureSet;
726 typedef struct OTF_Ligature OTF_Ligature;
730 unsigned LigSetCount;
731 OTF_LigatureSet *LigatureSet;
732 } OTF_GSUB_Ligature1;
734 struct OTF_LigatureSet
737 unsigned LigatureCount;
738 OTF_Ligature *Ligature;
744 OTF_GlyphID LigGlyph;
746 OTF_GlyphID *Component;
749 typedef OTF_Context1 OTF_GSUB_Context1;
751 typedef OTF_Context2 OTF_GSUB_Context2;
753 typedef OTF_Context3 OTF_GSUB_Context3;
755 typedef OTF_ChainContext1 OTF_GSUB_ChainContext1;
757 typedef OTF_ChainContext2 OTF_GSUB_ChainContext2;
759 typedef OTF_ChainContext3 OTF_GSUB_ChainContext3;
763 unsigned ExtensionLookupType;
764 unsigned ExtensionOffset;
765 OTF_LookupSubTableGSUB *ExtensionSubtable;
766 } OTF_GSUB_Extension1;
770 unsigned BacktrackGlyphCount;
771 OTF_Coverage *Backtrack;
772 unsigned LookaheadGlyphCount;
773 OTF_Coverage *LookAhead;
775 OTF_GlyphID *Substitute;
776 } OTF_GSUB_ReverseChain1;
778 struct OTF_LookupSubTableGSUB
781 OTF_Coverage Coverage;
784 OTF_GSUB_Single1 single1;
785 OTF_GSUB_Single2 single2;
787 OTF_GSUB_Multiple1 multiple1;
789 OTF_GSUB_Alternate1 alternate1;
791 OTF_GSUB_Ligature1 ligature1;
793 OTF_GSUB_Context1 context1;
794 OTF_GSUB_Context2 context2;
795 OTF_GSUB_Context3 context3;
797 OTF_GSUB_ChainContext1 chain_context1;
798 OTF_GSUB_ChainContext2 chain_context2;
799 OTF_GSUB_ChainContext3 chain_context3;
801 OTF_GSUB_Extension1 extension1;
803 OTF_GSUB_ReverseChain1 reverse_chain1;
807 typedef OTF_GSUB_GPOS OTF_GSUB;
809 /*** (1-10) "GPOS" table */
813 OTF_XPlacement = 0x0001,
814 OTF_YPlacement = 0x0002,
815 OTF_XAdvance = 0x0004,
816 OTF_YAdvance = 0x0008,
817 OTF_XPlaDevice = 0x0010,
818 OTF_YPlaDevice = 0x0020,
819 OTF_XAdvDevice = 0x0040,
820 OTF_YAdvDevice = 0x0080
829 OTF_DeviceTable XPlaDevice;
830 OTF_DeviceTable YPlaDevice;
831 OTF_DeviceTable XAdvDevice;
832 OTF_DeviceTable YAdvDevice;
838 unsigned AnchorFormat;
843 unsigned AnchorPoint;
846 OTF_DeviceTable XDeviceTable;
847 OTF_DeviceTable YDeviceTable;
855 OTF_Anchor MarkAnchor;
862 OTF_MarkRecord *MarkRecord;
867 unsigned ValueFormat;
868 OTF_ValueRecord Value;
873 unsigned ValueFormat;
875 OTF_ValueRecord *Value; /* [<ValueCount>] */
880 OTF_GlyphID SecondGlyph;
881 OTF_ValueRecord Value1;
882 OTF_ValueRecord Value2;
883 } OTF_PairValueRecord;
888 unsigned PairValueCount;
889 OTF_PairValueRecord *PairValueRecord;
894 unsigned ValueFormat1;
895 unsigned ValueFormat2;
896 unsigned PairSetCount;
897 OTF_PairSet *PairSet;
902 OTF_ValueRecord Value1;
903 OTF_ValueRecord Value2;
908 OTF_Class2Record *Class2Record;
913 unsigned ValueFormat1;
914 unsigned ValueFormat2;
915 OTF_ClassDef ClassDef1;
916 OTF_ClassDef ClassDef2;
917 unsigned Class1Count;
918 unsigned Class2Count;
919 OTF_Class1Record *Class1Record; /* size: <Class1Count> */
924 OTF_Anchor EntryAnchor;
925 OTF_Anchor ExitAnchor;
926 } OTF_EntryExitRecord;
930 unsigned EntryExitCount;
931 OTF_EntryExitRecord *EntryExitRecord;
943 OTF_AnchorRecord *AnchorRecord;
948 OTF_Coverage BaseCoverage;
950 OTF_MarkArray MarkArray;
951 OTF_AnchorArray BaseArray;
952 } OTF_GPOS_MarkBase1;
956 OTF_Anchor *LigatureAnchor; /* [<ClassCount>] */
957 } OTF_ComponentRecord;
962 unsigned ComponentCount;
963 OTF_ComponentRecord *ComponentRecord; /* [<ComponentCount>] */
964 } OTF_LigatureAttach;
969 unsigned LigatureCount;
970 OTF_LigatureAttach *LigatureAttach; /* [<LiagureCount>] */
975 OTF_Coverage LigatureCoverage;
977 OTF_MarkArray MarkArray;
978 OTF_LigatureArray LigatureArray;
983 OTF_Coverage Mark2Coverage;
985 OTF_MarkArray Mark1Array;
986 OTF_AnchorArray Mark2Array;
987 } OTF_GPOS_MarkMark1;
989 typedef OTF_Context1 OTF_GPOS_Context1;
991 typedef OTF_Context2 OTF_GPOS_Context2;
993 typedef OTF_Context3 OTF_GPOS_Context3;
995 typedef OTF_ChainContext1 OTF_GPOS_ChainContext1;
997 typedef OTF_ChainContext2 OTF_GPOS_ChainContext2;
999 typedef OTF_ChainContext3 OTF_GPOS_ChainContext3;
1003 unsigned ExtensionLookupType;
1004 unsigned ExtensionOffset;
1005 OTF_LookupSubTableGPOS *ExtensionSubtable;
1006 } OTF_GPOS_Extension1;
1009 struct OTF_LookupSubTableGPOS
1012 OTF_Coverage Coverage;
1015 OTF_GPOS_Single1 single1;
1016 OTF_GPOS_Single2 single2;
1018 OTF_GPOS_Pair1 pair1;
1019 OTF_GPOS_Pair2 pair2;
1021 OTF_GPOS_Cursive1 cursive1;
1023 OTF_GPOS_MarkBase1 mark_base1;
1025 OTF_GPOS_MarkLig1 mark_lig1;
1027 OTF_GPOS_MarkMark1 mark_mark1;
1029 OTF_GPOS_Context1 context1;
1030 OTF_GPOS_Context2 context2;
1031 OTF_GPOS_Context3 context3;
1033 OTF_GPOS_ChainContext1 chain_context1;
1034 OTF_GPOS_ChainContext2 chain_context2;
1035 OTF_GPOS_ChainContext3 chain_context3;
1037 OTF_GPOS_Extension1 extension1;
1041 typedef OTF_GSUB_GPOS OTF_GPOS;
1043 /*** (1-11) Structure for OTF */
1047 OTF_Fixed sfnt_version;
1049 unsigned searchRange;
1050 unsigned enterSelector;
1051 unsigned rangeShift;
1061 } OTF_TableDirectory;
1063 typedef struct OTF_InternalData OTF_InternalData;
1068 OTF_OffsetTable offset_table;
1069 OTF_TableDirectory *table_dirs;
1076 /* The following tables are not yet supported. */
1077 /* OTF_BASE *base; */
1078 /* OTF_JSTF *jstf; */
1079 OTF_InternalData *internal_data;
1083 /*** (2) API for reading OTF */
1085 /*** (2-1) otf_open () */
1090 The OTF_open() function reads the OpenType font file whose name is
1091 $NAME, and return a pointer to the structure of type OTF.
1093 It setups these member of the structure OTF:
1094 filename, offset_table, table_dirs
1096 If the file can't be read or the file contains invalid data, NULL
1097 is returned, and the variable OTF_error is set to one of the
1104 See also OTF_get_table() and OTF_close(). */
1106 extern OTF *OTF_open (const char *name);
1108 #include <ft2build.h>
1109 #include FT_FREETYPE_H
1111 extern OTF *OTF_open_ft_face (FT_Face face);
1114 /*** (2-2) OTF_close () */
1119 The OTF_close() function closes the OpenType font $OTF which must
1120 be what the OTF_open() function returned.
1122 See also OTF_open(). */
1124 extern void OTF_close (OTF *otf);
1127 /*** (2-3) OTF_get_table () */
1130 Get OpenType font table
1132 The OTF_get_table() function setups one of the OTF table specified
1133 by $NAME in the OpenType font $OTF.
1135 $NAME must be one of "head", "name", "cmap", "GDEF", "GSUB", and
1136 "GPOS", and a member of the same name is setup.
1138 If the table is successfully setup, return 0. Otherwise, return
1139 -1, and set the variable OTF_error to OTF_ERROR_TABLE.
1141 See also OTF_open(). */
1143 extern int OTF_get_table (OTF *otf, const char *name);
1145 /*** (2-4) OTF_check_table () */
1148 Check the existence of OpenType font table
1150 The OTF_check_table() function checks if the the OTF table
1151 specified by $NAME exists in OpenType font $OTF.
1153 If the table exists, return 0, else return -1.
1155 See also OTF_open(). */
1157 extern int OTF_check_table (OTF *otf, const char *name);
1159 /*** (2-5) OTF_get_scripts () */
1162 Get supported scripts.
1164 The OTF_get_scripts() function setups OTF_ScriptList of GSUB (if
1165 $GSUBP is nonzero) or GPOS (if $GSUBP is zero) table of the
1168 If the table is successfully setup, return 0. Otherwise, retrun
1169 -1, and set the variable OTF_error to OTF_ERROR_TABLE. */
1171 extern int OTF_get_scripts (OTF *otf, int gsubp);
1173 /*** (2-6) OTF_get_features () */
1176 Get supported features.
1178 The OTF_get_features() function setups OTF_FeatureList of GSUB (if
1179 $GSUBP is nonzero) or GPOS (if $GSUBP is zero) table of the
1182 If the table is successfully setup, return 0. Otherwise, retrun
1183 -1, and set the variable OTF_error to OTF_ERROR_TABLE. */
1185 extern int OTF_get_features (OTF *otf, int gsubp);
1187 /*** (2-7) OTF_check_features */
1190 Check supported features.
1192 The OTF_check_features() function checks if or not the OpenType
1193 font $OTF has, for $SCRIPT and $LANGUAGE, all features in the
1194 array $FEATURES. The array size is $N_FEATURES. If $LANGUAGE is
1195 zero or $OTF doesn't have LangSys for $SCRIPT, the default LangSys
1198 If $OTF has all the features, return 1. Otherwise, return 0. If
1199 an error occurs, return -1, and set the variable OTF_error to
1202 extern int OTF_check_features (OTF *otf, int gsubp,
1203 OTF_Tag script, OTF_Tag language,
1204 const OTF_Tag *features, int n_features);
1206 /*** (3) API for driving OTF */
1208 /*** (3-1) Structure for glyph string */
1211 The structure OTF_Glyph contains information about each glyph in
1212 the structure OTF_GlyphString. */
1216 /** The first two members must be set by a clinet before calling the
1217 function OTF_drive_XXX(). **/
1219 /* Character code of the glyph. The value less than 32 is treated
1220 as a place-holder in a glyph string, and OTF_drive_XXX ()
1221 function just ignore the glyph as if it doesn't exist. */
1224 /* Glyph ID of the glyph. If the value is 0, the library gets a
1225 correct value from the above character code via cmap if such a
1226 glyph is available in the font.
1228 The function OTF_drive_gpos2 may insert a glyph whose glyph_id is
1229 0 but positioning_type is positive. It is not an actual glyph
1230 but just contains positioning information that should be
1231 accumulated to the positioning information of the previous
1233 OTF_GlyphID glyph_id;
1235 /* GlyphClass of the glyph. The value is extracted from the GDEF
1237 enum OTF_GlyphClassDef GlyphClass;
1239 /* MarkAttachClassDef of the glyph. The value is extracted from the
1241 unsigned MarkAttachClass;
1243 /* Positioning format type of the glyph. The value specifies how
1244 the glyph positioning information is encoded in the member <f>.
1245 If the value is N, the union member fN, is used. If the value is
1246 zero, the glyph has no positioning information, i.e. it should be
1247 drawn at the normal position. */
1248 int positioning_type;
1254 enum OTF_ValueFormat format;
1255 OTF_ValueRecord *value;
1258 enum OTF_ValueFormat format;
1259 OTF_ValueRecord *value;
1262 OTF_Anchor *entry_anchor;
1263 OTF_Anchor *exit_anchor;
1266 OTF_Anchor *mark_anchor;
1267 OTF_Anchor *base_anchor;
1270 OTF_Anchor *mark_anchor;
1271 OTF_Anchor *ligature_anchor;
1274 OTF_Anchor *mark1_anchor;
1275 OTF_Anchor *mark2_anchor;
1281 The structure OTF_GlyphString contains an array of glyphs (type
1282 OTF_Glyph). It is used as arguments of otf_drive_XXX(). */
1286 /* How many glyphs are allocated at the memory pointed by the member
1289 /* How many glyphs contain valid information. */
1291 /* Array of glyphs. It must be allocated by malloc(). The
1292 functions otf_drive_XXX() may reallocate it and increase the
1293 members <size> and <used>. */
1298 /*** (3-2) OTF_drive_cmap() */
1301 Process glyph string by Unicode-based cmap table.
1303 The OTF_drive_cmap() function looks up a Unicode-based cmap table
1304 of OpenType font $OTF, and setup the member <glyph_id> of all
1305 glhphs in the glyph string $GSTRING if the value of the member is
1308 extern int OTF_drive_cmap (OTF *otf, OTF_GlyphString *gstring);
1311 Process glyph string by a specific cmap table.
1313 The OTF_drive_cmap2() function looks up a cmap table (whose
1314 Platform-ID is $PLATFORM_ID an Encoding-ID is $ENCODING_ID) of
1315 OpenType font $OTF, and setup the member <glyph_id> of all glhphs
1316 in the glyph string $GSTRING if the value of the member is not
1319 extern int OTF_drive_cmap2 (OTF *otf, OTF_GlyphString *gstring,
1320 int platform_id, int encoding_id);
1324 Store variable glyphs of character C in the array CODE. The array
1325 size must be 256. The Nth element of CODE is the glyph corresponding
1326 to the variation selector (N + 1). The return value is the number
1327 of variation glyphs. */
1329 extern int OTF_get_variation_glyphs (OTF *otf, int c, OTF_GlyphID code[256]);
1332 /*** (3-3) OTF_drive_gdef() */
1335 Process glyph string by GDEF table.
1337 The OTF_drive_gdef() function looks up the GDEF table of OpenType
1338 font $OTF, and setup members <GlyphClass> and <MarkAttachClass> of
1339 all glhphs in the glyph string $GSTRING. */
1341 extern int OTF_drive_gdef (OTF *otf, OTF_GlyphString *gstring);
1344 /*** (3-4) OTF_drive_gsub() */
1347 Process glyph string by GSUB table.
1349 The OTF_drive_gsub() function looks up the GSUB table of OpenType
1350 font $OTF, and by using features the font has for script $SCRIPT
1351 and language system $LANGSYS, update member <glyphs> of the glyph
1352 string $GSTRING. It may substitute, delete, insert glyphs in that
1353 array. $FEATURES is a list of features to apply. This doesn't
1354 perform a lookup of type 3 (Alternate Substitution). For that,
1355 use OTF_drive_gsub_alternate(). */
1357 extern int OTF_drive_gsub (OTF *otf, OTF_GlyphString *gstring,
1358 const char *script, const char *language,
1359 const char *features);
1361 /*** (3-5) OTF_drive_gpos() */
1364 Process glyph string by GPOS table.
1366 The OTF_drive_gpos() function is deprecated. Use
1367 OTF_drive_gpos2() instread. */
1369 extern int OTF_drive_gpos (OTF *otf, OTF_GlyphString *gstring,
1370 const char *script, const char *language,
1371 const char *features);
1374 Process glyph string by GPOS table.
1376 The OTF_drive_gpos2() function looks up the GPOS table of $OTF of
1377 OpenType font $OTF, and by using features the font has for script
1378 $SCRIPT and language system $LANGSYS, setup members
1379 <positioning_type> and <f> of all glhphs in the glyph string
1380 $GSTRING. $FEATURES is a list of features to apply. */
1382 extern int OTF_drive_gpos2 (OTF *otf, OTF_GlyphString *gstring,
1383 const char *script, const char *language,
1384 const char *features);
1386 /*** (3-6) OTF_drive_tables() */
1389 Process glyph string by cmap, GDEF, GSUB, and GPOS tables.
1391 The OTF_drive_tables() function calls OTF_drive_cmap(),
1392 OTF_drive_gdef(), OTF_drive_gsub(), and OTF_drive_gpos() in this
1393 order, and update the glyphs string GSTRING. */
1395 extern int OTF_drive_tables (OTF *otf, OTF_GlyphString *gstring,
1396 const char *script, const char *language,
1397 const char *gsub_features,
1398 const char *gpos_features);
1401 /*** (3-7) OTF_get_unicode() */
1404 Return Unicode code point corresponding to the glyph-id CODE.
1407 extern int OTF_get_unicode (OTF *otf, OTF_GlyphID code);
1409 /*** (3-8) OTF_drive_gsub_alternate() */
1412 Find alternate glyphs.
1414 This is like OTF_drive_gsub(), but perform only a lookup of type 3
1415 (Alternate Substituion). */
1417 extern int OTF_drive_gsub_alternate (OTF *otf, OTF_GlyphString *gstring,
1418 const char *script, const char *language,
1419 const char *features);
1421 /*** (3-9) OTF_iterate_on_feature() */
1422 typedef int (*OTF_Feature_Callback) (OTF *otf, const char *feature,
1425 extern int OTF_iterate_gsub_feature (OTF *otf, OTF_Feature_Callback callback,
1426 const char *script, const char *language,
1427 const char *feature);
1429 /*** (4) API for error handling ***/
1431 /*** (4-1) Error codes ***/
1434 Global variable holding an error code.
1436 The variable OTF_error is set to one of OTF_ERROR_XXX macros when
1437 an error is detected in the OTF library. */
1438 extern int OTF_error;
1441 Memory allocation error
1443 This error indicates that the library couldn't allocate
1445 #define OTF_ERROR_MEMORY 1
1450 This error indicates that the library fails in opening, reading,
1451 or seeking an OTF file. */
1452 #define OTF_ERROR_FILE 2
1455 Invalid table contents
1457 This error indicates that an OTF file contains invalid data. */
1458 #define OTF_ERROR_TABLE 3
1463 See the function otf_drive_cmap() for more detail. */
1464 #define OTF_ERROR_CMAP_DRIVE 4
1469 See the function OTF_drive_gdef() for more detail. */
1470 #define OTF_ERROR_GDEF_DRIVE 5
1475 See the function OTF_drive_gsub() for more detail. */
1476 #define OTF_ERROR_GSUB_DRIVE 6
1481 See the function OTF_drive_gpos() for more detail. */
1482 #define OTF_ERROR_GPOS_DRIVE 7
1485 FT_Face access error.
1487 This error indicates that the library fails in accessing Sfnt
1488 tables via FT_Face. */
1489 #define OTF_ERROR_FT_FACE 8
1492 /*** (4-2) OTF_perror() */
1495 Print an OTF error message
1497 The OTF_perror() function produces a message on the standard error
1498 output, describing the last error encountered during a call to the
1499 OTF library function. If $PREFIX is not NULL, it is printed
1500 first, followed by a colon and a blank. Then the message and a
1503 extern void OTF_perror (const char *prefix);
1506 /*** (5) API miscellaneous ***/
1509 Return OTF tag of a specified name string.
1511 The OTF_tag() function returns OTF tag of name $NAME. If $NAME is
1512 NULL, return 0. Otherwise, $NAME must be at least 4-byte length.
1513 Only the first 4 characters are took into an account. */
1515 extern OTF_Tag OTF_tag (const char *name);
1518 Convert OTF tag to name string.
1520 The OTF_tag_name() function converts OTF tag $TAG to a 5-byte name
1521 string (including the terminating NULL), and store it in $NAME.
1522 At least 5-byte space must be at $NAME. */
1524 extern void OTF_tag_name (OTF_Tag tag, char *name);
1526 extern int OTF_put_data (OTF *otf, char *id, void *data,
1527 void (*freer) (void *data));
1529 extern void *OTF_get_data (OTF *otf, char *id);
1535 #endif /* not _OTF_H_ */