aboutsummaryrefslogtreecommitdiff
path: root/freetype/src/autofit/afcjk.c
diff options
context:
space:
mode:
Diffstat (limited to 'freetype/src/autofit/afcjk.c')
-rw-r--r--freetype/src/autofit/afcjk.c89
1 files changed, 52 insertions, 37 deletions
diff --git a/freetype/src/autofit/afcjk.c b/freetype/src/autofit/afcjk.c
index 360ecd935..8f2bd00ee 100644
--- a/freetype/src/autofit/afcjk.c
+++ b/freetype/src/autofit/afcjk.c
@@ -4,7 +4,7 @@
/* */
/* Auto-fitter hinting routines for CJK writing system (body). */
/* */
-/* Copyright 2006-2013 by */
+/* Copyright 2006-2014 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -178,6 +178,8 @@
goto Exit;
af_latin_hints_link_segments( hints,
+ 0,
+ NULL,
(AF_Dimension)dim );
seg = axhints->segments;
@@ -261,6 +263,8 @@
FT_Int num_fills;
FT_Int num_flats;
+ FT_Bool fill;
+
AF_CJKBlue blue;
FT_Error error;
AF_CJKAxis axis;
@@ -271,22 +275,6 @@
AF_Blue_Stringset bss = sc->blue_stringset;
const AF_Blue_StringRec* bs = &af_blue_stringsets[bss];
-#ifdef FT_DEBUG_LEVEL_TRACE
- FT_String* cjk_blue_name[4] =
- {
- (FT_String*)"bottom", /* -- , -- */
- (FT_String*)"top", /* -- , TOP */
- (FT_String*)"left", /* HORIZ, -- */
- (FT_String*)"right" /* HORIZ, TOP */
- };
-
- FT_String* cjk_blue_type_name[2] =
- {
- (FT_String*)"unfilled", /* -- */
- (FT_String*)"filled" /* FILL */
- };
-#endif
-
/* we walk over the blue character strings as specified in the */
/* style's entry in the `af_blue_stringset' array, computing its */
@@ -308,15 +296,29 @@
else
axis = &metrics->axis[AF_DIMENSION_VERT];
- FT_TRACE5(( "blue zone %d:\n", axis->blue_count ));
+#ifdef FT_DEBUG_LEVEL_TRACE
+ {
+ FT_String* cjk_blue_name[4] =
+ {
+ (FT_String*)"bottom", /* -- , -- */
+ (FT_String*)"top", /* -- , TOP */
+ (FT_String*)"left", /* HORIZ, -- */
+ (FT_String*)"right" /* HORIZ, TOP */
+ };
+
+
+ FT_TRACE5(( "blue zone %d (%s):\n",
+ axis->blue_count,
+ cjk_blue_name[AF_CJK_IS_HORIZ_BLUE( bs ) |
+ AF_CJK_IS_TOP_BLUE( bs ) ] ));
+ }
+#endif /* FT_DEBUG_LEVEL_TRACE */
num_fills = 0;
num_flats = 0;
- FT_TRACE5(( " cjk blue %s/%s\n",
- cjk_blue_name[AF_CJK_IS_HORIZ_BLUE( bs ) |
- AF_CJK_IS_TOP_BLUE( bs ) ],
- cjk_blue_type_name[!!AF_CJK_IS_FILLED_BLUE( bs )] ));
+ fill = 1; /* start with characters that define fill values */
+ FT_TRACE5(( " [overshoot values]\n" ));
while ( *p )
{
@@ -330,6 +332,14 @@
GET_UTF8_CHAR( ch, p );
+ /* switch to characters that define flat values */
+ if ( ch == '|' )
+ {
+ fill = 0;
+ FT_TRACE5(( " [reference values]\n" ));
+ continue;
+ }
+
/* load the character in the face -- skip unknown or empty ones */
af_get_char_index( &metrics->root, ch, &glyph_index, &y_offset );
if ( glyph_index == 0 )
@@ -417,7 +427,7 @@
FT_TRACE5(( " U+%04lX: best_pos = %5ld\n", ch, best_pos ));
}
- if ( AF_CJK_IS_FILLED_BLUE( bs ) )
+ if ( fill )
fills[num_fills++] = best_pos;
else
flats[num_flats++] = best_pos;
@@ -429,15 +439,15 @@
* 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;
}
- /* we have computed the contents of the `fill' and `flats' tables, */
- /* now determine the reference position of the blue zone -- */
- /* we simply take the median value after a simple sort */
- af_sort_pos( num_flats, flats );
+ /* we have computed the contents of the `fill' and `flats' tables, */
+ /* now determine the reference and overshoot position of the blue -- */
+ /* we simply take the median value after a simple sort */
af_sort_pos( num_fills, fills );
+ af_sort_pos( num_flats, flats );
blue = &axis->blues[axis->blue_count];
blue_ref = &blue->ref.org;
@@ -476,7 +486,7 @@
*blue_ref =
*blue_shoot = ( shoot + ref ) / 2;
- FT_TRACE5(( " [overshoot smaller than reference,"
+ FT_TRACE5(( " [reference smaller than overshoot,"
" taking mean value]\n" ));
}
}
@@ -755,10 +765,6 @@
/* now compare each segment to the others */
for ( seg1 = segments; seg1 < segment_limit; seg1++ )
{
- /* the fake segments are for metrics hinting only */
- if ( seg1->first == seg1->last )
- continue;
-
if ( seg1->dir != major_dir )
continue;
@@ -1018,10 +1024,11 @@
edge->first = seg;
edge->last = seg;
+ edge->dir = seg->dir;
edge->fpos = seg->pos;
- edge->opos = edge->pos = FT_MulFix( seg->pos, scale );
+ edge->opos = FT_MulFix( seg->pos, scale );
+ edge->pos = edge->opos;
seg->edge_next = seg;
- edge->dir = seg->dir;
}
else
{
@@ -1230,8 +1237,10 @@
/* zone, check for left edges */
/* */
/* of course, that's for TrueType */
- is_top_right_blue = FT_BOOL( blue->flags & AF_CJK_BLUE_TOP );
- is_major_dir = FT_BOOL( edge->dir == axis->major_dir );
+ is_top_right_blue =
+ (FT_Byte)( ( blue->flags & AF_CJK_BLUE_TOP ) != 0 );
+ is_major_dir =
+ FT_BOOL( edge->dir == axis->major_dir );
/* if it is a top zone, the edge must be against the major */
/* direction; if it is a bottom zone, it must be in the major */
@@ -1528,6 +1537,12 @@
stem_edge->pos = base_edge->pos + fitted_width;
+
+ FT_TRACE5(( " CJKLINK: edge %d @%d (opos=%.2f) linked to %.2f,"
+ " dist was %.2f, now %.2f\n",
+ stem_edge - hints->axis[dim].edges, stem_edge->fpos,
+ stem_edge->opos / 64.0, stem_edge->pos / 64.0,
+ dist / 64.0, fitted_width / 64.0 ));
}