updated freetype to 2.3.4

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20817 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Jérôme Duval 2007-04-25 17:18:01 +00:00
parent 7f1085115e
commit c36e4d4c9f
68 changed files with 1009 additions and 750 deletions

View File

@ -4,7 +4,7 @@
/* */
/* ANSI-specific configuration file (specification only). */
/* */
/* Copyright 1996-2001, 2002, 2003, 2004, 2006 by */
/* Copyright 1996-2001, 2002, 2003, 2004, 2006, 2007 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@ -126,7 +126,14 @@ FT_BEGIN_HEADER
/* */
#if ( defined( __APPLE__ ) && !defined( DARWIN_NO_CARBON ) ) || \
( defined( __MWERKS__ ) && defined( macintosh ) )
/* no Carbon frameworks for 64bit 10.4.x */
#include "AvailabilityMacros.h"
#if defined( __LP64__ ) && \
( MAC_OS_X_VERSION_MIN_REQUIRED <= MAC_OS_X_VERSION_10_4 )
#define DARWIN_NO_CARBON 1
#else
#define FT_MACINTOSH 1
#endif
#endif

View File

@ -5,7 +5,7 @@
/* ANSI-specific library and header configuration file (specification */
/* only). */
/* */
/* Copyright 2002, 2003, 2004, 2005, 2006 by */
/* Copyright 2002, 2003, 2004, 2005, 2006, 2007 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@ -101,6 +101,7 @@
#define ft_strncmp strncmp
#define ft_strncpy strncpy
#define ft_strrchr strrchr
#define ft_strstr strstr
/**********************************************************************/

View File

@ -637,7 +637,7 @@ FT_BEGIN_HEADER
/* http://www.unicode.org/Public/MAPPINGS/VENDORS/APPLE/README.TXT */
/* */
/* to get an idea how to do that. Basically, if the language ID is 0, */
/* dont use it, otherwise subtract 1 from the language ID. Then */
/* don't use it, otherwise subtract 1 from the language ID. Then */
/* examine `encoding_id'. If, for example, `encoding_id' is */
/* @TT_MAC_ID_ROMAN and the language ID (minus 1) is */
/* `TT_MAC_LANGID_GREEK', it is the Greek encoding, not Roman. */
@ -1585,7 +1585,7 @@ FT_BEGIN_HEADER
/* FT_Done_FreeType */
/* */
/* <Description> */
/* Destroy a given FreeType library object and all of its childs, */
/* Destroy a given FreeType library object and all of its children, */
/* including resources, drivers, faces, sizes, etc. */
/* */
/* <Input> */
@ -1725,6 +1725,10 @@ FT_BEGIN_HEADER
/* If the `FT_OPEN_PARAMS' bit is set, the parameters given by */
/* `num_params' and `params' is used. They are ignored otherwise. */
/* */
/* Ideally, both the `pathname' and `params' fields should be tagged */
/* as `const'; this is missing for API backwards compatibility. With */
/* other words, applications should treat them as read-only. */
/* */
typedef struct FT_Open_Args_
{
FT_UInt flags;
@ -2311,7 +2315,7 @@ FT_BEGIN_HEADER
* This flag implies @FT_LOAD_NO_SCALE and @FT_LOAD_IGNORE_TRANSFORM.
*
* FT_LOAD_IGNORE_TRANSFORM ::
* Indicates that the tranform matrix set by @FT_Set_Transform should
* Indicates that the transform matrix set by @FT_Set_Transform should
* be ignored.
*
* FT_LOAD_MONOCHROME ::
@ -2809,6 +2813,11 @@ FT_BEGIN_HEADER
/* This function returns an error if no charmap in the face */
/* corresponds to the encoding queried here. */
/* */
/* Because many fonts contain more than a single cmap for Unicode */
/* encoding, this function has some special code to select the one */
/* which covers Unicode best. It is thus preferable to */
/* @FT_Set_Charmap in this case. */
/* */
FT_EXPORT( FT_Error )
FT_Select_Charmap( FT_Face face,
FT_Encoding encoding );
@ -3314,7 +3323,7 @@ FT_BEGIN_HEADER
*/
#define FREETYPE_MAJOR 2
#define FREETYPE_MINOR 3
#define FREETYPE_PATCH 0
#define FREETYPE_PATCH 4
/*************************************************************************/

View File

@ -4,7 +4,7 @@
/* */
/* FreeType error code handling (specification). */
/* */
/* Copyright 1996-2001, 2002, 2004 by */
/* Copyright 1996-2001, 2002, 2004, 2007 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@ -73,7 +73,7 @@
/* const struct */
/* { */
/* int err_code; */
/* const char* err_msg */
/* const char* err_msg; */
/* } ft_errors[] = */
/* */
/* #include FT_ERRORS_H */

View File

@ -5,7 +5,7 @@
/* FreeType glyph image formats and default raster interface */
/* (specification). */
/* */
/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006 by */
/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006, 2007 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@ -381,8 +381,7 @@ FT_BEGIN_HEADER
/* the outline uses the opposite */
/* direction (typically for Type 1 */
/* fonts). This flag is ignored by the */
/* scan-converter. However, it is very */
/* important for the auto-hinter. */
/* scan-converter. */
/* */
/* FT_OUTLINE_IGNORE_DROPOUTS :: By default, the scan converter will */
/* try to detect drop-outs in an outline */
@ -724,7 +723,7 @@ FT_BEGIN_HEADER
/* ft_glyph_format_xxx */
/* */
/* <Description> */
/* A list of decprecated constants. Use the corresponding */
/* A list of deprecated constants. Use the corresponding */
/* @FT_Glyph_Format values instead. */
/* */
/* <Values> */

View File

@ -4,7 +4,7 @@
/* */
/* FreeType incremental loading (specification). */
/* */
/* Copyright 2002, 2003, 2006 by */
/* Copyright 2002, 2003, 2006, 2007 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@ -149,7 +149,7 @@ FT_BEGIN_HEADER
* FreeType error code. 0 means success.
*
* @note:
* If this function returns succesfully the method
* If this function returns successfully the method
* @FT_Incremental_FreeGlyphDataFunc will be called later to release
* the data bytes.
*

View File

@ -4,7 +4,7 @@
/* */
/* Generic list support for FreeType (specification). */
/* */
/* Copyright 1996-2001, 2003 by */
/* Copyright 1996-2001, 2003, 2007 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@ -199,8 +199,7 @@ FT_BEGIN_HEADER
/* */
/* <Input> */
/* list :: A handle to the list. */
/* iterator :: An interator function, called on each node of the */
/* list. */
/* iterator :: An iterator function, called on each node of the list. */
/* user :: A user-supplied field which is passed as the second */
/* argument to the iterator. */
/* */

View File

@ -4,7 +4,7 @@
/* */
/* Additional Mac-specific API. */
/* */
/* Copyright 1996-2001, 2004, 2006 by */
/* Copyright 1996-2001, 2004, 2006, 2007 by */
/* Just van Rossum, David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@ -35,6 +35,17 @@
FT_BEGIN_HEADER
/* gcc-3.4.1 and later can warn about functions tagged as deprecated */
#ifndef FT_DEPRECATED_ATTRIBUTE
#if defined(__GNUC__) && \
((__GNUC__ >= 4) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 1)))
#define FT_DEPRECATED_ATTRIBUTE __attribute__((deprecated))
#else
#define FT_DEPRECATED_ATTRIBUTE
#endif
#endif
/*************************************************************************/
/* */
/* <Section> */
@ -105,9 +116,11 @@ FT_BEGIN_HEADER
/* Bold). */
/* */
/* <Output> */
/* pathSpec :: FSSpec to the file. For passing to @FT_New_Face. */
/* pathSpec :: FSSpec to the file. For passing to */
/* @FT_New_Face_From_FSSpec. */
/* */
/* face_index :: Index of the face. For passing to @FT_New_Face. */
/* face_index :: Index of the face. For passing to */
/* @FT_New_Face_From_FSSpec. */
/* */
/* <Return> */
/* FreeType error code. 0 means success. */
@ -115,7 +128,8 @@ FT_BEGIN_HEADER
FT_EXPORT( FT_Error )
FT_GetFile_From_Mac_Name( const char* fontName,
FSSpec* pathSpec,
FT_Long* face_index );
FT_Long* face_index )
FT_DEPRECATED_ATTRIBUTE;
/*************************************************************************/
@ -130,9 +144,11 @@ FT_BEGIN_HEADER
/* fontName :: Mac OS name of the font in ATS framework. */
/* */
/* <Output> */
/* pathSpec :: FSSpec to the file. For passing to @FT_New_Face. */
/* pathSpec :: FSSpec to the file. For passing to */
/* @FT_New_Face_From_FSSpec. */
/* */
/* face_index :: Index of the face. For passing to @FT_New_Face. */
/* face_index :: Index of the face. For passing to */
/* @FT_New_Face_From_FSSpec. */
/* */
/* <Return> */
/* FreeType error code. 0 means success. */
@ -140,7 +156,39 @@ FT_BEGIN_HEADER
FT_EXPORT( FT_Error )
FT_GetFile_From_Mac_ATS_Name( const char* fontName,
FSSpec* pathSpec,
FT_Long* face_index );
FT_Long* face_index )
FT_DEPRECATED_ATTRIBUTE;
/*************************************************************************/
/* */
/* <Function> */
/* FT_GetFilePath_From_Mac_ATS_Name */
/* */
/* <Description> */
/* Return a pathname of the disk file and face index for given font */
/* name which is handled by ATS framework. */
/* */
/* <Input> */
/* fontName :: Mac OS name of the font in ATS framework. */
/* */
/* <Output> */
/* path :: Buffer to store pathname of the file. For passing */
/* to @FT_New_Face. The client must allocate this */
/* buffer before calling this function. */
/* */
/* maxPathSize :: Lengths of the buffer `path' that client allocated. */
/* */
/* face_index :: Index of the face. For passing to @FT_New_Face. */
/* */
/* <Return> */
/* FreeType error code. 0 means success. */
/* */
FT_EXPORT( FT_Error )
FT_GetFilePath_From_Mac_ATS_Name( const char* fontName,
UInt8* path,
UInt32 maxPathSize,
FT_Long* face_index );
/*************************************************************************/
@ -174,7 +222,8 @@ FT_BEGIN_HEADER
FT_New_Face_From_FSSpec( FT_Library library,
const FSSpec *spec,
FT_Long face_index,
FT_Face *aface );
FT_Face *aface )
FT_DEPRECATED_ATTRIBUTE;
/*************************************************************************/
@ -208,7 +257,8 @@ FT_BEGIN_HEADER
FT_New_Face_From_FSRef( FT_Library library,
const FSRef *ref,
FT_Long face_index,
FT_Face *aface );
FT_Face *aface )
FT_DEPRECATED_ATTRIBUTE;
/* */

View File

