1 |
|
/***************************************************************************/ |
2 |
|
/* */ |
3 |
|
/* afhints.c */ |
4 |
|
/* */ |
5 |
|
/* Auto-fitter hinting routines (body). */ |
6 |
|
/* */ |
7 |
|
/* Copyright 2003, 2004, 2005 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 |
#include "afhints.h" |
#include "afhints.h" |
20 |
|
|
21 |
|
|
24 |
FT_Memory memory, |
FT_Memory memory, |
25 |
AF_Segment *asegment ) |
AF_Segment *asegment ) |
26 |
{ |
{ |
27 |
FT_Error error = 0; |
FT_Error error = FT_Err_Ok; |
28 |
AF_Segment segment = NULL; |
AF_Segment segment = NULL; |
29 |
|
|
30 |
|
|
60 |
} |
} |
61 |
|
|
62 |
|
|
63 |
FT_LOCAL( FT_Error) |
FT_LOCAL( FT_Error ) |
64 |
af_axis_hints_new_edge( AF_AxisHints axis, |
af_axis_hints_new_edge( AF_AxisHints axis, |
65 |
FT_Int fpos, |
FT_Int fpos, |
66 |
FT_Memory memory, |
FT_Memory memory, |
67 |
AF_Edge *aedge ) |
AF_Edge *aedge ) |
68 |
{ |
{ |
69 |
FT_Error error = 0; |
FT_Error error = FT_Err_Ok; |
70 |
AF_Edge edge = NULL; |
AF_Edge edge = NULL; |
71 |
AF_Edge edges; |
AF_Edge edges; |
72 |
|
|
304 |
/* do each contour separately */ |
/* do each contour separately */ |
305 |
for ( ; contour < contour_limit; contour++ ) |
for ( ; contour < contour_limit; contour++ ) |
306 |
{ |
{ |
307 |
AF_Point point = contour[0]; |
AF_Point point = contour[0]; |
308 |
AF_Point first = point; |
AF_Point first = point; |
309 |
AF_Point start = point; |
AF_Point start = point; |
310 |
AF_Point end = point; |
AF_Point end = point; |
311 |
AF_Point before; |
AF_Point before; |
312 |
AF_Point after; |
AF_Point after; |
313 |
AF_Angle angle_in, angle_seg, angle_out; |
AF_Angle angle_in, angle_seg, angle_out; |
314 |
AF_Angle diff_in, diff_out; |
AF_Angle diff_in, diff_out; |
315 |
FT_Int finished = 0; |
FT_Int finished = 0; |
316 |
|
|
317 |
|
|
318 |
/* compute first segment in contour */ |
/* compute first segment in contour */ |
415 |
{ |
{ |
416 |
if ( hints && hints->memory ) |
if ( hints && hints->memory ) |
417 |
{ |
{ |
418 |
FT_Memory memory = hints->memory; |
FT_Memory memory = hints->memory; |
419 |
AF_Dimension dim; |
int dim; |
420 |
|
|
421 |
|
|
422 |
/* |
/* |
423 |
* note that we don't need to free the segment and edge |
* note that we don't need to free the segment and edge |
424 |
* buffers, since they are really within the hints->points array |
* buffers, since they are really within the hints->points array |
425 |
*/ |
*/ |
426 |
for ( dim = 0; dim < 2; dim++ ) |
for ( dim = 0; dim < AF_DIMENSION_MAX; dim++ ) |
427 |
{ |
{ |
428 |
AF_AxisHints axis = &hints->axis[dim]; |
AF_AxisHints axis = &hints->axis[dim]; |
429 |
|
|
473 |
FT_Memory memory = hints->memory; |
FT_Memory memory = hints->memory; |
474 |
|
|
475 |
|
|
476 |
hints->scaler_flags = scaler->flags; |
hints->scaler_flags = scaler->flags; |
477 |
hints->num_points = 0; |
hints->num_points = 0; |
478 |
hints->num_contours = 0; |
hints->num_contours = 0; |
479 |
|
|
480 |
hints->axis[0].num_segments = 0; |
hints->axis[0].num_segments = 0; |
481 |
hints->axis[0].num_edges = 0; |
hints->axis[0].num_edges = 0; |
496 |
} |
} |
497 |
|
|
498 |
/* |
/* |
499 |
* then, reallocate the points arrays if needed -- |
* then reallocate the points arrays if necessary -- |
500 |
* note that we reserve two additional point positions, used to |
* note that we reserve two additional point positions, used to |
501 |
* hint metrics appropriately |
* hint metrics appropriately |
502 |
*/ |
*/ |
565 |
break; |
break; |
566 |
default: |
default: |
567 |
point->flags = 0; |
point->flags = 0; |
|
; |
|
568 |
} |
} |
569 |
} |
} |
570 |
} |
} |
878 |
} |
} |
879 |
|
|
880 |
Store_Point: |
Store_Point: |
|
|
|
881 |
/* save the point position */ |
/* save the point position */ |
882 |
if ( dim == AF_DIMENSION_HORZ ) |
if ( dim == AF_DIMENSION_HORZ ) |
883 |
point->x = u; |
point->x = u; |
986 |
af_glyph_hints_align_weak_points( AF_GlyphHints hints, |
af_glyph_hints_align_weak_points( AF_GlyphHints hints, |
987 |
AF_Dimension dim ) |
AF_Dimension dim ) |
988 |
{ |
{ |
989 |
AF_Point points = hints->points; |
AF_Point points = hints->points; |
990 |
AF_Point point_limit = points + hints->num_points; |
AF_Point point_limit = points + hints->num_points; |
991 |
AF_Point* contour = hints->contours; |
AF_Point* contour = hints->contours; |
992 |
AF_Point* contour_limit = contour + hints->num_contours; |
AF_Point* contour_limit = contour + hints->num_contours; |
993 |
AF_Flags touch_flag; |
AF_Flags touch_flag; |
994 |
AF_Point point; |
AF_Point point; |
995 |
AF_Point end_point; |
AF_Point end_point; |
996 |
AF_Point first_point; |
AF_Point first_point; |
997 |
|
|
998 |
|
|
999 |
/* PASS 1: Move segment points to edge positions */ |
/* PASS 1: Move segment points to edge positions */ |