1 module ft.tttables;
2 
3 import ft.freetype : FT_CharMap, FT_Face;
4 import ft.types : FT_Byte, FT_Char, FT_Error, FT_Fixed, FT_UInt, FT_Long, FT_ULong, FT_Short, FT_UShort;
5 
6 extern(C) nothrow @nogc:
7 
8 struct TT_Header
9 {
10     FT_Fixed   Table_Version;
11     FT_Fixed   Font_Revision;
12 
13     FT_Long    CheckSum_Adjust;
14     FT_Long    Magic_Number;
15 
16     FT_UShort  Flags;
17     FT_UShort  Units_Per_EM;
18 
19     FT_Long[2] Created;
20     FT_Long[2] Modified;
21 
22     FT_Short   xMin;
23     FT_Short   yMin;
24     FT_Short   xMax;
25     FT_Short   yMax;
26 
27     FT_UShort  Mac_Style;
28     FT_UShort  Lowest_Rec_PPEM;
29 
30     FT_Short   Font_Direction;
31     FT_Short   Index_To_Loc_Format;
32     FT_Short   Glyph_Data_Format;
33 }
34 
35 struct TT_HoriHeader
36 {
37     FT_Fixed    Version;
38     FT_Short    Ascender;
39     FT_Short    Descender;
40     FT_Short    Line_Gap;
41 
42     FT_UShort   advance_Width_Max;      /* advance width maximum */
43 
44     FT_Short    min_Left_Side_Bearing;  /* minimum left-sb       */
45     FT_Short    min_Right_Side_Bearing; /* minimum right-sb      */
46     FT_Short    xMax_Extent;            /* xmax extents          */
47     FT_Short    caret_Slope_Rise;
48     FT_Short    caret_Slope_Run;
49     FT_Short    caret_Offset;
50 
51     FT_Short[4] Reserved;
52 
53     FT_Short    metric_Data_Format;
54     FT_UShort   number_Of_HMetrics;
55 
56     void*       long_metrics;
57     void*       short_metrics;
58 }
59 
60 struct TT_VertHeader
61 {
62     FT_Fixed    Version;
63     FT_Short    Ascender;
64     FT_Short    Descender;
65     FT_Short    Line_Gap;
66 
67     FT_UShort   advance_Height_Max;      /* advance height maximum */
68 
69     FT_Short    min_Top_Side_Bearing;    /* minimum top-sb          */
70     FT_Short    min_Bottom_Side_Bearing; /* minimum bottom-sb       */
71     FT_Short    yMax_Extent;             /* ymax extents            */
72     FT_Short    caret_Slope_Rise;
73     FT_Short    caret_Slope_Run;
74     FT_Short    caret_Offset;
75 
76     FT_Short[4] Reserved;
77 
78     FT_Short    metric_Data_Format;
79     FT_UShort   number_Of_VMetrics;
80 
81     void*       long_metrics;
82     void*       short_metrics;
83 }
84 
85 struct TT_OS2
86 {
87     FT_UShort  ver;
88     FT_Short   xAvgCharWidth;
89     FT_UShort  usWeightClass;
90     FT_UShort  usWidthClass;
91     FT_UShort  fsType;
92     FT_Short   ySubscriptXSize;
93     FT_Short   ySubscriptYSize;
94     FT_Short   ySubscriptXOffset;
95     FT_Short   ySubscriptYOffset;
96     FT_Short   ySuperscriptXSize;
97     FT_Short   ySuperscriptYSize;
98     FT_Short   ySuperscriptXOffset;
99     FT_Short   ySuperscriptYOffset;
100     FT_Short   yStrikeoutSize;
101     FT_Short   yStrikeoutPosition;
102     FT_Short   sFamilyClass;
103 
104     FT_Byte[10] panose;
105 
106     FT_ULong   ulUnicodeRange1;        /* Bits 0-31   */
107     FT_ULong   ulUnicodeRange2;        /* Bits 32-63  */
108     FT_ULong   ulUnicodeRange3;        /* Bits 64-95  */
109     FT_ULong   ulUnicodeRange4;        /* Bits 96-127 */
110 
111     FT_Char[4] achVendID;
112 
113     FT_UShort  fsSelection;
114     FT_UShort  usFirstCharIndex;
115     FT_UShort  usLastCharIndex;
116     FT_Short   sTypoAscender;
117     FT_Short   sTypoDescender;
118     FT_Short   sTypoLineGap;
119     FT_UShort  usWinAscent;
120     FT_UShort  usWinDescent;
121 
122     /* only version 1 and higher: */
123 
124     FT_ULong   ulCodePageRange1;       /* Bits 0-31   */
125     FT_ULong   ulCodePageRange2;       /* Bits 32-63  */
126 
127     /* only version 2 and higher: */
128 
129     FT_Short   sxHeight;
130     FT_Short   sCapHeight;
131     FT_UShort  usDefaultChar;
132     FT_UShort  usBreakChar;
133     FT_UShort  usMaxContext;
134 
135     /* only version 5 and higher: */
136 
137     FT_UShort  usLowerOpticalPointSize;       /* in twips (1/20th points) */
138     FT_UShort  usUpperOpticalPointSize;       /* in twips (1/20th points) */
139 }
140 
141 struct TT_Postscript
142 {
143     FT_Fixed  FormatType;
144     FT_Fixed  italicAngle;
145     FT_Short  underlinePosition;
146     FT_Short  underlineThickness;
147     FT_ULong  isFixedPitch;
148     FT_ULong  minMemType42;
149     FT_ULong  maxMemType42;
150     FT_ULong  minMemType1;
151     FT_ULong  maxMemType1;
152 }
153 
154 struct TT_PCLT
155 {
156     FT_Fixed   Version;
157     FT_ULong   FontNumber;
158     FT_UShort  Pitch;
159     FT_UShort  xHeight;
160     FT_UShort  Style;
161     FT_UShort  TypeFamily;
162     FT_UShort  CapHeight;
163     FT_UShort  SymbolSet;
164     FT_Char[16] TypeFace;
165     FT_Char[8] CharacterComplement;
166     FT_Char[6] FileName;
167     FT_Char    StrokeWeight;
168     FT_Char    WidthType;
169     FT_Byte    SerifStyle;
170     FT_Byte    Reserved;
171 }
172 
173 struct TT_MaxProfile
174 {
175     FT_Fixed   ver;
176     FT_UShort  numGlyphs;
177     FT_UShort  maxPoints;
178     FT_UShort  maxContours;
179     FT_UShort  maxCompositePoints;
180     FT_UShort  maxCompositeContours;
181     FT_UShort  maxZones;
182     FT_UShort  maxTwilightPoints;
183     FT_UShort  maxStorage;
184     FT_UShort  maxFunctionDefs;
185     FT_UShort  maxInstructionDefs;
186     FT_UShort  maxStackElements;
187     FT_UShort  maxSizeOfInstructions;
188     FT_UShort  maxComponentElements;
189     FT_UShort  maxComponentDepth;
190 }
191 
192 enum FT_Sfnt_Tag
193 {
194     FT_SFNT_HEAD,
195     FT_SFNT_MAXP,
196     FT_SFNT_OS2,
197     FT_SFNT_HHEA,
198     FT_SFNT_VHEA,
199     FT_SFNT_POST,
200     FT_SFNT_PCLT,
201 
202     FT_SFNT_MAX
203 }
204 
205 enum FT_SFNT_HEAD = FT_Sfnt_Tag.FT_SFNT_HEAD;
206 enum FT_SFNT_MAXP = FT_Sfnt_Tag.FT_SFNT_MAXP;
207 enum FT_SFNT_OS2  = FT_Sfnt_Tag.FT_SFNT_OS2;
208 enum FT_SFNT_HHEA = FT_Sfnt_Tag.FT_SFNT_HHEA;
209 enum FT_SFNT_VHEA = FT_Sfnt_Tag.FT_SFNT_VHEA;
210 enum FT_SFNT_POST = FT_Sfnt_Tag.FT_SFNT_POST;
211 enum FT_SFNT_PCLT = FT_Sfnt_Tag.FT_SFNT_PCLT;
212 enum FT_SFNT_MAX  = FT_Sfnt_Tag.FT_SFNT_MAX;
213 
214 
215   void*
216   FT_Get_Sfnt_Table( FT_Face      face,
217                      FT_Sfnt_Tag  tag );
218 
219   FT_Error
220   FT_Load_Sfnt_Table( FT_Face    face,
221                       FT_ULong   tag,
222                       FT_Long    offset,
223                       FT_Byte*   buffer,
224                       FT_ULong*  length );
225 
226   FT_Error
227   FT_Sfnt_Table_Info( FT_Face    face,
228                       FT_UInt    table_index,
229                       FT_ULong  *tag,
230                       FT_ULong  *length );
231 
232   FT_ULong
233   FT_Get_CMap_Language_ID( FT_CharMap  charmap );
234 
235   FT_Long
236   FT_Get_CMap_Format( FT_CharMap  charmap );