@ -5,7 +5,7 @@
/* Support for the FT_Outline type used to store glyph shapes of */
/* most scalable font formats (specification). */
/* */
/* Copyright 1996-2001, 2002, 2003, 2005, 2006 by */
/* Copyright 1996-2001, 2002, 2003, 2005, 2006, 2007 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@ -103,7 +103,7 @@ FT_BEGIN_HEADER
/* decomposition. */
/* */
/* <Return> */
/* FreeType error code. 0 means sucess. */
/* FreeType error code. 0 means success. */
/* */
FT_EXPORT( FT_Error )
FT_Outline_Decompose( FT_Outline* outline,
@ -393,7 +393,7 @@ FT_BEGIN_HEADER
/* This function does NOT CREATE the bitmap, it only renders an */
/* outline image within the one you pass to it! */
/* */
/* It will use the raster correponding to the default glyph format. */
/* It will use the raster corresponding to the default glyph format. */
/* */
FT_EXPORT( FT_Error )
FT_Outline_Get_Bitmap( FT_Library library,

View File

@ -4,7 +4,7 @@
/* */
/* FreeType trigonometric functions (specification). */
/* */
/* Copyright 2001, 2003, 2005 by */
/* Copyright 2001, 2003, 2005, 2007 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@ -210,7 +210,7 @@ FT_BEGIN_HEADER
* Second angle.
*
* @return:
* Contrainted value of `value2-value1'.
* Constrained value of `value2-value1'.
*
*/
FT_EXPORT( FT_Angle )

View File

@ -4,7 +4,7 @@
/* */
/* Support functions for X11. */
/* */
/* Copyright 2002, 2003, 2004, 2006 by */
/* Copyright 2002, 2003, 2004, 2006, 2007 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@ -47,7 +47,7 @@ FT_BEGIN_HEADER
/* The single function in this section can be used to get the font */
/* format. Note that this information is not needed normally; */
/* however, there are special cases (like in PDF devices) where it is */
/* important to differentiate, inspite of FreeType's uniform API. */
/* important to differentiate, in spite of FreeType's uniform API. */
/* */
/*************************************************************************/

View File

@ -4,7 +4,7 @@
/* */
/* High-level `autohint' module-specific interface (specification). */
/* */
/* Copyright 1996-2001, 2002 by */
/* Copyright 1996-2001, 2002, 2007 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@ -37,7 +37,7 @@
/* */
/* - global hints: Usually some metrics that describe global properties */
/* of the face. It is computed by scanning more or less */
/* agressively the glyphs in the face, and thus can be */
/* aggressively the glyphs in the face, and thus can be */
/* very slow to compute (even if the size of global */
/* hints is really small). */
/* */

View File

@ -4,7 +4,7 @@
/* */
/* Debugging and logging component (specification). */
/* */
/* Copyright 1996-2001, 2002, 2004, 2006 by */
/* Copyright 1996-2001, 2002, 2004, 2006, 2007 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@ -138,7 +138,7 @@ FT_BEGIN_HEADER
/* components. */
/* */
/* This function may be useful if you want to control FreeType 2's */
/* debug level in your appliaciton. */
/* debug level in your application. */
/* */
FT_BASE( const char * )
FT_Trace_Get_Name( FT_Int idx );

View File

@ -4,7 +4,7 @@
/* */
/* The FreeType memory management macros (specification). */
/* */
/* Copyright 1996-2001, 2002, 2004, 2005, 2006 by */
/* Copyright 1996-2001, 2002, 2004, 2005, 2006, 2007 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg */
/* */
/* This file is part of the FreeType project, and may only be used, */
@ -209,7 +209,7 @@ FT_BEGIN_HEADER
/*
* Return the maximum number of adressable elements in an array.
* Return the maximum number of addressable elements in an array.
* We limit ourselves to INT_MAX, rather than UINT_MAX, to avoid
* any problems.
*/
@ -322,6 +322,41 @@ FT_BEGIN_HEADER
#endif /* FT_CONFIG_OPTION_OLD_INTERNALS */
FT_BASE( FT_Pointer )
ft_mem_strdup( FT_Memory memory,
const char* str,
FT_Error *p_error );
FT_BASE( FT_Pointer )
ft_mem_dup( FT_Memory memory,
const void* address,
FT_ULong size,
FT_Error *p_error );
#define FT_MEM_STRDUP( dst, str ) \
(dst) = ft_mem_strdup( memory, (const char*)(str), &error )
#define FT_STRDUP( dst, str ) \
FT_MEM_SET_ERROR( FT_MEM_STRDUP( dst, str ) )
#define FT_MEM_DUP( dst, address, size ) \
(dst) = ft_mem_dup( memory, (address), (FT_ULong)(size), &error )
#define FT_DUP( dst, address, size ) \
FT_MEM_SET_ERROR( FT_MEM_DUP( dst, address, size ) )
/* Return >= 1 if a truncation occurs. */
/* Return 0 if the source string fits the buffer. */
/* This is *not* the same as strlcpy(). */
FT_BASE( FT_Int )
ft_mem_strcpyn( char* dst,
const char* src,
FT_ULong size );
#define FT_STRCPYN( dst, src, size ) \
ft_mem_strcpyn( (char*)dst, (const char*)(src), (FT_ULong)(size) )
/* */

View File

@ -6,7 +6,7 @@
/* recorders (specification only). These are used to support native */
/* T1/T2 hints in the `type1', `cid', and `cff' font drivers. */
/* */
/* Copyright 2001, 2002, 2003, 2005, 2006 by */
/* Copyright 2001, 2002, 2003, 2005, 2006, 2007 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@ -452,9 +452,9 @@ FT_BEGIN_HEADER
* Use vertical coordinates (y) for horizontal stems (dim=0). Use
* horizontal coordinates (x) for vertical stems (dim=1).
*
* There are `2*count' elements in the `coords' aray. Each even element
* is an absolute position in font units, each odd element is a length
* in font units.
* There are `2*count' elements in the `coords' array. Each even
* element is an absolute position in font units, each odd element is a
* length in font units.
*
* A length can be negative, in which case it must be either -20 or
* -21. It is interpreted as a `ghost' stem, according to the Type 1

View File

@ -4,7 +4,7 @@
/* */
/* The FreeType PostScript name services (specification). */
/* */
/* Copyright 2003 by */
/* Copyright 2003, 2007 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@ -28,7 +28,7 @@ FT_BEGIN_HEADER
* A trivial service used to retrieve the PostScript name of a given
* font when available. The `get_name' field should never be NULL.
*
* The correponding function can return NULL to indicate that the
* The corresponding function can return NULL to indicate that the
* PostScript name is not available.
*
* The name is owned by the face and will be destroyed with it.

View File

@ -864,7 +864,7 @@ FT_BEGIN_HEADER
*
* USHORT version `BDF ' table version number, should be 0x0001.
* USHORT strikeCount Number of strikes (bitmap sizes) in this table.
* ULONG stringTable Offset (froms start of BDF table) to string
* ULONG stringTable Offset (from start of BDF table) to string
* table.
*
* This is followed by an array of `strikeCount' descriptors, having the
@ -1445,7 +1445,7 @@ FT_BEGIN_HEADER
/* */
/* max_points :: The maximal size in points of the zone. */
/* */
/* max_contours :: Max size in links contours of thez one. */
/* max_contours :: Max size in links contours of the zone. */
/* */
/* n_points :: The current number of points in the zone. */
/* */

View File

@ -4,7 +4,7 @@
/* */
/* TrueType name ID definitions (specification only). */
/* */
/* Copyright 1996-2002, 2003, 2004, 2006 by */
/* Copyright 1996-2002, 2003, 2004, 2006, 2007 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@ -606,7 +606,7 @@ FT_BEGIN_HEADER
#define TT_MS_LANGID_CROATIAN_BOSNIA_HERZEGOVINA 0x101a
#define TT_MS_LANGID_BOSNIAN_BOSNIA_HERZEGOVINA 0x141a
/* and XPsp2 Platform SDK added (2004-07-26) */
/* Names are shortened to be signifiant within 40 chars. */
/* Names are shortened to be significant within 40 chars. */
#define TT_MS_LANGID_SERBIAN_BOSNIA_HERZ_LATIN 0x181a
#define TT_MS_LANGID_SERBIAN_BOSNIA_HERZ_CYRILLIC 0x181a
#endif
@ -660,7 +660,7 @@ FT_BEGIN_HEADER
/* ... and we also keep our old identifier... */
#define TT_MS_LANGID_SAAMI_LAPONIA 0x043b
#if 0 /* this seems to be a previous invertion */
#if 0 /* this seems to be a previous inversion */
#define TT_MS_LANGID_IRISH_GAELIC_IRELAND 0x043c
#define TT_MS_LANGID_SCOTTISH_GAELIC_UNITED_KINGDOM 0x083c
#else
@ -698,6 +698,15 @@ FT_BEGIN_HEADER
#define TT_MS_LANGID_MONGOLIAN_MONGOLIA /* Cyrillic */ 0x0450
#define TT_MS_LANGID_MONGOLIAN_MONGOLIA_MONGOLIAN 0x0850
#define TT_MS_LANGID_TIBETAN_CHINA 0x0451
/* Don't use the next constant! It has */
/* (1) the wrong spelling (Dzonghka) */
/* (2) Microsoft doesn't officially define it -- */
/* at least it is not in the List of Local */
/* ID Values. */
/* (3) Dzongkha is not the same language as */
/* Tibetan, so merging it is wrong anyway. */
/* */
/* TT_MS_LANGID_TIBETAN_BHUTAN is correct, BTW. */
#define TT_MS_LANGID_DZONGHKA_BHUTAN 0x0851
#if 0

View File

@ -4,7 +4,7 @@
/* */
/* Auto-fitter routines to compute global hinting values (body). */
/* */
/* Copyright 2003, 2004, 2005, 2006 by */
/* Copyright 2003, 2004, 2005, 2006, 2007 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 @@
Exit:
/*
* By default, all uncovered glyphs are set to the latin script.
* XXX: Shouldnt' we disable hinting or do something similar?
* XXX: Shouldn't we disable hinting or do something similar?
*/
{
FT_UInt nn;

View File

@ -727,6 +727,9 @@
hints->x_delta = x_delta;
hints->y_delta = y_delta;
hints->xmin_delta = 0;
hints->xmax_delta = 0;
points = hints->points;
if ( hints->num_points == 0 )
goto Exit;

View File

@ -4,7 +4,7 @@
/* */
/* Auto-fitter hinting routines (specification). */
/* */
/* Copyright 2003, 2004, 2005, 2006 by */
/* Copyright 2003, 2004, 2005, 2006, 2007 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@ -208,6 +208,9 @@ FT_BEGIN_HEADER
/* implementations */
AF_ScriptMetrics metrics;
FT_Pos xmin_delta; /* used for warping */
FT_Pos xmax_delta;
} AF_GlyphHintsRec;

View File

@ -133,6 +133,8 @@
/* let's try 20% of the smallest width */
axis->edge_distance_threshold = stdw / 5;
axis->standard_width = stdw;
axis->extra_light = 0;
}
}
@ -193,10 +195,8 @@
for ( ; p < limit && *p; p++ )
{
FT_UInt glyph_index;
FT_Vector* extremum;
FT_Int best_point, best_y, best_first, best_last;
FT_Vector* points;
FT_Vector* point_limit;
FT_Vector* point;
FT_Bool round;
@ -213,85 +213,97 @@
/* now compute min or max point indices and coordinates */
points = glyph->outline.points;
point_limit = points + glyph->outline.n_points;
point = points;
extremum = point;
point++;
best_point = -1;
best_y = 0; /* make compiler happy */
best_first = 0; /* ditto */
best_last = 0; /* ditto */
if ( AF_LATIN_IS_TOP_BLUE( bb ) )
{
for ( ; point < point_limit; point++ )
if ( point->y > extremum->y )
extremum = point;
}
else
{
for ( ; point < point_limit; point++ )
if ( point->y < extremum->y )
extremum = point;
FT_Int nn;
FT_Int first = 0;
FT_Int last = -1;
for ( nn = 0; nn < glyph->outline.n_contours; first = last+1, nn++ )
{
FT_Int old_best_point = best_point;
FT_Int pp;
last = glyph->outline.contours[nn];
/* Avoid single-point contours since they are never rasterized. */
/* In some fonts, they correspond to mark attachment points */
/* which are way outside of the glyph's real outline. */
if ( last <= first )
continue;
if ( AF_LATIN_IS_TOP_BLUE( bb ) )
{
for ( pp = first; pp <= last; pp++ )
if ( best_point < 0 || points[pp].y > best_y )
{
best_point = pp;
best_y = points[pp].y;
}
}
else
{
for ( pp = first; pp <= last; pp++ )
if ( best_point < 0 || points[pp].y < best_y )
{
best_point = pp;
best_y = points[pp].y;
}
}
if ( best_point != old_best_point )
{
best_first = first;
best_last = last;
}
}
AF_LOG(( "%5d", best_y ));
}
AF_LOG(( "%5d", (int)extremum->y ));
/* now, check whether the point belongs to a straight or round */
/* now check whether the point belongs to a straight or round */
/* segment; we first need to find in which contour the extremum */
/* lies, then see its previous and next points */
/* lies, then inspect its previous and next points */
{
FT_Int idx = (FT_Int)( extremum - points );
FT_Int n;
FT_Int first, last, prev, next, end;
FT_Int prev, next;
FT_Pos dist;
last = -1;
first = 0;
for ( n = 0; n < glyph->outline.n_contours; n++ )
{
end = glyph->outline.contours[n];
if ( end >= idx )
{
last = end;
break;
}
first = end + 1;
}
/* XXX: should never happen! */
if ( last < 0 )
continue;
/* now look for the previous and next points that are not on the */
/* same Y coordinate. Threshold the `closeness'... */
prev = idx;
prev = best_point;
next = prev;
do
{
if ( prev > first )
if ( prev > best_first )
prev--;
else
prev = last;
prev = best_last;
dist = points[prev].y - extremum->y;
dist = points[prev].y - best_y;
if ( dist < -5 || dist > 5 )
break;
} while ( prev != idx );
} while ( prev != best_point );
do
{
if ( next < last )
if ( next < best_last )
next++;
else
next = first;
next = best_first;
dist = points[next].y - extremum->y;
dist = points[next].y - best_y;
if ( dist < -5 || dist > 5 )
break;
} while ( next != idx );
} while ( next != best_point );
/* now, set the `round' flag depending on the segment's kind */
round = FT_BOOL(
@ -302,9 +314,9 @@
}
if ( round )
rounds[num_rounds++] = extremum->y;
rounds[num_rounds++] = best_y;
else
flats[num_flats++] = extremum->y;
flats[num_flats++] = best_y;
}
AF_LOG(( "\n" ));
@ -479,7 +491,7 @@
if ( dim == AF_DIMENSION_HORZ )
{
if ( fitted < scaled )
scale -= scale/50; /* x_scale = x_scale*0.98 */
scale -= scale / 50; /* scale *= 0.98 */
}
else
{
@ -513,6 +525,10 @@
width->fit = width->cur;
}
/* an extra-light axis corresponds to a standard width that is */
/* smaller than 0.75 pixels */
axis->extra_light = FT_MulFix( axis->standard_width, scale ) < 32 + 8;
if ( dim == AF_DIMENSION_VERT )
{
/* scale the blue zones */
@ -907,7 +923,6 @@
AF_AxisHints axis = &hints->axis[dim];
AF_Segment segments = axis->segments;
AF_Segment segment_limit = segments + axis->num_segments;
AF_Direction major_dir = axis->major_dir;
FT_Pos len_threshold, len_score;
AF_Segment seg1, seg2;
@ -923,11 +938,11 @@
{
/* the fake segments are introduced to hint the metrics -- */
/* we must never link them to anything */
if ( seg1->first == seg1->last || seg1->dir != major_dir )
if ( seg1->first == seg1->last )
continue;
for ( seg2 = segments; seg2 < segment_limit; seg2++ )
if ( seg2 != seg1 && seg1->dir + seg2->dir == 0 )
for ( seg2 = seg1 + 1; seg2 < segment_limit; seg2++ )
if ( seg1->dir + seg2->dir == 0 )
{
FT_Pos pos1 = seg1->pos;
FT_Pos pos2 = seg2->pos;
@ -935,7 +950,7 @@
if ( dist < 0 )
continue;
dist = -dist;
{
FT_Pos min = seg1->min_coord;
@ -1020,7 +1035,7 @@
* corresponding threshold in font units.
*/
if ( dim == AF_DIMENSION_HORZ )
segment_length_threshold = FT_DivFix( 96, hints->y_scale );
segment_length_threshold = FT_DivFix( 64, hints->y_scale );
else
segment_length_threshold = 0;
@ -1057,6 +1072,12 @@
if ( seg->height < segment_length_threshold )
continue;
/* A special case for serif edges: If they are smaller than */
/* 1.5 pixels we ignore them. */
if ( seg->serif &&
2 * seg->height < 3 * segment_length_threshold )
continue;
/* look for an edge corresponding to the segment */
for ( ee = 0; ee < axis->num_edges; ee++ )
{
@ -1385,8 +1406,8 @@
af_glyph_hints_rescale( hints, (AF_ScriptMetrics)metrics );
/*
* correct x_scale and y_scale when needed, since they may have
* been modified af_latin_scale_dim above
* correct x_scale and y_scale if needed, since they may have
* been modified `af_latin_metrics_scale_dim' above
*/
hints->x_scale = metrics->axis[AF_DIMENSION_HORZ].scale;
hints->x_delta = metrics->axis[AF_DIMENSION_HORZ].delta;
@ -1396,7 +1417,7 @@
/* compute flags depending on render mode, etc. */
mode = metrics->root.scaler.render_mode;
#ifdef AF_USE_WARPER
#if 0 /* #ifdef AF_USE_WARPER */
if ( mode == FT_RENDER_MODE_LCD || mode == FT_RENDER_MODE_LCD_V )
{
metrics->root.scaler.render_mode = mode = FT_RENDER_MODE_NORMAL;
@ -1516,7 +1537,8 @@
FT_Int vertical = ( dim == AF_DIMENSION_VERT );
if ( !AF_LATIN_HINTS_DO_STEM_ADJUST( hints ) )
if ( !AF_LATIN_HINTS_DO_STEM_ADJUST( hints ) ||
axis->extra_light )
return width;
if ( dist < 0 )
@ -2114,7 +2136,12 @@
goto Exit;
/* analyze glyph outline */
#ifdef AF_USE_WARPER
if ( metrics->root.scaler.render_mode == FT_RENDER_MODE_LIGHT ||
AF_HINTS_DO_HORIZONTAL( hints ) )
#else
if ( AF_HINTS_DO_HORIZONTAL( hints ) )
#endif
{
error = af_latin_hints_detect_features( hints, AF_DIMENSION_HORZ );
if ( error )
@ -2133,23 +2160,24 @@
/* grid-fit the outline */
for ( dim = 0; dim < AF_DIMENSION_MAX; dim++ )
{
#ifdef AF_USE_WARPER
if ( ( dim == AF_DIMENSION_HORZ &&
metrics->root.scaler.render_mode == FT_RENDER_MODE_LIGHT ) )
{
AF_WarperRec warper;
FT_Fixed scale;
FT_Pos delta;
af_warper_compute( &warper, hints, dim, &scale, &delta );
af_glyph_hints_scale_dim( hints, dim, scale, delta );
continue;
}
#endif
if ( ( dim == AF_DIMENSION_HORZ && AF_HINTS_DO_HORIZONTAL( hints ) ) ||
( dim == AF_DIMENSION_VERT && AF_HINTS_DO_VERTICAL( hints ) ) )
{
#ifdef AF_USE_WARPER
if ( dim == AF_DIMENSION_HORZ &&
metrics->root.scaler.render_mode == FT_RENDER_MODE_NORMAL )
{
AF_WarperRec warper;
FT_Fixed scale;
FT_Pos delta;
af_warper_compute( &warper, hints, dim, &scale, &delta );
af_glyph_hints_scale_dim( hints, dim, scale, delta );
continue;
}
#endif
af_latin_hint_edges( hints, (AF_Dimension)dim );
af_glyph_hints_align_edge_points( hints, (AF_Dimension)dim );
af_glyph_hints_align_strong_points( hints, (AF_Dimension)dim );

View File

@ -4,7 +4,7 @@
/* */
/* Auto-fitter hinting routines for latin script (specification). */
/* */
/* Copyright 2003, 2004, 2005, 2006 by */
/* Copyright 2003, 2004, 2005, 2006, 2007 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@ -102,6 +102,8 @@ FT_BEGIN_HEADER
FT_UInt width_count;
AF_WidthRec widths[AF_LATIN_MAX_WIDTHS];
FT_Pos edge_distance_threshold;
FT_Pos standard_width;
FT_Bool extra_light;
/* ignored for horizontal metrics */
FT_Bool control_overshoot;

View File

@ -4,7 +4,7 @@
/* */
/* Auto-fitter glyph loading routines (body). */
/* */
/* Copyright 2003, 2004, 2005, 2006 by */
/* Copyright 2003, 2004, 2005, 2006, 2007 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@ -170,9 +170,9 @@
metrics );
/* we now need to hint the metrics according to the change in */
/* width/positioning that occured during the hinting process */
/* width/positioning that occurred during the hinting process */
if ( scaler->render_mode != FT_RENDER_MODE_LIGHT )
{
#ifndef AF_USE_WARPER
FT_Pos old_advance, old_rsb, old_lsb, new_lsb;
FT_Pos pp1x_uh, pp2x_uh;
AF_AxisHints axis = &hints->axis[AF_DIMENSION_HORZ];
@ -183,8 +183,8 @@
if ( axis->num_edges > 1 && AF_HINTS_DO_ADVANCE( hints ) )
{
old_advance = loader->pp2.x;
old_rsb = old_advance - edge2->opos;
old_advance = loader->pp2.x - loader->pp1.x;
old_rsb = loader->pp2.x - edge2->opos;
old_lsb = edge1->opos;
new_lsb = edge1->pos;
@ -198,36 +198,46 @@
/* for very small sizes */
if ( old_lsb < 24 )
pp1x_uh -= 5;
pp1x_uh -= 8;
if ( old_rsb < 24 )
pp2x_uh += 5;
pp2x_uh += 8;
loader->pp1.x = FT_PIX_ROUND( pp1x_uh );
loader->pp2.x = FT_PIX_ROUND( pp2x_uh );
if ( loader->pp1.x >= new_lsb )
if ( loader->pp1.x >= new_lsb && old_lsb > 0 )
loader->pp1.x -= 64;
if ( loader->pp2.x <= pp2x_uh )
if ( loader->pp2.x <= edge2->pos && old_rsb > 0 )
loader->pp2.x += 64;
slot->lsb_delta = loader->pp1.x - pp1x_uh;
slot->rsb_delta = loader->pp2.x - pp2x_uh;
}
else
#endif /* !AF_USE_WARPER */
{
FT_Pos pp1x = loader->pp1.x;
FT_Pos pp2x = loader->pp2.x;
loader->pp1.x = FT_PIX_ROUND( loader->pp1.x );
loader->pp2.x = FT_PIX_ROUND( loader->pp2.x );
loader->pp1.x = FT_PIX_ROUND( pp1x );
loader->pp2.x = FT_PIX_ROUND( pp2x );
slot->lsb_delta = loader->pp1.x - pp1x;
slot->rsb_delta = loader->pp2.x - pp2x;
}
}
else
{
FT_Pos pp1x = loader->pp1.x;
FT_Pos pp2x = loader->pp2.x;
loader->pp1.x = FT_PIX_ROUND( pp1x + hints->xmin_delta );
loader->pp2.x = FT_PIX_ROUND( pp2x + hints->xmax_delta );
slot->lsb_delta = loader->pp1.x - pp1x;
slot->rsb_delta = loader->pp2.x - pp2x;
}
/* good, we simply add the glyph to our loader's base */
FT_GlyphLoader_Add( gloader );
@ -412,10 +422,21 @@
x_scale );
#else
if ( !FT_IS_FIXED_WIDTH( slot->face ) )
slot->metrics.horiAdvance = loader->pp2.x - loader->pp1.x;
{
/* non-spacing glyphs must stay as-is */
if ( slot->metrics.horiAdvance )
slot->metrics.horiAdvance = loader->pp2.x - loader->pp1.x;
}
else
{
slot->metrics.horiAdvance = FT_MulFix( slot->metrics.horiAdvance,
metrics->scaler.x_scale );
/* Set delta values to 0. Otherwise code that uses them is */
/* going to ruin the fixed advance width. */
slot->lsb_delta = 0;
slot->rsb_delta = 0;
}
#endif
slot->metrics.vertAdvance = FT_MulFix( slot->metrics.vertAdvance,

View File

@ -22,7 +22,7 @@
* Its main feature is the ability to differentiate between different
* scripts in order to apply language-specific rules.
*
* The code has also been compartimentized into several entities that
* The code has also been compartmentized into several entities that
* should make algorithmic experimentation easier than with the old
* code.
*

View File

@ -4,7 +4,7 @@
/* */
/* Auto-fitter warping algorithm (body). */
/* */
/* Copyright 2006 by */
/* Copyright 2006, 2007 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@ -24,11 +24,11 @@
static const AF_WarpScore
af_warper_weights[64] =
{
35, 20, 20, 20, 15, 12, 10, 5, 2, 1, 0, 0, 0, 0, 0, 0,
35, 32, 30, 25, 20, 15, 12, 10, 5, 1, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, -1, -2, -5, -8,-10,-10,-20,-20,-30,-30,
-30,-30,-20,-20,-10,-10, -8, -5, -2, -1, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 1, 2, 5, 10, 12, 15, 20, 20, 20,
0, 0, 0, 0, 0, 0, 0, 1, 5, 10, 12, 15, 20, 25, 30, 32,
};
#else
static const AF_WarpScore
@ -55,10 +55,10 @@
{
FT_Int idx_min, idx_max, idx0;
FT_UInt nn;
AF_WarpScore scores[64];
AF_WarpScore scores[65];
for ( nn = 0; nn < 64; nn++ )
for ( nn = 0; nn < 65; nn++ )
scores[nn] = 0;
idx0 = xx1 - warper->t1;
@ -71,16 +71,16 @@
if ( xx1min + w < warper->x2min )
xx1min = warper->x2min - ( xx2 - xx1 );
xx1min = warper->x2min - w;
xx1max = warper->x1max;
if ( xx1max + w > warper->x2max )
xx1max = warper->x2max - ( xx2 - xx1 );
xx1max = warper->x2max - w;
idx_min = xx1min - warper->t1;
idx_max = xx1max - warper->t1;
if ( idx_min > idx_max )
if ( idx_min < 0 || idx_min > idx_max || idx_max > 64 )
{
AF_LOG(( "invalid indices:\n"
" min=%d max=%d, xx1=%ld xx2=%ld,\n"
@ -97,7 +97,6 @@
FT_Pos len = segments[nn].max_coord - segments[nn].min_coord;
FT_Pos y0 = FT_MulFix( segments[nn].pos, scale ) + delta;
FT_Pos y = y0 + ( idx_min - idx0 );
FT_Int idx;
@ -165,7 +164,7 @@
warper->best_scale = org_scale;
warper->best_delta = org_delta;
warper->best_score = 0;
warper->best_score = INT_MIN;
warper->best_distort = 0;
axis = &hints->axis[dim];
@ -178,7 +177,7 @@
*a_delta = org_delta;
/* get X1 and X2, minimum and maximum in original coordinates */
if ( axis->num_segments < 1 )
if ( num_segments < 1 )
return;
#if 1
@ -238,19 +237,34 @@
warper->wmin = warper->x2min - warper->x1max;
warper->wmax = warper->x2max - warper->x1min;
if ( warper->wmin < warper->w0 - 32 )
warper->wmin = warper->w0 - 32;
#if 1
{
int margin = 16;
if ( warper->wmax > warper->w0 + 32 )
warper->wmax = warper->w0 + 32;
if ( warper->w0 <= 128 )
{
margin = 8;
if ( warper->w0 <= 96 )
margin = 4;
}
if ( warper->wmin < warper->w0 - margin )
warper->wmin = warper->w0 - margin;
if ( warper->wmax > warper->w0 + margin )
warper->wmax = warper->w0 + margin;
}
if ( warper->wmin < warper->w0 * 3 / 4 )
warper->wmin = warper->w0 * 3 / 4;
if ( warper->wmax > warper->w0 * 5 / 4 )
warper->wmax = warper->w0 * 5 / 4;
/* warper->wmin = warper->wmax = warper->w0; */
#else
/* no scaling, just translation */
warper->wmin = warper->wmax = warper->w0;
#endif
for ( w = warper->wmin; w <= warper->wmax; w++ )
{
@ -300,8 +314,19 @@
segments, num_segments );
}
*a_scale = warper->best_scale;
*a_delta = warper->best_delta;
{
FT_Fixed best_scale = warper->best_scale;
FT_Pos best_delta = warper->best_delta;
hints->xmin_delta = FT_MulFix( X1, best_scale - org_scale )
+ best_delta;
hints->xmax_delta = FT_MulFix( X2, best_scale - org_scale )
+ best_delta;
*a_scale = best_scale;
*a_delta = best_delta;
}
}
#else /* !AF_USE_WARPER */

View File

@ -4,7 +4,7 @@
/* */
/* Auto-fitter warping algorithm (specification). */
/* */
/* Copyright 2006 by */
/* Copyright 2006, 2007 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@ -33,7 +33,6 @@ FT_BEGIN_HEADER
typedef struct AF_WarperRec_
{
FT_Int X1, X2;
FT_Pos x1, x2;
FT_Pos t1, t2;
FT_Pos x1min, x1max;

View File

@ -4,7 +4,7 @@
/* */
/* Single object library component (body only). */
/* */
/* Copyright 1996-2001, 2002, 2003, 2004, 2006 by */
/* Copyright 1996-2001, 2002, 2003, 2004, 2006, 2007 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@ -32,7 +32,7 @@
#include "ftutil.c"
#if defined( __APPLE__ ) && !defined ( DARWIN_NO_CARBON )
#include "ftmac.c"
#include <ftmac.c>
#endif
/* END */

View File

@ -4,7 +4,7 @@
/* */
/* FreeType bbox computation (body). */
/* */
/* Copyright 1996-2001, 2002, 2004 by */
/* Copyright 1996-2001, 2002, 2004, 2006 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used */
@ -303,7 +303,7 @@
FT_UNUSED ( y4 );
/* The polynom is */
/* The polynomial is */
/* */
/* P(x) = a*x^3 + 3b*x^2 + 3c*x + d , */
/* */

View File

@ -103,75 +103,82 @@
FT_Error error;
int pitch;
int new_pitch;
FT_UInt ppb;
FT_Int i, width;
FT_UInt bpp;
FT_Int i, width, height;
unsigned char* buffer;
width = bitmap->width;
pitch = bitmap->pitch;
width = bitmap->width;
height = bitmap->rows;
pitch = bitmap->pitch;
if ( pitch < 0 )
pitch = -pitch;
switch ( bitmap->pixel_mode )
{
case FT_PIXEL_MODE_MONO:
ppb = 8;
bpp = 1;
new_pitch = ( width + xpixels + 7 ) >> 3;
break;
case FT_PIXEL_MODE_GRAY2:
ppb = 4;
bpp = 2;
new_pitch = ( width + xpixels + 3 ) >> 2;
break;
case FT_PIXEL_MODE_GRAY4:
ppb = 2;
bpp = 4;
new_pitch = ( width + xpixels + 1 ) >> 1;
break;
case FT_PIXEL_MODE_GRAY:
case FT_PIXEL_MODE_LCD:
case FT_PIXEL_MODE_LCD_V:
ppb = 1;
bpp = 8;
new_pitch = ( width + xpixels );
break;
default:
return FT_Err_Invalid_Glyph_Format;
}
/* if no need to allocate memory */
if ( ypixels == 0 && pitch * ppb >= bitmap->width + xpixels )
if ( ypixels == 0 && new_pitch <= pitch )
{
/* zero the padding */
for ( i = 0; i < bitmap->rows; i++ )
FT_Int bit_width = pitch * 8;
FT_Int bit_last = ( width + xpixels ) * bpp;
if ( bit_last < bit_width )
{
unsigned char* last_byte;
int bits = xpixels * ( 8 / ppb );
int mask = 0;
FT_Byte* line = bitmap->buffer + ( bit_last >> 3 );
FT_Byte* end = bitmap->buffer + pitch;
FT_Int shift = bit_last & 7;
FT_UInt mask = 0xFF00U >> shift;
FT_Int count = height;
last_byte = bitmap->buffer + i * pitch + ( bitmap->width - 1 ) / ppb;
if ( bits >= 8 )
for ( ; count > 0; count--, line += pitch, end += pitch )
{
FT_MEM_ZERO( last_byte + 1, bits / 8 );
bits %= 8;
}
FT_Byte* write = line;
if ( bits > 0 )
{
while ( bits-- > 0 )
mask |= 1 << bits;
*last_byte &= ~mask;
if ( shift > 0 )
{
write[0] = (FT_Byte)( write[0] & mask );
write++;
}
if ( write < end )
FT_MEM_ZERO( write, end-write );
}
}
return FT_Err_Ok;
}
new_pitch = ( bitmap->width + xpixels + ppb - 1 ) / ppb;
if ( FT_QALLOC_MULT( buffer, new_pitch, bitmap->rows + ypixels ) )
return error;
if ( bitmap->pitch > 0 )
{
FT_Int len = ( width + ppb - 1 ) / ppb;
FT_Int len = ( width * bpp + 7 ) >> 3;
for ( i = 0; i < bitmap->rows; i++ )
@ -180,7 +187,7 @@
}
else
{
FT_Int len = ( width + ppb - 1 ) / ppb;
FT_Int len = ( width * bpp + 7 ) >> 3;
for ( i = 0; i < bitmap->rows; i++ )
@ -194,7 +201,7 @@
if ( bitmap->pitch < 0 )
new_pitch = -new_pitch;
/* set pitch only */
/* set pitch only, width and height are left untouched */
bitmap->pitch = new_pitch;
return FT_Err_Ok;
@ -244,8 +251,8 @@
align = ( bitmap->width + xstr + 1 ) / 2;
FT_Bitmap_New( &tmp );
error = FT_Bitmap_Convert( library, bitmap, &tmp, align );
error = FT_Bitmap_Convert( library, bitmap, &tmp, align );
if ( error )
return error;

View File

@ -4,7 +4,7 @@
/* */
/* FreeType initialization layer (body). */
/* */
/* Copyright 1996-2001, 2002, 2005 by */
/* Copyright 1996-2001, 2002, 2005, 2007 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@ -124,7 +124,9 @@
/* default drivers. */
error = FT_New_Library( memory, alibrary );
if ( !error )
if ( error )
FT_Done_Memory( memory );
else
{
(*alibrary)->version_major = FREETYPE_MAJOR;
(*alibrary)->version_minor = FREETYPE_MINOR;

View File

@ -8,7 +8,7 @@
/* This file is for Mac OS X only; see builds/mac/ftoldmac.c for */
/* classic platforms built by MPW. */
/* */
/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006 by */
/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006, 2007 by */
/* Just van Rossum, David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@ -72,14 +72,17 @@
/* This is for Mac OS X. Without redefinition, OS_INLINE */
/* expands to `static inline' which doesn't survive the */
/* -ansi compilation flag of GCC. */
#if !HAVE_ANSI_OS_INLINE
#undef OS_INLINE
#define OS_INLINE static __inline__
#define OS_INLINE static __inline__
#endif
#include <Carbon/Carbon.h>
#ifndef HFS_MAXPATHLEN
#define HFS_MAXPATHLEN 1024
#endif
#define FT_DEPRECATED_ATTRIBUTE
#include FT_MAC_H
@ -106,10 +109,31 @@
}
FT_EXPORT_DEF( FT_Error )
FT_GetFile_From_Mac_ATS_Name( const char* fontName,
FSSpec* pathSpec,
FT_Long* face_index )
/* Private function. */
/* The FSSpec type has been discouraged for a long time, */
/* but for some reason, there is no FSRef version of */
/* ATSFontGetFileSpecification(), so we made our own. */
/* Apple will provide one eventually. */
static OSStatus
FT_ATSFontGetFileReference( ATSFontRef ats_font_id,
FSRef* ats_font_ref )
{
OSStatus err;
FSSpec spec;
err = ATSFontGetFileSpecification( ats_font_id, &spec );
if ( noErr == err )
err = FSpMakeFSRef( &spec, ats_font_ref );
return err;
}
static FT_Error
FT_GetFileRef_From_Mac_ATS_Name( const char* fontName,
FSRef* ats_font_ref,
FT_Long* face_index )
{
CFStringRef cf_fontName;
ATSFontRef ats_font_id;
@ -121,38 +145,88 @@
kCFStringEncodingMacRoman );
ats_font_id = ATSFontFindFromName( cf_fontName,
kATSOptionFlagsUnRestrictedScope );
CFRelease( cf_fontName );
if ( ats_font_id == 0 || ats_font_id == 0xFFFFFFFFUL )
return FT_Err_Unknown_File_Format;
if ( 0 != ATSFontGetFileSpecification( ats_font_id, pathSpec ) )
if ( noErr != FT_ATSFontGetFileReference( ats_font_id, ats_font_ref ) )
return FT_Err_Unknown_File_Format;
/* face_index calculation by searching preceding fontIDs */
/* with same FSRef */
{
int i;
FSSpec f;
ATSFontRef id2 = ats_font_id - 1;
FSRef ref2;
for ( i = 1; i < ats_font_id; i++ )
while ( id2 > 0 )
{
if ( 0 != ATSFontGetFileSpecification( ats_font_id - i,
&f ) ||
f.vRefNum != pathSpec->vRefNum ||
f.parID != pathSpec->parID ||
f.name[0] != pathSpec->name[0] ||
0 != ft_strncmp( (char *)f.name + 1,
(char *)pathSpec->name + 1,
f.name[0] ) )
if ( noErr != FT_ATSFontGetFileReference( id2, &ref2 ) )
break;
if ( noErr != FSCompareFSRefs( ats_font_ref, &ref2 ) )
break;
id2 --;
}
*face_index = ( i - 1 );
*face_index = ats_font_id - ( id2 + 1 );
}
return FT_Err_Ok;
}
FT_EXPORT_DEF( FT_Error )
FT_GetFilePath_From_Mac_ATS_Name( const char* fontName,
UInt8* path,
UInt32 maxPathSize,
FT_Long* face_index )
{
FSRef ref;
FT_Error err;
err = FT_GetFileRef_From_Mac_ATS_Name( fontName, &ref, face_index );
if ( FT_Err_Ok != err )
return err;
if ( noErr != FSRefMakePath( &ref, path, maxPathSize ) )
return FT_Err_Unknown_File_Format;
return FT_Err_Ok;
}
/* This function is deprecated because FSSpec is deprecated in Mac OS X */
FT_EXPORT_DEF( FT_Error )
FT_GetFile_From_Mac_ATS_Name( const char* fontName,
FSSpec* pathSpec,
FT_Long* face_index )
{
#if __LP64__
return FT_Err_Unimplemented_Feature;
#else
FSRef ref;
FT_Error err;
err = FT_GetFileRef_From_Mac_ATS_Name( fontName, &ref, face_index );
if ( FT_Err_Ok != err )
return err;
if ( noErr != FSGetCatalogInfo( &ref, kFSCatInfoNone, NULL, NULL,
pathSpec, NULL ) )
return FT_Err_Unknown_File_Format;
return FT_Err_Ok;
#endif
}
static OSErr
FT_FSPathMakeRes( const UInt8* pathname,
short* res )

View File

@ -922,7 +922,7 @@
*/
/* Since the `interesting' table, with IDs (3,10), is normally the */
/* last one, we loop backwards. This looses with type1 fonts with */
/* last one, we loop backwards. This loses with type1 fonts with */
/* non-BMP characters (<.0001%), this wins with .ttf with non-BMP */
/* chars (.01% ?), and this is the same about 99.99% of the time! */
@ -2425,6 +2425,11 @@
else if ( !char_height )
char_height = char_width;
if ( !horz_resolution )
horz_resolution = vert_resolution;
else if ( !vert_resolution )
vert_resolution = horz_resolution;
if ( char_width < 1 * 64 )
char_width = 1 * 64;
if ( char_height < 1 * 64 )
@ -2460,7 +2465,7 @@
if ( pixel_height < 1 )
pixel_height = 1;
/* use `>=' to avoid potention compiler warning on 16bit platforms */
/* use `>=' to avoid potential compiler warning on 16bit platforms */
if ( pixel_width >= 0xFFFFU )
pixel_width = 0xFFFFU;
if ( pixel_height >= 0xFFFFU )

View File

@ -4,7 +4,7 @@
/* */
/* FreeType utility file for memory and list management (body). */
/* */
/* Copyright 2002, 2004, 2005, 2006 by */
/* Copyright 2002, 2004, 2005, 2006, 2007 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@ -172,6 +172,54 @@
}
FT_BASE_DEF( FT_Pointer )
ft_mem_dup( FT_Memory memory,
const void* address,
FT_ULong size,
FT_Error *p_error )
{
FT_Error error;
FT_Pointer p = ft_mem_qalloc( memory, size, &error );
if ( !error && address )
ft_memcpy( p, address, size );
*p_error = error;
return p;
}
FT_BASE_DEF( FT_Pointer )
ft_mem_strdup( FT_Memory memory,
const char* str,
FT_Error *p_error )
{
FT_ULong len = str ? (FT_ULong)ft_strlen( str ) + 1
: 0;
return ft_mem_dup( memory, str, len, p_error );
}
FT_BASE_DEF( FT_Int )
ft_mem_strcpyn( char* dst,
const char* src,
FT_ULong size )
{
while ( size > 1 && *src != 0 )
{
*dst++ = *src++;
size--;
}
*dst = 0; /* always zero-terminate */
return *src != 0;
}
/*************************************************************************/
/*************************************************************************/
/*************************************************************************/

View File

@ -2,7 +2,7 @@
FreeType font driver for bdf files
Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006 by
Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007 by
Francesco Zappa Nardelli
Permission is hereby granted, free of charge, to any person obtaining a copy
@ -194,10 +194,9 @@ THE SOFTWARE.
bdf_font_t* font = bdf->bdffont;
bdf_property_t* prop;
char *istr = NULL, *bstr = NULL;
char *sstr = NULL, *astr = NULL;
int parts = 0, len = 0;
int nn, len;
char* strings[4] = { NULL, NULL, NULL, NULL };
int lengths[4];
face->style_flags = 0;
@ -209,11 +208,9 @@ THE SOFTWARE.
*(prop->value.atom) == 'I' || *(prop->value.atom) == 'i' ) )
{
face->style_flags |= FT_STYLE_FLAG_ITALIC;
istr = ( *(prop->value.atom) == 'O' || *(prop->value.atom) == 'o' )
? (char *)"Oblique"
: (char *)"Italic";
len += ft_strlen( istr );
parts++;
strings[2] = ( *(prop->value.atom) == 'O' || *(prop->value.atom) == 'o' )
? (char *)"Oblique"
: (char *)"Italic";
}
prop = bdf_get_font_property( font, (char *)"WEIGHT_NAME" );
@ -222,80 +219,80 @@ THE SOFTWARE.
( *(prop->value.atom) == 'B' || *(prop->value.atom) == 'b' ) )
{
face->style_flags |= FT_STYLE_FLAG_BOLD;
bstr = (char *)"Bold";
len += ft_strlen( bstr );
parts++;
strings[1] = (char *)"Bold";
}
prop = bdf_get_font_property( font, (char *)"SETWIDTH_NAME" );
if ( prop && prop->format == BDF_ATOM &&
prop->value.atom && *(prop->value.atom) &&
!( *(prop->value.atom) == 'N' || *(prop->value.atom) == 'n' ) )
{
sstr = (char *)(prop->value.atom);
len += ft_strlen( sstr );
parts++;
}
strings[3] = (char *)(prop->value.atom);
prop = bdf_get_font_property( font, (char *)"ADD_STYLE_NAME" );
if ( prop && prop->format == BDF_ATOM &&
prop->value.atom && *(prop->value.atom) &&
!( *(prop->value.atom) == 'N' || *(prop->value.atom) == 'n' ) )
strings[0] = (char *)(prop->value.atom);
len = 0;
for ( len = 0, nn = 0; nn < 4; nn++ )
{
astr = (char *)(prop->value.atom);
len += ft_strlen( astr );
parts++;
lengths[nn] = 0;
if ( strings[nn] )
{
lengths[nn] = ft_strlen( strings[nn] );
len += lengths[nn] + 1;
}
}
if ( !parts || !len )
if ( len == 0 )
{
if ( FT_ALLOC( face->style_name, ft_strlen( "Regular" ) + 1 ) )
return error;
ft_strcpy( face->style_name, "Regular" );
strings[0] = (char *)"Regular";
lengths[0] = ft_strlen( strings[0] );
len = lengths[0] + 1;
}
else
{
char *style, *s;
unsigned int i;
char* s;
if ( FT_ALLOC( style, len + parts ) )
if ( FT_ALLOC( face->style_name, len ) )
return error;
s = style;
s = face->style_name;
if ( astr )
for ( nn = 0; nn < 4; nn++ )
{
ft_strcpy( s, astr );
for ( i = 0; i < ft_strlen( astr ); i++, s++ )
if ( *s == ' ' )
*s = '-'; /* replace spaces with dashes */
*(s++) = ' ';
}
if ( bstr )
{
ft_strcpy( s, bstr );
s += ft_strlen( bstr );
*(s++) = ' ';
}
if ( istr )
{
ft_strcpy( s, istr );
s += ft_strlen( istr );
*(s++) = ' ';
}
if ( sstr )
{
ft_strcpy( s, sstr );
for ( i = 0; i < ft_strlen( sstr ); i++, s++ )
if ( *s == ' ' )
*s = '-'; /* replace spaces with dashes */
*(s++) = ' ';
}
*(--s) = '\0'; /* overwrite last ' ', terminate the string */
char* src = strings[nn];
face->style_name = style; /* allocated string */
len = lengths[nn];
if ( src == NULL )
continue;
/* separate elements with a space */
if ( s != face->style_name )
*s++ = ' ';
ft_memcpy( s, src, len );
/* need to convert spaces to dashes for */
/* add_style_name and setwidth_name */
if ( nn == 0 || nn == 3 )
{
int mm;
for ( mm = 0; mm < len; mm++ )
if ( s[mm] == ' ' )
s[mm] = '-';
}
s += len;
}
*s = 0;
}
return error;
@ -394,12 +391,8 @@ THE SOFTWARE.
prop = bdf_get_font_property( font, "FAMILY_NAME" );
if ( prop && prop->value.atom )
{
int l = ft_strlen( prop->value.atom ) + 1;
if ( FT_NEW_ARRAY( bdfface->family_name, l ) )
if ( FT_STRDUP( bdfface->family_name, prop->value.atom ) )
goto Exit;
ft_strcpy( bdfface->family_name, prop->value.atom );
}
else
bdfface->family_name = 0;
@ -503,18 +496,14 @@ THE SOFTWARE.
const char* s;
if ( FT_NEW_ARRAY( face->charset_encoding,
ft_strlen( charset_encoding->value.atom ) + 1 ) )
goto Exit;
if ( FT_NEW_ARRAY( face->charset_registry,
ft_strlen( charset_registry->value.atom ) + 1 ) )
if ( FT_STRDUP( face->charset_encoding,
charset_encoding->value.atom ) ||
FT_STRDUP( face->charset_registry,
charset_registry->value.atom ) )
goto Exit;
ft_strcpy( face->charset_registry, charset_registry->value.atom );
ft_strcpy( face->charset_encoding, charset_encoding->value.atom );
/* Uh, oh, compare first letters manually to avoid dependency
on locales. */
/* Uh, oh, compare first letters manually to avoid dependency */
/* on locales. */
s = face->charset_registry;
if ( ( s[0] == 'i' || s[0] == 'I' ) &&
( s[1] == 's' || s[1] == 'S' ) &&

View File

@ -1,6 +1,7 @@
/*
* Copyright 2000 Computing Research Labs, New Mexico State University
* Copyright 2001, 2002, 2003, 2004, 2005, 2006 Francesco Zappa Nardelli
* Copyright 2001, 2002, 2003, 2004, 2005, 2006, 2007
* Francesco Zappa Nardelli
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@ -384,8 +385,10 @@
} _bdf_parse_t;
#define setsbit( m, cc ) ( m[(cc) >> 3] |= (FT_Byte)( 1 << ( (cc) & 7 ) ) )
#define sbitset( m, cc ) ( m[(cc) >> 3] & ( 1 << ( (cc) & 7 ) ) )
#define setsbit( m, cc ) \
( m[(FT_Byte)(cc) >> 3] |= (FT_Byte)( 1 << ( (cc) & 7 ) ) )
#define sbitset( m, cc ) \
( m[(FT_Byte)(cc) >> 3] & ( 1 << ( (cc) & 7 ) ) )
static void
@ -1129,7 +1132,7 @@
bdf_options_t* opts )
{
unsigned long len;
char name[128];
char name[256];
_bdf_list_t list;
FT_Memory memory;
FT_Error error = BDF_Err_Ok;
@ -1148,6 +1151,13 @@
font->spacing = opts->font_spacing;
len = (unsigned long)( ft_strlen( font->name ) + 1 );
/* Limit ourselves to 256 characters in the font name. */
if ( len >= 256 )
{
error = BDF_Err_Invalid_Argument;
goto Exit;
}
FT_MEM_COPY( name, font->name, len );
error = _bdf_list_split( &list, (char *)"-", name, len );
@ -1253,7 +1263,6 @@
{
unsigned long propid;
hashnode hn;
int len;
bdf_property_t *prop, *fp;
FT_Memory memory = font->memory;
FT_Error error = BDF_Err_Ok;
@ -1272,19 +1281,11 @@
/* Delete the current atom if it exists. */
FT_FREE( fp->value.atom );
if ( value == 0 )
len = 1;
else
len = ft_strlen( value ) + 1;
if ( len > 1 )
if ( value && value[0] != 0 )
{
if ( FT_NEW_ARRAY( fp->value.atom, len ) )
if ( FT_STRDUP( fp->value.atom, value ) )
goto Exit;
FT_MEM_COPY( fp->value.atom, value, len );
}
else
fp->value.atom = 0;
break;
case BDF_INTEGER:
@ -1349,19 +1350,12 @@
switch ( prop->format )
{
case BDF_ATOM:
if ( value == 0 )
len = 1;
else
len = ft_strlen( value ) + 1;
if ( len > 1 )
fp->value.atom = 0;
if ( value != 0 && value[0] )
{
if ( FT_NEW_ARRAY( fp->value.atom, len ) )
if ( FT_STRDUP( fp->value.atom, value ) )
goto Exit;
FT_MEM_COPY( fp->value.atom, value, len );
}
else
fp->value.atom = 0;
break;
case BDF_INTEGER:
@ -1482,6 +1476,14 @@
if ( p->cnt == 0 )
font->glyphs_size = 64;
/* Limit ourselves to 1,114,112 glyphs in the font (this is the */
/* number of code points available in Unicode). */
if ( p->cnt >= 1114112UL )
{
error = BDF_Err_Invalid_Argument;
goto Exit;
}
if ( FT_NEW_ARRAY( font->glyphs, font->glyphs_size ) )
goto Exit;

View File

@ -220,17 +220,8 @@
/* now, lookup the name itself */
gname = cff_index_get_sid_string( &font->string_index, sid, psnames );
if ( gname && buffer_max > 0 )
{
FT_UInt len = (FT_UInt)ft_strlen( gname );
if ( len >= buffer_max )
len = buffer_max - 1;
FT_MEM_COPY( buffer, gname, len );
((FT_Byte*)buffer)[len] = 0;
}
if ( gname )
FT_STRCPYN( buffer, gname, buffer_max );
FT_FREE( gname );
error = CFF_Err_Ok;
@ -270,6 +261,9 @@
else
name = (FT_String *)psnames->adobe_std_strings( sid );
if ( !name )
continue;
result = ft_strcmp( glyph_name, name );
if ( sid > 390 )

View File

@ -1563,7 +1563,7 @@
check_points( builder, 6 ) )
goto Fail;
/* Record the starting point's y postion for later use */
/* Record the starting point's y position for later use */
start_y = y;
/* first control point */
@ -1666,7 +1666,7 @@
check_points( builder, 6 ) )
goto Fail;
/* record the starting point's x, y postion for later use */
/* record the starting point's x, y position for later use */
start_x = x;
start_y = y;
@ -2089,7 +2089,7 @@
zone->limit = decoder->locals[idx + 1];
zone->cursor = zone->base;
if ( !zone->base )
if ( !zone->base || zone->limit == zone->base )
{
FT_ERROR(( "cff_decoder_parse_charstrings:"
" invoking empty subrs!\n" ));
@ -2131,7 +2131,7 @@
zone->limit = decoder->globals[idx + 1];
zone->cursor = zone->base;
if ( !zone->base )
if ( !zone->base || zone->limit == zone->base )
{
FT_ERROR(( "cff_decoder_parse_charstrings:"
" invoking empty subrs!\n" ));

View File

@ -403,8 +403,11 @@
if ( !offset )
offset = old_offset;
/* sanity check for invalid offset tables */
else if ( offset < old_offset || offset - 1 >= idx->data_size )
/* two sanity checks for invalid offset tables */
else if ( offset < old_offset )
offset = old_offset;
else if ( offset - 1 >= idx->data_size && n < idx->count )
offset = old_offset;
t[n] = idx->bytes + offset - 1;
@ -567,7 +570,6 @@
{
FT_String* name = 0;
const char* adobe_name = psnames->adobe_std_strings( sid );
FT_UInt len;
if ( adobe_name )
@ -576,12 +578,7 @@
FT_Error error;
len = (FT_UInt)ft_strlen( adobe_name );
if ( !FT_ALLOC( name, len + 1 ) )
{
FT_MEM_COPY( name, adobe_name, len );
name[len] = 0;
}
(void)FT_STRDUP( name, adobe_name );
FT_UNUSED( error );
}

View File

@ -285,17 +285,10 @@
const FT_String* source )
{
FT_Error error;
FT_String* result = 0;
FT_Int len = (FT_Int)ft_strlen( source );
FT_String* result;
if ( !FT_ALLOC( result, len + 1 ) )
{
FT_MEM_COPY( result, source, len );
result[len] = 0;
}
FT_UNUSED( error );
result = ft_mem_strdup( memory, source, &error );
return result;
}

View File

@ -4,7 +4,7 @@
/* */
/* CFF token stream parser (body) */
/* */
/* Copyright 1996-2001, 2002, 2003, 2004 by */
/* Copyright 1996-2001, 2002, 2003, 2004, 2007 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@ -159,7 +159,7 @@
for (;;)
{
/* If we entered this iteration with phase == 4, we need to */
/* read a new byte. This also skips past the intial 0x1E. */
/* read a new byte. This also skips past the initial 0x1E. */
if ( phase )
{
p++;

View File

@ -131,7 +131,7 @@ uIntf *v /* working area: values in order of bit length */
uInt z; /* number of entries in current table */
/* Make comiler happy */
/* Make compiler happy */
r.base = 0;
/* Generate counts for each bit length */

View File

@ -12,7 +12,7 @@ in X world. This code implements a PCF driver for the FreeType library.
Glyph images are loaded into memory only on demand, thus leading to a small
memory footprint.
Informations on the PCF font format can only be worked out from
Information on the PCF font format can only be worked out from
`pcfread.c', and `pcfwrite.c', to be found, for instance, in the XFree86
(www.xfree86.org) source tree (xc/lib/font/bitmap/).
@ -75,7 +75,7 @@ ink_metrics.
- height is defined as (ascent - descent). Is this correct?
- if unable to read size informations from the font, PCF_Init_Face
- if unable to read size information from the font, PCF_Init_Face
sets available_size->width and available_size->height to 12.
- too many english grammar errors in the readme file :-(

View File

@ -513,10 +513,8 @@ THE SOFTWARE.
goto Bail;
}
if ( FT_NEW_ARRAY( properties[i].name,
ft_strlen( strings + name_offset ) + 1 ) )
if ( FT_STRDUP( properties[i].name, strings + name_offset ) )
goto Bail;
ft_strcpy( properties[i].name, strings + name_offset );
FT_TRACE4(( " %s:", properties[i].name ));
@ -534,10 +532,8 @@ THE SOFTWARE.
goto Bail;
}
if ( FT_NEW_ARRAY( properties[i].value.atom,
ft_strlen( strings + value_offset ) + 1 ) )
if ( FT_STRDUP( properties[i].value.atom, strings + value_offset ) )
goto Bail;
ft_strcpy( properties[i].value.atom, strings + props[i].value );
FT_TRACE4(( " `%s'\n", properties[i].value.atom ));
}
@ -993,10 +989,9 @@ THE SOFTWARE.
PCF_Property prop;
char *istr = NULL, *bstr = NULL;
char *sstr = NULL, *astr = NULL;
int parts = 0, len = 0;
int nn, len;
char* strings[4] = { NULL, NULL, NULL, NULL };
int lengths[4];
face->style_flags = 0;
@ -1007,11 +1002,9 @@ THE SOFTWARE.
*(prop->value.atom) == 'I' || *(prop->value.atom) == 'i' ) )
{
face->style_flags |= FT_STYLE_FLAG_ITALIC;
istr = ( *(prop->value.atom) == 'O' || *(prop->value.atom) == 'o' )
? (char *)"Oblique"
: (char *)"Italic";
len += ft_strlen( istr );
parts++;
strings[2] = ( *(prop->value.atom) == 'O' ||
*(prop->value.atom) == 'o' ) ? (char *)"Oblique"
: (char *)"Italic";
}
prop = pcf_find_property( pcf, "WEIGHT_NAME" );
@ -1019,80 +1012,78 @@ THE SOFTWARE.
( *(prop->value.atom) == 'B' || *(prop->value.atom) == 'b' ) )
{
face->style_flags |= FT_STYLE_FLAG_BOLD;
bstr = (char *)"Bold";
len += ft_strlen( bstr );
parts++;
strings[1] = (char *)"Bold";
}
prop = pcf_find_property( pcf, "SETWIDTH_NAME" );
if ( prop && prop->isString &&
*(prop->value.atom) &&
!( *(prop->value.atom) == 'N' || *(prop->value.atom) == 'n' ) )
{
sstr = (char *)(prop->value.atom);
len += ft_strlen( sstr );
parts++;
}
strings[3] = (char *)(prop->value.atom);
prop = pcf_find_property( pcf, "ADD_STYLE_NAME" );
if ( prop && prop->isString &&
*(prop->value.atom) &&
!( *(prop->value.atom) == 'N' || *(prop->value.atom) == 'n' ) )
strings[0] = (char *)(prop->value.atom);
for ( len = 0, nn = 0; nn < 4; nn++ )
{
astr = (char *)(prop->value.atom);
len += ft_strlen( astr );
parts++;
lengths[nn] = 0;
if ( strings[nn] )
{
lengths[nn] = ft_strlen( strings[nn] );
len += lengths[nn] + 1;
}
}
if ( !parts || !len )
if ( len == 0 )
{
if ( FT_ALLOC( face->style_name, 8 ) )
return error;
ft_strcpy( face->style_name, "Regular" );
face->style_name[7] = '\0';
strings[0] = (char *)"Regular";
lengths[0] = ft_strlen( strings[0] );
len = lengths[0] + 1;
}
else
{
char *style, *s;
unsigned int i;
char* s;
if ( FT_ALLOC( style, len + parts ) )
if ( FT_ALLOC( face->style_name, len ) )
return error;
s = style;
s = face->style_name;
if ( astr )
for ( nn = 0; nn < 4; nn++ )
{
ft_strcpy( s, astr );
for ( i = 0; i < ft_strlen( astr ); i++, s++ )
if ( *s == ' ' )
*s = '-'; /* replace spaces with dashes */
*(s++) = ' ';
}
if ( bstr )
{
ft_strcpy( s, bstr );
s += ft_strlen( bstr );
*(s++) = ' ';
}
if ( istr )
{
ft_strcpy( s, istr );
s += ft_strlen( istr );
*(s++) = ' ';
}
if ( sstr )
{
ft_strcpy( s, sstr );
for ( i = 0; i < ft_strlen( sstr ); i++, s++ )
if ( *s == ' ' )
*s = '-'; /* replace spaces with dashes */
*(s++) = ' ';
}
*(--s) = '\0'; /* overwrite last ' ', terminate the string */
char* src = strings[nn];
face->style_name = style; /* allocated string */
len = lengths[nn];
if ( src == NULL )
continue;
/* separate elements with a space */
if ( s != face->style_name )
*s++ = ' ';
ft_memcpy( s, src, len );
/* need to convert spaces to dashes for */
/* add_style_name and setwidth_name */
if ( nn == 0 || nn == 3 )
{
int mm;
for ( mm = 0; mm < len; mm++ )
if (s[mm] == ' ')
s[mm] = '-';
}
s += len;
}
*s = 0;
}
return error;
@ -1173,12 +1164,8 @@ THE SOFTWARE.
prop = pcf_find_property( face, "FAMILY_NAME" );
if ( prop && prop->isString )
{
int l = ft_strlen( prop->value.atom ) + 1;
if ( FT_NEW_ARRAY( root->family_name, l ) )
if ( FT_STRDUP( root->family_name, prop->value.atom ) )
goto Exit;
ft_strcpy( root->family_name, prop->value.atom );
}
else
root->family_name = NULL;
@ -1256,16 +1243,11 @@ THE SOFTWARE.
if ( charset_registry && charset_registry->isString &&
charset_encoding && charset_encoding->isString )
{
if ( FT_NEW_ARRAY( face->charset_encoding,
ft_strlen( charset_encoding->value.atom ) + 1 ) )
if ( FT_STRDUP( face->charset_encoding,
charset_encoding->value.atom ) ||
FT_STRDUP( face->charset_registry,
charset_registry->value.atom ) )
goto Exit;
if ( FT_NEW_ARRAY( face->charset_registry,
ft_strlen( charset_registry->value.atom ) + 1 ) )
goto Exit;
ft_strcpy( face->charset_registry, charset_registry->value.atom );
ft_strcpy( face->charset_encoding, charset_encoding->value.atom );
}
}
}

