1 /**************************************************************************** 2 * 3 * gxfgen.c 4 * 5 * Generate feature registry data for gxv `feat' validator. 6 * This program is derived from gxfeatreg.c in gxlayout. 7 * 8 * Copyright 2004-2018 by 9 * Masatake YAMATO and Redhat K.K. 10 * 11 * This file may only be used, 12 * modified, and distributed under the terms of the FreeType project 13 * license, LICENSE.TXT. By continuing to use, modify, or distribute 14 * this file you indicate that you have read the license and 15 * understand and accept it fully. 16 * 17 */ 18 19 /**************************************************************************** 20 * 21 * gxfeatreg.c 22 * 23 * Database of font features pre-defined by Apple Computer, Inc. 24 * https://developer.apple.com/fonts/TrueType-Reference-Manual/RM09/AppendixF.html 25 * (body). 26 * 27 * Copyright 2003 by 28 * Masatake YAMATO and Redhat K.K. 29 * 30 * This file may only be used, 31 * modified, and distributed under the terms of the FreeType project 32 * license, LICENSE.TXT. By continuing to use, modify, or distribute 33 * this file you indicate that you have read the license and 34 * understand and accept it fully. 35 * 36 */ 37 38 /**************************************************************************** 39 * 40 * Development of gxfeatreg.c is supported by 41 * Information-technology Promotion Agency, Japan. 42 * 43 */ 44 45 46 /**************************************************************************** 47 * 48 * This file is compiled as a stand-alone executable. 49 * This file is never compiled into `libfreetype2'. 50 * The output of this file is used in `gxvfeat.c'. 51 * ----------------------------------------------------------------------- 52 * Compile: gcc `pkg-config --cflags freetype2` gxvfgen.c -o gxvfgen 53 * Run: ./gxvfgen > tmp.c 54 * 55 */ 56 57 /******************************************************************** 58 * WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING 59 */ 60 61 /* 62 * If you add a new setting to a feature, check the number of settings 63 * in the feature. If the number is greater than the value defined as 64 * FEATREG_MAX_SETTING, update the value. 65 */ 66 #define FEATREG_MAX_SETTING 12 67 68 /******************************************************************** 69 * WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING 70 */ 71 72 73 #include <stdio.h> 74 #include <string.h> 75 76 77 /*************************************************************************/ 78 /*************************************************************************/ 79 /***** *****/ 80 /***** Data and Types *****/ 81 /***** *****/ 82 /*************************************************************************/ 83 /*************************************************************************/ 84 85 #define APPLE_RESERVED "Apple Reserved" 86 #define APPLE_RESERVED_LENGTH 14 87 88 typedef struct GX_Feature_RegistryRec_ 89 { 90 const char* feat_name; 91 char exclusive; 92 char* setting_name[FEATREG_MAX_SETTING]; 93 94 } GX_Feature_RegistryRec; 95 96 97 #define EMPTYFEAT {0, 0, {NULL}} 98 99 100 static GX_Feature_RegistryRec featreg_table[] = { 101 { /* 0 */ 102 "All Typographic Features", 103 0, 104 { 105 "All Type Features", 106 NULL 107 } 108 }, { /* 1 */ 109 "Ligatures", 110 0, 111 { 112 "Required Ligatures", 113 "Common Ligatures", 114 "Rare Ligatures", 115 "Logos", 116 "Rebus Pictures", 117 "Diphthong Ligatures", 118 "Squared Ligatures", 119 "Squared Ligatures, Abbreviated", 120 NULL 121 } 122 }, { /* 2 */ 123 "Cursive Connection", 124 1, 125 { 126 "Unconnected", 127 "Partially Connected", 128 "Cursive", 129 NULL 130 } 131 }, { /* 3 */ 132 "Letter Case", 133 1, 134 { 135 "Upper & Lower Case", 136 "All Caps", 137 "All Lower Case", 138 "Small Caps", 139 "Initial Caps", 140 "Initial Caps & Small Caps", 141 NULL 142 } 143 }, { /* 4 */ 144 "Vertical Substitution", 145 0, 146 { 147 /* "Substitute Vertical Forms", */ 148 "Turns on the feature", 149 NULL 150 } 151 }, { /* 5 */ 152 "Linguistic Rearrangement", 153 0, 154 { 155 /* "Linguistic Rearrangement", */ 156 "Turns on the feature", 157 NULL 158 } 159 }, { /* 6 */ 160 "Number Spacing", 161 1, 162 { 163 "Monospaced Numbers", 164 "Proportional Numbers", 165 NULL 166 } 167 }, { /* 7 */ 168 APPLE_RESERVED " 1", 169 0, 170 {NULL} 171 }, { /* 8 */ 172 "Smart Swashes", 173 0, 174 { 175 "Word Initial Swashes", 176 "Word Final Swashes", 177 "Line Initial Swashes", 178 "Line Final Swashes", 179 "Non-Final Swashes", 180 NULL 181 } 182 }, { /* 9 */ 183 "Diacritics", 184 1, 185 { 186 "Show Diacritics", 187 "Hide Diacritics", 188 "Decompose Diacritics", 189 NULL 190 } 191 }, { /* 10 */ 192 "Vertical Position", 193 1, 194 { 195 /* "Normal Position", */ 196 "No Vertical Position", 197 "Superiors", 198 "Inferiors", 199 "Ordinals", 200 NULL 201 } 202 }, { /* 11 */ 203 "Fractions", 204 1, 205 { 206 "No Fractions", 207 "Vertical Fractions", 208 "Diagonal Fractions", 209 NULL 210 } 211 }, { /* 12 */ 212 APPLE_RESERVED " 2", 213 0, 214 {NULL} 215 }, { /* 13 */ 216 "Overlapping Characters", 217 0, 218 { 219 /* "Prevent Overlap", */ 220 "Turns on the feature", 221 NULL 222 } 223 }, { /* 14 */ 224 "Typographic Extras", 225 0, 226 { 227 "Hyphens to Em Dash", 228 "Hyphens to En Dash", 229 "Unslashed Zero", 230 "Form Interrobang", 231 "Smart Quotes", 232 "Periods to Ellipsis", 233 NULL 234 } 235 }, { /* 15 */ 236 "Mathematical Extras", 237 0, 238 { 239 "Hyphens to Minus", 240 "Asterisk to Multiply", 241 "Slash to Divide", 242 "Inequality Ligatures", 243 "Exponents", 244 NULL 245 } 246 }, { /* 16 */ 247 "Ornament Sets", 248 1, 249 { 250 "No Ornaments", 251 "Dingbats", 252 "Pi Characters", 253 "Fleurons", 254 "Decorative Borders", 255 "International Symbols", 256 "Math Symbols", 257 NULL 258 } 259 }, { /* 17 */ 260 "Character Alternatives", 261 1, 262 { 263 "No Alternates", 264 /* TODO */ 265 NULL 266 } 267 }, { /* 18 */ 268 "Design Complexity", 269 1, 270 { 271 "Design Level 1", 272 "Design Level 2", 273 "Design Level 3", 274 "Design Level 4", 275 "Design Level 5", 276 /* TODO */ 277 NULL 278 } 279 }, { /* 19 */ 280 "Style Options", 281 1, 282 { 283 "No Style Options", 284 "Display Text", 285 "Engraved Text", 286 "Illuminated Caps", 287 "Tilling Caps", 288 "Tall Caps", 289 NULL 290 } 291 }, { /* 20 */ 292 "Character Shape", 293 1, 294 { 295 "Traditional Characters", 296 "Simplified Characters", 297 "JIS 1978 Characters", 298 "JIS 1983 Characters", 299 "JIS 1990 Characters", 300 "Traditional Characters, Alternative Set 1", 301 "Traditional Characters, Alternative Set 2", 302 "Traditional Characters, Alternative Set 3", 303 "Traditional Characters, Alternative Set 4", 304 "Traditional Characters, Alternative Set 5", 305 "Expert Characters", 306 NULL /* count => 12 */ 307 } 308 }, { /* 21 */ 309 "Number Case", 310 1, 311 { 312 "Lower Case Numbers", 313 "Upper Case Numbers", 314 NULL 315 } 316 }, { /* 22 */ 317 "Text Spacing", 318 1, 319 { 320 "Proportional", 321 "Monospaced", 322 "Half-width", 323 "Normal", 324 NULL 325 } 326 }, /* Here after Newer */ { /* 23 */ 327 "Transliteration", 328 1, 329 { 330 "No Transliteration", 331 "Hanja To Hangul", 332 "Hiragana to Katakana", 333 "Katakana to Hiragana", 334 "Kana to Romanization", 335 "Romanization to Hiragana", 336 "Romanization to Katakana", 337 "Hanja to Hangul, Alternative Set 1", 338 "Hanja to Hangul, Alternative Set 2", 339 "Hanja to Hangul, Alternative Set 3", 340 NULL 341 } 342 }, { /* 24 */ 343 "Annotation", 344 1, 345 { 346 "No Annotation", 347 "Box Annotation", 348 "Rounded Box Annotation", 349 "Circle Annotation", 350 "Inverted Circle Annotation", 351 "Parenthesis Annotation", 352 "Period Annotation", 353 "Roman Numeral Annotation", 354 "Diamond Annotation", 355 NULL 356 } 357 }, { /* 25 */ 358 "Kana Spacing", 359 1, 360 { 361 "Full Width", 362 "Proportional", 363 NULL 364 } 365 }, { /* 26 */ 366 "Ideographic Spacing", 367 1, 368 { 369 "Full Width", 370 "Proportional", 371 NULL 372 } 373 }, EMPTYFEAT, EMPTYFEAT, EMPTYFEAT, EMPTYFEAT, /* 27-30 */ 374 EMPTYFEAT, EMPTYFEAT, EMPTYFEAT, EMPTYFEAT, EMPTYFEAT, /* 31-35 */ 375 EMPTYFEAT, EMPTYFEAT, EMPTYFEAT, EMPTYFEAT, EMPTYFEAT, /* 36-40 */ 376 EMPTYFEAT, EMPTYFEAT, EMPTYFEAT, EMPTYFEAT, EMPTYFEAT, /* 40-45 */ 377 EMPTYFEAT, EMPTYFEAT, EMPTYFEAT, EMPTYFEAT, EMPTYFEAT, /* 46-50 */ 378 EMPTYFEAT, EMPTYFEAT, EMPTYFEAT, EMPTYFEAT, EMPTYFEAT, /* 51-55 */ 379 EMPTYFEAT, EMPTYFEAT, EMPTYFEAT, EMPTYFEAT, EMPTYFEAT, /* 56-60 */ 380 EMPTYFEAT, EMPTYFEAT, EMPTYFEAT, EMPTYFEAT, EMPTYFEAT, /* 61-65 */ 381 EMPTYFEAT, EMPTYFEAT, EMPTYFEAT, EMPTYFEAT, EMPTYFEAT, /* 66-70 */ 382 EMPTYFEAT, EMPTYFEAT, EMPTYFEAT, EMPTYFEAT, EMPTYFEAT, /* 71-75 */ 383 EMPTYFEAT, EMPTYFEAT, EMPTYFEAT, EMPTYFEAT, EMPTYFEAT, /* 76-80 */ 384 EMPTYFEAT, EMPTYFEAT, EMPTYFEAT, EMPTYFEAT, EMPTYFEAT, /* 81-85 */ 385 EMPTYFEAT, EMPTYFEAT, EMPTYFEAT, EMPTYFEAT, EMPTYFEAT, /* 86-90 */ 386 EMPTYFEAT, EMPTYFEAT, EMPTYFEAT, EMPTYFEAT, EMPTYFEAT, /* 91-95 */ 387 EMPTYFEAT, EMPTYFEAT, EMPTYFEAT, /* 96-98 */ 388 EMPTYFEAT, /* 99 */ { /* 100 => 22 */ 389 "Text Spacing", 390 1, 391 { 392 "Proportional", 393 "Monospaced", 394 "Half-width", 395 "Normal", 396 NULL 397 } 398 }, { /* 101 => 25 */ 399 "Kana Spacing", 400 1, 401 { 402 "Full Width", 403 "Proportional", 404 NULL 405 } 406 }, { /* 102 => 26 */ 407 "Ideographic Spacing", 408 1, 409 { 410 "Full Width", 411 "Proportional", 412 NULL 413 } 414 }, { /* 103 */ 415 "CJK Roman Spacing", 416 1, 417 { 418 "Half-width", 419 "Proportional", 420 "Default Roman", 421 "Full-width Roman", 422 NULL 423 } 424 }, { /* 104 => 1 */ 425 "All Typographic Features", 426 0, 427 { 428 "All Type Features", 429 NULL 430 } 431 } 432 }; 433 434 435 /*************************************************************************/ 436 /*************************************************************************/ 437 /***** *****/ 438 /***** Generator *****/ 439 /***** *****/ 440 /*************************************************************************/ 441 /*************************************************************************/ 442 443 int main(void)444 main( void ) 445 { 446 int i; 447 448 449 printf( " {\n" ); 450 printf( " /* Generated from %s */\n", __FILE__ ); 451 452 for ( i = 0; 453 i < sizeof ( featreg_table ) / sizeof ( GX_Feature_RegistryRec ); 454 i++ ) 455 { 456 const char* feat_name; 457 int nSettings; 458 459 460 feat_name = featreg_table[i].feat_name; 461 for ( nSettings = 0; 462 featreg_table[i].setting_name[nSettings]; 463 nSettings++) 464 ; /* Do nothing */ 465 466 printf( " {%1d, %1d, %1d, %2d}, /* %s */\n", 467 feat_name ? 1 : 0, 468 ( feat_name && 469 ( ft_strncmp( feat_name, 470 APPLE_RESERVED, APPLE_RESERVED_LENGTH ) == 0 ) 471 ) ? 1 : 0, 472 featreg_table[i].exclusive ? 1 : 0, 473 nSettings, 474 feat_name ? feat_name : "__EMPTY__" ); 475 } 476 477 printf( " };\n" ); 478 479 return 0; 480 } 481 482 483 /* END */ 484