1 /***************************************************************************/ 2 /* */ 3 /* aflatin.h */ 4 /* */ 5 /* Auto-fitter hinting routines for latin writing system */ 6 /* (specification). */ 7 /* */ 8 /* Copyright 2003-2007, 2009, 2011-2013 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_X_HEIGHT_BLUE( b ) \ 57 ( (b)->properties & AF_BLUE_PROPERTY_LATIN_X_HEIGHT ) 58 #define AF_LATIN_IS_LONG_BLUE( b ) \ 59 ( (b)->properties & AF_BLUE_PROPERTY_LATIN_LONG ) 60 61 #define AF_LATIN_MAX_WIDTHS 16 62 63 64 enum 65 { 66 AF_LATIN_BLUE_ACTIVE = 1 << 0, /* set if zone height is <= 3/4px */ 67 AF_LATIN_BLUE_TOP = 1 << 1, /* result of AF_LATIN_IS_TOP_BLUE */ 68 AF_LATIN_BLUE_ADJUSTMENT = 1 << 2, /* used for scale adjustment */ 69 /* optimization */ 70 AF_LATIN_BLUE_FLAG_MAX 71 }; 72 73 74 typedef struct AF_LatinBlueRec_ 75 { 76 AF_WidthRec ref; 77 AF_WidthRec shoot; 78 FT_UInt flags; 79 80 } AF_LatinBlueRec, *AF_LatinBlue; 81 82 83 typedef struct AF_LatinAxisRec_ 84 { 85 FT_Fixed scale; 86 FT_Pos delta; 87 88 FT_UInt width_count; /* number of used widths */ 89 AF_WidthRec widths[AF_LATIN_MAX_WIDTHS]; /* widths array */ 90 FT_Pos edge_distance_threshold; /* used for creating edges */ 91 FT_Pos standard_width; /* the default stem thickness */ 92 FT_Bool extra_light; /* is standard width very light? */ 93 94 /* ignored for horizontal metrics */ 95 FT_UInt blue_count; 96 AF_LatinBlueRec blues[AF_BLUE_STRINGSET_MAX]; 97 98 FT_Fixed org_scale; 99 FT_Pos org_delta; 100 101 } AF_LatinAxisRec, *AF_LatinAxis; 102 103 104 typedef struct AF_LatinMetricsRec_ 105 { 106 AF_StyleMetricsRec root; 107 FT_UInt units_per_em; 108 AF_LatinAxisRec axis[AF_DIMENSION_MAX]; 109 110 } AF_LatinMetricsRec, *AF_LatinMetrics; 111 112 113 FT_LOCAL( FT_Error ) 114 af_latin_metrics_init( AF_LatinMetrics metrics, 115 FT_Face face ); 116 117 FT_LOCAL( void ) 118 af_latin_metrics_scale( AF_LatinMetrics metrics, 119 AF_Scaler scaler ); 120 121 FT_LOCAL( void ) 122 af_latin_metrics_init_widths( AF_LatinMetrics metrics, 123 FT_Face face ); 124 125 FT_LOCAL( void ) 126 af_latin_metrics_check_digits( AF_LatinMetrics metrics, 127 FT_Face face ); 128 129 130 /*************************************************************************/ 131 /*************************************************************************/ 132 /***** *****/ 133 /***** L A T I N G L Y P H A N A L Y S I S *****/ 134 /***** *****/ 135 /*************************************************************************/ 136 /*************************************************************************/ 137 138 enum 139 { 140 AF_LATIN_HINTS_HORZ_SNAP = 1 << 0, /* enable stem width snapping */ 141 AF_LATIN_HINTS_VERT_SNAP = 1 << 1, /* enable stem height snapping */ 142 AF_LATIN_HINTS_STEM_ADJUST = 1 << 2, /* enable stem width/height */ 143 /* adjustment */ 144 AF_LATIN_HINTS_MONO = 1 << 3 /* indicate monochrome */ 145 /* rendering */ 146 }; 147 148 149 #define AF_LATIN_HINTS_DO_HORZ_SNAP( h ) \ 150 AF_HINTS_TEST_OTHER( h, AF_LATIN_HINTS_HORZ_SNAP ) 151 152 #define AF_LATIN_HINTS_DO_VERT_SNAP( h ) \ 153 AF_HINTS_TEST_OTHER( h, AF_LATIN_HINTS_VERT_SNAP ) 154 155 #define AF_LATIN_HINTS_DO_STEM_ADJUST( h ) \ 156 AF_HINTS_TEST_OTHER( h, AF_LATIN_HINTS_STEM_ADJUST ) 157 158 #define AF_LATIN_HINTS_DO_MONO( h ) \ 159 AF_HINTS_TEST_OTHER( h, AF_LATIN_HINTS_MONO ) 160 161 162 /* 163 * The next functions shouldn't normally be exported. However, other 164 * writing systems might like to use these functions as-is. 165 */ 166 FT_LOCAL( FT_Error ) 167 af_latin_hints_compute_segments( AF_GlyphHints hints, 168 AF_Dimension dim ); 169 170 FT_LOCAL( void ) 171 af_latin_hints_link_segments( AF_GlyphHints hints, 172 AF_Dimension dim ); 173 174 FT_LOCAL( FT_Error ) 175 af_latin_hints_compute_edges( AF_GlyphHints hints, 176 AF_Dimension dim ); 177 178 FT_LOCAL( FT_Error ) 179 af_latin_hints_detect_features( AF_GlyphHints hints, 180 AF_Dimension dim ); 181 182 /* */ 183 184 FT_END_HEADER 185 186 #endif /* __AFLATIN_H__ */ 187 188 189 /* END */ 190