updated freetype to 2.3.6

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25977 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Jérôme Duval 2008-06-16 20:51:14 +00:00
parent 4498384dd3
commit 49a0ff0c19
110 changed files with 4563 additions and 1193 deletions

View File

@ -139,13 +139,65 @@ FT_BEGIN_HEADER
/*************************************************************************/
/* */
/* IntN types */
/* <Section> */
/* basic_types */
/* */
/* Used to guarantee the size of some specific integers. */
/*************************************************************************/
/*************************************************************************/
/* */
/* <Type> */
/* FT_Int16 */
/* */
/* <Description> */
/* A typedef for a 16bit signed integer type. */
/* */
typedef signed short FT_Int16;
/*************************************************************************/
/* */
/* <Type> */
/* FT_UInt16 */
/* */
/* <Description> */
/* A typedef for a 16bit unsigned integer type. */
/* */
typedef signed short FT_Int16;
typedef unsigned short FT_UInt16;
/* */
/* this #if 0 ... #endif clause is for documentation purposes */
#if 0
/*************************************************************************/
/* */
/* <Type> */
/* FT_Int32 */
/* */
/* <Description> */
/* A typedef for a 32bit signed integer type. The size depends on */
/* the configuration. */
/* */
typedef signed XXX FT_Int32;
/*************************************************************************/
/* */
/* <Type> */
/* FT_UInt32 */
/* */
/* A typedef for a 32bit unsigned integer type. The size depends on */
/* the configuration. */
/* */
typedef unsigned XXX FT_UInt32;
/* */
#endif
#if FT_SIZEOF_INT == (32 / FT_CHAR_BIT)
typedef signed int FT_Int32;

View File

@ -4,7 +4,7 @@
/* */
/* Build macros of the FreeType 2 library. */
/* */
/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006, 2007 by */
/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@ -156,6 +156,7 @@
#define FT_CONFIG_MODULES_H <freetype/config/ftmodule.h>
#endif
/* */
/* public headers */
@ -383,6 +384,20 @@
#define FT_BDF_H <freetype/ftbdf.h>
/*************************************************************************
*
* @macro:
* FT_CID_H
*
* @description:
* A macro used in #include statements to name the file containing the
* definitions of an API which access CID font information from a
* face.
*
*/
#define FT_CID_H <freetype/ftcid.h>
/*************************************************************************
*
* @macro:
@ -678,6 +693,30 @@
#define FT_LCD_FILTER_H <freetype/ftlcdfil.h>
/*************************************************************************
*
* @macro:
* FT_UNPATENTED_HINTING_H
*
* @description:
* A macro used in #include statements to name the file containing the
* FreeType 2 API which performs color filtering for subpixel rendering.
*/
#define FT_UNPATENTED_HINTING_H <freetype/ttunpat.h>
/*************************************************************************
*
* @macro:
* FT_INCREMENTAL_H
*
* @description:
* A macro used in #include statements to name the file containing the
* FreeType 2 API which performs color filtering for subpixel rendering.
*/
#define FT_INCREMENTAL_H <freetype/ftincrem.h>
/*************************************************************************
*
* @macro:

View File

@ -4,7 +4,7 @@
/* */
/* User-selectable configuration macros (specification only). */
/* */
/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006, 2007 by */
/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@ -436,6 +436,7 @@ FT_BEGIN_HEADER
#define TT_CONFIG_CMAP_FORMAT_8
#define TT_CONFIG_CMAP_FORMAT_10
#define TT_CONFIG_CMAP_FORMAT_12
#define TT_CONFIG_CMAP_FORMAT_14
/*************************************************************************/
@ -624,7 +625,8 @@ FT_BEGIN_HEADER
/*************************************************************************/
/* */
/* Compile autofit module with CJK script support. */
/* Compile autofit module with CJK (Chinese, Japanese, Korean) script */
/* support. */
/* */
#define AF_CONFIG_OPTION_CJK

View File

@ -4,7 +4,7 @@
/* */
/* FreeType high-level API and common types (specification only). */
/* */
/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006, 2007 by */
/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@ -799,6 +799,8 @@ FT_BEGIN_HEADER
/* provide localized and Unicode versions of */
/* this string. Applications should use the */
/* format specific interface to access them. */
/* Can be NULL (e.g., in fonts embedded in a */
/* PDF file). */
/* */
/* style_name :: The face's style name. This is an ASCII */
/* string, usually in English, which describes */
@ -1019,6 +1021,15 @@ FT_BEGIN_HEADER
/* the SFNT `gasp' table only if the native TrueType hinting engine */
/* (with the bytecode interpreter) is available and active. */
/* */
/* FT_FACE_FLAG_CID_KEYED :: */
/* Set if the font is CID-keyed. In that case, the font is not */
/* accessed by glyph indices but by CID values. For subsetted */
/* CID-keyed fonts this has the consequence that not all index */
/* values are a valid argument to FT_Load_Glyph. Only the CID */
/* values for which corresponding glyphs in the subsetted font */
/* exist make FT_Load_Glyph return successfully; in all other cases */
/* you get an `FT_Err_Invalid_Argument' error. */
/* */
#define FT_FACE_FLAG_SCALABLE ( 1L << 0 )
#define FT_FACE_FLAG_FIXED_SIZES ( 1L << 1 )
#define FT_FACE_FLAG_FIXED_WIDTH ( 1L << 2 )
@ -1031,6 +1042,7 @@ FT_BEGIN_HEADER
#define FT_FACE_FLAG_GLYPH_NAMES ( 1L << 9 )
#define FT_FACE_FLAG_EXTERNAL_STREAM ( 1L << 10 )
#define FT_FACE_FLAG_HINTER ( 1L << 11 )
#define FT_FACE_FLAG_CID_KEYED ( 1L << 12 )
/* */
@ -1187,6 +1199,24 @@ FT_BEGIN_HEADER
( face->face_flags & FT_FACE_FLAG_MULTIPLE_MASTERS )
/*************************************************************************
*
* @macro:
* FT_IS_CID_KEYED( face )
*
* @description:
* A macro that returns true whenever a face object contains a CID-keyed
* font. See the discussion of @FT_FACE_FLAG_CID_KEYED for more
* details.
*
* If this macro is true, all functions defined in @FT_CID_H are
* available.
*
*/
#define FT_IS_CID_KEYED( face ) \
( face->face_flags & FT_FACE_FLAG_CID_KEYED )
/*************************************************************************/
/* */
/* <Constant> */
@ -1198,11 +1228,17 @@ FT_BEGIN_HEADER
/* */
/* <Values> */
/* FT_STYLE_FLAG_ITALIC :: */
/* Indicates that a given face is italicized. */
/* Indicates that a given face style is italic or oblique. */
/* */
/* FT_STYLE_FLAG_BOLD :: */
/* Indicates that a given face is bold. */
/* */
/* <Note> */
/* The style information as provided by FreeType is very basic. More */
/* details are beyond the scope and should be done on a higher level */
/* (for example, by analyzing various fields of the `OS/2' table in */
/* SFNT based fonts). */
/* */
#define FT_STYLE_FLAG_ITALIC ( 1 << 0 )
#define FT_STYLE_FLAG_BOLD ( 1 << 1 )
@ -1214,7 +1250,7 @@ FT_BEGIN_HEADER
/* */
/* <Description> */
/* An opaque handle to an `FT_Size_InternalRec' structure, used to */
/* model private data of a given FT_Size object. */
/* model private data of a given @FT_Size object. */
/* */
typedef struct FT_Size_InternalRec_* FT_Size_Internal;
@ -1345,7 +1381,7 @@ FT_BEGIN_HEADER
/* */
/* <Description> */
/* An opaque handle to an `FT_Slot_InternalRec' structure, used to */
/* model private data of a given FT_GlyphSlot object. */
/* model private data of a given @FT_GlyphSlot object. */
/* */
typedef struct FT_Slot_InternalRec_* FT_Slot_Internal;
@ -2055,7 +2091,18 @@ FT_BEGIN_HEADER
FT_UInt horiResolution;
FT_UInt vertResolution;
} FT_Size_RequestRec, *FT_Size_Request;
} FT_Size_RequestRec;
/*************************************************************************/
/* */
/* <Struct> */
/* FT_Size_Request */
/* */
/* <Description> */
/* A handle to a size request structure. */
/* */
typedef struct FT_Size_RequestRec_ *FT_Size_Request;
/*************************************************************************/
@ -2186,6 +2233,11 @@ FT_BEGIN_HEADER
/* The loaded glyph may be transformed. See @FT_Set_Transform for */
/* the details. */
/* */
/* For subsetted CID-keyed fonts, `FT_Err_Invalid_Argument' is */
/* returned for invalid CID values (this is, for CID values which */
/* don't have a corresponding glyph in the font). See the discussion */
/* of the @FT_FACE_FLAG_CID_KEYED flag for more details. */
/* */
FT_EXPORT( FT_Error )
FT_Load_Glyph( FT_Face face,
FT_UInt glyph_index,
@ -2367,9 +2419,7 @@ FT_BEGIN_HEADER
#define FT_LOAD_IGNORE_TRANSFORM 0x800
#define FT_LOAD_MONOCHROME 0x1000
#define FT_LOAD_LINEAR_DESIGN 0x2000
/* temporary hack! */
#define FT_LOAD_SBITS_ONLY 0x4000
#define FT_LOAD_SBITS_ONLY 0x4000 /* temporary hack! */
#define FT_LOAD_NO_AUTOHINT 0x8000U
/* */
@ -2448,19 +2498,19 @@ FT_BEGIN_HEADER
#define FT_LOAD_TARGET_LCD_V FT_LOAD_TARGET_( FT_RENDER_MODE_LCD_V )
/*
/**************************************************************************
*
* @macro:
* FT_LOAD_TARGET_MODE
*
* @description:
* Return the @FT_Render_Mode corresponding to a given
* @FT_LOAD_TARGET_XXX value.
*
*/
#define FT_LOAD_TARGET_MODE( x ) ( (FT_Render_Mode)( ( (x) >> 16 ) & 15 ) )
/* */
/*************************************************************************/
/* */
@ -2537,9 +2587,11 @@ FT_BEGIN_HEADER
/* glyph outline in pixels and use the @FT_PIXEL_MODE_LCD_V mode. */
/* */
/* <Note> */
/* The LCD-optimized glyph bitmaps produced by FT_Render_Glyph are */
/* _not_ _filtered_ to reduce color-fringes. It is up to the caller */
/* to perform this pass. */
/* The LCD-optimized glyph bitmaps produced by FT_Render_Glyph can be */
/* filtered to reduce color-fringes by using @FT_Library_SetLcdFilter */
/* (not active in the default builds). It is up to the caller to */
/* either call @FT_Library_SetLcdFilter (if available) or do the */
/* filtering itself. */
/* */
typedef enum FT_Render_Mode_
{
@ -2821,7 +2873,8 @@ FT_BEGIN_HEADER
/* */
/* Because many fonts contain more than a single cmap for Unicode */
/* encoding, this function has some special code to select the one */
/* which covers Unicode best. It is thus preferable to */
/* which covers Unicode best (`best' in the sense that a UCS-4 cmap */
/* is preferred to a UCS-2 cmap). It is thus preferable to */
/* @FT_Set_Charmap in this case. */
/* */
FT_EXPORT( FT_Error )
@ -2851,6 +2904,8 @@ FT_BEGIN_HEADER
/* the face (i.e., if it is not listed in the `face->charmaps' */
/* table). */
/* */
/* It also fails if a type 14 charmap is selected. */
/* */
FT_EXPORT( FT_Error )
FT_Set_Charmap( FT_Face face,
FT_CharMap charmap );
@ -3091,6 +3146,223 @@ FT_BEGIN_HEADER
FT_Matrix *p_transform );
/*************************************************************************/
/* */
/* <Section> */
/* glyph_variants */
/* */
/* <Title> */
/* Glyph Variants */
/* */
/* <Abstract> */
/* The FreeType 2 interface to Unicode Ideographic Variation */
/* Sequences (IVS), using the SFNT cmap format 14. */
/* */
/* <Description> */
/* Many CJK characters have variant forms. They are a sort of grey */
/* area somewhere between being totally irrelevant and semantically */
/* distinct; for this reason, the Unicode consortium decided to */
/* introduce Ideographic Variation Sequences (IVS), consisting of a */
/* Unicode base character and one of 240 variant selectors */
/* (U+E0100-U+E01EF), instead of further extending the already huge */
/* code range for CJK characters. */
/* */
/* An IVS is registered and unique; for further details please refer */
/* to Unicode Technical Report #37, the Ideographic Variation */
/* Database. To date (October 2007), the character with the most */
/* variants is U+908A, having 8 such IVS. */
/* */
/* Adobe and MS decided to support IVS with a new cmap subtable */
/* (format 14). It is an odd subtable because it is not a mapping of */
/* input code points to glyphs, but contains lists of all variants */
/* supported by the font. */
/* */
/* A variant may be either `default' or `non-default'. A default */
/* variant is the one you will get for that code point if you look it */
/* up in the standard Unicode cmap. A non-default variant is a */
/* different glyph. */
/* */
/*************************************************************************/
/*************************************************************************/
/* */
/* <Function> */
/* FT_Face_GetCharVariantIndex */
/* */
/* <Description> */
/* Return the glyph index of a given character code as modified by */
/* the variation selector. */
/* */
/* <Input> */
/* face :: */
/* A handle to the source face object. */
/* */
/* charcode :: */
/* The character code point in Unicode. */
/* */
/* variantSelector :: */
/* The Unicode code point of the variation selector. */
/* */
/* <Return> */
/* The glyph index. 0 means either `undefined character code', or */
/* `undefined selector code', or `no variation selector cmap */
/* subtable', or `current CharMap is not Unicode'. */
/* */
/* <Note> */
/* If you use FreeType to manipulate the contents of font files */
/* directly, be aware that the glyph index returned by this function */
/* doesn't always correspond to the internal indices used within */
/* the file. This is done to ensure that value 0 always corresponds */
/* to the `missing glyph'. */
/* */
/* This function is only meaningful if */
/* a) the font has a variation selector cmap sub table, */
/* and */
/* b) the current charmap has a Unicode encoding. */
/* */
/* <Since> */
/* 2.3.6 */
/* */
FT_EXPORT( FT_UInt )
FT_Face_GetCharVariantIndex( FT_Face face,
FT_ULong charcode,
FT_ULong variantSelector );
/*************************************************************************/
/* */
/* <Function> */
/* FT_Face_GetCharVariantIsDefault */
/* */
/* <Description> */
/* Check whether this variant of this Unicode character is the one to */
/* be found in the `cmap'. */
/* */
/* <Input> */
/* face :: */
/* A handle to the source face object. */
/* */
/* charcode :: */
/* The character codepoint in Unicode. */
/* */
/* variantSelector :: */
/* The Unicode codepoint of the variation selector. */
/* */
/* <Return> */
/* 1 if found in the standard (Unicode) cmap, 0 if found in the */
/* variation selector cmap, or -1 if it is not a variant. */
/* */
/* <Note> */
/* This function is only meaningful if the font has a variation */
/* selector cmap subtable. */
/* */
/* <Since> */
/* 2.3.6 */
/* */
FT_EXPORT( FT_Int )
FT_Face_GetCharVariantIsDefault( FT_Face face,
FT_ULong charcode,
FT_ULong variantSelector );
/*************************************************************************/
/* */
/* <Function> */
/* FT_Face_GetVariantSelectors */
/* */
/* <Description> */
/* Return a zero-terminated list of Unicode variant selectors found */
/* in the font. */
/* */
/* <Input> */
/* face :: */
/* A handle to the source face object. */
/* */
/* <Return> */
/* A pointer to an array of selector code points, or NULL if there is */
/* no valid variant selector cmap subtable. */
/* */
/* <Note> */
/* The last item in the array is 0; the array is owned by the */
/* @FT_Face object but can be overwritten or released on the next */
/* call to a FreeType function. */
/* */
/* <Since> */
/* 2.3.6 */
/* */
FT_EXPORT( FT_UInt32* )
FT_Face_GetVariantSelectors( FT_Face face );
/*************************************************************************/
/* */
/* <Function> */
/* FT_Face_GetVariantsOfChar */
/* */
/* <Description> */
/* Return a zero-terminated list of Unicode variant selectors found */
/* for the specified character code. */
/* */
/* <Input> */
/* face :: */
/* A handle to the source face object. */
/* */
/* charcode :: */
/* The character codepoint in Unicode. */
/* */
/* <Return> */
/* A pointer to an array of variant selector code points which are */
/* active for the given character, or NULL if the corresponding list */
/* is empty. */
/* */
/* <Note> */
/* The last item in the array is 0; the array is owned by the */
/* @FT_Face object but can be overwritten or released on the next */
/* call to a FreeType function. */
/* */
/* <Since> */
/* 2.3.6 */
/* */
FT_EXPORT( FT_UInt32* )
FT_Face_GetVariantsOfChar( FT_Face face,
FT_ULong charcode );
/*************************************************************************/
/* */
/* <Function> */
/* FT_Face_GetCharsOfVariant */
/* */
/* <Description> */
/* Return a zero-terminated list of Unicode character codes found for */
/* the specified variant selector. */
/* */
/* <Input> */
/* face :: */
/* A handle to the source face object. */
/* */
/* variantSelector :: */
/* The variant selector code point in Unicode. */
/* */
/* <Return> */
/* A list of all the code points which are specified by this selector */
/* (both default and non-default codes are returned) or NULL if there */
/* is no valid cmap or the variant selector is invalid. */
/* */
/* <Note> */
/* The last item in the array is 0; the array is owned by the */
/* @FT_Face object but can be overwritten or released on the next */
/* call to a FreeType function. */
/* */
/* <Since> */
/* 2.3.6 */
/* */
FT_EXPORT( FT_UInt32* )
FT_Face_GetCharsOfVariant( FT_Face face,
FT_ULong variantSelector );
/*************************************************************************/
/* */
/* <Section> */
@ -3329,7 +3601,7 @@ FT_BEGIN_HEADER
*/
#define FREETYPE_MAJOR 2
#define FREETYPE_MINOR 3
#define FREETYPE_PATCH 5
#define FREETYPE_PATCH 6
/*************************************************************************/

View File

@ -4,7 +4,7 @@
/* */
/* FreeType exact bbox computation (specification). */
/* */
/* Copyright 1996-2001, 2003 by */
/* Copyright 1996-2001, 2003, 2007 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@ -61,7 +61,7 @@ FT_BEGIN_HEADER
/* Computes the exact bounding box of an outline. This is slower */
/* than computing the control box. However, it uses an advanced */
/* algorithm which returns _very_ quickly when the two boxes */
/* coincide. Otherwise, the outline Bézier arcs are walked over to */
/* coincide. Otherwise, the outline Bézier arcs are traversed to */
/* extract their extrema. */
/* */
/* <Input> */

View File

@ -4,7 +4,7 @@
/* */
/* FreeType Cache subsystem (specification). */
/* */
/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006, 2007 by */
/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@ -165,7 +165,7 @@ FT_BEGIN_HEADER
* Failure to do so will result in incorrect behaviour or even
* memory leaks and crashes.
*/
typedef struct FTC_FaceIDRec_* FTC_FaceID;
typedef FT_Pointer FTC_FaceID;
/************************************************************************
@ -434,7 +434,18 @@ FT_BEGIN_HEADER
FT_UInt x_res;
FT_UInt y_res;
} FTC_ScalerRec, *FTC_Scaler;
} FTC_ScalerRec;
/*************************************************************************/
/* */
/* <Struct> */
/* FTC_Scaler */
/* */
/* <Description> */
/* A handle to an @FTC_ScalerRec structure. */
/* */
typedef struct FTC_ScalerRec_* FTC_Scaler;
/*************************************************************************/

View File

@ -32,6 +32,7 @@
/* version */
/* basic_types */
/* base_interface */
/* glyph_variants */
/* glyph_management */
/* mac_specific */
/* sizes_management */
@ -54,6 +55,7 @@
/* type1_tables */
/* sfnt_names */
/* bdf_fonts */
/* cid_fonts */
/* pfr_fonts */
/* winfnt_fonts */
/* font_formats */

View File

@ -0,0 +1,98 @@
/***************************************************************************/
/* */
/* ftcid.h */
/* */
/* FreeType API for accessing CID font information (specification). */
/* */
/* Copyright 2007 by Dereg Clegg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
/* modified, and distributed under the terms of the FreeType project */
/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
/* this file you indicate that you have read the license and */
/* understand and accept it fully. */
/* */
/***************************************************************************/
#ifndef __FTCID_H__
#define __FTCID_H__
#include <ft2build.h>
#include FT_FREETYPE_H
#ifdef FREETYPE_H
#error "freetype.h of FreeType 1 has been loaded!"
#error "Please fix the directory search order for header files"
#error "so that freetype.h of FreeType 2 is found first."
#endif
FT_BEGIN_HEADER
/*************************************************************************/
/* */
/* <Section> */
/* cid_fonts */
/* */
/* <Title> */
/* CID Fonts */
/* */
/* <Abstract> */
/* CID-keyed font specific API. */
/* */
/* <Description> */
/* This section contains the declaration of CID-keyed font specific */
/* functions. */
/* */
/*************************************************************************/
/**********************************************************************
*
* @function:
* FT_Get_CID_Registry_Ordering_Supplement
*
* @description:
* Retrieve the Registry/Ordering/Supplement triple (also known as the
* "R/O/S") from a CID-keyed font.
*
* @input:
* face ::
* A handle to the input face.
*
* @output:
* registry ::
* The registry, as a C string, owned by the face.
*
* ordering ::
* The ordering, as a C string, owned by the face.
*
* supplement ::
* The supplement.
*
* @return:
* FreeType error code. 0 means success.
*
* @note:
* This function only works with CID faces, returning an error
* otherwise.
*
* @since:
* 2.3.6
*/
FT_EXPORT( FT_Error )
FT_Get_CID_Registry_Ordering_Supplement( FT_Face face,
const char* *registry,
const char* *ordering,
FT_Int *supplement);
/* */
FT_END_HEADER
#endif /* __FTCID_H__ */
/* END */

View File

@ -4,7 +4,7 @@
/* */
/* Access of TrueType's `gasp' table (specification). */
/* */
/* Copyright 2007 by */
/* Copyright 2007, 2008 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@ -95,7 +95,7 @@
* ppem :: The vertical character pixel size.
*
* @return:
* Bit flags (see @FT_GASP_XXX), or @FT_GASP_NO_TABLE is there is no
* Bit flags (see @FT_GASP_XXX), or @FT_GASP_NO_TABLE if there is no
* `gasp' table in the face.
*
* @since:

View File

@ -537,7 +537,7 @@ FT_BEGIN_HEADER
/* */
FT_EXPORT( void )
FT_Matrix_Multiply( const FT_Matrix* a,
FT_Matrix* b );
FT_Matrix* b );
/*************************************************************************/

View File

@ -5,7 +5,7 @@
/* FreeType glyph image formats and default raster interface */
/* (specification). */
/* */
/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006, 2007 by */
/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@ -28,7 +28,7 @@
#define __FTIMAGE_H__
/* _STANDALONE_ is from ftgrays.c */
/* _STANDALONE_ is from ftgrays.c */
#ifndef _STANDALONE_
#include <ft2build.h>
#endif
@ -206,7 +206,7 @@ FT_BEGIN_HEADER
/* An enumeration type to describe the format of a bitmap palette, */
/* used with ft_pixel_mode_pal4 and ft_pixel_mode_pal8. */
/* */
/* <Fields> */
/* <Values> */
/* ft_palette_mode_rgb :: The palette is an array of 3-bytes RGB */
/* records. */
/* */
@ -222,7 +222,7 @@ FT_BEGIN_HEADER
ft_palette_mode_rgb = 0,
ft_palette_mode_rgba,
ft_palettte_mode_max /* do not remove */
ft_palette_mode_max /* do not remove */
} FT_Palette_Mode;
@ -458,11 +458,12 @@ FT_BEGIN_HEADER
#define FT_CURVE_TAG_TOUCH_BOTH ( FT_CURVE_TAG_TOUCH_X | \
FT_CURVE_TAG_TOUCH_Y )
#define FT_Curve_Tag_On FT_CURVE_TAG_ON
#define FT_Curve_Tag_Conic FT_CURVE_TAG_CONIC
#define FT_Curve_Tag_Cubic FT_CURVE_TAG_CUBIC
#define FT_Curve_Tag_Touch_X FT_CURVE_TAG_TOUCH_X
#define FT_Curve_Tag_Touch_Y FT_CURVE_TAG_TOUCH_Y
#define FT_Curve_Tag_On FT_CURVE_TAG_ON
#define FT_Curve_Tag_Conic FT_CURVE_TAG_CONIC
#define FT_Curve_Tag_Cubic FT_CURVE_TAG_CUBIC
#define FT_Curve_Tag_Touch_X FT_CURVE_TAG_TOUCH_X
#define FT_Curve_Tag_Touch_Y FT_CURVE_TAG_TOUCH_Y
/*************************************************************************/
/* */
@ -490,6 +491,7 @@ FT_BEGIN_HEADER
#define FT_Outline_MoveTo_Func FT_Outline_MoveToFunc
/*************************************************************************/
/* */
/* <FuncType> */
@ -514,7 +516,8 @@ FT_BEGIN_HEADER
(*FT_Outline_LineToFunc)( const FT_Vector* to,
void* user );
#define FT_Outline_LineTo_Func FT_Outline_LineToFunc
#define FT_Outline_LineTo_Func FT_Outline_LineToFunc
/*************************************************************************/
/* */
@ -545,7 +548,8 @@ FT_BEGIN_HEADER
const FT_Vector* to,
void* user );
#define FT_Outline_ConicTo_Func FT_Outline_ConicToFunc
#define FT_Outline_ConicTo_Func FT_Outline_ConicToFunc
/*************************************************************************/
/* */
@ -577,7 +581,7 @@ FT_BEGIN_HEADER
const FT_Vector* to,
void* user );
#define FT_Outline_CubicTo_Func FT_Outline_CubicToFunc
#define FT_Outline_CubicTo_Func FT_Outline_CubicToFunc
/*************************************************************************/
@ -868,7 +872,7 @@ FT_BEGIN_HEADER
const FT_Span* spans,
void* user );
#define FT_Raster_Span_Func FT_SpanFunc
#define FT_Raster_Span_Func FT_SpanFunc
/*************************************************************************/
@ -1073,7 +1077,8 @@ FT_BEGIN_HEADER
(*FT_Raster_NewFunc)( void* memory,
FT_Raster* raster );
#define FT_Raster_New_Func FT_Raster_NewFunc
#define FT_Raster_New_Func FT_Raster_NewFunc
/*************************************************************************/
/* */
@ -1089,7 +1094,8 @@ FT_BEGIN_HEADER
typedef void
(*FT_Raster_DoneFunc)( FT_Raster raster );
#define FT_Raster_Done_Func FT_Raster_DoneFunc
#define FT_Raster_Done_Func FT_Raster_DoneFunc
/*************************************************************************/
/* */
@ -1123,7 +1129,8 @@ FT_BEGIN_HEADER
unsigned char* pool_base,
unsigned long pool_size );
#define FT_Raster_Reset_Func FT_Raster_ResetFunc
#define FT_Raster_Reset_Func FT_Raster_ResetFunc
/*************************************************************************/
/* */
@ -1148,7 +1155,8 @@ FT_BEGIN_HEADER
unsigned long mode,
void* args );
#define FT_Raster_Set_Mode_Func FT_Raster_SetModeFunc
#define FT_Raster_Set_Mode_Func FT_Raster_SetModeFunc
/*************************************************************************/
/* */
@ -1188,7 +1196,8 @@ FT_BEGIN_HEADER
(*FT_Raster_RenderFunc)( FT_Raster raster,
const FT_Raster_Params* params );
#define FT_Raster_Render_Func FT_Raster_RenderFunc
#define FT_Raster_Render_Func FT_Raster_RenderFunc
/*************************************************************************/
/* */
@ -1211,12 +1220,12 @@ FT_BEGIN_HEADER
/* */
typedef struct FT_Raster_Funcs_
{
FT_Glyph_Format glyph_format;
FT_Raster_NewFunc raster_new;
FT_Raster_ResetFunc raster_reset;
FT_Raster_SetModeFunc raster_set_mode;
FT_Raster_RenderFunc raster_render;
FT_Raster_DoneFunc raster_done;
FT_Glyph_Format glyph_format;
FT_Raster_NewFunc raster_new;
FT_Raster_ResetFunc raster_reset;
FT_Raster_SetModeFunc raster_set_mode;
FT_Raster_RenderFunc raster_render;
FT_Raster_DoneFunc raster_done;
} FT_Raster_Funcs;

View File