View File

@ -4,7 +4,7 @@
/* */
/* FreeType PFR loader (body). */
/* */
/* Copyright 2002, 2003, 2004, 2005 by */
/* Copyright 2002, 2003, 2004, 2005, 2007 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@ -743,7 +743,7 @@
phy_font->bbox.yMax = PFR_NEXT_SHORT( p );
phy_font->flags = flags = PFR_NEXT_BYTE( p );
/* get the standard advance for non-proprotional fonts */
/* get the standard advance for non-proportional fonts */
if ( !(flags & PFR_PHY_PROPORTIONAL) )
{
PFR_CHECK( 2 );

View File

@ -4,7 +4,7 @@
/* */
/* Auxiliary functions for PostScript fonts (body). */
/* */
/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006 by */
/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006, 2007 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@ -1173,7 +1173,7 @@
break;
default:
/* an error occured */
/* an error occurred */
goto Fail;
}
}

View File

@ -543,13 +543,58 @@
/* the stem is less than one pixel; we will center it
* around the nearest pixel center
*/
#if 1
pos = FT_PIX_FLOOR( pos + ( len >> 1 ) );
#else
/* this seems to be a bug! */
pos = pos + FT_PIX_FLOOR( len >> 1 );
#endif
len = 64;
if ( len >= 32 )
{
/* This is a special case where we also widen the stem
* and align it to the pixel grid.
*
* stem_center = pos + (len/2)
* nearest_pixel_center = FT_ROUND(stem_center-32)+32
* new_pos = nearest_pixel_center-32
* = FT_ROUND(stem_center-32)
* = FT_FLOOR(stem_center-32+32)
* = FT_FLOOR(stem_center)
* new_len = 64
*/
pos = FT_PIX_FLOOR( pos + ( len >> 1 ) );
len = 64;
}
else if ( len > 0 )
{
/* This is a very small stem; we simply align it to the
* pixel grid, trying to find the minimal displacement.
*
* left = pos
* right = pos + len
* left_nearest_edge = ROUND(pos)
* right_nearest_edge = ROUND(right)
*
* if ( ABS(left_nearest_edge - left) <=
* ABS(right_nearest_edge - right) )
* new_pos = left
* else
* new_pos = right
*/
FT_Pos left_nearest = FT_PIX_ROUND( pos );
FT_Pos right_nearest = FT_PIX_ROUND( pos + len );
FT_Pos left_disp = left_nearest - pos;
FT_Pos right_disp = right_nearest - ( pos + len );
if ( left_disp < 0 )
left_disp = -left_disp;
if ( right_disp < 0 )
right_disp = -right_disp;
if ( left_disp <= right_disp )
pos = left_nearest;
else
pos = right_nearest;
}
else
{
/* this is a ghost stem; we simply round it */
pos = FT_PIX_ROUND( pos );
}
}
else
{
@ -2175,11 +2220,11 @@
PSH_Dimension dim_x = &glyph->globals->dimension[0];
PSH_Dimension dim_y = &glyph->globals->dimension[1];
FT_Fixed x_scale = dim_x->scale_mult;
FT_Fixed y_scale = dim_y->scale_mult;
FT_Fixed x_scale = dim_x->scale_mult;
FT_Fixed y_scale = dim_y->scale_mult;
FT_Fixed scaled;
FT_Fixed fitted;
FT_Fixed scaled;
FT_Fixed fitted;
scaled = FT_MulFix( globals->blues.normal_top.zones->org_ref, y_scale );

View File

@ -4,7 +4,7 @@
/* */
/* FreeType PostScript hints recorder (body). */
/* */
/* Copyright 2001, 2002, 2003, 2004 by */
/* Copyright 2001, 2002, 2003, 2004, 2007 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@ -730,7 +730,7 @@
break;
}
/* creat a new counter when needed */
/* create a new counter when needed */
if ( count == 0 )
{
error = ps_mask_table_alloc( &dim->counters, memory, &counter );

View File

@ -4,7 +4,7 @@
/* */
/* PSNames module implementation (body). */
/* */
/* Copyright 1996-2001, 2002, 2003, 2005, 2006 by */
/* Copyright 1996-2001, 2002, 2003, 2005, 2006, 2007 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@ -97,7 +97,7 @@
}
/* If the name begins with `u', followed by four to six uppercase */
/* hexadicimal digits, it is a hard-coded unicode character code. */
/* hexadecimal digits, it is a hard-coded unicode character code. */
if ( glyph_name[0] == 'u' )
{
FT_Int count;

View File

@ -126,7 +126,7 @@
/* optimize performance (see technical note on the sweep below). */
/* */
/* Of course, the raster detects whether the two stacks collide and */
/* handles the situation propertly. */
/* handles the situation properly. */
/* */
/*************************************************************************/
@ -486,7 +486,7 @@
Byte dropOutControl; /* current drop_out control method */
Bool second_pass; /* indicates wether a horizontal pass */
Bool second_pass; /* indicates whether a horizontal pass */
/* should be performed to control */
/* drop-out accurately when calling */
/* Render_Glyph. Note that there is */
@ -1646,7 +1646,7 @@ static const char count_table[256] =
/* Decompose_Curve */
/* */
/* <Description> */
/* Scans the outline arays in order to emit individual segments and */
/* Scans the outline arrays in order to emit individual segments and */
/* Beziers by calling Line_To() and Bezier_To(). It handles all */
/* weird cases, like when the first point is off the curve, or when */
/* there are simply no `on' points in the contour! */

View File

@ -4,7 +4,7 @@
/* */
/* High-level SFNT driver interface (body). */
/* */
/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006 by */
/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006, 2007 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@ -144,17 +144,8 @@
error = tt_face_get_ps_name( face, glyph_index, &gname );
if ( !error && buffer_max > 0 )
{
FT_UInt len = (FT_UInt)( ft_strlen( gname ) );
if ( len >= buffer_max )
len = buffer_max - 1;
FT_MEM_COPY( buffer, gname, len );
((FT_Byte*)buffer)[len] = 0;
}
if ( !error )
FT_STRCPYN( buffer, gname, buffer_max );
return error;
}

View File

@ -828,7 +828,7 @@
/* - otherwise, the correct typographic values are in the */
/* sTypoAscender, sTypoDescender & sTypoLineGap fields. */
/* */
/* However, certains fonts have these fields set to 0. */
/* However, certain fonts have these fields set to 0. */
/* Rather, they have usWinAscent & usWinDescent correctly */
/* set (but with different values). */
/* */

View File

@ -1528,7 +1528,7 @@
/* NAME OFFSET TYPE DESCRIPTION */
/* */
/* format 0 USHORT must be 8 */
/* reseved 2 USHORT reserved */
/* reserved 2 USHORT reserved */
/* length 4 ULONG length in bytes */
/* language 8 ULONG Mac language code */
/* is32 12 BYTE[8192] 32-bitness bitmap */

View File

@ -275,7 +275,7 @@
goto NextTable;
Found:
if ( coverage & 8 ) /* overide or add */
if ( coverage & 8 ) /* override or add */
result = value;
else
result += value;

View File

@ -806,8 +806,8 @@
/* tt_face_load_cmap */
/* */
/* <Description> */
/* Loads the cmap directory in a face object. The cmaps itselves are */
/* loaded on demand in the `ttcmap.c' module. */
/* Loads the cmap directory in a face object. The cmaps themselves */
/* are loaded on demand in the `ttcmap.c' module. */
/* */
/* <Input> */
/* face :: A handle to the target face object. */

View File

@ -368,11 +368,11 @@
if ( gindex < (FT_UInt)k )
{
table_pos += 4 * gindex;
if ( table_pos + 6 > table_end )
if ( table_pos + 4 > table_end )
goto NoData;
if ( FT_STREAM_SEEK( table_pos ) ||
FT_READ_USHORT( *aadvance) ||
FT_READ_USHORT( *aadvance ) ||
FT_READ_SHORT( *abearing ) )
goto NoData;
}

View File

@ -5,7 +5,7 @@
/* Postcript name table processing for TrueType and OpenType fonts */
/* (body). */
/* */
/* Copyright 1996-2001, 2002, 2003, 2006 by */
/* Copyright 1996-2001, 2002, 2003, 2006, 2007 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@ -240,7 +240,7 @@
}
}
/* all right, set table fields and exit successfuly */
/* all right, set table fields and exit successfully */
{
TT_Post_20 table = &face->postscript_names.names.format_20;
@ -314,7 +314,7 @@
}
}
/* OK, set table fields and exit successfuly */
/* OK, set table fields and exit successfully */
{
TT_Post_25 table = &face->postscript_names.names.format_25;

View File

@ -1359,7 +1359,7 @@
/* decomposition. */
/* */
/* <Return> */
/* Error code. 0 means sucess. */
/* Error code. 0 means success. */
/* */
static
int FT_Outline_Decompose( const FT_Outline* outline,

View File

@ -108,7 +108,7 @@
if ( face->vertical_info )
( (SFNT_Service)face->sfnt )->get_metrics( face, 1, idx, tsb, ah );
#if 1 /* Emperically determined, at variance with what MS said */
#if 1 /* Empirically determined, at variance with what MS said */
else
{
@ -616,7 +616,7 @@
translate_array( zone->n_points, zone->cur, origin, 0 );
#ifdef TT_USE_BYTECODE_INTERPRETER
/* save original point positioin in org */
/* save original point position in org */
if ( n_ins > 0 )
FT_ARRAY_COPY( zone->org, zone->cur, zone->n_points );
#endif
@ -934,7 +934,7 @@
/* */
/* <Description> */
/* This is slightly different from TT_Process_Simple_Glyph, in that */
/* it's sole purpose is to hint the glyph. Thus this function is */
/* its sole purpose is to hint the glyph. Thus this function is */
/* only available when bytecode interpreter is enabled. */
/* */
static FT_Error
@ -1377,6 +1377,8 @@
FT_UInt num_subglyphs = gloader->current.num_subglyphs;
FT_UInt num_base_subgs = gloader->base.num_subglyphs;
FT_Stream old_stream = loader->stream;
FT_GlyphLoader_Add( gloader );
@ -1430,6 +1432,7 @@
num_base_points );
}
loader->stream = old_stream;
/* process the glyph */
loader->ins_pos = ins_pos;

View File

@ -4,7 +4,7 @@
/* */
/* TrueType GX Font Variation loader */
/* */
/* Copyright 2004, 2005, 2006 by */
/* Copyright 2004, 2005, 2006, 2007 by */
/* David Turner, Robert Wilhelm, Werner Lemberg, and George Williams. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@ -22,7 +22,7 @@
/* */
/* http://developer.apple.com/fonts/TTRefMan/RM06/Chap6[fgca]var.html */
/* */
/* The documentation for `fvar' is inconsistant. At one point it says */
/* The documentation for `fvar' is inconsistent. At one point it says */
/* that `countSizePairs' should be 3, at another point 2. It should be 2. */
/* */
/* The documentation for `gvar' is not intelligible; `cvar' refers you to */

View File

@ -16,11 +16,6 @@
/***************************************************************************/
/* define FIX_BYTECODE to implement the bytecode interpreter fixes */
/* needed to match Windows behaviour more accurately */
/* #define FIX_BYTECODE */
#include <ft2build.h>
#include FT_INTERNAL_DEBUG_H
#include FT_INTERNAL_CALC_H
@ -53,7 +48,7 @@
/* */
/* In order to detect infinite loops in the code, we set up a counter */
/* within the run loop. A single stroke of interpretation is now */
/* limitet to a maximal number of opcodes defined below. */
/* limited to a maximal number of opcodes defined below. */
/* */
#define MAX_RUNNABLE_OPCODES 1000000L
@ -140,7 +135,7 @@
/*************************************************************************/
/* */
/* The following macros hide the use of EXEC_ARG and EXEC_ARG_ to */
/* increase readabilty of the code. */
/* increase readability of the code. */
/* */
/*************************************************************************/
@ -163,18 +158,12 @@
#define INS_Goto_CodeRange( range, ip ) \
Ins_Goto_CodeRange( EXEC_ARG_ range, ip )
#define CUR_Func_project( x, y ) \
CUR.func_project( EXEC_ARG_ x, y )
#define CUR_Func_move( z, p, d ) \
CUR.func_move( EXEC_ARG_ z, p, d )
#define CUR_Func_move_orig( z, p, d ) \
CUR.func_move_orig( EXEC_ARG_ z, p, d )
#define CUR_Func_dualproj( x, y ) \
CUR.func_dualproj( EXEC_ARG_ x, y )
#define CUR_Func_round( d, c ) \
CUR.func_round( EXEC_ARG_ d, c )
@ -212,6 +201,19 @@
Move_Zp2_Point( EXEC_ARG_ a, b, c, t )
#define CUR_Func_project( v1, v2 ) \
CUR.func_project( EXEC_ARG_ (v1)->x - (v2)->x, (v1)->y - (v2)->y )
#define CUR_Func_dualproj( v1, v2 ) \
CUR.func_dualproj( EXEC_ARG_ (v1)->x - (v2)->x, (v1)->y - (v2)->y )
#define CUR_fast_project( v ) \
CUR.func_project( EXEC_ARG_ (v)->x, (v)->y )
#define CUR_fast_dualproj( v ) \
CUR.func_dualproj( EXEC_ARG_ (v)->x, (v)->y )
/*************************************************************************/
/* */
/* Instruction dispatch function, as used by the interpreter. */
@ -1136,6 +1138,41 @@
#define NULL_Vector (FT_Vector*)&Null_Vector
#if 1
static FT_Int32
TT_MulFix14( FT_Int32 a,
FT_Int b )
{
FT_Int32 sign;
FT_UInt32 ah, al, mid, lo, hi;
sign = a ^ b;
if ( a < 0 )
a = -a;
if ( b < 0 )
b = -b;
ah = (FT_UInt32)( ( a >> 16 ) & 0xFFFFU );
al = (FT_UInt32)( a & 0xFFFFU );
lo = al * b;
mid = ah * b;
hi = mid >> 16;
mid = ( mid << 16 ) + ( 1 << 13 ); /* rounding */
lo += mid;
if ( lo < mid )
hi += 1;
mid = ( lo >> 14 ) | ( hi << 18 );
return sign >= 0 ? (FT_Int32)mid : -(FT_Int32)mid;
}
#else
/* compute (a*b)/2^14 with maximal accuracy and rounding */
static FT_Int32
TT_MulFix14( FT_Int32 a,
@ -1159,10 +1196,11 @@
lo = l;
l = lo + 0x2000U;
hi += (l < lo);
hi += l < lo;
return ( hi << 18 ) | ( l >> 14 );
}
#endif
/* compute (ax*bx+ay*by)/2^14 with maximal accuracy and rounding */
@ -1851,9 +1889,9 @@
{
FT_F26Dot6 val;
FT_UNUSED_EXEC;
if ( distance >= 0 )
{
val = distance + compensation + 63;
@ -2122,7 +2160,7 @@
break;
}
if ( (selector & 0x0F) == 0 )
if ( ( selector & 0x0F ) == 0 )
CUR.threshold = CUR.period - 1;
else
CUR.threshold = ( (FT_Int)( selector & 0x0F ) - 4 ) * CUR.period / 8;
@ -2150,19 +2188,19 @@
/* The distance in F26dot6 format. */
/* */
static FT_F26Dot6
Project( EXEC_OP_ FT_Vector* v1,
FT_Vector* v2 )
Project( EXEC_OP_ FT_Pos dx,
FT_Pos dy )
{
#ifdef TT_CONFIG_OPTION_UNPATENTED_HINTING
FT_ASSERT( !CUR.face->unpatented_hinting );
#endif
return TT_DotFix14( v1->x - v2->x,
v1->y - v2->y,
return TT_DotFix14( dx, dy,
CUR.GS.projVector.x,
CUR.GS.projVector.y );
}
/*************************************************************************/
/* */
/* <Function> */
@ -2180,11 +2218,10 @@
/* The distance in F26dot6 format. */
/* */
static FT_F26Dot6
Dual_Project( EXEC_OP_ FT_Vector* v1,
FT_Vector* v2 )
Dual_Project( EXEC_OP_ FT_Pos dx,
FT_Pos dy )
{
return TT_DotFix14( v1->x - v2->x,
v1->y - v2->y,
return TT_DotFix14( dx, dy,
CUR.GS.dualVector.x,
CUR.GS.dualVector.y );
}
@ -2207,12 +2244,13 @@
/* The distance in F26dot6 format. */
/* */
static FT_F26Dot6
Project_x( EXEC_OP_ FT_Vector* v1,
FT_Vector* v2 )
Project_x( EXEC_OP_ FT_Pos dx,
FT_Pos dy )
{
FT_UNUSED_EXEC;
FT_UNUSED( dy );
return ( v1->x - v2->x );
return dx;
}
@ -2233,12 +2271,13 @@
/* The distance in F26dot6 format. */
/* */
static FT_F26Dot6
Project_y( EXEC_OP_ FT_Vector* v1,
FT_Vector* v2 )
Project_y( EXEC_OP_ FT_Pos dx,
FT_Pos dy )
{
FT_UNUSED_EXEC;
FT_UNUSED( dx );
return ( v1->y - v2->y );
return dy;
}
@ -2769,12 +2808,12 @@
CUR.GS.single_width_cutin = (FT_F26Dot6)args[0];
/* XXX: UNDOCUMENTED! or bug in the Windows engine? */
/* */
/* It seems that the value that is read here is */
/* expressed in 16.16 format rather than in font */
/* units. */
/* */
/* XXX: UNDOCUMENTED! or bug in the Windows engine? */
/* */
/* It seems that the value that is read here is */
/* expressed in 16.16 format rather than in font */
/* units. */
/* */
#define DO_SSW \
CUR.GS.single_width_value = (FT_F26Dot6)( args[0] >> 10 );
@ -4319,7 +4358,7 @@
/* Exit the current call frame. */
/* NOTE: If the last intruction of a program is a */
/* NOTE: If the last instruction of a program is a */
/* CALL or LOOPCALL, the return address is */
/* always out of the code range. This is a */
/* valid address, and it is why we do not test */
@ -4619,7 +4658,7 @@
FT_UShort L, K;
L = (FT_UShort)(CUR.opcode - 0xB0 + 1);
L = (FT_UShort)( CUR.opcode - 0xB0 + 1 );
if ( BOUNDS( L, CUR.stackSize + 1 - CUR.top ) )
{
@ -4644,7 +4683,7 @@
FT_UShort L, K;
L = (FT_UShort)(CUR.opcode - 0xB8 + 1);
L = (FT_UShort)( CUR.opcode - 0xB8 + 1 );
if ( BOUNDS( L, CUR.stackSize + 1 - CUR.top ) )
{
@ -4701,9 +4740,9 @@
else
{
if ( CUR.opcode & 1 )
R = CUR_Func_dualproj( CUR.zp2.org + L, NULL_Vector );
R = CUR_fast_dualproj( &CUR.zp2.org[L] );
else
R = CUR_Func_project( CUR.zp2.cur + L, NULL_Vector );
R = CUR_fast_project( &CUR.zp2.cur[L] );
}
args[0] = R;
@ -4736,7 +4775,7 @@
return;
}
K = CUR_Func_project( CUR.zp2.cur + L, NULL_Vector );
K = CUR_fast_project( &CUR.zp2.cur[L] );
CUR_Func_move( &CUR.zp2, L, args[1] - K );
@ -4787,35 +4826,7 @@
if ( CUR.opcode & 1 )
D = CUR_Func_project( CUR.zp0.cur + L, CUR.zp1.cur + K );
else
{
#ifdef FIX_BYTECODE
FT_Vector vec1, vec2;
if ( CUR.GS.gep0 == 0 || CUR.GS.gep1 == 0 )
FT_ARRAY_COPY( CUR.twilight.orus,
CUR.twilight.org,
CUR.twilight.n_points );
/* get scaled orus coordinates */
vec1 = CUR.zp0.orus[L];
vec2 = CUR.zp1.orus[K];
vec1.x = TT_MULFIX( vec1.x, CUR.metrics.x_scale );
vec1.y = TT_MULFIX( vec1.y, CUR.metrics.y_scale );
vec2.x = TT_MULFIX( vec2.x, CUR.metrics.x_scale );
vec2.y = TT_MULFIX( vec2.y, CUR.metrics.y_scale );
D = CUR_Func_dualproj( &vec1, &vec2 );
#else
D = CUR_Func_dualproj( CUR.zp0.org + L, CUR.zp1.org + K );
#endif /* FIX_BYTECODE */
}
}
args[0] = D;
@ -5068,25 +5079,25 @@
A *= 64;
#if 0
if ( (args[0] & 0x100) != 0 && CUR.metrics.pointSize <= A )
if ( ( args[0] & 0x100 ) != 0 && CUR.metrics.pointSize <= A )
CUR.GS.scan_control = TRUE;
#endif
if ( (args[0] & 0x200) != 0 && CUR.tt_metrics.rotated )
if ( ( args[0] & 0x200 ) != 0 && CUR.tt_metrics.rotated )
CUR.GS.scan_control = TRUE;
if ( (args[0] & 0x400) != 0 && CUR.tt_metrics.stretched )
if ( ( args[0] & 0x400 ) != 0 && CUR.tt_metrics.stretched )
CUR.GS.scan_control = TRUE;
#if 0
if ( (args[0] & 0x800) != 0 && CUR.metrics.pointSize > A )
if ( ( args[0] & 0x800 ) != 0 && CUR.metrics.pointSize > A )
CUR.GS.scan_control = FALSE;
#endif
if ( (args[0] & 0x1000) != 0 && CUR.tt_metrics.rotated )
if ( ( args[0] & 0x1000 ) != 0 && CUR.tt_metrics.rotated )
CUR.GS.scan_control = FALSE;
if ( (args[0] & 0x2000) != 0 && CUR.tt_metrics.stretched )
if ( ( args[0] & 0x2000 ) != 0 && CUR.tt_metrics.stretched )
CUR.GS.scan_control = FALSE;
}
@ -5430,7 +5441,7 @@
last_point = 0;
}
/* XXX: UNDOCUMENTED! SHC does touch the points */
/* XXX: UNDOCUMENTED! SHC touches the points */
for ( i = first_point; i <= last_point; i++ )
{
if ( zp.cur != CUR.zp2.cur || refp != i )
@ -5466,8 +5477,14 @@
if ( COMPUTE_Point_Displacement( &dx, &dy, &zp, &refp ) )
return;
if ( CUR.zp2.n_points > 0 )
last_point = (FT_UShort)(CUR.zp2.n_points - 1);
/* XXX: UNDOCUMENTED! SHZ doesn't move the phantom points. */
/* Twilight zone has no contours, so use `n_points'. */
/* Normal zone's `n_points' includes phantoms, so must */
/* use end of last contour. */
if ( CUR.GS.gep2 == 0 && CUR.zp2.n_points > 0 )
last_point = (FT_UShort)( CUR.zp2.n_points - 1 );
else if ( CUR.GS.gep2 == 1 && CUR.zp2.n_contours > 0 )
last_point = (FT_UShort)( CUR.zp2.contours[CUR.zp2.n_contours - 1] );
else
last_point = 0;
@ -5585,7 +5602,7 @@
CUR.GS.rp1 = CUR.GS.rp0;
CUR.GS.rp2 = point;
if ( (CUR.opcode & 1) != 0 )
if ( ( CUR.opcode & 1 ) != 0 )
CUR.GS.rp0 = point;
}
@ -5617,7 +5634,7 @@
/* twilight zone? ? */
if ( ( CUR.opcode & 1 ) != 0 )
{
cur_dist = CUR_Func_project( CUR.zp0.cur + point, NULL_Vector );
cur_dist = CUR_fast_project( &CUR.zp0.cur[point] );
distance = CUR_Func_round( cur_dist,
CUR.tt_metrics.compensations[0] ) - cur_dist;
}
@ -5657,12 +5674,12 @@
return;
}
/* UNDOCUMENTED! */
/* XXX: UNDOCUMENTED! */
/* */
/* The behaviour of an MIAP instruction is quite */
/* different when used in the twilight zone. */
/* */
/* First, no control value cutin test is performed */
/* First, no control value cut-in test is performed */
/* as it would fail anyway. Second, the original */
/* point, i.e. (org_x,org_y) of zp0.point, is set */
/* to the absolute, unrounded distance found in */
@ -5688,7 +5705,7 @@
CUR.zp0.cur[point] = CUR.zp0.org[point];
}
org_dist = CUR_Func_project( CUR.zp0.cur + point, NULL_Vector );
org_dist = CUR_fast_project( &CUR.zp0.cur[point] );
if ( ( CUR.opcode & 1 ) != 0 ) /* rounding and control cutin flag */
{
@ -5731,35 +5748,39 @@
/* XXX: Is there some undocumented feature while in the */
/* twilight zone? */
#ifdef FIX_BYTECODE
/* XXX: UNDOCUMENTED: twilight zone special case */
if ( CUR.GS.gep0 == 0 || CUR.GS.gep1 == 0 )
{
FT_Vector vec1, vec2;
FT_Vector* vec1 = &CUR.zp1.org[point];
FT_Vector* vec2 = &CUR.zp0.org[CUR.GS.rp0];
if ( CUR.GS.gep0 == 0 || CUR.GS.gep1 == 0 )
FT_ARRAY_COPY( CUR.twilight.orus,
CUR.twilight.org,
CUR.twilight.n_points );
vec1 = CUR.zp1.orus[point];
vec2 = CUR.zp0.orus[CUR.GS.rp0];
vec1.x = TT_MULFIX( vec1.x, CUR.metrics.x_scale );
vec1.y = TT_MULFIX( vec1.y, CUR.metrics.y_scale );
vec2.x = TT_MULFIX( vec2.x, CUR.metrics.x_scale );
vec2.y = TT_MULFIX( vec2.y, CUR.metrics.y_scale );
org_dist = CUR_Func_dualproj( &vec1, &vec2 );
org_dist = CUR_Func_dualproj( vec1, vec2 );
}
else
{
FT_Vector* vec1 = &CUR.zp1.orus[point];
FT_Vector* vec2 = &CUR.zp0.orus[CUR.GS.rp0];
#else
org_dist = CUR_Func_dualproj( CUR.zp1.org + point,
CUR.zp0.org + CUR.GS.rp0 );
if ( CUR.metrics.x_scale == CUR.metrics.y_scale )
{
/* this should be faster */
org_dist = CUR_Func_dualproj( vec1, vec2 );
org_dist = TT_MULFIX( org_dist, CUR.metrics.x_scale );
}
else
{
FT_Vector vec;
#endif /* FIX_BYTECODE */
vec.x = TT_MULFIX( vec1->x - vec2->x, CUR.metrics.x_scale );
vec.y = TT_MULFIX( vec1->y - vec2->y, CUR.metrics.y_scale );
org_dist = CUR_fast_dualproj( &vec );
}
}
/* single width cut-in test */
@ -5872,14 +5893,13 @@
CUR.zp1.org[point].y = CUR.zp0.org[CUR.GS.rp0].y +
TT_MulFix14( cvt_dist, CUR.GS.freeVector.y );
CUR.zp1.cur[point] = CUR.zp1.org[point];
CUR.zp1.cur[point] = CUR.zp0.cur[point];
}
org_dist = CUR_Func_dualproj( CUR.zp1.org + point,
CUR.zp0.org + CUR.GS.rp0 );
cur_dist = CUR_Func_project( CUR.zp1.cur + point,
CUR.zp0.cur + CUR.GS.rp0 );
org_dist = CUR_Func_dualproj( &CUR.zp1.org[point],
&CUR.zp0.org[CUR.GS.rp0] );
cur_dist = CUR_Func_project ( &CUR.zp1.cur[point],
&CUR.zp0.cur[CUR.GS.rp0] );
/* auto-flip test */
@ -5933,7 +5953,6 @@
CUR.GS.rp0 = point;
/* XXX: UNDOCUMENTED! */
CUR.GS.rp2 = point;
}
@ -6111,13 +6130,16 @@
/* Opcode range: 0x39 */
/* Stack: uint32... --> */
/* */
/* SOMETIMES, DUMBER CODE IS BETTER CODE */
static void
Ins_IP( INS_ARG )
{
FT_F26Dot6 org_a, org_b, org_x,
cur_a, cur_b, cur_x,
distance = 0;
FT_UShort point;
FT_F26Dot6 old_range, cur_range;
FT_Vector* orus_base;
FT_Vector* cur_base;
FT_Int twilight;
FT_UNUSED_ARG;
@ -6128,70 +6150,49 @@
return;
}
#ifdef FIX_BYTECODE
/* We need to deal in a special way with the twilight zone. The easiest
* solution is simply to copy the coordinates from `org' to `orus'
* whenever someone tries to perform intersections based on some of its
* points.
*
* Otherwise, by definition, value of CUR.twilight[n] is (0,0),
* whatever value of `n'.
/*
* We need to deal in a special way with the twilight zone.
* Otherwise, by definition, the value of CUR.twilight.orus[n] is (0,0),
* for every n.
*/
if ( CUR.GS.gep0 == 0 || CUR.GS.gep1 == 0 || CUR.GS.gep2 == 0 )
{
FT_ARRAY_COPY( CUR.twilight.orus,
CUR.twilight.org,
CUR.twilight.n_points );
}
twilight = CUR.GS.gep0 == 0 || CUR.GS.gep1 == 0 || CUR.GS.gep2 == 0;
#endif /* FIX_BYTECODE */
if ( twilight )
orus_base = &CUR.zp0.org[CUR.GS.rp1];
else
orus_base = &CUR.zp0.orus[CUR.GS.rp1];
/* XXX: There are some glyphs in some braindead but popular */
/* fonts out there (e.g. [aeu]grave in monotype.ttf) */
/* calling IP[] with bad values of rp[12]. */
/* Do something sane when this odd thing happens. */
cur_base = &CUR.zp0.cur[CUR.GS.rp1];
/* XXX: There are some glyphs in some braindead but popular */
/* fonts out there (e.g. [aeu]grave in monotype.ttf) */
/* calling IP[] with bad values of rp[12]. */
/* Do something sane when this odd thing happens. */
if ( BOUNDS( CUR.GS.rp1, CUR.zp0.n_points ) ||
BOUNDS( CUR.GS.rp2, CUR.zp1.n_points ) )
{
org_a = cur_a = 0;
org_b = cur_b = 0;
old_range = 0;
cur_range = 0;
}
else
{
if ( twilight )
old_range = CUR_Func_dualproj( &CUR.zp1.org[CUR.GS.rp2],
orus_base );
else
old_range = CUR_Func_dualproj( &CUR.zp1.orus[CUR.GS.rp2],
orus_base );
#ifdef FIX_BYTECODE
FT_Vector vec1, vec2;
vec1 = CUR.zp0.orus[CUR.GS.rp1];
vec2 = CUR.zp1.orus[CUR.GS.rp2];
vec1.x = TT_MULFIX( vec1.x, CUR.metrics.x_scale );
vec1.y = TT_MULFIX( vec1.y, CUR.metrics.y_scale );
vec2.x = TT_MULFIX( vec2.x, CUR.metrics.x_scale );
vec2.y = TT_MULFIX( vec2.y, CUR.metrics.y_scale );
org_a = CUR_Func_dualproj( &vec1, NULL_Vector );
org_b = CUR_Func_dualproj( &vec2, NULL_Vector );
#else
org_a = CUR_Func_dualproj( CUR.zp0.org + CUR.GS.rp1, NULL_Vector );
org_b = CUR_Func_dualproj( CUR.zp1.org + CUR.GS.rp2, NULL_Vector );
#endif /* FIX_BYTECODE */
cur_a = CUR_Func_project( CUR.zp0.cur + CUR.GS.rp1, NULL_Vector );
cur_b = CUR_Func_project( CUR.zp1.cur + CUR.GS.rp2, NULL_Vector );
cur_range = CUR_Func_project ( &CUR.zp1.cur[CUR.GS.rp2], cur_base );
}
while ( CUR.GS.loop > 0 )
for ( ; CUR.GS.loop > 0; --CUR.GS.loop )
{
CUR.args--;
FT_UInt point = (FT_UInt)CUR.stack[--CUR.args];
FT_F26Dot6 org_dist, cur_dist, new_dist;
point = (FT_UShort)CUR.stack[CUR.args];
/* check point bounds */
if ( BOUNDS( point, CUR.zp2.n_points ) )
{
if ( CUR.pedantic_hinting )
@ -6199,53 +6200,21 @@
CUR.error = TT_Err_Invalid_Reference;
return;
}
continue;
}
if ( twilight )
org_dist = CUR_Func_dualproj( &CUR.zp2.org[point], orus_base );
else
{
org_dist = CUR_Func_dualproj( &CUR.zp2.orus[point], orus_base );
#ifdef FIX_BYTECODE
cur_dist = CUR_Func_project ( &CUR.zp2.cur[point], cur_base );
new_dist = ( old_range != 0 )
? TT_MULDIV( org_dist, cur_range, old_range )
: cur_dist;
FT_Vector vec;
vec = CUR.zp2.orus[point];
vec.x = TT_MULFIX( vec.x, CUR.metrics.x_scale );
vec.y = TT_MULFIX( vec.y, CUR.metrics.y_scale );
org_x = CUR_Func_dualproj( &vec, NULL_Vector );
#else
org_x = CUR_Func_dualproj( CUR.zp2.org + point, NULL_Vector );
#endif /* FIX_BYTECODE */
cur_x = CUR_Func_project ( CUR.zp2.cur + point, NULL_Vector );
if ( ( org_a <= org_b && org_x <= org_a ) ||
( org_a > org_b && org_x >= org_a ) )
distance = ( cur_a - org_a ) + ( org_x - cur_x );
else if ( ( org_a <= org_b && org_x >= org_b ) ||
( org_a > org_b && org_x < org_b ) )
distance = ( cur_b - org_b ) + ( org_x - cur_x );
else if ( org_b != org_a )
/* note: it seems that rounding this value isn't a good */
/* idea (cf. width of capital `S' in Times) */
distance = TT_MULDIV( cur_b - cur_a,
org_x - org_a,
org_b - org_a ) + ( cur_a - cur_x );
CUR_Func_move( &CUR.zp2, point, distance );
}
CUR.GS.loop--;
CUR_Func_move( &CUR.zp2, point, new_dist - cur_dist );
}
CUR.GS.loop = 1;
CUR.new_top = CUR.args;
}
@ -6453,7 +6422,7 @@
end_point = CUR.pts.contours[contour] - CUR.pts.first_point;
first_point = point;
while ( point <= end_point && (CUR.pts.tags[point] & mask) == 0 )
while ( point <= end_point && ( CUR.pts.tags[point] & mask ) == 0 )
point++;
if ( point <= end_point )
@ -7072,7 +7041,7 @@
/* - After executing one single opcode, if the flag `Instruction_Trap' */
/* is set to TRUE (returns TRUE). */
/* */
/* On exit whith TRUE, test IP < CodeSize to know wether it comes from */
/* On exit with TRUE, test IP < CodeSize to know whether it comes from */
/* an instruction trap or a normal termination. */
/* */
/* */

