1 /* otf.h -- Header file for libotf (OpenType font library).
3 Copyright (C) 2003, 2004, 2005, 2006
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. */
27 /* Version name of this library. */
28 #define LIBOTF_VERSION "0.9.5"
30 /* Major version number. */
31 #define LIBOTF_MAJOR_VERSION 0
32 /* Minor version number. */
33 #define LIBOTF_MINOR_VERSION 9
34 /* Release (i.e. patch level) number. */
35 #define LIBOTF_RELEASE_NUMBER 5
40 (1) Structures for OTF Layout tables and OTF itself
45 (1-5) Structures common to GDEF, GSUB, and GPOS
47 (1-7) Structures for ScriptList, FeatureList, and LookupList
48 (1-8) Structures common to GSUB and GPOS
51 (1-11) Structure for OTF
53 (2) API for reading OTF
54 (2-1) OTF_open(), OTF_open_ft_face()
57 (2-4) OTF_check_table()
59 (3) API for driving OTF
60 (3-1) Structure for glyph string
61 (3-2) OTF_drive_cmap()
62 (3-3) OTF_drive_gdef()
63 (3-4) OTF_drive_gsub()
64 (3-5) OTF_drive_gpos()
65 (3-6) OTF_drive_tables()
66 (3-7) OTF_get_unicode()
67 (3-8) OTF_drive_gsub_alternate()
69 (4) API for error handling
78 /*** (1) Structures for OTF Layout tables and OTF itself */
80 /*** (1-1) Basic types */
82 typedef unsigned OTF_Tag;
83 typedef unsigned OTF_GlyphID;
84 typedef unsigned OTF_Offset;
93 /*** (1-2) "head" table */
97 OTF_Fixed TableVersionNumber;
98 OTF_Fixed fontRevision;
99 unsigned checkSumAdjustment;
100 unsigned magicNumber;
106 /*** (1-3) "name" table */
117 /* If nonzero, NAME is an ASCII string. */
122 #define OTF_max_nameID 23
129 OTF_NameRecord *nameRecord;
130 char *name[OTF_max_nameID + 1];
134 /*** (1-4) "cmap" table */
138 unsigned char glyphIdArray[256];
139 } OTF_EncodingSubtable0;
146 unsigned idRangeOffset;
151 unsigned short subHeaderKeys[256];
153 OTF_cmapSubHeader *subHeaders;
155 OTF_GlyphID *glyphIndexArray;
156 } OTF_EncodingSubtable2;
163 unsigned idRangeOffset;
169 unsigned searchRange;
170 unsigned entrySelector;
172 OTF_cmapSegument *segments;
174 unsigned *glyphIdArray;
175 } OTF_EncodingSubtable4;
181 unsigned *glyphIdArray;
182 } OTF_EncodingSubtable6;
186 unsigned startCharCode;
187 unsigned endCharCode;
188 unsigned startGlyphID;
193 unsigned char is32[8192];
195 OTF_cmapGroup *Groups;
196 } OTF_EncodingSubtable8;
200 unsigned startCharCode;
203 } OTF_EncodingSubtable10;
208 OTF_cmapGroup *Groups;
209 } OTF_EncodingSubtable12;
217 OTF_EncodingSubtable0 *f0;
218 OTF_EncodingSubtable2 *f2;
219 OTF_EncodingSubtable4 *f4;
220 OTF_EncodingSubtable6 *f6;
221 OTF_EncodingSubtable8 *f8;
222 OTF_EncodingSubtable10 *f10;
223 OTF_EncodingSubtable12 *f12;
225 } OTF_EncodingSubtable;
232 OTF_EncodingSubtable subtable;
233 } OTF_EncodingRecord;
239 OTF_EncodingRecord *EncodingRecord;
240 /* Mapping table: Unicode->GlyphID */
241 unsigned short *unicode_table;
243 /* Mapping table: GlyphID->Unicode */
244 unsigned short *decode_table;
248 /*** (1-5) Structures common to GDEF, GSUB, GPOS */
254 unsigned StartCoverageIndex;
260 unsigned CoverageFormat;
263 OTF_GlyphID *GlyphArray;
264 OTF_RangeRecord *RangeRecord;
273 unsigned DeltaFormat;
282 } OTF_ClassRangeRecord;
287 unsigned ClassFormat;
290 OTF_GlyphID StartGlyph;
292 unsigned *ClassValueArray;
295 unsigned ClassRangeCount;
296 OTF_ClassRangeRecord *ClassRangeRecord;
302 /*** (1-6) "GDEF" table */
307 OTF_Offset GlyphClassDef;
308 OTF_Offset AttachList;
309 OTF_Offset LigCaretList;
310 OTF_Offset MarkAttachClassDef;
313 enum OTF_GlyphClassDef
316 OTF_GlyphClassBase = 1,
317 OTF_GlyphClassLigature = 2,
318 OTF_GlyphClassMark = 3,
319 OTF_GlyphClassComponent = 4
326 unsigned *PointIndex;
331 OTF_Coverage Coverage;
333 OTF_AttachPoint *AttachPoint;
339 unsigned CaretValueFormat; /* 1, 2, or 3 */
345 unsigned CaretValuePoint;
349 OTF_DeviceTable DeviceTable;
358 OTF_CaretValue *CaretValue;
363 OTF_Coverage Coverage;
364 unsigned LigGlyphCount;
365 OTF_LigGlyph *LigGlyph;
370 OTF_GDEFHeader header;
371 OTF_ClassDef glyph_class_def;
372 OTF_AttachList attach_list;
373 OTF_LigCaretList lig_caret_list;
374 OTF_ClassDef mark_attach_class_def;
378 /*** (1-7) Structures for ScriptList, FeatureList, and LookupList */
380 /*** The structure hierarchy
407 SubTable.gsub[] or SubTable.gpos[]
413 OTF_Offset LookupOrder;
414 unsigned ReqFeatureIndex;
415 unsigned FeatureCount;
416 unsigned *FeatureIndex;
429 OTF_Offset DefaultLangSysOffset;
430 OTF_LangSys DefaultLangSys;
431 unsigned LangSysCount;
432 OTF_LangSysRecord *LangSysRecord;
433 OTF_LangSys *LangSys;
439 unsigned ScriptCount;
447 OTF_Offset FeatureParams;
448 unsigned LookupCount;
449 unsigned *LookupListIndex;
455 unsigned FeatureCount;
456 OTF_Feature *Feature;
459 typedef struct OTF_LookupSubTableGSUB OTF_LookupSubTableGSUB;
460 typedef struct OTF_LookupSubTableGPOS OTF_LookupSubTableGPOS;
462 enum OTF_LookupFlagBit
464 OTF_RightToLeft = 0x0001,
465 OTF_IgnoreBaseGlyphs = 0x0002,
466 OTF_IgnoreLigatures = 0x0004,
467 OTF_IgnoreMarks = 0x0008,
468 OTF_Reserved = 0x00F0,
469 OTF_MarkAttachmentType = 0xFF00
472 #define OTF_LookupFlagIgnoreMask \
473 (OTF_IgnoreBaseGlyphs | OTF_IgnoreLigatures | OTF_IgnoreMarks)
480 unsigned SubTableCount;
481 OTF_Offset *SubTableOffset;
483 OTF_LookupSubTableGSUB *gsub;
484 OTF_LookupSubTableGPOS *gpos;
491 unsigned LookupCount;
496 /*** (1-8) Structures common to GSUB and GPOS */
498 /* For SubstLookupRecord (GSUB) and PosLookupRecord (GPOS). */
502 unsigned SequenceIndex;
503 unsigned LookupListIndex;
510 unsigned LookupCount;
511 OTF_GlyphID *Input; /* [<GlyphCount> - 1] */
512 OTF_LookupRecord *LookupRecord; /* [<LookupCount>] */
519 OTF_Rule *Rule; /* [<RuleCount>] */
526 unsigned LookupCount;
527 unsigned *Class; /* [<GlyphCount> - 1] */
528 OTF_LookupRecord *LookupRecord; /* [<LookupCount>] */
534 unsigned ClassRuleCnt;
535 OTF_ClassRule *ClassRule; /* [<ClassRuleCnt>] */
541 unsigned BacktrackGlyphCount;
542 OTF_GlyphID *Backtrack;
543 unsigned InputGlyphCount;
545 unsigned LookaheadGlyphCount;
546 OTF_GlyphID *LookAhead;
547 unsigned LookupCount;
548 OTF_LookupRecord *LookupRecord;
554 unsigned ChainRuleCount;
555 OTF_ChainRule *ChainRule;
561 unsigned BacktrackGlyphCount;
563 unsigned InputGlyphCount;
565 unsigned LookaheadGlyphCount;
567 unsigned LookupCount;
568 OTF_LookupRecord *LookupRecord;
569 } OTF_ChainClassRule;
574 unsigned ChainClassRuleCnt;
575 OTF_ChainClassRule *ChainClassRule;
579 /* Common to OTF_GSUB/GPOS_Context1/2/3. */
583 unsigned RuleSetCount;
584 OTF_RuleSet *RuleSet; /* [<RuleSetCount>] */
589 OTF_ClassDef ClassDef;
590 unsigned ClassSetCnt;
591 OTF_ClassSet *ClassSet; /* [<ClassSetCnt>] */
597 unsigned LookupCount;
598 OTF_Coverage *Coverage; /* [<GlyphCount>] */
599 OTF_LookupRecord *LookupRecord; /* [<LookupCount>] */
603 /* Common to OTF_GSUB/GPOS_ChainContext1/2/3. */
607 unsigned ChainRuleSetCount;
608 OTF_ChainRuleSet *ChainRuleSet;
613 OTF_ClassDef BacktrackClassDef;
614 OTF_ClassDef InputClassDef;
615 OTF_ClassDef LookaheadClassDef;
616 unsigned ChainClassSetCnt;
617 OTF_ChainClassSet *ChainClassSet;
622 unsigned BacktrackGlyphCount;
623 OTF_Coverage *Backtrack;
624 unsigned InputGlyphCount;
626 unsigned LookaheadGlyphCount;
627 OTF_Coverage *LookAhead;
628 unsigned LookupCount;
629 OTF_LookupRecord *LookupRecord;
632 /* Common to OTF_GSUB/GPOS. */
637 OTF_ScriptList ScriptList;
638 OTF_FeatureList FeatureList;
639 OTF_LookupList LookupList;
642 /*** (1-9) "GSUB" table */
652 OTF_GlyphID *Substitute;
655 typedef struct OTF_Sequence OTF_Sequence;
659 unsigned SequenceCount;
660 OTF_Sequence *Sequence;
661 } OTF_GSUB_Multiple1;
667 OTF_GlyphID *Substitute;
670 typedef struct OTF_AlternateSet OTF_AlternateSet;
674 unsigned AlternateSetCount;
675 OTF_AlternateSet *AlternateSet;
676 } OTF_GSUB_Alternate1;
678 struct OTF_AlternateSet
682 OTF_GlyphID *Alternate;
685 typedef struct OTF_LigatureSet OTF_LigatureSet;
686 typedef struct OTF_Ligature OTF_Ligature;
690 unsigned LigSetCount;
691 OTF_LigatureSet *LigatureSet;
692 } OTF_GSUB_Ligature1;
694 struct OTF_LigatureSet
697 unsigned LigatureCount;
698 OTF_Ligature *Ligature;
704 OTF_GlyphID LigGlyph;
706 OTF_GlyphID *Component;
709 typedef OTF_Context1 OTF_GSUB_Context1;
711 typedef OTF_Context2 OTF_GSUB_Context2;
713 typedef OTF_Context3 OTF_GSUB_Context3;
715 typedef OTF_ChainContext1 OTF_GSUB_ChainContext1;
717 typedef OTF_ChainContext2 OTF_GSUB_ChainContext2;
719 typedef OTF_ChainContext3 OTF_GSUB_ChainContext3;
723 unsigned ExtensionLookupType;
724 unsigned ExtensionOffset;
725 OTF_LookupSubTableGSUB *ExtensionSubtable;
726 } OTF_GSUB_Extension1;
730 unsigned BacktrackGlyphCount;
731 OTF_Coverage *Backtrack;
732 unsigned LookaheadGlyphCount;
733 OTF_Coverage *LookAhead;
735 OTF_GlyphID *Substitute;
736 } OTF_GSUB_ReverseChain1;
738 struct OTF_LookupSubTableGSUB
741 OTF_Coverage Coverage;
744 OTF_GSUB_Single1 single1;
745 OTF_GSUB_Single2 single2;
747 OTF_GSUB_Multiple1 multiple1;
749 OTF_GSUB_Alternate1 alternate1;
751 OTF_GSUB_Ligature1 ligature1;
753 OTF_GSUB_Context1 context1;
754 OTF_GSUB_Context2 context2;
755 OTF_GSUB_Context3 context3;
757 OTF_GSUB_ChainContext1 chain_context1;
758 OTF_GSUB_ChainContext2 chain_context2;
759 OTF_GSUB_ChainContext3 chain_context3;
761 OTF_GSUB_Extension1 extension1;
763 OTF_GSUB_ReverseChain1 reverse_chain1;
767 typedef OTF_GSUB_GPOS OTF_GSUB;
769 /*** (1-10) "GPOS" table */
773 OTF_XPlacement = 0x0001,
774 OTF_YPlacement = 0x0002,
775 OTF_XAdvance = 0x0004,
776 OTF_YAdvance = 0x0008,
777 OTF_XPlaDevice = 0x0010,
778 OTF_YPlaDevice = 0x0020,
779 OTF_XAdvDevice = 0x0040,
780 OTF_YAdvDevice = 0x0080
789 OTF_DeviceTable XPlaDevice;
790 OTF_DeviceTable YPlaDevice;
791 OTF_DeviceTable XAdvDevice;
792 OTF_DeviceTable YAdvDevice;
798 unsigned AnchorFormat;
803 unsigned AnchorPoint;
806 OTF_DeviceTable XDeviceTable;
807 OTF_DeviceTable YDeviceTable;
815 OTF_Anchor MarkAnchor;
822 OTF_MarkRecord *MarkRecord;
827 unsigned ValueFormat;
828 OTF_ValueRecord Value;
833 unsigned ValueFormat;
835 OTF_ValueRecord *Value; /* [<ValueCount>] */
840 OTF_GlyphID SecondGlyph;
841 OTF_ValueRecord Value1;
842 OTF_ValueRecord Value2;
843 } OTF_PairValueRecord;
848 unsigned PairValueCount;
849 OTF_PairValueRecord *PairValueRecord;
854 unsigned ValueFormat1;
855 unsigned ValueFormat2;
856 unsigned PairSetCount;
857 OTF_PairSet *PairSet;
862 OTF_ValueRecord Value1;
863 OTF_ValueRecord Value2;
868 OTF_Class2Record *Class2Record;
873 unsigned ValueFormat1;
874 unsigned ValueFormat2;
875 OTF_ClassDef ClassDef1;
876 OTF_ClassDef ClassDef2;
877 unsigned Class1Count;
878 unsigned Class2Count;
879 OTF_Class1Record *Class1Record; /* size: <Class1Count> */
884 OTF_Anchor EntryAnchor;
885 OTF_Anchor ExitAnchor;
886 } OTF_EntryExitRecord;
890 unsigned EntryExitCount;
891 OTF_EntryExitRecord *EntryExitRecord;
903 OTF_AnchorRecord *AnchorRecord;
908 OTF_Coverage BaseCoverage;
910 OTF_MarkArray MarkArray;
911 OTF_AnchorArray BaseArray;
912 } OTF_GPOS_MarkBase1;
916 OTF_Anchor *LigatureAnchor; /* [<ClassCount>] */
917 } OTF_ComponentRecord;
922 unsigned ComponentCount;
923 OTF_ComponentRecord *ComponentRecord; /* [<ComponentCount>] */
924 } OTF_LigatureAttach;
929 unsigned LigatureCount;
930 OTF_LigatureAttach *LigatureAttach; /* [<LiagureCount>] */
935 OTF_Coverage LigatureCoverage;
937 OTF_MarkArray MarkArray;
938 OTF_LigatureArray LigatureArray;
943 OTF_Coverage Mark2Coverage;
945 OTF_MarkArray Mark1Array;
946 OTF_AnchorArray Mark2Array;
947 } OTF_GPOS_MarkMark1;
949 typedef OTF_Context1 OTF_GPOS_Context1;
951 typedef OTF_Context2 OTF_GPOS_Context2;
953 typedef OTF_Context3 OTF_GPOS_Context3;
955 typedef OTF_ChainContext1 OTF_GPOS_ChainContext1;
957 typedef OTF_ChainContext2 OTF_GPOS_ChainContext2;
959 typedef OTF_ChainContext3 OTF_GPOS_ChainContext3;
963 unsigned ExtensionLookupType;
964 unsigned ExtensionOffset;
965 OTF_LookupSubTableGPOS *ExtensionSubtable;
966 } OTF_GPOS_Extension1;
969 struct OTF_LookupSubTableGPOS
972 OTF_Coverage Coverage;
975 OTF_GPOS_Single1 single1;
976 OTF_GPOS_Single2 single2;
978 OTF_GPOS_Pair1 pair1;
979 OTF_GPOS_Pair2 pair2;
981 OTF_GPOS_Cursive1 cursive1;
983 OTF_GPOS_MarkBase1 mark_base1;
985 OTF_GPOS_MarkLig1 mark_lig1;
987 OTF_GPOS_MarkMark1 mark_mark1;
989 OTF_GPOS_Context1 context1;
990 OTF_GPOS_Context2 context2;
991 OTF_GPOS_Context3 context3;
993 OTF_GPOS_ChainContext1 chain_context1;
994 OTF_GPOS_ChainContext2 chain_context2;
995 OTF_GPOS_ChainContext3 chain_context3;
997 OTF_GPOS_Extension1 extension1;
1001 typedef OTF_GSUB_GPOS OTF_GPOS;
1003 /*** (1-11) Structure for OTF */
1007 OTF_Fixed sfnt_version;
1009 unsigned searchRange;
1010 unsigned enterSelector;
1011 unsigned rangeShift;
1021 } OTF_TableDirectory;
1023 typedef struct OTF_InternalData OTF_InternalData;
1028 OTF_OffsetTable offset_table;
1029 OTF_TableDirectory *table_dirs;
1036 /* The following tables are not yet supported. */
1037 /* OTF_BASE *base; */
1038 /* OTF_JSTF *jstf; */
1039 OTF_InternalData *internal_data;
1043 /*** (2) API for reading OTF */
1045 /*** (2-1) otf_open () */
1050 The OTF_open() function reads the OpenType font file whose name is
1051 $NAME, and return a pointer to the structure of type OTF.
1053 It setups these member of the structure OTF:
1054 filename, offset_table, table_dirs
1056 If the file can't be read or the file contains invalid data, NULL
1057 is returned, and the variable OTF_error is set to one of the
1064 See also OTF_get_table() and OTF_close(). */
1066 extern OTF *OTF_open (char *name);
1068 #include <ft2build.h>
1069 #include FT_FREETYPE_H
1071 extern OTF *OTF_open_ft_face (FT_Face face);
1074 /*** (2-2) OTF_close () */
1079 The OTF_close() function closes the OpenType font $OTF which must
1080 be what the OTF_open() function returned.
1082 See also OTF_open(). */
1084 extern void OTF_close (OTF *otf);
1087 /*** (2-3) OTF_get_table () */
1090 Get OpenType font table
1092 The OTF_get_table() function setups one of the OTF table specified
1093 by $NAME in the OpenType font $OTF.
1095 $NAME must be one of "head", "name", "cmap", "GDEF", "GSUB", and
1096 "GPOS", and a member of the same name is setup.
1098 If the table is successfully setup, return 0. Otherwise, return
1099 -1, and set the variable OTF_error to OTF_ERROR_TABLE.
1101 See also OTF_open(). */
1103 extern int OTF_get_table (OTF *otf, char *name);
1105 /*** (2-4) OTF_check_table () */
1108 Check the existence of OpenType font table
1110 The OTF_check_table() function checks if the the OTF table
1111 specified by $NAME exists in OpenType font $OTF.
1113 If the table exists, return 0, else return -1.
1115 See also OTF_open(). */
1117 extern int OTF_check_table (OTF *otf, char *name);
1119 /*** (2-5) OTF_get_scripts () */
1122 Get supported scripts.
1124 The OTF_get_scripts() function setups OTF_ScriptList of GSUB (if
1125 $GSUBP is nonzero) or GPOS (if $GSUBP is zero) table of the
1128 If the table is successfully setup, return 0. Otherwise, retrun
1129 -1, and set the variable OTF_error to OTF_ERROR_TABLE. */
1131 extern int OTF_get_scripts (OTF *otf, int gsubp);
1133 /*** (2-6) OTF_get_features () */
1136 Get supported features.
1138 The OTF_get_features() function setups OTF_FeatureList of GSUB (if
1139 $GSUBP is nonzero) or GPOS (if $GSUBP is zero) table of the
1142 If the table is successfully setup, return 0. Otherwise, retrun
1143 -1, and set the variable OTF_error to OTF_ERROR_TABLE. */
1145 extern int OTF_get_features (OTF *otf, int gsubp);
1147 /*** (2-7) OTF_check_features */
1150 Check supported features.
1152 The OTF_check_features() function checks if or not the OpenType
1153 font $OTF has, for $SCRIPT and $LANGUAGE, all features in the
1154 array $FEATURES. The array size is $N_FEATURES. If $LANGUAGE is
1155 zero or $OTF doesn't have LangSys for $SCRIPT, the default LangSys
1158 If $OTF has all the features, return 1. Otherwise, return 0. If
1159 an error occurs, return -1, and set the variable OTF_error to
1162 extern int OTF_check_features (OTF *otf, int gsubp,
1163 OTF_Tag script, OTF_Tag language,
1164 OTF_Tag *features, int n_features);
1166 /*** (3) API for driving OTF */
1168 /*** (3-1) Structure for glyph string */
1171 The structure OTF_Glyph contains information about each glyph in
1172 the structure OTF_GlyphString. */
1176 /** The first two members must be set by a clinet before calling the
1177 function OTF_drive_XXX(). **/
1179 /* Character code of the glyph. The value less than 32 is treated
1180 as a place-holder in a glyph string, and OTF_drive_XXX ()
1181 function just ignore the glyph as if it doesn't exist. */
1184 /* Glyph ID of the glyph. If the value is 0, the library gets a
1185 correct value from the above character code via cmap. */
1186 OTF_GlyphID glyph_id;
1188 /* GlyphClass of the glyph. The value is extracted from the GDEF
1190 enum OTF_GlyphClassDef GlyphClass;
1192 /* MarkAttachClassDef of the glyph. The value is extracted from the
1194 unsigned MarkAttachClass;
1196 /* Positioning format type of the glyph. The value specifies how
1197 the glyph positioning information is encoded in the member <f>.
1198 If the value is N, the union member fN, is used. If the value is
1199 zero, the glyph has no positioning information, i.e. it should be
1200 drawn at the normal position. */
1201 int positioning_type;
1207 enum OTF_ValueFormat format;
1208 OTF_ValueRecord *value;
1211 enum OTF_ValueFormat format;
1212 OTF_ValueRecord *value;
1215 OTF_Anchor *entry_anchor;
1216 OTF_Anchor *exit_anchor;
1219 OTF_Anchor *mark_anchor;
1220 OTF_Anchor *base_anchor;
1223 OTF_Anchor *mark_anchor;
1224 OTF_Anchor *ligature_anchor;
1227 OTF_Anchor *mark1_anchor;
1228 OTF_Anchor *mark2_anchor;
1234 The structure OTF_GlyphString contains an array of glyphs (type
1235 OTF_Glyph). It is used as arguments of otf_drive_XXX(). */
1239 /* How many glyphs are allocated at the memory pointed by the member
1242 /* How many glyphs contain valid information. */
1244 /* Array of glyphs. It must be allocated by malloc(). The
1245 functions otf_drive_XXX() may reallocate it and increase the
1246 members <size> and <used>. */
1251 /*** (3-2) OTF_drive_cmap() */
1254 Process glyph string by Unicode-based cmap table.
1256 The OTF_drive_cmap() function looks up a Unicode-based cmap table
1257 of OpenType font $OTF, and setup the member <glyhph_id> of all
1258 glhphs in the glyph string $GSTRING if the value of the member is
1261 extern int OTF_drive_cmap (OTF *otf, OTF_GlyphString *gstring);
1264 Process glyph string by a specific cmap table.
1266 The OTF_drive_cmap2() function looks up a cmap table (whose
1267 Platform-ID is $PLATFORM_ID an Encoding-ID is $ENCODING_ID) of
1268 OpenType font $OTF, and setup the member <glyhph_id> of all glhphs
1269 in the glyph string $GSTRING if the value of the member is not
1272 extern int OTF_drive_cmap2 (OTF *otf, OTF_GlyphString *gstring,
1273 int platform_id, int encoding_id);
1275 /*** (3-3) OTF_drive_gdef() */
1278 Process glyph string by GDEF table.
1280 The OTF_drive_gdef() function looks up the GDEF table of OpenType
1281 font $OTF, and setup members <GlyphClass> and <MarkAttachClass> of
1282 all glhphs in the glyph string $GSTRING. */
1284 extern int OTF_drive_gdef (OTF *otf, OTF_GlyphString *gstring);
1287 /*** (3-4) OTF_drive_gsub() */
1290 Process glyph string by GSUB table.
1292 The OTF_drive_gsub() function looks up the GSUB table of OpenType
1293 font $OTF, and by using features the font has for script $SCRIPT
1294 and language system $LANGSYS, update member <glyphs> of the glyph
1295 string $GSTRING. It may substitute, delete, insert glyphs in that
1296 array. $FEATURES is a list of features to apply. This doesn't
1297 perform a lookup of type 3 (Alternate Substitution). For that,
1298 use OTF_drive_gsub_alternate(). */
1300 extern int OTF_drive_gsub (OTF *otf, OTF_GlyphString *gstring,
1301 char *script, char *language, char *features);
1303 /*** (3-5) OTF_drive_gpos() */
1306 Process glyph string by GPOS table.
1308 The OTF_drive_gdef() function looks up the GPOS table of $OTF of
1309 OpenType font $OTF, and by using features the font has for script
1310 $SCRIPT and language system $LANGSYS, setup members
1311 <positioning_type> and <f> of all glhphs in the glyph string
1312 $GSTRING. $FEATURES is a list of features to apply. */
1314 extern int OTF_drive_gpos (OTF *otf, OTF_GlyphString *gstring,
1315 char *script, char *language, char *features);
1317 /*** (3-6) OTF_drive_tables() */
1320 Process glyph string by cmap, GDEF, GSUB, and GPOS tables.
1322 The OTF_drive_tables() function calls OTF_drive_cmap(),
1323 OTF_drive_gdef(), OTF_drive_gsub(), and OTF_drive_gpos() in this
1324 order, and update the glyphs string GSTRING. */
1326 extern int OTF_drive_tables (OTF *otf, OTF_GlyphString *gstring,
1327 char *script, char *language,
1328 char *gsub_features, char *gpos_features);
1331 /*** (3-7) OTF_get_unicode() */
1334 Return Unicode code point corresponding to the glyph-id CODE.
1337 extern int OTF_get_unicode (OTF *otf, OTF_GlyphID code);
1339 /*** (3-8) OTF_drive_gsub_alternate() */
1342 Find alternate glyphs.
1344 This is like OTF_drive_gsub(), but perform only a lookup of type 3
1345 (Alternate Substituion). */
1347 extern int OTF_drive_gsub_alternate (OTF *otf, OTF_GlyphString *gstring,
1348 char *script, char *language,
1351 /*** (4) API for error handling ***/
1353 /*** (4-1) Error codes ***/
1356 Global variable holding an error code.
1358 The variable OTF_error is set to one of OTF_ERROR_XXX macros when
1359 an error is detected in the OTF library. */
1360 extern int OTF_error;
1363 Memory allocation error
1365 This error indicates that the library couldn't allocate
1367 #define OTF_ERROR_MEMORY 1
1372 This error indicates that the library fails in opening, reading,
1373 or seeking an OTF file. */
1374 #define OTF_ERROR_FILE 2
1377 Invalid table contents
1379 This error indicates that an OTF file contains invalid data. */
1380 #define OTF_ERROR_TABLE 3
1385 See the function otf_drive_cmap() for more detail. */
1386 #define OTF_ERROR_CMAP_DRIVE 4
1391 See the function OTF_drive_gdef() for more detail. */
1392 #define OTF_ERROR_GDEF_DRIVE 5
1397 See the function OTF_drive_gsub() for more detail. */
1398 #define OTF_ERROR_GSUB_DRIVE 6
1403 See the function OTF_drive_gpos() for more detail. */
1404 #define OTF_ERROR_GPOS_DRIVE 7
1407 FT_Face access error.
1409 This error indicates that the library fails in accessing Sfnt
1410 tables via FT_Face. */
1411 #define OTF_ERROR_FT_FACE 8
1414 /*** (4-2) OTF_perror() */
1417 Print an OTF error message
1419 The OTF_perror() function produces a message on the standard error
1420 output, describing the last error encountered during a call to the
1421 OTF library function. If $PREFIX is not NULL, it is printed
1422 first, followed by a colon and a blank. Then the message and a
1425 extern void OTF_perror (char *prefix);
1428 /*** (5) API miscellaneous ***/
1431 Return OTF tag of a specified name string.
1433 The OTF_tag() function returns OTF tag of name $NAME. If $NAME is
1434 NULL, return 0. Otherwise, $NAME must be at least 4-byte length.
1435 Only the first 4 characters are took into an account. */
1437 extern OTF_Tag OTF_tag (char *name);
1440 Convert OTF tag to name string.
1442 The OTF_tag_name() function converts OTF tag $TAG to a 5-byte name
1443 string (including the terminating NULL), and store it in $NAME.
1444 At least 5-byte space must be at $NAME. */
1446 extern void OTF_tag_name (OTF_Tag tag, char *name);
1449 #endif /* not _OTF_H_ */