@ -4,7 +4,7 @@
/* */
/* FreeType incremental loading (specification). */
/* */
/* Copyright 2002, 2003, 2006, 2007 by */
/* Copyright 2002, 2003, 2006, 2007, 2008 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@ -31,192 +31,208 @@
FT_BEGIN_HEADER
/***************************************************************************
*
* @section:
* incremental
*
* @title:
* Incremental Loading
*
* @abstract:
* Custom Glyph Loading.
*
* @description:
* This section contains various functions used to perform so-called
* `incremental' glyph loading. This is a mode where all glyphs loaded
* from a given @FT_Face are provided by the client application,
*
* Apart from that, all other tables are loaded normally from the font
* file. This mode is useful when FreeType is used within another
* engine, e.g., a Postscript Imaging Processor.
*
* To enable this mode, you must use @FT_Open_Face, passing an
* @FT_Parameter with the @FT_PARAM_TAG_INCREMENTAL tag and an
* @FT_Incremental_Interface value. See the comments for
* @FT_Incremental_InterfaceRec for an example.
*
*/
/***************************************************************************
*
* @section:
* incremental
*
* @title:
* Incremental Loading
*
* @abstract:
* Custom Glyph Loading.
*
* @description:
* This section contains various functions used to perform so-called
* `incremental' glyph loading. This is a mode where all glyphs loaded
* from a given @FT_Face are provided by the client application,
*
* Apart from that, all other tables are loaded normally from the font
* file. This mode is useful when FreeType is used within another
* engine, e.g., a Postscript Imaging Processor.
*
* To enable this mode, you must use @FT_Open_Face, passing an
* @FT_Parameter with the @FT_PARAM_TAG_INCREMENTAL tag and an
* @FT_Incremental_Interface value. See the comments for
* @FT_Incremental_InterfaceRec for an example.
*
*/
/***************************************************************************
*
* @type:
* FT_Incremental
*
* @description:
* An opaque type describing a user-provided object used to implement
* `incremental' glyph loading within FreeType. This is used to support
* embedded fonts in certain environments (e.g., Postscript interpreters),
* where the glyph data isn't in the font file, or must be overridden by
* different values.
*
* @note:
* It is up to client applications to create and implement @FT_Incremental
* objects, as long as they provide implementations for the methods
* @FT_Incremental_GetGlyphDataFunc, @FT_Incremental_FreeGlyphDataFunc
* and @FT_Incremental_GetGlyphMetricsFunc.
*
* See the description of @FT_Incremental_InterfaceRec to understand how
* to use incremental objects with FreeType.
*/
/***************************************************************************
*
* @type:
* FT_Incremental
*
* @description:
* An opaque type describing a user-provided object used to implement
* `incremental' glyph loading within FreeType. This is used to support
* embedded fonts in certain environments (e.g., Postscript interpreters),
* where the glyph data isn't in the font file, or must be overridden by
* different values.
*
* @note:
* It is up to client applications to create and implement @FT_Incremental
* objects, as long as they provide implementations for the methods
* @FT_Incremental_GetGlyphDataFunc, @FT_Incremental_FreeGlyphDataFunc
* and @FT_Incremental_GetGlyphMetricsFunc.
*
* See the description of @FT_Incremental_InterfaceRec to understand how
* to use incremental objects with FreeType.
*
*/
typedef struct FT_IncrementalRec_* FT_Incremental;
/***************************************************************************
*
* @struct:
* FT_Incremental_Metrics
*
* @description:
* A small structure used to contain the basic glyph metrics returned
* by the @FT_Incremental_GetGlyphMetricsFunc method.
*
* @fields:
* bearing_x ::
* Left bearing, in font units.
*
* bearing_y ::
* Top bearing, in font units.
*
* advance ::
* Glyph advance, in font units.
*
* @note:
* These correspond to horizontal or vertical metrics depending on the
* value of the `vertical' argument to the function
* @FT_Incremental_GetGlyphMetricsFunc.
*/
/***************************************************************************
*
* @struct:
* FT_Incremental_MetricsRec
*
* @description:
* A small structure used to contain the basic glyph metrics returned
* by the @FT_Incremental_GetGlyphMetricsFunc method.
*
* @fields:
* bearing_x ::
* Left bearing, in font units.
*
* bearing_y ::
* Top bearing, in font units.
*
* advance ::
* Glyph advance, in font units.
*
* @note:
* These correspond to horizontal or vertical metrics depending on the
* value of the `vertical' argument to the function
* @FT_Incremental_GetGlyphMetricsFunc.
*
*/
typedef struct FT_Incremental_MetricsRec_
{
FT_Long bearing_x;
FT_Long bearing_y;
FT_Long advance;
} FT_Incremental_MetricsRec, *FT_Incremental_Metrics;
} FT_Incremental_MetricsRec;
/***************************************************************************
*
* @type:
* FT_Incremental_GetGlyphDataFunc
*
* @description:
* A function called by FreeType to access a given glyph's data bytes
* during @FT_Load_Glyph or @FT_Load_Char if incremental loading is
* enabled.
*
* Note that the format of the glyph's data bytes depends on the font
* file format. For TrueType, it must correspond to the raw bytes within
* the `glyf' table. For Postscript formats, it must correspond to the
* *unencrypted* charstring bytes, without any `lenIV' header. It is
* undefined for any other format.
*
* @input:
* incremental ::
* Handle to an opaque @FT_Incremental handle provided by the client
* application.
*
* glyph_index ::
* Index of relevant glyph.
*
* @output:
* adata ::
* A structure describing the returned glyph data bytes (which will be
* accessed as a read-only byte block).
*
* @return:
* FreeType error code. 0 means success.
*
* @note:
* If this function returns successfully the method
* @FT_Incremental_FreeGlyphDataFunc will be called later to release
* the data bytes.
*
* Nested calls to @FT_Incremental_GetGlyphDataFunc can happen for
* compound glyphs.
*/
/***************************************************************************
*
* @struct:
* FT_Incremental_Metrics
*
* @description:
* A handle to an @FT_Incremental_MetricsRec structure.
*
*/
typedef struct FT_Incremental_MetricsRec_* FT_Incremental_Metrics;
/***************************************************************************
*
* @type:
* FT_Incremental_GetGlyphDataFunc
*
* @description:
* A function called by FreeType to access a given glyph's data bytes
* during @FT_Load_Glyph or @FT_Load_Char if incremental loading is
* enabled.
*
* Note that the format of the glyph's data bytes depends on the font
* file format. For TrueType, it must correspond to the raw bytes within
* the `glyf' table. For Postscript formats, it must correspond to the
* *unencrypted* charstring bytes, without any `lenIV' header. It is
* undefined for any other format.
*
* @input:
* incremental ::
* Handle to an opaque @FT_Incremental handle provided by the client
* application.
*
* glyph_index ::
* Index of relevant glyph.
*
* @output:
* adata ::
* A structure describing the returned glyph data bytes (which will be
* accessed as a read-only byte block).
*
* @return:
* FreeType error code. 0 means success.
*
* @note:
* If this function returns successfully the method
* @FT_Incremental_FreeGlyphDataFunc will be called later to release
* the data bytes.
*
* Nested calls to @FT_Incremental_GetGlyphDataFunc can happen for
* compound glyphs.
*
*/
typedef FT_Error
(*FT_Incremental_GetGlyphDataFunc)( FT_Incremental incremental,
FT_UInt glyph_index,
FT_Data* adata );
/***************************************************************************
*
* @type:
* FT_Incremental_FreeGlyphDataFunc
*
* @description:
* A function used to release the glyph data bytes returned by a
* successful call to @FT_Incremental_GetGlyphDataFunc.
*
* @input:
* incremental ::
* A handle to an opaque @FT_Incremental handle provided by the client
* application.
*
* data ::
* A structure describing the glyph data bytes (which will be accessed
* as a read-only byte block).
*/
/***************************************************************************
*
* @type:
* FT_Incremental_FreeGlyphDataFunc
*
* @description:
* A function used to release the glyph data bytes returned by a
* successful call to @FT_Incremental_GetGlyphDataFunc.
*
* @input:
* incremental ::
* A handle to an opaque @FT_Incremental handle provided by the client
* application.
*
* data ::
* A structure describing the glyph data bytes (which will be accessed
* as a read-only byte block).
*
*/
typedef void
(*FT_Incremental_FreeGlyphDataFunc)( FT_Incremental incremental,
FT_Data* data );
/***************************************************************************
*
* @type:
* FT_Incremental_GetGlyphMetricsFunc
*
* @description:
* A function used to retrieve the basic metrics of a given glyph index
* before accessing its data. This is necessary because, in certain
* formats like TrueType, the metrics are stored in a different place from
* the glyph images proper.
*
* @input:
* incremental ::
* A handle to an opaque @FT_Incremental handle provided by the client
* application.
*
* glyph_index ::
* Index of relevant glyph.
*
* vertical ::
* If true, return vertical metrics.
*
* ametrics ::
* This parameter is used for both input and output.
* The original glyph metrics, if any, in font units. If metrics are
* not available all the values must be set to zero.
*
* @output:
* ametrics ::
* The replacement glyph metrics in font units.
*
*/
/***************************************************************************
*
* @type:
* FT_Incremental_GetGlyphMetricsFunc
*
* @description:
* A function used to retrieve the basic metrics of a given glyph index
* before accessing its data. This is necessary because, in certain
* formats like TrueType, the metrics are stored in a different place from
* the glyph images proper.
*
* @input:
* incremental ::
* A handle to an opaque @FT_Incremental handle provided by the client
* application.
*
* glyph_index ::
* Index of relevant glyph.
*
* vertical ::
* If true, return vertical metrics.
*
* ametrics ::
* This parameter is used for both input and output.
* The original glyph metrics, if any, in font units. If metrics are
* not available all the values must be set to zero.
*
* @output:
* ametrics ::
* The replacement glyph metrics in font units.
*
*/
typedef FT_Error
(*FT_Incremental_GetGlyphMetricsFunc)
( FT_Incremental incremental,
@ -244,6 +260,7 @@ FT_BEGIN_HEADER
* get_glyph_metrics ::
* The function to get glyph metrics. May be null if the font does
* not provide overriding glyph metrics.
*
*/
typedef struct FT_Incremental_FuncsRec_
{
@ -254,41 +271,42 @@ FT_BEGIN_HEADER
} FT_Incremental_FuncsRec;
/***************************************************************************
*
* @struct:
* FT_Incremental_InterfaceRec
*
* @description:
* A structure to be used with @FT_Open_Face to indicate that the user
* wants to support incremental glyph loading. You should use it with
* @FT_PARAM_TAG_INCREMENTAL as in the following example:
*
* {
* FT_Incremental_InterfaceRec inc_int;
* FT_Parameter parameter;
* FT_Open_Args open_args;
*
*
* // set up incremental descriptor
* inc_int.funcs = my_funcs;
* inc_int.object = my_object;
*
* // set up optional parameter
* parameter.tag = FT_PARAM_TAG_INCREMENTAL;
* parameter.data = &inc_int;
*
* // set up FT_Open_Args structure
* open_args.flags = FT_OPEN_PATHNAME | FT_OPEN_PARAMS;
* open_args.pathname = my_font_pathname;
* open_args.num_params = 1;
* open_args.params = &parameter; // we use one optional argument
*
* // open the font
* error = FT_Open_Face( library, &open_args, index, &face );
* ...
* }
*/
/***************************************************************************
*
* @struct:
* FT_Incremental_InterfaceRec
*
* @description:
* A structure to be used with @FT_Open_Face to indicate that the user
* wants to support incremental glyph loading. You should use it with
* @FT_PARAM_TAG_INCREMENTAL as in the following example:
*
* {
* FT_Incremental_InterfaceRec inc_int;
* FT_Parameter parameter;
* FT_Open_Args open_args;
*
*
* // set up incremental descriptor
* inc_int.funcs = my_funcs;
* inc_int.object = my_object;
*
* // set up optional parameter
* parameter.tag = FT_PARAM_TAG_INCREMENTAL;
* parameter.data = &inc_int;
*
* // set up FT_Open_Args structure
* open_args.flags = FT_OPEN_PATHNAME | FT_OPEN_PARAMS;
* open_args.pathname = my_font_pathname;
* open_args.num_params = 1;
* open_args.params = &parameter; // we use one optional argument
*
* // open the font
* error = FT_Open_Face( library, &open_args, index, &face );
* ...
* }
*
*/
typedef struct FT_Incremental_InterfaceRec_
{
const FT_Incremental_FuncsRec* funcs;
@ -297,31 +315,31 @@ FT_BEGIN_HEADER
} FT_Incremental_InterfaceRec;
/***************************************************************************
*
* @type:
* FT_Incremental_Interface
*
* @description:
* A pointer to an @FT_Incremental_InterfaceRec structure.
*
*/
/***************************************************************************
*
* @type:
* FT_Incremental_Interface
*
* @description:
* A pointer to an @FT_Incremental_InterfaceRec structure.
*
*/
typedef FT_Incremental_InterfaceRec* FT_Incremental_Interface;
/***************************************************************************
*
* @constant:
* FT_PARAM_TAG_INCREMENTAL
*
* @description:
* A constant used as the tag of @FT_Parameter structures to indicate
* an incremental loading object to be used by FreeType.
*
*/
/***************************************************************************
*
* @constant:
* FT_PARAM_TAG_INCREMENTAL
*
* @description:
* A constant used as the tag of @FT_Parameter structures to indicate
* an incremental loading object to be used by FreeType.
*
*/
#define FT_PARAM_TAG_INCREMENTAL FT_MAKE_TAG( 'i', 'n', 'c', 'r' )
/* */
/* */
FT_END_HEADER

View File

@ -5,7 +5,7 @@
/* FreeType API for color filtering of subpixel bitmap glyphs */
/* (specification). */
/* */
/* Copyright 2006, 2007 by */
/* Copyright 2006, 2007, 2008 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@ -85,7 +85,7 @@ FT_BEGIN_HEADER
* @since:
* 2.3.0
*/
typedef enum
typedef enum FT_LcdFilter_
{
FT_LCD_FILTER_NONE = 0,
FT_LCD_FILTER_DEFAULT = 1,

View File

@ -18,9 +18,9 @@
/***************************************************************************/
/* */
/* NOTE: Include this file after <freetype/freetype.h> and after the */
/* Mac-specific <Types.h> header (or any other Mac header that */
/* includes <Types.h>); we use Handle type. */
/* NOTE: Include this file after <freetype/freetype.h> and after any */
/* Mac-specific headers (because this header uses Mac types such as */
/* Handle, FSSpec, FSRef, etc.) */
/* */
/***************************************************************************/
@ -100,7 +100,8 @@ FT_BEGIN_HEADER
FT_New_Face_From_FOND( FT_Library library,
Handle fond,
FT_Long face_index,
FT_Face *aface );
FT_Face *aface )
FT_DEPRECATED_ATTRIBUTE;
/*************************************************************************/
@ -188,7 +189,8 @@ FT_BEGIN_HEADER
FT_GetFilePath_From_Mac_ATS_Name( const char* fontName,
UInt8* path,
UInt32 maxPathSize,
FT_Long* face_index );
FT_Long* face_index )
FT_DEPRECATED_ATTRIBUTE;
/*************************************************************************/

View File

