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()
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 (for BMP only) */
277 unsigned short *unicode_table;
279 /* Mapping table: GlyphID->Unicode */
280 unsigned short *decode_table;
281 /* Index of the EncodingRecord for Unicode->GlyphID mapping.
282 -1 means that the font supports only Unicode BMP characters. */
287 /*** (1-5) Structures common to GDEF, GSUB, GPOS */
293 unsigned StartCoverageIndex;
299 unsigned CoverageFormat;
302 OTF_GlyphID *GlyphArray;
303 OTF_RangeRecord *RangeRecord;
312 unsigned DeltaFormat;
321 } OTF_ClassRangeRecord;
326 unsigned ClassFormat;
329 OTF_GlyphID StartGlyph;
331 unsigned *ClassValueArray;
334 unsigned ClassRangeCount;
335 OTF_ClassRangeRecord *ClassRangeRecord;
341 /*** (1-6) "GDEF" table */
346 OTF_Offset GlyphClassDef;
347 OTF_Offset AttachList;
348 OTF_Offset LigCaretList;
349 OTF_Offset MarkAttachClassDef;
352 enum OTF_GlyphClassDef
355 OTF_GlyphClassBase = 1,
356 OTF_GlyphClassLigature = 2,
357 OTF_GlyphClassMark = 3,
358 OTF_GlyphClassComponent = 4
365 unsigned *PointIndex;
370 OTF_Coverage Coverage;
372 OTF_AttachPoint *AttachPoint;
378 unsigned CaretValueFormat; /* 1, 2, or 3 */
384 unsigned CaretValuePoint;
388 OTF_DeviceTable DeviceTable;
397 OTF_CaretValue *CaretValue;
402 OTF_Coverage Coverage;
403 unsigned LigGlyphCount;
404 OTF_LigGlyph *LigGlyph;
409 OTF_GDEFHeader header;
410 OTF_ClassDef glyph_class_def;
411 OTF_AttachList attach_list;
412 OTF_LigCaretList lig_caret_list;
413 OTF_ClassDef mark_attach_class_def;
417 /*** (1-7) Structures for ScriptList, FeatureList, and LookupList */
419 /*** The structure hierarchy
446 SubTable.gsub[] or SubTable.gpos[]
452 OTF_Offset LookupOrder;
453 unsigned ReqFeatureIndex;
454 unsigned FeatureCount;
455 unsigned *FeatureIndex;
468 OTF_Offset DefaultLangSysOffset;
469 OTF_LangSys DefaultLangSys;
470 unsigned LangSysCount;
471 OTF_LangSysRecord *LangSysRecord;
472 OTF_LangSys *LangSys;
478 unsigned ScriptCount;
486 OTF_Offset FeatureParams;
487 unsigned LookupCount;
488 unsigned *LookupListIndex;
494 unsigned FeatureCount;
495 OTF_Feature *Feature;
498 typedef struct OTF_LookupSubTableGSUB OTF_LookupSubTableGSUB;
499 typedef struct OTF_LookupSubTableGPOS OTF_LookupSubTableGPOS;
501 enum OTF_LookupFlagBit
503 OTF_RightToLeft = 0x0001,
504 OTF_IgnoreBaseGlyphs = 0x0002,
505 OTF_IgnoreLigatures = 0x0004,
506 OTF_IgnoreMarks = 0x0008,
507 OTF_Reserved = 0x00F0,
508 OTF_MarkAttachmentType = 0xFF00
511 #define OTF_LookupFlagIgnoreMask \
512 (OTF_IgnoreBaseGlyphs | OTF_IgnoreLigatures | OTF_IgnoreMarks)
519 unsigned SubTableCount;
520 OTF_Offset *SubTableOffset;
522 OTF_LookupSubTableGSUB *gsub;
523 OTF_LookupSubTableGPOS *gpos;
530 unsigned LookupCount;
535 /*** (1-8) Structures common to GSUB and GPOS */
537 /* For SubstLookupRecord (GSUB) and PosLookupRecord (GPOS). */
541 unsigned SequenceIndex;
542 unsigned LookupListIndex;
549 unsigned LookupCount;
550 OTF_GlyphID *Input; /* [<GlyphCount> - 1] */
551 OTF_LookupRecord *LookupRecord; /* [<LookupCount>] */
558 OTF_Rule *Rule; /* [<RuleCount>] */
565 unsigned LookupCount;
566 unsigned *Class; /* [<GlyphCount> - 1] */
567 OTF_LookupRecord *LookupRecord; /* [<LookupCount>] */
573 unsigned ClassRuleCnt;
574 OTF_ClassRule *ClassRule; /* [<ClassRuleCnt>] */
580 unsigned BacktrackGlyphCount;
581 OTF_GlyphID *Backtrack;
582 unsigned InputGlyphCount;
584 unsigned LookaheadGlyphCount;
585 OTF_GlyphID *LookAhead;
586 unsigned LookupCount;
587 OTF_LookupRecord *LookupRecord;
593 unsigned ChainRuleCount;
594 OTF_ChainRule *ChainRule;
600 unsigned BacktrackGlyphCount;
602 unsigned InputGlyphCount;
604 unsigned LookaheadGlyphCount;
606 unsigned LookupCount;
607 OTF_LookupRecord *LookupRecord;
608 } OTF_ChainClassRule;
613 unsigned ChainClassRuleCnt;
614 OTF_ChainClassRule *ChainClassRule;
618 /* Common to OTF_GSUB/GPOS_Context1/2/3. */
622 unsigned RuleSetCount;
623 OTF_RuleSet *RuleSet; /* [<RuleSetCount>] */
628 OTF_ClassDef ClassDef;
629 unsigned ClassSetCnt;
630 OTF_ClassSet *ClassSet; /* [<ClassSetCnt>] */
636 unsigned LookupCount;
637 OTF_Coverage *Coverage; /* [<GlyphCount>] */
638 OTF_LookupRecord *LookupRecord; /* [<LookupCount>] */
642 /* Common to OTF_GSUB/GPOS_ChainContext1/2/3. */
646 unsigned ChainRuleSetCount;
647 OTF_ChainRuleSet *ChainRuleSet;
652 OTF_ClassDef BacktrackClassDef;
653 OTF_ClassDef InputClassDef;
654 OTF_ClassDef LookaheadClassDef;
655 unsigned ChainClassSetCnt;
656 OTF_ChainClassSet *ChainClassSet;
661 unsigned BacktrackGlyphCount;
662 OTF_Coverage *Backtrack;
663 unsigned InputGlyphCount;
665 unsigned LookaheadGlyphCount;
666 OTF_Coverage *LookAhead;
667 unsigned LookupCount;
668 OTF_LookupRecord *LookupRecord;
671 /* Common to OTF_GSUB/GPOS. */
676 OTF_ScriptList ScriptList;
677 OTF_FeatureList FeatureList;
678 OTF_LookupList LookupList;
681 /*** (1-9) "GSUB" table */
691 OTF_GlyphID *Substitute;
694 typedef struct OTF_Sequence OTF_Sequence;
698 unsigned SequenceCount;
699 OTF_Sequence *Sequence;
700 } OTF_GSUB_Multiple1;
706 OTF_GlyphID *Substitute;
709 typedef struct OTF_AlternateSet OTF_AlternateSet;
713 unsigned AlternateSetCount;
714 OTF_AlternateSet *AlternateSet;
715 } OTF_GSUB_Alternate1;
717 struct OTF_AlternateSet
721 OTF_GlyphID *Alternate;
724 typedef struct OTF_LigatureSet OTF_LigatureSet;
725 typedef struct OTF_Ligature OTF_Ligature;
729 unsigned LigSetCount;
730 OTF_LigatureSet *LigatureSet;
731 } OTF_GSUB_Ligature1;
733 struct OTF_LigatureSet
736 unsigned LigatureCount;
737 OTF_Ligature *Ligature;
743 OTF_GlyphID LigGlyph;
745 OTF_GlyphID *Component;
748 typedef OTF_Context1 OTF_GSUB_Context1;
750 typedef OTF_Context2 OTF_GSUB_Context2;
752 typedef OTF_Context3 OTF_GSUB_Context3;
754 typedef OTF_ChainContext1 OTF_GSUB_ChainContext1;
756 typedef OTF_ChainContext2 OTF_GSUB_ChainContext2;
758 typedef OTF_ChainContext3 OTF_GSUB_ChainContext3;
762 unsigned ExtensionLookupType;
763 unsigned ExtensionOffset;
764 OTF_LookupSubTableGSUB *ExtensionSubtable;
765 } OTF_GSUB_Extension1;
769 unsigned BacktrackGlyphCount;
770 OTF_Coverage *Backtrack;
771 unsigned LookaheadGlyphCount;
772 OTF_Coverage *LookAhead;
774 OTF_GlyphID *Substitute;
775 } OTF_GSUB_ReverseChain1;
777 struct OTF_LookupSubTableGSUB
780 OTF_Coverage Coverage;
783 OTF_GSUB_Single1 single1;
784 OTF_GSUB_Single2 single2;
786 OTF_GSUB_Multiple1 multiple1;
788 OTF_GSUB_Alternate1 alternate1;
790 OTF_GSUB_Ligature1 ligature1;
792 OTF_GSUB_Context1 context1;
793 OTF_GSUB_Context2 context2;
794 OTF_GSUB_Context3 context3;
796 OTF_GSUB_ChainContext1 chain_context1;
797 OTF_GSUB_ChainContext2 chain_context2;
798 OTF_GSUB_ChainContext3 chain_context3;
800 OTF_GSUB_Extension1 extension1;
802 OTF_GSUB_ReverseChain1 reverse_chain1;
806 typedef OTF_GSUB_GPOS OTF_GSUB;
808 /*** (1-10) "GPOS" table */
812 OTF_XPlacement = 0x0001,
813 OTF_YPlacement = 0x0002,
814 OTF_XAdvance = 0x0004,
815 OTF_YAdvance = 0x0008,
816 OTF_XPlaDevice = 0x0010,
817 OTF_YPlaDevice = 0x0020,
818 OTF_XAdvDevice = 0x0040,
819 OTF_YAdvDevice = 0x0080
828 OTF_DeviceTable XPlaDevice;
829 OTF_DeviceTable YPlaDevice;
830 OTF_DeviceTable XAdvDevice;
831 OTF_DeviceTable YAdvDevice;
837 unsigned AnchorFormat;
842 unsigned AnchorPoint;
845 OTF_DeviceTable XDeviceTable;
846 OTF_DeviceTable YDeviceTable;
854 OTF_Anchor MarkAnchor;
861 OTF_MarkRecord *MarkRecord;
866 unsigned ValueFormat;
867 OTF_ValueRecord Value;
872 unsigned ValueFormat;
874 OTF_ValueRecord *Value; /* [<ValueCount>] */
879 OTF_GlyphID SecondGlyph;
880 OTF_ValueRecord Value1;
881 OTF_ValueRecord Value2;
882 } OTF_PairValueRecord;
887 unsigned PairValueCount;
888 OTF_PairValueRecord *PairValueRecord;
893 unsigned ValueFormat1;
894 unsigned ValueFormat2;
895 unsigned PairSetCount;
896 OTF_PairSet *PairSet;
901 OTF_ValueRecord Value1;
902 OTF_ValueRecord Value2;
907 OTF_Class2Record *Class2Record;
912 unsigned ValueFormat1;
913 unsigned ValueFormat2;
914 OTF_ClassDef ClassDef1;
915 OTF_ClassDef ClassDef2;
916 unsigned Class1Count;
917 unsigned Class2Count;
918 OTF_Class1Record *Class1Record; /* size: <Class1Count> */
923 OTF_Anchor EntryAnchor;
924 OTF_Anchor ExitAnchor;
925 } OTF_EntryExitRecord;
929 unsigned EntryExitCount;
930 OTF_EntryExitRecord *EntryExitRecord;
942 OTF_AnchorRecord *AnchorRecord;
947 OTF_Coverage BaseCoverage;
949 OTF_MarkArray MarkArray;
950 OTF_AnchorArray BaseArray;
951 } OTF_GPOS_MarkBase1;
955 OTF_Anchor *LigatureAnchor; /* [<ClassCount>] */
956 } OTF_ComponentRecord;
961 unsigned ComponentCount;
962 OTF_ComponentRecord *ComponentRecord; /* [<ComponentCount>] */
963 } OTF_LigatureAttach;
968 unsigned LigatureCount;
969 OTF_LigatureAttach *LigatureAttach; /* [<LiagureCount>] */
974 OTF_Coverage LigatureCoverage;
976 OTF_MarkArray MarkArray;
977 OTF_LigatureArray LigatureArray;
982 OTF_Coverage Mark2Coverage;
984 OTF_MarkArray Mark1Array;
985 OTF_AnchorArray Mark2Array;
986 } OTF_GPOS_MarkMark1;
988 typedef OTF_Context1 OTF_GPOS_Context1;
990 typedef OTF_Context2 OTF_GPOS_Context2;
992 typedef OTF_Context3 OTF_GPOS_Context3;
994 typedef OTF_ChainContext1 OTF_GPOS_ChainContext1;
996 typedef OTF_ChainContext2 OTF_GPOS_ChainContext2;
998 typedef OTF_ChainContext3 OTF_GPOS_ChainContext3;
1002 unsigned ExtensionLookupType;
1003 unsigned ExtensionOffset;
1004 OTF_LookupSubTableGPOS *ExtensionSubtable;
1005 } OTF_GPOS_Extension1;
1008 struct OTF_LookupSubTableGPOS
1011 OTF_Coverage Coverage;
1014 OTF_GPOS_Single1 single1;
1015 OTF_GPOS_Single2 single2;
1017 OTF_GPOS_Pair1 pair1;
1018 OTF_GPOS_Pair2 pair2;
1020 OTF_GPOS_Cursive1 cursive1;
1022 OTF_GPOS_MarkBase1 mark_base1;
1024 OTF_GPOS_MarkLig1 mark_lig1;
1026 OTF_GPOS_MarkMark1 mark_mark1;
1028 OTF_GPOS_Context1 context1;
1029 OTF_GPOS_Context2 context2;
1030 OTF_GPOS_Context3 context3;
1032 OTF_GPOS_ChainContext1 chain_context1;
1033 OTF_GPOS_ChainContext2 chain_context2;
1034 OTF_GPOS_ChainContext3 chain_context3;
1036 OTF_GPOS_Extension1 extension1;
1040 typedef OTF_GSUB_GPOS OTF_GPOS;
1042 /*** (1-11) Structure for OTF */
1046 OTF_Fixed sfnt_version;
1048 unsigned searchRange;
1049 unsigned enterSelector;
1050 unsigned rangeShift;
1060 } OTF_TableDirectory;
1062 typedef struct OTF_InternalData OTF_InternalData;
1067 OTF_OffsetTable offset_table;
1068 OTF_TableDirectory *table_dirs;
1075 /* The following tables are not yet supported. */
1076 /* OTF_BASE *base; */
1077 /* OTF_JSTF *jstf; */
1078 OTF_InternalData *internal_data;
1082 /*** (2) API for reading OTF */
1084 /*** (2-1) otf_open () */
1089 The OTF_open() function reads the OpenType font file whose name is
1090 $NAME, and return a pointer to the structure of type OTF.
1092 It setups these member of the structure OTF:
1093 filename, offset_table, table_dirs
1095 If the file can't be read or the file contains invalid data, NULL
1096 is returned, and the variable OTF_error is set to one of the
1103 See also OTF_get_table() and OTF_close(). */
1105 extern OTF *OTF_open (const char *name);
1107 #include <ft2build.h>
1108 #include FT_FREETYPE_H
1110 extern OTF *OTF_open_ft_face (FT_Face face);
1113 /*** (2-2) OTF_close () */
1118 The OTF_close() function closes the OpenType font $OTF which must
1119 be what the OTF_open() function returned.
1121 See also OTF_open(). */
1123 extern void OTF_close (OTF *otf);
1126 /*** (2-3) OTF_get_table () */
1129 Get OpenType font table
1131 The OTF_get_table() function setups one of the OTF table specified
1132 by $NAME in the OpenType font $OTF.
1134 $NAME must be one of "head", "name", "cmap", "GDEF", "GSUB", and
1135 "GPOS", and a member of the same name is setup.
1137 If the table is successfully setup, return 0. Otherwise, return
1138 -1, and set the variable OTF_error to OTF_ERROR_TABLE.
1140 See also OTF_open(). */
1142 extern int OTF_get_table (OTF *otf, const char *name);
1144 /*** (2-4) OTF_check_table () */
1147 Check the existence of OpenType font table
1149 The OTF_check_table() function checks if the the OTF table
1150 specified by $NAME exists in OpenType font $OTF.
1152 If the table exists, return 0, else return -1.
1154 See also OTF_open(). */
1156 extern int OTF_check_table (OTF *otf, const char *name);
1158 /*** (2-5) OTF_get_scripts () */
1161 Get supported scripts.
1163 The OTF_get_scripts() function setups OTF_ScriptList of GSUB (if
1164 $GSUBP is nonzero) or GPOS (if $GSUBP is zero) table of the
1167 If the table is successfully setup, return 0. Otherwise, retrun
1168 -1, and set the variable OTF_error to OTF_ERROR_TABLE. */
1170 extern int OTF_get_scripts (OTF *otf, int gsubp);
1172 /*** (2-6) OTF_get_features () */
1175 Get supported features.
1177 The OTF_get_features() function setups OTF_FeatureList of GSUB (if
1178 $GSUBP is nonzero) or GPOS (if $GSUBP is zero) table of the
1181 If the table is successfully setup, return 0. Otherwise, retrun
1182 -1, and set the variable OTF_error to OTF_ERROR_TABLE. */
1184 extern int OTF_get_features (OTF *otf, int gsubp);
1186 /*** (2-7) OTF_check_features */
1189 Check supported features.
1191 The OTF_check_features() function checks if or not the OpenType
1192 font $OTF has, for $SCRIPT and $LANGUAGE, all features in the
1193 array $FEATURES. The array size is $N_FEATURES. If $LANGUAGE is
1194 zero or $OTF doesn't have LangSys for $SCRIPT, the default LangSys
1197 If $OTF has all the features, return 1. Otherwise, return 0. If
1198 an error occurs, return -1, and set the variable OTF_error to
1201 extern int OTF_check_features (OTF *otf, int gsubp,
1202 OTF_Tag script, OTF_Tag language,
1203 const OTF_Tag *features, int n_features);
1205 /*** (3) API for driving OTF */
1207 /*** (3-1) Structure for glyph string */
1210 The structure OTF_Glyph contains information about each glyph in
1211 the structure OTF_GlyphString. */
1215 /** The first two members must be set by a clinet before calling the
1216 function OTF_drive_XXX(). **/
1218 /* Character code of the glyph. The value less than 32 is treated
1219 as a place-holder in a glyph string, and OTF_drive_XXX ()
1220 function just ignore the glyph as if it doesn't exist. */
1223 /* Glyph ID of the glyph. If the value is 0, the library gets a
1224 correct value from the above character code via cmap if such a
1225 glyph is available in the font.
1227 The function OTF_drive_gpos2 may insert a glyph whose glyph_id is
1228 0 but positioning_type is positive. It is not an actual glyph
1229 but just contains positioning information that should be
1230 accumulated to the positioning information of the previous
1232 OTF_GlyphID glyph_id;
1234 /* GlyphClass of the glyph. The value is extracted from the GDEF
1236 enum OTF_GlyphClassDef GlyphClass;
1238 /* MarkAttachClassDef of the glyph. The value is extracted from the
1240 unsigned MarkAttachClass;
1242 /* Positioning format type of the glyph. The value specifies how
1243 the glyph positioning information is encoded in the member <f>.
1244 If the value is N, the union member fN, is used. If the value is
1245 zero, the glyph has no positioning information, i.e. it should be
1246 drawn at the normal position. */
1247 int positioning_type;
1253 enum OTF_ValueFormat format;
1254 OTF_ValueRecord *value;
1257 enum OTF_ValueFormat format;
1258 OTF_ValueRecord *value;
1261 OTF_Anchor *entry_anchor;
1262 OTF_Anchor *exit_anchor;
1265 OTF_Anchor *mark_anchor;
1266 OTF_Anchor *base_anchor;
1269 OTF_Anchor *mark_anchor;
1270 OTF_Anchor *ligature_anchor;
1273 OTF_Anchor *mark1_anchor;
1274 OTF_Anchor *mark2_anchor;
1280 The structure OTF_GlyphString contains an array of glyphs (type
1281 OTF_Glyph). It is used as arguments of otf_drive_XXX(). */
1285 /* How many glyphs are allocated at the memory pointed by the member
1288 /* How many glyphs contain valid information. */
1290 /* Array of glyphs. It must be allocated by malloc(). The
1291 functions otf_drive_XXX() may reallocate it and increase the
1292 members <size> and <used>. */
1297 /*** (3-2) OTF_drive_cmap() */
1300 Process glyph string by Unicode-based cmap table.
1302 The OTF_drive_cmap() function looks up a Unicode-based cmap table
1303 of OpenType font $OTF, and setup the member <glyph_id> of all
1304 glhphs in the glyph string $GSTRING if the value of the member is
1307 extern int OTF_drive_cmap (OTF *otf, OTF_GlyphString *gstring);
1310 Process glyph string by a specific cmap table.
1312 The OTF_drive_cmap2() function looks up a cmap table (whose
1313 Platform-ID is $PLATFORM_ID an Encoding-ID is $ENCODING_ID) of
1314 OpenType font $OTF, and setup the member <glyph_id> of all glhphs
1315 in the glyph string $GSTRING if the value of the member is not
1318 extern int OTF_drive_cmap2 (OTF *otf, OTF_GlyphString *gstring,
1319 int platform_id, int encoding_id);
1323 Store variable glyphs of character C in the array CODE. The array
1324 size must be 256. The Nth element of CODE is the glyph corresponding
1325 to the variation selector (N + 1). The return value is the number
1326 of variation glyphs. */
1328 extern int OTF_get_variation_glyphs (OTF *otf, int c, OTF_GlyphID code[256]);
1331 /*** (3-3) OTF_drive_gdef() */
1334 Process glyph string by GDEF table.
1336 The OTF_drive_gdef() function looks up the GDEF table of OpenType
1337 font $OTF, and setup members <GlyphClass> and <MarkAttachClass> of
1338 all glhphs in the glyph string $GSTRING. */
1340 extern int OTF_drive_gdef (OTF *otf, OTF_GlyphString *gstring);
1343 /*** (3-4) OTF_drive_gsub() */
1346 Process glyph string by GSUB table.
1348 The OTF_drive_gsub() function looks up the GSUB table of OpenType
1349 font $OTF, and by using features the font has for script $SCRIPT
1350 and language system $LANGSYS, update member <glyphs> of the glyph
1351 string $GSTRING. It may substitute, delete, insert glyphs in that
1352 array. $FEATURES is a list of features to apply. This doesn't
1353 perform a lookup of type 3 (Alternate Substitution). For that,
1354 use OTF_drive_gsub_alternate(). */
1356 extern int OTF_drive_gsub (OTF *otf, OTF_GlyphString *gstring,
1357 const char *script, const char *language,
1358 const char *features);
1360 /*** (3-5) OTF_drive_gpos() */
1363 Process glyph string by GPOS table.
1365 The OTF_drive_gpos() function is deprecated. Use
1366 OTF_drive_gpos2() instread. */
1368 extern int OTF_drive_gpos (OTF *otf, OTF_GlyphString *gstring,
1369 const char *script, const char *language,
1370 const char *features);
1373 Process glyph string by GPOS table.
1375 The OTF_drive_gpos2() function looks up the GPOS table of $OTF of
1376 OpenType font $OTF, and by using features the font has for script
1377 $SCRIPT and language system $LANGSYS, setup members
1378 <positioning_type> and <f> of all glhphs in the glyph string
1379 $GSTRING. $FEATURES is a list of features to apply. */
1381 extern int OTF_drive_gpos2 (OTF *otf, OTF_GlyphString *gstring,
1382 const char *script, const char *language,
1383 const char *features);
1385 /*** (3-6) OTF_drive_tables() */
1388 Process glyph string by cmap, GDEF, GSUB, and GPOS tables.
1390 The OTF_drive_tables() function calls OTF_drive_cmap(),
1391 OTF_drive_gdef(), OTF_drive_gsub(), and OTF_drive_gpos() in this
1392 order, and update the glyphs string GSTRING. */
1394 extern int OTF_drive_tables (OTF *otf, OTF_GlyphString *gstring,
1395 const char *script, const char *language,
1396 const char *gsub_features,
1397 const char *gpos_features);
1400 /*** (3-7) OTF_get_unicode() */
1403 Return Unicode code point corresponding to the glyph-id CODE.
1406 extern int OTF_get_unicode (OTF *otf, OTF_GlyphID code);
1408 /*** (3-8) OTF_drive_gsub_alternate() */
1411 Find alternate glyphs.
1413 This is like OTF_drive_gsub(), but perform only a lookup of type 3
1414 (Alternate Substituion). */
1416 extern int OTF_drive_gsub_alternate (OTF *otf, OTF_GlyphString *gstring,
1417 const char *script, const char *language,
1418 const char *features);
1420 /*** (4) API for error handling ***/
1422 /*** (4-1) Error codes ***/
1425 Global variable holding an error code.
1427 The variable OTF_error is set to one of OTF_ERROR_XXX macros when
1428 an error is detected in the OTF library. */
1429 extern int OTF_error;
1432 Memory allocation error
1434 This error indicates that the library couldn't allocate
1436 #define OTF_ERROR_MEMORY 1
1441 This error indicates that the library fails in opening, reading,
1442 or seeking an OTF file. */
1443 #define OTF_ERROR_FILE 2
1446 Invalid table contents
1448 This error indicates that an OTF file contains invalid data. */
1449 #define OTF_ERROR_TABLE 3
1454 See the function otf_drive_cmap() for more detail. */
1455 #define OTF_ERROR_CMAP_DRIVE 4
1460 See the function OTF_drive_gdef() for more detail. */
1461 #define OTF_ERROR_GDEF_DRIVE 5
1466 See the function OTF_drive_gsub() for more detail. */
1467 #define OTF_ERROR_GSUB_DRIVE 6
1472 See the function OTF_drive_gpos() for more detail. */
1473 #define OTF_ERROR_GPOS_DRIVE 7
1476 FT_Face access error.
1478 This error indicates that the library fails in accessing Sfnt
1479 tables via FT_Face. */
1480 #define OTF_ERROR_FT_FACE 8
1483 /*** (4-2) OTF_perror() */
1486 Print an OTF error message
1488 The OTF_perror() function produces a message on the standard error
1489 output, describing the last error encountered during a call to the
1490 OTF library function. If $PREFIX is not NULL, it is printed
1491 first, followed by a colon and a blank. Then the message and a
1494 extern void OTF_perror (const char *prefix);
1497 /*** (5) API miscellaneous ***/
1500 Return OTF tag of a specified name string.
1502 The OTF_tag() function returns OTF tag of name $NAME. If $NAME is
1503 NULL, return 0. Otherwise, $NAME must be at least 4-byte length.
1504 Only the first 4 characters are took into an account. */
1506 extern OTF_Tag OTF_tag (const char *name);
1509 Convert OTF tag to name string.
1511 The OTF_tag_name() function converts OTF tag $TAG to a 5-byte name
1512 string (including the terminating NULL), and store it in $NAME.
1513 At least 5-byte space must be at $NAME. */
1515 extern void OTF_tag_name (OTF_Tag tag, char *name);
1521 #endif /* not _OTF_H_ */