tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

gxvfgen.c (13319B)


      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 (C) 2004-2025 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  {
    102    {                                       /* 0 */
    103      "All Typographic Features",
    104      0,
    105      {
    106        "All Type Features",
    107        NULL
    108      }
    109    }, {                                    /* 1 */
    110      "Ligatures",
    111      0,
    112      {
    113        "Required Ligatures",
    114        "Common Ligatures",
    115        "Rare Ligatures",
    116        "Logos",
    117        "Rebus Pictures",
    118        "Diphthong Ligatures",
    119        "Squared Ligatures",
    120        "Squared Ligatures, Abbreviated",
    121        NULL
    122      }
    123    }, {                                    /* 2 */
    124      "Cursive Connection",
    125      1,
    126      {
    127        "Unconnected",
    128        "Partially Connected",
    129        "Cursive",
    130        NULL
    131      }
    132    }, {                                    /* 3 */
    133      "Letter Case",
    134      1,
    135      {
    136        "Upper & Lower Case",
    137        "All Caps",
    138        "All Lower Case",
    139        "Small Caps",
    140        "Initial Caps",
    141        "Initial Caps & Small Caps",
    142        NULL
    143      }
    144    }, {                                    /* 4 */
    145      "Vertical Substitution",
    146      0,
    147      {
    148        /* "Substitute Vertical Forms", */
    149        "Turns on the feature",
    150        NULL
    151      }
    152    }, {                                    /* 5 */
    153      "Linguistic Rearrangement",
    154      0,
    155      {
    156        /* "Linguistic Rearrangement", */
    157        "Turns on the feature",
    158        NULL
    159      }
    160    }, {                                    /* 6 */
    161      "Number Spacing",
    162      1,
    163      {
    164        "Monospaced Numbers",
    165        "Proportional Numbers",
    166        NULL
    167      }
    168    }, {                                    /* 7 */
    169      APPLE_RESERVED " 1",
    170      0,
    171      {NULL}
    172    }, {                                    /* 8 */
    173      "Smart Swashes",
    174      0,
    175      {
    176        "Word Initial Swashes",
    177        "Word Final Swashes",
    178        "Line Initial Swashes",
    179        "Line Final Swashes",
    180        "Non-Final Swashes",
    181        NULL
    182      }
    183    }, {                                    /* 9 */
    184      "Diacritics",
    185      1,
    186      {
    187        "Show Diacritics",
    188        "Hide Diacritics",
    189        "Decompose Diacritics",
    190        NULL
    191      }
    192    }, {                                    /* 10 */
    193      "Vertical Position",
    194      1,
    195      {
    196        /* "Normal Position", */
    197        "No Vertical Position",
    198        "Superiors",
    199        "Inferiors",
    200        "Ordinals",
    201        NULL
    202      }
    203    }, {                                    /* 11 */
    204      "Fractions",
    205      1,
    206      {
    207        "No Fractions",
    208        "Vertical Fractions",
    209        "Diagonal Fractions",
    210        NULL
    211      }
    212    }, {                                    /* 12 */
    213      APPLE_RESERVED " 2",
    214      0,
    215      {NULL}
    216    }, {                                    /* 13 */
    217      "Overlapping Characters",
    218      0,
    219      {
    220        /* "Prevent Overlap", */
    221        "Turns on the feature",
    222        NULL
    223      }
    224    }, {                                    /* 14 */
    225      "Typographic Extras",
    226      0,
    227      {
    228        "Hyphens to Em Dash",
    229        "Hyphens to En Dash",
    230        "Unslashed Zero",
    231        "Form Interrobang",
    232        "Smart Quotes",
    233        "Periods to Ellipsis",
    234        NULL
    235      }
    236    }, {                                    /* 15 */
    237      "Mathematical Extras",
    238      0,
    239      {
    240        "Hyphens to Minus",
    241        "Asterisk to Multiply",
    242        "Slash to Divide",
    243        "Inequality Ligatures",
    244        "Exponents",
    245        NULL
    246      }
    247    }, {                                    /* 16 */
    248      "Ornament Sets",
    249      1,
    250      {
    251        "No Ornaments",
    252        "Dingbats",
    253        "Pi Characters",
    254        "Fleurons",
    255        "Decorative Borders",
    256        "International Symbols",
    257        "Math Symbols",
    258        NULL
    259      }
    260    }, {                                    /* 17 */
    261      "Character Alternatives",
    262      1,
    263      {
    264        "No Alternates",
    265        /* TODO */
    266        NULL
    267      }
    268    }, {                                    /* 18 */
    269      "Design Complexity",
    270      1,
    271      {
    272        "Design Level 1",
    273        "Design Level 2",
    274        "Design Level 3",
    275        "Design Level 4",
    276        "Design Level 5",
    277        /* TODO */
    278        NULL
    279      }
    280    }, {                                    /* 19 */
    281      "Style Options",
    282      1,
    283      {
    284        "No Style Options",
    285        "Display Text",
    286        "Engraved Text",
    287        "Illuminated Caps",
    288        "Tilling Caps",
    289        "Tall Caps",
    290        NULL
    291      }
    292    }, {                                    /* 20 */
    293      "Character Shape",
    294      1,
    295      {
    296        "Traditional Characters",
    297        "Simplified Characters",
    298        "JIS 1978 Characters",
    299        "JIS 1983 Characters",
    300        "JIS 1990 Characters",
    301        "Traditional Characters, Alternative Set 1",
    302        "Traditional Characters, Alternative Set 2",
    303        "Traditional Characters, Alternative Set 3",
    304        "Traditional Characters, Alternative Set 4",
    305        "Traditional Characters, Alternative Set 5",
    306        "Expert Characters",
    307        NULL                           /* count => 12 */
    308      }
    309    }, {                                    /* 21 */
    310      "Number Case",
    311      1,
    312      {
    313        "Lower Case Numbers",
    314        "Upper Case Numbers",
    315        NULL
    316      }
    317    }, {                                    /* 22 */
    318      "Text Spacing",
    319      1,
    320      {
    321        "Proportional",
    322        "Monospaced",
    323        "Half-width",
    324        "Normal",
    325        NULL
    326      }
    327    }, /* Here after Newer */  { /* 23 */
    328      "Transliteration",
    329      1,
    330      {
    331        "No Transliteration",
    332        "Hanja To Hangul",
    333        "Hiragana to Katakana",
    334        "Katakana to Hiragana",
    335        "Kana to Romanization",
    336        "Romanization to Hiragana",
    337        "Romanization to Katakana",
    338        "Hanja to Hangul, Alternative Set 1",
    339        "Hanja to Hangul, Alternative Set 2",
    340        "Hanja to Hangul, Alternative Set 3",
    341        NULL
    342      }
    343    }, {                                    /* 24 */
    344      "Annotation",
    345      1,
    346      {
    347        "No Annotation",
    348        "Box Annotation",
    349        "Rounded Box Annotation",
    350        "Circle Annotation",
    351        "Inverted Circle Annotation",
    352        "Parenthesis Annotation",
    353        "Period Annotation",
    354        "Roman Numeral Annotation",
    355        "Diamond Annotation",
    356        NULL
    357      }
    358    }, {                                    /* 25 */
    359      "Kana Spacing",
    360      1,
    361      {
    362        "Full Width",
    363        "Proportional",
    364        NULL
    365      }
    366    }, {                                    /* 26 */
    367      "Ideographic Spacing",
    368      1,
    369      {
    370        "Full Width",
    371        "Proportional",
    372        NULL
    373      }
    374    }, EMPTYFEAT, EMPTYFEAT, EMPTYFEAT, EMPTYFEAT,         /* 27-30 */
    375    EMPTYFEAT, EMPTYFEAT, EMPTYFEAT, EMPTYFEAT, EMPTYFEAT, /* 31-35 */
    376    EMPTYFEAT, EMPTYFEAT, EMPTYFEAT, EMPTYFEAT, EMPTYFEAT, /* 36-40 */
    377    EMPTYFEAT, EMPTYFEAT, EMPTYFEAT, EMPTYFEAT, EMPTYFEAT, /* 40-45 */
    378    EMPTYFEAT, EMPTYFEAT, EMPTYFEAT, EMPTYFEAT, EMPTYFEAT, /* 46-50 */
    379    EMPTYFEAT, EMPTYFEAT, EMPTYFEAT, EMPTYFEAT, EMPTYFEAT, /* 51-55 */
    380    EMPTYFEAT, EMPTYFEAT, EMPTYFEAT, EMPTYFEAT, EMPTYFEAT, /* 56-60 */
    381    EMPTYFEAT, EMPTYFEAT, EMPTYFEAT, EMPTYFEAT, EMPTYFEAT, /* 61-65 */
    382    EMPTYFEAT, EMPTYFEAT, EMPTYFEAT, EMPTYFEAT, EMPTYFEAT, /* 66-70 */
    383    EMPTYFEAT, EMPTYFEAT, EMPTYFEAT, EMPTYFEAT, EMPTYFEAT, /* 71-75 */
    384    EMPTYFEAT, EMPTYFEAT, EMPTYFEAT, EMPTYFEAT, EMPTYFEAT, /* 76-80 */
    385    EMPTYFEAT, EMPTYFEAT, EMPTYFEAT, EMPTYFEAT, EMPTYFEAT, /* 81-85 */
    386    EMPTYFEAT, EMPTYFEAT, EMPTYFEAT, EMPTYFEAT, EMPTYFEAT, /* 86-90 */
    387    EMPTYFEAT, EMPTYFEAT, EMPTYFEAT, EMPTYFEAT, EMPTYFEAT, /* 91-95 */
    388    EMPTYFEAT, EMPTYFEAT, EMPTYFEAT,                       /* 96-98 */
    389    EMPTYFEAT, /* 99 */ {                   /* 100 => 22 */
    390      "Text Spacing",
    391      1,
    392      {
    393        "Proportional",
    394        "Monospaced",
    395        "Half-width",
    396        "Normal",
    397        NULL
    398      }
    399    }, {                                    /* 101 => 25 */
    400      "Kana Spacing",
    401      1,
    402      {
    403        "Full Width",
    404        "Proportional",
    405        NULL
    406      }
    407    }, {                                    /* 102 => 26 */
    408      "Ideographic Spacing",
    409      1,
    410      {
    411        "Full Width",
    412        "Proportional",
    413        NULL
    414      }
    415    }, {                                    /* 103 */
    416      "CJK Roman Spacing",
    417      1,
    418      {
    419        "Half-width",
    420        "Proportional",
    421        "Default Roman",
    422        "Full-width Roman",
    423        NULL
    424      }
    425    }, {                                    /* 104 => 1 */
    426      "All Typographic Features",
    427      0,
    428      {
    429        "All Type Features",
    430        NULL
    431      }
    432    }
    433  };
    434 
    435 
    436  /*************************************************************************/
    437  /*************************************************************************/
    438  /*****                                                               *****/
    439  /*****                         Generator                             *****/
    440  /*****                                                               *****/
    441  /*************************************************************************/
    442  /*************************************************************************/
    443 
    444  int
    445  main( void )
    446  {
    447    int  i;
    448 
    449 
    450    printf( "  {\n" );
    451    printf( "   /* Generated from %s */\n", __FILE__ );
    452 
    453    for ( i = 0;
    454          i < sizeof ( featreg_table ) / sizeof ( GX_Feature_RegistryRec );
    455          i++ )
    456    {
    457      const char*  feat_name;
    458      int          nSettings;
    459 
    460 
    461      feat_name = featreg_table[i].feat_name;
    462      for ( nSettings = 0;
    463            featreg_table[i].setting_name[nSettings];
    464            nSettings++)
    465        ;                                   /* Do nothing */
    466 
    467      printf( "    {%1d, %1d, %1d, %2d},   /* %s */\n",
    468              feat_name ? 1 : 0,
    469              ( feat_name                                                  &&
    470                ( ft_strncmp( feat_name,
    471                              APPLE_RESERVED, APPLE_RESERVED_LENGTH ) == 0 )
    472              ) ? 1 : 0,
    473              featreg_table[i].exclusive ? 1 : 0,
    474              nSettings,
    475              feat_name ? feat_name : "__EMPTY__" );
    476    }
    477 
    478    printf( "  };\n" );
    479 
    480    return 0;
    481  }
    482 
    483 
    484 /* END */