@ -4,7 +4,7 @@
/* */
/* FreeType modules public interface (specification). */
/* */
/* Copyright 1996-2001, 2002, 2003, 2006 by */
/* Copyright 1996-2001, 2002, 2003, 2006, 2008 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@ -78,12 +78,50 @@ FT_BEGIN_HEADER
typedef FT_Pointer FT_Module_Interface;
/*************************************************************************/
/* */
/* <FuncType> */
/* FT_Module_Constructor */
/* */
/* <Description> */
/* A function used to initialize (not create) a new module object. */
/* */
/* <Input> */
/* module :: The module to initialize. */
/* */
typedef FT_Error
(*FT_Module_Constructor)( FT_Module module );
/*************************************************************************/
/* */
/* <FuncType> */
/* FT_Module_Destructor */
/* */
/* <Description> */
/* A function used to finalize (not destroy) a given module object. */
/* */
/* <Input> */
/* module :: The module to finalize. */
/* */
typedef void
(*FT_Module_Destructor)( FT_Module module );
/*************************************************************************/
/* */
/* <FuncType> */
/* FT_Module_Requester */
/* */
/* <Description> */
/* A function used to query a given module for a specific interface. */
/* */
/* <Input> */
/* module :: The module to finalize. */
/* */
/* name :: The name of the interface in the module. */
/* */
typedef FT_Module_Interface
(*FT_Module_Requester)( FT_Module module,
const char* name );
@ -112,14 +150,11 @@ FT_BEGIN_HEADER
/* as a 16.16 fixed number (major.minor). Starts */
/* at version 2.0, i.e., 0x20000. */
/* */
/* module_init :: A function used to initialize (not create) a */
/* new module object. */
/* module_init :: The initializing function. */
/* */
/* module_done :: A function used to finalize (not destroy) a */
/* given module object */
/* module_done :: The finalizing function. */
/* */
/* get_interface :: Queries a given module for a specific */
/* interface by name. */
/* get_interface :: The interface requesting function. */
/* */
typedef struct FT_Module_Class_
{
@ -362,7 +397,7 @@ FT_BEGIN_HEADER
* 2.2
*
*/
typedef enum
typedef enum FT_TrueTypeEngineType_
{
FT_TRUETYPE_ENGINE_TYPE_NONE = 0,
FT_TRUETYPE_ENGINE_TYPE_UNPATENTED,

View File

@ -4,7 +4,7 @@
/* */
/* FreeType API for validating OpenType tables (specification). */
/* */
/* Copyright 2004, 2005, 2006 by */
/* Copyright 2004, 2005, 2006, 2007 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@ -56,7 +56,7 @@ FT_BEGIN_HEADER
/* */
/* <Description> */
/* This section contains the declaration of functions to validate */
/* some OpenType tables (BASE, GDEF, GPOS, GSUB, JSTF). */
/* some OpenType tables (BASE, GDEF, GPOS, GSUB, JSTF, MATH). */
/* */
/*************************************************************************/
@ -86,8 +86,11 @@ FT_BEGIN_HEADER
* FT_VALIDATE_JSTF ::
* Validate JSTF table.
*
* FT_VALIDATE_MATH ::
* Validate MATH table.
*
* FT_VALIDATE_OT ::
* Validate all OpenType tables (BASE, GDEF, GPOS, GSUB, JSTF).
* Validate all OpenType tables (BASE, GDEF, GPOS, GSUB, JSTF, MATH).
*
*/
#define FT_VALIDATE_BASE 0x0100
@ -95,12 +98,14 @@ FT_BEGIN_HEADER
#define FT_VALIDATE_GPOS 0x0400
#define FT_VALIDATE_GSUB 0x0800
#define FT_VALIDATE_JSTF 0x1000
#define FT_VALIDATE_MATH 0x2000
#define FT_VALIDATE_OT FT_VALIDATE_BASE | \
FT_VALIDATE_GDEF | \
FT_VALIDATE_GPOS | \
FT_VALIDATE_GSUB | \
FT_VALIDATE_JSTF
FT_VALIDATE_JSTF | \
FT_VALIDATE_MATH
/* */

View File

@ -5,7 +5,7 @@
/* Support for the FT_Outline type used to store glyph shapes of */
/* most scalable font formats (specification). */
/* */
/* Copyright 1996-2001, 2002, 2003, 2005, 2006, 2007 by */
/* Copyright 1996-2001, 2002, 2003, 2005, 2006, 2007, 2008 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@ -473,7 +473,7 @@ FT_BEGIN_HEADER
* the glyph have different orientation.
*
*/
typedef enum
typedef enum FT_Orientation_
{
FT_ORIENTATION_TRUETYPE = 0,
FT_ORIENTATION_POSTSCRIPT = 1,

View File

@ -124,27 +124,32 @@ FT_BEGIN_HEADER
/* The renderer module class descriptor. */
/* */
/* <Fields> */
/* root :: The root @FT_Module_Class fields. */
/* root :: The root @FT_Module_Class fields. */
/* */
/* glyph_format :: The glyph image format this renderer handles. */
/* glyph_format :: The glyph image format this renderer handles. */
/* */
/* render_glyph :: A method used to render the image that is in a */
/* given glyph slot into a bitmap. */
/* render_glyph :: A method used to render the image that is in a */
/* given glyph slot into a bitmap. */
/* */
/* set_mode :: A method used to pass additional parameters. */
/* transform_glyph :: A method used to transform the image that is in */
/* a given glyph slot. */
/* */
/* raster_class :: For @FT_GLYPH_FORMAT_OUTLINE renderers only. This */
/* is a pointer to its raster's class. */
/* get_glyph_cbox :: A method used to access the glyph's cbox. */
/* */
/* raster :: For @FT_GLYPH_FORMAT_OUTLINE renderers only. This */
/* is a pointer to the corresponding raster object, */
/* if any. */
/* set_mode :: A method used to pass additional parameters. */
/* */
/* raster_class :: For @FT_GLYPH_FORMAT_OUTLINE renderers only. */
/* This is a pointer to its raster's class. */
/* */
/* raster :: For @FT_GLYPH_FORMAT_OUTLINE renderers only. */
/* This is a pointer to the corresponding raster */
/* object, if any. */
/* */
typedef struct FT_Renderer_Class_
{
FT_Module_Class root;
FT_Module_Class root;
FT_Glyph_Format glyph_format;
FT_Glyph_Format glyph_format;
FT_Renderer_RenderFunc render_glyph;
FT_Renderer_TransformFunc transform_glyph;

View File

@ -4,7 +4,7 @@
/* */
/* FreeType path stroker (specification). */
/* */
/* Copyright 2002, 2003, 2004, 2005, 2006 by */
/* Copyright 2002, 2003, 2004, 2005, 2006, 2008 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@ -84,7 +84,7 @@ FT_BEGIN_HEADER
* is too closed (this is useful to avoid unpleasant spikes
* in beveled rendering).
*/
typedef enum
typedef enum FT_Stroker_LineJoin_
{
FT_STROKER_LINEJOIN_ROUND = 0,
FT_STROKER_LINEJOIN_BEVEL,
@ -115,7 +115,7 @@ FT_BEGIN_HEADER
* The end of lines is rendered as a square around the
* last point.
*/
typedef enum
typedef enum FT_Stroker_LineCap_
{
FT_STROKER_LINECAP_BUTT = 0,
FT_STROKER_LINECAP_ROUND,
@ -149,7 +149,7 @@ FT_BEGIN_HEADER
* You can however use @FT_Outline_GetInsideBorder and
* @FT_Outline_GetOutsideBorder to get these.
*/
typedef enum
typedef enum FT_StrokerBorder_
{
FT_STROKER_BORDER_LEFT = 0,
FT_STROKER_BORDER_RIGHT

View File

@ -4,7 +4,7 @@
/* */
/* FreeType simple types definitions (specification only). */
/* */
/* Copyright 1996-2001, 2002, 2004, 2006, 2007 by */
/* Copyright 1996-2001, 2002, 2004, 2006, 2007, 2008 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@ -53,6 +53,10 @@ FT_BEGIN_HEADER
/* FT_Char */
/* FT_Int */
/* FT_UInt */
/* FT_Int16 */
/* FT_UInt16 */
/* FT_Int32 */
/* FT_UInt32 */
/* FT_Short */
/* FT_UShort */
/* FT_Long */

View File

@ -4,7 +4,7 @@
/* */
/* FreeType API for accessing Windows fnt-specific data. */
/* */
/* Copyright 2003, 2004 by */
/* Copyright 2003, 2004, 2008 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@ -219,36 +219,47 @@ FT_BEGIN_HEADER
FT_UShort color_table_offset;
FT_ULong reserved1[4];
} FT_WinFNT_HeaderRec, *FT_WinFNT_Header;
} FT_WinFNT_HeaderRec;
/**********************************************************************
*
* @function:
* FT_Get_WinFNT_Header
*
* @description:
* Retrieve a Windows FNT font info header.
*
* @input:
* face :: A handle to the input face.
*
* @output:
* aheader :: The WinFNT header.
*
* @return:
* FreeType error code. 0 means success.
*
* @note:
* This function only works with Windows FNT faces, returning an error
* otherwise.
*/
/*************************************************************************/
/* */
/* <Struct> */
/* FT_WinFNT_Header */
/* */
/* <Description> */
/* A handle to an @FT_WinFNT_HeaderRec structure. */
/* */
typedef struct FT_WinFNT_HeaderRec_* FT_WinFNT_Header;
/**********************************************************************
*
* @function:
* FT_Get_WinFNT_Header
*
* @description:
* Retrieve a Windows FNT font info header.
*
* @input:
* face :: A handle to the input face.
*
* @output:
* aheader :: The WinFNT header.
*
* @return:
* FreeType error code. 0 means success.
*
* @note:
* This function only works with Windows FNT faces, returning an error
* otherwise.
*/
FT_EXPORT( FT_Error )
FT_Get_WinFNT_Header( FT_Face face,
FT_WinFNT_HeaderRec *aheader );
/* */
/* */
FT_END_HEADER

View File

@ -4,7 +4,7 @@
/* */
/* Arithmetic computations (specification). */
/* */
/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006 by */
/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006, 2008 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@ -111,6 +111,31 @@ FT_BEGIN_HEADER
#endif /* TT_USE_BYTECODE_INTERPRETER */
/*
* A variant of FT_Matrix_Multiply which scales its result afterwards.
* The idea is that both `a' and `b' are scaled by factors of 10 so that
* the values are as precise as possible to get a correct result during
* the 64bit multiplication. Let `sa' and `sb' be the scaling factors of
* `a' and `b', respectively, then the scaling factor of the result is
* `sa*sb'.
*/
FT_BASE( void )
FT_Matrix_Multiply_Scaled( const FT_Matrix* a,
FT_Matrix *b,
FT_Long scaling );
/*
* A variant of FT_Vector_Transform. See comments for
* FT_Matrix_Multiply_Scaled.
*/
FT_BASE( void )
FT_Vector_Transform_Scaled( FT_Vector* vector,
const FT_Matrix* matrix,
FT_Long scaling );
/*
* Return -1, 0, or +1, depending on the orientation of a given corner.
* We use the Cartesian coordinate system, with positive vertical values

View File

@ -4,7 +4,7 @@
/* */
/* Debugging and logging component (specification). */
/* */
/* Copyright 1996-2001, 2002, 2004, 2006, 2007 by */
/* Copyright 1996-2001, 2002, 2004, 2006, 2007, 2008 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@ -54,7 +54,7 @@ FT_BEGIN_HEADER
#define FT_TRACE_DEF( x ) trace_ ## x ,
/* defining the enumeration */
typedef enum
typedef enum FT_Trace_
{
#include FT_INTERNAL_TRACE_H
trace_count
@ -146,10 +146,12 @@ FT_BEGIN_HEADER
/*************************************************************************/
/* */
/* You need two opening resp. closing parentheses! */
/* You need two opening and closing parentheses! */
/* */
/* Example: FT_TRACE0(( "Value is %i", foo )) */
/* */
/* Output of the FT_TRACEX macros is sent to stderr. */
/* */
/*************************************************************************/
#define FT_TRACE0( varformat ) FT_TRACE( 0, varformat )
@ -164,7 +166,9 @@ FT_BEGIN_HEADER
/*************************************************************************/
/* */
/* Define the FT_ERROR macro */
/* Define the FT_ERROR macro. */
/* */
/* Output of this macro is sent to stderr. */
/* */
/*************************************************************************/
@ -181,7 +185,7 @@ FT_BEGIN_HEADER
/*************************************************************************/
/* */
/* Define the FT_ASSERT macro */
/* Define the FT_ASSERT macro. */
/* */
/*************************************************************************/
@ -204,21 +208,23 @@ FT_BEGIN_HEADER
/*************************************************************************/
/* */
/* Define `FT_Message' and `FT_Panic' when needed */
/* Define `FT_Message' and `FT_Panic' when needed. */
/* */
/*************************************************************************/
#ifdef FT_DEBUG_LEVEL_ERROR
#include "stdio.h" /* for vprintf() */
#include "stdio.h" /* for vfprintf() */
/* print a message */
FT_BASE( void )
FT_Message( const char* fmt, ... );
FT_Message( const char* fmt,
... );
/* print a message and exit */
FT_BASE( void )
FT_Panic( const char* fmt, ... );
FT_Panic( const char* fmt,
... );
#endif /* FT_DEBUG_LEVEL_ERROR */
@ -229,8 +235,8 @@ FT_BEGIN_HEADER
#if defined( _MSC_VER ) /* Visual C++ (and Intel C++) */
/* we disable the warning `conditional expression is constant' here */
/* in order to compile cleanly with the maximum level of warnings */
/* We disable the warning `conditional expression is constant' here */
/* in order to compile cleanly with the maximum level of warnings. */
#pragma warning( disable : 4127 )
#endif /* _MSC_VER */

View File

@ -4,7 +4,7 @@
/* */
/* FreeType font driver interface (specification). */
/* */
/* Copyright 1996-2001, 2002, 2003, 2006 by */
/* Copyright 1996-2001, 2002, 2003, 2006, 2008 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@ -145,10 +145,6 @@ FT_BEGIN_HEADER
/* load_glyph :: A function handle to load a glyph to a slot. */
/* This field is mandatory! */
/* */
/* get_char_index :: A function handle to return the glyph index of */
/* a given character for a given charmap. This */
/* field is mandatory! */
/* */
/* get_kerning :: A function handle to return the unscaled */
/* kerning for a given pair of glyphs. Can be */
/* set to 0 if the format doesn't support */
@ -180,8 +176,8 @@ FT_BEGIN_HEADER
/* to 0 if the scaling done in the base layer */
/* suffices. */
/* <Note> */
/* Most function pointers, with the exception of `load_glyph' and */
/* `get_char_index' can be set to 0 to indicate a default behaviour. */
/* Most function pointers, with the exception of `load_glyph', can be */
/* set to 0 to indicate a default behaviour. */
/* */
typedef struct FT_Driver_ClassRec_
{

View File

@ -333,8 +333,8 @@ FT_BEGIN_HEADER
FT_ULong size,
FT_Error *p_error );
#define FT_MEM_STRDUP( dst, str ) \
(dst) = ft_mem_strdup( memory, (const char*)(str), &error )
#define FT_MEM_STRDUP( dst, str ) \
(dst) = (char*)ft_mem_strdup( memory, (const char*)(str), &error )
#define FT_STRDUP( dst, str ) \
FT_MEM_SET_ERROR( FT_MEM_STRDUP( dst, str ) )

View File

@ -4,7 +4,7 @@
/* */
/* The FreeType private base classes (specification). */
/* */
/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006 by */
/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006, 2008 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@ -160,6 +160,31 @@ FT_BEGIN_HEADER
(*FT_CMap_CharNextFunc)( FT_CMap cmap,
FT_UInt32 *achar_code );
typedef FT_UInt
(*FT_CMap_CharVarIndexFunc)( FT_CMap cmap,
FT_CMap unicode_cmap,
FT_UInt32 char_code,
FT_UInt32 variant_selector );
typedef FT_Bool
(*FT_CMap_CharVarIsDefaultFunc)( FT_CMap cmap,
FT_UInt32 char_code,
FT_UInt32 variant_selector );
typedef FT_UInt32 *
(*FT_CMap_VariantListFunc)( FT_CMap cmap,
FT_Memory mem );
typedef FT_UInt32 *
(*FT_CMap_CharVariantListFunc)( FT_CMap cmap,
FT_Memory mem,
FT_UInt32 char_code );
typedef FT_UInt32 *
(*FT_CMap_VariantCharListFunc)( FT_CMap cmap,
FT_Memory mem,
FT_UInt32 variant_selector );
typedef struct FT_CMap_ClassRec_
{
@ -169,6 +194,15 @@ FT_BEGIN_HEADER
FT_CMap_CharIndexFunc char_index;
FT_CMap_CharNextFunc char_next;
/* Subsequent entries are special ones for format 14 -- the variant */
/* selector subtable which behaves like no other */
FT_CMap_CharVarIndexFunc char_var_index;
FT_CMap_CharVarIsDefaultFunc char_var_default;
FT_CMap_VariantListFunc variant_list;
FT_CMap_CharVariantListFunc charvariant_list;
FT_CMap_VariantCharListFunc variantchar_list;
} FT_CMap_ClassRec;
@ -306,7 +340,28 @@ FT_BEGIN_HEADER
} FT_GlyphSlot_InternalRec;
#if 0
/*************************************************************************/
/* */
/* <Struct> */
/* FT_Size_InternalRec */
/* */
/* <Description> */
/* This structure contains the internal fields of each FT_Size */
/* object. Currently, it's empty. */
/* */
/*************************************************************************/
typedef struct FT_Size_InternalRec_
{
/* empty */
} FT_Size_InternalRec;
#endif
/*************************************************************************/
/*************************************************************************/
/**** ****/

View File

@ -4,7 +4,7 @@
/* */
/* Embedded resource forks accessor (specification). */
/* */
/* Copyright 2004, 2006 by */
/* Copyright 2004, 2006, 2007 by */
/* Masatake YAMATO and Redhat K.K. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@ -34,7 +34,19 @@ FT_BEGIN_HEADER
/* Number of guessing rules supported in `FT_Raccess_Guess'. */
/* Don't forget to increment the number if you add a new guessing rule. */
#define FT_RACCESS_N_RULES 8
#define FT_RACCESS_N_RULES 9
/* A structure to describe a reference in a resource by its resource ID */
/* and internal offset. The `POST' resource expects to be concatenated */
/* by the order of resource IDs instead of its appearance in the file. */
typedef struct FT_RFork_Ref_
{
FT_UShort res_id;
FT_ULong offset;
} FT_RFork_Ref;
/*************************************************************************/

View File

@ -301,6 +301,7 @@ FT_BEGIN_HEADER
*/
#define FT_SERVICE_BDF_H <freetype/internal/services/svbdf.h>
#define FT_SERVICE_CID_H <freetype/internal/services/svcid.h>
#define FT_SERVICE_GLYPH_DICT_H <freetype/internal/services/svgldict.h>
#define FT_SERVICE_GX_VALIDATE_H <freetype/internal/services/svgxval.h>
#define FT_SERVICE_KERNING_H <freetype/internal/services/svkern.h>

View File

@ -4,7 +4,7 @@
/* */
/* Tracing handling (specification only). */
/* */
/* Copyright 2002, 2004, 2005, 2006 by */
/* Copyright 2002, 2004, 2005, 2006, 2007 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@ -114,6 +114,7 @@ FT_TRACE_DEF( otvgdef )
FT_TRACE_DEF( otvgpos )
FT_TRACE_DEF( otvgsub )
FT_TRACE_DEF( otvjstf )
FT_TRACE_DEF( otvmath )
/* TrueTypeGX/AAT validation components */
FT_TRACE_DEF( gxvmodule )

View File

@ -5,7 +5,7 @@
/* Auxiliary functions and data structures related to PostScript fonts */
/* (specification). */
/* */
/* Copyright 1996-2001, 2002, 2003, 2004, 2006 by */
/* Copyright 1996-2001, 2002, 2003, 2004, 2006, 2008 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@ -530,11 +530,6 @@ FT_BEGIN_HEADER
/* */
/* last :: The last point position. */
/* */
/* scale_x :: The horizontal scaling value (FUnits to */
/* sub-pixels). */
/* */
/* scale_y :: The vertical scaling value (FUnits to sub-pixels). */
/* */
/* pos_x :: The horizontal translation (if composite glyph). */
/* */
/* pos_y :: The vertical translation (if composite glyph). */
@ -569,9 +564,6 @@ FT_BEGIN_HEADER
FT_Vector last;
FT_Fixed scale_x;
FT_Fixed scale_y;
FT_Pos pos_x;
FT_Pos pos_y;

View File

@ -0,0 +1,49 @@
/***************************************************************************/
/* */
/* svcid.h */
/* */
/* The FreeType CID font services (specification). */
/* */
/* Copyright 2007 by Derek Clegg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
/* modified, and distributed under the terms of the FreeType project */
/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
/* this file you indicate that you have read the license and */
/* understand and accept it fully. */
/* */
/***************************************************************************/
#ifndef __SVCID_H__
#define __SVCID_H__
#include FT_INTERNAL_SERVICE_H
FT_BEGIN_HEADER
#define FT_SERVICE_ID_CID "CID"
typedef FT_Error
(*FT_CID_GetRegistryOrderingSupplementFunc)( FT_Face face,
const char* *registry,
const char* *ordering,
FT_Int *supplement );
FT_DEFINE_SERVICE( CID )
{
FT_CID_GetRegistryOrderingSupplementFunc get_ros;
};
/* */
FT_END_HEADER
#endif /* __SVCID_H__ */
/* END */

View File

@ -5,7 +5,7 @@
/* Basic SFNT/TrueType type definitions and interface (specification */
/* only). */
/* */
/* Copyright 1996-2001, 2002, 2004, 2005, 2006, 2007 by */
/* Copyright 1996-2001, 2002, 2004, 2005, 2006, 2007, 2008 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@ -586,7 +586,7 @@ FT_BEGIN_HEADER
/* table_offset :: The offset of the index table in the `EBLC' */
/* table. Only used during strike loading. */
/* */
typedef struct TT_SBit_RangeRec
typedef struct TT_SBit_RangeRec_
{
FT_UShort first_glyph;
FT_UShort last_glyph;

View File

@ -5,7 +5,7 @@
/* Basic Type 1/Type 2 tables definitions and interface (specification */
/* only). */
/* */
/* Copyright 1996-2001, 2002, 2003, 2004, 2006 by */
/* Copyright 1996-2001, 2002, 2003, 2004, 2006, 2008 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@ -66,7 +66,7 @@ FT_BEGIN_HEADER
/* that for Multiple Master fonts, each instance has its own */
/* FontInfo dictionary. */
/* */
typedef struct PS_FontInfoRec
typedef struct PS_FontInfoRec_
{
FT_String* version;
FT_String* notice;
@ -78,7 +78,18 @@ FT_BEGIN_HEADER
FT_Short underline_position;
FT_UShort underline_thickness;
} PS_FontInfoRec, *PS_FontInfo;
} PS_FontInfoRec;
/*************************************************************************/
/* */
/* <Struct> */
/* PS_FontInfo */
/* */
/* <Description> */
/* A handle to a @PS_FontInfoRec structure. */
/* */
typedef struct PS_FontInfoRec_* PS_FontInfo;
/*************************************************************************/
@ -142,7 +153,18 @@ FT_BEGIN_HEADER
FT_Short min_feature[2];
} PS_PrivateRec, *PS_Private;
} PS_PrivateRec;
/*************************************************************************/
/* */
/* <Struct> */
/* PS_Private */
/* */
/* <Description> */
/* A handle to a @PS_PrivateRec structure. */
/* */
typedef struct PS_PrivateRec_* PS_Private;
/*************************************************************************/
@ -168,7 +190,7 @@ FT_BEGIN_HEADER
/* given blend dictionary (font info or private). Used to support */
/* Multiple Masters fonts. */
/* */
typedef enum
typedef enum T1_Blend_Flags_
{
/*# required fields in a FontInfo blend dictionary */
T1_BLEND_UNDERLINE_POSITION = 0,
@ -272,6 +294,14 @@ FT_BEGIN_HEADER
typedef PS_BlendRec T1_Blend;
/*************************************************************************/
/* */
/* <Struct> */
/* CID_FaceDictRec */
/* */
/* <Description> */
/* A structure used to represent data in a CID top-level dictionary. */
/* */
typedef struct CID_FaceDictRec_
{
PS_PrivateRec private_dict;
@ -290,7 +320,20 @@ FT_BEGIN_HEADER
FT_ULong subrmap_offset;
FT_Int sd_bytes;
} CID_FaceDictRec, *CID_FaceDict;
} CID_FaceDictRec;
/*************************************************************************/
/* */
/* <Struct> */
/* CID_FaceDict */
/* */
/* <Description> */
/* A handle to a @CID_FaceDictRec structure. */
/* */
typedef struct CID_FaceDictRec_* CID_FaceDict;
/* */
/* backwards-compatible definition */
@ -332,7 +375,18 @@ FT_BEGIN_HEADER
FT_ULong data_offset;
} CID_FaceInfoRec, *CID_FaceInfo;
} CID_FaceInfoRec;
/*************************************************************************/
/* */
/* <Struct> */
/* CID_FaceInfo */
/* */
/* <Description> */
/* A handle to a @CID_FaceInfoRec structure. */
/* */
typedef struct CID_FaceInfoRec_* CID_FaceInfo;
/*************************************************************************/
@ -347,99 +401,99 @@ FT_BEGIN_HEADER
/* */
typedef CID_FaceInfoRec CID_Info;
/* */
/************************************************************************
*
* @function:
* FT_Has_PS_Glyph_Names
*
* @description:
* Return true if a given face provides reliable Postscript glyph
* names. This is similar to using the @FT_HAS_GLYPH_NAMES macro,
* except that certain fonts (mostly TrueType) contain incorrect
* glyph name tables.
*
* When this function returns true, the caller is sure that the glyph
* names returned by @FT_Get_Glyph_Name are reliable.
*
* @input:
* face ::
* face handle
*
* @return:
* Boolean. True if glyph names are reliable.
*/
/************************************************************************
*
* @function:
* FT_Has_PS_Glyph_Names
*
* @description:
* Return true if a given face provides reliable Postscript glyph
* names. This is similar to using the @FT_HAS_GLYPH_NAMES macro,
* except that certain fonts (mostly TrueType) contain incorrect
* glyph name tables.
*
* When this function returns true, the caller is sure that the glyph
* names returned by @FT_Get_Glyph_Name are reliable.
*
* @input:
* face ::
* face handle
*
* @return:
* Boolean. True if glyph names are reliable.
*
*/
FT_EXPORT( FT_Int )
FT_Has_PS_Glyph_Names( FT_Face face );
/************************************************************************
*
* @function:
* FT_Get_PS_Font_Info
*
* @description:
* Retrieve the @PS_FontInfoRec structure corresponding to a given
* Postscript font.
*
* @input:
* face ::
* Postscript face handle.
*
* @output:
* afont_info ::
* Output font info structure pointer.
*
* @return:
* FreeType error code. 0 means success.
*
* @note:
* The string pointers within the font info structure are owned by
* the face and don't need to be freed by the caller.
*
* If the font's format is not Postscript-based, this function will
* return the `FT_Err_Invalid_Argument' error code.
*/
/************************************************************************
*
* @function:
* FT_Get_PS_Font_Info
*
* @description:
* Retrieve the @PS_FontInfoRec structure corresponding to a given
* Postscript font.
*
* @input:
* face ::
* Postscript face handle.
*
* @output:
* afont_info ::
* Output font info structure pointer.
*
* @return:
* FreeType error code. 0 means success.
*
* @note:
* The string pointers within the font info structure are owned by
* the face and don't need to be freed by the caller.
*
* If the font's format is not Postscript-based, this function will
* return the `FT_Err_Invalid_Argument' error code.
*
*/
FT_EXPORT( FT_Error )
FT_Get_PS_Font_Info( FT_Face face,
PS_FontInfoRec *afont_info );
FT_Get_PS_Font_Info( FT_Face face,
PS_FontInfo afont_info );
/************************************************************************
*
* @function:
* FT_Get_PS_Font_Private
*
* @description:
* Retrieve the @PS_PrivateRec structure corresponding to a given
* Postscript font.
*
* @input:
* face ::
* Postscript face handle.
*
* @output:
* afont_private ::
* Output private dictionary structure pointer.
*
* @return:
* FreeType error code. 0 means success.
*
* @note:
* The string pointers within the font info structure are owned by
* the face and don't need to be freed by the caller.
*
* If the font's format is not Postscript-based, this function will
* return the `FT_Err_Invalid_Argument' error code.
*/
/************************************************************************
*
* @function:
* FT_Get_PS_Font_Private
*
* @description:
* Retrieve the @PS_PrivateRec structure corresponding to a given
* Postscript font.
*
* @input:
* face ::
* Postscript face handle.
*
* @output:
* afont_private ::
* Output private dictionary structure pointer.
*
* @return:
* FreeType error code. 0 means success.
*
* @note:
* The string pointers within the font info structure are owned by
* the face and don't need to be freed by the caller.
*
* If the font's format is not Postscript-based, this function will
* return the `FT_Err_Invalid_Argument' error code.
*
*/
FT_EXPORT( FT_Error )
FT_Get_PS_Font_Private( FT_Face face,
PS_PrivateRec *afont_private );
/* */
FT_Get_PS_Font_Private( FT_Face face,
PS_Private afont_private );
/* */
FT_END_HEADER

View File

@ -4,7 +4,7 @@
/* */
/* TrueType name ID definitions (specification only). */
/* */
/* Copyright 1996-2002, 2003, 2004, 2006, 2007 by */
/* Copyright 1996-2002, 2003, 2004, 2006, 2007, 2008 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@ -26,6 +26,13 @@
FT_BEGIN_HEADER
/*************************************************************************/
/* */
/* <Section> */
/* truetype_tables */
/* */
/*************************************************************************/
/* */
/* Possible values for the `platform' identifier code in the name */
@ -108,13 +115,18 @@ FT_BEGIN_HEADER
*
* TT_APPLE_ID_UNICODE_32 ::
* Unicode 3.1 and beyond, using UTF-32.
*
* TT_APPLE_ID_VARIANT_SELECTOR ::
* From Adobe, not Apple. Not a normal cmap. Specifies variations
* on a real cmap.
*/
#define TT_APPLE_ID_DEFAULT 0 /* Unicode 1.0 */
#define TT_APPLE_ID_UNICODE_1_1 1 /* specify Hangul at U+34xx */
#define TT_APPLE_ID_ISO_10646 2 /* deprecated */
#define TT_APPLE_ID_UNICODE_2_0 3 /* or later */
#define TT_APPLE_ID_UNICODE_32 4 /* 2.0 or later, full repertoire */
#define TT_APPLE_ID_DEFAULT 0 /* Unicode 1.0 */
#define TT_APPLE_ID_UNICODE_1_1 1 /* specify Hangul at U+34xx */
#define TT_APPLE_ID_ISO_10646 2 /* deprecated */
#define TT_APPLE_ID_UNICODE_2_0 3 /* or later */
#define TT_APPLE_ID_UNICODE_32 4 /* 2.0 or later, full repertoire */
#define TT_APPLE_ID_VARIANT_SELECTOR 5 /* variation selector data */
/***********************************************************************
@ -290,6 +302,8 @@ FT_BEGIN_HEADER
* Adobe expert encoding.
* TT_ADOBE_ID_CUSTOM ::
* Adobe custom encoding.
* TT_ADOBE_ID_LATIN_1 ::
* Adobe Latin 1 encoding.
*/
#define TT_ADOBE_ID_STANDARD 0

View File

@ -5,7 +5,7 @@
/* Basic SFNT/TrueType tables definitions and interface */
/* (specification only). */
/* */
/* Copyright 1996-2001, 2002, 2003, 2004, 2005 by */
/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2008 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@ -156,7 +156,7 @@ FT_BEGIN_HEADER
/* caret_Slope_Run :: The run coefficient of the cursor's */
/* slope. */
/* */
/* Reserved :: 10 reserved bytes. */
/* Reserved :: 8 reserved bytes. */
/* */
/* metric_Data_Format :: Always 0. */
/* */
@ -555,7 +555,7 @@ FT_BEGIN_HEADER
/* An enumeration used to specify the index of an SFNT table. */
/* Used in the @FT_Get_Sfnt_Table API function. */
/* */
typedef enum
typedef enum FT_Sfnt_Tag_
{
ft_sfnt_head = 0,
ft_sfnt_maxp = 1,

View File

@ -4,7 +4,7 @@
/* */
/* Tags for TrueType and OpenType tables (specification only). */
/* */
/* Copyright 1996-2001, 2004, 2005 by */
/* Copyright 1996-2001, 2004, 2005, 2007 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@ -67,6 +67,7 @@ FT_BEGIN_HEADER
#define TTAG_lcar FT_MAKE_TAG( 'l', 'c', 'a', 'r' )
#define TTAG_loca FT_MAKE_TAG( 'l', 'o', 'c', 'a' )
#define TTAG_LTSH FT_MAKE_TAG( 'L', 'T', 'S', 'H' )
#define TTAG_MATH FT_MAKE_TAG( 'M', 'A', 'T', 'H' )
#define TTAG_maxp FT_MAKE_TAG( 'm', 'a', 'x', 'p' )
#define TTAG_META FT_MAKE_TAG( 'M', 'E', 'T', 'A' )
#define TTAG_MMFX FT_MAKE_TAG( 'M', 'M', 'F', 'X' )

View File

@ -45,7 +45,7 @@
/*************************************************************************/
/*************************************************************************/
static FT_Error
FT_LOCAL_DEF( FT_Error )
af_cjk_metrics_init( AF_LatinMetrics metrics,
FT_Face face )
{
@ -91,7 +91,7 @@
}
static void
FT_LOCAL_DEF( void )
af_cjk_metrics_scale( AF_LatinMetrics metrics,
AF_Scaler scaler )
{
@ -427,7 +427,9 @@
/* insert a new edge in the list and */
/* sort according to the position */
error = af_axis_hints_new_edge( axis, seg->pos, seg->dir, memory, &edge );
error = af_axis_hints_new_edge( axis, seg->pos,
(AF_Direction)seg->dir,
memory, &edge );
if ( error )
goto Exit;
@ -596,7 +598,7 @@
}
static FT_Error
FT_LOCAL_DEF( FT_Error )
af_cjk_hints_init( AF_GlyphHints hints,
AF_LatinMetrics metrics )
{
@ -1350,7 +1352,7 @@
}
static FT_Error
FT_LOCAL_DEF( FT_Error )
af_cjk_hints_apply( AF_GlyphHints hints,
FT_Outline* outline,
AF_LatinMetrics metrics )

View File

@ -4,7 +4,7 @@
/* */
/* Auto-fitter hinting routines for CJK script (specification). */
/* */
/* Copyright 2006 by */
/* Copyright 2006, 2007 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@ -31,6 +31,23 @@ FT_BEGIN_HEADER
af_cjk_script_class;
FT_LOCAL( FT_Error )
af_cjk_metrics_init( AF_LatinMetrics metrics,
FT_Face face );
FT_LOCAL( void )
af_cjk_metrics_scale( AF_LatinMetrics metrics,
AF_Scaler scaler );
FT_LOCAL( FT_Error )
af_cjk_hints_init( AF_GlyphHints hints,
AF_LatinMetrics metrics );
FT_LOCAL( FT_Error )
af_cjk_hints_apply( AF_GlyphHints hints,
FT_Outline* outline,
AF_LatinMetrics metrics );
/* */
FT_END_HEADER

View File

@ -4,7 +4,7 @@
/* */
/* Auto-fitter routines to compute global hinting values (body). */
/* */
/* Copyright 2003, 2004, 2005, 2006, 2007 by */
/* Copyright 2003, 2004, 2005, 2006, 2007, 2008 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@ -84,8 +84,8 @@
if ( error )
{
/*
* Ignore this error; we simply use Latin as the standard
* script. XXX: Shouldn't we rather disable hinting?
* Ignore this error; we simply use the default script.
* XXX: Shouldn't we rather disable hinting?
*/
error = AF_Err_Ok;
goto Exit;

View File

@ -4,7 +4,7 @@
/* */
/* Auto-fitter hinting routines (specification). */
/* */
/* Copyright 2003, 2004, 2005, 2006, 2007 by */
/* Copyright 2003, 2004, 2005, 2006, 2007, 2008 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@ -30,7 +30,7 @@ FT_BEGIN_HEADER
* script analysis routines (until now).
*/
typedef enum
typedef enum AF_Dimension_
{
AF_DIMENSION_HORZ = 0, /* x coordinates, */
/* i.e., vertical segments & edges */
@ -44,7 +44,7 @@ FT_BEGIN_HEADER
/* hint directions -- the values are computed so that two vectors are */
/* in opposite directions iff `dir1 + dir2 == 0' */
typedef enum
typedef enum AF_Direction_
{
AF_DIR_NONE = 4,
AF_DIR_RIGHT = 1,
@ -56,7 +56,7 @@ FT_BEGIN_HEADER
/* point hint flags */
typedef enum
typedef enum AF_Flags_
{
AF_FLAG_NONE = 0,
@ -87,7 +87,7 @@ FT_BEGIN_HEADER
/* edge hint flags */
typedef enum
typedef enum AF_Edge_Flags_
{
AF_EDGE_NORMAL = 0,
AF_EDGE_ROUND = 1 << 0,

View File

@ -43,7 +43,7 @@
static void
af_indic_metrics_scale( AF_LatinMetrics metrics,
AF_Scaler scaler )
AF_Scaler scaler )
{
/* use CJK routines */
af_cjk_metrics_scale( metrics, scaler );
@ -52,7 +52,7 @@
static FT_Error
af_indic_hints_init( AF_GlyphHints hints,
AF_LatinMetrics metrics )
AF_LatinMetrics metrics )
{
/* use CJK routines */
return af_cjk_hints_init( hints, metrics );
@ -61,8 +61,8 @@
static FT_Error
af_indic_hints_apply( AF_GlyphHints hints,
FT_Outline* outline,
AF_LatinMetrics metrics)
FT_Outline* outline,
AF_LatinMetrics metrics)
{
/* use CJK routines */
return af_cjk_hints_apply( hints, outline, metrics );

View File

@ -197,7 +197,7 @@
FT_UInt glyph_index;
FT_Int best_point, best_y, best_first, best_last;
FT_Vector* points;
FT_Bool round;
FT_Bool round = 0;
AF_LOG(( "'%c'", *p ));
@ -1004,12 +1004,14 @@
if ( !found )
{
AF_Edge edge;
AF_Edge edge;
/* insert a new edge in the list and */
/* sort according to the position */
error = af_axis_hints_new_edge( axis, seg->pos, seg->dir, memory, &edge );
error = af_axis_hints_new_edge( axis, seg->pos,
(AF_Direction)seg->dir,
memory, &edge );
if ( error )
goto Exit;

View File

@ -4,7 +4,7 @@
/* */
/* Auto-fitter glyph loading routines (body). */
/* */
/* Copyright 2003, 2004, 2005, 2006, 2007 by */
/* Copyright 2003, 2004, 2005, 2006, 2007, 2008 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@ -165,9 +165,10 @@
/* now load the slot image into the auto-outline and run the */
/* automatic hinting process */
metrics->clazz->script_hints_apply( hints,
&gloader->current.outline,
metrics );
if ( metrics->clazz->script_hints_apply )
metrics->clazz->script_hints_apply( hints,
&gloader->current.outline,
metrics );
/* we now need to hint the metrics according to the change in */
/* width/positioning that occurred during the hinting process */
@ -515,9 +516,13 @@
load_flags |= FT_LOAD_NO_SCALE | FT_LOAD_IGNORE_TRANSFORM;
load_flags &= ~FT_LOAD_RENDER;
error = metrics->clazz->script_hints_init( &loader->hints, metrics );
if ( error )
goto Exit;
if ( metrics->clazz->script_hints_init )
{
error = metrics->clazz->script_hints_init( &loader->hints,
metrics );
if ( error )
goto Exit;
}
error = af_loader_load_g( loader, &scaler, gindex, load_flags, 0 );
}

View File

@ -4,7 +4,7 @@
/* */
/* Auto-fitter types (specification only). */
/* */
/* Copyright 2003, 2004, 2005, 2006, 2007 by */
/* Copyright 2003, 2004, 2005, 2006, 2007, 2008 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@ -202,7 +202,7 @@ extern void* _af_debug_hints;
* auto-hinted glyph image.
*/
typedef enum
typedef enum AF_ScalerFlags_
{
AF_SCALER_FLAG_NO_HORIZONTAL = 1, /* disable horizontal hinting */
AF_SCALER_FLAG_NO_VERTICAL = 2, /* disable vertical hinting */
@ -260,7 +260,7 @@ extern void* _af_debug_hints;
* used by more than one script.
*/
typedef enum
typedef enum AF_Script_
{
AF_SCRIPT_NONE = 0,
AF_SCRIPT_LATIN = 1,

View File

@ -32,7 +32,7 @@
#include "ftutil.c"
#if defined( __APPLE__ ) && !defined ( DARWIN_NO_CARBON )
#include <ftmac.c>
#include "ftmac.c"
#endif
/* END */

View File

@ -4,7 +4,7 @@
/* */
/* Arithmetic computations (body). */
/* */
/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006 by */
/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006, 2008 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@ -512,8 +512,8 @@
FT_UInt32 q;
s = a; a = FT_ABS(a);
s ^= b; b = FT_ABS(b);
s = a; a = FT_ABS( a );
s ^= b; b = FT_ABS( b );
if ( b == 0 )
{
@ -666,6 +666,57 @@
#endif /* FT_LONG64 */
/* documentation is in ftcalc.h */
FT_BASE_DEF( void )
FT_Matrix_Multiply_Scaled( const FT_Matrix* a,
FT_Matrix *b,
FT_Long scaling )
{
FT_Fixed xx, xy, yx, yy;
FT_Long val = 0x10000L * scaling;
if ( !a || !b )
return;
xx = FT_MulDiv( a->xx, b->xx, val ) + FT_MulDiv( a->xy, b->yx, val );
xy = FT_MulDiv( a->xx, b->xy, val ) + FT_MulDiv( a->xy, b->yy, val );
yx = FT_MulDiv( a->yx, b->xx, val ) + FT_MulDiv( a->yy, b->yx, val );
yy = FT_MulDiv( a->yx, b->xy, val ) + FT_MulDiv( a->yy, b->yy, val );
b->xx = xx; b->xy = xy;
b->yx = yx; b->yy = yy;
}
/* documentation is in ftcalc.h */
FT_BASE_DEF( void )
FT_Vector_Transform_Scaled( FT_Vector* vector,
const FT_Matrix* matrix,
FT_Long scaling )
{
FT_Pos xz, yz;
FT_Long val = 0x10000L * scaling;
if ( !vector || !matrix )
return;
xz = FT_MulDiv( vector->x, matrix->xx, val ) +
FT_MulDiv( vector->y, matrix->xy, val );
yz = FT_MulDiv( vector->x, matrix->yx, val ) +
FT_MulDiv( vector->y, matrix->yy, val );
vector->x = xz;
vector->y = yz;
}
/* documentation is in ftcalc.h */
FT_BASE_DEF( FT_Int32 )

View File

@ -0,0 +1,63 @@
/***************************************************************************/
/* */
/* ftcid.c */
/* */
/* FreeType API for accessing CID font information. */
/* */
/* Copyright 2007 by Derek Clegg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
/* modified, and distributed under the terms of the FreeType project */
/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
/* this file you indicate that you have read the license and */
/* understand and accept it fully. */
/* */
/***************************************************************************/
#include <ft2build.h>
#include FT_INTERNAL_OBJECTS_H
#include FT_SERVICE_CID_H
/* documentation is in ftcid.h */
FT_EXPORT_DEF( FT_Error )
FT_Get_CID_Registry_Ordering_Supplement( FT_Face face,
const char* *registry,
const char* *ordering,
FT_Int *supplement)
{
FT_Error error;
const char* r = NULL;
const char* o = NULL;
FT_Int s = 0;
error = FT_Err_Invalid_Argument;
if ( face )
{
FT_Service_CID service;
FT_FACE_FIND_SERVICE( face, service, CID );
if ( service && service->get_ros )
error = service->get_ros( face, &r, &o, &s );
}
if ( registry )
*registry = r;
if ( ordering )
*ordering = o;
if ( supplement )
*supplement = s;
return error;
}
/* END */

View File

@ -4,7 +4,7 @@
/* */
/* Debugging and logging component (body). */
/* */
/* Copyright 1996-2001, 2002, 2004 by */
/* Copyright 1996-2001, 2002, 2004, 2008 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@ -57,7 +57,7 @@
va_start( ap, fmt );
vprintf( fmt, ap );
vfprintf( stderr, fmt, ap );
va_end( ap );
}
@ -71,7 +71,7 @@
va_start( ap, fmt );
vprintf( fmt, ap );
vfprintf( stderr, fmt, ap );
va_end( ap );
exit( EXIT_FAILURE );

View File

@ -376,10 +376,16 @@
const FT_Glyph_Class* clazz;
/* check arguments */
if ( !target )
{
error = FT_Err_Invalid_Argument;
goto Exit;
}
*target = 0;
/* check arguments */
if ( !target || !source || !source->clazz )
if ( !source || !source->clazz )
{
error = FT_Err_Invalid_Argument;
goto Exit;

View File

@ -4,7 +4,7 @@
/* */
/* FreeType API for color filtering of subpixel bitmap glyphs (body). */
/* */
/* Copyright 2006 by */
/* Copyright 2006, 2008 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@ -161,7 +161,7 @@
#ifdef USE_LEGACY
/* FIR filter used by the default and light filters */
/* intra-pixel filter used by the legacy filter */
static void
_ft_lcd_filter_legacy( FT_Bitmap* bitmap,
FT_Render_Mode mode,
@ -181,7 +181,7 @@
FT_UNUSED( library );
/* horizontal in-place FIR filter */
/* horizontal in-place intra-pixel filter */
if ( mode == FT_RENDER_MODE_LCD && width >= 3 )
{
FT_Byte* line = bitmap->buffer;

View File

@ -8,7 +8,7 @@
/* This file is for Mac OS X only; see builds/mac/ftoldmac.c for */
/* classic platforms built by MPW. */
/* */
/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006, 2007 by */
/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 by */
/* Just van Rossum, David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@ -76,12 +76,16 @@
#undef OS_INLINE
#define OS_INLINE static __inline__
#endif
#include <Carbon/Carbon.h>
#ifndef HFS_MAXPATHLEN
#define HFS_MAXPATHLEN 1024
/* The ResourceIndex type was only added in the 10.5 SDK */
#ifndef MAC_OS_X_VERSION_10_5
typedef short ResourceIndex;
#endif
#include <CoreServices/CoreServices.h>
#include <ApplicationServices/ApplicationServices.h>
#include <sys/syslimits.h> /* PATH_MAX */
#define FT_DEPRECATED_ATTRIBUTE
#include FT_MAC_H
@ -89,7 +93,13 @@
/* undefine blocking-macros in ftmac.h */
#undef FT_GetFile_From_Mac_Name( a, b, c )
#undef FT_GetFile_From_Mac_ATS_Name( a, b, c )
#undef FT_New_Face_From_FOND( a, b, c, d )
#undef FT_New_Face_From_FSSpec( a, b, c, d )
#undef FT_New_Face_From_FSRef( a, b, c, d )
#ifndef kATSOptionFlagsUnRestrictedScope /* since Mac OS X 10.1 */
#define kATSOptionFlagsUnRestrictedScope kATSOptionFlagsDefault
#endif
/* Set PREFER_LWFN to 1 if LWFN (Type 1) is preferred over
@ -100,6 +110,7 @@
#endif
/* This function is deprecated because FSSpec is deprecated in Mac OS X */
FT_EXPORT_DEF( FT_Error )
FT_GetFile_From_Mac_Name( const char* fontName,
FSSpec* pathSpec,
@ -115,19 +126,28 @@
/* Private function. */
/* The FSSpec type has been discouraged for a long time, */
/* but for some reason, there is no FSRef version of */
/* ATSFontGetFileSpecification(), so we made our own. */
/* Apple will provide one eventually. */
/* unfortunately an FSRef replacement API for */
/* ATSFontGetFileSpecification() is only available in */
/* Mac OS X 10.5 and later. */
static OSStatus
FT_ATSFontGetFileReference( ATSFontRef ats_font_id,
FSRef* ats_font_ref )
{
#if __LP64__
#if defined( MAC_OS_X_VERSION_10_5 ) && \
MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5
OSStatus err;
err = ATSFontGetFileReference( ats_font_id, ats_font_ref );
return err;
#elif __LP64__ /* No 64bit Carbon API on legacy platforms */
FT_UNUSED( ats_font_id );
FT_UNUSED( ats_font_ref );
return fnfErr;
#else
#else /* 32bit Carbon API on legacy platforms */
OSStatus err;
FSSpec spec;
@ -214,7 +234,8 @@
FSSpec* pathSpec,
FT_Long* face_index )
{
#if __LP64__
#if ( __LP64__ ) || ( defined( MAC_OS_X_VERSION_10_5 ) && \
MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5 )
FT_UNUSED( fontName );
FT_UNUSED( pathSpec );
FT_UNUSED( face_index );
@ -239,8 +260,8 @@
static OSErr
FT_FSPathMakeRes( const UInt8* pathname,
short* res )
FT_FSPathMakeRes( const UInt8* pathname,
ResFileRefNum* res )
{
OSErr err;
FSRef ref;
@ -357,7 +378,7 @@
static void
parse_fond( char* fond_data,
short* have_sfnt,
short* sfnt_id,
ResID* sfnt_id,
Str255 lwfn_file_name,
short face_index )
{
@ -374,6 +395,10 @@
assoc = (AsscEntry*)( fond_data + sizeof ( FamRec ) + 2 );
base_assoc = assoc;
/* the maximum faces in a FOND is 48, size of StyleTable.indexes[] */
if ( 47 < face_index )
return;
/* Let's do a little range checking before we get too excited here */
if ( face_index < count_faces_sfnt( fond_data ) )
{
@ -425,9 +450,10 @@
ft_memcpy(ps_name, names[0] + 1, ps_name_len);
ps_name[ps_name_len] = 0;
}
if ( style->indexes[0] > 1 )
if ( style->indexes[face_index] > 1 &&
style->indexes[face_index] <= FT_MIN( string_count, 64 ) )
{
unsigned char* suffixes = names[style->indexes[0] - 1];
unsigned char* suffixes = names[style->indexes[face_index] - 1];
for ( i = 1; i <= suffixes[0]; i++ )
@ -463,8 +489,8 @@
UInt8* path_lwfn,
size_t path_size )
{
FSRef ref, par_ref;
int dirname_len;
FSRef ref, par_ref;
size_t dirname_len;
/* Pathname for FSRef can be in various formats: HFS, HFS+, and POSIX. */
@ -504,10 +530,10 @@
count_faces( Handle fond,
const UInt8* pathname )
{
short sfnt_id;
ResID sfnt_id;
short have_sfnt, have_lwfn;
Str255 lwfn_file_name;
UInt8 buff[HFS_MAXPATHLEN];
UInt8 buff[PATH_MAX];
FT_Error err;
short num_faces;
@ -539,13 +565,13 @@
chunks are often not organized that way, so we glue chunks
of the same type together. */
static FT_Error
read_lwfn( FT_Memory memory,
short res,
FT_Byte** pfb_data,
FT_ULong* size )
read_lwfn( FT_Memory memory,
ResFileRefNum res,
FT_Byte** pfb_data,
FT_ULong* size )
{
FT_Error error = FT_Err_Ok;
short res_id;
ResID res_id;
unsigned char *buffer, *p, *size_p = NULL;
FT_ULong total_size = 0;
FT_ULong old_total_size = 0;
@ -563,7 +589,8 @@
for (;;)
{
post_data = Get1Resource( 'POST', res_id++ );
post_data = Get1Resource( FT_MAKE_TAG( 'P', 'O', 'S', 'T' ),
res_id++ );
if ( post_data == NULL )
break; /* we are done */
@ -602,7 +629,8 @@
for (;;)
{
post_data = Get1Resource( 'POST', res_id++ );
post_data = Get1Resource( FT_MAKE_TAG( 'P', 'O', 'S', 'T' ),
res_id++ );
if ( post_data == NULL )
break; /* we are done */
@ -707,12 +735,12 @@
/* Create a new FT_Face given a buffer and a driver name. */
static FT_Error
open_face_from_buffer( FT_Library library,
FT_Byte* base,
FT_ULong size,
FT_Long face_index,
char* driver_name,
FT_Face* aface )
open_face_from_buffer( FT_Library library,
FT_Byte* base,
FT_ULong size,
FT_Long face_index,
const char* driver_name,
FT_Face* aface )
{
FT_Open_Args args;
FT_Error error;
@ -764,10 +792,10 @@
FT_Long face_index,
FT_Face* aface )
{
FT_Byte* pfb_data;
FT_ULong pfb_size;
FT_Error error;
short res;
FT_Byte* pfb_data;
FT_ULong pfb_size;
FT_Error error;
ResFileRefNum res;
if ( noErr != FT_FSPathMakeRes( pathname, &res ) )
@ -792,7 +820,7 @@
/* Create a new FT_Face from an SFNT resource, specified by res ID. */
static FT_Error
FT_New_Face_From_SFNT( FT_Library library,
short sfnt_id,
ResID sfnt_id,
FT_Long face_index,
FT_Face* aface )
{
@ -804,8 +832,8 @@
int is_cff;
sfnt = GetResource( 'sfnt', sfnt_id );
if ( ResError() )
sfnt = GetResource( FT_MAKE_TAG( 's', 'f', 'n', 't' ), sfnt_id );
if ( sfnt == NULL )
return FT_Err_Invalid_Handle;
sfnt_size = (FT_ULong)GetHandleSize( sfnt );
@ -839,10 +867,11 @@
FT_Long face_index,
FT_Face* aface )
{
FT_Error error = FT_Err_Cannot_Open_Resource;
short res_ref, res_index;
Handle fond;
short num_faces_in_res, num_faces_in_fond;
FT_Error error = FT_Err_Cannot_Open_Resource;
ResFileRefNum res_ref;
ResourceIndex res_index;
Handle fond;
short num_faces_in_res, num_faces_in_fond;
if ( noErr != FT_FSPathMakeRes( pathname, &res_ref ) )
@ -855,7 +884,8 @@
num_faces_in_res = 0;
for ( res_index = 1; ; ++res_index )
{
fond = Get1IndResource( 'FOND', res_index );
fond = Get1IndResource( FT_MAKE_TAG( 'F', 'O', 'N', 'D' ),
res_index );
if ( ResError() )
break;
@ -869,7 +899,7 @@
}
CloseResFile( res_ref );
if ( FT_Err_Ok == error && NULL != aface )
if ( FT_Err_Ok == error && NULL != aface && NULL != *aface )
(*aface)->num_faces = num_faces_in_res;
return error;
}
@ -883,25 +913,25 @@
FT_Long face_index,
FT_Face* aface )
{
short sfnt_id, have_sfnt, have_lwfn = 0;
short fond_id;
short have_sfnt, have_lwfn = 0;
ResID sfnt_id, fond_id;
OSType fond_type;
Str255 fond_name;
Str255 lwfn_file_name;
UInt8 path_lwfn[HFS_MAXPATHLEN];
UInt8 path_lwfn[PATH_MAX];
OSErr err;
FT_Error error = FT_Err_Ok;
GetResInfo( fond, &fond_id, &fond_type, fond_name );
if ( ResError() != noErr || fond_type != 'FOND' )
if ( ResError() != noErr || fond_type != FT_MAKE_TAG( 'F', 'O', 'N', 'D' ) )
return FT_Err_Invalid_File_Format;
parse_fond( *fond, &have_sfnt, &sfnt_id, lwfn_file_name, face_index );
if ( lwfn_file_name[0] )
{
short res;
ResFileRefNum res;
res = HomeResFile( fond );
@ -909,7 +939,7 @@
goto found_no_lwfn_file;
{
UInt8 path_fond[HFS_MAXPATHLEN];
UInt8 path_fond[PATH_MAX];
FSRef ref;
@ -961,7 +991,7 @@
/* LWFN is a (very) specific file format, check for it explicitly */
file_type = get_file_type_from_path( pathname );
if ( file_type == 'LWFN' )
if ( file_type == FT_MAKE_TAG( 'L', 'W', 'F', 'N' ) )
return FT_New_Face_From_LWFN( library, pathname, face_index, aface );
/* Otherwise the file type doesn't matter (there are more than */
@ -1029,6 +1059,8 @@
/* FT_New_Face_From_FSRef is identical to FT_New_Face except it */
/* accepts an FSRef instead of a path. */
/* */
/* This function is deprecated because Carbon data types (FSRef) */
/* are not cross-platform, and thus not suitable for the freetype API. */
FT_EXPORT_DEF( FT_Error )
FT_New_Face_From_FSRef( FT_Library library,
const FSRef* ref,
@ -1038,7 +1070,7 @@
FT_Error error;
FT_Open_Args args;
OSErr err;
UInt8 pathname[HFS_MAXPATHLEN];
UInt8 pathname[PATH_MAX];
if ( !ref )
@ -1068,13 +1100,15 @@
/* FT_New_Face_From_FSSpec is identical to FT_New_Face except it */
/* accepts an FSSpec instead of a path. */
/* */
/* This function is deprecated because FSSpec is deprecated in Mac OS X */
FT_EXPORT_DEF( FT_Error )
FT_New_Face_From_FSSpec( FT_Library library,
const FSSpec* spec,
FT_Long face_index,
FT_Face* aface )
{
#if __LP64__
#if ( __LP64__ ) || ( defined( MAC_OS_X_VERSION_10_5 ) && \
MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5 )
FT_UNUSED( library );
FT_UNUSED( spec );
FT_UNUSED( face_index );

View File

@ -4,7 +4,7 @@
/* */
/* The FreeType private base classes (body). */
/* */
/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006, 2007 by */
/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@ -634,12 +634,24 @@
goto Load_Ok;
}
/* load auto-hinted outline */
hinting = (FT_AutoHinter_Service)hinter->clazz->module_interface;
{
FT_Face_Internal internal = face->internal;
FT_Int transform_flags = internal->transform_flags;
error = hinting->load_glyph( (FT_AutoHinter)hinter,
slot, face->size,
glyph_index, load_flags );
/* since the auto-hinter calls FT_Load_Glyph by itself, */
/* make sure that glyphs aren't transformed */
internal->transform_flags = 0;
/* load auto-hinted outline */
hinting = (FT_AutoHinter_Service)hinter->clazz->module_interface;
error = hinting->load_glyph( (FT_AutoHinter)hinter,
slot, face->size,
glyph_index, load_flags );
internal->transform_flags = transform_flags;
}
}
else
{
@ -883,14 +895,13 @@
/* are limited to the BMP (said UCS-2 encoding.) */
/* */
/* This function is called from open_face() (just below), and also */
/* from FT_Select_Charmap( ..., FT_ENCODING_UNICODE). */
/* from FT_Select_Charmap( ..., FT_ENCODING_UNICODE ). */
/* */
static FT_Error
find_unicode_charmap( FT_Face face )
{
FT_CharMap* first;
FT_CharMap* cur;
FT_CharMap* unicmap = NULL; /* some UCS-2 map, if we found it */
/* caller should have already checked that `face' is valid */
@ -935,36 +946,75 @@
{
if ( cur[0]->encoding == FT_ENCODING_UNICODE )
{
unicmap = cur; /* record we found a Unicode charmap */
/* XXX If some new encodings to represent UCS-4 are added, */
/* they should be added here. */
/* XXX If some new encodings to represent UCS-4 are added, */
/* they should be added here. */
if ( ( cur[0]->platform_id == TT_PLATFORM_MICROSOFT &&
cur[0]->encoding_id == TT_MS_ID_UCS_4 ) ||
cur[0]->encoding_id == TT_MS_ID_UCS_4 ) ||
( cur[0]->platform_id == TT_PLATFORM_APPLE_UNICODE &&
cur[0]->encoding_id == TT_APPLE_ID_UNICODE_32 ) )
/* Hurray! We found a UCS-4 charmap. We can stop the scan! */
cur[0]->encoding_id == TT_APPLE_ID_UNICODE_32 ) )
{
face->charmap = cur[0];
return 0;
return FT_Err_Ok;
}
}
}
/* We do not have any UCS-4 charmap. Sigh. */
/* Let's see if we have some other kind of Unicode charmap, though. */
if ( unicmap != NULL )
/* We do not have any UCS-4 charmap. */
/* Do the loop again and search for UCS-2 charmaps. */
cur = first + face->num_charmaps;
for ( ; --cur >= first; )
{
face->charmap = unicmap[0];
return 0;
if ( cur[0]->encoding == FT_ENCODING_UNICODE )
{
face->charmap = cur[0];
return FT_Err_Ok;
}
}
/* Chou blanc! */
return FT_Err_Invalid_CharMap_Handle;
}
/*************************************************************************/
/* */
/* <Function> */
/* find_variant_selector_charmap */
/* */
/* <Description> */
/* This function finds the variant selector charmap, if there is one. */
/* There can only be one (platform=0, specific=5, format=14). */
/* */
static FT_CharMap
find_variant_selector_charmap( FT_Face face )
{
FT_CharMap* first;
FT_CharMap* end;
FT_CharMap* cur;
/* caller should have already checked that `face' is valid */
FT_ASSERT( face );
first = face->charmaps;
if ( !first )
return NULL;
end = first + face->num_charmaps; /* points after the last one */
for ( cur = first; cur < end; ++cur )
{
if ( cur[0]->platform_id == TT_PLATFORM_APPLE_UNICODE &&
cur[0]->encoding_id == TT_APPLE_ID_VARIANT_SELECTOR &&
FT_Get_CMap_Format( cur[0] ) == 14 )
return cur[0];
}
return NULL;
}
/*************************************************************************/
/* */
/* <Function> */
@ -1013,15 +1063,17 @@
for ( i = 0; i < num_params && !face->internal->incremental_interface;
i++ )
if ( params[i].tag == FT_PARAM_TAG_INCREMENTAL )
face->internal->incremental_interface = params[i].data;
face->internal->incremental_interface =
(FT_Incremental_Interface)params[i].data;
}
#endif
error = clazz->init_face( stream,
face,
(FT_Int)face_index,
num_params,
params );
if ( clazz->init_face )
error = clazz->init_face( stream,
face,
(FT_Int)face_index,
num_params,
params );
if ( error )
goto Fail;
@ -1044,7 +1096,8 @@
if ( error )
{
destroy_charmaps( face, memory );
clazz->done_face( face );
if ( clazz->done_face )
clazz->done_face( face );
FT_FREE( internal );
FT_FREE( face );
*aface = 0;
@ -1488,6 +1541,9 @@
FT_Long dlen, offset;
if ( NULL == stream )
return FT_Err_Invalid_Stream_Operation;
error = FT_Stream_Seek( stream, 0 );
if ( error )
goto Exit;
@ -1661,6 +1717,8 @@
FT_Face face = 0;
FT_ListNode node = 0;
FT_Bool external_stream;
FT_Module* cur;
FT_Module* limit;
/* test for valid `library' delayed to */
@ -1675,7 +1733,7 @@
/* create input stream */
error = FT_Stream_New( library, args, &stream );
if ( error )
goto Exit;
goto Fail3;
memory = library->memory;
@ -1712,8 +1770,8 @@
else
{
/* check each font driver for an appropriate format */
FT_Module* cur = library->modules;
FT_Module* limit = cur + library->num_modules;
cur = library->modules;
limit = cur + library->num_modules;
for ( ; cur < limit; cur++ )
@ -1747,7 +1805,8 @@
/* If we are on the mac, and we get an FT_Err_Invalid_Stream_Operation */
/* it may be because we have an empty data fork, so we need to check */
/* the resource fork. */
if ( FT_ERROR_BASE( error ) != FT_Err_Unknown_File_Format &&
if ( FT_ERROR_BASE( error ) != FT_Err_Cannot_Open_Stream &&
FT_ERROR_BASE( error ) != FT_Err_Unknown_File_Format &&
FT_ERROR_BASE( error ) != FT_Err_Invalid_Stream_Operation )
goto Fail2;
@ -2631,6 +2690,8 @@
cur = face->charmaps;
if ( !cur )
return FT_Err_Invalid_CharMap_Handle;
if ( FT_Get_CMap_Format( charmap ) == 14 )
return FT_Err_Invalid_Argument;
limit = cur + face->num_charmaps;
@ -2849,6 +2910,149 @@
}
/* documentation is in freetype.h */
FT_EXPORT_DEF( FT_UInt )
FT_Face_GetCharVariantIndex( FT_Face face,
FT_ULong charcode,
FT_ULong variantSelector )
{
FT_UInt result = 0;
if ( face && face->charmap &&
face->charmap->encoding == FT_ENCODING_UNICODE )
{
FT_CharMap charmap = find_variant_selector_charmap( face );
FT_CMap ucmap = FT_CMAP( face->charmap );
if ( charmap != NULL )
{
FT_CMap vcmap = FT_CMAP( charmap );
result = vcmap->clazz->char_var_index( vcmap, ucmap, charcode,
variantSelector );
}
}
return result;
}
/* documentation is in freetype.h */
FT_EXPORT_DEF( FT_Int )
FT_Face_GetCharVariantIsDefault( FT_Face face,
FT_ULong charcode,
FT_ULong variantSelector )
{
FT_Int result = -1;
if ( face )
{
FT_CharMap charmap = find_variant_selector_charmap( face );
if ( charmap != NULL )
{
FT_CMap vcmap = FT_CMAP( charmap );
result = vcmap->clazz->char_var_default( vcmap, charcode,
variantSelector );
}
}
return result;
}
/* documentation is in freetype.h */
FT_EXPORT_DEF( FT_UInt32* )
FT_Face_GetVariantSelectors( FT_Face face )
{
FT_UInt32 *result = NULL;
if ( face )
{
FT_CharMap charmap = find_variant_selector_charmap( face );
if ( charmap != NULL )
{
FT_CMap vcmap = FT_CMAP( charmap );
FT_Memory memory = FT_FACE_MEMORY( face );
result = vcmap->clazz->variant_list( vcmap, memory );
}
}
return result;
}
/* documentation is in freetype.h */
FT_EXPORT_DEF( FT_UInt32* )
FT_Face_GetVariantsOfChar( FT_Face face,
FT_ULong charcode )
{
FT_UInt32 *result = NULL;
if ( face )
{
FT_CharMap charmap = find_variant_selector_charmap( face );
if ( charmap != NULL )
{
FT_CMap vcmap = FT_CMAP( charmap );
FT_Memory memory = FT_FACE_MEMORY( face );
result = vcmap->clazz->charvariant_list( vcmap, memory, charcode );
}
}
return result;
}
/* documentation is in freetype.h */
FT_EXPORT_DEF( FT_UInt32* )
FT_Face_GetCharsOfVariant( FT_Face face,
FT_ULong variantSelector )
{
FT_UInt32 *result = NULL;
if ( face )
{
FT_CharMap charmap = find_variant_selector_charmap( face );
if ( charmap != NULL )
{
FT_CMap vcmap = FT_CMAP( charmap );
FT_Memory memory = FT_FACE_MEMORY( face );
result = vcmap->clazz->variantchar_list( vcmap, memory,
variantSelector );
}
}
return result;
}
/* documentation is in freetype.h */
FT_EXPORT_DEF( FT_UInt )
@ -3725,9 +3929,10 @@
/* allocate the render pool */
library->raster_pool_size = FT_RENDER_POOL_SIZE;
if ( FT_RENDER_POOL_SIZE > 0 )
if ( FT_ALLOC( library->raster_pool, FT_RENDER_POOL_SIZE ) )
goto Fail;
#if FT_RENDER_POOL_SIZE > 0
if ( FT_ALLOC( library->raster_pool, FT_RENDER_POOL_SIZE ) )
goto Fail;
#endif
/* That's ok now */
*alibrary = library;

View File

@ -474,12 +474,14 @@
FT_Pos yOffset )
{
FT_UShort n;
FT_Vector* vec = outline->points;
FT_Vector* vec;
if ( !outline )
return;
vec = outline->points;
for ( n = 0; n < outline->n_points; n++ )
{
vec->x += xOffset;
@ -626,13 +628,13 @@
}
/* documentation is in ftoutln.h */
/* documentation is in freetype.h */
FT_EXPORT_DEF( void )
FT_Vector_Transform( FT_Vector* vector,
const FT_Matrix* matrix )
{
FT_Pos xz, yz;
FT_Pos xz, yz;
if ( !vector || !matrix )

View File

@ -4,7 +4,7 @@
/* */
/* Embedded resource forks accessor (body). */
/* */
/* Copyright 2004, 2005, 2006 by */
/* Copyright 2004, 2005, 2006, 2007 by */
/* Masatake YAMATO and Redhat K.K. */
/* */
/* FT_Raccess_Get_HeaderInfo() and raccess_guess_darwin_hfsplus() are */
@ -132,6 +132,19 @@
}
static int
ft_raccess_sort_ref_by_id( FT_RFork_Ref* a,
FT_RFork_Ref* b )
{
if ( a->res_id < b->res_id )
return -1;
else if ( a->res_id > b->res_id )
return 1;
else
return 0;
}
FT_BASE_DEF( FT_Error )
FT_Raccess_Get_DataOffsets( FT_Library library,
FT_Stream stream,
@ -141,12 +154,13 @@
FT_Long **offsets,
FT_Long *count )
{
FT_Error error;
int i, j, cnt, subcnt;
FT_Long tag_internal, rpos;
FT_Memory memory = library->memory;
FT_Long temp;
FT_Long *offsets_internal;
FT_Error error;
int i, j, cnt, subcnt;
FT_Long tag_internal, rpos;
FT_Memory memory = library->memory;
FT_Long temp;
FT_Long *offsets_internal;
FT_RFork_Ref *ref;
error = FT_Stream_Seek( stream, map_offset );
@ -179,28 +193,43 @@
if ( error )
return error;
if ( FT_NEW_ARRAY( offsets_internal, *count ) )
if ( FT_NEW_ARRAY( ref, *count ) )
return error;
for ( j = 0; j < *count; ++j )
{
(void)FT_STREAM_SKIP( 2 ); /* resource id */
(void)FT_STREAM_SKIP( 2 ); /* rsource name */
if ( FT_READ_USHORT( ref[j].res_id ) )
goto Exit;
if ( FT_STREAM_SKIP( 2 ) ) /* resource name */
goto Exit;
if ( FT_READ_LONG( temp ) )
{
FT_FREE( offsets_internal );
return error;
}
goto Exit;
if ( FT_STREAM_SKIP( 4 ) ) /* mbz */
goto Exit;
offsets_internal[j] = rdata_pos + ( temp & 0xFFFFFFL );
(void)FT_STREAM_SKIP( 4 ); /* mbz */
ref[j].offset = temp & 0xFFFFFFL;
}
*offsets = offsets_internal;
ft_qsort( ref, *count, sizeof ( FT_RFork_Ref ),
( int(*)(const void*, const void*) )
ft_raccess_sort_ref_by_id );
return FT_Err_Ok;
if ( FT_NEW_ARRAY( offsets_internal, *count ) )
goto Exit;
/* XXX: duplicated reference ID,
* gap between reference IDs are acceptable?
* further investigation on Apple implementation is needed.
*/
for ( j = 0; j < *count; ++j )
offsets_internal[j] = rdata_pos + ref[j].offset;
*offsets = offsets_internal;
error = FT_Err_Ok;
Exit:
FT_FREE( ref );
return error;
}
}
@ -227,7 +256,7 @@
typedef FT_Error
(*raccess_guess_func)( FT_Library library,
FT_Stream stream,
char * base_file_name,
char *base_file_name,
char **result_file_name,
FT_Long *result_offset );
@ -235,56 +264,63 @@
static FT_Error
raccess_guess_apple_double( FT_Library library,
FT_Stream stream,
char * base_file_name,
char *base_file_name,
char **result_file_name,
FT_Long *result_offset );
static FT_Error
raccess_guess_apple_single( FT_Library library,
FT_Stream stream,
char * base_file_name,
char *base_file_name,
char **result_file_name,
FT_Long *result_offset );
static FT_Error
raccess_guess_darwin_ufs_export( FT_Library library,
FT_Stream stream,
char * base_file_name,
char *base_file_name,
char **result_file_name,
FT_Long *result_offset );
static FT_Error
raccess_guess_darwin_newvfs( FT_Library library,
FT_Stream stream,
char *base_file_name,
char **result_file_name,
FT_Long *result_offset );
static FT_Error
raccess_guess_darwin_hfsplus( FT_Library library,
FT_Stream stream,
char * base_file_name,
char *base_file_name,
char **result_file_name,
FT_Long *result_offset );
static FT_Error
raccess_guess_vfat( FT_Library library,
FT_Stream stream,
char * base_file_name,
char *base_file_name,
char **result_file_name,
FT_Long *result_offset );
static FT_Error
raccess_guess_linux_cap( FT_Library library,
FT_Stream stream,
char * base_file_name,
char *base_file_name,
char **result_file_name,
FT_Long *result_offset );
static FT_Error
raccess_guess_linux_double( FT_Library library,
FT_Stream stream,
char * base_file_name,
char *base_file_name,
char **result_file_name,
FT_Long *result_offset );
static FT_Error
raccess_guess_linux_netatalk( FT_Library library,
FT_Stream stream,
char * base_file_name,
char *base_file_name,
char **result_file_name,
FT_Long *result_offset );
@ -298,7 +334,7 @@
static FT_Error
raccess_guess_apple_generic( FT_Library library,
FT_Stream stream,
char * base_file_name,
char *base_file_name,
FT_Int32 magic,
FT_Long *result_offset );
@ -329,6 +365,7 @@
raccess_guess_apple_double,
raccess_guess_apple_single,
raccess_guess_darwin_ufs_export,
raccess_guess_darwin_newvfs,
raccess_guess_darwin_hfsplus,
raccess_guess_vfat,
raccess_guess_linux_cap,
@ -339,7 +376,11 @@
for ( i = 0; i < FT_RACCESS_N_RULES; i++ )
{
new_names[i] = NULL;
errors[i] = FT_Stream_Seek( stream, 0 );
if ( NULL != stream )
errors[i] = FT_Stream_Seek( stream, 0 );
else
errors[i] = FT_Err_Ok;
if ( errors[i] )
continue ;
@ -354,7 +395,7 @@
static FT_Error
raccess_guess_apple_double( FT_Library library,
FT_Stream stream,
char * base_file_name,
char *base_file_name,
char **result_file_name,
FT_Long *result_offset )
{
@ -362,6 +403,9 @@
*result_file_name = NULL;
if ( NULL == stream )
return FT_Err_Cannot_Open_Stream;
return raccess_guess_apple_generic( library, stream, base_file_name,
magic, result_offset );
}
@ -370,7 +414,7 @@
static FT_Error
raccess_guess_apple_single( FT_Library library,
FT_Stream stream,
char * base_file_name,
char *base_file_name,
char **result_file_name,
FT_Long *result_offset )
{
@ -378,6 +422,9 @@
*result_file_name = NULL;
if ( NULL == stream )
return FT_Err_Cannot_Open_Stream;
return raccess_guess_apple_generic( library, stream, base_file_name,
magic, result_offset );
}
@ -386,7 +433,7 @@
static FT_Error
raccess_guess_darwin_ufs_export( FT_Library library,
FT_Stream stream,
char * base_file_name,
char *base_file_name,
char **result_file_name,
FT_Long *result_offset )
{
@ -416,7 +463,7 @@
static FT_Error
raccess_guess_darwin_hfsplus( FT_Library library,
FT_Stream stream,
char * base_file_name,
char *base_file_name,
char **result_file_name,
FT_Long *result_offset )
{
@ -433,7 +480,7 @@
memory = library->memory;
if ( base_file_len > FT_INT_MAX )
if ( base_file_len + 6 > FT_INT_MAX )
return FT_Err_Array_Too_Large;
if ( FT_ALLOC( newpath, base_file_len + 6 ) )
@ -449,10 +496,46 @@
}
static FT_Error
raccess_guess_darwin_newvfs( FT_Library library,
FT_Stream stream,
char *base_file_name,
char **result_file_name,
FT_Long *result_offset )
{
/*
Only meaningful on systems with Mac OS X (> 10.1).
*/
FT_Error error;
char* newpath;
FT_Memory memory;
FT_Long base_file_len = ft_strlen( base_file_name );
FT_UNUSED( stream );
memory = library->memory;
if ( base_file_len + 18 > FT_INT_MAX )
return FT_Err_Array_Too_Large;
if ( FT_ALLOC( newpath, base_file_len + 18 ) )
return error;
FT_MEM_COPY( newpath, base_file_name, base_file_len );
FT_MEM_COPY( newpath + base_file_len, "/..namedfork/rsrc", 18 );
*result_file_name = newpath;
*result_offset = 0;
return FT_Err_Ok;
}
static FT_Error
raccess_guess_vfat( FT_Library library,
FT_Stream stream,
char * base_file_name,
char *base_file_name,
char **result_file_name,
FT_Long *result_offset )
{
@ -479,7 +562,7 @@
static FT_Error
raccess_guess_linux_cap( FT_Library library,
FT_Stream stream,
char * base_file_name,
char *base_file_name,
char **result_file_name,
FT_Long *result_offset )
{
@ -505,7 +588,7 @@
static FT_Error
raccess_guess_linux_double( FT_Library library,
FT_Stream stream,
char * base_file_name,
char *base_file_name,
char **result_file_name,
FT_Long *result_offset )
{
@ -536,7 +619,7 @@
static FT_Error
raccess_guess_linux_netatalk( FT_Library library,
FT_Stream stream,
char * base_file_name,
char *base_file_name,
char **result_file_name,
FT_Long *result_offset )
{
@ -568,7 +651,7 @@
static FT_Error
raccess_guess_apple_generic( FT_Library library,
FT_Stream stream,
char * base_file_name,
char *base_file_name,
FT_Int32 magic,
FT_Long *result_offset )
{
@ -629,7 +712,7 @@
static FT_Error
raccess_guess_linux_double_from_file_name( FT_Library library,
char * file_name,
char *file_name,
FT_Long *result_offset )
{
FT_Open_Args args2;
@ -701,7 +784,7 @@
FT_BASE_DEF( void )
FT_Raccess_Guess( FT_Library library,
FT_Stream stream,
char* base_name,
char *base_name,
char **new_names,
FT_Long *offsets,
FT_Error *errors )

View File

@ -4,7 +4,7 @@
/* */
/* I/O stream support (body). */
/* */
/* Copyright 2000-2001, 2002, 2004, 2005, 2006 by */
/* Copyright 2000-2001, 2002, 2004, 2005, 2006, 2008 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@ -89,6 +89,9 @@
FT_Stream_Skip( FT_Stream stream,
FT_Long distance )
{
if ( distance < 0 )
return FT_Err_Invalid_Stream_Operation;
return FT_Stream_Seek( stream, (FT_ULong)( stream->pos + distance ) );
}

View File

@ -4,7 +4,7 @@
/* */
/* FreeType path stroker (body). */
/* */
/* Copyright 2002, 2003, 2004, 2005, 2006 by */
/* Copyright 2002, 2003, 2004, 2005, 2006, 2008 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@ -230,7 +230,7 @@
/***************************************************************************/
/***************************************************************************/
typedef enum
typedef enum FT_StrokeTags_
{
FT_STROKE_TAG_ON = 1, /* on-curve point */
FT_STROKE_TAG_CUBIC = 2, /* cubic off-point */

View File

@ -181,7 +181,9 @@ THE SOFTWARE.
bdf_cmap_init,
bdf_cmap_done,
bdf_cmap_char_index,
bdf_cmap_char_next
bdf_cmap_char_next,
NULL, NULL, NULL, NULL, NULL
};

View File

@ -4,7 +4,7 @@
/* */
/* CFF character mapping table (cmap) support (body). */
/* */
/* Copyright 2002, 2003, 2004, 2005, 2006 by */
/* Copyright 2002, 2003, 2004, 2005, 2006, 2007 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@ -107,7 +107,9 @@
(FT_CMap_InitFunc) cff_cmap_encoding_init,
(FT_CMap_DoneFunc) cff_cmap_encoding_done,
(FT_CMap_CharIndexFunc)cff_cmap_encoding_char_index,
(FT_CMap_CharNextFunc) cff_cmap_encoding_char_next
(FT_CMap_CharNextFunc) cff_cmap_encoding_char_next,
NULL, NULL, NULL, NULL, NULL
};
@ -213,7 +215,9 @@
(FT_CMap_InitFunc) cff_cmap_unicode_init,
(FT_CMap_DoneFunc) cff_cmap_unicode_done,
(FT_CMap_CharIndexFunc)cff_cmap_unicode_char_index,
(FT_CMap_CharNextFunc) cff_cmap_unicode_char_next
(FT_CMap_CharNextFunc) cff_cmap_unicode_char_next,
NULL, NULL, NULL, NULL, NULL
};

View File

@ -22,8 +22,10 @@
#include FT_INTERNAL_STREAM_H
#include FT_INTERNAL_SFNT_H
#include FT_TRUETYPE_IDS_H
#include FT_SERVICE_CID_H
#include FT_SERVICE_POSTSCRIPT_CMAPS_H
#include FT_SERVICE_POSTSCRIPT_INFO_H
#include FT_SERVICE_POSTSCRIPT_NAME_H
#include FT_SERVICE_TT_CMAP_H
#include "cffdrivr.h"
@ -36,6 +38,7 @@
#include FT_SERVICE_XFREE86_NAME_H
#include FT_SERVICE_GLYPH_DICT_H
/*************************************************************************/
/* */
/* The macro FT_COMPONENT is used in trace mode. It is an implicit */
@ -151,7 +154,7 @@
FT_UInt glyph_index,
FT_Int32 load_flags )
{
FT_Error error;
FT_Error error;
CFF_GlyphSlot slot = (CFF_GlyphSlot)cffslot;
CFF_Size size = (CFF_Size)cffsize;
@ -163,10 +166,10 @@
if ( !size )
load_flags |= FT_LOAD_NO_SCALE | FT_LOAD_NO_HINTING;
/* reset the size object if necessary */
if ( load_flags & FT_LOAD_NO_SCALE )
size = NULL;
/* reset the size object if necessary */
if ( size )
{
/* these two objects must have the same parent */
@ -184,10 +187,10 @@
}
/*
* GLYPH DICT SERVICE
*
*/
/*
* GLYPH DICT SERVICE
*
*/
static FT_Error
cff_get_glyph_name( CFF_Face face,
@ -226,8 +229,8 @@
FT_FREE( gname );
error = CFF_Err_Ok;
Exit:
return error;
Exit:
return error;
}
@ -284,10 +287,10 @@
};
/*
* POSTSCRIPT INFO SERVICE
*
*/
/*
* POSTSCRIPT INFO SERVICE
*
*/
static FT_Int
cff_ps_has_glyph_names( FT_Face face )
@ -306,9 +309,10 @@
if ( cff && cff->font_info == NULL )
{
CFF_FontRecDict dict = &cff->top_font.font_dict;
PS_FontInfoRec *font_info;
FT_Memory memory = face->root.memory;
CFF_FontRecDict dict = &cff->top_font.font_dict;
PS_FontInfoRec *font_info;
FT_Memory memory = face->root.memory;
FT_Service_PsCMaps psnames = (FT_Service_PsCMaps)cff->psnames;
if ( FT_ALLOC( font_info, sizeof ( *font_info ) ) )
@ -316,19 +320,19 @@
font_info->version = cff_index_get_sid_string( &cff->string_index,
dict->version,
cff->psnames );
psnames );
font_info->notice = cff_index_get_sid_string( &cff->string_index,
dict->notice,
cff->psnames );
psnames );
font_info->full_name = cff_index_get_sid_string( &cff->string_index,
dict->full_name,
cff->psnames );
psnames );
font_info->family_name = cff_index_get_sid_string( &cff->string_index,
dict->family_name,
cff->psnames );
psnames );
font_info->weight = cff_index_get_sid_string( &cff->string_index,
dict->weight,
cff->psnames );
psnames );
font_info->italic_angle = dict->italic_angle;
font_info->is_fixed_pitch = dict->is_fixed_pitch;
font_info->underline_position = (FT_Short)dict->underline_position;
@ -352,6 +356,27 @@
};
/*
* POSTSCRIPT NAME SERVICE
*
*/
static const char*
cff_get_ps_name( CFF_Face face )
{
CFF_Font cff = (CFF_Font)face->extra.data;
return (const char*)cff->font_name;
}
static const FT_Service_PsFontNameRec cff_service_ps_name =
{
(FT_PsName_GetFunc)cff_get_ps_name
};
/*
* TT CMAP INFO
*
@ -397,6 +422,65 @@
};
/*
* CID INFO SERVICE
*
*/
static FT_Error
cff_get_ros( CFF_Face face,
const char* *registry,
const char* *ordering,
FT_Int *supplement )
{
FT_Error error = CFF_Err_Ok;
CFF_Font cff = (CFF_Font)face->extra.data;
if ( cff )
{
CFF_FontRecDict dict = &cff->top_font.font_dict;
FT_Service_PsCMaps psnames = (FT_Service_PsCMaps)cff->psnames;
if ( dict->cid_registry == 0xFFFFU )
{
error = CFF_Err_Invalid_Argument;
goto Fail;
}
if ( registry )
{
if ( cff->registry == NULL )
cff->registry = cff_index_get_sid_string( &cff->string_index,
dict->cid_registry,
psnames );
*registry = cff->registry;
}
if ( ordering )
{
if ( cff->ordering == NULL )
cff->ordering = cff_index_get_sid_string( &cff->string_index,
dict->cid_ordering,
psnames );
*ordering = cff->ordering;
}
if ( supplement )
*supplement = dict->cid_supplement;
}
Fail:
return error;
}
static const FT_Service_CIDRec cff_service_cid_info =
{
(FT_CID_GetRegistryOrderingSupplementFunc)cff_get_ros
};
/*************************************************************************/
/*************************************************************************/
/*************************************************************************/
@ -411,12 +495,14 @@
static const FT_ServiceDescRec cff_services[] =
{
{ FT_SERVICE_ID_XF86_NAME, FT_XF86_FORMAT_CFF },
{ FT_SERVICE_ID_POSTSCRIPT_INFO, &cff_service_ps_info },
{ FT_SERVICE_ID_XF86_NAME, FT_XF86_FORMAT_CFF },
{ FT_SERVICE_ID_POSTSCRIPT_INFO, &cff_service_ps_info },
{ FT_SERVICE_ID_POSTSCRIPT_FONT_NAME, &cff_service_ps_name },
#ifndef FT_CONFIG_OPTION_NO_GLYPH_NAMES
{ FT_SERVICE_ID_GLYPH_DICT, &cff_service_glyph_dict },
{ FT_SERVICE_ID_GLYPH_DICT, &cff_service_glyph_dict },
#endif
{ FT_SERVICE_ID_TT_CMAP, &cff_service_get_cmap_info },
{ FT_SERVICE_ID_TT_CMAP, &cff_service_get_cmap_info },
{ FT_SERVICE_ID_CID, &cff_service_cid_info },
{ NULL, NULL }
};

View File

@ -4,7 +4,7 @@
/* */
/* OpenType Glyph Loader (body). */
/* */
/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006, 2007 by */
/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@ -110,6 +110,9 @@
cff_op_callgsubr,
cff_op_return,
cff_op_hsbw, /* Type 1 opcode: invalid but seen in real life */
cff_op_closepath, /* ditto */
/* do not remove */
cff_op_max
@ -187,6 +190,9 @@
1, /* callsubr */
1,
0,
2, /* hsbw */
0
};
@ -222,6 +228,8 @@
/* */
/* glyph :: The current glyph object. */
/* */
/* hinting :: Whether hinting is active. */
/* */
static void
cff_builder_init( CFF_Builder* builder,
TT_Face face,
@ -251,17 +259,14 @@
if ( hinting && size )
{
builder->hints_globals = size->root.internal;
CFF_Internal internal = (CFF_Internal)size->root.internal;
builder->hints_globals = (void *)internal->topfont;
builder->hints_funcs = glyph->root.internal->glyph_hints;
}
}
if ( size )
{
builder->scale_x = size->root.metrics.x_scale;
builder->scale_y = size->root.metrics.y_scale;
}
builder->pos_x = 0;
builder->pos_y = 0;
@ -339,11 +344,15 @@
/* decoder :: A pointer to the glyph builder to initialize. */
/* */
/* <Input> */
/* face :: The current face object. */
/* face :: The current face object. */
/* */
/* size :: The current size object. */
/* size :: The current size object. */
/* */
/* slot :: The current glyph object. */
/* slot :: The current glyph object. */
/* */
/* hinting :: Whether hinting is active. */
/* */
/* hint_mode :: The hinting mode. */
/* */
FT_LOCAL_DEF( void )
cff_decoder_init( CFF_Decoder* decoder,
@ -371,18 +380,21 @@
}
/* this function is used to select the locals subrs array */
/* this function is used to select the subfont */
/* and the locals subrs array */
FT_LOCAL_DEF( FT_Error )
cff_decoder_prepare( CFF_Decoder* decoder,
CFF_Size size,
FT_UInt glyph_index )
{
CFF_Font cff = (CFF_Font)decoder->builder.face->extra.data;
CFF_SubFont sub = &cff->top_font;
FT_Error error = CFF_Err_Ok;
CFF_Builder *builder = &decoder->builder;
CFF_Font cff = (CFF_Font)builder->face->extra.data;
CFF_SubFont sub = &cff->top_font;
FT_Error error = CFF_Err_Ok;
/* manage CID fonts */
if ( cff->num_subfonts >= 1 )
if ( cff->num_subfonts )
{
FT_Byte fd_index = cff_fd_select_get( &cff->fd_select, glyph_index );
@ -393,8 +405,17 @@
error = CFF_Err_Invalid_File_Format;
goto Exit;
}
sub = cff->subfonts[fd_index];
if ( builder->hints_funcs )
{
CFF_Internal internal = (CFF_Internal)size->root.internal;
/* for CFFs without subfonts, this value has already been set */
builder->hints_globals = (void *)internal->subfonts[fd_index];
}
}
decoder->num_locals = sub->num_local_subrs;
@ -954,6 +975,9 @@
case 8:
op = cff_op_rrcurveto;
break;
case 9:
op = cff_op_closepath;
break;
case 10:
op = cff_op_callsubr;
break;
@ -1055,6 +1079,9 @@
}
}
break;
case 13:
op = cff_op_hsbw;
break;
case 14:
op = cff_op_endchar;
break;
@ -1168,7 +1195,7 @@
req_args = 0;
}
req_args &= 15;
req_args &= 0x000F;
if ( num_args < req_args )
goto Stack_Underflow;
args -= req_args;
@ -2022,6 +2049,30 @@
FT_TRACE4(( " dotsection" ));
break;
case cff_op_closepath:
/* this is an invalid Type 2 operator; however, there */
/* exist fonts which are incorrectly converted from probably */
/* Type 1 to CFF, and some parsers seem to accept it */
FT_TRACE4(( " closepath (invalid op)" ));
args = stack;
break;
case cff_op_hsbw:
/* this is an invalid Type 2 operator; however, there */
/* exist fonts which are incorrectly converted from probably */
/* Type 1 to CFF, and some parsers seem to accept it */
FT_TRACE4(( " hsbw (invalid op)" ));
decoder->glyph_width = decoder->nominal_width +
(args[1] >> 16);
x = args[0];
y = 0;
args = stack;
break;
case cff_op_and:
{
FT_Fixed cond = args[0] && args[1];
@ -2260,7 +2311,7 @@
&charstring, &charstring_len );
if ( !error )
{
error = cff_decoder_prepare( &decoder, glyph_index );
error = cff_decoder_prepare( &decoder, size, glyph_index );
if ( !error )
error = cff_decoder_parse_charstrings( &decoder,
charstring,
@ -2291,18 +2342,20 @@
FT_Error error;
CFF_Decoder decoder;
TT_Face face = (TT_Face)glyph->root.face;
FT_Bool hinting;
FT_Bool hinting, force_scaling;
CFF_Font cff = (CFF_Font)face->extra.data;
FT_Matrix font_matrix;
FT_Vector font_offset;
force_scaling = FALSE;
/* in a CID-keyed font, consider `glyph_index' as a CID and map */
/* it immediately to the real glyph_index -- if it isn't a */
/* subsetted font, glyph_indices and CIDs are identical, though */
if ( cff->top_font.font_dict.cid_registry != 0xFFFFU &&
cff->charset.cids )
cff->charset.cids )
{
glyph_index = cff_charset_cid_to_gindex( &cff->charset, glyph_index );
if ( glyph_index == 0 )
@ -2389,6 +2442,36 @@
if ( load_flags & FT_LOAD_SBITS_ONLY )
return CFF_Err_Invalid_Argument;
/* if we have a CID subfont, use its matrix (which has already */
/* been multiplied with the root matrix) */
/* this scaling is only relevant if the PS hinter isn't active */
if ( cff->num_subfonts )
{
FT_Byte fd_index = cff_fd_select_get( &cff->fd_select,
glyph_index );
FT_Int top_upm = cff->top_font.font_dict.units_per_em;
FT_Int sub_upm = cff->subfonts[fd_index]->font_dict.units_per_em;
font_matrix = cff->subfonts[fd_index]->font_dict.font_matrix;
font_offset = cff->subfonts[fd_index]->font_dict.font_offset;
if ( top_upm != sub_upm )
{
glyph->x_scale = FT_MulDiv( glyph->x_scale, top_upm, sub_upm );
glyph->y_scale = FT_MulDiv( glyph->y_scale, top_upm, sub_upm );
force_scaling = TRUE;
}
}
else
{
font_matrix = cff->top_font.font_dict.font_matrix;
font_offset = cff->top_font.font_dict.font_offset;
}
glyph->root.outline.n_points = 0;
glyph->root.outline.n_contours = 0;
@ -2413,7 +2496,7 @@
&charstring, &charstring_len );
if ( !error )
{
error = cff_decoder_prepare( &decoder, glyph_index );
error = cff_decoder_prepare( &decoder, size, glyph_index );
if ( !error )
{
error = cff_decoder_parse_charstrings( &decoder,
@ -2481,21 +2564,6 @@
if ( !error )
{
if ( cff->num_subfonts >= 1 )
{
FT_Byte fd_index = cff_fd_select_get( &cff->fd_select,
glyph_index );
font_matrix = cff->subfonts[fd_index]->font_dict.font_matrix;
font_offset = cff->subfonts[fd_index]->font_dict.font_offset;
}
else
{
font_matrix = cff->top_font.font_dict.font_matrix;
font_offset = cff->top_font.font_dict.font_offset;
}
/* Now, set the metrics -- this is rather simple, as */
/* the left side bearing is the xMin, and the top side */
/* bearing the yMax. */
@ -2565,9 +2633,8 @@
glyph->root.outline.flags |= FT_OUTLINE_REVERSE_FILL;
/* apply the font matrix */
if ( !( font_matrix.xx == 0x10000L &&
font_matrix.yy == 0x10000L &&
/* apply the font matrix -- `xx' has already been normalized */
if ( !( font_matrix.yy == 0x10000L &&
font_matrix.xy == 0 &&
font_matrix.yx == 0 ) )
FT_Outline_Transform( &glyph->root.outline, &font_matrix );
@ -2587,7 +2654,7 @@
FT_Vector_Transform( &advance, &font_matrix );
metrics->vertAdvance = advance.y + font_offset.y;
if ( ( load_flags & FT_LOAD_NO_SCALE ) == 0 )
if ( ( load_flags & FT_LOAD_NO_SCALE ) == 0 || force_scaling )
{
/* scale the outline and the metrics */
FT_Int n;

View File

@ -4,7 +4,7 @@
/* */
/* OpenType Glyph Loader (specification). */
/* */
/* Copyright 1996-2001, 2002, 2003, 2004, 2006, 2007 by */
/* Copyright 1996-2001, 2002, 2003, 2004, 2006, 2007, 2008 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@ -55,10 +55,6 @@ FT_BEGIN_HEADER
/* */
/* last :: The last point position. */
/* */
/* scale_x :: The horizontal scale (FUnits to sub-pixels). */
/* */
/* scale_y :: The vertical scale (FUnits to sub-pixels). */
/* */
/* pos_x :: The horizontal translation (if composite glyph). */
/* */
/* pos_y :: The vertical translation (if composite glyph). */
@ -94,9 +90,6 @@ FT_BEGIN_HEADER
FT_Vector last;
FT_Fixed scale_x;
FT_Fixed scale_y;
FT_Pos pos_x;
FT_Pos pos_y;
@ -177,6 +170,7 @@ FT_BEGIN_HEADER
FT_LOCAL( FT_Error )
cff_decoder_prepare( CFF_Decoder* decoder,
CFF_Size size,
FT_UInt glyph_index );
#if 0 /* unused until we support pure CFF fonts */

View File

@ -31,6 +31,7 @@
#if 1
static const FT_UShort cff_isoadobe_charset[229] =
{
0, 1, 2, 3, 4, 5, 6, 7,
@ -175,13 +176,15 @@
363, 364, 365, 366, 367, 368, 369, 370,
371, 372, 373, 374, 375, 376, 377, 378
};
#endif
#endif /* 1 */
FT_LOCAL_DEF( FT_UShort )
cff_get_standard_encoding( FT_UInt charcode )
{
return (FT_UShort)(charcode < 256 ? cff_standard_encoding[charcode] : 0);
return (FT_UShort)( charcode < 256 ? cff_standard_encoding[charcode]
: 0 );
}
@ -1272,8 +1275,9 @@
top->cid_ordering = 0xFFFFU;
top->cid_font_name = 0xFFFFU;
error = cff_index_access_element( idx, font_index, &dict, &dict_len ) ||
cff_parser_run( &parser, dict, dict + dict_len );
error = cff_index_access_element( idx, font_index, &dict, &dict_len );
if ( !error )
error = cff_parser_run( &parser, dict, dict + dict_len );
cff_index_forget_element( idx, &dict );
@ -1590,6 +1594,9 @@
FT_FREE( font->font_info );
}
FT_FREE( font->registry );
FT_FREE( font->ordering );
FT_FREE( font->global_subrs );
FT_FREE( font->font_name );
}

View File

@ -4,7 +4,7 @@
/* */
/* OpenType objects manager (body). */
/* */
/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006, 2007 by */
/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@ -56,7 +56,7 @@
cff_size_get_globals_funcs( CFF_Size size )
{
CFF_Face face = (CFF_Face)size->root.face;
CFF_Font font = (CFF_FontRec *)face->extra.data;
CFF_Font font = (CFF_Font)face->extra.data;
PSHinter_Service pshinter = (PSHinter_Service)font->pshinter;
FT_Module module;
@ -72,23 +72,84 @@
FT_LOCAL_DEF( void )
cff_size_done( FT_Size cffsize ) /* CFF_Size */
{
CFF_Size size = (CFF_Size)cffsize;
CFF_Size size = (CFF_Size)cffsize;
CFF_Face face = (CFF_Face)size->root.face;
CFF_Font font = (CFF_Font)face->extra.data;
CFF_Internal internal = (CFF_Internal)cffsize->internal;
if ( cffsize->internal )
if ( internal )
{
PSH_Globals_Funcs funcs;
funcs = cff_size_get_globals_funcs( size );
if ( funcs )
funcs->destroy( (PSH_Globals)cffsize->internal );
{
FT_UInt i;
cffsize->internal = 0;
funcs->destroy( internal->topfont );
for ( i = font->num_subfonts; i > 0; i-- )
funcs->destroy( internal->subfonts[i - 1] );
}
/* `internal' is freed by destroy_size (in ftobjs.c) */
}
}
/* CFF and Type 1 private dictionaries have slightly different */
/* structures; we need to synthetize a Type 1 dictionary on the fly */
static void
cff_make_private_dict( CFF_SubFont subfont,
PS_Private priv )
{
CFF_Private cpriv = &subfont->private_dict;
FT_UInt n, count;
FT_MEM_ZERO( priv, sizeof ( *priv ) );
count = priv->num_blue_values = cpriv->num_blue_values;
for ( n = 0; n < count; n++ )
priv->blue_values[n] = (FT_Short)cpriv->blue_values[n];
count = priv->num_other_blues = cpriv->num_other_blues;
for ( n = 0; n < count; n++ )
priv->other_blues[n] = (FT_Short)cpriv->other_blues[n];
count = priv->num_family_blues = cpriv->num_family_blues;
for ( n = 0; n < count; n++ )
priv->family_blues[n] = (FT_Short)cpriv->family_blues[n];
count = priv->num_family_other_blues = cpriv->num_family_other_blues;
for ( n = 0; n < count; n++ )
priv->family_other_blues[n] = (FT_Short)cpriv->family_other_blues[n];
priv->blue_scale = cpriv->blue_scale;
priv->blue_shift = (FT_Int)cpriv->blue_shift;
priv->blue_fuzz = (FT_Int)cpriv->blue_fuzz;
priv->standard_width[0] = (FT_UShort)cpriv->standard_width;
priv->standard_height[0] = (FT_UShort)cpriv->standard_height;
count = priv->num_snap_widths = cpriv->num_snap_widths;
for ( n = 0; n < count; n++ )
priv->snap_widths[n] = (FT_Short)cpriv->snap_widths[n];
count = priv->num_snap_heights = cpriv->num_snap_heights;
for ( n = 0; n < count; n++ )
priv->snap_heights[n] = (FT_Short)cpriv->snap_heights[n];
priv->force_bold = cpriv->force_bold;
priv->language_group = cpriv->language_group;
priv->lenIV = cpriv->lenIV;
}
FT_LOCAL_DEF( FT_Error )
cff_size_init( FT_Size cffsize ) /* CFF_Size */
{
@ -99,68 +160,43 @@
if ( funcs )
{
PSH_Globals globals;
CFF_Face face = (CFF_Face)cffsize->face;
CFF_Font font = (CFF_FontRec *)face->extra.data;
CFF_SubFont subfont = &font->top_font;
CFF_Face face = (CFF_Face)cffsize->face;
CFF_Font font = (CFF_Font)face->extra.data;
CFF_Internal internal;
CFF_Private cpriv = &subfont->private_dict;
PS_PrivateRec priv;
FT_Memory memory = cffsize->face->memory;
FT_UInt i;
/* IMPORTANT: The CFF and Type1 private dictionaries have */
/* slightly different structures; we need to */
/* synthetize a type1 dictionary on the fly here. */
if ( FT_NEW( internal ) )
goto Exit;
cff_make_private_dict( &font->top_font, &priv );
error = funcs->create( cffsize->face->memory, &priv,
&internal->topfont );
if ( error )
goto Exit;
for ( i = font->num_subfonts; i > 0; i-- )
{
FT_UInt n, count;
CFF_SubFont sub = font->subfonts[i - 1];
FT_MEM_ZERO( &priv, sizeof ( priv ) );
count = priv.num_blue_values = cpriv->num_blue_values;
for ( n = 0; n < count; n++ )
priv.blue_values[n] = (FT_Short)cpriv->blue_values[n];
count = priv.num_other_blues = cpriv->num_other_blues;
for ( n = 0; n < count; n++ )
priv.other_blues[n] = (FT_Short)cpriv->other_blues[n];
count = priv.num_family_blues = cpriv->num_family_blues;
for ( n = 0; n < count; n++ )
priv.family_blues[n] = (FT_Short)cpriv->family_blues[n];
count = priv.num_family_other_blues = cpriv->num_family_other_blues;
for ( n = 0; n < count; n++ )
priv.family_other_blues[n] = (FT_Short)cpriv->family_other_blues[n];
priv.blue_scale = cpriv->blue_scale;
priv.blue_shift = (FT_Int)cpriv->blue_shift;
priv.blue_fuzz = (FT_Int)cpriv->blue_fuzz;
priv.standard_width[0] = (FT_UShort)cpriv->standard_width;
priv.standard_height[0] = (FT_UShort)cpriv->standard_height;
count = priv.num_snap_widths = cpriv->num_snap_widths;
for ( n = 0; n < count; n++ )
priv.snap_widths[n] = (FT_Short)cpriv->snap_widths[n];
count = priv.num_snap_heights = cpriv->num_snap_heights;
for ( n = 0; n < count; n++ )
priv.snap_heights[n] = (FT_Short)cpriv->snap_heights[n];
priv.force_bold = cpriv->force_bold;
priv.language_group = cpriv->language_group;
priv.lenIV = cpriv->lenIV;
cff_make_private_dict( sub, &priv );
error = funcs->create( cffsize->face->memory, &priv,
&internal->subfonts[i - 1] );
if ( error )
goto Exit;
}
error = funcs->create( cffsize->face->memory, &priv, &globals );
if ( !error )
cffsize->internal = (FT_Size_Internal)(void*)globals;
cffsize->internal = (FT_Size_Internal)(void*)internal;
}
size->strike_index = 0xFFFFFFFFUL;
Exit:
return error;
}
@ -182,11 +218,42 @@
funcs = cff_size_get_globals_funcs( cffsize );
if ( funcs )
funcs->set_scale( (PSH_Globals)size->internal,
size->metrics.x_scale,
size->metrics.y_scale,
{
CFF_Face face = (CFF_Face)size->face;
CFF_Font font = (CFF_Font)face->extra.data;
CFF_Internal internal = (CFF_Internal)size->internal;
FT_Int top_upm = font->top_font.font_dict.units_per_em;
FT_UInt i;
funcs->set_scale( internal->topfont,
size->metrics.x_scale, size->metrics.y_scale,
0, 0 );
for ( i = font->num_subfonts; i > 0; i-- )
{
CFF_SubFont sub = font->subfonts[i - 1];
FT_Int sub_upm = sub->font_dict.units_per_em;
FT_Pos x_scale, y_scale;
if ( top_upm != sub_upm )
{
x_scale = FT_MulDiv( size->metrics.x_scale, top_upm, sub_upm );
y_scale = FT_MulDiv( size->metrics.y_scale, top_upm, sub_upm );
}
else
{
x_scale = size->metrics.x_scale;
y_scale = size->metrics.y_scale;
}
funcs->set_scale( internal->subfonts[i - 1],
x_scale, y_scale, 0, 0 );
}
}
return CFF_Err_Ok;
}
@ -223,11 +290,42 @@
funcs = cff_size_get_globals_funcs( cffsize );
if ( funcs )
funcs->set_scale( (PSH_Globals)size->internal,
size->metrics.x_scale,
size->metrics.y_scale,
{
CFF_Face cffface = (CFF_Face)size->face;
CFF_Font font = (CFF_Font)cffface->extra.data;
CFF_Internal internal = (CFF_Internal)size->internal;
FT_Int top_upm = font->top_font.font_dict.units_per_em;
FT_UInt i;
funcs->set_scale( internal->topfont,
size->metrics.x_scale, size->metrics.y_scale,
0, 0 );
for ( i = font->num_subfonts; i > 0; i-- )
{
CFF_SubFont sub = font->subfonts[i - 1];
FT_Int sub_upm = sub->font_dict.units_per_em;
FT_Pos x_scale, y_scale;
if ( top_upm != sub_upm )
{
x_scale = FT_MulDiv( size->metrics.x_scale, top_upm, sub_upm );
y_scale = FT_MulDiv( size->metrics.y_scale, top_upm, sub_upm );
}
else
{
x_scale = size->metrics.x_scale;
y_scale = size->metrics.y_scale;
}
funcs->set_scale( internal->subfonts[i - 1],
x_scale, y_scale, 0, 0 );
}
}
return CFF_Err_Ok;
}
@ -249,7 +347,7 @@
cff_slot_init( FT_GlyphSlot slot )
{
CFF_Face face = (CFF_Face)slot->face;
CFF_Font font = (CFF_FontRec *)face->extra.data;
CFF_Font font = (CFF_Font)face->extra.data;
PSHinter_Service pshinter = (PSHinter_Service)font->pshinter;
@ -270,7 +368,7 @@
}
}
return 0;
return CFF_Err_Ok;
}
@ -288,7 +386,9 @@
FT_String* result;
result = ft_mem_strdup( memory, source, &error );
(void)FT_STRDUP( result, source );
FT_UNUSED( error );
return result;
}
@ -444,7 +544,7 @@
/* compute number of glyphs */
if ( dict->cid_registry != 0xFFFFU )
cffface->num_glyphs = dict->cid_count;
cffface->num_glyphs = cff->charset.max_cid;
else
cffface->num_glyphs = cff->charstrings_index.count;
@ -617,39 +717,119 @@
dict->units_per_em = face->root.units_per_EM;
}
/* handle font matrix settings in subfonts (if any) */
/* Normalize the font matrix so that `matrix->xx' is 1; the */
/* scaling is done with `units_per_em' then (at this point, */
/* it already contains the scaling factor, but without */
/* normalization of the matrix). */
/* */
/* Note that the offsets must be expressed in integer font */
/* units. */
{
FT_Matrix* matrix = &dict->font_matrix;
FT_Vector* offset = &dict->font_offset;
FT_ULong* upm = &dict->units_per_em;
FT_Fixed temp = FT_ABS( matrix->yy );
if ( temp != 0x10000L )
{
*upm = FT_DivFix( *upm, temp );
matrix->xx = FT_DivFix( matrix->xx, temp );
matrix->yx = FT_DivFix( matrix->yx, temp );
matrix->xy = FT_DivFix( matrix->xy, temp );
matrix->yy = FT_DivFix( matrix->yy, temp );
offset->x = FT_DivFix( offset->x, temp );
offset->y = FT_DivFix( offset->y, temp );
}
offset->x >>= 16;
offset->y >>= 16;
}
for ( i = cff->num_subfonts; i > 0; i-- )
{
CFF_FontRecDict sub = &cff->subfonts[i - 1]->font_dict;
CFF_FontRecDict top = &cff->top_font.font_dict;
FT_Matrix* matrix;
FT_Vector* offset;
FT_ULong* upm;
FT_Fixed temp;
if ( sub->units_per_em )
{
FT_Matrix scale;
FT_Int scaling;
scale.xx = scale.yy = (FT_Fixed)FT_DivFix( top->units_per_em,
sub->units_per_em );
scale.xy = scale.yx = 0;
if ( top->units_per_em > 1 && sub->units_per_em > 1 )
scaling = FT_MIN( top->units_per_em, sub->units_per_em );
else
scaling = 1;
FT_Matrix_Multiply( &scale, &sub->font_matrix );
FT_Vector_Transform( &sub->font_offset, &scale );
FT_Matrix_Multiply_Scaled( &top->font_matrix,
&sub->font_matrix,
scaling );
FT_Vector_Transform_Scaled( &sub->font_offset,
&top->font_matrix,
scaling );
sub->units_per_em = FT_MulDiv( sub->units_per_em,
top->units_per_em,
scaling );
}
else
{
sub->font_matrix = top->font_matrix;
sub->font_offset = top->font_offset;
sub->units_per_em = top->units_per_em;
}
matrix = &sub->font_matrix;
offset = &sub->font_offset;
upm = &sub->units_per_em;
temp = FT_ABS( matrix->yy );
if ( temp != 0x10000L )
{
*upm = FT_DivFix( *upm, temp );
/* if *upm is larger than 100*1000 we divide by 1000 -- */
/* this can happen if e.g. there is no top-font FontMatrix */
/* and the subfont FontMatrix already contains the complete */
/* scaling for the subfont (see section 5.11 of the PLRM) */
/* 100 is a heuristic value */
if ( *upm > 100L * 1000L )
*upm = ( *upm + 500 ) / 1000;
matrix->xx = FT_DivFix( matrix->xx, temp );
matrix->yx = FT_DivFix( matrix->yx, temp );
matrix->xy = FT_DivFix( matrix->xy, temp );
matrix->yy = FT_DivFix( matrix->yy, temp );
offset->x = FT_DivFix( offset->x, temp );
offset->y = FT_DivFix( offset->y, temp );
}
offset->x >>= 16;
offset->y >>= 16;
}
#ifndef FT_CONFIG_OPTION_NO_GLYPH_NAMES
/* CID-keyed CFF fonts don't have glyph names -- the SFNT loader */
/* has unset this flag because of the 3.0 `post' table */
/* has unset this flag because of the 3.0 `post' table. */
if ( dict->cid_registry == 0xFFFFU )
cffface->face_flags |= FT_FACE_FLAG_GLYPH_NAMES;
#endif
if ( dict->cid_registry != 0xFFFFU )
cffface->face_flags |= FT_FACE_FLAG_CID_KEYED;
/*******************************************************************/
/* */
/* Compute char maps. */
@ -683,7 +863,7 @@
if ( pure_cff && cff->top_font.font_dict.cid_registry != 0xFFFFU )
goto Exit;
/* we didn't find a Unicode charmap -- synthetize one */
/* we didn't find a Unicode charmap -- synthesize one */
cmaprec.face = cffface;
cmaprec.platform_id = 3;
cmaprec.encoding_id = 1;

View File

@ -4,7 +4,7 @@
/* */
/* OpenType objects manager (specification). */
/* */
/* Copyright 1996-2001, 2002, 2003, 2004, 2006, 2007 by */
/* Copyright 1996-2001, 2002, 2003, 2004, 2006, 2007, 2008 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@ -25,6 +25,7 @@
#include "cfftypes.h"
#include FT_INTERNAL_TRUETYPE_TYPES_H
#include FT_SERVICE_POSTSCRIPT_CMAPS_H
#include FT_INTERNAL_POSTSCRIPT_HINTS_H
FT_BEGIN_HEADER
@ -53,8 +54,8 @@ FT_BEGIN_HEADER
/* */
typedef struct CFF_SizeRec_
{
FT_SizeRec root;
FT_ULong strike_index; /* 0xFFFFFFFF to indicate invalid */
FT_SizeRec root;
FT_ULong strike_index; /* 0xFFFFFFFF to indicate invalid */
} CFF_SizeRec, *CFF_Size;
@ -80,6 +81,21 @@ FT_BEGIN_HEADER
} CFF_GlyphSlotRec, *CFF_GlyphSlot;
/*************************************************************************/
/* */
/* <Type> */
/* CFF_Internal */
/* */
/* <Description> */
/* The interface to the `internal' field of `FT_Size'. */
/* */
typedef struct CFF_InternalRec_
{
PSH_Globals topfont;
PSH_Globals subfonts[CFF_MAX_CID_FONTS];
} CFF_InternalRec, *CFF_Internal;
/*************************************************************************/
/* */

View File

@ -4,7 +4,7 @@
/* */
/* CFF token stream parser (body) */
/* */
/* Copyright 1996-2001, 2002, 2003, 2004, 2007 by */
/* Copyright 1996-2001, 2002, 2003, 2004, 2007, 2008 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@ -19,6 +19,7 @@
#include <ft2build.h>
#include "cffparse.h"
#include FT_INTERNAL_STREAM_H
#include FT_INTERNAL_DEBUG_H
#include "cfferrs.h"
@ -136,24 +137,51 @@
}
static const FT_Long power_tens[] =
{
1L,
10L,
100L,
1000L,
10000L,
100000L,
1000000L,
10000000L,
100000000L,
1000000000L
};
/* read a real */
static FT_Fixed
cff_parse_real( FT_Byte* start,
FT_Byte* limit,
FT_Int power_ten )
FT_Int power_ten,
FT_Int* scaling )
{
FT_Byte* p = start;
FT_Long num, divider, result, exponent;
FT_Int sign = 0, exponent_sign = 0;
FT_Byte* p = start;
FT_UInt nib;
FT_UInt phase;
FT_Long result, number, rest, exponent;
FT_Int sign = 0, exponent_sign = 0;
FT_Int exponent_add, integer_length, fraction_length;
result = 0;
num = 0;
divider = 1;
/* first of all, read the integer part */
if ( scaling )
*scaling = 0;
result = 0;
number = 0;
rest = 0;
exponent = 0;
exponent_add = 0;
integer_length = 0;
fraction_length = 0;
/* First of all, read the integer part. */
phase = 4;
for (;;)
@ -166,7 +194,7 @@
/* Make sure we don't read past the end. */
if ( p >= limit )
goto Bad;
goto Exit;
}
/* Get the nibble. */
@ -178,10 +206,20 @@
else if ( nib > 9 )
break;
else
result = result * 10 + nib;
{
/* Increase exponent if we can't add the digit. */
if ( number >= 0xCCCCCCCL )
exponent_add++;
/* Skip leading zeros. */
else if ( nib || number )
{
integer_length++;
number = number * 10 + nib;
}
}
}
/* read decimal part, if any */
/* Read fraction part, if any. */
if ( nib == 0xa )
for (;;)
{
@ -193,7 +231,7 @@
/* Make sure we don't read past the end. */
if ( p >= limit )
goto Bad;
goto Exit;
}
/* Get the nibble. */
@ -202,14 +240,18 @@
if ( nib >= 10 )
break;
if ( divider < 10000000L )
/* Skip leading zeros if possible. */
if ( !nib && !number )
exponent_add--;
/* Only add digit if we don't overflow. */
else if ( number < 0xCCCCCCCL )
{
num = num * 10 + nib;
divider *= 10;
fraction_length++;
number = number * 10 + nib;
}
}
/* read exponent, if any */
/* Read exponent, if any. */
if ( nib == 12 )
{
exponent_sign = 1;
@ -218,19 +260,17 @@
if ( nib == 11 )
{
exponent = 0;
for (;;)
{
/* If we entered this iteration with phase == 4, we need */
/* to read a new byte. */
/* If we entered this iteration with phase == 4, */
/* we need to read a new byte. */
if ( phase )
{
p++;
/* Make sure we don't read past the end. */
if ( p >= limit )
goto Bad;
goto Exit;
}
/* Get the nibble. */
@ -240,47 +280,105 @@
break;
exponent = exponent * 10 + nib;
/* Arbitrarily limit exponent. */
if ( exponent > 1000 )
goto Exit;
}
if ( exponent_sign )
exponent = -exponent;
power_ten += (FT_Int)exponent;
}
/* raise to power of ten if needed */
while ( power_ten > 0 )
/* We don't check `power_ten' and `exponent_add'. */
exponent += power_ten + exponent_add;
if ( scaling )
{
result = result * 10;
num = num * 10;
/* Only use `fraction_length'. */
fraction_length += integer_length;
exponent += integer_length;
power_ten--;
if ( fraction_length <= 5 )
{
if ( number > 0x7FFFL )
{
result = FT_DivFix( number, 10 );
*scaling = exponent - fraction_length + 1;
}
else
{
if ( exponent > 0 )
{
FT_Int new_fraction_length, shift;
/* Make `scaling' as small as possible. */
new_fraction_length = FT_MIN( exponent, 5 );
exponent -= new_fraction_length;
shift = new_fraction_length - fraction_length;
number *= power_tens[shift];
if ( number > 0x7FFFL )
{
number /= 10;
exponent += 1;
}
}
else
exponent -= fraction_length;
result = number << 16;
*scaling = exponent;
}
}
else
{
if ( ( number / power_tens[fraction_length - 5] ) > 0x7FFFL )
{
result = FT_DivFix( number, power_tens[fraction_length - 4] );
*scaling = exponent - 4;
}
else
{
result = FT_DivFix( number, power_tens[fraction_length - 5] );
*scaling = exponent - 5;
}
}
}
while ( power_ten < 0 )
else
{
result = result / 10;
divider = divider * 10;
integer_length += exponent;
fraction_length -= exponent;
power_ten++;
/* Check for overflow and underflow. */
if ( FT_ABS( integer_length ) > 5 )
goto Exit;
/* Convert into 16.16 format. */
if ( fraction_length > 0 )
{
if ( ( number / power_tens[fraction_length] ) > 0x7FFFL )
goto Exit;
result = FT_DivFix( number, power_tens[fraction_length] );
}
else
{
number *= power_tens[-fraction_length];
if ( number > 0x7FFFL )
goto Exit;
result = number << 16;
}
}
/* Move the integer part into the high 16 bits. */
result <<= 16;
/* Place the decimal part into the low 16 bits. */
if ( num )
result |= FT_DivFix( num, divider );
if ( sign )
result = -result;
Exit:
return result;
Bad:
result = 0;
goto Exit;
}
@ -288,8 +386,8 @@
static FT_Long
cff_parse_num( FT_Byte** d )
{
return ( **d == 30 ? ( cff_parse_real ( d[0], d[1], 0 ) >> 16 )
: cff_parse_integer( d[0], d[1] ) );
return **d == 30 ? ( cff_parse_real( d[0], d[1], 0, NULL ) >> 16 )
: cff_parse_integer( d[0], d[1] );
}
@ -297,64 +395,121 @@
static FT_Fixed
cff_parse_fixed( FT_Byte** d )
{
return ( **d == 30 ? cff_parse_real ( d[0], d[1], 0 )
: cff_parse_integer( d[0], d[1] ) << 16 );
return **d == 30 ? cff_parse_real( d[0], d[1], 0, NULL )
: cff_parse_integer( d[0], d[1] ) << 16;
}
/* read a floating point number, either integer or real, */
/* but return 1000 times the number read in. */
/* but return `10^scaling' times the number read in */
static FT_Fixed
cff_parse_fixed_thousand( FT_Byte** d )
cff_parse_fixed_scaled( FT_Byte** d,
FT_Int scaling )
{
return **d ==
30 ? cff_parse_real ( d[0], d[1], 3 )
: (FT_Fixed)FT_MulFix( cff_parse_integer( d[0], d[1] ) << 16, 1000 );
30 ? cff_parse_real( d[0], d[1], scaling, NULL )
: (FT_Fixed)FT_MulFix( cff_parse_integer( d[0], d[1] ) << 16,
power_tens[scaling] );
}
/* read a floating point number, either integer or real, */
/* and return it as precise as possible -- `scaling' returns */
/* the scaling factor (as a power of 10) */
static FT_Fixed
cff_parse_fixed_dynamic( FT_Byte** d,
FT_Int* scaling )
{
FT_ASSERT( scaling );
if ( **d == 30 )
return cff_parse_real( d[0], d[1], 0, scaling );
else
{
FT_Long number;
FT_Int integer_length;
number = cff_parse_integer( d[0], d[1] );
if ( number > 0x7FFFL )
{
for ( integer_length = 5; integer_length < 10; integer_length++ )
if ( number < power_tens[integer_length] )
break;
if ( ( number / power_tens[integer_length - 5] ) > 0x7FFFL )
{
*scaling = integer_length - 4;
return FT_DivFix( number, power_tens[integer_length - 4] );
}
else
{
*scaling = integer_length - 5;
return FT_DivFix( number, power_tens[integer_length - 5] );
}
}
else
{
*scaling = 0;
return number << 16;
}
}
}
static FT_Error
cff_parse_font_matrix( CFF_Parser parser )
{
CFF_FontRecDict dict = (CFF_FontRecDict)parser->object;
FT_Matrix* matrix = &dict->font_matrix;
FT_Vector* offset = &dict->font_offset;
FT_UShort* upm = &dict->units_per_em;
FT_ULong* upm = &dict->units_per_em;
FT_Byte** data = parser->stack;
FT_Error error;
FT_Fixed temp;
FT_Error error = CFF_Err_Stack_Underflow;
error = CFF_Err_Stack_Underflow;
if ( parser->top >= parser->stack + 6 )
{
matrix->xx = cff_parse_fixed_thousand( data++ );
matrix->yx = cff_parse_fixed_thousand( data++ );
matrix->xy = cff_parse_fixed_thousand( data++ );
matrix->yy = cff_parse_fixed_thousand( data++ );
offset->x = cff_parse_fixed_thousand( data++ );
offset->y = cff_parse_fixed_thousand( data );
FT_Int scaling;
temp = FT_ABS( matrix->yy );
*upm = (FT_UShort)FT_DivFix( 0x10000L, FT_DivFix( temp, 1000 ) );
if ( temp != 0x10000L )
{
matrix->xx = FT_DivFix( matrix->xx, temp );
matrix->yx = FT_DivFix( matrix->yx, temp );
matrix->xy = FT_DivFix( matrix->xy, temp );
matrix->yy = FT_DivFix( matrix->yy, temp );
offset->x = FT_DivFix( offset->x, temp );
offset->y = FT_DivFix( offset->y, temp );
}
/* note that the offsets must be expressed in integer font units */
offset->x >>= 16;
offset->y >>= 16;
error = CFF_Err_Ok;
/* We expect a well-formed font matrix, this is, the matrix elements */
/* `xx' and `yy' are of approximately the same magnitude. To avoid */
/* loss of precision, we use the magnitude of element `xx' to scale */
/* all other elements. The scaling factor is then contained in the */
/* `units_per_em' value. */
matrix->xx = cff_parse_fixed_dynamic( data++, &scaling );
scaling = -scaling;
if ( scaling < 0 || scaling > 9 )
{
/* Return default matrix in case of unlikely values. */
matrix->xx = 0x10000L;
matrix->yx = 0;
matrix->yx = 0;
matrix->yy = 0x10000L;
offset->x = 0;
offset->y = 0;
*upm = 1;
goto Exit;
}
matrix->yx = cff_parse_fixed_scaled( data++, scaling );
matrix->xy = cff_parse_fixed_scaled( data++, scaling );
matrix->yy = cff_parse_fixed_scaled( data++, scaling );
offset->x = cff_parse_fixed_scaled( data++, scaling );
offset->y = cff_parse_fixed_scaled( data, scaling );
*upm = power_tens[scaling];
}
Exit:
return error;
}
@ -585,7 +740,7 @@
goto Store_Number;
case cff_kind_fixed_thousand:
val = cff_parse_fixed_thousand( parser->stack );
val = cff_parse_fixed_scaled( parser->stack, 3 );
Store_Number:
switch ( field->size )

View File

@ -5,7 +5,7 @@
/* Basic OpenType/CFF type definitions and interface (specification */
/* only). */
/* */
/* Copyright 1996-2001, 2002, 2003, 2006, 2007 by */
/* Copyright 1996-2001, 2002, 2003, 2006, 2007, 2008 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@ -114,7 +114,7 @@ FT_BEGIN_HEADER
FT_Int paint_type;
FT_Int charstring_type;
FT_Matrix font_matrix;
FT_UShort units_per_em;
FT_ULong units_per_em; /* temporarily used as scaling value also */
FT_Vector font_offset;
FT_ULong unique_id;
FT_BBox font_bbox;
@ -259,6 +259,10 @@ FT_BEGIN_HEADER
/* since version 2.3.0 */
PS_FontInfoRec* font_info; /* font info dictionary */
/* since version 2.3.6 */
FT_String* registry;
FT_String* ordering;
} CFF_FontRec, *CFF_Font;

View File

@ -74,7 +74,7 @@
if ( glyph_data.length != 0 )
{
glyph_length = glyph_data.length - cid->fd_bytes;
FT_ALLOC( charstring, glyph_length );
(void)FT_ALLOC( charstring, glyph_length );
if ( !error )
ft_memcpy( charstring, glyph_data.pointer + cid->fd_bytes,
glyph_length );

View File

@ -4,7 +4,7 @@
/* */
/* CID driver interface (body). */
/* */
/* Copyright 1996-2001, 2002, 2003, 2004, 2006 by */
/* Copyright 1996-2001, 2002, 2003, 2004, 2006, 2008 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@ -27,6 +27,8 @@
#include FT_SERVICE_POSTSCRIPT_NAME_H
#include FT_SERVICE_XFREE86_NAME_H
#include FT_SERVICE_POSTSCRIPT_INFO_H
#include FT_SERVICE_CID_H
/*************************************************************************/
/* */
@ -38,10 +40,10 @@
#define FT_COMPONENT trace_ciddriver
/*
* POSTSCRIPT NAME SERVICE
*
*/
/*
* POSTSCRIPT NAME SERVICE
*
*/
static const char*
cid_get_postscript_name( CID_Face face )
@ -62,10 +64,10 @@
};
/*
* POSTSCRIPT INFO SERVICE
*
*/
/*
* POSTSCRIPT INFO SERVICE
*
*/
static FT_Error
cid_ps_get_font_info( FT_Face face,
@ -84,16 +86,49 @@
};
/*
* SERVICE LIST
*
*/
/*
* CID INFO SERVICE
*
*/
static FT_Error
cid_get_ros( CID_Face face,
const char* *registry,
const char* *ordering,
FT_Int *supplement )
{
CID_FaceInfo cid = &face->cid;
if ( registry )
*registry = cid->registry;
if ( ordering )
*ordering = cid->ordering;
if ( supplement )
*supplement = cid->supplement;
return CID_Err_Ok;
}
static const FT_Service_CIDRec cid_service_cid_info =
{
(FT_CID_GetRegistryOrderingSupplementFunc)cid_get_ros
};
/*
* SERVICE LIST
*
*/
static const FT_ServiceDescRec cid_services[] =
{
{ FT_SERVICE_ID_POSTSCRIPT_FONT_NAME, &cid_service_ps_name },
{ FT_SERVICE_ID_XF86_NAME, FT_XF86_FORMAT_CID },
{ FT_SERVICE_ID_POSTSCRIPT_FONT_NAME, &cid_service_ps_name },
{ FT_SERVICE_ID_POSTSCRIPT_INFO, &cid_service_ps_info },
{ FT_SERVICE_ID_CID, &cid_service_cid_info },
{ NULL, NULL }
};

View File

@ -8,7 +8,7 @@
/* be used to parse compressed PCF fonts, as found with many X11 server */
/* distributions. */
/* */
/* Copyright 2005, 2006, 2007 by David Turner. */
/* Copyright 2005, 2006, 2007, 2008 by David Turner. */
/* */
/* This file is part of the FreeType project, and may only be used, */
/* modified, and distributed under the terms of the FreeType project */
@ -46,7 +46,7 @@
#define LZW_MASK( n ) ( ( 1U << (n) ) - 1U )
typedef enum
typedef enum FT_LzwPhase_
{
FT_LZW_PHASE_START = 0,
FT_LZW_PHASE_CODE,
@ -109,7 +109,7 @@
* `free_ent', `num_bits' cannot grow larger than `max_bits'.
*/
typedef struct _FT_LzwStateRec
typedef struct FT_LzwStateRec_
{
FT_LzwPhase phase;
FT_Int in_eof;

View File

@ -4,7 +4,7 @@
/* */
/* FreeType validator for OpenType tables (body only). */
/* */
/* Copyright 2004 by */
/* Copyright 2004, 2007 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@ -25,6 +25,7 @@
#include "otvgpos.c"
#include "otvgsub.c"
#include "otvjstf.c"
#include "otvmath.c"
#include "otvmod.c"
/* END */

View File

@ -4,7 +4,7 @@
/* */
/* OpenType table validation (specification only). */
/* */
/* Copyright 2004 by */
/* Copyright 2004, 2008 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@ -63,6 +63,11 @@ FT_BEGIN_HEADER
FT_UInt glyph_count,
FT_Validator valid );
FT_LOCAL( void )
otv_MATH_validate( FT_Bytes table,
FT_UInt glyph_count,
FT_Validator ftvalid );
FT_END_HEADER

View File

@ -4,7 +4,7 @@
/* */
/* OpenType BASE table validation (body). */
/* */
/* Copyright 2004 by */
/* Copyright 2004, 2007 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@ -62,7 +62,7 @@
break;
default:
FT_INVALID_DATA;
FT_INVALID_FORMAT;
}
OTV_EXIT;
@ -297,7 +297,7 @@
OTV_LIMIT_CHECK( 6 );
if ( FT_NEXT_ULONG( p ) != 0x10000UL ) /* Version */
FT_INVALID_DATA;
FT_INVALID_FORMAT;
table_size = 6;

View File

@ -4,7 +4,7 @@
/* */
/* OpenType common tables validation (body). */
/* */
/* Copyright 2004, 2005, 2006 by */
/* Copyright 2004, 2005, 2006, 2007 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@ -39,10 +39,12 @@
FT_LOCAL_DEF( void )
otv_Coverage_validate( FT_Bytes table,
OTV_Validator valid )
OTV_Validator valid,
FT_Int expected_count )
{
FT_Bytes p = table;
FT_UInt CoverageFormat;
FT_UInt total = 0;
OTV_NAME_ENTER( "Coverage" );
@ -57,6 +59,7 @@
case 1: /* CoverageFormat1 */
{
FT_UInt GlyphCount;
FT_UInt i;
GlyphCount = FT_NEXT_USHORT( p );
@ -64,13 +67,25 @@
OTV_TRACE(( " (GlyphCount = %d)\n", GlyphCount ));
OTV_LIMIT_CHECK( GlyphCount * 2 ); /* GlyphArray */
for ( i = 0; i < GlyphCount; ++i )
{
FT_UInt gid;
gid = FT_NEXT_USHORT( p );
if ( gid >= valid->glyph_count )
FT_INVALID_GLYPH_ID;
}
total = GlyphCount;
}
break;
case 2: /* CoverageFormat2 */
{
FT_UInt n, RangeCount;
FT_UInt Start, End, StartCoverageIndex, total = 0, last = 0;
FT_UInt Start, End, StartCoverageIndex, last = 0;
RangeCount = FT_NEXT_USHORT( p );
@ -89,6 +104,9 @@
if ( Start > End || StartCoverageIndex != total )
FT_INVALID_DATA;
if ( End >= valid->glyph_count )
FT_INVALID_GLYPH_ID;
if ( n > 0 && Start <= last )
FT_INVALID_DATA;
@ -102,8 +120,11 @@
FT_INVALID_FORMAT;
}
/* no need to check glyph indices used as input to coverage tables */
/* since even invalid glyph indices return a meaningful result */
/* Generally, a coverage table offset has an associated count field. */
/* The number of glyphs in the table should match this field. If */
/* there is no associated count, a value of -1 tells us not to check. */
if ( expected_count != -1 && (FT_UInt)expected_count != total )
FT_INVALID_DATA;
OTV_EXIT;
}
@ -215,18 +236,21 @@
{
case 1: /* ClassDefFormat1 */
{
FT_UInt StartGlyph;
FT_UInt GlyphCount;
p += 2; /* skip StartGlyph */
OTV_LIMIT_CHECK( 2 );
OTV_LIMIT_CHECK( 4 );
StartGlyph = FT_NEXT_USHORT( p );
GlyphCount = FT_NEXT_USHORT( p );
OTV_TRACE(( " (GlyphCount = %d)\n", GlyphCount ));
OTV_LIMIT_CHECK( GlyphCount * 2 ); /* ClassValueArray */
if ( StartGlyph + GlyphCount - 1 >= valid->glyph_count )
FT_INVALID_GLYPH_ID;
}
break;
@ -252,6 +276,9 @@
if ( Start > End || ( n > 0 && Start <= last ) )
FT_INVALID_DATA;
if ( End >= valid->glyph_count )
FT_INVALID_GLYPH_ID;
last = End;
}
}
@ -291,7 +318,10 @@
EndSize = FT_NEXT_USHORT( p );
DeltaFormat = FT_NEXT_USHORT( p );
if ( DeltaFormat < 1 || DeltaFormat > 3 || EndSize < StartSize )
if ( DeltaFormat < 1 || DeltaFormat > 3 )
FT_INVALID_FORMAT;
if ( EndSize < StartSize )
FT_INVALID_DATA;
count = EndSize - StartSize + 1;
@ -330,7 +360,7 @@
OTV_TRACE(( " (type %d)\n", LookupType ));
if ( LookupType == 0 || LookupType >= valid->type_count )
if ( LookupType == 0 || LookupType > valid->type_count )
FT_INVALID_DATA;
validate = valid->type_funcs[LookupType - 1];
@ -657,7 +687,7 @@
OTV_TRACE(( " (Count = %d)\n", Count ));
otv_Coverage_validate( table + Coverage, valid );
otv_Coverage_validate( table + Coverage, valid, Count );
OTV_LIMIT_CHECK( Count * 2 );
@ -729,6 +759,7 @@
FT_INVALID_DATA;
OTV_LIMIT_CHECK( ( Count1 - 1 ) * 2 + Count2 * 4 );
p += ( Count1 - 1 ) * 2;
for ( ; Count2 > 0; Count2-- )
{
@ -824,7 +855,7 @@
OTV_TRACE(( " (ClassSetCount = %d)\n", ClassSetCount ));
otv_Coverage_validate( table + Coverage, valid );
otv_Coverage_validate( table + Coverage, valid, -1 );
otv_ClassDef_validate( table + ClassDef, valid );
OTV_LIMIT_CHECK( ClassSetCount * 2 );
@ -872,7 +903,7 @@
OTV_LIMIT_CHECK( GlyphCount * 2 + Count * 4 );
for ( count1 = GlyphCount; count1 > 0; count1-- )
otv_Coverage_validate( table + FT_NEXT_USHORT( p ), valid );
otv_Coverage_validate( table + FT_NEXT_USHORT( p ), valid, -1 );
for ( ; Count > 0; Count-- )
{
@ -913,7 +944,7 @@
OTV_TRACE(( " (ChainClassSetCount = %d)\n", ChainClassSetCount ));
otv_Coverage_validate( table + Coverage, valid );
otv_Coverage_validate( table + Coverage, valid, -1 );
otv_ClassDef_validate( table + BacktrackClassDef, valid );
otv_ClassDef_validate( table + InputClassDef, valid );
@ -963,7 +994,7 @@
OTV_LIMIT_CHECK( BacktrackGlyphCount * 2 + 2 );
for ( ; BacktrackGlyphCount > 0; BacktrackGlyphCount-- )
otv_Coverage_validate( table + FT_NEXT_USHORT( p ), valid );
otv_Coverage_validate( table + FT_NEXT_USHORT( p ), valid, -1 );
InputGlyphCount = FT_NEXT_USHORT( p );
@ -972,7 +1003,7 @@
OTV_LIMIT_CHECK( InputGlyphCount * 2 + 2 );
for ( count1 = InputGlyphCount; count1 > 0; count1-- )
otv_Coverage_validate( table + FT_NEXT_USHORT( p ), valid );
otv_Coverage_validate( table + FT_NEXT_USHORT( p ), valid, -1 );
LookaheadGlyphCount = FT_NEXT_USHORT( p );
@ -981,7 +1012,7 @@
OTV_LIMIT_CHECK( LookaheadGlyphCount * 2 + 2 );
for ( ; LookaheadGlyphCount > 0; LookaheadGlyphCount-- )
otv_Coverage_validate( table + FT_NEXT_USHORT( p ), valid );
otv_Coverage_validate( table + FT_NEXT_USHORT( p ), valid, -1 );
count2 = FT_NEXT_USHORT( p );

View File

@ -4,7 +4,7 @@
/* */
/* OpenType common tables validation (specification). */
/* */
/* Copyright 2004, 2005 by */
/* Copyright 2004, 2005, 2007 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@ -215,7 +215,8 @@ FT_BEGIN_HEADER
FT_LOCAL( void )
otv_Coverage_validate( FT_Bytes table,
OTV_Validator valid );
OTV_Validator valid,
FT_Int expected_count );
/* return first covered glyph */
FT_LOCAL( FT_UInt )

View File

@ -4,7 +4,7 @@
/* */
/* OpenType GDEF table validation (body). */
/* */
/* Copyright 2004, 2005 by */
/* Copyright 2004, 2005, 2007 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@ -61,7 +61,7 @@
OTV_TRACE(( " (GlyphCount = %d)\n", GlyphCount ));
otv_Coverage_validate( Coverage, valid );
otv_Coverage_validate( Coverage, valid, GlyphCount );
if ( GlyphCount != otv_Coverage_get_count( Coverage ) )
FT_INVALID_DATA;
@ -126,7 +126,7 @@
break;
default:
FT_INVALID_DATA;
FT_INVALID_FORMAT;
}
OTV_EXIT;

View File

@ -4,7 +4,7 @@
/* */
/* OpenType GPOS table validation (body). */
/* */
/* Copyright 2002, 2004, 2005, 2006 by */
/* Copyright 2002, 2004, 2005, 2006, 2007 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@ -124,8 +124,8 @@
Array1 = FT_NEXT_USHORT( p );
Array2 = FT_NEXT_USHORT( p );
otv_Coverage_validate( table + Coverage1, valid );
otv_Coverage_validate( table + Coverage2, valid );
otv_Coverage_validate( table + Coverage1, valid, -1 );
otv_Coverage_validate( table + Coverage2, valid, -1 );
otv_MarkArray_validate( table + Array1, valid );
@ -191,7 +191,7 @@
#endif
if ( format >= 0x100 )
FT_INVALID_DATA;
FT_INVALID_FORMAT;
for ( count = 4; count > 0; count-- )
{
@ -294,7 +294,7 @@
break;
default:
FT_INVALID_DATA;
FT_INVALID_FORMAT;
}
OTV_EXIT;
@ -376,7 +376,7 @@
Coverage = FT_NEXT_USHORT( p );
ValueFormat = FT_NEXT_USHORT( p );
otv_Coverage_validate( table + Coverage, valid );
otv_Coverage_validate( table + Coverage, valid, -1 );
otv_ValueRecord_validate( p, ValueFormat, valid ); /* Value */
}
break;
@ -395,7 +395,7 @@
len_value = otv_value_length( ValueFormat );
otv_Coverage_validate( table + Coverage, valid );
otv_Coverage_validate( table + Coverage, valid, ValueCount );
OTV_LIMIT_CHECK( ValueCount * len_value );
@ -409,7 +409,7 @@
break;
default:
FT_INVALID_DATA;
FT_INVALID_FORMAT;
}
OTV_EXIT;
@ -498,7 +498,7 @@
OTV_TRACE(( " (PairSetCount = %d)\n", PairSetCount ));
otv_Coverage_validate( table + Coverage, valid );
otv_Coverage_validate( table + Coverage, valid, -1 );
OTV_LIMIT_CHECK( PairSetCount * 2 );
@ -530,7 +530,7 @@
len_value1 = otv_value_length( ValueFormat1 );
len_value2 = otv_value_length( ValueFormat2 );
otv_Coverage_validate( table + Coverage, valid );
otv_Coverage_validate( table + Coverage, valid, -1 );
otv_ClassDef_validate( table + ClassDef1, valid );
otv_ClassDef_validate( table + ClassDef2, valid );
@ -558,7 +558,7 @@
break;
default:
FT_INVALID_DATA;
FT_INVALID_FORMAT;
}
OTV_EXIT;
@ -605,7 +605,7 @@
OTV_TRACE(( " (EntryExitCount = %d)\n", EntryExitCount ));
otv_Coverage_validate( table + Coverage, valid );
otv_Coverage_validate( table + Coverage, valid, EntryExitCount );
OTV_LIMIT_CHECK( EntryExitCount * 4 );
@ -629,7 +629,7 @@
break;
default:
FT_INVALID_DATA;
FT_INVALID_FORMAT;
}
OTV_EXIT;
@ -670,7 +670,7 @@
break;
default:
FT_INVALID_DATA;
FT_INVALID_FORMAT;
}
OTV_EXIT;
@ -711,7 +711,7 @@
break;
default:
FT_INVALID_DATA;
FT_INVALID_FORMAT;
}
OTV_EXIT;
@ -752,7 +752,7 @@
break;
default:
FT_INVALID_DATA;
FT_INVALID_FORMAT;
}
OTV_EXIT;
@ -811,7 +811,7 @@
break;
default:
FT_INVALID_DATA;
FT_INVALID_FORMAT;
}
OTV_EXIT;
@ -872,7 +872,7 @@
break;
default:
FT_INVALID_DATA;
FT_INVALID_FORMAT;
}
OTV_EXIT;
@ -925,7 +925,7 @@
break;
default:
FT_INVALID_DATA;
FT_INVALID_FORMAT;
}
OTV_EXIT;
@ -989,7 +989,7 @@
OTV_LIMIT_CHECK( 10 );
if ( FT_NEXT_ULONG( p ) != 0x10000UL ) /* Version */
FT_INVALID_DATA;
FT_INVALID_FORMAT;
ScriptList = FT_NEXT_USHORT( p );
FeatureList = FT_NEXT_USHORT( p );

View File

@ -4,7 +4,7 @@
/* */
/* OpenType GSUB table validation (body). */
/* */
/* Copyright 2004, 2005 by */
/* Copyright 2004, 2005, 2007 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@ -68,7 +68,7 @@
Coverage = table + FT_NEXT_USHORT( p );
DeltaGlyphID = FT_NEXT_SHORT( p );
otv_Coverage_validate( Coverage, valid );
otv_Coverage_validate( Coverage, valid, -1 );
idx = otv_Coverage_get_first( Coverage ) + DeltaGlyphID;
if ( idx < 0 )
@ -91,19 +91,19 @@
OTV_TRACE(( " (GlyphCount = %d)\n", GlyphCount ));
otv_Coverage_validate( table + Coverage, valid );
otv_Coverage_validate( table + Coverage, valid, GlyphCount );
OTV_LIMIT_CHECK( GlyphCount * 2 );
/* Substitute */
for ( ; GlyphCount > 0; GlyphCount-- )
if ( FT_NEXT_USHORT( p ) >= valid->glyph_count )
FT_INVALID_DATA;
FT_INVALID_GLYPH_ID;
}
break;
default:
FT_INVALID_DATA;
FT_INVALID_FORMAT;
}
OTV_EXIT;
@ -144,7 +144,7 @@
break;
default:
FT_INVALID_DATA;
FT_INVALID_FORMAT;
}
OTV_EXIT;
@ -185,7 +185,7 @@
break;
default:
FT_INVALID_DATA;
FT_INVALID_FORMAT;
}
OTV_EXIT;
@ -259,7 +259,7 @@
break;
default:
FT_INVALID_DATA;
FT_INVALID_FORMAT;
}
OTV_EXIT;
@ -318,7 +318,7 @@
break;
default:
FT_INVALID_DATA;
FT_INVALID_FORMAT;
}
OTV_EXIT;
@ -379,7 +379,7 @@
break;
default:
FT_INVALID_DATA;
FT_INVALID_FORMAT;
}
OTV_EXIT;
@ -434,7 +434,7 @@
break;
default:
FT_INVALID_DATA;
FT_INVALID_FORMAT;
}
OTV_EXIT;
@ -476,12 +476,12 @@
OTV_TRACE(( " (BacktrackGlyphCount = %d)\n", BacktrackGlyphCount ));
otv_Coverage_validate( Coverage, valid );
otv_Coverage_validate( Coverage, valid, -1 );
OTV_LIMIT_CHECK( BacktrackGlyphCount * 2 + 2 );
for ( ; BacktrackGlyphCount > 0; BacktrackGlyphCount-- )
otv_Coverage_validate( table + FT_NEXT_USHORT( p ), valid );
otv_Coverage_validate( table + FT_NEXT_USHORT( p ), valid, -1 );
LookaheadGlyphCount = FT_NEXT_USHORT( p );
@ -490,7 +490,7 @@
OTV_LIMIT_CHECK( LookaheadGlyphCount * 2 + 2 );
for ( ; LookaheadGlyphCount > 0; LookaheadGlyphCount-- )
otv_Coverage_validate( table + FT_NEXT_USHORT( p ), valid );
otv_Coverage_validate( table + FT_NEXT_USHORT( p ), valid, -1 );
GlyphCount = FT_NEXT_USHORT( p );
@ -509,7 +509,7 @@
break;
default:
FT_INVALID_DATA;
FT_INVALID_FORMAT;
}
OTV_EXIT;
@ -560,7 +560,7 @@
OTV_LIMIT_CHECK( 10 );
if ( FT_NEXT_ULONG( p ) != 0x10000UL ) /* Version */
FT_INVALID_DATA;
FT_INVALID_FORMAT;
ScriptList = FT_NEXT_USHORT( p );
FeatureList = FT_NEXT_USHORT( p );

View File

@ -4,7 +4,7 @@
/* */
/* OpenType JSTF table validation (body). */
/* */
/* Copyright 2004 by */
/* Copyright 2004, 2007 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@ -222,7 +222,7 @@
OTV_LIMIT_CHECK( 6 );
if ( FT_NEXT_ULONG( p ) != 0x10000UL ) /* Version */
FT_INVALID_DATA;
FT_INVALID_FORMAT;
JstfScriptCount = FT_NEXT_USHORT( p );

View File

@ -0,0 +1,450 @@
/***************************************************************************/
/* */
/* otvmath.c */
/* */
/* OpenType MATH table validation (body). */
/* */
/* Copyright 2007 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* Written by George Williams. */
/* */
/* This file is part of the FreeType project, and may only be used, */
/* modified, and distributed under the terms of the FreeType project */
/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
/* this file you indicate that you have read the license and */
/* understand and accept it fully. */
/* */
/***************************************************************************/
#include "otvalid.h"
#include "otvcommn.h"
#include "otvgpos.h"
/*************************************************************************/
/* */
/* The macro FT_COMPONENT is used in trace mode. It is an implicit */
/* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */
/* messages during execution. */
/* */
#undef FT_COMPONENT
#define FT_COMPONENT trace_otvmath
/*************************************************************************/
/*************************************************************************/
/***** *****/
/***** MATH TYPOGRAPHIC CONSTANTS *****/
/***** *****/
/*************************************************************************/
/*************************************************************************/
static void
otv_MathConstants_validate( FT_Bytes table,
OTV_Validator valid )
{
FT_Bytes p = table;
FT_UInt i;
FT_UInt table_size;
OTV_OPTIONAL_TABLE( DeviceTableOffset );
OTV_NAME_ENTER( "MathConstants" );
/* 56 constants, 51 have device tables */
OTV_LIMIT_CHECK( 2 * ( 56 + 51 ) );
table_size = 2 * ( 56 + 51 );
p += 4 * 2; /* First 4 constants have no device tables */
for ( i = 0; i < 51; ++i )
{
p += 2; /* skip the value */
OTV_OPTIONAL_OFFSET( DeviceTableOffset );
OTV_SIZE_CHECK( DeviceTableOffset );
if ( DeviceTableOffset )
otv_Device_validate( table + DeviceTableOffset, valid );
}
OTV_EXIT;
}
/*************************************************************************/
/*************************************************************************/
/***** *****/
/***** MATH ITALICS CORRECTION *****/
/***** MATH TOP ACCENT ATTACHMENT *****/
/***** *****/
/*************************************************************************/
/*************************************************************************/
static void
otv_MathItalicsCorrectionInfo_validate( FT_Bytes table,
OTV_Validator valid,
FT_Int isItalic )
{
FT_Bytes p = table;
FT_UInt i, cnt, table_size ;
OTV_OPTIONAL_TABLE( Coverage );
OTV_OPTIONAL_TABLE( DeviceTableOffset );
OTV_NAME_ENTER( isItalic ? "MathItalicsCorrectionInfo"
: "MathTopAccentAttachment" );
OTV_LIMIT_CHECK( 4 );
OTV_OPTIONAL_OFFSET( Coverage );
cnt = FT_NEXT_USHORT( p );
OTV_LIMIT_CHECK( 4 * cnt );
table_size = 4 + 4 * cnt;
OTV_SIZE_CHECK( Coverage );
otv_Coverage_validate( table + Coverage, valid, cnt );
for ( i = 0; i < cnt; ++i )
{
p += 2; /* Skip the value */
OTV_OPTIONAL_OFFSET( DeviceTableOffset );
OTV_SIZE_CHECK( DeviceTableOffset );
if ( DeviceTableOffset )
otv_Device_validate( table + DeviceTableOffset, valid );
}
OTV_EXIT;
}
/*************************************************************************/
/*************************************************************************/
/***** *****/
/***** MATH KERNING *****/
/***** *****/
/*************************************************************************/
/*************************************************************************/
static void
otv_MathKern_validate( FT_Bytes table,
OTV_Validator valid )
{
FT_Bytes p = table;
FT_UInt i, cnt, table_size;
OTV_OPTIONAL_TABLE( DeviceTableOffset );
/* OTV_NAME_ENTER( "MathKern" );*/
OTV_LIMIT_CHECK( 2 );
cnt = FT_NEXT_USHORT( p );
OTV_LIMIT_CHECK( 4 * cnt + 2 );
table_size = 4 + 4 * cnt;
/* Heights */
for ( i = 0; i < cnt; ++i )
{
p += 2; /* Skip the value */
OTV_OPTIONAL_OFFSET( DeviceTableOffset );
OTV_SIZE_CHECK( DeviceTableOffset );
if ( DeviceTableOffset )
otv_Device_validate( table + DeviceTableOffset, valid );
}
/* One more Kerning value */
for ( i = 0; i < cnt + 1; ++i )
{
p += 2; /* Skip the value */
OTV_OPTIONAL_OFFSET( DeviceTableOffset );
OTV_SIZE_CHECK( DeviceTableOffset );
if ( DeviceTableOffset )
otv_Device_validate( table + DeviceTableOffset, valid );
}
OTV_EXIT;
}
static void
otv_MathKernInfo_validate( FT_Bytes table,
OTV_Validator valid )
{
FT_Bytes p = table;
FT_UInt i, j, cnt, table_size;
OTV_OPTIONAL_TABLE( Coverage );
OTV_OPTIONAL_TABLE( MKRecordOffset );
OTV_NAME_ENTER( "MathKernInfo" );
OTV_LIMIT_CHECK( 4 );
OTV_OPTIONAL_OFFSET( Coverage );
cnt = FT_NEXT_USHORT( p );
OTV_LIMIT_CHECK( 8 * cnt );
table_size = 4 + 8 * cnt;
OTV_SIZE_CHECK( Coverage );
otv_Coverage_validate( table + Coverage, valid, cnt );
for ( i = 0; i < cnt; ++i )
{
for ( j = 0; j < 4; ++j )
{
OTV_OPTIONAL_OFFSET( MKRecordOffset );
OTV_SIZE_CHECK( MKRecordOffset );
if ( MKRecordOffset )
otv_MathKern_validate( table + MKRecordOffset, valid );
}
}
OTV_EXIT;
}
/*************************************************************************/
/*************************************************************************/
/***** *****/
/***** MATH GLYPH INFO *****/
/***** *****/
/*************************************************************************/
/*************************************************************************/
static void
otv_MathGlyphInfo_validate( FT_Bytes table,
OTV_Validator valid )
{
FT_Bytes p = table;
FT_UInt MathItalicsCorrectionInfo, MathTopAccentAttachment;
FT_UInt ExtendedShapeCoverage, MathKernInfo;
OTV_NAME_ENTER( "MathGlyphInfo" );
OTV_LIMIT_CHECK( 8 );
MathItalicsCorrectionInfo = FT_NEXT_USHORT( p );
MathTopAccentAttachment = FT_NEXT_USHORT( p );
ExtendedShapeCoverage = FT_NEXT_USHORT( p );
MathKernInfo = FT_NEXT_USHORT( p );
if ( MathItalicsCorrectionInfo )
otv_MathItalicsCorrectionInfo_validate(
table + MathItalicsCorrectionInfo, valid, TRUE );
/* Italic correction and Top Accent Attachment have the same format */
if ( MathTopAccentAttachment )
otv_MathItalicsCorrectionInfo_validate(
table + MathTopAccentAttachment, valid, FALSE );
if ( ExtendedShapeCoverage ) {
OTV_NAME_ENTER( "ExtendedShapeCoverage" );
otv_Coverage_validate( table + ExtendedShapeCoverage, valid, -1 );
OTV_EXIT;
}
if ( MathKernInfo )
otv_MathKernInfo_validate( table + MathKernInfo, valid );
OTV_EXIT;
}
/*************************************************************************/
/*************************************************************************/
/***** *****/
/***** MATH GLYPH CONSTRUCTION *****/
/***** *****/
/*************************************************************************/
/*************************************************************************/
static void
otv_GlyphAssembly_validate( FT_Bytes table,
OTV_Validator valid )
{
FT_Bytes p = table;
FT_UInt pcnt, table_size;
FT_UInt i;
OTV_OPTIONAL_TABLE( DeviceTableOffset );
/* OTV_NAME_ENTER( "GlyphAssembly" ); */
OTV_LIMIT_CHECK( 6 );
p += 2; /* Skip the Italics Correction value */
OTV_OPTIONAL_OFFSET( DeviceTableOffset );
pcnt = FT_NEXT_USHORT( p );
OTV_LIMIT_CHECK( 8 * pcnt );
table_size = 6 + 8 * pcnt;
OTV_SIZE_CHECK( DeviceTableOffset );
if ( DeviceTableOffset )
otv_Device_validate( table + DeviceTableOffset, valid );
for ( i = 0; i < pcnt; ++i )
{
FT_UInt gid;
gid = FT_NEXT_USHORT( p );
if ( gid >= valid->glyph_count )
FT_INVALID_GLYPH_ID;
p += 2*4; /* skip the Start, End, Full, and Flags fields */
}
/* OTV_EXIT; */
}
static void
otv_MathGlyphConstruction_validate( FT_Bytes table,
OTV_Validator valid )
{
FT_Bytes p = table;
FT_UInt vcnt, table_size;
FT_UInt i;
OTV_OPTIONAL_TABLE( GlyphAssembly );
/* OTV_NAME_ENTER( "MathGlyphConstruction" ); */
OTV_LIMIT_CHECK( 4 );
OTV_OPTIONAL_OFFSET( GlyphAssembly );
vcnt = FT_NEXT_USHORT( p );
OTV_LIMIT_CHECK( 4 * vcnt );
table_size = 4 + 4 * vcnt;
for ( i = 0; i < vcnt; ++i )
{
FT_UInt gid;
gid = FT_NEXT_USHORT( p );
if ( gid >= valid->glyph_count )
FT_INVALID_GLYPH_ID;
p += 2; /* skip the size */
}
OTV_SIZE_CHECK( GlyphAssembly );
if ( GlyphAssembly )
otv_GlyphAssembly_validate( table+GlyphAssembly, valid );
/* OTV_EXIT; */
}
static void
otv_MathVariants_validate( FT_Bytes table,
OTV_Validator valid )
{
FT_Bytes p = table;
FT_UInt vcnt, hcnt, i, table_size;
OTV_OPTIONAL_TABLE( VCoverage );
OTV_OPTIONAL_TABLE( HCoverage );
OTV_OPTIONAL_TABLE( Offset );
OTV_NAME_ENTER( "MathVariants" );
OTV_LIMIT_CHECK( 10 );
p += 2; /* Skip the MinConnectorOverlap constant */
OTV_OPTIONAL_OFFSET( VCoverage );
OTV_OPTIONAL_OFFSET( HCoverage );
vcnt = FT_NEXT_USHORT( p );
hcnt = FT_NEXT_USHORT( p );
OTV_LIMIT_CHECK( 2 * vcnt + 2 * hcnt );
table_size = 10 + 2 * vcnt + 2 * hcnt;
OTV_SIZE_CHECK( VCoverage );
if ( VCoverage )
otv_Coverage_validate( table + VCoverage, valid, vcnt );
OTV_SIZE_CHECK( HCoverage );
if ( HCoverage )
otv_Coverage_validate( table + HCoverage, valid, hcnt );
for ( i = 0; i < vcnt; ++i )
{
OTV_OPTIONAL_OFFSET( Offset );
OTV_SIZE_CHECK( Offset );
otv_MathGlyphConstruction_validate( table + Offset, valid );
}
for ( i = 0; i < hcnt; ++i )
{
OTV_OPTIONAL_OFFSET( Offset );
OTV_SIZE_CHECK( Offset );
otv_MathGlyphConstruction_validate( table + Offset, valid );
}
OTV_EXIT;
}
/*************************************************************************/
/*************************************************************************/
/***** *****/
/***** MATH TABLE *****/
/***** *****/
/*************************************************************************/
/*************************************************************************/
/* sets valid->glyph_count */
FT_LOCAL_DEF( void )
otv_MATH_validate( FT_Bytes table,
FT_UInt glyph_count,
FT_Validator ftvalid )
{
OTV_ValidatorRec validrec;
OTV_Validator valid = &validrec;
FT_Bytes p = table;
FT_UInt MathConstants, MathGlyphInfo, MathVariants;
valid->root = ftvalid;
FT_TRACE3(( "validating MATH table\n" ));
OTV_INIT;
OTV_LIMIT_CHECK( 10 );
if ( FT_NEXT_ULONG( p ) != 0x10000UL ) /* Version */
FT_INVALID_FORMAT;
MathConstants = FT_NEXT_USHORT( p );
MathGlyphInfo = FT_NEXT_USHORT( p );
MathVariants = FT_NEXT_USHORT( p );
valid->glyph_count = glyph_count;
otv_MathConstants_validate( table + MathConstants,
valid );
otv_MathGlyphInfo_validate( table + MathGlyphInfo,
valid );
otv_MathVariants_validate ( table + MathVariants,
valid );
FT_TRACE4(( "\n" ));
}
/* END */

View File

@ -4,7 +4,7 @@
/* */
/* FreeType's OpenType validation module implementation (body). */
/* */
/* Copyright 2004, 2005, 2006 by */
/* Copyright 2004, 2005, 2006, 2007 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@ -79,12 +79,14 @@
FT_Byte* volatile gpos;
FT_Byte* volatile gsub;
FT_Byte* volatile jstf;
FT_Byte* volatile math;
FT_ULong len_base, len_gdef, len_gpos, len_gsub, len_jstf;
FT_ULong len_math;
FT_ValidatorRec volatile valid;
base = gdef = gpos = gsub = jstf = NULL;
len_base = len_gdef = len_gpos = len_gsub = len_jstf = 0;
base = gdef = gpos = gsub = jstf = math = NULL;
len_base = len_gdef = len_gpos = len_gsub = len_jstf = len_math = 0;
/* load tables */
@ -123,6 +125,13 @@
goto Exit;
}
if ( ot_flags & FT_VALIDATE_MATH )
{
error = otv_load_table( face, TTAG_MATH, &math, &len_math );
if ( error )
goto Exit;
}
/* validate tables */
if ( base )
@ -175,6 +184,16 @@
goto Exit;
}
if ( math )
{
ft_validator_init( &valid, math, math + len_math, FT_VALIDATE_DEFAULT );
if ( ft_setjmp( valid.jump_buffer ) == 0 )
otv_MATH_validate( math, face->num_glyphs, &valid );
error = valid.error;
if ( error )
goto Exit;
}
*ot_base = (FT_Bytes)base;
*ot_gdef = (FT_Bytes)gdef;
*ot_gpos = (FT_Bytes)gpos;
@ -192,6 +211,12 @@
FT_FREE( gsub );
FT_FREE( jstf );
}
{
FT_Memory memory = FT_FACE_MEMORY( face );
FT_FREE( math ); /* Can't return this as API is frozen */
}
return error;
}

