adding support for dummy script, i.e. no-hinting for non latin glyphs

This commit is contained in:
David Turner 2004-02-23 21:08:37 +00:00
parent 1029ed26af
commit 9bfbf79c9f
10 changed files with 80 additions and 12 deletions

View File

@ -1,3 +1,10 @@
2004-02-23 David Turner <david@freetype.org>
* src/autofit/afhints.c, src/autofit/afhints.h, src/autofit/aflatin.c,
src/autofit/afloader.c, src/types.h: grave bugs were fixed. The
auto-fitter works, doesn't crashes, but still produces unexpected
results !!
2004-02-21 Werner Lemberg <wl@gnu.org>
* src/pshinter/pshalgo.c (PSH_STRONG_THRESHOLD): Changed to hold

View File

@ -5,7 +5,7 @@ SubDir FT2_TOP src autofit ;
if $(FT2_MULTI)
{
_sources = afangles afglobal afhints aflatin afloader afmodule ;
_sources = afangles afglobal afhints aflatin afloader afmodule afdummy ;
}
else
{

35
src/autofit/afdummy.c Normal file
View File

@ -0,0 +1,35 @@
#include "afdummy.h"
static FT_Error
af_dummy_hints_init( AF_GlyphHints hints,
FT_Outline* outline,
AF_ScriptMetrics metrics )
{
return af_glyph_hints_reset( hints,
&metrics->scaler,
metrics,
outline );
}
static FT_Error
af_dummy_hints_apply( AF_GlyphHints hints,
FT_Outline* outline )
{
af_glyph_hints_save( hints, outline );
}
FT_LOCAL_DEF( const AF_ScriptClassRec ) af_dummy_script_class =
{
AF_SCRIPT_NONE,
NULL,
sizeof( AF_ScriptMetricsRec ),
(AF_Script_InitMetricsFunc) NULL,
(AF_Script_ScaleMetricsFunc) NULL,
(AF_Script_DoneMetricsFunc) NULL,
(AF_Script_InitHintsFunc) af_dummy_hints_init,
(AF_Script_ApplyHintsFunc) af_dummy_hints_apply
};

18
src/autofit/afdummy.h Normal file
View File

@ -0,0 +1,18 @@
#ifndef __AFDUMMY_H__
#define __AFDUMMY_H__
#include "aftypes.h"
FT_BEGIN_HEADER
/* a dummy script metrics class used when no hinting should
* be performed. This is the default for non-latin glyphs !
*/
FT_LOCAL( const AF_ScriptClassRec ) af_dummy_script_class;
/* */
FT_END_HEADER
#endif /* __AFDUMMY_H__ */

View File

@ -1,10 +1,12 @@
#include "afglobal.h"
#include "afdummy.h"
#include "aflatin.h"
/* populate this list when you add new scripts
*/
static AF_ScriptClass const af_script_classes[] =
{
& af_dummy_script_class,
& af_latin_script_class,
NULL /* do not remove */
@ -66,6 +68,9 @@
AF_ScriptClass clazz = af_script_classes[ss];
AF_Script_UniRange range;
if ( clazz->script_uni_ranges == NULL )
continue;
/* scan all unicode points in the range, and set the corresponding
* glyph script index
*/

View File

@ -389,13 +389,13 @@
if ( dim == AF_DIMENSION_HORZ )
{
metrics->scaler.x_scale = scale;
metrics->scaler.x_delta = delta;
metrics->root.scaler.x_scale = scale;
metrics->root.scaler.x_delta = delta;
}
else
{
metrics->scaler.y_scale = scale;
metrics->scaler.y_delta = delta;
metrics->root.scaler.y_scale = scale;
metrics->root.scaler.y_delta = delta;
}
/* scale the standard widths
@ -437,8 +437,6 @@
af_latin_metrics_scale( AF_LatinMetrics metrics,
AF_Scaler scaler )
{
metrics->scaler = scaler[0];
af_latin_metrics_scale_dim( metrics, scaler, AF_DIMENSION_HORZ );
af_latin_metrics_scale_dim( metrics, scaler, AF_DIMENSION_VERT );
}
@ -1146,7 +1144,7 @@
FT_Error error;
FT_Render_Mode mode;
error = af_glyph_hints_reset( hints, &metrics->scaler,
error = af_glyph_hints_reset( hints, &metrics->root.scaler,
(AF_ScriptMetrics) metrics,
outline );
if (error)
@ -1156,7 +1154,7 @@
/* compute flags depending on render mode, etc...
*/
mode = metrics->scaler.render_mode;
mode = metrics->root.scaler.render_mode;
/* we snap the width of vertical stems for the monochrome and
* horizontal LCD rendering targets only.

View File

@ -92,7 +92,6 @@ FT_BEGIN_HEADER
AF_ScriptMetricsRec root;
FT_UInt units_per_em;
AF_LatinAxisRec axis[ AF_DIMENSION_MAX ];
AF_ScalerRec scaler;
} AF_LatinMetricsRec, *AF_LatinMetrics;

View File

@ -426,7 +426,10 @@
{
loader->metrics = metrics;
metrics->clazz->script_metrics_scale( metrics, &scaler );
metrics->scaler = scaler;
if ( metrics->clazz->script_metrics_scale )
metrics->clazz->script_metrics_scale( metrics, &scaler );
load_flags |= FT_LOAD_NO_SCALE | FT_LOAD_IGNORE_TRANSFORM;
load_flags &= ~FT_LOAD_RENDER;

View File

@ -195,7 +195,8 @@ FT_BEGIN_HEADER
*/
typedef enum
{
AF_SCRIPT_LATIN = 0,
AF_SCRIPT_NONE = 0,
AF_SCRIPT_LATIN = 1,
/* add new scripts here. don't forget to update the list in "afglobal.c" */
AF_SCRIPT_MAX /* do not remove */
@ -209,6 +210,7 @@ FT_BEGIN_HEADER
typedef struct AF_ScriptMetricsRec_
{
AF_ScriptClass clazz;
AF_ScalerRec scaler;
} AF_ScriptMetricsRec, *AF_ScriptMetrics;

View File

@ -3,6 +3,7 @@
#include "afangles.c"
#include "afglobal.c"
#include "afhints.c"
#include "afdummy.c"
#include "aflatin.c"
#include "afloader.c"
#include "afmodule.c"