summaryrefslogtreecommitdiff
path: root/src/freetype2/autofit
diff options
context:
space:
mode:
authorscuri <scuri>2009-10-20 17:20:18 +0000
committerscuri <scuri>2009-10-20 17:20:18 +0000
commit27a4f9c4ac45ff65f941964f7351b64b1e6a9f35 (patch)
tree2f68c5d9ce5bf6cbc320ac17aef0a65a3ceb99a1 /src/freetype2/autofit
parent2b70507615b2611fce4294c65bec7264644e2665 (diff)
*** empty log message ***
Diffstat (limited to 'src/freetype2/autofit')
-rw-r--r--src/freetype2/autofit/afcjk.c96
-rw-r--r--src/freetype2/autofit/afcjk.h22
-rw-r--r--src/freetype2/autofit/afdummy.c6
-rw-r--r--src/freetype2/autofit/afdummy.h3
-rw-r--r--src/freetype2/autofit/afglobal.c67
-rw-r--r--src/freetype2/autofit/afglobal.h8
-rw-r--r--src/freetype2/autofit/afhints.c19
-rw-r--r--src/freetype2/autofit/afhints.h10
-rw-r--r--src/freetype2/autofit/afindic.c26
-rw-r--r--src/freetype2/autofit/afindic.h3
-rw-r--r--src/freetype2/autofit/aflatin.c133
-rw-r--r--src/freetype2/autofit/aflatin.h9
-rw-r--r--src/freetype2/autofit/aflatin2.c150
-rw-r--r--src/freetype2/autofit/aflatin2.h3
-rw-r--r--src/freetype2/autofit/afloader.c55
-rw-r--r--src/freetype2/autofit/afmodule.c15
-rw-r--r--src/freetype2/autofit/afmodule.h4
-rw-r--r--src/freetype2/autofit/afpic.c92
-rw-r--r--src/freetype2/autofit/afpic.h64
-rw-r--r--src/freetype2/autofit/aftypes.h66
-rw-r--r--src/freetype2/autofit/autofit.c1
21 files changed, 620 insertions, 232 deletions
diff --git a/src/freetype2/autofit/afcjk.c b/src/freetype2/autofit/afcjk.c
index c7ca266..bab0c42 100644
--- a/src/freetype2/autofit/afcjk.c
+++ b/src/freetype2/autofit/afcjk.c
@@ -4,7 +4,7 @@
/* */
/* Auto-fitter hinting routines for CJK script (body). */
/* */
-/* Copyright 2006, 2007 by */
+/* Copyright 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, */
@@ -45,7 +45,7 @@
/*************************************************************************/
/*************************************************************************/
- static FT_Error
+ FT_LOCAL_DEF( FT_Error )
af_cjk_metrics_init( AF_LatinMetrics metrics,
FT_Face face )
{
@@ -58,9 +58,12 @@
if ( FT_Select_Charmap( face, FT_ENCODING_UNICODE ) )
face->charmap = NULL;
-
- /* latin's version would suffice */
- af_latin_metrics_init_widths( metrics, face, 0x7530 );
+ else
+ {
+ /* latin's version would suffice */
+ af_latin_metrics_init_widths( metrics, face, 0x7530 );
+ af_latin_metrics_check_digits( metrics, face );
+ }
FT_Set_Charmap( face, oldmap );
@@ -91,7 +94,7 @@
}
- static void
+ FT_LOCAL_DEF( void )
af_cjk_metrics_scale( AF_LatinMetrics metrics,
AF_Scaler scaler )
{
@@ -427,7 +430,9 @@
/* insert a new edge in the list and */
/* sort according to the position */
- error = af_axis_hints_new_edge( axis, seg->pos, seg->dir, memory, &edge );
+ error = af_axis_hints_new_edge( axis, seg->pos,
+ (AF_Direction)seg->dir,
+ memory, &edge );
if ( error )
goto Exit;
@@ -596,7 +601,7 @@
}
- static FT_Error
+ FT_LOCAL_DEF( FT_Error )
af_cjk_hints_init( AF_GlyphHints hints,
AF_LatinMetrics metrics )
{
@@ -1015,7 +1020,7 @@
AF_AxisHints axis = &hints->axis[dim];
AF_Edge edges = axis->edges;
AF_Edge edge_limit = edges + axis->num_edges;
- FT_Int n_edges;
+ FT_PtrDist n_edges;
AF_Edge edge;
AF_Edge anchor = 0;
FT_Pos delta = 0;
@@ -1251,10 +1256,15 @@
else if ( after >= edge_limit )
af_cjk_align_serif_edge( hints, before, edge );
else
- edge->pos = before->pos +
- FT_MulDiv( edge->fpos - before->fpos,
- after->pos - before->pos,
- after->fpos - before->fpos );
+ {
+ if ( after->fpos == before->fpos )
+ edge->pos = before->pos;
+ else
+ edge->pos = before->pos +
+ FT_MulDiv( edge->fpos - before->fpos,
+ after->pos - before->pos,
+ after->fpos - before->fpos );
+ }
}
}
}
@@ -1350,7 +1360,7 @@
}
- static FT_Error
+ FT_LOCAL_DEF( FT_Error )
af_cjk_hints_apply( AF_GlyphHints hints,
FT_Outline* outline,
AF_LatinMetrics metrics )
@@ -1434,35 +1444,33 @@
static const AF_Script_UniRangeRec af_cjk_uniranges[] =
{
#if 0
- { 0x0100, 0xFFFF }, /* why this? */
+ AF_UNIRANGE_REC( 0x0100UL, 0xFFFFUL ), /* why this? */
#endif
- { 0x2E80, 0x2EFF }, /* CJK Radicals Supplement */
- { 0x2F00, 0x2FDF }, /* Kangxi Radicals */
- { 0x3000, 0x303F }, /* CJK Symbols and Punctuation */
- { 0x3040, 0x309F }, /* Hiragana */
- { 0x30A0, 0x30FF }, /* Katakana */
- { 0x3100, 0x312F }, /* Bopomofo */
- { 0x3130, 0x318F }, /* Hangul Compatibility Jamo */
- { 0x31A0, 0x31BF }, /* Bopomofo Extended */
- { 0x31C0, 0x31EF }, /* CJK Strokes */
- { 0x31F0, 0x31FF }, /* Katakana Phonetic Extensions */
- { 0x3200, 0x32FF }, /* Enclosed CJK Letters and Months */
- { 0x3300, 0x33FF }, /* CJK Compatibility */
- { 0x3400, 0x4DBF }, /* CJK Unified Ideographs Extension A */
- { 0x4DC0, 0x4DFF }, /* Yijing Hexagram Symbols */
- { 0x4E00, 0x9FFF }, /* CJK Unified Ideographs */
- { 0xF900, 0xFAFF }, /* CJK Compatibility Ideographs */
- { 0xFE30, 0xFE4F }, /* CJK Compatibility Forms */
- { 0xFF00, 0xFFEF }, /* Halfwidth and Fullwidth Forms */
- { 0x20000, 0x2A6DF }, /* CJK Unified Ideographs Extension B */
- { 0x2F800, 0x2FA1F }, /* CJK Compatibility Ideographs Supplement */
- { 0, 0 }
+ AF_UNIRANGE_REC( 0x2E80UL, 0x2EFFUL ), /* CJK Radicals Supplement */
+ AF_UNIRANGE_REC( 0x2F00UL, 0x2FDFUL ), /* Kangxi Radicals */
+ AF_UNIRANGE_REC( 0x3000UL, 0x303FUL ), /* CJK Symbols and Punctuation */
+ AF_UNIRANGE_REC( 0x3040UL, 0x309FUL ), /* Hiragana */
+ AF_UNIRANGE_REC( 0x30A0UL, 0x30FFUL ), /* Katakana */
+ AF_UNIRANGE_REC( 0x3100UL, 0x312FUL ), /* Bopomofo */
+ AF_UNIRANGE_REC( 0x3130UL, 0x318FUL ), /* Hangul Compatibility Jamo */
+ AF_UNIRANGE_REC( 0x31A0UL, 0x31BFUL ), /* Bopomofo Extended */
+ AF_UNIRANGE_REC( 0x31C0UL, 0x31EFUL ), /* CJK Strokes */
+ AF_UNIRANGE_REC( 0x31F0UL, 0x31FFUL ), /* Katakana Phonetic Extensions */
+ AF_UNIRANGE_REC( 0x3200UL, 0x32FFUL ), /* Enclosed CJK Letters and Months */
+ AF_UNIRANGE_REC( 0x3300UL, 0x33FFUL ), /* CJK Compatibility */
+ AF_UNIRANGE_REC( 0x3400UL, 0x4DBFUL ), /* CJK Unified Ideographs Extension A */
+ AF_UNIRANGE_REC( 0x4DC0UL, 0x4DFFUL ), /* Yijing Hexagram Symbols */
+ AF_UNIRANGE_REC( 0x4E00UL, 0x9FFFUL ), /* CJK Unified Ideographs */
+ AF_UNIRANGE_REC( 0xF900UL, 0xFAFFUL ), /* CJK Compatibility Ideographs */
+ AF_UNIRANGE_REC( 0xFE30UL, 0xFE4FUL ), /* CJK Compatibility Forms */
+ AF_UNIRANGE_REC( 0xFF00UL, 0xFFEFUL ), /* Halfwidth and Fullwidth Forms */
+ AF_UNIRANGE_REC( 0x20000UL, 0x2A6DFUL ), /* CJK Unified Ideographs Extension B */
+ AF_UNIRANGE_REC( 0x2F800UL, 0x2FA1FUL ), /* CJK Compatibility Ideographs Supplement */
+ AF_UNIRANGE_REC( 0UL, 0UL )
};
- FT_CALLBACK_TABLE_DEF const AF_ScriptClassRec
- af_cjk_script_class =
- {
+ AF_DEFINE_SCRIPT_CLASS(af_cjk_script_class,
AF_SCRIPT_CJK,
af_cjk_uniranges,
@@ -1474,19 +1482,17 @@
(AF_Script_InitHintsFunc) af_cjk_hints_init,
(AF_Script_ApplyHintsFunc) af_cjk_hints_apply
- };
+ )
#else /* !AF_CONFIG_OPTION_CJK */
static const AF_Script_UniRangeRec af_cjk_uniranges[] =
{
- { 0, 0 }
+ AF_UNIRANGE_REC( 0UL, 0UL )
};
- FT_CALLBACK_TABLE_DEF const AF_ScriptClassRec
- af_cjk_script_class =
- {
+ AF_DEFINE_SCRIPT_CLASS(af_cjk_script_class,
AF_SCRIPT_CJK,
af_cjk_uniranges,
@@ -1498,7 +1504,7 @@
(AF_Script_InitHintsFunc) NULL,
(AF_Script_ApplyHintsFunc) NULL
- };
+ )
#endif /* !AF_CONFIG_OPTION_CJK */
diff --git a/src/freetype2/autofit/afcjk.h b/src/freetype2/autofit/afcjk.h
index 0de4a5a..0b20d4a 100644
--- a/src/freetype2/autofit/afcjk.h
+++ b/src/freetype2/autofit/afcjk.h
@@ -4,7 +4,7 @@
/* */
/* Auto-fitter hinting routines for CJK script (specification). */
/* */
-/* Copyright 2006 by */
+/* Copyright 2006, 2007 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -27,10 +27,26 @@ FT_BEGIN_HEADER
/* the CJK-specific script class */
- FT_CALLBACK_TABLE const AF_ScriptClassRec
- af_cjk_script_class;
+ AF_DECLARE_SCRIPT_CLASS(af_cjk_script_class)
+ FT_LOCAL( FT_Error )
+ af_cjk_metrics_init( AF_LatinMetrics metrics,
+ FT_Face face );
+
+ FT_LOCAL( void )
+ af_cjk_metrics_scale( AF_LatinMetrics metrics,
+ AF_Scaler scaler );
+
+ FT_LOCAL( FT_Error )
+ af_cjk_hints_init( AF_GlyphHints hints,
+ AF_LatinMetrics metrics );
+
+ FT_LOCAL( FT_Error )
+ af_cjk_hints_apply( AF_GlyphHints hints,
+ FT_Outline* outline,
+ AF_LatinMetrics metrics );
+
/* */
FT_END_HEADER
diff --git a/src/freetype2/autofit/afdummy.c b/src/freetype2/autofit/afdummy.c
index ed96e96..42b2fcb 100644
--- a/src/freetype2/autofit/afdummy.c
+++ b/src/freetype2/autofit/afdummy.c
@@ -42,9 +42,7 @@
}
- FT_CALLBACK_TABLE_DEF const AF_ScriptClassRec
- af_dummy_script_class =
- {
+ AF_DEFINE_SCRIPT_CLASS(af_dummy_script_class,
AF_SCRIPT_NONE,
NULL,
@@ -56,7 +54,7 @@
(AF_Script_InitHintsFunc) af_dummy_hints_init,
(AF_Script_ApplyHintsFunc) af_dummy_hints_apply
- };
+ )
/* END */
diff --git a/src/freetype2/autofit/afdummy.h b/src/freetype2/autofit/afdummy.h
index 2a5faf8..b69ef43 100644
--- a/src/freetype2/autofit/afdummy.h
+++ b/src/freetype2/autofit/afdummy.h
@@ -29,8 +29,7 @@ FT_BEGIN_HEADER
* be performed. This is the default for non-latin glyphs!
*/
- FT_CALLBACK_TABLE const AF_ScriptClassRec
- af_dummy_script_class;
+ AF_DECLARE_SCRIPT_CLASS(af_dummy_script_class)
/* */
diff --git a/src/freetype2/autofit/afglobal.c b/src/freetype2/autofit/afglobal.c
index ad3baa1..ac29361 100644
--- a/src/freetype2/autofit/afglobal.c
+++ b/src/freetype2/autofit/afglobal.c
@@ -4,7 +4,7 @@
/* */
/* Auto-fitter routines to compute global hinting values (body). */
/* */
-/* Copyright 2003, 2004, 2005, 2006, 2007 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, */
@@ -21,6 +21,7 @@
#include "aflatin.h"
#include "afcjk.h"
#include "afindic.h"
+#include "afpic.h"
#include "aferrors.h"
@@ -28,6 +29,11 @@
#include "aflatin2.h"
#endif
+#ifndef FT_CONFIG_OPTION_PIC
+
+/* when updating this table, don't forget to update
+ AF_SCRIPT_CLASSES_COUNT and autofit_module_class_pic_init */
+
/* populate this list when you add new scripts */
static AF_ScriptClass const af_script_classes[] =
{
@@ -41,10 +47,14 @@
NULL /* do not remove */
};
+#endif /* FT_CONFIG_OPTION_PIC */
+
/* index of default script in `af_script_classes' */
#define AF_SCRIPT_LIST_DEFAULT 2
- /* indicates an uncovered glyph */
-#define AF_SCRIPT_LIST_NONE 255
+ /* a bit mask indicating an uncovered glyph */
+#define AF_SCRIPT_LIST_NONE 0x7F
+ /* if this flag is set, we have an ASCII digit */
+#define AF_DIGIT 0x80
/*
@@ -55,7 +65,7 @@
typedef struct AF_FaceGlobalsRec_
{
FT_Face face;
- FT_UInt glyph_count; /* same as face->num_glyphs */
+ FT_Long glyph_count; /* same as face->num_glyphs */
FT_Byte* glyph_scripts;
AF_ScriptMetrics metrics[AF_SCRIPT_MAX];
@@ -72,7 +82,7 @@
FT_Face face = globals->face;
FT_CharMap old_charmap = face->charmap;
FT_Byte* gscripts = globals->glyph_scripts;
- FT_UInt ss;
+ FT_UInt ss, i;
/* the value 255 means `uncovered glyph' */
@@ -84,17 +94,17 @@
if ( error )
{
/*
- * Ignore this error; we simply use Latin as the standard
- * script. XXX: Shouldn't we rather disable hinting?
+ * Ignore this error; we simply use the default script.
+ * XXX: Shouldn't we rather disable hinting?
*/
error = AF_Err_Ok;
goto Exit;
}
/* scan each script in a Unicode charmap */
- for ( ss = 0; af_script_classes[ss]; ss++ )
+ for ( ss = 0; AF_SCRIPT_CLASSES_GET[ss]; ss++ )
{
- AF_ScriptClass clazz = af_script_classes[ss];
+ AF_ScriptClass clazz = AF_SCRIPT_CLASSES_GET[ss];
AF_Script_UniRange range;
@@ -114,7 +124,7 @@
gindex = FT_Get_Char_Index( face, charcode );
if ( gindex != 0 &&
- gindex < globals->glyph_count &&
+ gindex < (FT_ULong)globals->glyph_count &&
gscripts[gindex] == AF_SCRIPT_LIST_NONE )
{
gscripts[gindex] = (FT_Byte)ss;
@@ -127,7 +137,7 @@
if ( gindex == 0 || charcode > range->last )
break;
- if ( gindex < globals->glyph_count &&
+ if ( gindex < (FT_ULong)globals->glyph_count &&
gscripts[gindex] == AF_SCRIPT_LIST_NONE )
{
gscripts[gindex] = (FT_Byte)ss;
@@ -136,13 +146,23 @@
}
}
+ /* mark ASCII digits */
+ for ( i = 0x30; i <= 0x39; i++ )
+ {
+ FT_UInt gindex = FT_Get_Char_Index( face, i );
+
+
+ if ( gindex != 0 && gindex < (FT_ULong)globals->glyph_count )
+ gscripts[gindex] |= AF_DIGIT;
+ }
+
Exit:
/*
* By default, all uncovered glyphs are set to the latin script.
* XXX: Shouldn't we disable hinting or do something similar?
*/
{
- FT_UInt nn;
+ FT_Long nn;
for ( nn = 0; nn < globals->glyph_count; nn++ )
@@ -201,7 +221,7 @@
{
if ( globals->metrics[nn] )
{
- AF_ScriptClass clazz = af_script_classes[nn];
+ AF_ScriptClass clazz = AF_SCRIPT_CLASSES_GET[nn];
FT_ASSERT( globals->metrics[nn]->clazz == clazz );
@@ -232,12 +252,12 @@
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] );
+ const FT_Offset script_max = sizeof ( AF_SCRIPT_CLASSES_GET ) /
+ sizeof ( AF_SCRIPT_CLASSES_GET[0] );
FT_Error error = AF_Err_Ok;
- if ( gindex >= globals->glyph_count )
+ if ( gindex >= (FT_ULong)globals->glyph_count )
{
error = AF_Err_Invalid_Argument;
goto Exit;
@@ -245,9 +265,9 @@
gidx = script;
if ( gidx == 0 || gidx + 1 >= script_max )
- gidx = globals->glyph_scripts[gindex];
+ gidx = globals->glyph_scripts[gindex] & AF_SCRIPT_LIST_NONE;
- clazz = af_script_classes[gidx];
+ clazz = AF_SCRIPT_CLASSES_GET[gidx];
if ( script == 0 )
script = clazz->script;
@@ -286,4 +306,15 @@
}
+ FT_LOCAL_DEF( FT_Bool )
+ af_face_globals_is_digit( AF_FaceGlobals globals,
+ FT_UInt gindex )
+ {
+ if ( gindex < (FT_ULong)globals->glyph_count )
+ return (FT_Bool)( globals->glyph_scripts[gindex] & AF_DIGIT );
+
+ return (FT_Bool)0;
+ }
+
+
/* END */
diff --git a/src/freetype2/autofit/afglobal.h b/src/freetype2/autofit/afglobal.h
index cf52c08..2a68e19 100644
--- a/src/freetype2/autofit/afglobal.h
+++ b/src/freetype2/autofit/afglobal.h
@@ -5,7 +5,7 @@
/* Auto-fitter routines to compute global hinting values */
/* (specification). */
/* */
-/* Copyright 2003, 2004, 2005, 2007 by */
+/* Copyright 2003, 2004, 2005, 2007, 2009 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -56,7 +56,11 @@ FT_BEGIN_HEADER
FT_LOCAL( void )
af_face_globals_free( AF_FaceGlobals globals );
- /* */
+ FT_LOCAL_DEF( FT_Bool )
+ af_face_globals_is_digit( AF_FaceGlobals globals,
+ FT_UInt gindex );
+
+ /* */
FT_END_HEADER
diff --git a/src/freetype2/autofit/afhints.c b/src/freetype2/autofit/afhints.c
index 4828706..fe38fba 100644
--- a/src/freetype2/autofit/afhints.c
+++ b/src/freetype2/autofit/afhints.c
@@ -4,7 +4,7 @@
/* */
/* Auto-fitter hinting routines (body). */
/* */
-/* Copyright 2003, 2004, 2005, 2006, 2007 by */
+/* Copyright 2003, 2004, 2005, 2006, 2007, 2009 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -34,7 +34,7 @@
{
FT_Int old_max = axis->max_segments;
FT_Int new_max = old_max;
- FT_Int big_max = FT_INT_MAX / sizeof ( *segment );
+ FT_Int big_max = (FT_Int)( FT_INT_MAX / sizeof ( *segment ) );
if ( old_max >= big_max )
@@ -77,7 +77,7 @@
{
FT_Int old_max = axis->max_edges;
FT_Int new_max = old_max;
- FT_Int big_max = FT_INT_MAX / sizeof ( *edge );
+ FT_Int big_max = (FT_Int)( FT_INT_MAX / sizeof ( *edge ) );
if ( old_max >= big_max )
@@ -127,7 +127,7 @@
#ifdef AF_DEBUG
-#include <stdio.h>
+#include FT_CONFIG_STANDARD_LIBRARY_H
static const char*
af_dir_str( AF_Direction dir )
@@ -203,14 +203,14 @@
if ( flags & AF_EDGE_ROUND )
{
- memcpy( temp + pos, "round", 5 );
+ ft_memcpy( temp + pos, "round", 5 );
pos += 5;
}
if ( flags & AF_EDGE_SERIF )
{
if ( pos > 0 )
temp[pos++] = ' ';
- memcpy( temp + pos, "serif", 5 );
+ ft_memcpy( temp + pos, "serif", 5 );
pos += 5;
}
if ( pos == 0 )
@@ -645,6 +645,7 @@
FT_Int contour_index = 0;
+ FT_UNUSED( first );
for ( point = points; point < point_limit; point++, vec++, tag++ )
{
point->fx = (FT_Short)vec->x;
@@ -940,8 +941,8 @@
}
{
- FT_UInt min, max, mid;
- FT_Pos fpos;
+ FT_PtrDist min, max, mid;
+ FT_Pos fpos;
/* find enclosing edges */
@@ -952,7 +953,7 @@
/* for small edge counts, a linear search is better */
if ( max <= 8 )
{
- FT_UInt nn;
+ FT_PtrDist nn;
for ( nn = 0; nn < max; nn++ )
if ( edges[nn].fpos >= u )
diff --git a/src/freetype2/autofit/afhints.h b/src/freetype2/autofit/afhints.h
index 1308d5c..6758268 100644
--- a/src/freetype2/autofit/afhints.h
+++ b/src/freetype2/autofit/afhints.h
@@ -4,7 +4,7 @@
/* */
/* Auto-fitter hinting routines (specification). */
/* */
-/* Copyright 2003, 2004, 2005, 2006, 2007 by */
+/* Copyright 2003, 2004, 2005, 2006, 2007, 2008 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -30,7 +30,7 @@ FT_BEGIN_HEADER
* script analysis routines (until now).
*/
- typedef enum
+ typedef enum AF_Dimension_
{
AF_DIMENSION_HORZ = 0, /* x coordinates, */
/* i.e., vertical segments & edges */
@@ -44,7 +44,7 @@ FT_BEGIN_HEADER
/* hint directions -- the values are computed so that two vectors are */
/* in opposite directions iff `dir1 + dir2 == 0' */
- typedef enum
+ typedef enum AF_Direction_
{
AF_DIR_NONE = 4,
AF_DIR_RIGHT = 1,
@@ -56,7 +56,7 @@ FT_BEGIN_HEADER
/* point hint flags */
- typedef enum
+ typedef enum AF_Flags_
{
AF_FLAG_NONE = 0,
@@ -87,7 +87,7 @@ FT_BEGIN_HEADER
/* edge hint flags */
- typedef enum
+ typedef enum AF_Edge_Flags_
{
AF_EDGE_NORMAL = 0,
AF_EDGE_ROUND = 1 << 0,
diff --git a/src/freetype2/autofit/afindic.c b/src/freetype2/autofit/afindic.c
index c6e7522..1d9e9ea 100644
--- a/src/freetype2/autofit/afindic.c
+++ b/src/freetype2/autofit/afindic.c
@@ -43,7 +43,7 @@
static void
af_indic_metrics_scale( AF_LatinMetrics metrics,
- AF_Scaler scaler )
+ AF_Scaler scaler )
{
/* use CJK routines */
af_cjk_metrics_scale( metrics, scaler );
@@ -52,7 +52,7 @@
static FT_Error
af_indic_hints_init( AF_GlyphHints hints,
- AF_LatinMetrics metrics )
+ AF_LatinMetrics metrics )
{
/* use CJK routines */
return af_cjk_hints_init( hints, metrics );
@@ -61,8 +61,8 @@
static FT_Error
af_indic_hints_apply( AF_GlyphHints hints,
- FT_Outline* outline,
- AF_LatinMetrics metrics)
+ FT_Outline* outline,
+ AF_LatinMetrics metrics)
{
/* use CJK routines */
return af_cjk_hints_apply( hints, outline, metrics );
@@ -81,16 +81,14 @@
static const AF_Script_UniRangeRec af_indic_uniranges[] =
{
#if 0
- { 0x0100, 0xFFFF }, /* why this? */
+ AF_UNIRANGE_REC( 0x0100UL, 0xFFFFUL ), /* why this? */
#endif
- { 0x0900, 0x0DFF}, /* Indic Range */
- { 0, 0 }
+ AF_UNIRANGE_REC( 0x0900UL, 0x0DFFUL), /* Indic Range */
+ AF_UNIRANGE_REC( 0UL, 0UL)
};
- FT_CALLBACK_TABLE_DEF const AF_ScriptClassRec
- af_indic_script_class =
- {
+ AF_DEFINE_SCRIPT_CLASS(af_indic_script_class,
AF_SCRIPT_INDIC,
af_indic_uniranges,
@@ -102,7 +100,7 @@
(AF_Script_InitHintsFunc) af_indic_hints_init,
(AF_Script_ApplyHintsFunc) af_indic_hints_apply
- };
+ )
#else /* !AF_CONFIG_OPTION_INDIC */
@@ -112,9 +110,7 @@
};
- FT_CALLBACK_TABLE_DEF const AF_ScriptClassRec
- af_indic_script_class =
- {
+ AF_DEFINE_SCRIPT_CLASS(af_indic_script_class,
AF_SCRIPT_INDIC,
af_indic_uniranges,
@@ -126,7 +122,7 @@
(AF_Script_InitHintsFunc) NULL,
(AF_Script_ApplyHintsFunc) NULL
- };
+ )
#endif /* !AF_CONFIG_OPTION_INDIC */
diff --git a/src/freetype2/autofit/afindic.h b/src/freetype2/autofit/afindic.h
index b242b26..662a982 100644
--- a/src/freetype2/autofit/afindic.h
+++ b/src/freetype2/autofit/afindic.h
@@ -27,8 +27,7 @@ FT_BEGIN_HEADER
/* the Indic-specific script class */
- FT_CALLBACK_TABLE const AF_ScriptClassRec
- af_indic_script_class;
+ AF_DECLARE_SCRIPT_CLASS(af_indic_script_class)
/* */
diff --git a/src/freetype2/autofit/aflatin.c b/src/freetype2/autofit/aflatin.c
index 2ae9ec5..394fb97 100644
--- a/src/freetype2/autofit/aflatin.c
+++ b/src/freetype2/autofit/aflatin.c
@@ -4,7 +4,7 @@
/* */
/* Auto-fitter hinting routines for latin script (body). */
/* */
-/* Copyright 2003, 2004, 2005, 2006, 2007 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,9 @@
/***************************************************************************/
+#include <ft2build.h>
+#include FT_ADVANCES_H
+
#include "aflatin.h"
#include "aferrors.h"
@@ -146,7 +149,8 @@
#define AF_LATIN_MAX_TEST_CHARACTERS 12
- static const char* const af_latin_blue_chars[AF_LATIN_MAX_BLUES] =
+ static const char af_latin_blue_chars[AF_LATIN_MAX_BLUES]
+ [AF_LATIN_MAX_TEST_CHARACTERS + 1] =
{
"THEZOCQS",
"HEZLOCUS",
@@ -195,9 +199,10 @@
for ( ; p < limit && *p; p++ )
{
FT_UInt glyph_index;
- FT_Int best_point, best_y, best_first, best_last;
+ FT_Pos best_y; /* same as points.y */
+ FT_Int best_point, best_first, best_last;
FT_Vector* points;
- FT_Bool round;
+ FT_Bool round = 0;
AF_LOG(( "'%c'", *p ));
@@ -328,7 +333,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;
}
@@ -379,7 +384,7 @@
blue->flags |= AF_LATIN_BLUE_TOP;
/*
- * The following flags is used later to adjust the y and x scales
+ * The following flag is used later to adjust the y and x scales
* in order to optimize the pixel grid alignment of the top of small
* letters.
*/
@@ -393,6 +398,52 @@
}
+ FT_LOCAL_DEF( void )
+ af_latin_metrics_check_digits( AF_LatinMetrics metrics,
+ FT_Face face )
+ {
+ FT_UInt i;
+ FT_Bool started = 0, same_width = 1;
+
+
+ /* 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;
+ FT_Fixed advance, old_advance = 0;
+
+
+ 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_latin_metrics_init( AF_LatinMetrics metrics,
FT_Face face )
@@ -426,6 +477,7 @@
/* For now, compute the standard width and height from the `o'. */
af_latin_metrics_init_widths( metrics, face, 'o' );
af_latin_metrics_init_blues( metrics, face );
+ af_latin_metrics_check_digits( metrics, face );
}
FT_Set_Charmap( face, oldmap );
@@ -1004,12 +1056,14 @@
if ( !found )
{
- AF_Edge edge;
+ AF_Edge edge;
/* insert a new edge in the list and */
/* sort according to the position */
- error = af_axis_hints_new_edge( axis, seg->pos, seg->dir, memory, &edge );
+ error = af_axis_hints_new_edge( axis, seg->pos,
+ (AF_Direction)seg->dir,
+ memory, &edge );
if ( error )
goto Exit;
@@ -1565,7 +1619,7 @@
/* not hinted, appear a lot bolder or thinner than the */
/* vertical stems. */
- FT_Int delta;
+ FT_Pos delta;
dist = ( dist + 22 ) & ~63;
@@ -1649,7 +1703,7 @@
AF_AxisHints axis = &hints->axis[dim];
AF_Edge edges = axis->edges;
AF_Edge edge_limit = edges + axis->num_edges;
- FT_Int n_edges;
+ FT_PtrDist n_edges;
AF_Edge edge;
AF_Edge anchor = 0;
FT_Int has_serifs = 0;
@@ -2006,7 +2060,10 @@
if ( before >= edges && before < edge &&
after < edge_limit && after > edge )
{
- edge->pos = before->pos +
+ if ( after->opos == before->opos )
+ edge->pos = before->pos;
+ else
+ edge->pos = before->pos +
FT_MulDiv( edge->opos - before->opos,
after->pos - before->pos,
after->opos - before->opos );
@@ -2122,33 +2179,37 @@
static const AF_Script_UniRangeRec af_latin_uniranges[] =
{
- { 0x0020, 0x007F }, /* Basic Latin (no control characters) */
- { 0x00A0, 0x00FF }, /* Latin-1 Supplement (no control characters) */
- { 0x0100, 0x017F }, /* Latin Extended-A */
- { 0x0180, 0x024F }, /* Latin Extended-B */
- { 0x0250, 0x02AF }, /* IPA Extensions */
- { 0x02B0, 0x02FF }, /* Spacing Modifier Letters */
- { 0x0300, 0x036F }, /* Combining Diacritical Marks */
- { 0x0370, 0x03FF }, /* Greek and Coptic */
- { 0x0400, 0x04FF }, /* Cyrillic */
- { 0x0500, 0x052F }, /* Cyrillic Supplement */
- { 0x1D00, 0x1D7F }, /* Phonetic Extensions */
- { 0x1D80, 0x1DBF }, /* Phonetic Extensions Supplement */
- { 0x1DC0, 0x1DFF }, /* Combining Diacritical Marks Supplement */
- { 0x1E00, 0x1EFF }, /* Latin Extended Additional */
- { 0x1F00, 0x1FFF }, /* Greek Extended */
- { 0x2000, 0x206F }, /* General Punctuation */
- { 0x2070, 0x209F }, /* Superscripts and Subscripts */
- { 0x20A0, 0x20CF }, /* Currency Symbols */
- { 0x2150, 0x218F }, /* Number Forms */
- { 0x2460, 0x24FF }, /* Enclosed Alphanumerics */
- { 0 , 0 }
+ AF_UNIRANGE_REC( 0x0020UL, 0x007FUL ), /* Basic Latin (no control chars) */
+ AF_UNIRANGE_REC( 0x00A0UL, 0x00FFUL ), /* Latin-1 Supplement (no control chars) */
+ AF_UNIRANGE_REC( 0x0100UL, 0x017FUL ), /* Latin Extended-A */
+ AF_UNIRANGE_REC( 0x0180UL, 0x024FUL ), /* Latin Extended-B */
+ AF_UNIRANGE_REC( 0x0250UL, 0x02AFUL ), /* IPA Extensions */
+ AF_UNIRANGE_REC( 0x02B0UL, 0x02FFUL ), /* Spacing Modifier Letters */
+ AF_UNIRANGE_REC( 0x0300UL, 0x036FUL ), /* Combining Diacritical Marks */
+ AF_UNIRANGE_REC( 0x0370UL, 0x03FFUL ), /* Greek and Coptic */
+ AF_UNIRANGE_REC( 0x0400UL, 0x04FFUL ), /* Cyrillic */
+ AF_UNIRANGE_REC( 0x0500UL, 0x052FUL ), /* Cyrillic Supplement */
+ AF_UNIRANGE_REC( 0x1D00UL, 0x1D7FUL ), /* Phonetic Extensions */
+ AF_UNIRANGE_REC( 0x1D80UL, 0x1DBFUL ), /* Phonetic Extensions Supplement */
+ AF_UNIRANGE_REC( 0x1DC0UL, 0x1DFFUL ), /* Combining Diacritical Marks Supplement */
+ AF_UNIRANGE_REC( 0x1E00UL, 0x1EFFUL ), /* Latin Extended Additional */
+ AF_UNIRANGE_REC( 0x1F00UL, 0x1FFFUL ), /* Greek Extended */
+ AF_UNIRANGE_REC( 0x2000UL, 0x206FUL ), /* General Punctuation */
+ AF_UNIRANGE_REC( 0x2070UL, 0x209FUL ), /* Superscripts and Subscripts */
+ AF_UNIRANGE_REC( 0x20A0UL, 0x20CFUL ), /* Currency Symbols */
+ AF_UNIRANGE_REC( 0x2150UL, 0x218FUL ), /* Number Forms */
+ AF_UNIRANGE_REC( 0x2460UL, 0x24FFUL ), /* Enclosed Alphanumerics */
+ AF_UNIRANGE_REC( 0x2C60UL, 0x2C7FUL ), /* Latin Extended-C */
+ AF_UNIRANGE_REC( 0x2DE0UL, 0x2DFFUL ), /* Cyrillic Extended-A */
+ AF_UNIRANGE_REC( 0xA640UL, 0xA69FUL ), /* Cyrillic Extended-B */
+ AF_UNIRANGE_REC( 0xA720UL, 0xA7FFUL ), /* Latin Extended-D */
+ AF_UNIRANGE_REC( 0xFB00UL, 0xFB06UL ), /* Alphab. Present. Forms (Latin Ligs) */
+ AF_UNIRANGE_REC( 0x1D400UL, 0x1D7FFUL ), /* Mathematical Alphanumeric Symbols */
+ AF_UNIRANGE_REC( 0UL, 0UL )
};
- FT_CALLBACK_TABLE_DEF const AF_ScriptClassRec
- af_latin_script_class =
- {
+ AF_DEFINE_SCRIPT_CLASS(af_latin_script_class,
AF_SCRIPT_LATIN,
af_latin_uniranges,
@@ -2160,7 +2221,7 @@
(AF_Script_InitHintsFunc) af_latin_hints_init,
(AF_Script_ApplyHintsFunc) af_latin_hints_apply
- };
+ )
/* END */
diff --git a/src/freetype2/autofit/aflatin.h b/src/freetype2/autofit/aflatin.h
index 3251d37..660b10c 100644
--- a/src/freetype2/autofit/aflatin.h
+++ b/src/freetype2/autofit/aflatin.h
@@ -4,7 +4,7 @@
/* */
/* Auto-fitter hinting routines for latin script (specification). */
/* */
-/* Copyright 2003, 2004, 2005, 2006, 2007 by */
+/* Copyright 2003, 2004, 2005, 2006, 2007, 2009 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -27,8 +27,7 @@ FT_BEGIN_HEADER
/* the latin-specific script class */
- FT_CALLBACK_TABLE const AF_ScriptClassRec
- af_latin_script_class;
+ AF_DECLARE_SCRIPT_CLASS(af_latin_script_class)
/* constants are given with units_per_em == 2048 in mind */
@@ -138,6 +137,10 @@ FT_BEGIN_HEADER
FT_Face face,
FT_ULong charcode );
+ FT_LOCAL( void )
+ af_latin_metrics_check_digits( AF_LatinMetrics metrics,
+ FT_Face face );
+
/*************************************************************************/
/*************************************************************************/
diff --git a/src/freetype2/autofit/aflatin2.c b/src/freetype2/autofit/aflatin2.c
index 0b41774..5e2ad48 100644
--- a/src/freetype2/autofit/aflatin2.c
+++ b/src/freetype2/autofit/aflatin2.c
@@ -4,7 +4,7 @@
/* */
/* Auto-fitter hinting routines for latin script (body). */
/* */
-/* Copyright 2003, 2004, 2005, 2006, 2007 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;
+
+
+ /* 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;
+ FT_Fixed advance, old_advance;
+
+
+ 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 );
@@ -944,6 +993,9 @@
}
}
}
+#if 0
+ }
+#endif
/* now, compute the `serif' segments */
for ( seg1 = segments; seg1 < segment_limit; seg1++ )
@@ -1736,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;
@@ -2047,54 +2098,60 @@
/* 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;
- if ( dim == AF_DIMENSION_HORZ && ( n_edges == 6 || n_edges == 12 ) )
{
- AF_Edge edge1, edge2, edge3;
- FT_Pos dist1, dist2, span, delta;
+ FT_Int n_edges = edge_limit - edges;
- if ( n_edges == 6 )
+ if ( dim == AF_DIMENSION_HORZ && ( n_edges == 6 || n_edges == 12 ) )
{
- edge1 = edges;
- edge2 = edges + 2;
- edge3 = edges + 4;
- }
- else
- {
- edge1 = edges + 1;
- edge2 = edges + 5;
- edge3 = edges + 9;
- }
+ AF_Edge edge1, edge2, edge3;
+ FT_Pos dist1, dist2, span, delta;
- dist1 = edge2->opos - edge1->opos;
- dist2 = edge3->opos - edge2->opos;
- span = dist1 - dist2;
- if ( span < 0 )
- span = -span;
+ if ( n_edges == 6 )
+ {
+ edge1 = edges;
+ edge2 = edges + 2;
+ edge3 = edges + 4;
+ }
+ else
+ {
+ edge1 = edges + 1;
+ edge2 = edges + 5;
+ edge3 = edges + 9;
+ }
- if ( span < 8 )
- {
- delta = edge3->pos - ( 2 * edge2->pos - edge1->pos );
- edge3->pos -= delta;
- if ( edge3->link )
- edge3->link->pos -= delta;
+ dist1 = edge2->opos - edge1->opos;
+ dist2 = edge3->opos - edge2->opos;
+
+ span = dist1 - dist2;
+ if ( span < 0 )
+ span = -span;
- /* move the serifs along with the stem */
- if ( n_edges == 12 )
+ if ( span < 8 )
{
- ( edges + 8 )->pos -= delta;
- ( edges + 11 )->pos -= delta;
- }
+ delta = edge3->pos - ( 2 * edge2->pos - edge1->pos );
+ edge3->pos -= delta;
+ if ( edge3->link )
+ edge3->link->pos -= delta;
+
+ /* move the serifs along with the stem */
+ if ( n_edges == 12 )
+ {
+ ( edges + 8 )->pos -= delta;
+ ( edges + 11 )->pos -= delta;
+ }
- edge3->flags |= AF_EDGE_DONE;
- if ( edge3->link )
- edge3->link->flags |= AF_EDGE_DONE;
+ edge3->flags |= AF_EDGE_DONE;
+ if ( edge3->link )
+ edge3->link->flags |= AF_EDGE_DONE;
+ }
}
}
#endif
+
if ( has_serifs || !anchor )
{
/*
@@ -2150,7 +2207,10 @@
if ( before >= edges && before < edge &&
after < edge_limit && after > edge )
{
- edge->pos = before->pos +
+ if ( after->opos == before->opos )
+ edge->pos = before->pos;
+ else
+ edge->pos = before->pos +
FT_MulDiv( edge->opos - before->opos,
after->pos - before->pos,
after->opos - before->opos );
@@ -2260,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,
@@ -2280,7 +2338,7 @@
(AF_Script_InitHintsFunc) af_latin2_hints_init,
(AF_Script_ApplyHintsFunc) af_latin2_hints_apply
- };
+ )
/* END */
diff --git a/src/freetype2/autofit/aflatin2.h b/src/freetype2/autofit/aflatin2.h
index 34eda05..925c621 100644
--- a/src/freetype2/autofit/aflatin2.h
+++ b/src/freetype2/autofit/aflatin2.h
@@ -27,8 +27,7 @@ FT_BEGIN_HEADER
/* the latin-specific script class */
- FT_CALLBACK_TABLE const AF_ScriptClassRec
- af_latin2_script_class;
+ AF_DECLARE_SCRIPT_CLASS(af_latin2_script_class)
/* */
diff --git a/src/freetype2/autofit/afloader.c b/src/freetype2/autofit/afloader.c
index 4e4373a..6dd9f2a 100644
--- a/src/freetype2/autofit/afloader.c
+++ b/src/freetype2/autofit/afloader.c
@@ -4,7 +4,7 @@
/* */
/* Auto-fitter glyph loading routines (body). */
/* */
-/* Copyright 2003, 2004, 2005, 2006, 2007 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, */
@@ -19,7 +19,6 @@
#include "afloader.h"
#include "afhints.h"
#include "afglobal.h"
-#include "aflatin.h"
#include "aferrors.h"
@@ -165,9 +164,10 @@
/* now load the slot image into the auto-outline and run the */
/* automatic hinting process */
- metrics->clazz->script_hints_apply( hints,
- &gloader->current.outline,
- metrics );
+ if ( metrics->clazz->script_hints_apply )
+ metrics->clazz->script_hints_apply( hints,
+ &gloader->current.outline,
+ metrics );
/* we now need to hint the metrics according to the change in */
/* width/positioning that occurred during the hinting process */
@@ -183,9 +183,9 @@
if ( axis->num_edges > 1 && AF_HINTS_DO_ADVANCE( hints ) )
{
- old_rsb = loader->pp2.x - edge2->opos;
- old_lsb = edge1->opos;
- new_lsb = edge1->pos;
+ old_rsb = loader->pp2.x - edge2->opos;
+ old_lsb = edge1->opos;
+ new_lsb = edge1->pos;
/* remember unhinted values to later account */
/* for rounding errors */
@@ -216,8 +216,9 @@
}
else
{
- FT_Pos pp1x = loader->pp1.x;
- FT_Pos pp2x = loader->pp2.x;
+ FT_Pos pp1x = loader->pp1.x;
+ FT_Pos pp2x = loader->pp2.x;
+
loader->pp1.x = FT_PIX_ROUND( pp1x );
loader->pp2.x = FT_PIX_ROUND( pp2x );
@@ -228,8 +229,9 @@
}
else
{
- FT_Pos pp1x = loader->pp1.x;
- FT_Pos pp2x = loader->pp2.x;
+ FT_Pos pp1x = loader->pp1.x;
+ FT_Pos pp2x = loader->pp2.x;
+
loader->pp1.x = FT_PIX_ROUND( pp1x + hints->xmin_delta );
loader->pp2.x = FT_PIX_ROUND( pp2x + hints->xmax_delta );
@@ -412,7 +414,8 @@
slot->metrics.vertBearingY = FT_PIX_FLOOR( bbox.yMax + vvector.y );
/* for mono-width fonts (like Andale, Courier, etc.) we need */
- /* to keep the original rounded advance width */
+ /* to keep the original rounded advance width; ditto for */
+ /* digits if all have the same advance width */
#if 0
if ( !FT_IS_FIXED_WIDTH( slot->face ) )
slot->metrics.horiAdvance = loader->pp2.x - loader->pp1.x;
@@ -420,13 +423,9 @@
slot->metrics.horiAdvance = FT_MulFix( slot->metrics.horiAdvance,
x_scale );
#else
- if ( !FT_IS_FIXED_WIDTH( slot->face ) )
- {
- /* non-spacing glyphs must stay as-is */
- if ( slot->metrics.horiAdvance )
- slot->metrics.horiAdvance = loader->pp2.x - loader->pp1.x;
- }
- else
+ if ( FT_IS_FIXED_WIDTH( slot->face ) ||
+ ( af_face_globals_is_digit( loader->globals, glyph_index ) &&
+ metrics->digits_have_same_width ) )
{
slot->metrics.horiAdvance = FT_MulFix( slot->metrics.horiAdvance,
metrics->scaler.x_scale );
@@ -436,6 +435,12 @@
slot->lsb_delta = 0;
slot->rsb_delta = 0;
}
+ else
+ {
+ /* non-spacing glyphs must stay as-is */
+ if ( slot->metrics.horiAdvance )
+ slot->metrics.horiAdvance = loader->pp2.x - loader->pp1.x;
+ }
#endif
slot->metrics.vertAdvance = FT_MulFix( slot->metrics.vertAdvance,
@@ -515,9 +520,13 @@
load_flags |= FT_LOAD_NO_SCALE | FT_LOAD_IGNORE_TRANSFORM;
load_flags &= ~FT_LOAD_RENDER;
- error = metrics->clazz->script_hints_init( &loader->hints, metrics );
- if ( error )
- goto Exit;
+ if ( metrics->clazz->script_hints_init )
+ {
+ error = metrics->clazz->script_hints_init( &loader->hints,
+ metrics );
+ if ( error )
+ goto Exit;
+ }
error = af_loader_load_g( loader, &scaler, gindex, load_flags, 0 );
}
diff --git a/src/freetype2/autofit/afmodule.c b/src/freetype2/autofit/afmodule.c
index cd5e1cc..ec2d707 100644
--- a/src/freetype2/autofit/afmodule.c
+++ b/src/freetype2/autofit/afmodule.c
@@ -18,6 +18,7 @@
#include "afmodule.h"
#include "afloader.h"
+#include "afpic.h"
#ifdef AF_DEBUG
int _af_debug;
@@ -66,19 +67,15 @@
}
- FT_CALLBACK_TABLE_DEF
- const FT_AutoHinter_ServiceRec af_autofitter_service =
- {
+ FT_DEFINE_AUTOHINTER_SERVICE(af_autofitter_service,
NULL,
NULL,
NULL,
(FT_AutoHinter_GlyphLoadFunc)af_autofitter_load_glyph
- };
+ )
+ FT_DEFINE_MODULE(autofit_module_class,
- FT_CALLBACK_TABLE_DEF
- const FT_Module_Class autofit_module_class =
- {
FT_MODULE_HINTER,
sizeof ( FT_AutofitterRec ),
@@ -86,12 +83,12 @@
0x10000L, /* version 1.0 of the autofitter */
0x20000L, /* requires FreeType 2.0 or above */
- (const void*)&af_autofitter_service,
+ (const void*)&AF_AF_AUTOFITTER_SERVICE_GET,
(FT_Module_Constructor)af_autofitter_init,
(FT_Module_Destructor) af_autofitter_done,
(FT_Module_Requester) NULL
- };
+ )
/* END */
diff --git a/src/freetype2/autofit/afmodule.h b/src/freetype2/autofit/afmodule.h
index 36268a0..d979239 100644
--- a/src/freetype2/autofit/afmodule.h
+++ b/src/freetype2/autofit/afmodule.h
@@ -20,13 +20,13 @@
#define __AFMODULE_H__
#include <ft2build.h>
+#include FT_INTERNAL_OBJECTS_H
#include FT_MODULE_H
FT_BEGIN_HEADER
- FT_CALLBACK_TABLE
- const FT_Module_Class autofit_module_class;
+FT_DECLARE_MODULE(autofit_module_class)
FT_END_HEADER
diff --git a/src/freetype2/autofit/afpic.c b/src/freetype2/autofit/afpic.c
new file mode 100644
index 0000000..76822c3
--- /dev/null
+++ b/src/freetype2/autofit/afpic.c
@@ -0,0 +1,92 @@
+/***************************************************************************/
+/* */
+/* afpic.c */
+/* */
+/* The FreeType position independent code services for autofit module. */
+/* */
+/* Copyright 2009 by */
+/* Oran Agra and Mickey Gabel. */
+/* */
+/* This file is part of the FreeType project, and may only be used, */
+/* modified, and distributed under the terms of the FreeType project */
+/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
+/* this file you indicate that you have read the license and */
+/* understand and accept it fully. */
+/* */
+/***************************************************************************/
+
+
+#include <ft2build.h>
+#include FT_FREETYPE_H
+#include FT_INTERNAL_OBJECTS_H
+#include "afpic.h"
+
+#ifdef FT_CONFIG_OPTION_PIC
+
+ /* forward declaration of PIC init functions from afmodule.c */
+ void FT_Init_Class_af_autofitter_service( FT_Library, FT_AutoHinter_ServiceRec*);
+
+ /* forward declaration of PIC init functions from script classes */
+#include "aflatin.h"
+#include "aflatin2.h"
+#include "afcjk.h"
+#include "afdummy.h"
+#include "afindic.h"
+
+ void
+ autofit_module_class_pic_free( FT_Library library )
+ {
+ FT_PIC_Container* pic_container = &library->pic_container;
+ FT_Memory memory = library->memory;
+ if ( pic_container->autofit )
+ {
+ FT_FREE( pic_container->autofit );
+ pic_container->autofit = NULL;
+ }
+ }
+
+ FT_Error
+ autofit_module_class_pic_init( FT_Library library )
+ {
+ FT_PIC_Container* pic_container = &library->pic_container;
+ FT_UInt ss;
+ FT_Error error = FT_Err_Ok;
+ AFModulePIC* container;
+ FT_Memory memory = library->memory;
+
+ /* allocate pointer, clear and set global container pointer */
+ if ( FT_ALLOC ( container, sizeof ( *container ) ) )
+ return error;
+ FT_MEM_SET( container, 0, sizeof(*container) );
+ pic_container->autofit = container;
+
+ /* initialize pointer table - this is how the module usually expects this data */
+ for ( ss = 0 ; ss < AF_SCRIPT_CLASSES_REC_COUNT ; ss++ )
+ {
+ container->af_script_classes[ss] = &container->af_script_classes_rec[ss];
+ }
+ container->af_script_classes[AF_SCRIPT_CLASSES_COUNT-1] = NULL;
+
+ /* add call to initialization function when you add new scripts */
+ ss = 0;
+ FT_Init_Class_af_dummy_script_class(&container->af_script_classes_rec[ss++]);
+#ifdef FT_OPTION_AUTOFIT2
+ FT_Init_Class_af_latin2_script_class(&container->af_script_classes_rec[ss++]);
+#endif
+ FT_Init_Class_af_latin_script_class(&container->af_script_classes_rec[ss++]);
+ FT_Init_Class_af_cjk_script_class(&container->af_script_classes_rec[ss++]);
+ FT_Init_Class_af_indic_script_class(&container->af_script_classes_rec[ss++]);
+
+ FT_Init_Class_af_autofitter_service(library, &container->af_autofitter_service);
+
+/*Exit:*/
+ if(error)
+ autofit_module_class_pic_free(library);
+ return error;
+ }
+
+
+#endif /* FT_CONFIG_OPTION_PIC */
+
+
+/* END */
diff --git a/src/freetype2/autofit/afpic.h b/src/freetype2/autofit/afpic.h
new file mode 100644
index 0000000..80e62d3
--- /dev/null
+++ b/src/freetype2/autofit/afpic.h
@@ -0,0 +1,64 @@
+/***************************************************************************/
+/* */
+/* afpic.h */
+/* */
+/* The FreeType position independent code services for autofit module. */
+/* */
+/* Copyright 2009 by */
+/* Oran Agra and Mickey Gabel. */
+/* */
+/* This file is part of the FreeType project, and may only be used, */
+/* modified, and distributed under the terms of the FreeType project */
+/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
+/* this file you indicate that you have read the license and */
+/* understand and accept it fully. */
+/* */
+/***************************************************************************/
+
+
+#ifndef __AFPIC_H__
+#define __AFPIC_H__
+
+
+FT_BEGIN_HEADER
+
+#include FT_INTERNAL_PIC_H
+
+#ifndef FT_CONFIG_OPTION_PIC
+
+#define AF_SCRIPT_CLASSES_GET af_script_classes
+#define AF_AF_AUTOFITTER_SERVICE_GET af_autofitter_service
+
+#else /* FT_CONFIG_OPTION_PIC */
+
+#include "aftypes.h"
+
+/* increase these when you add new scripts, and update autofit_module_class_pic_init */
+#ifdef FT_OPTION_AUTOFIT2
+ #define AF_SCRIPT_CLASSES_COUNT 6
+#else
+ #define AF_SCRIPT_CLASSES_COUNT 5
+#endif
+#define AF_SCRIPT_CLASSES_REC_COUNT (AF_SCRIPT_CLASSES_COUNT-1)
+
+ typedef struct AFModulePIC_
+ {
+ AF_ScriptClass af_script_classes[AF_SCRIPT_CLASSES_COUNT];
+ AF_ScriptClassRec af_script_classes_rec[AF_SCRIPT_CLASSES_REC_COUNT];
+ FT_AutoHinter_ServiceRec af_autofitter_service;
+ } AFModulePIC;
+
+#define GET_PIC(lib) ((AFModulePIC*)((lib)->pic_container.autofit))
+#define AF_SCRIPT_CLASSES_GET (GET_PIC(FT_FACE_LIBRARY(globals->face))->af_script_classes)
+#define AF_AF_AUTOFITTER_SERVICE_GET (GET_PIC(library)->af_autofitter_service)
+
+#endif /* FT_CONFIG_OPTION_PIC */
+
+ /* */
+
+FT_END_HEADER
+
+#endif /* __AFPIC_H__ */
+
+
+/* END */
diff --git a/src/freetype2/autofit/aftypes.h b/src/freetype2/autofit/aftypes.h
index bd3fa88..5574f0c 100644
--- a/src/freetype2/autofit/aftypes.h
+++ b/src/freetype2/autofit/aftypes.h
@@ -4,7 +4,7 @@
/* */
/* Auto-fitter types (specification only). */
/* */
-/* Copyright 2003, 2004, 2005, 2006, 2007 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, */
@@ -58,7 +58,8 @@ FT_BEGIN_HEADER
#ifdef AF_DEBUG
-#include <stdio.h>
+#include FT_CONFIG_STANDARD_LIBRARY_H
+
#define AF_LOG( x ) do { if ( _af_debug ) printf x; } while ( 0 )
extern int _af_debug;
@@ -69,7 +70,7 @@ extern void* _af_debug_hints;
#else /* !AF_DEBUG */
-#define AF_LOG( x ) do ; while ( 0 ) /* nothing */
+#define AF_LOG( x ) do { } while ( 0 ) /* nothing */
#endif /* !AF_DEBUG */
@@ -202,7 +203,7 @@ extern void* _af_debug_hints;
* auto-hinted glyph image.
*/
- typedef enum
+ typedef enum AF_ScalerFlags_
{
AF_SCALER_FLAG_NO_HORIZONTAL = 1, /* disable horizontal hinting */
AF_SCALER_FLAG_NO_VERTICAL = 2, /* disable vertical hinting */
@@ -260,7 +261,7 @@ extern void* _af_debug_hints;
* used by more than one script.
*/
- typedef enum
+ typedef enum AF_Script_
{
AF_SCRIPT_NONE = 0,
AF_SCRIPT_LATIN = 1,
@@ -284,6 +285,7 @@ extern void* _af_debug_hints;
{
AF_ScriptClass clazz;
AF_ScalerRec scaler;
+ FT_Bool digits_have_same_width;
} AF_ScriptMetricsRec, *AF_ScriptMetrics;
@@ -320,6 +322,8 @@ extern void* _af_debug_hints;
} AF_Script_UniRangeRec;
+#define AF_UNIRANGE_REC( a, b ) { (FT_UInt32)(a), (FT_UInt32)(b) }
+
typedef const AF_Script_UniRangeRec *AF_Script_UniRange;
@@ -328,7 +332,7 @@ extern void* _af_debug_hints;
AF_Script script;
AF_Script_UniRange script_uni_ranges; /* last must be { 0, 0 } */
- FT_UInt script_metrics_size;
+ FT_Offset script_metrics_size;
AF_Script_InitMetricsFunc script_metrics_init;
AF_Script_ScaleMetricsFunc script_metrics_scale;
AF_Script_DoneMetricsFunc script_metrics_done;
@@ -338,6 +342,56 @@ extern void* _af_debug_hints;
} AF_ScriptClassRec;
+/* Declare and define vtables for classes */
+#ifndef FT_CONFIG_OPTION_PIC
+
+#define AF_DECLARE_SCRIPT_CLASS(script_class) \
+ FT_CALLBACK_TABLE const AF_ScriptClassRec \
+ script_class;
+
+#define AF_DEFINE_SCRIPT_CLASS(script_class, script_, ranges, m_size, \
+ m_init, m_scale, m_done, h_init, h_apply) \
+ FT_CALLBACK_TABLE_DEF const AF_ScriptClassRec \
+ script_class = \
+ { \
+ script_, \
+ ranges, \
+ \
+ m_size, \
+ \
+ m_init, \
+ m_scale, \
+ m_done, \
+ \
+ h_init, \
+ h_apply \
+ };
+
+#else
+
+#define AF_DECLARE_SCRIPT_CLASS(script_class) \
+ FT_LOCAL(void) \
+ FT_Init_Class_##script_class(AF_ScriptClassRec* ac);
+
+#define AF_DEFINE_SCRIPT_CLASS(script_class, script_, ranges, m_size, \
+ m_init, m_scale, m_done, h_init, h_apply) \
+ FT_LOCAL_DEF(void) \
+ FT_Init_Class_##script_class(AF_ScriptClassRec* ac) \
+ { \
+ ac->script = script_; \
+ ac->script_uni_ranges = ranges; \
+ \
+ ac->script_metrics_size = m_size; \
+ \
+ ac->script_metrics_init = m_init; \
+ ac->script_metrics_scale = m_scale; \
+ ac->script_metrics_done = m_done; \
+ \
+ ac->script_hints_init = h_init; \
+ ac->script_hints_apply = h_apply; \
+ }
+#endif
+
/* */
diff --git a/src/freetype2/autofit/autofit.c b/src/freetype2/autofit/autofit.c
index 2fe66a9..83b613e 100644
--- a/src/freetype2/autofit/autofit.c
+++ b/src/freetype2/autofit/autofit.c
@@ -18,6 +18,7 @@
#define FT_MAKE_OPTION_SINGLE_OBJECT
#include <ft2build.h>
+#include "afpic.c"
#include "afangles.c"
#include "afglobal.c"
#include "afhints.c"