Lines Matching defs:os2

5 #include "os2.h"
10 // http://www.microsoft.com/opentype/otspec/os2.htm
17 OpenTypeOS2 *os2 = new OpenTypeOS2;
18 file->os2 = os2;
20 if (!table.ReadU16(&os2->version) ||
21 !table.ReadS16(&os2->avg_char_width) ||
22 !table.ReadU16(&os2->weight_class) ||
23 !table.ReadU16(&os2->width_class) ||
24 !table.ReadU16(&os2->type) ||
25 !table.ReadS16(&os2->subscript_x_size) ||
26 !table.ReadS16(&os2->subscript_y_size) ||
27 !table.ReadS16(&os2->subscript_x_offset) ||
28 !table.ReadS16(&os2->subscript_y_offset) ||
29 !table.ReadS16(&os2->superscript_x_size) ||
30 !table.ReadS16(&os2->superscript_y_size) ||
31 !table.ReadS16(&os2->superscript_x_offset) ||
32 !table.ReadS16(&os2->superscript_y_offset) ||
33 !table.ReadS16(&os2->strikeout_size) ||
34 !table.ReadS16(&os2->strikeout_position) ||
35 !table.ReadS16(&os2->family_class)) {
39 if (os2->version > 4) {
45 if (os2->weight_class < 100 ||
46 os2->weight_class > 900 ||
47 os2->weight_class % 100) {
48 OTS_WARNING("bad weight: %u", os2->weight_class);
49 os2->weight_class = 400; // FW_NORMAL
51 if (os2->width_class < 1) {
52 OTS_WARNING("bad width: %u", os2->width_class);
53 os2->width_class = 1;
54 } else if (os2->width_class > 9) {
55 OTS_WARNING("bad width: %u", os2->width_class);
56 os2->width_class = 9;
60 if (os2->type & 0x2) {
62 os2->type &= 0xfff3u;
63 } else if (os2->type & 0x4) {
65 os2->type &= 0xfff4u;
66 } else if (os2->type & 0x8) {
68 os2->type &= 0xfff9u;
72 os2->type &= 0x30f;
74 if (os2->subscript_x_size < 0) {
75 OTS_WARNING("bad subscript_x_size: %d", os2->subscript_x_size);
76 os2->subscript_x_size = 0;
78 if (os2->subscript_y_size < 0) {
79 OTS_WARNING("bad subscript_y_size: %d", os2->subscript_y_size);
80 os2->subscript_y_size = 0;
82 if (os2->superscript_x_size < 0) {
83 OTS_WARNING("bad superscript_x_size: %d", os2->superscript_x_size);
84 os2->superscript_x_size = 0;
86 if (os2->superscript_y_size < 0) {
87 OTS_WARNING("bad superscript_y_size: %d", os2->superscript_y_size);
88 os2->superscript_y_size = 0;
90 if (os2->strikeout_size < 0) {
91 OTS_WARNING("bad strikeout_size: %d", os2->strikeout_size);
92 os2->strikeout_size = 0;
96 if (!table.ReadU8(&os2->panose[i])) {
101 if (!table.ReadU32(&os2->unicode_range_1) ||
102 !table.ReadU32(&os2->unicode_range_2) ||
103 !table.ReadU32(&os2->unicode_range_3) ||
104 !table.ReadU32(&os2->unicode_range_4) ||
105 !table.ReadU32(&os2->vendor_id) ||
106 !table.ReadU16(&os2->selection) ||
107 !table.ReadU16(&os2->first_char_index) ||
108 !table.ReadU16(&os2->last_char_index) ||
109 !table.ReadS16(&os2->typo_ascender) ||
110 !table.ReadS16(&os2->typo_descender) ||
111 !table.ReadS16(&os2->typo_linegap) ||
112 !table.ReadU16(&os2->win_ascent) ||
113 !table.ReadU16(&os2->win_descent)) {
118 if (os2->selection & 0x40) {
119 os2->selection &= 0xffdeu;
127 if ((os2->selection & 0x1) &&
132 if ((os2->selection & 0x2) &&
140 if ((os2->selection & 0x40) &&
146 if ((os2->version < 4) &&
147 (os2->selection & 0x300)) {
153 os2->selection &= 0x3ff;
155 if (os2->first_char_index > os2->last_char_index) {
158 if (os2->typo_linegap < 0) {
159 OTS_WARNING("bad linegap: %d", os2->typo_linegap);
160 os2->typo_linegap = 0;
163 if (os2->version < 1) {
169 OTS_WARNING("bad version number: %u", os2->version);
172 os2->version = 0;
176 if (!table.ReadU32(&os2->code_page_range_1) ||
177 !table.ReadU32(&os2->code_page_range_2)) {
181 if (os2->version < 2) {
187 OTS_WARNING("bad version number: %u", os2->version);
190 os2->version = 1;
194 if (!table.ReadS16(&os2->x_height) ||
195 !table.ReadS16(&os2->cap_height) ||
196 !table.ReadU16(&os2->default_char) ||
197 !table.ReadU16(&os2->break_char) ||
198 !table.ReadU16(&os2->max_context)) {
202 if (os2->x_height < 0) {
203 OTS_WARNING("bad x_height: %d", os2->x_height);
204 os2->x_height = 0;
206 if (os2->cap_height < 0) {
207 OTS_WARNING("bad cap_height: %d", os2->cap_height);
208 os2->cap_height = 0;
215 return file->os2 != NULL;
219 const OpenTypeOS2 *os2 = file->os2;
221 if (!out->WriteU16(os2->version) ||
222 !out->WriteS16(os2->avg_char_width) ||
223 !out->WriteU16(os2->weight_class) ||
224 !out->WriteU16(os2->width_class) ||
225 !out->WriteU16(os2->type) ||
226 !out->WriteS16(os2->subscript_x_size) ||
227 !out->WriteS16(os2->subscript_y_size) ||
228 !out->WriteS16(os2->subscript_x_offset) ||
229 !out->WriteS16(os2->subscript_y_offset) ||
230 !out->WriteS16(os2->superscript_x_size) ||
231 !out->WriteS16(os2->superscript_y_size) ||
232 !out->WriteS16(os2->superscript_x_offset) ||
233 !out->WriteS16(os2->superscript_y_offset) ||
234 !out->WriteS16(os2->strikeout_size) ||
235 !out->WriteS16(os2->strikeout_position) ||
236 !out->WriteS16(os2->family_class)) {
241 if (!out->Write(&os2->panose[i], 1)) {
246 if (!out->WriteU32(os2->unicode_range_1) ||
247 !out->WriteU32(os2->unicode_range_2) ||
248 !out->WriteU32(os2->unicode_range_3) ||
249 !out->WriteU32(os2->unicode_range_4) ||
250 !out->WriteU32(os2->vendor_id) ||
251 !out->WriteU16(os2->selection) ||
252 !out->WriteU16(os2->first_char_index) ||
253 !out->WriteU16(os2->last_char_index) ||
254 !out->WriteS16(os2->typo_ascender) ||
255 !out->WriteS16(os2->typo_descender) ||
256 !out->WriteS16(os2->typo_linegap) ||
257 !out->WriteU16(os2->win_ascent) ||
258 !out->WriteU16(os2->win_descent)) {
262 if (os2->version < 1) {
266 if (!out->WriteU32(os2->code_page_range_1) ||
267 !out->WriteU32(os2->code_page_range_2)) {
271 if (os2->version < 2) {
275 if (!out->WriteS16(os2->x_height) ||
276 !out->WriteS16(os2->cap_height) ||
277 !out->WriteU16(os2->default_char) ||
278 !out->WriteU16(os2->break_char) ||
279 !out->WriteU16(os2->max_context)) {
287 delete file->os2;