[FREETYPE]

Sync to version 2.4.4

svn path=/trunk/; revision=51542
This commit is contained in:
Timo Kreuzer 2011-05-02 09:43:01 +00:00
parent 19c2502076
commit 341e9e4d23
119 changed files with 19910 additions and 9066 deletions

File diff suppressed because it is too large Load diff

15896
reactos/lib/3rdparty/freetype/ChangeLog.23 vendored Normal file

File diff suppressed because it is too large Load diff

View file

@ -1,6 +1,6 @@
# FreeType 2 top Jamfile.
#
# Copyright 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 by
# Copyright 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 by
# David Turner, Robert Wilhelm, and Werner Lemberg.
#
# This file is part of the FreeType project, and may only be used, modified,
@ -194,7 +194,7 @@ rule RefDoc
actions RefDoc
{
python $(FT2_SRC)/tools/docmaker/docmaker.py --prefix=ft2 --title=FreeType-2.3.12 --output=$(DOC_DIR) $(FT2_INCLUDE)/freetype/*.h $(FT2_INCLUDE)/freetype/config/*.h
python $(FT2_SRC)/tools/docmaker/docmaker.py --prefix=ft2 --title=FreeType-2.4.4 --output=$(DOC_DIR) $(FT2_INCLUDE)/freetype/*.h $(FT2_INCLUDE)/freetype/config/*.h
}
RefDoc refdoc ;

View file

@ -9,8 +9,8 @@
is called `libttf'. They are *not* compatible!
FreeType 2.3.12
===============
FreeType 2.4.4
==============
Please read the docs/CHANGES file, it contains IMPORTANT
INFORMATION.
@ -26,9 +26,9 @@
and download one of the following files.
freetype-doc-2.3.12.tar.bz2
freetype-doc-2.3.12.tar.gz
ftdoc2312.zip
freetype-doc-2.4.4.tar.bz2
freetype-doc-2.4.4.tar.gz
ftdoc244.zip
Bugs

View file

@ -33,7 +33,7 @@ should work on all platforms which have GNU make (or makepp).
----------------------------------------------------------------------
Copyright 2005, 2006, 2007, 2008, 2009 by
Copyright 2005, 2006, 2007, 2008, 2009, 2010 by
David Turner, Robert Wilhelm, and Werner Lemberg.
This file is part of the FreeType project, and may only be used,
@ -43,4 +43,4 @@ this file you indicate that you have read the license and understand
and accept it fully.
--- end of README.CVS ---
--- end of README.git ---

View file

@ -1,6 +1,6 @@
#!/bin/sh
#
# Copyright 2002, 2003, 2004, 2005, 2006, 2008, 2009 by
# Copyright 2002, 2003, 2004, 2005, 2006, 2008, 2009, 2010 by
# David Turner, Robert Wilhelm, and Werner Lemberg.
#
# This file is part of the FreeType project, and may only be used, modified,
@ -78,10 +78,15 @@ if test $# -gt 0; then
done
fi
# build a dummy Makefile if we are not building in the source tree
# build a dummy Makefile if we are not building in the source tree;
# we use inodes to avoid issues with symbolic links
inode_src=`ls -id $abs_ft2_dir | awk '{print $1}'`
inode_dst=`ls -id $abs_curr_dir | awk '{print $1}'`
if test "$abs_curr_dir" != "$abs_ft2_dir"; then
mkdir reference
if test $inode_src -ne $inode_dst; then
if test ! -d reference; then
mkdir reference
fi
if test ! -r $abs_curr_dir/modules.cfg; then
echo "Copying \`modules.cfg'"
cp $abs_ft2_dir/modules.cfg $abs_curr_dir
@ -91,7 +96,7 @@ if test "$abs_curr_dir" != "$abs_ft2_dir"; then
echo "OBJ_DIR := $abs_curr_dir" >> Makefile
echo "OBJ_BUILD := \$(OBJ_DIR)" >> Makefile
echo "DOC_DIR := \$(OBJ_DIR)/reference" >> Makefile
echo "LIBTOOL := \$(OBJ_DIR)/libtool" >> Makefile
echo "FT_LIBTOOL_DIR := \$(OBJ_DIR)" >> Makefile
echo "ifndef FT2DEMOS" >> Makefile
echo " include \$(TOP_DIR)/Makefile" >> Makefile
echo "else" >> Makefile

View file

@ -488,8 +488,7 @@ FT_BEGIN_HEADER
/*************************************************************************/
/* */
/* Define TT_CONFIG_OPTION_BYTECODE_INTERPRETER if you want to compile */
/* a bytecode interpreter in the TrueType driver. Note that there are */
/* important patent issues related to the use of the interpreter. */
/* a bytecode interpreter in the TrueType driver. */
/* */
/* By undefining this, you will only compile the code necessary to load */
/* TrueType glyphs without hinting. */
@ -504,10 +503,13 @@ FT_BEGIN_HEADER
/* */
/* If you define TT_CONFIG_OPTION_UNPATENTED_HINTING, a special version */
/* of the TrueType bytecode interpreter is used that doesn't implement */
/* any of the patented opcodes and algorithms. Note that the */
/* TT_CONFIG_OPTION_UNPATENTED_HINTING macro is *ignored* if you define */
/* TT_CONFIG_OPTION_BYTECODE_INTERPRETER; in other words, either define */
/* TT_CONFIG_OPTION_BYTECODE_INTERPRETER or */
/* any of the patented opcodes and algorithms. The patents related to */
/* TrueType hinting have expired worldwide since May 2010; this option */
/* is now deprecated. */
/* */
/* Note that the TT_CONFIG_OPTION_UNPATENTED_HINTING macro is *ignored* */
/* if you define TT_CONFIG_OPTION_BYTECODE_INTERPRETER; in other words, */
/* either define TT_CONFIG_OPTION_BYTECODE_INTERPRETER or */
/* TT_CONFIG_OPTION_UNPATENTED_HINTING but not both at the same time. */
/* */
/* This macro is only useful for a small number of font files (mostly */
@ -687,7 +689,28 @@ FT_BEGIN_HEADER
* is recommended to disable the macro since it reduces the library's code
* size and activates a few memory-saving optimizations as well.
*/
/* #define FT_CONFIG_OPTION_OLD_INTERNALS */
/* #define FT_CONFIG_OPTION_OLD_INTERNALS xxx */
/*
* To detect legacy cache-lookup call from a rogue client (<= 2.1.7),
* we restrict the number of charmaps in a font. The current API of
* FTC_CMapCache_Lookup() takes cmap_index & charcode, but old API
* takes charcode only. To determine the passed value is for cmap_index
* or charcode, the possible cmap_index is restricted not to exceed
* the minimum possible charcode by a rogue client. It is also very
* unlikely that a rogue client is interested in Unicode values 0 to 15.
*
* NOTE: The original threshold was 4 deduced from popular number of
* cmap subtables in UCS-4 TrueType fonts, but now it is not
* irregular for OpenType fonts to have more than 4 subtables,
* because variation selector subtables are available for Apple
* and Microsoft platforms.
*/
#ifdef FT_CONFIG_OPTION_OLD_INTERNALS
#define FT_MAX_CHARMAP_CACHEABLE 15
#endif
/*

View file

@ -4,12 +4,6 @@
<include base="freetype">include</include>
<define name="__NTDRIVER__" />
<define name="FT2_BUILD_LIBRARY" />
<if property="NSWPAT" value="0">
<define name="TT_CONFIG_OPTION_UNPATENTED_HINTING" />
</if>
<if property="NSWPAT" value="1">
<define name="TT_CONFIG_OPTION_BYTECODE_INTERPRETER" />
</if>
<directory name="src">
<directory name="base">
<file>ftbase.c</file>

View file

@ -363,7 +363,7 @@ FT_BEGIN_HEADER
#endif /* __arm__ && !__thumb__ && !( __CC_ARM || __ARMCC__ ) */
#if defined( i386 )
#if defined( __i386__ )
#define FT_MULFIX_ASSEMBLER FT_MulFix_i386
/* documentation is in freetype.h */

View file

@ -317,7 +317,7 @@ FT_BEGIN_HEADER
/* supply font data incrementally as the document is parsed, such */
/* as the Ghostscript interpreter for the PostScript language. */
/* */
/* #define FT_CONFIG_OPTION_INCREMENTAL */
#define FT_CONFIG_OPTION_INCREMENTAL
/*************************************************************************/
@ -488,8 +488,7 @@ FT_BEGIN_HEADER
/*************************************************************************/
/* */
/* Define TT_CONFIG_OPTION_BYTECODE_INTERPRETER if you want to compile */
/* a bytecode interpreter in the TrueType driver. Note that there are */
/* important patent issues related to the use of the interpreter. */
/* a bytecode interpreter in the TrueType driver. */
/* */
/* By undefining this, you will only compile the code necessary to load */
/* TrueType glyphs without hinting. */
@ -497,17 +496,20 @@ FT_BEGIN_HEADER
/* Do not #undef this macro here, since the build system might */
/* define it for certain configurations only. */
/* */
/* #define TT_CONFIG_OPTION_BYTECODE_INTERPRETER */
#define TT_CONFIG_OPTION_BYTECODE_INTERPRETER
/*************************************************************************/
/* */
/* If you define TT_CONFIG_OPTION_UNPATENTED_HINTING, a special version */
/* of the TrueType bytecode interpreter is used that doesn't implement */
/* any of the patented opcodes and algorithms. Note that the */
/* TT_CONFIG_OPTION_UNPATENTED_HINTING macro is *ignored* if you define */
/* TT_CONFIG_OPTION_BYTECODE_INTERPRETER; in other words, either define */
/* TT_CONFIG_OPTION_BYTECODE_INTERPRETER or */
/* any of the patented opcodes and algorithms. The patents related to */
/* TrueType hinting have expired worldwide since May 2010; this option */
/* is now deprecated. */
/* */
/* Note that the TT_CONFIG_OPTION_UNPATENTED_HINTING macro is *ignored* */
/* if you define TT_CONFIG_OPTION_BYTECODE_INTERPRETER; in other words, */
/* either define TT_CONFIG_OPTION_BYTECODE_INTERPRETER or */
/* TT_CONFIG_OPTION_UNPATENTED_HINTING but not both at the same time. */
/* */
/* This macro is only useful for a small number of font files (mostly */
@ -544,7 +546,7 @@ FT_BEGIN_HEADER
/* ... */
/* } */
/* */
//#define TT_CONFIG_OPTION_UNPATENTED_HINTING
/* #define TT_CONFIG_OPTION_UNPATENTED_HINTING */
/*************************************************************************/
@ -690,6 +692,27 @@ FT_BEGIN_HEADER
#define FT_CONFIG_OPTION_OLD_INTERNALS
/*
* To detect legacy cache-lookup call from a rogue client (<= 2.1.7),
* we restrict the number of charmaps in a font. The current API of
* FTC_CMapCache_Lookup() takes cmap_index & charcode, but old API
* takes charcode only. To determine the passed value is for cmap_index
* or charcode, the possible cmap_index is restricted not to exceed
* the minimum possible charcode by a rogue client. It is also very
* unlikely that a rogue client is interested in Unicode values 0 to 15.
*
* NOTE: The original threshold was 4 deduced from popular number of
* cmap subtables in UCS-4 TrueType fonts, but now it is not
* irregular for OpenType fonts to have more than 4 subtables,
* because variation selector subtables are available for Apple
* and Microsoft platforms.
*/
#ifdef FT_CONFIG_OPTION_OLD_INTERNALS
#define FT_MAX_CHARMAP_CACHEABLE 15
#endif
/*
* This macro is defined if either unpatented or native TrueType
* hinting is requested by the definitions above.

View file

@ -1952,6 +1952,9 @@ FT_BEGIN_HEADER
/* Each new face object created with this function also owns a */
/* default @FT_Size object, accessible as `face->size'. */
/* */
/* See the discussion of reference counters in the description of */
/* @FT_Reference_Face. */
/* */
FT_EXPORT( FT_Error )
FT_Open_Face( FT_Library library,
const FT_Open_Args* args,
@ -2016,6 +2019,33 @@ FT_BEGIN_HEADER
FT_Open_Args* parameters );
/*************************************************************************/
/* */
/* <Function> */
/* FT_Reference_Face */
/* */
/* <Description> */
/* A counter gets initialized to~1 at the time an @FT_Face structure */
/* is created. This function increments the counter. @FT_Done_Face */
/* then only destroys a face if the counter is~1, otherwise it simply */
/* decrements the counter. */
/* */
/* This function helps in managing life-cycles of structures which */
/* reference @FT_Face objects. */
/* */
/* <Input> */
/* face :: A handle to a target face object. */
/* */
/* <Return> */
/* FreeType error code. 0~means success. */
/* */
/* <Since> */
/* 2.4.2 */
/* */
FT_EXPORT( FT_Error )
FT_Reference_Face( FT_Face face );
/*************************************************************************/
/* */
/* <Function> */
@ -2031,6 +2061,10 @@ FT_BEGIN_HEADER
/* <Return> */
/* FreeType error code. 0~means success. */
/* */
/* <Note> */
/* See the discussion of reference counters in the description of */
/* @FT_Reference_Face. */
/* */
FT_EXPORT( FT_Error )
FT_Done_Face( FT_Face face );
@ -2997,7 +3031,7 @@ FT_BEGIN_HEADER
*
* @return:
* The index into the array of character maps within the face to which
* `charmap' belongs.
* `charmap' belongs. If an error occurs, -1 is returned.
*
*/
FT_EXPORT( FT_Int )
@ -3773,8 +3807,8 @@ FT_BEGIN_HEADER
*
*/
#define FREETYPE_MAJOR 2
#define FREETYPE_MINOR 3
#define FREETYPE_PATCH 12
#define FREETYPE_MINOR 4
#define FREETYPE_PATCH 4
/*************************************************************************/
@ -3834,6 +3868,9 @@ FT_BEGIN_HEADER
/* 1~if this is a TrueType font that uses one of the patented */
/* opcodes, 0~otherwise. */
/* */
/* <Note> */
/* Since May 2010, TrueType hinting is no longer patented. */
/* */
/* <Since> */
/* 2.3.5 */
/* */
@ -3861,6 +3898,9 @@ FT_BEGIN_HEADER
/* an SFNT font, or if the unpatented hinter is not compiled in this */
/* instance of the library. */
/* */
/* <Note> */
/* Since May 2010, TrueType hinting is no longer patented. */
/* */
/* <Since> */
/* 2.3.5 */
/* */

View file

@ -4,7 +4,7 @@
/* */
/* FreeType Cache subsystem (specification). */
/* */
/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 by */
/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2010 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@ -56,9 +56,12 @@ FT_BEGIN_HEADER
* interpret them in any way.
*
* Second, the cache calls, only when needed, a client-provided function
* to convert a @FTC_FaceID into a new @FT_Face object. The latter is
* to convert an @FTC_FaceID into a new @FT_Face object. The latter is
* then completely managed by the cache, including its termination
* through @FT_Done_Face.
* through @FT_Done_Face. To monitor termination of face objects, the
* finalizer callback in the `generic' field of the @FT_Face object can
* be used, which might also be used to store the @FTC_FaceID of the
* face.
*
* Clients are free to map face IDs to anything else. The most simple
* usage is to associate them to a (pathname,face_index) pair that is
@ -211,12 +214,17 @@ FT_BEGIN_HEADER
/* */
#ifdef FT_CONFIG_OPTION_OLD_INTERNALS
/* these macros are incompatible with LLP64, should not be used */
#define FT_POINTER_TO_ULONG( p ) ( (FT_ULong)(FT_Pointer)(p) )
#define FTC_FACE_ID_HASH( i ) \
((FT_UInt32)(( FT_POINTER_TO_ULONG( i ) >> 3 ) ^ \
( FT_POINTER_TO_ULONG( i ) << 7 ) ) )
#endif /* FT_CONFIG_OPTION_OLD_INTERNALS */
/*************************************************************************/
/*************************************************************************/
@ -263,10 +271,10 @@ FT_BEGIN_HEADER
/* reference-counted. A node with a count of~0 might be flushed */
/* out of a full cache whenever a lookup request is performed. */
/* */
/* If you lookup nodes, you have the ability to `acquire' them, i.e., */
/* to increment their reference count. This will prevent the node */
/* from being flushed out of the cache until you explicitly `release' */
/* it (see @FTC_Node_Unref). */
/* If you look up nodes, you have the ability to `acquire' them, */
/* i.e., to increment their reference count. This will prevent the */
/* node from being flushed out of the cache until you explicitly */
/* `release' it (see @FTC_Node_Unref). */
/* */
/* See also @FTC_SBitCache_Lookup and @FTC_ImageCache_Lookup. */
/* */
@ -697,11 +705,17 @@ FT_BEGIN_HEADER
(d1)->width == (d2)->width && \
(d1)->flags == (d2)->flags )
#ifdef FT_CONFIG_OPTION_OLD_INTERNALS
/* this macro is incompatible with LLP64, should not be used */
#define FTC_IMAGE_TYPE_HASH( d ) \
(FT_UFast)( FTC_FACE_ID_HASH( (d)->face_id ) ^ \
( (d)->width << 8 ) ^ (d)->height ^ \
( (d)->flags << 4 ) )
#endif /* FT_CONFIG_OPTION_OLD_INTERNALS */
/*************************************************************************/
/* */
@ -1093,6 +1107,7 @@ FT_BEGIN_HEADER
(f1)->pix_width == (f2)->pix_width && \
(f1)->pix_height == (f2)->pix_height )
/* this macro is incompatible with LLP64, should not be used */
#define FTC_FONT_HASH( f ) \
(FT_UInt32)( FTC_FACE_ID_HASH((f)->face_id) ^ \
((f)->pix_width << 8) ^ \

View file

@ -4,7 +4,7 @@
/* */
/* FreeType error codes (specification). */
/* */
/* Copyright 2002, 2004, 2006, 2007 by */
/* Copyright 2002, 2004, 2006, 2007, 2010 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@ -211,6 +211,9 @@
"argument stack underflow" )
FT_ERRORDEF_( Ignore, 0xA2, \
"ignore" )
FT_ERRORDEF_( No_Unicode_Glyph_Name, 0xA3, \
"no Unicode glyph name found" )
/* BDF errors */
@ -220,19 +223,21 @@
"`FONT' field missing" )
FT_ERRORDEF_( Missing_Size_Field, 0xB2, \
"`SIZE' field missing" )
FT_ERRORDEF_( Missing_Chars_Field, 0xB3, \
FT_ERRORDEF_( Missing_Fontboundingbox_Field, 0xB3, \
"`FONTBOUNDINGBOX' field missing" )
FT_ERRORDEF_( Missing_Chars_Field, 0xB4, \
"`CHARS' field missing" )
FT_ERRORDEF_( Missing_Startchar_Field, 0xB4, \
FT_ERRORDEF_( Missing_Startchar_Field, 0xB5, \
"`STARTCHAR' field missing" )
FT_ERRORDEF_( Missing_Encoding_Field, 0xB5, \
FT_ERRORDEF_( Missing_Encoding_Field, 0xB6, \
"`ENCODING' field missing" )
FT_ERRORDEF_( Missing_Bbx_Field, 0xB6, \
FT_ERRORDEF_( Missing_Bbx_Field, 0xB7, \
"`BBX' field missing" )
FT_ERRORDEF_( Bbx_Too_Big, 0xB7, \
FT_ERRORDEF_( Bbx_Too_Big, 0xB8, \
"`BBX' too big" )
FT_ERRORDEF_( Corrupted_Font_Header, 0xB8, \
FT_ERRORDEF_( Corrupted_Font_Header, 0xB9, \
"Font header corrupted or missing fields" )
FT_ERRORDEF_( Corrupted_Font_Glyphs, 0xB9, \
FT_ERRORDEF_( Corrupted_Font_Glyphs, 0xBA, \
"Font glyphs corrupted or missing fields" )

View file

@ -268,9 +268,21 @@ FT_BEGIN_HEADER
/* flow. In all cases, the pitch is an offset to add */
/* to a bitmap pointer in order to go down one row. */
/* */
/* Note that `padding' means the alignment of a */
/* bitmap to a byte border, and FreeType functions */
/* normally align to the smallest possible integer */
/* value. */
/* */
/* For the B/W rasterizer, `pitch' is always an even */
/* number. */
/* */
/* To change the pitch of a bitmap (say, to make it a */
/* multiple of 4), use @FT_Bitmap_Convert. */
/* Alternatively, you might use callback functions to */
/* directly render to the application's surface; see */
/* the file `example2.cpp' in the tutorial for a */
/* demonstration. */
/* */
/* buffer :: A typeless pointer to the bitmap buffer. This */
/* value should be aligned on 32-bit boundaries in */
/* most cases. */

View file

@ -5,7 +5,7 @@
/* FreeType API for color filtering of subpixel bitmap glyphs */
/* (specification). */
/* */
/* Copyright 2006, 2007, 2008 by */
/* Copyright 2006, 2007, 2008, 2010 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@ -58,7 +58,7 @@ FT_BEGIN_HEADER
/****************************************************************************
*
* @func:
* @enum:
* FT_LcdFilter
*
* @description:
@ -161,6 +161,47 @@ FT_BEGIN_HEADER
FT_Library_SetLcdFilter( FT_Library library,
FT_LcdFilter filter );
/**************************************************************************
*
* @func:
* FT_Library_SetLcdFilterWeights
*
* @description:
* Use this function to override the filter weights selected by
* @FT_Library_SetLcdFilter. By default, FreeType uses the quintuple
* (0x00, 0x55, 0x56, 0x55, 0x00) for FT_LCD_FILTER_LIGHT, and (0x10,
* 0x40, 0x70, 0x40, 0x10) for FT_LCD_FILTER_DEFAULT and
* FT_LCD_FILTER_LEGACY.
*
* @input:
* library ::
* A handle to the target library instance.
*
* weights ::
* A pointer to an array; the function copies the first five bytes and
* uses them to specify the filter weights.
*
* @return:
* FreeType error code. 0~means success.
*
* @note:
* Due to *PATENTS* covering subpixel rendering, this function doesn't
* do anything except returning `FT_Err_Unimplemented_Feature' if the
* configuration macro FT_CONFIG_OPTION_SUBPIXEL_RENDERING is not
* defined in your build of the library, which should correspond to all
* default builds of FreeType.
*
* This function must be called after @FT_Library_SetLcdFilter to have
* any effect.
*
* @since:
* 2.4.0
*/
FT_EXPORT( FT_Error )
FT_Library_SetLcdFilterWeights( FT_Library library,
unsigned char *weights );
/* */

View file

@ -4,7 +4,7 @@
/* */
/* Generic list support for FreeType (specification). */
/* */
/* Copyright 1996-2001, 2003, 2007 by */
/* Copyright 1996-2001, 2003, 2007, 2010 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@ -255,6 +255,10 @@ FT_BEGIN_HEADER
/* user :: A user-supplied field which is passed as the last */
/* argument to the destructor. */
/* */
/* <Note> */
/* This function expects that all nodes added by @FT_List_Add or */
/* @FT_List_Insert have been dynamically allocated. */
/* */
FT_EXPORT( void )
FT_List_Finalize( FT_List list,
FT_List_Destructor destroy,

View file

@ -4,7 +4,7 @@
/* */
/* FreeType modules public interface (specification). */
/* */
/* Copyright 1996-2001, 2002, 2003, 2006, 2008, 2009 by */
/* Copyright 1996-2001, 2002, 2003, 2006, 2008, 2009, 2010 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@ -249,6 +249,33 @@ FT_BEGIN_HEADER
FT_Module module );
/*************************************************************************/
/* */
/* <Function> */
/* FT_Reference_Library */
/* */
/* <Description> */
/* A counter gets initialized to~1 at the time an @FT_Library */
/* structure is created. This function increments the counter. */
/* @FT_Done_Library then only destroys a library if the counter is~1, */
/* otherwise it simply decrements the counter. */
/* */
/* This function helps in managing life-cycles of structures which */
/* reference @FT_Library objects. */
/* */
/* <Input> */
/* library :: A handle to a target library object. */
/* */
/* <Return> */
/* FreeType error code. 0~means success. */
/* */
/* <Since> */
/* 2.4.2 */
/* */
FT_EXPORT( FT_Error )
FT_Reference_Library( FT_Library library );
/*************************************************************************/
/* */
/* <Function> */
@ -263,6 +290,9 @@ FT_BEGIN_HEADER
/* @FT_Add_Default_Modules or a series of calls to @FT_Add_Module) */
/* instead of @FT_Init_FreeType to initialize the FreeType library. */
/* */
/* Don't use @FT_Done_FreeType but @FT_Done_Library to destroy a */
/* library instance. */
/* */
/* <Input> */
/* memory :: A handle to the original memory object. */
/* */
@ -272,6 +302,10 @@ FT_BEGIN_HEADER
/* <Return> */
/* FreeType error code. 0~means success. */
/* */
/* <Note> */
/* See the discussion of reference counters in the description of */
/* @FT_Reference_Library. */
/* */
FT_EXPORT( FT_Error )
FT_New_Library( FT_Memory memory,
FT_Library *alibrary );
@ -292,6 +326,10 @@ FT_BEGIN_HEADER
/* <Return> */
/* FreeType error code. 0~means success. */
/* */
/* <Note> */
/* See the discussion of reference counters in the description of */
/* @FT_Reference_Library. */
/* */
FT_EXPORT( FT_Error )
FT_Done_Library( FT_Library library );
@ -394,8 +432,8 @@ FT_BEGIN_HEADER
*
* FT_TRUETYPE_ENGINE_TYPE_PATENTED ::
* The library implements a bytecode interpreter that covers
* the full instruction set of the TrueType virtual machine.
* See the file `docs/PATENTS' for legal aspects.
* the full instruction set of the TrueType virtual machine (this
* was governed by patents until May 2010, hence the name).
*
* @since:
* 2.2

View file

@ -4,7 +4,7 @@
/* */
/* FreeType renderer modules public interface (specification). */
/* */
/* Copyright 1996-2001, 2005, 2006 by */
/* Copyright 1996-2001, 2005, 2006, 2010 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@ -141,10 +141,6 @@ FT_BEGIN_HEADER
/* raster_class :: For @FT_GLYPH_FORMAT_OUTLINE renderers only. */
/* This is a pointer to its raster's class. */
/* */
/* raster :: For @FT_GLYPH_FORMAT_OUTLINE renderers only. */
/* This is a pointer to the corresponding raster */
/* object, if any. */
/* */
typedef struct FT_Renderer_Class_
{
FT_Module_Class root;

View file

@ -4,7 +4,7 @@
/* */
/* FreeType low-level system interface definition (specification). */
/* */
/* Copyright 1996-2001, 2002, 2005 by */
/* Copyright 1996-2001, 2002, 2005, 2010 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@ -240,7 +240,8 @@ FT_BEGIN_HEADER
*
* @note:
* This function might be called to perform a seek or skip operation
* with a `count' of~0.
* with a `count' of~0. A non-zero return value then indicates an
* error.
*
*/
typedef unsigned long
@ -301,7 +302,7 @@ FT_BEGIN_HEADER
* The stream's input function.
*
* close ::
* The stream;s close function.
* The stream's close function.
*
* memory ::
* The memory manager to use to preload frames. This is set

View file

@ -4,7 +4,7 @@
/* */
/* The FreeType memory management macros (specification). */
/* */
/* Copyright 1996-2001, 2002, 2004, 2005, 2006, 2007 by */
/* Copyright 1996-2001, 2002, 2004, 2005, 2006, 2007, 2010 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg */
/* */
/* This file is part of the FreeType project, and may only be used, */
@ -58,15 +58,27 @@ FT_BEGIN_HEADER
/*
* C++ refuses to handle statements like p = (void*)anything; where `p'
* is a typed pointer. Since we don't have a `typeof' operator in
* standard C++, we have to use ugly casts.
* C++ refuses to handle statements like p = (void*)anything, with `p' a
* typed pointer. Since we don't have a `typeof' operator in standard
* C++, we have to use a template to emulate it.
*/
#ifdef __cplusplus
#define FT_ASSIGNP( p, val ) *((void**)&(p)) = (val)
extern "C++"
template <typename T> inline T*
cplusplus_typeof( T*,
void *v )
{
return static_cast <T*> ( v );
}
#define FT_ASSIGNP( p, val ) (p) = cplusplus_typeof( (p), (val) )
#else
#define FT_ASSIGNP( p, val ) (p) = (val)
#endif

View file

@ -4,7 +4,7 @@
/* */
/* The FreeType private base classes (specification). */
/* */
/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006, 2008 by */
/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006, 2008, 2010 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@ -311,6 +311,12 @@ FT_BEGIN_HEADER
/* in the case when the unpatented hinter is compiled within the */
/* library. */
/* */
/* refcount :: */
/* A counter initialized to~1 at the time an @FT_Face structure is */
/* created. @FT_Reference_Face increments this counter, and */
/* @FT_Done_Face only destroys a face if the counter is~1, */
/* otherwise it simply decrements it. */
/* */
typedef struct FT_Face_InternalRec_
{
#ifdef FT_CONFIG_OPTION_OLD_INTERNALS
@ -328,6 +334,7 @@ FT_BEGIN_HEADER
#endif
FT_Bool ignore_unpatented_hinter;
FT_UInt refcount;
} FT_Face_InternalRec;
@ -805,10 +812,28 @@ FT_BEGIN_HEADER
/* */
/* debug_hooks :: XXX */
/* */
/* lcd_filter :: If subpixel rendering is activated, the */
/* selected LCD filter mode. */
/* */
/* lcd_extra :: If subpixel rendering is activated, the number */
/* of extra pixels needed for the LCD filter. */
/* */
/* lcd_weights :: If subpixel rendering is activated, the LCD */
/* filter weights, if any. */
/* */
/* lcd_filter_func :: If subpixel rendering is activated, the LCD */
/* filtering callback function. */
/* */
/* pic_container :: Contains global structs and tables, instead */
/* of defining them globallly. */
/* */
/* refcount :: A counter initialized to~1 at the time an */
/* @FT_Library structure is created. */
/* @FT_Reference_Library increments this counter, */
/* and @FT_Done_Library only destroys a library */
/* if the counter is~1, otherwise it simply */
/* decrements it. */
/* */
typedef struct FT_LibraryRec_
{
FT_Memory memory; /* library's memory manager */
@ -843,6 +868,8 @@ FT_BEGIN_HEADER
FT_PIC_Container pic_container;
#endif
FT_UInt refcount;
} FT_LibraryRec;

View file

@ -64,7 +64,7 @@ FT_BEGIN_HEADER
* MacOS systems (even if they contain a Microsoft charmap as well).
*
* TT_PLATFORM_ISO ::
* This value was used to specify Unicode charmaps. It is however
* This value was used to specify ISO/IEC 10646 charmaps. It is however
* now deprecated. See @TT_ISO_ID_XXX for a list of corresponding
* `encoding_id' values.
*

View file

@ -5,7 +5,7 @@
/* Basic SFNT/TrueType tables definitions and interface */
/* (specification only). */
/* */
/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2008, 2009 by */
/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2008, 2009, 2010 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@ -557,13 +557,13 @@ FT_BEGIN_HEADER
/* */
typedef enum FT_Sfnt_Tag_
{
ft_sfnt_head = 0,
ft_sfnt_maxp = 1,
ft_sfnt_os2 = 2,
ft_sfnt_hhea = 3,
ft_sfnt_vhea = 4,
ft_sfnt_post = 5,
ft_sfnt_pclt = 6,
ft_sfnt_head = 0, /* TT_Header */
ft_sfnt_maxp = 1, /* TT_MaxProfile */
ft_sfnt_os2 = 2, /* TT_OS2 */
ft_sfnt_hhea = 3, /* TT_HoriHeader */
ft_sfnt_vhea = 4, /* TT_VertHeader */
ft_sfnt_post = 5, /* TT_Postscript */
ft_sfnt_pclt = 6, /* TT_PCLT */
sfnt_max /* internal end mark */
@ -590,6 +590,9 @@ FT_BEGIN_HEADER
/* error, or if the corresponding table was not found *OR* loaded */
/* from the file. */
/* */
/* Use a typecast according to `tag' to access the structure */
/* elements. */
/* */
/* <Note> */
/* The table is owned by the face object and disappears with it. */
/* */

View file

@ -4,7 +4,7 @@
/* */
/* Auto-fitter hinting routines for CJK script (body). */
/* */
/* Copyright 2006, 2007, 2008, 2009 by */
/* Copyright 2006, 2007, 2008, 2009, 2010 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@ -1371,7 +1371,7 @@
FT_UNUSED( metrics );
error = af_glyph_hints_reload( hints, outline, 0 );
error = af_glyph_hints_reload( hints, outline );
if ( error )
goto Exit;

View file

@ -4,7 +4,7 @@
/* */
/* Auto-fitter routines to compute global hinting values (body). */
/* */
/* Copyright 2003, 2004, 2005, 2006, 2007, 2008, 2009 by */
/* Copyright 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@ -167,8 +167,11 @@
for ( nn = 0; nn < globals->glyph_count; nn++ )
{
if ( gscripts[nn] == AF_SCRIPT_LIST_NONE )
gscripts[nn] = AF_SCRIPT_LIST_DEFAULT;
if ( ( gscripts[nn] & ~AF_DIGIT ) == AF_SCRIPT_LIST_NONE )
{
gscripts[nn] &= ~AF_SCRIPT_LIST_NONE;
gscripts[nn] |= AF_SCRIPT_LIST_DEFAULT;
}
}
}
@ -183,7 +186,7 @@
{
FT_Error error;
FT_Memory memory;
AF_FaceGlobals globals;
AF_FaceGlobals globals = NULL;
memory = face->memory;

View file

@ -4,7 +4,7 @@
/* */
/* Auto-fitter hinting routines (body). */
/* */
/* Copyright 2003, 2004, 2005, 2006, 2007, 2009 by */
/* Copyright 2003, 2004, 2005, 2006, 2007, 2009, 2010 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@ -377,120 +377,6 @@
}
/* compute all inflex points in a given glyph */
static void
af_glyph_hints_compute_inflections( AF_GlyphHints hints )
{
AF_Point* contour = hints->contours;
AF_Point* contour_limit = contour + hints->num_contours;
/* do each contour separately */
for ( ; contour < contour_limit; contour++ )
{
AF_Point point = contour[0];
AF_Point first = point;
AF_Point start = point;
AF_Point end = point;
AF_Point before;
AF_Point after;
FT_Pos in_x, in_y, out_x, out_y;
AF_Angle orient_prev, orient_cur;
FT_Int finished = 0;
/* compute first segment in contour */
first = point;
start = end = first;
do
{
end = end->next;
if ( end == first )
goto Skip;
in_x = end->fx - start->fx;
in_y = end->fy - start->fy;
} while ( in_x == 0 && in_y == 0 );
/* extend the segment start whenever possible */
before = start;
do
{
do
{
start = before;
before = before->prev;
if ( before == first )
goto Skip;
out_x = start->fx - before->fx;
out_y = start->fy - before->fy;
} while ( out_x == 0 && out_y == 0 );
orient_prev = ft_corner_orientation( in_x, in_y, out_x, out_y );
} while ( orient_prev == 0 );
first = start;
in_x = out_x;
in_y = out_y;
/* now process all segments in the contour */
do
{
/* first, extend current segment's end whenever possible */
after = end;
do
{
do
{
end = after;
after = after->next;
if ( after == first )
finished = 1;
out_x = after->fx - end->fx;
out_y = after->fy - end->fy;
} while ( out_x == 0 && out_y == 0 );
orient_cur = ft_corner_orientation( in_x, in_y, out_x, out_y );
} while ( orient_cur == 0 );
if ( ( orient_prev + orient_cur ) == 0 )
{
/* we have an inflection point here */
do
{
start->flags |= AF_FLAG_INFLECTION;
start = start->next;
} while ( start != end );
start->flags |= AF_FLAG_INFLECTION;
}
start = end;
end = after;
orient_prev = orient_cur;
in_x = out_x;
in_y = out_y;
} while ( !finished );
Skip:
;
}
}
FT_LOCAL_DEF( void )
af_glyph_hints_init( AF_GlyphHints hints,
FT_Memory memory )
@ -551,8 +437,7 @@
FT_LOCAL_DEF( FT_Error )
af_glyph_hints_reload( AF_GlyphHints hints,
FT_Outline* outline,
FT_Bool get_inflections )
FT_Outline* outline )
{
FT_Error error = AF_Err_Ok;
AF_Point points;
@ -639,13 +524,11 @@
{
FT_Vector* vec = outline->points;
char* tag = outline->tags;
AF_Point first = points;
AF_Point end = points + outline->contours[0];
AF_Point prev = end;
FT_Int contour_index = 0;
FT_UNUSED( first );
for ( point = points; point < point_limit; point++, vec++, tag++ )
{
point->fx = (FT_Short)vec->x;
@ -673,9 +556,8 @@
{
if ( ++contour_index < outline->n_contours )
{
first = point + 1;
end = points + outline->contours[contour_index];
prev = end;
end = points + outline->contours[contour_index];
prev = end;
}
}
}
@ -752,11 +634,6 @@
}
}
/* compute inflection points -- */
/* disabled due to no longer perceived benefits */
if ( 0 && get_inflections )
af_glyph_hints_compute_inflections( hints );
Exit:
return error;
}

View file

@ -4,7 +4,7 @@
/* */
/* Auto-fitter hinting routines (specification). */
/* */
/* Copyright 2003, 2004, 2005, 2006, 2007, 2008 by */
/* Copyright 2003, 2004, 2005, 2006, 2007, 2008, 2010 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@ -286,8 +286,7 @@ FT_BEGIN_HEADER
FT_LOCAL( FT_Error )
af_glyph_hints_reload( AF_GlyphHints hints,
FT_Outline* outline,
FT_Bool get_inflections );
FT_Outline* outline );
FT_LOCAL( void )
af_glyph_hints_save( AF_GlyphHints hints,

View file

@ -4,7 +4,7 @@
/* */
/* Auto-fitter hinting routines for latin script (body). */
/* */
/* Copyright 2003, 2004, 2005, 2006, 2007, 2008, 2009 by */
/* Copyright 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@ -77,7 +77,7 @@
af_glyph_hints_rescale( hints, (AF_ScriptMetrics)dummy );
error = af_glyph_hints_reload( hints, &face->glyph->outline, 0 );
error = af_glyph_hints_reload( hints, &face->glyph->outline );
if ( error )
goto Exit;
@ -1534,21 +1534,18 @@
/* compare to standard width */
if ( axis->width_count > 0 )
delta = dist - axis->widths[0].cur;
if ( delta < 0 )
delta = -delta;
if ( delta < 40 )
{
delta = dist - axis->widths[0].cur;
dist = axis->widths[0].cur;
if ( dist < 48 )
dist = 48;
if ( delta < 0 )
delta = -delta;
if ( delta < 40 )
{
dist = axis->widths[0].cur;
if ( dist < 48 )
dist = 48;
goto Done_Width;
}
goto Done_Width;
}
if ( dist < 3 * 64 )
@ -2105,7 +2102,7 @@
int dim;
error = af_glyph_hints_reload( hints, outline, 1 );
error = af_glyph_hints_reload( hints, outline );
if ( error )
goto Exit;

View file

@ -4,7 +4,7 @@
/* */
/* Auto-fitter hinting routines for latin script (body). */
/* */
/* Copyright 2003, 2004, 2005, 2006, 2007, 2008, 2009 by */
/* Copyright 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@ -84,7 +84,7 @@
af_glyph_hints_rescale( hints, (AF_ScriptMetrics)dummy );
error = af_glyph_hints_reload( hints, &face->glyph->outline, 0 );
error = af_glyph_hints_reload( hints, &face->glyph->outline );
if ( error )
goto Exit;
@ -545,7 +545,8 @@
FT_Pos fitted = ( scaled + 40 ) & ~63;
#if 1
if ( scaled != fitted ) {
if ( scaled != fitted )
{
scale = FT_MulDiv( scale, fitted, scaled );
AF_LOG(( "== scaled x-top = %.2g fitted = %.2g, scaling = %.4g\n", scaled/64.0, fitted/64.0, (fitted*1.0)/scaled ));
}
@ -2249,7 +2250,7 @@
int dim;
error = af_glyph_hints_reload( hints, outline, 1 );
error = af_glyph_hints_reload( hints, outline );
if ( error )
goto Exit;

View file

@ -4,7 +4,7 @@
/* */
/* The FreeType position independent code services for autofit module. */
/* */
/* Copyright 2009 by */
/* Copyright 2009, 2010 by */
/* Oran Agra and Mickey Gabel. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@ -45,19 +45,21 @@
}
}
FT_Error
autofit_module_class_pic_init( FT_Library library )
autofit_module_class_pic_init( FT_Library library )
{
FT_PIC_Container* pic_container = &library->pic_container;
FT_UInt ss;
FT_Error error = FT_Err_Ok;
AFModulePIC* container;
FT_Memory memory = library->memory;
FT_PIC_Container* pic_container = &library->pic_container;
FT_UInt ss;
FT_Error error = AF_Err_Ok;
AFModulePIC* container;
FT_Memory memory = library->memory;
/* allocate pointer, clear and set global container pointer */
if ( FT_ALLOC ( container, sizeof ( *container ) ) )
return error;
FT_MEM_SET( container, 0, sizeof(*container) );
FT_MEM_SET( container, 0, sizeof ( *container ) );
pic_container->autofit = container;
/* initialize pointer table - this is how the module usually expects this data */

View file

@ -49,6 +49,17 @@ FT_BEGIN_HEADER
FT_Face *aface );
#ifdef FT_CONFIG_OPTION_GUESSING_EMBEDDED_RFORK
/* Mac OS X/Darwin kernel often changes recommended method to access */
/* the resource fork and older methods makes the kernel issue the */
/* warning of deprecated method. To calm it down, the methods based */
/* on Darwin VFS should be grouped and skip the rest methods after */
/* the case the resource is opened but found to lack a font in it. */
FT_LOCAL( FT_Bool )
raccess_rule_by_darwin_vfs( FT_UInt rule_index );
#endif /* FT_CONFIG_OPTION_GUESSING_EMBEDDED_RFORK */
FT_END_HEADER
#endif /* __FTBASE_H__ */

View file

@ -47,7 +47,7 @@
typedef struct FT_MemTableRec_* FT_MemTable;
#define FT_MEM_VAL( addr ) ((FT_ULong)(FT_Pointer)( addr ))
#define FT_MEM_VAL( addr ) ((FT_PtrDist)(FT_Pointer)( addr ))
/*
* This structure holds statistics for a single allocation/release
@ -275,7 +275,7 @@
for ( i = 0; i < table->size; i++ )
{
FT_MemNode node, next, *pnode;
FT_ULong hash;
FT_PtrDist hash;
node = table->buckets[i];
@ -430,7 +430,7 @@
ft_mem_table_get_nodep( FT_MemTable table,
FT_Byte* address )
{
FT_ULong hash;
FT_PtrDist hash;
FT_MemNode *pnode, node;

View file

@ -4,7 +4,7 @@
/* */
/* The FreeType glyph loader (body). */
/* */
/* Copyright 2002, 2003, 2004, 2005, 2006 by */
/* Copyright 2002, 2003, 2004, 2005, 2006, 2010 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg */
/* */
/* This file is part of the FreeType project, and may only be used, */
@ -69,7 +69,7 @@
FT_GlyphLoader_New( FT_Memory memory,
FT_GlyphLoader *aloader )
{
FT_GlyphLoader loader;
FT_GlyphLoader loader = NULL;
FT_Error error;

View file

@ -4,7 +4,7 @@
/* */
/* FreeType convenience functions to handle glyphs (body). */
/* */
/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2007, 2008 by */
/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2007, 2008, 2010 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@ -282,7 +282,7 @@
{
FT_Memory memory = library->memory;
FT_Error error;
FT_Glyph glyph;
FT_Glyph glyph = NULL;
*aglyph = 0;

View file

@ -4,7 +4,7 @@
/* */
/* FreeType API for validating TrueTyepGX/AAT tables (body). */
/* */
/* Copyright 2004, 2005, 2006 by */
/* Copyright 2004, 2005, 2006, 2010 by */
/* Masatake YAMATO, Redhat K.K, */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
@ -73,9 +73,14 @@
FT_TrueTypeGX_Free( FT_Face face,
FT_Bytes table )
{
FT_Memory memory = FT_FACE_MEMORY( face );
FT_Memory memory;
if ( !face )
return;
memory = FT_FACE_MEMORY( face );
FT_FREE( table );
}
@ -119,7 +124,13 @@
FT_ClassicKern_Free( FT_Face face,
FT_Bytes table )
{
FT_Memory memory = FT_FACE_MEMORY( face );
FT_Memory memory;
if ( !face )
return;
memory = FT_FACE_MEMORY( face );
FT_FREE( table );

View file

@ -98,7 +98,8 @@
#undef FT_USE_MODULE
#define FT_USE_MODULE( type, x ) MODULE_CLASS_##x,
enum {
enum
{
#include FT_CONFIG_MODULES_H
FT_NUM_MODULE_CLASSES
};

View file

@ -4,7 +4,7 @@
/* */
/* FreeType API for color filtering of subpixel bitmap glyphs (body). */
/* */
/* Copyright 2006, 2008, 2009 by */
/* Copyright 2006, 2008, 2009, 2010 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@ -267,18 +267,31 @@
FT_EXPORT_DEF( FT_Error )
FT_Library_SetLcdFilter( FT_Library library,
FT_LcdFilter filter )
FT_Library_SetLcdFilterWeights( FT_Library library,
unsigned char *weights )
{
if ( !library || !weights )
return FT_Err_Invalid_Argument;
ft_memcpy( library->lcd_weights, weights, 5 );
return FT_Err_Ok;
}
FT_EXPORT_DEF( FT_Error )
FT_Library_SetLcdFilter( FT_Library library,
FT_LcdFilter filter )
{
static const FT_Byte light_filter[5] =
{ 0, 85, 86, 85, 0 };
{ 0x00, 0x55, 0x56, 0x55, 0x00 };
/* the values here sum up to a value larger than 256, */
/* providing a cheap gamma correction */
static const FT_Byte default_filter[5] =
{ 0x10, 0x40, 0x70, 0x40, 0x10 };
if ( library == NULL )
if ( !library )
return FT_Err_Invalid_Argument;
switch ( filter )
@ -330,11 +343,23 @@
}
library->lcd_filter = filter;
return 0;
return FT_Err_Ok;
}
#else /* !FT_CONFIG_OPTION_SUBPIXEL_RENDERING */
FT_EXPORT_DEF( FT_Error )
FT_Library_SetLcdFilterWeights( FT_Library library,
unsigned char *weights )
{
FT_UNUSED( library );
FT_UNUSED( weights );
return FT_Err_Unimplemented_Feature;
}
FT_EXPORT_DEF( FT_Error )
FT_Library_SetLcdFilter( FT_Library library,
FT_LcdFilter filter )

View file

@ -29,7 +29,6 @@
#include FT_TRUETYPE_TABLES_H
#include FT_TRUETYPE_TAGS_H
#include FT_TRUETYPE_IDS_H
#include FT_OUTLINE_H
#include FT_SERVICE_SFNT_H
#include FT_SERVICE_POSTSCRIPT_NAME_H
@ -143,7 +142,7 @@
if ( !args )
return FT_Err_Invalid_Argument;
memory = library->memory;
memory = library->memory;
if ( FT_NEW( stream ) )
goto Exit;
@ -230,11 +229,11 @@
static FT_Error
ft_glyphslot_init( FT_GlyphSlot slot )
{
FT_Driver driver = slot->face->driver;
FT_Driver_Class clazz = driver->clazz;
FT_Memory memory = driver->root.memory;
FT_Error error = FT_Err_Ok;
FT_Slot_Internal internal;
FT_Driver driver = slot->face->driver;
FT_Driver_Class clazz = driver->clazz;
FT_Memory memory = driver->root.memory;
FT_Error error = FT_Err_Ok;
FT_Slot_Internal internal = NULL;
slot->library = driver->root.library;
@ -992,6 +991,14 @@
( cur[0]->platform_id == TT_PLATFORM_APPLE_UNICODE &&
cur[0]->encoding_id == TT_APPLE_ID_UNICODE_32 ) )
{
#ifdef FT_MAX_CHARMAP_CACHEABLE
if ( cur - first > FT_MAX_CHARMAP_CACHEABLE )
{
FT_ERROR(( "find_unicode_charmap: UCS-4 cmap is found "
"at too late position (%d)\n", cur - first ));
continue;
}
#endif
face->charmap = cur[0];
return FT_Err_Ok;
}
@ -1006,6 +1013,14 @@
{
if ( cur[0]->encoding == FT_ENCODING_UNICODE )
{
#ifdef FT_MAX_CHARMAP_CACHEABLE
if ( cur - first > FT_MAX_CHARMAP_CACHEABLE )
{
FT_ERROR(( "find_unicode_charmap: UCS-2 cmap is found "
"at too late position (%d)\n", cur - first ));
continue;
}
#endif
face->charmap = cur[0];
return FT_Err_Ok;
}
@ -1047,7 +1062,17 @@
if ( cur[0]->platform_id == TT_PLATFORM_APPLE_UNICODE &&
cur[0]->encoding_id == TT_APPLE_ID_VARIANT_SELECTOR &&
FT_Get_CMap_Format( cur[0] ) == 14 )
{
#ifdef FT_MAX_CHARMAP_CACHEABLE
if ( cur - first > FT_MAX_CHARMAP_CACHEABLE )
{
FT_ERROR(( "find_unicode_charmap: UVS cmap is found "
"at too late position (%d)\n", cur - first ));
continue;
}
#endif
return cur[0];
}
}
return NULL;
@ -1548,11 +1573,26 @@
goto Exit;
if ( FT_READ_USHORT( flags ) )
goto Exit;
rlen -= 2; /* the flags are part of the resource */
FT_TRACE3(( "POST fragment[%d]: offsets=0x%08x, rlen=0x%08x, flags=0x%04x\n",
i, offsets[i], rlen, flags ));
/* postpone the check of rlen longer than buffer until FT_Stream_Read() */
if ( ( flags >> 8 ) == 0 ) /* Comment, should not be loaded */
continue;
/* the flags are part of the resource, so rlen >= 2. */
/* but some fonts declare rlen = 0 for empty fragment */
if ( rlen > 2 )
rlen -= 2;
else
rlen = 0;
if ( ( flags >> 8 ) == type )
len += rlen;
else
{
if ( pfb_lenpos + 3 > pfb_len + 2 )
goto Exit2;
pfb_data[pfb_lenpos ] = (FT_Byte)( len );
pfb_data[pfb_lenpos + 1] = (FT_Byte)( len >> 8 );
pfb_data[pfb_lenpos + 2] = (FT_Byte)( len >> 16 );
@ -1561,6 +1601,8 @@
if ( ( flags >> 8 ) == 5 ) /* End of font mark */
break;
if ( pfb_pos + 6 > pfb_len + 2 )
goto Exit2;
pfb_data[pfb_pos++] = 0x80;
type = flags >> 8;
@ -1574,13 +1616,23 @@
pfb_data[pfb_pos++] = 0;
}
error = FT_Err_Cannot_Open_Resource;
if ( pfb_pos > pfb_len || pfb_pos + rlen > pfb_len )
goto Exit2;
error = FT_Stream_Read( stream, (FT_Byte *)pfb_data + pfb_pos, rlen );
if ( error )
goto Exit2;
pfb_pos += rlen;
}
if ( pfb_pos + 2 > pfb_len + 2 )
goto Exit2;
pfb_data[pfb_pos++] = 0x80;
pfb_data[pfb_pos++] = 3;
if ( pfb_lenpos + 3 > pfb_len + 2 )
goto Exit2;
pfb_data[pfb_lenpos ] = (FT_Byte)( len );
pfb_data[pfb_lenpos + 1] = (FT_Byte)( len >> 8 );
pfb_data[pfb_lenpos + 2] = (FT_Byte)( len >> 16 );
@ -1799,6 +1851,7 @@
char * file_names[FT_RACCESS_N_RULES];
FT_Long offsets[FT_RACCESS_N_RULES];
FT_Error errors[FT_RACCESS_N_RULES];
FT_Bool is_darwin_vfs, vfs_rfork_has_no_font = FALSE; /* not tested */
FT_Open_Args args2;
FT_Stream stream2 = 0;
@ -1809,6 +1862,15 @@
for ( i = 0; i < FT_RACCESS_N_RULES; i++ )
{
is_darwin_vfs = raccess_rule_by_darwin_vfs( i );
if ( is_darwin_vfs && vfs_rfork_has_no_font )
{
FT_TRACE3(( "Skip rule %d: darwin vfs resource fork"
" is already checked and"
" no font is found\n", i ));
continue;
}
if ( errors[i] )
{
FT_TRACE3(( "Error[%d] has occurred in rule %d\n", errors[i], i ));
@ -1822,6 +1884,9 @@
i, args2.pathname, offsets[i] ));
error = FT_Stream_New( library, &args2, &stream2 );
if ( is_darwin_vfs && error == FT_Err_Cannot_Open_Stream )
vfs_rfork_has_no_font = TRUE;
if ( error )
{
FT_TRACE3(( "failed\n" ));
@ -1836,6 +1901,8 @@
if ( !error )
break;
else if ( is_darwin_vfs )
vfs_rfork_has_no_font = TRUE;
}
for (i = 0; i < FT_RACCESS_N_RULES; i++)
@ -1915,9 +1982,9 @@
FT_Error error;
FT_Driver driver;
FT_Memory memory;
FT_Stream stream = 0;
FT_Face face = 0;
FT_ListNode node = 0;
FT_Stream stream = NULL;
FT_Face face = NULL;
FT_ListNode node = NULL;
FT_Bool external_stream;
FT_Module* cur;
FT_Module* limit;
@ -2141,6 +2208,8 @@
internal->transform_delta.x = 0;
internal->transform_delta.y = 0;
internal->refcount = 1;
}
if ( aface )
@ -2226,6 +2295,17 @@
}
/* documentation is in freetype.h */
FT_EXPORT_DEF( FT_Error )
FT_Reference_Face( FT_Face face )
{
face->internal->refcount++;
return FT_Err_Ok;
}
/* documentation is in freetype.h */
FT_EXPORT_DEF( FT_Error )
@ -2240,22 +2320,29 @@
error = FT_Err_Invalid_Face_Handle;
if ( face && face->driver )
{
driver = face->driver;
memory = driver->root.memory;
/* find face in driver's list */
node = FT_List_Find( &driver->faces_list, face );
if ( node )
{
/* remove face object from the driver's list */
FT_List_Remove( &driver->faces_list, node );
FT_FREE( node );
/* now destroy the object proper */
destroy_face( memory, face, driver );
face->internal->refcount--;
if ( face->internal->refcount > 0 )
error = FT_Err_Ok;
else
{
driver = face->driver;
memory = driver->root.memory;
/* find face in driver's list */
node = FT_List_Find( &driver->faces_list, face );
if ( node )
{
/* remove face object from the driver's list */
FT_List_Remove( &driver->faces_list, node );
FT_FREE( node );
/* now destroy the object proper */
destroy_face( memory, face, driver );
error = FT_Err_Ok;
}
}
}
return error;
}
@ -2901,6 +2988,15 @@
{
if ( cur[0]->encoding == encoding )
{
#ifdef FT_MAX_CHARMAP_CACHEABLE
if ( cur - face->charmaps > FT_MAX_CHARMAP_CACHEABLE )
{
FT_ERROR(( "FT_Select_Charmap: requested charmap is found (%d), "
"but in too late position to cache\n",
cur - face->charmaps ));
continue;
}
#endif
face->charmap = cur[0];
return 0;
}
@ -2935,6 +3031,15 @@
{
if ( cur[0] == charmap )
{
#ifdef FT_MAX_CHARMAP_CACHEABLE
if ( cur - face->charmaps > FT_MAX_CHARMAP_CACHEABLE )
{
FT_ERROR(( "FT_Set_Charmap: requested charmap is found (%d), "
"but in too late position to cache\n",
cur - face->charmaps ));
continue;
}
#endif
face->charmap = cur[0];
return 0;
}
@ -2951,12 +3056,24 @@
FT_Int i;
if ( !charmap || !charmap->face )
return -1;
for ( i = 0; i < charmap->face->num_charmaps; i++ )
if ( charmap->face->charmaps[i] == charmap )
break;
FT_ASSERT( i < charmap->face->num_charmaps );
#ifdef FT_MAX_CHARMAP_CACHEABLE
if ( i > FT_MAX_CHARMAP_CACHEABLE )
{
FT_ERROR(( "FT_Get_Charmap_Index: requested charmap is found (%d), "
"but in too late position to cache\n",
i ));
return -i;
}
#endif
return i;
}
@ -3095,7 +3212,7 @@
}
result = cmap->clazz->char_index( cmap, (FT_UInt32)charcode );
}
return result;
return result;
}
@ -3109,14 +3226,14 @@
FT_UInt gindex = 0;
if ( face && face->charmap )
if ( face && face->charmap && face->num_glyphs )
{
gindex = FT_Get_Char_Index( face, 0 );
if ( gindex == 0 )
if ( gindex == 0 || gindex >= (FT_UInt)face->num_glyphs )
result = FT_Get_Next_Char( face, 0, &gindex );
}
if ( agindex )
if ( agindex )
*agindex = gindex;
return result;
@ -3134,13 +3251,16 @@
FT_UInt gindex = 0;
if ( face && face->charmap )
if ( face && face->charmap && face->num_glyphs )
{
FT_UInt32 code = (FT_UInt32)charcode;
FT_CMap cmap = FT_CMAP( face->charmap );
gindex = cmap->clazz->char_next( cmap, &code );
do {
gindex = cmap->clazz->char_next( cmap, &code );
} while ( gindex >= (FT_UInt)face->num_glyphs );
result = ( gindex == 0 ) ? 0 : code;
}
@ -3645,7 +3765,7 @@
FT_Library library = module->library;
FT_Memory memory = library->memory;
FT_Error error;
FT_ListNode node;
FT_ListNode node = NULL;
if ( FT_NEW( node ) )
@ -3661,7 +3781,7 @@
/* allocate raster object if needed */
if ( clazz->glyph_format == FT_GLYPH_FORMAT_OUTLINE &&
clazz->raster_class->raster_new )
clazz->raster_class->raster_new )
{
error = clazz->raster_class->raster_new( memory, &render->raster );
if ( error )
@ -3702,7 +3822,8 @@
/* release raster object, if any */
if ( render->raster )
if ( render->clazz->glyph_format == FT_GLYPH_FORMAT_OUTLINE &&
render->raster )
render->clazz->raster_class->raster_done( render->raster );
/* remove from list */
@ -3842,7 +3963,7 @@
FT_Library library;
if ( !slot )
if ( !slot || !slot->face )
return FT_Err_Invalid_Argument;
library = FT_FACE_LIBRARY( slot->face );
@ -4029,7 +4150,8 @@
FT_Renderer renderer = FT_RENDERER( module );
if ( renderer->raster )
if ( renderer->clazz->glyph_format == FT_GLYPH_FORMAT_OUTLINE &&
renderer->raster )
renderer->clazz->raster_class->raster_done( renderer->raster );
}
@ -4182,13 +4304,24 @@
/*************************************************************************/
/* documentation is in ftmodapi.h */
FT_EXPORT_DEF( FT_Error )
FT_Reference_Library( FT_Library library )
{
library->refcount++;
return FT_Err_Ok;
}
/* documentation is in ftmodapi.h */
FT_EXPORT_DEF( FT_Error )
FT_New_Library( FT_Memory memory,
FT_Library *alibrary )
{
FT_Library library = 0;
FT_Library library = NULL;
FT_Error error;
@ -4224,6 +4357,8 @@
library->version_minor = FREETYPE_MINOR;
library->version_patch = FREETYPE_PATCH;
library->refcount = 1;
/* That's ok now */
*alibrary = library;
@ -4280,40 +4415,64 @@
if ( !library )
return FT_Err_Invalid_Library_Handle;
library->refcount--;
if ( library->refcount > 0 )
goto Exit;
memory = library->memory;
/* Discard client-data */
if ( library->generic.finalizer )
library->generic.finalizer( library );
/* Close all faces in the library. If we don't do
* this, we can have some subtle memory leaks.
/*
* Close all faces in the library. If we don't do this, we can have
* some subtle memory leaks.
*
* Example:
*
* - the cff font driver uses the pshinter module in cff_size_done
* - if the pshinter module is destroyed before the cff font driver,
* opened FT_Face objects managed by the driver are not properly
* destroyed, resulting in a memory leak
*
* Some faces are dependent on other faces, like Type42 faces that
* depend on TrueType faces synthesized internally.
*
* The order of drivers should be specified in driver_name[].
*/
{
FT_UInt n;
FT_UInt m, n;
const char* driver_name[] = { "type42", NULL };
for ( n = 0; n < library->num_modules; n++ )
for ( m = 0;
m < sizeof ( driver_name ) / sizeof ( driver_name[0] );
m++ )
{
FT_Module module = library->modules[n];
FT_List faces;
if ( ( module->clazz->module_flags & FT_MODULE_FONT_DRIVER ) == 0 )
continue;
faces = &FT_DRIVER(module)->faces_list;
while ( faces->head )
for ( n = 0; n < library->num_modules; n++ )
{
FT_Done_Face( FT_FACE( faces->head->data ) );
if ( faces->head )
FT_TRACE0(( "FT_Done_Library: failed to free some faces\n" ));
FT_Module module = library->modules[n];
const char* module_name = module->clazz->module_name;
FT_List faces;
if ( driver_name[m] &&
ft_strcmp( module_name, driver_name[m] ) != 0 )
continue;
if ( ( module->clazz->module_flags & FT_MODULE_FONT_DRIVER ) == 0 )
continue;
FT_TRACE7(( "FT_Done_Library: close faces for %s\n", module_name ));
faces = &FT_DRIVER( module )->faces_list;
while ( faces->head )
{
FT_Done_Face( FT_FACE( faces->head->data ) );
if ( faces->head )
FT_TRACE0(( "FT_Done_Library: failed to free some faces\n" ));
}
}
}
}
@ -4355,6 +4514,8 @@
#endif
FT_FREE( library );
Exit:
return FT_Err_Ok;
}
@ -4467,6 +4628,8 @@
#endif /* FT_CONFIG_OPTION_OLD_INTERNALS */
/* documentation is in freetype.h */
FT_EXPORT_DEF( FT_Error )
FT_Get_SubGlyph_Info( FT_GlyphSlot glyph,
FT_UInt sub_index,
@ -4479,7 +4642,8 @@
FT_Error error = FT_Err_Invalid_Argument;
if ( glyph != NULL &&
if ( glyph &&
glyph->subglyphs &&
glyph->format == FT_GLYPH_FORMAT_COMPOSITE &&
sub_index < glyph->num_subglyphs )
{

View file

@ -4,7 +4,7 @@
/* */
/* FreeType API for validating OpenType tables (body). */
/* */
/* Copyright 2004, 2006, 2008 by */
/* Copyright 2004, 2006, 2008, 2010 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@ -74,9 +74,14 @@
FT_OpenType_Free( FT_Face face,
FT_Bytes table )
{
FT_Memory memory = FT_FACE_MEMORY( face );
FT_Memory memory;
if ( !face )
return;
memory = FT_FACE_MEMORY( face );
FT_FREE( table );
}

View file

@ -990,7 +990,8 @@
int i;
FT_Pos ray_y[3];
FT_Orientation result[3];
FT_Orientation result[3] =
{ FT_ORIENTATION_NONE, FT_ORIENTATION_NONE, FT_ORIENTATION_NONE };
if ( !outline || outline->n_points <= 0 )

View file

@ -4,7 +4,7 @@
/* */
/* FreeType API for accessing PFR-specific data (body). */
/* */
/* Copyright 2002, 2003, 2004, 2008 by */
/* Copyright 2002, 2003, 2004, 2008, 2010 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@ -24,10 +24,11 @@
static FT_Service_PfrMetrics
ft_pfr_check( FT_Face face )
{
FT_Service_PfrMetrics service;
FT_Service_PfrMetrics service = NULL;
FT_FACE_LOOKUP_SERVICE( face, service, PFR_METRICS );
if ( face )
FT_FACE_LOOKUP_SERVICE( face, service, PFR_METRICS );
return service;
}

View file

@ -4,7 +4,7 @@
/* */
/* Embedded resource forks accessor (body). */
/* */
/* Copyright 2004, 2005, 2006, 2007, 2008, 2009 by */
/* Copyright 2004, 2005, 2006, 2007, 2008, 2009, 2010 by */
/* Masatake YAMATO and Redhat K.K. */
/* */
/* FT_Raccess_Get_HeaderInfo() and raccess_guess_darwin_hfsplus() are */
@ -349,6 +349,42 @@
const char *insertion );
typedef enum FT_RFork_Rule_ {
FT_RFork_Rule_invalid = -2,
FT_RFork_Rule_uknown, /* -1 */
FT_RFork_Rule_apple_double,
FT_RFork_Rule_apple_single,
FT_RFork_Rule_darwin_ufs_export,
FT_RFork_Rule_darwin_newvfs,
FT_RFork_Rule_darwin_hfsplus,
FT_RFork_Rule_vfat,
FT_RFork_Rule_linux_cap,
FT_RFork_Rule_linux_double,
FT_RFork_Rule_linux_netatalk
} FT_RFork_Rule;
/* For fast translation between rule index and rule type,
* the macros FT_RFORK_xxx should be kept consistent with
* the raccess_guess_funcs table
*/
typedef struct raccess_guess_rec_ {
raccess_guess_func func;
FT_RFork_Rule type;
} raccess_guess_rec;
static raccess_guess_rec raccess_guess_table[FT_RACCESS_N_RULES] =
{
{ raccess_guess_apple_double, FT_RFork_Rule_apple_double, },
{ raccess_guess_apple_single, FT_RFork_Rule_apple_single, },
{ raccess_guess_darwin_ufs_export, FT_RFork_Rule_darwin_ufs_export, },
{ raccess_guess_darwin_newvfs, FT_RFork_Rule_darwin_newvfs, },
{ raccess_guess_darwin_hfsplus, FT_RFork_Rule_darwin_hfsplus, },
{ raccess_guess_vfat, FT_RFork_Rule_vfat, },
{ raccess_guess_linux_cap, FT_RFork_Rule_linux_cap, },
{ raccess_guess_linux_double, FT_RFork_Rule_linux_double, },
{ raccess_guess_linux_netatalk, FT_RFork_Rule_linux_netatalk, },
};
FT_BASE_DEF( void )
FT_Raccess_Guess( FT_Library library,
FT_Stream stream,
@ -360,19 +396,6 @@
FT_Long i;
raccess_guess_func funcs[FT_RACCESS_N_RULES] =
{
raccess_guess_apple_double,
raccess_guess_apple_single,
raccess_guess_darwin_ufs_export,
raccess_guess_darwin_newvfs,
raccess_guess_darwin_hfsplus,
raccess_guess_vfat,
raccess_guess_linux_cap,
raccess_guess_linux_double,
raccess_guess_linux_netatalk,
};
for ( i = 0; i < FT_RACCESS_N_RULES; i++ )
{
new_names[i] = NULL;
@ -384,14 +407,41 @@
if ( errors[i] )
continue ;
errors[i] = (funcs[i])( library, stream, base_name,
&(new_names[i]), &(offsets[i]) );
errors[i] = (raccess_guess_table[i].func)( library,
stream, base_name,
&(new_names[i]),
&(offsets[i]) );
}
return;
}
static FT_RFork_Rule
raccess_get_rule_type_from_rule_index( FT_UInt rule_index )
{
if ( rule_index >= FT_RACCESS_N_RULES )
return FT_RFork_Rule_invalid;
return raccess_guess_table[rule_index].type;
}
FT_LOCAL_DEF( FT_Bool )
raccess_rule_by_darwin_vfs( FT_UInt rule_index )
{
switch( raccess_get_rule_type_from_rule_index( rule_index ) )
{
case FT_RFork_Rule_darwin_newvfs:
case FT_RFork_Rule_darwin_hfsplus:
return TRUE;
default:
return FALSE;
}
}
static FT_Error
raccess_guess_apple_double( FT_Library library,
FT_Stream stream,
@ -751,7 +801,7 @@
const char *original_name,
const char *insertion )
{
char* new_name;
char* new_name = NULL;
const char* tmp;
const char* slash;
size_t new_length;

View file

@ -4,7 +4,7 @@
/* */
/* I/O stream support (body). */
/* */
/* Copyright 2000-2001, 2002, 2004, 2005, 2006, 2008, 2009 by */
/* Copyright 2000-2001, 2002, 2004, 2005, 2006, 2008, 2009, 2010 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@ -246,6 +246,18 @@
/* allocate the frame in memory */
FT_Memory memory = stream->memory;
/* simple sanity check */
if ( count > stream->size )
{
FT_ERROR(( "FT_Stream_EnterFrame:"
" frame size (%lu) larger than stream size (%lu)\n",
count, stream->size ));
error = FT_Err_Invalid_Stream_Operation;
goto Exit;
}
#ifdef FT_DEBUG_MEMORY
/* assume _ft_debug_file and _ft_debug_lineno are already set */
stream->base = (unsigned char*)ft_mem_qalloc( memory, count, &error );
@ -275,7 +287,7 @@
{
/* check current and new position */
if ( stream->pos >= stream->size ||
stream->pos + count > stream->size )
stream->size - stream->pos < count )
{
FT_ERROR(( "FT_Stream_EnterFrame:"
" invalid i/o; pos = 0x%lx, count = %lu, size = 0x%lx\n",

View file

@ -90,7 +90,7 @@
if ( slot->format != FT_GLYPH_FORMAT_OUTLINE &&
slot->format != FT_GLYPH_FORMAT_BITMAP )
slot->format != FT_GLYPH_FORMAT_BITMAP )
return;
/* some reasonable strength */
@ -108,7 +108,7 @@
xstr = xstr * 2;
ystr = xstr;
}
else if ( slot->format == FT_GLYPH_FORMAT_BITMAP )
else /* slot->format == FT_GLYPH_FORMAT_BITMAP */
{
/* round to full pixels */
xstr &= ~63;

View file

@ -4,7 +4,7 @@
/* */
/* ANSI-specific FreeType low-level system interface (body). */
/* */
/* Copyright 1996-2001, 2002, 2006, 2008, 2009 by */
/* Copyright 1996-2001, 2002, 2006, 2008, 2009, 2010 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@ -192,7 +192,9 @@
/* count :: The number of bytes to read from the stream. */
/* */
/* <Return> */
/* The number of bytes actually read. */
/* The number of bytes actually read. If `count' is zero (this is, */
/* the function is used for seeking), a non-zero return value */
/* indicates an error. */
/* */
FT_CALLBACK_DEF( unsigned long )
ft_ansi_stream_io( FT_Stream stream,
@ -203,6 +205,9 @@
FT_FILE* file;
if ( !count && offset > stream->size )
return 1;
file = STREAM_FILE( stream );
if ( stream->pos != offset )
@ -224,6 +229,13 @@
if ( !stream )
return FT_Err_Invalid_Stream_Handle;
stream->descriptor.pointer = NULL;
stream->pathname.pointer = (char*)filepathname;
stream->base = 0;
stream->pos = 0;
stream->read = NULL;
stream->close = NULL;
file = ft_fopen( filepathname, "rb" );
if ( !file )
{
@ -235,12 +247,16 @@
ft_fseek( file, 0, SEEK_END );
stream->size = ft_ftell( file );
if ( !stream->size )
{
FT_ERROR(( "FT_Stream_Open:" ));
FT_ERROR(( " opened `%s' but zero-sized\n", filepathname ));
ft_fclose( file );
return FT_Err_Cannot_Open_Stream;
}
ft_fseek( file, 0, SEEK_SET );
stream->descriptor.pointer = file;
stream->pathname.pointer = (char*)filepathname;
stream->pos = 0;
stream->read = ft_ansi_stream_io;
stream->close = ft_ansi_stream_close;

View file

@ -30,6 +30,7 @@ THE SOFTWARE.
#include FT_INTERNAL_STREAM_H
#include FT_INTERNAL_OBJECTS_H
#include FT_BDF_H
#include FT_TRUETYPE_IDS_H
#include FT_SERVICE_BDF_H
#include FT_SERVICE_XFREE86_NAME_H
@ -540,14 +541,15 @@ THE SOFTWARE.
charmap.face = FT_FACE( face );
charmap.encoding = FT_ENCODING_NONE;
charmap.platform_id = 0;
charmap.encoding_id = 0;
/* initial platform/encoding should indicate unset status? */
charmap.platform_id = TT_PLATFORM_APPLE_UNICODE;
charmap.encoding_id = TT_APPLE_ID_DEFAULT;
if ( unicode_charmap )
{
charmap.encoding = FT_ENCODING_UNICODE;
charmap.platform_id = 3;
charmap.encoding_id = 1;
charmap.platform_id = TT_PLATFORM_MICROSOFT;
charmap.encoding_id = TT_MS_ID_UNICODE_CS;
}
error = FT_CMap_New( &bdf_cmap_class, NULL, &charmap, NULL );
@ -571,8 +573,8 @@ THE SOFTWARE.
charmap.face = FT_FACE( face );
charmap.encoding = FT_ENCODING_ADOBE_STANDARD;
charmap.platform_id = 7;
charmap.encoding_id = 0;
charmap.platform_id = TT_PLATFORM_ADOBE;
charmap.encoding_id = TT_ADOBE_ID_STANDARD;
error = FT_CMap_New( &bdf_cmap_class, NULL, &charmap, NULL );

View file

@ -1,6 +1,6 @@
/*
* Copyright 2000 Computing Research Labs, New Mexico State University
* Copyright 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2009
* Copyright 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2009, 2010
* Francesco Zappa Nardelli
*
* Permission is hereby granted, free of charge, to any person obtaining a
@ -470,6 +470,11 @@
}
/* An empty string for empty fields. */
static const char empty[1] = { 0 }; /* XXX eliminate this */
static char *
_bdf_list_join( _bdf_list_t* list,
int c,
@ -494,18 +499,14 @@
if ( i + 1 < list->used )
dp[j++] = (char)c;
}
dp[j] = 0;
if ( dp != empty )
dp[j] = 0;
*alen = j;
return dp;
}
/* An empty string for empty fields. */
static const char empty[1] = { 0 }; /* XXX eliminate this */
static FT_Error
_bdf_list_split( _bdf_list_t* list,
char* separators,
@ -648,8 +649,9 @@
{
if ( refill )
{
bytes = (ptrdiff_t)FT_Stream_TryRead( stream, (FT_Byte*)buf + cursor,
(FT_ULong)(buf_size - cursor) );
bytes = (ptrdiff_t)FT_Stream_TryRead(
stream, (FT_Byte*)buf + cursor,
(FT_ULong)( buf_size - cursor ) );
avail = cursor + bytes;
cursor = 0;
refill = 0;
@ -719,6 +721,10 @@
{
error = (*cb)( buf + start, end - start, lineno,
(void*)&cb, client_data );
/* Redo if we have encountered CHARS without properties. */
if ( error == -1 )
error = (*cb)( buf + start, end - start, lineno,
(void*)&cb, client_data );
if ( error )
break;
}
@ -1371,7 +1377,8 @@
/* If the property happens to be a comment, then it doesn't need */
/* to be added to the internal hash table. */
if ( ft_memcmp( name, "COMMENT", 7 ) != 0 ) {
if ( ft_memcmp( name, "COMMENT", 7 ) != 0 )
{
/* Add the property to the font property table. */
error = hash_insert( fp->name,
font->props_used,
@ -1867,6 +1874,9 @@
error = BDF_Err_Invalid_File_Format;
Exit:
if ( error && ( p->flags & _BDF_GLYPH ) )
FT_FREE( p->glyph_name );
return error;
}
@ -2077,6 +2087,14 @@
/* Check for the start of the properties. */
if ( ft_memcmp( line, "STARTPROPERTIES", 15 ) == 0 )
{
if ( !( p->flags & _BDF_FONT_BBX ) )
{
/* Missing the FONTBOUNDINGBOX field. */
FT_ERROR(( "_bdf_parse_start: " ERRMSG1, lineno, "FONTBOUNDINGBOX" ));
error = BDF_Err_Missing_Fontboundingbox_Field;
goto Exit;
}
error = _bdf_list_split( &p->list, (char *)" +", line, linelen );
if ( error )
goto Exit;
@ -2095,7 +2113,7 @@
/* Check for the FONTBOUNDINGBOX field. */
if ( ft_memcmp( line, "FONTBOUNDINGBOX", 15 ) == 0 )
{
if ( !(p->flags & _BDF_SIZE ) )
if ( !( p->flags & _BDF_SIZE ) )
{
/* Missing the SIZE field. */
FT_ERROR(( "_bdf_parse_start: " ERRMSG1, lineno, "SIZE" ));
@ -2139,6 +2157,9 @@
goto Exit;
}
/* Allowing multiple `FONT' lines (which is invalid) doesn't hurt... */
FT_FREE( p->font->name );
if ( FT_NEW_ARRAY( p->font->name, slen + 1 ) )
goto Exit;
FT_MEM_COPY( p->font->name, s, slen + 1 );
@ -2208,6 +2229,45 @@
goto Exit;
}
/* Check for the CHARS field -- font properties are optional */
if ( ft_memcmp( line, "CHARS", 5 ) == 0 )
{
char nbuf[128];
if ( !( p->flags & _BDF_FONT_BBX ) )
{
/* Missing the FONTBOUNDINGBOX field. */
FT_ERROR(( "_bdf_parse_start: " ERRMSG1, lineno, "FONTBOUNDINGBOX" ));
error = BDF_Err_Missing_Fontboundingbox_Field;
goto Exit;
}
/* Add the two standard X11 properties which are required */
/* for compiling fonts. */
p->font->font_ascent = p->font->bbx.ascent;
ft_sprintf( nbuf, "%hd", p->font->bbx.ascent );
error = _bdf_add_property( p->font, (char *)"FONT_ASCENT", nbuf );
if ( error )
goto Exit;
FT_TRACE2(( "_bdf_parse_properties: " ACMSG1, p->font->bbx.ascent ));
p->font->font_descent = p->font->bbx.descent;
ft_sprintf( nbuf, "%hd", p->font->bbx.descent );
error = _bdf_add_property( p->font, (char *)"FONT_DESCENT", nbuf );
if ( error )
goto Exit;
FT_TRACE2(( "_bdf_parse_properties: " ACMSG2, p->font->bbx.descent ));
p->font->modified = 1;
*next = _bdf_parse_glyphs;
/* A special return value. */
error = -1;
goto Exit;
}
error = BDF_Err_Invalid_File_Format;
Exit:
@ -2229,7 +2289,7 @@
bdf_font_t* *font )
{
unsigned long lineno = 0; /* make compiler happy */
_bdf_parse_t *p;
_bdf_parse_t *p = NULL;
FT_Memory memory = extmemory;
FT_Error error = BDF_Err_Ok;
@ -2344,7 +2404,8 @@
/* Make sure the comments are NULL terminated if they exist. */
memory = p->font->memory;
if ( p->font->comments_len > 0 ) {
if ( p->font->comments_len > 0 )
{
if ( FT_RENEW_ARRAY( p->font->comments,
p->font->comments_len,
p->font->comments_len + 1 ) )
@ -2448,8 +2509,8 @@
hash_free( &(font->proptbl), memory );
/* Free up the user defined properties. */
for (prop = font->user_props, i = 0;
i < font->nuser_props; i++, prop++ )
for ( prop = font->user_props, i = 0;
i < font->nuser_props; i++, prop++ )
{
FT_FREE( prop->name );
if ( prop->format == BDF_ATOM )

View file

@ -4,7 +4,7 @@
/* */
/* The FreeType basic cache interface (body). */
/* */
/* Copyright 2003, 2004, 2005, 2006, 2007, 2009 by */
/* Copyright 2003, 2004, 2005, 2006, 2007, 2009, 2010 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@ -318,7 +318,7 @@
FTC_BasicQueryRec query;
FTC_Node node = 0; /* make compiler happy */
FT_Error error;
FT_UInt32 hash;
FT_PtrDist hash;
/* some argument checks are delayed to FTC_Cache_Lookup */
@ -414,7 +414,7 @@
FTC_BasicQueryRec query;
FTC_Node node = 0; /* make compiler happy */
FT_Error error;
FT_UInt32 hash;
FT_PtrDist hash;
/* some argument checks are delayed to FTC_Cache_Lookup */
@ -656,7 +656,7 @@
FT_Error error;
FTC_BasicQueryRec query;
FTC_Node node = 0; /* make compiler happy */
FT_UInt32 hash;
FT_PtrDist hash;
if ( anode )
@ -753,7 +753,7 @@
FT_Error error;
FTC_BasicQueryRec query;
FTC_Node node = 0; /* make compiler happy */
FT_UInt32 hash;
FT_PtrDist hash;
if ( anode )
@ -834,7 +834,7 @@
if ( !desc )
return FT_Err_Invalid_Argument;
return FTC_Err_Invalid_Argument;
ftc_image_type_from_old_desc( &type0, desc );

View file

@ -4,7 +4,7 @@
/* */
/* The FreeType internal cache interface (body). */
/* */
/* Copyright 2000-2001, 2002, 2003, 2004, 2005, 2006, 2007, 2009 by */
/* Copyright 2000-2001, 2002, 2003, 2004, 2005, 2006, 2007, 2009, 2010 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@ -346,7 +346,7 @@
static void
FTC_Cache_Clear( FTC_Cache cache )
{
if ( cache )
if ( cache && cache->buckets )
{
FTC_Manager manager = cache->manager;
FT_UFast i;
@ -410,7 +410,7 @@
static void
ftc_cache_add( FTC_Cache cache,
FT_UInt32 hash,
FT_PtrDist hash,
FTC_Node node )
{
node->hash = hash;
@ -438,7 +438,7 @@
FT_LOCAL_DEF( FT_Error )
FTC_Cache_NewNode( FTC_Cache cache,
FT_UInt32 hash,
FT_PtrDist hash,
FT_Pointer query,
FTC_Node *anode )
{
@ -477,7 +477,7 @@
FT_LOCAL_DEF( FT_Error )
FTC_Cache_Lookup( FTC_Cache cache,
FT_UInt32 hash,
FT_PtrDist hash,
FT_Pointer query,
FTC_Node *anode )
{
@ -485,13 +485,13 @@
FTC_Node* bucket;
FTC_Node* pnode;
FTC_Node node;
FT_Error error = 0;
FT_Error error = FTC_Err_Ok;
FTC_Node_CompareFunc compare = cache->clazz.node_compare;
if ( cache == NULL || anode == NULL )
return FT_Err_Invalid_Argument;
return FTC_Err_Invalid_Argument;
idx = hash & cache->mask;
if ( idx < cache->p )

View file

@ -4,7 +4,7 @@
/* */
/* FreeType internal cache interface (specification). */
/* */
/* Copyright 2000-2001, 2002, 2003, 2004, 2005, 2006, 2007, 2009 by */
/* Copyright 2000-2001, 2002, 2003, 2004, 2005, 2006, 2007, 2009, 2010 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@ -24,6 +24,9 @@
FT_BEGIN_HEADER
#define _FTC_FACE_ID_HASH( i ) \
((FT_PtrDist)(( (FT_PtrDist)(i) >> 3 ) ^ ( (FT_PtrDist)(i) << 7 )))
/* handle to cache object */
typedef struct FTC_CacheRec_* FTC_Cache;
@ -56,7 +59,7 @@ FT_BEGIN_HEADER
{
FTC_MruNodeRec mru; /* circular mru list pointer */
FTC_Node link; /* used for hashing */
FT_UInt32 hash; /* used for hashing too */
FT_PtrDist hash; /* used for hashing too */
FT_UShort cache_index; /* index of cache the node belongs to */
FT_Short ref_count; /* reference count for this node */
@ -168,14 +171,14 @@ FT_BEGIN_HEADER
#ifndef FTC_INLINE
FT_LOCAL( FT_Error )
FTC_Cache_Lookup( FTC_Cache cache,
FT_UInt32 hash,
FT_PtrDist hash,
FT_Pointer query,
FTC_Node *anode );
#endif
FT_LOCAL( FT_Error )
FTC_Cache_NewNode( FTC_Cache cache,
FT_UInt32 hash,
FT_PtrDist hash,
FT_Pointer query,
FTC_Node *anode );
@ -200,12 +203,12 @@ FT_BEGIN_HEADER
FT_BEGIN_STMNT \
FTC_Node *_bucket, *_pnode, _node; \
FTC_Cache _cache = FTC_CACHE(cache); \
FT_UInt32 _hash = (FT_UInt32)(hash); \
FT_PtrDist _hash = (FT_PtrDist)(hash); \
FTC_Node_CompareFunc _nodcomp = (FTC_Node_CompareFunc)(nodecmp); \
FT_UFast _idx; \
\
\
error = 0; \
error = FTC_Err_Ok; \
node = NULL; \
_idx = _hash & _cache->mask; \
if ( _idx < _cache->p ) \
@ -288,7 +291,7 @@ FT_BEGIN_HEADER
#define FTC_CACHE_TRYLOOP_END() \
if ( !error || error != FT_Err_Out_Of_Memory ) \
if ( !error || error != FTC_Err_Out_Of_Memory ) \
break; \
\
_try_done = FTC_Manager_FlushN( _try_manager, _try_count ); \

View file

@ -4,7 +4,8 @@
/* */
/* FreeType CharMap cache (body) */
/* */
/* Copyright 2000-2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 by */
/* Copyright 2000-2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, */
/* 2010 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@ -86,7 +87,7 @@
/* compute a query/node hash */
#define FTC_CMAP_HASH( faceid, index, charcode ) \
( FTC_FACE_ID_HASH( faceid ) + 211 * (index) + \
( _FTC_FACE_ID_HASH( faceid ) + 211 * (index) + \
( (charcode) / FTC_CMAP_INDICES_MAX ) )
/* the charmap query */
@ -153,7 +154,7 @@
FTC_CMapQuery query = (FTC_CMapQuery)ftcquery;
FT_Error error;
FT_Memory memory = cache->memory;
FTC_CMapNode node;
FTC_CMapNode node = NULL;
FT_UInt nn;
@ -286,7 +287,7 @@
FTC_Node node;
FT_Error error;
FT_UInt gindex = 0;
FT_UInt32 hash;
FT_PtrDist hash;
FT_Int no_cmap_change = 0;
@ -310,19 +311,11 @@
#ifdef FT_CONFIG_OPTION_OLD_INTERNALS
/*
* Detect a call from a rogue client that thinks it is linking
* to FreeType 2.1.7. This is possible because the third parameter
* is then a character code, and we have never seen any font with
* more than a few charmaps, so if the index is very large...
*
* It is also very unlikely that a rogue client is interested
* in Unicode values 0 to 15.
*
* NOTE: The original threshold was 4, but we found a font from the
* Adobe Acrobat Reader Pack, named `KozMinProVI-Regular.otf',
* which contains more than 5 charmaps.
* If cmap_index is greater than the maximum number of cachable
* charmaps, we assume the request is from a legacy rogue client
* using old internal header. See include/config/ftoption.h.
*/
if ( cmap_index >= 16 && !no_cmap_change )
if ( cmap_index > FT_MAX_CHARMAP_CACHEABLE && !no_cmap_change )
{
FTC_OldCMapDesc desc = (FTC_OldCMapDesc) face_id;
@ -384,7 +377,7 @@
/* something rotten can happen with rogue clients */
if ( (FT_UInt)( char_code - FTC_CMAP_NODE( node )->first >=
FTC_CMAP_INDICES_MAX ) )
return 0;
return 0; /* XXX: should return appropriate error */
gindex = FTC_CMAP_NODE( node )->indices[char_code -
FTC_CMAP_NODE( node )->first];
@ -401,6 +394,12 @@
if ( error )
goto Exit;
#ifdef FT_MAX_CHARMAP_CACHEABLE
/* something rotten can happen with rogue clients */
if ( cmap_index > FT_MAX_CHARMAP_CACHEABLE )
return 0; /* XXX: should return appropriate error */
#endif
if ( (FT_UInt)cmap_index < (FT_UInt)face->num_charmaps )
{
FT_CharMap old, cmap = NULL;

View file

@ -175,7 +175,7 @@
FT_LOCAL_DEF( FT_Error )
FTC_GCache_Lookup( FTC_GCache cache,
FT_UInt32 hash,
FT_PtrDist hash,
FT_UInt gindex,
FTC_GQuery query,
FTC_Node *anode )

View file

@ -254,7 +254,7 @@ FT_BEGIN_HEADER
#ifndef FTC_INLINE
FT_LOCAL( FT_Error )
FTC_GCache_Lookup( FTC_GCache cache,
FT_UInt32 hash,
FT_PtrDist hash,
FT_UInt gindex,
FTC_GQuery query,
FTC_Node *anode );

View file

@ -4,7 +4,7 @@
/* */
/* FreeType Image cache (body). */
/* */
/* Copyright 2000-2001, 2003, 2004, 2006 by */
/* Copyright 2000-2001, 2003, 2004, 2006, 2010 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@ -61,7 +61,7 @@
{
FT_Memory memory = cache->memory;
FT_Error error;
FTC_INode inode;
FTC_INode inode = NULL;
if ( !FT_NEW( inode ) )

View file

@ -4,7 +4,7 @@
/* */
/* FreeType Cache Manager (body). */
/* */
/* Copyright 2000-2001, 2002, 2003, 2004, 2005, 2006, 2008, 2009 by */
/* Copyright 2000-2001, 2002, 2003, 2004, 2005, 2006, 2008, 2009, 2010 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@ -670,7 +670,7 @@
* the face_id as well
*/
FTC_MruList_RemoveSelection( &manager->faces,
(FTC_MruNode_CompareFunc)NULL,
ftc_face_node_compare,
face_id );
for ( nn = 0; nn < manager->num_caches; nn++ )

View file

@ -161,7 +161,7 @@ FT_BEGIN_HEADER
(a)->y_res == (b)->y_res ) ) )
#define FTC_SCALER_HASH( q ) \
( FTC_FACE_ID_HASH( (q)->face_id ) + \
( _FTC_FACE_ID_HASH( (q)->face_id ) + \
(q)->width + (q)->height*7 + \
( (q)->pixel ? 0 : ( (q)->x_res*33 ^ (q)->y_res*61 ) ) )

View file

@ -4,7 +4,7 @@
/* */
/* Simple MRU list-cache (specification). */
/* */
/* Copyright 2000-2001, 2003, 2004, 2005, 2006 by */
/* Copyright 2000-2001, 2003, 2004, 2005, 2006, 2010 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@ -166,7 +166,7 @@ FT_BEGIN_HEADER
FTC_MruNode _first, _node; \
\
\
error = 0; \
error = FTC_Err_Ok; \
_first = *(_pfirst); \
_node = NULL; \
\

View file

@ -4,7 +4,7 @@
/* */
/* FreeType sbits manager (body). */
/* */
/* Copyright 2000-2001, 2002, 2003, 2004, 2005, 2006, 2009 by */
/* Copyright 2000-2001, 2002, 2003, 2004, 2005, 2006, 2009, 2010 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@ -160,7 +160,11 @@
!CHECK_CHAR( slot->bitmap_top ) ||
!CHECK_CHAR( xadvance ) ||
!CHECK_CHAR( yadvance ) )
{
FT_TRACE2(( "ftc_snode_load:"
" glyph too large for small bitmap cache\n"));
goto BadGlyph;
}
sbit->width = (FT_Byte)bitmap->width;
sbit->height = (FT_Byte)bitmap->rows;
@ -191,7 +195,7 @@
sbit->width = 255;
sbit->height = 0;
sbit->buffer = NULL;
error = 0;
error = FTC_Err_Ok;
if ( asize )
*asize = 0;
}
@ -218,7 +222,7 @@
total = clazz->family_get_count( family, cache->manager );
if ( total == 0 || gindex >= total )
{
error = FT_Err_Invalid_Argument;
error = FTC_Err_Invalid_Argument;
goto Exit;
}

View file

@ -4,7 +4,7 @@
/* */
/* CFF character mapping table (cmap) support (body). */
/* */
/* Copyright 2002, 2003, 2004, 2005, 2006, 2007 by */
/* Copyright 2002, 2003, 2004, 2005, 2006, 2007, 2010 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@ -120,27 +120,15 @@
/*************************************************************************/
FT_CALLBACK_DEF( const char* )
cff_sid_to_glyph_name( TT_Face face,
FT_UInt idx )
cff_sid_to_glyph_name( TT_Face face,
FT_UInt idx )
{
CFF_Font cff = (CFF_Font)face->extra.data;
CFF_Charset charset = &cff->charset;
FT_Service_PsCMaps psnames = (FT_Service_PsCMaps)cff->psnames;
FT_UInt sid = charset->sids[idx];
CFF_Font cff = (CFF_Font)face->extra.data;
CFF_Charset charset = &cff->charset;
FT_UInt sid = charset->sids[idx];
return cff_index_get_sid_string( &cff->string_index, sid, psnames );
}
FT_CALLBACK_DEF( void )
cff_sid_free_glyph_name( TT_Face face,
const char* gname )
{
FT_Memory memory = FT_FACE_MEMORY( face );
FT_FREE( gname );
return cff_index_get_sid_string( cff, sid );
}
@ -155,14 +143,15 @@
/* can't build Unicode map for CID-keyed font */
/* because we don't know glyph names. */
if ( !charset->sids )
return CFF_Err_Invalid_Argument;
return CFF_Err_No_Unicode_Glyph_Name;
return psnames->unicodes_init( memory,
unicodes,
cff->num_glyphs,
(PS_GetGlyphNameFunc)&cff_sid_to_glyph_name,
(PS_FreeGlyphNameFunc)&cff_sid_free_glyph_name,
(PS_FreeGlyphNameFunc)NULL,
(FT_Pointer)face );
}

View file

@ -4,7 +4,8 @@
/* */
/* OpenType font driver implementation (body). */
/* */
/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 by */
/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, */
/* 2010 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@ -22,7 +23,6 @@
#include FT_INTERNAL_STREAM_H
#include FT_INTERNAL_SFNT_H
#include FT_SERVICE_CID_H
#include FT_SERVICE_POSTSCRIPT_CMAPS_H
#include FT_SERVICE_POSTSCRIPT_INFO_H
#include FT_SERVICE_POSTSCRIPT_NAME_H
#include FT_SERVICE_TT_CMAP_H
@ -228,16 +228,13 @@
FT_Pointer buffer,
FT_UInt buffer_max )
{
CFF_Font font = (CFF_Font)face->extra.data;
FT_Memory memory = FT_FACE_MEMORY( face );
FT_String* gname;
FT_UShort sid;
FT_Service_PsCMaps psnames;
FT_Error error;
CFF_Font font = (CFF_Font)face->extra.data;
FT_String* gname;
FT_UShort sid;
FT_Error error;
FT_FACE_FIND_GLOBAL_SERVICE( face, psnames, POSTSCRIPT_CMAPS );
if ( !psnames )
if ( !font->psnames )
{
FT_ERROR(( "cff_get_glyph_name:"
" cannot get glyph name from CFF & CEF fonts\n"
@ -251,12 +248,11 @@
sid = font->charset.sids[glyph_index];
/* now, lookup the name itself */
gname = cff_index_get_sid_string( &font->string_index, sid, psnames );
gname = cff_index_get_sid_string( font, sid );
if ( gname )
FT_STRCPYN( buffer, gname, buffer_max );
FT_FREE( gname );
error = CFF_Err_Ok;
Exit:
@ -271,11 +267,9 @@
CFF_Font cff;
CFF_Charset charset;
FT_Service_PsCMaps psnames;
FT_Memory memory = FT_FACE_MEMORY( face );
FT_String* name;
FT_UShort sid;
FT_UInt i;
FT_Int result;
cff = (CFF_FontRec *)face->extra.data;
@ -290,19 +284,14 @@
sid = charset->sids[i];
if ( sid > 390 )
name = cff_index_get_name( &cff->string_index, sid - 391 );
name = cff_index_get_string( cff, sid - 391 );
else
name = (FT_String *)psnames->adobe_std_strings( sid );
if ( !name )
continue;
result = ft_strcmp( glyph_name, name );
if ( sid > 390 )
FT_FREE( name );
if ( !result )
if ( !ft_strcmp( glyph_name, name ) )
return i;
}
@ -333,35 +322,29 @@
PS_FontInfoRec* afont_info )
{
CFF_Font cff = (CFF_Font)face->extra.data;
FT_Error error = FT_Err_Ok;
FT_Error error = CFF_Err_Ok;
if ( cff && cff->font_info == NULL )
{
CFF_FontRecDict dict = &cff->top_font.font_dict;
PS_FontInfoRec *font_info;
FT_Memory memory = face->root.memory;
FT_Service_PsCMaps psnames = (FT_Service_PsCMaps)cff->psnames;
CFF_FontRecDict dict = &cff->top_font.font_dict;
PS_FontInfoRec *font_info;
FT_Memory memory = face->root.memory;
if ( FT_ALLOC( font_info, sizeof ( *font_info ) ) )
goto Fail;
font_info->version = cff_index_get_sid_string( &cff->string_index,
dict->version,
psnames );
font_info->notice = cff_index_get_sid_string( &cff->string_index,
dict->notice,
psnames );
font_info->full_name = cff_index_get_sid_string( &cff->string_index,
dict->full_name,
psnames );
font_info->family_name = cff_index_get_sid_string( &cff->string_index,
dict->family_name,
psnames );
font_info->weight = cff_index_get_sid_string( &cff->string_index,
dict->weight,
psnames );
font_info->version = cff_index_get_sid_string( cff,
dict->version );
font_info->notice = cff_index_get_sid_string( cff,
dict->notice );
font_info->full_name = cff_index_get_sid_string( cff,
dict->full_name );
font_info->family_name = cff_index_get_sid_string( cff,
dict->family_name );
font_info->weight = cff_index_get_sid_string( cff,
dict->weight );
font_info->italic_angle = dict->italic_angle;
font_info->is_fixed_pitch = dict->is_fixed_pitch;
font_info->underline_position = (FT_Short)dict->underline_position;
@ -467,8 +450,7 @@
if ( cff )
{
CFF_FontRecDict dict = &cff->top_font.font_dict;
FT_Service_PsCMaps psnames = (FT_Service_PsCMaps)cff->psnames;
CFF_FontRecDict dict = &cff->top_font.font_dict;
if ( dict->cid_registry == 0xFFFFU )
@ -480,18 +462,16 @@
if ( registry )
{
if ( cff->registry == NULL )
cff->registry = cff_index_get_sid_string( &cff->string_index,
dict->cid_registry,
psnames );
cff->registry = cff_index_get_sid_string( cff,
dict->cid_registry );
*registry = cff->registry;
}
if ( ordering )
{
if ( cff->ordering == NULL )
cff->ordering = cff_index_get_sid_string( &cff->string_index,
dict->cid_ordering,
psnames );
cff->ordering = cff_index_get_sid_string( cff,
dict->cid_ordering );
*ordering = cff->ordering;
}

View file

@ -22,7 +22,6 @@
#include FT_INTERNAL_STREAM_H
#include FT_INTERNAL_SFNT_H
#include FT_OUTLINE_H
#include FT_INTERNAL_POSTSCRIPT_HINTS_H
#include "cffobjs.h"
#include "cffload.h"
@ -394,7 +393,7 @@
/* initialize Type2 decoder */
decoder->cff = cff;
decoder->num_globals = cff->num_global_subrs;
decoder->num_globals = cff->global_subrs_index.count;
decoder->globals = cff->global_subrs;
decoder->globals_bias = cff_compute_bias(
cff->top_font.font_dict.charstring_type,
@ -430,7 +429,7 @@
goto Exit;
}
FT_TRACE4(( "glyph index %d (subfont %d):\n", glyph_index, fd_index ));
FT_TRACE3(( "glyph index %d (subfont %d):\n", glyph_index, fd_index ));
sub = cff->subfonts[fd_index];
@ -445,10 +444,10 @@
}
#ifdef FT_DEBUG_LEVEL_TRACE
else
FT_TRACE4(( "glyph index %d:\n", glyph_index ));
FT_TRACE3(( "glyph index %d:\n", glyph_index ));
#endif
decoder->num_locals = sub->num_local_subrs;
decoder->num_locals = sub->local_subrs_index.count;
decoder->locals = sub->local_subrs;
decoder->locals_bias = cff_compute_bias(
decoder->cff->top_font.font_dict.charstring_type,
@ -812,10 +811,10 @@
charstring_len );
decoder->seac = FALSE;
cff_free_glyph_data( face, &charstring, charstring_len );
if ( error )
goto Exit;
cff_free_glyph_data( face, &charstring, charstring_len );
}
/* Save the left bearing, advance and glyph width of the base */
@ -842,10 +841,10 @@
charstring_len );
decoder->seac = FALSE;
cff_free_glyph_data( face, &charstring, charstring_len );
if ( error )
goto Exit;
cff_free_glyph_data( face, &charstring, charstring_len );
}
/* Restore the left side bearing, advance and glyph width */
@ -1340,6 +1339,14 @@
decoder->num_hints += num_args / 2;
}
/* In a valid charstring there must be at least one byte */
/* after `hintmask' or `cntrmask' (e.g., for a `return' */
/* instruction). Additionally, there must be space for */
/* `num_hints' bits. */
if ( ( ip + ( ( decoder->num_hints + 7 ) >> 3 ) ) >= limit )
goto Syntax_Error;
if ( hinter )
{
if ( op == cff_op_hintmask )
@ -1358,20 +1365,18 @@
FT_UInt maskbyte;
FT_TRACE4(( " (maskbytes: " ));
FT_TRACE4(( " (maskbytes:" ));
for ( maskbyte = 0;
maskbyte < (FT_UInt)(( decoder->num_hints + 7 ) >> 3);
maskbyte < (FT_UInt)( ( decoder->num_hints + 7 ) >> 3 );
maskbyte++, ip++ )
FT_TRACE4(( "0x%02X", *ip ));
FT_TRACE4(( " 0x%02X", *ip ));
FT_TRACE4(( ")\n" ));
}
#else
ip += ( decoder->num_hints + 7 ) >> 3;
#endif
if ( ip >= limit )
goto Syntax_Error;
args = stack;
break;
@ -2275,7 +2280,11 @@
/* subsequent `pop' operands should add the arguments, */
/* this is the implementation described for `unknown' other */
/* subroutines in the Type1 spec. */
/* */
/* XXX Fix return arguments (see discussion below). */
args -= 2 + ( args[-2] >> 16 );
if ( args < stack )
goto Stack_Underflow;
break;
case cff_op_pop:
@ -2285,6 +2294,22 @@
FT_TRACE4(( " pop (invalid op)\n" ));
/* XXX Increasing `args' is wrong: After a certain number of */
/* `pop's we get a stack overflow. Reason for doing it is */
/* code like this (actually found in a CFF font): */
/* */
/* 17 1 3 callothersubr */
/* pop */
/* callsubr */
/* */
/* Since we handle `callothersubr' as a no-op, and */
/* `callsubr' needs at least one argument, `pop' can't be a */
/* no-op too as it basically should be. */
/* */
/* The right solution would be to provide real support for */
/* `callothersubr' as done in `t1decode.c', however, given */
/* the fact that CFF fonts with `pop' are invalid, it is */
/* questionable whether it is worth the time. */
args++;
break;
@ -2448,7 +2473,10 @@
return CFF_Err_Unimplemented_Feature;
}
decoder->top = args;
decoder->top = args;
if ( decoder->top - stack >= CFF_MAX_OPERANDS )
goto Stack_Overflow;
} /* general operator processing */
@ -2668,11 +2696,15 @@
/* this scaling is only relevant if the PS hinter isn't active */
if ( cff->num_subfonts )
{
FT_Byte fd_index = cff_fd_select_get( &cff->fd_select,
glyph_index );
FT_ULong top_upm, sub_upm;
FT_Byte fd_index = cff_fd_select_get( &cff->fd_select,
glyph_index );
FT_ULong top_upm = cff->top_font.font_dict.units_per_em;
FT_ULong sub_upm = cff->subfonts[fd_index]->font_dict.units_per_em;
if ( fd_index >= cff->num_subfonts )
fd_index = cff->num_subfonts - 1;
top_upm = cff->top_font.font_dict.units_per_em;
sub_upm = cff->subfonts[fd_index]->font_dict.units_per_em;
font_matrix = cff->subfonts[fd_index]->font_dict.font_matrix;
@ -2717,48 +2749,53 @@
/* now load the unscaled outline */
error = cff_get_glyph_data( face, glyph_index,
&charstring, &charstring_len );
if ( !error )
{
error = cff_decoder_prepare( &decoder, size, glyph_index );
if ( !error )
{
error = cff_decoder_parse_charstrings( &decoder,
charstring,
charstring_len );
if ( error )
goto Glyph_Build_Finished;
cff_free_glyph_data( face, &charstring, charstring_len );
error = cff_decoder_prepare( &decoder, size, glyph_index );
if ( error )
goto Glyph_Build_Finished;
error = cff_decoder_parse_charstrings( &decoder,
charstring,
charstring_len );
cff_free_glyph_data( face, &charstring, charstring_len );
if ( error )
goto Glyph_Build_Finished;
#ifdef FT_CONFIG_OPTION_INCREMENTAL
/* Control data and length may not be available for incremental */
/* fonts. */
if ( face->root.internal->incremental_interface )
{
glyph->root.control_data = 0;
glyph->root.control_len = 0;
}
else
/* Control data and length may not be available for incremental */
/* fonts. */
if ( face->root.internal->incremental_interface )
{
glyph->root.control_data = 0;
glyph->root.control_len = 0;
}
else
#endif /* FT_CONFIG_OPTION_INCREMENTAL */
/* We set control_data and control_len if charstrings is loaded. */
/* See how charstring loads at cff_index_access_element() in */
/* cffload.c. */
{
CFF_Index csindex = &cff->charstrings_index;
/* We set control_data and control_len if charstrings is loaded. */
/* See how charstring loads at cff_index_access_element() in */
/* cffload.c. */
{
CFF_Index csindex = &cff->charstrings_index;
if ( csindex->offsets )
{
glyph->root.control_data = csindex->bytes +
csindex->offsets[glyph_index] - 1;
glyph->root.control_len = charstring_len;
}
}
if ( csindex->offsets )
{
glyph->root.control_data = csindex->bytes +
csindex->offsets[glyph_index] - 1;
glyph->root.control_len = charstring_len;
}
}
/* save new glyph tables */
cff_builder_done( &decoder.builder );
Glyph_Build_Finished:
/* save new glyph tables, if no error */
if ( !error )
cff_builder_done( &decoder.builder );
/* XXX: anything to do for broken glyph entry? */
}
#ifdef FT_CONFIG_OPTION_INCREMENTAL

View file

@ -4,7 +4,8 @@
/* */
/* OpenType and CFF data/program tables loader (body). */
/* */
/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 by */
/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, */
/* 2010 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@ -20,7 +21,6 @@
#include FT_INTERNAL_DEBUG_H
#include FT_INTERNAL_OBJECTS_H
#include FT_INTERNAL_STREAM_H
#include FT_SERVICE_POSTSCRIPT_CMAPS_H
#include FT_TRUETYPE_TAGS_H
#include FT_TYPE1_TABLES_H
@ -251,7 +251,7 @@
if ( offsize < 1 || offsize > 4 )
{
error = FT_Err_Invalid_Table;
error = CFF_Err_Invalid_Table;
goto Exit;
}
@ -377,18 +377,21 @@
}
/* allocate a table containing pointers to an index's elements */
/* Allocate a table containing pointers to an index's elements. */
/* The `pool' argument makes this function convert the index */
/* entries to C-style strings (this is, NULL-terminated). */
static FT_Error
cff_index_get_pointers( CFF_Index idx,
FT_Byte*** table )
FT_Byte*** table,
FT_Byte** pool )
{
FT_Error error = CFF_Err_Ok;
FT_Memory memory = idx->stream->memory;
FT_ULong n, offset, old_offset;
FT_Error error = CFF_Err_Ok;
FT_Memory memory = idx->stream->memory;
FT_Byte** t;
FT_Byte* new_bytes = NULL;
*table = 0;
*table = NULL;
if ( idx->offsets == NULL )
{
@ -397,28 +400,65 @@
goto Exit;
}
if ( idx->count > 0 && !FT_NEW_ARRAY( t, idx->count + 1 ) )
if ( idx->count > 0 &&
!FT_NEW_ARRAY( t, idx->count + 1 ) &&
( !pool || !FT_ALLOC( new_bytes,
idx->data_size + idx->count ) ) )
{
old_offset = 1;
for ( n = 0; n <= idx->count; n++ )
FT_ULong n, cur_offset;
FT_ULong extra = 0;
FT_Byte* org_bytes = idx->bytes;
/* at this point, `idx->offsets' can't be NULL */
cur_offset = idx->offsets[0] - 1;
/* sanity check */
if ( cur_offset >= idx->data_size )
{
/* at this point, `idx->offsets' can't be NULL */
offset = idx->offsets[n];
if ( !offset )
offset = old_offset;
FT_TRACE0(( "cff_index_get_pointers:"
" invalid first offset value %d set to zero\n",
cur_offset ));
cur_offset = 0;
}
/* two sanity checks for invalid offset tables */
else if ( offset < old_offset )
offset = old_offset;
if ( !pool )
t[0] = org_bytes + cur_offset;
else
t[0] = new_bytes + cur_offset;
else if ( offset - 1 >= idx->data_size && n < idx->count )
offset = old_offset;
for ( n = 1; n <= idx->count; n++ )
{
FT_ULong next_offset = idx->offsets[n] - 1;
t[n] = idx->bytes + offset - 1;
old_offset = offset;
/* empty slot + two sanity checks for invalid offset tables */
if ( next_offset == 0 ||
next_offset < cur_offset ||
( next_offset >= idx->data_size && n < idx->count ) )
next_offset = cur_offset;
if ( !pool )
t[n] = org_bytes + next_offset;
else
{
t[n] = new_bytes + next_offset + extra;
if ( next_offset != cur_offset )
{
FT_MEM_COPY( t[n - 1], org_bytes + cur_offset, t[n] - t[n - 1] );
t[n][0] = '\0';
t[n] += 1;
extra++;
}
}
cur_offset = next_offset;
}
*table = t;
if ( pool )
*pool = new_bytes;
}
Exit:
@ -479,6 +519,18 @@
}
}
/* XXX: should check off2 does not exceed the end of this entry; */
/* at present, only truncate off2 at the end of this stream */
if ( off2 > stream->size + 1 ||
idx->data_offset > stream->size - off2 + 1 )
{
FT_ERROR(( "cff_index_access_element:"
" offset to next entry (%d)"
" exceeds the end of stream (%d)\n",
off2, stream->size - idx->data_offset + 1 ));
off2 = stream->size - idx->data_offset + 1;
}
/* access element */
if ( off1 && off2 > off1 )
{
@ -526,10 +578,12 @@
}
/* get an entry from Name INDEX */
FT_LOCAL_DEF( FT_String* )
cff_index_get_name( CFF_Index idx,
FT_UInt element )
cff_index_get_name( CFF_Font font,
FT_UInt element )
{
CFF_Index idx = &font->name_index;
FT_Memory memory = idx->stream->memory;
FT_Byte* bytes;
FT_ULong byte_len;
@ -553,42 +607,35 @@
}
/* get an entry from String INDEX */
FT_LOCAL_DEF( FT_String* )
cff_index_get_sid_string( CFF_Index idx,
FT_UInt sid,
FT_Service_PsCMaps psnames )
cff_index_get_string( CFF_Font font,
FT_UInt element )
{
return ( element < font->num_strings )
? (FT_String*)font->strings[element]
: NULL;
}
FT_LOCAL_DEF( FT_String* )
cff_index_get_sid_string( CFF_Font font,
FT_UInt sid )
{
/* value 0xFFFFU indicates a missing dictionary entry */
if ( sid == 0xFFFFU )
return 0;
return NULL;
/* if it is not a standard string, return it */
if ( sid > 390 )
return cff_index_get_name( idx, sid - 391 );
return cff_index_get_string( font, sid - 391 );
/* CID-keyed CFF fonts don't have glyph names */
if ( !psnames )
return 0;
if ( !font->psnames )
return NULL;
/* that's a standard string, fetch a copy from the PSName module */
{
FT_String* name = 0;
const char* adobe_name = psnames->adobe_std_strings( sid );
if ( adobe_name )
{
FT_Memory memory = idx->stream->memory;
FT_Error error;
(void)FT_STRDUP( name, adobe_name );
FT_UNUSED( error );
}
return name;
}
/* this is a standard string */
return (FT_String *)font->psnames->adobe_std_strings( sid );
}
@ -734,7 +781,7 @@
FT_UInt num_glyphs,
FT_Memory memory )
{
FT_Error error = FT_Err_Ok;
FT_Error error = CFF_Err_Ok;
FT_UInt i;
FT_Long j;
FT_UShort max_cid = 0;
@ -744,11 +791,12 @@
goto Exit;
for ( i = 0; i < num_glyphs; i++ )
{
if ( charset->sids[i] > max_cid )
max_cid = charset->sids[i];
max_cid++;
}
if ( FT_NEW_ARRAY( charset->cids, max_cid ) )
if ( FT_NEW_ARRAY( charset->cids, (FT_ULong)max_cid + 1 ) )
goto Exit;
/* When multiple GIDs map to the same CID, we choose the lowest */
@ -772,7 +820,7 @@
FT_UInt result = 0;
if ( cid < charset->max_cid )
if ( cid <= charset->max_cid )
result = charset->cids[cid];
return result;
@ -846,20 +894,7 @@
goto Exit;
for ( j = 1; j < num_glyphs; j++ )
{
FT_UShort sid = FT_GET_USHORT();
/* this constant is given in the CFF specification */
if ( sid < 65000L )
charset->sids[j] = sid;
else
{
FT_TRACE0(( "cff_charset_load:"
" invalid SID value %d set to zero\n", sid ));
charset->sids[j] = 0;
}
}
charset->sids[j] = FT_GET_USHORT();
FT_FRAME_EXIT();
}
@ -892,18 +927,12 @@
goto Exit;
}
/* check whether the range contains at least one valid glyph; */
/* the constant is given in the CFF specification */
if ( glyph_sid >= 65000L ) {
FT_ERROR(( "cff_charset_load: invalid SID range\n" ));
error = CFF_Err_Invalid_File_Format;
goto Exit;
}
/* try to rescue some of the SIDs if `nleft' is too large */
if ( nleft > 65000L - 1L || glyph_sid >= 65000L - nleft ) {
FT_ERROR(( "cff_charset_load: invalid SID range trimmed\n" ));
nleft = ( FT_UInt )( 65000L - 1L - glyph_sid );
if ( glyph_sid > 0xFFFFL - nleft )
{
FT_ERROR(( "cff_charset_load: invalid SID range trimmed"
" nleft=%d -> %d\n", nleft, 0xFFFFL - glyph_sid ));
nleft = ( FT_UInt )( 0xFFFFL - glyph_sid );
}
/* Fill in the range of sids -- `nleft + 1' glyphs. */
@ -1240,9 +1269,7 @@
if ( gid != 0 )
{
encoding->codes[j] = (FT_UShort)gid;
if ( encoding->count < j + 1 )
encoding->count = j + 1;
encoding->count = j + 1;
}
else
{
@ -1361,9 +1388,8 @@
if ( error )
goto Exit;
font->num_local_subrs = font->local_subrs_index.count;
error = cff_index_get_pointers( &font->local_subrs_index,
&font->local_subrs );
&font->local_subrs, NULL );
if ( error )
goto Exit;
}
@ -1409,9 +1435,11 @@
FT_Memory memory = stream->memory;
FT_ULong base_offset;
CFF_FontRecDict dict;
CFF_IndexRec string_index;
FT_ZERO( font );
FT_ZERO( &string_index );
font->stream = stream;
font->memory = memory;
@ -1438,15 +1466,20 @@
/* read the name, top dict, string and global subrs index */
if ( FT_SET_ERROR( cff_index_init( &font->name_index,
stream, 0 ) ) ||
stream, 0 ) ) ||
FT_SET_ERROR( cff_index_init( &font->font_dict_index,
stream, 0 ) ) ||
FT_SET_ERROR( cff_index_init( &font->string_index,
stream, 0 ) ) ||
stream, 0 ) ) ||
FT_SET_ERROR( cff_index_init( &string_index,
stream, 1 ) ) ||
FT_SET_ERROR( cff_index_init( &font->global_subrs_index,
stream, 1 ) ) )
stream, 1 ) ) ||
FT_SET_ERROR( cff_index_get_pointers( &string_index,
&font->strings,
&font->string_pool ) ) )
goto Exit;
font->num_strings = string_index.count;
/* well, we don't really forget the `disabled' fonts... */
font->num_faces = font->name_index.count;
if ( face_index >= (FT_Int)font->num_faces )
@ -1542,12 +1575,10 @@
goto Exit;
}
/* explicit the global subrs */
font->num_global_subrs = font->global_subrs_index.count;
font->num_glyphs = font->charstrings_index.count;
font->num_glyphs = font->charstrings_index.count;
error = cff_index_get_pointers( &font->global_subrs_index,
&font->global_subrs ) ;
&font->global_subrs, NULL );
if ( error )
goto Exit;
@ -1579,9 +1610,11 @@
/* get the font name (/CIDFontName for CID-keyed fonts, */
/* /FontName otherwise) */
font->font_name = cff_index_get_name( &font->name_index, face_index );
font->font_name = cff_index_get_name( font, face_index );
Exit:
cff_index_done( &string_index );
return error;
}
@ -1594,7 +1627,6 @@
cff_index_done( &font->global_subrs_index );
cff_index_done( &font->string_index );
cff_index_done( &font->font_dict_index );
cff_index_done( &font->name_index );
cff_index_done( &font->charstrings_index );
@ -1617,21 +1649,12 @@
CFF_Done_FD_Select( &font->fd_select, font->stream );
if (font->font_info != NULL)
{
FT_FREE( font->font_info->version );
FT_FREE( font->font_info->notice );
FT_FREE( font->font_info->full_name );
FT_FREE( font->font_info->family_name );
FT_FREE( font->font_info->weight );
FT_FREE( font->font_info );
}
FT_FREE( font->font_info );
FT_FREE( font->registry );
FT_FREE( font->ordering );
FT_FREE( font->global_subrs );
FT_FREE( font->font_name );
FT_FREE( font->global_subrs );
FT_FREE( font->strings );
FT_FREE( font->string_pool );
}

