From 7734a1f720b185a3b0b6fe3b009202c58e0b5f18 Mon Sep 17 00:00:00 2001 From: Werner Lemberg Date: Wed, 5 Oct 2005 15:18:29 +0000 Subject: [PATCH] Add FT_FACE_FLAG_HINTER to indicate that a specific font driver has a hinting engine of its own. * include/freetype/freetype.h (FT_FACE_FLAG_HINTER): New macro. * src/cff/cffobjs.c (cff_face_init), src/cid/cidobjs.c (cid_face_init), src/truetype/ttobjs.c (tt_face_init) [TT_CONFIG_OPTION_BYTECODE_INTERPRETER], src/type1/t1objs.c (T1_Face_Init), src/type42/t42objs.c (T42_Face_Init) [TT_CONFIG_OPTION_BYTECODE_INTERPRETER]: Update face flags. * docs/CHANGES: Document it. --- ChangeLog | 15 +++++++++++++++ docs/CHANGES | 7 +++++++ include/freetype/freetype.h | 8 ++++++++ src/cff/cffobjs.c | 5 +++-- src/cid/cidobjs.c | 6 +++--- src/sfnt/sfobjs.c | 6 ++++-- src/truetype/ttobjs.c | 6 +++++- src/type1/t1objs.c | 9 +++++---- src/type42/t42objs.c | 10 +++++++--- 9 files changed, 57 insertions(+), 15 deletions(-) diff --git a/ChangeLog b/ChangeLog index 8122dbd9c..4d2d98dfd 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,18 @@ +2005-09-05 Werner Lemberg + + Add FT_FACE_FLAG_HINTER to indicate that a specific font driver has + a hinting engine of its own. + + * include/freetype/freetype.h (FT_FACE_FLAG_HINTER): New macro. + + * src/cff/cffobjs.c (cff_face_init), src/cid/cidobjs.c + (cid_face_init), src/truetype/ttobjs.c (tt_face_init) + [TT_CONFIG_OPTION_BYTECODE_INTERPRETER], src/type1/t1objs.c + (T1_Face_Init), src/type42/t42objs.c (T42_Face_Init) + [TT_CONFIG_OPTION_BYTECODE_INTERPRETER]: Update face flags. + + * docs/CHANGES: Document it. + 2005-09-27 Werner Lemberg * builds/unix/freetype2.m4: Add license exception so that the file diff --git a/docs/CHANGES b/docs/CHANGES index cfca7d953..0a9f3520c 100644 --- a/docs/CHANGES +++ b/docs/CHANGES @@ -33,6 +33,13 @@ LATEST CHANGES BETWEEN 2.2.0 and 2.1.10 III. MISCELLANEOUS + - A new face flag `FT_FACE_FLAG_HINTER' has been added which is + set if the font's driver has a hinting engine of its own. This + makes it possible to check at run-time whether the TrueType + bytecode interpreter has been activated. An example use is to + enable the interpretation of the `gasp' table only if native + TrueType hinting is available. + - The demo programs `ftview' and `ftstring' have been rewritten for better readability. diff --git a/include/freetype/freetype.h b/include/freetype/freetype.h index b1a357cfd..586e170fc 100644 --- a/include/freetype/freetype.h +++ b/include/freetype/freetype.h @@ -120,6 +120,7 @@ FT_BEGIN_HEADER /* FT_FACE_FLAG_GLYPH_NAMES */ /* FT_FACE_FLAG_EXTERNAL_STREAM */ /* FT_FACE_FLAG_FAST_GLYPHS */ + /* FT_FACE_FLAG_HINTER */ /* */ /* FT_STYLE_FLAG_BOLD */ /* FT_STYLE_FLAG_ITALIC */ @@ -1061,6 +1062,12 @@ FT_BEGIN_HEADER /* provided by the client application and should not be destroyed */ /* when @FT_Done_Face is called. Don't read or test this flag. */ /* */ + /* FT_FACE_FLAG_HINTER :: */ + /* Set if the font driver has a hinting machine of its own. For */ + /* example, with TrueType fonts, it makes sense to use data from */ + /* the SFNT `gasp' table only if the native TrueType hinting engine */ + /* (with the bytecode interpreter) is available and active. */ + /* */ #define FT_FACE_FLAG_SCALABLE ( 1L << 0 ) #define FT_FACE_FLAG_FIXED_SIZES ( 1L << 1 ) #define FT_FACE_FLAG_FIXED_WIDTH ( 1L << 2 ) @@ -1072,6 +1079,7 @@ FT_BEGIN_HEADER #define FT_FACE_FLAG_MULTIPLE_MASTERS ( 1L << 8 ) #define FT_FACE_FLAG_GLYPH_NAMES ( 1L << 9 ) #define FT_FACE_FLAG_EXTERNAL_STREAM ( 1L << 10 ) +#define FT_FACE_FLAG_HINTER ( 1L << 11 ) /* */ diff --git a/src/cff/cffobjs.c b/src/cff/cffobjs.c index 8522c1f1f..19ea482ab 100644 --- a/src/cff/cffobjs.c +++ b/src/cff/cffobjs.c @@ -636,8 +636,9 @@ /* */ /* Compute face flags. */ /* */ - flags = FT_FACE_FLAG_SCALABLE | /* scalable outlines */ - FT_FACE_FLAG_HORIZONTAL; /* horizontal data */ + flags = FT_FACE_FLAG_SCALABLE | /* scalable outlines */ + FT_FACE_FLAG_HORIZONTAL | /* horizontal data */ + FT_FACE_FLAG_HINTER; /* has native hinter */ if ( sfnt_format ) flags |= FT_FACE_FLAG_SFNT; diff --git a/src/cid/cidobjs.c b/src/cid/cidobjs.c index 3fb47bcce..efeb47e78 100644 --- a/src/cid/cidobjs.c +++ b/src/cid/cidobjs.c @@ -362,9 +362,9 @@ cidface->num_charmaps = 0; cidface->face_index = face_index; - cidface->face_flags = FT_FACE_FLAG_SCALABLE; - - cidface->face_flags |= FT_FACE_FLAG_HORIZONTAL; + cidface->face_flags = FT_FACE_FLAG_SCALABLE | /* scalable outlines */ + FT_FACE_FLAG_HORIZONTAL | /* horizontal data */ + FT_FACE_FLAG_HINTER; /* has native hinter */ if ( info->is_fixed_pitch ) cidface->face_flags |= FT_FACE_FLAG_FIXED_WIDTH; diff --git a/src/sfnt/sfobjs.c b/src/sfnt/sfobjs.c index 9e846624a..bb6752a73 100644 --- a/src/sfnt/sfobjs.c +++ b/src/sfnt/sfobjs.c @@ -536,9 +536,11 @@ /* Compute face flags. */ /* */ if ( has_outline == TRUE ) - flags |= FT_FACE_FLAG_SCALABLE; /* scalable outlines */ + flags |= FT_FACE_FLAG_SCALABLE; /* scalable outlines */ - flags |= FT_FACE_FLAG_SFNT | /* SFNT file format */ + /* The sfnt driver only supports bitmap fonts natively, thus we */ + /* don't set FT_FACE_FLAG_HINTER. */ + flags |= FT_FACE_FLAG_SFNT | /* SFNT file format */ FT_FACE_FLAG_HORIZONTAL; /* horizontal data */ #ifdef TT_CONFIG_OPTION_POSTSCRIPT_NAMES diff --git a/src/truetype/ttobjs.c b/src/truetype/ttobjs.c index b61d50cb8..e73efb6ae 100644 --- a/src/truetype/ttobjs.c +++ b/src/truetype/ttobjs.c @@ -203,7 +203,11 @@ goto Bad_Format; } - /* If we are performing a simple font format check, exit immediately */ +#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER + face->root.face_flags |= FT_FACE_FLAG_HINTER; +#endif + + /* If we are performing a simple font format check, exit immediately. */ if ( face_index < 0 ) return TT_Err_Ok; diff --git a/src/type1/t1objs.c b/src/type1/t1objs.c index 519fa08d9..0e5659088 100644 --- a/src/type1/t1objs.c +++ b/src/type1/t1objs.c @@ -4,7 +4,7 @@ /* */ /* Type 1 objects manager (body). */ /* */ -/* Copyright 1996-2001, 2002, 2003, 2004 by */ +/* Copyright 1996-2001, 2002, 2003, 2004, 2005 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -329,9 +329,10 @@ root->num_glyphs = type1->num_glyphs; root->face_index = face_index; - root->face_flags = FT_FACE_FLAG_SCALABLE; - root->face_flags |= FT_FACE_FLAG_HORIZONTAL; - root->face_flags |= FT_FACE_FLAG_GLYPH_NAMES; + root->face_flags = FT_FACE_FLAG_SCALABLE | + FT_FACE_FLAG_HORIZONTAL | + FT_FACE_FLAG_GLYPH_NAMES | + FT_FACE_FLAG_HINTER; if ( info->is_fixed_pitch ) root->face_flags |= FT_FACE_FLAG_FIXED_WIDTH; diff --git a/src/type42/t42objs.c b/src/type42/t42objs.c index d51a91cd5..814ad90a3 100644 --- a/src/type42/t42objs.c +++ b/src/type42/t42objs.c @@ -202,13 +202,17 @@ root->num_charmaps = 0; root->face_index = face_index; - root->face_flags = FT_FACE_FLAG_SCALABLE; - root->face_flags |= FT_FACE_FLAG_HORIZONTAL; - root->face_flags |= FT_FACE_FLAG_GLYPH_NAMES; + root->face_flags = FT_FACE_FLAG_SCALABLE | + FT_FACE_FLAG_HORIZONTAL | + FT_FACE_FLAG_GLYPH_NAMES; if ( info->is_fixed_pitch ) root->face_flags |= FT_FACE_FLAG_FIXED_WIDTH; +#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER + root->face_flags |= FT_FACE_FLAG_HINTER; +#endif + /* XXX: TODO -- add kerning with .afm support */ /* get style name -- be careful, some broken fonts only */