[FREETYPE] Update to v2.7.1. Patch by Katayama Hirofumi MZ, verified by me. CORE-12949

svn path=/trunk/; revision=74206
This commit is contained in:
Amine Khaldi
2017-03-19 17:53:42 +00:00
parent f7de731248
commit 2d7b980fca
136 changed files with 8028 additions and 2208 deletions
+1 -1
View File
@@ -23,7 +23,7 @@ Used Version: 1.1
Website: http://www.geocities.com/dborca/opengl/tc.html
Title: FreeType
Used Version: 2.7.0
Used Version: 2.7.1
Website: http://www.freetype.org
Title: Mesa3D
File diff suppressed because it is too large Load Diff
+5 -5
View File
@@ -1,5 +1,5 @@
FreeType 2.7
============
FreeType 2.7.1
==============
Homepage: http://www.freetype.org
@@ -24,9 +24,9 @@
and download one of the following files.
freetype-doc-2.7.tar.bz2
freetype-doc-2.7.tar.gz
ftdoc27.zip
freetype-doc-2.7.1.tar.bz2
freetype-doc-2.7.1.tar.gz
ftdoc271.zip
To view the documentation online, go to
@@ -143,6 +143,14 @@ FT_BEGIN_HEADER
#endif
/* Fix compiler warning with sgi compiler */
#if defined( __sgi ) && !defined( __GNUC__ )
#if defined( _COMPILER_VERSION ) && ( _COMPILER_VERSION >= 730 )
#pragma set woff 3505
#endif
#endif
/*************************************************************************/
/* */
/* <Section> */
@@ -338,10 +346,11 @@ FT_BEGIN_HEADER
/* typeof condition taken from gnulib's `intprops.h' header file */
#if ( __GNUC__ >= 2 || \
defined( __IBM__TYPEOF__ ) || \
( __SUNPRO_C >= 0x5110 && !__STDC__ ) )
#define FT_TYPEOF( type ) (__typeof__ (type))
#if ( ( defined( __GNUC__ ) && __GNUC__ >= 2 ) || \
( defined( __IBMC__ ) && __IBMC__ >= 1210 && \
defined( __IBM__TYPEOF__ ) ) || \
( defined( __SUNPRO_C ) && __SUNPRO_C >= 0x5110 && !__STDC__ ) )
#define FT_TYPEOF( type ) ( __typeof__ ( type ) )
#else
#define FT_TYPEOF( type ) /* empty */
#endif
@@ -951,6 +951,10 @@ FT_BEGIN_HEADER
/* strikes in the face. It is set to NULL if */
/* there is no bitmap strike. */
/* */
/* Note that FreeType tries to sanitize the */
/* strike data since they are sometimes sloppy */
/* or incorrect, but this can easily fail. */
/* */
/* num_charmaps :: The number of charmaps in the face. */
/* */
/* charmaps :: An array of the charmaps of the face. */
@@ -1727,7 +1731,6 @@ FT_BEGIN_HEADER
/* position (e.g., coordinates (0,0) on the baseline). Of course, */
/* `slot->format' is also changed to @FT_GLYPH_FORMAT_BITMAP. */
/* */
/* <Note> */
/* Here is a small pseudo code fragment that shows how to use */
/* `lsb_delta' and `rsb_delta': */
/* */
@@ -1755,6 +1758,12 @@ FT_BEGIN_HEADER
/* endfor */
/* } */
/* */
/* If you use strong auto-hinting, you *must* apply these delta */
/* values! Otherwise you will experience far too large inter-glyph */
/* spacing at small rendering sizes in most cases. Note that it */
/* doesn't harm to use the above code for other hinting modes also, */
/* since the delta values are zero then. */
/* */
typedef struct FT_GlyphSlotRec_
{
FT_Library library;
@@ -2322,7 +2331,10 @@ FT_BEGIN_HEADER
/* FT_Select_Size */
/* */
/* <Description> */
/* Select a bitmap strike. */
/* Select a bitmap strike. To be more precise, this function sets */
/* the scaling factors of the active @FT_Size object in a face so */
/* that bitmaps from this particular strike are taken by */
/* @FT_Load_Glyph and friends. */
/* */
/* <InOut> */
/* face :: A handle to a target face object. */
@@ -2334,6 +2346,20 @@ FT_BEGIN_HEADER
/* <Return> */
/* FreeType error code. 0~means success. */
/* */
/* <Note> */
/* For bitmaps embedded in outline fonts it is common that only a */
/* subset of the available glyphs at a given ppem value is available. */
/* FreeType silently uses outlines if there is no bitmap for a given */
/* glyph index. */
/* */
/* For GX variation fonts, a bitmap strike makes sense only if the */
/* default instance is active (this is, no glyph variation takes */
/* place); otherwise, FreeType simply ignores bitmap strikes. The */
/* same is true for all named instances that are different from the */
/* default instance. */
/* */
/* Don't use this function if you are using the FreeType cache API. */
/* */
FT_EXPORT( FT_Error )
FT_Select_Size( FT_Face face,
FT_Int strike_index );
@@ -2786,6 +2812,14 @@ FT_BEGIN_HEADER
*
* Currently, this flag is only implemented for TrueType fonts.
*
* FT_LOAD_BITMAP_METRICS_ONLY ::
* This flag is used to request loading of the metrics and bitmap
* image information of a (possibly embedded) bitmap glyph without
* allocating or copying the bitmap image data itself. No effect if
* the target glyph is not a bitmap image.
*
* This flag unsets @FT_LOAD_RENDER.
*
* FT_LOAD_CROP_BITMAP ::
* Ignored. Deprecated.
*
@@ -2832,6 +2866,7 @@ FT_BEGIN_HEADER
/* Bits 16..19 are used by `FT_LOAD_TARGET_' */
#define FT_LOAD_COLOR ( 1L << 20 )
#define FT_LOAD_COMPUTE_METRICS ( 1L << 21 )
#define FT_LOAD_BITMAP_METRICS_ONLY ( 1L << 22 )
/* */
@@ -4206,7 +4241,7 @@ FT_BEGIN_HEADER
*/
#define FREETYPE_MAJOR 2
#define FREETYPE_MINOR 7
#define FREETYPE_PATCH 0
#define FREETYPE_PATCH 1
/*************************************************************************/
@@ -1180,6 +1180,7 @@ 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;
+74 -1
View File
@@ -171,6 +171,7 @@ FT_BEGIN_HEADER
{
FT_Fixed* coords;
FT_UInt strid;
FT_UInt psid; /* since 2.7.1 */
} FT_Var_Named_Style;
@@ -334,6 +335,34 @@ FT_BEGIN_HEADER
FT_Fixed* coords );
/*************************************************************************/
/* */
/* <Function> */
/* FT_Get_Var_Design_Coordinates */
/* */
/* <Description> */
/* For Multiple Master and GX Var fonts, get the design coordinates */
/* of the currently selected interpolated font. */
/* */
/* <Input> */
/* face :: A handle to the source face. */
/* */
/* num_coords :: The number of design coordinates to retrieve. If it */
/* is larger than the number of axes, set the excess */
/* values to~0. */
/* */
/* <Output> */
/* coords :: The design coordinates array. */
/* */
/* <Return> */
/* FreeType error code. 0~means success. */
/* */
FT_EXPORT( FT_Error )
FT_Get_Var_Design_Coordinates( FT_Face face,
FT_UInt num_coords,
FT_Fixed* coords );
/*************************************************************************/
/* */
/* <Function> */
@@ -353,7 +382,8 @@ FT_BEGIN_HEADER
/* use default values for the remaining axes. */
/* */
/* coords :: The design coordinates array (each element must be */
/* between 0 and 1.0). */
/* between 0 and 1.0 for MM fonts, and between -1.0 and */
/* 1.0 for GX var fonts). */
/* */
/* <Return> */
/* FreeType error code. 0~means success. */
@@ -364,6 +394,35 @@ FT_BEGIN_HEADER
FT_Fixed* coords );
/*************************************************************************/
/* */
/* <Function> */
/* FT_Get_MM_Blend_Coordinates */
/* */
/* <Description> */
/* For Multiple Masters and GX var fonts, get the normalized blend */
/* coordinates of the currently selected interpolated font. */
/* */
/* <Input> */
/* face :: A handle to the source face. */
/* */
/* num_coords :: The number of normalized blend coordinates to */
/* retrieve. If it is larger than the number of axes, */
/* set the excess values to~0.5 for MM fonts, and to~0 */
/* for GX var fonts. */
/* */
/* <Output> */
/* coords :: The normalized blend coordinates array. */
/* */
/* <Return> */
/* FreeType error code. 0~means success. */
/* */
FT_EXPORT( FT_Error )
FT_Get_MM_Blend_Coordinates( FT_Face face,
FT_UInt num_coords,
FT_Fixed* coords );
/*************************************************************************/
/* */
/* <Function> */
@@ -377,6 +436,20 @@ FT_BEGIN_HEADER
FT_UInt num_coords,
FT_Fixed* coords );
/*************************************************************************/
/* */
/* <Function> */
/* FT_Get_Var_Blend_Coordinates */
/* */
/* <Description> */
/* This is another name of @FT_Get_MM_Blend_Coordinates. */
/* */
FT_EXPORT( FT_Error )
FT_Get_Var_Blend_Coordinates( FT_Face face,
FT_UInt num_coords,
FT_Fixed* coords );
/* */
@@ -75,6 +75,7 @@ FT_BEGIN_HEADER
{
FT_Long glyph_size;
FT_Glyph_Format glyph_format;
FT_Glyph_InitFunc glyph_init;
FT_Glyph_DoneFunc glyph_done;
FT_Glyph_CopyFunc glyph_copy;
@@ -193,6 +193,7 @@ FT_BEGIN_HEADER
typedef struct FT_CMap_ClassRec_
{
FT_ULong size;
FT_CMap_InitFunc init;
FT_CMap_DoneFunc done;
FT_CMap_CharIndexFunc char_index;
@@ -530,7 +531,8 @@ FT_BEGIN_HEADER
FT_BASE( FT_Pointer )
ft_module_get_service( FT_Module module,
const char* service_id );
const char* service_id,
FT_Bool global );
#ifdef FT_CONFIG_OPTION_ENVIRONMENT_PROPERTIES
FT_BASE( FT_Error )
@@ -874,7 +876,7 @@ FT_BEGIN_HEADER
#ifdef FT_CONFIG_OPTION_SUBPIXEL_RENDERING
FT_LcdFilter lcd_filter;
FT_Int lcd_extra; /* number of extra pixels */
FT_Byte lcd_weights[7]; /* filter weights, if any */
FT_Byte lcd_weights[5]; /* filter weights, if any */
FT_Bitmap_LcdFilterFunc lcd_filter_func; /* filtering callback */
#endif
@@ -43,11 +43,12 @@ FT_BEGIN_HEADER
typedef struct FT_RFork_Ref_
{
FT_UShort res_id;
FT_Long offset;
FT_Short res_id;
FT_Long offset;
} FT_RFork_Ref;
#ifdef FT_CONFIG_OPTION_GUESSING_EMBEDDED_RFORK
typedef FT_Error
(*ft_raccess_guess_func)( FT_Library library,
@@ -109,27 +109,27 @@ FT_BEGIN_HEADER
*/
#ifdef __cplusplus
#define FT_FACE_FIND_GLOBAL_SERVICE( face, ptr, id ) \
FT_BEGIN_STMNT \
FT_Module module = FT_MODULE( FT_FACE( face )->driver ); \
FT_Pointer _tmp_; \
FT_Pointer* _pptr_ = (FT_Pointer*)&(ptr); \
\
\
_tmp_ = ft_module_get_service( module, FT_SERVICE_ID_ ## id ); \
*_pptr_ = _tmp_; \
#define FT_FACE_FIND_GLOBAL_SERVICE( face, ptr, id ) \
FT_BEGIN_STMNT \
FT_Module module = FT_MODULE( FT_FACE( face )->driver ); \
FT_Pointer _tmp_; \
FT_Pointer* _pptr_ = (FT_Pointer*)&(ptr); \
\
\
_tmp_ = ft_module_get_service( module, FT_SERVICE_ID_ ## id, 1 ); \
*_pptr_ = _tmp_; \
FT_END_STMNT
#else /* !C++ */
#define FT_FACE_FIND_GLOBAL_SERVICE( face, ptr, id ) \
FT_BEGIN_STMNT \
FT_Module module = FT_MODULE( FT_FACE( face )->driver ); \
FT_Pointer _tmp_; \
\
\
_tmp_ = ft_module_get_service( module, FT_SERVICE_ID_ ## id ); \
ptr = _tmp_; \
#define FT_FACE_FIND_GLOBAL_SERVICE( face, ptr, id ) \
FT_BEGIN_STMNT \
FT_Module module = FT_MODULE( FT_FACE( face )->driver ); \
FT_Pointer _tmp_; \
\
\
_tmp_ = ft_module_get_service( module, FT_SERVICE_ID_ ## id, 1 ); \
ptr = _tmp_; \
FT_END_STMNT
#endif /* !C++ */
@@ -167,6 +167,7 @@ FT_BEGIN_HEADER
/* FT_DEFINE_SERVICEDESCREC5 */
/* FT_DEFINE_SERVICEDESCREC6 */
/* FT_DEFINE_SERVICEDESCREC7 */
/* FT_DEFINE_SERVICEDESCREC8 */
/* */
/* <Description> */
/* Used to initialize an array of FT_ServiceDescRec structures. */
@@ -283,6 +284,28 @@ FT_BEGIN_HEADER
{ NULL, NULL } \
};
#define FT_DEFINE_SERVICEDESCREC8( class_, \
serv_id_1, serv_data_1, \
serv_id_2, serv_data_2, \
serv_id_3, serv_data_3, \
serv_id_4, serv_data_4, \
serv_id_5, serv_data_5, \
serv_id_6, serv_data_6, \
serv_id_7, serv_data_7, \
serv_id_8, serv_data_8 ) \
static const FT_ServiceDescRec class_[] = \
{ \
{ serv_id_1, serv_data_1 }, \
{ serv_id_2, serv_data_2 }, \
{ serv_id_3, serv_data_3 }, \
{ serv_id_4, serv_data_4 }, \
{ serv_id_5, serv_data_5 }, \
{ serv_id_6, serv_data_6 }, \
{ serv_id_7, serv_data_7 }, \
{ serv_id_8, serv_data_8 }, \
{ NULL, NULL } \
};
#else /* FT_CONFIG_OPTION_PIC */
#define FT_DEFINE_SERVICEDESCREC1( class_, \
@@ -593,6 +616,62 @@ FT_BEGIN_HEADER
return FT_Err_Ok; \
}
#define FT_DEFINE_SERVICEDESCREC8( class_, \
serv_id_1, serv_data_1, \
serv_id_2, serv_data_2, \
serv_id_3, serv_data_3, \
serv_id_4, serv_data_4, \
serv_id_5, serv_data_5, \
serv_id_6, serv_data_6, \
serv_id_7, serv_data_7, \
serv_id_8, serv_data_8 ) \
void \
FT_Destroy_Class_ ## class_( FT_Library library, \
FT_ServiceDescRec* clazz ) \
{ \
FT_Memory memory = library->memory; \
\
\
if ( clazz ) \
FT_FREE( clazz ); \
} \
\
FT_Error \
FT_Create_Class_ ## class_( FT_Library library, \
FT_ServiceDescRec** output_class) \
{ \
FT_ServiceDescRec* clazz = NULL; \
FT_Error error; \
FT_Memory memory = library->memory; \
\
\
if ( FT_ALLOC( clazz, sizeof ( *clazz ) * 9 ) ) \
return error; \
\
clazz[0].serv_id = serv_id_1; \
clazz[0].serv_data = serv_data_1; \
clazz[1].serv_id = serv_id_2; \
clazz[1].serv_data = serv_data_2; \
clazz[2].serv_id = serv_id_3; \
clazz[2].serv_data = serv_data_3; \
clazz[3].serv_id = serv_id_4; \
clazz[3].serv_data = serv_data_4; \
clazz[4].serv_id = serv_id_5; \
clazz[4].serv_data = serv_data_5; \
clazz[5].serv_id = serv_id_6; \
clazz[5].serv_data = serv_data_6; \
clazz[6].serv_id = serv_id_7; \
clazz[6].serv_data = serv_data_7; \
clazz[7].serv_id = serv_id_8; \
clazz[7].serv_data = serv_data_8; \
clazz[8].serv_id = NULL; \
clazz[8].serv_data = NULL; \
\
*output_class = clazz; \
\
return FT_Err_Ok; \
}
#endif /* FT_CONFIG_OPTION_PIC */
@@ -739,6 +818,7 @@ FT_BEGIN_HEADER
#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>
#define FT_SERVICE_METRICS_VARIATIONS_H <freetype/internal/services/svmetric.h>
#define FT_SERVICE_MULTIPLE_MASTERS_H <freetype/internal/services/svmm.h>
#define FT_SERVICE_OPENTYPE_VALIDATE_H <freetype/internal/services/svotval.h>
#define FT_SERVICE_PFR_H <freetype/internal/services/svpfr.h>
@@ -0,0 +1,155 @@
/***************************************************************************/
/* */
/* svmetric.h */
/* */
/* The FreeType services for metrics variations (specification). */
/* */
/* Copyright 2016 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* 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 SVMETRIC_H_
#define SVMETRIC_H_
#include FT_INTERNAL_SERVICE_H
FT_BEGIN_HEADER
/*
* A service to manage the `HVAR, `MVAR', and `VVAR' OpenType tables.
*
*/
#define FT_SERVICE_ID_METRICS_VARIATIONS "metrics-variations"
/* HVAR */
typedef FT_Error
(*FT_HAdvance_Adjust_Func)( FT_Face face,
FT_UInt gindex,
FT_Int *avalue );
typedef FT_Error
(*FT_LSB_Adjust_Func)( FT_Face face,
FT_UInt gindex,
FT_Int *avalue );
typedef FT_Error
(*FT_RSB_Adjust_Func)( FT_Face face,
FT_UInt gindex,
FT_Int *avalue );
/* VVAR */
typedef FT_Error
(*FT_VAdvance_Adjust_Func)( FT_Face face,
FT_UInt gindex,
FT_Int *avalue );
typedef FT_Error
(*FT_TSB_Adjust_Func)( FT_Face face,
FT_UInt gindex,
FT_Int *avalue );
typedef FT_Error
(*FT_BSB_Adjust_Func)( FT_Face face,
FT_UInt gindex,
FT_Int *avalue );
typedef FT_Error
(*FT_VOrg_Adjust_Func)( FT_Face face,
FT_UInt gindex,
FT_Int *avalue );
/* MVAR */
typedef FT_Error
(*FT_Metrics_Adjust_Func)( FT_Face face,
FT_ULong tag,
FT_Int *avalue );
FT_DEFINE_SERVICE( MetricsVariations )
{
FT_HAdvance_Adjust_Func hadvance_adjust;
FT_LSB_Adjust_Func lsb_adjust;
FT_RSB_Adjust_Func rsb_adjust;
FT_VAdvance_Adjust_Func vadvance_adjust;
FT_TSB_Adjust_Func tsb_adjust;
FT_BSB_Adjust_Func bsb_adjust;
FT_VOrg_Adjust_Func vorg_adjust;
FT_Metrics_Adjust_Func metrics_adjust;
};
#ifndef FT_CONFIG_OPTION_PIC
#define FT_DEFINE_SERVICE_METRICSVARIATIONSREC( class_, \
hadvance_adjust_, \
lsb_adjust_, \
rsb_adjust_, \
vadvance_adjust_, \
tsb_adjust_, \
bsb_adjust_, \
vorg_adjust_, \
metrics_adjust_ ) \
static const FT_Service_MetricsVariationsRec class_ = \
{ \
hadvance_adjust_, \
lsb_adjust_, \
rsb_adjust_, \
vadvance_adjust_, \
tsb_adjust_, \
bsb_adjust_, \
vorg_adjust_, \
metrics_adjust_ \
};
#else /* FT_CONFIG_OPTION_PIC */
#define FT_DEFINE_SERVICE_METRICSVARIATIONSREC( class_, \
hadvance_adjust_, \
lsb_adjust_, \
rsb_adjust_, \
vadvance_adjust_, \
tsb_adjust_, \
bsb_adjust_, \
vorg_adjust_, \
metrics_adjust_ ) \
void \
FT_Init_Class_ ## class_( FT_Service_MetricsVariationsRec* clazz ) \
{ \
clazz->hadvance_adjust = hadvance_adjust_; \
clazz->lsb_adjust = lsb_adjust_; \
clazz->rsb_adjust = rsb_adjust_; \
clazz->vadvance_adjust = vadvance_adjust_; \
clazz->tsb_adjust = tsb_adjust_; \
clazz->bsb_adjust = bsb_adjust_; \
clazz->vorg_adjust = vorg_adjust_; \
clazz->metrics_adjust = metrics_adjust_; \
};
#endif /* FT_CONFIG_OPTION_PIC */
/* */
FT_END_HEADER
#endif /* SVMETRIC_H_ */
/* END */
@@ -58,46 +58,91 @@ FT_BEGIN_HEADER
FT_UInt num_coords,
FT_Long* coords );
typedef FT_Error
(*FT_Get_Var_Design_Func)( FT_Face face,
FT_UInt num_coords,
FT_Fixed* coords );
typedef FT_Error
(*FT_Get_MM_Blend_Func)( FT_Face face,
FT_UInt num_coords,
FT_Long* coords );
typedef FT_Error
(*FT_Get_Var_Blend_Func)( FT_Face face,
FT_UInt *num_coords,
FT_Fixed* *coords,
FT_MM_Var* *mm_var );
typedef void
(*FT_Done_Blend_Func)( FT_Face );
FT_DEFINE_SERVICE( MultiMasters )
{
FT_Get_MM_Func get_mm;
FT_Set_MM_Design_Func set_mm_design;
FT_Set_MM_Blend_Func set_mm_blend;
FT_Get_MM_Blend_Func get_mm_blend;
FT_Get_MM_Var_Func get_mm_var;
FT_Set_Var_Design_Func set_var_design;
FT_Get_Var_Design_Func get_var_design;
/* for internal use; only needed for code sharing between modules */
FT_Get_Var_Blend_Func get_var_blend;
FT_Done_Blend_Func done_blend;
};
#ifndef FT_CONFIG_OPTION_PIC
#define FT_DEFINE_SERVICE_MULTIMASTERSREC( class_, \
get_mm_, \
set_mm_design_, \
set_mm_blend_, \
get_mm_var_, \
set_var_design_ ) \
static const FT_Service_MultiMastersRec class_ = \
{ \
get_mm_, set_mm_design_, set_mm_blend_, get_mm_var_, set_var_design_ \
#define FT_DEFINE_SERVICE_MULTIMASTERSREC( class_, \
get_mm_, \
set_mm_design_, \
set_mm_blend_, \
get_mm_blend_, \
get_mm_var_, \
set_var_design_, \
get_var_design_, \
get_var_blend_, \
done_blend_ ) \
static const FT_Service_MultiMastersRec class_ = \
{ \
get_mm_, \
set_mm_design_, \
set_mm_blend_, \
get_mm_blend_, \
get_mm_var_, \
set_var_design_, \
get_var_design_, \
get_var_blend_, \
done_blend_ \
};
#else /* FT_CONFIG_OPTION_PIC */
#define FT_DEFINE_SERVICE_MULTIMASTERSREC( class_, \
get_mm_, \
set_mm_design_, \
set_mm_blend_, \
get_mm_var_, \
set_var_design_ ) \
void \
FT_Init_Class_ ## class_( FT_Service_MultiMastersRec* clazz ) \
{ \
clazz->get_mm = get_mm_; \
clazz->set_mm_design = set_mm_design_; \
clazz->set_mm_blend = set_mm_blend_; \
clazz->get_mm_var = get_mm_var_; \
clazz->set_var_design = set_var_design_; \
#define FT_DEFINE_SERVICE_MULTIMASTERSREC( class_, \
get_mm_, \
set_mm_design_, \
set_mm_blend_, \
get_mm_blend_, \
get_mm_var_, \
set_var_design_, \
get_var_design_, \
get_var_blend_, \
done_blend_ ) \
void \
FT_Init_Class_ ## class_( FT_Service_MultiMastersRec* clazz ) \
{ \
clazz->get_mm = get_mm_; \
clazz->set_mm_design = set_mm_design_; \
clazz->set_mm_blend = set_mm_blend_; \
clazz->get_mm_blend = get_mm_blend_; \
clazz->get_mm_var = get_mm_var_; \
clazz->set_var_design = set_var_design_; \
clazz->get_var_design = get_var_design_; \
clazz->get_var_blend = get_var_blend_; \
clazz->done_blend = done_blend_; \
}
#endif /* FT_CONFIG_OPTION_PIC */
@@ -1060,6 +1060,75 @@ FT_BEGIN_HEADER
} TT_SbitTableType;
/* OpenType 1.8 brings new tables for variation font support; */
/* to make the old MM and GX fonts still work we need to check */
/* the presence (and validity) of the functionality provided */
/* by those tables. The following flag macros are for the */
/* field `variation_support'. */
/* */
/* Note that `fvar' gets checked immediately at font loading, */
/* while the other features are only loaded if MM support is */
/* actually requested. */
/* FVAR */
#define TT_FACE_FLAG_VAR_FVAR ( 1 << 0 )
/* HVAR */
#define TT_FACE_FLAG_VAR_HADVANCE ( 1 << 1 )
#define TT_FACE_FLAG_VAR_LSB ( 1 << 2 )
#define TT_FACE_FLAG_VAR_RSB ( 1 << 3 )
/* VVAR */
#define TT_FACE_FLAG_VAR_VADVANCE ( 1 << 4 )
#define TT_FACE_FLAG_VAR_TSB ( 1 << 5 )
#define TT_FACE_FLAG_VAR_BSB ( 1 << 6 )
#define TT_FACE_FLAG_VAR_VORG ( 1 << 7 )
/* MVAR gasp data */
#define TT_FACE_FLAG_VAR_GASP_0 ( 1 << 20 )
#define TT_FACE_FLAG_VAR_GASP_1 ( 1 << 21 )
#define TT_FACE_FLAG_VAR_GASP_2 ( 1 << 22 )
#define TT_FACE_FLAG_VAR_GASP_3 ( 1 << 23 )
#define TT_FACE_FLAG_VAR_GASP_4 ( 1 << 24 )
#define TT_FACE_FLAG_VAR_GASP_5 ( 1 << 25 )
#define TT_FACE_FLAG_VAR_GASP_6 ( 1 << 26 )
#define TT_FACE_FLAG_VAR_GASP_7 ( 1 << 27 )
#define TT_FACE_FLAG_VAR_GASP_8 ( 1 << 28 )
#define TT_FACE_FLAG_VAR_GASP_9 ( 1 << 29 )
/* The following flag macros are for the field `mvar_support'. */
/* remaining MVAR data */
#define TT_FACE_FLAG_VAR_CPHT ( 1 << 0 )
#define TT_FACE_FLAG_VAR_HASC ( 1 << 1 )
#define TT_FACE_FLAG_VAR_HCLA ( 1 << 2 )
#define TT_FACE_FLAG_VAR_HCLD ( 1 << 3 )
#define TT_FACE_FLAG_VAR_HCOF ( 1 << 4 )
#define TT_FACE_FLAG_VAR_HCRN ( 1 << 5 )
#define TT_FACE_FLAG_VAR_HCRS ( 1 << 6 )
#define TT_FACE_FLAG_VAR_HDSC ( 1 << 7 )
#define TT_FACE_FLAG_VAR_HLGP ( 1 << 8 )
#define TT_FACE_FLAG_VAR_SBXO ( 1 << 9 )
#define TT_FACE_FLAG_VAR_SBXS ( 1 << 10 )
#define TT_FACE_FLAG_VAR_SBYO ( 1 << 11 )
#define TT_FACE_FLAG_VAR_SBYS ( 1 << 12 )
#define TT_FACE_FLAG_VAR_SPXO ( 1 << 13 )
#define TT_FACE_FLAG_VAR_SPXS ( 1 << 14 )
#define TT_FACE_FLAG_VAR_SPYO ( 1 << 15 )
#define TT_FACE_FLAG_VAR_SPYS ( 1 << 16 )
#define TT_FACE_FLAG_VAR_STRO ( 1 << 17 )
#define TT_FACE_FLAG_VAR_STRS ( 1 << 18 )
#define TT_FACE_FLAG_VAR_UNDO ( 1 << 19 )
#define TT_FACE_FLAG_VAR_UNDS ( 1 << 20 )
#define TT_FACE_FLAG_VAR_VASC ( 1 << 21 )
#define TT_FACE_FLAG_VAR_VCOF ( 1 << 22 )
#define TT_FACE_FLAG_VAR_VCRN ( 1 << 23 )
#define TT_FACE_FLAG_VAR_VCRS ( 1 << 24 )
#define TT_FACE_FLAG_VAR_VDSC ( 1 << 25 )
#define TT_FACE_FLAG_VAR_VLGP ( 1 << 26 )
#define TT_FACE_FLAG_VAR_XHGT ( 1 << 27 )
/*************************************************************************/
/* */
/* TrueType Face Type */
@@ -1161,6 +1230,11 @@ FT_BEGIN_HEADER
/* */
/* psnames :: A pointer to the PostScript names service. */
/* */
/* mm :: A pointer to the Multiple Masters service. */
/* */
/* var :: A pointer to the Metrics Variations */
/* service. */
/* */
/* hdmx :: The face's horizontal device metrics */
/* (`hdmx' table). This table is optional in */
/* TrueType/OpenType fonts. */
@@ -1182,18 +1256,6 @@ FT_BEGIN_HEADER
/* file `ttconfig.h' for comments on the */
/* TT_CONFIG_OPTION_POSTSCRIPT_NAMES option. */
/* */
/* num_locations :: The number of glyph locations in this */
/* TrueType file. This should be */
/* identical to the number of glyphs. */
/* Ignored for Type 2 fonts. */
/* */
/* glyph_locations :: An array of longs. These are offsets to */
/* glyph data within the `glyf' table. */
/* Ignored for Type 2 font faces. */
/* */
/* glyf_len :: The length of the `glyf' table. Needed */
/* for malformed `loca' tables. */
/* */
/* font_program_size :: Size in bytecodes of the face's font */
/* program. 0 if none defined. Ignored for */
/* Type 2 fonts. */
@@ -1219,20 +1281,20 @@ FT_BEGIN_HEADER
/* units. Comes from the `cvt ' table. */
/* Ignored for Type 2 fonts. */
/* */
/* num_kern_pairs :: The number of kerning pairs present in the */
/* font file. The engine only loads the */
/* first horizontal format 0 kern table it */
/* finds in the font file. Ignored for */
/* Type 2 fonts. */
/* */
/* kern_table_index :: The index of the kerning table in the font */
/* kerning directory. Ignored for Type 2 */
/* fonts. */
/* */
/* interpreter :: A pointer to the TrueType bytecode */
/* interpreters field is also used to hook */
/* the debugger in `ttdebug'. */
/* */
/* extra :: Reserved for third-party font drivers. */
/* */
/* postscript_name :: The PS name of the font. Used by the */
/* postscript name service. */
/* */
/* glyf_len :: The length of the `glyf' table. Needed */
/* for malformed `loca' tables. */
/* */
/* glyf_offset :: The file offset of the `glyf' table. */
/* */
/* doblend :: A boolean which is set if the font should */
/* be blended (this is for GX var). */
/* */
@@ -1240,10 +1302,92 @@ FT_BEGIN_HEADER
/* variation tables (rather like Multiple */
/* Master data). */
/* */
/* extra :: Reserved for third-party font drivers. */
/* is_default_instance :: Set if the glyph outlines can be used */
/* unmodified (i.e., without applying glyph */
/* variation deltas). */
/* */
/* postscript_name :: The PS name of the font. Used by the */
/* postscript name service. */
/* variation_support :: Flags that indicate which OpenType */
/* functionality related to font variation */
/* support is present, valid, and usable. */
/* For example, TT_FACE_FLAG_VAR_FVAR is only */
/* set if we have at least one design axis. */
/* */
/* mvar_support :: Flags that indicate which metrics */
/* variations are supported. */
/* */
/* horz_metrics_size :: The size of the `hmtx' table. */
/* */
/* vert_metrics_size :: The size of the `vmtx' table. */
/* */
/* num_locations :: The number of glyph locations in this */
/* TrueType file. This should be */
/* identical to the number of glyphs. */
/* Ignored for Type 2 fonts. */
/* */
/* glyph_locations :: An array of longs. These are offsets to */
/* glyph data within the `glyf' table. */
/* Ignored for Type 2 font faces. */
/* */
/* hdmx_table :: A pointer to the `hdmx' table. */
/* */
/* hdmx_table_size :: The size of the `hdmx' table. */
/* */
/* hdmx_record_count :: The number of hdmx records. */
/* */
/* hdmx_record_size :: The size of a single hdmx record. */
/* */
/* hdmx_record_sizes :: An array holding the ppem sizes available */
/* in the `hdmx' table. */
/* */
/* sbit_table :: A pointer to the font's embedded bitmap */
/* location table. */
/* */
/* sbit_table_size :: The size of `sbit_table'. */
/* */
/* sbit_table_type :: The sbit table type (CBLC, SBIX, etc.). */
/* */
/* sbit_num_strikes :: The number of sbit strikes exposed by */
/* FreeType's API, omitting invalid strikes. */
/* */
/* sbit_strike_map :: A mapping between the strike indices */
/* exposed by the API and the indices used in */
/* the font's sbit table. */
/* */
/* kern_table :: A pointer to the `kern' table. */
/* */
/* kern_table_size :: The size of the `kern' table. */
/* */
/* num_kern_tables :: The number of supported kern subtables */
/* (up to 32; FreeType recognizes only */
/* horizontal ones with format 0). */
/* */
/* kern_avail_bits :: The availability status of kern subtables; */
/* if bit n is set, table n is available. */
/* */
/* kern_order_bits :: The sortedness status of kern subtables; */
/* if bit n is set, table n is sorted. */
/* */
/* bdf :: Data related to an SFNT font's `bdf' */
/* table; see `tttypes.h'. */
/* */
/* horz_metrics_offset :: The file offset of the `hmtx' table. */
/* */
/* vert_metrics_offset :: The file offset of the `vmtx' table. */
/* */
/* sph_found_func_flags :: Flags identifying special bytecode */
/* functions (used by the v38 implementation */
/* of the bytecode interpreter). */
/* */
/* sph_compatibility_mode :: */
/* This flag is set if we are in ClearType */
/* backwards compatibility mode (used by the */
/* v38 implementation of the bytecode */
/* interpreter). */
/* */
/* ebdt_start :: The file offset of the sbit data table */
/* (CBDT, bdat, etc.). */
/* */
/* ebdt_size :: The size of the sbit data table. */
/* */
typedef struct TT_FaceRec_
{
@@ -1288,6 +1432,16 @@ FT_BEGIN_HEADER
/* handle glyph names <-> unicode & Mac values */
void* psnames;
#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
/* a typeless pointer to the FT_Service_MultiMasters table used to */
/* handle variation fonts */
void* mm;
/* a typeless pointer to the FT_Service_MetricsVariationsRec table */
/* used to handle the HVAR, VVAR, and MVAR OpenType tables */
void* var;
#endif
/***********************************************************************/
/* */
@@ -1344,18 +1498,22 @@ FT_BEGIN_HEADER
const char* postscript_name;
FT_ULong glyf_len;
FT_ULong glyf_offset; /* since 2.7.1 */
FT_Bool isCFF2; /* since 2.7.1 */
#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
FT_Bool doblend;
GX_Blend blend;
FT_Bool is_default_instance; /* since 2.7.1 */
FT_UInt32 variation_support; /* since 2.7.1 */
FT_UInt32 mvar_support; /* since 2.7.1 */
#endif
/* since version 2.2 */
FT_Byte* horz_metrics;
FT_ULong horz_metrics_size;
FT_Byte* vert_metrics;
FT_ULong vert_metrics_size;
FT_ULong num_locations; /* in broken TTF, gid > 0xFFFF */
@@ -1371,6 +1529,7 @@ FT_BEGIN_HEADER
FT_ULong sbit_table_size;
TT_SbitTableType sbit_table_type;
FT_UInt sbit_num_strikes;
FT_UInt* sbit_strike_map;
FT_Byte* kern_table;
FT_ULong kern_table_size;
@@ -1491,8 +1650,6 @@ FT_BEGIN_HEADER
FT_Vector pp1;
FT_Vector pp2;
FT_ULong glyf_offset;
/* the zone where we load our glyphs */
TT_GlyphZoneRec base;
TT_GlyphZoneRec zone;
@@ -43,6 +43,7 @@ FT_BEGIN_HEADER
#define TTAG_CBDT FT_MAKE_TAG( 'C', 'B', 'D', 'T' )
#define TTAG_CBLC FT_MAKE_TAG( 'C', 'B', 'L', 'C' )
#define TTAG_CFF FT_MAKE_TAG( 'C', 'F', 'F', ' ' )
#define TTAG_CFF2 FT_MAKE_TAG( 'C', 'F', 'F', '2' )
#define TTAG_CID FT_MAKE_TAG( 'C', 'I', 'D', ' ' )
#define TTAG_cmap FT_MAKE_TAG( 'c', 'm', 'a', 'p' )
#define TTAG_cvar FT_MAKE_TAG( 'c', 'v', 'a', 'r' )
@@ -61,6 +62,7 @@ FT_BEGIN_HEADER
#define TTAG_GPOS FT_MAKE_TAG( 'G', 'P', 'O', 'S' )
#define TTAG_GSUB FT_MAKE_TAG( 'G', 'S', 'U', 'B' )
#define TTAG_gvar FT_MAKE_TAG( 'g', 'v', 'a', 'r' )
#define TTAG_HVAR FT_MAKE_TAG( 'H', 'V', 'A', 'R' )
#define TTAG_hdmx FT_MAKE_TAG( 'h', 'd', 'm', 'x' )
#define TTAG_head FT_MAKE_TAG( 'h', 'e', 'a', 'd' )
#define TTAG_hhea FT_MAKE_TAG( 'h', 'h', 'e', 'a' )
@@ -79,6 +81,7 @@ FT_BEGIN_HEADER
#define TTAG_MMSD FT_MAKE_TAG( 'M', 'M', 'S', 'D' )
#define TTAG_mort FT_MAKE_TAG( 'm', 'o', 'r', 't' )
#define TTAG_morx FT_MAKE_TAG( 'm', 'o', 'r', 'x' )
#define TTAG_MVAR FT_MAKE_TAG( 'M', 'V', 'A', 'R' )
#define TTAG_name FT_MAKE_TAG( 'n', 'a', 'm', 'e' )
#define TTAG_opbd FT_MAKE_TAG( 'o', 'p', 'b', 'd' )
#define TTAG_OS2 FT_MAKE_TAG( 'O', 'S', '/', '2' )
@@ -100,6 +103,7 @@ FT_BEGIN_HEADER
#define TTAG_VDMX FT_MAKE_TAG( 'V', 'D', 'M', 'X' )
#define TTAG_vhea FT_MAKE_TAG( 'v', 'h', 'e', 'a' )
#define TTAG_vmtx FT_MAKE_TAG( 'v', 'm', 't', 'x' )
#define TTAG_VVAR FT_MAKE_TAG( 'V', 'V', 'A', 'R' )
#define TTAG_wOFF FT_MAKE_TAG( 'w', 'O', 'F', 'F' )
+12 -12
View File
@@ -2366,13 +2366,13 @@
sizeof ( AF_CJKMetricsRec ),
(AF_WritingSystem_InitMetricsFunc) af_cjk_metrics_init,
(AF_WritingSystem_ScaleMetricsFunc)af_cjk_metrics_scale,
(AF_WritingSystem_DoneMetricsFunc) NULL,
(AF_WritingSystem_GetStdWidthsFunc)af_cjk_get_standard_widths,
(AF_WritingSystem_InitMetricsFunc) af_cjk_metrics_init, /* style_metrics_init */
(AF_WritingSystem_ScaleMetricsFunc)af_cjk_metrics_scale, /* style_metrics_scale */
(AF_WritingSystem_DoneMetricsFunc) NULL, /* style_metrics_done */
(AF_WritingSystem_GetStdWidthsFunc)af_cjk_get_standard_widths, /* style_metrics_getstdw */
(AF_WritingSystem_InitHintsFunc) af_cjk_hints_init,
(AF_WritingSystem_ApplyHintsFunc) af_cjk_hints_apply
(AF_WritingSystem_InitHintsFunc) af_cjk_hints_init, /* style_hints_init */
(AF_WritingSystem_ApplyHintsFunc) af_cjk_hints_apply /* style_hints_apply */
)
@@ -2386,13 +2386,13 @@
sizeof ( AF_CJKMetricsRec ),
(AF_WritingSystem_InitMetricsFunc) NULL,
(AF_WritingSystem_ScaleMetricsFunc)NULL,
(AF_WritingSystem_DoneMetricsFunc) NULL,
(AF_WritingSystem_GetStdWidthsFunc)NULL,
(AF_WritingSystem_InitMetricsFunc) NULL, /* style_metrics_init */
(AF_WritingSystem_ScaleMetricsFunc)NULL, /* style_metrics_scale */
(AF_WritingSystem_DoneMetricsFunc) NULL, /* style_metrics_done */
(AF_WritingSystem_GetStdWidthsFunc)NULL, /* style_metrics_getstdw */
(AF_WritingSystem_InitHintsFunc) NULL,
(AF_WritingSystem_ApplyHintsFunc) NULL
(AF_WritingSystem_InitHintsFunc) NULL, /* style_hints_init */
(AF_WritingSystem_ApplyHintsFunc) NULL /* style_hints_apply */
)
+6 -6
View File
@@ -62,13 +62,13 @@
sizeof ( AF_StyleMetricsRec ),
(AF_WritingSystem_InitMetricsFunc) NULL,
(AF_WritingSystem_ScaleMetricsFunc)NULL,
(AF_WritingSystem_DoneMetricsFunc) NULL,
(AF_WritingSystem_GetStdWidthsFunc)NULL,
(AF_WritingSystem_InitMetricsFunc) NULL, /* style_metrics_init */
(AF_WritingSystem_ScaleMetricsFunc)NULL, /* style_metrics_scale */
(AF_WritingSystem_DoneMetricsFunc) NULL, /* style_metrics_done */
(AF_WritingSystem_GetStdWidthsFunc)NULL, /* style_metrics_getstdw */
(AF_WritingSystem_InitHintsFunc) af_dummy_hints_init,
(AF_WritingSystem_ApplyHintsFunc) af_dummy_hints_apply
(AF_WritingSystem_InitHintsFunc) af_dummy_hints_init, /* style_hints_init */
(AF_WritingSystem_ApplyHintsFunc) af_dummy_hints_apply /* style_hints_apply */
)
+4 -13
View File
@@ -168,7 +168,7 @@
AF_Script_UniRange range;
if ( script_class->script_uni_ranges == NULL )
if ( !script_class->script_uni_ranges )
continue;
/*
@@ -417,17 +417,8 @@
globals->hb_buf = NULL;
#endif
globals->glyph_count = 0;
globals->stem_darkening_for_ppem = 0;
globals->darken_x = 0;
globals->darken_y = 0;
globals->standard_vertical_width = 0;
globals->standard_horizontal_width = 0;
globals->scale_down_factor = 0;
/* no need to free this one! */
globals->glyph_styles = NULL;
globals->face = NULL;
/* no need to free `globals->glyph_styles'; */
/* it is part of the `globals' array */
FT_FREE( globals );
}
}
@@ -465,7 +456,7 @@
[style_class->writing_system];
metrics = globals->metrics[style];
if ( metrics == NULL )
if ( !metrics )
{
/* create the global metrics object if necessary */
FT_Memory memory = globals->face->memory;
+6 -6
View File
@@ -45,7 +45,7 @@
if ( axis->num_segments < AF_SEGMENTS_EMBEDDED )
{
if ( axis->segments == NULL )
if ( !axis->segments )
{
axis->segments = axis->embedded.segments;
axis->max_segments = AF_SEGMENTS_EMBEDDED;
@@ -110,7 +110,7 @@
if ( axis->num_edges < AF_EDGES_EMBEDDED )
{
if ( axis->edges == NULL )
if ( !axis->edges )
{
axis->edges = axis->embedded.edges;
axis->max_edges = AF_EDGES_EMBEDDED;
@@ -743,7 +743,7 @@
if ( new_max <= AF_CONTOURS_EMBEDDED )
{
if ( hints->contours == NULL )
if ( !hints->contours )
{
hints->contours = hints->embedded.contours;
hints->max_contours = AF_CONTOURS_EMBEDDED;
@@ -772,7 +772,7 @@
if ( new_max <= AF_POINTS_EMBEDDED )
{
if ( hints->points == NULL )
if ( !hints->points )
{
hints->points = hints->embedded.points;
hints->max_points = AF_POINTS_EMBEDDED;
@@ -1182,7 +1182,7 @@
AF_Point point, first, last;
if ( edge == NULL )
if ( !edge )
continue;
first = seg->first;
@@ -1208,7 +1208,7 @@
AF_Point point, first, last;
if ( edge == NULL )
if ( !edge )
continue;
first = seg->first;
+12 -12
View File
@@ -121,13 +121,13 @@
sizeof ( AF_CJKMetricsRec ),
(AF_WritingSystem_InitMetricsFunc) af_indic_metrics_init,
(AF_WritingSystem_ScaleMetricsFunc)af_indic_metrics_scale,
(AF_WritingSystem_DoneMetricsFunc) NULL,
(AF_WritingSystem_GetStdWidthsFunc)af_indic_get_standard_widths,
(AF_WritingSystem_InitMetricsFunc) af_indic_metrics_init, /* style_metrics_init */
(AF_WritingSystem_ScaleMetricsFunc)af_indic_metrics_scale, /* style_metrics_scale */
(AF_WritingSystem_DoneMetricsFunc) NULL, /* style_metrics_done */
(AF_WritingSystem_GetStdWidthsFunc)af_indic_get_standard_widths, /* style_metrics_getstdw */
(AF_WritingSystem_InitHintsFunc) af_indic_hints_init,
(AF_WritingSystem_ApplyHintsFunc) af_indic_hints_apply
(AF_WritingSystem_InitHintsFunc) af_indic_hints_init, /* style_hints_init */
(AF_WritingSystem_ApplyHintsFunc) af_indic_hints_apply /* style_hints_apply */
)
@@ -141,13 +141,13 @@
sizeof ( AF_CJKMetricsRec ),
(AF_WritingSystem_InitMetricsFunc) NULL,
(AF_WritingSystem_ScaleMetricsFunc)NULL,
(AF_WritingSystem_DoneMetricsFunc) NULL,
(AF_WritingSystem_GetStdWidthsFunc)NULL,
(AF_WritingSystem_InitMetricsFunc) NULL, /* style_metrics_init */
(AF_WritingSystem_ScaleMetricsFunc)NULL, /* style_metrics_scale */
(AF_WritingSystem_DoneMetricsFunc) NULL, /* style_metrics_done */
(AF_WritingSystem_GetStdWidthsFunc)NULL, /* style_metrics_getstdw */
(AF_WritingSystem_InitHintsFunc) NULL,
(AF_WritingSystem_ApplyHintsFunc) NULL
(AF_WritingSystem_InitHintsFunc) NULL, /* style_hints_init */
(AF_WritingSystem_ApplyHintsFunc) NULL /* style_hints_apply */
)
+8 -8
View File
@@ -1143,7 +1143,7 @@
"af_latin_metrics_scale_dim:"
" x height alignment (style `%s'):\n"
" "
" vertical scaling changed from %.4f to %.4f (by %d%%)\n"
" vertical scaling changed from %.5f to %.5f (by %d%%)\n"
"\n",
af_style_names[metrics->root.style_class->style],
scale / 65536.0,
@@ -2227,7 +2227,7 @@
seg->serif->edge &&
seg->serif->edge != edge );
if ( ( seg->link && seg->link->edge != NULL ) || is_serif )
if ( ( seg->link && seg->link->edge ) || is_serif )
{
AF_Edge edge2;
AF_Segment seg2;
@@ -3493,13 +3493,13 @@
sizeof ( AF_LatinMetricsRec ),
(AF_WritingSystem_InitMetricsFunc) af_latin_metrics_init,
(AF_WritingSystem_ScaleMetricsFunc)af_latin_metrics_scale,
(AF_WritingSystem_DoneMetricsFunc) NULL,
(AF_WritingSystem_GetStdWidthsFunc)af_latin_get_standard_widths,
(AF_WritingSystem_InitMetricsFunc) af_latin_metrics_init, /* style_metrics_init */
(AF_WritingSystem_ScaleMetricsFunc)af_latin_metrics_scale, /* style_metrics_scale */
(AF_WritingSystem_DoneMetricsFunc) NULL, /* style_metrics_done */
(AF_WritingSystem_GetStdWidthsFunc)af_latin_get_standard_widths, /* style_metrics_getstdw */
(AF_WritingSystem_InitHintsFunc) af_latin_hints_init,
(AF_WritingSystem_ApplyHintsFunc) af_latin_hints_apply
(AF_WritingSystem_InitHintsFunc) af_latin_hints_init, /* style_hints_init */
(AF_WritingSystem_ApplyHintsFunc) af_latin_hints_apply /* style_hints_apply */
)
+7 -7
View File
@@ -1303,7 +1303,7 @@
seg->serif->edge &&
seg->serif->edge != edge );
if ( ( seg->link && seg->link->edge != NULL ) || is_serif )
if ( ( seg->link && seg->link->edge ) || is_serif )
{
AF_Edge edge2;
AF_Segment seg2;
@@ -2410,13 +2410,13 @@
sizeof ( AF_LatinMetricsRec ),
(AF_WritingSystem_InitMetricsFunc) af_latin2_metrics_init,
(AF_WritingSystem_ScaleMetricsFunc)af_latin2_metrics_scale,
(AF_WritingSystem_DoneMetricsFunc) NULL,
(AF_WritingSystem_GetStdWidthsFunc)af_latin2_get_standard_widths,
(AF_WritingSystem_InitMetricsFunc) af_latin2_metrics_init, /* style_metrics_init */
(AF_WritingSystem_ScaleMetricsFunc)af_latin2_metrics_scale, /* style_metrics_scale */
(AF_WritingSystem_DoneMetricsFunc) NULL, /* style_metrics_done */
(AF_WritingSystem_GetStdWidthsFunc)af_latin2_get_standard_widths, /* style_metrics_getstdw */
(AF_WritingSystem_InitHintsFunc) af_latin2_hints_init,
(AF_WritingSystem_ApplyHintsFunc) af_latin2_hints_apply
(AF_WritingSystem_InitHintsFunc) af_latin2_hints_init, /* style_hints_init */
(AF_WritingSystem_ApplyHintsFunc) af_latin2_hints_apply /* style_hints_apply */
)
+258 -260
View File
@@ -51,7 +51,7 @@
loader->face = face;
loader->globals = (AF_FaceGlobals)face->autohint.data;
if ( loader->globals == NULL )
if ( !loader->globals )
{
error = af_face_globals_new( face, &loader->globals, module );
if ( !error )
@@ -86,161 +86,258 @@
( (FT_Fixed)( (f) * 65536.0 + 0.5 ) )
/* Do the main work of `af_loader_load_glyph'. Note that we never */
/* have to deal with composite glyphs as those get loaded into */
/* FT_GLYPH_FORMAT_OUTLINE by the recursed `FT_Load_Glyph' function. */
/* In the rare cases where FT_LOAD_NO_RECURSE is set, it implies */
/* FT_LOAD_NO_SCALE and as such the auto-hinter is never called. */
static FT_Error
af_loader_load_g( AF_Loader loader,
AF_Scaler scaler,
FT_UInt glyph_index,
FT_Int32 load_flags )
af_loader_embolden_glyph_in_slot( AF_Loader loader,
FT_Face face,
AF_StyleMetrics style_metrics )
{
AF_Module module = loader->globals->module;
FT_Error error = FT_Err_Ok;
FT_Error error;
FT_Face face = loader->face;
AF_StyleMetrics metrics = loader->metrics;
AF_GlyphHints hints = loader->hints;
FT_GlyphSlot slot = face->glyph;
AF_FaceGlobals globals = loader->globals;
AF_WritingSystemClass writing_system_class;
FT_Pos stdVW = 0;
FT_Pos stdHW = 0;
FT_Bool size_changed = face->size->metrics.x_ppem
!= globals->stem_darkening_for_ppem;
FT_Fixed em_size = af_intToFixed( face->units_per_EM );
FT_Fixed em_ratio = FT_DivFix( af_intToFixed( 1000 ), em_size );
FT_Matrix scale_down_matrix = { 0x10000L, 0, 0, 0x10000L };
/* Skip stem darkening for broken fonts. */
if ( !face->units_per_EM )
{
error = FT_Err_Corrupted_Font_Header;
goto Exit;
}
/*
* We depend on the writing system (script analyzers) to supply
* standard widths for the script of the glyph we are looking at. If
* it can't deliver, stem darkening is disabled.
*/
writing_system_class =
AF_WRITING_SYSTEM_CLASSES_GET[style_metrics->style_class->writing_system];
if ( writing_system_class->style_metrics_getstdw )
writing_system_class->style_metrics_getstdw( style_metrics,
&stdHW,
&stdVW );
else
{
error = FT_Err_Unimplemented_Feature;
goto Exit;
}
if ( size_changed ||
( stdVW > 0 && stdVW != globals->standard_vertical_width ) )
{
FT_Fixed darken_by_font_units_x, darken_x;
darken_by_font_units_x =
af_intToFixed( af_loader_compute_darkening( loader,
face,
stdVW ) );
darken_x = FT_DivFix( FT_MulFix( darken_by_font_units_x,
face->size->metrics.x_scale ),
em_ratio );
globals->standard_vertical_width = stdVW;
globals->stem_darkening_for_ppem = face->size->metrics.x_ppem;
globals->darken_x = af_fixedToInt( darken_x );
}
if ( size_changed ||
( stdHW > 0 && stdHW != globals->standard_horizontal_width ) )
{
FT_Fixed darken_by_font_units_y, darken_y;
darken_by_font_units_y =
af_intToFixed( af_loader_compute_darkening( loader,
face,
stdHW ) );
darken_y = FT_DivFix( FT_MulFix( darken_by_font_units_y,
face->size->metrics.y_scale ),
em_ratio );
globals->standard_horizontal_width = stdHW;
globals->stem_darkening_for_ppem = face->size->metrics.x_ppem;
globals->darken_y = af_fixedToInt( darken_y );
/*
* Scale outlines down on the Y-axis to keep them inside their blue
* zones. The stronger the emboldening, the stronger the downscaling
* (plus heuristical padding to prevent outlines still falling out
* their zones due to rounding).
*
* Reason: `FT_Outline_Embolden' works by shifting the rightmost
* points of stems farther to the right, and topmost points farther
* up. This positions points on the Y-axis outside their
* pre-computed blue zones and leads to distortion when applying the
* hints in the code further below. Code outside this emboldening
* block doesn't know we are presenting it with modified outlines the
* analyzer didn't see!
*
* An unfortunate side effect of downscaling is that the emboldening
* effect is slightly decreased. The loss becomes more pronounced
* versus the CFF driver at smaller sizes, e.g., at 9ppem and below.
*/
globals->scale_down_factor =
FT_DivFix( em_size - ( darken_by_font_units_y + af_intToFixed( 8 ) ),
em_size );
}
FT_Outline_EmboldenXY( &slot->outline,
globals->darken_x,
globals->darken_y );
scale_down_matrix.yy = globals->scale_down_factor;
FT_Outline_Transform( &slot->outline, &scale_down_matrix );
Exit:
return error;
}
/* Load the glyph at index into the current slot of a face and hint it. */
FT_LOCAL_DEF( FT_Error )
af_loader_load_glyph( AF_Loader loader,
AF_Module module,
FT_Face face,
FT_UInt glyph_index,
FT_Int32 load_flags )
{
FT_Error error;
FT_Size size = face->size;
FT_GlyphSlot slot = face->glyph;
FT_Slot_Internal internal = slot->internal;
FT_GlyphLoader gloader = internal->loader;
FT_Int32 flags;
AF_GlyphHints hints = loader->hints;
AF_ScalerRec scaler;
AF_StyleMetrics style_metrics;
FT_UInt style_options = AF_STYLE_NONE_DFLT;
AF_StyleClass style_class;
AF_WritingSystemClass writing_system_class;
#ifdef FT_CONFIG_OPTION_PIC
AF_FaceGlobals globals = loader->globals;
#endif
flags = load_flags | FT_LOAD_LINEAR_DESIGN;
error = FT_Load_Glyph( face, glyph_index, flags );
if ( !size )
return FT_THROW( Invalid_Size_Handle );
FT_ZERO( &scaler );
/*
* TODO: This code currently doesn't support fractional advance widths,
* i.e. placing hinted glyphs at anything other than integer
* x-positions. This is only relevant for the warper code, which
* scales and shifts glyphs to optimize blackness of stems (hinting on
* the x-axis by nature places things on pixel integers, hinting on the
* y-axis only, i.e. LIGHT mode, doesn't touch the x-axis). The delta
* values of the scaler would need to be adjusted.
*/
scaler.face = face;
scaler.x_scale = size->metrics.x_scale;
scaler.x_delta = 0;
scaler.y_scale = size->metrics.y_scale;
scaler.y_delta = 0;
scaler.render_mode = FT_LOAD_TARGET_MODE( load_flags );
scaler.flags = 0;
error = af_loader_reset( loader, module, face );
if ( error )
goto Exit;
#ifdef FT_OPTION_AUTOFIT2
/* XXX: undocumented hook to activate the latin2 writing system. */
if ( load_flags & ( 1UL << 20 ) )
style_options = AF_STYLE_LTN2_DFLT;
#endif
/*
* Glyphs (really code points) are assigned to scripts. Script
* analysis is done lazily: For each glyph that passes through here,
* the corresponding script analyzer is called, but returns immediately
* if it has been run already.
*/
error = af_face_globals_get_metrics( loader->globals, glyph_index,
style_options, &style_metrics );
if ( error )
goto Exit;
style_class = style_metrics->style_class;
writing_system_class =
AF_WRITING_SYSTEM_CLASSES_GET[style_class->writing_system];
loader->metrics = style_metrics;
if ( writing_system_class->style_metrics_scale )
writing_system_class->style_metrics_scale( style_metrics, &scaler );
else
style_metrics->scaler = scaler;
if ( writing_system_class->style_hints_init )
{
error = writing_system_class->style_hints_init( hints,
style_metrics );
if ( error )
goto Exit;
}
/*
* Do the main work of `af_loader_load_glyph'. Note that we never have
* to deal with composite glyphs as those get loaded into
* FT_GLYPH_FORMAT_OUTLINE by the recursed `FT_Load_Glyph' function.
* In the rare cases where FT_LOAD_NO_RECURSE is set, it implies
* FT_LOAD_NO_SCALE and as such the auto-hinter is never called.
*/
load_flags |= FT_LOAD_NO_SCALE |
FT_LOAD_IGNORE_TRANSFORM |
FT_LOAD_LINEAR_DESIGN;
load_flags &= ~FT_LOAD_RENDER;
error = FT_Load_Glyph( face, glyph_index, load_flags );
if ( error )
goto Exit;
/*
* Apply stem darkening (emboldening) here before hints are applied to
* the outline. Glyphs are scaled down proportionally to the
* emboldening so that curve points don't fall outside their precomputed
* blue zones.
* Apply stem darkening (emboldening) here before hints are applied to
* the outline. Glyphs are scaled down proportionally to the
* emboldening so that curve points don't fall outside their
* precomputed blue zones.
*
* Any emboldening done by the font driver (e.g., the CFF driver)
* doesn't reach here because the autohinter loads the unprocessed
* glyphs in font units for analysis (functions `af_*_metrics_init_*')
* and then above to prepare it for the rasterizers by itself,
* independently of the font driver. So emboldening must be done here,
* within the autohinter.
* Any emboldening done by the font driver (e.g., the CFF driver)
* doesn't reach here because the autohinter loads the unprocessed
* glyphs in font units for analysis (functions `af_*_metrics_init_*')
* and then above to prepare it for the rasterizers by itself,
* independently of the font driver. So emboldening must be done here,
* within the autohinter.
*
* All glyphs to be autohinted pass through here one by one. The
* standard widths can therefore change from one glyph to the next,
* depending on what script a glyph is assigned to (each script has its
* own set of standard widths and other metrics). The darkening amount
* must therefore be recomputed for each size and
* `standard_{vertical,horizontal}_width' change.
* All glyphs to be autohinted pass through here one by one. The
* standard widths can therefore change from one glyph to the next,
* depending on what script a glyph is assigned to (each script has its
* own set of standard widths and other metrics). The darkening amount
* must therefore be recomputed for each size and
* `standard_{vertical,horizontal}_width' change.
*
* Ignore errors and carry on without emboldening.
*/
if ( !module->no_stem_darkening )
{
AF_FaceGlobals globals = loader->globals;
AF_WritingSystemClass writing_system_class;
af_loader_embolden_glyph_in_slot( loader, face, style_metrics );
FT_Pos stdVW = 0;
FT_Pos stdHW = 0;
FT_Bool size_changed = face->size->metrics.x_ppem
!= globals->stem_darkening_for_ppem;
FT_Fixed em_size = af_intToFixed( face->units_per_EM );
FT_Fixed em_ratio = FT_DivFix( af_intToFixed( 1000 ), em_size );
FT_Matrix scale_down_matrix = { 0x10000L, 0, 0, 0x10000L };
/* Skip stem darkening for broken fonts. */
if ( !face->units_per_EM )
goto After_Emboldening;
/*
* We depend on the writing system (script analyzers) to supply
* standard widths for the script of the glyph we are looking at. If
* it can't deliver, stem darkening is effectively disabled.
*/
writing_system_class =
AF_WRITING_SYSTEM_CLASSES_GET[metrics->style_class->writing_system];
if ( writing_system_class->style_metrics_getstdw )
writing_system_class->style_metrics_getstdw( metrics,
&stdHW,
&stdVW );
else
goto After_Emboldening;
if ( size_changed ||
( stdVW > 0 && stdVW != globals->standard_vertical_width ) )
{
FT_Fixed darken_by_font_units_x, darken_x;
darken_by_font_units_x =
af_intToFixed( af_loader_compute_darkening( loader,
face,
stdVW ) );
darken_x = FT_DivFix( FT_MulFix( darken_by_font_units_x,
face->size->metrics.x_scale ),
em_ratio );
globals->standard_vertical_width = stdVW;
globals->stem_darkening_for_ppem = face->size->metrics.x_ppem;
globals->darken_x = af_fixedToInt( darken_x );
}
if ( size_changed ||
( stdHW > 0 && stdHW != globals->standard_horizontal_width ) )
{
FT_Fixed darken_by_font_units_y, darken_y;
darken_by_font_units_y =
af_intToFixed( af_loader_compute_darkening( loader,
face,
stdHW ) );
darken_y = FT_DivFix( FT_MulFix( darken_by_font_units_y,
face->size->metrics.y_scale ),
em_ratio );
globals->standard_horizontal_width = stdHW;
globals->stem_darkening_for_ppem = face->size->metrics.x_ppem;
globals->darken_y = af_fixedToInt( darken_y );
/*
* Scale outlines down on the Y-axis to keep them inside their blue
* zones. The stronger the emboldening, the stronger the
* downscaling (plus heuristical padding to prevent outlines still
* falling out their zones due to rounding).
*
* Reason: `FT_Outline_Embolden' works by shifting the rightmost
* points of stems farther to the right, and topmost points farther
* up. This positions points on the Y-axis outside their
* pre-computed blue zones and leads to distortion when applying the
* hints in the code further below. Code outside this emboldening
* block doesn't know we are presenting it with modified outlines
* the analyzer didn't see!
*
* An unfortunate side effect of downscaling is that the emboldening
* effect is slightly decreased. The loss becomes more pronounced
* versus the CFF driver at smaller sizes, e.g., at 9ppem and below.
*/
globals->scale_down_factor =
FT_DivFix( em_size - ( darken_by_font_units_y + af_intToFixed( 8 ) ),
em_size );
}
FT_Outline_EmboldenXY( &slot->outline,
globals->darken_x,
globals->darken_y );
scale_down_matrix.yy = globals->scale_down_factor;
FT_Outline_Transform( &slot->outline, &scale_down_matrix );
}
After_Emboldening:
loader->transformed = internal->glyph_transformed;
if ( loader->transformed )
{
@@ -264,8 +361,8 @@
loader->trans_delta.x,
loader->trans_delta.y );
/* compute original horizontal phantom points (and ignore */
/* vertical ones) */
/* compute original horizontal phantom points */
/* (and ignore vertical ones) */
loader->pp1.x = hints->x_delta;
loader->pp1.y = hints->y_delta;
loader->pp2.x = FT_MulFix( slot->metrics.horiAdvance,
@@ -276,30 +373,28 @@
if ( slot->outline.n_points == 0 )
goto Hint_Metrics;
/* now load the slot image into the auto-outline and run the */
/* automatic hinting process */
/* now load the slot image into the auto-outline */
/* and run the automatic hinting process */
{
#ifdef FT_CONFIG_OPTION_PIC
AF_FaceGlobals globals = loader->globals;
AF_FaceGlobals globals = loader->globals;
#endif
AF_StyleClass style_class = metrics->style_class;
AF_WritingSystemClass writing_system_class =
AF_WRITING_SYSTEM_CLASSES_GET[style_class->writing_system];
if ( writing_system_class->style_hints_apply )
writing_system_class->style_hints_apply( glyph_index,
hints,
&gloader->base.outline,
metrics );
style_metrics );
}
/* we now need to adjust the metrics according to the change in */
/* width/positioning that occurred during the hinting process */
if ( scaler->render_mode != FT_RENDER_MODE_LIGHT )
if ( scaler.render_mode != FT_RENDER_MODE_LIGHT )
{
FT_Pos old_rsb, old_lsb, new_lsb;
FT_Pos pp1x_uh, pp2x_uh;
FT_Pos old_rsb, old_lsb, new_lsb;
FT_Pos pp1x_uh, pp2x_uh;
AF_AxisHints axis = &hints->axis[AF_DIMENSION_HORZ];
AF_Edge edge1 = axis->edges; /* leftmost edge */
AF_Edge edge2 = edge1 +
@@ -309,12 +404,10 @@
if ( axis->num_edges > 1 && AF_HINTS_DO_ADVANCE( hints ) )
{
old_rsb = loader->pp2.x - edge2->opos;
old_lsb = edge1->opos;
/* loader->pp1.x is always zero at this point of time */
old_lsb = edge1->opos /* - loader->pp1.x */;
new_lsb = edge1->pos;
/* remember unhinted values to later account */
/* for rounding errors */
pp1x_uh = new_lsb - old_lsb;
pp2x_uh = edge2->pos + old_rsb;
@@ -380,8 +473,8 @@
vvector.x = slot->metrics.vertBearingX - slot->metrics.horiBearingX;
vvector.y = slot->metrics.vertBearingY - slot->metrics.horiBearingY;
vvector.x = FT_MulFix( vvector.x, metrics->scaler.x_scale );
vvector.y = FT_MulFix( vvector.y, metrics->scaler.y_scale );
vvector.x = FT_MulFix( vvector.x, style_metrics->scaler.x_scale );
vvector.y = FT_MulFix( vvector.y, style_metrics->scaler.y_scale );
/* transform the hinted outline if needed */
if ( loader->transformed )
@@ -389,12 +482,12 @@
FT_Outline_Transform( &gloader->base.outline, &loader->trans_matrix );
FT_Vector_Transform( &vvector, &loader->trans_matrix );
}
#if 1
/* we must translate our final outline by -pp1.x and compute */
/* the new metrics */
if ( loader->pp1.x )
FT_Outline_Translate( &gloader->base.outline, -loader->pp1.x, 0 );
#endif
FT_Outline_Get_CBox( &gloader->base.outline, &bbox );
bbox.xMin = FT_PIX_FLOOR( bbox.xMin );
@@ -413,20 +506,14 @@
/* for mono-width fonts (like Andale, Courier, etc.) we need */
/* to keep the original rounded advance width; ditto for */
/* digits if all have the same advance width */
#if 0
if ( !FT_IS_FIXED_WIDTH( slot->face ) )
slot->metrics.horiAdvance = loader->pp2.x - loader->pp1.x;
else
slot->metrics.horiAdvance = FT_MulFix( slot->metrics.horiAdvance,
x_scale );
#else
if ( scaler->render_mode != FT_RENDER_MODE_LIGHT &&
if ( scaler.render_mode != FT_RENDER_MODE_LIGHT &&
( FT_IS_FIXED_WIDTH( slot->face ) ||
( af_face_globals_is_digit( loader->globals, glyph_index ) &&
metrics->digits_have_same_width ) ) )
style_metrics->digits_have_same_width ) ) )
{
slot->metrics.horiAdvance = FT_MulFix( slot->metrics.horiAdvance,
metrics->scaler.x_scale );
slot->metrics.horiAdvance =
FT_MulFix( slot->metrics.horiAdvance,
style_metrics->scaler.x_scale );
/* Set delta values to 0. Otherwise code that uses them is */
/* going to ruin the fixed advance width. */
@@ -439,23 +526,13 @@
if ( slot->metrics.horiAdvance )
slot->metrics.horiAdvance = loader->pp2.x - loader->pp1.x;
}
#endif
slot->metrics.vertAdvance = FT_MulFix( slot->metrics.vertAdvance,
metrics->scaler.y_scale );
style_metrics->scaler.y_scale );
slot->metrics.horiAdvance = FT_PIX_ROUND( slot->metrics.horiAdvance );
slot->metrics.vertAdvance = FT_PIX_ROUND( slot->metrics.vertAdvance );
#if 0
/* reassign all outline fields except flags to protect them */
slot->outline.n_contours = internal->loader->base.outline.n_contours;
slot->outline.n_points = internal->loader->base.outline.n_points;
slot->outline.points = internal->loader->base.outline.points;
slot->outline.tags = internal->loader->base.outline.tags;
slot->outline.contours = internal->loader->base.outline.contours;
#endif
slot->format = FT_GLYPH_FORMAT_OUTLINE;
}
@@ -464,85 +541,6 @@
}
/* Load a glyph. */
FT_LOCAL_DEF( FT_Error )
af_loader_load_glyph( AF_Loader loader,
AF_Module module,
FT_Face face,
FT_UInt gindex,
FT_Int32 load_flags )
{
FT_Error error;
FT_Size size = face->size;
AF_ScalerRec scaler;
if ( !size )
return FT_THROW( Invalid_Size_Handle );
FT_ZERO( &scaler );
scaler.face = face;
scaler.x_scale = size->metrics.x_scale;
scaler.x_delta = 0; /* XXX: TODO: add support for sub-pixel hinting */
scaler.y_scale = size->metrics.y_scale;
scaler.y_delta = 0; /* XXX: TODO: add support for sub-pixel hinting */
scaler.render_mode = FT_LOAD_TARGET_MODE( load_flags );
scaler.flags = 0; /* XXX: fix this */
error = af_loader_reset( loader, module, face );
if ( !error )
{
AF_StyleMetrics metrics;
FT_UInt options = AF_STYLE_NONE_DFLT;
#ifdef FT_OPTION_AUTOFIT2
/* XXX: undocumented hook to activate the latin2 writing system */
if ( load_flags & ( 1UL << 20 ) )
options = AF_STYLE_LTN2_DFLT;
#endif
error = af_face_globals_get_metrics( loader->globals, gindex,
options, &metrics );
if ( !error )
{
#ifdef FT_CONFIG_OPTION_PIC
AF_FaceGlobals globals = loader->globals;
#endif
AF_StyleClass style_class = metrics->style_class;
AF_WritingSystemClass writing_system_class =
AF_WRITING_SYSTEM_CLASSES_GET[style_class->writing_system];
loader->metrics = metrics;
if ( writing_system_class->style_metrics_scale )
writing_system_class->style_metrics_scale( metrics, &scaler );
else
metrics->scaler = scaler;
load_flags |= FT_LOAD_NO_SCALE | FT_LOAD_IGNORE_TRANSFORM;
load_flags &= ~FT_LOAD_RENDER;
if ( writing_system_class->style_hints_init )
{
error = writing_system_class->style_hints_init( loader->hints,
metrics );
if ( error )
goto Exit;
}
error = af_loader_load_g( loader, &scaler, gindex, load_flags );
}
}
Exit:
return error;
}
/*
* Compute amount of font units the face should be emboldened by, in
* analogy to the CFF driver's `cf2_computeDarkening' function. See there
+17 -6
View File
@@ -421,12 +421,14 @@
FT_DEFINE_SERVICE_PROPERTIESREC(
af_service_properties,
(FT_Properties_SetFunc)af_property_set, /* set_property */
(FT_Properties_GetFunc)af_property_get ) /* get_property */
FT_DEFINE_SERVICEDESCREC1(
af_services,
FT_SERVICE_ID_PROPERTIES, &AF_SERVICE_PROPERTIES_GET )
@@ -519,9 +521,16 @@
error = af_loader_load_glyph( loader, module, slot->face,
glyph_index, load_flags );
af_glyph_hints_dump_points( hints, 0 );
af_glyph_hints_dump_segments( hints, 0 );
af_glyph_hints_dump_edges( hints, 0 );
#ifdef FT_DEBUG_LEVEL_TRACE
if ( ft_trace_levels[FT_COMPONENT] )
{
#endif
af_glyph_hints_dump_points( hints, 0 );
af_glyph_hints_dump_segments( hints, 0 );
af_glyph_hints_dump_edges( hints, 0 );
#ifdef FT_DEBUG_LEVEL_TRACE
}
#endif
af_loader_done( loader );
@@ -561,6 +570,7 @@
FT_DEFINE_AUTOHINTER_INTERFACE(
af_autofitter_interface,
NULL, /* reset_face */
NULL, /* get_global_hints */
NULL, /* done_global_hints */
@@ -579,9 +589,10 @@
(const void*)&AF_INTERFACE_GET,
(FT_Module_Constructor)af_autofitter_init,
(FT_Module_Destructor) af_autofitter_done,
(FT_Module_Requester) af_get_interface )
(FT_Module_Constructor)af_autofitter_init, /* module_init */
(FT_Module_Destructor) af_autofitter_done, /* module_done */
(FT_Module_Requester) af_get_interface /* get_interface */
)
/* END */
+1 -1
View File
@@ -221,7 +221,7 @@ extern void* _af_debug_hints;
(*AF_WritingSystem_InitHintsFunc)( AF_GlyphHints hints,
AF_StyleMetrics metrics );
typedef void
typedef FT_Error
(*AF_WritingSystem_ApplyHintsFunc)( FT_UInt glyph_index,
AF_GlyphHints hints,
FT_Outline* outline,
+7 -6
View File
@@ -36,7 +36,7 @@
if ( flags & FT_LOAD_NO_SCALE )
return FT_Err_Ok;
if ( face->size == NULL )
if ( !face->size )
return FT_THROW( Invalid_Size_Handle );
if ( flags & FT_LOAD_VERTICAL_LAYOUT )
@@ -60,12 +60,13 @@
/* - unscaled load */
/* - unhinted load */
/* - light-hinted load */
/* - neither a MM nor a GX font */
/* - if a variations font, it must have an `HVAR' or `VVAR' */
/* table (thus the old MM or GX fonts don't qualify; this */
/* gets checked by the driver-specific functions) */
#define LOAD_ADVANCE_FAST_CHECK( face, flags ) \
( ( flags & ( FT_LOAD_NO_SCALE | FT_LOAD_NO_HINTING ) || \
FT_LOAD_TARGET_MODE( flags ) == FT_RENDER_MODE_LIGHT ) && \
!FT_HAS_MULTIPLE_MASTERS( face ) )
#define LOAD_ADVANCE_FAST_CHECK( face, flags ) \
( flags & ( FT_LOAD_NO_SCALE | FT_LOAD_NO_HINTING ) || \
FT_LOAD_TARGET_MODE( flags ) == FT_RENDER_MODE_LIGHT )
/* documentation is in ftadvanc.h */
+16 -10
View File
@@ -423,12 +423,15 @@
}
FT_DEFINE_OUTLINE_FUNCS(bbox_interface,
(FT_Outline_MoveTo_Func) BBox_Move_To,
(FT_Outline_LineTo_Func) BBox_Line_To,
(FT_Outline_ConicTo_Func)BBox_Conic_To,
(FT_Outline_CubicTo_Func)BBox_Cubic_To,
0, 0
FT_DEFINE_OUTLINE_FUNCS(
bbox_interface,
(FT_Outline_MoveTo_Func) BBox_Move_To, /* move_to */
(FT_Outline_LineTo_Func) BBox_Line_To, /* line_to */
(FT_Outline_ConicTo_Func)BBox_Conic_To, /* conic_to */
(FT_Outline_CubicTo_Func)BBox_Cubic_To, /* cubic_to */
0, /* shift */
0 /* delta */
)
@@ -457,6 +460,7 @@
{
abbox->xMin = abbox->xMax = 0;
abbox->yMin = abbox->yMax = 0;
return 0;
}
@@ -468,10 +472,10 @@
for ( n = 0; n < outline->n_points; n++ )
{
FT_UPDATE_BBOX( vec, cbox);
FT_UPDATE_BBOX( vec, cbox );
if ( FT_CURVE_TAG( outline->tags[n] ) == FT_CURVE_TAG_ON )
FT_UPDATE_BBOX( vec, bbox);
FT_UPDATE_BBOX( vec, bbox );
vec++;
}
@@ -487,8 +491,10 @@
TBBox_Rec user;
#ifdef FT_CONFIG_OPTION_PIC
FT_Outline_Funcs bbox_interface;
Init_Class_bbox_interface(&bbox_interface);
FT_Outline_Funcs bbox_interface;
Init_Class_bbox_interface( &bbox_interface );
#endif
user.bbox = bbox;
+1 -1
View File
@@ -76,7 +76,7 @@
source_pitch_sign = source->pitch < 0 ? -1 : 1;
target_pitch_sign = target->pitch < 0 ? -1 : 1;
if ( source->buffer == NULL )
if ( !source->buffer )
{
*target = *source;
if ( source_pitch_sign != target_pitch_sign )
+4 -4
View File
@@ -449,8 +449,8 @@
FT_Add64( &temp, &temp2, &temp );
/* last attempt to ditch long division */
a = temp.hi == 0 ? temp.lo / c
: ft_div64by32( temp.hi, temp.lo, c );
a = ( temp.hi == 0 ) ? temp.lo / c
: ft_div64by32( temp.hi, temp.lo, c );
}
a_ = (FT_Long)a;
@@ -492,8 +492,8 @@
ft_multo64( a, b, &temp );
/* last attempt to ditch long division */
a = temp.hi == 0 ? temp.lo / c
: ft_div64by32( temp.hi, temp.lo, c );
a = ( temp.hi == 0 ) ? temp.lo / c
: ft_div64by32( temp.hi, temp.lo, c );
}
a_ = (FT_Long)a;
+11 -11
View File
@@ -268,7 +268,7 @@
ft_mem_table_alloc(
table,
new_size * (FT_Long)sizeof ( FT_MemNode ) );
if ( new_buckets == NULL )
if ( !new_buckets )
return;
FT_ARRAY_ZERO( new_buckets, new_size );
@@ -309,7 +309,7 @@
table = (FT_MemTable)memory->alloc( memory, sizeof ( *table ) );
if ( table == NULL )
if ( !table )
goto Exit;
FT_ZERO( table );
@@ -466,7 +466,7 @@
for (;;)
{
node = *pnode;
if ( node == NULL )
if ( !node )
break;
if ( node->file_name == _ft_debug_file &&
@@ -477,7 +477,7 @@
}
node = (FT_MemSource)ft_mem_table_alloc( table, sizeof ( *node ) );
if ( node == NULL )
if ( !node )
ft_mem_debug_panic(
"not enough memory to perform memory debugging\n" );
@@ -545,7 +545,7 @@
/* we need to create a new node in this table */
node = (FT_MemNode)ft_mem_table_alloc( table, sizeof ( *node ) );
if ( node == NULL )
if ( !node )
ft_mem_debug_panic( "not enough memory to run memory tests" );
node->address = address;
@@ -717,7 +717,7 @@
FT_MemTable table = (FT_MemTable)memory->user;
if ( block == NULL )
if ( !block )
ft_mem_debug_panic( "trying to free NULL in (%s:%ld)",
FT_FILENAME( _ft_debug_file ),
_ft_debug_lineno );
@@ -755,7 +755,7 @@
/* the following is valid according to ANSI C */
#if 0
if ( block == NULL || cur_size == 0 )
if ( !block || !cur_size )
ft_mem_debug_panic( "trying to reallocate NULL in (%s:%ld)",
file_name, line_no );
#endif
@@ -799,7 +799,7 @@
return NULL;
new_block = (FT_Pointer)ft_mem_table_alloc( table, new_size );
if ( new_block == NULL )
if ( !new_block )
return NULL;
ft_mem_table_set( table, (FT_Byte*)new_block, new_size, delta );
@@ -840,7 +840,7 @@
memory->free = ft_mem_debug_free;
p = getenv( "FT2_ALLOC_TOTAL_MAX" );
if ( p != NULL )
if ( p )
{
FT_Long total_max = ft_strtol( p, NULL, 10 );
@@ -853,7 +853,7 @@
}
p = getenv( "FT2_ALLOC_COUNT_MAX" );
if ( p != NULL )
if ( p )
{
FT_Long total_count = ft_strtol( p, NULL, 10 );
@@ -866,7 +866,7 @@
}
p = getenv( "FT2_KEEP_ALIVE" );
if ( p != NULL )
if ( p )
{
FT_Long keep_alive = ft_strtol( p, NULL, 10 );
+20 -16
View File
@@ -132,16 +132,18 @@
}
FT_DEFINE_GLYPH(ft_bitmap_glyph_class,
FT_DEFINE_GLYPH(
ft_bitmap_glyph_class,
sizeof ( FT_BitmapGlyphRec ),
FT_GLYPH_FORMAT_BITMAP,
ft_bitmap_glyph_init,
ft_bitmap_glyph_done,
ft_bitmap_glyph_copy,
0, /* FT_Glyph_TransformFunc */
ft_bitmap_glyph_bbox,
0 /* FT_Glyph_PrepareFunc */
ft_bitmap_glyph_init, /* FT_Glyph_InitFunc glyph_init */
ft_bitmap_glyph_done, /* FT_Glyph_DoneFunc glyph_done */
ft_bitmap_glyph_copy, /* FT_Glyph_CopyFunc glyph_copy */
NULL, /* FT_Glyph_TransformFunc glyph_transform */
ft_bitmap_glyph_bbox, /* FT_Glyph_GetBBoxFunc glyph_bbox */
NULL /* FT_Glyph_PrepareFunc glyph_prepare */
)
@@ -260,16 +262,18 @@
}
FT_DEFINE_GLYPH( ft_outline_glyph_class,
FT_DEFINE_GLYPH(
ft_outline_glyph_class,
sizeof ( FT_OutlineGlyphRec ),
FT_GLYPH_FORMAT_OUTLINE,
ft_outline_glyph_init,
ft_outline_glyph_done,
ft_outline_glyph_copy,
ft_outline_glyph_transform,
ft_outline_glyph_bbox,
ft_outline_glyph_prepare
ft_outline_glyph_init, /* FT_Glyph_InitFunc glyph_init */
ft_outline_glyph_done, /* FT_Glyph_DoneFunc glyph_done */
ft_outline_glyph_copy, /* FT_Glyph_CopyFunc glyph_copy */
ft_outline_glyph_transform, /* FT_Glyph_TransformFunc glyph_transform */
ft_outline_glyph_bbox, /* FT_Glyph_GetBBoxFunc glyph_bbox */
ft_outline_glyph_prepare /* FT_Glyph_PrepareFunc glyph_prepare */
)
@@ -542,8 +546,8 @@
/* we render the glyph into a glyph bitmap using a `dummy' glyph slot */
/* then calling FT_Render_Glyph_Internal() */
FT_MEM_ZERO( &dummy, sizeof ( dummy ) );
FT_MEM_ZERO( &dummy_internal, sizeof ( dummy_internal ) );
FT_ZERO( &dummy );
FT_ZERO( &dummy_internal );
dummy.internal = &dummy_internal;
dummy.library = library;
dummy.format = clazz->glyph_format;
+15 -13
View File
@@ -605,7 +605,7 @@
for (;;)
{
post_data = Get1Resource( TTAG_POST, res_id++ );
if ( post_data == NULL )
if ( !post_data )
break; /* we are done */
code = (*post_data)[0];
@@ -644,7 +644,7 @@
for (;;)
{
post_data = Get1Resource( TTAG_POST, res_id++ );
if ( post_data == NULL )
if ( !post_data )
break; /* we are done */
post_size = (FT_ULong)GetHandleSize( post_data ) - 2;
@@ -655,7 +655,7 @@
if ( last_code != -1 )
{
/* we are done adding a chunk, fill in the size field */
if ( size_p != NULL )
if ( size_p )
{
*size_p++ = (FT_Byte)( pfb_chunk_size & 0xFF );
*size_p++ = (FT_Byte)( ( pfb_chunk_size >> 8 ) & 0xFF );
@@ -743,7 +743,7 @@
sfnt = GetResource( TTAG_sfnt, sfnt_id );
if ( sfnt == NULL )
if ( !sfnt )
return FT_THROW( Invalid_Handle );
sfnt_size = (FT_ULong)GetHandleSize( sfnt );
@@ -821,7 +821,7 @@
return FT_THROW( Cannot_Open_Resource );
num_faces_in_res = 0;
for ( res_index = 1; ; ++res_index )
for ( res_index = 1; ; res_index++ )
{
short num_faces_in_fond;
@@ -942,13 +942,14 @@
/* if it works, fine. */
error = FT_New_Face_From_Suitcase( library, pathname, face_index, aface );
if ( error == 0 )
return error;
if ( error )
{
/* let it fall through to normal loader (.ttf, .otf, etc.); */
/* we signal this by returning no error and no FT_Face */
*aface = NULL;
}
/* let it fall through to normal loader (.ttf, .otf, etc.); */
/* we signal this by returning no error and no FT_Face */
*aface = NULL;
return 0;
return FT_Err_Ok;
}
@@ -982,12 +983,13 @@
/* try resourcefork based font: LWFN, FFIL */
error = FT_New_Face_From_Resource( library, (UInt8 *)pathname,
face_index, aface );
if ( error != 0 || *aface != NULL )
if ( error || *aface )
return error;
/* let it fall through to normal loader (.ttf, .otf, etc.) */
args.flags = FT_OPEN_PATHNAME;
args.pathname = (char*)pathname;
return FT_Open_Face( library, &args, face_index, aface );
}
@@ -1027,7 +1029,7 @@
error = FT_THROW( Cannot_Open_Resource );
error = FT_New_Face_From_Resource( library, pathname, face_index, aface );
if ( error != 0 || *aface != NULL )
if ( error || *aface )
return error;
/* fallback to datafork font */
+117 -2
View File
@@ -140,6 +140,13 @@
error = service->set_mm_design( face, num_coords, coords );
}
/* enforce recomputation of auto-hinting data */
if ( !error && face->autohint.finalizer )
{
face->autohint.finalizer( face->autohint.data );
face->autohint.data = NULL;
}
return error;
}
@@ -168,6 +175,41 @@
error = service->set_var_design( face, num_coords, coords );
}
/* enforce recomputation of auto-hinting data */
if ( !error && face->autohint.finalizer )
{
face->autohint.finalizer( face->autohint.data );
face->autohint.data = NULL;
}
return error;
}
/* documentation is in ftmm.h */
FT_EXPORT_DEF( FT_Error )
FT_Get_Var_Design_Coordinates( FT_Face face,
FT_UInt num_coords,
FT_Fixed* coords )
{
FT_Error error;
FT_Service_MultiMasters service;
/* check of `face' delayed to `ft_face_get_mm_service' */
if ( !coords )
return FT_THROW( Invalid_Argument );
error = ft_face_get_mm_service( face, &service );
if ( !error )
{
error = FT_ERR( Invalid_Argument );
if ( service->get_var_design )
error = service->get_var_design( face, num_coords, coords );
}
return error;
}
@@ -193,7 +235,14 @@
{
error = FT_ERR( Invalid_Argument );
if ( service->set_mm_blend )
error = service->set_mm_blend( face, num_coords, coords );
error = service->set_mm_blend( face, num_coords, coords );
}
/* enforce recomputation of auto-hinting data */
if ( !error && face->autohint.finalizer )
{
face->autohint.finalizer( face->autohint.data );
face->autohint.data = NULL;
}
return error;
@@ -224,7 +273,73 @@
{
error = FT_ERR( Invalid_Argument );
if ( service->set_mm_blend )
error = service->set_mm_blend( face, num_coords, coords );
error = service->set_mm_blend( face, num_coords, coords );
}
/* enforce recomputation of auto-hinting data */
if ( !error && face->autohint.finalizer )
{
face->autohint.finalizer( face->autohint.data );
face->autohint.data = NULL;
}
return error;
}
/* documentation is in ftmm.h */
FT_EXPORT_DEF( FT_Error )
FT_Get_MM_Blend_Coordinates( FT_Face face,
FT_UInt num_coords,
FT_Fixed* coords )
{
FT_Error error;
FT_Service_MultiMasters service;
/* check of `face' delayed to `ft_face_get_mm_service' */
if ( !coords )
return FT_THROW( Invalid_Argument );
error = ft_face_get_mm_service( face, &service );
if ( !error )
{
error = FT_ERR( Invalid_Argument );
if ( service->get_mm_blend )
error = service->get_mm_blend( face, num_coords, coords );
}
return error;
}
/* documentation is in ftmm.h */
/* This is exactly the same as the previous function. It exists for */
/* orthogonality. */
FT_EXPORT_DEF( FT_Error )
FT_Get_Var_Blend_Coordinates( FT_Face face,
FT_UInt num_coords,
FT_Fixed* coords )
{
FT_Error error;
FT_Service_MultiMasters service;
/* check of `face' delayed to `ft_face_get_mm_service' */
if ( !coords )
return FT_THROW( Invalid_Argument );
error = ft_face_get_mm_service( face, &service );
if ( !error )
{
error = FT_ERR( Invalid_Argument );
if ( service->get_mm_blend )
error = service->get_mm_blend( face, num_coords, coords );
}
return error;
+155 -65
View File
@@ -79,6 +79,15 @@
#define GRID_FIT_METRICS
/* forward declaration */
static FT_Error
ft_open_face_internal( FT_Library library,
const FT_Open_Args* args,
FT_Long face_index,
FT_Face *aface,
FT_Bool test_mac_fonts );
FT_BASE_DEF( FT_Pointer )
ft_service_list_lookup( FT_ServiceDesc service_descriptors,
const char* service_id )
@@ -641,6 +650,9 @@
load_flags &= ~FT_LOAD_RENDER;
}
if ( load_flags & FT_LOAD_BITMAP_METRICS_ONLY )
load_flags &= ~FT_LOAD_RENDER;
/*
* Determine whether we need to auto-hint or not.
* The general rules are:
@@ -1102,7 +1114,7 @@
end = first + face->num_charmaps; /* points after the last one */
for ( cur = first; cur < end; ++cur )
for ( cur = first; cur < end; cur++ )
{
if ( cur[0]->platform_id == TT_PLATFORM_APPLE_UNICODE &&
cur[0]->encoding_id == TT_APPLE_ID_VARIANT_SELECTOR &&
@@ -1237,7 +1249,7 @@
args.pathname = (char*)pathname;
args.stream = NULL;
return FT_Open_Face( library, &args, face_index, aface );
return ft_open_face_internal( library, &args, face_index, aface, 1 );
}
#endif
@@ -1264,7 +1276,7 @@
args.memory_size = file_size;
args.stream = NULL;
return FT_Open_Face( library, &args, face_index, aface );
return ft_open_face_internal( library, &args, face_index, aface, 1 );
}
@@ -1299,7 +1311,7 @@
/* Finalizer for a memory stream; gets called by FT_Done_Face(). */
/* It frees the memory it uses. */
/* From ftmac.c. */
/* From `ftmac.c'. */
static void
memory_stream_close( FT_Stream stream )
{
@@ -1315,7 +1327,7 @@
/* Create a new memory stream from a buffer and a size. */
/* From ftmac.c. */
/* From `ftmac.c'. */
static FT_Error
new_memory_stream( FT_Library library,
FT_Byte* base,
@@ -1335,7 +1347,7 @@
return FT_THROW( Invalid_Argument );
*astream = NULL;
memory = library->memory;
memory = library->memory;
if ( FT_NEW( stream ) )
goto Exit;
@@ -1351,7 +1363,7 @@
/* Create a new FT_Face given a buffer and a driver name. */
/* from ftmac.c */
/* From `ftmac.c'. */
FT_LOCAL_DEF( FT_Error )
open_face_from_buffer( FT_Library library,
FT_Byte* base,
@@ -1377,11 +1389,11 @@
return error;
}
args.flags = FT_OPEN_STREAM;
args.flags = FT_OPEN_STREAM;
args.stream = stream;
if ( driver_name )
{
args.flags = args.flags | FT_OPEN_DRIVER;
args.flags = args.flags | FT_OPEN_DRIVER;
args.driver = FT_Get_Module( library, driver_name );
}
@@ -1395,9 +1407,9 @@
face_index &= 0x7FFF0000L; /* retain GX data */
#endif
error = FT_Open_Face( library, &args, face_index, aface );
error = ft_open_face_internal( library, &args, face_index, aface, 0 );
if ( error == FT_Err_Ok )
if ( !error )
(*aface)->face_flags &= ~FT_FACE_FLAG_EXTERNAL_STREAM;
else
#ifdef FT_MACINTOSH
@@ -1589,6 +1601,7 @@
{
FT_Error error = FT_ERR( Cannot_Open_Resource );
FT_Memory memory = library->memory;
FT_Byte* pfb_data = NULL;
int i, type, flags;
FT_ULong len;
@@ -1604,12 +1617,12 @@
/* Find the length of all the POST resources, concatenated. Assume */
/* worst case (each resource in its own section). */
pfb_len = 0;
for ( i = 0; i < resource_cnt; ++i )
for ( i = 0; i < resource_cnt; i++ )
{
error = FT_Stream_Seek( stream, (FT_ULong)offsets[i] );
if ( error )
goto Exit;
if ( FT_READ_ULONG( temp ) )
if ( FT_READ_ULONG( temp ) ) /* actually LONG */
goto Exit;
/* FT2 allocator takes signed long buffer length,
@@ -1617,12 +1630,15 @@
*/
FT_TRACE4(( " POST fragment #%d: length=0x%08x"
" total pfb_len=0x%08x\n",
i, temp, pfb_len + temp + 6));
i, temp, pfb_len + temp + 6 ));
if ( FT_MAC_RFORK_MAX_LEN < temp ||
FT_MAC_RFORK_MAX_LEN - temp < pfb_len + 6 )
{
FT_TRACE2(( " MacOS resource length cannot exceed"
" 0x%08x\n", FT_MAC_RFORK_MAX_LEN ));
" 0x%08x\n",
FT_MAC_RFORK_MAX_LEN ));
error = FT_THROW( Invalid_Offset );
goto Exit;
}
@@ -1630,15 +1646,20 @@
pfb_len += temp + 6;
}
FT_TRACE2(( " total buffer size to concatenate %d"
" POST fragments: 0x%08x\n",
resource_cnt, pfb_len + 2));
if ( pfb_len + 2 < 6 ) {
FT_TRACE2(( " total buffer size to concatenate"
" %d POST fragments: 0x%08x\n",
resource_cnt, pfb_len + 2 ));
if ( pfb_len + 2 < 6 )
{
FT_TRACE2(( " too long fragment length makes"
" pfb_len confused: pfb_len=0x%08x\n", pfb_len ));
" pfb_len confused: pfb_len=0x%08x\n",
pfb_len ));
error = FT_THROW( Array_Too_Large );
goto Exit;
}
if ( FT_ALLOC( pfb_data, (FT_Long)pfb_len + 2 ) )
goto Exit;
@@ -1651,9 +1672,10 @@
pfb_pos = 6;
pfb_lenpos = 2;
len = 0;
len = 0;
type = 1;
for ( i = 0; i < resource_cnt; ++i )
for ( i = 0; i < resource_cnt; i++ )
{
error = FT_Stream_Seek( stream, (FT_ULong)offsets[i] );
if ( error )
@@ -1672,18 +1694,24 @@
if ( FT_READ_USHORT( flags ) )
goto Exit2;
FT_TRACE3(( "POST fragment[%d]: offsets=0x%08x, rlen=0x%08x, flags=0x%04x\n",
i, offsets[i], rlen, flags ));
FT_TRACE3(( "POST fragment[%d]:"
" offsets=0x%08x, rlen=0x%08x, flags=0x%04x\n",
i, offsets[i], rlen, flags ));
error = FT_ERR( Array_Too_Large );
/* postpone the check of rlen longer than buffer until FT_Stream_Read() */
/* postpone the check of `rlen longer than buffer' */
/* until `FT_Stream_Read' */
if ( ( flags >> 8 ) == 0 ) /* Comment, should not be loaded */
{
FT_TRACE3(( " Skip POST fragment #%d because it is a comment\n", i ));
FT_TRACE3(( " Skip POST fragment #%d because it is a comment\n",
i ));
continue;
}
/* the flags are part of the resource, so rlen >= 2. */
/* the flags are part of the resource, so rlen >= 2, */
/* but some fonts declare rlen = 0 for empty fragment */
if ( rlen > 2 )
rlen -= 2;
@@ -1695,9 +1723,12 @@
else
{
FT_TRACE3(( " Write POST fragment #%d header (4-byte) to buffer"
" %p + 0x%08x\n", i, pfb_data, pfb_lenpos ));
" %p + 0x%08x\n",
i, pfb_data, pfb_lenpos ));
if ( pfb_lenpos + 3 > pfb_len + 2 )
goto Exit2;
pfb_data[pfb_lenpos ] = (FT_Byte)( len );
pfb_data[pfb_lenpos + 1] = (FT_Byte)( len >> 8 );
pfb_data[pfb_lenpos + 2] = (FT_Byte)( len >> 16 );
@@ -1707,13 +1738,16 @@
break;
FT_TRACE3(( " Write POST fragment #%d header (6-byte) to buffer"
" %p + 0x%08x\n", i, pfb_data, pfb_pos ));
" %p + 0x%08x\n",
i, pfb_data, pfb_pos ));
if ( pfb_pos + 6 > pfb_len + 2 )
goto Exit2;
pfb_data[pfb_pos++] = 0x80;
type = flags >> 8;
len = rlen;
len = rlen;
pfb_data[pfb_pos++] = (FT_Byte)type;
pfb_lenpos = pfb_pos;
@@ -1727,14 +1761,18 @@
goto Exit2;
FT_TRACE3(( " Load POST fragment #%d (%d byte) to buffer"
" %p + 0x%08x\n", i, rlen, pfb_data, pfb_pos ));
" %p + 0x%08x\n",
i, rlen, pfb_data, pfb_pos ));
error = FT_Stream_Read( stream, (FT_Byte *)pfb_data + pfb_pos, rlen );
if ( error )
goto Exit2;
pfb_pos += rlen;
}
error = FT_ERR( Array_Too_Large );
if ( pfb_pos + 2 > pfb_len + 2 )
goto Exit2;
pfb_data[pfb_pos++] = 0x80;
@@ -1755,11 +1793,12 @@
aface );
Exit2:
if ( error == FT_ERR( Array_Too_Large ) )
if ( FT_ERR_EQ( error, Array_Too_Large ) )
FT_TRACE2(( " Abort due to too-short buffer to store"
" all POST fragments\n" ));
else if ( error == FT_ERR( Invalid_Offset ) )
else if ( FT_ERR_EQ( error, Invalid_Offset ) )
FT_TRACE2(( " Abort due to invalid offset in a POST fragment\n" ));
if ( error )
error = FT_ERR( Cannot_Open_Resource );
FT_FREE( pfb_data );
@@ -1803,7 +1842,7 @@
if ( FT_READ_LONG( rlen ) )
goto Exit;
if ( rlen == -1 )
if ( rlen < 1 )
return FT_THROW( Cannot_Open_Resource );
if ( (FT_ULong)rlen > FT_MAC_RFORK_MAX_LEN )
return FT_THROW( Invalid_Offset );
@@ -1856,19 +1895,19 @@
{
FT_Memory memory = library->memory;
FT_Error error;
FT_Long map_offset, rdara_pos;
FT_Long map_offset, rdata_pos;
FT_Long *data_offsets;
FT_Long count;
error = FT_Raccess_Get_HeaderInfo( library, stream, resource_offset,
&map_offset, &rdara_pos );
&map_offset, &rdata_pos );
if ( error )
return error;
/* POST resources must be sorted to concatenate properly */
error = FT_Raccess_Get_DataOffsets( library, stream,
map_offset, rdara_pos,
map_offset, rdata_pos,
TTAG_POST, TRUE,
&data_offsets, &count );
if ( !error )
@@ -1885,7 +1924,7 @@
/* sfnt resources should not be sorted to preserve the face order by
QuickDraw API */
error = FT_Raccess_Get_DataOffsets( library, stream,
map_offset, rdara_pos,
map_offset, rdata_pos,
TTAG_sfnt, FALSE,
&data_offsets, &count );
if ( !error )
@@ -1918,7 +1957,7 @@
FT_Long dlen, offset;
if ( NULL == stream )
if ( !stream )
return FT_THROW( Invalid_Stream_Operation );
error = FT_Stream_Seek( stream, 0 );
@@ -2107,6 +2146,17 @@
const FT_Open_Args* args,
FT_Long face_index,
FT_Face *aface )
{
return ft_open_face_internal( library, args, face_index, aface, 1 );
}
static FT_Error
ft_open_face_internal( FT_Library library,
const FT_Open_Args* args,
FT_Long face_index,
FT_Face *aface,
FT_Bool test_mac_fonts )
{
FT_Error error;
FT_Driver driver = NULL;
@@ -2118,6 +2168,23 @@
FT_Module* cur;
FT_Module* limit;
#ifndef FT_CONFIG_OPTION_MAC_FONTS
FT_UNUSED( test_mac_fonts );
#endif
#ifdef FT_DEBUG_LEVEL_TRACE
FT_TRACE3(( "FT_Open_Face: " ));
if ( face_index < 0 )
FT_TRACE3(( "Requesting number of faces and named instances\n"));
else
{
FT_TRACE3(( "Requesting face %ld", face_index & 0xFFFFL ));
if ( face_index & 0x7FFF0000L )
FT_TRACE3(( ", named instance %ld", face_index >> 16 ));
FT_TRACE3(( "\n" ));
}
#endif
/* test for valid `library' delayed to `FT_Stream_New' */
@@ -2195,7 +2262,8 @@
goto Success;
#ifdef FT_CONFIG_OPTION_MAC_FONTS
if ( ft_strcmp( cur[0]->clazz->module_name, "truetype" ) == 0 &&
if ( test_mac_fonts &&
ft_strcmp( cur[0]->clazz->module_name, "truetype" ) == 0 &&
FT_ERR_EQ( error, Table_Missing ) )
{
/* TrueType but essential tables are missing */
@@ -2232,16 +2300,20 @@
goto Fail2;
#if !defined( FT_MACINTOSH ) && defined( FT_CONFIG_OPTION_MAC_FONTS )
error = load_mac_face( library, stream, face_index, aface, args );
if ( !error )
if ( test_mac_fonts )
{
/* We don't want to go to Success here. We've already done that. */
/* On the other hand, if we succeeded we still need to close this */
/* stream (we opened a different stream which extracted the */
/* interesting information out of this stream here. That stream */
/* will still be open and the face will point to it). */
FT_Stream_Free( stream, external_stream );
return error;
error = load_mac_face( library, stream, face_index, aface, args );
if ( !error )
{
/* We don't want to go to Success here. We've already done */
/* that. On the other hand, if we succeeded we still need to */
/* close this stream (we opened a different stream which */
/* extracted the interesting information out of this stream */
/* here. That stream will still be open and the face will */
/* point to it). */
FT_Stream_Free( stream, external_stream );
return error;
}
}
if ( FT_ERR_NEQ( error, Unknown_File_Format ) )
@@ -2365,6 +2437,17 @@
destroy_face( memory, face, driver );
Exit:
#ifdef FT_DEBUG_LEVEL_TRACE
if ( !error && face_index < 0 )
{
FT_TRACE3(( "FT_Open_Face: The font has %ld faces\n"
" and %ld named instances for face %ld\n",
face->num_faces,
face->style_flags >> 16,
-face_index - 1 ));
}
#endif
FT_TRACE4(( "FT_Open_Face: Return %d\n", error ));
return error;
@@ -2631,6 +2714,9 @@
w = FT_PIX_ROUND( w );
h = FT_PIX_ROUND( h );
if ( !w || !h )
return FT_THROW( Invalid_Pixel_Size );
for ( i = 0; i < face->num_fixed_sizes; i++ )
{
FT_Bitmap_Size* bsize = face->available_sizes + i;
@@ -2650,6 +2736,8 @@
}
}
FT_TRACE3(( "FT_Match_Size: no matching bitmap strike\n" ));
return FT_THROW( Invalid_Pixel_Size );
}
@@ -3369,7 +3457,7 @@
FT_CMap cmap = NULL;
if ( clazz == NULL || charmap == NULL || charmap->face == NULL )
if ( !clazz || !charmap || !charmap->face )
return FT_THROW( Invalid_Argument );
face = charmap->face;
@@ -3514,7 +3602,7 @@
FT_CMap ucmap = FT_CMAP( face->charmap );
if ( charmap != NULL )
if ( charmap )
{
FT_CMap vcmap = FT_CMAP( charmap );
@@ -3555,7 +3643,7 @@
FT_CharMap charmap = find_variant_selector_charmap( face );
if ( charmap != NULL )
if ( charmap )
{
FT_CMap vcmap = FT_CMAP( charmap );
@@ -3594,7 +3682,7 @@
FT_CharMap charmap = find_variant_selector_charmap( face );
if ( charmap != NULL )
if ( charmap )
{
FT_CMap vcmap = FT_CMAP( charmap );
FT_Memory memory = FT_FACE_MEMORY( face );
@@ -3622,7 +3710,7 @@
FT_CharMap charmap = find_variant_selector_charmap( face );
if ( charmap != NULL )
if ( charmap )
{
FT_CMap vcmap = FT_CMAP( charmap );
FT_Memory memory = FT_FACE_MEMORY( face );
@@ -3656,7 +3744,7 @@
FT_CharMap charmap = find_variant_selector_charmap( face );
if ( charmap != NULL )
if ( charmap )
{
FT_CMap vcmap = FT_CMAP( charmap );
FT_Memory memory = FT_FACE_MEMORY( face );
@@ -3784,7 +3872,7 @@
if ( face && FT_IS_SFNT( face ) )
{
FT_FACE_FIND_SERVICE( face, service, SFNT_TABLE );
if ( service != NULL )
if ( service )
table = service->get_table( face, tag );
}
@@ -3808,7 +3896,7 @@
return FT_THROW( Invalid_Face_Handle );
FT_FACE_FIND_SERVICE( face, service, SFNT_TABLE );
if ( service == NULL )
if ( !service )
return FT_THROW( Unimplemented_Feature );
return service->load_table( face, tag, offset, buffer, length );
@@ -3833,7 +3921,7 @@
return FT_THROW( Invalid_Face_Handle );
FT_FACE_FIND_SERVICE( face, service, SFNT_TABLE );
if ( service == NULL )
if ( !service )
return FT_THROW( Unimplemented_Feature );
return service->table_info( face, table_index, tag, &offset, length );
@@ -3855,7 +3943,7 @@
face = charmap->face;
FT_FACE_FIND_SERVICE( face, service, TT_CMAP );
if ( service == NULL )
if ( !service )
return 0;
if ( service->get_cmap_info( charmap, &cmap_info ))
return 0;
@@ -3879,7 +3967,7 @@
face = charmap->face;
FT_FACE_FIND_SERVICE( face, service, TT_CMAP );
if ( service == NULL )
if ( !service )
return -1;
if ( service->get_cmap_info( charmap, &cmap_info ))
return -1;
@@ -4209,7 +4297,7 @@
if ( ft_trace_levels[trace_bitmap] >= 3 )
{
/* we convert to a single bitmap format for computing the checksum */
if ( !error )
if ( !error && slot->bitmap.buffer )
{
FT_Bitmap bitmap;
FT_Error err;
@@ -4488,7 +4576,8 @@
FT_BASE_DEF( FT_Pointer )
ft_module_get_service( FT_Module module,
const char* service_id )
const char* service_id,
FT_Bool global )
{
FT_Pointer result = NULL;
@@ -4501,7 +4590,7 @@
if ( module->clazz->get_interface )
result = module->clazz->get_interface( module, service_id );
if ( result == NULL )
if ( global && !result )
{
/* we didn't find it, look in all other modules then */
FT_Library library = module->library;
@@ -4518,7 +4607,7 @@
if ( cur[0]->clazz->get_interface )
{
result = cur[0]->clazz->get_interface( cur[0], service_id );
if ( result != NULL )
if ( result )
break;
}
}
@@ -4969,7 +5058,8 @@
service = (FT_Service_TrueTypeEngine)
ft_module_get_service( module,
FT_SERVICE_ID_TRUETYPE_ENGINE );
FT_SERVICE_ID_TRUETYPE_ENGINE,
0 );
if ( service )
result = service->engine_type;
}
+86 -29
View File
@@ -56,7 +56,7 @@
{
FT_Error error;
unsigned char head[16], head2[16];
FT_Long map_pos, rdata_len;
FT_Long map_pos, map_len, rdata_len;
int allzeros, allmatch, i;
FT_Long type_list;
@@ -67,12 +67,15 @@
if ( error )
return error;
error = FT_Stream_Read( stream, (FT_Byte *)head, 16 );
error = FT_Stream_Read( stream, (FT_Byte*)head, 16 );
if ( error )
return error;
/* ensure positive values */
if ( head[0] >= 0x80 || head[4] >= 0x80 || head[8] >= 0x80 )
if ( head[0] >= 0x80 ||
head[4] >= 0x80 ||
head[8] >= 0x80 ||
head[12] >= 0x80 )
return FT_THROW( Unknown_File_Format );
*rdata_pos = ( head[ 0] << 24 ) |
@@ -87,14 +90,36 @@
( head[ 9] << 16 ) |
( head[10] << 8 ) |
head[11];
map_len = ( head[12] << 24 ) |
( head[13] << 16 ) |
( head[14] << 8 ) |
head[15];
/* map_len = head[12] .. head[15] */
if ( *rdata_pos != map_pos - rdata_len || map_pos == 0 )
/* the map must not be empty */
if ( !map_pos )
return FT_THROW( Unknown_File_Format );
if ( FT_LONG_MAX - rfork_offset < *rdata_pos ||
FT_LONG_MAX - rfork_offset < map_pos )
/* check whether rdata and map overlap */
if ( *rdata_pos < map_pos )
{
if ( *rdata_pos > map_pos - rdata_len )
return FT_THROW( Unknown_File_Format );
}
else
{
if ( map_pos > *rdata_pos - map_len )
return FT_THROW( Unknown_File_Format );
}
/* check whether end of rdata or map exceeds stream size */
if ( FT_LONG_MAX - rdata_len < *rdata_pos ||
FT_LONG_MAX - map_len < map_pos ||
FT_LONG_MAX - ( *rdata_pos + rdata_len ) < rfork_offset ||
FT_LONG_MAX - ( map_pos + map_len ) < rfork_offset ||
(FT_ULong)( rfork_offset + *rdata_pos + rdata_len ) > stream->size ||
(FT_ULong)( rfork_offset + map_pos + map_len ) > stream->size )
return FT_THROW( Unknown_File_Format );
*rdata_pos += rfork_offset;
@@ -112,7 +137,7 @@
allzeros = 1;
allmatch = 1;
for ( i = 0; i < 16; ++i )
for ( i = 0; i < 16; i++ )
{
if ( head2[i] != 0 )
allzeros = 0;
@@ -124,15 +149,14 @@
/* If we have reached this point then it is probably a mac resource */
/* file. Now, does it contain any interesting resources? */
/* Skip handle to next resource map, the file resource number, and */
/* attributes. */
(void)FT_STREAM_SKIP( 4 /* skip handle to next resource map */
+ 2 /* skip file resource number */
+ 2 ); /* skip attributes */
if ( FT_READ_USHORT( type_list ) )
if ( FT_READ_SHORT( type_list ) )
return error;
if ( type_list == -1 )
if ( type_list < 0 )
return FT_THROW( Unknown_File_Format );
error = FT_Stream_Seek( stream, (FT_ULong)( map_pos + type_list ) );
@@ -181,15 +205,34 @@
if ( error )
return error;
if ( FT_READ_USHORT( cnt ) )
if ( FT_READ_SHORT( cnt ) )
return error;
cnt++;
for ( i = 0; i < cnt; ++i )
/* `rpos' is a signed 16bit integer offset to resource records; the */
/* size of a resource record is 12 bytes. The map header is 28 bytes, */
/* and a type list needs 10 bytes or more. If we assume that the name */
/* list is empty and we have only a single entry in the type list, */
/* there can be at most */
/* */
/* (32768 - 28 - 10) / 12 = 2727 */
/* */
/* resources. */
/* */
/* A type list starts with a two-byte counter, followed by 10-byte */
/* type records. Assuming that there are no resources, the number of */
/* type records can be at most */
/* */
/* (32768 - 28 - 2) / 8 = 4079 */
/* */
if ( cnt > 4079 )
return FT_THROW( Invalid_Table );
for ( i = 0; i < cnt; i++ )
{
if ( FT_READ_LONG( tag_internal ) ||
FT_READ_USHORT( subcnt ) ||
FT_READ_USHORT( rpos ) )
FT_READ_SHORT( subcnt ) ||
FT_READ_SHORT( rpos ) )
return error;
FT_TRACE2(( "Resource tags: %c%c%c%c\n",
@@ -205,6 +248,11 @@
*count = subcnt + 1;
rpos += map_offset;
/* a zero count might be valid in the resource specification, */
/* however, it is completely useless to us */
if ( *count < 1 || *count > 2727 )
return FT_THROW( Invalid_Table );
error = FT_Stream_Seek( stream, (FT_ULong)rpos );
if ( error )
return error;
@@ -212,35 +260,44 @@
if ( FT_NEW_ARRAY( ref, *count ) )
return error;
for ( j = 0; j < *count; ++j )
for ( j = 0; j < *count; j++ )
{
if ( FT_READ_USHORT( ref[j].res_id ) )
if ( FT_READ_SHORT( ref[j].res_id ) )
goto Exit;
if ( FT_STREAM_SKIP( 2 ) ) /* resource name */
if ( FT_STREAM_SKIP( 2 ) ) /* resource name offset */
goto Exit;
if ( FT_READ_LONG( temp ) )
if ( FT_READ_LONG( temp ) ) /* attributes (8bit), offset (24bit) */
goto Exit;
if ( FT_STREAM_SKIP( 4 ) ) /* mbz */
if ( FT_STREAM_SKIP( 4 ) ) /* mbz */
goto Exit;
if ( ref[j].res_id < 0 || temp < 0 )
{
error = FT_THROW( Invalid_Table );
goto Exit;
}
ref[j].offset = temp & 0xFFFFFFL;
FT_TRACE3(( " [%d]:"
" resource_id=0x%04x, offset=0x%08x\n",
j, ref[j].res_id, ref[j].offset ));
}
if (sort_by_res_id)
if ( sort_by_res_id )
{
ft_qsort( ref, (size_t)*count, sizeof ( FT_RFork_Ref ),
( int(*)(const void*, const void*) )
ft_raccess_sort_ref_by_id );
ft_qsort( ref,
(size_t)*count,
sizeof ( FT_RFork_Ref ),
( int(*)(const void*,
const void*) )ft_raccess_sort_ref_by_id );
FT_TRACE3(( " -- sort resources by their ids --\n" ));
for ( j = 0; j < *count; ++ j ) {
for ( j = 0; j < *count; j++ )
FT_TRACE3(( " [%d]:"
" resource_id=0x%04x, offset=0x%08x\n",
j, ref[j].res_id, ref[j].offset ));
}
}
if ( FT_NEW_ARRAY( offsets_internal, *count ) )
@@ -250,7 +307,7 @@
* gap between reference IDs are acceptable?
* further investigation on Apple implementation is needed.
*/
for ( j = 0; j < *count; ++j )
for ( j = 0; j < *count; j++ )
offsets_internal[j] = rdata_pos + ref[j].offset;
*offsets = offsets_internal;
+1 -1
View File
@@ -58,7 +58,7 @@
/* load name on demand */
if ( entry->stringLength > 0 && entry->string == NULL )
if ( entry->stringLength > 0 && !entry->string )
{
FT_Memory memory = face->memory;
FT_Stream stream = face->stream;
+3 -3
View File
@@ -74,7 +74,7 @@
if ( size > 0 )
{
block = memory->alloc( memory, size );
if ( block == NULL )
if ( !block )
error = FT_THROW( Out_Of_Memory );
}
else if ( size < 0 )
@@ -141,7 +141,7 @@
}
else if ( cur_count == 0 )
{
FT_ASSERT( block == NULL );
FT_ASSERT( !block );
block = ft_mem_alloc( memory, new_count*item_size, &error );
}
@@ -153,7 +153,7 @@
block2 = memory->realloc( memory, cur_size, new_size, block );
if ( block2 == NULL )
if ( !block2 )
error = FT_THROW( Out_Of_Memory );
else
block = block2;
+13 -13
View File
@@ -276,7 +276,7 @@ THE SOFTWARE.
len = lengths[nn];
if ( src == NULL )
if ( !src )
continue;
/* separate elements with a space */
@@ -423,7 +423,7 @@ THE SOFTWARE.
else
bdfface->family_name = NULL;
if ( ( error = bdf_interpret_style( face ) ) != 0 )
if ( FT_SET_ERROR( bdf_interpret_style( face ) ) )
goto Exit;
/* the number of glyphs (with one slot for the undefined glyph */
@@ -439,7 +439,7 @@ THE SOFTWARE.
FT_Short resolution_x = 0, resolution_y = 0;
FT_MEM_ZERO( bsize, sizeof ( FT_Bitmap_Size ) );
FT_ZERO( bsize );
bsize->height = (FT_Short)( font->font_ascent + font->font_descent );
@@ -866,10 +866,10 @@ THE SOFTWARE.
0x10000L,
0x20000L,
0, /* module-specific interface */
NULL, /* module-specific interface */
0, /* FT_Module_Constructor module_init */
0, /* FT_Module_Destructor module_done */
NULL, /* FT_Module_Constructor module_init */
NULL, /* FT_Module_Destructor module_done */
bdf_driver_requester /* FT_Module_Requester get_interface */
},
@@ -879,16 +879,16 @@ THE SOFTWARE.
BDF_Face_Init, /* FT_Face_InitFunc init_face */
BDF_Face_Done, /* FT_Face_DoneFunc done_face */
0, /* FT_Size_InitFunc init_size */
0, /* FT_Size_DoneFunc done_size */
0, /* FT_Slot_InitFunc init_slot */
0, /* FT_Slot_DoneFunc done_slot */
NULL, /* FT_Size_InitFunc init_size */
NULL, /* FT_Size_DoneFunc done_size */
NULL, /* FT_Slot_InitFunc init_slot */
NULL, /* FT_Slot_DoneFunc done_slot */
BDF_Glyph_Load, /* FT_Slot_LoadFunc load_glyph */
0, /* FT_Face_GetKerningFunc get_kerning */
0, /* FT_Face_AttachFunc attach_file */
0, /* FT_Face_GetAdvancesFunc get_advances */
NULL, /* FT_Face_GetKerningFunc get_kerning */
NULL, /* FT_Face_AttachFunc attach_file */
NULL, /* FT_Face_GetAdvancesFunc get_advances */
BDF_Size_Request, /* FT_Size_RequestFunc request_size */
BDF_Size_Select /* FT_Size_SelectFunc select_size */
+3 -3
View File
@@ -1119,7 +1119,7 @@
/* See whether this property type exists yet or not. */
/* If not, create it. */
propid = ft_hash_str_lookup( name, &(font->proptbl) );
if ( propid == NULL )
if ( !propid )
{
error = bdf_create_property( name, BDF_ATOM, font );
if ( error )
@@ -1144,7 +1144,7 @@
}
fp = font->props + font->props_size;
FT_MEM_ZERO( fp, sizeof ( bdf_property_t ) );
FT_ZERO( fp );
font->props_size++;
}
@@ -2301,7 +2301,7 @@
p->font->comments[p->font->comments_len] = 0;
}
}
else if ( error == FT_Err_Ok )
else if ( !error )
error = FT_THROW( Invalid_File_Format );
*font = p->font;
+1 -1
View File
@@ -180,7 +180,7 @@
bzstream->next_in = (char*)zip->buffer;
if ( BZ2_bzDecompressInit( bzstream, 0, 0 ) != BZ_OK ||
bzstream->next_in == NULL )
!bzstream->next_in )
error = FT_THROW( Invalid_File_Format );
Exit:
+28 -23
View File
@@ -237,12 +237,14 @@
{
{
sizeof ( FTC_BasicFamilyRec ),
ftc_basic_family_compare,
ftc_basic_family_init,
0, /* FTC_MruNode_ResetFunc */
0 /* FTC_MruNode_DoneFunc */
ftc_basic_family_compare, /* FTC_MruNode_CompareFunc node_compare */
ftc_basic_family_init, /* FTC_MruNode_InitFunc node_init */
NULL, /* FTC_MruNode_ResetFunc node_reset */
NULL /* FTC_MruNode_DoneFunc node_done */
},
ftc_basic_family_load_glyph
ftc_basic_family_load_glyph /* FTC_IFamily_LoadGlyphFunc family_load_glyph */
};
@@ -250,16 +252,17 @@
const FTC_GCacheClassRec ftc_basic_image_cache_class =
{
{
ftc_inode_new,
ftc_inode_weight,
ftc_gnode_compare,
ftc_basic_gnode_compare_faceid,
ftc_inode_free,
ftc_inode_new, /* FTC_Node_NewFunc node_new */
ftc_inode_weight, /* FTC_Node_WeightFunc node_weight */
ftc_gnode_compare, /* FTC_Node_CompareFunc node_compare */
ftc_basic_gnode_compare_faceid, /* FTC_Node_CompareFunc node_remove_faceid */
ftc_inode_free, /* FTC_Node_FreeFunc node_free */
sizeof ( FTC_GCacheRec ),
ftc_gcache_init,
ftc_gcache_done
ftc_gcache_init, /* FTC_Cache_InitFunc cache_init */
ftc_gcache_done /* FTC_Cache_DoneFunc cache_done */
},
(FTC_MruListClass)&ftc_basic_image_family_class
};
@@ -419,11 +422,12 @@
{
{
sizeof ( FTC_BasicFamilyRec ),
ftc_basic_family_compare,
ftc_basic_family_init,
0, /* FTC_MruNode_ResetFunc */
0 /* FTC_MruNode_DoneFunc */
ftc_basic_family_compare, /* FTC_MruNode_CompareFunc node_compare */
ftc_basic_family_init, /* FTC_MruNode_InitFunc node_init */
NULL, /* FTC_MruNode_ResetFunc node_reset */
NULL /* FTC_MruNode_DoneFunc node_done */
},
ftc_basic_family_get_count,
ftc_basic_family_load_bitmap
};
@@ -433,16 +437,17 @@
const FTC_GCacheClassRec ftc_basic_sbit_cache_class =
{
{
ftc_snode_new,
ftc_snode_weight,
ftc_snode_compare,
ftc_basic_gnode_compare_faceid,
ftc_snode_free,
ftc_snode_new, /* FTC_Node_NewFunc node_new */
ftc_snode_weight, /* FTC_Node_WeightFunc node_weight */
ftc_snode_compare, /* FTC_Node_CompareFunc node_compare */
ftc_basic_gnode_compare_faceid, /* FTC_Node_CompareFunc node_remove_faceid */
ftc_snode_free, /* FTC_Node_FreeFunc node_free */
sizeof ( FTC_GCacheRec ),
ftc_gcache_init,
ftc_gcache_done
ftc_gcache_init, /* FTC_Cache_InitFunc cache_init */
ftc_gcache_done /* FTC_Cache_DoneFunc cache_done */
},
(FTC_MruListClass)&ftc_basic_sbit_family_class
};
+7 -7
View File
@@ -147,7 +147,7 @@
for (;;)
{
node = *pnode;
if ( node == NULL )
if ( !node )
break;
if ( node->hash & ( mask + 1 ) )
@@ -232,7 +232,7 @@
FTC_Node node = *pnode;
if ( node == NULL )
if ( !node )
{
FT_TRACE0(( "ftc_node_hash_unlink: unknown node\n" ));
return;
@@ -288,7 +288,7 @@
cache = manager->caches[node->cache_index];
#ifdef FT_DEBUG_ERROR
if ( cache == NULL )
if ( !cache )
{
FT_TRACE0(( "ftc_node_destroy: invalid node handle\n" ));
return;
@@ -494,7 +494,7 @@
FTC_Node_CompareFunc compare = cache->clazz.node_compare;
if ( cache == NULL || anode == NULL )
if ( !cache || !anode )
return FT_THROW( Invalid_Argument );
/* Go to the `top' node of the list sharing same masked hash */
@@ -505,7 +505,7 @@
for (;;)
{
node = *pnode;
if ( node == NULL )
if ( !node )
goto NewNode;
if ( node->hash == hash &&
@@ -523,7 +523,7 @@
/* Update pnode by modified linked list */
while ( *pnode != node )
{
if ( *pnode == NULL )
if ( !*pnode )
{
FT_ERROR(( "FTC_Cache_Lookup: oops!!! node missing\n" ));
goto NewNode;
@@ -582,7 +582,7 @@
FT_Bool list_changed = FALSE;
if ( node == NULL )
if ( !node )
break;
if ( cache->clazz.node_remove_faceid( node, face_id,
+3 -3
View File
@@ -227,7 +227,7 @@ FT_BEGIN_HEADER
for (;;) \
{ \
_node = *_pnode; \
if ( _node == NULL ) \
if ( !_node ) \
goto NewNode_; \
\
if ( _node->hash == _hash && \
@@ -245,7 +245,7 @@ FT_BEGIN_HEADER
/* Update _pnode by possibly modified linked list */ \
while ( *_pnode != _node ) \
{ \
if ( *_pnode == NULL ) \
if ( !*_pnode ) \
{ \
FT_ERROR(( "FTC_CACHE_LOOKUP_CMP: oops!!! node missing\n" )); \
goto NewNode_; \
@@ -325,7 +325,7 @@ FT_BEGIN_HEADER
break; \
\
_try_done = FTC_Manager_FlushN( _try_manager, _try_count ); \
if ( _try_done > 0 && ( list_changed != NULL ) ) \
if ( _try_done > 0 && list_changed != NULL ) \
*(FT_Bool*)( list_changed ) = TRUE; \
\
if ( _try_done == 0 ) \
+7 -7
View File
@@ -201,15 +201,15 @@
static
const FTC_CacheClassRec ftc_cmap_cache_class =
{
ftc_cmap_node_new,
ftc_cmap_node_weight,
ftc_cmap_node_compare,
ftc_cmap_node_remove_faceid,
ftc_cmap_node_free,
ftc_cmap_node_new, /* FTC_Node_NewFunc node_new */
ftc_cmap_node_weight, /* FTC_Node_WeightFunc node_weight */
ftc_cmap_node_compare, /* FTC_Node_CompareFunc node_compare */
ftc_cmap_node_remove_faceid, /* FTC_Node_CompareFunc node_remove_faceid */
ftc_cmap_node_free, /* FTC_Node_FreeFunc node_free */
sizeof ( FTC_CacheRec ),
ftc_cache_init,
ftc_cache_done,
ftc_cache_init, /* FTC_Cache_InitFunc cache_init */
ftc_cache_done, /* FTC_Cache_DoneFunc cache_done */
};
+11 -10
View File
@@ -156,10 +156,11 @@
const FTC_MruListClassRec ftc_size_list_class =
{
sizeof ( FTC_SizeNodeRec ),
ftc_size_node_compare,
ftc_size_node_init,
ftc_size_node_reset,
ftc_size_node_done
ftc_size_node_compare, /* FTC_MruNode_CompareFunc node_compare */
ftc_size_node_init, /* FTC_MruNode_InitFunc node_init */
ftc_size_node_reset, /* FTC_MruNode_ResetFunc node_reset */
ftc_size_node_done /* FTC_MruNode_DoneFunc node_done */
};
@@ -296,10 +297,10 @@
{
sizeof ( FTC_FaceNodeRec),
ftc_face_node_compare,
ftc_face_node_init,
0, /* FTC_MruNode_ResetFunc */
ftc_face_node_done
ftc_face_node_compare, /* FTC_MruNode_CompareFunc node_compare */
ftc_face_node_init, /* FTC_MruNode_InitFunc node_init */
NULL, /* FTC_MruNode_ResetFunc node_reset */
ftc_face_node_done /* FTC_MruNode_DoneFunc node_done */
};
@@ -552,7 +553,7 @@
manager->num_nodes ));
#endif
if ( manager->cur_weight < manager->max_weight || first == NULL )
if ( manager->cur_weight < manager->max_weight || !first )
return;
/* go to last node -- it's a circular list */
@@ -637,7 +638,7 @@
/* try to remove `count' nodes from the list */
if ( first == NULL ) /* empty list! */
if ( !first ) /* empty list! */
return 0;
/* go to last node - it's a circular list */
+5 -5
View File
@@ -76,7 +76,7 @@
FTC_MruNode first = *plist;
FT_ASSERT( first != NULL );
FT_ASSERT( first );
if ( first != node )
{
@@ -126,7 +126,7 @@
FTC_MruNode prev, next;
FT_ASSERT( first != NULL );
FT_ASSERT( first );
#ifdef FT_DEBUG_ERROR
{
@@ -238,7 +238,7 @@
FTC_MruNode *anode )
{
FT_Error error;
FTC_MruNode node = NULL;
FTC_MruNode node = NULL;
FT_Memory memory = list->memory;
@@ -296,7 +296,7 @@
node = FTC_MruList_Find( list, key );
if ( node == NULL )
if ( !node )
return FTC_MruList_New( list, key, anode );
*anode = node;
@@ -332,7 +332,7 @@
first = list->nodes;
while ( first && ( selection == NULL || selection( first, key ) ) )
while ( first && ( !selection || selection( first, key ) ) )
{
FTC_MruList_Remove( list, first );
first = list->nodes;
+2
View File
@@ -108,6 +108,7 @@ FT_BEGIN_HEADER
typedef struct FTC_MruListClassRec_
{
FT_Offset node_size;
FTC_MruNode_CompareFunc node_compare;
FTC_MruNode_InitFunc node_init;
FTC_MruNode_ResetFunc node_reset;
@@ -115,6 +116,7 @@ FT_BEGIN_HEADER
} FTC_MruListClassRec;
typedef struct FTC_MruListRec_
{
FT_UInt num_nodes;
+1 -1
View File
@@ -378,7 +378,7 @@
*
*/
if ( sbit->buffer == NULL && sbit->width == 255 )
if ( !sbit->buffer && sbit->width == 255 )
{
FT_ULong size;
FT_Error error;
+10 -10
View File
@@ -58,7 +58,7 @@
FT_Error* error,
size_t sizeItem )
{
FT_ASSERT( arrstack != NULL );
FT_ASSERT( arrstack );
/* initialize the structure */
arrstack->memory = memory;
@@ -78,7 +78,7 @@
FT_Memory memory = arrstack->memory; /* for FT_FREE */
FT_ASSERT( arrstack != NULL );
FT_ASSERT( arrstack );
arrstack->allocated = 0;
arrstack->count = 0;
@@ -95,7 +95,7 @@
cf2_arrstack_setNumElements( CF2_ArrStack arrstack,
size_t numElements )
{
FT_ASSERT( arrstack != NULL );
FT_ASSERT( arrstack );
{
FT_Error error = FT_Err_Ok; /* for FT_REALLOC */
@@ -140,7 +140,7 @@
cf2_arrstack_setCount( CF2_ArrStack arrstack,
size_t numElements )
{
FT_ASSERT( arrstack != NULL );
FT_ASSERT( arrstack );
if ( numElements > arrstack->allocated )
{
@@ -157,7 +157,7 @@
FT_LOCAL_DEF( void )
cf2_arrstack_clear( CF2_ArrStack arrstack )
{
FT_ASSERT( arrstack != NULL );
FT_ASSERT( arrstack );
arrstack->count = 0;
}
@@ -167,7 +167,7 @@
FT_LOCAL_DEF( size_t )
cf2_arrstack_size( const CF2_ArrStack arrstack )
{
FT_ASSERT( arrstack != NULL );
FT_ASSERT( arrstack );
return arrstack->count;
}
@@ -176,7 +176,7 @@
FT_LOCAL_DEF( void* )
cf2_arrstack_getBuffer( const CF2_ArrStack arrstack )
{
FT_ASSERT( arrstack != NULL );
FT_ASSERT( arrstack );
return arrstack->ptr;
}
@@ -190,7 +190,7 @@
void* newPtr;
FT_ASSERT( arrstack != NULL );
FT_ASSERT( arrstack );
if ( idx >= arrstack->count )
{
@@ -212,7 +212,7 @@
cf2_arrstack_push( CF2_ArrStack arrstack,
const void* ptr )
{
FT_ASSERT( arrstack != NULL );
FT_ASSERT( arrstack );
if ( arrstack->count == arrstack->allocated )
{
@@ -225,7 +225,7 @@
}
}
FT_ASSERT( ptr != NULL );
FT_ASSERT( ptr );
{
size_t offset = arrstack->count * arrstack->sizeItem;
+1 -1
View File
@@ -44,7 +44,7 @@
cf2_setError( FT_Error* error,
FT_Error value )
{
if ( error && *error == 0 )
if ( error && !*error )
*error = value;
}
+2 -2
View File
@@ -51,8 +51,8 @@ FT_BEGIN_HEADER
#define CF2_FIXED_MAX ( (CF2_Fixed)0x7FFFFFFFL )
#define CF2_FIXED_MIN ( (CF2_Fixed)0x80000000L )
#define CF2_FIXED_ONE 0x10000L
#define CF2_FIXED_EPSILON 0x0001
#define CF2_FIXED_ONE ( (CF2_Fixed)0x10000L )
#define CF2_FIXED_EPSILON ( (CF2_Fixed)0x0001 )
/* in C 89, left and right shift of negative numbers is */
/* implementation specific behaviour in the general case */
+52 -2
View File
@@ -234,7 +234,8 @@
}
/* set up values for the current FontDict and matrix */
/* set up values for the current FontDict and matrix; */
/* called for each glyph to be rendered */
/* caller's transform is adjusted for subpixel positioning */
static void
@@ -246,6 +247,9 @@
FT_Bool needExtraSetup = FALSE;
CFF_VStoreRec* vstore;
FT_Bool hasVariations = FALSE;
/* character space units */
CF2_Fixed boldenX = font->syntheticEmboldeningAmountX;
CF2_Fixed boldenY = font->syntheticEmboldeningAmountY;
@@ -253,6 +257,9 @@
CFF_SubFont subFont;
CF2_Fixed ppem;
CF2_UInt lenNormalizedV = 0;
FT_Fixed* normalizedV = NULL;
/* clear previous error */
font->error = FT_Err_Ok;
@@ -266,6 +273,48 @@
needExtraSetup = TRUE;
}
/* check for variation vectors */
vstore = cf2_getVStore( decoder );
hasVariations = ( vstore->dataCount != 0 );
if ( hasVariations )
{
#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
/* check whether Private DICT in this subfont needs to be reparsed */
font->error = cf2_getNormalizedVector( decoder,
&lenNormalizedV,
&normalizedV );
if ( font->error )
return;
if ( cff_blend_check_vector( &subFont->blend,
subFont->private_dict.vsindex,
lenNormalizedV,
normalizedV ) )
{
/* blend has changed, reparse */
cff_load_private_dict( decoder->cff,
subFont,
lenNormalizedV,
normalizedV );
needExtraSetup = TRUE;
}
#endif
/* copy from subfont */
font->blend.font = subFont->blend.font;
/* clear state of charstring blend */
font->blend.usedBV = FALSE;
/* initialize value for charstring */
font->vsindex = subFont->private_dict.vsindex;
/* store vector inputs for blends in charstring */
font->lenNDV = lenNormalizedV;
font->NDV = normalizedV;
}
/* if ppem has changed, we need to recompute some cached data */
/* note: because of CID font matrix concatenation, ppem and transform */
/* do not necessarily track. */
@@ -423,7 +472,8 @@
/* compute blue zones for this instance */
cf2_blues_init( &font->blues, font );
}
} /* needExtraSetup */
}
+8
View File
@@ -42,6 +42,7 @@
#include "cf2ft.h"
#include "cf2blues.h"
#include "cffload.h"
FT_BEGIN_HEADER
@@ -63,6 +64,7 @@ FT_BEGIN_HEADER
FT_Memory memory;
FT_Error error; /* shared error for this instance */
FT_Bool isCFF2;
CF2_RenderingFlags renderingFlags;
/* variables that depend on Transform: */
@@ -74,6 +76,12 @@ FT_BEGIN_HEADER
CF2_Matrix outerTransform; /* post hinting; includes rotations */
CF2_Fixed ppem; /* transform-dependent */
/* variation data */
CFF_BlendRec blend; /* cached charstring blend vector */
CF2_UInt vsindex; /* current vsindex */
CF2_UInt lenNDV; /* current length NDV or zero */
FT_Fixed* NDV; /* ptr to current NDV or NULL */
CF2_Int unitsPerEm;
CF2_Fixed syntheticEmboldeningAmountX; /* character space units */
+45 -3
View File
@@ -104,7 +104,8 @@
FT_Memory memory = font->memory;
(void)memory;
FT_FREE( font->blend.lastNDV );
FT_FREE( font->blend.BV );
}
}
@@ -239,7 +240,7 @@
FT_Memory memory,
FT_Error* error )
{
FT_MEM_ZERO( outline, sizeof ( CF2_OutlineRec ) );
FT_ZERO( outline );
outline->root.memory = memory;
outline->root.error = error;
@@ -311,7 +312,7 @@
font = (CF2_Font)decoder->cff->cf2_instance.data;
/* on first glyph, allocate instance structure */
if ( decoder->cff->cf2_instance.data == NULL )
if ( !decoder->cff->cf2_instance.data )
{
decoder->cff->cf2_instance.finalizer =
(FT_Generic_Finalizer)cf2_free_instance;
@@ -366,6 +367,9 @@
&hinted,
&scaled );
/* copy isCFF2 boolean from TT_Face to CF2_Font */
font->isCFF2 = builder->face->isCFF2;
font->renderingFlags = 0;
if ( hinted )
font->renderingFlags |= CF2_FlagsHinted;
@@ -413,6 +417,44 @@
}
/* get pointer to VStore structure */
FT_LOCAL_DEF( CFF_VStore )
cf2_getVStore( CFF_Decoder* decoder )
{
FT_ASSERT( decoder && decoder->cff );
return &decoder->cff->vstore;
}
/* get maxstack value from CFF2 Top DICT */
FT_LOCAL_DEF( FT_UInt )
cf2_getMaxstack( CFF_Decoder* decoder )
{
FT_ASSERT( decoder && decoder->cff );
return decoder->cff->top_font.font_dict.maxstack;
}
#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
/* Get normalized design vector for current render request; */
/* return pointer and length. */
/* */
/* Note: Uses FT_Fixed not CF2_Fixed for the vector. */
FT_LOCAL_DEF( FT_Error )
cf2_getNormalizedVector( CFF_Decoder* decoder,
CF2_UInt *len,
FT_Fixed* *vec )
{
FT_ASSERT( decoder && decoder->builder.face );
FT_ASSERT( vec && len );
return cff_get_var_blend( decoder->builder.face, len, vec, NULL );
}
#endif
/* get `y_ppem' from `CFF_Size' */
FT_LOCAL_DEF( CF2_Fixed )
cf2_getPpemY( CFF_Decoder* decoder )
+12
View File
@@ -64,6 +64,18 @@ FT_BEGIN_HEADER
FT_LOCAL( CFF_SubFont )
cf2_getSubfont( CFF_Decoder* decoder );
FT_LOCAL( CFF_VStore )
cf2_getVStore( CFF_Decoder* decoder );
FT_LOCAL( FT_UInt )
cf2_getMaxstack( CFF_Decoder* decoder );
#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
FT_LOCAL( FT_Error )
cf2_getNormalizedVector( CFF_Decoder* decoder,
CF2_UInt *len,
FT_Fixed* *vec );
#endif
FT_LOCAL( CF2_Fixed )
cf2_getPpemY( CFF_Decoder* decoder );
+2 -2
View File
@@ -401,10 +401,10 @@
/* calculate all four possibilities; moves down are negative */
CF2_Fixed downMoveDown = 0 - fracDown;
CF2_Fixed upMoveDown = 0 - fracUp;
CF2_Fixed downMoveUp = fracDown == 0
CF2_Fixed downMoveUp = ( fracDown == 0 )
? 0
: cf2_intToFixed( 1 ) - fracDown;
CF2_Fixed upMoveUp = fracUp == 0
CF2_Fixed upMoveUp = ( fracUp == 0 )
? 0
: cf2_intToFixed( 1 ) - fracUp;
+478 -338
View File
@@ -47,6 +47,8 @@
#include "cf2error.h"
#include "cffload.h"
/*************************************************************************/
/* */
@@ -215,8 +217,8 @@
cf2_cmdESC, /* 12 */
cf2_cmdRESERVED_13, /* 13 */
cf2_cmdENDCHAR, /* 14 */
cf2_cmdRESERVED_15, /* 15 */
cf2_cmdRESERVED_16, /* 16 */
cf2_cmdVSINDEX, /* 15 */
cf2_cmdBLEND, /* 16 */
cf2_cmdRESERVED_17, /* 17 */
cf2_cmdHSTEMHM, /* 18 */
cf2_cmdHINTMASK, /* 19 */
@@ -273,7 +275,8 @@
cf2_escHFLEX, /* 34 */
cf2_escFLEX, /* 35 */
cf2_escHFLEX1, /* 36 */
cf2_escFLEX1 /* 37 */
cf2_escFLEX1, /* 37 */
cf2_escRESERVED_38 /* 38 & all higher */
};
@@ -344,7 +347,7 @@
vals[0] = *curX;
vals[1] = *curY;
index = 0;
isHFlex = readFromStack[9] == FALSE;
isHFlex = FT_BOOL( readFromStack[9] == FALSE );
top = isHFlex ? 9 : 10;
for ( i = 0; i < top; i++ )
@@ -403,6 +406,43 @@
}
/* Blend numOperands on the stack, */
/* store results into the first numBlends values, */
/* then pop remaining arguments. */
static void
cf2_doBlend( const CFF_Blend blend,
CF2_Stack opStack,
CF2_UInt numBlends )
{
CF2_UInt delta;
CF2_UInt base;
CF2_UInt i, j;
CF2_UInt numOperands = (CF2_UInt)( numBlends * blend->lenBV );
base = cf2_stack_count( opStack ) - numOperands;
delta = base + numBlends;
for ( i = 0; i < numBlends; i++ )
{
const CF2_Fixed* weight = &blend->BV[1];
/* start with first term */
CF2_Fixed sum = cf2_stack_getReal( opStack, i + base );
for ( j = 1; j < blend->lenBV; j++ )
sum += FT_MulFix( *weight++, cf2_stack_getReal( opStack, delta++ ) );
/* store blended result */
cf2_stack_setReal( opStack, i + base, sum );
}
/* leave only `numBlends' results on stack */
cf2_stack_pop( opStack, numOperands - numBlends );
}
/*
* `error' is a shared error code used by many objects in this
* routine. Before the code continues from an error, it must check and
@@ -445,6 +485,7 @@
CF2_Fixed hintOriginY = curY;
CF2_Stack opStack = NULL;
FT_UInt stackSize;
FT_Byte op1; /* first opcode byte */
CF2_F16Dot16 storage[CF2_STORAGE_SIZE]; /* for `put' and `get' */
@@ -525,19 +566,24 @@
* If one of the above operators occurs without explicitly specifying
* a width, we assume the default width.
*
* CFF2 charstrings always return the default width (0).
*
*/
haveWidth = FALSE;
haveWidth = font->isCFF2 ? TRUE : FALSE;
*width = cf2_getDefaultWidthX( decoder );
/*
* Note: at this point, all pointers to resources must be NULL
* and all local objects must be initialized.
* There must be no branches to exit: above this point.
* Note: At this point, all pointers to resources must be NULL
* and all local objects must be initialized.
* There must be no branches to `exit:' above this point.
*
*/
/* allocate an operand stack */
opStack = cf2_stack_init( memory, error );
stackSize = font->isCFF2 ? cf2_getMaxstack( decoder )
: CF2_OPERAND_STACK_SIZE;
opStack = cf2_stack_init( memory, error, stackSize );
if ( !opStack )
{
lastError = FT_THROW( Out_Of_Memory );
@@ -566,14 +612,23 @@
{
/* If we've reached the end of the charstring, simulate a */
/* cf2_cmdRETURN or cf2_cmdENDCHAR. */
/* We do this for both CFF and CFF2. */
if ( charstringIndex )
op1 = cf2_cmdRETURN; /* end of buffer for subroutine */
else
op1 = cf2_cmdENDCHAR; /* end of buffer for top level charstring */
}
else
{
op1 = (FT_Byte)cf2_buf_readByte( charstring );
/* Explicit RETURN and ENDCHAR in CFF2 should be ignored. */
/* Note: Trace message will report 0 instead of 11 or 14. */
if ( ( op1 == cf2_cmdRETURN || op1 == cf2_cmdENDCHAR ) &&
font->isCFF2 )
op1 = cf2_cmdRESERVED_0;
}
/* check for errors once per loop */
if ( *error )
goto exit;
@@ -591,13 +646,78 @@
case cf2_cmdRESERVED_2:
case cf2_cmdRESERVED_9:
case cf2_cmdRESERVED_13:
case cf2_cmdRESERVED_15:
case cf2_cmdRESERVED_16:
case cf2_cmdRESERVED_17:
/* we may get here if we have a prior error */
FT_TRACE4(( " unknown op (%d)\n", op1 ));
break;
case cf2_cmdVSINDEX:
FT_TRACE4(( " vsindex\n" ));
if ( !font->isCFF2 )
break; /* clear stack & ignore */
if ( font->blend.usedBV )
{
/* vsindex not allowed after blend */
lastError = FT_THROW( Invalid_Glyph_Format );
goto exit;
}
{
FT_Int temp = cf2_stack_popInt( opStack );
if ( temp >= 0 )
font->vsindex = (FT_UInt)temp;
}
break;
case cf2_cmdBLEND:
{
FT_UInt numBlends;
FT_TRACE4(( " blend\n" ));
if ( !font->isCFF2 )
break; /* clear stack & ignore */
/* do we have a `blend' op in a non-variant font? */
if ( !font->blend.font )
{
lastError = FT_THROW( Invalid_Glyph_Format );
goto exit;
}
/* check cached blend vector */
if ( cff_blend_check_vector( &font->blend,
font->vsindex,
font->lenNDV,
font->NDV ) )
{
lastError = cff_blend_build_vector( &font->blend,
font->vsindex,
font->lenNDV,
font->NDV );
if ( lastError )
goto exit;
}
/* do the blend */
numBlends = (FT_UInt)cf2_stack_popInt( opStack );
if ( numBlends > stackSize )
{
lastError = FT_THROW( Invalid_Glyph_Format );
goto exit;
}
cf2_doBlend( &font->blend, opStack, numBlends );
font->blend.usedBV = TRUE;
}
continue; /* do not clear the stack */
case cf2_cmdHSTEMHM:
case cf2_cmdHSTEM:
FT_TRACE4(( op1 == cf2_cmdHSTEMHM ? " hstemhm\n" : " hstem\n" ));
@@ -690,7 +810,7 @@
CF2_UInt index;
CF2_UInt count = cf2_stack_count( opStack );
FT_Bool isX = op1 == cf2_cmdHLINETO;
FT_Bool isX = FT_BOOL( op1 == cf2_cmdHLINETO );
FT_TRACE4(( isX ? " hlineto\n" : " vlineto\n" ));
@@ -835,325 +955,10 @@
FT_Byte op2 = (FT_Byte)cf2_buf_readByte( charstring );
/* first switch for 2-byte operators handles CFF2 */
/* and opcodes that are reserved for both CFF and CFF2 */
switch ( op2 )
{
case cf2_escDOTSECTION:
/* something about `flip type of locking' -- ignore it */
FT_TRACE4(( " dotsection\n" ));
break;
case cf2_escAND:
{
CF2_F16Dot16 arg1;
CF2_F16Dot16 arg2;
FT_TRACE4(( " and\n" ));
arg2 = cf2_stack_popFixed( opStack );
arg1 = cf2_stack_popFixed( opStack );
cf2_stack_pushInt( opStack, arg1 && arg2 );
}
continue; /* do not clear the stack */
case cf2_escOR:
{
CF2_F16Dot16 arg1;
CF2_F16Dot16 arg2;
FT_TRACE4(( " or\n" ));
arg2 = cf2_stack_popFixed( opStack );
arg1 = cf2_stack_popFixed( opStack );
cf2_stack_pushInt( opStack, arg1 || arg2 );
}
continue; /* do not clear the stack */
case cf2_escNOT:
{
CF2_F16Dot16 arg;
FT_TRACE4(( " not\n" ));
arg = cf2_stack_popFixed( opStack );
cf2_stack_pushInt( opStack, !arg );
}
continue; /* do not clear the stack */
case cf2_escABS:
{
CF2_F16Dot16 arg;
FT_TRACE4(( " abs\n" ));
arg = cf2_stack_popFixed( opStack );
cf2_stack_pushFixed( opStack, FT_ABS( arg ) );
}
continue; /* do not clear the stack */
case cf2_escADD:
{
CF2_F16Dot16 summand1;
CF2_F16Dot16 summand2;
FT_TRACE4(( " add\n" ));
summand2 = cf2_stack_popFixed( opStack );
summand1 = cf2_stack_popFixed( opStack );
cf2_stack_pushFixed( opStack, summand1 + summand2 );
}
continue; /* do not clear the stack */
case cf2_escSUB:
{
CF2_F16Dot16 minuend;
CF2_F16Dot16 subtrahend;
FT_TRACE4(( " sub\n" ));
subtrahend = cf2_stack_popFixed( opStack );
minuend = cf2_stack_popFixed( opStack );
cf2_stack_pushFixed( opStack, minuend - subtrahend );
}
continue; /* do not clear the stack */
case cf2_escDIV:
{
CF2_F16Dot16 dividend;
CF2_F16Dot16 divisor;
FT_TRACE4(( " div\n" ));
divisor = cf2_stack_popFixed( opStack );
dividend = cf2_stack_popFixed( opStack );
cf2_stack_pushFixed( opStack, FT_DivFix( dividend, divisor ) );
}
continue; /* do not clear the stack */
case cf2_escNEG:
{
CF2_F16Dot16 arg;
FT_TRACE4(( " neg\n" ));
arg = cf2_stack_popFixed( opStack );
cf2_stack_pushFixed( opStack, -arg );
}
continue; /* do not clear the stack */
case cf2_escEQ:
{
CF2_F16Dot16 arg1;
CF2_F16Dot16 arg2;
FT_TRACE4(( " eq\n" ));
arg2 = cf2_stack_popFixed( opStack );
arg1 = cf2_stack_popFixed( opStack );
cf2_stack_pushInt( opStack, arg1 == arg2 );
}
continue; /* do not clear the stack */
case cf2_escDROP:
FT_TRACE4(( " drop\n" ));
(void)cf2_stack_popFixed( opStack );
continue; /* do not clear the stack */
case cf2_escPUT:
{
CF2_F16Dot16 val;
CF2_Int idx;
FT_TRACE4(( " put\n" ));
idx = cf2_stack_popInt( opStack );
val = cf2_stack_popFixed( opStack );
if ( idx >= 0 && idx < CF2_STORAGE_SIZE )
storage[idx] = val;
}
continue; /* do not clear the stack */
case cf2_escGET:
{
CF2_Int idx;
FT_TRACE4(( " get\n" ));
idx = cf2_stack_popInt( opStack );
if ( idx >= 0 && idx < CF2_STORAGE_SIZE )
cf2_stack_pushFixed( opStack, storage[idx] );
}
continue; /* do not clear the stack */
case cf2_escIFELSE:
{
CF2_F16Dot16 arg1;
CF2_F16Dot16 arg2;
CF2_F16Dot16 cond1;
CF2_F16Dot16 cond2;
FT_TRACE4(( " ifelse\n" ));
cond2 = cf2_stack_popFixed( opStack );
cond1 = cf2_stack_popFixed( opStack );
arg2 = cf2_stack_popFixed( opStack );
arg1 = cf2_stack_popFixed( opStack );
cf2_stack_pushFixed( opStack, cond1 <= cond2 ? arg1 : arg2 );
}
continue; /* do not clear the stack */
case cf2_escRANDOM: /* in spec */
FT_TRACE4(( " random\n" ));
CF2_FIXME;
break;
case cf2_escMUL:
{
CF2_F16Dot16 factor1;
CF2_F16Dot16 factor2;
FT_TRACE4(( " mul\n" ));
factor2 = cf2_stack_popFixed( opStack );
factor1 = cf2_stack_popFixed( opStack );
cf2_stack_pushFixed( opStack, FT_MulFix( factor1, factor2 ) );
}
continue; /* do not clear the stack */
case cf2_escSQRT:
{
CF2_F16Dot16 arg;
FT_TRACE4(( " sqrt\n" ));
arg = cf2_stack_popFixed( opStack );
if ( arg > 0 )
{
FT_Fixed root = arg;
FT_Fixed new_root;
/* Babylonian method */
for (;;)
{
new_root = ( root + FT_DivFix( arg, root ) + 1 ) >> 1;
if ( new_root == root )
break;
root = new_root;
}
arg = new_root;
}
else
arg = 0;
cf2_stack_pushFixed( opStack, arg );
}
continue; /* do not clear the stack */
case cf2_escDUP:
{
CF2_F16Dot16 arg;
FT_TRACE4(( " dup\n" ));
arg = cf2_stack_popFixed( opStack );
cf2_stack_pushFixed( opStack, arg );
cf2_stack_pushFixed( opStack, arg );
}
continue; /* do not clear the stack */
case cf2_escEXCH:
{
CF2_F16Dot16 arg1;
CF2_F16Dot16 arg2;
FT_TRACE4(( " exch\n" ));
arg2 = cf2_stack_popFixed( opStack );
arg1 = cf2_stack_popFixed( opStack );
cf2_stack_pushFixed( opStack, arg2 );
cf2_stack_pushFixed( opStack, arg1 );
}
continue; /* do not clear the stack */
case cf2_escINDEX:
{
CF2_Int idx;
CF2_UInt size;
FT_TRACE4(( " index\n" ));
idx = cf2_stack_popInt( opStack );
size = cf2_stack_count( opStack );
if ( size > 0 )
{
/* for `cf2_stack_getReal', index 0 is bottom of stack */
CF2_UInt gr_idx;
if ( idx < 0 )
gr_idx = size - 1;
else if ( (CF2_UInt)idx >= size )
gr_idx = 0;
else
gr_idx = size - 1 - (CF2_UInt)idx;
cf2_stack_pushFixed( opStack,
cf2_stack_getReal( opStack, gr_idx ) );
}
}
continue; /* do not clear the stack */
case cf2_escROLL:
{
CF2_Int idx;
CF2_Int count;
FT_TRACE4(( " roll\n" ));
idx = cf2_stack_popInt( opStack );
count = cf2_stack_popInt( opStack );
cf2_stack_roll( opStack, count, idx );
}
continue; /* do not clear the stack */
case cf2_escHFLEX:
{
static const FT_Bool readFromStack[12] =
@@ -1250,6 +1055,7 @@
}
continue;
/* these opcodes are reserved in both CFF & CFF2 */
case cf2_escRESERVED_1:
case cf2_escRESERVED_2:
case cf2_escRESERVED_6:
@@ -1263,12 +1069,342 @@
case cf2_escRESERVED_31:
case cf2_escRESERVED_32:
case cf2_escRESERVED_33:
default:
FT_TRACE4(( " unknown op (12, %d)\n", op2 ));
break;
}; /* end of switch statement checking `op2' */
default:
{
if ( font->isCFF2 || op2 >= cf2_escRESERVED_38 )
FT_TRACE4(( " unknown op (12, %d)\n", op2 ));
else
{
/* second switch for 2-byte operators handles just CFF */
switch ( op2 )
{
case cf2_escDOTSECTION:
/* something about `flip type of locking' -- ignore it */
FT_TRACE4(( " dotsection\n" ));
break;
case cf2_escAND:
{
CF2_F16Dot16 arg1;
CF2_F16Dot16 arg2;
FT_TRACE4(( " and\n" ));
arg2 = cf2_stack_popFixed( opStack );
arg1 = cf2_stack_popFixed( opStack );
cf2_stack_pushInt( opStack, arg1 && arg2 );
}
continue; /* do not clear the stack */
case cf2_escOR:
{
CF2_F16Dot16 arg1;
CF2_F16Dot16 arg2;
FT_TRACE4(( " or\n" ));
arg2 = cf2_stack_popFixed( opStack );
arg1 = cf2_stack_popFixed( opStack );
cf2_stack_pushInt( opStack, arg1 || arg2 );
}
continue; /* do not clear the stack */
case cf2_escNOT:
{
CF2_F16Dot16 arg;
FT_TRACE4(( " not\n" ));
arg = cf2_stack_popFixed( opStack );
cf2_stack_pushInt( opStack, !arg );
}
continue; /* do not clear the stack */
case cf2_escABS:
{
CF2_F16Dot16 arg;
FT_TRACE4(( " abs\n" ));
arg = cf2_stack_popFixed( opStack );
cf2_stack_pushFixed( opStack, FT_ABS( arg ) );
}
continue; /* do not clear the stack */
case cf2_escADD:
{
CF2_F16Dot16 summand1;
CF2_F16Dot16 summand2;
FT_TRACE4(( " add\n" ));
summand2 = cf2_stack_popFixed( opStack );
summand1 = cf2_stack_popFixed( opStack );
cf2_stack_pushFixed( opStack, summand1 + summand2 );
}
continue; /* do not clear the stack */
case cf2_escSUB:
{
CF2_F16Dot16 minuend;
CF2_F16Dot16 subtrahend;
FT_TRACE4(( " sub\n" ));
subtrahend = cf2_stack_popFixed( opStack );
minuend = cf2_stack_popFixed( opStack );
cf2_stack_pushFixed( opStack, minuend - subtrahend );
}
continue; /* do not clear the stack */
case cf2_escDIV:
{
CF2_F16Dot16 dividend;
CF2_F16Dot16 divisor;
FT_TRACE4(( " div\n" ));
divisor = cf2_stack_popFixed( opStack );
dividend = cf2_stack_popFixed( opStack );
cf2_stack_pushFixed( opStack, FT_DivFix( dividend, divisor ) );
}
continue; /* do not clear the stack */
case cf2_escNEG:
{
CF2_F16Dot16 arg;
FT_TRACE4(( " neg\n" ));
arg = cf2_stack_popFixed( opStack );
cf2_stack_pushFixed( opStack, -arg );
}
continue; /* do not clear the stack */
case cf2_escEQ:
{
CF2_F16Dot16 arg1;
CF2_F16Dot16 arg2;
FT_TRACE4(( " eq\n" ));
arg2 = cf2_stack_popFixed( opStack );
arg1 = cf2_stack_popFixed( opStack );
cf2_stack_pushInt( opStack, arg1 == arg2 );
}
continue; /* do not clear the stack */
case cf2_escDROP:
FT_TRACE4(( " drop\n" ));
(void)cf2_stack_popFixed( opStack );
continue; /* do not clear the stack */
case cf2_escPUT:
{
CF2_F16Dot16 val;
CF2_Int idx;
FT_TRACE4(( " put\n" ));
idx = cf2_stack_popInt( opStack );
val = cf2_stack_popFixed( opStack );
if ( idx >= 0 && idx < CF2_STORAGE_SIZE )
storage[idx] = val;
}
continue; /* do not clear the stack */
case cf2_escGET:
{
CF2_Int idx;
FT_TRACE4(( " get\n" ));
idx = cf2_stack_popInt( opStack );
if ( idx >= 0 && idx < CF2_STORAGE_SIZE )
cf2_stack_pushFixed( opStack, storage[idx] );
}
continue; /* do not clear the stack */
case cf2_escIFELSE:
{
CF2_F16Dot16 arg1;
CF2_F16Dot16 arg2;
CF2_F16Dot16 cond1;
CF2_F16Dot16 cond2;
FT_TRACE4(( " ifelse\n" ));
cond2 = cf2_stack_popFixed( opStack );
cond1 = cf2_stack_popFixed( opStack );
arg2 = cf2_stack_popFixed( opStack );
arg1 = cf2_stack_popFixed( opStack );
cf2_stack_pushFixed( opStack, cond1 <= cond2 ? arg1 : arg2 );
}
continue; /* do not clear the stack */
case cf2_escRANDOM: /* in spec */
FT_TRACE4(( " random\n" ));
CF2_FIXME;
break;
case cf2_escMUL:
{
CF2_F16Dot16 factor1;
CF2_F16Dot16 factor2;
FT_TRACE4(( " mul\n" ));
factor2 = cf2_stack_popFixed( opStack );
factor1 = cf2_stack_popFixed( opStack );
cf2_stack_pushFixed( opStack, FT_MulFix( factor1, factor2 ) );
}
continue; /* do not clear the stack */
case cf2_escSQRT:
{
CF2_F16Dot16 arg;
FT_TRACE4(( " sqrt\n" ));
arg = cf2_stack_popFixed( opStack );
if ( arg > 0 )
{
FT_Fixed root = arg;
FT_Fixed new_root;
/* Babylonian method */
for (;;)
{
new_root = ( root + FT_DivFix( arg, root ) + 1 ) >> 1;
if ( new_root == root )
break;
root = new_root;
}
arg = new_root;
}
else
arg = 0;
cf2_stack_pushFixed( opStack, arg );
}
continue; /* do not clear the stack */
case cf2_escDUP:
{
CF2_F16Dot16 arg;
FT_TRACE4(( " dup\n" ));
arg = cf2_stack_popFixed( opStack );
cf2_stack_pushFixed( opStack, arg );
cf2_stack_pushFixed( opStack, arg );
}
continue; /* do not clear the stack */
case cf2_escEXCH:
{
CF2_F16Dot16 arg1;
CF2_F16Dot16 arg2;
FT_TRACE4(( " exch\n" ));
arg2 = cf2_stack_popFixed( opStack );
arg1 = cf2_stack_popFixed( opStack );
cf2_stack_pushFixed( opStack, arg2 );
cf2_stack_pushFixed( opStack, arg1 );
}
continue; /* do not clear the stack */
case cf2_escINDEX:
{
CF2_Int idx;
CF2_UInt size;
FT_TRACE4(( " index\n" ));
idx = cf2_stack_popInt( opStack );
size = cf2_stack_count( opStack );
if ( size > 0 )
{
/* for `cf2_stack_getReal', index 0 is bottom of stack */
CF2_UInt gr_idx;
if ( idx < 0 )
gr_idx = size - 1;
else if ( (CF2_UInt)idx >= size )
gr_idx = 0;
else
gr_idx = size - 1 - (CF2_UInt)idx;
cf2_stack_pushFixed( opStack,
cf2_stack_getReal( opStack, gr_idx ) );
}
}
continue; /* do not clear the stack */
case cf2_escROLL:
{
CF2_Int idx;
CF2_Int count;
FT_TRACE4(( " roll\n" ));
idx = cf2_stack_popInt( opStack );
count = cf2_stack_popInt( opStack );
cf2_stack_roll( opStack, count, idx );
}
continue; /* do not clear the stack */
} /* end of 2nd switch checking op2 */
}
}
} /* end of 1st switch checking op2 */
} /* case cf2_cmdESC */
break;
case cf2_cmdENDCHAR:
@@ -1290,7 +1426,8 @@
/* close path if still open */
cf2_glyphpath_closeOpenPath( &glyphPath );
if ( cf2_stack_count( opStack ) > 1 )
/* disable seac for CFF2 (charstring ending with args on stack) */
if ( !font->isCFF2 && cf2_stack_count( opStack ) > 1 )
{
/* must be either 4 or 5 -- */
/* this is a (deprecated) implied `seac' operator */
@@ -1528,7 +1665,7 @@
{
x1 = cf2_stack_getReal( opStack, index ) + curX;
++index;
index++;
}
else
x1 = curX;
@@ -1573,7 +1710,7 @@
{
y1 = cf2_stack_getReal( opStack, index ) + curY;
++index;
index++;
}
else
y1 = curY;
@@ -1601,7 +1738,7 @@
CF2_UInt count, count1 = cf2_stack_count( opStack );
CF2_UInt index = 0;
FT_Bool alternate = op1 == cf2_cmdHVCURVETO;
FT_Bool alternate = FT_BOOL( op1 == cf2_cmdHVCURVETO );
/* if `cf2_stack_count' isn't of the form 8n, 8n+1, */
@@ -1630,7 +1767,7 @@
{
x3 = cf2_stack_getReal( opStack, index + 4 ) + x2;
++index;
index++;
}
else
x3 = x2;
@@ -1649,7 +1786,7 @@
{
y3 = cf2_stack_getReal( opStack, index + 4 ) + y2;
++index;
index++;
}
else
y3 = y2;
@@ -1750,7 +1887,7 @@
( byte3 << 8 ) |
byte4 );
FT_TRACE4(( " %.2f", v / 65536.0 ));
FT_TRACE4(( " %.5f", v / 65536.0 ));
cf2_stack_pushFixed( opStack, v );
}
@@ -1771,6 +1908,9 @@
/* check whether last error seen is also the first one */
cf2_setError( error, lastError );
if ( *error )
FT_TRACE4(( "charstring error %d\n", *error ));
/* free resources from objects we've used */
cf2_glyphpath_finalize( &glyphPath );
cf2_arrstack_finalize( &vStemHintArray );
+57 -14
View File
@@ -51,7 +51,8 @@
/* `error'). */
FT_LOCAL_DEF( CF2_Stack )
cf2_stack_init( FT_Memory memory,
FT_Error* e )
FT_Error* e,
FT_UInt stackSize )
{
FT_Error error = FT_Err_Ok; /* for FT_NEW */
@@ -63,9 +64,18 @@
/* initialize the structure; FT_NEW zeroes it */
stack->memory = memory;
stack->error = e;
stack->top = &stack->buffer[0]; /* empty stack */
}
/* allocate the stack buffer */
if ( FT_NEW_ARRAY( stack->buffer, stackSize ) )
{
FT_FREE( stack );
return NULL;
}
stack->stackSize = stackSize;
stack->top = stack->buffer; /* empty stack */
return stack;
}
@@ -77,6 +87,8 @@
{
FT_Memory memory = stack->memory;
/* free the buffer */
FT_FREE( stack->buffer );
/* free the main structure */
FT_FREE( stack );
@@ -87,7 +99,7 @@
FT_LOCAL_DEF( CF2_UInt )
cf2_stack_count( CF2_Stack stack )
{
return (CF2_UInt)( stack->top - &stack->buffer[0] );
return (CF2_UInt)( stack->top - stack->buffer );
}
@@ -95,7 +107,7 @@
cf2_stack_pushInt( CF2_Stack stack,
CF2_Int val )
{
if ( stack->top == &stack->buffer[CF2_OPERAND_STACK_SIZE] )
if ( stack->top == stack->buffer + stack->stackSize )
{
CF2_SET_ERROR( stack->error, Stack_Overflow );
return; /* stack overflow */
@@ -103,7 +115,7 @@
stack->top->u.i = val;
stack->top->type = CF2_NumberInt;
++stack->top;
stack->top++;
}
@@ -111,7 +123,7 @@
cf2_stack_pushFixed( CF2_Stack stack,
CF2_Fixed val )
{
if ( stack->top == &stack->buffer[CF2_OPERAND_STACK_SIZE] )
if ( stack->top == stack->buffer + stack->stackSize )
{
CF2_SET_ERROR( stack->error, Stack_Overflow );
return; /* stack overflow */
@@ -119,7 +131,7 @@
stack->top->u.r = val;
stack->top->type = CF2_NumberFixed;
++stack->top;
stack->top++;
}
@@ -127,7 +139,7 @@
FT_LOCAL_DEF( CF2_Int )
cf2_stack_popInt( CF2_Stack stack )
{
if ( stack->top == &stack->buffer[0] )
if ( stack->top == stack->buffer )
{
CF2_SET_ERROR( stack->error, Stack_Underflow );
return 0; /* underflow */
@@ -138,7 +150,7 @@
return 0; /* type mismatch */
}
--stack->top;
stack->top--;
return stack->top->u.i;
}
@@ -149,13 +161,13 @@
FT_LOCAL_DEF( CF2_Fixed )
cf2_stack_popFixed( CF2_Stack stack )
{
if ( stack->top == &stack->buffer[0] )
if ( stack->top == stack->buffer )
{
CF2_SET_ERROR( stack->error, Stack_Underflow );
return cf2_intToFixed( 0 ); /* underflow */
}
--stack->top;
stack->top--;
switch ( stack->top->type )
{
@@ -175,7 +187,7 @@
cf2_stack_getReal( CF2_Stack stack,
CF2_UInt idx )
{
FT_ASSERT( cf2_stack_count( stack ) <= CF2_OPERAND_STACK_SIZE );
FT_ASSERT( cf2_stack_count( stack ) <= stack->stackSize );
if ( idx >= cf2_stack_count( stack ) )
{
@@ -195,7 +207,38 @@
}
FT_LOCAL( void )
/* provide random access to stack */
FT_LOCAL_DEF( void )
cf2_stack_setReal( CF2_Stack stack,
CF2_UInt idx,
CF2_Fixed val )
{
if ( idx > cf2_stack_count( stack ) )
{
CF2_SET_ERROR( stack->error, Stack_Overflow );
return;
}
stack->buffer[idx].u.r = val;
stack->buffer[idx].type = CF2_NumberFixed;
}
/* discard (pop) num values from stack */
FT_LOCAL_DEF( void )
cf2_stack_pop( CF2_Stack stack,
CF2_UInt num )
{
if ( num > cf2_stack_count( stack ) )
{
CF2_SET_ERROR( stack->error, Stack_Underflow );
return;
}
stack->top -= num;
}
FT_LOCAL_DEF( void )
cf2_stack_roll( CF2_Stack stack,
CF2_Int count,
CF2_Int shift )
@@ -278,7 +321,7 @@
FT_LOCAL_DEF( void )
cf2_stack_clear( CF2_Stack stack )
{
stack->top = &stack->buffer[0];
stack->top = stack->buffer;
}
+12 -2
View File
@@ -62,15 +62,17 @@ FT_BEGIN_HEADER
{
FT_Memory memory;
FT_Error* error;
CF2_StackNumber buffer[CF2_OPERAND_STACK_SIZE];
CF2_StackNumber* buffer;
CF2_StackNumber* top;
FT_UInt stackSize;
} CF2_StackRec, *CF2_Stack;
FT_LOCAL( CF2_Stack )
cf2_stack_init( FT_Memory memory,
FT_Error* error );
FT_Error* error,
FT_UInt stackSize );
FT_LOCAL( void )
cf2_stack_free( CF2_Stack stack );
@@ -92,6 +94,14 @@ FT_BEGIN_HEADER
FT_LOCAL( CF2_Fixed )
cf2_stack_getReal( CF2_Stack stack,
CF2_UInt idx );
FT_LOCAL( void )
cf2_stack_setReal( CF2_Stack stack,
CF2_UInt idx,
CF2_Fixed val );
FT_LOCAL( void )
cf2_stack_pop( CF2_Stack stack,
CF2_UInt num );
FT_LOCAL( void )
cf2_stack_roll( CF2_Stack stack,
+25 -12
View File
@@ -104,15 +104,21 @@
}
FT_DEFINE_CMAP_CLASS(cff_cmap_encoding_class_rec,
FT_DEFINE_CMAP_CLASS(
cff_cmap_encoding_class_rec,
sizeof ( CFF_CMapStdRec ),
(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_InitFunc) cff_cmap_encoding_init, /* init */
(FT_CMap_DoneFunc) cff_cmap_encoding_done, /* done */
(FT_CMap_CharIndexFunc)cff_cmap_encoding_char_index, /* char_index */
(FT_CMap_CharNextFunc) cff_cmap_encoding_char_next, /* char_next */
NULL, NULL, NULL, NULL, NULL
(FT_CMap_CharVarIndexFunc) NULL, /* char_var_index */
(FT_CMap_CharVarIsDefaultFunc)NULL, /* char_var_default */
(FT_CMap_VariantListFunc) NULL, /* variant_list */
(FT_CMap_CharVariantListFunc) NULL, /* charvariant_list */
(FT_CMap_VariantCharListFunc) NULL /* variantchar_list */
)
@@ -202,15 +208,22 @@
}
FT_DEFINE_CMAP_CLASS(cff_cmap_unicode_class_rec,
FT_DEFINE_CMAP_CLASS(
cff_cmap_unicode_class_rec,
sizeof ( PS_UnicodesRec ),
(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_InitFunc) cff_cmap_unicode_init, /* init */
(FT_CMap_DoneFunc) cff_cmap_unicode_done, /* done */
(FT_CMap_CharIndexFunc)cff_cmap_unicode_char_index, /* char_index */
(FT_CMap_CharNextFunc) cff_cmap_unicode_char_next, /* char_next */
NULL, NULL, NULL, NULL, NULL
(FT_CMap_CharVarIndexFunc) NULL, /* char_var_index */
(FT_CMap_CharVarIsDefaultFunc)NULL, /* char_var_default */
(FT_CMap_VariantListFunc) NULL, /* variant_list */
(FT_CMap_CharVariantListFunc) NULL, /* charvariant_list */
(FT_CMap_VariantCharListFunc) NULL /* variantchar_list */
)
/* END */
+204 -14
View File
@@ -32,6 +32,10 @@
#include "cffcmap.h"
#include "cffparse.h"
#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
#include FT_SERVICE_MULTIPLE_MASTERS_H
#endif
#include "cfferrs.h"
#include "cffpic.h"
@@ -207,6 +211,13 @@
if ( flags & FT_LOAD_VERTICAL_LAYOUT )
{
#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
/* no fast retrieval for blended MM fonts without VVAR table */
if ( !ttface->is_default_instance &&
!( ttface->variation_support & TT_FACE_FLAG_VAR_VADVANCE ) )
return FT_THROW( Unimplemented_Feature );
#endif
/* check whether we have data from the `vmtx' table at all; */
/* otherwise we extract the info from the CFF glyphstrings */
/* (instead of synthesizing a global value using the `OS/2' */
@@ -232,6 +243,13 @@
}
else
{
#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
/* no fast retrieval for blended MM fonts without HVAR table */
if ( !ttface->is_default_instance &&
!( ttface->variation_support & TT_FACE_FLAG_VAR_HADVANCE ) )
return FT_THROW( Unimplemented_Feature );
#endif
/* check whether we have data from the `hmtx' table at all */
if ( !ttface->horizontal.number_Of_HMetrics )
goto Missing_Table;
@@ -291,6 +309,35 @@
FT_Error error;
/* CFF2 table does not have glyph names; */
/* we need to use `post' table method */
if ( font->version_major == 2 )
{
FT_Library library = FT_FACE_LIBRARY( face );
FT_Module sfnt_module = FT_Get_Module( library, "sfnt" );
FT_Service_GlyphDict service =
(FT_Service_GlyphDict)ft_module_get_service(
sfnt_module,
FT_SERVICE_ID_GLYPH_DICT,
0 );
if ( service && service->get_name )
return service->get_name( FT_FACE( face ),
glyph_index,
buffer,
buffer_max );
else
{
FT_ERROR(( "cff_get_glyph_name:"
" cannot get glyph name from a CFF2 font\n"
" "
" without the `PSNames' module\n" ));
error = FT_THROW( Missing_Module );
goto Exit;
}
}
if ( !font->psnames )
{
FT_ERROR(( "cff_get_glyph_name:"
@@ -332,6 +379,31 @@
cff = (CFF_FontRec *)face->extra.data;
charset = &cff->charset;
/* CFF2 table does not have glyph names; */
/* we need to use `post' table method */
if ( cff->version_major == 2 )
{
FT_Library library = FT_FACE_LIBRARY( face );
FT_Module sfnt_module = FT_Get_Module( library, "sfnt" );
FT_Service_GlyphDict service =
(FT_Service_GlyphDict)ft_module_get_service(
sfnt_module,
FT_SERVICE_ID_GLYPH_DICT,
0 );
if ( service && service->name_index )
return service->name_index( FT_FACE( face ), glyph_name );
else
{
FT_ERROR(( "cff_get_name_index:"
" cannot get glyph index from a CFF2 font\n"
" "
" without the `PSNames' module\n" ));
return 0;
}
}
FT_FACE_FIND_GLOBAL_SERVICE( face, psnames, POSTSCRIPT_CMAPS );
if ( !psnames )
return 0;
@@ -358,6 +430,7 @@
FT_DEFINE_SERVICE_GLYPHDICTREC(
cff_service_glyph_dict,
(FT_GlyphDict_GetNameFunc) cff_get_glyph_name, /* get_name */
(FT_GlyphDict_NameIndexFunc)cff_get_name_index /* name_index */
)
@@ -383,11 +456,11 @@
FT_Error error = FT_Err_Ok;
if ( cff && cff->font_info == NULL )
if ( cff && !cff->font_info )
{
CFF_FontRecDict dict = &cff->top_font.font_dict;
CFF_FontRecDict dict = &cff->top_font.font_dict;
PS_FontInfoRec *font_info = NULL;
FT_Memory memory = face->root.memory;
FT_Memory memory = face->root.memory;
if ( FT_ALLOC( font_info, sizeof ( *font_info ) ) )
@@ -421,6 +494,7 @@
FT_DEFINE_SERVICE_PSINFOREC(
cff_service_ps_info,
(PS_GetFontInfoFunc) cff_ps_get_font_info, /* ps_get_font_info */
(PS_GetFontExtraFunc) NULL, /* ps_get_font_extra */
(PS_HasGlyphNamesFunc) cff_ps_has_glyph_names, /* ps_has_glyph_names */
@@ -453,7 +527,8 @@
FT_Service_PsFontName service =
(FT_Service_PsFontName)ft_module_get_service(
sfnt_module,
FT_SERVICE_ID_POSTSCRIPT_FONT_NAME );
FT_SERVICE_ID_POSTSCRIPT_FONT_NAME,
0 );
if ( service && service->get_ps_font_name )
@@ -466,6 +541,7 @@
FT_DEFINE_SERVICE_PSFONTNAMEREC(
cff_service_ps_name,
(FT_PsName_GetFunc)cff_get_ps_name /* get_ps_font_name */
)
@@ -491,21 +567,21 @@
FT_Library library = FT_FACE_LIBRARY( face );
cmap_info->language = 0;
cmap_info->format = 0;
if ( cmap->clazz != &CFF_CMAP_ENCODING_CLASS_REC_GET &&
cmap->clazz != &CFF_CMAP_UNICODE_CLASS_REC_GET )
{
FT_Module sfnt = FT_Get_Module( library, "sfnt" );
FT_Service_TTCMaps service =
(FT_Service_TTCMaps)ft_module_get_service( sfnt,
FT_SERVICE_ID_TT_CMAP );
FT_SERVICE_ID_TT_CMAP,
0 );
if ( service && service->get_cmap_info )
error = service->get_cmap_info( charmap, cmap_info );
}
else
error = FT_THROW( Invalid_CharMap_Format );
return error;
}
@@ -513,6 +589,7 @@
FT_DEFINE_SERVICE_TTCMAPSREC(
cff_service_get_cmap_info,
(TT_CMap_Info_GetFunc)cff_get_cmap_info /* get_cmap_info */
)
@@ -544,7 +621,7 @@
if ( registry )
{
if ( cff->registry == NULL )
if ( !cff->registry )
cff->registry = cff_index_get_sid_string( cff,
dict->cid_registry );
*registry = cff->registry;
@@ -552,7 +629,7 @@
if ( ordering )
{
if ( cff->ordering == NULL )
if ( !cff->ordering )
cff->ordering = cff_index_get_sid_string( cff,
dict->cid_ordering );
*ordering = cff->ordering;
@@ -643,6 +720,7 @@
FT_DEFINE_SERVICE_CIDREC(
cff_service_cid_info,
(FT_CID_GetRegistryOrderingSupplementFunc)
cff_get_ros, /* get_ros */
(FT_CID_GetIsInternallyCIDKeyedFunc)
@@ -855,10 +933,94 @@
FT_DEFINE_SERVICE_PROPERTIESREC(
cff_service_properties,
(FT_Properties_SetFunc)cff_property_set, /* set_property */
(FT_Properties_GetFunc)cff_property_get ) /* get_property */
#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
/*
* MULTIPLE MASTER SERVICE
*
*/
static FT_Error
cff_set_mm_blend( CFF_Face face,
FT_UInt num_coords,
FT_Fixed* coords )
{
FT_Service_MultiMasters mm = (FT_Service_MultiMasters)face->mm;
return mm->set_mm_blend( FT_FACE( face ), num_coords, coords );
}
static FT_Error
cff_get_mm_blend( CFF_Face face,
FT_UInt num_coords,
FT_Fixed* coords )
{
FT_Service_MultiMasters mm = (FT_Service_MultiMasters)face->mm;
return mm->get_mm_blend( FT_FACE( face ), num_coords, coords );
}
static FT_Error
cff_get_mm_var( CFF_Face face,
FT_MM_Var* *master )
{
FT_Service_MultiMasters mm = (FT_Service_MultiMasters)face->mm;
return mm->get_mm_var( FT_FACE( face ), master );
}
static FT_Error
cff_set_var_design( CFF_Face face,
FT_UInt num_coords,
FT_Fixed* coords )
{
FT_Service_MultiMasters mm = (FT_Service_MultiMasters)face->mm;
return mm->set_var_design( FT_FACE( face ), num_coords, coords );
}
static FT_Error
cff_get_var_design( CFF_Face face,
FT_UInt num_coords,
FT_Fixed* coords )
{
FT_Service_MultiMasters mm = (FT_Service_MultiMasters)face->mm;
return mm->get_var_design( FT_FACE( face ), num_coords, coords );
}
FT_DEFINE_SERVICE_MULTIMASTERSREC(
cff_service_multi_masters,
(FT_Get_MM_Func) NULL, /* get_mm */
(FT_Set_MM_Design_Func) NULL, /* set_mm_design */
(FT_Set_MM_Blend_Func) cff_set_mm_blend, /* set_mm_blend */
(FT_Get_MM_Blend_Func) cff_get_mm_blend, /* get_mm_blend */
(FT_Get_MM_Var_Func) cff_get_mm_var, /* get_mm_var */
(FT_Set_Var_Design_Func)cff_set_var_design, /* set_var_design */
(FT_Get_Var_Design_Func)cff_get_var_design, /* get_var_design */
(FT_Get_Var_Blend_Func) cff_get_var_blend, /* get_var_blend */
(FT_Done_Blend_Func) cff_done_blend /* done_blend */
)
#endif
/*************************************************************************/
/*************************************************************************/
/*************************************************************************/
@@ -871,9 +1033,24 @@
/*************************************************************************/
/*************************************************************************/
#ifndef FT_CONFIG_OPTION_NO_GLYPH_NAMES
#if !defined FT_CONFIG_OPTION_NO_GLYPH_NAMES && \
defined TT_CONFIG_OPTION_GX_VAR_SUPPORT
FT_DEFINE_SERVICEDESCREC8(
cff_services,
FT_SERVICE_ID_FONT_FORMAT, FT_FONT_FORMAT_CFF,
FT_SERVICE_ID_MULTI_MASTERS, &CFF_SERVICE_MULTI_MASTERS_GET,
FT_SERVICE_ID_POSTSCRIPT_INFO, &CFF_SERVICE_PS_INFO_GET,
FT_SERVICE_ID_POSTSCRIPT_FONT_NAME, &CFF_SERVICE_PS_NAME_GET,
FT_SERVICE_ID_GLYPH_DICT, &CFF_SERVICE_GLYPH_DICT_GET,
FT_SERVICE_ID_TT_CMAP, &CFF_SERVICE_GET_CMAP_INFO_GET,
FT_SERVICE_ID_CID, &CFF_SERVICE_CID_INFO_GET,
FT_SERVICE_ID_PROPERTIES, &CFF_SERVICE_PROPERTIES_GET
)
#elif !defined FT_CONFIG_OPTION_NO_GLYPH_NAMES
FT_DEFINE_SERVICEDESCREC7(
cff_services,
FT_SERVICE_ID_FONT_FORMAT, FT_FONT_FORMAT_CFF,
FT_SERVICE_ID_POSTSCRIPT_INFO, &CFF_SERVICE_PS_INFO_GET,
FT_SERVICE_ID_POSTSCRIPT_FONT_NAME, &CFF_SERVICE_PS_NAME_GET,
@@ -882,9 +1059,22 @@
FT_SERVICE_ID_CID, &CFF_SERVICE_CID_INFO_GET,
FT_SERVICE_ID_PROPERTIES, &CFF_SERVICE_PROPERTIES_GET
)
#elif defined TT_CONFIG_OPTION_GX_VAR_SUPPORT
FT_DEFINE_SERVICEDESCREC7(
cff_services,
FT_SERVICE_ID_FONT_FORMAT, FT_FONT_FORMAT_CFF,
FT_SERVICE_ID_MULTI_MASTERS, &CFF_SERVICE_MULTI_MASTERS_GET,
FT_SERVICE_ID_POSTSCRIPT_INFO, &CFF_SERVICE_PS_INFO_GET,
FT_SERVICE_ID_POSTSCRIPT_FONT_NAME, &CFF_SERVICE_PS_NAME_GET,
FT_SERVICE_ID_TT_CMAP, &CFF_SERVICE_GET_CMAP_INFO_GET,
FT_SERVICE_ID_CID, &CFF_SERVICE_CID_INFO_GET,
FT_SERVICE_ID_PROPERTIES, &CFF_SERVICE_PROPERTIES_GET
)
#else
FT_DEFINE_SERVICEDESCREC6(
cff_services,
FT_SERVICE_ID_FONT_FORMAT, FT_FONT_FORMAT_CFF,
FT_SERVICE_ID_POSTSCRIPT_INFO, &CFF_SERVICE_PS_INFO_GET,
FT_SERVICE_ID_POSTSCRIPT_FONT_NAME, &CFF_SERVICE_PS_NAME_GET,
@@ -914,7 +1104,7 @@
#endif
result = ft_service_list_lookup( CFF_SERVICES_GET, module_interface );
if ( result != NULL )
if ( result )
return result;
/* `driver' is not yet evaluated in non-PIC mode */
@@ -954,7 +1144,7 @@
0x10000L,
0x20000L,
0, /* module-specific interface */
NULL, /* module-specific interface */
cff_driver_init, /* FT_Module_Constructor module_init */
cff_driver_done, /* FT_Module_Destructor module_done */
@@ -974,7 +1164,7 @@
cff_glyph_load, /* FT_Slot_LoadFunc load_glyph */
cff_get_kerning, /* FT_Face_GetKerningFunc get_kerning */
0, /* FT_Face_AttachFunc attach_file */
NULL, /* FT_Face_AttachFunc attach_file */
cff_get_advances, /* FT_Face_GetAdvancesFunc get_advances */
cff_size_request, /* FT_Size_RequestFunc request_size */
+5 -5
View File
@@ -391,7 +391,7 @@
/* clear everything */
FT_MEM_ZERO( decoder, sizeof ( *decoder ) );
FT_ZERO( decoder );
/* initialize builder */
cff_builder_init( &decoder->builder, face, size, slot, hinting );
@@ -1026,7 +1026,7 @@
if ( !( val & 0xFFFFL ) )
FT_TRACE4(( " %hd", (FT_Short)( (FT_UInt32)val >> 16 ) ));
else
FT_TRACE4(( " %.2f", val / 65536.0 ));
FT_TRACE4(( " %.5f", val / 65536.0 ));
#endif
}
@@ -2445,7 +2445,7 @@
case cff_op_and:
{
FT_Fixed cond = args[0] && args[1];
FT_Fixed cond = ( args[0] && args[1] );
FT_TRACE4(( " and\n" ));
@@ -2457,7 +2457,7 @@
case cff_op_or:
{
FT_Fixed cond = args[0] || args[1];
FT_Fixed cond = ( args[0] || args[1] );
FT_TRACE4(( " or\n" ));
@@ -2481,7 +2481,7 @@
case cff_op_eq:
{
FT_Fixed cond = args[0] == args[1];
FT_Fixed cond = ( args[0] == args[1] );
FT_TRACE4(( " eq\n" ));
File diff suppressed because it is too large Load Diff
+45 -5
View File
@@ -22,6 +22,8 @@
#include <ft2build.h>
#include "cfftypes.h"
#include "cffparse.h"
#include "cffobjs.h" /* for CFF_Face */
FT_BEGIN_HEADER
@@ -60,20 +62,58 @@ FT_BEGIN_HEADER
FT_LOCAL( FT_Error )
cff_font_load( FT_Library library,
FT_Stream stream,
FT_Int face_index,
CFF_Font font,
FT_Bool pure_cff );
cff_font_load( FT_Library library,
FT_Stream stream,
FT_Int face_index,
CFF_Font font,
FT_Bool pure_cff,
FT_Bool cff2 );
FT_LOCAL( void )
cff_font_done( CFF_Font font );
FT_LOCAL( FT_Error )
cff_load_private_dict( CFF_Font font,
CFF_SubFont subfont,
FT_UInt lenNDV,
FT_Fixed* NDV );
FT_LOCAL( FT_Byte )
cff_fd_select_get( CFF_FDSelect fdselect,
FT_UInt glyph_index );
FT_LOCAL( FT_Bool )
cff_blend_check_vector( CFF_Blend blend,
FT_UInt vsindex,
FT_UInt lenNDV,
FT_Fixed* NDV );
FT_LOCAL( FT_Error )
cff_blend_build_vector( CFF_Blend blend,
FT_UInt vsindex,
FT_UInt lenNDV,
FT_Fixed* NDV );
FT_LOCAL( void )
cff_blend_clear( CFF_SubFont subFont );
FT_LOCAL( FT_Error )
cff_blend_doBlend( CFF_SubFont subfont,
CFF_Parser parser,
FT_UInt numBlends );
#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
FT_LOCAL( FT_Error )
cff_get_var_blend( CFF_Face face,
FT_UInt *num_coords,
FT_Fixed* *coords,
FT_MM_Var* *mm_var );
FT_LOCAL( void )
cff_done_blend( CFF_Face face );
#endif
FT_END_HEADER
+84 -7
View File
@@ -114,7 +114,7 @@
FT_UInt n, count;
FT_MEM_ZERO( priv, sizeof ( *priv ) );
FT_ZERO( priv );
count = priv->num_blue_values = cpriv->num_blue_values;
for ( n = 0; n < count; n++ )
@@ -450,7 +450,7 @@
FT_Int idx;
for ( idx = 1; idx <= style_name_length; ++idx )
for ( idx = 1; idx <= style_name_length; idx++ )
{
if ( family_name[family_name_length - idx] !=
style_name[style_name_length - idx] )
@@ -469,7 +469,7 @@
family_name[idx] == ' ' ||
family_name[idx] == '_' ||
family_name[idx] == '+' ) )
--idx;
idx--;
if ( idx > 0 )
family_name[idx + 1] = '\0';
@@ -491,6 +491,7 @@
FT_Service_PsCMaps psnames;
PSHinter_Service pshinter;
FT_Bool pure_cff = 1;
FT_Bool cff2 = 0;
FT_Bool sfnt_format = 0;
FT_Library library = cffface->driver->root.library;
@@ -553,8 +554,18 @@
goto Exit;
}
/* now load the CFF part of the file */
error = face->goto_table( face, TTAG_CFF, stream, 0 );
/* now load the CFF part of the file; */
/* give priority to CFF2 */
error = face->goto_table( face, TTAG_CFF2, stream, 0 );
if ( !error )
{
cff2 = 1;
face->isCFF2 = cff2;
}
if ( FT_ERR_EQ( error, Table_Missing ) )
error = face->goto_table( face, TTAG_CFF, stream, 0 );
if ( error )
goto Exit;
}
@@ -579,7 +590,12 @@
goto Exit;
face->extra.data = cff;
error = cff_font_load( library, stream, face_index, cff, pure_cff );
error = cff_font_load( library,
stream,
face_index,
cff,
pure_cff,
cff2 );
if ( error )
goto Exit;
@@ -667,6 +683,62 @@
}
#endif /* FT_DEBUG_LEVEL_TRACE */
#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
{
FT_Service_MultiMasters mm = (FT_Service_MultiMasters)face->mm;
FT_Int instance_index = face_index >> 16;
if ( FT_HAS_MULTIPLE_MASTERS( cffface ) &&
mm &&
instance_index > 0 )
{
FT_MM_Var* mm_var;
error = mm->get_mm_var( cffface, NULL );
if ( error )
goto Exit;
mm->get_var_blend( cffface, NULL, NULL, &mm_var );
if ( mm_var->namedstyle )
{
FT_Var_Named_Style* named_style;
FT_String* style_name;
/* in `face_index', the instance index starts with value 1 */
named_style = mm_var->namedstyle + instance_index - 1;
error = sfnt->get_name( face,
(FT_UShort)named_style->strid,
&style_name );
if ( error )
goto Exit;
/* set style name; if already set, replace it */
if ( face->root.style_name )
FT_FREE( face->root.style_name );
face->root.style_name = style_name;
/* finally, select the named instance */
error = mm->set_var_design( cffface,
mm_var->num_axis,
named_style->coords );
if ( error )
goto Exit;
}
}
}
#endif /* TT_CONFIG_OPTION_GX_VAR_SUPPORT */
if ( !dict->has_font_matrix )
dict->units_per_em = pure_cff ? 1000 : face->root.units_per_EM;
@@ -1011,7 +1083,7 @@
error = FT_Err_Ok;
/* if no Unicode charmap was previously selected, select this one */
if ( cffface->charmap == NULL && nn != (FT_UInt)cffface->num_charmaps )
if ( !cffface->charmap && nn != (FT_UInt)cffface->num_charmaps )
cffface->charmap = cffface->charmaps[nn];
Skip_Unicode:
@@ -1079,6 +1151,11 @@
FT_FREE( face->extra.data );
}
}
#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
cff_done_blend( face );
face->blend = NULL;
#endif
}
+243 -47
View File
@@ -24,6 +24,7 @@
#include "cfferrs.h"
#include "cffpic.h"
#include "cffgload.h"
#include "cffload.h"
/*************************************************************************/
@@ -36,22 +37,52 @@
#define FT_COMPONENT trace_cffparse
FT_LOCAL_DEF( void )
FT_LOCAL_DEF( FT_Error )
cff_parser_init( CFF_Parser parser,
FT_UInt code,
void* object,
FT_Library library,
FT_UInt stackSize,
FT_UShort num_designs,
FT_UShort num_axes )
{
FT_MEM_ZERO( parser, sizeof ( *parser ) );
FT_Memory memory = library->memory; /* for FT_NEW_ARRAY */
FT_Error error; /* for FT_NEW_ARRAY */
FT_ZERO( parser );
#if 0
parser->top = parser->stack;
#endif
parser->object_code = code;
parser->object = object;
parser->library = library;
parser->num_designs = num_designs;
parser->num_axes = num_axes;
/* allocate the stack buffer */
if ( FT_NEW_ARRAY( parser->stack, stackSize ) )
{
FT_FREE( parser->stack );
goto Exit;
}
parser->stackSize = stackSize;
parser->top = parser->stack; /* empty stack */
Exit:
return error;
}
FT_LOCAL_DEF( void )
cff_parser_done( CFF_Parser parser )
{
FT_Memory memory = parser->library->memory; /* for FT_FREE */
FT_FREE( parser->stack );
}
@@ -402,24 +433,42 @@
/* read a number, either integer or real */
static FT_Long
cff_parse_num( FT_Byte** d )
FT_LOCAL_DEF( FT_Long )
cff_parse_num( CFF_Parser parser,
FT_Byte** d )
{
return **d == 30 ? ( cff_parse_real( d[0], d[1], 0, NULL ) >> 16 )
: cff_parse_integer( d[0], d[1] );
if ( **d == 30 )
{
/* binary-coded decimal is truncated to integer */
return cff_parse_real( *d, parser->limit, 0, NULL ) >> 16;
}
else if ( **d == 255 )
{
/* 16.16 fixed point is used internally for CFF2 blend results. */
/* Since these are trusted values, a limit check is not needed. */
/* After the 255, 4 bytes are in host order. */
/* Blend result is rounded to integer. */
return (FT_Long)( *( (FT_UInt32 *) ( d[0] + 1 ) ) + 0x8000U ) >> 16;
}
else
return cff_parse_integer( *d, parser->limit );
}
/* read a floating point number, either integer or real */
static FT_Fixed
do_fixed( FT_Byte** d,
FT_Long scaling )
do_fixed( CFF_Parser parser,
FT_Byte** d,
FT_Long scaling )
{
if ( **d == 30 )
return cff_parse_real( d[0], d[1], scaling, NULL );
return cff_parse_real( *d, parser->limit, scaling, NULL );
else
{
FT_Long val = cff_parse_integer( d[0], d[1] );
FT_Long val = cff_parse_integer( *d, parser->limit );
if ( scaling )
@@ -447,19 +496,21 @@
/* read a floating point number, either integer or real */
static FT_Fixed
cff_parse_fixed( FT_Byte** d )
cff_parse_fixed( CFF_Parser parser,
FT_Byte** d )
{
return do_fixed( d, 0 );
return do_fixed( parser, d, 0 );
}
/* read a floating point number, either integer or real, */
/* but return `10^scaling' times the number read in */
static FT_Fixed
cff_parse_fixed_scaled( FT_Byte** d,
FT_Long scaling )
cff_parse_fixed_scaled( CFF_Parser parser,
FT_Byte** d,
FT_Long scaling )
{
return do_fixed( d, scaling );
return do_fixed( parser, d, scaling );
}
@@ -467,13 +518,14 @@
/* 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_Long* scaling )
cff_parse_fixed_dynamic( CFF_Parser parser,
FT_Byte** d,
FT_Long* scaling )
{
FT_ASSERT( scaling );
if ( **d == 30 )
return cff_parse_real( d[0], d[1], 0, scaling );
return cff_parse_real( *d, parser->limit, 0, scaling );
else
{
FT_Long number;
@@ -543,7 +595,7 @@
for ( i = 0; i < 6; i++ )
{
values[i] = cff_parse_fixed_dynamic( data++, &scalings[i] );
values[i] = cff_parse_fixed_dynamic( parser, data++, &scalings[i] );
if ( values[i] )
{
if ( scalings[i] > max_scaling )
@@ -640,10 +692,10 @@
if ( parser->top >= parser->stack + 4 )
{
bbox->xMin = FT_RoundFix( cff_parse_fixed( data++ ) );
bbox->yMin = FT_RoundFix( cff_parse_fixed( data++ ) );
bbox->xMax = FT_RoundFix( cff_parse_fixed( data++ ) );
bbox->yMax = FT_RoundFix( cff_parse_fixed( data ) );
bbox->xMin = FT_RoundFix( cff_parse_fixed( parser, data++ ) );
bbox->yMin = FT_RoundFix( cff_parse_fixed( parser, data++ ) );
bbox->xMax = FT_RoundFix( cff_parse_fixed( parser, data++ ) );
bbox->yMax = FT_RoundFix( cff_parse_fixed( parser, data ) );
error = FT_Err_Ok;
FT_TRACE4(( " [%d %d %d %d]\n",
@@ -672,7 +724,7 @@
FT_Long tmp;
tmp = cff_parse_num( data++ );
tmp = cff_parse_num( parser, data++ );
if ( tmp < 0 )
{
FT_ERROR(( "cff_parse_private_dict: Invalid dictionary size\n" ));
@@ -681,7 +733,7 @@
}
dict->private_size = (FT_ULong)tmp;
tmp = cff_parse_num( data );
tmp = cff_parse_num( parser, data );
if ( tmp < 0 )
{
FT_ERROR(( "cff_parse_private_dict: Invalid dictionary offset\n" ));
@@ -726,7 +778,7 @@
/* currently, we handle only the first argument */
if ( parser->top >= parser->stack + 5 )
{
FT_Long num_designs = cff_parse_num( parser->stack );
FT_Long num_designs = cff_parse_num( parser, parser->stack );
if ( num_designs > 16 || num_designs < 2 )
@@ -763,11 +815,11 @@
if ( parser->top >= parser->stack + 3 )
{
dict->cid_registry = (FT_UInt)cff_parse_num( data++ );
dict->cid_ordering = (FT_UInt)cff_parse_num( data++ );
dict->cid_registry = (FT_UInt)cff_parse_num( parser, data++ );
dict->cid_ordering = (FT_UInt)cff_parse_num( parser, data++ );
if ( **data == 30 )
FT_TRACE1(( "cff_parse_cid_ros: real supplement is rounded\n" ));
dict->cid_supplement = cff_parse_num( data );
dict->cid_supplement = cff_parse_num( parser, data );
if ( dict->cid_supplement < 0 )
FT_TRACE1(( "cff_parse_cid_ros: negative supplement %d is found\n",
dict->cid_supplement ));
@@ -783,6 +835,125 @@
}
static FT_Error
cff_parse_vsindex( CFF_Parser parser )
{
/* vsindex operator can only be used in a Private DICT */
CFF_Private priv = (CFF_Private)parser->object;
FT_Byte** data = parser->stack;
CFF_Blend blend;
FT_Error error;
if ( !priv || !priv->subfont )
{
error = FT_THROW( Invalid_File_Format );
goto Exit;
}
blend = &priv->subfont->blend;
if ( blend->usedBV )
{
FT_ERROR(( " cff_parse_vsindex: vsindex not allowed after blend\n" ));
error = FT_THROW( Syntax_Error );
goto Exit;
}
priv->vsindex = (FT_UInt)cff_parse_num( parser, data++ );
FT_TRACE4(( " %d\n", priv->vsindex ));
error = FT_Err_Ok;
Exit:
return error;
}
static FT_Error
cff_parse_blend( CFF_Parser parser )
{
/* blend operator can only be used in a Private DICT */
CFF_Private priv = (CFF_Private)parser->object;
CFF_SubFont subFont;
CFF_Blend blend;
FT_UInt numBlends;
FT_Error error;
error = FT_ERR( Stack_Underflow );
if ( !priv || !priv->subfont )
{
error = FT_THROW( Invalid_File_Format );
goto Exit;
}
subFont = priv->subfont;
blend = &subFont->blend;
if ( cff_blend_check_vector( blend,
priv->vsindex,
subFont->lenNDV,
subFont->NDV ) )
{
error = cff_blend_build_vector( blend,
priv->vsindex,
subFont->lenNDV,
subFont->NDV );
if ( error )
goto Exit;
}
numBlends = (FT_UInt)cff_parse_num( parser, parser->top - 1 );
if ( numBlends > parser->stackSize )
{
FT_ERROR(( "cff_parse_blend: Invalid number of blends\n" ));
error = FT_THROW( Invalid_File_Format );
goto Exit;
}
FT_TRACE4(( " %d values blended\n", numBlends ));
error = cff_blend_doBlend( subFont, parser, numBlends );
blend->usedBV = TRUE;
Exit:
return error;
}
/* maxstack operator increases parser and operand stacks for CFF2 */
static FT_Error
cff_parse_maxstack( CFF_Parser parser )
{
/* maxstack operator can only be used in a Top DICT */
CFF_FontRecDict dict = (CFF_FontRecDict)parser->object;
FT_Byte** data = parser->stack;
FT_Error error = FT_Err_Ok;
if ( !dict )
{
error = FT_THROW( Invalid_File_Format );
goto Exit;
}
dict->maxstack = (FT_UInt)cff_parse_num( parser, data++ );
if ( dict->maxstack > CFF2_MAX_STACK )
dict->maxstack = CFF2_MAX_STACK;
if ( dict->maxstack < CFF2_DEFAULT_STACK )
dict->maxstack = CFF2_DEFAULT_STACK;
FT_TRACE4(( " %d\n", dict->maxstack ));
Exit:
return error;
}
#define CFF_FIELD_NUM( code, name, id ) \
CFF_FIELD( code, name, id, cff_kind_num )
#define CFF_FIELD_FIXED( code, name, id ) \
@@ -794,9 +965,6 @@
#define CFF_FIELD_BOOL( code, name, id ) \
CFF_FIELD( code, name, id, cff_kind_bool )
#define CFFCODE_TOPDICT 0x1000
#define CFFCODE_PRIVATE 0x2000
#ifndef FT_CONFIG_OPTION_PIC
@@ -817,6 +985,15 @@
0, 0 \
},
#define CFF_FIELD_BLEND( code, id ) \
{ \
cff_kind_blend, \
code | CFFCODE, \
0, 0, \
cff_parse_blend, \
0, 0 \
},
#define CFF_FIELD( code, name, id, kind ) \
{ \
kind, \
@@ -860,6 +1037,16 @@
id \
},
#define CFF_FIELD_BLEND( code, id ) \
{ \
cff_kind_blend, \
code | CFFCODE, \
0, 0, \
cff_parse_blend, \
0, 0, \
id \
},
#define CFF_FIELD( code, name, id, kind ) \
{ \
kind, \
@@ -1067,11 +1254,13 @@
{
FT_UInt v = *p;
if ( v >= 27 && v != 31 )
/* Opcode 31 is legacy MM T2 operator, not a number. */
/* Opcode 255 is reserved and should not appear in fonts; */
/* it is used internally for CFF2 blends. */
if ( v >= 27 && v != 31 && v != 255 )
{
/* it's a number; we will push its position on the stack */
if ( parser->top - parser->stack >= CFF_MAX_STACK_DEPTH )
if ( (FT_UInt)( parser->top - parser->stack ) >= parser->stackSize )
goto Stack_Overflow;
*parser->top++ = p;
@@ -1132,8 +1321,8 @@
charstring_len = (FT_ULong)( p - charstring_base ) + 1;
/* construct CFF_Decoder object */
FT_MEM_ZERO( &decoder, sizeof ( decoder ) );
FT_MEM_ZERO( &cff_rec, sizeof ( cff_rec ) );
FT_ZERO( &decoder );
FT_ZERO( &cff_rec );
cff_rec.top_font.font_dict.num_designs = parser->num_designs;
cff_rec.top_font.font_dict.num_axes = parser->num_axes;
@@ -1162,7 +1351,7 @@
FT_Bool neg;
if ( parser->top - parser->stack >= CFF_MAX_STACK_DEPTH )
if ( (FT_UInt)( parser->top - parser->stack ) >= parser->stackSize )
goto Stack_Overflow;
*parser->top++ = q;
@@ -1239,13 +1428,17 @@
/* and look for it in our current list. */
FT_UInt code;
FT_UInt num_args = (FT_UInt)
( parser->top - parser->stack );
FT_UInt num_args;
const CFF_Field_Handler* field;
if ( (FT_UInt)( parser->top - parser->stack ) >= parser->stackSize )
goto Stack_Overflow;
num_args = (FT_UInt)( parser->top - parser->stack );
*parser->top = p;
code = v;
code = v;
if ( v == 12 )
{
/* two byte operator */
@@ -1280,15 +1473,15 @@
case cff_kind_bool:
case cff_kind_string:
case cff_kind_num:
val = cff_parse_num( parser->stack );
val = cff_parse_num( parser, parser->stack );
goto Store_Number;
case cff_kind_fixed:
val = cff_parse_fixed( parser->stack );
val = cff_parse_fixed( parser, parser->stack );
goto Store_Number;
case cff_kind_fixed_thousand:
val = cff_parse_fixed_scaled( parser->stack, 3 );
val = cff_parse_fixed_scaled( parser, parser->stack, 3 );
Store_Number:
switch ( field->size )
@@ -1357,7 +1550,7 @@
val = 0;
while ( num_args > 0 )
{
val += cff_parse_num( data++ );
val += cff_parse_num( parser, data++ );
switch ( field->size )
{
case (8 / FT_CHAR_BIT):
@@ -1386,7 +1579,7 @@
}
break;
default: /* callback */
default: /* callback or blend */
error = field->reader( parser );
if ( error )
goto Exit;
@@ -1400,7 +1593,10 @@
Found:
/* clear stack */
parser->top = parser->stack;
/* TODO: could clear blend stack here, */
/* but we don't have access to subFont */
if ( field->kind != cff_kind_blend )
parser->top = parser->stack;
}
p++;
}
+21 -4
View File
@@ -28,10 +28,17 @@
FT_BEGIN_HEADER
/* CFF uses constant parser stack size; */
/* CFF2 can increase from default 193 */
#define CFF_MAX_STACK_DEPTH 96
#define CFF2_MAX_STACK 513
#define CFF2_DEFAULT_STACK 193
#define CFF_CODE_TOPDICT 0x1000
#define CFF_CODE_PRIVATE 0x2000
#define CFF_CODE_TOPDICT 0x1000
#define CFF_CODE_PRIVATE 0x2000
#define CFF2_CODE_TOPDICT 0x3000
#define CFF2_CODE_FONTDICT 0x4000
#define CFF2_CODE_PRIVATE 0x5000
typedef struct CFF_ParserRec_
@@ -41,8 +48,9 @@ FT_BEGIN_HEADER
FT_Byte* limit;
FT_Byte* cursor;
FT_Byte* stack[CFF_MAX_STACK_DEPTH + 1];
FT_Byte** stack;
FT_Byte** top;
FT_UInt stackSize; /* allocated size */
FT_UInt object_code;
void* object;
@@ -53,14 +61,22 @@ FT_BEGIN_HEADER
} CFF_ParserRec, *CFF_Parser;
FT_LOCAL( void )
FT_LOCAL( FT_Long )
cff_parse_num( CFF_Parser parser,
FT_Byte** d );
FT_LOCAL( FT_Error )
cff_parser_init( CFF_Parser parser,
FT_UInt code,
void* object,
FT_Library library,
FT_UInt stackSize,
FT_UShort num_designs,
FT_UShort num_axes );
FT_LOCAL( void )
cff_parser_done( CFF_Parser parser );
FT_LOCAL( FT_Error )
cff_parser_run( CFF_Parser parser,
FT_Byte* start,
@@ -77,6 +93,7 @@ FT_BEGIN_HEADER
cff_kind_bool,
cff_kind_delta,
cff_kind_callback,
cff_kind_blend,
cff_kind_max /* do not remove */
};
+1
View File
@@ -32,6 +32,7 @@
#define CFF_SERVICE_CID_INFO_GET cff_service_cid_info
#define CFF_SERVICE_PROPERTIES_GET cff_service_properties
#define CFF_SERVICES_GET cff_services
#define CFF_SERVICE_MULTI_MASTERS_GET cff_service_multi_masters
#define CFF_CMAP_ENCODING_CLASS_REC_GET cff_cmap_encoding_class_rec
#define CFF_CMAP_UNICODE_CLASS_REC_GET cff_cmap_unicode_class_rec
#define CFF_FIELD_HANDLERS_GET cff_field_handlers
+47 -2
View File
@@ -20,7 +20,7 @@
#define FT_STRUCTURE CFF_FontRecDictRec
#undef CFFCODE
#define CFFCODE CFFCODE_TOPDICT
#define CFFCODE CFF_CODE_TOPDICT
CFF_FIELD_STRING ( 0, version, "Version" )
CFF_FIELD_STRING ( 1, notice, "Notice" )
@@ -78,7 +78,7 @@
#undef FT_STRUCTURE
#define FT_STRUCTURE CFF_PrivateRec
#undef CFFCODE
#define CFFCODE CFFCODE_PRIVATE
#define CFFCODE CFF_CODE_PRIVATE
CFF_FIELD_DELTA ( 6, blue_values, 14, "BlueValues" )
CFF_FIELD_DELTA ( 7, other_blues, 10, "OtherBlues" )
@@ -102,4 +102,49 @@
CFF_FIELD_NUM ( 21, nominal_width, "nominalWidthX" )
#undef FT_STRUCTURE
#define FT_STRUCTURE CFF_FontRecDictRec
#undef CFFCODE
#define CFFCODE CFF2_CODE_TOPDICT
CFF_FIELD_CALLBACK( 0x107, font_matrix, "FontMatrix" )
CFF_FIELD_NUM ( 17, charstrings_offset, "CharStrings" )
CFF_FIELD_NUM ( 0x124, cid_fd_array_offset, "FDArray" )
CFF_FIELD_NUM ( 0x125, cid_fd_select_offset, "FDSelect" )
CFF_FIELD_NUM ( 24, vstore_offset, "vstore" )
CFF_FIELD_CALLBACK( 25, maxstack, "maxstack" )
#undef FT_STRUCTURE
#define FT_STRUCTURE CFF_FontRecDictRec
#undef CFFCODE
#define CFFCODE CFF2_CODE_FONTDICT
CFF_FIELD_CALLBACK( 18, private_dict, "Private" )
CFF_FIELD_CALLBACK( 0x107, font_matrix, "FontMatrix" )
#undef FT_STRUCTURE
#define FT_STRUCTURE CFF_PrivateRec
#undef CFFCODE
#define CFFCODE CFF2_CODE_PRIVATE
CFF_FIELD_DELTA ( 6, blue_values, 14, "BlueValues" )
CFF_FIELD_DELTA ( 7, other_blues, 10, "OtherBlues" )
CFF_FIELD_DELTA ( 8, family_blues, 14, "FamilyBlues" )
CFF_FIELD_DELTA ( 9, family_other_blues, 10, "FamilyOtherBlues" )
CFF_FIELD_FIXED_1000( 0x109, blue_scale, "BlueScale" )
CFF_FIELD_NUM ( 0x10A, blue_shift, "BlueShift" )
CFF_FIELD_NUM ( 0x10B, blue_fuzz, "BlueFuzz" )
CFF_FIELD_NUM ( 10, standard_width, "StdHW" )
CFF_FIELD_NUM ( 11, standard_height, "StdVW" )
CFF_FIELD_DELTA ( 0x10C, snap_widths, 13, "StemSnapH" )
CFF_FIELD_DELTA ( 0x10D, snap_heights, 13, "StemSnapV" )
CFF_FIELD_NUM ( 0x111, language_group, "LanguageGroup" )
CFF_FIELD_FIXED ( 0x112, expansion_factor, "ExpansionFactor" )
CFF_FIELD_CALLBACK ( 22, vsindex, "vsindex" )
CFF_FIELD_BLEND ( 23, "blend" )
CFF_FIELD_NUM ( 19, local_subrs_offset, "Subrs" )
/* END */
+117 -6
View File
@@ -64,6 +64,7 @@ FT_BEGIN_HEADER
{
FT_Stream stream;
FT_ULong start;
FT_UInt hdr_size;
FT_UInt count;
FT_Byte off_size;
FT_ULong data_offset;
@@ -102,6 +103,79 @@ FT_BEGIN_HEADER
} CFF_CharsetRec, *CFF_Charset;
/* cf. similar fields in file `ttgxvar.h' from the `truetype' module */
typedef struct CFF_VarData_
{
#if 0
FT_UInt itemCount; /* not used; always zero */
FT_UInt shortDeltaCount; /* not used; always zero */
#endif
FT_UInt regionIdxCount; /* number of regions in this var data */
FT_UInt* regionIndices; /* array of `regionCount' indices; */
/* these index `varRegionList' */
} CFF_VarData;
/* contribution of one axis to a region */
typedef struct CFF_AxisCoords_
{
FT_Fixed startCoord;
FT_Fixed peakCoord; /* zero peak means no effect (factor = 1) */
FT_Fixed endCoord;
} CFF_AxisCoords;
typedef struct CFF_VarRegion_
{
CFF_AxisCoords* axisList; /* array of axisCount records */
} CFF_VarRegion;
typedef struct CFF_VStoreRec_
{
FT_UInt dataCount;
CFF_VarData* varData; /* array of dataCount records */
/* vsindex indexes this array */
FT_UShort axisCount;
FT_UInt regionCount; /* total number of regions defined */
CFF_VarRegion* varRegionList;
} CFF_VStoreRec, *CFF_VStore;
/* forward reference */
typedef struct CFF_FontRec_* CFF_Font;
/* This object manages one cached blend vector. */
/* */
/* There is a BlendRec for Private DICT parsing in each subfont */
/* and a BlendRec for charstrings in CF2_Font instance data. */
/* A cached BV may be used across DICTs or Charstrings if inputs */
/* have not changed. */
/* */
/* `usedBV' is reset at the start of each parse or charstring. */
/* vsindex cannot be changed after a BV is used. */
/* */
/* Note: NDV is long (32/64 bit), while BV is 16.16 (FT_Int32). */
typedef struct CFF_BlendRec_
{
FT_Bool builtBV; /* blendV has been built */
FT_Bool usedBV; /* blendV has been used */
CFF_Font font; /* top level font struct */
FT_UInt lastVsindex; /* last vsindex used */
FT_UInt lenNDV; /* normDV length (aka numAxes) */
FT_Fixed* lastNDV; /* last NDV used */
FT_UInt lenBV; /* BlendV length (aka numMasters) */
FT_Int32* BV; /* current blendV (per DICT/glyph) */
} CFF_BlendRec, *CFF_Blend;
typedef struct CFF_FontRecDictRec_
{
FT_UInt version;
@@ -151,9 +225,17 @@ FT_BEGIN_HEADER
FT_UShort num_designs;
FT_UShort num_axes;
/* fields for CFF2 */
FT_ULong vstore_offset;
FT_UInt maxstack;
} CFF_FontRecDictRec, *CFF_FontRecDict;
/* forward reference */
typedef struct CFF_SubFontRec_* CFF_SubFont;
typedef struct CFF_PrivateRec_
{
FT_Byte num_blue_values;
@@ -186,6 +268,10 @@ FT_BEGIN_HEADER
FT_Pos default_width;
FT_Pos nominal_width;
/* fields for CFF2 */
FT_UInt vsindex;
CFF_SubFont subfont;
} CFF_PrivateRec, *CFF_Private;
@@ -213,10 +299,29 @@ FT_BEGIN_HEADER
CFF_FontRecDictRec font_dict;
CFF_PrivateRec private_dict;
CFF_IndexRec local_subrs_index;
FT_Byte** local_subrs; /* array of pointers into Local Subrs INDEX data */
/* fields for CFF2 */
CFF_BlendRec blend; /* current blend vector */
FT_UInt lenNDV; /* current length NDV or zero */
FT_Fixed* NDV; /* ptr to current NDV or NULL */
} CFF_SubFontRec, *CFF_SubFont;
/* `blend_stack' is a writable buffer to hold blend results. */
/* This buffer is to the side of the normal cff parser stack; */
/* `cff_parse_blend' and `cff_blend_doBlend' push blend results here. */
/* The normal stack then points to these values instead of the DICT */
/* because all other operators in Private DICT clear the stack. */
/* `blend_stack' could be cleared at each operator other than blend. */
/* Blended values are stored as 5-byte fixed point values. */
FT_Byte* blend_stack; /* base of stack allocation */
FT_Byte* blend_top; /* first empty slot */
FT_UInt blend_used; /* number of bytes in use */
FT_UInt blend_alloc; /* number of bytes allocated */
CFF_IndexRec local_subrs_index;
FT_Byte** local_subrs; /* array of pointers */
/* into Local Subrs INDEX data */
} CFF_SubFontRec;
#define CFF_MAX_CID_FONTS 256
@@ -224,16 +329,20 @@ FT_BEGIN_HEADER
typedef struct CFF_FontRec_
{
FT_Library library;
FT_Stream stream;
FT_Memory memory;
FT_Memory memory; /* TODO: take this from stream->memory? */
FT_ULong base_offset; /* offset to start of CFF */
FT_UInt num_faces;
FT_UInt num_glyphs;
FT_Byte version_major;
FT_Byte version_minor;
FT_Byte header_size;
FT_Byte absolute_offsize;
FT_UInt top_dict_length; /* cff2 only */
FT_Bool cff2;
CFF_IndexRec name_index;
CFF_IndexRec top_dict_index;
@@ -280,7 +389,9 @@ FT_BEGIN_HEADER
/* since version 2.4.12 */
FT_Generic cf2_instance;
} CFF_FontRec, *CFF_Font;
CFF_VStoreRec vstore; /* parsed vstore structure */
} CFF_FontRec;
FT_END_HEADER
+6 -4
View File
@@ -570,7 +570,7 @@
{
FT_UNUSED( face );
FT_MEM_ZERO( loader, sizeof ( *loader ) );
FT_ZERO( loader );
}
@@ -733,9 +733,11 @@
}
/* we must convert the data section from hexadecimal to binary */
if ( FT_ALLOC( face->binary_data, parser->binary_length ) ||
cid_hex_to_binary( face->binary_data, parser->binary_length,
parser->data_offset, face ) )
if ( FT_ALLOC( face->binary_data, parser->binary_length ) ||
FT_SET_ERROR( cid_hex_to_binary( face->binary_data,
parser->binary_length,
parser->data_offset,
face ) ) )
goto Exit;
FT_Stream_OpenMemory( face->cid_stream,
+3 -3
View File
@@ -65,7 +65,7 @@
FT_Byte *arg1, *arg2;
FT_MEM_ZERO( parser, sizeof ( *parser ) );
FT_ZERO( parser );
psaux->ps_parser_funcs->init( &parser->root, 0, 0, memory );
parser->stream = stream;
@@ -138,13 +138,13 @@
ft_strncmp( (char*)p, STARTDATA, STARTDATA_LEN ) == 0 )
{
/* save offset of binary data after `StartData' */
offset += (FT_ULong)( p - buffer ) + STARTDATA_LEN;
offset += (FT_ULong)( p - buffer ) + STARTDATA_LEN + 1;
goto Found;
}
else if ( p[1] == 's' &&
ft_strncmp( (char*)p, SFNTS, SFNTS_LEN ) == 0 )
{
offset += (FT_ULong)( p - buffer ) + SFNTS_LEN;
offset += (FT_ULong)( p - buffer ) + SFNTS_LEN + 1;
goto Found;
}
}
+5 -5
View File
@@ -206,7 +206,7 @@
0x10000L, /* version 1.0 of driver */
0x20000L, /* requires FreeType 2.0 */
0, /* module-specific interface */
NULL, /* module-specific interface */
cid_driver_init, /* FT_Module_Constructor module_init */
cid_driver_done, /* FT_Module_Destructor module_done */
@@ -226,12 +226,12 @@
cid_slot_load_glyph, /* FT_Slot_LoadFunc load_glyph */
0, /* FT_Face_GetKerningFunc get_kerning */
0, /* FT_Face_AttachFunc attach_file */
0, /* FT_Face_GetAdvancesFunc get_advances */
NULL, /* FT_Face_GetKerningFunc get_kerning */
NULL, /* FT_Face_AttachFunc attach_file */
NULL, /* FT_Face_GetAdvancesFunc get_advances */
cid_size_request, /* FT_Size_RequestFunc request_size */
0 /* FT_Size_SelectFunc select_size */
NULL /* FT_Size_SelectFunc select_size */
};
+8 -8
View File
@@ -789,7 +789,7 @@
FT_INVALID_FORMAT;
func = fmt_funcs_table[format];
if ( func == NULL )
if ( !func )
FT_INVALID_FORMAT;
func( p, limit, gxvalid );
@@ -972,7 +972,7 @@
FT_UShort i;
ft_memset( nGlyphInClass, 0, 256 );
FT_MEM_ZERO( nGlyphInClass, 256 );
for ( i = 0; i < nGlyphs; i++ )
@@ -1161,7 +1161,7 @@
break;
}
if ( NULL != gxvalid->statetable.entry_validate_func )
if ( gxvalid->statetable.entry_validate_func )
gxvalid->statetable.entry_validate_func( state,
flags,
&glyphOffset,
@@ -1244,10 +1244,10 @@
if ( stateSize > 0xFF )
FT_INVALID_DATA;
if ( gxvalid->statetable.optdata_load_func != NULL )
if ( gxvalid->statetable.optdata_load_func )
gxvalid->statetable.optdata_load_func( p, limit, gxvalid );
if ( gxvalid->statetable.subtable_setup_func != NULL)
if ( gxvalid->statetable.subtable_setup_func )
setup_func = gxvalid->statetable.subtable_setup_func;
else
setup_func = gxv_StateTable_subtable_setup;
@@ -1534,7 +1534,7 @@
goto Exit;
}
if ( NULL != gxvalid->xstatetable.entry_validate_func )
if ( gxvalid->xstatetable.entry_validate_func )
gxvalid->xstatetable.entry_validate_func( state,
flags,
&glyphOffset,
@@ -1591,10 +1591,10 @@
GXV_TRACE(( "StateTable Subtables\n" ));
if ( gxvalid->xstatetable.optdata_load_func != NULL )
if ( gxvalid->xstatetable.optdata_load_func )
gxvalid->xstatetable.optdata_load_func( p, limit, gxvalid );
if ( gxvalid->xstatetable.subtable_setup_func != NULL )
if ( gxvalid->xstatetable.subtable_setup_func )
setup_func = gxvalid->xstatetable.subtable_setup_func;
else
setup_func = gxv_XStateTable_subtable_setup;
+4 -4
View File
@@ -274,11 +274,11 @@
0x10000L,
0x20000L,
0, /* module-specific interface */
NULL, /* module-specific interface */
(FT_Module_Constructor)0,
(FT_Module_Destructor) 0,
(FT_Module_Requester) gxvalid_get_service
(FT_Module_Constructor)NULL, /* module_init */
(FT_Module_Destructor) NULL, /* module_done */
(FT_Module_Requester) gxvalid_get_service /* get_interface */
};
+1 -1
View File
@@ -205,7 +205,7 @@
FT_INVALID_FORMAT;
func = fmt_funcs_table[type];
if ( func == NULL )
if ( !func )
GXV_TRACE(( "morx type %d is reserved\n", type ));
func( p, p + rest, gxvalid );
+1 -1
View File
@@ -98,7 +98,7 @@
FT_INVALID_FORMAT;
func = fmt_funcs_table[type];
if ( func == NULL )
if ( !func )
GXV_TRACE(( "morx type %d is reserved\n", type ));
func( p, p + rest, gxvalid );
+19 -7
View File
@@ -51,17 +51,29 @@
#else /* !FT_CONFIG_OPTION_SYSTEM_ZLIB */
/* In this case, we include our own modified sources of the ZLib */
/* within the "ftgzip" component. The modifications were necessary */
/* to #include all files without conflicts, as well as preventing */
/* the definition of "extern" functions that may cause linking */
/* conflicts when a program is linked with both FreeType and the */
/* original ZLib. */
/* In this case, we include our own modified sources of the ZLib */
/* within the `gzip' component. The modifications were necessary */
/* to #include all files without conflicts, as well as preventing */
/* the definition of `extern' functions that may cause linking */
/* conflicts when a program is linked with both FreeType and the */
/* original ZLib. */
#ifndef USE_ZLIB_ZCALLOC
#define MY_ZCALLOC /* prevent all zcalloc() & zfree() in zutil.c */
#endif
/* Note that our `zlib.h' includes `ftzconf.h' instead of `zconf.h'; */
/* the main reason is that even a global `zlib.h' includes `zconf.h' */
/* with */
/* */
/* #include "zconf.h" */
/* */
/* instead of the expected */
/* */
/* #include <zconf.h> */
/* */
/* so that configuration with `FT_CONFIG_OPTION_SYSTEM_ZLIB' might */
/* include the wrong `zconf.h' file, leading to errors. */
#include "zlib.h"
#undef SLOW
@@ -305,7 +317,7 @@
zstream->next_in = zip->buffer;
if ( inflateInit2( zstream, -MAX_WBITS ) != Z_OK ||
zstream->next_in == NULL )
!zstream->next_in )
error = FT_THROW( Invalid_File_Format );
Exit:
+284
View File
@@ -0,0 +1,284 @@
/* zconf.h -- configuration of the zlib compression library
* Copyright (C) 1995-2002 Jean-loup Gailly.
* For conditions of distribution and use, see copyright notice in zlib.h
*/
/* @(#) $Id$ */
#ifndef _ZCONF_H
#define _ZCONF_H
/*
* If you *really* need a unique prefix for all types and library functions,
* compile with -DZ_PREFIX. The "standard" zlib should be compiled without it.
*/
#ifdef Z_PREFIX
# define deflateInit_ z_deflateInit_
# define deflate z_deflate
# define deflateEnd z_deflateEnd
# define inflateInit_ z_inflateInit_
# define inflate z_inflate
# define inflateEnd z_inflateEnd
# define deflateInit2_ z_deflateInit2_
# define deflateSetDictionary z_deflateSetDictionary
# define deflateCopy z_deflateCopy
# define deflateReset z_deflateReset
# define deflateParams z_deflateParams
# define inflateInit2_ z_inflateInit2_
# define inflateSetDictionary z_inflateSetDictionary
# define inflateSync z_inflateSync
# define inflateSyncPoint z_inflateSyncPoint
# define inflateReset z_inflateReset
# define compress z_compress
# define compress2 z_compress2
# define uncompress z_uncompress
# define adler32 z_adler32
# define crc32 z_crc32
# define get_crc_table z_get_crc_table
# define Byte z_Byte
# define uInt z_uInt
# define uLong z_uLong
# define Bytef z_Bytef
# define charf z_charf
# define intf z_intf
# define uIntf z_uIntf
# define uLongf z_uLongf
# define voidpf z_voidpf
# define voidp z_voidp
#endif
#if (defined(_WIN32) || defined(__WIN32__)) && !defined(WIN32)
# define WIN32
#endif
#if defined(__GNUC__) || defined(WIN32) || defined(__386__) || defined(i386)
# ifndef __32BIT__
# define __32BIT__
# endif
#endif
#if defined(__MSDOS__) && !defined(MSDOS)
# define MSDOS
#endif
/* WinCE doesn't have errno.h */
#ifdef _WIN32_WCE
# define NO_ERRNO_H
#endif
/*
* Compile with -DMAXSEG_64K if the alloc function cannot allocate more
* than 64k bytes at a time (needed on systems with 16-bit int).
*/
#if defined(MSDOS) && !defined(__32BIT__)
# define MAXSEG_64K
#endif
#ifdef MSDOS
# define UNALIGNED_OK
#endif
#if (defined(MSDOS) || defined(_WINDOWS) || defined(WIN32)) && !defined(STDC)
# define STDC
#endif
#if defined(__STDC__) || defined(__cplusplus) || defined(__OS2__)
# ifndef STDC
# define STDC
# endif
#endif
#ifndef STDC
# ifndef const /* cannot use !defined(STDC) && !defined(const) on Mac */
# define const
# endif
#endif
/* Some Mac compilers merge all .h files incorrectly: */
#if defined(__MWERKS__) || defined(applec) ||defined(THINK_C) ||defined(__SC__)
# define NO_DUMMY_DECL
#endif
/* Old Borland C and LCC incorrectly complains about missing returns: */
#if defined(__BORLANDC__) && (__BORLANDC__ < 0x500)
# define NEED_DUMMY_RETURN
#endif
#if defined(__LCC__)
# define NEED_DUMMY_RETURN
#endif
/* Maximum value for memLevel in deflateInit2 */
#ifndef MAX_MEM_LEVEL
# ifdef MAXSEG_64K
# define MAX_MEM_LEVEL 8
# else
# define MAX_MEM_LEVEL 9
# endif
#endif
/* Maximum value for windowBits in deflateInit2 and inflateInit2.
* WARNING: reducing MAX_WBITS makes minigzip unable to extract .gz files
* created by gzip. (Files created by minigzip can still be extracted by
* gzip.)
*/
#ifndef MAX_WBITS
# define MAX_WBITS 15 /* 32K LZ77 window */
#endif
/* The memory requirements for deflate are (in bytes):
(1 << (windowBits+2)) + (1 << (memLevel+9))
that is: 128K for windowBits=15 + 128K for memLevel = 8 (default values)
plus a few kilobytes for small objects. For example, if you want to reduce
the default memory requirements from 256K to 128K, compile with
make CFLAGS="-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7"
Of course this will generally degrade compression (there's no free lunch).
The memory requirements for inflate are (in bytes) 1 << windowBits
that is, 32K for windowBits=15 (default value) plus a few kilobytes
for small objects.
*/
/* Type declarations */
#ifndef OF /* function prototypes */
# ifdef STDC
# define OF(args) args
# else
# define OF(args) ()
# endif
#endif
/* The following definitions for FAR are needed only for MSDOS mixed
* model programming (small or medium model with some far allocations).
* This was tested only with MSC; for other MSDOS compilers you may have
* to define NO_MEMCPY in zutil.h. If you don't need the mixed model,
* just define FAR to be empty.
*/
#if (defined(M_I86SM) || defined(M_I86MM)) && !defined(__32BIT__)
/* MSC small or medium model */
# define SMALL_MEDIUM
# ifdef _MSC_VER
# define FAR _far
# else
# define FAR far
# endif
#endif
#if defined(__BORLANDC__) && (defined(__SMALL__) || defined(__MEDIUM__))
# ifndef __32BIT__
# define SMALL_MEDIUM
# define FAR _far
# endif
#endif
/* Compile with -DZLIB_DLL for Windows DLL support */
#if defined(ZLIB_DLL)
# if defined(_WINDOWS) || defined(WINDOWS)
# ifdef FAR
# undef FAR
# endif
# include <windows.h>
# define ZEXPORT(x) x WINAPI
# ifdef WIN32
# define ZEXPORTVA(x) x WINAPIV
# else
# define ZEXPORTVA(x) x FAR _cdecl _export
# endif
# endif
# if defined (__BORLANDC__)
# if (__BORLANDC__ >= 0x0500) && defined (WIN32)
# include <windows.h>
# define ZEXPORT(x) x __declspec(dllexport) WINAPI
# define ZEXPORTRVA(x) x __declspec(dllexport) WINAPIV
# else
# if defined (_Windows) && defined (__DLL__)
# define ZEXPORT(x) x _export
# define ZEXPORTVA(x) x _export
# endif
# endif
# endif
#endif
#ifndef ZEXPORT
# define ZEXPORT(x) static x
#endif
#ifndef ZEXPORTVA
# define ZEXPORTVA(x) static x
#endif
#ifndef ZEXTERN
# define ZEXTERN(x) static x
#endif
#ifndef ZEXTERNDEF
# define ZEXTERNDEF(x) static x
#endif
#ifndef FAR
# define FAR
#endif
#if !defined(MACOS) && !defined(TARGET_OS_MAC)
typedef unsigned char Byte; /* 8 bits */
#endif
typedef unsigned int uInt; /* 16 bits or more */
typedef unsigned long uLong; /* 32 bits or more */
#ifdef SMALL_MEDIUM
/* Borland C/C++ and some old MSC versions ignore FAR inside typedef */
# define Bytef Byte FAR
#else
typedef Byte FAR Bytef;
#endif
typedef char FAR charf;
typedef int FAR intf;
typedef uInt FAR uIntf;
typedef uLong FAR uLongf;
#ifdef STDC
typedef void FAR *voidpf;
typedef void *voidp;
#else
typedef Byte FAR *voidpf;
typedef Byte *voidp;
#endif
#ifdef HAVE_UNISTD_H
# include <sys/types.h> /* for off_t */
# include <unistd.h> /* for SEEK_* and off_t */
# define z_off_t off_t
#endif
#ifndef SEEK_SET
# define SEEK_SET 0 /* Seek from beginning of file. */
# define SEEK_CUR 1 /* Seek from current position. */
# define SEEK_END 2 /* Set file pointer to EOF plus "offset" */
#endif
#ifndef z_off_t
# define z_off_t long
#endif
/* MVS linker does not support external names larger than 8 bytes */
#if defined(__MVS__)
# pragma map(deflateInit_,"DEIN")
# pragma map(deflateInit2_,"DEIN2")
# pragma map(deflateEnd,"DEEND")
# pragma map(inflateInit_,"ININ")
# pragma map(inflateInit2_,"ININ2")
# pragma map(inflateEnd,"INEND")
# pragma map(inflateSync,"INSY")
# pragma map(inflateSetDictionary,"INSEDI")
# pragma map(inflate_blocks,"INBL")
# pragma map(inflate_blocks_new,"INBLNE")
# pragma map(inflate_blocks_free,"INBLFR")
# pragma map(inflate_blocks_reset,"INBLRE")
# pragma map(inflate_codes_free,"INCOFR")
# pragma map(inflate_codes,"INCO")
# pragma map(inflate_fast,"INFA")
# pragma map(inflate_flush,"INFLU")
# pragma map(inflate_mask,"INMA")
# pragma map(inflate_set_dictionary,"INSEDI2")
# pragma map(inflate_copyright,"INCOPY")
# pragma map(inflate_trees_bits,"INTRBI")
# pragma map(inflate_trees_dynamic,"INTRDY")
# pragma map(inflate_trees_fixed,"INTRFI")
# pragma map(inflate_trees_free,"INTRFR")
#endif
#endif /* _ZCONF_H */
+1 -1
View File
@@ -31,7 +31,7 @@
#ifndef _ZLIB_H
#define _ZLIB_H
#include "zconf.h"
#include "ftzconf.h"
#ifdef __cplusplus
extern "C" {
+1 -1
View File
@@ -374,7 +374,7 @@
{
while ( state->stack_top > 0 )
{
--state->stack_top;
state->stack_top--;
if ( buffer )
buffer[result] = state->stack[state->stack_top];
+1 -1
View File
@@ -68,7 +68,7 @@
OTV_LIMIT_CHECK( GlyphCount * 2 ); /* GlyphArray */
for ( i = 0; i < GlyphCount; ++i )
for ( i = 0; i < GlyphCount; i++ )
{
FT_UInt gid;
+10 -10
View File
@@ -60,7 +60,7 @@
table_size = 2 * ( 56 + 51 );
p += 4 * 2; /* First 4 constants have no device tables */
for ( i = 0; i < 51; ++i )
for ( i = 0; i < 51; i++ )
{
p += 2; /* skip the value */
OTV_OPTIONAL_OFFSET( DeviceTableOffset );
@@ -110,7 +110,7 @@
OTV_SIZE_CHECK( Coverage );
otv_Coverage_validate( table + Coverage, otvalid, (FT_Int)cnt );
for ( i = 0; i < cnt; ++i )
for ( i = 0; i < cnt; i++ )
{
p += 2; /* Skip the value */
OTV_OPTIONAL_OFFSET( DeviceTableOffset );
@@ -151,7 +151,7 @@
table_size = 4 + 4 * cnt;
/* Heights */
for ( i = 0; i < cnt; ++i )
for ( i = 0; i < cnt; i++ )
{
p += 2; /* Skip the value */
OTV_OPTIONAL_OFFSET( DeviceTableOffset );
@@ -161,7 +161,7 @@
}
/* One more Kerning value */
for ( i = 0; i < cnt + 1; ++i )
for ( i = 0; i < cnt + 1; i++ )
{
p += 2; /* Skip the value */
OTV_OPTIONAL_OFFSET( DeviceTableOffset );
@@ -198,9 +198,9 @@
OTV_SIZE_CHECK( Coverage );
otv_Coverage_validate( table + Coverage, otvalid, (FT_Int)cnt );
for ( i = 0; i < cnt; ++i )
for ( i = 0; i < cnt; i++ )
{
for ( j = 0; j < 4; ++j )
for ( j = 0; j < 4; j++ )
{
OTV_OPTIONAL_OFFSET( MKRecordOffset );
OTV_SIZE_CHECK( MKRecordOffset );
@@ -296,7 +296,7 @@
if ( DeviceTableOffset )
otv_Device_validate( table + DeviceTableOffset, otvalid );
for ( i = 0; i < pcnt; ++i )
for ( i = 0; i < pcnt; i++ )
{
FT_UInt gid;
@@ -332,7 +332,7 @@
OTV_LIMIT_CHECK( 4 * vcnt );
table_size = 4 + 4 * vcnt;
for ( i = 0; i < vcnt; ++i )
for ( i = 0; i < vcnt; i++ )
{
FT_UInt gid;
@@ -384,14 +384,14 @@
if ( HCoverage )
otv_Coverage_validate( table + HCoverage, otvalid, (FT_Int)hcnt );
for ( i = 0; i < vcnt; ++i )
for ( i = 0; i < vcnt; i++ )
{
OTV_OPTIONAL_OFFSET( Offset );
OTV_SIZE_CHECK( Offset );
otv_MathGlyphConstruction_validate( table + Offset, otvalid );
}
for ( i = 0; i < hcnt; ++i )
for ( i = 0; i < hcnt; i++ )
{
OTV_OPTIONAL_OFFSET( Offset );
OTV_SIZE_CHECK( Offset );
+4 -4
View File
@@ -271,11 +271,11 @@
0x10000L,
0x20000L,
0, /* module-specific interface */
NULL, /* module-specific interface */
(FT_Module_Constructor)0,
(FT_Module_Destructor) 0,
(FT_Module_Requester) otvalid_get_service
(FT_Module_Constructor)NULL, /* module_init */
(FT_Module_Destructor) NULL, /* module_done */
(FT_Module_Requester) otvalid_get_service /* get_interface */
};
+29 -28
View File
@@ -492,8 +492,6 @@ THE SOFTWARE.
PCF_Metric metric;
FT_ULong bytes;
FT_UNUSED( load_flags );
FT_TRACE1(( "PCF_Glyph_Load: glyph index %d\n", glyph_index ));
@@ -550,6 +548,24 @@ THE SOFTWARE.
return FT_THROW( Invalid_File_Format );
}
slot->format = FT_GLYPH_FORMAT_BITMAP;
slot->bitmap_left = metric->leftSideBearing;
slot->bitmap_top = metric->ascent;
slot->metrics.horiAdvance = (FT_Pos)( metric->characterWidth * 64 );
slot->metrics.horiBearingX = (FT_Pos)( metric->leftSideBearing * 64 );
slot->metrics.horiBearingY = (FT_Pos)( metric->ascent * 64 );
slot->metrics.width = (FT_Pos)( ( metric->rightSideBearing -
metric->leftSideBearing ) * 64 );
slot->metrics.height = (FT_Pos)( bitmap->rows * 64 );
ft_synthesize_vertical_metrics( &slot->metrics,
( face->accel.fontAscent +
face->accel.fontDescent ) * 64 );
if ( load_flags & FT_LOAD_BITMAP_METRICS_ONLY )
goto Exit;
/* XXX: to do: are there cases that need repadding the bitmap? */
bytes = (FT_ULong)bitmap->pitch * bitmap->rows;
@@ -582,21 +598,6 @@ THE SOFTWARE.
}
}
slot->format = FT_GLYPH_FORMAT_BITMAP;
slot->bitmap_left = metric->leftSideBearing;
slot->bitmap_top = metric->ascent;
slot->metrics.horiAdvance = (FT_Pos)( metric->characterWidth * 64 );
slot->metrics.horiBearingX = (FT_Pos)( metric->leftSideBearing * 64 );
slot->metrics.horiBearingY = (FT_Pos)( metric->ascent * 64 );
slot->metrics.width = (FT_Pos)( ( metric->rightSideBearing -
metric->leftSideBearing ) * 64 );
slot->metrics.height = (FT_Pos)( bitmap->rows * 64 );
ft_synthesize_vertical_metrics( &slot->metrics,
( face->accel.fontAscent +
face->accel.fontDescent ) * 64 );
Exit:
return error;
}
@@ -617,7 +618,7 @@ THE SOFTWARE.
prop = pcf_find_property( face, prop_name );
if ( prop != NULL )
if ( prop )
{
if ( prop->isString )
{
@@ -700,10 +701,10 @@ THE SOFTWARE.
0x10000L,
0x20000L,
0, /* module-specific interface */
NULL, /* module-specific interface */
0, /* FT_Module_Constructor module_init */
0, /* FT_Module_Destructor module_done */
NULL, /* FT_Module_Constructor module_init */
NULL, /* FT_Module_Destructor module_done */
pcf_driver_requester /* FT_Module_Requester get_interface */
},
@@ -713,16 +714,16 @@ THE SOFTWARE.
PCF_Face_Init, /* FT_Face_InitFunc init_face */
PCF_Face_Done, /* FT_Face_DoneFunc done_face */
0, /* FT_Size_InitFunc init_size */
0, /* FT_Size_DoneFunc done_size */
0, /* FT_Slot_InitFunc init_slot */
0, /* FT_Slot_DoneFunc done_slot */
NULL, /* FT_Size_InitFunc init_size */
NULL, /* FT_Size_DoneFunc done_size */
NULL, /* FT_Slot_InitFunc init_slot */
NULL, /* FT_Slot_DoneFunc done_slot */
PCF_Glyph_Load, /* FT_Slot_LoadFunc load_glyph */
0, /* FT_Face_GetKerningFunc get_kerning */
0, /* FT_Face_AttachFunc attach_file */
0, /* FT_Face_GetAdvancesFunc get_advances */
NULL, /* FT_Face_GetKerningFunc get_kerning */
NULL, /* FT_Face_AttachFunc attach_file */
NULL, /* FT_Face_GetAdvancesFunc get_advances */
PCF_Size_Request, /* FT_Size_RequestFunc request_size */
PCF_Size_Select /* FT_Size_SelectFunc select_size */
+65 -11
View File
@@ -109,13 +109,18 @@ THE SOFTWARE.
if ( stream->size < 16 )
return FT_THROW( Invalid_File_Format );
/* we need 16 bytes per TOC entry */
if ( toc->count > stream->size >> 4 )
/* We need 16 bytes per TOC entry. Additionally, as a */
/* heuristic protection against gzip bombs (i.e., very */
/* small input files that expand to insanely large */
/* files), we limit the number of TOC entries to 1024. */
if ( toc->count > stream->size >> 4 ||
toc->count > 1024 )
{
FT_TRACE0(( "pcf_read_TOC: adjusting number of tables"
" (from %d to %d)\n",
toc->count, stream->size >> 4 ));
toc->count = stream->size >> 4;
toc->count,
FT_MIN( stream->size >> 4, 1024 ) ));
toc->count = FT_MIN( stream->size >> 4, 1024 );
}
if ( FT_NEW_ARRAY( face->toc.tables, toc->count ) )
@@ -319,7 +324,7 @@ THE SOFTWARE.
/* parsing normal metrics */
fields = PCF_BYTE_ORDER( format ) == MSBFirst
fields = ( PCF_BYTE_ORDER( format ) == MSBFirst )
? pcf_metric_msb_header
: pcf_metric_header;
@@ -1156,7 +1161,7 @@ THE SOFTWARE.
len = lengths[nn];
if ( src == NULL )
if ( !src )
continue;
/* separate elements with a space */
@@ -1260,14 +1265,63 @@ THE SOFTWARE.
if ( face->accel.constantWidth )
root->face_flags |= FT_FACE_FLAG_FIXED_WIDTH;
if ( ( error = pcf_interpret_style( face ) ) != 0 )
goto Exit;
if ( FT_SET_ERROR( pcf_interpret_style( face ) ) )
goto Exit;
prop = pcf_find_property( face, "FAMILY_NAME" );
if ( prop && prop->isString )
{
if ( FT_STRDUP( root->family_name, prop->value.atom ) )
goto Exit;
/* Prepend the foundry name plus a space to the family name. */
/* There are many fonts just called `Fixed' which look completely */
/* different, and which have nothing to do with each other. When */
/* selecting `Fixed' in KDE or Gnome one gets results that appear */
/* rather random, the style changes often if one changes the size */
/* and one cannot select some fonts at all. */
/* */
/* We also check whether we have `wide' characters; all put */
/* together, we get family names like `Sony Fixed' or `Misc Fixed */
/* Wide'. */
PCF_Property foundry_prop, point_size_prop, average_width_prop;
int l = ft_strlen( prop->value.atom ) + 1;
int wide = 0;
foundry_prop = pcf_find_property( face, "FOUNDRY" );
point_size_prop = pcf_find_property( face, "POINT_SIZE" );
average_width_prop = pcf_find_property( face, "AVERAGE_WIDTH" );
if ( point_size_prop && average_width_prop )
{
if ( average_width_prop->value.l >= point_size_prop->value.l )
{
/* This font is at least square shaped or even wider */
wide = 1;
l += ft_strlen( " Wide" );
}
}
if ( foundry_prop && foundry_prop->isString )
{
l += ft_strlen( foundry_prop->value.atom ) + 1;
if ( FT_NEW_ARRAY( root->family_name, l ) )
goto Exit;
ft_strcpy( root->family_name, foundry_prop->value.atom );
ft_strcat( root->family_name, " " );
ft_strcat( root->family_name, prop->value.atom );
}
else
{
if ( FT_NEW_ARRAY( root->family_name, l ) )
goto Exit;
ft_strcpy( root->family_name, prop->value.atom );
}
if ( wide )
ft_strcat( root->family_name, " Wide" );
}
else
root->family_name = NULL;
@@ -1290,7 +1344,7 @@ THE SOFTWARE.
FT_Short resolution_x = 0, resolution_y = 0;
FT_MEM_ZERO( bsize, sizeof ( FT_Bitmap_Size ) );
FT_ZERO( bsize );
/* for simplicity, we take absolute values of integer properties */
+9 -5
View File
@@ -161,12 +161,16 @@
{
sizeof ( PFR_CMapRec ),
(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_InitFunc) pfr_cmap_init, /* init */
(FT_CMap_DoneFunc) pfr_cmap_done, /* done */
(FT_CMap_CharIndexFunc)pfr_cmap_char_index, /* char_index */
(FT_CMap_CharNextFunc) pfr_cmap_char_next, /* char_next */
NULL, NULL, NULL, NULL, NULL
(FT_CMap_CharVarIndexFunc) NULL, /* char_var_index */
(FT_CMap_CharVarIsDefaultFunc)NULL, /* char_var_default */
(FT_CMap_VariantListFunc) NULL, /* variant_list */
(FT_CMap_CharVariantListFunc) NULL, /* charvariant_list */
(FT_CMap_VariantCharListFunc) NULL /* variantchar_list */
};
+9 -9
View File
@@ -181,10 +181,10 @@
0x10000L,
0x20000L,
0, /* module-specific interface */
NULL, /* module-specific interface */
0, /* FT_Module_Constructor module_init */
0, /* FT_Module_Destructor module_done */
NULL, /* FT_Module_Constructor module_init */
NULL, /* FT_Module_Destructor module_done */
pfr_get_service /* FT_Module_Requester get_interface */
},
@@ -194,19 +194,19 @@
pfr_face_init, /* FT_Face_InitFunc init_face */
pfr_face_done, /* FT_Face_DoneFunc done_face */
0, /* FT_Size_InitFunc init_size */
0, /* FT_Size_DoneFunc done_size */
NULL, /* FT_Size_InitFunc init_size */
NULL, /* FT_Size_DoneFunc done_size */
pfr_slot_init, /* FT_Slot_InitFunc init_slot */
pfr_slot_done, /* FT_Slot_DoneFunc done_slot */
pfr_slot_load, /* FT_Slot_LoadFunc load_glyph */
pfr_get_kerning, /* FT_Face_GetKerningFunc get_kerning */
0, /* FT_Face_AttachFunc attach_file */
0, /* FT_Face_GetAdvancesFunc get_advances */
NULL, /* FT_Face_AttachFunc attach_file */
NULL, /* FT_Face_GetAdvancesFunc get_advances */
0, /* FT_Size_RequestFunc request_size */
0, /* FT_Size_SelectFunc select_size */
NULL, /* FT_Size_RequestFunc request_size */
NULL, /* FT_Size_SelectFunc select_size */
};
+2 -2
View File
@@ -562,7 +562,7 @@
FT_UInt len = (FT_UInt)( limit - p );
if ( phy_font->font_id != NULL )
if ( phy_font->font_id )
goto Exit;
if ( FT_ALLOC( phy_font->font_id, len + 1 ) )
@@ -589,7 +589,7 @@
FT_Memory memory = phy_font->memory;
if ( phy_font->vertical.stem_snaps != NULL )
if ( phy_font->vertical.stem_snaps )
goto Exit;
PFR_CHECK( 1 );
+7 -3
View File
@@ -185,7 +185,7 @@
* nothing.
*/
pfrface->family_name = phy_font->family_name;
if ( pfrface->family_name == NULL )
if ( !pfrface->family_name )
pfrface->family_name = phy_font->font_id;
/* note that the style name can be NULL in certain PFR fonts,
@@ -342,8 +342,12 @@
/* try to load an embedded bitmap */
if ( ( load_flags & ( FT_LOAD_NO_SCALE | FT_LOAD_NO_BITMAP ) ) == 0 )
{
error = pfr_slot_load_bitmap( slot, size, gindex );
if ( error == 0 )
error = pfr_slot_load_bitmap(
slot,
size,
gindex,
( load_flags & FT_LOAD_BITMAP_METRICS_ONLY ) != 0 );
if ( !error )
goto Exit;
}
+5 -1
View File
@@ -578,7 +578,8 @@
FT_LOCAL( FT_Error )
pfr_slot_load_bitmap( PFR_Slot glyph,
PFR_Size size,
FT_UInt glyph_index )
FT_UInt glyph_index,
FT_Bool metrics_only )
{
FT_Error error;
PFR_Face face = (PFR_Face) glyph->root.face;
@@ -775,6 +776,9 @@
glyph->root.bitmap_left = (FT_Int)xpos;
glyph->root.bitmap_top = (FT_Int)( ypos + (FT_Long)ysize );
if ( metrics_only )
goto Exit1;
/* Allocate and read bitmap data */
{
FT_ULong len = (FT_ULong)glyph->root.bitmap.pitch * ysize;
+2 -1
View File
@@ -26,7 +26,8 @@ FT_BEGIN_HEADER
FT_LOCAL( FT_Error )
pfr_slot_load_bitmap( PFR_Slot glyph,
PFR_Size size,
FT_UInt glyph_index );
FT_UInt glyph_index,
FT_Bool metrics_only );
FT_END_HEADER
+38 -34
View File
@@ -30,52 +30,56 @@
FT_CALLBACK_TABLE_DEF
const PS_Table_FuncsRec ps_table_funcs =
{
ps_table_new,
ps_table_done,
ps_table_add,
ps_table_release
ps_table_new, /* init */
ps_table_done, /* done */
ps_table_add, /* add */
ps_table_release /* release */
};
FT_CALLBACK_TABLE_DEF
const PS_Parser_FuncsRec ps_parser_funcs =
{
ps_parser_init,
ps_parser_done,
ps_parser_skip_spaces,
ps_parser_skip_PS_token,
ps_parser_to_int,
ps_parser_to_fixed,
ps_parser_to_bytes,
ps_parser_to_coord_array,
ps_parser_to_fixed_array,
ps_parser_to_token,
ps_parser_to_token_array,
ps_parser_load_field,
ps_parser_load_field_table
ps_parser_init, /* init */
ps_parser_done, /* done */
ps_parser_skip_spaces, /* skip_spaces */
ps_parser_skip_PS_token, /* skip_PS_token */
ps_parser_to_int, /* to_int */
ps_parser_to_fixed, /* to_fixed */
ps_parser_to_bytes, /* to_bytes */
ps_parser_to_coord_array, /* to_coord_array */
ps_parser_to_fixed_array, /* to_fixed_array */
ps_parser_to_token, /* to_token */
ps_parser_to_token_array, /* to_token_array */
ps_parser_load_field, /* load_field */
ps_parser_load_field_table /* load_field_table */
};
FT_CALLBACK_TABLE_DEF
const T1_Builder_FuncsRec t1_builder_funcs =
{
t1_builder_init,
t1_builder_done,
t1_builder_check_points,
t1_builder_add_point,
t1_builder_add_point1,
t1_builder_add_contour,
t1_builder_start_point,
t1_builder_close_contour
t1_builder_init, /* init */
t1_builder_done, /* done */
t1_builder_check_points, /* check_points */
t1_builder_add_point, /* add_point */
t1_builder_add_point1, /* add_point1 */
t1_builder_add_contour, /* add_contour */
t1_builder_start_point, /* start_point */
t1_builder_close_contour /* close_contour */
};
FT_CALLBACK_TABLE_DEF
const T1_Decoder_FuncsRec t1_decoder_funcs =
{
t1_decoder_init,
t1_decoder_done,
t1_decoder_parse_charstrings
t1_decoder_init, /* init */
t1_decoder_done, /* done */
t1_decoder_parse_charstrings /* parse_charstrings */
};
@@ -83,9 +87,9 @@
FT_CALLBACK_TABLE_DEF
const AFM_Parser_FuncsRec afm_parser_funcs =
{
afm_parser_init,
afm_parser_done,
afm_parser_parse
afm_parser_init, /* init */
afm_parser_done, /* done */
afm_parser_parse /* parse */
};
#endif
@@ -130,9 +134,9 @@
&psaux_interface, /* module-specific interface */
(FT_Module_Constructor)0,
(FT_Module_Destructor) 0,
(FT_Module_Requester) 0
(FT_Module_Constructor)NULL, /* module_init */
(FT_Module_Destructor) NULL, /* module_done */
(FT_Module_Requester) NULL /* get_interface */
};
+15 -15
View File
@@ -344,7 +344,7 @@
FT_Byte c = *cur;
++cur;
cur++;
if ( c == '\\' )
{
@@ -370,17 +370,17 @@
case '\\':
case '(':
case ')':
++cur;
cur++;
break;
default:
/* skip octal escape or ignore backslash */
for ( i = 0; i < 3 && cur < limit; ++i )
for ( i = 0; i < 3 && cur < limit; i++ )
{
if ( !IS_OCTAL_DIGIT( *cur ) )
break;
++cur;
cur++;
}
}
}
@@ -455,19 +455,19 @@
FT_ASSERT( **acur == '{' );
for ( cur = *acur; cur < limit && error == FT_Err_Ok; ++cur )
for ( cur = *acur; cur < limit && error == FT_Err_Ok; cur++ )
{
switch ( *cur )
{
case '{':
++embed;
embed++;
break;
case '}':
--embed;
embed--;
if ( embed == 0 )
{
++cur;
cur++;
goto end;
}
break;
@@ -695,7 +695,7 @@
/* ************ otherwise, it is any token **************/
default:
token->start = cur;
token->type = ( *cur == '/' ? T1_TOKEN_TYPE_KEY : T1_TOKEN_TYPE_ANY );
token->type = ( *cur == '/' ) ? T1_TOKEN_TYPE_KEY : T1_TOKEN_TYPE_ANY;
ps_parser_skip_PS_token( parser );
cur = parser->cursor;
if ( !parser->error )
@@ -750,7 +750,7 @@
if ( !token.type )
break;
if ( tokens != NULL && cur < limit )
if ( tokens && cur < limit )
*cur = token;
cur++;
@@ -815,12 +815,12 @@
old_cur = cur;
if ( coords != NULL && count >= max_coords )
if ( coords && count >= max_coords )
break;
/* call PS_Conv_ToFixed() even if coords == NULL */
/* to properly parse number at `cur' */
*( coords != NULL ? &coords[count] : &dummy ) =
*( coords ? &coords[count] : &dummy ) =
(FT_Short)( PS_Conv_ToFixed( &cur, limit, 0 ) >> 16 );
if ( old_cur == cur )
@@ -895,12 +895,12 @@
old_cur = cur;
if ( values != NULL && count >= max_values )
if ( values && count >= max_values )
break;
/* call PS_Conv_ToFixed() even if coords == NULL */
/* to properly parse number at `cur' */
*( values != NULL ? &values[count] : &dummy ) =
*( values ? &values[count] : &dummy ) =
PS_Conv_ToFixed( &cur, limit, power_ten );
if ( old_cur == cur )
@@ -1172,7 +1172,7 @@
/* for this to work (FT_String**)q must have been */
/* initialized to NULL */
if ( *(FT_String**)q != NULL )
if ( *(FT_String**)q )
{
FT_TRACE0(( "ps_parser_load_field: overwriting field %s\n",
field->ident ));
+39 -23
View File
@@ -45,7 +45,7 @@
cmap->code_to_sid = is_expert ? psnames->adobe_expert_encoding
: psnames->adobe_std_encoding;
FT_ASSERT( cmap->code_to_sid != NULL );
FT_ASSERT( cmap->code_to_sid );
}
@@ -136,12 +136,16 @@
{
sizeof ( T1_CMapStdRec ),
(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_InitFunc) t1_cmap_standard_init, /* init */
(FT_CMap_DoneFunc) t1_cmap_std_done, /* done */
(FT_CMap_CharIndexFunc)t1_cmap_std_char_index, /* char_index */
(FT_CMap_CharNextFunc) t1_cmap_std_char_next, /* char_next */
NULL, NULL, NULL, NULL, NULL
(FT_CMap_CharVarIndexFunc) NULL, /* char_var_index */
(FT_CMap_CharVarIsDefaultFunc)NULL, /* char_var_default */
(FT_CMap_VariantListFunc) NULL, /* variant_list */
(FT_CMap_CharVariantListFunc) NULL, /* charvariant_list */
(FT_CMap_VariantCharListFunc) NULL /* variantchar_list */
};
@@ -161,12 +165,16 @@
{
sizeof ( T1_CMapStdRec ),
(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_InitFunc) t1_cmap_expert_init, /* init */
(FT_CMap_DoneFunc) t1_cmap_std_done, /* done */
(FT_CMap_CharIndexFunc)t1_cmap_std_char_index, /* char_index */
(FT_CMap_CharNextFunc) t1_cmap_std_char_next, /* char_next */
NULL, NULL, NULL, NULL, NULL
(FT_CMap_CharVarIndexFunc) NULL, /* char_var_index */
(FT_CMap_CharVarIsDefaultFunc)NULL, /* char_var_default */
(FT_CMap_VariantListFunc) NULL, /* variant_list */
(FT_CMap_CharVariantListFunc) NULL, /* charvariant_list */
(FT_CMap_VariantCharListFunc) NULL /* variantchar_list */
};
@@ -193,7 +201,7 @@
cmap->count = (FT_UInt)encoding->code_last - cmap->first;
cmap->indices = encoding->char_index;
FT_ASSERT( cmap->indices != NULL );
FT_ASSERT( cmap->indices );
FT_ASSERT( encoding->code_first <= encoding->code_last );
return 0;
@@ -232,7 +240,7 @@
FT_UInt32 char_code = *pchar_code;
++char_code;
char_code++;
if ( char_code < cmap->first )
char_code = cmap->first;
@@ -257,12 +265,16 @@
{
sizeof ( T1_CMapCustomRec ),
(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_InitFunc) t1_cmap_custom_init, /* init */
(FT_CMap_DoneFunc) t1_cmap_custom_done, /* done */
(FT_CMap_CharIndexFunc)t1_cmap_custom_char_index, /* char_index */
(FT_CMap_CharNextFunc) t1_cmap_custom_char_next, /* char_next */
NULL, NULL, NULL, NULL, NULL
(FT_CMap_CharVarIndexFunc) NULL, /* char_var_index */
(FT_CMap_CharVarIsDefaultFunc)NULL, /* char_var_default */
(FT_CMap_VariantListFunc) NULL, /* variant_list */
(FT_CMap_CharVariantListFunc) NULL, /* charvariant_list */
(FT_CMap_VariantCharListFunc) NULL /* variantchar_list */
};
@@ -343,12 +355,16 @@
{
sizeof ( PS_UnicodesRec ),
(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_InitFunc) t1_cmap_unicode_init, /* init */
(FT_CMap_DoneFunc) t1_cmap_unicode_done, /* done */
(FT_CMap_CharIndexFunc)t1_cmap_unicode_char_index, /* char_index */
(FT_CMap_CharNextFunc) t1_cmap_unicode_char_next, /* char_next */
NULL, NULL, NULL, NULL, NULL
(FT_CMap_CharVarIndexFunc) NULL, /* char_var_index */
(FT_CMap_CharVarIsDefaultFunc)NULL, /* char_var_default */
(FT_CMap_VariantListFunc) NULL, /* variant_list */
(FT_CMap_CharVariantListFunc) NULL, /* charvariant_list */
(FT_CMap_VariantCharListFunc) NULL /* variantchar_list */
};
+23 -36
View File
@@ -405,9 +405,7 @@
( decoder->buildchar == NULL ) );
if ( decoder->buildchar && decoder->len_buildchar > 0 )
ft_memset( &decoder->buildchar[0],
0,
sizeof ( decoder->buildchar[0] ) * decoder->len_buildchar );
FT_ARRAY_ZERO( decoder->buildchar, decoder->len_buildchar );
FT_TRACE4(( "\n"
"Start charstring\n" ));
@@ -736,7 +734,7 @@
if ( arg_cnt != 3 )
goto Unexpected_OtherSubr;
if ( decoder->flex_state == 0 ||
if ( !decoder->flex_state ||
decoder->num_flex_vectors != 7 )
{
FT_ERROR(( "t1_decoder_parse_charstrings:"
@@ -754,13 +752,12 @@
if ( arg_cnt != 0 )
goto Unexpected_OtherSubr;
if ( FT_SET_ERROR( t1_builder_start_point( builder, x, y ) ) ||
FT_SET_ERROR( t1_builder_check_points( builder, 6 ) ) )
goto Fail;
decoder->flex_state = 1;
decoder->num_flex_vectors = 0;
if ( ( error = t1_builder_start_point( builder, x, y ) )
!= FT_Err_Ok ||
( error = t1_builder_check_points( builder, 6 ) )
!= FT_Err_Ok )
goto Fail;
break;
case 2: /* add flex vectors */
@@ -771,7 +768,7 @@
if ( arg_cnt != 0 )
goto Unexpected_OtherSubr;
if ( decoder->flex_state == 0 )
if ( !decoder->flex_state )
{
FT_ERROR(( "t1_decoder_parse_charstrings:"
" missing flex start\n" ));
@@ -876,7 +873,7 @@
PS_Blend blend = decoder->blend;
if ( arg_cnt != 1 || blend == NULL )
if ( arg_cnt != 1 || !blend )
goto Unexpected_OtherSubr;
idx = Fix2Int( top[0] );
@@ -944,7 +941,7 @@
PS_Blend blend = decoder->blend;
if ( arg_cnt != 2 || blend == NULL )
if ( arg_cnt != 2 || !blend )
goto Unexpected_OtherSubr;
idx = Fix2Int( top[1] );
@@ -965,7 +962,7 @@
PS_Blend blend = decoder->blend;
if ( arg_cnt != 1 || blend == NULL )
if ( arg_cnt != 1 || !blend )
goto Unexpected_OtherSubr;
idx = Fix2Int( top[0] );
@@ -1123,7 +1120,7 @@
FT_TRACE4(( "BuildCharArray = [ " ));
for ( i = 0; i < decoder->len_buildchar; ++i )
for ( i = 0; i < decoder->len_buildchar; i++ )
FT_TRACE4(( "%d ", decoder->buildchar[i] ));
FT_TRACE4(( "]\n" ));
@@ -1201,8 +1198,7 @@
case op_hlineto:
FT_TRACE4(( " hlineto" ));
if ( ( error = t1_builder_start_point( builder, x, y ) )
!= FT_Err_Ok )
if ( FT_SET_ERROR( t1_builder_start_point( builder, x, y ) ) )
goto Fail;
x += top[0];
@@ -1223,10 +1219,8 @@
case op_hvcurveto:
FT_TRACE4(( " hvcurveto" ));
if ( ( error = t1_builder_start_point( builder, x, y ) )
!= FT_Err_Ok ||
( error = t1_builder_check_points( builder, 3 ) )
!= FT_Err_Ok )
if ( FT_SET_ERROR( t1_builder_start_point( builder, x, y ) ) ||
FT_SET_ERROR( t1_builder_check_points( builder, 3 ) ) )
goto Fail;
x += top[0];
@@ -1241,16 +1235,14 @@
case op_rlineto:
FT_TRACE4(( " rlineto" ));
if ( ( error = t1_builder_start_point( builder, x, y ) )
!= FT_Err_Ok )
if ( FT_SET_ERROR( t1_builder_start_point( builder, x, y ) ) )
goto Fail;
x += top[0];
y += top[1];
Add_Line:
if ( ( error = t1_builder_add_point1( builder, x, y ) )
!= FT_Err_Ok )
if ( FT_SET_ERROR( t1_builder_add_point1( builder, x, y ) ) )
goto Fail;
break;
@@ -1270,10 +1262,8 @@
case op_rrcurveto:
FT_TRACE4(( " rrcurveto" ));
if ( ( error = t1_builder_start_point( builder, x, y ) )
!= FT_Err_Ok ||
( error = t1_builder_check_points( builder, 3 ) )
!= FT_Err_Ok )
if ( FT_SET_ERROR( t1_builder_start_point( builder, x, y ) ) ||
FT_SET_ERROR( t1_builder_check_points( builder, 3 ) ) )
goto Fail;
x += top[0];
@@ -1292,10 +1282,8 @@
case op_vhcurveto:
FT_TRACE4(( " vhcurveto" ));
if ( ( error = t1_builder_start_point( builder, x, y ) )
!= FT_Err_Ok ||
( error = t1_builder_check_points( builder, 3 ) )
!= FT_Err_Ok )
if ( FT_SET_ERROR( t1_builder_start_point( builder, x, y ) ) ||
FT_SET_ERROR( t1_builder_check_points( builder, 3 ) ) )
goto Fail;
y += top[0];
@@ -1310,8 +1298,7 @@
case op_vlineto:
FT_TRACE4(( " vlineto" ));
if ( ( error = t1_builder_start_point( builder, x, y ) )
!= FT_Err_Ok )
if ( FT_SET_ERROR( t1_builder_start_point( builder, x, y ) ) )
goto Fail;
y += top[0];
@@ -1336,7 +1323,7 @@
/* otherwise, we divide numbers in 16.16 format -- */
/* in both cases, it is the same operation */
*top = FT_DivFix( top[0], top[1] );
++top;
top++;
large_int = FALSE;
break;
@@ -1591,7 +1578,7 @@
FT_Render_Mode hint_mode,
T1_Decoder_Callback parse_callback )
{
FT_MEM_ZERO( decoder, sizeof ( *decoder ) );
FT_ZERO( decoder );
/* retrieve PSNames interface from list of current modules */
{
+5 -5
View File
@@ -898,7 +898,7 @@
static void
psh_print_zone( PSH_Zone zone )
{
printf( "zone [scale,delta,min,max] = [%.3f,%.3f,%d,%d]\n",
printf( "zone [scale,delta,min,max] = [%.5f,%.2f,%d,%d]\n",
zone->scale / 65536.0,
zone->delta / 64.0,
zone->min,
@@ -1162,7 +1162,7 @@
/* clear all fields */
FT_MEM_ZERO( glyph, sizeof ( *glyph ) );
FT_ZERO( glyph );
memory = glyph->memory = globals->memory;
@@ -1531,7 +1531,7 @@
}
}
if ( point->hint == NULL )
if ( !point->hint )
{
for ( nn = 0; nn < num_hints; nn++ )
{
@@ -1572,8 +1572,8 @@
PS_Mask mask = table->hint_masks->masks;
FT_UInt num_masks = table->hint_masks->num_masks;
FT_UInt first = 0;
FT_Int major_dir = dimension == 0 ? PSH_DIR_VERTICAL
: PSH_DIR_HORIZONTAL;
FT_Int major_dir = ( dimension == 0 ) ? PSH_DIR_VERTICAL
: PSH_DIR_HORIZONTAL;
PSH_Dimension dim = &glyph->globals->dimension[dimension];
FT_Fixed scale = dim->scale_mult;
FT_Int threshold;
+7 -5
View File
@@ -95,9 +95,11 @@
FT_DEFINE_PSHINTER_INTERFACE(
pshinter_interface,
pshinter_get_globals_funcs,
pshinter_get_t1_funcs,
pshinter_get_t2_funcs )
pshinter_get_t2_funcs
)
FT_DEFINE_MODULE(
@@ -111,9 +113,9 @@
&PSHINTER_INTERFACE_GET, /* module-specific interface */
(FT_Module_Constructor)ps_hinter_init,
(FT_Module_Destructor) ps_hinter_done,
(FT_Module_Requester) NULL ) /* no additional interface for now */
(FT_Module_Constructor)ps_hinter_init, /* module_init */
(FT_Module_Destructor) ps_hinter_done, /* module_done */
(FT_Module_Requester) NULL /* get_interface */
)
/* END */
+3 -3
View File
@@ -818,7 +818,7 @@
ps_hints_init( PS_Hints hints,
FT_Memory memory )
{
FT_MEM_ZERO( hints, sizeof ( *hints ) );
FT_ZERO( hints );
hints->memory = memory;
}
@@ -1140,7 +1140,7 @@
FT_LOCAL_DEF( void )
t1_hints_funcs_init( T1_Hints_FuncsRec* funcs )
{
FT_MEM_ZERO( (char*)funcs, sizeof ( *funcs ) );
FT_ZERO( funcs );
funcs->open = (T1_Hints_OpenFunc) t1_hints_open;
funcs->close = (T1_Hints_CloseFunc) ps_hints_close;
@@ -1206,7 +1206,7 @@
FT_LOCAL_DEF( void )
t2_hints_funcs_init( T2_Hints_FuncsRec* funcs )
{
FT_MEM_ZERO( funcs, sizeof ( *funcs ) );
FT_ZERO( funcs );
funcs->open = (T2_Hints_OpenFunc) t2_hints_open;
funcs->close = (T2_Hints_CloseFunc) ps_hints_close;
+14 -5
View File
@@ -22,6 +22,8 @@
#include FT_SERVICE_POSTSCRIPT_CMAPS_H
#include "psmodule.h"
#define DEFINE_PS_TABLES
#include "pstables.h"
#include "psnamerr.h"
@@ -525,6 +527,7 @@
FT_DEFINE_SERVICE_PSCMAPSREC(
pscmaps_interface,
(PS_Unicode_ValueFunc) ps_unicode_value, /* unicode_value */
(PS_Unicodes_InitFunc) ps_unicodes_init, /* unicodes_init */
(PS_Unicodes_CharIndexFunc)ps_unicodes_char_index, /* unicodes_char_index */
@@ -534,12 +537,14 @@
(PS_Adobe_Std_StringsFunc) ps_get_standard_strings, /* adobe_std_strings */
t1_standard_encoding, /* adobe_std_encoding */
t1_expert_encoding ) /* adobe_expert_encoding */
t1_expert_encoding /* adobe_expert_encoding */
)
#else
FT_DEFINE_SERVICE_PSCMAPSREC(
pscmaps_interface,
NULL, /* unicode_value */
NULL, /* unicodes_init */
NULL, /* unicodes_char_index */
@@ -549,13 +554,15 @@
(PS_Adobe_Std_StringsFunc) ps_get_standard_strings, /* adobe_std_strings */
t1_standard_encoding, /* adobe_std_encoding */
t1_expert_encoding ) /* adobe_expert_encoding */
t1_expert_encoding /* adobe_expert_encoding */
)
#endif /* FT_CONFIG_OPTION_ADOBE_GLYPH_LIST */
FT_DEFINE_SERVICEDESCREC1(
pscmaps_services,
FT_SERVICE_ID_POSTSCRIPT_CMAPS, &PSCMAPS_INTERFACE_GET )
@@ -601,9 +608,11 @@
PUT_PS_NAMES_SERVICE(
(void*)&PSCMAPS_INTERFACE_GET ), /* module specific interface */
(FT_Module_Constructor)NULL,
(FT_Module_Destructor) NULL,
(FT_Module_Requester) PUT_PS_NAMES_SERVICE( psnames_get_service ) )
(FT_Module_Constructor)NULL, /* module_init */
(FT_Module_Destructor) NULL, /* module_done */
(FT_Module_Requester) PUT_PS_NAMES_SERVICE( psnames_get_service ) /* get_interface */
)
/* END */

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