View File

@ -3,7 +3,7 @@
#
# Copyright 2004 by
# Copyright 2004, 2007 by
# David Turner, Robert Wilhelm, and Werner Lemberg.
#
# This file is part of the FreeType project, and may only be used, modified,
@ -31,14 +31,15 @@ OTV_DRV_SRC := $(OTV_DIR)/otvbase.c \
$(OTV_DIR)/otvgpos.c \
$(OTV_DIR)/otvgsub.c \
$(OTV_DIR)/otvjstf.c \
$(OTV_DIR)/otvmath.c \
$(OTV_DIR)/otvmod.c
# OTV driver headers
#
OTV_DRV_H := $(OTV_DIR)/otvalid.h \
$(OTV_DIR)/otverror.h \
OTV_DRV_H := $(OTV_DIR)/otvalid.h \
$(OTV_DIR)/otvcommn.h \
$(OTV_DIR)/otvgpos.h \
$(OTV_DIR)/otverror.h \
$(OTV_DIR)/otvgpos.h \
$(OTV_DIR)/otvmod.h

View File

@ -2,7 +2,7 @@
FreeType font driver for pcf files
Copyright (C) 2000, 2001, 2002, 2003, 2004, 2006 by
Copyright (C) 2000, 2001, 2002, 2003, 2004, 2006, 2007, 2008 by
Francesco Zappa Nardelli
Permission is hereby granted, free of charge, to any person obtaining a copy
@ -187,7 +187,9 @@ THE SOFTWARE.
pcf_cmap_init,
pcf_cmap_done,
pcf_cmap_char_index,
pcf_cmap_char_next
pcf_cmap_char_next,
NULL, NULL, NULL, NULL, NULL
};
@ -271,6 +273,7 @@ THE SOFTWARE.
error = error2;
if ( error )
#ifdef FT_CONFIG_OPTION_USE_LZW
{
FT_Error error3;
@ -293,6 +296,9 @@ THE SOFTWARE.
if ( error )
goto Fail;
}
#else
goto Fail;
#endif
else
{
face->gzip_source = stream;

View File

@ -20,6 +20,8 @@
#include "pfrobjs.h"
#include FT_INTERNAL_DEBUG_H
#include "pfrerror.h"
FT_CALLBACK_DEF( FT_Error )
pfr_cmap_init( PFR_CMap cmap )
@ -156,7 +158,9 @@
(FT_CMap_InitFunc) pfr_cmap_init,
(FT_CMap_DoneFunc) pfr_cmap_done,
(FT_CMap_CharIndexFunc)pfr_cmap_char_index,
(FT_CMap_CharNextFunc) pfr_cmap_char_next
(FT_CMap_CharNextFunc) pfr_cmap_char_next,
NULL, NULL, NULL, NULL, NULL
};

