From 09e9b596053e5a4e799a92a160a1f47494aafca8 Mon Sep 17 00:00:00 2001 From: Werner Lemberg Date: Wed, 4 Jul 2012 13:00:06 +0200 Subject: [PATCH] [autofit] Beautify blue zone tracing. * src/autofit/aflatin.c (af_latin_metrics_init_blues), src/autofit/aflatin2.c (af_latin2_metrics_init_blues): Implement it. --- ChangeLog | 7 +++++++ src/autofit/aflatin.c | 25 ++++++++++++++----------- src/autofit/aflatin2.c | 28 ++++++++++++++++------------ 3 files changed, 37 insertions(+), 23 deletions(-) diff --git a/ChangeLog b/ChangeLog index dbe75d8bf..16ad35d0c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2012-07-04 Werner Lemberg + + [autofit] Beautify blue zone tracing. + + * src/autofit/aflatin.c (af_latin_metrics_init_blues), + src/autofit/aflatin2.c (af_latin2_metrics_init_blues): Implement it. + 2012-07-03 Werner Lemberg [autofit] Quantize stem widths. diff --git a/src/autofit/aflatin.c b/src/autofit/aflatin.c index 6ef0dba56..8ccef60f1 100644 --- a/src/autofit/aflatin.c +++ b/src/autofit/aflatin.c @@ -205,8 +205,8 @@ /* `af_latin_blue_chars[blues]' string, then finding its top-most or */ /* bottom-most points (depending on `AF_IS_TOP_BLUE') */ - FT_TRACE5(( "blue zones computation\n" )); - FT_TRACE5(( "------------------------------------------------\n" )); + FT_TRACE5(( "blue zones computation\n" + "======================\n\n" )); for ( bb = 0; bb < AF_LATIN_BLUE_MAX; bb++ ) { @@ -216,7 +216,7 @@ FT_Pos* blue_shoot; - FT_TRACE5(( "blue %3d: ", bb )); + FT_TRACE5(( "blue zone %d:\n", bb )); num_flats = 0; num_rounds = 0; @@ -230,8 +230,6 @@ FT_Bool round = 0; - FT_TRACE5(( "'%c'", *p )); - /* load the character in the face -- skip unknown or empty ones */ glyph_index = FT_Get_Char_Index( face, (FT_UInt)*p ); if ( glyph_index == 0 ) @@ -295,7 +293,7 @@ best_last = last; } } - FT_TRACE5(( "%5d", best_y )); + FT_TRACE5(( " %c %d", *p, best_y )); } /* now check whether the point belongs to a straight or round */ @@ -343,7 +341,7 @@ FT_CURVE_TAG( glyph->outline.tags[prev] ) != FT_CURVE_TAG_ON || FT_CURVE_TAG( glyph->outline.tags[next] ) != FT_CURVE_TAG_ON ); - FT_TRACE5(( "%c ", round ? 'r' : 'f' )); + FT_TRACE5(( " (%s)\n", round ? "round" : "flat" )); } if ( round ) @@ -352,15 +350,13 @@ flats[num_flats++] = best_y; } - FT_TRACE5(( "\n" )); - if ( num_flats == 0 && num_rounds == 0 ) { /* * we couldn't find a single glyph to compute this blue zone, * we will simply ignore it then */ - FT_TRACE5(( "empty\n" )); + FT_TRACE5(( " empty\n" )); continue; } @@ -403,8 +399,13 @@ if ( AF_LATIN_IS_TOP_BLUE( bb ) ^ over_ref ) + { *blue_ref = *blue_shoot = ( shoot + ref ) / 2; + + FT_TRACE5(( " [overshoot smaller than reference," + " taking mean value]\n" )); + } } blue->flags = 0; @@ -419,7 +420,9 @@ if ( bb == AF_LATIN_BLUE_SMALL_TOP ) blue->flags |= AF_LATIN_BLUE_ADJUSTMENT; - FT_TRACE5(( "-- ref = %ld, shoot = %ld\n", *blue_ref, *blue_shoot )); + FT_TRACE5(( " -> reference = %ld\n" + " overshoot = %ld\n", + *blue_ref, *blue_shoot )); } FT_TRACE5(( "\n" )); diff --git a/src/autofit/aflatin2.c b/src/autofit/aflatin2.c index 927cce7b4..50a6f8b74 100644 --- a/src/autofit/aflatin2.c +++ b/src/autofit/aflatin2.c @@ -198,8 +198,8 @@ /* 'af_latin2_blue_chars[blues]' string, then compute its top-most or */ /* bottom-most points (depending on `AF_IS_TOP_BLUE') */ - FT_TRACE5(( "blue zones computation\n" )); - FT_TRACE5(( "------------------------------------------------\n" )); + FT_TRACE5(( "blue zones computation\n" + "======================\n\n" )); for ( bb = 0; bb < AF_LATIN_BLUE_MAX; bb++ ) { @@ -209,7 +209,7 @@ FT_Pos* blue_shoot; - FT_TRACE5(( "blue %3d: ", bb )); + FT_TRACE5(( "blue zone %d:\n", bb )); num_flats = 0; num_rounds = 0; @@ -222,8 +222,6 @@ FT_Bool round; - FT_TRACE5(( "'%c'", *p )); - /* load the character in the face -- skip unknown or empty ones */ glyph_index = FT_Get_Char_Index( face, (FT_UInt)*p ); if ( glyph_index == 0 ) @@ -285,7 +283,7 @@ best_last = last; } } - FT_TRACE5(( "%5d", best_y )); + FT_TRACE5(( " %c %d", *p, best_y )); } /* now check whether the point belongs to a straight or round */ @@ -333,7 +331,7 @@ FT_CURVE_TAG( glyph->outline.tags[start] ) != FT_CURVE_TAG_ON || FT_CURVE_TAG( glyph->outline.tags[ end ] ) != FT_CURVE_TAG_ON ); - FT_TRACE5(( "%c ", round ? 'r' : 'f' )); + FT_TRACE5(( " (%s)\n", round ? "round" : "flat" )); } if ( round ) @@ -342,15 +340,13 @@ flats[num_flats++] = best_y; } - FT_TRACE5(( "\n" )); - if ( num_flats == 0 && num_rounds == 0 ) { /* * we couldn't find a single glyph to compute this blue zone, * we will simply ignore it then */ - FT_TRACE5(( "empty\n" )); + FT_TRACE5(( " empty\n" )); continue; } @@ -393,7 +389,13 @@ if ( AF_LATIN_IS_TOP_BLUE( bb ) ^ over_ref ) - *blue_shoot = *blue_ref = ( shoot + ref ) / 2; + { + *blue_ref = + *blue_shoot = ( shoot + ref ) / 2; + + FT_TRACE5(( " [overshoot smaller than reference," + " taking mean value]\n" )); + } } blue->flags = 0; @@ -408,7 +410,9 @@ if ( bb == AF_LATIN_BLUE_SMALL_TOP ) blue->flags |= AF_LATIN_BLUE_ADJUSTMENT; - FT_TRACE5(( "-- ref = %ld, shoot = %ld\n", *blue_ref, *blue_shoot )); + FT_TRACE5(( " -> reference = %ld\n" + " overshoot = %ld\n", + *blue_ref, *blue_shoot )); } return;