From f48b60ed59b3de5b08d8139ba8c3cfc662b7615a Mon Sep 17 00:00:00 2001 From: David Turner Date: Mon, 8 Jan 2007 15:15:32 +0000 Subject: [PATCH] * include/freetype/ftgasp.h, src/base/ftgasp.c: adding a new API FT_Get_Gasp to return entries of the GASP table corresponding to a given character pixel size. * src/sfnt/ttload.c: add version check for the GASP table, in order to be better future-proof * include/freetype/config/ftheader.h: add definition of FT_GASP_H, corresponding to * src/base/rules.mk, src/base/Jamfile, modules.cfg, builds/win32/visualc/freetype.dsp, builds/win32/visualc/freetype.vcproj: Adding src/base/ftgasp.c to the default build --- ChangeLog | 17 ++++++++ builds/win32/visualc/freetype.dsp | 4 ++ builds/win32/visualc/freetype.vcproj | 4 ++ include/freetype/config/ftheader.h | 13 ++++++ include/freetype/ftgasp.h | 65 ++++++++++++++++++++++++++++ modules.cfg | 4 ++ src/base/Jamfile | 2 +- src/base/ftgasp.c | 38 ++++++++++++++++ src/base/rules.mk | 1 + src/sfnt/ttload.c | 8 ++++ 10 files changed, 155 insertions(+), 1 deletion(-) create mode 100644 include/freetype/ftgasp.h create mode 100644 src/base/ftgasp.c diff --git a/ChangeLog b/ChangeLog index f26ab9344..26c722655 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,20 @@ +2007-01-08 David Turner + + * include/freetype/ftgasp.h, src/base/ftgasp.c: adding a + new API FT_Get_Gasp to return entries of the GASP table + corresponding to a given character pixel size. + + * src/sfnt/ttload.c: add version check for the GASP table, + in order to be better future-proof + + * include/freetype/config/ftheader.h: add definition of + FT_GASP_H, corresponding to + + * src/base/rules.mk, src/base/Jamfile, modules.cfg, + builds/win32/visualc/freetype.dsp, + builds/win32/visualc/freetype.vcproj: Adding src/base/ftgasp.c + to the default build + 2007-01-07 Werner Lemberg * src/cid/cidparse.c (cid_parser_new): Improve error message for diff --git a/builds/win32/visualc/freetype.dsp b/builds/win32/visualc/freetype.dsp index fb1f1a988..07e3552cc 100644 --- a/builds/win32/visualc/freetype.dsp +++ b/builds/win32/visualc/freetype.dsp @@ -226,6 +226,10 @@ SOURCE=..\..\..\src\base\ftbitmap.c # End Source File # Begin Source File +SOURCE=..\..\..\src\base\ftgasp.c +# End Source File +# Begin Source File + SOURCE=..\..\..\src\cache\ftcache.c # SUBTRACT CPP /Fr # End Source File diff --git a/builds/win32/visualc/freetype.vcproj b/builds/win32/visualc/freetype.vcproj index 1f7109b62..dc68555d6 100644 --- a/builds/win32/visualc/freetype.vcproj +++ b/builds/win32/visualc/freetype.vcproj @@ -674,6 +674,10 @@ RelativePath="..\..\..\src\base\ftbitmap.c" > + + diff --git a/include/freetype/config/ftheader.h b/include/freetype/config/ftheader.h index 126519109..0bec85073 100644 --- a/include/freetype/config/ftheader.h +++ b/include/freetype/config/ftheader.h @@ -677,6 +677,19 @@ */ #define FT_LCD_FILTER_H + + /************************************************************************* + * + * @macro: + * FT_GASP_H + * + * @description: + * A macro used in #include statements to name the file containing the + * FreeType 2 API which returns entries from the TrueType GASP table + */ +#define FT_GASP_H + + /* */ #define FT_ERROR_DEFINITIONS_H diff --git a/include/freetype/ftgasp.h b/include/freetype/ftgasp.h new file mode 100644 index 000000000..f6c14f7db --- /dev/null +++ b/include/freetype/ftgasp.h @@ -0,0 +1,65 @@ +#ifndef _FT_GASP_H_ +#define _FT_GASP_H_ + +#include +#include FT_FREETYPE_H + +/** + * @enum: FT_GASP_XXX + * + * @description: + * a list of values and/or bit-flags returned by the + * @FT_Get_Gasp function. + * + * @values: + * FT_GASP_NO_TABLE :: + * this special value means that there is no GASP table + * in this face. It's up to the client to decide what to + * do + * + * FT_GASP_DO_GRIDFIT :: + * indicates that grid-fitting/hinting should be + * performed at the specified ppem. This *really* + * means TrueType bytecode interpretation + * + * FT_GASP_DO_GRAY :: + * indicates that anti-aliased rendering should be + * performed at the specified ppem + * + * FT_GASP_SYMMETRIC_SMOOTHING :: + * indicates that smoothing along multiple axis + * must be used with ClearType. + * + * FT_GASP_SYMMETRIC_GRIDFIT :: + * indicates that grid-fitting must be used with + * ClearType's symmetric smoothing + */ +#define FT_GASP_NO_TABLE -1 +#define FT_GASP_DO_GRIDFIT 0x01 +#define FT_GASP_DO_GRAY 0x02 +#define FT_GASP_SYMMETRIC_SMOOTHING 0x08 +#define FT_GASP_SYMMETRIC_GRIDFIT 0x10 + + /** + * @func: FT_Get_Gasp + * + * @description: + * read the GASP table from a TrueType or OpenType font file + * and return the entry corresponding to a given character + * pixel size + * + * @input: + * face :: source face handle + * ppem :: vertical character pixel size + * + * @return: + * bit flags, or @FT_GASP_NO_TABLE is there is no GASP table + * in the face. + */ + FT_EXPORT( FT_Int ) + FT_Get_Gasp( FT_Face face, + FT_UInt ppem ); + +/* */ + +#endif /* _FT_GASP_H_ */ diff --git a/modules.cfg b/modules.cfg index 26a750669..6c924c07b 100644 --- a/modules.cfg +++ b/modules.cfg @@ -216,6 +216,10 @@ BASE_EXTENSIONS += ftxf86.c # See include/freetype/ftlcdfil.h for the API. BASE_EXTENSIONS += ftlcdfil.c +# Support for GASP table queries +# +# See include/freetype/ftgasp.h for the API +BASE_EXTENSIONS += ftgasp.c #### #### The components `ftsystem.c' (for memory allocation and stream I/O diff --git a/src/base/Jamfile b/src/base/Jamfile index c6ac6b36f..70fbbe841 100644 --- a/src/base/Jamfile +++ b/src/base/Jamfile @@ -34,7 +34,7 @@ SubDir FT2_TOP $(FT2_SRC_DIR) base ; local _sources = system init glyph mm bdf bbox debug xf86 type1 pfr stroke winfnt otval bitmap synth - gxval lcdfil + gxval lcdfil gasp ; Library $(FT2_LIB) : ft$(_sources).c ; diff --git a/src/base/ftgasp.c b/src/base/ftgasp.c new file mode 100644 index 000000000..27797bbff --- /dev/null +++ b/src/base/ftgasp.c @@ -0,0 +1,38 @@ +#include +#include FT_GASP_H +#include FT_INTERNAL_TRUETYPE_TYPES_H + + FT_EXPORT_DEF( FT_Int ) + FT_Get_Gasp( FT_Face face, + FT_UInt ppem ) + { + FT_Int result = FT_GASP_NO_TABLE; + + if ( face && FT_IS_SFNT(face) ) + { + TT_Face ttface = (TT_Face)face; + + if ( ttface->gasp.numRanges > 0 ) + { + TT_GaspRange range = ttface->gasp.gaspRanges; + TT_GaspRange range_end = range + ttface->gasp.numRanges; + + while ( ppem > range->maxPPEM ) + { + range++; + if ( range >= range_end ) + goto Exit; + } + + result = range->gaspFlag; + + /* ensure we don't have spurious bits */ + if ( ttface->gasp.version == 0 ) + result &= 3; + } + } + Exit: + return result; + } + + diff --git a/src/base/rules.mk b/src/base/rules.mk index c947ba999..a3a5ac0de 100644 --- a/src/base/rules.mk +++ b/src/base/rules.mk @@ -44,6 +44,7 @@ BASE_SRC := $(BASE_DIR)/ftcalc.c \ $(BASE_DIR)/ftrfork.c \ $(BASE_DIR)/ftstream.c \ $(BASE_DIR)/fttrigon.c \ + $(BASE_DIR)/ftgasp.c \ $(BASE_DIR)/ftutil.c # Base layer `extensions' sources diff --git a/src/sfnt/ttload.c b/src/sfnt/ttload.c index c81f80d5e..0801f8370 100644 --- a/src/sfnt/ttload.c +++ b/src/sfnt/ttload.c @@ -1138,6 +1138,14 @@ FT_FRAME_EXIT(); + /* only support versions 0 and 1 of the table */ + if ( face->gasp.version >= 2 ) + { + face->gasp.numRanges = 0; + error = FT_Err_Invalid_Table; + goto Exit; + } + num_ranges = face->gasp.numRanges; FT_TRACE3(( "numRanges: %u\n", num_ranges ));