1 
2 //          Copyright Michael D. Parker 2018.
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.t1tables;
8 
9 import bindbc.freetype.bind.freetype,
10        bindbc.freetype.bind.ftimage,
11        bindbc.freetype.bind.fttypes;
12 
13 struct PS_FontInfoRec {
14     FT_String* _version;
15     FT_String* notice;
16     FT_String* full_name;
17     FT_String* family_name;
18     FT_String* weight;
19     FT_Long italic_angle;
20     FT_Bool is_fixed_pitch;
21     FT_Short underline_position;
22     FT_UShort underline_thickness;
23 }
24 
25 alias PS_FontInfo = PS_FontInfoRec*;
26 
27 struct PS_PrivateRec {
28     FT_Int unique_id;
29     FT_Int lenIV;
30     FT_Byte num_blue_values;
31     FT_Byte num_other_blues;
32     FT_Byte num_family_blues;
33     FT_Byte num_family_other_blues;
34     FT_Short[14] blue_values;
35     FT_Short[10] other_blues;
36     FT_Short[14] family_blues;
37     FT_Short[10] family_other_blues;
38     FT_Fixed blue_scale;
39     FT_Int blue_shift;
40     FT_Int blue_fuzz;
41     FT_UShort[1] standard_width;
42     FT_UShort[1] standard_height;
43     FT_Byte num_snap_widths;
44     FT_Byte num_snap_heights;
45     FT_Bool force_bold;
46     FT_Bool round_stem_up;
47     FT_Short[13] snap_widths;
48     FT_Short[13] snap_heights;
49     FT_Fixed expansion_factor;
50     FT_Long language_group;
51     FT_Long password;
52     FT_Short[2] min_feature;
53 }
54 
55 alias PS_Private = PS_PrivateRec*;
56 
57 alias T1_Blend_Flags = int;
58 enum {
59     T1_BLEND_UNDERLINE_POSITION = 0,
60     T1_BLEND_UNDERLINE_THICKNESS,
61     T1_BLEND_ITALIC_ANGLE,
62     T1_BLEND_BLUE_VALUES,
63     T1_BLEND_OTHER_BLUES,
64     T1_BLEND_STANDARD_WIDTH,
65     T1_BLEND_STANDARD_HEIGHT,
66     T1_BLEND_STEM_SNAP_WIDTHS,
67     T1_BLEND_STEM_SNAP_HEIGHTS,
68     T1_BLEND_BLUE_SCALE,
69     T1_BLEND_BLUE_SHIFT,
70     T1_BLEND_FAMILY_BLUES,
71     T1_BLEND_FAMILY_OTHER_BLUES,
72     T1_BLEND_FORCE_BOLD,
73     T1_BLEND_MAX
74 }
75 
76 enum T1_MAX_MM_DESIGNS = 16;
77 enum T1_MAX_MM_AXIS = 4;
78 enum T1_MAX_MM_MAP_POINTS = 20;
79 
80 struct PS_DesignMapRec {
81     FT_Byte num_points;
82     FT_Long* design_points;
83     FT_Fixed* blend_points;
84 }
85 
86 alias PS_DesignMap = PS_DesignMapRec*;
87 
88 struct PS_BlendRec {
89     FT_UInt num_designs;
90     FT_UInt num_axis;
91     FT_String*[T1_MAX_MM_AXIS] axis_names;
92     FT_Fixed*[T1_MAX_MM_DESIGNS] design_pos;
93     PS_DesignMapRec[T1_MAX_MM_AXIS] design_map;
94     FT_Fixed* weight_vector;
95     FT_Fixed* default_weight_vector;
96     PS_FontInfo[T1_MAX_MM_DESIGNS+1] font_infos;
97     PS_Private[T1_MAX_MM_DESIGNS+1] privates;
98     FT_ULong blend_bitflags;
99     FT_BBox*[T1_MAX_MM_DESIGNS+1] bboxes;
100     FT_UInt[T1_MAX_MM_DESIGNS] default_design_vector;
101     FT_UInt num_default_design_vector;
102 }
103 
104 alias PS_Blend = PS_BlendRec*;
105 
106 struct CID_FaceDictRec {
107     PS_PrivateRec private_dict;
108     FT_UInt len_buildchar;
109     FT_Fixed forcebold_threshold;
110     FT_Pos stroke_width;
111     FT_Fixed expansion_factor;
112     FT_Byte paint_type;
113     FT_Byte font_type;
114     FT_Matrix font_matrix;
115     FT_Vector font_offset;
116     FT_UInt num_subrs;
117     FT_ULong subrmap_offset;
118     FT_Int sd_bytes;
119 }
120 
121 alias CID_FaceDict = CID_FaceDictRec*;
122 
123 struct CID_FaceInfoRec {
124     FT_String* cid_font_name;
125     FT_Fixed cid_version;
126     FT_Int cid_font_type;
127     FT_String* registry;
128     FT_String* ordering;
129     FT_Int supplement;
130     PS_FontInfoRec font_info;
131     FT_BBox font_bbox;
132     FT_ULong uid_base;
133     FT_Int num_xuid;
134     FT_ULong[16] xuid;
135     FT_ULong cidmap_offset;
136     FT_Int fd_bytes;
137     FT_Int gd_bytes;
138     FT_ULong cid_count;
139     FT_Int num_dicts;
140     CID_FaceDict font_dicts;
141     FT_ULong data_offset;
142 }
143 
144 alias CID_FaceInfo = CID_FaceInfoRec*;
145 
146 alias T1_EncodingType = int;
147 enum {
148     T1_ENCODING_TYPE_NONE = 0,
149     T1_ENCODING_TYPE_ARRAY,
150     T1_ENCODING_TYPE_STANDARD,
151     T1_ENCODING_TYPE_ISOLATIN1,
152     T1_ENCODING_TYPE_EXPERT,
153 }
154 
155 alias PS_Dict_Keys = int;
156 enum {
157     PS_DICT_FONT_TYPE,
158     PS_DICT_FONT_MATRIX,
159     PS_DICT_FONT_BBOX,
160     PS_DICT_PAINT_TYPE,
161     PS_DICT_FONT_NAME,
162     PS_DICT_UNIQUE_ID,
163     PS_DICT_NUM_CHAR_STRINGS,
164     PS_DICT_CHAR_STRING_KEY,
165     PS_DICT_CHAR_STRING,
166     PS_DICT_ENCODING_TYPE,
167     PS_DICT_ENCODING_ENTRY,
168 
169     PS_DICT_NUM_SUBRS,
170     PS_DICT_SUBR,
171     PS_DICT_STD_HW,
172     PS_DICT_STD_VW,
173     PS_DICT_NUM_BLUE_VALUES,
174     PS_DICT_BLUE_VALUE,
175     PS_DICT_BLUE_FUZZ,
176     PS_DICT_NUM_OTHER_BLUES,
177     PS_DICT_OTHER_BLUE,
178     PS_DICT_NUM_FAMILY_BLUES,
179     PS_DICT_FAMILY_BLUE,
180     PS_DICT_NUM_FAMILY_OTHER_BLUES,
181     PS_DICT_FAMILY_OTHER_BLUE,
182     PS_DICT_BLUE_SCALE,
183     PS_DICT_BLUE_SHIFT,
184     PS_DICT_NUM_STEM_SNAP_H,
185     PS_DICT_STEM_SNAP_H,
186     PS_DICT_NUM_STEM_SNAP_V,
187     PS_DICT_STEM_SNAP_V,
188     PS_DICT_FORCE_BOLD,
189     PS_DICT_RND_STEM_UP,
190     PS_DICT_MIN_FEATURE,
191     PS_DICT_LEN_IV,
192     PS_DICT_PASSWORD,
193     PS_DICT_LANGUAGE_GROUP,
194 
195     PS_DICT_VERSION,
196     PS_DICT_NOTICE,
197     PS_DICT_FULL_NAME,
198     PS_DICT_FAMILY_NAME,
199     PS_DICT_WEIGHT,
200     PS_DICT_IS_FIXED_PITCH,
201     PS_DICT_UNDERLINE_POSITION,
202     PS_DICT_UNDERLINE_THICKNESS,
203     PS_DICT_FS_TYPE,
204     PS_DICT_ITALIC_ANGLE,
205 
206     PS_DICT_MAX = PS_DICT_ITALIC_ANGLE
207 }
208 
209 version(BindFT_Static) {
210 	extern(C) @nogc nothrow {
211         FT_Int FT_Has_PS_Glyph_Names(FT_Face);
212         FT_Error FT_Get_PS_Font_Info(FT_Face,PS_FontInfoRec*);
213         FT_Error FT_Get_PS_Font_Private(FT_Face,PS_PrivateRec*);
214         FT_Long FT_Get_PS_Font_Value(FT_Face,PS_Dict_Keys*,FT_UInt,FT_Long);
215     }
216 }
217 else {
218     extern(C) @nogc nothrow {
219         alias da_FT_Has_PS_Glyph_Names = FT_Int function(FT_Face);
220         alias da_FT_Get_PS_Font_Info = FT_Error function(FT_Face,PS_FontInfoRec*);
221         alias da_FT_Get_PS_Font_Private = FT_Error function(FT_Face,PS_PrivateRec*);
222         alias da_FT_Get_PS_Font_Value = FT_Long function(FT_Face,PS_Dict_Keys*,FT_UInt,FT_Long);
223     }
224 
225     __gshared {
226         da_FT_Has_PS_Glyph_Names FT_Has_PS_Glyph_Names;
227         da_FT_Get_PS_Font_Info FT_Get_PS_Font_Info;
228         da_FT_Get_PS_Font_Private FT_Get_PS_Font_Private;
229         da_FT_Get_PS_Font_Value FT_Get_PS_Font_Value;
230     }
231 }