Index: src/autofit/afglobal.c |
diff --git a/src/autofit/afglobal.c b/src/autofit/afglobal.c |
index 3e0c02d3f1490594f96f2cd510e3312116d1044a..3e41465756b7d2003b1e342972436915643c0aaa 100644 |
--- a/src/autofit/afglobal.c |
+++ b/src/autofit/afglobal.c |
@@ -4,7 +4,7 @@ |
/* */ |
/* Auto-fitter routines to compute global hinting values (body). */ |
/* */ |
-/* Copyright 2003-2011 by */ |
+/* Copyright 2003-2013 by */ |
/* David Turner, Robert Wilhelm, and Werner Lemberg. */ |
/* */ |
/* This file is part of the FreeType project, and may only be used, */ |
@@ -49,55 +49,33 @@ |
#endif /* !FT_CONFIG_OPTION_PIC */ |
- /* index of default script in `af_script_classes' */ |
-#define AF_SCRIPT_LIST_DEFAULT 2 |
- /* 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 |
- |
- |
- /* |
- * Note that glyph_scripts[] is used to map each glyph into |
- * an index into the `af_script_classes' array. |
- * |
- */ |
- typedef struct AF_FaceGlobalsRec_ |
- { |
- FT_Face face; |
- FT_Long glyph_count; /* same as face->num_glyphs */ |
- FT_Byte* glyph_scripts; |
- |
- AF_ScriptMetrics metrics[AF_SCRIPT_MAX]; |
- |
- } AF_FaceGlobalsRec; |
- |
/* Compute the script index of each glyph within a given face. */ |
static FT_Error |
af_face_globals_compute_script_coverage( AF_FaceGlobals globals ) |
{ |
- FT_Error error = AF_Err_Ok; |
+ FT_Error error; |
FT_Face face = globals->face; |
FT_CharMap old_charmap = face->charmap; |
FT_Byte* gscripts = globals->glyph_scripts; |
- FT_UInt ss, i; |
+ FT_UInt ss; |
+ FT_UInt i; |
- /* the value AF_SCRIPT_LIST_NONE means `uncovered glyph' */ |
+ /* the value AF_SCRIPT_NONE means `uncovered glyph' */ |
FT_MEM_SET( globals->glyph_scripts, |
- AF_SCRIPT_LIST_NONE, |
+ AF_SCRIPT_NONE, |
globals->glyph_count ); |
error = FT_Select_Charmap( face, FT_ENCODING_UNICODE ); |
if ( error ) |
{ |
/* |
- * Ignore this error; we simply use the default script. |
+ * Ignore this error; we simply use the fallback script. |
* XXX: Shouldn't we rather disable hinting? |
*/ |
- error = AF_Err_Ok; |
+ error = FT_Err_Ok; |
goto Exit; |
} |
@@ -112,7 +90,7 @@ |
continue; |
/* |
- * Scan all unicode points in the range and set the corresponding |
+ * Scan all Unicode points in the range and set the corresponding |
* glyph script index. |
*/ |
for ( range = clazz->script_uni_ranges; range->first != 0; range++ ) |
@@ -125,7 +103,7 @@ |
if ( gindex != 0 && |
gindex < (FT_ULong)globals->glyph_count && |
- gscripts[gindex] == AF_SCRIPT_LIST_NONE ) |
+ gscripts[gindex] == AF_SCRIPT_NONE ) |
gscripts[gindex] = (FT_Byte)ss; |
for (;;) |
@@ -136,7 +114,7 @@ |
break; |
if ( gindex < (FT_ULong)globals->glyph_count && |
- gscripts[gindex] == AF_SCRIPT_LIST_NONE ) |
+ gscripts[gindex] == AF_SCRIPT_NONE ) |
gscripts[gindex] = (FT_Byte)ss; |
} |
} |
@@ -154,19 +132,20 @@ |
Exit: |
/* |
- * By default, all uncovered glyphs are set to the latin script. |
+ * By default, all uncovered glyphs are set to the fallback script. |
* XXX: Shouldn't we disable hinting or do something similar? |
*/ |
+ if ( globals->module->fallback_script != AF_SCRIPT_NONE ) |
{ |
FT_Long nn; |
for ( nn = 0; nn < globals->glyph_count; nn++ ) |
{ |
- if ( ( gscripts[nn] & ~AF_DIGIT ) == AF_SCRIPT_LIST_NONE ) |
+ if ( ( gscripts[nn] & ~AF_DIGIT ) == AF_SCRIPT_NONE ) |
{ |
- gscripts[nn] &= ~AF_SCRIPT_LIST_NONE; |
- gscripts[nn] |= AF_SCRIPT_LIST_DEFAULT; |
+ gscripts[nn] &= ~AF_SCRIPT_NONE; |
+ gscripts[nn] |= globals->module->fallback_script; |
} |
} |
} |
@@ -178,7 +157,8 @@ |
FT_LOCAL_DEF( FT_Error ) |
af_face_globals_new( FT_Face face, |
- AF_FaceGlobals *aglobals ) |
+ AF_FaceGlobals *aglobals, |
+ AF_Module module ) |
{ |
FT_Error error; |
FT_Memory memory; |
@@ -187,21 +167,25 @@ |
memory = face->memory; |
- if ( !FT_ALLOC( globals, sizeof ( *globals ) + |
- face->num_glyphs * sizeof ( FT_Byte ) ) ) |
- { |
- globals->face = face; |
- globals->glyph_count = face->num_glyphs; |
- globals->glyph_scripts = (FT_Byte*)( globals + 1 ); |
+ if ( FT_ALLOC( globals, sizeof ( *globals ) + |
+ face->num_glyphs * sizeof ( FT_Byte ) ) ) |
+ goto Exit; |
- error = af_face_globals_compute_script_coverage( globals ); |
- if ( error ) |
- { |
- af_face_globals_free( globals ); |
- globals = NULL; |
- } |
+ globals->face = face; |
+ globals->glyph_count = face->num_glyphs; |
+ globals->glyph_scripts = (FT_Byte*)( globals + 1 ); |
+ globals->module = module; |
+ |
+ error = af_face_globals_compute_script_coverage( globals ); |
+ if ( error ) |
+ { |
+ af_face_globals_free( globals ); |
+ globals = NULL; |
} |
+ globals->increase_x_height = AF_PROP_INCREASE_X_HEIGHT_MAX; |
+ |
+ Exit: |
*aglobals = globals; |
return error; |
} |
@@ -253,18 +237,18 @@ |
FT_UInt script = options & 15; |
const FT_Offset script_max = sizeof ( AF_SCRIPT_CLASSES_GET ) / |
sizeof ( AF_SCRIPT_CLASSES_GET[0] ); |
- FT_Error error = AF_Err_Ok; |
+ FT_Error error = FT_Err_Ok; |
if ( gindex >= (FT_ULong)globals->glyph_count ) |
{ |
- error = AF_Err_Invalid_Argument; |
+ error = FT_THROW( Invalid_Argument ); |
goto Exit; |
} |
gidx = script; |
if ( gidx == 0 || gidx + 1 >= script_max ) |
- gidx = globals->glyph_scripts[gindex] & AF_SCRIPT_LIST_NONE; |
+ gidx = globals->glyph_scripts[gindex] & AF_SCRIPT_NONE; |
clazz = AF_SCRIPT_CLASSES_GET[gidx]; |
if ( script == 0 ) |
@@ -273,14 +257,15 @@ |
metrics = globals->metrics[clazz->script]; |
if ( metrics == NULL ) |
{ |
- /* create the global metrics object when needed */ |
+ /* create the global metrics object if necessary */ |
FT_Memory memory = globals->face->memory; |
if ( FT_ALLOC( metrics, clazz->script_metrics_size ) ) |
goto Exit; |
- metrics->clazz = clazz; |
+ metrics->clazz = clazz; |
+ metrics->globals = globals; |
if ( clazz->script_metrics_init ) |
{ |