| 1 |
#include "OS_2.h" |
| 2 |
#include "support/util.h" |
| 3 |
|
| 4 |
|
| 5 |
static INLINE void initOS2(table_OS_2 *table) { |
| 6 |
memset(table, 0, sizeof(*table)); |
| 7 |
table->version = 4; |
| 8 |
} |
| 9 |
static INLINE void disposeOS2(MOVE table_OS_2 *table) { |
| 10 |
// trivial |
| 11 |
} |
| 12 |
caryll_standardRefType(table_OS_2, table_iOS_2, initOS2, disposeOS2); |
| 13 |
|
| 14 |
table_OS_2 *otfcc_readOS_2(const otfcc_Packet packet, const otfcc_Options *options) { |
| 15 |
table_OS_2 *os_2 = NULL; |
| 16 |
FOR_TABLE(OTFCC_CHR('O','S','/','2'), table) { |
| 17 |
font_file_pointer data = table.data; |
| 18 |
uint32_t length = table.length; |
| 19 |
if (length < 2) goto OS_2_CORRUPTED; |
| 20 |
os_2 = table_iOS_2.create(); |
| 21 |
os_2->version = read_16u(data); |
| 22 |
// version 0 (Apple's TrueType) |
| 23 |
if (length < 68) goto OS_2_CORRUPTED; |
| 24 |
{ |
| 25 |
os_2->xAvgCharWidth = read_16u(data + 2); |
| 26 |
os_2->usWeightClass = read_16u(data + 4); |
| 27 |
os_2->usWidthClass = read_16u(data + 6); |
| 28 |
os_2->fsType = read_16u(data + 8); |
| 29 |
os_2->ySubscriptXSize = read_16u(data + 10); |
| 30 |
os_2->ySubscriptYSize = read_16u(data + 12); |
| 31 |
os_2->ySubscriptXOffset = read_16u(data + 14); |
| 32 |
os_2->ySubscriptYOffset = read_16u(data + 16); |
| 33 |
os_2->ySupscriptXSize = read_16u(data + 18); |
| 34 |
os_2->ySupscriptYSize = read_16u(data + 20); |
| 35 |
os_2->ySupscriptXOffset = read_16u(data + 22); |
| 36 |
os_2->ySupscriptYOffset = read_16u(data + 24); |
| 37 |
os_2->yStrikeoutSize = read_16u(data + 26); |
| 38 |
os_2->yStrikeoutPosition = read_16u(data + 28); |
| 39 |
os_2->sFamilyClass = read_16u(data + 30); |
| 40 |
memcpy(os_2->panose, data + 32, 10); |
| 41 |
os_2->ulUnicodeRange1 = read_32u(data + 42); |
| 42 |
os_2->ulUnicodeRange2 = read_32u(data + 46); |
| 43 |
os_2->ulUnicodeRange3 = read_32u(data + 50); |
| 44 |
os_2->ulUnicodeRange4 = read_32u(data + 54); |
| 45 |
memcpy(os_2->achVendID, data + 58, 4); |
| 46 |
os_2->fsSelection = read_16u(data + 62); |
| 47 |
os_2->usFirstCharIndex = read_16u(data + 64); |
| 48 |
os_2->usLastCharIndex = read_16u(data + 66); |
| 49 |
} |
| 50 |
// version 0 (OpenType) |
| 51 |
if (length >= 78) { |
| 52 |
os_2->sTypoAscender = read_16s(data + 68); |
| 53 |
os_2->sTypoDescender = read_16s(data + 70); |
| 54 |
os_2->sTypoLineGap = read_16s(data + 72); |
| 55 |
os_2->usWinAscent = read_16u(data + 74); |
| 56 |
os_2->usWinDescent = read_16u(data + 76); |
| 57 |
} |
| 58 |
// version 1 |
| 59 |
if (os_2->version >= 1 && length < 86) goto OS_2_CORRUPTED; |
| 60 |
if (os_2->version >= 1) { |
| 61 |
os_2->ulCodePageRange1 = read_32u(data + 78); |
| 62 |
os_2->ulCodePageRange2 = read_32u(data + 82); |
| 63 |
} |
| 64 |
// version 2, 3, 4 |
| 65 |
if (os_2->version >= 2 && length < 96) goto OS_2_CORRUPTED; |
| 66 |
if (os_2->version >= 2) { |
| 67 |
os_2->sxHeight = read_16s(data + 86); |
| 68 |
os_2->sCapHeight = read_16s(data + 88); |
| 69 |
os_2->usDefaultChar = read_16u(data + 90); |
| 70 |
os_2->usBreakChar = read_16u(data + 92); |
| 71 |
os_2->usMaxContext = read_16u(data + 94); |
| 72 |
} |
| 73 |
// version 5 |
| 74 |
if (os_2->version >= 5 && length < 100) goto OS_2_CORRUPTED; |
| 75 |
if (os_2->version >= 5) { |
| 76 |
os_2->usLowerOpticalPointSize = read_16u(data + 96); |
| 77 |
os_2->usLowerOpticalPointSize = read_16u(data + 98); |
| 78 |
} |
| 79 |
return os_2; |
| 80 |
|
| 81 |
OS_2_CORRUPTED: |
| 82 |
logWarning("table 'OS/2' corrupted.\n"); |
| 83 |
if (os_2 != NULL) FREE(os_2); |
| 84 |
} |
| 85 |
return NULL; |
| 86 |
} |
| 87 |
|
| 88 |
const char *fsTypeLabels[] = {"_reserved1", |
| 89 |
"restrictedLicense", |
| 90 |
"previewPrintLicense", |
| 91 |
"editableEmbedding", |
| 92 |
"_reserved2", |
| 93 |
"_reserved3", |
| 94 |
"_reserved4", |
| 95 |
"_reserved5", |
| 96 |
"noSubsetting", |
| 97 |
"bitmapEmbeddingOnly", |
| 98 |
NULL}; |
| 99 |
const char *fsSelectionLabels[] = {"italic", "underscore", "negative", "outlined", |
| 100 |
"strikeout", "bold", "regular", "useTypoMetrics", |
| 101 |
"wws", "oblique", NULL}; |
| 102 |
const char *codePageLabels1[] = { |
| 103 |
"latin1", "latin2", "cyrillic", "greek", "turkish", "hebrew", "arabic", |
| 104 |
"windowsBaltic", "vietnamese", "ansi1", "ansi2", "ansi3", "ansi4", "ansi5", |
| 105 |
"ansi6", "ansi7", "thai", "jis", "gbk", "korean", "big5", |
| 106 |
"koreanJohab", "oem1", "oem2", "oem3", "oem4", "oem5", "oem6", |
| 107 |
"oem7", "macRoman", "oem", "symbol", NULL}; |
| 108 |
const char *codePageLabels2[] = {"oem8", "oem9", "oem10", "oem11", "oem12", "oem13", "oem14", |
| 109 |
"oem15", "oem16", "oem17", "oem18", "oem19", "oem20", "oem21", |
| 110 |
"oem22", "oem23", "cp869", "cp866", "cp865", "cp864", "cp863", |
| 111 |
"cp862", "cp861", "cp860", "cp857", "cp855", "cp852", "cp775", |
| 112 |
"cp737", "cp708", "cp850", "ascii", NULL}; |
| 113 |
const char *unicodeRangeLabels1[] = {"Basic_Latin", |
| 114 |
"Latin_1_Supplement", |
| 115 |
"Latin_Extended_A", |
| 116 |
"Latin_Extended_B", |
| 117 |
"Phonetics", |
| 118 |
"Spacing_Modifiers", |
| 119 |
"Combining_Diacritical_Marks", |
| 120 |
"Greek_and_Coptic", |
| 121 |
"Coptic", |
| 122 |
"Cyrillic", |
| 123 |
"Armenian", |
| 124 |
"Hebrew", |
| 125 |
"Vai", |
| 126 |
"Arabic", |
| 127 |
"NKo", |
| 128 |
"Devanagari", |
| 129 |
"Bengali", |
| 130 |
"Gurmukhi", |
| 131 |
"Gujarati", |
| 132 |
"Oriya", |
| 133 |
"Tamil", |
| 134 |
"Telugu", |
| 135 |
"Kannada", |
| 136 |
"Malayalam", |
| 137 |
"Thai", |
| 138 |
"Lao", |
| 139 |
"Georgian", |
| 140 |
"Balinese", |
| 141 |
"Hangul_Jamo", |
| 142 |
"Latin_Extended_Additional", |
| 143 |
"Greek_Extended", |
| 144 |
"Punctuations", |
| 145 |
NULL}; |
| 146 |
const char *unicodeRangeLabels2[] = {"Superscripts_And_Subscripts", |
| 147 |
"Currency_Symbols", |
| 148 |
"Combining_Diacritical_Marks_For_Symbols", |
| 149 |
"Letterlike_Symbols", |
| 150 |
"Number_Forms", |
| 151 |
"Arrows", |
| 152 |
"Mathematical_Operators", |
| 153 |
"Miscellaneous_Technical", |
| 154 |
"Control_Pictures", |
| 155 |
"Optical_Character_Recognition", |
| 156 |
"Enclosed_Alphanumerics", |
| 157 |
"Box_Drawing", |
| 158 |
"Block_Elements", |
| 159 |
"Geometric_Shapes", |
| 160 |
"Miscellaneous_Symbols", |
| 161 |
"Dingbats", |
| 162 |
"CJK_Symbols_And_Punctuation", |
| 163 |
"Hiragana", |
| 164 |
"Katakana", |
| 165 |
"Bopomofo", |
| 166 |
"Hangul_Compatibility_Jamo", |
| 167 |
"Phags_pa", |
| 168 |
"Enclosed_CJK_Letters_And_Months", |
| 169 |
"CJK_Compatibility", |
| 170 |
"Hangul_Syllables", |
| 171 |
"Non_Plane_0", |
| 172 |
"Phoenician", |
| 173 |
"CJK_Unified_Ideographs", |
| 174 |
"Private_Use_Area_p0", |
| 175 |
"CJK_Strokes", |
| 176 |
"Alphabetic_Presentation_Forms", |
| 177 |
"Arabic_Presentation_Forms_A", |
| 178 |
NULL}; |
| 179 |
const char *unicodeRangeLabels3[] = {"Combining_Half_Marks", |
| 180 |
"Vertical_Forms_and_CJK_Compatibility_Forms", |
| 181 |
"Small_Form_Variants", |
| 182 |
"Arabic_Presentation_Forms_B", |
| 183 |
"Halfwidth_And_Fullwidth_Forms", |
| 184 |
"Specials", |
| 185 |
"Tibetan", |
| 186 |
"Syriac", |
| 187 |
"Thaana", |
| 188 |
"Sinhala", |
| 189 |
"Myanmar", |
| 190 |
"Ethiopic", |
| 191 |
"Cherokee", |
| 192 |
"Unified_Canadian_Aboriginal_Syllabics", |
| 193 |
"Ogham", |
| 194 |
"Runic", |
| 195 |
"Khmer", |
| 196 |
"Mongolian", |
| 197 |
"Braille_Patterns", |
| 198 |
"Yi_Syllables", |
| 199 |
"Tagalog", |
| 200 |
"Old_Italic", |
| 201 |
"Gothic", |
| 202 |
"Deseret", |
| 203 |
"Musical_Symbols", |
| 204 |
"Mathematical_Alphanumeric_Symbols", |
| 205 |
"Private_Use_p15_and_p16", |
| 206 |
"Variation_Selectors", |
| 207 |
"Tags", |
| 208 |
"Limbu", |
| 209 |
"Tai_Le", |
| 210 |
"New_Tai_Lue", |
| 211 |
NULL}; |
| 212 |
const char *unicodeRangeLabels4[] = {"Buginese", |
| 213 |
"Glagolitic", |
| 214 |
"Tifinagh", |
| 215 |
"Yijing_Hexagram_Symbols", |
| 216 |
"Syloti_Nagri", |
| 217 |
"Linear_B_Syllabary_Ideograms_and_Aegean_Numbers", |
| 218 |
"Ancient_Greek_Numbers", |
| 219 |
"Ugaritic", |
| 220 |
"Old_Persian", |
| 221 |
"Shavian", |
| 222 |
"Osmanya", |
| 223 |
"Cypriot_Syllabary", |
| 224 |
"Kharoshthi", |
| 225 |
"Tai_Xuan_Jing_Symbols", |
| 226 |
"Cuneiform", |
| 227 |
"Counting_Rod_Numerals", |
| 228 |
"Sundanese", |
| 229 |
"Lepcha", |
| 230 |
"Ol_Chiki", |
| 231 |
"Saurashtra", |
| 232 |
"Kayah_Li", |
| 233 |
"Rejang", |
| 234 |
"Cham", |
| 235 |
"Ancient_Symbols", |
| 236 |
"Phaistos_Disc", |
| 237 |
"Carian_and_Lycian", |
| 238 |
"Domino_and_Mahjong_Tiles", |
| 239 |
NULL}; |
| 240 |
|
| 241 |
void otfcc_dumpOS_2(const table_OS_2 *table, json_value *root, const otfcc_Options *options) { |
| 242 |
if (!table) return; |
| 243 |
loggedStep("OS/2") { |
| 244 |
json_value *os_2 = json_object_new(30); |
| 245 |
json_object_push(os_2, "version", json_integer_new(table->version)); |
| 246 |
json_object_push(os_2, "xAvgCharWidth", json_integer_new(table->xAvgCharWidth)); |
| 247 |
json_object_push(os_2, "usWeightClass", json_integer_new(table->usWeightClass)); |
| 248 |
json_object_push(os_2, "usWidthClass", json_integer_new(table->usWidthClass)); |
| 249 |
json_object_push(os_2, "fsType", otfcc_dump_flags(table->fsType, fsTypeLabels)); |
| 250 |
json_object_push(os_2, "ySubscriptXSize", json_integer_new(table->ySubscriptXSize)); |
| 251 |
json_object_push(os_2, "ySubscriptYSize", json_integer_new(table->ySubscriptYSize)); |
| 252 |
json_object_push(os_2, "ySubscriptXOffset", json_integer_new(table->ySubscriptXOffset)); |
| 253 |
json_object_push(os_2, "ySubscriptYOffset", json_integer_new(table->ySubscriptYOffset)); |
| 254 |
json_object_push(os_2, "ySupscriptXSize", json_integer_new(table->ySupscriptXSize)); |
| 255 |
json_object_push(os_2, "ySupscriptYSize", json_integer_new(table->ySupscriptYSize)); |
| 256 |
json_object_push(os_2, "ySupscriptXOffset", json_integer_new(table->ySupscriptXOffset)); |
| 257 |
json_object_push(os_2, "ySupscriptYOffset", json_integer_new(table->ySupscriptYOffset)); |
| 258 |
json_object_push(os_2, "yStrikeoutSize", json_integer_new(table->yStrikeoutSize)); |
| 259 |
json_object_push(os_2, "yStrikeoutPosition", json_integer_new(table->yStrikeoutPosition)); |
| 260 |
json_object_push(os_2, "sFamilyClass", json_integer_new(table->sFamilyClass)); |
| 261 |
|
| 262 |
json_value *panose = json_array_new(10); |
| 263 |
for (uint8_t j = 0; j < 10; j++) { |
| 264 |
json_array_push(panose, json_integer_new(table->panose[j])); |
| 265 |
} |
| 266 |
json_object_push(os_2, "panose", panose); |
| 267 |
|
| 268 |
json_object_push(os_2, "ulUnicodeRange1", |
| 269 |
otfcc_dump_flags(table->ulUnicodeRange1, unicodeRangeLabels1)); |
| 270 |
json_object_push(os_2, "ulUnicodeRange2", |
| 271 |
otfcc_dump_flags(table->ulUnicodeRange2, unicodeRangeLabels2)); |
| 272 |
json_object_push(os_2, "ulUnicodeRange3", |
| 273 |
otfcc_dump_flags(table->ulUnicodeRange3, unicodeRangeLabels3)); |
| 274 |
json_object_push(os_2, "ulUnicodeRange4", |
| 275 |
otfcc_dump_flags(table->ulUnicodeRange4, unicodeRangeLabels4)); |
| 276 |
|
| 277 |
sds vendorid = sdsnewlen(table->achVendID, 4); |
| 278 |
json_object_push(os_2, "achVendID", json_string_new(vendorid)); |
| 279 |
sdsfree(vendorid); |
| 280 |
|
| 281 |
json_object_push(os_2, "fsSelection", |
| 282 |
otfcc_dump_flags(table->fsSelection, fsSelectionLabels)); |
| 283 |
json_object_push(os_2, "usFirstCharIndex", json_integer_new(table->usFirstCharIndex)); |
| 284 |
json_object_push(os_2, "usLastCharIndex", json_integer_new(table->usLastCharIndex)); |
| 285 |
json_object_push(os_2, "sTypoAscender", json_integer_new(table->sTypoAscender)); |
| 286 |
json_object_push(os_2, "sTypoDescender", json_integer_new(table->sTypoDescender)); |
| 287 |
json_object_push(os_2, "sTypoLineGap", json_integer_new(table->sTypoLineGap)); |
| 288 |
json_object_push(os_2, "usWinAscent", json_integer_new(table->usWinAscent)); |
| 289 |
json_object_push(os_2, "usWinDescent", json_integer_new(table->usWinDescent)); |
| 290 |
json_object_push(os_2, "ulCodePageRange1", |
| 291 |
otfcc_dump_flags(table->ulCodePageRange1, codePageLabels1)); |
| 292 |
json_object_push(os_2, "ulCodePageRange2", |
| 293 |
otfcc_dump_flags(table->ulCodePageRange2, codePageLabels2)); |
| 294 |
json_object_push(os_2, "sxHeight", json_integer_new(table->sxHeight)); |
| 295 |
json_object_push(os_2, "sCapHeight", json_integer_new(table->sCapHeight)); |
| 296 |
json_object_push(os_2, "usDefaultChar", json_integer_new(table->usDefaultChar)); |
| 297 |
json_object_push(os_2, "usBreakChar", json_integer_new(table->usBreakChar)); |
| 298 |
json_object_push(os_2, "usMaxContext", json_integer_new(table->usMaxContext)); |
| 299 |
json_object_push(os_2, "usLowerOpticalPointSize", |
| 300 |
json_integer_new(table->usLowerOpticalPointSize)); |
| 301 |
json_object_push(os_2, "usUpperOpticalPointSize", |
| 302 |
json_integer_new(table->usUpperOpticalPointSize)); |
| 303 |
json_object_push(root, "OS_2", os_2); |
| 304 |
} |
| 305 |
} |
| 306 |
|
| 307 |
table_OS_2 *otfcc_parseOS_2(const json_value *root, const otfcc_Options *options) { |
| 308 |
table_OS_2 *os_2 = table_iOS_2.create(); |
| 309 |
if (!os_2) return NULL; |
| 310 |
json_value *table = NULL; |
| 311 |
if ((table = json_obj_get_type(root, "OS_2", json_object))) { |
| 312 |
loggedStep("OS/2") { |
| 313 |
os_2->version = json_obj_getnum_fallback(table, "version", 0); |
| 314 |
os_2->xAvgCharWidth = json_obj_getnum_fallback(table, "xAvgCharWidth", 0); |
| 315 |
os_2->usWeightClass = json_obj_getnum_fallback(table, "usWeightClass", 0); |
| 316 |
os_2->usWidthClass = json_obj_getnum_fallback(table, "usWidthClass", 0); |
| 317 |
os_2->fsType = otfcc_parse_flags(json_obj_get(table, "fsType"), fsTypeLabels); |
| 318 |
os_2->ySubscriptXSize = json_obj_getnum_fallback(table, "ySubscriptXSize", 0); |
| 319 |
os_2->ySubscriptYSize = json_obj_getnum_fallback(table, "ySubscriptYSize", 0); |
| 320 |
os_2->ySubscriptXOffset = json_obj_getnum_fallback(table, "ySubscriptXOffset", 0); |
| 321 |
os_2->ySubscriptYOffset = json_obj_getnum_fallback(table, "ySubscriptYOffset", 0); |
| 322 |
os_2->ySupscriptXSize = json_obj_getnum_fallback(table, "ySupscriptXSize", 0); |
| 323 |
os_2->ySupscriptYSize = json_obj_getnum_fallback(table, "ySupscriptYSize", 0); |
| 324 |
os_2->ySupscriptXOffset = json_obj_getnum_fallback(table, "ySupscriptXOffset", 0); |
| 325 |
os_2->ySupscriptYOffset = json_obj_getnum_fallback(table, "ySupscriptYOffset", 0); |
| 326 |
os_2->yStrikeoutSize = json_obj_getnum_fallback(table, "yStrikeoutSize", 0); |
| 327 |
os_2->yStrikeoutPosition = json_obj_getnum_fallback(table, "yStrikeoutPosition", 0); |
| 328 |
os_2->sFamilyClass = json_obj_getnum_fallback(table, "sFamilyClass", 0); |
| 329 |
os_2->fsSelection = |
| 330 |
otfcc_parse_flags(json_obj_get(table, "fsSelection"), fsSelectionLabels); |
| 331 |
os_2->usFirstCharIndex = json_obj_getnum_fallback(table, "usFirstCharIndex", 0); |
| 332 |
os_2->usLastCharIndex = json_obj_getnum_fallback(table, "usLastCharIndex", 0); |
| 333 |
os_2->sTypoAscender = json_obj_getnum_fallback(table, "sTypoAscender", 0); |
| 334 |
os_2->sTypoDescender = json_obj_getnum_fallback(table, "sTypoDescender", 0); |
| 335 |
os_2->sTypoLineGap = json_obj_getnum_fallback(table, "sTypoLineGap", 0); |
| 336 |
os_2->usWinAscent = json_obj_getnum_fallback(table, "usWinAscent", 0); |
| 337 |
os_2->usWinDescent = json_obj_getnum_fallback(table, "usWinDescent", 0); |
| 338 |
os_2->ulCodePageRange1 = |
| 339 |
otfcc_parse_flags(json_obj_get(table, "ulCodePageRange1"), codePageLabels1); |
| 340 |
os_2->ulCodePageRange2 = |
| 341 |
otfcc_parse_flags(json_obj_get(table, "ulCodePageRange2"), codePageLabels2); |
| 342 |
os_2->ulUnicodeRange1 = |
| 343 |
otfcc_parse_flags(json_obj_get(table, "ulUnicodeRange1"), unicodeRangeLabels1); |
| 344 |
os_2->ulUnicodeRange2 = |
| 345 |
otfcc_parse_flags(json_obj_get(table, "ulUnicodeRange2"), unicodeRangeLabels2); |
| 346 |
os_2->ulUnicodeRange3 = |
| 347 |
otfcc_parse_flags(json_obj_get(table, "ulUnicodeRange3"), unicodeRangeLabels3); |
| 348 |
os_2->ulUnicodeRange4 = |
| 349 |
otfcc_parse_flags(json_obj_get(table, "ulUnicodeRange4"), unicodeRangeLabels4); |
| 350 |
os_2->sxHeight = json_obj_getnum_fallback(table, "sxHeight", 0); |
| 351 |
os_2->sCapHeight = json_obj_getnum_fallback(table, "sCapHeight", 0); |
| 352 |
os_2->usDefaultChar = json_obj_getnum_fallback(table, "usDefaultChar", 0); |
| 353 |
os_2->usBreakChar = json_obj_getnum_fallback(table, "usBreakChar", 0); |
| 354 |
os_2->usMaxContext = json_obj_getnum_fallback(table, "usMaxContext", 0); |
| 355 |
os_2->usLowerOpticalPointSize = |
| 356 |
json_obj_getnum_fallback(table, "usLowerOpticalPointSize", 0); |
| 357 |
os_2->usUpperOpticalPointSize = |
| 358 |
json_obj_getnum_fallback(table, "usUpperOpticalPointSize", 0); |
| 359 |
// panose |
| 360 |
json_value *panose = NULL; |
| 361 |
if ((panose = json_obj_get_type(table, "panose", json_array))) { |
| 362 |
for (uint32_t j = 0; j < panose->u.array.length && j < 10; j++) { |
| 363 |
json_value *term = panose->u.array.values[j]; |
| 364 |
if (term->type == json_integer) { |
| 365 |
os_2->panose[j] = term->u.integer; |
| 366 |
} else if (term->type == json_double) { |
| 367 |
os_2->panose[j] = term->u.dbl; |
| 368 |
} |
| 369 |
} |
| 370 |
} |
| 371 |
// achVendID |
| 372 |
json_value *vendorid = NULL; |
| 373 |
if ((vendorid = json_obj_get_type(table, "achVendID", json_string))) { |
| 374 |
os_2->achVendID[0] = ' '; |
| 375 |
os_2->achVendID[1] = ' '; |
| 376 |
os_2->achVendID[2] = ' '; |
| 377 |
os_2->achVendID[3] = ' '; |
| 378 |
if (vendorid->u.string.length >= 4) { |
| 379 |
memcpy(os_2->achVendID, vendorid->u.string.ptr, 4); |
| 380 |
} else { |
| 381 |
memcpy(os_2->achVendID, vendorid->u.string.ptr, vendorid->u.string.length); |
| 382 |
} |
| 383 |
} |
| 384 |
} |
| 385 |
} |
| 386 |
if (os_2->version < 1) os_2->version = 1; |
| 387 |
return os_2; |
| 388 |
} |
| 389 |
|
| 390 |
caryll_Buffer *otfcc_buildOS_2(const table_OS_2 *os_2, const otfcc_Options *options) { |
| 391 |
if (!os_2) return NULL; |
| 392 |
caryll_Buffer *buf = bufnew(); |
| 393 |
bufwrite16b(buf, os_2->version); |
| 394 |
bufwrite16b(buf, os_2->xAvgCharWidth); |
| 395 |
bufwrite16b(buf, os_2->usWeightClass); |
| 396 |
bufwrite16b(buf, os_2->usWidthClass); |
| 397 |
bufwrite16b(buf, os_2->fsType); |
| 398 |
bufwrite16b(buf, os_2->ySubscriptXSize); |
| 399 |
bufwrite16b(buf, os_2->ySubscriptYSize); |
| 400 |
bufwrite16b(buf, os_2->ySubscriptXOffset); |
| 401 |
bufwrite16b(buf, os_2->ySubscriptYOffset); |
| 402 |
bufwrite16b(buf, os_2->ySupscriptXSize); |
| 403 |
bufwrite16b(buf, os_2->ySupscriptYSize); |
| 404 |
bufwrite16b(buf, os_2->ySupscriptXOffset); |
| 405 |
bufwrite16b(buf, os_2->ySupscriptYOffset); |
| 406 |
bufwrite16b(buf, os_2->yStrikeoutSize); |
| 407 |
bufwrite16b(buf, os_2->yStrikeoutPosition); |
| 408 |
bufwrite16b(buf, os_2->sFamilyClass); |
| 409 |
bufwrite_bytes(buf, 10, os_2->panose); |
| 410 |
bufwrite32b(buf, os_2->ulUnicodeRange1); |
| 411 |
bufwrite32b(buf, os_2->ulUnicodeRange2); |
| 412 |
bufwrite32b(buf, os_2->ulUnicodeRange3); |
| 413 |
bufwrite32b(buf, os_2->ulUnicodeRange4); |
| 414 |
bufwrite_bytes(buf, 4, os_2->achVendID); |
| 415 |
bufwrite16b(buf, os_2->fsSelection); |
| 416 |
bufwrite16b(buf, os_2->usFirstCharIndex); |
| 417 |
bufwrite16b(buf, os_2->usLastCharIndex); |
| 418 |
bufwrite16b(buf, os_2->sTypoAscender); |
| 419 |
bufwrite16b(buf, os_2->sTypoDescender); |
| 420 |
bufwrite16b(buf, os_2->sTypoLineGap); |
| 421 |
bufwrite16b(buf, os_2->usWinAscent); |
| 422 |
bufwrite16b(buf, os_2->usWinDescent); |
| 423 |
bufwrite32b(buf, os_2->ulCodePageRange1); |
| 424 |
bufwrite32b(buf, os_2->ulCodePageRange2); |
| 425 |
if (os_2->version < 2) return buf; |
| 426 |
bufwrite16b(buf, os_2->sxHeight); |
| 427 |
bufwrite16b(buf, os_2->sCapHeight); |
| 428 |
bufwrite16b(buf, os_2->usDefaultChar); |
| 429 |
bufwrite16b(buf, os_2->usBreakChar); |
| 430 |
bufwrite16b(buf, os_2->usMaxContext); |
| 431 |
if (os_2->version < 5) return buf; |
| 432 |
bufwrite16b(buf, os_2->usLowerOpticalPointSize); |
| 433 |
bufwrite16b(buf, os_2->usUpperOpticalPointSize); |
| 434 |
return buf; |
| 435 |
} |