ref: f48b60ed59b3de5b08d8139ba8c3cfc662b7615a
parent: b8004d2e884fe0315a0bf072964356a126a5a016
author: David Turner <[email protected]>
date: Mon Jan 8 10:15:32 EST 2007
* 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 <freetype/ftgasp.h> * 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
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,20 @@
+2007-01-08 David Turner <[email protected]>
+
+ * 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 <freetype/ftgasp.h>
+
+ * 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 <[email protected]>
* src/cid/cidparse.c (cid_parser_new): Improve error message for
--- a/builds/win32/visualc/freetype.dsp
+++ b/builds/win32/visualc/freetype.dsp
@@ -226,6 +226,10 @@
# 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
--- a/builds/win32/visualc/freetype.vcproj
+++ b/builds/win32/visualc/freetype.vcproj
@@ -675,6 +675,10 @@
>
</File>
<File
+ RelativePath="..\..\..\src\base\ftgasp.c"
+ >
+ </File>
+ <File
RelativePath="..\..\..\src\cache\ftcache.c"
>
<FileConfiguration
--- a/include/freetype/config/ftheader.h
+++ b/include/freetype/config/ftheader.h
@@ -677,6 +677,19 @@
*/
#define FT_LCD_FILTER_H <freetype/ftlcdfil.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 <freetype/ftgasp.h>
+
+
/* */
#define FT_ERROR_DEFINITIONS_H <freetype/fterrdef.h>
--- /dev/null
+++ b/include/freetype/ftgasp.h
@@ -1,0 +1,65 @@
+#ifndef _FT_GASP_H_
+#define _FT_GASP_H_
+
+#include <ft2build.h>
+#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_ */
--- a/modules.cfg
+++ b/modules.cfg
@@ -216,6 +216,10 @@
# 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
--- a/src/base/Jamfile
+++ b/src/base/Jamfile
@@ -34,7 +34,7 @@
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 ;
--- /dev/null
+++ b/src/base/ftgasp.c
@@ -1,0 +1,38 @@
+#include <ft2build.h>
+#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;
+ }
+
+
--- a/src/base/rules.mk
+++ b/src/base/rules.mk
@@ -44,6 +44,7 @@
$(BASE_DIR)/ftrfork.c \
$(BASE_DIR)/ftstream.c \
$(BASE_DIR)/fttrigon.c \
+ $(BASE_DIR)/ftgasp.c \
$(BASE_DIR)/ftutil.c
# Base layer `extensions' sources
--- 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 ));