1 
2 //          Copyright 2019 - 2021 Michael D. Parker
3 // Distributed under the Boost Software License, Version 1.0.
4 //    (See accompanying file LICENSE_1_0.txt or copy at
5 //          http://www.boost.org/LICENSE_1_0.txt)
6 
7 module bindbc.freetype.bind.tttables;
8 
9 import bindbc.freetype.config;
10 import bindbc.freetype.bind.freetype,
11        bindbc.freetype.bind.fttypes;
12 
13 struct TT_Header {
14     FT_Fixed Table_Version;
15     FT_Fixed Font_Revision;
16     FT_Long CheckSum_Adjust;
17     FT_Long Magic_Number;
18     FT_UShort Flags;
19     FT_UShort Units_Per_EM;
20     static if(ftSupport >= FTSupport.ft210) {
21         FT_ULong[2] Created;
22         FT_ULong[2] Modified;
23     }
24     else {
25         FT_Long[2] Created;
26         FT_Long[2] Modified;
27     }
28     FT_Short xMin;
29     FT_Short yMin;
30     FT_Short xMax;
31     FT_Short yMax;
32     FT_UShort Mac_Style;
33     FT_UShort Lowest_Rec_PPEM;
34     FT_Short Font_Direction;
35     FT_Short Index_To_Loc_Format;
36     FT_Short Glyph_Data_Format;
37 }
38 
39 struct TT_HoriHeader {
40     FT_Fixed Version;
41     FT_Short Ascender;
42     FT_Short Descender;
43     FT_Short Line_Gap;
44     FT_UShort advance_Width_Max;
45     FT_Short min_Left_Side_Bearing;
46     FT_Short min_Right_Side_Bearing;
47     FT_Short xMax_Extent;
48     FT_Short caret_Slope_Rise;
49     FT_Short caret_Slope_Run;
50     FT_Short caret_Offset;
51     FT_Short[4] Reserved;
52     FT_Short metric_Data_Format;
53     FT_UShort number_Of_HMetrics;
54     void* long_metrics;
55     void* short_metrics;
56 }
57 
58 struct TT_VertHeader {
59     FT_Fixed Version;
60     FT_Short Ascender;
61     FT_Short Descender;
62     FT_Short Line_Gap;
63     FT_UShort advance_Height_Max;
64     FT_Short min_Top_Side_Bearing;
65     FT_Short min_Bottom_Side_Bearing;
66     FT_Short yMax_Extent;
67     FT_Short caret_Slope_Rise;
68     FT_Short caret_Slope_Run;
69     FT_Short caret_Offset;
70     FT_Short[4] Reserved;
71     FT_Short metric_Data_Format;
72     FT_UShort number_Of_VMetrics;
73     void* long_metrics;
74     void* short_metrics;
75 }
76 
77 struct TT_OS2 {
78     FT_UShort _version;
79     FT_Short xAvgCharWidth;
80     FT_UShort usWeightClass;
81     FT_UShort usWidthClass;
82     FT_UShort fsType;
83     FT_Short ySubscriptXSize;
84     FT_Short ySubscriptYSize;
85     FT_Short ySubscriptXOffset;
86     FT_Short ySubscriptYOffset;
87     FT_Short ySuperscriptXSize;
88     FT_Short ySuperscriptYSize;
89     FT_Short ySuperscriptXOffset;
90     FT_Short ySuperscriptYOffset;
91     FT_Short yStrikeoutSize;
92     FT_Short yStrikeoutPosition;
93     FT_Short sFamilyClass;
94     FT_Byte[10] panose;
95     FT_ULong ulUnicodeRange1;
96     FT_ULong ulUnicodeRange2;
97     FT_ULong ulUnicodeRange3;
98     FT_ULong ulUnicodeRange4;
99     FT_Char[4] achVendID;
100     FT_UShort fsSelection;
101     FT_UShort usFirstCharIndex;
102     FT_UShort usLastCharIndex;
103     FT_Short sTypoAscender;
104     FT_Short sTypoDescender;
105     FT_Short sTypoLineGap;
106     FT_UShort usWinAscent;
107     FT_UShort usWinDescent;
108     FT_ULong ulCodePageRange1;
109     FT_ULong ulCodePageRange2;
110     FT_Short sxHeight;
111     FT_Short sCapHeight;
112     FT_UShort usDefaultChar;
113     FT_UShort usBreakChar;
114     FT_UShort usMaxContext;
115     FT_UShort usLowerOpticalPointSize;
116     FT_UShort usUpperOpticalPointSize;
117 }
118 
119 struct TT_Postscript {
120     FT_Fixed FormatType;
121     FT_Fixed italicAngle;
122     FT_Short underlinePosition;
123     FT_Short underlineThickness;
124     FT_ULong isFixedPitch;
125     FT_ULong minMemType42;
126     FT_ULong maxMemType42;
127     FT_ULong minMemType1;
128     FT_ULong maxMemType1;
129 }
130 
131 struct TT_PCLT {
132     FT_Fixed Version;
133     FT_ULong FontNumber;
134     FT_UShort Pitch;
135     FT_UShort xHeight;
136     FT_UShort Style;
137     FT_UShort TypeFamily;
138     FT_UShort CapHeight;
139     FT_UShort SymbolSet;
140     FT_Char[16] TypeFace;
141     FT_Char[8] CharacterComplement;
142     FT_Char[6] FileName;
143     FT_Char StrokeWeight;
144     FT_Char WidthType;
145     FT_Byte SerifStyle;
146     FT_Byte Reserved;
147 }
148 
149 struct TT_MaxProfile {
150     FT_Fixed _version;
151     FT_UShort numGlyphs;
152     FT_UShort maxPoints;
153     FT_UShort maxContours;
154     FT_UShort maxCompositePoints;
155     FT_UShort maxCompositeContours;
156     FT_UShort maxZones;
157     FT_UShort maxTwilightPoints;
158     FT_UShort maxStorage;
159     FT_UShort maxFunctionDefs;
160     FT_UShort maxInstructionDefs;
161     FT_UShort maxStackElements;
162     FT_UShort maxSizeOfInstructions;
163     FT_UShort maxComponentElements;
164     FT_UShort maxComponentDepth;
165 }
166 
167 alias FT_Sfnt_Tag = int;
168 enum {
169     FT_SFNT_HEAD,
170     FT_SFNT_MAXP,
171     FT_SFNT_OS2,
172     FT_SFNT_HHEA,
173     FT_SFNT_VHEA,
174     FT_SFNT_POST,
175     FT_SFNT_PCLT,
176     FT_SFNT_MAX
177 }
178 
179 static if(staticBinding) {
180 	extern(C) @nogc nothrow {
181         void* FT_Get_Sfnt_Table(FT_Face face, FT_Sfnt_Tag tag);
182         FT_Error FT_Load_Sfnt_Table(FT_Face face, FT_ULong tag, FT_Long offset, FT_Byte* buffer, FT_ULong* length);
183         FT_Error FT_Sfnt_Table_Info(FT_Face face, FT_UInt table_index, FT_ULong* tag, FT_ULong* length);
184         FT_ULong FT_Get_CMap_Language_ID(FT_CharMap charmap);
185         FT_ULong FT_Get_CMap_Format(FT_CharMap charmap);
186     }
187 }
188 else {
189     extern(C) @nogc nothrow {
190         alias pFT_Get_Sfnt_Table = void* function(FT_Face face, FT_Sfnt_Tag tag);
191         alias pFT_Load_Sfnt_Table = FT_Error function(FT_Face face, FT_ULong tag, FT_Long offset, FT_Byte* buffer, FT_ULong* length);
192         alias pFT_Sfnt_Table_Info = FT_Error function(FT_Face face, FT_UInt table_index, FT_ULong* tag, FT_ULong* length);
193         alias pFT_Get_CMap_Language_ID = FT_ULong function(FT_CharMap charmap);
194         alias pFT_Get_CMap_Format = FT_ULong function(FT_CharMap charmap);
195     }
196 
197     __gshared {
198         pFT_Get_Sfnt_Table FT_Get_Sfnt_Table;
199         pFT_Load_Sfnt_Table FT_Load_Sfnt_Table;
200         pFT_Sfnt_Table_Info FT_Sfnt_Table_Info;
201         pFT_Get_CMap_Language_ID FT_Get_CMap_Language_ID;
202         pFT_Get_CMap_Format FT_Get_CMap_Format;
203     }
204 }