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