tor-browser

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

afglobal.h (5413B)


      1 /****************************************************************************
      2 *
      3 * afglobal.h
      4 *
      5 *   Auto-fitter routines to compute global hinting values
      6 *   (specification).
      7 *
      8 * Copyright (C) 2003-2025 by
      9 * David Turner, Robert Wilhelm, and Werner Lemberg.
     10 *
     11 * This file is part of the FreeType project, and 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 #ifndef AFGLOBAL_H_
     21 #define AFGLOBAL_H_
     22 
     23 
     24 #include "aftypes.h"
     25 #include "afmodule.h"
     26 #include "afshaper.h"
     27 
     28 
     29 FT_BEGIN_HEADER
     30 
     31 
     32  FT_LOCAL_ARRAY( AF_WritingSystemClass )
     33  af_writing_system_classes[];
     34 
     35 
     36 #undef  SCRIPT
     37 #define SCRIPT( s, S, d, h, H, ss )                            \
     38          AF_DECLARE_SCRIPT_CLASS( af_ ## s ## _script_class )
     39 
     40 #include "afscript.h"
     41 
     42  FT_LOCAL_ARRAY( AF_ScriptClass )
     43  af_script_classes[];
     44 
     45 
     46 #undef  STYLE
     47 #define STYLE( s, S, d, ws, sc, ss, c )                      \
     48          AF_DECLARE_STYLE_CLASS( af_ ## s ## _style_class )
     49 
     50 #include "afstyles.h"
     51 
     52  FT_LOCAL_ARRAY( AF_StyleClass )
     53  af_style_classes[];
     54 
     55 
     56 #ifdef FT_DEBUG_LEVEL_TRACE
     57  FT_LOCAL_ARRAY( char* )
     58  af_style_names[];
     59 #endif
     60 
     61 
     62  /*
     63   * Default values and flags for both autofitter globals (found in
     64   * AF_ModuleRec) and face globals (in AF_FaceGlobalsRec).
     65   */
     66 
     67  /* index of fallback style in `af_style_classes' */
     68 #ifdef AF_CONFIG_OPTION_CJK
     69 #define AF_STYLE_FALLBACK    AF_STYLE_HANI_DFLT
     70 #else
     71 #define AF_STYLE_FALLBACK    AF_STYLE_NONE_DFLT
     72 #endif
     73  /* default script for OpenType; ignored if HarfBuzz isn't used */
     74 #define AF_SCRIPT_DEFAULT    AF_SCRIPT_LATN
     75 
     76  /* a bit mask for AF_DIGIT, AF_NONBASE, and AF_HAS_CMAP_ENTRY */
     77 #define AF_STYLE_MASK        0x1FFF
     78  /* an uncovered glyph      */
     79 #define AF_STYLE_UNASSIGNED  AF_STYLE_MASK
     80 
     81  /* if this flag is set, we have an ASCII digit */
     82 #define AF_DIGIT             0x8000U
     83  /* if this flag is set, we have a non-base character */
     84 #define AF_NONBASE           0x4000U
     85  /* if this flag is set, the glyph has a (direct) cmap entry */
     86 #define AF_HAS_CMAP_ENTRY    0x2000U
     87 
     88  /* `increase-x-height' property */
     89 #define AF_PROP_INCREASE_X_HEIGHT_MIN  6
     90 #define AF_PROP_INCREASE_X_HEIGHT_MAX  0
     91 
     92 
     93  /************************************************************************/
     94  /************************************************************************/
     95  /*****                                                              *****/
     96  /*****                  F A C E   G L O B A L S                     *****/
     97  /*****                                                              *****/
     98  /************************************************************************/
     99  /************************************************************************/
    100 
    101 
    102  /*
    103   * Note that glyph_styles[] maps each glyph to an index into the
    104   * `af_style_classes' array.
    105   *
    106   */
    107  typedef struct  AF_FaceGlobalsRec_
    108  {
    109    FT_Face          face;
    110    FT_UInt          glyph_count;    /* unsigned face->num_glyphs */
    111    FT_UShort*       glyph_styles;
    112 
    113 #ifdef FT_CONFIG_OPTION_USE_HARFBUZZ
    114    hb_font_t*       hb_font;
    115    hb_buffer_t*     hb_buf;           /* for feature comparison */
    116 
    117    /* The GSUB table. */
    118    FT_Byte*         gsub;
    119    /* Lookup offsets, with only SingleSubst and AlternateSubst non-NULL. */
    120    FT_UInt32*       gsub_lookups_single_alternate;
    121 #endif
    122 
    123    /* per-face auto-hinter properties */
    124    FT_UInt          increase_x_height;
    125 
    126    AF_StyleMetrics  metrics[AF_STYLE_MAX];
    127 
    128    /* Compute darkening amount once per size.  Use this to check whether */
    129    /* darken_{x,y} needs to be recomputed.                               */
    130    FT_UShort        stem_darkening_for_ppem;
    131    /* Copy from e.g. AF_LatinMetrics.axis[AF_DIMENSION_HORZ] */
    132    /* to compute the darkening amount.                       */
    133    FT_Pos           standard_vertical_width;
    134    /* Copy from e.g. AF_LatinMetrics.axis[AF_DIMENSION_VERT] */
    135    /* to compute the darkening amount.                       */
    136    FT_Pos           standard_horizontal_width;
    137    /* The actual amount to darken a glyph along the X axis. */
    138    FT_Pos           darken_x;
    139    /* The actual amount to darken a glyph along the Y axis. */
    140    FT_Pos           darken_y;
    141    /* Amount to scale down by to keep emboldened points */
    142    /* on the Y-axis in pre-computed blue zones.         */
    143    FT_Fixed         scale_down_factor;
    144    AF_Module        module;         /* to access global properties */
    145 
    146  } AF_FaceGlobalsRec;
    147 
    148 
    149  /*
    150   * model the global hints data for a given face, decomposed into
    151   * style-specific items
    152   */
    153 
    154  FT_LOCAL( FT_Error )
    155  af_face_globals_new( FT_Face          face,
    156                       AF_FaceGlobals  *aglobals,
    157                       AF_Module        module );
    158 
    159  FT_LOCAL( FT_Error )
    160  af_face_globals_get_metrics( AF_FaceGlobals    globals,
    161                               FT_UInt           gindex,
    162                               FT_UInt           options,
    163                               AF_StyleMetrics  *ametrics );
    164 
    165  FT_LOCAL( void )
    166  af_face_globals_free( void*  globals );
    167 
    168  FT_LOCAL( FT_Bool )
    169  af_face_globals_is_digit( AF_FaceGlobals  globals,
    170                            FT_UInt         gindex );
    171 
    172  /* */
    173 
    174 
    175 FT_END_HEADER
    176 
    177 #endif /* AFGLOBAL_H_ */
    178 
    179 
    180 /* END */