tor-browser

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

aflatin.h (7408B)


      1 /****************************************************************************
      2 *
      3 * aflatin.h
      4 *
      5 *   Auto-fitter hinting routines for latin writing system
      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 AFLATIN_H_
     21 #define AFLATIN_H_
     22 
     23 #include "afhints.h"
     24 
     25 
     26 FT_BEGIN_HEADER
     27 
     28  /* the `latin' writing system */
     29 
     30  AF_DECLARE_WRITING_SYSTEM_CLASS( af_latin_writing_system_class )
     31 
     32 
     33  /* constants are given with units_per_em == 2048 in mind */
     34 #define AF_LATIN_CONSTANT( metrics, c )                                      \
     35  ( ( (c) * (FT_Long)( (AF_LatinMetrics)(metrics) )->units_per_em ) / 2048 )
     36 
     37 
     38  /*************************************************************************/
     39  /*************************************************************************/
     40  /*****                                                               *****/
     41  /*****            L A T I N   G L O B A L   M E T R I C S            *****/
     42  /*****                                                               *****/
     43  /*************************************************************************/
     44  /*************************************************************************/
     45 
     46 
     47  /*
     48   * The following declarations could be embedded in the file `aflatin.c';
     49   * they have been made semi-public to allow alternate writing system
     50   * hinters to re-use some of them.
     51   */
     52 
     53 
     54 #define AF_LATIN_IS_TOP_BLUE( b ) \
     55          ( (b)->properties & AF_BLUE_PROPERTY_LATIN_TOP )
     56 #define AF_LATIN_IS_SUB_TOP_BLUE( b ) \
     57          ( (b)->properties & AF_BLUE_PROPERTY_LATIN_SUB_TOP )
     58 #define AF_LATIN_IS_NEUTRAL_BLUE( b ) \
     59          ( (b)->properties & AF_BLUE_PROPERTY_LATIN_NEUTRAL )
     60 #define AF_LATIN_IS_X_HEIGHT_BLUE( b ) \
     61          ( (b)->properties & AF_BLUE_PROPERTY_LATIN_X_HEIGHT )
     62 #define AF_LATIN_IS_LONG_BLUE( b ) \
     63          ( (b)->properties & AF_BLUE_PROPERTY_LATIN_LONG )
     64 #define AF_LATIN_IS_CAPITAL_BOTTOM_BLUE( b ) \
     65          ( (b)->properties & AF_BLUE_PROPERTY_LATIN_CAPITAL_BOTTOM )
     66 #define AF_LATIN_IS_SMALL_BOTTOM_BLUE( b ) \
     67          ( (b)->properties & AF_BLUE_PROPERTY_LATIN_SMALL_BOTTOM )
     68 
     69 #define AF_LATIN_MAX_WIDTHS  16
     70 
     71 
     72 #define AF_LATIN_BLUE_ACTIVE        ( 1U << 0 ) /* zone height is <= 3/4px */
     73 #define AF_LATIN_BLUE_TOP           ( 1U << 1 ) /* we have a top blue zone */
     74 #define AF_LATIN_BLUE_SUB_TOP       ( 1U << 2 ) /* we have a subscript     */
     75                                                /* top blue zone           */
     76 #define AF_LATIN_BLUE_NEUTRAL       ( 1U << 3 ) /* we have a neutral blue  */
     77                                                /* zone                    */
     78 #define AF_LATIN_BLUE_ADJUSTMENT    ( 1U << 4 ) /* used for scale adjustm. */
     79                                                /* optimization            */
     80 #define AF_LATIN_BLUE_BOTTOM        ( 1U << 5 ) /* we have a capital       */
     81                                                /* letter bottom blue zone */
     82 #define AF_LATIN_BLUE_BOTTOM_SMALL  ( 1U << 6 ) /* we have a small letter  */
     83                                                /* bottom blue zone        */
     84 
     85 
     86  typedef struct  AF_LatinBlueRec_
     87  {
     88    AF_WidthRec  ref;
     89    AF_WidthRec  shoot;
     90    FT_Pos       ascender;
     91    FT_Pos       descender;
     92    FT_UInt      flags;
     93 
     94  } AF_LatinBlueRec, *AF_LatinBlue;
     95 
     96 
     97  typedef struct  AF_LatinAxisRec_
     98  {
     99    FT_Fixed         scale;
    100    FT_Pos           delta;
    101 
    102    FT_UInt          width_count;                 /* number of used widths */
    103    AF_WidthRec      widths[AF_LATIN_MAX_WIDTHS]; /* widths array          */
    104    FT_Pos           edge_distance_threshold;   /* used for creating edges */
    105    FT_Pos           standard_width;         /* the default stem thickness */
    106    FT_Bool          extra_light;         /* is standard width very light? */
    107 
    108    /* ignored for horizontal metrics */
    109    FT_UInt          blue_count;
    110    AF_LatinBlueRec  blues[AF_BLUE_STRINGSET_MAX_LEN];
    111 
    112    FT_Fixed         org_scale;
    113    FT_Pos           org_delta;
    114 
    115  } AF_LatinAxisRec, *AF_LatinAxis;
    116 
    117 
    118  typedef struct  AF_LatinMetricsRec_
    119  {
    120    AF_StyleMetricsRec  root;
    121    FT_UInt             units_per_em;
    122    AF_LatinAxisRec     axis[AF_DIMENSION_MAX];
    123 
    124  } AF_LatinMetricsRec, *AF_LatinMetrics;
    125 
    126 
    127  FT_LOCAL( FT_Error )
    128  af_latin_metrics_init( AF_StyleMetrics  metrics,
    129                         FT_Face          face );
    130 
    131  FT_LOCAL( void )
    132  af_latin_metrics_scale( AF_StyleMetrics  metrics,
    133                          AF_Scaler        scaler );
    134 
    135  FT_LOCAL( void )
    136  af_latin_metrics_init_widths( AF_LatinMetrics  metrics,
    137                                FT_Face          face );
    138 
    139  FT_LOCAL( void )
    140  af_latin_metrics_check_digits( AF_LatinMetrics  metrics,
    141                                 FT_Face          face );
    142 
    143 
    144  /*************************************************************************/
    145  /*************************************************************************/
    146  /*****                                                               *****/
    147  /*****           L A T I N   G L Y P H   A N A L Y S I S             *****/
    148  /*****                                                               *****/
    149  /*************************************************************************/
    150  /*************************************************************************/
    151 
    152 #define AF_LATIN_HINTS_HORZ_SNAP    ( 1U << 0 ) /* stem width snapping  */
    153 #define AF_LATIN_HINTS_VERT_SNAP    ( 1U << 1 ) /* stem height snapping */
    154 #define AF_LATIN_HINTS_STEM_ADJUST  ( 1U << 2 ) /* stem width/height    */
    155                                                /* adjustment           */
    156 #define AF_LATIN_HINTS_MONO         ( 1U << 3 ) /* monochrome rendering */
    157 
    158 
    159 #define AF_LATIN_HINTS_DO_HORZ_SNAP( h )             \
    160  AF_HINTS_TEST_OTHER( h, AF_LATIN_HINTS_HORZ_SNAP )
    161 
    162 #define AF_LATIN_HINTS_DO_VERT_SNAP( h )             \
    163  AF_HINTS_TEST_OTHER( h, AF_LATIN_HINTS_VERT_SNAP )
    164 
    165 #define AF_LATIN_HINTS_DO_STEM_ADJUST( h )             \
    166  AF_HINTS_TEST_OTHER( h, AF_LATIN_HINTS_STEM_ADJUST )
    167 
    168 #define AF_LATIN_HINTS_DO_MONO( h )             \
    169  AF_HINTS_TEST_OTHER( h, AF_LATIN_HINTS_MONO )
    170 
    171 
    172  /*
    173   * The next functions shouldn't normally be exported.  However, other
    174   * writing systems might like to use these functions as-is.
    175   */
    176  FT_LOCAL( FT_Error )
    177  af_latin_hints_compute_segments( AF_GlyphHints  hints,
    178                                   AF_Dimension   dim );
    179 
    180  FT_LOCAL( void )
    181  af_latin_hints_link_segments( AF_GlyphHints  hints,
    182                                FT_UInt        width_count,
    183                                AF_WidthRec*   widths,
    184                                AF_Dimension   dim );
    185 
    186  FT_LOCAL( FT_Error )
    187  af_latin_hints_compute_edges( AF_GlyphHints  hints,
    188                                AF_Dimension   dim );
    189 
    190  FT_LOCAL( FT_Error )
    191  af_latin_hints_detect_features( AF_GlyphHints  hints,
    192                                  FT_UInt        width_count,
    193                                  AF_WidthRec*   widths,
    194                                  AF_Dimension   dim );
    195 
    196 /* */
    197 
    198 FT_END_HEADER
    199 
    200 #endif /* AFLATIN_H_ */
    201 
    202 
    203 /* END */