View File

@ -595,7 +595,7 @@
if ( org_count + count > glyph->max_subs )
{
FT_UInt new_max = ( org_count + count + 3 ) & -4;
FT_UInt new_max = ( org_count + count + 3 ) & (FT_UInt)-4;
if ( FT_RENEW_ARRAY( glyph->subs, glyph->max_subs, new_max ) )

View File

@ -4,7 +4,7 @@
/* */
/* Some convenience conversions (body). */
/* */
/* Copyright 2006 by */
/* Copyright 2006, 2008 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@ -187,10 +187,18 @@
if ( c < 0 || c >= 10 )
break;
if ( divider < 10000000L )
if ( !integral && power_ten > 0 )
{
power_ten--;
decimal = decimal * 10 + c;
divider *= 10;
}
else
{
if ( divider < 10000000L )
{
decimal = decimal * 10 + c;
divider *= 10;
}
}
}
}

View File

@ -4,7 +4,7 @@
/* */
/* Auxiliary functions for PostScript fonts (body). */
/* */
/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006, 2007 by */
/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@ -169,7 +169,7 @@
void* object,
FT_PtrDist length )
{
if ( idx < 0 || idx > table->max_elems )
if ( idx < 0 || idx >= table->max_elems )
{
FT_ERROR(( "ps_table_add: invalid index\n" ));
return PSaux_Err_Invalid_Argument;
@ -1483,12 +1483,6 @@
builder->hints_funcs = glyph->internal->glyph_hints;
}
if ( size )
{
builder->scale_x = size->metrics.x_scale;
builder->scale_y = size->metrics.y_scale;
}
builder->pos_x = 0;
builder->pos_y = 0;

View File

@ -4,7 +4,7 @@
/* */
/* Type 1 character map support (body). */
/* */
/* Copyright 2002, 2003, 2006 by */
/* Copyright 2002, 2003, 2006, 2007 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@ -135,7 +135,9 @@
(FT_CMap_InitFunc) t1_cmap_standard_init,
(FT_CMap_DoneFunc) t1_cmap_std_done,
(FT_CMap_CharIndexFunc)t1_cmap_std_char_index,
(FT_CMap_CharNextFunc) t1_cmap_std_char_next
(FT_CMap_CharNextFunc) t1_cmap_std_char_next,
NULL, NULL, NULL, NULL, NULL
};
@ -154,7 +156,9 @@
(FT_CMap_InitFunc) t1_cmap_expert_init,
(FT_CMap_DoneFunc) t1_cmap_std_done,
(FT_CMap_CharIndexFunc)t1_cmap_std_char_index,
(FT_CMap_CharNextFunc) t1_cmap_std_char_next
(FT_CMap_CharNextFunc) t1_cmap_std_char_next,
NULL, NULL, NULL, NULL, NULL
};
@ -245,7 +249,9 @@
(FT_CMap_InitFunc) t1_cmap_custom_init,
(FT_CMap_DoneFunc) t1_cmap_custom_done,
(FT_CMap_CharIndexFunc)t1_cmap_custom_char_index,
(FT_CMap_CharNextFunc) t1_cmap_custom_char_next
(FT_CMap_CharNextFunc) t1_cmap_custom_char_next,
NULL, NULL, NULL, NULL, NULL
};
@ -326,7 +332,9 @@
(FT_CMap_InitFunc) t1_cmap_unicode_init,
(FT_CMap_DoneFunc) t1_cmap_unicode_done,
(FT_CMap_CharIndexFunc)t1_cmap_unicode_char_index,
(FT_CMap_CharNextFunc) t1_cmap_unicode_char_next
(FT_CMap_CharNextFunc) t1_cmap_unicode_char_next,
NULL, NULL, NULL, NULL, NULL
};

View File

@ -4,7 +4,7 @@
/* */
/* PostScript Type 1 decoding routines (body). */
/* */
/* Copyright 2000-2001, 2002, 2003, 2004, 2005, 2006, 2007 by */
/* Copyright 2000-2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@ -1062,10 +1062,11 @@
case op_closepath:
FT_TRACE4(( " closepath" ));
close_contour( builder );
if ( !( builder->parse_state == T1_Parse_Have_Path ||
builder->parse_state == T1_Parse_Have_Moveto ) )
goto Syntax_Error;
/* if there is no path, `closepath' is a no-op */
if ( builder->parse_state == T1_Parse_Have_Path ||
builder->parse_state == T1_Parse_Have_Moveto )
close_contour( builder );
builder->parse_state = T1_Parse_Have_Width;
break;

View File

@ -4,7 +4,7 @@
/* */
/* PostScript hinting algorithm (body). */
/* */
/* Copyright 2001, 2002, 2003, 2004, 2005, 2006, 2007 by */
/* Copyright 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used */
@ -2223,15 +2223,22 @@
FT_Fixed x_scale = dim_x->scale_mult;
FT_Fixed y_scale = dim_y->scale_mult;
FT_Fixed old_x_scale = x_scale;
FT_Fixed old_y_scale = y_scale;
FT_Fixed scaled;
FT_Fixed fitted;
FT_Bool rescale = FALSE;
scaled = FT_MulFix( globals->blues.normal_top.zones->org_ref, y_scale );
fitted = FT_PIX_ROUND( scaled );
if ( fitted != 0 && scaled != fitted )
{
rescale = TRUE;
y_scale = FT_MulDiv( y_scale, fitted, scaled );
if ( fitted < scaled )
@ -2239,43 +2246,47 @@
psh_globals_set_scale( glyph->globals, x_scale, y_scale, 0, 0 );
}
}
glyph->do_horz_hints = 1;
glyph->do_vert_hints = 1;
glyph->do_horz_hints = 1;
glyph->do_vert_hints = 1;
glyph->do_horz_snapping = FT_BOOL( hint_mode == FT_RENDER_MODE_MONO ||
hint_mode == FT_RENDER_MODE_LCD );
glyph->do_horz_snapping = FT_BOOL( hint_mode == FT_RENDER_MODE_MONO ||
hint_mode == FT_RENDER_MODE_LCD );
glyph->do_vert_snapping = FT_BOOL( hint_mode == FT_RENDER_MODE_MONO ||
hint_mode == FT_RENDER_MODE_LCD_V );
glyph->do_vert_snapping = FT_BOOL( hint_mode == FT_RENDER_MODE_MONO ||
hint_mode == FT_RENDER_MODE_LCD_V );
glyph->do_stem_adjust = FT_BOOL( hint_mode != FT_RENDER_MODE_LIGHT );
glyph->do_stem_adjust = FT_BOOL( hint_mode != FT_RENDER_MODE_LIGHT );
for ( dimension = 0; dimension < 2; dimension++ )
{
/* load outline coordinates into glyph */
psh_glyph_load_points( glyph, dimension );
for ( dimension = 0; dimension < 2; dimension++ )
{
/* load outline coordinates into glyph */
psh_glyph_load_points( glyph, dimension );
/* compute local extrema */
psh_glyph_compute_extrema( glyph );
/* compute local extrema */
psh_glyph_compute_extrema( glyph );
/* compute aligned stem/hints positions */
psh_hint_table_align_hints( &glyph->hint_tables[dimension],
glyph->globals,
dimension,
glyph );
/* compute aligned stem/hints positions */
psh_hint_table_align_hints( &glyph->hint_tables[dimension],
glyph->globals,
dimension,
glyph );
/* find strong points, align them, then interpolate others */
psh_glyph_find_strong_points( glyph, dimension );
if ( dimension == 1 )
psh_glyph_find_blue_points( &globals->blues, glyph );
psh_glyph_interpolate_strong_points( glyph, dimension );
psh_glyph_interpolate_normal_points( glyph, dimension );
psh_glyph_interpolate_other_points( glyph, dimension );
/* find strong points, align them, then interpolate others */
psh_glyph_find_strong_points( glyph, dimension );
if ( dimension == 1 )
psh_glyph_find_blue_points( &globals->blues, glyph );
psh_glyph_interpolate_strong_points( glyph, dimension );
psh_glyph_interpolate_normal_points( glyph, dimension );
psh_glyph_interpolate_other_points( glyph, dimension );
/* save hinted coordinates back to outline */
psh_glyph_save_points( glyph, dimension );
/* save hinted coordinates back to outline */
psh_glyph_save_points( glyph, dimension );
if ( rescale )
psh_globals_set_scale( glyph->globals,
old_x_scale, old_y_scale, 0, 0 );
}
}
Exit:

