tor-browser

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

pfrtypes.h (8090B)


      1 /****************************************************************************
      2 *
      3 * pfrtypes.h
      4 *
      5 *   FreeType PFR data structures (specification only).
      6 *
      7 * Copyright (C) 2002-2025 by
      8 * David Turner, Robert Wilhelm, and Werner Lemberg.
      9 *
     10 * This file is part of the FreeType project, and may only be used,
     11 * modified, and distributed under the terms of the FreeType project
     12 * license, LICENSE.TXT.  By continuing to use, modify, or distribute
     13 * this file you indicate that you have read the license and
     14 * understand and accept it fully.
     15 *
     16 */
     17 
     18 
     19 #ifndef PFRTYPES_H_
     20 #define PFRTYPES_H_
     21 
     22 #include <freetype/internal/ftobjs.h>
     23 
     24 FT_BEGIN_HEADER
     25 
     26  /************************************************************************/
     27 
     28  /* the PFR Header structure */
     29  typedef struct  PFR_HeaderRec_
     30  {
     31    FT_UInt32  signature;
     32    FT_UInt    version;
     33    FT_UInt    signature2;
     34    FT_UInt    header_size;
     35 
     36    FT_UInt    log_dir_size;
     37    FT_UInt    log_dir_offset;
     38 
     39    FT_UInt    log_font_max_size;
     40    FT_UInt32  log_font_section_size;
     41    FT_UInt32  log_font_section_offset;
     42 
     43    FT_UInt32  phy_font_max_size;
     44    FT_UInt32  phy_font_section_size;
     45    FT_UInt32  phy_font_section_offset;
     46 
     47    FT_UInt    gps_max_size;
     48    FT_UInt32  gps_section_size;
     49    FT_UInt32  gps_section_offset;
     50 
     51    FT_UInt    max_blue_values;
     52    FT_UInt    max_x_orus;
     53    FT_UInt    max_y_orus;
     54 
     55    FT_UInt    phy_font_max_size_high;
     56    FT_UInt    color_flags;
     57 
     58    FT_UInt32  bct_max_size;
     59    FT_UInt32  bct_set_max_size;
     60    FT_UInt32  phy_bct_set_max_size;
     61 
     62    FT_UInt    num_phy_fonts;
     63    FT_UInt    max_vert_stem_snap;
     64    FT_UInt    max_horz_stem_snap;
     65    FT_UInt    max_chars;
     66 
     67  } PFR_HeaderRec, *PFR_Header;
     68 
     69 
     70  /* used in `color_flags' field of the PFR_Header */
     71 #define PFR_FLAG_BLACK_PIXEL    0x01U
     72 #define PFR_FLAG_INVERT_BITMAP  0x02U
     73 
     74 
     75  /************************************************************************/
     76 
     77  typedef struct  PFR_LogFontRec_
     78  {
     79    FT_UInt32  size;
     80    FT_UInt32  offset;
     81 
     82    FT_Int32   matrix[4];
     83    FT_UInt    stroke_flags;
     84    FT_Int     stroke_thickness;
     85    FT_Int     bold_thickness;
     86    FT_Int32   miter_limit;
     87 
     88    FT_UInt32  phys_size;
     89    FT_UInt32  phys_offset;
     90 
     91  } PFR_LogFontRec, *PFR_LogFont;
     92 
     93 
     94 #define PFR_LINE_JOIN_MITER   0x00U
     95 #define PFR_LINE_JOIN_ROUND   0x01U
     96 #define PFR_LINE_JOIN_BEVEL   0x02U
     97 #define PFR_LINE_JOIN_MASK    ( PFR_LINE_JOIN_ROUND | PFR_LINE_JOIN_BEVEL )
     98 
     99 #define PFR_LOG_STROKE        0x04U
    100 #define PFR_LOG_2BYTE_STROKE  0x08U
    101 #define PFR_LOG_BOLD          0x10U
    102 #define PFR_LOG_2BYTE_BOLD    0x20U
    103 #define PFR_LOG_EXTRA_ITEMS   0x40U
    104 
    105 
    106  /************************************************************************/
    107 
    108 #define PFR_BITMAP_2BYTE_CHARCODE  0x01U
    109 #define PFR_BITMAP_2BYTE_SIZE      0x02U
    110 #define PFR_BITMAP_3BYTE_OFFSET    0x04U
    111 
    112  /* not part of the specification but used for implementation */
    113 #define PFR_BITMAP_CHARCODES_VALIDATED  0x40U
    114 #define PFR_BITMAP_VALID_CHARCODES      0x80U
    115 
    116 
    117  typedef struct  PFR_BitmapCharRec_
    118  {
    119    FT_UInt    char_code;
    120    FT_UInt    gps_size;
    121    FT_UInt32  gps_offset;
    122 
    123  } PFR_BitmapCharRec, *PFR_BitmapChar;
    124 
    125 
    126 #define PFR_STRIKE_2BYTE_XPPM    0x01U
    127 #define PFR_STRIKE_2BYTE_YPPM    0x02U
    128 #define PFR_STRIKE_3BYTE_SIZE    0x04U
    129 #define PFR_STRIKE_3BYTE_OFFSET  0x08U
    130 #define PFR_STRIKE_2BYTE_COUNT   0x10U
    131 
    132 
    133  typedef struct  PFR_StrikeRec_
    134  {
    135    FT_UInt         x_ppm;
    136    FT_UInt         y_ppm;
    137    FT_UInt         flags;
    138 
    139    FT_UInt32       gps_size;
    140    FT_UInt32       gps_offset;
    141 
    142    FT_UInt32       bct_size;
    143    FT_UInt32       bct_offset;
    144 
    145    /* optional */
    146    FT_UInt         num_bitmaps;
    147    PFR_BitmapChar  bitmaps;
    148 
    149  } PFR_StrikeRec, *PFR_Strike;
    150 
    151 
    152  /************************************************************************/
    153 
    154  typedef struct  PFR_CharRec_
    155  {
    156    FT_UInt    char_code;
    157    FT_Int     advance;
    158    FT_UInt    gps_size;
    159    FT_UInt32  gps_offset;
    160 
    161  } PFR_CharRec, *PFR_Char;
    162 
    163 
    164  /************************************************************************/
    165 
    166  typedef struct  PFR_DimensionRec_
    167  {
    168    FT_UInt  standard;
    169    FT_UInt  num_stem_snaps;
    170    FT_Int*  stem_snaps;
    171 
    172  } PFR_DimensionRec, *PFR_Dimension;
    173 
    174  /************************************************************************/
    175 
    176  typedef struct PFR_KernItemRec_*  PFR_KernItem;
    177 
    178  typedef struct  PFR_KernItemRec_
    179  {
    180    PFR_KernItem  next;
    181    FT_Byte       pair_count;
    182    FT_Byte       flags;
    183    FT_Short      base_adj;
    184    FT_UInt       pair_size;
    185    FT_Offset     offset;
    186    FT_UInt32     pair1;
    187    FT_UInt32     pair2;
    188 
    189  } PFR_KernItemRec;
    190 
    191 
    192 #define PFR_KERN_INDEX( g1, g2 )                          \
    193          ( ( (FT_UInt32)(g1) << 16 ) | (FT_UInt16)(g2) )
    194 
    195 #define PFR_KERN_PAIR_INDEX( pair )                        \
    196          PFR_KERN_INDEX( (pair)->glyph1, (pair)->glyph2 )
    197 
    198 #define PFR_NEXT_KPAIR( p )  ( p += 2,                              \
    199                               ( (FT_UInt32)p[-2] << 16 ) | p[-1] )
    200 
    201 
    202  /************************************************************************/
    203 
    204  typedef struct  PFR_PhyFontRec_
    205  {
    206    FT_Memory          memory;
    207    FT_UInt32          offset;
    208 
    209    FT_UInt            font_ref_number;
    210    FT_UInt            outline_resolution;
    211    FT_UInt            metrics_resolution;
    212    FT_BBox            bbox;
    213    FT_UInt            flags;
    214    FT_Int             standard_advance;
    215 
    216    FT_Int             ascent;   /* optional, bbox.yMax if not present */
    217    FT_Int             descent;  /* optional, bbox.yMin if not present */
    218    FT_Int             leading;  /* optional, 0 if not present         */
    219 
    220    PFR_DimensionRec   horizontal;
    221    PFR_DimensionRec   vertical;
    222 
    223    FT_String*         font_id;
    224    FT_String*         family_name;
    225    FT_String*         style_name;
    226 
    227    FT_UInt            num_strikes;
    228    FT_UInt            max_strikes;
    229    PFR_StrikeRec*     strikes;
    230 
    231    FT_UInt            num_blue_values;
    232    FT_Int            *blue_values;
    233    FT_UInt            blue_fuzz;
    234    FT_UInt            blue_scale;
    235 
    236    FT_UInt            num_chars;
    237    FT_Offset          chars_offset;
    238    PFR_Char           chars;
    239 
    240    FT_UInt            num_kern_pairs;
    241    PFR_KernItem       kern_items;
    242    PFR_KernItem*      kern_items_tail;
    243 
    244    /* not part of the spec, but used during load */
    245    FT_ULong           bct_offset;
    246    FT_Byte*           cursor;
    247 
    248  } PFR_PhyFontRec, *PFR_PhyFont;
    249 
    250 
    251 #define PFR_PHY_VERTICAL          0x01U
    252 #define PFR_PHY_2BYTE_CHARCODE    0x02U
    253 #define PFR_PHY_PROPORTIONAL      0x04U
    254 #define PFR_PHY_ASCII_CODE        0x08U
    255 #define PFR_PHY_2BYTE_GPS_SIZE    0x10U
    256 #define PFR_PHY_3BYTE_GPS_OFFSET  0x20U
    257 #define PFR_PHY_EXTRA_ITEMS       0x80U
    258 
    259 
    260 #define PFR_KERN_2BYTE_CHAR  0x01U
    261 #define PFR_KERN_2BYTE_ADJ   0x02U
    262 
    263 
    264  /************************************************************************/
    265 
    266 #define PFR_GLYPH_YCOUNT         0x01U
    267 #define PFR_GLYPH_XCOUNT         0x02U
    268 #define PFR_GLYPH_1BYTE_XYCOUNT  0x04U
    269 
    270 #define PFR_GLYPH_SINGLE_EXTRA_ITEMS    0x08U
    271 #define PFR_GLYPH_COMPOUND_EXTRA_ITEMS  0x40U
    272 
    273 #define PFR_GLYPH_IS_COMPOUND  0x80U
    274 
    275 
    276  /* controlled coordinate */
    277  typedef struct  PFR_CoordRec_
    278  {
    279    FT_UInt  org;
    280    FT_UInt  cur;
    281 
    282  } PFR_CoordRec, *PFR_Coord;
    283 
    284 
    285  typedef struct  PFR_SubGlyphRec_
    286  {
    287    FT_Fixed   x_scale;
    288    FT_Fixed   y_scale;
    289    FT_Int     x_delta;
    290    FT_Int     y_delta;
    291    FT_UInt32  gps_offset;
    292    FT_UInt    gps_size;
    293 
    294  } PFR_SubGlyphRec, *PFR_SubGlyph;
    295 
    296 
    297 #define PFR_SUBGLYPH_XSCALE        0x10U
    298 #define PFR_SUBGLYPH_YSCALE        0x20U
    299 #define PFR_SUBGLYPH_2BYTE_SIZE    0x40U
    300 #define PFR_SUBGLYPH_3BYTE_OFFSET  0x80U
    301 
    302 
    303  typedef struct  PFR_GlyphRec_
    304  {
    305    FT_Byte           format;
    306 
    307 #if 0
    308    FT_UInt           num_x_control;
    309    FT_UInt           num_y_control;
    310 #endif
    311    FT_UInt           max_xy_control;
    312    FT_Pos*           x_control;
    313    FT_Pos*           y_control;
    314 
    315 
    316    FT_UInt           num_subs;
    317    FT_UInt           max_subs;
    318    PFR_SubGlyphRec*  subs;
    319 
    320    FT_GlyphLoader    loader;
    321    FT_Bool           path_begun;
    322 
    323  } PFR_GlyphRec, *PFR_Glyph;
    324 
    325 
    326 FT_END_HEADER
    327 
    328 #endif /* PFRTYPES_H_ */
    329 
    330 
    331 /* END */