aboutsummaryrefslogtreecommitdiff
path: root/freetype/src/autofit
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2009-12-21 15:22:51 +0000
committermarha <marha@users.sourceforge.net>2009-12-21 15:22:51 +0000
commit1ee02cd0419021c3d4950af2619da39c6e9c47f0 (patch)
treef5b61f7d9e151c7a64cff51399560ffb77800349 /freetype/src/autofit
parentd8432fdd4f13e9f9d1d44f5482faeb56562661a9 (diff)
downloadvcxsrv-1ee02cd0419021c3d4950af2619da39c6e9c47f0.tar.gz
vcxsrv-1ee02cd0419021c3d4950af2619da39c6e9c47f0.tar.bz2
vcxsrv-1ee02cd0419021c3d4950af2619da39c6e9c47f0.zip
Updated to freetype-2.3.11
Diffstat (limited to 'freetype/src/autofit')
-rw-r--r--freetype/src/autofit/Jamfile6
-rw-r--r--freetype/src/autofit/afcjk.c71
-rw-r--r--freetype/src/autofit/afcjk.h3
-rw-r--r--freetype/src/autofit/afdummy.c6
-rw-r--r--freetype/src/autofit/afdummy.h3
-rw-r--r--freetype/src/autofit/afglobal.c63
-rw-r--r--freetype/src/autofit/afglobal.h8
-rw-r--r--freetype/src/autofit/afhints.c11
-rw-r--r--freetype/src/autofit/afindic.c18
-rw-r--r--freetype/src/autofit/afindic.h3
-rw-r--r--freetype/src/autofit/aflatin.c126
-rw-r--r--freetype/src/autofit/aflatin.h9
-rw-r--r--freetype/src/autofit/aflatin2.c142
-rw-r--r--freetype/src/autofit/aflatin2.h3
-rw-r--r--freetype/src/autofit/afloader.c38
-rw-r--r--freetype/src/autofit/afmodule.c15
-rw-r--r--freetype/src/autofit/afmodule.h4
-rw-r--r--freetype/src/autofit/afpic.c92
-rw-r--r--freetype/src/autofit/afpic.h64
-rw-r--r--freetype/src/autofit/aftypes.h55
-rw-r--r--freetype/src/autofit/autofit.c1
21 files changed, 541 insertions, 200 deletions
diff --git a/freetype/src/autofit/Jamfile b/freetype/src/autofit/Jamfile
index acee8bf2c..2714765b5 100644
--- a/freetype/src/autofit/Jamfile
+++ b/freetype/src/autofit/Jamfile
@@ -1,6 +1,6 @@
# FreeType 2 src/autofit Jamfile
#
-# 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, modified,
@@ -14,14 +14,14 @@ SubDir FT2_TOP src autofit ;
{
local _sources ;
- # define FT2_AUTOFIT2 do enable to experimental latin hinter replacement
+ # define FT2_AUTOFIT2 to enable experimental latin hinter replacement
if $(FT2_AUTOFIT2)
{
DEFINES += FT_OPTION_AUTOFIT2 ;
}
if $(FT2_MULTI)
{
- _sources = afangles afglobal afhints aflatin afcjk afindic afloader afmodule afdummy afwarp ;
+ _sources = afangles afglobal afhints aflatin afcjk afindic afloader afmodule afdummy afwarp afpic ;
if $(FT2_AUTOFIT2)
{
diff --git a/freetype/src/autofit/afcjk.c b/freetype/src/autofit/afcjk.c
index de3ce11d5..bab0c42ba 100644
--- a/freetype/src/autofit/afcjk.c
+++ b/freetype/src/autofit/afcjk.c
@@ -4,7 +4,7 @@
/* */
/* Auto-fitter hinting routines for CJK script (body). */
/* */
-/* Copyright 2006, 2007, 2008 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, */
@@ -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 );
@@ -1017,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;
@@ -1441,35 +1444,33 @@
static const AF_Script_UniRangeRec af_cjk_uniranges[] =
{
#if 0
- { 0x0100UL, 0xFFFFUL }, /* why this? */
+ AF_UNIRANGE_REC( 0x0100UL, 0xFFFFUL ), /* why this? */
#endif
- { 0x2E80UL, 0x2EFFUL }, /* CJK Radicals Supplement */
- { 0x2F00UL, 0x2FDFUL }, /* Kangxi Radicals */
- { 0x3000UL, 0x303FUL }, /* CJK Symbols and Punctuation */
- { 0x3040UL, 0x309FUL }, /* Hiragana */
- { 0x30A0UL, 0x30FFUL }, /* Katakana */
- { 0x3100UL, 0x312FUL }, /* Bopomofo */
- { 0x3130UL, 0x318FUL }, /* Hangul Compatibility Jamo */
- { 0x31A0UL, 0x31BFUL }, /* Bopomofo Extended */
- { 0x31C0UL, 0x31EFUL }, /* CJK Strokes */
- { 0x31F0UL, 0x31FFUL }, /* Katakana Phonetic Extensions */
- { 0x3200UL, 0x32FFUL }, /* Enclosed CJK Letters and Months */
- { 0x3300UL, 0x33FFUL }, /* CJK Compatibility */
- { 0x3400UL, 0x4DBFUL }, /* CJK Unified Ideographs Extension A */
- { 0x4DC0UL, 0x4DFFUL }, /* Yijing Hexagram Symbols */
- { 0x4E00UL, 0x9FFFUL }, /* CJK Unified Ideographs */
- { 0xF900UL, 0xFAFFUL }, /* CJK Compatibility Ideographs */
- { 0xFE30UL, 0xFE4FUL }, /* CJK Compatibility Forms */
- { 0xFF00UL, 0xFFEFUL }, /* Halfwidth and Fullwidth Forms */
- { 0x20000UL, 0x2A6DFUL }, /* CJK Unified Ideographs Extension B */
- { 0x2F800UL, 0x2FA1FUL }, /* CJK Compatibility Ideographs Supplement */
- { 0UL, 0UL }
+ 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,
@@ -1481,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,
@@ -1505,7 +1504,7 @@
(AF_Script_InitHintsFunc) NULL,
(AF_Script_ApplyHintsFunc) NULL
- };
+ )
#endif /* !AF_CONFIG_OPTION_CJK */
diff --git a/freetype/src/autofit/afcjk.h b/freetype/src/autofit/afcjk.h
index 9f77fda14..0b20d4ae3 100644
--- a/freetype/src/autofit/afcjk.h
+++ b/freetype/src/autofit/afcjk.h
@@ -27,8 +27,7 @@ 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 )
diff --git a/freetype/src/autofit/afdummy.c b/freetype/src/autofit/afdummy.c
index ed96e9641..42b2fcb21 100644
--- a/freetype/src/autofit/afdummy.c
+++ b/freetype/src/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/freetype/src/autofit/afdummy.h b/freetype/src/autofit/afdummy.h
index 2a5faf8f8..b69ef437f 100644
--- a/freetype/src/autofit/afdummy.h
+++ b/freetype/src/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/freetype/src/autofit/afglobal.c b/freetype/src/autofit/afglobal.c
index bfb9091bf..ac293619d 100644
--- a/freetype/src/autofit/afglobal.c
+++ b/freetype/src/autofit/afglobal.c
@@ -4,7 +4,7 @@
/* */
/* Auto-fitter routines to compute global hinting values (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, */
@@ -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' */
@@ -92,9 +102,9 @@
}
/* 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/freetype/src/autofit/afglobal.h b/freetype/src/autofit/afglobal.h
index cf52c0875..2a68e1960 100644
--- a/freetype/src/autofit/afglobal.h
+++ b/freetype/src/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/freetype/src/autofit/afhints.c b/freetype/src/autofit/afhints.c
index 8ab176148..fe38fba99 100644
--- a/freetype/src/autofit/afhints.c
+++ b/freetype/src/autofit/afhints.c
@@ -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 )
@@ -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/freetype/src/autofit/afindic.c b/freetype/src/autofit/afindic.c
index 3d27f521b..1d9e9eafb 100644
--- a/freetype/src/autofit/afindic.c
+++ b/freetype/src/autofit/afindic.c
@@ -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/freetype/src/autofit/afindic.h b/freetype/src/autofit/afindic.h
index b242b2614..662a98220 100644
--- a/freetype/src/autofit/afindic.h
+++ b/freetype/src/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/freetype/src/autofit/aflatin.c b/freetype/src/autofit/aflatin.c
index ba59e5b38..394fb9789 100644
--- a/freetype/src/autofit/aflatin.c
+++ b/freetype/src/autofit/aflatin.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,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,7 +199,8 @@
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 = 0;
@@ -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 );
@@ -1567,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;
@@ -1651,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;
@@ -2127,39 +2179,37 @@
static const AF_Script_UniRangeRec af_latin_uniranges[] =
{
- { 0x0020 , 0x007F }, /* Basic Latin (no control chars) */
- { 0x00A0 , 0x00FF }, /* Latin-1 Supplement (no control chars) */
- { 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 */
- { 0x2C60 , 0x2C7F }, /* Latin Extended-C */
- { 0x2DE0 , 0x2DFF }, /* Cyrillic Extended-A */
- { 0xA640U , 0xA69FU }, /* Cyrillic Extended-B */
- { 0xA720U , 0xA7FFU }, /* Latin Extended-D */
- { 0xFB00U , 0xFB06U }, /* Alphab. Present. Forms (Latin Ligs) */
- { 0x1D400UL, 0x1D7FFUL }, /* Mathematical Alphanumeric Symbols */
- { 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,
@@ -2171,7 +2221,7 @@
(AF_Script_InitHintsFunc) af_latin_hints_init,
(AF_Script_ApplyHintsFunc) af_latin_hints_apply
- };
+ )
/* END */
diff --git a/freetype/src/autofit/aflatin.h b/freetype/src/autofit/aflatin.h
index 3251d3783..660b10c83 100644
--- a/freetype/src/autofit/aflatin.h
+++ b/freetype/src/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/freetype/src/autofit/aflatin2.c b/freetype/src/autofit/aflatin2.c
index 14327b172..5e2ad48c4 100644
--- a/freetype/src/autofit/aflatin2.c
+++ b/freetype/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;
+
+
+ /* 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 );
@@ -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,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 )
- {
- edge1 = edges;
- edge2 = edges + 2;
- edge3 = edges + 4;
- }
- else
+ if ( dim == AF_DIMENSION_HORZ && ( n_edges == 6 || n_edges == 12 ) )
{
- 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;
- edge3->flags |= AF_EDGE_DONE;
- if ( edge3->link )
- edge3->link->flags |= AF_EDGE_DONE;
+ /* 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;
+ }
}
}
#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 */
diff --git a/freetype/src/autofit/aflatin2.h b/freetype/src/autofit/aflatin2.h
index 34eda0582..925c6214d 100644
--- a/freetype/src/autofit/aflatin2.h
+++ b/freetype/src/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/freetype/src/autofit/afloader.c b/freetype/src/autofit/afloader.c
index 4e48c2fe9..6dd9f2a31 100644
--- a/freetype/src/autofit/afloader.c
+++ b/freetype/src/autofit/afloader.c
@@ -4,7 +4,7 @@
/* */
/* Auto-fitter glyph loading routines (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, */
@@ -19,7 +19,6 @@
#include "afloader.h"
#include "afhints.h"
#include "afglobal.h"
-#include "aflatin.h"
#include "aferrors.h"
@@ -184,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 */
@@ -217,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 );
@@ -229,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 );
@@ -413,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;
@@ -421,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 );
@@ -437,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,
diff --git a/freetype/src/autofit/afmodule.c b/freetype/src/autofit/afmodule.c
index cd5e1cc21..ec2d707c9 100644
--- a/freetype/src/autofit/afmodule.c
+++ b/freetype/src/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/freetype/src/autofit/afmodule.h b/freetype/src/autofit/afmodule.h
index 36268a089..d9792399b 100644
--- a/freetype/src/autofit/afmodule.h
+++ b/freetype/src/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/freetype/src/autofit/afpic.c b/freetype/src/autofit/afpic.c
new file mode 100644
index 000000000..76822c301
--- /dev/null
+++ b/freetype/src/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/freetype/src/autofit/afpic.h b/freetype/src/autofit/afpic.h
new file mode 100644
index 000000000..80e62d39a
--- /dev/null
+++ b/freetype/src/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/freetype/src/autofit/aftypes.h b/freetype/src/autofit/aftypes.h
index 626a38865..5574f0c30 100644
--- a/freetype/src/autofit/aftypes.h
+++ b/freetype/src/autofit/aftypes.h
@@ -285,6 +285,7 @@ extern void* _af_debug_hints;
{
AF_ScriptClass clazz;
AF_ScalerRec scaler;
+ FT_Bool digits_have_same_width;
} AF_ScriptMetricsRec, *AF_ScriptMetrics;
@@ -321,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;
@@ -329,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;
@@ -339,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/freetype/src/autofit/autofit.c b/freetype/src/autofit/autofit.c
index 2fe66a990..83b613e79 100644
--- a/freetype/src/autofit/autofit.c
+++ b/freetype/src/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"