[FREETYPE] Update to v2.7.0. CORE-11639

svn path=/trunk/; revision=72670
This commit is contained in:
Amine Khaldi
2016-09-14 10:01:27 +00:00
parent 019c2ecb53
commit fd3e47079c
57 changed files with 1836 additions and 5994 deletions
+1 -1
View File
@@ -23,7 +23,7 @@ Used Version: 1.1
Website: http://www.geocities.com/dborca/opengl/tc.html
Title: FreeType
Used Version: 2.6.4
Used Version: 2.7.0
Website: http://www.freetype.org
Title: Mesa3D
File diff suppressed because it is too large Load Diff
+5 -5
View File
@@ -1,5 +1,5 @@
FreeType 2.6.4
==============
FreeType 2.7
============
Homepage: http://www.freetype.org
@@ -24,9 +24,9 @@
and download one of the following files.
freetype-doc-2.6.4.tar.bz2
freetype-doc-2.6.4.tar.gz
ftdoc264.zip
freetype-doc-2.7.tar.bz2
freetype-doc-2.7.tar.gz
ftdoc27.zip
To view the documentation online, go to
+45 -1
View File
@@ -75,6 +75,36 @@ FT_BEGIN_HEADER
/*************************************************************************/
/*************************************************************************/
/* */
/* If you enable this configuration option, FreeType recognizes an */
/* environment variable called `FREETYPE_PROPERTIES', which can be used */
/* to control the various font drivers and modules. The controllable */
/* properties are listed in the section `Controlling FreeType Modules' */
/* in the reference's table of contents; currently there are properties */
/* for the auto-hinter (file `ftautoh.h'), CFF (file `ftcffdrv.h'), and */
/* TrueType (file `ftttdrv.h'). */
/* */
/* `FREETYPE_PROPERTIES' has the following syntax form (broken here into */
/* multiple lines for better readability). */
/* */
/* <optional whitespace> */
/* <module-name1> ':' */
/* <property-name1> '=' <property-value1> */
/* <whitespace> */
/* <module-name2> ':' */
/* <property-name2> '=' <property-value2> */
/* ... */
/* */
/* Example: */
/* */
/* FREETYPE_PROPERTIES=truetype:interpreter-version=35 \ */
/* cff:no-stem-darkening=1 \ */
/* autofitter:warping=1 */
/* */
//#define FT_CONFIG_OPTION_ENVIRONMENT_PROPERTIES
/*************************************************************************/
/* */
/* Uncomment the line below if you want to activate sub-pixel rendering */
@@ -492,7 +522,21 @@ FT_BEGIN_HEADER
/* code will be used. */
/* */
/* Setting this macro is needed for systems that prohibit address */
/* fixups, such as BREW. */
/* fixups, such as BREW. [Note that standard compilers like gcc or */
/* clang handle PIC generation automatically; you don't have to set */
/* FT_CONFIG_OPTION_PIC, which is only necessary for very special */
/* compilers.] */
/* */
/* Note that FT_CONFIG_OPTION_PIC support is not available for all */
/* modules (see `modules.cfg' for a complete list). For building with */
/* FT_CONFIG_OPTION_PIC support, do the following. */
/* */
/* 0. Clone the repository. */
/* 1. Define FT_CONFIG_OPTION_PIC. */
/* 2. Remove all subdirectories in `src' that don't have */
/* FT_CONFIG_OPTION_PIC support. */
/* 3. Comment out the corresponding modules in `modules.cfg'. */
/* 4. Compile. */
/* */
/* #define FT_CONFIG_OPTION_PIC */
@@ -75,6 +75,36 @@ FT_BEGIN_HEADER
/*************************************************************************/
/*************************************************************************/
/* */
/* If you enable this configuration option, FreeType recognizes an */
/* environment variable called `FREETYPE_PROPERTIES', which can be used */
/* to control the various font drivers and modules. The controllable */
/* properties are listed in the section `Controlling FreeType Modules' */
/* in the reference's table of contents; currently there are properties */
/* for the auto-hinter (file `ftautoh.h'), CFF (file `ftcffdrv.h'), and */
/* TrueType (file `ftttdrv.h'). */
/* */
/* `FREETYPE_PROPERTIES' has the following syntax form (broken here into */
/* multiple lines for better readability). */
/* */
/* <optional whitespace> */
/* <module-name1> ':' */
/* <property-name1> '=' <property-value1> */
/* <whitespace> */
/* <module-name2> ':' */
/* <property-name2> '=' <property-value2> */
/* ... */
/* */
/* Example: */
/* */
/* FREETYPE_PROPERTIES=truetype:interpreter-version=35 \ */
/* cff:no-stem-darkening=1 \ */
/* autofitter:warping=1 */
/* */
//#define FT_CONFIG_OPTION_ENVIRONMENT_PROPERTIES
/*************************************************************************/
/* */
/* Uncomment the line below if you want to activate sub-pixel rendering */
@@ -492,7 +522,21 @@ FT_BEGIN_HEADER
/* code will be used. */
/* */
/* Setting this macro is needed for systems that prohibit address */
/* fixups, such as BREW. */
/* fixups, such as BREW. [Note that standard compilers like gcc or */
/* clang handle PIC generation automatically; you don't have to set */
/* FT_CONFIG_OPTION_PIC, which is only necessary for very special */
/* compilers.] */
/* */
/* Note that FT_CONFIG_OPTION_PIC support is not available for all */
/* modules (see `modules.cfg' for a complete list). For building with */
/* FT_CONFIG_OPTION_PIC support, do the following. */
/* */
/* 0. Clone the repository. */
/* 1. Define FT_CONFIG_OPTION_PIC. */
/* 2. Remove all subdirectories in `src' that don't have */
/* FT_CONFIG_OPTION_PIC support. */
/* 3. Comment out the corresponding modules in `modules.cfg'. */
/* 4. Compile. */
/* */
/* #define FT_CONFIG_OPTION_PIC */
@@ -630,8 +674,8 @@ FT_BEGIN_HEADER
/* */
/* [1] http://www.microsoft.com/typography/cleartype/truetypecleartype.aspx */
/* */
/* #define TT_CONFIG_OPTION_SUBPIXEL_HINTING 1 */
#define TT_CONFIG_OPTION_SUBPIXEL_HINTING 2
/* #define TT_CONFIG_OPTION_SUBPIXEL_HINTING 1 */
#define TT_CONFIG_OPTION_SUBPIXEL_HINTING 2
/* #define TT_CONFIG_OPTION_SUBPIXEL_HINTING ( 1 | 2 ) */
@@ -142,7 +142,8 @@
/**********************************************************************/
#define ft_atol atol
#define ft_strtol strtol
#define ft_getenv getenv
/**********************************************************************/
+41 -11
View File
@@ -1358,6 +1358,20 @@ FT_BEGIN_HEADER
( (face)->face_flags & FT_FACE_FLAG_MULTIPLE_MASTERS )
/*************************************************************************
*
* @macro:
* FT_IS_NAMED_INSTANCE( face )
*
* @description:
* A macro that returns true whenever a face object is a named instance
* of a GX variation font.
*
*/
#define FT_IS_NAMED_INSTANCE( face ) \
( (face)->face_index & 0x7FFF0000L )
/*************************************************************************
*
* @macro:
@@ -2331,13 +2345,22 @@ FT_BEGIN_HEADER
/* FT_Size_Request_Type */
/* */
/* <Description> */
/* An enumeration type that lists the supported size request types. */
/* An enumeration type that lists the supported size request types, */
/* i.e., what input size (in font units) maps to the requested output */
/* size (in pixels, as computed from the arguments of */
/* @FT_Size_Request). */
/* */
/* <Values> */
/* FT_SIZE_REQUEST_TYPE_NOMINAL :: */
/* The nominal size. The `units_per_EM' field of @FT_FaceRec is */
/* used to determine both scaling values. */
/* */
/* This is the standard scaling found in most applications. In */
/* particular, use this size request type for TrueType fonts if */
/* they provide optical scaling or something similar. Note, */
/* however, that `units_per_EM' is a rather abstract value which */
/* bears no relation to the actual size of the glyphs in a font. */
/* */
/* FT_SIZE_REQUEST_TYPE_REAL_DIM :: */
/* The real dimension. The sum of the `ascender' and (minus of) */
/* the `descender' fields of @FT_FaceRec are used to determine both */
@@ -2391,22 +2414,29 @@ FT_BEGIN_HEADER
/* <Fields> */
/* type :: See @FT_Size_Request_Type. */
/* */
/* width :: The desired width. */
/* width :: The desired width, given as a 26.6 fractional */
/* point value (with 72pt = 1in). */
/* */
/* height :: The desired height. */
/* height :: The desired height, given as a 26.6 fractional */
/* point value (with 72pt = 1in). */
/* */
/* horiResolution :: The horizontal resolution. If set to zero, */
/* `width' is treated as a 26.6 fractional pixel */
/* value. */
/* horiResolution :: The horizontal resolution (dpi, i.e., pixels per */
/* inch). If set to zero, `width' is treated as a */
/* 26.6 fractional *pixel* value. */
/* */
/* vertResolution :: The vertical resolution. If set to zero, */
/* `height' is treated as a 26.6 fractional pixel */
/* value. */
/* vertResolution :: The vertical resolution (dpi, i.e., pixels per */
/* inch). If set to zero, `height' is treated as a */
/* 26.6 fractional *pixel* value. */
/* */
/* <Note> */
/* If `width' is zero, then the horizontal scaling value is set equal */
/* to the vertical scaling value, and vice versa. */
/* */
/* If `type' is FT_SIZE_REQUEST_TYPE_SCALES, `width' and `height' are */
/* interpreted directly as 16.16 fractional scaling values, without */
/* any further modification, and both `horiResolution' and */
/* `vertResolution' are ignored. */
/* */
typedef struct FT_Size_RequestRec_
{
FT_Size_Request_Type type;
@@ -4175,8 +4205,8 @@ FT_BEGIN_HEADER
*
*/
#define FREETYPE_MAJOR 2
#define FREETYPE_MINOR 6
#define FREETYPE_PATCH 4
#define FREETYPE_MINOR 7
#define FREETYPE_PATCH 0
/*************************************************************************/
@@ -428,6 +428,9 @@ FT_BEGIN_HEADER
* @note:
* This property can be used with @FT_Property_Get also.
*
* This property can be set via the `FREETYPE_PROPERTIES' environment
* variable (using values 1 and 0 for `on' and `off', respectively).
*
* The warping code can also change advance widths. Have a look at the
* `lsb_delta' and `rsb_delta' fields in the @FT_GlyphSlotRec structure
* for details on improving inter-glyph distances while rendering.
@@ -473,6 +476,9 @@ FT_BEGIN_HEADER
* The smaller the size (especially 9ppem and down), the higher the loss
* of emboldening versus the CFF driver.
*
* This property can be set via the `FREETYPE_PROPERTIES' environment
* variable similar to the CFF driver.
*
*/
@@ -489,6 +495,8 @@ FT_BEGIN_HEADER
* CFF_CONFIG_OPTION_DARKENING_PARAMETER_* #defines for consistency.
* Note the differences described in @no-stem-darkening[autofit].
*
* This property can be set via the `FREETYPE_PROPERTIES' environment
* variable similar to the CFF driver.
*/
@@ -148,6 +148,8 @@ FT_BEGIN_HEADER
* @note:
* This property can be used with @FT_Property_Get also.
*
* This property can be set via the `FREETYPE_PROPERTIES' environment
* variable (using values `adobe' or `freetype').
*/
@@ -199,6 +201,9 @@ FT_BEGIN_HEADER
* @note:
* This property can be used with @FT_Property_Get also.
*
* This property can be set via the `FREETYPE_PROPERTIES' environment
* variable (using values 1 and 0 for `on' and `off', respectively).
*
*/
@@ -248,6 +253,14 @@ FT_BEGIN_HEADER
* @note:
* This property can be used with @FT_Property_Get also.
*
* This property can be set via the `FREETYPE_PROPERTIES' environment
* variable, using eight comma-separated integers without spaces. Here
* the above example, using `\' to break the line for readability.
*
* {
* FREETYPE_PROPERTIES=\
* cff:darkening-parameters=500,300,1000,200,1500,100,2000,0
* }
*/
/* */
@@ -860,16 +860,6 @@ FT_BEGIN_HEADER
/* This can be used to write anti-aliased outlines directly to a */
/* given background bitmap, and even perform translucency. */
/* */
/* Note that the `count' field cannot be greater than a fixed value */
/* defined by the `FT_MAX_GRAY_SPANS' configuration macro in */
/* `ftoption.h'. By default, this value is set to~32, which means */
/* that if there are more than 32~spans on a given scanline, the */
/* callback is called several times with the same `y' parameter in */
/* order to draw all callbacks. */
/* */
/* Otherwise, the callback is only called once per scan-line, and */
/* only for those scanlines that do have `gray' pixels on them. */
/* */
typedef void
(*FT_SpanFunc)( int y,
int count,
+9 -5
View File
@@ -195,11 +195,15 @@ FT_BEGIN_HEADER
/* (where every glyph could have a different */
/* number of designs). */
/* */
/* num_namedstyles :: The number of named styles; only meaningful for */
/* GX that allows certain design coordinates to */
/* have a string ID (in the `name' table) */
/* associated with them. The font can tell the */
/* user that, for example, Weight=1.5 is `Bold'. */
/* num_namedstyles :: The number of named styles; a `named style' is */
/* a tuple of design coordinates that has a string */
/* ID (in the `name' table) associated with it. */
/* The font can tell the user that, for example, */
/* [Weight=1.5,Width=1.1] is `Bold'. */
/* */
/* For Type 1 Multiple Masters fonts, this value */
/* is always zero because the format does not */
/* support named styles. */
/* */
/* axis :: An axis descriptor table. */
/* GX fonts contain slightly more data than MM. */
@@ -115,6 +115,10 @@ FT_BEGIN_HEADER
/* outline for stroking purposes (otherwise it would result in a */
/* visible dot when round caps are used). */
/* */
/* Similarly, the function returns success for an empty outline also */
/* (doing nothing, this is, not calling any emitter); if necessary, */
/* you should filter this out, too. */
/* */
FT_EXPORT( FT_Error )
FT_Outline_Decompose( FT_Outline* outline,
const FT_Outline_Funcs* func_interface,
@@ -213,6 +217,10 @@ FT_BEGIN_HEADER
/* <Return> */
/* FreeType error code. 0~means success. */
/* */
/* <Note> */
/* An empty outline, or an outline with a single point only is also */
/* valid. */
/* */
FT_EXPORT( FT_Error )
FT_Outline_Check( FT_Outline* outline );
@@ -181,6 +181,8 @@ FT_BEGIN_HEADER
* @note:
* This property can be used with @FT_Property_Get also.
*
* This property can be set via the `FREETYPE_PROPERTIES' environment
* variable (using values `35', `38', or `40').
*/
@@ -67,15 +67,6 @@ FT_BEGIN_HEADER
FT_Int32 load_flags );
typedef FT_UInt
(*FT_CharMap_CharIndexFunc)( FT_CharMap charmap,
FT_Long charcode );
typedef FT_Long
(*FT_CharMap_CharNextFunc)( FT_CharMap charmap,
FT_Long charcode );
typedef FT_Error
(*FT_Face_GetKerningFunc)( FT_Face face,
FT_UInt left_glyph,
@@ -108,10 +108,12 @@ extern "C++"
/*
* The allocation functions return a pointer, and the error code
* is written to through the `p_error' parameter. See below for
* for documentation.
* is written to through the `p_error' parameter.
*/
/* The `q' variants of the functions below (`q' for `quick') don't fill */
/* the allocated or reallocated memory with zero bytes. */
FT_BASE( FT_Pointer )
ft_mem_alloc( FT_Memory memory,
FT_Long size,
@@ -143,6 +145,9 @@ extern "C++"
const void* P );
/* The `Q' variants of the macros below (`Q' for `quick') don't fill */
/* the allocated or reallocated memory with zero bytes. */
#define FT_MEM_ALLOC( ptr, size ) \
FT_ASSIGNP_INNER( ptr, ft_mem_alloc( memory, \
(FT_Long)(size), \
@@ -532,6 +532,14 @@ FT_BEGIN_HEADER
ft_module_get_service( FT_Module module,
const char* service_id );
#ifdef FT_CONFIG_OPTION_ENVIRONMENT_PROPERTIES
FT_BASE( FT_Error )
ft_property_string_set( FT_Library library,
const FT_String* module_name,
const FT_String* property_name,
FT_String* value );
#endif
/* */
@@ -29,7 +29,8 @@ FT_BEGIN_HEADER
typedef FT_Error
(*FT_Properties_SetFunc)( FT_Module module,
const char* property_name,
const void* value );
const void* value,
FT_Bool value_is_string );
typedef FT_Error
(*FT_Properties_GetFunc)( FT_Module module,
@@ -1393,6 +1393,12 @@ FT_BEGIN_HEADER
FT_Bool sph_compatibility_mode;
#endif /* TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY */
#ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS
/* since 2.7 */
FT_ULong ebdt_start; /* either `CBDT', `EBDT', or `bdat' */
FT_ULong ebdt_size;
#endif
} TT_FaceRec;
+15
View File
@@ -37,6 +37,7 @@ FONT_MODULES += truetype
# PostScript Type 1 font driver.
#
# This driver needs the `psaux', `pshinter', and `psnames' modules.
# No FT_CONFIG_OPTION_PIC support.
FONT_MODULES += type1
# CFF/OpenType font driver.
@@ -47,24 +48,30 @@ FONT_MODULES += cff
# Type 1 CID-keyed font driver.
#
# This driver needs the `psaux', `pshinter', and `psnames' modules.
# No FT_CONFIG_OPTION_PIC support.
FONT_MODULES += cid
# PFR/TrueDoc font driver. See optional extension ftpfr.c below also.
# No FT_CONFIG_OPTION_PIC support.
FONT_MODULES += pfr
# PostScript Type 42 font driver.
#
# This driver needs the `truetype' and `psaux' modules.
# No FT_CONFIG_OPTION_PIC support.
FONT_MODULES += type42
# Windows FONT/FNT font driver. See optional extension ftwinfnt.c below
# also.
# No FT_CONFIG_OPTION_PIC support.
FONT_MODULES += winfonts
# PCF font driver.
# No FT_CONFIG_OPTION_PIC support.
FONT_MODULES += pcf
# BDF font driver. See optional extension ftbdf.c below also.
# No FT_CONFIG_OPTION_PIC support.
FONT_MODULES += bdf
# SFNT files support. If used without `truetype' or `cff', it supports
@@ -107,33 +114,41 @@ RASTER_MODULES += smooth
# FreeType's cache sub-system (quite stable but still in beta -- this means
# that its public API is subject to change if necessary). See
# include/freetype/ftcache.h. Needs ftglyph.c.
# No FT_CONFIG_OPTION_PIC support.
AUX_MODULES += cache
# TrueType GX/AAT table validation. Needs ftgxval.c below.
#
# No FT_CONFIG_OPTION_PIC support.
# AUX_MODULES += gxvalid
# Support for streams compressed with gzip (files with suffix .gz).
#
# See include/freetype/ftgzip.h for the API.
# No FT_CONFIG_OPTION_PIC support.
AUX_MODULES += gzip
# Support for streams compressed with LZW (files with suffix .Z).
#
# See include/freetype/ftlzw.h for the API.
# No FT_CONFIG_OPTION_PIC support.
AUX_MODULES += lzw
# Support for streams compressed with bzip2 (files with suffix .bz2).
#
# See include/freetype/ftbzip2.h for the API.
# No FT_CONFIG_OPTION_PIC support.
AUX_MODULES += bzip2
# OpenType table validation. Needs ftotval.c below.
#
# No FT_CONFIG_OPTION_PIC support.
# AUX_MODULES += otvalid
# Auxiliary PostScript driver component to share common code.
#
# This module depends on `psnames'.
# No FT_CONFIG_OPTION_PIC support.
AUX_MODULES += psaux
# Support for PostScript glyph names.
+4 -4
View File
@@ -32,13 +32,13 @@
'\0',
'\xD9', '\x80', /* ـ */
'\0',
'\xD4', '\xB1', ' ', '\xD5', '\x84', ' ', '\xD5', '\x92', ' ', '\xD5', '\x93', ' ', '\xD4', '\xB2', ' ', '\xD4', '\xB3', ' ', '\xD4', '\xB4', ' ', '\xD5', '\x95', /* Ա Մ Ւ Փ Բ Գ Դ Օ */
'\xD4', '\xB1', ' ', '\xD5', '\x84', ' ', '\xD5', '\x92', ' ', '\xD5', '\x8D', ' ', '\xD4', '\xB2', ' ', '\xD4', '\xB3', ' ', '\xD4', '\xB4', ' ', '\xD5', '\x95', /* Ա Մ Ւ Ս Բ Գ Դ Օ */
'\0',
'\xD5', '\x92', ' ', '\xD5', '\x88', ' ', '\xD5', '\x93', ' ', '\xD5', '\x83', ' ', '\xD5', '\x87', ' ', '\xD5', '\x8D', ' ', '\xD5', '\x8F', ' ', '\xD5', '\x95', /* Ւ Ո Փ Ճ Շ Ս Տ Օ */
'\xD5', '\x92', ' ', '\xD5', '\x88', ' ', '\xD4', '\xB4', ' ', '\xD5', '\x83', ' ', '\xD5', '\x87', ' ', '\xD5', '\x8D', ' ', '\xD5', '\x8F', ' ', '\xD5', '\x95', /* Ւ Ո Դ Ճ Շ Ս Տ Օ */
'\0',
'\xD5', '\xA5', ' ', '\xD5', '\xA7', ' ', '\xD5', '\xAB', ' ', '\xD5', '\xB4', ' ', '\xD5', '\xBE', ' ', '\xD6', '\x83', ' ', '\xD6', '\x86', ' ', '\xD6', '\x83', /* ե է ի մ վ փ ֆ փ */
'\xD5', '\xA5', ' ', '\xD5', '\xA7', ' ', '\xD5', '\xAB', ' ', '\xD5', '\xB4', ' ', '\xD5', '\xBE', ' ', '\xD6', '\x86', ' ', '\xD5', '\xB3', /* ե է ի մ վ ֆ ճ */
'\0',
'\xD5', '\xA1', ' ', '\xD5', '\xB5', ' ', '\xD6', '\x82', ' ', '\xD5', '\xBD', ' ', '\xD5', '\xA3', ' ', '\xD5', '\xBB', ' ', '\xD6', '\x80', ' ', '\xD6', '\x85', /* ա յ ւ ս գ ջ ր օ */
'\xD5', '\xA1', ' ', '\xD5', '\xB5', ' ', '\xD6', '\x82', ' ', '\xD5', '\xBD', ' ', '\xD5', '\xA3', ' ', '\xD5', '\xB7', ' ', '\xD6', '\x80', ' ', '\xD6', '\x85', /* ա յ ւ ս գ շ ր օ */
'\0',
'\xD5', '\xB0', ' ', '\xD5', '\xB8', ' ', '\xD5', '\xB3', ' ', '\xD5', '\xA1', ' ', '\xD5', '\xA5', ' ', '\xD5', '\xAE', ' ', '\xD5', '\xBD', ' ', '\xD6', '\x85', /* հ ո ճ ա ե ծ ս օ */
'\0',
+4 -4
View File
@@ -87,13 +87,13 @@ AF_BLUE_STRING_ENUM AF_BLUE_STRINGS_ARRAY AF_BLUE_STRING_MAX_LEN:
"ـ"
AF_BLUE_STRING_ARMENIAN_CAPITAL_TOP
"Ա Մ Ւ Փ Բ Գ Դ Օ"
"Ա Մ Ւ Ս Բ Գ Դ Օ"
AF_BLUE_STRING_ARMENIAN_CAPITAL_BOTTOM
"Ւ Ո Փ Ճ Շ Ս Տ Օ"
"Ւ Ո Դ Ճ Շ Ս Տ Օ"
AF_BLUE_STRING_ARMENIAN_SMALL_ASCENDER
"ե է ի մ վ փ ֆ փ"
"ե է ի մ վ ֆ ճ"
AF_BLUE_STRING_ARMENIAN_SMALL_TOP
"ա յ ւ ս գ ջ ր օ"
"ա յ ւ ս գ շ ր օ"
AF_BLUE_STRING_ARMENIAN_SMALL_BOTTOM
"հ ո ճ ա ե ծ ս օ"
AF_BLUE_STRING_ARMENIAN_SMALL_DESCENDER
+98 -98
View File
@@ -83,104 +83,104 @@ FT_BEGIN_HEADER
AF_BLUE_STRING_ARMENIAN_CAPITAL_TOP = 36,
AF_BLUE_STRING_ARMENIAN_CAPITAL_BOTTOM = 60,
AF_BLUE_STRING_ARMENIAN_SMALL_ASCENDER = 84,
AF_BLUE_STRING_ARMENIAN_SMALL_TOP = 108,
AF_BLUE_STRING_ARMENIAN_SMALL_BOTTOM = 132,
AF_BLUE_STRING_ARMENIAN_SMALL_DESCENDER = 156,
AF_BLUE_STRING_BENGALI_BASE = 180,
AF_BLUE_STRING_BENGALI_TOP = 212,
AF_BLUE_STRING_BENGALI_HEAD = 240,
AF_BLUE_STRING_CHEROKEE_CAPITAL = 272,
AF_BLUE_STRING_CHEROKEE_SMALL_ASCENDER = 304,
AF_BLUE_STRING_CHEROKEE_SMALL = 336,
AF_BLUE_STRING_CHEROKEE_SMALL_DESCENDER = 368,
AF_BLUE_STRING_CYRILLIC_CAPITAL_TOP = 384,
AF_BLUE_STRING_CYRILLIC_CAPITAL_BOTTOM = 408,
AF_BLUE_STRING_CYRILLIC_SMALL = 432,
AF_BLUE_STRING_CYRILLIC_SMALL_DESCENDER = 456,
AF_BLUE_STRING_DEVANAGARI_BASE = 465,
AF_BLUE_STRING_DEVANAGARI_TOP = 497,
AF_BLUE_STRING_DEVANAGARI_HEAD = 529,
AF_BLUE_STRING_DEVANAGARI_BOTTOM = 561,
AF_BLUE_STRING_ETHIOPIC_TOP = 569,
AF_BLUE_STRING_ETHIOPIC_BOTTOM = 601,
AF_BLUE_STRING_GEORGIAN_MKHEDRULI_TOP = 633,
AF_BLUE_STRING_GEORGIAN_MKHEDRULI_BOTTOM = 665,
AF_BLUE_STRING_GEORGIAN_MKHEDRULI_ASCENDER = 697,
AF_BLUE_STRING_GEORGIAN_MKHEDRULI_DESCENDER = 729,
AF_BLUE_STRING_GEORGIAN_ASOMTAVRULI_TOP = 761,
AF_BLUE_STRING_GEORGIAN_ASOMTAVRULI_BOTTOM = 793,
AF_BLUE_STRING_GEORGIAN_NUSKHURI_TOP = 825,
AF_BLUE_STRING_GEORGIAN_NUSKHURI_BOTTOM = 857,
AF_BLUE_STRING_GEORGIAN_NUSKHURI_ASCENDER = 889,
AF_BLUE_STRING_GEORGIAN_NUSKHURI_DESCENDER = 921,
AF_BLUE_STRING_GREEK_CAPITAL_TOP = 953,
AF_BLUE_STRING_GREEK_CAPITAL_BOTTOM = 974,
AF_BLUE_STRING_GREEK_SMALL_BETA_TOP = 992,
AF_BLUE_STRING_GREEK_SMALL = 1010,
AF_BLUE_STRING_GREEK_SMALL_DESCENDER = 1034,
AF_BLUE_STRING_GUJARATI_TOP = 1058,
AF_BLUE_STRING_GUJARATI_BOTTOM = 1090,
AF_BLUE_STRING_GUJARATI_ASCENDER = 1122,
AF_BLUE_STRING_GUJARATI_DESCENDER = 1172,
AF_BLUE_STRING_GUJARATI_DIGIT_TOP = 1205,
AF_BLUE_STRING_GURMUKHI_BASE = 1225,
AF_BLUE_STRING_GURMUKHI_HEAD = 1257,
AF_BLUE_STRING_GURMUKHI_TOP = 1289,
AF_BLUE_STRING_GURMUKHI_BOTTOM = 1321,
AF_BLUE_STRING_GURMUKHI_DIGIT_TOP = 1353,
AF_BLUE_STRING_HEBREW_TOP = 1373,
AF_BLUE_STRING_HEBREW_BOTTOM = 1397,
AF_BLUE_STRING_HEBREW_DESCENDER = 1415,
AF_BLUE_STRING_KANNADA_TOP = 1430,
AF_BLUE_STRING_KANNADA_BOTTOM = 1474,
AF_BLUE_STRING_KHMER_TOP = 1506,
AF_BLUE_STRING_KHMER_SUBSCRIPT_TOP = 1530,
AF_BLUE_STRING_KHMER_BOTTOM = 1570,
AF_BLUE_STRING_KHMER_DESCENDER = 1602,
AF_BLUE_STRING_KHMER_LARGE_DESCENDER = 1636,
AF_BLUE_STRING_KHMER_SYMBOLS_WAXING_TOP = 1723,
AF_BLUE_STRING_KHMER_SYMBOLS_WANING_BOTTOM = 1731,
AF_BLUE_STRING_LAO_TOP = 1739,
AF_BLUE_STRING_LAO_BOTTOM = 1771,
AF_BLUE_STRING_LAO_ASCENDER = 1803,
AF_BLUE_STRING_LAO_LARGE_ASCENDER = 1819,
AF_BLUE_STRING_LAO_DESCENDER = 1831,
AF_BLUE_STRING_LATIN_CAPITAL_TOP = 1855,
AF_BLUE_STRING_LATIN_CAPITAL_BOTTOM = 1871,
AF_BLUE_STRING_LATIN_SMALL_F_TOP = 1887,
AF_BLUE_STRING_LATIN_SMALL = 1901,
AF_BLUE_STRING_LATIN_SMALL_DESCENDER = 1915,
AF_BLUE_STRING_LATIN_SUBS_CAPITAL_TOP = 1925,
AF_BLUE_STRING_LATIN_SUBS_CAPITAL_BOTTOM = 1945,
AF_BLUE_STRING_LATIN_SUBS_SMALL_F_TOP = 1965,
AF_BLUE_STRING_LATIN_SUBS_SMALL = 1985,
AF_BLUE_STRING_LATIN_SUBS_SMALL_DESCENDER = 2021,
AF_BLUE_STRING_LATIN_SUPS_CAPITAL_TOP = 2041,
AF_BLUE_STRING_LATIN_SUPS_CAPITAL_BOTTOM = 2072,
AF_BLUE_STRING_LATIN_SUPS_SMALL_F_TOP = 2101,
AF_BLUE_STRING_LATIN_SUPS_SMALL = 2127,
AF_BLUE_STRING_LATIN_SUPS_SMALL_DESCENDER = 2152,
AF_BLUE_STRING_MALAYALAM_TOP = 2163,
AF_BLUE_STRING_MALAYALAM_BOTTOM = 2207,
AF_BLUE_STRING_MYANMAR_TOP = 2239,
AF_BLUE_STRING_MYANMAR_BOTTOM = 2271,
AF_BLUE_STRING_MYANMAR_ASCENDER = 2303,
AF_BLUE_STRING_MYANMAR_DESCENDER = 2331,
AF_BLUE_STRING_SINHALA_TOP = 2363,
AF_BLUE_STRING_SINHALA_BOTTOM = 2395,
AF_BLUE_STRING_SINHALA_DESCENDER = 2427,
AF_BLUE_STRING_TAMIL_TOP = 2471,
AF_BLUE_STRING_TAMIL_BOTTOM = 2503,
AF_BLUE_STRING_TELUGU_TOP = 2535,
AF_BLUE_STRING_TELUGU_BOTTOM = 2563,
AF_BLUE_STRING_THAI_TOP = 2591,
AF_BLUE_STRING_THAI_BOTTOM = 2615,
AF_BLUE_STRING_THAI_ASCENDER = 2643,
AF_BLUE_STRING_THAI_LARGE_ASCENDER = 2655,
AF_BLUE_STRING_THAI_DESCENDER = 2667,
AF_BLUE_STRING_THAI_LARGE_DESCENDER = 2683,
AF_BLUE_STRING_THAI_DIGIT_TOP = 2691,
af_blue_1_1 = 2702,
AF_BLUE_STRING_ARMENIAN_SMALL_TOP = 105,
AF_BLUE_STRING_ARMENIAN_SMALL_BOTTOM = 129,
AF_BLUE_STRING_ARMENIAN_SMALL_DESCENDER = 153,
AF_BLUE_STRING_BENGALI_BASE = 177,
AF_BLUE_STRING_BENGALI_TOP = 209,
AF_BLUE_STRING_BENGALI_HEAD = 237,
AF_BLUE_STRING_CHEROKEE_CAPITAL = 269,
AF_BLUE_STRING_CHEROKEE_SMALL_ASCENDER = 301,
AF_BLUE_STRING_CHEROKEE_SMALL = 333,
AF_BLUE_STRING_CHEROKEE_SMALL_DESCENDER = 365,
AF_BLUE_STRING_CYRILLIC_CAPITAL_TOP = 381,
AF_BLUE_STRING_CYRILLIC_CAPITAL_BOTTOM = 405,
AF_BLUE_STRING_CYRILLIC_SMALL = 429,
AF_BLUE_STRING_CYRILLIC_SMALL_DESCENDER = 453,
AF_BLUE_STRING_DEVANAGARI_BASE = 462,
AF_BLUE_STRING_DEVANAGARI_TOP = 494,
AF_BLUE_STRING_DEVANAGARI_HEAD = 526,
AF_BLUE_STRING_DEVANAGARI_BOTTOM = 558,
AF_BLUE_STRING_ETHIOPIC_TOP = 566,
AF_BLUE_STRING_ETHIOPIC_BOTTOM = 598,
AF_BLUE_STRING_GEORGIAN_MKHEDRULI_TOP = 630,
AF_BLUE_STRING_GEORGIAN_MKHEDRULI_BOTTOM = 662,
AF_BLUE_STRING_GEORGIAN_MKHEDRULI_ASCENDER = 694,
AF_BLUE_STRING_GEORGIAN_MKHEDRULI_DESCENDER = 726,
AF_BLUE_STRING_GEORGIAN_ASOMTAVRULI_TOP = 758,
AF_BLUE_STRING_GEORGIAN_ASOMTAVRULI_BOTTOM = 790,
AF_BLUE_STRING_GEORGIAN_NUSKHURI_TOP = 822,
AF_BLUE_STRING_GEORGIAN_NUSKHURI_BOTTOM = 854,
AF_BLUE_STRING_GEORGIAN_NUSKHURI_ASCENDER = 886,
AF_BLUE_STRING_GEORGIAN_NUSKHURI_DESCENDER = 918,
AF_BLUE_STRING_GREEK_CAPITAL_TOP = 950,
AF_BLUE_STRING_GREEK_CAPITAL_BOTTOM = 971,
AF_BLUE_STRING_GREEK_SMALL_BETA_TOP = 989,
AF_BLUE_STRING_GREEK_SMALL = 1007,
AF_BLUE_STRING_GREEK_SMALL_DESCENDER = 1031,
AF_BLUE_STRING_GUJARATI_TOP = 1055,
AF_BLUE_STRING_GUJARATI_BOTTOM = 1087,
AF_BLUE_STRING_GUJARATI_ASCENDER = 1119,
AF_BLUE_STRING_GUJARATI_DESCENDER = 1169,
AF_BLUE_STRING_GUJARATI_DIGIT_TOP = 1202,
AF_BLUE_STRING_GURMUKHI_BASE = 1222,
AF_BLUE_STRING_GURMUKHI_HEAD = 1254,
AF_BLUE_STRING_GURMUKHI_TOP = 1286,
AF_BLUE_STRING_GURMUKHI_BOTTOM = 1318,
AF_BLUE_STRING_GURMUKHI_DIGIT_TOP = 1350,
AF_BLUE_STRING_HEBREW_TOP = 1370,
AF_BLUE_STRING_HEBREW_BOTTOM = 1394,
AF_BLUE_STRING_HEBREW_DESCENDER = 1412,
AF_BLUE_STRING_KANNADA_TOP = 1427,
AF_BLUE_STRING_KANNADA_BOTTOM = 1471,
AF_BLUE_STRING_KHMER_TOP = 1503,
AF_BLUE_STRING_KHMER_SUBSCRIPT_TOP = 1527,
AF_BLUE_STRING_KHMER_BOTTOM = 1567,
AF_BLUE_STRING_KHMER_DESCENDER = 1599,
AF_BLUE_STRING_KHMER_LARGE_DESCENDER = 1633,
AF_BLUE_STRING_KHMER_SYMBOLS_WAXING_TOP = 1720,
AF_BLUE_STRING_KHMER_SYMBOLS_WANING_BOTTOM = 1728,
AF_BLUE_STRING_LAO_TOP = 1736,
AF_BLUE_STRING_LAO_BOTTOM = 1768,
AF_BLUE_STRING_LAO_ASCENDER = 1800,
AF_BLUE_STRING_LAO_LARGE_ASCENDER = 1816,
AF_BLUE_STRING_LAO_DESCENDER = 1828,
AF_BLUE_STRING_LATIN_CAPITAL_TOP = 1852,
AF_BLUE_STRING_LATIN_CAPITAL_BOTTOM = 1868,
AF_BLUE_STRING_LATIN_SMALL_F_TOP = 1884,
AF_BLUE_STRING_LATIN_SMALL = 1898,
AF_BLUE_STRING_LATIN_SMALL_DESCENDER = 1912,
AF_BLUE_STRING_LATIN_SUBS_CAPITAL_TOP = 1922,
AF_BLUE_STRING_LATIN_SUBS_CAPITAL_BOTTOM = 1942,
AF_BLUE_STRING_LATIN_SUBS_SMALL_F_TOP = 1962,
AF_BLUE_STRING_LATIN_SUBS_SMALL = 1982,
AF_BLUE_STRING_LATIN_SUBS_SMALL_DESCENDER = 2018,
AF_BLUE_STRING_LATIN_SUPS_CAPITAL_TOP = 2038,
AF_BLUE_STRING_LATIN_SUPS_CAPITAL_BOTTOM = 2069,
AF_BLUE_STRING_LATIN_SUPS_SMALL_F_TOP = 2098,
AF_BLUE_STRING_LATIN_SUPS_SMALL = 2124,
AF_BLUE_STRING_LATIN_SUPS_SMALL_DESCENDER = 2149,
AF_BLUE_STRING_MALAYALAM_TOP = 2160,
AF_BLUE_STRING_MALAYALAM_BOTTOM = 2204,
AF_BLUE_STRING_MYANMAR_TOP = 2236,
AF_BLUE_STRING_MYANMAR_BOTTOM = 2268,
AF_BLUE_STRING_MYANMAR_ASCENDER = 2300,
AF_BLUE_STRING_MYANMAR_DESCENDER = 2328,
AF_BLUE_STRING_SINHALA_TOP = 2360,
AF_BLUE_STRING_SINHALA_BOTTOM = 2392,
AF_BLUE_STRING_SINHALA_DESCENDER = 2424,
AF_BLUE_STRING_TAMIL_TOP = 2468,
AF_BLUE_STRING_TAMIL_BOTTOM = 2500,
AF_BLUE_STRING_TELUGU_TOP = 2532,
AF_BLUE_STRING_TELUGU_BOTTOM = 2560,
AF_BLUE_STRING_THAI_TOP = 2588,
AF_BLUE_STRING_THAI_BOTTOM = 2612,
AF_BLUE_STRING_THAI_ASCENDER = 2640,
AF_BLUE_STRING_THAI_LARGE_ASCENDER = 2652,
AF_BLUE_STRING_THAI_DESCENDER = 2664,
AF_BLUE_STRING_THAI_LARGE_DESCENDER = 2680,
AF_BLUE_STRING_THAI_DIGIT_TOP = 2688,
af_blue_1_1 = 2699,
#ifdef AF_CONFIG_OPTION_CJK
AF_BLUE_STRING_CJK_TOP = af_blue_1_1 + 1,
AF_BLUE_STRING_CJK_BOTTOM = af_blue_1_1 + 203,
+20 -13
View File
@@ -420,20 +420,19 @@
dimension == AF_DIMENSION_HORZ ? "vertical"
: "horizontal" ));
if ( axis->num_segments )
AF_DUMP(( " index pos dir from to"
" link serif edge"
AF_DUMP(( " index pos delta dir from to "
" link serif edge"
" height extra flags\n" ));
else
AF_DUMP(( " (none)\n" ));
for ( seg = segments; seg < limit; seg++ )
AF_DUMP(( " %5d %5.2g %5s %4d %4d"
AF_DUMP(( " %5d %5d %5d %5s %4d %4d"
" %4s %5s %4s"
" %6d %5d %11s\n",
AF_INDEX_NUM( seg, segments ),
dimension == AF_DIMENSION_HORZ
? (int)seg->first->ox / 64.0
: (int)seg->first->oy / 64.0,
seg->pos,
seg->delta,
af_dir_str( (AF_Direction)seg->dir ),
AF_INDEX_NUM( seg->first, points ),
AF_INDEX_NUM( seg->last, points ),
@@ -553,18 +552,26 @@
* note: AF_DIMENSION_HORZ corresponds to _vertical_ edges
* since they have a constant X coordinate.
*/
AF_DUMP(( "Table of %s edges:\n",
dimension == AF_DIMENSION_HORZ ? "vertical"
: "horizontal" ));
if ( dimension == AF_DIMENSION_HORZ )
AF_DUMP(( "Table of %s edges (1px=%.2fu, 10u=%.2fpx):\n",
"vertical",
65536.0 * 64.0 / hints->x_scale,
10.0 * hints->x_scale / 65536.0 / 64.0 ));
else
AF_DUMP(( "Table of %s edges (1px=%.2fu, 10u=%.2fpx):\n",
"horizontal",
65536.0 * 64.0 / hints->y_scale,
10.0 * hints->y_scale / 65536.0 / 64.0 ));
if ( axis->num_edges )
AF_DUMP(( " index pos dir link serif"
" blue opos pos flags\n" ));
AF_DUMP(( " index pos dir link serif"
" blue opos pos flags\n" ));
else
AF_DUMP(( " (none)\n" ));
for ( edge = edges; edge < limit; edge++ )
AF_DUMP(( " %5d %5.2g %5s %4s %5s"
" %c %5.2f %5.2f %11s\n",
AF_DUMP(( " %5d %7.2f %5s %4s %5s"
" %c %7.2f %7.2f %11s\n",
AF_INDEX_NUM( edge, edges ),
(int)edge->opos / 64.0,
af_dir_str( (AF_Direction)edge->dir ),
@@ -260,6 +260,7 @@ FT_BEGIN_HEADER
FT_Byte flags; /* edge/segment flags for this segment */
FT_Char dir; /* segment direction */
FT_Short pos; /* position of segment */
FT_Short delta; /* deviation from segment position */
FT_Short min_coord; /* minimum coordinate of segment */
FT_Short max_coord; /* maximum coordinate of segment */
FT_Short height; /* the hinted segment height */
+19 -10
View File
@@ -1092,7 +1092,7 @@
FT_UInt ppem;
scaled = FT_MulFix( blue->shoot.org, scaler->y_scale );
scaled = FT_MulFix( blue->shoot.org, scale );
ppem = metrics->root.scaler.face->size->metrics.x_ppem;
limit = metrics->root.globals->increase_x_height;
threshold = 40;
@@ -1139,8 +1139,6 @@
if ( dist == 0 )
{
scale = new_scale;
FT_TRACE5((
"af_latin_metrics_scale_dim:"
" x height alignment (style `%s'):\n"
@@ -1148,9 +1146,11 @@
" vertical scaling changed from %.4f to %.4f (by %d%%)\n"
"\n",
af_style_names[metrics->root.style_class->style],
axis->org_scale / 65536.0,
scale / 65536.0,
new_scale / 65536.0,
( fitted - scaled ) * 100 / scaled ));
scale = new_scale;
}
#ifdef FT_DEBUG_LEVEL_TRACE
else
@@ -1552,8 +1552,9 @@
/* points are different: we are just leaving an edge, thus */
/* record a new segment */
segment->last = point;
segment->pos = (FT_Short)( ( min_pos + max_pos ) >> 1 );
segment->last = point;
segment->pos = (FT_Short)( ( min_pos + max_pos ) >> 1 );
segment->delta = (FT_Short)( ( max_pos - min_pos ) >> 1 );
/* a segment is round if either its first or last point */
/* is a control point, and the length of the on points */
@@ -1982,6 +1983,7 @@
FT_Fixed scale;
FT_Pos edge_distance_threshold;
FT_Pos segment_length_threshold;
FT_Pos segment_width_threshold;
axis->num_edges = 0;
@@ -2003,9 +2005,15 @@
* corresponding threshold in font units.
*/
if ( dim == AF_DIMENSION_HORZ )
segment_length_threshold = FT_DivFix( 64, hints->y_scale );
segment_length_threshold = FT_DivFix( 64, hints->y_scale );
else
segment_length_threshold = 0;
segment_length_threshold = 0;
/*
* Similarly, we ignore segments that have a width delta
* larger than 0.5px (i.e., a width larger than 1px).
*/
segment_width_threshold = FT_DivFix( 32, scale );
/*********************************************************************/
/* */
@@ -2038,9 +2046,10 @@
FT_Int ee;
/* ignore too short segments and, in this loop, */
/* one-point segments without a direction */
/* ignore too short segments, too wide ones, and, in this loop, */
/* one-point segments without a direction */
if ( seg->height < segment_length_threshold ||
seg->delta > segment_width_threshold ||
seg->dir == AF_DIR_NONE )
continue;
+110 -18
View File
@@ -107,18 +107,29 @@
static FT_Error
af_property_set( FT_Module ft_module,
const char* property_name,
const void* value )
const void* value,
FT_Bool value_is_string )
{
FT_Error error = FT_Err_Ok;
AF_Module module = (AF_Module)ft_module;
#ifndef FT_CONFIG_OPTION_ENVIRONMENT_PROPERTIES
FT_UNUSED( value_is_string );
#endif
if ( !ft_strcmp( property_name, "fallback-script" ) )
{
FT_UInt* fallback_script = (FT_UInt*)value;
FT_UInt* fallback_script;
FT_UInt ss;
FT_UInt ss;
#ifdef FT_CONFIG_OPTION_ENVIRONMENT_PROPERTIES
if ( value_is_string )
return FT_THROW( Invalid_Argument );
#endif
fallback_script = (FT_UInt*)value;
/* We translate the fallback script to a fallback style that uses */
/* `fallback-script' as its script and `AF_COVERAGE_NONE' as its */
@@ -147,19 +158,33 @@
}
else if ( !ft_strcmp( property_name, "default-script" ) )
{
FT_UInt* default_script = (FT_UInt*)value;
FT_UInt* default_script;
#ifdef FT_CONFIG_OPTION_ENVIRONMENT_PROPERTIES
if ( value_is_string )
return FT_THROW( Invalid_Argument );
#endif
default_script = (FT_UInt*)value;
module->default_script = *default_script;
return error;
}
else if ( !ft_strcmp( property_name, "increase-x-height" ) )
{
FT_Prop_IncreaseXHeight* prop = (FT_Prop_IncreaseXHeight*)value;
FT_Prop_IncreaseXHeight* prop;
AF_FaceGlobals globals;
#ifdef FT_CONFIG_OPTION_ENVIRONMENT_PROPERTIES
if ( value_is_string )
return FT_THROW( Invalid_Argument );
#endif
prop = (FT_Prop_IncreaseXHeight*)value;
error = af_property_get_face_globals( prop->face, &globals, module );
if ( !error )
globals->increase_x_height = prop->limit;
@@ -169,28 +194,77 @@
#ifdef AF_CONFIG_OPTION_USE_WARPER
else if ( !ft_strcmp( property_name, "warping" ) )
{
FT_Bool* warping = (FT_Bool*)value;
#ifdef FT_CONFIG_OPTION_ENVIRONMENT_PROPERTIES
if ( value_is_string )
{
const char* s = (const char*)value;
long w = ft_strtol( s, NULL, 10 );
module->warping = *warping;
if ( w == 0 )
module->warping = 0;
else if ( w == 1 )
module->warping = 1;
else
return FT_THROW( Invalid_Argument );
}
else
#endif
{
FT_Bool* warping = (FT_Bool*)value;
module->warping = *warping;
}
return error;
}
#endif /* AF_CONFIG_OPTION_USE_WARPER */
else if ( !ft_strcmp( property_name, "darkening-parameters" ) )
{
FT_Int* darken_params = (FT_Int*)value;
FT_Int* darken_params;
FT_Int x1, y1, x2, y2, x3, y3, x4, y4;
FT_Int x1 = darken_params[0];
FT_Int y1 = darken_params[1];
FT_Int x2 = darken_params[2];
FT_Int y2 = darken_params[3];
FT_Int x3 = darken_params[4];
FT_Int y3 = darken_params[5];
FT_Int x4 = darken_params[6];
FT_Int y4 = darken_params[7];
#ifdef FT_CONFIG_OPTION_ENVIRONMENT_PROPERTIES
FT_Int dp[8];
if ( value_is_string )
{
const char* s = (const char*)value;
char* ep;
int i;
/* eight comma-separated numbers */
for ( i = 0; i < 7; i++ )
{
dp[i] = (FT_Int)ft_strtol( s, &ep, 10 );
if ( *ep != ',' || s == ep )
return FT_THROW( Invalid_Argument );
s = ep + 1;
}
dp[7] = (FT_Int)ft_strtol( s, &ep, 10 );
if ( !( *ep == '\0' || *ep == ' ' ) || s == ep )
return FT_THROW( Invalid_Argument );
darken_params = dp;
}
else
#endif
darken_params = (FT_Int*)value;
x1 = darken_params[0];
y1 = darken_params[1];
x2 = darken_params[2];
y2 = darken_params[3];
x3 = darken_params[4];
y3 = darken_params[5];
x4 = darken_params[6];
y4 = darken_params[7];
if ( x1 < 0 || x2 < 0 || x3 < 0 || x4 < 0 ||
y1 < 0 || y2 < 0 || y3 < 0 || y4 < 0 ||
x1 > x2 || x2 > x3 || x3 > x4 ||
@@ -210,10 +284,28 @@
}
else if ( !ft_strcmp( property_name, "no-stem-darkening" ) )
{
FT_Bool* no_stem_darkening = (FT_Bool*)value;
#ifdef FT_CONFIG_OPTION_ENVIRONMENT_PROPERTIES
if ( value_is_string )
{
const char* s = (const char*)value;
long nsd = ft_strtol( s, NULL, 10 );
module->no_stem_darkening = *no_stem_darkening;
if ( nsd == 0 )
module->no_stem_darkening = 0;
else if ( nsd == 1 )
module->no_stem_darkening = 1;
else
return FT_THROW( Invalid_Argument );
}
else
#endif
{
FT_Bool* no_stem_darkening = (FT_Bool*)value;
module->no_stem_darkening = *no_stem_darkening;
}
return error;
}
+1 -1
View File
@@ -40,7 +40,7 @@
"Armenian",
HB_SCRIPT_ARMENIAN,
HINTING_BOTTOM_TO_TOP,
"\xD6\x85 \xD5\x95" ) /* օ Օ */
"\xD5\xBD \xD5\x8D" ) /* ս Ս */
/* there are no simple forms for letters; we thus use two digit shapes */
SCRIPT( beng, BENG,
+3 -3
View File
@@ -842,7 +842,7 @@
p = getenv( "FT2_ALLOC_TOTAL_MAX" );
if ( p != NULL )
{
FT_Long total_max = ft_atol( p );
FT_Long total_max = ft_strtol( p, NULL, 10 );
if ( total_max > 0 )
@@ -855,7 +855,7 @@
p = getenv( "FT2_ALLOC_COUNT_MAX" );
if ( p != NULL )
{
FT_Long total_count = ft_atol( p );
FT_Long total_count = ft_strtol( p, NULL, 10 );
if ( total_count > 0 )
@@ -868,7 +868,7 @@
p = getenv( "FT2_KEEP_ALIVE" );
if ( p != NULL )
{
FT_Long keep_alive = ft_atol( p );
FT_Long keep_alive = ft_strtol( p, NULL, 10 );
if ( keep_alive > 0 )
+111
View File
@@ -226,6 +226,115 @@
}
#ifdef FT_CONFIG_OPTION_ENVIRONMENT_PROPERTIES
#define MAX_LENGTH 128
/*
* Set default properties derived from the `FREETYPE_PROPERTIES'
* environment variable.
*
* `FREETYPE_PROPERTIES' has the following syntax form (broken here into
* multiple lines for better readability)
*
* <optional whitespace>
* <module-name1> ':'
* <property-name1> '=' <property-value1>
* <whitespace>
* <module-name2> ':'
* <property-name2> '=' <property-value2>
* ...
*
* Example:
*
* FREETYPE_PROPERTIES=truetype:interpreter-version=35 \
* cff:no-stem-darkening=1 \
* autofitter:warping=1
*
*/
static void
ft_set_default_properties( FT_Library library )
{
const char* env;
const char* p;
const char* q;
char module_name[MAX_LENGTH + 1];
char property_name[MAX_LENGTH + 1];
char property_value[MAX_LENGTH + 1];
int i;
env = ft_getenv( "FREETYPE_PROPERTIES" );
if ( !env )
return;
for ( p = env; *p; p++ )
{
/* skip leading whitespace and separators */
if ( *p == ' ' || *p == '\t' )
continue;
/* read module name, followed by `:' */
q = p;
for ( i = 0; i < MAX_LENGTH; i++ )
{
if ( !*p || *p == ':' )
break;
module_name[i] = *p++;
}
module_name[i] = '\0';
if ( !*p || *p != ':' || p == q )
break;
/* read property name, followed by `=' */
q = ++p;
for ( i = 0; i < MAX_LENGTH; i++ )
{
if ( !*p || *p == '=' )
break;
property_name[i] = *p++;
}
property_name[i] = '\0';
if ( !*p || *p != '=' || p == q )
break;
/* read property value, followed by whitespace (if any) */
q = ++p;
for ( i = 0; i < MAX_LENGTH; i++ )
{
if ( !*p || *p == ' ' || *p == '\t' )
break;
property_value[i] = *p++;
}
property_value[i] = '\0';
if ( !( *p == '\0' || *p == ' ' || *p == '\t' ) || p == q )
break;
/* we completely ignore errors */
ft_property_string_set( library,
module_name,
property_name,
property_value );
}
}
#else
static void
ft_set_default_properties( FT_Library library )
{
FT_UNUSED( library );
}
#endif
/* documentation is in freetype.h */
FT_EXPORT_DEF( FT_Error )
@@ -256,6 +365,8 @@
else
FT_Add_Default_Modules( *alibrary );
ft_set_default_properties( *alibrary );
return error;
}
+49 -6
View File
@@ -2314,11 +2314,24 @@
if ( bsize->height < 0 )
bsize->height = (FT_Short)-bsize->height;
bsize->height = -bsize->height;
if ( bsize->x_ppem < 0 )
bsize->x_ppem = (FT_Short)-bsize->x_ppem;
bsize->x_ppem = -bsize->x_ppem;
if ( bsize->y_ppem < 0 )
bsize->y_ppem = -bsize->y_ppem;
/* check whether negation actually has worked */
if ( bsize->height < 0 || bsize->x_ppem < 0 || bsize->y_ppem < 0 )
{
FT_TRACE0(( "FT_Open_Face:"
" Invalid bitmap dimensions for stroke %d,"
" now disabled\n", i ));
bsize->width = 0;
bsize->height = 0;
bsize->size = 0;
bsize->x_ppem = 0;
bsize->y_ppem = 0;
}
}
}
@@ -4564,7 +4577,8 @@
const FT_String* module_name,
const FT_String* property_name,
void* value,
FT_Bool set )
FT_Bool set,
FT_Bool value_is_string )
{
FT_Module* cur;
FT_Module* limit;
@@ -4634,8 +4648,13 @@
return FT_THROW( Unimplemented_Feature );
}
return set ? service->set_property( cur[0], property_name, value )
: service->get_property( cur[0], property_name, value );
return set ? service->set_property( cur[0],
property_name,
value,
value_is_string )
: service->get_property( cur[0],
property_name,
value );
}
@@ -4651,7 +4670,8 @@
module_name,
property_name,
(void*)value,
TRUE );
TRUE,
FALSE );
}
@@ -4667,10 +4687,33 @@
module_name,
property_name,
value,
FALSE,
FALSE );
}
#ifdef FT_CONFIG_OPTION_ENVIRONMENT_PROPERTIES
/* this variant is used for handling the FREETYPE_PROPERTIES */
/* environment variable */
FT_BASE_DEF( FT_Error )
ft_property_string_set( FT_Library library,
const FT_String* module_name,
const FT_String* property_name,
FT_String* value )
{
return ft_property_do( library,
module_name,
property_name,
(void*)value,
TRUE,
TRUE );
}
#endif
/*************************************************************************/
/*************************************************************************/
/*************************************************************************/
+1
View File
@@ -474,6 +474,7 @@
CF2_GlyphPathRec glyphPath;
#endif
FT_ZERO( &storage );
/* initialize the remaining objects */
cf2_arrstack_init( &subrStack,
+3 -3
View File
@@ -53,14 +53,14 @@
cf2_stack_init( FT_Memory memory,
FT_Error* e )
{
FT_Error error = FT_Err_Ok; /* for FT_QNEW */
FT_Error error = FT_Err_Ok; /* for FT_NEW */
CF2_Stack stack = NULL;
if ( !FT_QNEW( stack ) )
if ( !FT_NEW( stack ) )
{
/* initialize the structure; FT_QNEW zeroes it */
/* initialize the structure; FT_NEW zeroes it */
stack->memory = memory;
stack->error = e;
stack->top = &stack->buffer[0]; /* empty stack */
+91 -19
View File
@@ -659,26 +659,62 @@
static FT_Error
cff_property_set( FT_Module module, /* CFF_Driver */
const char* property_name,
const void* value )
const void* value,
FT_Bool value_is_string )
{
FT_Error error = FT_Err_Ok;
CFF_Driver driver = (CFF_Driver)module;
#ifndef FT_CONFIG_OPTION_ENVIRONMENT_PROPERTIES
FT_UNUSED( value_is_string );
#endif
if ( !ft_strcmp( property_name, "darkening-parameters" ) )
{
FT_Int* darken_params = (FT_Int*)value;
FT_Int* darken_params;
FT_Int x1, y1, x2, y2, x3, y3, x4, y4;
FT_Int x1 = darken_params[0];
FT_Int y1 = darken_params[1];
FT_Int x2 = darken_params[2];
FT_Int y2 = darken_params[3];
FT_Int x3 = darken_params[4];
FT_Int y3 = darken_params[5];
FT_Int x4 = darken_params[6];
FT_Int y4 = darken_params[7];
#ifdef FT_CONFIG_OPTION_ENVIRONMENT_PROPERTIES
FT_Int dp[8];
if ( value_is_string )
{
const char* s = (const char*)value;
char* ep;
int i;
/* eight comma-separated numbers */
for ( i = 0; i < 7; i++ )
{
dp[i] = (FT_Int)ft_strtol( s, &ep, 10 );
if ( *ep != ',' || s == ep )
return FT_THROW( Invalid_Argument );
s = ep + 1;
}
dp[7] = (FT_Int)ft_strtol( s, &ep, 10 );
if ( !( *ep == '\0' || *ep == ' ' ) || s == ep )
return FT_THROW( Invalid_Argument );
darken_params = dp;
}
else
#endif
darken_params = (FT_Int*)value;
x1 = darken_params[0];
y1 = darken_params[1];
x2 = darken_params[2];
y2 = darken_params[3];
x3 = darken_params[4];
y3 = darken_params[5];
x4 = darken_params[6];
y4 = darken_params[7];
if ( x1 < 0 || x2 < 0 || x3 < 0 || x4 < 0 ||
y1 < 0 || y2 < 0 || y3 < 0 || y4 < 0 ||
x1 > x2 || x2 > x3 || x3 > x4 ||
@@ -698,26 +734,62 @@
}
else if ( !ft_strcmp( property_name, "hinting-engine" ) )
{
FT_UInt* hinting_engine = (FT_UInt*)value;
#ifdef FT_CONFIG_OPTION_ENVIRONMENT_PROPERTIES
if ( value_is_string )
{
const char* s = (const char*)value;
if ( *hinting_engine == FT_CFF_HINTING_ADOBE
if ( !ft_strcmp( s, "adobe" ) )
driver->hinting_engine = FT_CFF_HINTING_ADOBE;
#ifdef CFF_CONFIG_OPTION_OLD_ENGINE
|| *hinting_engine == FT_CFF_HINTING_FREETYPE
else if ( !ft_strcmp( s, "freetype" ) )
driver->hinting_engine = FT_CFF_HINTING_FREETYPE;
#endif
)
driver->hinting_engine = *hinting_engine;
else
return FT_THROW( Invalid_Argument );
}
else
error = FT_ERR( Unimplemented_Feature );
#endif
{
FT_UInt* hinting_engine = (FT_UInt*)value;
return error;
if ( *hinting_engine == FT_CFF_HINTING_ADOBE
#ifdef CFF_CONFIG_OPTION_OLD_ENGINE
|| *hinting_engine == FT_CFF_HINTING_FREETYPE
#endif
)
driver->hinting_engine = *hinting_engine;
else
error = FT_ERR( Unimplemented_Feature );
return error;
}
}
else if ( !ft_strcmp( property_name, "no-stem-darkening" ) )
{
FT_Bool* no_stem_darkening = (FT_Bool*)value;
#ifdef FT_CONFIG_OPTION_ENVIRONMENT_PROPERTIES
if ( value_is_string )
{
const char* s = (const char*)value;
long nsd = ft_strtol( s, NULL, 10 );
driver->no_stem_darkening = *no_stem_darkening;
if ( nsd == 0 )
driver->no_stem_darkening = 0;
else if ( nsd == 1 )
driver->no_stem_darkening = 1;
else
return FT_THROW( Invalid_Argument );
}
else
#endif
{
FT_Bool* no_stem_darkening = (FT_Bool*)value;
driver->no_stem_darkening = *no_stem_darkening;
}
return error;
}
+1
View File
@@ -2942,6 +2942,7 @@
cff_decoder_init( &decoder, face, size, glyph, hinting,
FT_LOAD_TARGET_MODE( load_flags ) );
/* this is for pure CFFs */
if ( load_flags & FT_LOAD_ADVANCE_ONLY )
decoder.width_only = TRUE;
+2 -1
View File
@@ -602,7 +602,8 @@
if ( !FT_ALLOC( name, byte_len + 1 ) )
{
FT_MEM_COPY( name, bytes, byte_len );
if ( byte_len )
FT_MEM_COPY( name, bytes, byte_len );
name[byte_len] = 0;
}
cff_index_forget_element( idx, &bytes );
+2 -1
View File
@@ -777,7 +777,8 @@
CID_FaceDict dict = cid->font_dicts + n;
if ( dict->sd_bytes < 0 )
if ( dict->sd_bytes < 0 ||
( dict->num_subrs && dict->sd_bytes < 1 ) )
{
FT_ERROR(( "cid_parse_dict: Invalid `SDBytes' value\n" ));
error = FT_THROW( Invalid_File_Format );
+3 -3
View File
@@ -199,7 +199,7 @@
limit = parser->root.limit;
cur = parser->root.cursor;
while ( cur < limit - SFNTS_LEN )
while ( cur <= limit - SFNTS_LEN )
{
if ( parser->root.error )
{
@@ -208,12 +208,12 @@
}
if ( cur[0] == 'S' &&
cur < limit - STARTDATA_LEN &&
cur <= limit - STARTDATA_LEN &&
ft_strncmp( (char*)cur, STARTDATA, STARTDATA_LEN ) == 0 )
{
if ( ft_strncmp( (char*)arg1, "(Hex)", 5 ) == 0 )
{
FT_Long tmp = ft_atol( (const char *)arg2 );
FT_Long tmp = ft_strtol( (const char *)arg2, NULL, 10 );
if ( tmp < 0 )
+10 -2
View File
@@ -42,7 +42,12 @@
state->buf_total += count;
state->in_eof = FT_BOOL( count < state->num_bits );
state->buf_offset = 0;
state->buf_size = ( state->buf_size << 3 ) - ( state->num_bits - 1 );
state->buf_size <<= 3;
if ( state->buf_size > state->num_bits )
state->buf_size -= state->num_bits - 1;
else
return -1; /* not enough data */
if ( count == 0 ) /* end of file */
return -1;
@@ -66,7 +71,10 @@
{
if ( state->free_ent >= state->free_bits )
{
state->num_bits = ++num_bits;
state->num_bits = ++num_bits;
if ( num_bits > LZW_MAX_BITS )
return -1;
state->free_bits = state->num_bits < state->max_bits
? (FT_UInt)( ( 1UL << num_bits ) - 256 )
: state->max_free + 1;
+30 -23
View File
@@ -459,55 +459,62 @@
FT_DEFINE_SFNT_INTERFACE(
sfnt_interface,
tt_face_goto_table,
tt_face_goto_table, /* TT_Loader_GotoTableFunc goto_table */
sfnt_init_face,
sfnt_load_face,
sfnt_done_face,
sfnt_get_interface,
sfnt_init_face, /* TT_Init_Face_Func init_face */
sfnt_load_face, /* TT_Load_Face_Func load_face */
sfnt_done_face, /* TT_Done_Face_Func done_face */
sfnt_get_interface, /* FT_Module_Requester get_interface */
tt_face_load_any,
tt_face_load_any, /* TT_Load_Any_Func load_any */
tt_face_load_head,
tt_face_load_hhea,
tt_face_load_cmap,
tt_face_load_maxp,
tt_face_load_os2,
tt_face_load_post,
tt_face_load_head, /* TT_Load_Table_Func load_head */
tt_face_load_hhea, /* TT_Load_Metrics_Func load_hhea */
tt_face_load_cmap, /* TT_Load_Table_Func load_cmap */
tt_face_load_maxp, /* TT_Load_Table_Func load_maxp */
tt_face_load_os2, /* TT_Load_Table_Func load_os2 */
tt_face_load_post, /* TT_Load_Table_Func load_post */
tt_face_load_name,
tt_face_free_name,
tt_face_load_name, /* TT_Load_Table_Func load_name */
tt_face_free_name, /* TT_Free_Table_Func free_name */
tt_face_load_kern,
tt_face_load_gasp,
tt_face_load_pclt,
tt_face_load_kern, /* TT_Load_Table_Func load_kern */
tt_face_load_gasp, /* TT_Load_Table_Func load_gasp */
tt_face_load_pclt, /* TT_Load_Table_Func load_init */
/* see `ttload.h' */
PUT_EMBEDDED_BITMAPS( tt_face_load_bhed ),
/* TT_Load_Table_Func load_bhed */
PUT_EMBEDDED_BITMAPS( tt_face_load_sbit_image ),
/* TT_Load_SBit_Image_Func load_sbit_image */
/* see `ttpost.h' */
PUT_PS_NAMES( tt_face_get_ps_name ),
/* TT_Get_PS_Name_Func get_psname */
PUT_PS_NAMES( tt_face_free_ps_names ),
/* TT_Free_Table_Func free_psnames */
/* since version 2.1.8 */
tt_face_get_kerning,
tt_face_get_kerning, /* TT_Face_GetKerningFunc get_kerning */
/* since version 2.2 */
tt_face_load_font_dir,
tt_face_load_hmtx,
tt_face_load_font_dir, /* TT_Load_Table_Func load_font_dir */
tt_face_load_hmtx, /* TT_Load_Metrics_Func load_hmtx */
/* see `ttsbit.h' and `sfnt.h' */
PUT_EMBEDDED_BITMAPS( tt_face_load_sbit ),
/* TT_Load_Table_Func load_eblc */
PUT_EMBEDDED_BITMAPS( tt_face_free_sbit ),
/* TT_Free_Table_Func free_eblc */
PUT_EMBEDDED_BITMAPS( tt_face_set_sbit_strike ),
/* TT_Set_SBit_Strike_Func set_sbit_strike */
PUT_EMBEDDED_BITMAPS( tt_face_load_strike_metrics ),
/* TT_Load_Strike_Metrics_Func load_strike_metrics */
tt_face_get_metrics,
tt_face_get_metrics, /* TT_Get_Metrics_Func get_metrics */
tt_face_get_name
tt_face_get_name /* TT_Get_Name_Func get_name */
)
+1 -1
View File
@@ -977,7 +977,7 @@
#endif
face->root.num_faces = face->ttc_header.count;
face->root.face_index = face_index;
face->root.face_index = face_instance_index;
return error;
}
+61 -8
View File
@@ -763,6 +763,9 @@
static void
tt_cmap4_next( TT_CMap4 cmap )
{
TT_Face face = (TT_Face)cmap->cmap.cmap.charmap.face;
FT_Byte* limit = face->cmap_table + face->cmap_size;
FT_UInt charcode;
@@ -788,15 +791,19 @@
FT_Byte* p = values + 2 * ( charcode - cmap->cur_start );
/* if p > limit, the whole segment is invalid */
if ( p > limit )
goto Next_Segment;
do
{
FT_UInt gindex = FT_NEXT_USHORT( p );
if ( gindex != 0 )
if ( gindex )
{
gindex = (FT_UInt)( (FT_Int)gindex + delta ) & 0xFFFFU;
if ( gindex != 0 )
if ( gindex )
{
cmap->cur_charcode = charcode;
cmap->cur_gindex = gindex;
@@ -812,7 +819,26 @@
FT_UInt gindex = (FT_UInt)( (FT_Int)charcode + delta ) & 0xFFFFU;
if ( gindex != 0 )
if ( gindex >= (FT_UInt)face->root.num_glyphs )
{
/* we have an invalid glyph index; if there is an overflow, */
/* we can adjust `charcode', otherwise the whole segment is */
/* invalid */
gindex = 0;
if ( (FT_Int)charcode + delta < 0 &&
(FT_Int)end + delta >= 0 )
charcode = (FT_UInt)( -delta );
else if ( (FT_Int)charcode + delta < 0x10000L &&
(FT_Int)end + delta >= 0x10000L )
charcode = (FT_UInt)( 0x10000L - delta );
else
goto Next_Segment;
}
if ( gindex )
{
cmap->cur_charcode = charcode;
cmap->cur_gindex = gindex;
@@ -822,6 +848,7 @@
}
}
Next_Segment:
/* we need to find another range */
if ( tt_cmap4_set_range( cmap, cmap->cur_range + 1 ) < 0 )
break;
@@ -1170,6 +1197,9 @@
FT_UInt32* pcharcode,
FT_Bool next )
{
TT_Face face = (TT_Face)cmap->cmap.charmap.face;
FT_Byte* limit = face->cmap_table + face->cmap_size;
FT_UInt num_segs2, start, end, offset;
FT_Int delta;
FT_UInt max, min, mid, num_segs;
@@ -1221,10 +1251,6 @@
if ( mid >= num_segs - 1 &&
start == 0xFFFFU && end == 0xFFFFU )
{
TT_Face face = (TT_Face)cmap->cmap.charmap.face;
FT_Byte* limit = face->cmap_table + face->cmap_size;
if ( offset && p + offset + 2 > limit )
{
delta = 1;
@@ -1347,13 +1373,40 @@
if ( offset )
{
p += offset + ( charcode - start ) * 2;
/* if p > limit, the whole segment is invalid */
if ( next && p > limit )
break;
gindex = TT_PEEK_USHORT( p );
if ( gindex != 0 )
if ( gindex )
{
gindex = (FT_UInt)( (FT_Int)gindex + delta ) & 0xFFFFU;
if ( gindex >= (FT_UInt)face->root.num_glyphs )
gindex = 0;
}
}
else
{
gindex = (FT_UInt)( (FT_Int)charcode + delta ) & 0xFFFFU;
if ( next && gindex >= (FT_UInt)face->root.num_glyphs )
{
/* we have an invalid glyph index; if there is an overflow, */
/* we can adjust `charcode', otherwise the whole segment is */
/* invalid */
gindex = 0;
if ( (FT_Int)charcode + delta < 0 &&
(FT_Int)end + delta >= 0 )
charcode = (FT_UInt)( -delta );
else if ( (FT_Int)charcode + delta < 0x10000L &&
(FT_Int)end + delta >= 0x10000L )
charcode = (FT_UInt)( 0x10000L - delta );
}
}
break;
}
}
+2 -11
View File
@@ -775,15 +775,6 @@
maxProfile->maxTwilightPoints = 0xFFFFU - 4;
}
/* we arbitrarily limit recursion to avoid stack exhaustion */
if ( maxProfile->maxComponentDepth > 100 )
{
FT_TRACE0(( "tt_face_load_maxp:"
" abnormally large component depth (%d) set to 100\n",
maxProfile->maxComponentDepth ));
maxProfile->maxComponentDepth = 100;
}
}
FT_TRACE3(( "numGlyphs: %u\n", maxProfile->numGlyphs ));
@@ -1193,8 +1184,8 @@
#define FT_STRUCTURE TT_Postscript
FT_FRAME_START( 32 ),
FT_FRAME_ULONG( FormatType ),
FT_FRAME_ULONG( italicAngle ),
FT_FRAME_LONG ( FormatType ),
FT_FRAME_LONG ( italicAngle ),
FT_FRAME_SHORT( underlinePosition ),
FT_FRAME_SHORT( underlineThickness ),
FT_FRAME_ULONG( isFixedPitch ),
+38 -11
View File
@@ -197,6 +197,27 @@
if ( !error )
FT_TRACE3(( "sbit_num_strikes: %u\n", face->sbit_num_strikes ));
face->ebdt_start = 0;
face->ebdt_size = 0;
if ( face->sbit_table_type != TT_SBIT_TABLE_TYPE_NONE )
{
FT_ULong ebdt_size;
error = face->goto_table( face, TTAG_CBDT, stream, &ebdt_size );
if ( error )
error = face->goto_table( face, TTAG_EBDT, stream, &ebdt_size );
if ( error )
error = face->goto_table( face, TTAG_bdat, stream, &ebdt_size );
if ( !error )
{
face->ebdt_start = FT_STREAM_POS();
face->ebdt_size = ebdt_size;
}
}
return FT_Err_Ok;
Exit:
@@ -323,6 +344,16 @@
strike[18] + /* max_width */
(FT_Char)strike[23] /* min_advance_SB */
) * 64;
/* set the scale values (in 16.16 units) so advances */
/* from the hmtx and vmtx table are scaled correctly */
metrics->x_scale = FT_MulDiv( metrics->x_ppem,
64 * 0x10000,
face->header.Units_Per_EM );
metrics->y_scale = FT_MulDiv( metrics->y_ppem,
64 * 0x10000,
face->header.Units_Per_EM );
return FT_Err_Ok;
}
@@ -414,17 +445,13 @@
FT_ULong strike_index,
TT_SBit_MetricsRec* metrics )
{
FT_Error error;
FT_Error error = FT_ERR( Table_Missing );
FT_Stream stream = face->root.stream;
FT_ULong ebdt_size;
error = face->goto_table( face, TTAG_CBDT, stream, &ebdt_size );
if ( error )
error = face->goto_table( face, TTAG_EBDT, stream, &ebdt_size );
if ( error )
error = face->goto_table( face, TTAG_bdat, stream, &ebdt_size );
if ( error )
if ( !face->ebdt_size )
goto Exit;
if ( FT_STREAM_SEEK( face->ebdt_start ) )
goto Exit;
decoder->face = face;
@@ -435,8 +462,8 @@
decoder->metrics_loaded = 0;
decoder->bitmap_allocated = 0;
decoder->ebdt_start = FT_STREAM_POS();
decoder->ebdt_size = ebdt_size;
decoder->ebdt_start = face->ebdt_start;
decoder->ebdt_size = face->ebdt_size;
decoder->eblc_base = face->sbit_table;
decoder->eblc_limit = face->sbit_table + face->sbit_table_size;
@@ -854,7 +881,7 @@
}
*pwrite++ |= ( ( rval >> nbits ) & 0xFF ) &
( ~( 0xFF << w ) << ( 8 - w - x_pos ) );
( ~( 0xFFU << w ) << ( 8 - w - x_pos ) );
rval <<= 8;
w = line_bits - w;
+137 -265
View File
@@ -403,9 +403,12 @@ typedef ptrdiff_t FT_PtrDist;
} TCell;
typedef struct TPixmap_
{
unsigned char* origin; /* pixmap origin at the bottom-left */
int pitch; /* pitch to go down one row */
/* maximum number of gray spans in a call to the span callback */
#define FT_MAX_GRAY_SPANS 32
} TPixmap;
/* maximum number of gray cells in the buffer */
#if FT_RENDER_POOL_SIZE > 2048
@@ -430,7 +433,6 @@ typedef ptrdiff_t FT_PtrDist;
TCoord ex, ey;
TCoord min_ex, max_ex;
TCoord min_ey, max_ey;
TCoord count_ex, count_ey;
TArea area;
TCoord cover;
@@ -443,14 +445,10 @@ typedef ptrdiff_t FT_PtrDist;
TPos x, y;
FT_Outline outline;
FT_Bitmap target;
FT_Span gray_spans[FT_MAX_GRAY_SPANS];
int num_gray_spans;
TPixmap target;
FT_Raster_Span_Func render_span;
void* render_span_data;
int span_y;
PCell* ycells;
@@ -482,17 +480,17 @@ typedef ptrdiff_t FT_PtrDist;
static void
gray_dump_cells( RAS_ARG )
{
int yindex;
int y;
for ( yindex = 0; yindex < ras.count_ey; yindex++ )
for ( y = ras.min_ey; y < ras.max_ey; y++ )
{
PCell cell;
PCell cell = ras.ycells[y - ras.min_ey];
printf( "%3d:", yindex );
printf( "%3d:", y );
for ( cell = ras.ycells[yindex]; cell != NULL; cell = cell->next )
for ( ; cell != NULL; cell = cell->next )
printf( " (%3d, c:%4d, a:%6d)",
cell->x, cell->cover, cell->area );
printf( "\n" );
@@ -513,10 +511,10 @@ typedef ptrdiff_t FT_PtrDist;
TCoord x = ras.ex;
if ( x > ras.count_ex )
x = ras.count_ex;
if ( x > ras.max_ex )
x = ras.max_ex;
pcell = &ras.ycells[ras.ey];
pcell = &ras.ycells[ras.ey - ras.min_ey];
for (;;)
{
cell = *pcell;
@@ -579,14 +577,11 @@ typedef ptrdiff_t FT_PtrDist;
/* All cells that are on the left of the clipping region go to the */
/* min_ex - 1 horizontal position. */
ey -= ras.min_ey;
if ( ex > ras.max_ex )
ex = ras.max_ex;
ex -= ras.min_ex;
if ( ex < 0 )
ex = -1;
if ( ex < ras.min_ex )
ex = ras.min_ex - 1;
/* are we moving to a different cell ? */
if ( ex != ras.ex || ey != ras.ey )
@@ -601,34 +596,11 @@ typedef ptrdiff_t FT_PtrDist;
ras.ey = ey;
}
ras.invalid = ( (unsigned int)ey >= (unsigned int)ras.count_ey ||
ex >= ras.count_ex );
ras.invalid = ( ey >= ras.max_ey || ey < ras.min_ey ||
ex >= ras.max_ex );
}
/*************************************************************************/
/* */
/* Start a new contour at a given cell. */
/* */
static void
gray_start_cell( RAS_ARG_ TCoord ex,
TCoord ey )
{
if ( ex > ras.max_ex )
ex = ras.max_ex;
if ( ex < ras.min_ex )
ex = ras.min_ex - 1;
ras.area = 0;
ras.cover = 0;
ras.ex = ex - ras.min_ex;
ras.ey = ey - ras.min_ey;
ras.invalid = 0;
gray_set_cell( RAS_VAR_ ex, ey );
}
#ifndef FT_LONG64
/*************************************************************************/
@@ -657,14 +629,14 @@ typedef ptrdiff_t FT_PtrDist;
return;
}
fx1 = (TCoord)( x1 - SUBPIXELS( ex1 ) );
fx2 = (TCoord)( x2 - SUBPIXELS( ex2 ) );
fx1 = (TCoord)( x1 - SUBPIXELS( ex1 ) );
fx2 = (TCoord)( x2 - SUBPIXELS( ex2 ) );
delta = y2 - y1;
/* everything is located in a single cell. That is easy! */
/* */
if ( ex1 == ex2 )
{
delta = y2 - y1;
ras.area += (TArea)(( fx1 + fx2 ) * delta);
ras.cover += delta;
return;
@@ -673,14 +645,17 @@ typedef ptrdiff_t FT_PtrDist;
/* ok, we'll have to render a run of adjacent cells on the same */
/* scanline... */
/* */
p = ( ONE_PIXEL - fx1 ) * ( y2 - y1 );
first = ONE_PIXEL;
incr = 1;
dx = x2 - x1;
dx = x2 - x1;
if ( dx < 0 )
if ( dx > 0 )
{
p = fx1 * ( y2 - y1 );
p = ( ONE_PIXEL - fx1 ) * delta;
first = ONE_PIXEL;
incr = 1;
}
else
{
p = fx1 * delta;
first = 0;
incr = -1;
dx = -dx;
@@ -764,8 +739,6 @@ typedef ptrdiff_t FT_PtrDist;
dy = to_y - ras.y;
/* vertical line - avoid calling gray_render_scanline */
incr = 1;
if ( dx == 0 )
{
TCoord ex = TRUNC( ras.x );
@@ -773,8 +746,12 @@ typedef ptrdiff_t FT_PtrDist;
TArea area;
first = ONE_PIXEL;
if ( dy < 0 )
if ( dy > 0)
{
first = ONE_PIXEL;
incr = 1;
}
else
{
first = 0;
incr = -1;
@@ -806,11 +783,13 @@ typedef ptrdiff_t FT_PtrDist;
}
/* ok, we have to render several scanlines */
p = ( ONE_PIXEL - fy1 ) * dx;
first = ONE_PIXEL;
incr = 1;
if ( dy < 0 )
if ( dy > 0)
{
p = ( ONE_PIXEL - fy1 ) * dx;
first = ONE_PIXEL;
incr = 1;
}
else
{
p = fy1 * dx;
first = 0;
@@ -1218,15 +1197,11 @@ typedef ptrdiff_t FT_PtrDist;
TPos x, y;
/* record current cell, if any */
if ( !ras.invalid )
gray_record_cell( RAS_VAR );
/* start to a new position */
x = UPSCALE( to->x );
y = UPSCALE( to->y );
gray_start_cell( RAS_VAR_ TRUNC( x ), TRUNC( y ) );
gray_set_cell( RAS_VAR_ TRUNC( x ), TRUNC( y ) );
ras.x = x;
ras.y = y;
@@ -1264,60 +1239,14 @@ typedef ptrdiff_t FT_PtrDist;
}
static void
gray_render_span( int y,
int count,
const FT_Span* spans,
gray_PWorker worker )
{
unsigned char* p;
FT_Bitmap* map = &worker->target;
/* first of all, compute the scanline offset */
p = (unsigned char*)map->buffer - y * map->pitch;
if ( map->pitch >= 0 )
p += ( map->rows - 1 ) * (unsigned int)map->pitch;
for ( ; count > 0; count--, spans++ )
{
unsigned char coverage = spans->coverage;
if ( coverage )
{
unsigned char* q = p + spans->x;
/* For small-spans it is faster to do it by ourselves than
* calling `memset'. This is mainly due to the cost of the
* function call.
*/
switch ( spans->len )
{
case 7: *q++ = coverage;
case 6: *q++ = coverage;
case 5: *q++ = coverage;
case 4: *q++ = coverage;
case 3: *q++ = coverage;
case 2: *q++ = coverage;
case 1: *q = coverage;
case 0: break;
default:
FT_MEM_SET( q, coverage, spans->len );
}
}
}
}
static void
gray_hline( RAS_ARG_ TCoord x,
TCoord y,
TArea area,
TCoord acount )
{
int coverage;
int coverage;
FT_Span span;
/* compute the coverage line's coverage, depending on the */
@@ -1346,64 +1275,37 @@ typedef ptrdiff_t FT_PtrDist;
coverage = 255;
}
y += ras.min_ey;
x += ras.min_ex;
if ( coverage )
if ( ras.render_span ) /* for FT_RASTER_FLAG_DIRECT only */
{
FT_Span* span;
int count;
span.x = (short)x;
span.len = (unsigned short)acount;
span.coverage = (unsigned char)coverage;
ras.render_span( y, 1, &span, ras.render_span_data );
}
else
{
unsigned char* q = ras.target.origin - ras.target.pitch * y + x;
unsigned char c = (unsigned char)coverage;
/* see whether we can add this span to the current list */
count = ras.num_gray_spans;
span = ras.gray_spans + count - 1;
if ( span->coverage == coverage &&
span->x + span->len == x &&
ras.span_y == y &&
count > 0 )
/* For small-spans it is faster to do it by ourselves than
* calling `memset'. This is mainly due to the cost of the
* function call.
*/
switch ( acount )
{
span->len = (unsigned short)( span->len + acount );
return;
case 7: *q++ = c;
case 6: *q++ = c;
case 5: *q++ = c;
case 4: *q++ = c;
case 3: *q++ = c;
case 2: *q++ = c;
case 1: *q = c;
case 0: break;
default:
FT_MEM_SET( q, c, acount );
}
if ( ras.span_y != y || count >= FT_MAX_GRAY_SPANS )
{
if ( ras.render_span && count > 0 )
ras.render_span( ras.span_y, count, ras.gray_spans,
ras.render_span_data );
#ifdef FT_DEBUG_LEVEL_TRACE
if ( count > 0 )
{
int n;
FT_TRACE7(( "y = %3d ", ras.span_y ));
span = ras.gray_spans;
for ( n = 0; n < count; n++, span++ )
FT_TRACE7(( "[%d..%d]:%02x ",
span->x, span->x + span->len - 1, span->coverage ));
FT_TRACE7(( "\n" ));
}
#endif /* FT_DEBUG_LEVEL_TRACE */
ras.num_gray_spans = 0;
ras.span_y = (int)y;
span = ras.gray_spans;
}
else
span++;
/* add a gray span to the current list */
span->x = (short)x;
span->len = (unsigned short)acount;
span->coverage = (unsigned char)coverage;
ras.num_gray_spans++;
}
}
@@ -1411,22 +1313,19 @@ typedef ptrdiff_t FT_PtrDist;
static void
gray_sweep( RAS_ARG )
{
int yindex;
int y;
if ( ras.num_cells == 0 )
return;
ras.num_gray_spans = 0;
ras.span_y = 0;
FT_TRACE7(( "gray_sweep: start\n" ));
for ( yindex = 0; yindex < ras.count_ey; yindex++ )
for ( y = ras.min_ey; y < ras.max_ey; y++ )
{
PCell cell = ras.ycells[yindex];
PCell cell = ras.ycells[y - ras.min_ey];
TCoord cover = 0;
TCoord x = 0;
TCoord x = ras.min_ex;
for ( ; cell != NULL; cell = cell->next )
@@ -1434,48 +1333,25 @@ typedef ptrdiff_t FT_PtrDist;
TArea area;
if ( cell->x > x && cover != 0 )
gray_hline( RAS_VAR_ x, yindex, (TArea)cover * ( ONE_PIXEL * 2 ),
if ( cover != 0 && cell->x > x )
gray_hline( RAS_VAR_ x, y, (TArea)cover * ( ONE_PIXEL * 2 ),
cell->x - x );
cover += cell->cover;
area = (TArea)cover * ( ONE_PIXEL * 2 ) - cell->area;
if ( area != 0 && cell->x >= 0 )
gray_hline( RAS_VAR_ cell->x, yindex, area, 1 );
if ( area != 0 && cell->x >= ras.min_ex )
gray_hline( RAS_VAR_ cell->x, y, area, 1 );
x = cell->x + 1;
}
if ( cover != 0 )
gray_hline( RAS_VAR_ x, yindex, (TArea)cover * ( ONE_PIXEL * 2 ),
ras.count_ex - x );
}
if ( ras.render_span && ras.num_gray_spans > 0 )
ras.render_span( ras.span_y, ras.num_gray_spans,
ras.gray_spans, ras.render_span_data );
#ifdef FT_DEBUG_LEVEL_TRACE
if ( ras.num_gray_spans > 0 )
{
FT_Span* span;
int n;
FT_TRACE7(( "y = %3d ", ras.span_y ));
span = ras.gray_spans;
for ( n = 0; n < ras.num_gray_spans; n++, span++ )
FT_TRACE7(( "[%d..%d]:%02x ",
span->x, span->x + span->len - 1, span->coverage ));
FT_TRACE7(( "\n" ));
gray_hline( RAS_VAR_ x, y, (TArea)cover * ( ONE_PIXEL * 2 ),
ras.max_ex - x );
}
FT_TRACE7(( "gray_sweep: end\n" ));
#endif /* FT_DEBUG_LEVEL_TRACE */
}
@@ -1839,13 +1715,6 @@ typedef ptrdiff_t FT_PtrDist;
#endif /* STANDALONE_ */
typedef struct gray_TBand_
{
TCoord min, max;
} gray_TBand;
FT_DEFINE_OUTLINE_FUNCS(
func_interface,
@@ -1895,47 +1764,49 @@ typedef ptrdiff_t FT_PtrDist;
#ifdef __REACTOS__
TCell *buffer;
#else
TCell buffer[FT_MAX_GRAY_POOL];
TCell buffer[FT_MAX_GRAY_POOL];
#endif
const int band_size = FT_MAX_GRAY_POOL / 8;
gray_TBand bands[32];
gray_TBand* band;
int n, num_bands;
TCoord min, max, max_y;
TCoord band_size = FT_MAX_GRAY_POOL / 8;
TCoord count = ras.max_ey - ras.min_ey;
int num_bands;
TCoord min, max, max_y;
TCoord bands[32]; /* enough to accommodate bisections */
TCoord* band;
#ifdef __REACTOS__
buffer = malloc(FT_MAX(FT_RENDER_POOL_SIZE, 2048));
#endif
/* set up vertical bands */
num_bands = (int)( ( ras.max_ey - ras.min_ey ) / band_size );
if ( num_bands == 0 )
num_bands = 1;
if ( num_bands >= 39 )
num_bands = 39;
if ( count > band_size )
{
/* two divisions rounded up */
num_bands = (int)( ( count + band_size - 1) / band_size );
band_size = ( count + num_bands - 1 ) / num_bands;
}
min = ras.min_ey;
max_y = ras.max_ey;
for ( n = 0; n < num_bands; n++, min = max )
for ( ; min < max_y; min = max )
{
max = min + band_size;
if ( n == num_bands - 1 || max > max_y )
if ( max > max_y )
max = max_y;
bands[0].min = min;
bands[0].max = max;
band = bands;
band = bands;
band[1] = min;
band[0] = max;
do
{
TCoord bottom, top, middle;
TCoord width = band[0] - band[1];
int error;
/* memory management */
{
size_t ycount = (size_t)( band->max - band->min );
size_t ycount = (size_t)width;
size_t cell_start;
@@ -1955,9 +1826,8 @@ typedef ptrdiff_t FT_PtrDist;
ras.num_cells = 0;
ras.invalid = 1;
ras.min_ey = band->min;
ras.max_ey = band->max;
ras.count_ey = band->max - band->min;
ras.min_ey = band[1];
ras.max_ey = ras.ey = band[0];
error = gray_convert_glyph_inner( RAS_VAR );
@@ -1977,13 +1847,11 @@ typedef ptrdiff_t FT_PtrDist;
ReduceBands:
/* render pool overflow; we will reduce the render band by half */
bottom = band->min;
top = band->max;
middle = bottom + ( ( top - bottom ) >> 1 );
width >>= 1;
/* This is too complex for a single scanline; there must */
/* be some problems. */
if ( middle == bottom )
if ( width == 0 )
{
FT_TRACE7(( "gray_convert_glyph: rotten glyph\n" ));
#ifdef __REACTOS__
@@ -1992,11 +1860,9 @@ typedef ptrdiff_t FT_PtrDist;
return 1;
}
band[1].min = bottom;
band[1].max = middle;
band[0].min = middle;
band[0].max = top;
band++;
band[1] = band[0];
band[0] += width;
} while ( band >= bands );
}
@@ -2016,12 +1882,18 @@ typedef ptrdiff_t FT_PtrDist;
const FT_Bitmap* target_map = params->target;
FT_BBox cbox, clip;
#ifndef FT_STATIC_RASTER
gray_TWorker worker[1];
#endif
if ( !raster )
return FT_THROW( Invalid_Argument );
/* this version does not support monochrome rendering */
if ( !( params->flags & FT_RASTER_FLAG_AA ) )
return FT_THROW( Invalid_Mode );
if ( !outline )
return FT_THROW( Invalid_Outline );
@@ -2036,9 +1908,19 @@ typedef ptrdiff_t FT_PtrDist;
outline->contours[outline->n_contours - 1] + 1 )
return FT_THROW( Invalid_Outline );
/* if direct mode is not set, we must have a target bitmap */
if ( !( params->flags & FT_RASTER_FLAG_DIRECT ) )
ras.outline = *outline;
if ( params->flags & FT_RASTER_FLAG_DIRECT )
{
if ( !params->gray_spans )
return 0;
ras.render_span = (FT_Raster_Span_Func)params->gray_spans;
ras.render_span_data = params->user;
}
else
{
/* if direct mode is not set, we must have a target bitmap */
if ( !target_map )
return FT_THROW( Invalid_Argument );
@@ -2048,11 +1930,18 @@ typedef ptrdiff_t FT_PtrDist;
if ( !target_map->buffer )
return FT_THROW( Invalid_Argument );
}
/* this version does not support monochrome rendering */
if ( !( params->flags & FT_RASTER_FLAG_AA ) )
return FT_THROW( Invalid_Mode );
if ( target_map->pitch < 0 )
ras.target.origin = target_map->buffer;
else
ras.target.origin = target_map->buffer
+ ( target_map->rows - 1 ) * (unsigned int)target_map->pitch;
ras.target.pitch = target_map->pitch;
ras.render_span = (FT_Raster_Span_Func)NULL;
ras.render_span_data = NULL;
}
FT_Outline_Get_CBox( outline, &cbox );
@@ -2095,23 +1984,6 @@ typedef ptrdiff_t FT_PtrDist;
if ( ras.max_ex <= ras.min_ex || ras.max_ey <= ras.min_ey )
return 0;
ras.count_ex = ras.max_ex - ras.min_ex;
ras.count_ey = ras.max_ey - ras.min_ey;
ras.outline = *outline;
if ( params->flags & FT_RASTER_FLAG_DIRECT )
{
ras.render_span = (FT_Raster_Span_Func)params->gray_spans;
ras.render_span_data = params->user;
}
else
{
ras.target = *target_map;
ras.render_span = (FT_Raster_Span_Func)gray_render_span;
ras.render_span_data = &ras;
}
return gray_convert_glyph( RAS_VAR );
}
@@ -5,7 +5,12 @@ TOP_DIR ?= ../../..
OBJ_DIR ?= $(TOP_DIR)/objs
# The setup below is for gcc on a Unix-like platform.
# The setup below is for gcc on a Unix-like platform,
# where FreeType has been set up to create a static library
# (which is the default).
VPATH = $(OBJ_DIR) \
$(OBJ_DIR)/.libs
SRC_DIR = $(TOP_DIR)/src/tools/ftrandom
@@ -20,16 +25,21 @@ WFLAGS = -Wmissing-prototypes \
-Wchar-subscripts \
-Wsequence-point
CFLAGS = $(WFLAGS) \
-g \
-I $(TOP_DIR)/include
-g
INCLUDES = -I $(TOP_DIR)/include
LDFLAGS =
LIBS = -lm \
-L $(OBJ_DIR) \
-lfreetype \
-lz
-lz \
-lpng \
-lbz2 \
-lharfbuzz
all: $(OBJ_DIR)/ftrandom
$(OBJ_DIR)/ftrandom: $(SRC_DIR)/ftrandom.c $(OBJ_DIR)/libfreetype.a
$(CC) -o $(OBJ_DIR)/ftrandom $(CFLAGS) $(SRC_DIR)/ftrandom.c $(LIBS)
$(OBJ_DIR)/ftrandom.o: $(SRC_DIR)/ftrandom.c
$(CC) $(CFLAGS) $(INCLUDES) -c -o $@ $<
$(OBJ_DIR)/ftrandom: $(OBJ_DIR)/ftrandom.o libfreetype.a
$(CC) $(LDFLAGS) -o $@ $^ $(LIBS)
# EOF
+50 -29
View File
@@ -1,48 +1,69 @@
ftrandom
--------
========
This program expects a set of directories containing good fonts, and a set
of extensions of fonts to be tested. It will randomly pick a font, copy it,
introduce and error and then test it.
introduce an error and then test it.
The FreeType tests are quite basic:
The FreeType tests are quite basic; for each erroneous font ftrandom
For each erroneous font it
forks off a new tester;
initializes the library;
opens each font in the file;
loads each glyph;
(optionally reviewing the contours of the glyph)
(optionally rasterizing)
closes the face.
. forks off a new tester,
. initializes the library,
. opens each font in the file,
. loads each glyph,
. optionally reviews the contours of the glyph,
. optionally rasterizes the glyph, and
. closes the face.
If the tester exits with a signal, or takes longer than 20 seconds then
ftrandom saves the erroneous font and continues. If the tester exits
normally or with an error, then the superstructure removes the test font and
continues.
If a tester takes longer than 20 seconds, ftrandom saves the erroneous font
and continues. If the tester exits normally or with an error, then the
superstructure removes the test font and continues.
Arguments are:
Command line options
--------------------
--all Test every font in the directory(ies) no matter
what its extension (some CID-keyed fonts have no
extension).
--check-outlines Call FT_Outline_Decompose on each glyph.
what its extension.
--check-outlines Call `FT_Outline_Decompose' on each glyph.
--dir <dir> Append <dir> to the list of directories to search
for good fonts.
for good fonts. No recursive search.
--error-count <cnt> Introduce <cnt> single-byte errors into the
erroneous fonts.
erroneous fonts (default: 1).
--error-fraction <frac> Multiply the file size of the font by <frac> and
introduce that many errors into the erroneous
font file.
--ext <ext> Add <ext> to the set of font types tested. Known
extensions are `ttf', `otf', `ttc', `cid', `pfb',
`pfa', `bdf', `pcf', `pfr', `fon', `otb', and
`cff'.
font file. <frac> should be in the range [0;1]
(default: 0.0).
--ext <ext> Add <ext> to the set of font types tested.
--help Print out this list of options.
--nohints Specify FT_LOAD_NO_HINTING when loading glyphs.
--rasterize Call FT_Render_Glyph as well as loading it.
--rasterize Call `FT_Render_Glyph' as well as loading it.
--result <dir> This is the directory in which test files are
placed.
--test <file> Run a single test on a pre-generated testcase.
Done in the current process so it can be debugged
more easily.
This is done in the current process so it can be
debugged more easily.
The default font extensions tested by ftrandom are
.ttf .otf .ttc .cid .pfb .pfa .bdf .pcf .pfr .fon .otb .cff
The default font directory is controlled by the macro `GOOD_FONTS_DIR' in
the source code (and can be thus specified during compilation); its default
value is
/usr/local/share/fonts
The default result directory is `results' (in the current directory).
Compilation
-----------
Two possible solutions.
. Run ftrandom within a debugging tool like `valgrind' to catch various
memory issues.
. Compile FreeType with sanitizer flags as provided by gcc or clang, for
example, then link it with ftrandom.
@@ -29,6 +29,9 @@
/* This file is now part of the FreeType library */
#define _XOPEN_SOURCE 500 /* for `kill', `strdup', `random', and `srandom' */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -38,7 +41,6 @@
#include <sys/wait.h>
#include <unistd.h>
#include <dirent.h>
#include <math.h>
#include <signal.h>
#include <time.h>
@@ -56,7 +58,7 @@
static int rasterize = false;
static char* results_dir = "results";
#define GOOD_FONTS_DIR "/home/wl/freetype-testfonts"
#define GOOD_FONTS_DIR "/usr/local/share/fonts"
static char* default_dir_list[] =
{
@@ -81,28 +83,31 @@
NULL
};
static int error_count = 1;
static int error_fraction = 0;
static unsigned int error_count = 1;
static double error_fraction = 0.0;
static FT_F26Dot6 font_size = 12 * 64;
static struct fontlist
{
char* name;
int len;
long len;
unsigned int isbinary: 1;
unsigned int isascii: 1;
unsigned int ishex: 1;
} *fontlist;
static int fcnt;
static unsigned int fcnt;
static int
FT_MoveTo( const FT_Vector *to,
void *user )
{
FT_UNUSED( to );
FT_UNUSED( user );
return 0;
}
@@ -111,6 +116,9 @@
FT_LineTo( const FT_Vector *to,
void *user )
{
FT_UNUSED( to );
FT_UNUSED( user );
return 0;
}
@@ -120,6 +128,10 @@
const FT_Vector *to,
void *user )
{
FT_UNUSED( _cp );
FT_UNUSED( to );
FT_UNUSED( user );
return 0;
}
@@ -130,6 +142,11 @@
const FT_Vector *to,
void *user )
{
FT_UNUSED( cp1 );
FT_UNUSED( cp2 );
FT_UNUSED( to );
FT_UNUSED( user );
return 0;
}
@@ -147,8 +164,8 @@
static void
TestFace( FT_Face face )
{
int gid;
int load_flags = FT_LOAD_DEFAULT;
unsigned int gid;
int load_flags = FT_LOAD_DEFAULT;
if ( check_outlines &&
@@ -202,7 +219,7 @@
TestFace( face );
else
{
int i, num;
long i, num;
num = face->num_faces;
@@ -215,6 +232,8 @@
}
}
FT_Done_FreeType( context );
exit( 0 );
}
@@ -329,9 +348,10 @@
FindFonts( char** fontdirs,
char** extensions )
{
int i, max;
char buffer[1025];
struct stat statb;
int i;
unsigned int max;
char buffer[1025];
struct stat statb;
max = 0;
@@ -392,13 +412,13 @@
}
static int
static unsigned int
getErrorCnt( struct fontlist* item )
{
if ( error_count == 0 && error_fraction == 0 )
if ( error_count == 0 && error_fraction == 0.0 )
return 0;
return error_count + ceil( error_fraction * item->len );
return error_count + (unsigned int)( error_fraction * item->len );
}
@@ -417,10 +437,10 @@
copyfont( struct fontlist* item,
char* newfont )
{
static char buffer[8096];
FILE *good, *new;
int len;
int i, err_cnt;
static char buffer[8096];
FILE *good, *new;
size_t len;
unsigned int i, err_cnt;
good = fopen( item->name, "r" );
@@ -446,7 +466,7 @@
err_cnt = getErrorCnt( item );
for ( i = 0; i < err_cnt; ++i )
{
fseek( new, getRandom( 0, item->len - 1 ), SEEK_SET );
fseek( new, getRandom( 0, (int)( item->len - 1 ) ), SEEK_SET );
if ( item->isbinary )
putc( getRandom( 0, 0xFF ), new );
@@ -484,6 +504,8 @@
static void
abort_test( int sig )
{
FT_UNUSED( sig );
/* If a time-out happens, then kill the child */
kill( child_pid, SIGFPE );
write( 2, "Timeout... ", 11 );
@@ -493,7 +515,7 @@
static void
do_test( void )
{
int i = getRandom( 0, fcnt - 1 );
int i = getRandom( 0, (int)( fcnt - 1 ) );
static int test_num = 0;
char buffer[1024];
@@ -534,22 +556,42 @@
usage( FILE* out,
char* name )
{
char** d = default_dir_list;
char** e = default_ext_list;
fprintf( out, "%s [options] -- Generate random erroneous fonts\n"
" and attempt to parse them with FreeType.\n\n", name );
fprintf( out, " --all All non-directory files are assumed to be fonts.\n" );
fprintf( out, " --check-outlines Make sure we can parse the outlines of each glyph.\n" );
fprintf( out, " --dir <path> Append <path> to list of font search directories.\n" );
fprintf( out, " --error-count <cnt> Introduce <cnt> single byte errors into each font.\n" );
fprintf( out, " --dir <path> Append <path> to list of font search directories\n"
" (no recursive search).\n" );
fprintf( out, " --error-count <cnt> Introduce <cnt> single byte errors into each font\n"
" (default: 1)\n" );
fprintf( out, " --error-fraction <frac> Introduce <frac>*filesize single byte errors\n"
" into each font.\n" );
" into each font (default: 0.0).\n" );
fprintf( out, " --ext <ext> Add <ext> to list of extensions indicating fonts.\n" );
fprintf( out, " --help Print this.\n" );
fprintf( out, " --nohints Turn off hinting.\n" );
fprintf( out, " --rasterize Attempt to rasterize each glyph.\n" );
fprintf( out, " --results <dir> Directory in which to place the test fonts.\n" );
fprintf( out, " --results <path> Place the created test fonts into <path>\n"
" (default: `results')\n" );
fprintf( out, " --size <float> Use the given font size for the tests.\n" );
fprintf( out, " --test <file> Run a single test on an already existing file.\n" );
fprintf( out, "\n" );
fprintf( out, "Default font extensions:\n" );
fprintf( out, " " );
while ( *e )
fprintf( out, " .%s", *e++ );
fprintf( out, "\n" );
fprintf( out, "Default font directories:\n" );
fprintf( out, " " );
while ( *d )
fprintf( out, " %s", *d++ );
fprintf( out, "\n" );
}
@@ -564,8 +606,8 @@
char* testfile = NULL;
dirs = calloc( argc + 1, sizeof ( char ** ) );
exts = calloc( argc + 1, sizeof ( char ** ) );
dirs = calloc( (size_t)( argc + 1 ), sizeof ( char ** ) );
exts = calloc( (size_t)( argc + 1 ), sizeof ( char ** ) );
for ( i = 1; i < argc; ++i )
{
@@ -585,9 +627,9 @@
else if ( strcmp( pt, "-error-count" ) == 0 )
{
if ( !rset )
error_fraction = 0;
error_fraction = 0.0;
rset = true;
error_count = strtol( argv[++i], &end, 10 );
error_count = (unsigned int)strtoul( argv[++i], &end, 10 );
if ( *end != '\0' )
{
fprintf( stderr, "Bad value for error-count: %s\n", argv[i] );
@@ -605,6 +647,11 @@
fprintf( stderr, "Bad value for error-fraction: %s\n", argv[i] );
exit( 1 );
}
if ( error_fraction < 0.0 || error_fraction > 1.0 )
{
fprintf( stderr, "error-fraction must be in the range [0;1]\n" );
exit( 1 );
}
}
else if ( strcmp( pt, "-ext" ) == 0 )
exts[ecnt++] = argv[++i];
@@ -658,7 +705,7 @@
ExecuteTest( testfile ); /* This should never return */
time( &now );
srandom( now );
srandom( (unsigned int)now );
FindFonts( dirs, exts );
mkdir( results_dir, 0755 );
+47 -6
View File
@@ -61,26 +61,48 @@
static FT_Error
tt_property_set( FT_Module module, /* TT_Driver */
const char* property_name,
const void* value )
const void* value,
FT_Bool value_is_string )
{
FT_Error error = FT_Err_Ok;
TT_Driver driver = (TT_Driver)module;
#ifndef FT_CONFIG_OPTION_ENVIRONMENT_PROPERTIES
FT_UNUSED( value_is_string );
#endif
if ( !ft_strcmp( property_name, "interpreter-version" ) )
{
FT_UInt* interpreter_version = (FT_UInt*)value;
FT_UInt interpreter_version;
if ( *interpreter_version == TT_INTERPRETER_VERSION_35
#ifdef FT_CONFIG_OPTION_ENVIRONMENT_PROPERTIES
if ( value_is_string )
{
const char* s = (const char*)value;
interpreter_version = (FT_UInt)ft_strtol( s, NULL, 10 );
}
else
#endif
{
FT_UInt* iv = (FT_UInt*)value;
interpreter_version = *iv;
}
if ( interpreter_version == TT_INTERPRETER_VERSION_35
#ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY
|| *interpreter_version == TT_INTERPRETER_VERSION_38
|| interpreter_version == TT_INTERPRETER_VERSION_38
#endif
#ifdef TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL
|| *interpreter_version == TT_INTERPRETER_VERSION_40
|| interpreter_version == TT_INTERPRETER_VERSION_40
#endif
)
driver->interpreter_version = *interpreter_version;
driver->interpreter_version = interpreter_version;
else
error = FT_ERR( Unimplemented_Feature );
@@ -317,6 +339,25 @@
{
error = tt_size_reset( ttsize );
ttsize->root.metrics = ttsize->metrics;
#ifdef TT_USE_BYTECODE_INTERPRETER
/* for the `MPS' bytecode instruction we need the point size */
{
FT_UInt resolution = ttsize->metrics.x_ppem > ttsize->metrics.y_ppem
? req->horiResolution
: req->vertResolution;
/* if we don't have a resolution value, assume 72dpi */
if ( req->type == FT_SIZE_REQUEST_TYPE_SCALES ||
!resolution )
resolution = 72;
ttsize->point_size = FT_MulDiv( ttsize->ttmetrics.ppem,
64 * 72,
resolution );
}
#endif
}
return error;
+10 -11
View File
@@ -1436,13 +1436,12 @@
FT_TRACE5(( " nesting level: %d\n", recurse_count ));
#endif
/* some fonts have an incorrect value of `maxComponentDepth', */
/* thus we allow depth 1 to catch the majority of them */
if ( recurse_count > 1 &&
recurse_count > face->max_profile.maxComponentDepth )
/* some fonts have an incorrect value of `maxComponentDepth' */
if ( recurse_count > face->max_profile.maxComponentDepth )
{
error = FT_THROW( Invalid_Composite );
goto Exit;
FT_TRACE1(( "load_truetype_glyph: maxComponentDepth set to %d\n",
recurse_count ));
face->max_profile.maxComponentDepth = (FT_UShort)recurse_count;
}
#ifndef FT_CONFIG_OPTION_INCREMENTAL
@@ -1808,11 +1807,11 @@
for ( i = 0; i < limit; i++, subglyph++ )
{
/* XXX: overflow check for subglyph->{arg1,arg2}. */
/* Deltas must be within signed 16-bit, */
/* but the restriction of summed deltas is not clear */
subglyph->arg1 = (FT_Int16)points[i].x;
subglyph->arg2 = (FT_Int16)points[i].y;
if ( subglyph->flags & ARGS_ARE_XY_VALUES )
{
subglyph->arg1 = (FT_Int16)points[i].x;
subglyph->arg2 = (FT_Int16)points[i].y;
}
}
loader->pp1.x = points[i + 0].x;
+55 -46
View File
@@ -158,48 +158,49 @@
return NULL;
}
if ( FT_NEW_ARRAY( points, n ) )
/* in the nested loops below we increase `i' twice; */
/* it is faster to simply allocate one more slot */
/* than to add another test within the loop */
if ( FT_NEW_ARRAY( points, n + 1 ) )
return NULL;
*point_cnt = n;
i = 0;
first = 0;
i = 0;
while ( i < n )
{
runcnt = FT_GET_BYTE();
if ( runcnt & GX_PT_POINTS_ARE_WORDS )
{
runcnt &= GX_PT_POINT_RUN_COUNT_MASK;
first = FT_GET_USHORT();
first += FT_GET_USHORT();
points[i++] = first;
if ( runcnt < 1 || i + runcnt > n )
goto Exit;
/* first point not included in run count */
for ( j = 0; j < runcnt; j++ )
{
first += FT_GET_USHORT();
points[i++] = first;
if ( i >= n )
break;
}
}
else
{
first = FT_GET_BYTE();
first += FT_GET_BYTE();
points[i++] = first;
if ( runcnt < 1 || i + runcnt > n )
goto Exit;
for ( j = 0; j < runcnt; j++ )
{
first += FT_GET_BYTE();
points[i++] = first;
if ( i >= n )
break;
}
}
}
Exit:
return points;
}
@@ -1716,12 +1717,11 @@
/* modeled after `Ins_IUP */
static void
tt_handle_deltas( FT_Outline* outline,
FT_Vector* in_points,
FT_Bool* has_delta )
tt_interpolate_deltas( FT_Outline* outline,
FT_Vector* out_points,
FT_Vector* in_points,
FT_Bool* has_delta )
{
FT_Vector* out_points;
FT_Int first_point;
FT_Int end_point;
@@ -1736,8 +1736,6 @@
if ( !outline->n_contours )
return;
out_points = outline->points;
contour = 0;
point = 0;
@@ -1841,6 +1839,7 @@
GX_Blend blend = face->blend;
FT_Vector* points_org = NULL;
FT_Vector* points_out = NULL;
FT_Bool* has_delta = NULL;
FT_Error error;
@@ -1872,6 +1871,7 @@
}
if ( FT_NEW_ARRAY( points_org, n_points ) ||
FT_NEW_ARRAY( points_out, n_points ) ||
FT_NEW_ARRAY( has_delta, n_points ) )
goto Fail1;
@@ -1894,7 +1894,8 @@
offsetToData = FT_GET_USHORT();
/* rough sanity test */
if ( offsetToData + tupleCount * 4 > blend->gvar_size )
if ( offsetToData + ( tupleCount & GX_TC_TUPLE_COUNT_MASK ) * 4 >
blend->gvar_size )
{
FT_TRACE2(( "TT_Vary_Apply_Glyph_Deltas:"
" invalid glyph variation array header\n" ));
@@ -1922,6 +1923,9 @@
FT_TRACE5(( "gvar: there are %d tuples:\n",
tupleCount & GX_TC_TUPLE_COUNT_MASK ));
for ( j = 0; j < n_points; j++ )
points_org[j] = outline->points[j];
for ( i = 0; i < ( tupleCount & GX_TC_TUPLE_COUNT_MASK ); i++ )
{
FT_UInt tupleDataSize;
@@ -1976,10 +1980,10 @@
here = FT_Stream_FTell( stream );
FT_Stream_SeekSet( stream, offsetToData );
if ( tupleIndex & GX_TI_PRIVATE_POINT_NUMBERS )
{
FT_Stream_SeekSet( stream, offsetToData );
localpoints = ft_var_readpackedpoints( stream,
blend->gvar_size,
&point_count );
@@ -2015,22 +2019,20 @@
/* this means that there are deltas for every point in the glyph */
for ( j = 0; j < n_points; j++ )
{
#ifdef FT_DEBUG_LEVEL_TRACE
FT_Vector point_org = outline->points[j];
#endif
FT_Pos delta_x = FT_MulFix( deltas_x[j], apply );
FT_Pos delta_y = FT_MulFix( deltas_y[j], apply );
outline->points[j].x += FT_MulFix( deltas_x[j], apply );
outline->points[j].y += FT_MulFix( deltas_y[j], apply );
outline->points[j].x += delta_x;
outline->points[j].y += delta_y;
#ifdef FT_DEBUG_LEVEL_TRACE
if ( ( point_org.x != outline->points[j].x ) ||
( point_org.y != outline->points[j].y ) )
if ( delta_x || delta_y )
{
FT_TRACE7(( " %d: (%d, %d) -> (%d, %d)\n",
j,
point_org.x,
point_org.y,
outline->points[j].x - delta_x,
outline->points[j].y - delta_y,
outline->points[j].x,
outline->points[j].y ));
count++;
@@ -2044,9 +2046,6 @@
#endif
}
else if ( localpoints == NULL )
; /* failure, ignore it */
else
{
#ifdef FT_DEBUG_LEVEL_TRACE
@@ -2058,13 +2057,13 @@
/* IUP bytecode instruction */
for ( j = 0; j < n_points; j++ )
{
points_org[j] = outline->points[j];
has_delta[j] = FALSE;
points_out[j] = points_org[j];
}
for ( j = 0; j < point_count; j++ )
{
FT_UShort idx = localpoints[j];
FT_UShort idx = points[j];
if ( idx >= n_points )
@@ -2072,34 +2071,43 @@
has_delta[idx] = TRUE;
outline->points[idx].x += FT_MulFix( deltas_x[j], apply );
outline->points[idx].y += FT_MulFix( deltas_y[j], apply );
points_out[idx].x += FT_MulFix( deltas_x[j], apply );
points_out[idx].y += FT_MulFix( deltas_y[j], apply );
}
/* no need to handle phantom points here, */
/* since solitary points can't be interpolated */
tt_handle_deltas( outline,
points_org,
has_delta );
tt_interpolate_deltas( outline,
points_out,
points_org,
has_delta );
#ifdef FT_DEBUG_LEVEL_TRACE
FT_TRACE7(( " point deltas:\n" ));
for ( j = 0; j < n_points; j++)
for ( j = 0; j < n_points; j++ )
{
if ( ( points_org[j].x != outline->points[j].x ) ||
( points_org[j].y != outline->points[j].y ) )
FT_Pos delta_x = points_out[j].x - points_org[j].x;
FT_Pos delta_y = points_out[j].y - points_org[j].y;
outline->points[j].x += delta_x;
outline->points[j].y += delta_y;
#ifdef FT_DEBUG_LEVEL_TRACE
if ( delta_x || delta_y )
{
FT_TRACE7(( " %d: (%d, %d) -> (%d, %d)\n",
j,
points_org[j].x,
points_org[j].y,
outline->points[j].x - delta_x,
outline->points[j].y - delta_y,
outline->points[j].x,
outline->points[j].y ));
count++;
}
#endif
}
#ifdef FT_DEBUG_LEVEL_TRACE
if ( !count )
FT_TRACE7(( " none\n" ));
#endif
@@ -2128,6 +2136,7 @@
Fail1:
FT_FREE( points_org );
FT_FREE( points_out );
FT_FREE( has_delta );
return error;
+141 -33
View File
@@ -26,10 +26,14 @@
#include FT_TRIGONOMETRY_H
#include FT_SYSTEM_H
#include FT_TRUETYPE_DRIVER_H
#include FT_MULTIPLE_MASTERS_H
#include "ttinterp.h"
#include "tterrors.h"
#include "ttsubpix.h"
#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
#include "ttgxvar.h"
#endif
#ifdef TT_USE_BYTECODE_INTERPRETER
@@ -74,14 +78,6 @@
exc->func_dualproj( exc, (v)->x, (v)->y )
/*************************************************************************/
/* */
/* Instruction dispatch function, as used by the interpreter. */
/* */
typedef void (*TInstruction_Function)( TT_ExecContext exc,
FT_Long* args );
/*************************************************************************/
/* */
/* Two simple bounds-checking macros. */
@@ -404,6 +400,7 @@
exec->maxIDefs = size->max_instruction_defs;
exec->FDefs = size->function_defs;
exec->IDefs = size->instruction_defs;
exec->pointSize = size->point_size;
exec->tt_metrics = size->ttmetrics;
exec->metrics = size->metrics;
@@ -689,17 +686,17 @@
/* IUP[0] */ PACK( 0, 0 ),
/* IUP[1] */ PACK( 0, 0 ),
/* SHP[0] */ PACK( 0, 0 ),
/* SHP[1] */ PACK( 0, 0 ),
/* SHP[0] */ PACK( 0, 0 ), /* loops */
/* SHP[1] */ PACK( 0, 0 ), /* loops */
/* SHC[0] */ PACK( 1, 0 ),
/* SHC[1] */ PACK( 1, 0 ),
/* SHZ[0] */ PACK( 1, 0 ),
/* SHZ[1] */ PACK( 1, 0 ),
/* SHPIX */ PACK( 1, 0 ),
/* IP */ PACK( 0, 0 ),
/* SHPIX */ PACK( 1, 0 ), /* loops */
/* IP */ PACK( 0, 0 ), /* loops */
/* MSIRP[0] */ PACK( 2, 0 ),
/* MSIRP[1] */ PACK( 2, 0 ),
/* AlignRP */ PACK( 0, 0 ),
/* AlignRP */ PACK( 0, 0 ), /* loops */
/* RTDG */ PACK( 0, 0 ),
/* MIAP[0] */ PACK( 2, 0 ),
/* MIAP[1] */ PACK( 2, 0 ),
@@ -772,7 +769,7 @@
/* SANGW */ PACK( 1, 0 ),
/* AA */ PACK( 1, 0 ),
/* FlipPT */ PACK( 0, 0 ),
/* FlipPT */ PACK( 0, 0 ), /* loops */
/* FlipRgON */ PACK( 2, 0 ),
/* FlipRgOFF */ PACK( 2, 0 ),
/* INS_$83 */ PACK( 0, 0 ),
@@ -790,8 +787,8 @@
/* INS_$8F */ PACK( 0, 0 ),
/* INS_$90 */ PACK( 0, 0 ),
/* INS_$91 */ PACK( 0, 0 ),
/* INS_$92 */ PACK( 0, 0 ),
/* GETVAR */ PACK( 0, 0 ), /* will be handled specially */
/* GETDATA */ PACK( 0, 1 ),
/* INS_$93 */ PACK( 0, 0 ),
/* INS_$94 */ PACK( 0, 0 ),
/* INS_$95 */ PACK( 0, 0 ),
@@ -1073,8 +1070,13 @@
"7 INS_$8F",
"7 INS_$90",
#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
"6 GETVAR",
"7 GETDATA",
#else
"7 INS_$91",
"7 INS_$92",
#endif
"7 INS_$93",
"7 INS_$94",
"7 INS_$95",
@@ -2582,13 +2584,20 @@
Ins_MPS( TT_ExecContext exc,
FT_Long* args )
{
/* Note: The point size should be irrelevant in a given font program; */
/* we thus decide to return only the PPEM value. */
#if 0
args[0] = exc->metrics.pointSize;
#else
args[0] = exc->func_cur_ppem( exc );
#endif
if ( NO_SUBPIXEL_HINTING )
{
/* Microsoft's GDI bytecode interpreter always returns value 12; */
/* we return the current PPEM value instead. */
args[0] = exc->func_cur_ppem( exc );
}
else
{
/* A possible practical application of the MPS instruction is to */
/* implement optical scaling and similar features, which should be */
/* based on perceptual attributes, thus independent of the */
/* resolution. */
args[0] = exc->pointSize;
}
}
@@ -2881,7 +2890,7 @@
/* */
/* NEG[]: NEGate */
/* Opcode range: 0x65 */
/* Stack: f26.6 --> f26.6 */
/* Stack: f26.6 --> f26.6 */
/* */
static void
Ins_NEG( FT_Long* args )
@@ -3121,7 +3130,7 @@
/*************************************************************************/
/* */
/* MAX[]: MAXimum */
/* Opcode range: 0x68 */
/* Opcode range: 0x8B */
/* Stack: int32? int32? --> int32 */
/* */
static void
@@ -3135,7 +3144,7 @@
/*************************************************************************/
/* */
/* MIN[]: MINimum */
/* Opcode range: 0x69 */
/* Opcode range: 0x8C */
/* Stack: int32? int32? --> int32 */
/* */
static void
@@ -4010,6 +4019,7 @@
exc->error = FT_THROW( Nested_DEFS );
return;
case 0x2D: /* ENDF */
def->end = exc->IP;
return;
}
}
@@ -4493,7 +4503,7 @@
/* */
/* FLIPOFF[]: Set auto-FLIP to OFF */
/* Opcode range: 0x4E */
/* Stack: --> */
/* Stack: --> */
/* */
static void
Ins_FLIPOFF( TT_ExecContext exc )
@@ -6096,7 +6106,6 @@
exc->GS.freeVector.x != 0 &&
!( exc->sph_tweak_flags & SPH_TWEAK_NORMAL_ROUND ) )
control_value_cutin = minimum_distance = 0;
else
#endif /* TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY */
/* XXX: UNDOCUMENTED! cvt[-1] = 0 always */
@@ -7236,7 +7245,7 @@
/* Return Bit(s): 8 */
/* */
if ( ( args[0] & 2 ) != 0 && exc->tt_metrics.rotated )
K |= 0x80;
K |= 1 << 8;
/********************************/
/* GLYPH STRETCHED */
@@ -7244,7 +7253,18 @@
/* Return Bit(s): 9 */
/* */
if ( ( args[0] & 4 ) != 0 && exc->tt_metrics.stretched )
K |= 1 << 8;
K |= 1 << 9;
#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
/********************************/
/* VARIATION GLYPH */
/* Selector Bit: 3 */
/* Return Bit(s): 10 */
/* */
/* XXX: UNDOCUMENTED! */
if ( (args[0] & 8 ) != 0 && exc->face->blend )
K |= 1 << 10;
#endif
/********************************/
/* BI-LEVEL HINTING AND */
@@ -7388,6 +7408,57 @@
}
#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
/*************************************************************************/
/* */
/* GETVARIATION[]: get normalized variation (blend) coordinates */
/* Opcode range: 0x91 */
/* Stack: --> f2.14... */
/* */
/* XXX: UNDOCUMENTED! There is no official documentation from Apple for */
/* this bytecode instruction. Active only if a font has GX */
/* variation axes. */
/* */
static void
Ins_GETVARIATION( TT_ExecContext exc,
FT_Long* args )
{
FT_UInt num_axes = exc->face->blend->num_axis;
FT_Fixed* coords = exc->face->blend->normalizedcoords;
FT_UInt i;
if ( BOUNDS( num_axes, exc->stackSize + 1 - exc->top ) )
{
exc->error = FT_THROW( Stack_Overflow );
return;
}
for ( i = 0; i < num_axes; i++ )
args[i] = coords[i] >> 2; /* convert 16.16 to 2.14 format */
}
/*************************************************************************/
/* */
/* GETDATA[]: no idea what this is good for */
/* Opcode range: 0x92 */
/* Stack: --> 17 */
/* */
/* XXX: UNDOCUMENTED! There is no documentation from Apple for this */
/* very weird bytecode instruction. */
/* */
static void
Ins_GETDATA( FT_Long* args )
{
args[0] = 17;
}
#endif /* TT_CONFIG_OPTION_GX_VAR_SUPPORT */
static void
Ins_UNKNOWN( TT_ExecContext exc )
{
@@ -7574,7 +7645,21 @@
exc->args = 0;
}
exc->new_top = exc->args + ( Pop_Push_Count[exc->opcode] & 15 );
#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
if ( exc->opcode == 0x91 )
{
/* this is very special: GETVARIATION returns */
/* a variable number of arguments */
/* it is the job of the application to `activate' GX handling, */
/* this is, calling any of the GX API functions on the current */
/* font to select a variation instance */
if ( exc->face->blend )
exc->new_top = exc->args + exc->face->blend->num_axis;
}
else
#endif
exc->new_top = exc->args + ( Pop_Push_Count[exc->opcode] & 15 );
/* `new_top' is the new top of the stack, after the instruction's */
/* execution. `top' will be set to `new_top' after the `switch' */
@@ -7767,7 +7852,7 @@
Ins_ALIGNPTS( exc, args );
break;
case 0x28: /* ???? */
case 0x28: /* RAW */
Ins_UNKNOWN( exc );
break;
@@ -8119,10 +8204,33 @@
Ins_INSTCTRL( exc, args );
break;
case 0x8F:
case 0x8F: /* ADJUST */
case 0x90: /* ADJUST */
Ins_UNKNOWN( exc );
break;
#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
case 0x91:
/* it is the job of the application to `activate' GX handling, */
/* this is, calling any of the GX API functions on the current */
/* font to select a variation instance */
if ( exc->face->blend )
Ins_GETVARIATION( exc, args );
else
Ins_UNKNOWN( exc );
break;
case 0x92:
/* there is at least one MS font (LaoUI.ttf version 5.01) that */
/* uses IDEFs for 0x91 and 0x92; for this reason we activate */
/* GETDATA for GX fonts only, similar to GETVARIATION */
if ( exc->face->blend )
Ins_GETDATA( args );
else
Ins_UNKNOWN( exc );
break;
#endif
default:
if ( opcode >= 0xE0 )
Ins_MIRP( exc, args );
@@ -170,6 +170,7 @@ FT_BEGIN_HEADER
pts,
twilight;
FT_Long pointSize; /* in 26.6 format */
FT_Size_Metrics metrics;
TT_Size_Metrics tt_metrics; /* size metrics */
@@ -286,6 +286,8 @@ FT_BEGIN_HEADER
#ifdef TT_USE_BYTECODE_INTERPRETER
FT_Long point_size; /* for the `MPS' bytecode instruction */
FT_UInt num_function_defs; /* number of function definitions */
FT_UInt max_function_defs;
TT_DefArray function_defs; /* table of function definitions */
+7 -1
View File
@@ -321,7 +321,7 @@
mmvar->num_axis = mmaster.num_axis;
mmvar->num_designs = mmaster.num_designs;
mmvar->num_namedstyles = ~0U; /* Does not apply */
mmvar->num_namedstyles = 0; /* Not supported */
mmvar->axis = (FT_Var_Axis*)&mmvar[1];
/* Point to axes after MM_Var struct */
mmvar->namedstyle = NULL;
@@ -1776,6 +1776,12 @@
}
}
if ( !n )
{
error = FT_THROW( Invalid_File_Format );
goto Fail;
}
loader->num_glyphs = n;
/* if /.notdef is found but does not occupy index 0, do our magic. */
+2 -1
View File
@@ -81,7 +81,8 @@
if ( glyph_name[0] == gname[0] && !ft_strcmp( glyph_name, gname ) )
return (FT_UInt)ft_atol( (const char *)face->type1.charstrings[i] );
return (FT_UInt)ft_strtol( (const char *)face->type1.charstrings[i],
NULL, 10 );
}
return 0;
+3 -2
View File
@@ -656,8 +656,9 @@
FT_TRACE1(( "T42_GlyphSlot_Load: glyph index %d\n", glyph_index ));
/* map T42 glyph index to embedded TTF's glyph index */
glyph_index = (FT_UInt)ft_atol(
(const char *)t42face->type1.charstrings[glyph_index] );
glyph_index = (FT_UInt)ft_strtol(
(const char *)t42face->type1.charstrings[glyph_index],
NULL, 10 );
t42_glyphslot_clear( t42slot->ttslot );
error = ttclazz->load_glyph( t42slot->ttslot,
+10 -1
View File
@@ -759,6 +759,14 @@
if ( error )
goto Fail;
/* sanity check */
if ( !face->font->header.pixel_height )
{
FT_TRACE2(( "invalid pixel height\n" ));
error = FT_THROW( Invalid_File_Format );
goto Fail;
}
/* we now need to fill the root FT_Face fields */
/* with relevant information */
{
@@ -1062,7 +1070,8 @@
bitmap->rows = font->header.pixel_height;
bitmap->pixel_mode = FT_PIXEL_MODE_MONO;
if ( offset + pitch * bitmap->rows > font->header.file_size )
if ( !pitch ||
offset + pitch * bitmap->rows > font->header.file_size )
{
FT_TRACE2(( "invalid bitmap width\n" ));
error = FT_THROW( Invalid_File_Format );