View File

@ -4,7 +4,7 @@
/* */
/* PostScript hinting algorithm (specification). */
/* */
/* Copyright 2001, 2002, 2003 by */
/* Copyright 2001, 2002, 2003, 2008 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@ -32,7 +32,7 @@ FT_BEGIN_HEADER
typedef struct PSH_HintRec_* PSH_Hint;
/* hint bit-flags */
typedef enum
typedef enum PSH_Hint_Flags_
{
PSH_HINT_GHOST = PS_HINT_FLAG_GHOST,
PSH_HINT_BOTTOM = PS_HINT_FLAG_BOTTOM,

View File

@ -4,7 +4,7 @@
/* */
/* Postscript (Type1/Type2) hints recorder (specification). */
/* */
/* Copyright 2001, 2002, 2003, 2006 by */
/* Copyright 2001, 2002, 2003, 2006, 2008 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@ -52,7 +52,7 @@ FT_BEGIN_HEADER
typedef struct PS_HintRec_* PS_Hint;
/* hint types */
typedef enum
typedef enum PS_Hint_Type_
{
PS_HINT_TYPE_1 = 1,
PS_HINT_TYPE_2 = 2
@ -61,7 +61,7 @@ FT_BEGIN_HEADER
/* hint flags */
typedef enum
typedef enum PS_Hint_Flags_
{
PS_HINT_FLAG_GHOST = 1,
PS_HINT_FLAG_BOTTOM = 2

View File

@ -4,7 +4,7 @@
/* */
/* PSNames module implementation (body). */
/* */
/* Copyright 1996-2001, 2002, 2003, 2005, 2006, 2007 by */
/* Copyright 1996-2001, 2002, 2003, 2005, 2006, 2007, 2008 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@ -26,7 +26,7 @@
#include "psnamerr.h"
#ifndef FT_CONFIG_OPTION_NO_POSTSCRIPT_NAMES
#ifdef FT_CONFIG_OPTION_POSTSCRIPT_NAMES
#ifdef FT_CONFIG_OPTION_ADOBE_GLYPH_LIST
@ -180,6 +180,95 @@
}
/* support for old WGL4 fonts */
#define WGL_EXTRA_LIST_SIZE 8
static const FT_UInt32 ft_wgl_extra_unicodes[WGL_EXTRA_LIST_SIZE] =
{
0x0394,
0x03A9,
0x2215,
0x00AD,
0x02C9,
0x03BC,
0x2219,
0x00A0
};
static const char ft_wgl_extra_glyph_names[] =
{
'D','e','l','t','a',0,
'O','m','e','g','a',0,
'f','r','a','c','t','i','o','n',0,
'h','y','p','h','e','n',0,
'm','a','c','r','o','n',0,
'm','u',0,
'p','e','r','i','o','d','c','e','n','t','e','r','e','d',0,
's','p','a','c','e',0
};
static const FT_Int
ft_wgl_extra_glyph_name_offsets[WGL_EXTRA_LIST_SIZE] =
{
0,
6,
12,
21,
28,
35,
38,
53
};
static void
ps_check_wgl_name( const char* gname,
FT_UInt glyph,
FT_UInt* wgl_glyphs,
FT_UInt *states )
{
FT_UInt n;
for ( n = 0; n < WGL_EXTRA_LIST_SIZE; n++ )
{
if ( ft_strcmp( ft_wgl_extra_glyph_names +
ft_wgl_extra_glyph_name_offsets[n], gname ) == 0 )
{
if ( states[n] == 0 )
{
/* mark this WGL extra glyph as a candidate for the cmap */
states[n] = 1;
wgl_glyphs[n] = glyph;
}
return;
}
}
}
static void
ps_check_wgl_unicode( FT_UInt32 uni_char,
FT_UInt *states )
{
FT_UInt n;
for ( n = 0; n < WGL_EXTRA_LIST_SIZE; n++ )
{
if ( uni_char == ft_wgl_extra_unicodes[n] )
{
/* disable this WGL extra glyph from being added to the cmap */
states[n] = 2;
return;
}
}
}
/* Build a table that maps Unicode values to glyph indices. */
static FT_Error
ps_unicodes_init( FT_Memory memory,
@ -191,12 +280,15 @@
{
FT_Error error;
FT_UInt wgl_list_states[] = { 0, 0, 0, 0, 0, 0, 0, 0 };
FT_UInt wgl_glyphs[WGL_EXTRA_LIST_SIZE];
/* we first allocate the table */
table->num_maps = 0;
table->maps = 0;
if ( !FT_NEW_ARRAY( table->maps, num_glyphs ) )
if ( !FT_NEW_ARRAY( table->maps, num_glyphs + WGL_EXTRA_LIST_SIZE ) )
{
FT_UInt n;
FT_UInt count;
@ -213,10 +305,12 @@
if ( gname )
{
ps_check_wgl_name( gname, n, wgl_glyphs, wgl_list_states );
uni_char = ps_unicode_value( gname );
if ( BASE_GLYPH( uni_char ) != 0 )
{
ps_check_wgl_unicode( uni_char, wgl_list_states );
map->unicode = uni_char;
map->glyph_index = n;
map++;
@ -227,6 +321,19 @@
}
}
for ( n = 0; n < WGL_EXTRA_LIST_SIZE; n++ )
{
if ( wgl_list_states[n] == 1 )
{
/* This glyph name has an additional WGL4 representation. */
/* Add it to the cmap. */
map->unicode = ft_wgl_extra_unicodes[n];
map->glyph_index = wgl_glyphs[n];
map++;
}
}
/* now compress the table a bit */
count = (FT_UInt)( map - table->maps );
@ -427,7 +534,7 @@
return ft_service_list_lookup( pscmaps_services, service_id );
}
#endif /* !FT_CONFIG_OPTION_NO_POSTSCRIPT_NAMES */
#endif /* FT_CONFIG_OPTION_POSTSCRIPT_NAMES */
@ -441,7 +548,7 @@
0x10000L, /* driver version */
0x20000L, /* driver requires FreeType 2 or above */
#ifdef FT_CONFIG_OPTION_NO_POSTSCRIPT_NAMES
#ifndef FT_CONFIG_OPTION_POSTSCRIPT_NAMES
0,
(FT_Module_Constructor)0,
(FT_Module_Destructor) 0,

View File

@ -4,7 +4,7 @@
/* */
/* The FreeType glyph rasterizer (body). */
/* */
/* Copyright 1996-2001, 2002, 2003, 2005, 2007 by */
/* Copyright 1996-2001, 2002, 2003, 2005, 2007, 2008 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@ -144,9 +144,7 @@
/* undefine FT_RASTER_OPTION_ANTI_ALIASING if you do not want to support */
/* 5-levels anti-aliasing */
#ifdef FT_CONFIG_OPTION_5_GRAY_LEVELS
#define FT_RASTER_OPTION_ANTI_ALIASING
#endif
#undef FT_RASTER_OPTION_ANTI_ALIASING
/* The size of the two-lines intermediate bitmap used */
/* for anti-aliasing, in bytes. */
@ -543,6 +541,8 @@
#endif /* FT_STATIC_RASTER */
#ifdef FT_RASTER_OPTION_ANTI_ALIASING
static const char count_table[256] =
{
0 , 1 , 1 , 2 , 1 , 2 , 2 , 3 , 1 , 2 , 2 , 3 , 2 , 3 , 3 , 4,
@ -562,6 +562,8 @@ static const char count_table[256] =
3 , 4 , 4 , 5 , 4 , 5 , 5 , 6 , 4 , 5 , 5 , 6 , 5 , 6 , 6 , 7,
4 , 5 , 5 , 6 , 5 , 6 , 6 , 7 , 5 , 6 , 6 , 7 , 6 , 7 , 7 , 8 };
#endif /* FT_RASTER_OPTION_ANTI_ALIASING */
/*************************************************************************/
@ -3172,8 +3174,6 @@ static const char count_table[256] =
static void
ft_black_init( PRaster raster )
{
FT_UNUSED( raster );
#ifdef FT_RASTER_OPTION_ANTI_ALIASING
FT_UInt n;
@ -3184,6 +3184,8 @@ static const char count_table[256] =
raster->gray_width = RASTER_GRAY_LINES / 2;
#else
FT_UNUSED( raster );
#endif
}
@ -3319,14 +3321,18 @@ static const char count_table[256] =
if ( !raster || !raster->buffer || !raster->buffer_size )
return Raster_Err_Not_Ini;
if ( !outline )
return Raster_Err_Invalid;
/* return immediately if the outline is empty */
if ( outline->n_points == 0 || outline->n_contours <= 0 )
return Raster_Err_None;
if ( !outline || !outline->contours || !outline->points )
if ( !outline->contours || !outline->points )
return Raster_Err_Invalid;
if ( outline->n_points != outline->contours[outline->n_contours - 1] + 1 )
if ( outline->n_points !=
outline->contours[outline->n_contours - 1] + 1 )
return Raster_Err_Invalid;
worker = raster->worker;
@ -3335,7 +3341,14 @@ static const char count_table[256] =
if ( params->flags & FT_RASTER_FLAG_DIRECT )
return Raster_Err_Unsupported;
if ( !target_map || !target_map->buffer )
if ( !target_map )
return Raster_Err_Invalid;
/* nothing to do */
if ( !target_map->width || !target_map->rows )
return Raster_Err_None;
if ( !target_map->buffer )
return Raster_Err_Invalid;
ras.outline = *outline;

View File

@ -4,7 +4,7 @@
/* */
/* SFNT object management (base). */
/* */
/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006, 2007 by */
/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@ -285,7 +285,7 @@
sfnt_find_encoding( int platform_id,
int encoding_id )
{
typedef struct TEncoding
typedef struct TEncoding_
{
int platform_id;
int encoding_id;
@ -696,22 +696,60 @@
face->root.num_glyphs = face->max_profile.numGlyphs;
face->root.family_name = tt_face_get_name( face,
TT_NAME_ID_PREFERRED_FAMILY );
if ( !face->root.family_name )
face->root.family_name = tt_face_get_name( face,
TT_NAME_ID_FONT_FAMILY );
#if 0
/* Bit 8 of the `fsSelection' field in the `OS/2' table denotes */
/* a WWS-only font face. `WWS' stands for `weight', width', and */
/* `slope', a term used by Microsoft's Windows Presentation */
/* Foundation (WPF). This flag will be introduced in version */
/* 1.5 of the OpenType specification (but is already in use). */
if ( face->os2.version != 0xFFFFU && face->os2.fsSelection & 256 )
#endif
{
face->root.family_name =
tt_face_get_name( face, TT_NAME_ID_PREFERRED_FAMILY );
if ( !face->root.family_name )
face->root.family_name =
tt_face_get_name( face, TT_NAME_ID_FONT_FAMILY );
face->root.style_name =
tt_face_get_name( face, TT_NAME_ID_PREFERRED_SUBFAMILY );
if ( !face->root.style_name )
face->root.style_name =
tt_face_get_name( face, TT_NAME_ID_FONT_SUBFAMILY );
}
#if 0
else
{
/* Support for `name' table ID 21 (WWS family) and 22 (WWS */
/* subfamily) is still under consideration by Microsoft and */
/* not implemented in the current version of WPF. */
face->root.family_name =
tt_face_get_name( face, TT_NAME_ID_WWS_FAMILY );
if ( !face->root.family_name )
face->root.family_name =
tt_face_get_name( face, TT_NAME_ID_PREFERRED_FAMILY );
if ( !face->root.family_name )
face->root.family_name =
tt_face_get_name( face, TT_NAME_ID_FONT_FAMILY );
face->root.style_name =
tt_face_get_name( face, TT_NAME_ID_WWS_SUBFAMILY );
if ( !face->root.style_name )
face->root.style_name =
tt_face_get_name( face, TT_NAME_ID_PREFERRED_SUBFAMILY );
if ( !face->root.style_name )
face->root.style_name =
tt_face_get_name( face, TT_NAME_ID_FONT_SUBFAMILY );
}
#endif
face->root.style_name = tt_face_get_name( face,
TT_NAME_ID_PREFERRED_SUBFAMILY );
if ( !face->root.style_name )
face->root.style_name = tt_face_get_name( face,
TT_NAME_ID_FONT_SUBFAMILY );
/* now set up root fields */
{
FT_Face root = &face->root;
FT_Int32 flags = root->face_flags;
FT_Face root = &face->root;
FT_Int32 flags = root->face_flags;
/*********************************************************************/
@ -727,7 +765,7 @@
FT_FACE_FLAG_HORIZONTAL; /* horizontal data */
#ifdef TT_CONFIG_OPTION_POSTSCRIPT_NAMES
if ( psnames_error == SFNT_Err_Ok &&
if ( psnames_error == SFNT_Err_Ok &&
face->postscript.FormatType != 0x00030000L )
flags |= FT_FACE_FLAG_GLYPH_NAMES;
#endif
@ -759,14 +797,21 @@
/* */
/* Compute style flags. */
/* */
flags = 0;
if ( has_outline == TRUE && face->os2.version != 0xFFFFU )
{
/* we have an OS/2 table; use the `fsSelection' field */
if ( face->os2.fsSelection & 1 )
/* We have an OS/2 table; use the `fsSelection' field. Bit 9 */
/* indicates an oblique font face. This flag will be */
/* introduced in version 1.5 of the OpenType specification (but */
/* is already in use). */
if ( face->os2.fsSelection & 512 ) /* bit 9 */
flags |= FT_STYLE_FLAG_ITALIC;
else if ( face->os2.fsSelection & 1 ) /* bit 0 */
flags |= FT_STYLE_FLAG_ITALIC;
if ( face->os2.fsSelection & 32 )
if ( face->os2.fsSelection & 32 ) /* bit 5 */
flags |= FT_STYLE_FLAG_BOLD;
}
else
@ -1051,7 +1096,8 @@
face->gasp.numRanges = 0;
/* freeing the name table */
sfnt->free_name( face );
if ( sfnt )
sfnt->free_name( face );
/* freeing family and style name */
FT_FREE( face->root.family_name );

View File

@ -39,11 +39,13 @@
#define TT_PEEK_SHORT FT_PEEK_SHORT
#define TT_PEEK_USHORT FT_PEEK_USHORT
#define TT_PEEK_UINT24 FT_PEEK_UOFF3
#define TT_PEEK_LONG FT_PEEK_LONG
#define TT_PEEK_ULONG FT_PEEK_ULONG
#define TT_NEXT_SHORT FT_NEXT_SHORT
#define TT_NEXT_USHORT FT_NEXT_USHORT
#define TT_NEXT_UINT24 FT_NEXT_UOFF3
#define TT_NEXT_LONG FT_NEXT_LONG
#define TT_NEXT_ULONG FT_NEXT_ULONG
@ -171,7 +173,9 @@
(FT_CMap_InitFunc) tt_cmap_init,
(FT_CMap_DoneFunc) NULL,
(FT_CMap_CharIndexFunc)tt_cmap0_char_index,
(FT_CMap_CharNextFunc) tt_cmap0_char_next
(FT_CMap_CharNextFunc) tt_cmap0_char_next,
NULL, NULL, NULL, NULL, NULL
},
0,
(TT_CMap_ValidateFunc) tt_cmap0_validate,
@ -544,7 +548,9 @@
(FT_CMap_InitFunc) tt_cmap_init,
(FT_CMap_DoneFunc) NULL,
(FT_CMap_CharIndexFunc)tt_cmap2_char_index,
(FT_CMap_CharNextFunc) tt_cmap2_char_next
(FT_CMap_CharNextFunc) tt_cmap2_char_next,
NULL, NULL, NULL, NULL, NULL
},
2,
(TT_CMap_ValidateFunc) tt_cmap2_validate,
@ -1320,7 +1326,9 @@
(FT_CMap_InitFunc) tt_cmap4_init,
(FT_CMap_DoneFunc) NULL,
(FT_CMap_CharIndexFunc)tt_cmap4_char_index,
(FT_CMap_CharNextFunc) tt_cmap4_char_next
(FT_CMap_CharNextFunc) tt_cmap4_char_next,
NULL, NULL, NULL, NULL, NULL
},
4,
(TT_CMap_ValidateFunc) tt_cmap4_validate,
@ -1481,7 +1489,9 @@
(FT_CMap_InitFunc) tt_cmap_init,
(FT_CMap_DoneFunc) NULL,
(FT_CMap_CharIndexFunc)tt_cmap6_char_index,
(FT_CMap_CharNextFunc) tt_cmap6_char_next
(FT_CMap_CharNextFunc) tt_cmap6_char_next,
NULL, NULL, NULL, NULL, NULL
},
6,
(TT_CMap_ValidateFunc) tt_cmap6_validate,
@ -1735,7 +1745,9 @@
(FT_CMap_InitFunc) tt_cmap_init,
(FT_CMap_DoneFunc) NULL,
(FT_CMap_CharIndexFunc)tt_cmap8_char_index,
(FT_CMap_CharNextFunc) tt_cmap8_char_next
(FT_CMap_CharNextFunc) tt_cmap8_char_next,
NULL, NULL, NULL, NULL, NULL
},
8,
(TT_CMap_ValidateFunc) tt_cmap8_validate,
@ -1884,7 +1896,9 @@
(FT_CMap_InitFunc) tt_cmap_init,
(FT_CMap_DoneFunc) NULL,
(FT_CMap_CharIndexFunc)tt_cmap10_char_index,
(FT_CMap_CharNextFunc) tt_cmap10_char_next
(FT_CMap_CharNextFunc) tt_cmap10_char_next,
NULL, NULL, NULL, NULL, NULL
},
10,
(TT_CMap_ValidateFunc) tt_cmap10_validate,
@ -2201,17 +2215,756 @@
(FT_CMap_InitFunc) tt_cmap12_init,
(FT_CMap_DoneFunc) NULL,
(FT_CMap_CharIndexFunc)tt_cmap12_char_index,
(FT_CMap_CharNextFunc) tt_cmap12_char_next
(FT_CMap_CharNextFunc) tt_cmap12_char_next,
NULL, NULL, NULL, NULL, NULL
},
12,
(TT_CMap_ValidateFunc) tt_cmap12_validate,
(TT_CMap_Info_GetFunc) tt_cmap12_get_info
};
#endif /* TT_CONFIG_CMAP_FORMAT_12 */
/*************************************************************************/
/*************************************************************************/
/***** *****/
/***** FORMAT 14 *****/
/***** *****/
/*************************************************************************/
/*************************************************************************/
/*************************************************************************/
/* */
/* TABLE OVERVIEW */
/* -------------- */
/* */
/* NAME OFFSET TYPE DESCRIPTION */
/* */
/* format 0 USHORT must be 14 */
/* length 2 ULONG table length in bytes */
/* numSelector 6 ULONG number of variation sel. records */
/* */
/* Followed by numSelector records, each of which looks like */
/* */
/* varSelector 0 UINT24 Unicode codepoint of sel. */
/* defaultOff 3 ULONG offset to a default UVS table */
/* describing any variants to be found in */
/* the normal Unicode subtable. */
/* nonDefOff 7 ULONG offset to a non-default UVS table */
/* describing any variants not in the */
/* standard cmap, with GIDs here */
/* (either offset may be 0 NULL) */
/* */
/* Selectors are sorted by code point. */
/* */
/* A default Unicode Variation Selector (UVS) subtable is just a list of */
/* ranges of code points which are to be found in the standard cmap. No */
/* glyph IDs (GIDs) here. */
/* */
/* numRanges 0 ULONG number of ranges following */
/* */
/* A range looks like */
/* */
/* uniStart 0 UINT24 code point of the first character in */
/* this range */
/* additionalCnt 3 UBYTE count of additional characters in this */
/* range (zero means a range of a single */
/* character) */
/* */
/* Ranges are sorted by `uniStart'. */
/* */
/* A non-default Unicode Variation Selector (UVS) subtable is a list of */
/* mappings from codepoint to GID. */
/* */
/* numMappings 0 ULONG number of mappings */
/* */
/* A range looks like */
/* */
/* uniStart 0 UINT24 code point of the first character in */
/* this range */
/* GID 3 USHORT and its GID */
/* */
/* Ranges are sorted by `uniStart'. */
#ifdef TT_CONFIG_CMAP_FORMAT_14
typedef struct TT_CMap14Rec_
{
TT_CMapRec cmap;
FT_ULong num_selectors;
/* This array is used to store the results of various
* cmap 14 query functions. The data is overwritten
* on each call to these functions.
*/
FT_UInt max_results;
FT_UInt32* results;
FT_Memory memory;
} TT_CMap14Rec, *TT_CMap14;
FT_CALLBACK_DEF( void )
tt_cmap14_done( TT_CMap14 cmap )
{
FT_Memory memory = cmap->memory;
cmap->max_results = 0;
if ( memory != NULL && cmap->results != NULL )
FT_FREE( cmap->results );
}
static FT_Error
tt_cmap14_ensure( TT_CMap14 cmap,
FT_UInt num_results,
FT_Memory memory )
{
FT_UInt old_max = cmap->max_results;
FT_Error error = 0;
if ( num_results > cmap->max_results )
{
cmap->memory = memory;
if ( FT_QRENEW_ARRAY( cmap->results, old_max, num_results ) )
return error;
cmap->max_results = num_results;
}
return error;
}
FT_CALLBACK_DEF( FT_Error )
tt_cmap14_init( TT_CMap14 cmap,
FT_Byte* table )
{
cmap->cmap.data = table;
table += 6;
cmap->num_selectors = FT_PEEK_ULONG( table );
cmap->max_results = 0;
cmap->results = NULL;
return SFNT_Err_Ok;
}
FT_CALLBACK_DEF( FT_Error )
tt_cmap14_validate( FT_Byte* table,
FT_Validator valid )
{
FT_Byte* p = table + 2;
FT_ULong length = TT_NEXT_ULONG( p );
FT_ULong num_selectors = TT_NEXT_ULONG( p );
if ( table + length > valid->limit || length < 10 + 11 * num_selectors )
FT_INVALID_TOO_SHORT;
/* check selectors, they must be in increasing order */
{
/* we start lastVarSel at 1 because a variant selector value of 0
* isn't valid.
*/
FT_ULong n, lastVarSel = 1;
for ( n = 0; n < num_selectors; n++ )
{
FT_ULong varSel = TT_NEXT_UINT24( p );
FT_ULong defOff = TT_NEXT_ULONG( p );
FT_ULong nondefOff = TT_NEXT_ULONG( p );
if ( defOff >= length || nondefOff >= length )
FT_INVALID_TOO_SHORT;
if ( varSel < lastVarSel )
FT_INVALID_DATA;
lastVarSel = varSel + 1;
/* check the default table (these glyphs should be reached */
/* through the normal Unicode cmap, no GIDs, just check order) */
if ( defOff != 0 )
{
FT_Byte* defp = table + defOff;
FT_ULong numRanges = TT_NEXT_ULONG( defp );
FT_ULong i;
FT_ULong lastBase = 0;
if ( defp + numRanges * 4 > valid->limit )
FT_INVALID_TOO_SHORT;
for ( i = 0; i < numRanges; ++i )
{
FT_ULong base = TT_NEXT_UINT24( defp );
FT_ULong cnt = FT_NEXT_BYTE( defp );
if ( base + cnt >= 0x110000UL ) /* end of Unicode */
FT_INVALID_DATA;
if ( base < lastBase )
FT_INVALID_DATA;
lastBase = base + cnt + 1U;
}
}
/* and the non-default table (these glyphs are specified here) */
if ( nondefOff != 0 ) {
FT_Byte* ndp = table + nondefOff;
FT_ULong numMappings = TT_NEXT_ULONG( ndp );
FT_ULong i, lastUni = 0;
if ( ndp + numMappings * 4 > valid->limit )
FT_INVALID_TOO_SHORT;
for ( i = 0; i < numMappings; ++i )
{
FT_ULong uni = TT_NEXT_UINT24( ndp );
FT_ULong gid = TT_NEXT_USHORT( ndp );
if ( uni >= 0x110000UL ) /* end of Unicode */
FT_INVALID_DATA;
if ( uni < lastUni )
FT_INVALID_DATA;
lastUni = uni + 1U;
if ( valid->level >= FT_VALIDATE_TIGHT &&
gid >= TT_VALID_GLYPH_COUNT( valid ) )
FT_INVALID_GLYPH_ID;
}
}
}
}
return SFNT_Err_Ok;
}
FT_CALLBACK_DEF( FT_UInt )
tt_cmap14_char_index( TT_CMap cmap,
FT_UInt32 char_code )
{
FT_UNUSED( cmap );
FT_UNUSED( char_code );
/* This can't happen */
return 0;
}
FT_CALLBACK_DEF( FT_UInt )
tt_cmap14_char_next( TT_CMap cmap,
FT_UInt32 *pchar_code )
{
FT_UNUSED( cmap );
/* This can't happen */
*pchar_code = 0;
return 0;
}
FT_CALLBACK_DEF( FT_Error )
tt_cmap14_get_info( TT_CMap cmap,
TT_CMapInfo *cmap_info )
{
FT_UNUSED( cmap );
cmap_info->format = 14;
/* subtable 14 does not define a language field */
cmap_info->language = 0xFFFFFFFFUL;
return SFNT_Err_Ok;
}
static FT_UInt
tt_cmap14_char_map_def_binary( FT_Byte *base,
FT_UInt32 char_code )
{
FT_UInt32 numRanges = TT_PEEK_ULONG( base );
FT_UInt32 max, min;
min = 0;
max = numRanges;
base += 4;
/* binary search */
while ( min < max )
{
FT_UInt32 mid = ( min + max ) >> 1;
FT_Byte* p = base + 4 * mid;
FT_ULong start = TT_NEXT_UINT24( p );
FT_UInt cnt = FT_NEXT_BYTE( p );
if ( char_code < start )
max = mid;
else if ( char_code > start+cnt )
min = mid + 1;
else
return TRUE;
}
return FALSE;
}
static FT_UInt
tt_cmap14_char_map_nondef_binary( FT_Byte *base,
FT_UInt32 char_code )
{
FT_UInt32 numMappings = TT_PEEK_ULONG( base );
FT_UInt32 max, min;
min = 0;
max = numMappings;
base += 4;
/* binary search */
while ( min < max )
{
FT_UInt32 mid = ( min + max ) >> 1;
FT_Byte* p = base + 5 * mid;
FT_UInt32 uni = TT_NEXT_UINT24( p );
if ( char_code < uni )
max = mid;
else if ( char_code > uni )
min = mid + 1;
else
return TT_PEEK_USHORT( p );
}
return 0;
}
static FT_Byte*
tt_cmap14_find_variant( FT_Byte *base,
FT_UInt32 variantCode )
{
FT_UInt32 numVar = TT_PEEK_ULONG( base );
FT_UInt32 max, min;
min = 0;
max = numVar;
base += 4;
/* binary search */
while ( min < max )
{
FT_UInt32 mid = ( min + max ) >> 1;
FT_Byte* p = base + 11 * mid;
FT_ULong varSel = TT_NEXT_UINT24( p );
if ( variantCode < varSel )
max = mid;
else if ( variantCode > varSel )
min = mid + 1;
else
return p;
}
return NULL;
}
FT_CALLBACK_DEF( FT_UInt )
tt_cmap14_char_var_index( TT_CMap cmap,
TT_CMap ucmap,
FT_ULong charcode,
FT_ULong variantSelector)
{
FT_Byte* p = tt_cmap14_find_variant( cmap->data + 6, variantSelector );
FT_ULong defOff;
FT_ULong nondefOff;
if ( !p )
return 0;
defOff = TT_NEXT_ULONG( p );
nondefOff = TT_PEEK_ULONG( p );
if ( defOff != 0 &&
tt_cmap14_char_map_def_binary( cmap->data + defOff, charcode ) )
{
/* This is the default variant of this charcode. GID not stored */
/* here; stored in the normal Unicode charmap instead. */
return ucmap->cmap.clazz->char_index( &ucmap->cmap, charcode );
}
if ( nondefOff != 0 )
return tt_cmap14_char_map_nondef_binary( cmap->data + nondefOff,
charcode );
return 0;
}
FT_CALLBACK_DEF( FT_Int )
tt_cmap14_char_var_isdefault( TT_CMap cmap,
FT_ULong charcode,
FT_ULong variantSelector )
{
FT_Byte* p = tt_cmap14_find_variant( cmap->data + 6, variantSelector );
FT_ULong defOff;
FT_ULong nondefOff;
if ( !p )
return -1;
defOff = TT_NEXT_ULONG( p );
nondefOff = TT_NEXT_ULONG( p );
if ( defOff != 0 &&
tt_cmap14_char_map_def_binary( cmap->data + defOff, charcode ) )
return 1;
if ( nondefOff != 0 &&
tt_cmap14_char_map_nondef_binary( cmap->data + nondefOff,
charcode ) != 0 )
return 0;
return -1;
}
FT_CALLBACK_DEF( FT_UInt32* )
tt_cmap14_variants( TT_CMap cmap,
FT_Memory memory )
{
TT_CMap14 cmap14 = (TT_CMap14)cmap;
FT_UInt count = cmap14->num_selectors;
FT_Byte* p = cmap->data + 10;
FT_UInt32* result;
FT_UInt i;
if ( tt_cmap14_ensure( cmap14, ( count + 1 ), memory ) )
return NULL;
result = cmap14->results;
for ( i = 0; i < count; ++i )
{
result[i] = TT_NEXT_UINT24( p );
p += 8;
}
result[i] = 0;
return result;
}
FT_CALLBACK_DEF( FT_UInt32 * )
tt_cmap14_char_variants( TT_CMap cmap,
FT_Memory memory,
FT_ULong charCode )
{
TT_CMap14 cmap14 = (TT_CMap14) cmap;
FT_UInt count = cmap14->num_selectors;
FT_Byte* p = cmap->data + 10;
FT_UInt32* q;
if ( tt_cmap14_ensure( cmap14, ( count + 1 ), memory ) )
return NULL;
for ( q = cmap14->results; count > 0; --count )
{
FT_UInt32 varSel = TT_NEXT_UINT24( p );
FT_ULong defOff = TT_NEXT_ULONG( p );
FT_ULong nondefOff = TT_NEXT_ULONG( p );
if ( ( defOff != 0 &&
tt_cmap14_char_map_def_binary( cmap->data + defOff,
charCode ) ) ||
( nondefOff != 0 &&
tt_cmap14_char_map_nondef_binary( cmap->data + nondefOff,
charCode ) != 0 ) )
{
q[0] = varSel;
q++;
}
}
q[0] = 0;
return cmap14->results;
}
static FT_UInt
tt_cmap14_def_char_count( FT_Byte *p )
{
FT_UInt32 numRanges = TT_NEXT_ULONG( p );
FT_UInt tot = 0;
p += 3; /* point to the first 'cnt' field */
for ( ; numRanges > 0; numRanges-- )
{
tot += 1 + p[0];
p += 4;
}
return tot;
}
static FT_UInt32*
tt_cmap14_get_def_chars( TT_CMap cmap,
FT_Byte* p,
FT_Memory memory )
{
TT_CMap14 cmap14 = (TT_CMap14) cmap;
FT_UInt32 numRanges;
FT_UInt cnt;
FT_UInt32* q;
cnt = tt_cmap14_def_char_count( p );
numRanges = TT_NEXT_ULONG( p );
if ( tt_cmap14_ensure( cmap14, ( cnt + 1 ), memory ) )
return NULL;
for ( q = cmap14->results; numRanges > 0; --numRanges )
{
FT_UInt uni = TT_NEXT_UINT24( p );
cnt = FT_NEXT_BYTE( p ) + 1;
do
{
q[0] = uni;
uni += 1;
q += 1;
} while ( --cnt != 0 );
}
q[0] = 0;
return cmap14->results;
}
static FT_UInt*
tt_cmap14_get_nondef_chars( TT_CMap cmap,
FT_Byte *p,
FT_Memory memory )
{
TT_CMap14 cmap14 = (TT_CMap14) cmap;
FT_UInt32 numMappings;
FT_UInt i;
FT_UInt32 *ret;
numMappings = TT_NEXT_ULONG( p );
if ( tt_cmap14_ensure( cmap14, ( numMappings + 1 ), memory ) )
return NULL;
ret = cmap14->results;
for ( i = 0; i < numMappings; ++i )
{
ret[i] = TT_NEXT_UINT24( p );
p += 2;
}
ret[i] = 0;
return ret;
}
FT_CALLBACK_DEF( FT_UInt32 * )
tt_cmap14_variant_chars( TT_CMap cmap,
FT_Memory memory,
FT_ULong variantSelector )
{
FT_Byte *p = tt_cmap14_find_variant( cmap->data + 6,
variantSelector );
FT_UInt32 *ret;
FT_Int i;
FT_ULong defOff;
FT_ULong nondefOff;
if ( !p )
return NULL;
defOff = TT_NEXT_ULONG( p );
nondefOff = TT_NEXT_ULONG( p );
if ( defOff == 0 && nondefOff == 0 )
return NULL;
if ( defOff == 0 )
return tt_cmap14_get_nondef_chars( cmap, cmap->data + nondefOff,
memory );
else if ( nondefOff == 0 )
return tt_cmap14_get_def_chars( cmap, cmap->data + defOff,
memory );
else
{
/* Both a default and a non-default glyph set? That's probably not */
/* good font design, but the spec allows for it... */
TT_CMap14 cmap14 = (TT_CMap14) cmap;
FT_UInt32 numRanges;
FT_UInt32 numMappings;
FT_UInt32 duni;
FT_UInt32 dcnt;
FT_UInt32 nuni;
FT_Byte* dp;
FT_UInt di, ni, k;
p = cmap->data + nondefOff;
dp = cmap->data + defOff;
numMappings = TT_NEXT_ULONG( p );
dcnt = tt_cmap14_def_char_count( dp );
numRanges = TT_NEXT_ULONG( dp );
if ( numMappings == 0 )
return tt_cmap14_get_def_chars( cmap, cmap->data + defOff,
memory );
if ( dcnt == 0 )
return tt_cmap14_get_nondef_chars( cmap, cmap->data + nondefOff,
memory );
if ( tt_cmap14_ensure( cmap14, ( dcnt + numMappings + 1 ), memory ) )
return NULL;
ret = cmap14->results;
duni = TT_NEXT_UINT24( dp );
dcnt = FT_NEXT_BYTE( dp );
di = 1;
nuni = TT_NEXT_UINT24( p );
p += 2;
ni = 1;
i = 0;
for ( ;; )
{
if ( nuni > duni + dcnt )
{
for ( k = 0; k <= dcnt; ++k )
ret[i++] = duni + k;
++di;
if ( di > numRanges )
break;
duni = TT_NEXT_UINT24( dp );
dcnt = FT_NEXT_BYTE( dp );
}
else
{
if ( nuni < duni )
ret[i++] = nuni;
/* If it is within the default range then ignore it -- */
/* that should not have happened */
++ni;
if ( ni > numMappings )
break;
nuni = TT_NEXT_UINT24( p );
p += 2;
}
}
if ( ni <= numMappings )
{
/* If we get here then we have run out of all default ranges. */
/* We have read one non-default mapping which we haven't stored */
/* and there may be others that need to be read. */
ret[i++] = nuni;
while ( ni < numMappings )
{
ret[i++] = TT_NEXT_UINT24( p );
p += 2;
++ni;
}
}
else if ( di <= numRanges )
{
/* If we get here then we have run out of all non-default */
/* mappings. We have read one default range which we haven't */
/* stored and there may be others that need to be read. */
for ( k = 0; k <= dcnt; ++k )
ret[i++] = duni + k;
while ( di < numRanges )
{
duni = TT_NEXT_UINT24( dp );
dcnt = FT_NEXT_BYTE( dp );
for ( k = 0; k <= dcnt; ++k )
ret[i++] = duni + k;
++di;
}
}
ret[i] = 0;
return ret;
}
}
FT_CALLBACK_TABLE_DEF
const TT_CMap_ClassRec tt_cmap14_class_rec =
{
{
sizeof ( TT_CMap14Rec ),
(FT_CMap_InitFunc) tt_cmap14_init,
(FT_CMap_DoneFunc) tt_cmap14_done,
(FT_CMap_CharIndexFunc)tt_cmap14_char_index,
(FT_CMap_CharNextFunc) tt_cmap14_char_next,
/* Format 14 extension functions */
(FT_CMap_CharVarIndexFunc) tt_cmap14_char_var_index,
(FT_CMap_CharVarIsDefaultFunc)tt_cmap14_char_var_isdefault,
(FT_CMap_VariantListFunc) tt_cmap14_variants,
(FT_CMap_CharVariantListFunc) tt_cmap14_char_variants,
(FT_CMap_VariantCharListFunc) tt_cmap14_variant_chars
},
14,
(TT_CMap_ValidateFunc)tt_cmap14_validate,
(TT_CMap_Info_GetFunc)tt_cmap14_get_info
};
#endif /* TT_CONFIG_CMAP_FORMAT_0 */
static const TT_CMap_Class tt_cmap_classes[] =
{
#ifdef TT_CONFIG_CMAP_FORMAT_0
@ -2242,6 +2995,10 @@
&tt_cmap12_class_rec,
#endif
#ifdef TT_CONFIG_CMAP_FORMAT_14
&tt_cmap14_class_rec,
#endif
NULL,
};
@ -2318,6 +3075,10 @@
FT_CMap ttcmap;
/* It might make sense to store the single variation selector */
/* cmap somewhere special. But it would have to be in the */
/* public FT_FaceRec, and we can't change that. */
if ( !FT_CMap_New( (FT_CMap_Class)clazz,
cmap, &charmap, &ttcmap ) )
{
@ -2334,6 +3095,12 @@
break;
}
}
if ( *pclazz == NULL )
{
FT_ERROR(( "tt_face_build_cmaps:" ));
FT_ERROR(( " unsupported cmap sub-table ignored!\n" ));
}
}
}