View File

@ -4,7 +4,7 @@
/* */
/* TrueType bytecode interpreter (specification). */
/* */
/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006 by */
/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006, 2007 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@ -19,7 +19,6 @@
#ifndef __TTINTERP_H__
#define __TTINTERP_H__
#include <ft2build.h>
#include "ttobjs.h"
@ -79,8 +78,8 @@ FT_BEGIN_HEADER
/* Distance projection along one of the projection vectors */
typedef FT_F26Dot6
(*TT_Project_Func)( EXEC_OP_ FT_Vector* v1,
FT_Vector* v2 );
(*TT_Project_Func)( EXEC_OP_ FT_Pos dx,
FT_Pos dy );
/* reading a cvt value. Take care of non-square pixels if necessary */
typedef FT_F26Dot6

View File

@ -283,8 +283,8 @@
/* be worth to do more checks for a few special cases. */
for ( nn = 0; trick_names[nn] != NULL; nn++ )
{
if ( ttface->family_name &&
ft_strcmp( ttface->family_name, trick_names[nn] ) == 0 )
if ( ttface->family_name &&
ft_strstr( ttface->family_name, trick_names[nn] ) )
{
unpatented_hinting = 1;
break;
@ -595,10 +595,9 @@
/* Set default metrics */
{
FT_Size_Metrics* metrics = &size->root.metrics;
FT_Size_Metrics* metrics = &size->metrics;
TT_Size_Metrics* metrics2 = &size->ttmetrics;
metrics->x_ppem = 0;
metrics->y_ppem = 0;
@ -704,7 +703,7 @@
FT_LOCAL_DEF( FT_Error )
tt_size_ready_bytecode( TT_Size size )
{
FT_UNUSED( ftsize );
FT_UNUSED( size );
return 0;
}

View File

@ -193,7 +193,7 @@
kp->index1 = FT_Get_Char_Index( t1_face, p[0] );
kp->index2 = FT_Get_Char_Index( t1_face, p[1] );
kp->x = (FT_Int)FT_PEEK_USHORT_LE(p + 2);
kp->x = (FT_Int)FT_PEEK_SHORT_LE(p + 2);
kp->y = 0;
kp++;

View File

@ -4,7 +4,7 @@
/* */
/* Type 1 driver interface (body). */
/* */
/* Copyright 1996-2001, 2002, 2003, 2004, 2006 by */
/* Copyright 1996-2001, 2002, 2003, 2004, 2006, 2007 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@ -59,22 +59,7 @@
FT_Pointer buffer,
FT_UInt buffer_max )
{
FT_String* gname;
gname = face->type1.glyph_names[glyph_index];
if ( buffer_max > 0 )
{
FT_UInt len = (FT_UInt)( ft_strlen( gname ) );
if (len >= buffer_max)
len = buffer_max - 1;
FT_MEM_COPY( buffer, gname, len );
((FT_Byte*)buffer)[len] = 0;
}
FT_STRCPYN( buffer, face->type1.glyph_names[glyph_index], buffer_max );
return T1_Err_Ok;
}

View File

@ -1885,7 +1885,7 @@
/* Font Installation for ATM Software) a `begin' */
/* must be followed by exactly one `end', and */
/* `begin' -- `end' pairs must be accurately */
/* paired. We could use this to dinstinguish */
/* paired. We could use this to distinguish */
/* between the global Private and the Private */
/* dict that is a member of the Blend dict. */

View File

@ -4,7 +4,7 @@
/* */
/* Type 1 font loader (specification). */
/* */
/* Copyright 1996-2001, 2002, 2004, 2006 by */
/* Copyright 1996-2001, 2002, 2004, 2006, 2007 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@ -54,7 +54,7 @@ FT_BEGIN_HEADER
/* treatment of some keywords differs depending on whether */
/* they preceed or follow certain other keywords */
/* they precede or follow certain other keywords */
#define T1_PRIVATE ( 1 << 0 )
#define T1_FONTDIR_AFTER_PRIVATE ( 1 << 1 )

View File

@ -4,7 +4,7 @@
/* */
/* High-level Type 42 driver interface (body). */
/* */
/* Copyright 2002, 2003, 2004, 2006 by Roberto Alameda. */
/* Copyright 2002, 2003, 2004, 2006, 2007 by Roberto Alameda. */
/* */
/* This file is part of the FreeType project, and may only be used, */
/* modified, and distributed under the terms of the FreeType project */
@ -61,22 +61,7 @@
FT_Pointer buffer,
FT_UInt buffer_max )
{
FT_String* gname;
gname = face->type1.glyph_names[glyph_index];
if ( buffer_max > 0 )
{
FT_UInt len = (FT_UInt)( ft_strlen( gname ) );
if ( len >= buffer_max )
len = buffer_max - 1;
FT_MEM_COPY( buffer, gname, len );
((FT_Byte*)buffer)[len] = 0;
}
FT_STRCPYN( buffer, face->type1.glyph_names[glyph_index], buffer_max );
return T42_Err_Ok;
}
@ -94,7 +79,7 @@
{
gname = face->type1.glyph_names[i];
if ( !ft_strcmp( glyph_name, gname ) )
if ( glyph_name[0] == gname[0] && !ft_strcmp( glyph_name, gname ) )
return (FT_UInt)ft_atol( (const char *)face->type1.charstrings[i] );
}