View file

@ -4,7 +4,7 @@
/* */
/* OpenType & CFF data/program tables loader (specification). */
/* */
/* Copyright 1996-2001, 2002, 2003, 2007, 2008 by */
/* Copyright 1996-2001, 2002, 2003, 2007, 2008, 2010 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@ -22,7 +22,6 @@
#include <ft2build.h>
#include "cfftypes.h"
#include FT_SERVICE_POSTSCRIPT_CMAPS_H
FT_BEGIN_HEADER
@ -32,13 +31,12 @@ FT_BEGIN_HEADER
FT_LOCAL( FT_String* )
cff_index_get_name( CFF_Index idx,
FT_UInt element );
cff_index_get_string( CFF_Font font,
FT_UInt element );
FT_LOCAL( FT_String* )
cff_index_get_sid_string( CFF_Index idx,
FT_UInt sid,
FT_Service_PsCMaps psnames );
cff_index_get_sid_string( CFF_Font font,
FT_UInt sid );
FT_LOCAL( FT_Error )
@ -51,6 +49,10 @@ FT_BEGIN_HEADER
cff_index_forget_element( CFF_Index idx,
FT_Byte** pbytes );
FT_LOCAL( FT_String* )
cff_index_get_name( CFF_Font font,
FT_UInt element );
FT_LOCAL( FT_UInt )
cff_charset_cid_to_gindex( CFF_Charset charset,

View file

@ -4,7 +4,8 @@
/* */
/* OpenType objects manager (body). */
/* */
/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 by */
/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, */
/* 2010 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@ -24,8 +25,6 @@
#include FT_TRUETYPE_IDS_H
#include FT_TRUETYPE_TAGS_H
#include FT_INTERNAL_SFNT_H
#include FT_SERVICE_POSTSCRIPT_CMAPS_H
#include FT_INTERNAL_POSTSCRIPT_HINTS_H
#include "cffobjs.h"
#include "cffload.h"
#include "cffcmap.h"
@ -58,7 +57,7 @@
{
CFF_Face face = (CFF_Face)size->root.face;
CFF_Font font = (CFF_Font)face->extra.data;
PSHinter_Service pshinter = (PSHinter_Service)font->pshinter;
PSHinter_Service pshinter = font->pshinter;
FT_Module module;
@ -349,7 +348,7 @@
{
CFF_Face face = (CFF_Face)slot->face;
CFF_Font font = (CFF_Font)face->extra.data;
PSHinter_Service pshinter = (PSHinter_Service)font->pshinter;
PSHinter_Service pshinter = font->pshinter;
if ( pshinter )
@ -395,6 +394,41 @@
}
/* Strip all subset prefixes of the form `ABCDEF+'. Usually, there */
/* is only one, but font names like `APCOOG+JFABTD+FuturaBQ-Bold' */
/* have been seen in the wild. */
static void
remove_subset_prefix( FT_String* name )
{
FT_Int32 idx = 0;
FT_Int32 length = strlen( name ) + 1;
FT_Bool continue_search = 1;
while ( continue_search )
{
if ( length >= 7 && name[6] == '+' )
{
for ( idx = 0; idx < 6; idx++ )
{
/* ASCII uppercase letters */
if ( !( 'A' <= name[idx] && name[idx] <= 'Z' ) )
continue_search = 0;
}
if ( continue_search )
{
for ( idx = 7; idx < length; idx++ )
name[idx - 7] = name[idx];
}
}
else
continue_search = 0;
}
}
FT_LOCAL_DEF( FT_Error )
cff_face_init( FT_Stream stream,
FT_Face cffface, /* CFF_Face */
@ -412,14 +446,6 @@
FT_Library library = cffface->driver->root.library;
#if 0
FT_FACE_FIND_GLOBAL_SERVICE( face, sfnt, SFNT );
FT_FACE_FIND_GLOBAL_SERVICE( face, psnames, POSTSCRIPT_NAMES );
FT_FACE_FIND_GLOBAL_SERVICE( face, pshinter, POSTSCRIPT_HINTER );
if ( !sfnt )
goto Bad_Format;
#else
sfnt = (SFNT_Service)FT_Get_Module_Interface(
library, "sfnt" );
if ( !sfnt )
@ -429,7 +455,6 @@
pshinter = (PSHinter_Service)FT_Get_Module_Interface(
library, "pshinter" );
#endif
/* create input stream from resource */
if ( FT_STREAM_SEEK( 0 ) )
@ -514,7 +539,7 @@
goto Exit;
cff->pshinter = pshinter;
cff->psnames = (void*)psnames;
cff->psnames = psnames;
cffface->face_index = face_index;
@ -652,7 +677,7 @@
/* compute number of glyphs */
if ( dict->cid_registry != 0xFFFFU )
cffface->num_glyphs = cff->charset.max_cid;
cffface->num_glyphs = cff->charset.max_cid + 1;
else
cffface->num_glyphs = cff->charstrings_index.count;
@ -678,24 +703,22 @@
(FT_Short)( dict->underline_thickness >> 16 );
/* retrieve font family & style name */
cffface->family_name = cff_index_get_name( &cff->name_index,
face_index );
cffface->family_name = cff_index_get_name( cff, face_index );
if ( cffface->family_name )
{
char* full = cff_index_get_sid_string( &cff->string_index,
dict->full_name,
psnames );
char* full = cff_index_get_sid_string( cff,
dict->full_name );
char* fullp = full;
char* family = cffface->family_name;
char* family_name = 0;
char* family_name = NULL;
remove_subset_prefix( cffface->family_name );
if ( dict->family_name )
{
family_name = cff_index_get_sid_string( &cff->string_index,
dict->family_name,
psnames);
family_name = cff_index_get_sid_string( cff,
dict->family_name );
if ( family_name )
family = family_name;
}
@ -738,23 +761,18 @@
}
break;
}
if ( family_name )
FT_FREE( family_name );
FT_FREE( full );
}
}
else
{
char *cid_font_name =
cff_index_get_sid_string( &cff->string_index,
dict->cid_font_name,
psnames );
cff_index_get_sid_string( cff,
dict->cid_font_name );
/* do we have a `/FontName' for a CID-keyed font? */
if ( cid_font_name )
cffface->family_name = cid_font_name;
cffface->family_name = cff_strcpy( memory, cid_font_name );
}
if ( style_name )
@ -797,16 +815,14 @@
flags |= FT_STYLE_FLAG_ITALIC;
{
char *weight = cff_index_get_sid_string( &cff->string_index,
dict->weight,
psnames );
char *weight = cff_index_get_sid_string( cff,
dict->weight );
if ( weight )
if ( !ft_strcmp( weight, "Bold" ) ||
!ft_strcmp( weight, "Black" ) )
flags |= FT_STYLE_FLAG_BOLD;
FT_FREE( weight );
}
/* double check */
@ -849,13 +865,14 @@
{
cmap = cffface->charmaps[nn];
/* Windows Unicode (3,1)? */
if ( cmap->platform_id == 3 && cmap->encoding_id == 1 )
/* Windows Unicode? */
if ( cmap->platform_id == TT_PLATFORM_MICROSOFT &&
cmap->encoding_id == TT_MS_ID_UNICODE_CS )
goto Skip_Unicode;
/* Deprecated Unicode platform id? */
if ( cmap->platform_id == 0 )
goto Skip_Unicode; /* Standard Unicode (deprecated) */
/* Apple Unicode platform id? */
if ( cmap->platform_id == TT_PLATFORM_APPLE_UNICODE )
goto Skip_Unicode; /* Apple Unicode */
}
/* since CID-keyed fonts don't contain glyph names, we can't */
@ -863,28 +880,51 @@
if ( pure_cff && cff->top_font.font_dict.cid_registry != 0xFFFFU )
goto Exit;
#ifdef FT_MAX_CHARMAP_CACHEABLE
if ( nn + 1 > FT_MAX_CHARMAP_CACHEABLE )
{
FT_ERROR(( "cff_face_init: no Unicode cmap is found, "
"and too many subtables (%d) to add synthesized cmap\n",
nn ));
goto Exit;
}
#endif
/* we didn't find a Unicode charmap -- synthesize one */
cmaprec.face = cffface;
cmaprec.platform_id = 3;
cmaprec.encoding_id = 1;
cmaprec.platform_id = TT_PLATFORM_MICROSOFT;
cmaprec.encoding_id = TT_MS_ID_UNICODE_CS;
cmaprec.encoding = FT_ENCODING_UNICODE;
nn = (FT_UInt)cffface->num_charmaps;
FT_CMap_New( &FT_CFF_CMAP_UNICODE_CLASS_REC_GET, NULL, &cmaprec, NULL );
error = FT_CMap_New( &FT_CFF_CMAP_UNICODE_CLASS_REC_GET, NULL,
&cmaprec, NULL );
if ( error && FT_Err_No_Unicode_Glyph_Name != error )
goto Exit;
error = FT_Err_Ok;
/* if no Unicode charmap was previously selected, select this one */
if ( cffface->charmap == NULL && nn != (FT_UInt)cffface->num_charmaps )
cffface->charmap = cffface->charmaps[nn];
Skip_Unicode:
#ifdef FT_MAX_CHARMAP_CACHEABLE
if ( nn > FT_MAX_CHARMAP_CACHEABLE )
{
FT_ERROR(( "cff_face_init: Unicode cmap is found, "
"but too many preceding subtables (%d) to access\n",
nn - 1 ));
goto Exit;
}
#endif
if ( encoding->count > 0 )
{
FT_CMap_Class clazz;
cmaprec.face = cffface;
cmaprec.platform_id = 7; /* Adobe platform id */
cmaprec.platform_id = TT_PLATFORM_ADOBE; /* Adobe platform id */
if ( encoding->offset == 0 )
{
@ -905,7 +945,7 @@
clazz = &FT_CFF_CMAP_ENCODING_CLASS_REC_GET;
}
FT_CMap_New( clazz, NULL, &cmaprec, NULL );
error = FT_CMap_New( clazz, NULL, &cmaprec, NULL );
}
}
}

