From 49e18b8d5f7df1c931e07f94615b375a0399162a Mon Sep 17 00:00:00 2001 From: Werner Lemberg Date: Mon, 11 Jun 2007 21:15:09 +0000 Subject: [PATCH] formatting --- ChangeLog | 47 +++++++++++++++++++++++--- src/autofit/afglobal.c | 14 ++++---- src/autofit/afglobal.h | 2 +- src/autofit/afhints.c | 77 +++++++++++++++++++++++------------------- src/autofit/aflatin.c | 11 +++--- src/autofit/afloader.c | 3 +- 6 files changed, 102 insertions(+), 52 deletions(-) diff --git a/ChangeLog b/ChangeLog index 2c71503a..c01e1091 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,12 +1,49 @@ 2007-06-11 David Turner - * src/autofit/aflatin,c: fix incorrect segment linking computation, - this was the root cause of bug #19565. + * src/autofit/aflatin.c (af_latin_hints_link_segments): Fix + incorrect segment linking computation. This was the root cause of + Savannah bug #19565. - * src/autofit/*: some very experimental changes to improve the Latin - auto-hinter. note that the new code is disabled by default since this - is not stablizied yet. + * src/autofit/* [FT_OPTION_AUTOFIT2]: Some very experimental changes + to improve the Latin auto-hinter. Note that the new code is + disabled by default since it is not stabilized yet. + + * src/autofit/aflatin2.c, src/autofit/aflatin2.h: New files + (disabled currently). + + * src/autofit/afhints.c: Remove dead code. + (af_axis_hints_new_edge): Add argument to handle segment directions. + (af_edge_flags_to_string): New function. + (af_glyph_hints_dump_segments, af_glyph_hints_dump_edges): Handle + option flags. + (af_glyph_hints_reload): Add argument to handle inflections. + Simplify. + (af_direction_compute): Fine tuning. + (af_glyph_hints_align_edge_points): Fix logic. + (af_glyph_hints_align_strong_points): Do linear search for small + edge counts. + (af_glyph_hints_align_weak_points): Skip any touched neighbors. + (af_iup_shift): Handle zero `delta'. + + * src/autofit/afhints.h: Updated. + (AF_SORT_SEGMENTS): New macro (disabled). + (AF_AxisHintsRec) [AF_SORT_SEGMENTS]: New member `mid_segments'. + + * src/autofit/afglobal.c (af_face_globals_get_metrics): Add + argument to pass option flags for handling scripts. + * src/autofit/afglobal.h: Updated. + + * src/autofit/afcjk.c: Updated. + * src/autofit/aflatin.c: Updated. + (af_latin_metrics_scale_dim): Don't reduce scale by 2%. + + (af_latin_hints_compute_segments) [AF_HINT_METRICS]: Remove dead code. + (af_latin_hints_compute_edges) [AF_HINT_METRICS]: Remove dead code. + Don't set `edge->dir' + (af_latin_hint_edges): Add more logging. + + * src/autofit/afloader.c: Updated. 2007-06-11 Werner Lemberg diff --git a/src/autofit/afglobal.c b/src/autofit/afglobal.c index 5f16250e..a272d502 100644 --- a/src/autofit/afglobal.c +++ b/src/autofit/afglobal.c @@ -229,10 +229,10 @@ AF_ScriptMetrics metrics = NULL; FT_UInt gidx; AF_ScriptClass clazz; - FT_UInt script = (options & 15); - const FT_UInt script_max = sizeof(af_script_classes)/ - sizeof(af_script_classes[0]); - FT_Error error = AF_Err_Ok; + FT_UInt script = options & 15; + const FT_UInt script_max = sizeof ( af_script_classes ) / + sizeof ( af_script_classes[0] ); + FT_Error error = AF_Err_Ok; if ( gindex >= globals->glyph_count ) @@ -242,11 +242,11 @@ } gidx = script; - if (gidx == 0 || gidx+1 >= script_max) + if ( gidx == 0 || gidx + 1 >= script_max ) gidx = globals->glyph_scripts[gindex]; - clazz = af_script_classes[gidx]; - if (script == 0) + clazz = af_script_classes[gidx]; + if ( script == 0 ) script = clazz->script; metrics = globals->metrics[clazz->script]; diff --git a/src/autofit/afglobal.h b/src/autofit/afglobal.h index b9e88fa4..cf52c087 100644 --- a/src/autofit/afglobal.h +++ b/src/autofit/afglobal.h @@ -5,7 +5,7 @@ /* Auto-fitter routines to compute global hinting values */ /* (specification). */ /* */ -/* Copyright 2003, 2004, 2005 by */ +/* Copyright 2003, 2004, 2005, 2007 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/src/autofit/afhints.c b/src/autofit/afhints.c index 865e643c..48287068 100644 --- a/src/autofit/afhints.c +++ b/src/autofit/afhints.c @@ -101,13 +101,12 @@ while ( edge > edges ) { - if (edge[-1].fpos < fpos) + if ( edge[-1].fpos < fpos ) break; - /* we want the edge with same position and minor direction - * to appear before those in the major one in the list - */ - if (edge[-1].fpos == fpos && dir == axis->major_dir) + /* we want the edge with same position and minor direction */ + /* to appear before those in the major one in the list */ + if ( edge[-1].fpos == fpos && dir == axis->major_dir ) break; edge[0] = edge[-1]; @@ -198,28 +197,31 @@ static const char* af_edge_flags_to_string( AF_Edge_Flags flags ) { - static char temp[32]; - int pos = 0; + static char temp[32]; + int pos = 0; + if ( flags & AF_EDGE_ROUND ) { - memcpy( temp+pos, "round", 5 ); + memcpy( temp + pos, "round", 5 ); pos += 5; } if ( flags & AF_EDGE_SERIF ) { - if (pos > 0) + if ( pos > 0 ) temp[pos++] = ' '; - memcpy( temp+pos, "serif", 5 ); + memcpy( temp + pos, "serif", 5 ); pos += 5; } - if (pos == 0) + if ( pos == 0 ) return "normal"; temp[pos] = 0; + return temp; } + /* A function to dump the array of linked segments. */ void af_glyph_hints_dump_segments( AF_GlyphHints hints ) @@ -244,13 +246,14 @@ { printf ( " [ %5d | %5.2g | %5s | %4d | %5d | %5d | %5d | %s ]\n", seg - segments, - dimension == AF_DIMENSION_HORZ ? (int)seg->first->ox/64.0 : (int)seg->first->oy/64.0, + dimension == AF_DIMENSION_HORZ ? (int)seg->first->ox / 64.0 + : (int)seg->first->oy / 64.0, af_dir_str( (AF_Direction)seg->dir ), AF_INDEX_NUM( seg->link, segments ), AF_INDEX_NUM( seg->serif, segments ), seg->height, seg->height - ( seg->max_coord - seg->min_coord ), - af_edge_flags_to_string(seg->flags)); + af_edge_flags_to_string( seg->flags ) ); } printf( "\n" ); } @@ -285,14 +288,14 @@ printf ( " [ %5d | %5.2g | %5s | %4d |" " %5d | %c | %5.2f | %5.2f | %s ]\n", edge - edges, - (int)edge->opos/64.0, + (int)edge->opos / 64.0, af_dir_str( (AF_Direction)edge->dir ), AF_INDEX_NUM( edge->link, edges ), AF_INDEX_NUM( edge->serif, edges ), edge->blue_edge ? 'y' : 'n', edge->opos / 64.0, edge->pos / 64.0, - af_edge_flags_to_string(edge->flags) ); + af_edge_flags_to_string( edge->flags ) ); } printf( "\n" ); } @@ -367,7 +370,7 @@ } ss *= 14; - if ( FT_ABS(ll) <= FT_ABS(ss) ) + if ( FT_ABS( ll ) <= FT_ABS( ss ) ) dir = AF_DIR_NONE; return dir; @@ -634,13 +637,14 @@ /* compute coordinates & Bezier flags, next and prev */ { - FT_Vector* vec = outline->points; - char* tag = outline->tags; - AF_Point first = points; - AF_Point end = points + outline->contours[0]; - AF_Point prev = end; + FT_Vector* vec = outline->points; + char* tag = outline->tags; + AF_Point first = points; + AF_Point end = points + outline->contours[0]; + AF_Point prev = end; FT_Int contour_index = 0; + for ( point = points; point < point_limit; point++, vec++, tag++ ) { point->fx = (FT_Short)vec->x; @@ -664,7 +668,7 @@ prev->next = point; prev = point; - if (point == end) + if ( point == end ) { if ( ++contour_index < outline->n_contours ) { @@ -699,11 +703,13 @@ FT_Pos in_y = 0; AF_Direction in_dir = AF_DIR_NONE; + for ( point = points; point < point_limit; point++ ) { AF_Point next; FT_Pos out_x, out_y; + if ( point == first ) { prev = first->prev; @@ -713,14 +719,14 @@ first = prev + 1; } - point->in_dir = (FT_Char) in_dir; + point->in_dir = (FT_Char)in_dir; - next = point->next; - out_x = next->fx - point->fx; - out_y = next->fy - point->fy; + next = point->next; + out_x = next->fx - point->fx; + out_y = next->fy - point->fy; in_dir = af_direction_compute( out_x, out_y ); - point->out_dir = (FT_Char) in_dir; + point->out_dir = (FT_Char)in_dir; if ( point->flags & ( AF_FLAG_CONIC | AF_FLAG_CUBIC ) ) { @@ -745,8 +751,9 @@ } } - /* compute inflection points -- disable due to no longer perceived benefits */ - if (0 && get_inflections) + /* compute inflection points -- */ + /* disabled due to no longer perceived benefits */ + if ( 0 && get_inflections ) af_glyph_hints_compute_inflections( hints ); Exit: @@ -1021,7 +1028,7 @@ AF_Point p; FT_Pos delta = ref->u - ref->v; - if (delta == 0) + if ( delta == 0 ) return; for ( p = p1; p < ref; p++ ) @@ -1141,7 +1148,8 @@ for ( ; contour < contour_limit; contour++ ) { - AF_Point first_touched, last_touched; + AF_Point first_touched, last_touched; + point = *contour; end_point = point->prev; @@ -1164,10 +1172,11 @@ for (;;) { - FT_ASSERT( point <= end_point && (point->flags & touch_flag) != 0 ); + FT_ASSERT( point <= end_point && + ( point->flags & touch_flag ) != 0 ); /* skip any touched neighbhours */ - while ( point < end_point && (point[1].flags & touch_flag) != 0 ) + while ( point < end_point && ( point[1].flags & touch_flag ) != 0 ) point++; last_touched = point; @@ -1179,7 +1188,7 @@ if ( point > end_point ) goto EndContour; - if ( (point->flags & touch_flag) != 0 ) + if ( ( point->flags & touch_flag ) != 0 ) break; point++; diff --git a/src/autofit/aflatin.c b/src/autofit/aflatin.c index 6cb670e3..04b4f7b2 100644 --- a/src/autofit/aflatin.c +++ b/src/autofit/aflatin.c @@ -2009,13 +2009,16 @@ FT_MulDiv( edge->opos - before->opos, after->pos - before->pos, after->opos - before->opos ); - AF_LOG(( "SERIF_LINK1: edge %d (opos=%.2f) snapped to (%.2f) from %d (opos=%.2f)\n", - edge-edges, edge->opos / 64.0, edge->pos / 64.0, before - edges, before->opos / 64.0 )); + AF_LOG(( "SERIF_LINK1: edge %d (opos=%.2f) snapped to (%.2f) " + "from %d (opos=%.2f)\n", + edge-edges, edge->opos / 64.0, + edge->pos / 64.0, before - edges, + before->opos / 64.0 )); } else { - edge->pos = anchor->pos + (( edge->opos - anchor->opos + 16) & ~31); - + edge->pos = anchor->pos + + ( ( edge->opos - anchor->opos + 16 ) & ~31 ); AF_LOG(( "SERIF_LINK2: edge %d (opos=%.2f) snapped to (%.2f)\n", edge-edges, edge->opos / 64.0, edge->pos / 64.0 )); } diff --git a/src/autofit/afloader.c b/src/autofit/afloader.c index 44a6f26e..4e4373a4 100644 --- a/src/autofit/afloader.c +++ b/src/autofit/afloader.c @@ -494,9 +494,10 @@ AF_ScriptMetrics metrics; FT_UInt options = 0; + #ifdef FT_OPTION_AUTOFIT2 /* XXX: undocumented hook to activate the latin2 hinter */ - if (load_flags & (1UL << 20)) + if ( load_flags & ( 1UL << 20 ) ) options = 2; #endif