summaryrefslogtreecommitdiffstats
path: root/src/autofit/aflatin2.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/autofit/aflatin2.c')
-rw-r--r--src/autofit/aflatin2.c76
1 files changed, 64 insertions, 12 deletions
diff --git a/src/autofit/aflatin2.c b/src/autofit/aflatin2.c
index 14327b1..f58ef38 100644
--- a/src/autofit/aflatin2.c
+++ b/src/autofit/aflatin2.c
@@ -4,7 +4,7 @@
/* */
/* Auto-fitter hinting routines for latin script (body). */
/* */
-/* Copyright 2003, 2004, 2005, 2006, 2007, 2008 by */
+/* Copyright 2003, 2004, 2005, 2006, 2007, 2008, 2009 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -16,6 +16,8 @@
/***************************************************************************/
+#include FT_ADVANCES_H
+
#include "aflatin.h"
#include "aflatin2.h"
#include "aferrors.h"
@@ -154,7 +156,7 @@
#define AF_LATIN_MAX_TEST_CHARACTERS 12
- static const char* const af_latin2_blue_chars[AF_LATIN_MAX_BLUES] =
+ static const char af_latin2_blue_chars[AF_LATIN_MAX_BLUES][AF_LATIN_MAX_TEST_CHARACTERS+1] =
{
"THEZOCQS",
"HEZLOCUS",
@@ -336,7 +338,7 @@
* we couldn't find a single glyph to compute this blue zone,
* we will simply ignore it then
*/
- AF_LOG(( "empty!\n" ));
+ AF_LOG(( "empty\n" ));
continue;
}
@@ -401,6 +403,52 @@
}
+ FT_LOCAL_DEF( void )
+ af_latin2_metrics_check_digits( AF_LatinMetrics metrics,
+ FT_Face face )
+ {
+ FT_UInt i;
+ FT_Bool started = 0, same_width = 1;
+ FT_Fixed advance, old_advance = 0;
+
+
+ /* check whether all ASCII digits have the same advance width; */
+ /* digit `0' is 0x30 in all supported charmaps */
+ for ( i = 0x30; i <= 0x39; i++ )
+ {
+ FT_UInt glyph_index;
+
+
+ glyph_index = FT_Get_Char_Index( face, i );
+ if ( glyph_index == 0 )
+ continue;
+
+ if ( FT_Get_Advance( face, glyph_index,
+ FT_LOAD_NO_SCALE |
+ FT_LOAD_NO_HINTING |
+ FT_LOAD_IGNORE_TRANSFORM,
+ &advance ) )
+ continue;
+
+ if ( started )
+ {
+ if ( advance != old_advance )
+ {
+ same_width = 0;
+ break;
+ }
+ }
+ else
+ {
+ old_advance = advance;
+ started = 1;
+ }
+ }
+
+ metrics->root.digits_have_same_width = same_width;
+ }
+
+
FT_LOCAL_DEF( FT_Error )
af_latin2_metrics_init( AF_LatinMetrics metrics,
FT_Face face )
@@ -434,6 +482,7 @@
/* For now, compute the standard width and height from the `o'. */
af_latin2_metrics_init_widths( metrics, face, 'o' );
af_latin2_metrics_init_blues( metrics, face );
+ af_latin2_metrics_check_digits( metrics, face );
}
FT_Set_Charmap( face, oldmap );
@@ -1739,7 +1788,6 @@
AF_AxisHints axis = &hints->axis[dim];
AF_Edge edges = axis->edges;
AF_Edge edge_limit = edges + axis->num_edges;
- FT_Int n_edges;
AF_Edge edge;
AF_Edge anchor = 0;
FT_Int has_serifs = 0;
@@ -2050,8 +2098,12 @@
/* We don't handle horizontal edges since we can't easily assure that */
/* the third (lowest) stem aligns with the base line; it might end up */
/* one pixel higher or lower. */
+
#if 0
- n_edges = edge_limit - edges;
+ {
+ FT_Int n_edges = edge_limit - edges;
+
+
if ( dim == AF_DIMENSION_HORZ && ( n_edges == 6 || n_edges == 12 ) )
{
AF_Edge edge1, edge2, edge3;
@@ -2097,7 +2149,9 @@
edge3->link->flags |= AF_EDGE_DONE;
}
}
+ }
#endif
+
if ( has_serifs || !anchor )
{
/*
@@ -2266,15 +2320,13 @@
static const AF_Script_UniRangeRec af_latin2_uniranges[] =
{
- { 32, 127 }, /* XXX: TODO: Add new Unicode ranges here! */
- { 160, 255 },
- { 0, 0 }
+ AF_UNIRANGE_REC( 32UL, 127UL ), /* XXX: TODO: Add new Unicode ranges here! */
+ AF_UNIRANGE_REC( 160UL, 255UL ),
+ AF_UNIRANGE_REC( 0UL, 0UL )
};
- FT_CALLBACK_TABLE_DEF const AF_ScriptClassRec
- af_latin2_script_class =
- {
+ AF_DEFINE_SCRIPT_CLASS(af_latin2_script_class,
AF_SCRIPT_LATIN2,
af_latin2_uniranges,
@@ -2286,7 +2338,7 @@
(AF_Script_InitHintsFunc) af_latin2_hints_init,
(AF_Script_ApplyHintsFunc) af_latin2_hints_apply
- };
+ )
/* END */