| OLD | NEW |
| 1 /***************************************************************************/ | 1 /***************************************************************************/ |
| 2 /* */ | 2 /* */ |
| 3 /* afhints.c */ | 3 /* afhints.c */ |
| 4 /* */ | 4 /* */ |
| 5 /* Auto-fitter hinting routines (body). */ | 5 /* Auto-fitter hinting routines (body). */ |
| 6 /* */ | 6 /* */ |
| 7 /* Copyright 2003-2007, 2009-2011 by */ | 7 /* Copyright 2003-2007, 2009-2013 by */ |
| 8 /* David Turner, Robert Wilhelm, and Werner Lemberg. */ | 8 /* David Turner, Robert Wilhelm, and Werner Lemberg. */ |
| 9 /* */ | 9 /* */ |
| 10 /* This file is part of the FreeType project, and may only be used, */ | 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 */ | 11 /* modified, and distributed under the terms of the FreeType project */ |
| 12 /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ | 12 /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ |
| 13 /* this file you indicate that you have read the license and */ | 13 /* this file you indicate that you have read the license and */ |
| 14 /* understand and accept it fully. */ | 14 /* understand and accept it fully. */ |
| 15 /* */ | 15 /* */ |
| 16 /***************************************************************************/ | 16 /***************************************************************************/ |
| 17 | 17 |
| 18 | 18 |
| 19 #include "afhints.h" | 19 #include "afhints.h" |
| 20 #include "aferrors.h" | 20 #include "aferrors.h" |
| 21 #include FT_INTERNAL_CALC_H | 21 #include FT_INTERNAL_CALC_H |
| 22 #include FT_INTERNAL_DEBUG_H |
| 23 |
| 24 |
| 25 /*************************************************************************/ |
| 26 /* */ |
| 27 /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ |
| 28 /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ |
| 29 /* messages during execution. */ |
| 30 /* */ |
| 31 #undef FT_COMPONENT |
| 32 #define FT_COMPONENT trace_afhints |
| 22 | 33 |
| 23 | 34 |
| 24 /* Get new segment for given axis. */ | 35 /* Get new segment for given axis. */ |
| 25 | 36 |
| 26 FT_LOCAL_DEF( FT_Error ) | 37 FT_LOCAL_DEF( FT_Error ) |
| 27 af_axis_hints_new_segment( AF_AxisHints axis, | 38 af_axis_hints_new_segment( AF_AxisHints axis, |
| 28 FT_Memory memory, | 39 FT_Memory memory, |
| 29 AF_Segment *asegment ) | 40 AF_Segment *asegment ) |
| 30 { | 41 { |
| 31 FT_Error error = AF_Err_Ok; | 42 FT_Error error = FT_Err_Ok; |
| 32 AF_Segment segment = NULL; | 43 AF_Segment segment = NULL; |
| 33 | 44 |
| 34 | 45 |
| 35 if ( axis->num_segments >= axis->max_segments ) | 46 if ( axis->num_segments >= axis->max_segments ) |
| 36 { | 47 { |
| 37 FT_Int old_max = axis->max_segments; | 48 FT_Int old_max = axis->max_segments; |
| 38 FT_Int new_max = old_max; | 49 FT_Int new_max = old_max; |
| 39 FT_Int big_max = (FT_Int)( FT_INT_MAX / sizeof ( *segment ) ); | 50 FT_Int big_max = (FT_Int)( FT_INT_MAX / sizeof ( *segment ) ); |
| 40 | 51 |
| 41 | 52 |
| 42 if ( old_max >= big_max ) | 53 if ( old_max >= big_max ) |
| 43 { | 54 { |
| 44 error = AF_Err_Out_Of_Memory; | 55 error = FT_THROW( Out_Of_Memory ); |
| 45 goto Exit; | 56 goto Exit; |
| 46 } | 57 } |
| 47 | 58 |
| 48 new_max += ( new_max >> 2 ) + 4; | 59 new_max += ( new_max >> 2 ) + 4; |
| 49 if ( new_max < old_max || new_max > big_max ) | 60 if ( new_max < old_max || new_max > big_max ) |
| 50 new_max = big_max; | 61 new_max = big_max; |
| 51 | 62 |
| 52 if ( FT_RENEW_ARRAY( axis->segments, old_max, new_max ) ) | 63 if ( FT_RENEW_ARRAY( axis->segments, old_max, new_max ) ) |
| 53 goto Exit; | 64 goto Exit; |
| 54 | 65 |
| 55 axis->max_segments = new_max; | 66 axis->max_segments = new_max; |
| 56 } | 67 } |
| 57 | 68 |
| 58 segment = axis->segments + axis->num_segments++; | 69 segment = axis->segments + axis->num_segments++; |
| 59 | 70 |
| 60 Exit: | 71 Exit: |
| 61 *asegment = segment; | 72 *asegment = segment; |
| 62 return error; | 73 return error; |
| 63 } | 74 } |
| 64 | 75 |
| 65 | 76 |
| 66 /* Get new edge for given axis, direction, and position. */ | 77 /* Get new edge for given axis, direction, and position. */ |
| 67 | 78 |
| 68 FT_LOCAL( FT_Error ) | 79 FT_LOCAL( FT_Error ) |
| 69 af_axis_hints_new_edge( AF_AxisHints axis, | 80 af_axis_hints_new_edge( AF_AxisHints axis, |
| 70 FT_Int fpos, | 81 FT_Int fpos, |
| 71 AF_Direction dir, | 82 AF_Direction dir, |
| 72 FT_Memory memory, | 83 FT_Memory memory, |
| 73 AF_Edge *aedge ) | 84 AF_Edge *anedge ) |
| 74 { | 85 { |
| 75 FT_Error error = AF_Err_Ok; | 86 FT_Error error = FT_Err_Ok; |
| 76 AF_Edge edge = NULL; | 87 AF_Edge edge = NULL; |
| 77 AF_Edge edges; | 88 AF_Edge edges; |
| 78 | 89 |
| 79 | 90 |
| 80 if ( axis->num_edges >= axis->max_edges ) | 91 if ( axis->num_edges >= axis->max_edges ) |
| 81 { | 92 { |
| 82 FT_Int old_max = axis->max_edges; | 93 FT_Int old_max = axis->max_edges; |
| 83 FT_Int new_max = old_max; | 94 FT_Int new_max = old_max; |
| 84 FT_Int big_max = (FT_Int)( FT_INT_MAX / sizeof ( *edge ) ); | 95 FT_Int big_max = (FT_Int)( FT_INT_MAX / sizeof ( *edge ) ); |
| 85 | 96 |
| 86 | 97 |
| 87 if ( old_max >= big_max ) | 98 if ( old_max >= big_max ) |
| 88 { | 99 { |
| 89 error = AF_Err_Out_Of_Memory; | 100 error = FT_THROW( Out_Of_Memory ); |
| 90 goto Exit; | 101 goto Exit; |
| 91 } | 102 } |
| 92 | 103 |
| 93 new_max += ( new_max >> 2 ) + 4; | 104 new_max += ( new_max >> 2 ) + 4; |
| 94 if ( new_max < old_max || new_max > big_max ) | 105 if ( new_max < old_max || new_max > big_max ) |
| 95 new_max = big_max; | 106 new_max = big_max; |
| 96 | 107 |
| 97 if ( FT_RENEW_ARRAY( axis->edges, old_max, new_max ) ) | 108 if ( FT_RENEW_ARRAY( axis->edges, old_max, new_max ) ) |
| 98 goto Exit; | 109 goto Exit; |
| 99 | 110 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 117 edge--; | 128 edge--; |
| 118 } | 129 } |
| 119 | 130 |
| 120 axis->num_edges++; | 131 axis->num_edges++; |
| 121 | 132 |
| 122 FT_ZERO( edge ); | 133 FT_ZERO( edge ); |
| 123 edge->fpos = (FT_Short)fpos; | 134 edge->fpos = (FT_Short)fpos; |
| 124 edge->dir = (FT_Char)dir; | 135 edge->dir = (FT_Char)dir; |
| 125 | 136 |
| 126 Exit: | 137 Exit: |
| 127 *aedge = edge; | 138 *anedge = edge; |
| 128 return error; | 139 return error; |
| 129 } | 140 } |
| 130 | 141 |
| 131 | 142 |
| 132 #ifdef FT_DEBUG_AUTOFIT | 143 #ifdef FT_DEBUG_AUTOFIT |
| 133 | 144 |
| 134 #include FT_CONFIG_STANDARD_LIBRARY_H | 145 #include FT_CONFIG_STANDARD_LIBRARY_H |
| 135 | 146 |
| 136 static const char* | 147 static const char* |
| 137 af_dir_str( AF_Direction dir ) | 148 af_dir_str( AF_Direction dir ) |
| (...skipping 30 matching lines...) Expand all Loading... |
| 168 extern "C" { | 179 extern "C" { |
| 169 #endif | 180 #endif |
| 170 void | 181 void |
| 171 af_glyph_hints_dump_points( AF_GlyphHints hints ) | 182 af_glyph_hints_dump_points( AF_GlyphHints hints ) |
| 172 { | 183 { |
| 173 AF_Point points = hints->points; | 184 AF_Point points = hints->points; |
| 174 AF_Point limit = points + hints->num_points; | 185 AF_Point limit = points + hints->num_points; |
| 175 AF_Point point; | 186 AF_Point point; |
| 176 | 187 |
| 177 | 188 |
| 178 printf( "Table of points:\n" ); | 189 FT_TRACE7(( "Table of points:\n" |
| 179 printf( " [ index | xorg | yorg | xscale | yscale" | 190 " [ index | xorg | yorg | xscale | yscale" |
| 180 " | xfit | yfit | flags ]\n" ); | 191 " | xfit | yfit | flags ]\n" )); |
| 181 | 192 |
| 182 for ( point = points; point < limit; point++ ) | 193 for ( point = points; point < limit; point++ ) |
| 183 { | 194 FT_TRACE7(( " [ %5d | %5d | %5d | %6.2f | %6.2f" |
| 184 printf( " [ %5d | %5d | %5d | %6.2f | %6.2f" | 195 " | %5.2f | %5.2f | %c%c%c%c%c%c ]\n", |
| 185 " | %5.2f | %5.2f | %c%c%c%c%c%c ]\n", | 196 point - points, |
| 186 point - points, | 197 point->fx, |
| 187 point->fx, | 198 point->fy, |
| 188 point->fy, | 199 point->ox / 64.0, |
| 189 point->ox / 64.0, | 200 point->oy / 64.0, |
| 190 point->oy / 64.0, | 201 point->x / 64.0, |
| 191 point->x / 64.0, | 202 point->y / 64.0, |
| 192 point->y / 64.0, | 203 ( point->flags & AF_FLAG_WEAK_INTERPOLATION ) ? 'w' : ' ', |
| 193 ( point->flags & AF_FLAG_WEAK_INTERPOLATION ) ? 'w' : ' ', | 204 ( point->flags & AF_FLAG_INFLECTION ) ? 'i' : ' ', |
| 194 ( point->flags & AF_FLAG_INFLECTION ) ? 'i' : ' ', | 205 ( point->flags & AF_FLAG_EXTREMA_X ) ? '<' : ' ', |
| 195 ( point->flags & AF_FLAG_EXTREMA_X ) ? '<' : ' ', | 206 ( point->flags & AF_FLAG_EXTREMA_Y ) ? 'v' : ' ', |
| 196 ( point->flags & AF_FLAG_EXTREMA_Y ) ? 'v' : ' ', | 207 ( point->flags & AF_FLAG_ROUND_X ) ? '(' : ' ', |
| 197 ( point->flags & AF_FLAG_ROUND_X ) ? '(' : ' ', | 208 ( point->flags & AF_FLAG_ROUND_Y ) ? 'u' : ' ')); |
| 198 ( point->flags & AF_FLAG_ROUND_Y ) ? 'u' : ' '); | 209 FT_TRACE7(( "\n" )); |
| 199 } | |
| 200 printf( "\n" ); | |
| 201 } | 210 } |
| 202 #ifdef __cplusplus | 211 #ifdef __cplusplus |
| 203 } | 212 } |
| 204 #endif | 213 #endif |
| 205 | 214 |
| 206 | 215 |
| 207 static const char* | 216 static const char* |
| 208 af_edge_flags_to_string( AF_Edge_Flags flags ) | 217 af_edge_flags_to_string( AF_Edge_Flags flags ) |
| 209 { | 218 { |
| 210 static char temp[32]; | 219 static char temp[32]; |
| 211 int pos = 0; | 220 int pos = 0; |
| 212 | 221 |
| 213 | 222 |
| 214 if ( flags & AF_EDGE_ROUND ) | 223 if ( flags & AF_EDGE_ROUND ) |
| 215 { | 224 { |
| 216 ft_memcpy( temp + pos, "round", 5 ); | 225 ft_memcpy( temp + pos, "round", 5 ); |
| 217 pos += 5; | 226 pos += 5; |
| 218 } | 227 } |
| 219 if ( flags & AF_EDGE_SERIF ) | 228 if ( flags & AF_EDGE_SERIF ) |
| 220 { | 229 { |
| 221 if ( pos > 0 ) | 230 if ( pos > 0 ) |
| 222 temp[pos++] = ' '; | 231 temp[pos++] = ' '; |
| 223 ft_memcpy( temp + pos, "serif", 5 ); | 232 ft_memcpy( temp + pos, "serif", 5 ); |
| 224 pos += 5; | 233 pos += 5; |
| 225 } | 234 } |
| 226 if ( pos == 0 ) | 235 if ( pos == 0 ) |
| 227 return "normal"; | 236 return "normal"; |
| 228 | 237 |
| 229 temp[pos] = 0; | 238 temp[pos] = '\0'; |
| 230 | 239 |
| 231 return temp; | 240 return temp; |
| 232 } | 241 } |
| 233 | 242 |
| 234 | 243 |
| 235 /* Dump the array of linked segments. */ | 244 /* Dump the array of linked segments. */ |
| 236 | 245 |
| 237 #ifdef __cplusplus | 246 #ifdef __cplusplus |
| 238 extern "C" { | 247 extern "C" { |
| 239 #endif | 248 #endif |
| 240 void | 249 void |
| 241 af_glyph_hints_dump_segments( AF_GlyphHints hints ) | 250 af_glyph_hints_dump_segments( AF_GlyphHints hints ) |
| 242 { | 251 { |
| 243 FT_Int dimension; | 252 FT_Int dimension; |
| 244 | 253 |
| 245 | 254 |
| 246 for ( dimension = 1; dimension >= 0; dimension-- ) | 255 for ( dimension = 1; dimension >= 0; dimension-- ) |
| 247 { | 256 { |
| 248 AF_AxisHints axis = &hints->axis[dimension]; | 257 AF_AxisHints axis = &hints->axis[dimension]; |
| 258 AF_Point points = hints->points; |
| 259 AF_Edge edges = axis->edges; |
| 249 AF_Segment segments = axis->segments; | 260 AF_Segment segments = axis->segments; |
| 250 AF_Segment limit = segments + axis->num_segments; | 261 AF_Segment limit = segments + axis->num_segments; |
| 251 AF_Segment seg; | 262 AF_Segment seg; |
| 252 | 263 |
| 253 | 264 |
| 254 printf ( "Table of %s segments:\n", | 265 FT_TRACE7(( "Table of %s segments:\n", |
| 255 dimension == AF_DIMENSION_HORZ ? "vertical" : "horizontal" ); | 266 dimension == AF_DIMENSION_HORZ ? "vertical" |
| 256 printf ( " [ index | pos | dir | link | serif |" | 267 : "horizontal" )); |
| 257 " height | extra | flags ]\n" ); | 268 if ( axis->num_segments ) |
| 269 FT_TRACE7(( " [ index | pos | dir | from" |
| 270 " | to | link | serif | edge" |
| 271 " | height | extra | flags ]\n" )); |
| 272 else |
| 273 FT_TRACE7(( " (none)\n" )); |
| 258 | 274 |
| 259 for ( seg = segments; seg < limit; seg++ ) | 275 for ( seg = segments; seg < limit; seg++ ) |
| 260 { | 276 FT_TRACE7(( " [ %5d | %5.2g | %5s | %4d" |
| 261 printf ( " [ %5d | %5.2g | %5s | %4d | %5d | %6d | %5d | %11s ]\n", | 277 " | %4d | %4d | %5d | %4d" |
| 262 seg - segments, | 278 " | %6d | %5d | %11s ]\n", |
| 263 dimension == AF_DIMENSION_HORZ ? (int)seg->first->ox / 64.0 | 279 seg - segments, |
| 264 : (int)seg->first->oy / 64.0, | 280 dimension == AF_DIMENSION_HORZ |
| 265 af_dir_str( (AF_Direction)seg->dir ), | 281 ? (int)seg->first->ox / 64.0 |
| 266 AF_INDEX_NUM( seg->link, segments ), | 282 : (int)seg->first->oy / 64.0, |
| 267 AF_INDEX_NUM( seg->serif, segments ), | 283 af_dir_str( (AF_Direction)seg->dir ), |
| 268 seg->height, | 284 AF_INDEX_NUM( seg->first, points ), |
| 269 seg->height - ( seg->max_coord - seg->min_coord ), | 285 AF_INDEX_NUM( seg->last, points ), |
| 270 af_edge_flags_to_string( (AF_Edge_Flags)seg->flags ) ); | 286 AF_INDEX_NUM( seg->link, segments ), |
| 271 } | 287 AF_INDEX_NUM( seg->serif, segments ), |
| 272 printf( "\n" ); | 288 AF_INDEX_NUM( seg->edge, edges ), |
| 289 seg->height, |
| 290 seg->height - ( seg->max_coord - seg->min_coord ), |
| 291 af_edge_flags_to_string( (AF_Edge_Flags)seg->flags ) )); |
| 292 FT_TRACE7(( "\n" )); |
| 273 } | 293 } |
| 274 } | 294 } |
| 275 #ifdef __cplusplus | 295 #ifdef __cplusplus |
| 276 } | 296 } |
| 277 #endif | 297 #endif |
| 278 | 298 |
| 279 | 299 |
| 280 /* Fetch number of segments. */ | 300 /* Fetch number of segments. */ |
| 281 | 301 |
| 282 #ifdef __cplusplus | 302 #ifdef __cplusplus |
| 283 extern "C" { | 303 extern "C" { |
| 284 #endif | 304 #endif |
| 285 FT_Error | 305 FT_Error |
| 286 af_glyph_hints_get_num_segments( AF_GlyphHints hints, | 306 af_glyph_hints_get_num_segments( AF_GlyphHints hints, |
| 287 FT_Int dimension, | 307 FT_Int dimension, |
| 288 FT_Int* num_segments ) | 308 FT_Int* num_segments ) |
| 289 { | 309 { |
| 290 AF_Dimension dim; | 310 AF_Dimension dim; |
| 291 AF_AxisHints axis; | 311 AF_AxisHints axis; |
| 292 | 312 |
| 293 | 313 |
| 294 dim = ( dimension == 0 ) ? AF_DIMENSION_HORZ : AF_DIMENSION_VERT; | 314 dim = ( dimension == 0 ) ? AF_DIMENSION_HORZ : AF_DIMENSION_VERT; |
| 295 | 315 |
| 296 axis = &hints->axis[dim]; | 316 axis = &hints->axis[dim]; |
| 297 *num_segments = axis->num_segments; | 317 *num_segments = axis->num_segments; |
| 298 | 318 |
| 299 return AF_Err_Ok; | 319 return FT_Err_Ok; |
| 300 } | 320 } |
| 301 #ifdef __cplusplus | 321 #ifdef __cplusplus |
| 302 } | 322 } |
| 303 #endif | 323 #endif |
| 304 | 324 |
| 305 | 325 |
| 306 /* Fetch offset of segments into user supplied offset array. */ | 326 /* Fetch offset of segments into user supplied offset array. */ |
| 307 | 327 |
| 308 #ifdef __cplusplus | 328 #ifdef __cplusplus |
| 309 extern "C" { | 329 extern "C" { |
| 310 #endif | 330 #endif |
| 311 FT_Error | 331 FT_Error |
| 312 af_glyph_hints_get_segment_offset( AF_GlyphHints hints, | 332 af_glyph_hints_get_segment_offset( AF_GlyphHints hints, |
| 313 FT_Int dimension, | 333 FT_Int dimension, |
| 314 FT_Int idx, | 334 FT_Int idx, |
| 315 FT_Pos* offset ) | 335 FT_Pos* offset ) |
| 316 { | 336 { |
| 317 AF_Dimension dim; | 337 AF_Dimension dim; |
| 318 AF_AxisHints axis; | 338 AF_AxisHints axis; |
| 319 AF_Segment seg; | 339 AF_Segment seg; |
| 320 | 340 |
| 321 | 341 |
| 322 if ( !offset ) | 342 if ( !offset ) |
| 323 return AF_Err_Invalid_Argument; | 343 return FT_THROW( Invalid_Argument ); |
| 324 | 344 |
| 325 dim = ( dimension == 0 ) ? AF_DIMENSION_HORZ : AF_DIMENSION_VERT; | 345 dim = ( dimension == 0 ) ? AF_DIMENSION_HORZ : AF_DIMENSION_VERT; |
| 326 | 346 |
| 327 axis = &hints->axis[dim]; | 347 axis = &hints->axis[dim]; |
| 328 | 348 |
| 329 if ( idx < 0 || idx >= axis->num_segments ) | 349 if ( idx < 0 || idx >= axis->num_segments ) |
| 330 return AF_Err_Invalid_Argument; | 350 return FT_THROW( Invalid_Argument ); |
| 331 | 351 |
| 332 seg = &axis->segments[idx]; | 352 seg = &axis->segments[idx]; |
| 333 *offset = (dim == AF_DIMENSION_HORZ) ? seg->first->ox | 353 *offset = ( dim == AF_DIMENSION_HORZ ) ? seg->first->ox |
| 334 : seg->first->oy; | 354 : seg->first->oy; |
| 335 | 355 |
| 336 return AF_Err_Ok; | 356 return FT_Err_Ok; |
| 337 } | 357 } |
| 338 #ifdef __cplusplus | 358 #ifdef __cplusplus |
| 339 } | 359 } |
| 340 #endif | 360 #endif |
| 341 | 361 |
| 342 | 362 |
| 343 /* Dump the array of linked edges. */ | 363 /* Dump the array of linked edges. */ |
| 344 | 364 |
| 345 #ifdef __cplusplus | 365 #ifdef __cplusplus |
| 346 extern "C" { | 366 extern "C" { |
| 347 #endif | 367 #endif |
| 348 void | 368 void |
| 349 af_glyph_hints_dump_edges( AF_GlyphHints hints ) | 369 af_glyph_hints_dump_edges( AF_GlyphHints hints ) |
| 350 { | 370 { |
| 351 FT_Int dimension; | 371 FT_Int dimension; |
| 352 | 372 |
| 353 | 373 |
| 354 for ( dimension = 1; dimension >= 0; dimension-- ) | 374 for ( dimension = 1; dimension >= 0; dimension-- ) |
| 355 { | 375 { |
| 356 AF_AxisHints axis = &hints->axis[dimension]; | 376 AF_AxisHints axis = &hints->axis[dimension]; |
| 357 AF_Edge edges = axis->edges; | 377 AF_Edge edges = axis->edges; |
| 358 AF_Edge limit = edges + axis->num_edges; | 378 AF_Edge limit = edges + axis->num_edges; |
| 359 AF_Edge edge; | 379 AF_Edge edge; |
| 360 | 380 |
| 361 | 381 |
| 362 /* | 382 /* |
| 363 * note: AF_DIMENSION_HORZ corresponds to _vertical_ edges | 383 * note: AF_DIMENSION_HORZ corresponds to _vertical_ edges |
| 364 * since they have a constant X coordinate. | 384 * since they have a constant X coordinate. |
| 365 */ | 385 */ |
| 366 printf ( "Table of %s edges:\n", | 386 FT_TRACE7(( "Table of %s edges:\n", |
| 367 dimension == AF_DIMENSION_HORZ ? "vertical" : "horizontal" ); | 387 dimension == AF_DIMENSION_HORZ ? "vertical" |
| 368 printf ( " [ index | pos | dir | link |" | 388 : "horizontal" )); |
| 369 " serif | blue | opos | pos | flags ]\n" ); | 389 if ( axis->num_edges ) |
| 390 FT_TRACE7(( " [ index | pos | dir | link" |
| 391 " | serif | blue | opos | pos | flags ]\n" )); |
| 392 else |
| 393 FT_TRACE7(( " (none)\n" )); |
| 370 | 394 |
| 371 for ( edge = edges; edge < limit; edge++ ) | 395 for ( edge = edges; edge < limit; edge++ ) |
| 372 { | 396 FT_TRACE7(( " [ %5d | %5.2g | %5s | %4d" |
| 373 printf ( " [ %5d | %5.2g | %5s | %4d |" | 397 " | %5d | %c | %5.2f | %5.2f | %11s ]\n", |
| 374 " %5d | %c | %5.2f | %5.2f | %11s ]\n", | 398 edge - edges, |
| 375 edge - edges, | 399 (int)edge->opos / 64.0, |
| 376 (int)edge->opos / 64.0, | 400 af_dir_str( (AF_Direction)edge->dir ), |
| 377 af_dir_str( (AF_Direction)edge->dir ), | 401 AF_INDEX_NUM( edge->link, edges ), |
| 378 AF_INDEX_NUM( edge->link, edges ), | 402 AF_INDEX_NUM( edge->serif, edges ), |
| 379 AF_INDEX_NUM( edge->serif, edges ), | 403 edge->blue_edge ? 'y' : 'n', |
| 380 edge->blue_edge ? 'y' : 'n', | 404 edge->opos / 64.0, |
| 381 edge->opos / 64.0, | 405 edge->pos / 64.0, |
| 382 edge->pos / 64.0, | 406 af_edge_flags_to_string( (AF_Edge_Flags)edge->flags ) )); |
| 383 af_edge_flags_to_string( (AF_Edge_Flags)edge->flags ) ); | 407 FT_TRACE7(( "\n" )); |
| 384 } | |
| 385 printf( "\n" ); | |
| 386 } | 408 } |
| 387 } | 409 } |
| 388 #ifdef __cplusplus | 410 #ifdef __cplusplus |
| 389 } | 411 } |
| 390 #endif | 412 #endif |
| 391 | 413 |
| 392 #else /* !FT_DEBUG_AUTOFIT */ | 414 #else /* !FT_DEBUG_AUTOFIT */ |
| 393 | 415 |
| 394 /* these empty stubs are only used to link the `ftgrid' test program */ | 416 /* these empty stubs are only used to link the `ftgrid' test program */ |
| 395 /* if debugging is disabled */ | 417 /* if debugging is disabled */ |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 487 ss = dy; | 509 ss = dy; |
| 488 } | 510 } |
| 489 else | 511 else |
| 490 { | 512 { |
| 491 dir = AF_DIR_DOWN; | 513 dir = AF_DIR_DOWN; |
| 492 ll = dy; | 514 ll = dy; |
| 493 ss = dx; | 515 ss = dx; |
| 494 } | 516 } |
| 495 } | 517 } |
| 496 | 518 |
| 497 /* return no direction if arm lengths differ too much */ | 519 /* return no direction if arm lengths differ too much */ |
| 498 /* (value 14 is heuristic) */ | 520 /* (value 14 is heuristic, corresponding to approx. 4.1 degrees) */ |
| 499 ss *= 14; | 521 ss *= 14; |
| 500 if ( FT_ABS( ll ) <= FT_ABS( ss ) ) | 522 if ( FT_ABS( ll ) <= FT_ABS( ss ) ) |
| 501 dir = AF_DIR_NONE; | 523 dir = AF_DIR_NONE; |
| 502 | 524 |
| 503 return dir; | 525 return dir; |
| 504 } | 526 } |
| 505 | 527 |
| 506 | 528 |
| 507 FT_LOCAL_DEF( void ) | 529 FT_LOCAL_DEF( void ) |
| 508 af_glyph_hints_init( AF_GlyphHints hints, | 530 af_glyph_hints_init( AF_GlyphHints hints, |
| 509 FT_Memory memory ) | 531 FT_Memory memory ) |
| 510 { | 532 { |
| 511 FT_ZERO( hints ); | 533 FT_ZERO( hints ); |
| 512 hints->memory = memory; | 534 hints->memory = memory; |
| 513 } | 535 } |
| 514 | 536 |
| 515 | 537 |
| 516 FT_LOCAL_DEF( void ) | 538 FT_LOCAL_DEF( void ) |
| 517 af_glyph_hints_done( AF_GlyphHints hints ) | 539 af_glyph_hints_done( AF_GlyphHints hints ) |
| 518 { | 540 { |
| 519 if ( hints && hints->memory ) | 541 FT_Memory memory = hints->memory; |
| 520 { | 542 int dim; |
| 521 FT_Memory memory = hints->memory; | |
| 522 int dim; | |
| 523 | 543 |
| 524 | 544 |
| 525 /* | 545 if ( !( hints && hints->memory ) ) |
| 526 * note that we don't need to free the segment and edge | 546 return; |
| 527 * buffers since they are really within the hints->points array | 547 |
| 528 */ | 548 /* |
| 529 for ( dim = 0; dim < AF_DIMENSION_MAX; dim++ ) | 549 * note that we don't need to free the segment and edge |
| 530 { | 550 * buffers since they are really within the hints->points array |
| 531 AF_AxisHints axis = &hints->axis[dim]; | 551 */ |
| 552 for ( dim = 0; dim < AF_DIMENSION_MAX; dim++ ) |
| 553 { |
| 554 AF_AxisHints axis = &hints->axis[dim]; |
| 532 | 555 |
| 533 | 556 |
| 534 axis->num_segments = 0; | 557 axis->num_segments = 0; |
| 535 axis->max_segments = 0; | 558 axis->max_segments = 0; |
| 536 FT_FREE( axis->segments ); | 559 FT_FREE( axis->segments ); |
| 537 | 560 |
| 538 axis->num_edges = 0; | 561 axis->num_edges = 0; |
| 539 axis->max_edges = 0; | 562 axis->max_edges = 0; |
| 540 FT_FREE( axis->edges ); | 563 FT_FREE( axis->edges ); |
| 541 } | 564 } |
| 542 | 565 |
| 543 FT_FREE( hints->contours ); | 566 FT_FREE( hints->contours ); |
| 544 hints->max_contours = 0; | 567 hints->max_contours = 0; |
| 545 hints->num_contours = 0; | 568 hints->num_contours = 0; |
| 546 | 569 |
| 547 FT_FREE( hints->points ); | 570 FT_FREE( hints->points ); |
| 548 hints->num_points = 0; | 571 hints->num_points = 0; |
| 549 hints->max_points = 0; | 572 hints->max_points = 0; |
| 550 | 573 |
| 551 hints->memory = NULL; | 574 hints->memory = NULL; |
| 552 } | |
| 553 } | 575 } |
| 554 | 576 |
| 555 | 577 |
| 556 /* Reset metrics. */ | 578 /* Reset metrics. */ |
| 557 | 579 |
| 558 FT_LOCAL_DEF( void ) | 580 FT_LOCAL_DEF( void ) |
| 559 af_glyph_hints_rescale( AF_GlyphHints hints, | 581 af_glyph_hints_rescale( AF_GlyphHints hints, |
| 560 AF_ScriptMetrics metrics ) | 582 AF_ScriptMetrics metrics ) |
| 561 { | 583 { |
| 562 hints->metrics = metrics; | 584 hints->metrics = metrics; |
| 563 hints->scaler_flags = metrics->scaler.flags; | 585 hints->scaler_flags = metrics->scaler.flags; |
| 564 } | 586 } |
| 565 | 587 |
| 566 | 588 |
| 567 /* Recompute all AF_Point in AF_GlyphHints from the definitions */ | 589 /* Recompute all AF_Point in AF_GlyphHints from the definitions */ |
| 568 /* in a source outline. */ | 590 /* in a source outline. */ |
| 569 | 591 |
| 570 FT_LOCAL_DEF( FT_Error ) | 592 FT_LOCAL_DEF( FT_Error ) |
| 571 af_glyph_hints_reload( AF_GlyphHints hints, | 593 af_glyph_hints_reload( AF_GlyphHints hints, |
| 572 FT_Outline* outline ) | 594 FT_Outline* outline ) |
| 573 { | 595 { |
| 574 FT_Error error = AF_Err_Ok; | 596 FT_Error error = FT_Err_Ok; |
| 575 AF_Point points; | 597 AF_Point points; |
| 576 FT_UInt old_max, new_max; | 598 FT_UInt old_max, new_max; |
| 577 FT_Fixed x_scale = hints->x_scale; | 599 FT_Fixed x_scale = hints->x_scale; |
| 578 FT_Fixed y_scale = hints->y_scale; | 600 FT_Fixed y_scale = hints->y_scale; |
| 579 FT_Pos x_delta = hints->x_delta; | 601 FT_Pos x_delta = hints->x_delta; |
| 580 FT_Pos y_delta = hints->y_delta; | 602 FT_Pos y_delta = hints->y_delta; |
| 581 FT_Memory memory = hints->memory; | 603 FT_Memory memory = hints->memory; |
| 582 | 604 |
| 583 | 605 |
| 584 hints->num_points = 0; | 606 hints->num_points = 0; |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 738 | 760 |
| 739 next = point->next; | 761 next = point->next; |
| 740 out_x = next->fx - point->fx; | 762 out_x = next->fx - point->fx; |
| 741 out_y = next->fy - point->fy; | 763 out_y = next->fy - point->fy; |
| 742 | 764 |
| 743 in_dir = af_direction_compute( out_x, out_y ); | 765 in_dir = af_direction_compute( out_x, out_y ); |
| 744 point->out_dir = (FT_Char)in_dir; | 766 point->out_dir = (FT_Char)in_dir; |
| 745 | 767 |
| 746 /* check for weak points */ | 768 /* check for weak points */ |
| 747 | 769 |
| 748 if ( point->flags & ( AF_FLAG_CONIC | AF_FLAG_CUBIC ) ) | 770 if ( point->flags & AF_FLAG_CONTROL ) |
| 749 { | 771 { |
| 750 Is_Weak_Point: | 772 Is_Weak_Point: |
| 751 point->flags |= AF_FLAG_WEAK_INTERPOLATION; | 773 point->flags |= AF_FLAG_WEAK_INTERPOLATION; |
| 752 } | 774 } |
| 753 else if ( point->out_dir == point->in_dir ) | 775 else if ( point->out_dir == point->in_dir ) |
| 754 { | 776 { |
| 755 if ( point->out_dir != AF_DIR_NONE ) | 777 if ( point->out_dir != AF_DIR_NONE ) |
| 756 goto Is_Weak_Point; | 778 goto Is_Weak_Point; |
| 757 | 779 |
| 758 if ( ft_corner_is_flat( in_x, in_y, out_x, out_y ) ) | 780 if ( ft_corner_is_flat( in_x, in_y, out_x, out_y ) ) |
| (...skipping 531 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1290 else | 1312 else |
| 1291 { | 1313 { |
| 1292 for ( point = points; point < points_limit; point++ ) | 1314 for ( point = points; point < points_limit; point++ ) |
| 1293 point->y = FT_MulFix( point->fy, scale ) + delta; | 1315 point->y = FT_MulFix( point->fy, scale ) + delta; |
| 1294 } | 1316 } |
| 1295 } | 1317 } |
| 1296 | 1318 |
| 1297 #endif /* AF_CONFIG_OPTION_USE_WARPER */ | 1319 #endif /* AF_CONFIG_OPTION_USE_WARPER */ |
| 1298 | 1320 |
| 1299 /* END */ | 1321 /* END */ |
| OLD | NEW |