* 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
This commit is contained in:
David Turner 2007-01-08 15:15:32 +00:00
parent b8004d2e88
commit f48b60ed59
10 changed files with 155 additions and 1 deletions

View File

@ -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

View File

@ -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

View File

@ -674,6 +674,10 @@
RelativePath="..\..\..\src\base\ftbitmap.c"
>
</File>
<File
RelativePath="..\..\..\src\base\ftgasp.c"
>
</File>
<File
RelativePath="..\..\..\src\cache\ftcache.c"
>

View File

@ -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>

65
include/freetype/ftgasp.h Normal file
View File

@ -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_ */

View File

@ -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

View File

@ -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 ;

38
src/base/ftgasp.c Normal file
View File

@ -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;
}

View File

@ -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

View File

@ -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 ));