View file

@ -4,7 +4,7 @@
/* */
/* CFF token stream parser (body) */
/* */
/* Copyright 1996-2001, 2002, 2003, 2004, 2007, 2008, 2009 by */
/* Copyright 1996-2001, 2002, 2003, 2004, 2007, 2008, 2009, 2010 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@ -137,26 +137,23 @@
FT_UInt nib;
FT_UInt phase;
FT_Long result, number, rest, exponent;
FT_Long result, number, exponent;
FT_Int sign = 0, exponent_sign = 0;
FT_Long exponent_add, integer_length, fraction_length;
if ( scaling )
*scaling = 0;
*scaling = 0;
result = 0;
number = 0;
rest = 0;
exponent = 0;
exponent_add = 0;
integer_length = 0;
fraction_length = 0;
FT_UNUSED( rest );
/* First of all, read the integer part. */
phase = 4;
@ -332,11 +329,19 @@
goto Exit;
/* Remove non-significant digits. */
if ( integer_length < 0 ) {
if ( integer_length < 0 )
{
number /= power_tens[-integer_length];
fraction_length += integer_length;
}
/* this can only happen if exponent was non-zero */
if ( fraction_length == 10 )
{
number /= 10;
fraction_length -= 1;
}
/* Convert into 16.16 format. */
if ( fraction_length > 0 )
{
@ -702,7 +707,7 @@
clazz[i].count_offset = 0;
*output_class = clazz;
return FT_Err_Ok;
return CFF_Err_Ok;
}

View file

@ -4,7 +4,7 @@
/* */
/* The FreeType position independent code services for cff module. */
/* */
/* Copyright 2009 by */
/* Copyright 2009, 2010 by */
/* Oran Agra and Mickey Gabel. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@ -59,18 +59,20 @@
}
}
FT_Error
cff_driver_class_pic_init( FT_Library library )
cff_driver_class_pic_init( FT_Library library )
{
FT_PIC_Container* pic_container = &library->pic_container;
FT_Error error = FT_Err_Ok;
CffModulePIC* container;
FT_Memory memory = library->memory;
FT_PIC_Container* pic_container = &library->pic_container;
FT_Error error = CFF_Err_Ok;
CffModulePIC* container;
FT_Memory memory = library->memory;
/* allocate pointer, clear and set global container pointer */
if ( FT_ALLOC ( container, sizeof ( *container ) ) )
return error;
FT_MEM_SET( container, 0, sizeof(*container) );
FT_MEM_SET( container, 0, sizeof ( *container ) );
pic_container->cff = container;
/* initialize pointer table - this is how the module usually expects this data */

View file

@ -5,7 +5,7 @@
/* Basic OpenType/CFF type definitions and interface (specification */
/* only). */
/* */
/* Copyright 1996-2001, 2002, 2003, 2006, 2007, 2008 by */
/* Copyright 1996-2001, 2002, 2003, 2006, 2007, 2008, 2010 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@ -24,6 +24,9 @@
#include <ft2build.h>
#include FT_FREETYPE_H
#include FT_TYPE1_TABLES_H
#include FT_INTERNAL_SERVICE_H
#include FT_SERVICE_POSTSCRIPT_CMAPS_H
#include FT_INTERNAL_POSTSCRIPT_HINTS_H
FT_BEGIN_HEADER
@ -204,8 +207,7 @@ FT_BEGIN_HEADER
CFF_PrivateRec private_dict;
CFF_IndexRec local_subrs_index;
FT_UInt num_local_subrs;
FT_Byte** local_subrs;
FT_Byte** local_subrs; /* array of pointers into Local Subrs INDEX data */
} CFF_SubFontRec, *CFF_SubFont;
@ -229,7 +231,6 @@ FT_BEGIN_HEADER
CFF_IndexRec name_index;
CFF_IndexRec top_dict_index;
CFF_IndexRec string_index;
CFF_IndexRec global_subrs_index;
CFF_EncodingRec encoding;
@ -241,9 +242,15 @@ FT_BEGIN_HEADER
CFF_IndexRec local_subrs_index;
FT_String* font_name;
FT_UInt num_global_subrs;
/* array of pointers into Global Subrs INDEX data */
FT_Byte** global_subrs;
/* array of pointers into String INDEX data stored at string_pool */
FT_UInt num_strings;
FT_Byte** strings;
FT_Byte* string_pool;
CFF_SubFontRec top_font;
FT_UInt num_subfonts;
CFF_SubFont subfonts[CFF_MAX_CID_FONTS];
@ -251,10 +258,10 @@ FT_BEGIN_HEADER
CFF_FDSelectRec fd_select;
/* interface to PostScript hinter */
void* pshinter;
PSHinter_Service pshinter;
/* interface to Postscript Names service */
void* psnames;
FT_Service_PsCMaps psnames;
/* since version 2.3.0 */
PS_FontInfoRec* font_info; /* font info dictionary */

