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.9"
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 9
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()
73 (4) API for error handling
82 /*** (1) Structures for OTF Layout tables and OTF itself */
84 /*** (1-1) Basic types */
86 typedef unsigned OTF_Tag;
87 typedef unsigned OTF_GlyphID;
88 typedef unsigned OTF_Offset;
97 /*** (1-2) "head" table */
101 OTF_Fixed TableVersionNumber;
102 OTF_Fixed fontRevision;
103 unsigned checkSumAdjustment;
104 unsigned magicNumber;
110 /*** (1-3) "name" table */
121 /* If nonzero, NAME is an ASCII string. */
126 #define OTF_max_nameID 23
133 OTF_NameRecord *nameRecord;
134 char *name[OTF_max_nameID + 1];
138 /*** (1-4) "cmap" table */
142 unsigned char glyphIdArray[256];
143 } OTF_EncodingSubtable0;
150 unsigned idRangeOffset;
155 unsigned short subHeaderKeys[256];
157 OTF_cmapSubHeader *subHeaders;
159 OTF_GlyphID *glyphIndexArray;
160 } OTF_EncodingSubtable2;
167 unsigned idRangeOffset;
173 unsigned searchRange;
174 unsigned entrySelector;
176 OTF_cmapSegment *segments;
178 unsigned *glyphIdArray;
179 } OTF_EncodingSubtable4;
185 unsigned *glyphIdArray;
186 } OTF_EncodingSubtable6;
190 unsigned startCharCode;
191 unsigned endCharCode;
192 unsigned startGlyphID;
197 unsigned char is32[8192];
199 OTF_cmapGroup *Groups;
200 } OTF_EncodingSubtable8;
204 unsigned startCharCode;
207 } OTF_EncodingSubtable10;
212 OTF_cmapGroup *Groups;
213 } OTF_EncodingSubtable12;
217 unsigned unicodeValue;
218 unsigned short glyphID;
223 unsigned startUnicodeValue;
224 unsigned short additionalCount;
225 } OTF_UnicodeValueRange;
229 unsigned varSelector;
230 unsigned defaultUVSOffset;
231 unsigned nonDefaultUVSOffset;
233 unsigned numUnicodeValueRanges;
234 OTF_UnicodeValueRange *unicodeValueRanges;
236 unsigned numUVSMappings;
237 OTF_UVSMapping *uvsMappings;
238 } OTF_VariationSelectorRecord;
243 OTF_VariationSelectorRecord *Records;
244 } OTF_EncodingSubtable14;
252 OTF_EncodingSubtable0 *f0;
253 OTF_EncodingSubtable2 *f2;
254 OTF_EncodingSubtable4 *f4;
255 OTF_EncodingSubtable6 *f6;
256 OTF_EncodingSubtable8 *f8;
257 OTF_EncodingSubtable10 *f10;
258 OTF_EncodingSubtable12 *f12;
259 OTF_EncodingSubtable14 *f14;
261 } OTF_EncodingSubtable;
268 OTF_EncodingSubtable subtable;
269 } OTF_EncodingRecord;
275 OTF_EncodingRecord *EncodingRecord;
276 /* Mapping table: Unicode->GlyphID */
277 unsigned short *unicode_table;
279 /* Mapping table: GlyphID->Unicode */
280 unsigned short *decode_table;
284 /*** (1-5) Structures common to GDEF, GSUB, GPOS */
290 unsigned StartCoverageIndex;
296 unsigned CoverageFormat;
299 OTF_GlyphID *GlyphArray;
300 OTF_RangeRecord *RangeRecord;
309 unsigned DeltaFormat;
318 } OTF_ClassRangeRecord;
323 unsigned ClassFormat;
326 OTF_GlyphID StartGlyph;
328 unsigned *ClassValueArray;
331 unsigned ClassRangeCount;
332 OTF_ClassRangeRecord *ClassRangeRecord;
338 /*** (1-6) "GDEF" table */
343 OTF_Offset GlyphClassDef;
344 OTF_Offset AttachList;
345 OTF_Offset LigCaretList;
346 OTF_Offset MarkAttachClassDef;
349 enum OTF_GlyphClassDef
352 OTF_GlyphClassBase = 1,
353 OTF_GlyphClassLigature = 2,
354 OTF_GlyphClassMark = 3,
355 OTF_GlyphClassComponent = 4
362 unsigned *PointIndex;
367 OTF_Coverage Coverage;
369 OTF_AttachPoint *AttachPoint;
375 unsigned CaretValueFormat; /* 1, 2, or 3 */
381 unsigned CaretValuePoint;
385 OTF_DeviceTable DeviceTable;
394 OTF_CaretValue *CaretValue;
399 OTF_Coverage Coverage;
400 unsigned LigGlyphCount;
401 OTF_LigGlyph *LigGlyph;
406 OTF_GDEFHeader header;
407 OTF_ClassDef glyph_class_def;
408 OTF_AttachList attach_list;
409 OTF_LigCaretList lig_caret_list;
410 OTF_ClassDef mark_attach_class_def;
414 /*** (1-7) Structures for ScriptList, FeatureList, and LookupList */
416 /*** The structure hierarchy
443 SubTable.gsub[] or SubTable.gpos[]
449 OTF_Offset LookupOrder;
450 unsigned ReqFeatureIndex;
451 unsigned FeatureCount;
452 unsigned *FeatureIndex;
465 OTF_Offset DefaultLangSysOffset;
466 OTF_LangSys DefaultLangSys;
467 unsigned LangSysCount;
468 OTF_LangSysRecord *LangSysRecord;
469 OTF_LangSys *LangSys;
475 unsigned ScriptCount;
483 OTF_Offset FeatureParams;
484 unsigned LookupCount;
485 unsigned *LookupListIndex;
491 unsigned FeatureCount;
492 OTF_Feature *Feature;
495 typedef struct OTF_LookupSubTableGSUB OTF_LookupSubTableGSUB;
496 typedef struct OTF_LookupSubTableGPOS OTF_LookupSubTableGPOS;
498 enum OTF_LookupFlagBit
500 OTF_RightToLeft = 0x0001,
501 OTF_IgnoreBaseGlyphs = 0x0002,
502 OTF_IgnoreLigatures = 0x0004,
503 OTF_IgnoreMarks = 0x0008,
504 OTF_Reserved = 0x00F0,
505 OTF_MarkAttachmentType = 0xFF00
508 #define OTF_LookupFlagIgnoreMask \
509 (OTF_IgnoreBaseGlyphs | OTF_IgnoreLigatures | OTF_IgnoreMarks)
516 unsigned SubTableCount;
517 OTF_Offset *SubTableOffset;
519 OTF_LookupSubTableGSUB *gsub;
520 OTF_LookupSubTableGPOS *gpos;
527 unsigned LookupCount;
532 /*** (1-8) Structures common to GSUB and GPOS */
534 /* For SubstLookupRecord (GSUB) and PosLookupRecord (GPOS). */
538 unsigned SequenceIndex;
539 unsigned LookupListIndex;
546 unsigned LookupCount;
547 OTF_GlyphID *Input; /* [<GlyphCount> - 1] */
548 OTF_LookupRecord *LookupRecord; /* [<LookupCount>] */
555 OTF_Rule *Rule; /* [<RuleCount>] */
562 unsigned LookupCount;
563 unsigned *Class; /* [<GlyphCount> - 1] */
564 OTF_LookupRecord *LookupRecord; /* [<LookupCount>] */
570 unsigned ClassRuleCnt;
571 OTF_ClassRule *ClassRule; /* [<ClassRuleCnt>] */
577 unsigned BacktrackGlyphCount;
578 OTF_GlyphID *Backtrack;
579 unsigned InputGlyphCount;
581 unsigned LookaheadGlyphCount;
582 OTF_GlyphID *LookAhead;
583 unsigned LookupCount;
584 OTF_LookupRecord *LookupRecord;
590 unsigned ChainRuleCount;
591 OTF_ChainRule *ChainRule;
597 unsigned BacktrackGlyphCount;
599 unsigned InputGlyphCount;
601 unsigned LookaheadGlyphCount;
603 unsigned LookupCount;
604 OTF_LookupRecord *LookupRecord;
605 } OTF_ChainClassRule;
610 unsigned ChainClassRuleCnt;
611 OTF_ChainClassRule *ChainClassRule;
615 /* Common to OTF_GSUB/GPOS_Context1/2/3. */
619 unsigned RuleSetCount;
620 OTF_RuleSet *RuleSet; /* [<RuleSetCount>] */
625 OTF_ClassDef ClassDef;
626 unsigned ClassSetCnt;
627 OTF_ClassSet *ClassSet; /* [<ClassSetCnt>] */
633 unsigned LookupCount;
634 OTF_Coverage *Coverage; /* [<GlyphCount>] */
635 OTF_LookupRecord *LookupRecord; /* [<LookupCount>] */
639 /* Common to OTF_GSUB/GPOS_ChainContext1/2/3. */
643 unsigned ChainRuleSetCount;
644 OTF_ChainRuleSet *ChainRuleSet;
649 OTF_ClassDef BacktrackClassDef;
650 OTF_ClassDef InputClassDef;
651 OTF_ClassDef LookaheadClassDef;
652 unsigned ChainClassSetCnt;
653 OTF_ChainClassSet *ChainClassSet;
658 unsigned BacktrackGlyphCount;
659 OTF_Coverage *Backtrack;
660 unsigned InputGlyphCount;
662 unsigned LookaheadGlyphCount;
663 OTF_Coverage *LookAhead;
664 unsigned LookupCount;
665 OTF_LookupRecord *LookupRecord;
668 /* Common to OTF_GSUB/GPOS. */
673 OTF_ScriptList ScriptList;
674 OTF_FeatureList FeatureList;
675 OTF_LookupList LookupList;
678 /*** (1-9) "GSUB" table */
688 OTF_GlyphID *Substitute;
691 typedef struct OTF_Sequence OTF_Sequence;
695 unsigned SequenceCount;
696 OTF_Sequence *Sequence;
697 } OTF_GSUB_Multiple1;
703 OTF_GlyphID *Substitute;
706 typedef struct OTF_AlternateSet OTF_AlternateSet;
710 unsigned AlternateSetCount;
711 OTF_AlternateSet *AlternateSet;
712 } OTF_GSUB_Alternate1;
714 struct OTF_AlternateSet
718 OTF_GlyphID *Alternate;
721 typedef struct OTF_LigatureSet OTF_LigatureSet;
722 typedef struct OTF_Ligature OTF_Ligature;
726 unsigned LigSetCount;
727 OTF_LigatureSet *LigatureSet;
728 } OTF_GSUB_Ligature1;
730 struct OTF_LigatureSet
733 unsigned LigatureCount;
734 OTF_Ligature *Ligature;
740 OTF_GlyphID LigGlyph;
742 OTF_GlyphID *Component;
745 typedef OTF_Context1 OTF_GSUB_Context1;
747 typedef OTF_Context2 OTF_GSUB_Context2;
749 typedef OTF_Context3 OTF_GSUB_Context3;
751 typedef OTF_ChainContext1 OTF_GSUB_ChainContext1;
753 typedef OTF_ChainContext2 OTF_GSUB_ChainContext2;
755 typedef OTF_ChainContext3 OTF_GSUB_ChainContext3;
759 unsigned ExtensionLookupType;
760 unsigned ExtensionOffset;
761 OTF_LookupSubTableGSUB *ExtensionSubtable;
762 } OTF_GSUB_Extension1;
766 unsigned BacktrackGlyphCount;
767 OTF_Coverage *Backtrack;
768 unsigned LookaheadGlyphCount;
769 OTF_Coverage *LookAhead;
771 OTF_GlyphID *Substitute;
772 } OTF_GSUB_ReverseChain1;
774 struct OTF_LookupSubTableGSUB
777 OTF_Coverage Coverage;
780 OTF_GSUB_Single1 single1;
781 OTF_GSUB_Single2 single2;
783 OTF_GSUB_Multiple1 multiple1;
785 OTF_GSUB_Alternate1 alternate1;
787 OTF_GSUB_Ligature1 ligature1;
789 OTF_GSUB_Context1 context1;
790 OTF_GSUB_Context2 context2;
791 OTF_GSUB_Context3 context3;
793 OTF_GSUB_ChainContext1 chain_context1;
794 OTF_GSUB_ChainContext2 chain_context2;
795 OTF_GSUB_ChainContext3 chain_context3;
797 OTF_GSUB_Extension1 extension1;
799 OTF_GSUB_ReverseChain1 reverse_chain1;
803 typedef OTF_GSUB_GPOS OTF_GSUB;
805 /*** (1-10) "GPOS" table */
809 OTF_XPlacement = 0x0001,
810 OTF_YPlacement = 0x0002,
811 OTF_XAdvance = 0x0004,
812 OTF_YAdvance = 0x0008,
813 OTF_XPlaDevice = 0x0010,
814 OTF_YPlaDevice = 0x0020,
815 OTF_XAdvDevice = 0x0040,
816 OTF_YAdvDevice = 0x0080
825 OTF_DeviceTable XPlaDevice;
826 OTF_DeviceTable YPlaDevice;
827 OTF_DeviceTable XAdvDevice;
828 OTF_DeviceTable YAdvDevice;
834 unsigned AnchorFormat;
839 unsigned AnchorPoint;
842 OTF_DeviceTable XDeviceTable;
843 OTF_DeviceTable YDeviceTable;
851 OTF_Anchor MarkAnchor;
858 OTF_MarkRecord *MarkRecord;
863 unsigned ValueFormat;
864 OTF_ValueRecord Value;
869 unsigned ValueFormat;
871 OTF_ValueRecord *Value; /* [<ValueCount>] */
876 OTF_GlyphID SecondGlyph;
877 OTF_ValueRecord Value1;
878 OTF_ValueRecord Value2;
879 } OTF_PairValueRecord;
884 unsigned PairValueCount;
885 OTF_PairValueRecord *PairValueRecord;
890 unsigned ValueFormat1;
891 unsigned ValueFormat2;
892 unsigned PairSetCount;
893 OTF_PairSet *PairSet;
898 OTF_ValueRecord Value1;
899 OTF_ValueRecord Value2;
904 OTF_Class2Record *Class2Record;
909 unsigned ValueFormat1;
910 unsigned ValueFormat2;
911 OTF_ClassDef ClassDef1;
912 OTF_ClassDef ClassDef2;
913 unsigned Class1Count;
914 unsigned Class2Count;
915 OTF_Class1Record *Class1Record; /* size: <Class1Count> */
920 OTF_Anchor EntryAnchor;
921 OTF_Anchor ExitAnchor;
922 } OTF_EntryExitRecord;
926 unsigned EntryExitCount;
927 OTF_EntryExitRecord *EntryExitRecord;
939 OTF_AnchorRecord *AnchorRecord;
944 OTF_Coverage BaseCoverage;
946 OTF_MarkArray MarkArray;
947 OTF_AnchorArray BaseArray;
948 } OTF_GPOS_MarkBase1;
952 OTF_Anchor *LigatureAnchor; /* [<ClassCount>] */
953 } OTF_ComponentRecord;
958 unsigned ComponentCount;
959 OTF_ComponentRecord *ComponentRecord; /* [<ComponentCount>] */
960 } OTF_LigatureAttach;
965 unsigned LigatureCount;
966 OTF_LigatureAttach *LigatureAttach; /* [<LiagureCount>] */
971 OTF_Coverage LigatureCoverage;
973 OTF_MarkArray MarkArray;
974 OTF_LigatureArray LigatureArray;
979 OTF_Coverage Mark2Coverage;
981 OTF_MarkArray Mark1Array;
982 OTF_AnchorArray Mark2Array;
983 } OTF_GPOS_MarkMark1;
985 typedef OTF_Context1 OTF_GPOS_Context1;
987 typedef OTF_Context2 OTF_GPOS_Context2;
989 typedef OTF_Context3 OTF_GPOS_Context3;
991 typedef OTF_ChainContext1 OTF_GPOS_ChainContext1;
993 typedef OTF_ChainContext2 OTF_GPOS_ChainContext2;
995 typedef OTF_ChainContext3 OTF_GPOS_ChainContext3;
999 unsigned ExtensionLookupType;
1000 unsigned ExtensionOffset;
1001 OTF_LookupSubTableGPOS *ExtensionSubtable;
1002 } OTF_GPOS_Extension1;
1005 struct OTF_LookupSubTableGPOS
1008 OTF_Coverage Coverage;
1011 OTF_GPOS_Single1 single1;
1012 OTF_GPOS_Single2 single2;
1014 OTF_GPOS_Pair1 pair1;
1015 OTF_GPOS_Pair2 pair2;
1017 OTF_GPOS_Cursive1 cursive1;
1019 OTF_GPOS_MarkBase1 mark_base1;
1021 OTF_GPOS_MarkLig1 mark_lig1;
1023 OTF_GPOS_MarkMark1 mark_mark1;
1025 OTF_GPOS_Context1 context1;
1026 OTF_GPOS_Context2 context2;
1027 OTF_GPOS_Context3 context3;
1029 OTF_GPOS_ChainContext1 chain_context1;
1030 OTF_GPOS_ChainContext2 chain_context2;
1031 OTF_GPOS_ChainContext3 chain_context3;
1033 OTF_GPOS_Extension1 extension1;
1037 typedef OTF_GSUB_GPOS OTF_GPOS;
1039 /*** (1-11) Structure for OTF */
1043 OTF_Fixed sfnt_version;
1045 unsigned searchRange;
1046 unsigned enterSelector;
1047 unsigned rangeShift;
1057 } OTF_TableDirectory;
1059 typedef struct OTF_InternalData OTF_InternalData;
1064 OTF_OffsetTable offset_table;
1065 OTF_TableDirectory *table_dirs;
1072 /* The following tables are not yet supported. */
1073 /* OTF_BASE *base; */
1074 /* OTF_JSTF *jstf; */
1075 OTF_InternalData *internal_data;
1079 /*** (2) API for reading OTF */
1081 /*** (2-1) otf_open () */
1086 The OTF_open() function reads the OpenType font file whose name is
1087 $NAME, and return a pointer to the structure of type OTF.
1089 It setups these member of the structure OTF:
1090 filename, offset_table, table_dirs
1092 If the file can't be read or the file contains invalid data, NULL
1093 is returned, and the variable OTF_error is set to one of the
1100 See also OTF_get_table() and OTF_close(). */
1102 extern OTF *OTF_open (const char *name);
1104 #include <ft2build.h>
1105 #include FT_FREETYPE_H
1107 extern OTF *OTF_open_ft_face (FT_Face face);
1110 /*** (2-2) OTF_close () */
1115 The OTF_close() function closes the OpenType font $OTF which must
1116 be what the OTF_open() function returned.
1118 See also OTF_open(). */
1120 extern void OTF_close (OTF *otf);
1123 /*** (2-3) OTF_get_table () */
1126 Get OpenType font table
1128 The OTF_get_table() function setups one of the OTF table specified
1129 by $NAME in the OpenType font $OTF.
1131 $NAME must be one of "head", "name", "cmap", "GDEF", "GSUB", and
1132 "GPOS", and a member of the same name is setup.
1134 If the table is successfully setup, return 0. Otherwise, return
1135 -1, and set the variable OTF_error to OTF_ERROR_TABLE.
1137 See also OTF_open(). */
1139 extern int OTF_get_table (OTF *otf, const char *name);
1141 /*** (2-4) OTF_check_table () */
1144 Check the existence of OpenType font table
1146 The OTF_check_table() function checks if the the OTF table
1147 specified by $NAME exists in OpenType font $OTF.
1149 If the table exists, return 0, else return -1.
1151 See also OTF_open(). */
1153 extern int OTF_check_table (OTF *otf, const char *name);
1155 /*** (2-5) OTF_get_scripts () */
1158 Get supported scripts.
1160 The OTF_get_scripts() function setups OTF_ScriptList of GSUB (if
1161 $GSUBP is nonzero) or GPOS (if $GSUBP is zero) table of the
1164 If the table is successfully setup, return 0. Otherwise, retrun
1165 -1, and set the variable OTF_error to OTF_ERROR_TABLE. */
1167 extern int OTF_get_scripts (OTF *otf, int gsubp);
1169 /*** (2-6) OTF_get_features () */
1172 Get supported features.
1174 The OTF_get_features() function setups OTF_FeatureList of GSUB (if
1175 $GSUBP is nonzero) or GPOS (if $GSUBP is zero) table of the
1178 If the table is successfully setup, return 0. Otherwise, retrun
1179 -1, and set the variable OTF_error to OTF_ERROR_TABLE. */
1181 extern int OTF_get_features (OTF *otf, int gsubp);
1183 /*** (2-7) OTF_check_features */
1186 Check supported features.
1188 The OTF_check_features() function checks if or not the OpenType
1189 font $OTF has, for $SCRIPT and $LANGUAGE, all features in the
1190 array $FEATURES. The array size is $N_FEATURES. If $LANGUAGE is
1191 zero or $OTF doesn't have LangSys for $SCRIPT, the default LangSys
1194 If $OTF has all the features, return 1. Otherwise, return 0. If
1195 an error occurs, return -1, and set the variable OTF_error to
1198 extern int OTF_check_features (OTF *otf, int gsubp,
1199 OTF_Tag script, OTF_Tag language,
1200 const OTF_Tag *features, int n_features);
1202 /*** (3) API for driving OTF */
1204 /*** (3-1) Structure for glyph string */
1207 The structure OTF_Glyph contains information about each glyph in
1208 the structure OTF_GlyphString. */
1212 /** The first two members must be set by a clinet before calling the
1213 function OTF_drive_XXX(). **/
1215 /* Character code of the glyph. The value less than 32 is treated
1216 as a place-holder in a glyph string, and OTF_drive_XXX ()
1217 function just ignore the glyph as if it doesn't exist. */
1220 /* Glyph ID of the glyph. If the value is 0, the library gets a
1221 correct value from the above character code via cmap if such a
1222 glyph is available in the font.
1224 The function OTF_drive_gpos2 may insert a glyph whose glyph_id is
1225 0 but positioning_type is positive. It is not an actual glyph
1226 but just contains positioning information that should be
1227 accumulated to the positioning information of the previous
1229 OTF_GlyphID glyph_id;
1231 /* GlyphClass of the glyph. The value is extracted from the GDEF
1233 enum OTF_GlyphClassDef GlyphClass;
1235 /* MarkAttachClassDef of the glyph. The value is extracted from the
1237 unsigned MarkAttachClass;
1239 /* Positioning format type of the glyph. The value specifies how
1240 the glyph positioning information is encoded in the member <f>.
1241 If the value is N, the union member fN, is used. If the value is
1242 zero, the glyph has no positioning information, i.e. it should be
1243 drawn at the normal position. */
1244 int positioning_type;
1250 enum OTF_ValueFormat format;
1251 OTF_ValueRecord *value;
1254 enum OTF_ValueFormat format;
1255 OTF_ValueRecord *value;
1258 OTF_Anchor *entry_anchor;
1259 OTF_Anchor *exit_anchor;
1262 OTF_Anchor *mark_anchor;
1263 OTF_Anchor *base_anchor;
1266 OTF_Anchor *mark_anchor;
1267 OTF_Anchor *ligature_anchor;
1270 OTF_Anchor *mark1_anchor;
1271 OTF_Anchor *mark2_anchor;
1277 The structure OTF_GlyphString contains an array of glyphs (type
1278 OTF_Glyph). It is used as arguments of otf_drive_XXX(). */
1282 /* How many glyphs are allocated at the memory pointed by the member
1285 /* How many glyphs contain valid information. */
1287 /* Array of glyphs. It must be allocated by malloc(). The
1288 functions otf_drive_XXX() may reallocate it and increase the
1289 members <size> and <used>. */
1294 /*** (3-2) OTF_drive_cmap() */
1297 Process glyph string by Unicode-based cmap table.
1299 The OTF_drive_cmap() function looks up a Unicode-based cmap table
1300 of OpenType font $OTF, and setup the member <glyph_id> of all
1301 glhphs in the glyph string $GSTRING if the value of the member is
1304 extern int OTF_drive_cmap (OTF *otf, OTF_GlyphString *gstring);
1307 Process glyph string by a specific cmap table.
1309 The OTF_drive_cmap2() function looks up a cmap table (whose
1310 Platform-ID is $PLATFORM_ID an Encoding-ID is $ENCODING_ID) of
1311 OpenType font $OTF, and setup the member <glyph_id> of all glhphs
1312 in the glyph string $GSTRING if the value of the member is not
1315 extern int OTF_drive_cmap2 (OTF *otf, OTF_GlyphString *gstring,
1316 int platform_id, int encoding_id);
1320 Store variable glyphs of character C in the array CODE. The array
1321 size must be 256. The Nth element of CODE is the glyph corresponding
1322 to the variation selector (N + 1). The return value is the number
1323 of variation glyphs. */
1325 extern int OTF_get_variation_glyphs (OTF *otf, int c, OTF_GlyphID code[256]);
1328 /*** (3-3) OTF_drive_gdef() */
1331 Process glyph string by GDEF table.
1333 The OTF_drive_gdef() function looks up the GDEF table of OpenType
1334 font $OTF, and setup members <GlyphClass> and <MarkAttachClass> of
1335 all glhphs in the glyph string $GSTRING. */
1337 extern int OTF_drive_gdef (OTF *otf, OTF_GlyphString *gstring);
1340 /*** (3-4) OTF_drive_gsub() */
1343 Process glyph string by GSUB table.
1345 The OTF_drive_gsub() function looks up the GSUB table of OpenType
1346 font $OTF, and by using features the font has for script $SCRIPT
1347 and language system $LANGSYS, update member <glyphs> of the glyph
1348 string $GSTRING. It may substitute, delete, insert glyphs in that
1349 array. $FEATURES is a list of features to apply. This doesn't
1350 perform a lookup of type 3 (Alternate Substitution). For that,
1351 use OTF_drive_gsub_alternate(). */
1353 extern int OTF_drive_gsub (OTF *otf, OTF_GlyphString *gstring,
1354 const char *script, const char *language,
1355 const char *features);
1357 /*** (3-5) OTF_drive_gpos() */
1360 Process glyph string by GPOS table.
1362 The OTF_drive_gpos() function is deprecated. Use
1363 OTF_drive_gpos2() instread. */
1365 extern int OTF_drive_gpos (OTF *otf, OTF_GlyphString *gstring,
1366 const char *script, const char *language,
1367 const char *features);
1370 Process glyph string by GPOS table.
1372 The OTF_drive_gpos2() function looks up the GPOS table of $OTF of
1373 OpenType font $OTF, and by using features the font has for script
1374 $SCRIPT and language system $LANGSYS, setup members
1375 <positioning_type> and <f> of all glhphs in the glyph string
1376 $GSTRING. $FEATURES is a list of features to apply. */
1378 extern int OTF_drive_gpos2 (OTF *otf, OTF_GlyphString *gstring,
1379 const char *script, const char *language,
1380 const char *features);
1382 /*** (3-6) OTF_drive_tables() */
1385 Process glyph string by cmap, GDEF, GSUB, and GPOS tables.
1387 The OTF_drive_tables() function calls OTF_drive_cmap(),
1388 OTF_drive_gdef(), OTF_drive_gsub(), and OTF_drive_gpos() in this
1389 order, and update the glyphs string GSTRING. */
1391 extern int OTF_drive_tables (OTF *otf, OTF_GlyphString *gstring,
1392 const char *script, const char *language,
1393 const char *gsub_features,
1394 const char *gpos_features);
1397 /*** (3-7) OTF_get_unicode() */
1400 Return Unicode code point corresponding to the glyph-id CODE.
1403 extern int OTF_get_unicode (OTF *otf, OTF_GlyphID code);
1405 /*** (3-8) OTF_drive_gsub_alternate() */
1408 Find alternate glyphs.
1410 This is like OTF_drive_gsub(), but perform only a lookup of type 3
1411 (Alternate Substituion). */
1413 extern int OTF_drive_gsub_alternate (OTF *otf, OTF_GlyphString *gstring,
1414 const char *script, const char *language,
1415 const char *features);
1417 /*** (4) API for error handling ***/
1419 /*** (4-1) Error codes ***/
1422 Global variable holding an error code.
1424 The variable OTF_error is set to one of OTF_ERROR_XXX macros when
1425 an error is detected in the OTF library. */
1426 extern int OTF_error;
1429 Memory allocation error
1431 This error indicates that the library couldn't allocate
1433 #define OTF_ERROR_MEMORY 1
1438 This error indicates that the library fails in opening, reading,
1439 or seeking an OTF file. */
1440 #define OTF_ERROR_FILE 2
1443 Invalid table contents
1445 This error indicates that an OTF file contains invalid data. */
1446 #define OTF_ERROR_TABLE 3
1451 See the function otf_drive_cmap() for more detail. */
1452 #define OTF_ERROR_CMAP_DRIVE 4
1457 See the function OTF_drive_gdef() for more detail. */
1458 #define OTF_ERROR_GDEF_DRIVE 5
1463 See the function OTF_drive_gsub() for more detail. */
1464 #define OTF_ERROR_GSUB_DRIVE 6
1469 See the function OTF_drive_gpos() for more detail. */
1470 #define OTF_ERROR_GPOS_DRIVE 7
1473 FT_Face access error.
1475 This error indicates that the library fails in accessing Sfnt
1476 tables via FT_Face. */
1477 #define OTF_ERROR_FT_FACE 8
1480 /*** (4-2) OTF_perror() */
1483 Print an OTF error message
1485 The OTF_perror() function produces a message on the standard error
1486 output, describing the last error encountered during a call to the
1487 OTF library function. If $PREFIX is not NULL, it is printed
1488 first, followed by a colon and a blank. Then the message and a
1491 extern void OTF_perror (const char *prefix);
1494 /*** (5) API miscellaneous ***/
1497 Return OTF tag of a specified name string.
1499 The OTF_tag() function returns OTF tag of name $NAME. If $NAME is
1500 NULL, return 0. Otherwise, $NAME must be at least 4-byte length.
1501 Only the first 4 characters are took into an account. */
1503 extern OTF_Tag OTF_tag (const char *name);
1506 Convert OTF tag to name string.
1508 The OTF_tag_name() function converts OTF tag $TAG to a 5-byte name
1509 string (including the terminating NULL), and store it in $NAME.
1510 At least 5-byte space must be at $NAME. */
1512 extern void OTF_tag_name (OTF_Tag tag, char *name);
1518 #endif /* not _OTF_H_ */