* 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
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253
diff --git a/ChangeLog b/ChangeLog
index f26ab93..26c7226 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,20 @@
+2007-01-08 David Turner <david@freetype.org>
+
+ * 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 <wl@gnu.org>
* 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 fb1f1a9..07e3552 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 1f7109b..dc68555 100644
--- 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
diff --git a/include/freetype/config/ftheader.h b/include/freetype/config/ftheader.h
index 1265191..0bec850 100644
--- 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>
diff --git a/include/freetype/ftgasp.h b/include/freetype/ftgasp.h
new file mode 100644
index 0000000..f6c14f7
--- /dev/null
+++ b/include/freetype/ftgasp.h
@@ -0,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_ */
diff --git a/modules.cfg b/modules.cfg
index 26a7506..6c924c0 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 c6ac6b3..70fbbe8 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 0000000..27797bb
--- /dev/null
+++ b/src/base/ftgasp.c
@@ -0,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;
+ }
+
+
diff --git a/src/base/rules.mk b/src/base/rules.mk
index c947ba9..a3a5ac0 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 c81f80d..0801f83 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 ));