View file

@ -272,7 +272,6 @@
FT_Int32 load_flags )
{
CID_GlyphSlot glyph = (CID_GlyphSlot)cidglyph;
CID_Size size = (CID_Size)cidsize;
FT_Error error;
T1_DecoderRec decoder;
CID_Face face = (CID_Face)cidglyph->face;
@ -375,7 +374,7 @@
cidglyph->format = FT_GLYPH_FORMAT_OUTLINE;
if ( size && cidsize->metrics.y_ppem < 24 )
if ( cidsize->metrics.y_ppem < 24 )
cidglyph->outline.flags |= FT_OUTLINE_HIGH_PRECISION;
/* apply the font matrix */

View file

@ -4,7 +4,7 @@
/* */
/* CID objects manager (body). */
/* */
/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006, 2008 by */
/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006, 2008, 2010 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@ -131,7 +131,7 @@
cid_size_init( FT_Size cidsize ) /* CID_Size */
{
CID_Size size = (CID_Size)cidsize;
FT_Error error = 0;
FT_Error error = CID_Err_Ok;
PSH_Globals_Funcs funcs = cid_size_get_globals_funcs( size );

View file

@ -4,7 +4,7 @@
/* */
/* TrueTypeGX/AAT common tables validation (body). */
/* */
/* Copyright 2004, 2005, 2009 */
/* Copyright 2004, 2005, 2009, 2010 */
/* by suzuki toshiya, Masatake YAMATO, Red Hat K.K., */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
@ -908,7 +908,7 @@
nnames = FT_Get_Sfnt_Name_Count( valid->face );
for ( i = 0; i < nnames; i++ )
{
if ( FT_Get_Sfnt_Name( valid->face, i, &name ) != FT_Err_Ok )
if ( FT_Get_Sfnt_Name( valid->face, i, &name ) != GXV_Err_Ok )
continue ;
if ( name.name_id == name_index )

View file

@ -8,7 +8,7 @@
/* parse compressed PCF fonts, as found with many X11 server */
/* distributions. */
/* */
/* Copyright 2002, 2003, 2004, 2005, 2006, 2009 by */
/* Copyright 2002, 2003, 2004, 2005, 2006, 2009, 2010 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@ -107,7 +107,7 @@
{
FT_ULong sz = (FT_ULong)size * items;
FT_Error error;
FT_Pointer p;
FT_Pointer p = NULL;
(void)FT_ALLOC( p, sz );
@ -390,7 +390,7 @@
ft_gzip_file_fill_output( FT_GZipFile zip )
{
z_stream* zstream = &zip->zstream;
FT_Error error = 0;
FT_Error error = Gzip_Err_Ok;
zip->cursor = zip->buffer;
@ -656,7 +656,7 @@
ft_gzip_file_io( zip, 0, NULL, 0 );
FT_FREE( zip_buff );
}
error = 0;
error = Gzip_Err_Ok;
}
}

View file

@ -171,7 +171,7 @@
{
FT_LzwState lzw = &zip->lzw;
FT_ULong count;
FT_Error error = 0;
FT_Error error = LZW_Err_Ok;
zip->cursor = zip->buffer;

View file

@ -248,7 +248,8 @@
otv_MathItalicsCorrectionInfo_validate(
table + MathTopAccentAttachment, valid, FALSE );
if ( ExtendedShapeCoverage ) {
if ( ExtendedShapeCoverage )
{
OTV_NAME_ENTER( "ExtendedShapeCoverage" );
otv_Coverage_validate( table + ExtendedShapeCoverage, valid, -1 );
OTV_EXIT;

View file

@ -214,7 +214,8 @@
*ot_jstf = (FT_Bytes)jstf;
Exit:
if ( error ) {
if ( error )
{
FT_Memory memory = FT_FACE_MEMORY( face );
@ -224,6 +225,7 @@
FT_FREE( gsub );
FT_FREE( jstf );
}
{
FT_Memory memory = FT_FACE_MEMORY( face );

View file

@ -34,6 +34,7 @@ THE SOFTWARE.
#include FT_LZW_H
#include FT_ERRORS_H
#include FT_BDF_H
#include FT_TRUETYPE_IDS_H
#include "pcf.h"
#include "pcfdrivr.h"
@ -227,7 +228,8 @@ THE SOFTWARE.
{
prop = &face->properties[i];
if ( prop ) {
if ( prop )
{
FT_FREE( prop->name );
if ( prop->isString )
FT_FREE( prop->value.atom );
@ -358,14 +360,15 @@ THE SOFTWARE.
charmap.face = FT_FACE( face );
charmap.encoding = FT_ENCODING_NONE;
charmap.platform_id = 0;
charmap.encoding_id = 0;
/* initial platform/encoding should indicate unset status? */
charmap.platform_id = TT_PLATFORM_APPLE_UNICODE;
charmap.encoding_id = TT_APPLE_ID_DEFAULT;
if ( unicode_charmap )
{
charmap.encoding = FT_ENCODING_UNICODE;
charmap.platform_id = 3;
charmap.encoding_id = 1;
charmap.platform_id = TT_PLATFORM_MICROSOFT;
charmap.encoding_id = TT_MS_ID_UNICODE_CS;
}
error = FT_CMap_New( &pcf_cmap_class, NULL, &charmap, NULL );

View file

@ -2,7 +2,8 @@
FreeType font driver for pcf fonts
Copyright 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 by
Copyright 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,
2010 by
Francesco Zappa Nardelli
Permission is hereby granted, free of charge, to any person obtaining a copy
@ -607,6 +608,9 @@ THE SOFTWARE.
face->nmetrics = nmetrics;
if ( !nmetrics )
return PCF_Err_Invalid_Table;
FT_TRACE4(( "pcf_get_metrics:\n" ));
FT_TRACE4(( " number of metrics: %d\n", nmetrics ));

View file

@ -4,7 +4,7 @@
/* */
/* FreeType PFR driver interface (body). */
/* */
/* Copyright 2002, 2003, 2004, 2006, 2008 by */
/* Copyright 2002, 2003, 2004, 2006, 2008, 2010 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@ -84,7 +84,7 @@
if ( gindex < phys->num_chars )
{
*anadvance = phys->chars[gindex].advance;
error = 0;
error = PFR_Err_Ok;
}
}

View file

@ -4,7 +4,7 @@
/* */
/* FreeType PFR glyph loader (body). */
/* */
/* Copyright 2002, 2003, 2005, 2007 by */
/* Copyright 2002, 2003, 2005, 2007, 2010 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@ -248,7 +248,7 @@
FT_Byte* p,
FT_Byte* limit )
{
FT_Error error = 0;
FT_Error error = PFR_Err_Ok;
FT_Memory memory = glyph->loader->memory;
FT_UInt flags, x_count, y_count, i, count, mask;
FT_Int x;
@ -268,8 +268,8 @@
{
PFR_CHECK( 1 );
count = PFR_NEXT_BYTE( p );
x_count = ( count & 15 );
y_count = ( count >> 4 );
x_count = count & 15;
y_count = count >> 4;
}
else
{
@ -388,7 +388,7 @@
case 2: /* horizontal line to */
FT_TRACE6(( "- horizontal line to cx.%d", format_low ));
if ( format_low > x_count )
if ( format_low >= x_count )
goto Failure;
pos[0].x = glyph->x_control[format_low];
pos[0].y = pos[3].y;
@ -398,7 +398,7 @@
case 3: /* vertical line to */
FT_TRACE6(( "- vertical line to cy.%d", format_low ));
if ( format_low > y_count )
if ( format_low >= y_count )
goto Failure;
pos[0].x = pos[3].x;
pos[0].y = glyph->y_control[format_low];
@ -440,7 +440,7 @@
case 0: /* 8-bit index */
PFR_CHECK( 1 );
idx = PFR_NEXT_BYTE( p );
if ( idx > x_count )
if ( idx >= x_count )
goto Failure;
cur->x = glyph->x_control[idx];
FT_TRACE7(( " cx#%d", idx ));
@ -470,7 +470,7 @@
case 0: /* 8-bit index */
PFR_CHECK( 1 );
idx = PFR_NEXT_BYTE( p );
if ( idx > y_count )
if ( idx >= y_count )
goto Failure;
cur->y = glyph->y_control[idx];
FT_TRACE7(( " cy#%d", idx ));
@ -558,7 +558,7 @@
FT_Byte* p,
FT_Byte* limit )
{
FT_Error error = 0;
FT_Error error = PFR_Err_Ok;
FT_GlyphLoader loader = glyph->loader;
FT_Memory memory = loader->memory;
PFR_SubGlyph subglyph;
@ -598,6 +598,16 @@
FT_UInt new_max = ( org_count + count + 3 ) & (FT_UInt)-4;
/* we arbitrarily limit the number of subglyphs */
/* to avoid endless recursion */
if ( new_max > 64 )
{
error = PFR_Err_Invalid_Table;
FT_ERROR(( "pfr_glyph_load_compound:"
" too many compound glyphs components\n" ));
goto Exit;
}
if ( FT_RENEW_ARRAY( glyph->subs, glyph->max_subs, new_max ) )
goto Exit;
@ -743,6 +753,9 @@
count = glyph->num_subs - old_count;
FT_TRACE4(( "compound glyph with %d elements (offset %lu):\n",
count, offset ));
/* now, load each individual glyph */
for ( n = 0; n < count; n++ )
{
@ -750,6 +763,8 @@
PFR_SubGlyph subglyph;
FT_TRACE4(( "subglyph %d:\n", n ));
subglyph = glyph->subs + old_count + n;
old_points = base->n_points;
@ -757,7 +772,7 @@
subglyph->gps_offset,
subglyph->gps_size );
if ( error )
goto Exit;
break;
/* note that `glyph->subs' might have been re-allocated */
subglyph = glyph->subs + old_count + n;
@ -791,9 +806,13 @@
/* proceed to next sub-glyph */
}
FT_TRACE4(( "end compound glyph with %d elements\n", count ));
}
else
{
FT_TRACE4(( "simple glyph (offset %lu)\n", offset ));
/* load a simple glyph */
error = pfr_glyph_load_simple( glyph, p, limit );
@ -805,9 +824,6 @@
}
FT_LOCAL_DEF( FT_Error )
pfr_glyph_load( PFR_Glyph glyph,
FT_Stream stream,

View file

@ -4,7 +4,7 @@
/* */
/* FreeType PFR loader (body). */
/* */
/* Copyright 2002, 2003, 2004, 2005, 2007, 2009 by */
/* Copyright 2002, 2003, 2004, 2005, 2007, 2009, 2010 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@ -49,7 +49,7 @@
PFR_ExtraItem item_list,
FT_Pointer item_data )
{
FT_Error error = 0;
FT_Error error = PFR_Err_Ok;
FT_Byte* p = *pp;
FT_UInt num_items, item_type, item_size;
@ -353,7 +353,7 @@
PFR_Strike strike;
FT_UInt flags0;
FT_UInt n, count, size1;
FT_Error error = 0;
FT_Error error = PFR_Err_Ok;
PFR_CHECK( 5 );
@ -449,7 +449,7 @@
FT_Byte* limit,
PFR_PhyFont phy_font )
{
FT_Error error = 0;
FT_Error error = PFR_Err_Ok;
FT_Memory memory = phy_font->memory;
FT_PtrDist len = limit - p;
@ -477,7 +477,7 @@
{
FT_UInt count, num_vert, num_horz;
FT_Int* snaps;
FT_Error error = 0;
FT_Error error = PFR_Err_Ok;
FT_Memory memory = phy_font->memory;
@ -520,8 +520,8 @@
FT_Byte* limit,
PFR_PhyFont phy_font )
{
PFR_KernItem item;
FT_Error error = 0;
PFR_KernItem item = NULL;
FT_Error error = PFR_Err_Ok;
FT_Memory memory = phy_font->memory;
@ -631,7 +631,7 @@
FT_Memory memory,
FT_String* *astring )
{
FT_Error error = 0;
FT_Error error = PFR_Err_Ok;
FT_String* result = NULL;
FT_UInt n, ok;

View file

@ -4,7 +4,7 @@
/* */
/* FreeType PFR object methods (body). */
/* */
/* Copyright 2002, 2003, 2004, 2005, 2006, 2007, 2008 by */
/* Copyright 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2010 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@ -23,6 +23,7 @@
#include "pfrsbit.h"
#include FT_OUTLINE_H
#include FT_INTERNAL_DEBUG_H
#include FT_TRUETYPE_IDS_H
#include "pfrerror.h"
@ -147,7 +148,16 @@
break;
if ( nn == phy_font->num_chars )
pfrface->face_flags = 0; /* not scalable */
{
if ( phy_font->num_strikes > 0 )
pfrface->face_flags = 0; /* not scalable */
else
{
FT_ERROR(( "pfr_face_init: font doesn't contain glyphs\n" ));
error = PFR_Err_Invalid_File_Format;
goto Exit;
}
}
}
if ( (phy_font->flags & PFR_PHY_PROPORTIONAL) == 0 )
@ -243,11 +253,11 @@
charmap.face = pfrface;
charmap.platform_id = 3;
charmap.encoding_id = 1;
charmap.platform_id = TT_PLATFORM_MICROSOFT;
charmap.encoding_id = TT_MS_ID_UNICODE_CS;
charmap.encoding = FT_ENCODING_UNICODE;
FT_CMap_New( &pfr_cmap_class_rec, NULL, &charmap, NULL );
error = FT_CMap_New( &pfr_cmap_class_rec, NULL, &charmap, NULL );
#if 0
/* Select default charmap */

View file

@ -4,7 +4,7 @@
/* */
/* FreeType PFR bitmap loader (body). */
/* */
/* Copyright 2002, 2003, 2006, 2009 by */
/* Copyright 2002, 2003, 2006, 2009, 2010 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@ -353,7 +353,7 @@
FT_Long *aadvance,
FT_UInt *aformat )
{
FT_Error error = 0;
FT_Error error = PFR_Err_Ok;
FT_Byte flags;
FT_Char b;
FT_Byte* p = *pdata;
@ -484,7 +484,7 @@
FT_Bool decreasing,
FT_Bitmap* target )
{
FT_Error error = 0;
FT_Error error = PFR_Err_Ok;
PFR_BitWriterRec writer;

View file

@ -4,7 +4,7 @@
/* */
/* AFM parser (body). */
/* */
/* Copyright 2006, 2007, 2008, 2009 by */
/* Copyright 2006, 2007, 2008, 2009, 2010 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@ -527,7 +527,7 @@
FT_Byte* base,
FT_Byte* limit )
{
AFM_Stream stream;
AFM_Stream stream = NULL;
FT_Error error;

View file

@ -56,7 +56,8 @@ FT_BEGIN_HEADER
typedef struct AFM_ValueRec_
{
enum AFM_ValueType_ type;
union {
union
{
char* s;
FT_Fixed f;
FT_Int i;

View file

@ -4,7 +4,8 @@
/* */
/* Auxiliary functions for PostScript fonts (body). */
/* */
/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 by */
/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, */
/* 2010 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@ -1588,6 +1589,13 @@
FT_Error error;
/* this might happen in invalid fonts */
if ( !outline )
{
FT_ERROR(( "t1_builder_add_contour: no outline to add points to\n" ));
return PSaux_Err_Invalid_File_Format;
}
if ( !builder->load_points )
{
outline->n_contours++;
@ -1621,7 +1629,7 @@
if ( builder->parse_state == T1_Parse_Have_Path )
error = PSaux_Err_Ok;
else if ( builder->parse_state == T1_Parse_Have_Moveto )
else
{
builder->parse_state = T1_Parse_Have_Path;
error = t1_builder_add_contour( builder );

View file

@ -373,15 +373,6 @@
#endif
/* we don't want to touch the source code -- use macro trick */
#define start_point t1_builder_start_point
#define check_points t1_builder_check_points
#define add_point t1_builder_add_point
#define add_point1 t1_builder_add_point1
#define add_contour t1_builder_add_contour
#define close_contour t1_builder_close_contour
/* compute random seed from stack address of parameter */
seed = (FT_Fixed)( ( (FT_PtrDist)(char*)&seed ^
(FT_PtrDist)(char*)&decoder ^
@ -739,8 +730,10 @@
decoder->flex_state = 1;
decoder->num_flex_vectors = 0;
if ( start_point( builder, x, y ) ||
check_points( builder, 6 ) )
if ( ( error = t1_builder_start_point( builder, x, y ) )
!= PSaux_Err_Ok ||
( error = t1_builder_check_points( builder, 6 ) )
!= PSaux_Err_Ok )
goto Fail;
break;
@ -757,10 +750,10 @@
/* point without adding any point to the outline */
idx = decoder->num_flex_vectors++;
if ( idx > 0 && idx < 7 )
add_point( builder,
x,
y,
(FT_Byte)( idx == 3 || idx == 6 ) );
t1_builder_add_point( builder,
x,
y,
(FT_Byte)( idx == 3 || idx == 6 ) );
}
break;
@ -777,6 +770,8 @@
}
/* the two `results' are popped by the following setcurrentpoint */
top[0] = x;
top[1] = y;
known_othersubr_result_cnt = 2;
break;
@ -1075,7 +1070,7 @@
case op_endchar:
FT_TRACE4(( " endchar\n" ));
close_contour( builder );
t1_builder_close_contour( builder );
/* close hints recording session */
if ( hinter )
@ -1174,7 +1169,7 @@
/* if there is no path, `closepath' is a no-op */
if ( builder->parse_state == T1_Parse_Have_Path ||
builder->parse_state == T1_Parse_Have_Moveto )
close_contour( builder );
t1_builder_close_contour( builder );
builder->parse_state = T1_Parse_Have_Width;
break;
@ -1182,7 +1177,8 @@
case op_hlineto:
FT_TRACE4(( " hlineto" ));
if ( start_point( builder, x, y ) )
if ( ( error = t1_builder_start_point( builder, x, y ) )
!= PSaux_Err_Ok )
goto Fail;
x += top[0];
@ -1203,30 +1199,34 @@
case op_hvcurveto:
FT_TRACE4(( " hvcurveto" ));
if ( start_point( builder, x, y ) ||
check_points( builder, 3 ) )
if ( ( error = t1_builder_start_point( builder, x, y ) )
!= PSaux_Err_Ok ||
( error = t1_builder_check_points( builder, 3 ) )
!= PSaux_Err_Ok )
goto Fail;
x += top[0];
add_point( builder, x, y, 0 );
t1_builder_add_point( builder, x, y, 0 );
x += top[1];
y += top[2];
add_point( builder, x, y, 0 );
t1_builder_add_point( builder, x, y, 0 );
y += top[3];
add_point( builder, x, y, 1 );
t1_builder_add_point( builder, x, y, 1 );
break;
case op_rlineto:
FT_TRACE4(( " rlineto" ));
if ( start_point( builder, x, y ) )
if ( ( error = t1_builder_start_point( builder, x, y ) )
!= PSaux_Err_Ok )
goto Fail;
x += top[0];
y += top[1];
Add_Line:
if ( add_point1( builder, x, y ) )
if ( ( error = t1_builder_add_point1( builder, x, y ) )
!= PSaux_Err_Ok )
goto Fail;
break;
@ -1246,43 +1246,48 @@
case op_rrcurveto:
FT_TRACE4(( " rrcurveto" ));
if ( start_point( builder, x, y ) ||
check_points( builder, 3 ) )
if ( ( error = t1_builder_start_point( builder, x, y ) )
!= PSaux_Err_Ok ||
( error = t1_builder_check_points( builder, 3 ) )
!= PSaux_Err_Ok )
goto Fail;
x += top[0];
y += top[1];
add_point( builder, x, y, 0 );
t1_builder_add_point( builder, x, y, 0 );
x += top[2];
y += top[3];
add_point( builder, x, y, 0 );
t1_builder_add_point( builder, x, y, 0 );
x += top[4];
y += top[5];
add_point( builder, x, y, 1 );
t1_builder_add_point( builder, x, y, 1 );
break;
case op_vhcurveto:
FT_TRACE4(( " vhcurveto" ));
if ( start_point( builder, x, y ) ||
check_points( builder, 3 ) )
if ( ( error = t1_builder_start_point( builder, x, y ) )
!= PSaux_Err_Ok ||
( error = t1_builder_check_points( builder, 3 ) )
!= PSaux_Err_Ok )
goto Fail;
y += top[0];
add_point( builder, x, y, 0 );
t1_builder_add_point( builder, x, y, 0 );
x += top[1];
y += top[2];
add_point( builder, x, y, 0 );
t1_builder_add_point( builder, x, y, 0 );
x += top[3];
add_point( builder, x, y, 1 );
t1_builder_add_point( builder, x, y, 1 );
break;
case op_vlineto:
FT_TRACE4(( " vlineto" ));
if ( start_point( builder, x, y ) )
if ( ( error = t1_builder_start_point( builder, x, y ) )
!= PSaux_Err_Ok )
goto Fail;
y += top[0];
@ -1480,8 +1485,12 @@
goto Syntax_Error;
}
else
...
#endif
decoder->flex_state = 0;
x = top[0];
y = top[1];
decoder->flex_state = 0;
break;
case op_unknown15:

View file

@ -4,7 +4,8 @@
/* */
/* PostScript hinting algorithm (body). */
/* */
/* Copyright 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 by */
/* Copyright 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 */
/* by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used */
@ -1690,7 +1691,10 @@
/* process secondary hints to `selected' points */
if ( num_masks > 1 && glyph->num_points > 0 )
{
first = mask->end_point;
/* the `endchar' op can reduce the number of points */
first = mask->end_point > glyph->num_points
? glyph->num_points
: mask->end_point;
mask++;
for ( ; num_masks > 1; num_masks--, mask++ )
{
@ -1698,7 +1702,9 @@
FT_Int count;
next = mask->end_point;
next = mask->end_point > glyph->num_points
? glyph->num_points
: mask->end_point;
count = next - first;
if ( count > 0 )
{
@ -1856,12 +1862,10 @@
point->cur_u = hint->cur_pos + hint->cur_len +
FT_MulFix( delta - hint->org_len, scale );
else if ( hint->org_len > 0 )
else /* hint->org_len > 0 */
point->cur_u = hint->cur_pos +
FT_MulDiv( delta, hint->cur_len,
hint->org_len );
else
point->cur_u = hint->cur_pos;
}
psh_point_set_fitted( point );
}

View file

@ -5,7 +5,7 @@
/* PostScript hinter global hinting management (body). */
/* Inspired by the new auto-hinter module. */
/* */
/* Copyright 2001, 2002, 2003, 2004, 2006 by */
/* Copyright 2001, 2002, 2003, 2004, 2006, 2010 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used */
@ -624,7 +624,7 @@
T1_Private* priv,
PSH_Globals *aglobals )
{
PSH_Globals globals;
PSH_Globals globals = NULL;
FT_Error error;

View file

@ -4,7 +4,7 @@
/* */
/* The FreeType position independent code services for pshinter module. */
/* */
/* Copyright 2009 by */
/* Copyright 2009, 2010 by */
/* Oran Agra and Mickey Gabel. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@ -38,18 +38,20 @@
}
}
FT_Error
pshinter_module_class_pic_init( FT_Library library )
pshinter_module_class_pic_init( FT_Library library )
{
FT_PIC_Container* pic_container = &library->pic_container;
FT_Error error = FT_Err_Ok;
PSHinterPIC* container;
FT_Memory memory = library->memory;
FT_PIC_Container* pic_container = &library->pic_container;
FT_Error error = PSH_Err_Ok;
PSHinterPIC* container;
FT_Memory memory = library->memory;
/* allocate pointer, clear and set global container pointer */
if ( FT_ALLOC ( container, sizeof ( *container ) ) )
return error;
FT_MEM_SET( container, 0, sizeof(*container) );
FT_MEM_SET( container, 0, sizeof ( *container ) );
pic_container->pshinter = container;
/* add call to initialization function when you add new scripts */

View file

@ -366,11 +366,13 @@
if ( count == 0 )
{
/* No unicode chars here! */
FT_FREE( table->maps );
if ( !error )
error = PSnames_Err_Invalid_Argument; /* No unicode chars here! */
error = PSnames_Err_No_Unicode_Glyph_Name;
}
else {
else
{
/* Reallocate if the number of used entries is much smaller. */
if ( count < num_glyphs / 2 )
{
@ -561,8 +563,7 @@
psnames_get_service( FT_Module module,
const char* service_id )
{
FT_Library library = module->library;
FT_UNUSED(library);
FT_UNUSED( module );
return ft_service_list_lookup( FT_PSCMAPS_SERVICES_GET, service_id );
}

View file

@ -4,7 +4,7 @@
/* */
/* The FreeType position independent code services for psnames module. */
/* */
/* Copyright 2009 by */
/* Copyright 2009, 2010 by */
/* Oran Agra and Mickey Gabel. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@ -44,13 +44,15 @@
}
}
FT_Error
psnames_module_class_pic_init( FT_Library library )
psnames_module_class_pic_init( FT_Library library )
{
FT_PIC_Container* pic_container = &library->pic_container;
FT_Error error = FT_Err_Ok;
PSModulePIC* container;
FT_Memory memory = library->memory;
FT_PIC_Container* pic_container = &library->pic_container;
FT_Error error = PSnames_Err_Ok;
PSModulePIC* container;
FT_Memory memory = library->memory;
/* allocate pointer, clear and set global container pointer */
if ( FT_ALLOC ( container, sizeof ( *container ) ) )

View file

@ -5,7 +5,7 @@
/* Miscellaneous macros for stand-alone rasterizer (specification */
/* only). */
/* */
/* Copyright 2005, 2009 by */
/* Copyright 2005, 2009, 2010 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used */
@ -27,6 +27,7 @@
#ifndef __FTMISC_H__
#define __FTMISC_H__
/* memset */
#include FT_CONFIG_STANDARD_LIBRARY_H
@ -35,6 +36,7 @@
#define FT_LOCAL_DEF( x ) static x
/* from include/freetype2/fttypes.h */
typedef unsigned char FT_Byte;
@ -77,12 +79,22 @@
} FT_MemoryRec;
/* from src/ftcalc.c */
#include <inttypes.h>
#if ( defined _WIN32 || defined _WIN64 )
typedef __int64 FT_Int64;
#else
#include "inttypes.h"
typedef int64_t FT_Int64;
#endif
static FT_Long
FT_MulDiv( FT_Long a,
FT_Long b,

View file

@ -4,7 +4,7 @@
/* */
/* The FreeType glyph rasterizer (body). */
/* */
/* Copyright 1996-2001, 2002, 2003, 2005, 2007, 2008, 2009 by */
/* Copyright 1996-2001, 2002, 2003, 2005, 2007, 2008, 2009, 2010 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@ -302,7 +302,6 @@
typedef short Short;
typedef unsigned short UShort, *PUShort;
typedef long Long, *PLong;
typedef unsigned long ULong;
typedef unsigned char Byte, *PByte;
typedef char Bool;
@ -448,7 +447,6 @@
Int precision_bits; /* precision related variables */
Int precision;
Int precision_half;
Long precision_mask;
Int precision_shift;
Int precision_step;
Int precision_jitter;
@ -671,7 +669,6 @@
ras.precision = 1 << ras.precision_bits;
ras.precision_half = ras.precision / 2;
ras.precision_shift = ras.precision_bits - Pixel_Bits;
ras.precision_mask = -ras.precision;
}
@ -725,13 +722,13 @@
if ( overshoot )
ras.cProfile->flags |= Overshoot_Bottom;
FT_TRACE6(( "New ascending profile = %lx\n", (long)ras.cProfile ));
FT_TRACE6(( "New ascending profile = %p\n", ras.cProfile ));
break;
case Descending_State:
if ( overshoot )
ras.cProfile->flags |= Overshoot_Top;
FT_TRACE6(( "New descending profile = %lx\n", (long)ras.cProfile ));
FT_TRACE6(( "New descending profile = %p\n", ras.cProfile ));
break;
default:
@ -784,8 +781,8 @@
if ( h > 0 )
{
FT_TRACE6(( "Ending profile %lx, start = %ld, height = %ld\n",
(long)ras.cProfile, ras.cProfile->start, h ));
FT_TRACE6(( "Ending profile %p, start = %ld, height = %ld\n",
ras.cProfile, ras.cProfile->start, h ));
ras.cProfile->height = h;
if ( overshoot )
@ -1094,7 +1091,7 @@
return SUCCESS;
else
{
x1 += FMulDiv( Dx, ras.precision - f1, Dy );
x1 += SMulDiv( Dx, ras.precision - f1, Dy );
e1 += 1;
}
}
@ -1122,13 +1119,13 @@
if ( Dx > 0 )
{
Ix = ( ras.precision * Dx ) / Dy;
Ix = SMulDiv( ras.precision, Dx, Dy);
Rx = ( ras.precision * Dx ) % Dy;
Dx = 1;
}
else
{
Ix = -( ( ras.precision * -Dx ) / Dy );
Ix = SMulDiv( ras.precision, -Dx, Dy) * -1;
Rx = ( ras.precision * -Dx ) % Dy;
Dx = -1;
}
@ -1931,18 +1928,21 @@
y1 = SCALED( point[-2].y );
x2 = SCALED( point[-1].x );
y2 = SCALED( point[-1].y );
x3 = SCALED( point[ 0].x );
y3 = SCALED( point[ 0].y );
if ( flipped )
{
SWAP_( x1, y1 );
SWAP_( x2, y2 );
SWAP_( x3, y3 );
}
if ( point <= limit )
{
x3 = SCALED( point[0].x );
y3 = SCALED( point[0].y );
if ( flipped )
SWAP_( x3, y3 );
if ( Cubic_To( RAS_VARS x1, y1, x2, y2, x3, y3 ) )
goto Fail;
continue;
@ -2495,7 +2495,7 @@
PByte p;
p = bits - e1*ras.target.pitch;
p = bits - e1 * ras.target.pitch;
if ( ras.target.pitch > 0 )
p += ( ras.target.rows - 1 ) * ras.target.pitch;
@ -3382,6 +3382,7 @@
FT_Raster *araster )
{
static TRaster the_raster;
FT_UNUSED( memory );
*araster = (FT_Raster)&the_raster;
@ -3400,7 +3401,7 @@
}
#else /* _STANDALONE_ */
#else /* !_STANDALONE_ */
static int
@ -3408,7 +3409,7 @@
PRaster *araster )
{
FT_Error error;
PRaster raster;
PRaster raster = NULL;
*araster = 0;
@ -3432,7 +3433,7 @@
}
#endif /* _STANDALONE_ */
#endif /* !_STANDALONE_ */
static void
@ -3447,9 +3448,8 @@
PWorker worker = (PWorker)pool_base;
raster->buffer = pool_base + ( (sizeof ( *worker ) + 7 ) & ~7 );
raster->buffer_size = ( ( pool_base + pool_size ) -
(char*)raster->buffer ) / sizeof ( Long );
raster->buffer = pool_base + ( ( sizeof ( *worker ) + 7 ) & ~7 );
raster->buffer_size = pool_base + pool_size - (char*)raster->buffer;
raster->worker = worker;
}
else

View file

@ -4,7 +4,7 @@
/* */
/* The FreeType position independent code services for raster module. */
/* */
/* Copyright 2009 by */
/* Copyright 2009, 2010 by */
/* Oran Agra and Mickey Gabel. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@ -43,16 +43,17 @@
FT_Error
ft_raster1_renderer_class_pic_init( FT_Library library )
ft_raster1_renderer_class_pic_init( FT_Library library )
{
FT_PIC_Container* pic_container = &library->pic_container;
FT_Error error = FT_Err_Ok;
RasterPIC* container;
FT_Memory memory = library->memory;
FT_Error error = Raster_Err_Ok;
RasterPIC* container;
FT_Memory memory = library->memory;
/* since this function also serve raster5 renderer,
it implements reference counting */
if(pic_container->raster)
if ( pic_container->raster )
{
((RasterPIC*)pic_container->raster)->ref_count++;
return error;

View file

@ -4,7 +4,7 @@
/* */
/* High-level SFNT driver interface (body). */
/* */
/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006, 2007, 2009 by */
/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006, 2007, 2009, 2010 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@ -362,7 +362,7 @@
*acharset_registry = registry.u.atom;
}
else
error = FT_Err_Invalid_Argument;
error = SFNT_Err_Invalid_Argument;
}
}
@ -436,7 +436,7 @@
FT_UNUSED( face_index );
FT_UNUSED( header );
return FT_Err_Unimplemented_Feature;
return SFNT_Err_Unimplemented_Feature;
}
@ -449,7 +449,7 @@
FT_UNUSED( stream );
FT_UNUSED( header );
return FT_Err_Unimplemented_Feature;
return SFNT_Err_Unimplemented_Feature;
}
@ -460,7 +460,7 @@
FT_UNUSED( face );
FT_UNUSED( stream );
return FT_Err_Unimplemented_Feature;
return SFNT_Err_Unimplemented_Feature;
}
@ -513,7 +513,7 @@
* is only there for some rogue clients which would want to call it
* directly (which doesn't make much sense).
*/
return FT_Err_Unimplemented_Feature;
return SFNT_Err_Unimplemented_Feature;
}
@ -534,7 +534,7 @@
FT_UNUSED( cmap );
FT_UNUSED( input );
return FT_Err_Unimplemented_Feature;
return SFNT_Err_Unimplemented_Feature;
}
@ -545,7 +545,7 @@
FT_UNUSED( face );
FT_UNUSED( cmap );
return 0;
return SFNT_Err_Ok;
}
#endif /* FT_CONFIG_OPTION_OLD_INTERNALS */