View File

@ -5,7 +5,7 @@
/* Load the basic TrueType tables, i.e., tables that can be either in */
/* TTF or OTF fonts (body). */
/* */
/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006, 2007 by */
/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@ -618,6 +618,15 @@
if ( maxProfile->maxFunctionDefs == 0 )
maxProfile->maxFunctionDefs = 64;
/* we add 4 phantom points later */
if ( maxProfile->maxTwilightPoints > ( 0xFFFFU - 4 ) )
{
FT_ERROR(( "Too much twilight points in `maxp' table;\n" ));
FT_ERROR(( " some glyphs might be rendered incorrectly.\n" ));
maxProfile->maxTwilightPoints = 0xFFFFU - 4;
}
}
FT_TRACE3(( "numGlyphs: %u\n", maxProfile->numGlyphs ));

View File

@ -431,7 +431,8 @@
{
void* v = &face->vertical;
void* h = &face->horizontal;
TT_HoriHeader* header = vertical ? (TT_HoriHeader*)v : h;
TT_HoriHeader* header = vertical ? (TT_HoriHeader*)v
: (TT_HoriHeader*)h;
TT_LongMetrics longs_m;
FT_UShort k = header->number_Of_HMetrics;

View File

@ -382,8 +382,9 @@
break;
case 5:
error = Load_SBit_Const_Metrics( range, stream ) ||
Load_SBit_Range_Codes( range, stream, 0 );
error = Load_SBit_Const_Metrics( range, stream );
if ( !error )
error = Load_SBit_Range_Codes( range, stream, 0 );
break;
default:

View File

@ -5,7 +5,7 @@
/* TrueType and OpenType embedded bitmap support (body). */
/* This is a heap-optimized version. */
/* */
/* Copyright 2005, 2006, 2007 by */
/* Copyright 2005, 2006, 2007, 2008 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@ -207,7 +207,7 @@
}
typedef struct
typedef struct TT_SBitDecoderRec_
{
TT_Face face;
FT_Stream stream;

View File

@ -144,10 +144,10 @@
#include "ftsmerrs.h"
#define ErrRaster_Invalid_Mode Smooth_Err_Cannot_Render_Glyph
#define ErrRaster_Invalid_Outline Smooth_Err_Invalid_Outline
#define ErrRaster_Memory_Overflow Smooth_Err_Out_Of_Memory
#define ErrRaster_Invalid_Argument Smooth_Err_Bad_Argument
#define ErrRaster_Invalid_Mode Smooth_Err_Cannot_Render_Glyph
#define ErrRaster_Invalid_Outline Smooth_Err_Invalid_Outline
#define ErrRaster_Memory_Overflow Smooth_Err_Out_Of_Memory
#define ErrRaster_Invalid_Argument Smooth_Err_Bad_Argument
#endif /* !_STANDALONE_ */
@ -1659,7 +1659,7 @@
ras.count_ex = ras.max_ex - ras.min_ex;
ras.count_ey = ras.max_ey - ras.min_ey;
/* simple heuristic used to speed-up the bezier decomposition -- see */
/* simple heuristic used to speed up the bezier decomposition -- see */
/* the code in gray_render_conic() and gray_render_cubic() for more */
/* details */
ras.conic_level = 32;
@ -1796,11 +1796,14 @@
if ( !raster || !raster->buffer || !raster->buffer_size )
return ErrRaster_Invalid_Argument;
if ( !outline )
return ErrRaster_Invalid_Outline;
/* return immediately if the outline is empty */
if ( outline->n_points == 0 || outline->n_contours <= 0 )
return 0;
if ( !outline || !outline->contours || !outline->points )
if ( !outline->contours || !outline->points )
return ErrRaster_Invalid_Outline;
if ( outline->n_points !=
@ -1850,10 +1853,10 @@
gray_init_cells( worker, raster->buffer, raster->buffer_size );
ras.outline = *outline;
ras.num_cells = 0;
ras.invalid = 1;
ras.band_size = raster->band_size;
ras.outline = *outline;
ras.num_cells = 0;
ras.invalid = 1;
ras.band_size = raster->band_size;
ras.num_gray_spans = 0;
if ( target_map )

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