1 /* otf.h -- Header file for libotf (OpenType font library).
3 Copyright (C) 2003, 2004, 2005, 2006, 2007
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.6"
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 6
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_cmapSegument *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;
221 OTF_EncodingSubtable0 *f0;
222 OTF_EncodingSubtable2 *f2;
223 OTF_EncodingSubtable4 *f4;
224 OTF_EncodingSubtable6 *f6;
225 OTF_EncodingSubtable8 *f8;
226 OTF_EncodingSubtable10 *f10;
227 OTF_EncodingSubtable12 *f12;
229 } OTF_EncodingSubtable;
236 OTF_EncodingSubtable subtable;
237 } OTF_EncodingRecord;
243 OTF_EncodingRecord *EncodingRecord;
244 /* Mapping table: Unicode->GlyphID */
245 unsigned short *unicode_table;
247 /* Mapping table: GlyphID->Unicode */
248 unsigned short *decode_table;
252 /*** (1-5) Structures common to GDEF, GSUB, GPOS */
258 unsigned StartCoverageIndex;
264 unsigned CoverageFormat;
267 OTF_GlyphID *GlyphArray;
268 OTF_RangeRecord *RangeRecord;
277 unsigned DeltaFormat;
286 } OTF_ClassRangeRecord;
291 unsigned ClassFormat;
294 OTF_GlyphID StartGlyph;
296 unsigned *ClassValueArray;
299 unsigned ClassRangeCount;
300 OTF_ClassRangeRecord *ClassRangeRecord;
306 /*** (1-6) "GDEF" table */
311 OTF_Offset GlyphClassDef;
312 OTF_Offset AttachList;
313 OTF_Offset LigCaretList;
314 OTF_Offset MarkAttachClassDef;
317 enum OTF_GlyphClassDef
320 OTF_GlyphClassBase = 1,
321 OTF_GlyphClassLigature = 2,
322 OTF_GlyphClassMark = 3,
323 OTF_GlyphClassComponent = 4
330 unsigned *PointIndex;
335 OTF_Coverage Coverage;
337 OTF_AttachPoint *AttachPoint;
343 unsigned CaretValueFormat; /* 1, 2, or 3 */
349 unsigned CaretValuePoint;
353 OTF_DeviceTable DeviceTable;
362 OTF_CaretValue *CaretValue;
367 OTF_Coverage Coverage;
368 unsigned LigGlyphCount;
369 OTF_LigGlyph *LigGlyph;
374 OTF_GDEFHeader header;
375 OTF_ClassDef glyph_class_def;
376 OTF_AttachList attach_list;
377 OTF_LigCaretList lig_caret_list;
378 OTF_ClassDef mark_attach_class_def;
382 /*** (1-7) Structures for ScriptList, FeatureList, and LookupList */
384 /*** The structure hierarchy
411 SubTable.gsub[] or SubTable.gpos[]
417 OTF_Offset LookupOrder;
418 unsigned ReqFeatureIndex;
419 unsigned FeatureCount;
420 unsigned *FeatureIndex;
433 OTF_Offset DefaultLangSysOffset;
434 OTF_LangSys DefaultLangSys;
435 unsigned LangSysCount;
436 OTF_LangSysRecord *LangSysRecord;
437 OTF_LangSys *LangSys;
443 unsigned ScriptCount;
451 OTF_Offset FeatureParams;
452 unsigned LookupCount;
453 unsigned *LookupListIndex;
459 unsigned FeatureCount;
460 OTF_Feature *Feature;
463 typedef struct OTF_LookupSubTableGSUB OTF_LookupSubTableGSUB;
464 typedef struct OTF_LookupSubTableGPOS OTF_LookupSubTableGPOS;
466 enum OTF_LookupFlagBit
468 OTF_RightToLeft = 0x0001,
469 OTF_IgnoreBaseGlyphs = 0x0002,
470 OTF_IgnoreLigatures = 0x0004,
471 OTF_IgnoreMarks = 0x0008,
472 OTF_Reserved = 0x00F0,
473 OTF_MarkAttachmentType = 0xFF00
476 #define OTF_LookupFlagIgnoreMask \
477 (OTF_IgnoreBaseGlyphs | OTF_IgnoreLigatures | OTF_IgnoreMarks)
484 unsigned SubTableCount;
485 OTF_Offset *SubTableOffset;
487 OTF_LookupSubTableGSUB *gsub;
488 OTF_LookupSubTableGPOS *gpos;
495 unsigned LookupCount;
500 /*** (1-8) Structures common to GSUB and GPOS */
502 /* For SubstLookupRecord (GSUB) and PosLookupRecord (GPOS). */
506 unsigned SequenceIndex;
507 unsigned LookupListIndex;
514 unsigned LookupCount;
515 OTF_GlyphID *Input; /* [<GlyphCount> - 1] */
516 OTF_LookupRecord *LookupRecord; /* [<LookupCount>] */
523 OTF_Rule *Rule; /* [<RuleCount>] */
530 unsigned LookupCount;
531 unsigned *Class; /* [<GlyphCount> - 1] */
532 OTF_LookupRecord *LookupRecord; /* [<LookupCount>] */
538 unsigned ClassRuleCnt;
539 OTF_ClassRule *ClassRule; /* [<ClassRuleCnt>] */
545 unsigned BacktrackGlyphCount;
546 OTF_GlyphID *Backtrack;
547 unsigned InputGlyphCount;
549 unsigned LookaheadGlyphCount;
550 OTF_GlyphID *LookAhead;
551 unsigned LookupCount;
552 OTF_LookupRecord *LookupRecord;
558 unsigned ChainRuleCount;
559 OTF_ChainRule *ChainRule;
565 unsigned BacktrackGlyphCount;
567 unsigned InputGlyphCount;
569 unsigned LookaheadGlyphCount;
571 unsigned LookupCount;
572 OTF_LookupRecord *LookupRecord;
573 } OTF_ChainClassRule;
578 unsigned ChainClassRuleCnt;
579 OTF_ChainClassRule *ChainClassRule;
583 /* Common to OTF_GSUB/GPOS_Context1/2/3. */
587 unsigned RuleSetCount;
588 OTF_RuleSet *RuleSet; /* [<RuleSetCount>] */
593 OTF_ClassDef ClassDef;
594 unsigned ClassSetCnt;
595 OTF_ClassSet *ClassSet; /* [<ClassSetCnt>] */
601 unsigned LookupCount;
602 OTF_Coverage *Coverage; /* [<GlyphCount>] */
603 OTF_LookupRecord *LookupRecord; /* [<LookupCount>] */
607 /* Common to OTF_GSUB/GPOS_ChainContext1/2/3. */
611 unsigned ChainRuleSetCount;
612 OTF_ChainRuleSet *ChainRuleSet;
617 OTF_ClassDef BacktrackClassDef;
618 OTF_ClassDef InputClassDef;
619 OTF_ClassDef LookaheadClassDef;
620 unsigned ChainClassSetCnt;
621 OTF_ChainClassSet *ChainClassSet;
626 unsigned BacktrackGlyphCount;
627 OTF_Coverage *Backtrack;
628 unsigned InputGlyphCount;
630 unsigned LookaheadGlyphCount;
631 OTF_Coverage *LookAhead;
632 unsigned LookupCount;
633 OTF_LookupRecord *LookupRecord;
636 /* Common to OTF_GSUB/GPOS. */
641 OTF_ScriptList ScriptList;
642 OTF_FeatureList FeatureList;
643 OTF_LookupList LookupList;
646 /*** (1-9) "GSUB" table */
656 OTF_GlyphID *Substitute;
659 typedef struct OTF_Sequence OTF_Sequence;
663 unsigned SequenceCount;
664 OTF_Sequence *Sequence;
665 } OTF_GSUB_Multiple1;
671 OTF_GlyphID *Substitute;
674 typedef struct OTF_AlternateSet OTF_AlternateSet;
678 unsigned AlternateSetCount;
679 OTF_AlternateSet *AlternateSet;
680 } OTF_GSUB_Alternate1;
682 struct OTF_AlternateSet
686 OTF_GlyphID *Alternate;
689 typedef struct OTF_LigatureSet OTF_LigatureSet;
690 typedef struct OTF_Ligature OTF_Ligature;
694 unsigned LigSetCount;
695 OTF_LigatureSet *LigatureSet;
696 } OTF_GSUB_Ligature1;
698 struct OTF_LigatureSet
701 unsigned LigatureCount;
702 OTF_Ligature *Ligature;
708 OTF_GlyphID LigGlyph;
710 OTF_GlyphID *Component;
713 typedef OTF_Context1 OTF_GSUB_Context1;
715 typedef OTF_Context2 OTF_GSUB_Context2;
717 typedef OTF_Context3 OTF_GSUB_Context3;
719 typedef OTF_ChainContext1 OTF_GSUB_ChainContext1;
721 typedef OTF_ChainContext2 OTF_GSUB_ChainContext2;
723 typedef OTF_ChainContext3 OTF_GSUB_ChainContext3;
727 unsigned ExtensionLookupType;
728 unsigned ExtensionOffset;
729 OTF_LookupSubTableGSUB *ExtensionSubtable;
730 } OTF_GSUB_Extension1;
734 unsigned BacktrackGlyphCount;
735 OTF_Coverage *Backtrack;
736 unsigned LookaheadGlyphCount;
737 OTF_Coverage *LookAhead;
739 OTF_GlyphID *Substitute;
740 } OTF_GSUB_ReverseChain1;
742 struct OTF_LookupSubTableGSUB
745 OTF_Coverage Coverage;
748 OTF_GSUB_Single1 single1;
749 OTF_GSUB_Single2 single2;
751 OTF_GSUB_Multiple1 multiple1;
753 OTF_GSUB_Alternate1 alternate1;
755 OTF_GSUB_Ligature1 ligature1;
757 OTF_GSUB_Context1 context1;
758 OTF_GSUB_Context2 context2;
759 OTF_GSUB_Context3 context3;
761 OTF_GSUB_ChainContext1 chain_context1;
762 OTF_GSUB_ChainContext2 chain_context2;
763 OTF_GSUB_ChainContext3 chain_context3;
765 OTF_GSUB_Extension1 extension1;
767 OTF_GSUB_ReverseChain1 reverse_chain1;
771 typedef OTF_GSUB_GPOS OTF_GSUB;
773 /*** (1-10) "GPOS" table */
777 OTF_XPlacement = 0x0001,
778 OTF_YPlacement = 0x0002,
779 OTF_XAdvance = 0x0004,
780 OTF_YAdvance = 0x0008,
781 OTF_XPlaDevice = 0x0010,
782 OTF_YPlaDevice = 0x0020,
783 OTF_XAdvDevice = 0x0040,
784 OTF_YAdvDevice = 0x0080
793 OTF_DeviceTable XPlaDevice;
794 OTF_DeviceTable YPlaDevice;
795 OTF_DeviceTable XAdvDevice;
796 OTF_DeviceTable YAdvDevice;
802 unsigned AnchorFormat;
807 unsigned AnchorPoint;
810 OTF_DeviceTable XDeviceTable;
811 OTF_DeviceTable YDeviceTable;
819 OTF_Anchor MarkAnchor;
826 OTF_MarkRecord *MarkRecord;
831 unsigned ValueFormat;
832 OTF_ValueRecord Value;
837 unsigned ValueFormat;
839 OTF_ValueRecord *Value; /* [<ValueCount>] */
844 OTF_GlyphID SecondGlyph;
845 OTF_ValueRecord Value1;
846 OTF_ValueRecord Value2;
847 } OTF_PairValueRecord;
852 unsigned PairValueCount;
853 OTF_PairValueRecord *PairValueRecord;
858 unsigned ValueFormat1;
859 unsigned ValueFormat2;
860 unsigned PairSetCount;
861 OTF_PairSet *PairSet;
866 OTF_ValueRecord Value1;
867 OTF_ValueRecord Value2;
872 OTF_Class2Record *Class2Record;
877 unsigned ValueFormat1;
878 unsigned ValueFormat2;
879 OTF_ClassDef ClassDef1;
880 OTF_ClassDef ClassDef2;
881 unsigned Class1Count;
882 unsigned Class2Count;
883 OTF_Class1Record *Class1Record; /* size: <Class1Count> */
888 OTF_Anchor EntryAnchor;
889 OTF_Anchor ExitAnchor;
890 } OTF_EntryExitRecord;
894 unsigned EntryExitCount;
895 OTF_EntryExitRecord *EntryExitRecord;
907 OTF_AnchorRecord *AnchorRecord;
912 OTF_Coverage BaseCoverage;
914 OTF_MarkArray MarkArray;
915 OTF_AnchorArray BaseArray;
916 } OTF_GPOS_MarkBase1;
920 OTF_Anchor *LigatureAnchor; /* [<ClassCount>] */
921 } OTF_ComponentRecord;
926 unsigned ComponentCount;
927 OTF_ComponentRecord *ComponentRecord; /* [<ComponentCount>] */
928 } OTF_LigatureAttach;
933 unsigned LigatureCount;
934 OTF_LigatureAttach *LigatureAttach; /* [<LiagureCount>] */
939 OTF_Coverage LigatureCoverage;
941 OTF_MarkArray MarkArray;
942 OTF_LigatureArray LigatureArray;
947 OTF_Coverage Mark2Coverage;
949 OTF_MarkArray Mark1Array;
950 OTF_AnchorArray Mark2Array;
951 } OTF_GPOS_MarkMark1;
953 typedef OTF_Context1 OTF_GPOS_Context1;
955 typedef OTF_Context2 OTF_GPOS_Context2;
957 typedef OTF_Context3 OTF_GPOS_Context3;
959 typedef OTF_ChainContext1 OTF_GPOS_ChainContext1;
961 typedef OTF_ChainContext2 OTF_GPOS_ChainContext2;
963 typedef OTF_ChainContext3 OTF_GPOS_ChainContext3;
967 unsigned ExtensionLookupType;
968 unsigned ExtensionOffset;
969 OTF_LookupSubTableGPOS *ExtensionSubtable;
970 } OTF_GPOS_Extension1;
973 struct OTF_LookupSubTableGPOS
976 OTF_Coverage Coverage;
979 OTF_GPOS_Single1 single1;
980 OTF_GPOS_Single2 single2;
982 OTF_GPOS_Pair1 pair1;
983 OTF_GPOS_Pair2 pair2;
985 OTF_GPOS_Cursive1 cursive1;
987 OTF_GPOS_MarkBase1 mark_base1;
989 OTF_GPOS_MarkLig1 mark_lig1;
991 OTF_GPOS_MarkMark1 mark_mark1;
993 OTF_GPOS_Context1 context1;
994 OTF_GPOS_Context2 context2;
995 OTF_GPOS_Context3 context3;
997 OTF_GPOS_ChainContext1 chain_context1;
998 OTF_GPOS_ChainContext2 chain_context2;
999 OTF_GPOS_ChainContext3 chain_context3;
1001 OTF_GPOS_Extension1 extension1;
1005 typedef OTF_GSUB_GPOS OTF_GPOS;
1007 /*** (1-11) Structure for OTF */
1011 OTF_Fixed sfnt_version;
1013 unsigned searchRange;
1014 unsigned enterSelector;
1015 unsigned rangeShift;
1025 } OTF_TableDirectory;
1027 typedef struct OTF_InternalData OTF_InternalData;
1032 OTF_OffsetTable offset_table;
1033 OTF_TableDirectory *table_dirs;
1040 /* The following tables are not yet supported. */
1041 /* OTF_BASE *base; */
1042 /* OTF_JSTF *jstf; */
1043 OTF_InternalData *internal_data;
1047 /*** (2) API for reading OTF */
1049 /*** (2-1) otf_open () */
1054 The OTF_open() function reads the OpenType font file whose name is
1055 $NAME, and return a pointer to the structure of type OTF.
1057 It setups these member of the structure OTF:
1058 filename, offset_table, table_dirs
1060 If the file can't be read or the file contains invalid data, NULL
1061 is returned, and the variable OTF_error is set to one of the
1068 See also OTF_get_table() and OTF_close(). */
1070 extern OTF *OTF_open (const char *name);
1072 #include <ft2build.h>
1073 #include FT_FREETYPE_H
1075 extern OTF *OTF_open_ft_face (FT_Face face);
1078 /*** (2-2) OTF_close () */
1083 The OTF_close() function closes the OpenType font $OTF which must
1084 be what the OTF_open() function returned.
1086 See also OTF_open(). */
1088 extern void OTF_close (OTF *otf);
1091 /*** (2-3) OTF_get_table () */
1094 Get OpenType font table
1096 The OTF_get_table() function setups one of the OTF table specified
1097 by $NAME in the OpenType font $OTF.
1099 $NAME must be one of "head", "name", "cmap", "GDEF", "GSUB", and
1100 "GPOS", and a member of the same name is setup.
1102 If the table is successfully setup, return 0. Otherwise, return
1103 -1, and set the variable OTF_error to OTF_ERROR_TABLE.
1105 See also OTF_open(). */
1107 extern int OTF_get_table (OTF *otf, const char *name);
1109 /*** (2-4) OTF_check_table () */
1112 Check the existence of OpenType font table
1114 The OTF_check_table() function checks if the the OTF table
1115 specified by $NAME exists in OpenType font $OTF.
1117 If the table exists, return 0, else return -1.
1119 See also OTF_open(). */
1121 extern int OTF_check_table (OTF *otf, const char *name);
1123 /*** (2-5) OTF_get_scripts () */
1126 Get supported scripts.
1128 The OTF_get_scripts() function setups OTF_ScriptList of GSUB (if
1129 $GSUBP is nonzero) or GPOS (if $GSUBP is zero) table of the
1132 If the table is successfully setup, return 0. Otherwise, retrun
1133 -1, and set the variable OTF_error to OTF_ERROR_TABLE. */
1135 extern int OTF_get_scripts (OTF *otf, int gsubp);
1137 /*** (2-6) OTF_get_features () */
1140 Get supported features.
1142 The OTF_get_features() function setups OTF_FeatureList of GSUB (if
1143 $GSUBP is nonzero) or GPOS (if $GSUBP is zero) table of the
1146 If the table is successfully setup, return 0. Otherwise, retrun
1147 -1, and set the variable OTF_error to OTF_ERROR_TABLE. */
1149 extern int OTF_get_features (OTF *otf, int gsubp);
1151 /*** (2-7) OTF_check_features */
1154 Check supported features.
1156 The OTF_check_features() function checks if or not the OpenType
1157 font $OTF has, for $SCRIPT and $LANGUAGE, all features in the
1158 array $FEATURES. The array size is $N_FEATURES. If $LANGUAGE is
1159 zero or $OTF doesn't have LangSys for $SCRIPT, the default LangSys
1162 If $OTF has all the features, return 1. Otherwise, return 0. If
1163 an error occurs, return -1, and set the variable OTF_error to
1166 extern int OTF_check_features (OTF *otf, int gsubp,
1167 OTF_Tag script, OTF_Tag language,
1168 const OTF_Tag *features, int n_features);
1170 /*** (3) API for driving OTF */
1172 /*** (3-1) Structure for glyph string */
1175 The structure OTF_Glyph contains information about each glyph in
1176 the structure OTF_GlyphString. */
1180 /** The first two members must be set by a clinet before calling the
1181 function OTF_drive_XXX(). **/
1183 /* Character code of the glyph. The value less than 32 is treated
1184 as a place-holder in a glyph string, and OTF_drive_XXX ()
1185 function just ignore the glyph as if it doesn't exist. */
1188 /* Glyph ID of the glyph. If the value is 0, the library gets a
1189 correct value from the above character code via cmap. */
1190 OTF_GlyphID glyph_id;
1192 /* GlyphClass of the glyph. The value is extracted from the GDEF
1194 enum OTF_GlyphClassDef GlyphClass;
1196 /* MarkAttachClassDef of the glyph. The value is extracted from the
1198 unsigned MarkAttachClass;
1200 /* Positioning format type of the glyph. The value specifies how
1201 the glyph positioning information is encoded in the member <f>.
1202 If the value is N, the union member fN, is used. If the value is
1203 zero, the glyph has no positioning information, i.e. it should be
1204 drawn at the normal position. */
1205 int positioning_type;
1211 enum OTF_ValueFormat format;
1212 OTF_ValueRecord *value;
1215 enum OTF_ValueFormat format;
1216 OTF_ValueRecord *value;
1219 OTF_Anchor *entry_anchor;
1220 OTF_Anchor *exit_anchor;
1223 OTF_Anchor *mark_anchor;
1224 OTF_Anchor *base_anchor;
1227 OTF_Anchor *mark_anchor;
1228 OTF_Anchor *ligature_anchor;
1231 OTF_Anchor *mark1_anchor;
1232 OTF_Anchor *mark2_anchor;
1238 The structure OTF_GlyphString contains an array of glyphs (type
1239 OTF_Glyph). It is used as arguments of otf_drive_XXX(). */
1243 /* How many glyphs are allocated at the memory pointed by the member
1246 /* How many glyphs contain valid information. */
1248 /* Array of glyphs. It must be allocated by malloc(). The
1249 functions otf_drive_XXX() may reallocate it and increase the
1250 members <size> and <used>. */
1255 /*** (3-2) OTF_drive_cmap() */
1258 Process glyph string by Unicode-based cmap table.
1260 The OTF_drive_cmap() function looks up a Unicode-based cmap table
1261 of OpenType font $OTF, and setup the member <glyhph_id> of all
1262 glhphs in the glyph string $GSTRING if the value of the member is
1265 extern int OTF_drive_cmap (OTF *otf, OTF_GlyphString *gstring);
1268 Process glyph string by a specific cmap table.
1270 The OTF_drive_cmap2() function looks up a cmap table (whose
1271 Platform-ID is $PLATFORM_ID an Encoding-ID is $ENCODING_ID) of
1272 OpenType font $OTF, and setup the member <glyhph_id> of all glhphs
1273 in the glyph string $GSTRING if the value of the member is not
1276 extern int OTF_drive_cmap2 (OTF *otf, OTF_GlyphString *gstring,
1277 int platform_id, int encoding_id);
1279 /*** (3-3) OTF_drive_gdef() */
1282 Process glyph string by GDEF table.
1284 The OTF_drive_gdef() function looks up the GDEF table of OpenType
1285 font $OTF, and setup members <GlyphClass> and <MarkAttachClass> of
1286 all glhphs in the glyph string $GSTRING. */
1288 extern int OTF_drive_gdef (OTF *otf, OTF_GlyphString *gstring);
1291 /*** (3-4) OTF_drive_gsub() */
1294 Process glyph string by GSUB table.
1296 The OTF_drive_gsub() function looks up the GSUB table of OpenType
1297 font $OTF, and by using features the font has for script $SCRIPT
1298 and language system $LANGSYS, update member <glyphs> of the glyph
1299 string $GSTRING. It may substitute, delete, insert glyphs in that
1300 array. $FEATURES is a list of features to apply. This doesn't
1301 perform a lookup of type 3 (Alternate Substitution). For that,
1302 use OTF_drive_gsub_alternate(). */
1304 extern int OTF_drive_gsub (OTF *otf, OTF_GlyphString *gstring,
1305 const char *script, const char *language,
1306 const char *features);
1308 /*** (3-5) OTF_drive_gpos() */
1311 Process glyph string by GPOS table.
1313 The OTF_drive_gdef() function looks up the GPOS table of $OTF of
1314 OpenType font $OTF, and by using features the font has for script
1315 $SCRIPT and language system $LANGSYS, setup members
1316 <positioning_type> and <f> of all glhphs in the glyph string
1317 $GSTRING. $FEATURES is a list of features to apply. */
1319 extern int OTF_drive_gpos (OTF *otf, OTF_GlyphString *gstring,
1320 const char *script, const char *language,
1321 const char *features);
1323 /*** (3-6) OTF_drive_tables() */
1326 Process glyph string by cmap, GDEF, GSUB, and GPOS tables.
1328 The OTF_drive_tables() function calls OTF_drive_cmap(),
1329 OTF_drive_gdef(), OTF_drive_gsub(), and OTF_drive_gpos() in this
1330 order, and update the glyphs string GSTRING. */
1332 extern int OTF_drive_tables (OTF *otf, OTF_GlyphString *gstring,
1333 const char *script, const char *language,
1334 const char *gsub_features,
1335 const char *gpos_features);
1338 /*** (3-7) OTF_get_unicode() */
1341 Return Unicode code point corresponding to the glyph-id CODE.
1344 extern int OTF_get_unicode (OTF *otf, OTF_GlyphID code);
1346 /*** (3-8) OTF_drive_gsub_alternate() */
1349 Find alternate glyphs.
1351 This is like OTF_drive_gsub(), but perform only a lookup of type 3
1352 (Alternate Substituion). */
1354 extern int OTF_drive_gsub_alternate (OTF *otf, OTF_GlyphString *gstring,
1355 const char *script, const char *language,
1356 const char *features);
1358 /*** (4) API for error handling ***/
1360 /*** (4-1) Error codes ***/
1363 Global variable holding an error code.
1365 The variable OTF_error is set to one of OTF_ERROR_XXX macros when
1366 an error is detected in the OTF library. */
1367 extern int OTF_error;
1370 Memory allocation error
1372 This error indicates that the library couldn't allocate
1374 #define OTF_ERROR_MEMORY 1
1379 This error indicates that the library fails in opening, reading,
1380 or seeking an OTF file. */
1381 #define OTF_ERROR_FILE 2
1384 Invalid table contents
1386 This error indicates that an OTF file contains invalid data. */
1387 #define OTF_ERROR_TABLE 3
1392 See the function otf_drive_cmap() for more detail. */
1393 #define OTF_ERROR_CMAP_DRIVE 4
1398 See the function OTF_drive_gdef() for more detail. */
1399 #define OTF_ERROR_GDEF_DRIVE 5
1404 See the function OTF_drive_gsub() for more detail. */
1405 #define OTF_ERROR_GSUB_DRIVE 6
1410 See the function OTF_drive_gpos() for more detail. */
1411 #define OTF_ERROR_GPOS_DRIVE 7
1414 FT_Face access error.
1416 This error indicates that the library fails in accessing Sfnt
1417 tables via FT_Face. */
1418 #define OTF_ERROR_FT_FACE 8
1421 /*** (4-2) OTF_perror() */
1424 Print an OTF error message
1426 The OTF_perror() function produces a message on the standard error
1427 output, describing the last error encountered during a call to the
1428 OTF library function. If $PREFIX is not NULL, it is printed
1429 first, followed by a colon and a blank. Then the message and a
1432 extern void OTF_perror (const char *prefix);
1435 /*** (5) API miscellaneous ***/
1438 Return OTF tag of a specified name string.
1440 The OTF_tag() function returns OTF tag of name $NAME. If $NAME is
1441 NULL, return 0. Otherwise, $NAME must be at least 4-byte length.
1442 Only the first 4 characters are took into an account. */
1444 extern OTF_Tag OTF_tag (const char *name);
1447 Convert OTF tag to name string.
1449 The OTF_tag_name() function converts OTF tag $TAG to a 5-byte name
1450 string (including the terminating NULL), and store it in $NAME.
1451 At least 5-byte space must be at $NAME. */
1453 extern void OTF_tag_name (OTF_Tag tag, char *name);
1459 #endif /* not _OTF_H_ */