View file

@ -4,7 +4,7 @@
/* */
/* The FreeType position independent code services for sfnt module. */
/* */
/* Copyright 2009 by */
/* Copyright 2009, 2010 by */
/* Oran Agra and Mickey Gabel. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@ -60,15 +60,16 @@
FT_Error
sfnt_module_class_pic_init( FT_Library library )
{
FT_PIC_Container* pic_container = &library->pic_container;
FT_Error error = FT_Err_Ok;
sfntModulePIC* container;
FT_Memory memory = library->memory;
FT_PIC_Container* pic_container = &library->pic_container;
FT_Error error = SFNT_Err_Ok;
sfntModulePIC* container;
FT_Memory memory = library->memory;
/* allocate pointer, clear and set global container pointer */
if ( FT_ALLOC ( container, sizeof ( *container ) ) )
return error;
FT_MEM_SET( container, 0, sizeof(*container) );
FT_MEM_SET( container, 0, sizeof ( *container ) );
pic_container->sfnt = container;
/* initialize pointer table - this is how the module usually expects this data */

View file

@ -4,7 +4,7 @@
/* */
/* SFNT object management (base). */
/* */
/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 by */
/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2010 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@ -50,9 +50,9 @@
tt_name_entry_ascii_from_utf16( TT_NameEntry entry,
FT_Memory memory )
{
FT_String* string;
FT_String* string = NULL;
FT_UInt len, code, n;
FT_Byte* read = (FT_Byte*)entry->string;
FT_Byte* read = (FT_Byte*)entry->string;
FT_Error error;
@ -81,9 +81,9 @@
tt_name_entry_ascii_from_other( TT_NameEntry entry,
FT_Memory memory )
{
FT_String* string;
FT_String* string = NULL;
FT_UInt len, code, n;
FT_Byte* read = (FT_Byte*)entry->string;
FT_Byte* read = (FT_Byte*)entry->string;
FT_Error error;
@ -160,7 +160,7 @@
/* According to the OpenType 1.3 specification, only Microsoft or */
/* Apple platform IDs might be used in the `name' table. The */
/* `Unicode' platform is reserved for the `cmap' table, and the */
/* `Iso' one is deprecated. */
/* `ISO' one is deprecated. */
/* */
/* However, the Apple TrueType specification doesn't say the same */
/* thing and goes to suggest that all Unicode `name' table entries */
@ -691,9 +691,7 @@
LOAD_( os2 );
if ( error )
{
if ( error != SFNT_Err_Table_Missing )
goto Exit;
/* we treat the table as missing if there are any errors */
face->os2.version = 0xFFFFU;
}
}

View file

@ -4,7 +4,7 @@
/* */
/* TrueType and OpenType embedded BDF properties (body). */
/* */
/* Copyright 2005, 2006 by */
/* Copyright 2005, 2006, 2010 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@ -74,7 +74,7 @@
length < 8 ||
FT_FRAME_EXTRACT( length, bdf->table ) )
{
error = FT_Err_Invalid_Table;
error = SFNT_Err_Invalid_Table;
goto Exit;
}
@ -131,7 +131,7 @@
BadTable:
FT_FRAME_RELEASE( bdf->table );
FT_ZERO( bdf );
error = FT_Err_Invalid_Table;
error = SFNT_Err_Invalid_Table;
goto Exit;
}
@ -143,7 +143,7 @@
{
TT_BDF bdf = &face->bdf;
FT_Size size = FT_FACE(face)->size;
FT_Error error = 0;
FT_Error error = SFNT_Err_Ok;
FT_Byte* p;
FT_UInt count;
FT_Byte* strike;
@ -163,7 +163,7 @@
p = bdf->table + 8;
strike = p + 4 * count;
error = FT_Err_Invalid_Argument;
error = SFNT_Err_Invalid_Argument;
if ( size == NULL || property_name == NULL )
goto Exit;
@ -215,7 +215,7 @@
{
aprop->type = BDF_PROPERTY_TYPE_ATOM;
aprop->u.atom = (const char*)bdf->strings + value;
error = 0;
error = SFNT_Err_Ok;
goto Exit;
}
break;
@ -223,13 +223,13 @@
case 0x02:
aprop->type = BDF_PROPERTY_TYPE_INTEGER;
aprop->u.integer = (FT_Int32)value;
error = 0;
error = SFNT_Err_Ok;
goto Exit;
case 0x03:
aprop->type = BDF_PROPERTY_TYPE_CARDINAL;
aprop->u.cardinal = value;
error = 0;
error = SFNT_Err_Ok;
goto Exit;
default:

View file

@ -4,7 +4,7 @@
/* */
/* TrueType character mapping table (cmap) support (body). */
/* */
/* Copyright 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 by */
/* Copyright 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@ -2689,7 +2689,7 @@
FT_Memory memory )
{
FT_UInt32 old_max = cmap->max_results;
FT_Error error = 0;
FT_Error error = SFNT_Err_Ok;
if ( num_results > cmap->max_results )
@ -2787,7 +2787,8 @@
}
/* and the non-default table (these glyphs are specified here) */
if ( nondefOff != 0 ) {
if ( nondefOff != 0 )
{
FT_Byte* ndp = table + nondefOff;
FT_ULong numMappings = TT_NEXT_ULONG( ndp );
FT_ULong i, lastUni = 0;
@ -3375,7 +3376,7 @@
clazz[i] = NULL;
*output_class = clazz;
return FT_Err_Ok;
return SFNT_Err_Ok;
}
#endif /*FT_CONFIG_OPTION_PIC*/
@ -3391,11 +3392,12 @@
FT_Byte* limit = table + face->cmap_size;
FT_UInt volatile num_cmaps;
FT_Byte* volatile p = table;
FT_Library library = FT_FACE_LIBRARY(face);
FT_UNUSED(library);
FT_Library library = FT_FACE_LIBRARY( face );
FT_UNUSED( library );
if ( p + 4 > limit )
if ( !p || p + 4 > limit )
return SFNT_Err_Invalid_Table;
/* only recognize format 0 */
@ -3409,6 +3411,12 @@
}
num_cmaps = TT_NEXT_USHORT( p );
#ifdef FT_MAX_CHARMAP_CACHEABLE
if ( num_cmaps > FT_MAX_CHARMAP_CACHEABLE )
FT_ERROR(( "tt_face_build_cmaps: too many cmap subtables(%d) "
"subtable#%d and later are loaded but cannot be searched\n",
num_cmaps, FT_MAX_CHARMAP_CACHEABLE + 1 ));
#endif
for ( ; num_cmaps > 0 && p + 8 <= limit; num_cmaps-- )
{

View file

@ -5,7 +5,7 @@
/* Load the basic TrueType kerning table. This doesn't handle */
/* kerning data within the GPOS table at the moment. */
/* */
/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006, 2007, 2009 by */
/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006, 2007, 2009, 2010 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@ -115,7 +115,7 @@
num_pairs = FT_NEXT_USHORT( p );
p += 6;
if ( ( p_next - p ) / 6 < (int)num_pairs ) /* handle broken count */
if ( ( p_next - p ) < 6 * (int)num_pairs ) /* handle broken count */
num_pairs = (FT_UInt)( ( p_next - p ) / 6 );
avail |= mask;
@ -220,7 +220,7 @@
num_pairs = FT_NEXT_USHORT( p );
p += 6;
if ( ( next - p ) / 6 < (int)num_pairs ) /* handle broken count */
if ( ( next - p ) < 6 * (int)num_pairs ) /* handle broken count */
num_pairs = (FT_UInt)( ( next - p ) / 6 );
switch ( coverage >> 8 )

View file

@ -5,7 +5,8 @@
/* Load the basic TrueType tables, i.e., tables that can be either in */
/* TTF or OTF fonts (body). */
/* */
/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 by */
/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, */
/* 2010 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@ -77,7 +78,8 @@
{
/* For compatibility with Windows, we consider */
/* zero-length tables the same as missing tables. */
if ( entry->Tag == tag ) {
if ( entry->Tag == tag )
{
if ( entry->Length != 0 )
{
FT_TRACE4(( "found table.\n" ));
@ -382,6 +384,10 @@
entry = face->dir_tables;
FT_TRACE2(( "\n"
" tag offset length checksum\n"
" ----------------------------------\n" ));
for ( nn = 0; nn < sfnt.num_tables; nn++ )
{
entry->Tag = FT_GET_TAG4();
@ -394,13 +400,14 @@
continue;
else
{
FT_TRACE2(( " %c%c%c%c - %08lx - %08lx\n",
FT_TRACE2(( " %c%c%c%c %08lx %08lx %08lx\n",
(FT_Char)( entry->Tag >> 24 ),
(FT_Char)( entry->Tag >> 16 ),
(FT_Char)( entry->Tag >> 8 ),
(FT_Char)( entry->Tag ),
entry->Offset,
entry->Length ));
entry->Length,
entry->CheckSum ));
entry++;
}
}
@ -678,9 +685,9 @@
/* broken fonts like `Keystrokes MT' :-( */
/* */
/* We allocate 64 function entries by default when */
/* the maxFunctionDefs field is null. */
/* the maxFunctionDefs value is smaller. */
if ( maxProfile->maxFunctionDefs == 0 )
if ( maxProfile->maxFunctionDefs < 64 )
maxProfile->maxFunctionDefs = 64;
/* we add 4 phantom points later */
@ -693,6 +700,15 @@
maxProfile->maxTwilightPoints = 0xFFFFU - 4;
}
/* we arbitrarily limit recursion to avoid stack exhaustion */
if ( maxProfile->maxComponentDepth > 100 )
{
FT_TRACE0(( "tt_face_load_maxp:"
" abnormally large component depth (%d) set to 100\n",
maxProfile->maxComponentDepth ));
maxProfile->maxComponentDepth = 100;
}
}
FT_TRACE3(( "numGlyphs: %u\n", maxProfile->numGlyphs ));

Some files were not shown because too many files have changed in this diff Show more