This commit was generated by cvs2svn to compensate for changes in r2038,

which included commits to RCS files with non-trunk default branches.


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@2039 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Ingo Weinhold
2002-11-20 19:21:05 +00:00
parent e7f818ff7c
commit 389d57611d
162 changed files with 7071 additions and 6118 deletions
+146 -1
View File
@@ -1,4 +1,149 @@
LATEST CHANGES BETWEEN 2.1.1 and 2.1.0
LATEST CHANGES BETWEEN 2.1.3 and 2.1.2
I. IMPORTANT BUG FIXES
- FT_Vector_Transform had been incorrectly modified in 2.1.2, resulting
in incorrect transformations being applied (for example, rotations
were processed in opposite angles).
- The format 8 and 12 TrueType charmap enumeration routines have been
fixed (FT_Get_Next_Char returned invalid values).
- The PFR font driver returned incorrect advance widths if the outline
and metrics resolution defined in the font file were different.
- FT_Glyph_To_Bitmap now returns successfully when called with an
FT_BitmapGlyph argument (it previously returned an error).
- A bug in the Type 1 loader that prevented valid font bounding boxes to
be loaded from multiple master fonts.
- The SFNT validation code has been rewritten. FreeType can now load
"broken" fonts that were usable on Windows, but not with previous
versions of the library.
- The computation of bearings in the BDF driver has been fixed.
- The Postscript hinter crashed when trying to hint certain glyphs (more
precisely, when trying to apply hints to an empty glyph outline).
- The TrueType glyph loader now supports composites in "Apple format"
(they differ slightly from Microsoft/OpenType ones in the way transform
offsets are computed).
- FreeType was very slow at opening certain asian CID/CFF fonts, due
to fixed increment in dynamic array re-allocations. This has been
changed to exponential behaviour to get acceptable performance
II. IMPORTANT CHANGES
- the PCF driver now supports gzip-compressed font files natively. This
means that you'll be able to use all these bitmap fonts that come
with XFree86 with FreeType (and libXft/libXft2, by extension).
- The automatic and postscript hinters have both been updated. This
results in a relatively important increase of rendering quality since
many nasty defaults have been supressed. Please visit the web page:
http://www.freetype.org/hinting/smooth-hinting.html
for additional details on this topic.
- The "load_flags" parameter of FT_Load_Glyph is now an FT_Int32
(instead of just being an FT_Int). This breaks source and binary
compatibility for 16bit systems only, while retaining both of them for
32 and 64 bit ones.
Some new flags have been added consequently:
FT_LOAD_NO_AUTOHINT :: Disable the use of the auto-hinter
(but not native format hinters).
FT_LOAD_TARGET_NORMAL :: Hint and render for normal anti-aliased
displays.
FT_LOAD_TARGET_MONO :: Hint and render for 1-bit displays.
FT_LOAD_TARGET_LCD :: Hint and render for horizontal RGB or BGR
sub-pixel displays (like LCD screens).
THIS IS STILL EXPERIMENTAL!
FT_LOAD_TARGET_LCD_V :: Same as FT_LOAD_TARGET_LCD, for vertical
sub-pixel displays (like rotated LCD
screens). THIS IS STILL EXPERIMENTAL!
FT_LOAD_MONOCHROME is still supported, but only affects rendering, not
the hinting.
Note that the 'ftview' demo program available in the 'ft2demos' package
has been updated to support LCD-optimized display on non-paletted
displays (under Win32 and X11)
- The PFR driver now supports embedded bitmaps (all formats supported),
and returns correct kerning metrics for all glyphs
- The TrueType charmap loader now supports certain "broken" fonts that
load under Windows without problems.
- The cache API has been slightly modified (it's still a beta!):
- The type FTC_ImageDesc has been removed; it is now replaced by
FTC_ImageTypeRec. Note that one of its fields is a `load_flag'
parameter for FT_Load_Glyph.
- The field "num_grays" of FT_SBitRec has been changed to "max_grays"
in order to fit within a single byte. Its maximum value is thus 255
(instead of 256 as previously).
III. MISCELLANEOUS
- Added support for the DESTDIR variable during "make install". This
simplifies packaging of FreeType.
- included modified copies of the ZLib sources in 'src/gzip' in order
to support gzip-compressed PCF fonts. We do not use the system-provided
zlib for now, though this is a probable enhancement for future releases
- The DocMaker tool used to generate the on-line API reference has been
completely rewritten. It is now located in
"src/tools/docmaker/docmaker.py". Features:
- better cross-referenced output
- more polished output
- uses Python regular expressions (though it didn't speed the
program)
- much more modular structure, which allows for different "backends"
in order to generate HTML, XML, or whatever format.
One can regenerate the API reference by calling:
python src/tools/docmaker/docmaker.py \
--prefix=ft2 \
--title=FreeType-2.1.3 \
--output=<outputdirectory>
include/freetype/*.h \
include/freetype/config/*.h \
include/freetype/cache/*.h
- A new, experimental, support for incremental font loading (i.e.,
loading of fonts where the glyphs are not in the font file itself, but
provided by an external component, like a Postscript interpreter) has
been added by Graham Asher. This is still work in progress, however.
- A new, EXPERIMENTAL, path stroker has been added. It doesn't suffer
from severe rounding errors and treat bezier arcs directly. Still
work in progress (i.e. not part of the official API). See the file
<freetype/ftstroker.h> for some of the details.
- The massive re-formatting of sources and internal re-design is still
under-way. Many internal functions, constants, and types have been
renamed.
========================================================================
LATEST CHANGES BETWEEN 2.1.2 and 2.1.1
I. IMPORTANT BUG FIXES
-8
View File
@@ -23,9 +23,6 @@
/* define to allow cache lookup inlining */
#define FTC_CACHE_USE_INLINE
/* define to use linear hash table */
#define FTC_CACHE_USE_LINEAR_HASHING
FT_BEGIN_HEADER
@@ -181,14 +178,9 @@ FT_BEGIN_HEADER
FT_UInt cache_index; /* in manager's table */
FT_Pointer cache_data; /* used by cache node methods */
#ifdef FTC_CACHE_USE_LINEAR_HASHING
FT_UFast p;
FT_UFast mask;
FT_Long slack;
#else
FT_UFast nodes;
FT_UFast size;
#endif
FTC_Node* buckets;
FT_LruList_ClassRec family_class;
+54 -53
View File
@@ -4,7 +4,7 @@
/* */
/* FreeType Image cache (specification). */
/* */
/* Copyright 2000-2001 by */
/* Copyright 2000-2001, 2002 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -53,65 +53,43 @@ FT_BEGIN_HEADER
/*************************************************************************/
#define FTC_IMAGE_FORMAT( x ) ( (x) & 7 )
#define ftc_image_format_bitmap 0x0000
#define ftc_image_format_outline 0x0001
#define ftc_image_format_mask 0x000F
#define ftc_image_flag_monochrome 0x0010
#define ftc_image_flag_unhinted 0x0020
#define ftc_image_flag_autohinted 0x0040
#define ftc_image_flag_unscaled 0x0080
#define ftc_image_flag_no_sbits 0x0100
/* monochrome bitmap */
#define ftc_image_mono ftc_image_format_bitmap | \
ftc_image_flag_monochrome
/* anti-aliased bitmap */
#define ftc_image_grays ftc_image_format_bitmap
/* scaled outline */
#define ftc_image_outline ftc_image_format_outline
/*************************************************************************/
/* */
/* <Struct> */
/* FTC_ImageDesc */
/* */
/* <Description> */
/* A simple structure used to describe a given glyph image category. */
/* Note that this is different from @FTC_Image_Desc. */
/* */
/* <Fields> */
/* size :: An @FTC_SizeRec used to describe the glyph's face and */
/* size. */
/* */
/* type :: The glyph image's type. Note that it is a 32-bit uint. */
/* */
/* <Note> */
/* This type deprecates @FTC_Image_Desc. */
/* */
typedef struct FTC_ImageDesc_
/**************************************************************************
*
* @struct:
* FTC_ImageTypeRec
*
* @description:
* A simple structure used to describe the type of glyph image to be
* loaded into the cache.
*
* @fields:
* font :: An @FTC_FontRec used to describe the glyph's face and size.
*
* flags :: The load flags to be applied when loading the glyph; see
* the @FT_LOAD_XXX constants for details.
*
* @note:
* This type completely replaces the @FTC_Image_Desc structure which is
* now obsolete.
*/
typedef struct FTC_ImageTypeRec_
{
FTC_FontRec font;
FT_UInt32 type;
FT_Int32 flags;
} FTC_ImageDesc;
} FTC_ImageTypeRec;
typedef struct FTC_ImageTypeRec_* FTC_ImageType;
/* */
#define FTC_IMAGE_DESC_COMPARE( d1, d2 ) \
#define FTC_IMAGE_TYPE_COMPARE( d1, d2 ) \
( FTC_FONT_COMPARE( &(d1)->font, &(d2)->font ) && \
(d1)->type == (d2)->type )
(d1)->flags == (d2)->flags )
#define FTC_IMAGE_DESC_HASH( d ) \
#define FTC_IMAGE_TYPE_HASH( d ) \
(FT_UFast)( FTC_FONT_HASH( &(d)->font ) ^ \
( (d)->type << 4 ) )
( (d)->flags << 4 ) )
/*************************************************************************/
@@ -160,7 +138,7 @@ FT_BEGIN_HEADER
/* <Input> */
/* cache :: A handle to the source glyph image cache. */
/* */
/* desc :: A pointer to a glyph image descriptor. */
/* type :: A pointer to a glyph image type descriptor. */
/* */
/* gindex :: The glyph index to retrieve. */
/* */
@@ -193,13 +171,36 @@ FT_BEGIN_HEADER
/* */
FT_EXPORT( FT_Error )
FTC_ImageCache_Lookup( FTC_ImageCache cache,
FTC_ImageDesc* desc,
FTC_ImageType type,
FT_UInt gindex,
FT_Glyph *aglyph,
FTC_Node *anode );
/* */
#define ftc_image_format( x ) ( (x) & 7 )
#define ftc_image_format_bitmap 0x0000
#define ftc_image_format_outline 0x0001
#define ftc_image_format_mask 0x000F
#define ftc_image_flag_monochrome 0x0010
#define ftc_image_flag_unhinted 0x0020
#define ftc_image_flag_autohinted 0x0040
#define ftc_image_flag_unscaled 0x0080
#define ftc_image_flag_no_sbits 0x0100
/* monochrome bitmap */
#define ftc_image_mono ftc_image_format_bitmap | \
ftc_image_flag_monochrome
/* anti-aliased bitmap */
#define ftc_image_grays ftc_image_format_bitmap
/* scaled outline */
#define ftc_image_outline ftc_image_format_outline
/*************************************************************************/
/* */
+6 -6
View File
@@ -4,7 +4,7 @@
/* */
/* A small-bitmap cache (specification). */
/* */
/* Copyright 2000-2001 by */
/* Copyright 2000-2001, 2002 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -72,7 +72,7 @@ FT_BEGIN_HEADER
/* */
/* format :: The format of the glyph bitmap (monochrome or gray). */
/* */
/* num_grays :: The number of gray levels. */
/* max_grays :: Maximum gray level value (in the range 1 to 255). */
/* */
/* pitch :: The number of bytes per bitmap line. May be positive */
/* or negative. */
@@ -91,8 +91,8 @@ FT_BEGIN_HEADER
FT_Char top;
FT_Byte format;
FT_Short num_grays; /* XXX: Should be FT_Byte. See ftcsbits.c */
FT_Char pitch;
FT_Byte max_grays;
FT_Short pitch;
FT_Char xadvance;
FT_Char yadvance;
@@ -160,7 +160,7 @@ FT_BEGIN_HEADER
/* <Input> */
/* cache :: A handle to the source sbit cache. */
/* */
/* desc :: A pointer to the glyph image descriptor. */
/* type :: A pointer to the glyph image type descriptor. */
/* */
/* gindex :: The glyph index. */
/* */
@@ -195,7 +195,7 @@ FT_BEGIN_HEADER
/* */
FT_EXPORT( FT_Error )
FTC_SBitCache_Lookup( FTC_SBitCache cache,
FTC_ImageDesc* desc,
FTC_ImageType type,
FT_UInt gindex,
FTC_SBit *sbit,
FTC_Node *anode );
@@ -361,6 +361,17 @@
/* */
#define FT_BDF_H <freetype/ftbdf.h>
/*************************************************************************/
/* */
/* @macro: */
/* FT_GZIP_H */
/* */
/* @description: */
/* A macro used in #include statements to name the file containing */
/* the definitions of an API to support for gzip-compressed files. */
/* */
#define FT_GZIP_H <freetype/ftgzip.h>
/*************************************************************************/
/* */
@@ -487,6 +498,7 @@
/* */
#define FT_TRIGONOMETRY_H <freetype/fttrigon.h>
#define FT_STROKER_H <freetype/ftstroker.h>
#define FT_SYNTHESIS_H <freetype/ftsynth.h>
#define FT_ERROR_DEFINITIONS_H <freetype/fterrdef.h>
@@ -498,6 +510,8 @@
#define FT_XFREE86_H <freetype/ftxf86.h>
#define FT_INCREMENTAL_H <freetype/ftincrem.h>
/* now include internal headers definitions from <freetype/internal/...> */
#define FT_INTERNAL_INTERNAL_H <freetype/internal/internal.h>
@@ -9,8 +9,11 @@ FT_USE_MODULE(pshinter_module_class)
FT_USE_MODULE(ft_raster1_renderer_class)
FT_USE_MODULE(sfnt_module_class)
FT_USE_MODULE(ft_smooth_renderer_class)
FT_USE_MODULE(ft_smooth_lcd_renderer_class)
FT_USE_MODULE(ft_smooth_lcdv_renderer_class)
FT_USE_MODULE(tt_driver_class)
FT_USE_MODULE(t1_driver_class)
FT_USE_MODULE(t42_driver_class)
FT_USE_MODULE(pfr_driver_class)
FT_USE_MODULE(winfnt_driver_class)
+149 -135
View File
@@ -25,7 +25,6 @@
FT_BEGIN_HEADER
/*************************************************************************/
/* */
/* USER-SELECTABLE CONFIGURATION MACROS */
@@ -78,68 +77,98 @@ FT_BEGIN_HEADER
/*************************************************************************/
/* */
/* CMap support */
/* Many compilers provide a non-ANSI 64-bit data type that can be used */
/* by FreeType to speed up some computations. However, this will create */
/* some problems when compiling the library in strict ANSI mode. */
/* */
/* Define this if you want generic cmap support. */
/* For this reason, the use of 64-bit ints is normally disabled when */
/* the __STDC__ macro is defined. You can however disable this by */
/* defining here the macro FT_CONFIG_OPTION_FORCE_INT64. */
/* */
#define FT_CONFIG_OPTION_USE_CMAPS
/* For most compilers, this will only create compilation warnings */
/* when building the library. */
/* */
/* ObNote: The compiler-specific 64-bit integers are detected in the */
/* file "ftconfig.h" either statically, or through Autoconf */
/* on platforms that support it. */
/* */
#undef FT_CONFIG_OPTION_FORCE_INT64
/*************************************************************************/
/* */
/* Convenience functions support */
/* Gzip-compressed file support. */
/* */
/* Some functions of the FreeType 2 API are provided as a convenience */
/* for client applications and developers. However, they are not */
/* required to build and run the library itself. */
/* FreeType now handles font files that have been compressed with the */
/* 'gzip' program. This is mostly used to parse many of the PCF files */
/* that come with XFree86. The implementation uses 'zlib' to */
/* partially uncompress the file on the fly (see src/base/ftgzip.c). */
/* */
/* By defining this configuration macro, you'll disable the */
/* compilation of these functions at build time. This can be useful */
/* to reduce the library's code size when you don't need any of */
/* these functions. */
/* Define this macro if you want to enable this "feature". Note that */
/* this will however force you to link the zlib to any program that */
/* also uses FreeType. */
/* */
/* All convenience functions are declared as such in their */
/* documentation. */
/* */
#undef FT_CONFIG_OPTION_NO_CONVENIENCE_FUNCS
#define FT_CONFIG_OPTION_USE_ZLIB
/*************************************************************************/
/* */
/* Module errors */
/* ZLib library selection */
/* */
/* If this macro is set (which is _not_ the default), the higher byte */
/* of an error code gives the module in which the error has occurred, */
/* while the lower byte is the real error code. */
/* This macro is only used when FT_CONFIG_OPTION_USE_ZLIB is defined. */
/* It allows FreeType's "ftgzip" component to link to the system's */
/* installation of the ZLib library. This is useful on systems like */
/* Unix or VMS where it generally is already available. */
/* */
/* Setting this macro makes sense for debugging purposes only, since */
/* it would break source compatibility of certain programs that use */
/* FreeType 2. */
/* If you let it undefined, the component will use its own copy */
/* of the zlib sources instead. These have been modified to be */
/* included directly within the component and *not* export external */
/* function names. This allows you to link any program with FreeType */
/* _and_ ZLib without linking conflicts. */
/* */
/* More details can be found in the files ftmoderr.h and fterrors.h. */
/* do not #undef this macro here, since the build system might */
/* define for certain configurations */
/* */
#undef FT_CONFIG_OPTION_USE_MODULE_ERRORS
/* #define FT_CONFIG_OPTION_SYSTEM_ZLIB */
/*************************************************************************/
/* */
/* Alternate Glyph Image Format support */
/* DLL export compilation */
/* */
/* By default, the glyph images returned by the FreeType glyph loader */
/* can either be a pixmap or a vectorial outline defined through */
/* Bezier control points. When defining the following configuration */
/* macro, some font drivers will be able to register alternate */
/* glyph image formats. */
/* When compiling FreeType as a DLL, some systems/compilers need a */
/* special keyword in front OR after the return type of function */
/* declarations. */
/* */
/* Unset this macro if you are sure that you will never use a font */
/* driver with an alternate glyph format; this will reduce the size of */
/* the base layer code. */
/* Two macros are used within the FreeType source code to define */
/* exported library functions: FT_EXPORT and FT_EXPORT_DEF. */
/* */
/* Note that a few Type 1 fonts, as well as Windows `vector' fonts */
/* use a vector `plotter' format that isn't supported when this */
/* macro is undefined. */
/* FT_EXPORT( return_type ) */
/* */
#define FT_CONFIG_OPTION_ALTERNATE_GLYPH_FORMATS
/* is used in a function declaration, as in */
/* */
/* FT_EXPORT( FT_Error ) */
/* FT_Init_FreeType( FT_Library* alibrary ); */
/* */
/* */
/* FT_EXPORT_DEF( return_type ) */
/* */
/* is used in a function definition, as in */
/* */
/* FT_EXPORT_DEF( FT_Error ) */
/* FT_Init_FreeType( FT_Library* alibrary ) */
/* { */
/* ... some code ... */
/* return FT_Err_Ok; */
/* } */
/* */
/* You can provide your own implementation of FT_EXPORT and */
/* FT_EXPORT_DEF here if you want. If you leave them undefined, they */
/* will be later automatically defined as `extern return_type' to */
/* allow normal compilation. */
/* */
/* #define FT_EXPORT(x) extern x */
/* #define FT_EXPORT_DEF(x) x */
/*************************************************************************/
@@ -187,93 +216,12 @@ FT_BEGIN_HEADER
/*************************************************************************/
/* */
/* Many compilers provide a non-ANSI 64-bit data type that can be used */
/* by FreeType to speed up some computations. However, this will create */
/* some problems when compiling the library in strict ANSI mode. */
/* Allow the use of FT_Incremental_Interface to load typefaces that */
/* contain no glyph data, but supply it via a callback function. */
/* This allows FreeType to be used with the PostScript language, using */
/* the GhostScript interpreter. */
/* */
/* For this reason, the use of 64-bit ints is normally disabled when */
/* the __STDC__ macro is defined. You can however disable this by */
/* defining here the macro FT_CONFIG_OPTION_FORCE_INT64. */
/* */
/* For most compilers, this will only create compilation warnings */
/* when building the library. */
/* */
/* ObNote: The compiler-specific 64-bit integers are detected in the */
/* file "ftconfig.h" either statically, or through Autoconf */
/* on platforms that support it. */
/* */
#undef FT_CONFIG_OPTION_FORCE_INT64
/*************************************************************************/
/* */
/* DLL export compilation */
/* */
/* When compiling FreeType as a DLL, some systems/compilers need a */
/* special keyword in front OR after the return type of function */
/* declarations. */
/* */
/* Two macros are used within the FreeType source code to define */
/* exported library functions: FT_EXPORT and FT_EXPORT_DEF. */
/* */
/* FT_EXPORT( return_type ) */
/* */
/* is used in a function declaration, as in */
/* */
/* FT_EXPORT( FT_Error ) */
/* FT_Init_FreeType( FT_Library* alibrary ); */
/* */
/* */
/* FT_EXPORT_DEF( return_type ) */
/* */
/* is used in a function definition, as in */
/* */
/* FT_EXPORT_DEF( FT_Error ) */
/* FT_Init_FreeType( FT_Library* alibrary ) */
/* { */
/* ... some code ... */
/* return FT_Err_Ok; */
/* } */
/* */
/* You can provide your own implementation of FT_EXPORT and */
/* FT_EXPORT_DEF here if you want. If you leave them undefined, they */
/* will be later automatically defined as `extern return_type' to */
/* allow normal compilation. */
/* */
#undef FT_EXPORT
#undef FT_EXPORT_DEF
/*************************************************************************/
/* */
/* Debug level */
/* */
/* FreeType can be compiled in debug or trace mode. In debug mode, */
/* errors are reported through the `ftdebug' component. In trace */
/* mode, additional messages are sent to the standard output during */
/* execution. */
/* */
/* Define FT_DEBUG_LEVEL_ERROR to build the library in debug mode. */
/* Define FT_DEBUG_LEVEL_TRACE to build it in trace mode. */
/* */
/* Don't define any of these macros to compile in `release' mode! */
/* */
#undef FT_DEBUG_LEVEL_ERROR
#undef FT_DEBUG_LEVEL_TRACE
/*************************************************************************/
/* */
/* Memory Debugging */
/* */
/* FreeType now comes with an integrated memory debugger that is */
/* capable of detecting simple errors like memory leaks or double */
/* deletes. To compile it within your build of the library, you */
/* should define FT_DEBUG_MEMORY here. */
/* */
/* Note that the memory debugger is only activated at runtime when */
/* when the _environment_ variable "FT_DEBUG_MEMORY" is also defined! */
/* */
#undef FT_DEBUG_MEMORY
/* #define FT_CONFIG_OPTION_INCREMENTAL */
/*************************************************************************/
@@ -291,9 +239,61 @@ FT_BEGIN_HEADER
/* FT_MAX_MODULES */
/* */
/* The maximum number of modules that can be registered in a single */
/* FreeType library object. 16 is the default. */
/* FreeType library object. 32 is the default. */
/* */
#define FT_MAX_MODULES 16
#define FT_MAX_MODULES 32
/*************************************************************************/
/* */
/* Debug level */
/* */
/* FreeType can be compiled in debug or trace mode. In debug mode, */
/* errors are reported through the `ftdebug' component. In trace */
/* mode, additional messages are sent to the standard output during */
/* execution. */
/* */
/* Define FT_DEBUG_LEVEL_ERROR to build the library in debug mode. */
/* Define FT_DEBUG_LEVEL_TRACE to build it in trace mode. */
/* */
/* Don't define any of these macros to compile in `release' mode! */
/* */
/* #define FT_DEBUG_LEVEL_ERROR */
/* #define FT_DEBUG_LEVEL_TRACE */
/*************************************************************************/
/* */
/* Memory Debugging */
/* */
/* FreeType now comes with an integrated memory debugger that is */
/* capable of detecting simple errors like memory leaks or double */
/* deletes. To compile it within your build of the library, you */
/* should define FT_DEBUG_MEMORY here. */
/* */
/* Note that the memory debugger is only activated at runtime when */
/* when the _environment_ variable "FT_DEBUG_MEMORY" is also defined! */
/* */
/* #define FT_DEBUG_MEMORY */
/*************************************************************************/
/* */
/* Module errors */
/* */
/* If this macro is set (which is _not_ the default), the higher byte */
/* of an error code gives the module in which the error has occurred, */
/* while the lower byte is the real error code. */
/* */
/* Setting this macro makes sense for debugging purposes only, since */
/* it would break source compatibility of certain programs that use */
/* FreeType 2. */
/* */
/* More details can be found in the files ftmoderr.h and fterrors.h. */
/* */
#undef FT_CONFIG_OPTION_USE_MODULE_ERRORS
/*************************************************************************/
@@ -375,7 +375,10 @@ FT_BEGIN_HEADER
/* By undefining this, you will only compile the code necessary to load */
/* TrueType glyphs without hinting. */
/* */
#undef TT_CONFIG_OPTION_BYTECODE_INTERPRETER
/* do not #undef this macro here, since the build system might */
/* define for certain configurations */
/* */
/* #define TT_CONFIG_OPTION_BYTECODE_INTERPRETER */
/*************************************************************************/
@@ -391,6 +394,25 @@ FT_BEGIN_HEADER
#define TT_CONFIG_OPTION_INTERPRETER_SWITCH
/*************************************************************************/
/* */
/* Define TT_CONFIG_OPTION_COMPONENT_OFFSET_SCALED to compile the */
/* TrueType glyph loader to use Apple's definition of how to handle */
/* component offsets in composite glyphs. */
/* */
/* Apple and MS disagree on the default behavior of component offsets */
/* in composites. Apple says that they should be scaled by the scale */
/* factors in the transformation matrix (roughly, it's more complex) */
/* while MS says they should not. OpenType defines two bits in the */
/* composite flags array which can be used to disambiguate, but old */
/* fonts will not have them. */
/* */
/* http://partners.adobe.com/asn/developer/opentype/glyf.html */
/* http://fonts.apple.com/TTRefMan/RM06/Chap6glyf.html */
/* */
#undef TT_CONFIG_OPTION_COMPONENT_OFFSET_SCALED
/*************************************************************************/
/*************************************************************************/
/**** ****/
@@ -427,14 +449,6 @@ FT_BEGIN_HEADER
#define T1_MAX_CHARSTRINGS_OPERANDS 256
/*************************************************************************/
/* */
/* Define T1_CONFIG_OPTION_DISABLE_HINTER if you want to generate a */
/* driver with no hinter. This can be useful to debug the parser. */
/* */
#undef T1_CONFIG_OPTION_DISABLE_HINTER
/*************************************************************************/
/* */
/* Define this configuration macro if you want to prevent the */
File diff suppressed because it is too large Load Diff
+5 -1
View File
@@ -183,7 +183,11 @@ FT_BEGIN_HEADER
(f1)->pix_width == (f2)->pix_width && \
(f1)->pix_height == (f2)->pix_height )
#define FTC_FACE_ID_HASH( i ) ((FT_UInt32)(FT_Pointer)( i ))
#define FT_POINTER_TO_ULONG( p ) ((FT_ULong)(FT_Pointer)(p))
#define FTC_FACE_ID_HASH( i ) \
((FT_UInt32)(( FT_POINTER_TO_ULONG( i ) >> 3 ) ^ \
( FT_POINTER_TO_ULONG( i ) << 7 ) ) )
#define FTC_FONT_HASH( f ) \
(FT_UInt32)( FTC_FACE_ID_HASH((f)->face_id) ^ \
@@ -30,6 +30,7 @@
/* type1_tables */
/* sfnt_names */
/* bdf_fonts */
/* pfr_fonts */
/* */
/***************************************************************************/
+6 -6
View File
@@ -145,7 +145,7 @@ FT_BEGIN_HEADER
/* */
/* <Note> */
/* You can typecast FT_Glyph to FT_BitmapGlyph if you have */
/* glyph->format == ft_glyph_format_bitmap. This lets you access */
/* glyph->format == FT_GLYPH_FORMAT_BITMAP. This lets you access */
/* the bitmap's contents easily. */
/* */
/* The corresponding pixel buffer is always owned by the BitmapGlyph */
@@ -189,7 +189,7 @@ FT_BEGIN_HEADER
/* */
/* <Note> */
/* You can typecast FT_Glyph to FT_OutlineGlyph if you have */
/* glyph->format == ft_glyph_format_outline. This lets you access */
/* glyph->format == FT_GLYPH_FORMAT_OUTLINE. This lets you access */
/* the outline's content easily. */
/* */
/* As the outline is extracted from a glyph slot, its coordinates are */
@@ -374,8 +374,8 @@ FT_BEGIN_HEADER
/* the_glyph :: A pointer to a handle to the target glyph. */
/* */
/* <Input> */
/* render_mode :: A set of bit flags that describe how the data is */
/* */
/* render_mode :: An enumeration that describe how the data is */
/* rendered. */
/* */
/* origin :: A pointer to a vector used to translate the glyph */
/* image before rendering. Can be 0 (if no */
@@ -411,7 +411,7 @@ FT_BEGIN_HEADER
/* error = FT_Get_Glyph( face->glyph, &glyph ); */
/* */
/* // convert to a bitmap (default render mode + destroy old) */
/* if ( glyph->format != ft_glyph_format_bitmap ) */
/* if ( glyph->format != FT_GLYPH_FORMAT_BITMAP ) */
/* { */
/* error = FT_Glyph_To_Bitmap( &glyph, ft_render_mode_default, */
/* 0, 1 ); */
@@ -435,7 +435,7 @@ FT_BEGIN_HEADER
/* */
FT_EXPORT( FT_Error )
FT_Glyph_To_Bitmap( FT_Glyph* the_glyph,
FT_ULong render_mode,
FT_Render_Mode render_mode,
FT_Vector* origin,
FT_Bool destroy );
+259 -129
View File
@@ -5,7 +5,7 @@
/* FreeType glyph image formats and default raster interface */
/* (specification). */
/* */
/* Copyright 1996-2001 by */
/* Copyright 1996-2001, 2002 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -28,7 +28,10 @@
#define __FTIMAGE_H__
/* _STANDALONE_ is from ftgrays.c */
#ifndef _STANDALONE_
#include <ft2build.h>
#endif
FT_BEGIN_HEADER
@@ -114,64 +117,92 @@ FT_BEGIN_HEADER
/* given bitmap. Note that additional formats may be added in the */
/* future. */
/* */
/* <Fields> */
/* ft_pixel_mode_mono :: A monochrome bitmap (1 bit/pixel). */
/* <Values> */
/* FT_PIXEL_MODE_NONE :: */
/* Value 0 is reserved. */
/* */
/* ft_pixel_mode_grays :: An 8-bit gray-levels bitmap. Note that the */
/* total number of gray levels is given in the */
/* `num_grays' field of the FT_Bitmap */
/* structure. */
/* FT_PIXEL_MODE_MONO :: */
/* A monochrome bitmap, using 1 bit per pixel. Note that pixels */
/* are stored in most-significant order (MSB), which means that */
/* the left-most pixel in a byte has value 128. */
/* */
/* ft_pixel_mode_pal2 :: A 2-bit paletted bitmap. */
/* Currently unused by FreeType. */
/* FT_PIXEL_MODE_GRAY :: */
/* An 8-bit bitmap, generally used to represent anti-aliased glyph */
/* images. Each pixel is stored in one byte. Note that the number */
/* of value "gray" levels is stored in the `num_bytes' field of */
/* the @FT_Bitmap structure (it generally is 256). */
/* */
/* ft_pixel_mode_pal4 :: A 4-bit paletted bitmap. */
/* Currently unused by FreeType. */
/* FT_PIXEL_MODE_GRAY2 :: */
/* A 2-bit/pixel bitmap, used to represent embedded anti-aliased */
/* bitmaps in font files according to the OpenType specification. */
/* We haven't found a single font using this format, however. */
/* */
/* ft_pixel_mode_pal8 :: An 8-bit paletted bitmap. */
/* Currently unused by FreeType. */
/* FT_PIXEL_MODE_GRAY4 :: */
/* A 4-bit/pixel bitmap, used to represent embedded anti-aliased */
/* bitmaps in font files according to the OpenType specification. */
/* We haven't found a single font using this format, however. */
/* */
/* ft_pixel_mode_rgb15 :: A 15-bit RGB bitmap. Uses 5:5:5 encoding. */
/* Currently unused by FreeType. */
/* FT_PIXEL_MODE_LCD :: */
/* An 8-bit bitmap, used to represent RGB or BGR decimated glyph */
/* images used for display on LCD displays; the bitmap's width is */
/* three times wider than the original glyph image. See also */
/* @FT_RENDER_MODE_LCD. */
/* */
/* ft_pixel_mode_rgb16 :: A 16-bit RGB bitmap. Uses 5:6:5 encoding. */
/* Currently unused by FreeType. */
/* */
/* ft_pixel_mode_rgb24 :: A 24-bit RGB bitmap. */
/* Currently unused by FreeType. */
/* */
/* ft_pixel_mode_rgb32 :: A 32-bit RGB bitmap. */
/* Currently unused by FreeType. */
/* */
/* <Note> */
/* Some anti-aliased bitmaps might be embedded in TrueType fonts */
/* using formats pal2 or pal4, though no fonts presenting those have */
/* been found to date. */
/* FT_PIXEL_MODE_LCD_V :: */
/* An 8-bit bitmap, used to represent RGB or BGR decimated glyph */
/* images used for display on rotated LCD displays; the bitmap's */
/* height is three times taller than the original glyph image. */
/* See also @FT_RENDER_MODE_LCD_V. */
/* */
typedef enum FT_Pixel_Mode_
{
ft_pixel_mode_none = 0,
ft_pixel_mode_mono,
ft_pixel_mode_grays,
ft_pixel_mode_pal2,
ft_pixel_mode_pal4,
ft_pixel_mode_pal8,
ft_pixel_mode_rgb15,
ft_pixel_mode_rgb16,
ft_pixel_mode_rgb24,
ft_pixel_mode_rgb32,
FT_PIXEL_MODE_NONE = 0,
FT_PIXEL_MODE_MONO,
FT_PIXEL_MODE_GRAY,
FT_PIXEL_MODE_GRAY2,
FT_PIXEL_MODE_GRAY4,
FT_PIXEL_MODE_LCD,
FT_PIXEL_MODE_LCD_V,
ft_pixel_mode_max /* do not remove */
FT_PIXEL_MODE_MAX /* do not remove */
} FT_Pixel_Mode;
/*************************************************************************/
/* */
/* <Enum> */
/* ft_pixel_mode_xxx */
/* */
/* <Description> */
/* A list of deprecated constants. Use the corresponding */
/* @FT_Pixel_Mode values instead. */
/* */
/* <Values> */
/* ft_pixel_mode_none :: see @FT_PIXEL_MODE_NONE */
/* ft_pixel_mode_mono :: see @FT_PIXEL_MODE_MONO */
/* ft_pixel_mode_grays :: see @FT_PIXEL_MODE_GRAY */
/* ft_pixel_mode_pal2 :: see @FT_PIXEL_MODE_GRAY2 */
/* ft_pixel_mode_pal4 :: see @FT_PIXEL_MODE_GRAY4 */
/* */
#define ft_pixel_mode_none FT_PIXEL_MODE_NONE
#define ft_pixel_mode_mono FT_PIXEL_MODE_MONO
#define ft_pixel_mode_grays FT_PIXEL_MODE_GRAY
#define ft_pixel_mode_pal2 FT_PIXEL_MODE_GRAY2
#define ft_pixel_mode_pal4 FT_PIXEL_MODE_GRAY4
/* */
#if 0
/*************************************************************************/
/* */
/* <Enum> */
/* FT_Palette_Mode */
/* */
/* <Description> */
/* THIS TYPE IS DEPRECATED. DO NOT USE IT! */
/* */
/* An enumeration type used to describe the format of a bitmap */
/* palette, used with ft_pixel_mode_pal4 and ft_pixel_mode_pal8. */
/* */
@@ -195,6 +226,10 @@ FT_BEGIN_HEADER
} FT_Palette_Mode;
/* */
#endif
/*************************************************************************/
/* */
@@ -223,7 +258,7 @@ FT_BEGIN_HEADER
/* most cases. */
/* */
/* num_grays :: This field is only used with */
/* `ft_pixel_mode_grays'; it gives the number of gray */
/* `FT_PIXEL_MODE_GRAY'; it gives the number of gray */
/* levels used in the bitmap. */
/* */
/* pixel_mode :: The pixel_mode, i.e., how pixel bits are stored. */
@@ -328,21 +363,23 @@ FT_BEGIN_HEADER
/* A simple type used to enumerates the flags in an outline's */
/* `outline_flags' field. */
/* */
/* <Fields> */
/* ft_outline_owner :: If set, this flag indicates that the */
/* <Values> */
/* FT_OUTLINE_NONE :: Value 0 is reserved. */
/* */
/* FT_OUTLINE_OWNER :: If set, this flag indicates that the */
/* outline's field arrays (i.e. */
/* `points', `flags' & `contours') are */
/* `owned' by the outline object, and */
/* should thus be freed when it is */
/* destroyed. */
/* */
/* ft_outline_even_odd_fill :: By default, outlines are filled using */
/* FT_OUTLINE_EVEN_ODD_FILL :: By default, outlines are filled using */
/* the non-zero winding rule. If set to */
/* 1, the outline will be filled using */
/* the even-odd fill rule (only works */
/* with the smooth raster). */
/* */
/* ft_outline_reverse_fill :: By default, outside contours of an */
/* FT_OUTLINE_REVERSE_FILL :: By default, outside contours of an */
/* outline are oriented in clock-wise */
/* direction, as defined in the TrueType */
/* specification. This flag is set if */
@@ -352,14 +389,14 @@ FT_BEGIN_HEADER
/* scan-converter. However, it is very */
/* important for the auto-hinter. */
/* */
/* ft_outline_ignore_dropouts :: By default, the scan converter will */
/* FT_OUTLINE_IGNORE_DROPOUTS :: By default, the scan converter will */
/* try to detect drop-outs in an outline */
/* and correct the glyph bitmap to */
/* ensure consistent shape continuity. */
/* If set, this flag hints the scan-line */
/* converter to ignore such cases. */
/* */
/* ft_outline_high_precision :: This flag indicates that the */
/* FT_OUTLINE_HIGH_PRECISION :: This flag indicates that the */
/* scan-line converter should try to */
/* convert this outline to bitmaps with */
/* the highest possible quality. It is */
@@ -368,7 +405,7 @@ FT_BEGIN_HEADER
/* hint, that might be completely */
/* ignored by a given scan-converter. */
/* */
/* ft_outline_single_pass :: This flag is set to force a given */
/* FT_OUTLINE_SINGLE_PASS :: This flag is set to force a given */
/* scan-converter to only use a single */
/* pass over the outline to render a */
/* bitmap glyph image. Normally, it is */
@@ -379,35 +416,67 @@ FT_BEGIN_HEADER
/* */
typedef enum FT_Outline_Flags_
{
ft_outline_none = 0,
ft_outline_owner = 1,
ft_outline_even_odd_fill = 2,
ft_outline_reverse_fill = 4,
ft_outline_ignore_dropouts = 8,
ft_outline_high_precision = 256,
ft_outline_single_pass = 512
FT_OUTLINE_NONE = 0,
FT_OUTLINE_OWNER = 1,
FT_OUTLINE_EVEN_ODD_FILL = 2,
FT_OUTLINE_REVERSE_FILL = 4,
FT_OUTLINE_IGNORE_DROPOUTS = 8,
FT_OUTLINE_HIGH_PRECISION = 256,
FT_OUTLINE_SINGLE_PASS = 512
} FT_Outline_Flags;
/*************************************************************************
*
* @enum:
* ft_outline_xxx
*
* @description:
* These constants are deprecated. Please use the corresponding
* @FT_OUTLINE_XXX values.
*
* @values:
* ft_outline_none :: See @FT_OUTLINE_NONE.
* ft_outline_owner :: See @FT_OUTLINE_OWNER.
* ft_outline_even_odd_fill :: See @FT_OUTLINE_EVEN_ODD_FILL.
* ft_outline_reverse_fill :: See @FT_OUTLINE_REVERSE_FILL.
* ft_outline_ignore_dropouts :: See @FT_OUTLINE_IGNORE_DROPOUTS.
* ft_outline_high_precision :: See @FT_OUTLINE_HIGH_PRECISION.
* ft_outline_single_pass :: See @FT_OUTLINE_SINGLE_PASS.
*/
#define ft_outline_none FT_OUTLINE_NONE
#define ft_outline_owner FT_OUTLINE_OWNER
#define ft_outline_even_odd_fill FT_OUTLINE_EVEN_ODD_FILL
#define ft_outline_reverse_fill FT_OUTLINE_REVERSE_FILL
#define ft_outline_ignore_dropouts FT_OUTLINE_IGNORE_DROPOUTS
#define ft_outline_high_precision FT_OUTLINE_HIGH_PRECISION
#define ft_outline_single_pass FT_OUTLINE_SINGLE_PASS
/* */
#define FT_CURVE_TAG( flag ) ( flag & 3 )
#define FT_Curve_Tag_On 1
#define FT_Curve_Tag_Conic 0
#define FT_Curve_Tag_Cubic 2
#define FT_CURVE_TAG_ON 1
#define FT_CURVE_TAG_CONIC 0
#define FT_CURVE_TAG_CUBIC 2
#define FT_Curve_Tag_Touch_X 8 /* reserved for the TrueType hinter */
#define FT_Curve_Tag_Touch_Y 16 /* reserved for the TrueType hinter */
#define FT_CURVE_TAG_TOUCH_X 8 /* reserved for the TrueType hinter */
#define FT_CURVE_TAG_TOUCH_Y 16 /* reserved for the TrueType hinter */
#define FT_Curve_Tag_Touch_Both ( FT_Curve_Tag_Touch_X | \
FT_Curve_Tag_Touch_Y )
#define FT_CURVE_TAG_TOUCH_BOTH ( FT_CURVE_TAG_TOUCH_X | \
FT_CURVE_TAG_TOUCH_Y )
#define FT_Curve_Tag_On FT_CURVE_TAG_ON
#define FT_Curve_Tag_Conic FT_CURVE_TAG_CONIC
#define FT_Curve_Tag_Cubic FT_CURVE_TAG_CUBIC
#define FT_Curve_Tag_Touch_X FT_CURVE_TAG_TOUCH_X
#define FT_Curve_Tag_Touch_Y FT_CURVE_TAG_TOUCH_Y
/*************************************************************************/
/* */
/* <FuncType> */
/* FT_Outline_MoveTo_Func */
/* FT_Outline_MoveToFunc */
/* */
/* <Description> */
/* A function pointer type used to describe the signature of a `move */
@@ -425,14 +494,15 @@ FT_BEGIN_HEADER
/* Error code. 0 means success. */
/* */
typedef int
(*FT_Outline_MoveTo_Func)( FT_Vector* to,
(*FT_Outline_MoveToFunc)( FT_Vector* to,
void* user );
#define FT_Outline_MoveTo_Func FT_Outline_MoveToFunc
/*************************************************************************/
/* */
/* <FuncType> */
/* FT_Outline_LineTo_Func */
/* FT_Outline_LineToFunc */
/* */
/* <Description> */
/* A function pointer type used to describe the signature of a `line */
@@ -450,14 +520,15 @@ FT_BEGIN_HEADER
/* Error code. 0 means success. */
/* */
typedef int
(*FT_Outline_LineTo_Func)( FT_Vector* to,
(*FT_Outline_LineToFunc)( FT_Vector* to,
void* user );
#define FT_Outline_LineTo_Func FT_Outline_LineToFunc
/*************************************************************************/
/* */
/* <FuncType> */
/* FT_Outline_ConicTo_Func */
/* FT_Outline_ConicToFunc */
/* */
/* <Description> */
/* A function pointer type use to describe the signature of a `conic */
@@ -479,15 +550,16 @@ FT_BEGIN_HEADER
/* Error code. 0 means success. */
/* */
typedef int
(*FT_Outline_ConicTo_Func)( FT_Vector* control,
(*FT_Outline_ConicToFunc)( FT_Vector* control,
FT_Vector* to,
void* user );
#define FT_Outline_ConicTo_Func FT_Outline_ConicToFunc
/*************************************************************************/
/* */
/* <FuncType> */
/* FT_Outline_CubicTo_Func */
/* FT_Outline_CubicToFunc */
/* */
/* <Description> */
/* A function pointer type used to describe the signature of a `cubic */
@@ -509,11 +581,13 @@ FT_BEGIN_HEADER
/* Error code. 0 means success. */
/* */
typedef int
(*FT_Outline_CubicTo_Func)( FT_Vector* control1,
(*FT_Outline_CubicToFunc)( FT_Vector* control1,
FT_Vector* control2,
FT_Vector* to,
void* user );
#define FT_Outline_CubicTo_Func FT_Outline_CubicToFunc
/*************************************************************************/
/* */
@@ -553,10 +627,10 @@ FT_BEGIN_HEADER
/* */
typedef struct FT_Outline_Funcs_
{
FT_Outline_MoveTo_Func move_to;
FT_Outline_LineTo_Func line_to;
FT_Outline_ConicTo_Func conic_to;
FT_Outline_CubicTo_Func cubic_to;
FT_Outline_MoveToFunc move_to;
FT_Outline_LineToFunc line_to;
FT_Outline_ConicToFunc conic_to;
FT_Outline_CubicToFunc cubic_to;
int shift;
FT_Pos delta;
@@ -580,6 +654,15 @@ FT_BEGIN_HEADER
/* <Description> */
/* This macro converts four letter tags into an unsigned long. */
/* */
/* <Note> */
/* Since many 16bit compilers don't like 32bit enumerations, you */
/* should redefine this macro in case of problems to something like */
/* this: */
/* */
/* #define FT_IMAGE_TAG( value, _x1, _x2, _x3, _x4 ) (value) */
/* */
/* to get a simple enumeration without assigning special numbers. */
/* */
#ifndef FT_IMAGE_TAG
#define FT_IMAGE_TAG( value, _x1, _x2, _x3, _x4 ) \
value = ( ( (unsigned long)_x1 << 24 ) | \
@@ -600,37 +683,68 @@ FT_BEGIN_HEADER
/* formats, even though future font drivers will be able to register */
/* their own format. */
/* */
/* <Fields> */
/* ft_glyph_format_composite :: The glyph image is a composite of */
/* several other images. This glyph */
/* format is _only_ used with the */
/* FT_LOAD_FLAG_NO_RECURSE flag (XXX: */
/* Which is currently unimplemented). */
/* <Values> */
/* FT_GLYPH_FORMAT_NONE :: */
/* The value 0 is reserved and does describe a glyph format. */
/* */
/* ft_glyph_format_bitmap :: The glyph image is a bitmap, and can */
/* be described as a FT_Bitmap. */
/* FT_GLYPH_FORMAT_COMPOSITE :: */
/* The glyph image is a composite of several other images. This */
/* format is _only_ used with @FT_LOAD_FLAG_NO_RECURSE, and is */
/* used to report compound glyphs (like accented characters). */
/* */
/* ft_glyph_format_outline :: The glyph image is a vectorial image */
/* made of bezier control points, and */
/* can be described as a FT_Outline. */
/* FT_GLYPH_FORMAT_BITMAP :: */
/* The glyph image is a bitmap, and can be described as an */
/* @FT_Bitmap. You generally need to access the `bitmap' field of */
/* the @FT_GlyphSlotRec structure to read it. */
/* */
/* ft_glyph_format_plotter :: The glyph image is a vectorial image */
/* made of plotter lines (some T1 fonts */
/* like Hershey contain glyph in this */
/* format). */
/* FT_GLYPH_FORMAT_OUTLINE :: */
/* The glyph image is a vertorial outline made of line segments */
/* and Bezier arcs; it can be described as an @FT_Outline; you */
/* generally want to access the `outline' field of the */
/* @FT_GlyphSlotRec structure to read it. */
/* */
/* FT_GLYPH_FORMAT_PLOTTER :: */
/* The glyph image is a vectorial path with no inside/outside */
/* contours. Some Type 1 fonts, like those in the Hershey family, */
/* contain glyphs in this format. These are described as */
/* @FT_Outline, but FreeType isn't currently capable of rendering */
/* them correctly. */
/* */
typedef enum FT_Glyph_Format_
{
FT_IMAGE_TAG( ft_glyph_format_none, 0, 0, 0, 0 ),
FT_IMAGE_TAG( FT_GLYPH_FORMAT_NONE, 0, 0, 0, 0 ),
FT_IMAGE_TAG( ft_glyph_format_composite, 'c', 'o', 'm', 'p' ),
FT_IMAGE_TAG( ft_glyph_format_bitmap, 'b', 'i', 't', 's' ),
FT_IMAGE_TAG( ft_glyph_format_outline, 'o', 'u', 't', 'l' ),
FT_IMAGE_TAG( ft_glyph_format_plotter, 'p', 'l', 'o', 't' )
FT_IMAGE_TAG( FT_GLYPH_FORMAT_COMPOSITE, 'c', 'o', 'm', 'p' ),
FT_IMAGE_TAG( FT_GLYPH_FORMAT_BITMAP, 'b', 'i', 't', 's' ),
FT_IMAGE_TAG( FT_GLYPH_FORMAT_OUTLINE, 'o', 'u', 't', 'l' ),
FT_IMAGE_TAG( FT_GLYPH_FORMAT_PLOTTER, 'p', 'l', 'o', 't' )
} FT_Glyph_Format;
/*************************************************************************/
/* */
/* <Enum> */
/* ft_glyph_format_xxx */
/* */
/* <Description> */
/* A list of decprecated constants. Use the corresponding */
/* @FT_Glyph_Format values instead. */
/* */
/* <Values> */
/* ft_glyph_format_none :: see @FT_GLYPH_FORMAT_NONE */
/* ft_glyph_format_composite :: see @FT_GLYPH_FORMAT_COMPOSITE */
/* ft_glyph_format_bitmap :: see @FT_GLYPH_FORMAT_BITMAP */
/* ft_glyph_format_outline :: see @FT_GLYPH_FORMAT_OUTLINE */
/* ft_glyph_format_plotter :: see @FT_GLYPH_FORMAT_PLOTTER */
/* */
#define ft_glyph_format_none FT_GLYPH_FORMAT_NONE
#define ft_glyph_format_composite FT_GLYPH_FORMAT_COMPOSITE
#define ft_glyph_format_bitmap FT_GLYPH_FORMAT_BITMAP
#define ft_glyph_format_outline FT_GLYPH_FORMAT_OUTLINE
#define ft_glyph_format_plotter FT_GLYPH_FORMAT_PLOTTER
/*************************************************************************/
/*************************************************************************/
/*************************************************************************/
@@ -657,7 +771,7 @@ FT_BEGIN_HEADER
/*************************************************************************/
/* */
/* <Section> */
/* Raster */
/* raster */
/* */
/* <Title> */
/* Scanline converter */
@@ -703,7 +817,7 @@ FT_BEGIN_HEADER
/* */
/* <Note> */
/* This structure is used by the span drawing callback type named */
/* FT_Raster_Span_Func(), which takes the y-coordinate of the span as */
/* FT_SpanFunc which takes the y-coordinate of the span as a */
/* a parameter. */
/* */
/* The coverage value is always between 0 and 255, even if the number */
@@ -721,7 +835,7 @@ FT_BEGIN_HEADER
/*************************************************************************/
/* */
/* <FuncType> */
/* FT_Raster_Span_Func */
/* FT_SpanFunc */
/* */
/* <Description> */
/* A function used as a call-back by the anti-aliased renderer in */
@@ -755,11 +869,13 @@ FT_BEGIN_HEADER
/* only for those scanlines that do have `gray' pixels on them. */
/* */
typedef void
(*FT_Raster_Span_Func)( int y,
(*FT_SpanFunc)( int y,
int count,
FT_Span* spans,
void* user );
#define FT_Raster_Span_Func FT_SpanFunc
/*************************************************************************/
/* */
@@ -767,6 +883,8 @@ FT_BEGIN_HEADER
/* FT_Raster_BitTest_Func */
/* */
/* <Description> */
/* THIS TYPE IS DEPRECATED. DO NOT USE IT. */
/* */
/* A function used as a call-back by the monochrome scan-converter */
/* to test whether a given target pixel is already set to the drawing */
/* `color'. These tests are crucial to implement drop-out control */
@@ -794,6 +912,8 @@ FT_BEGIN_HEADER
/* FT_Raster_BitSet_Func */
/* */
/* <Description> */
/* THIS TYPE IS DEPRECATED. DO NOT USE IT. */
/* */
/* A function used as a call-back by the monochrome scan-converter */
/* to set an individual target pixel. This is crucial to implement */
/* drop-out control according to the TrueType specification. */
@@ -823,15 +943,15 @@ FT_BEGIN_HEADER
/* An enumeration to list the bit flags as used in the `flags' field */
/* of a FT_Raster_Params structure. */
/* */
/* <Fields> */
/* ft_raster_flag_default :: This value is 0. */
/* <Values> */
/* FT_RASTER_FLAG_DEFAULT :: This value is 0. */
/* */
/* ft_raster_flag_aa :: This flag is set to indicate that an */
/* FT_RASTER_FLAG_AA :: This flag is set to indicate that an */
/* anti-aliased glyph image should be */
/* generated. Otherwise, it will be */
/* monochrome (1-bit) */
/* */
/* ft_raster_flag_direct :: This flag is set to indicate direct */
/* FT_RASTER_FLAG_DIRECT :: This flag is set to indicate direct */
/* rendering. In this mode, client */
/* applications must provide their own span */
/* callback. This lets them directly */
@@ -843,7 +963,7 @@ FT_BEGIN_HEADER
/* Note that for now, direct rendering is */
/* only possible with anti-aliased glyphs. */
/* */
/* ft_raster_flag_clip :: This flag is only used in direct */
/* FT_RASTER_FLAG_CLIP :: This flag is only used in direct */
/* rendering mode. If set, the output will */
/* be clipped to a box specified in the */
/* "clip_box" field of the FT_Raster_Params */
@@ -856,13 +976,18 @@ FT_BEGIN_HEADER
/* */
typedef enum
{
ft_raster_flag_default = 0,
ft_raster_flag_aa = 1,
ft_raster_flag_direct = 2,
ft_raster_flag_clip = 4
FT_RASTER_FLAG_DEFAULT = 0,
FT_RASTER_FLAG_AA = 1,
FT_RASTER_FLAG_DIRECT = 2,
FT_RASTER_FLAG_CLIP = 4
} FT_Raster_Flag;
#define ft_raster_flag_default FT_RASTER_FLAG_DEFAULT
#define ft_raster_flag_aa FT_RASTER_FLAG_AA
#define ft_raster_flag_direct FT_RASTER_FLAG_DIRECT
#define ft_raster_flag_clip FT_RASTER_FLAG_CLIP
/*************************************************************************/
/* */
@@ -885,9 +1010,9 @@ FT_BEGIN_HEADER
/* */
/* black_spans :: The black span drawing callback. */
/* */
/* bit_test :: The bit test callback. */
/* bit_test :: The bit test callback. UNIMPLEMENTED! */
/* */
/* bit_set :: The bit set callback. */
/* bit_set :: The bit set callback. UNIMPLEMENTED! */
/* */
/* user :: User-supplied data that is passed to each drawing */
/* callback. */
@@ -898,11 +1023,11 @@ FT_BEGIN_HEADER
/* 26.6 fixed-point units). */
/* */
/* <Note> */
/* An anti-aliased glyph bitmap is drawn if the ft_raster_flag_aa bit */
/* An anti-aliased glyph bitmap is drawn if the FT_RASTER_FLAG_AA bit */
/* flag is set in the `flags' field, otherwise a monochrome bitmap */
/* will be generated. */
/* */
/* If the ft_raster_flag_direct bit flag is set in `flags', the */
/* If the FT_RASTER_FLAG_DIRECT bit flag is set in `flags', the */
/* raster will call the `gray_spans' callback to draw gray pixel */
/* spans, in the case of an aa glyph bitmap, it will call */
/* `black_spans', and `bit_test' and `bit_set' in the case of a */
@@ -919,10 +1044,10 @@ FT_BEGIN_HEADER
FT_Bitmap* target;
void* source;
int flags;
FT_Raster_Span_Func gray_spans;
FT_Raster_Span_Func black_spans;
FT_Raster_BitTest_Func bit_test;
FT_Raster_BitSet_Func bit_set;
FT_SpanFunc gray_spans;
FT_SpanFunc black_spans;
FT_Raster_BitTest_Func bit_test; /* doesn't work! */
FT_Raster_BitSet_Func bit_set; /* doesn't work! */
void* user;
FT_BBox clip_box;
@@ -932,7 +1057,7 @@ FT_BEGIN_HEADER
/*************************************************************************/
/* */
/* <FuncType> */
/* FT_Raster_New_Func */
/* FT_Raster_NewFunc */
/* */
/* <Description> */
/* A function used to create a new raster object. */
@@ -954,14 +1079,15 @@ FT_BEGIN_HEADER
/* ignored by a given raster implementation. */
/* */
typedef int
(*FT_Raster_New_Func)( void* memory,
(*FT_Raster_NewFunc)( void* memory,
FT_Raster* raster );
#define FT_Raster_New_Func FT_Raster_NewFunc
/*************************************************************************/
/* */
/* <FuncType> */
/* FT_Raster_Done_Func */
/* FT_Raster_DoneFunc */
/* */
/* <Description> */
/* A function used to destroy a given raster object. */
@@ -970,13 +1096,14 @@ FT_BEGIN_HEADER
/* raster :: A handle to the raster object. */
/* */
typedef void
(*FT_Raster_Done_Func)( FT_Raster raster );
(*FT_Raster_DoneFunc)( FT_Raster raster );
#define FT_Raster_Done_Func FT_Raster_DoneFunc
/*************************************************************************/
/* */
/* <FuncType> */
/* FT_Raster_Reset_Func */
/* FT_Raster_ResetFunc */
/* */
/* <Description> */
/* FreeType provides an area of memory called the `render pool', */
@@ -1001,15 +1128,16 @@ FT_BEGIN_HEADER
/* recommended for efficiency purposes. */
/* */
typedef void
(*FT_Raster_Reset_Func)( FT_Raster raster,
(*FT_Raster_ResetFunc)( FT_Raster raster,
unsigned char* pool_base,
unsigned long pool_size );
#define FT_Raster_Reset_Func FT_Raster_ResetFunc
/*************************************************************************/
/* */
/* <FuncType> */
/* FT_Raster_Set_Mode_Func */
/* FT_Raster_SetModeFunc */
/* */
/* <Description> */
/* This function is a generic facility to change modes or attributes */
@@ -1025,15 +1153,16 @@ FT_BEGIN_HEADER
/* args :: A pointer to the new mode/property to use. */
/* */
typedef int
(*FT_Raster_Set_Mode_Func)( FT_Raster raster,
(*FT_Raster_SetModeFunc)( FT_Raster raster,
unsigned long mode,
void* args );
#define FT_Raster_Set_Mode_Func FT_Raster_SetModeFunc
/*************************************************************************/
/* */
/* <FuncType> */
/* FT_Raster_Render_Func */
/* FT_Raster_RenderFunc */
/* */
/* <Description> */
/* Invokes a given raster to scan-convert a given glyph image into a */
@@ -1065,9 +1194,10 @@ FT_BEGIN_HEADER
/* composition). */
/* */
typedef int
(*FT_Raster_Render_Func)( FT_Raster raster,
(*FT_Raster_RenderFunc)( FT_Raster raster,
FT_Raster_Params* params );
#define FT_Raster_Render_Func FT_Raster_RenderFunc
/*************************************************************************/
/* */
@@ -1091,11 +1221,11 @@ FT_BEGIN_HEADER
typedef struct FT_Raster_Funcs_
{
FT_Glyph_Format glyph_format;
FT_Raster_New_Func raster_new;
FT_Raster_Reset_Func raster_reset;
FT_Raster_Set_Mode_Func raster_set_mode;
FT_Raster_Render_Func raster_render;
FT_Raster_Done_Func raster_done;
FT_Raster_NewFunc raster_new;
FT_Raster_ResetFunc raster_reset;
FT_Raster_SetModeFunc raster_set_mode;
FT_Raster_RenderFunc raster_render;
FT_Raster_DoneFunc raster_done;
} FT_Raster_Funcs;
+1 -1
View File
@@ -111,7 +111,7 @@ FT_BEGIN_HEADER
typedef struct FT_Module_Class_
{
FT_ULong module_flags;
FT_Int module_size;
FT_Long module_size;
const FT_String* module_name;
FT_Fixed module_version;
FT_Fixed module_requires;
+1 -1
View File
@@ -310,7 +310,7 @@ FT_BEGIN_HEADER
/* outline :: A pointer to the target outline descriptor. */
/* */
/* <Note> */
/* This functions toggles the bit flag `ft_outline_reverse_fill' in */
/* This functions toggles the bit flag `FT_OUTLINE_REVERSE_FILL' in */
/* the outline's `flags' field. */
/* */
/* It shouldn't be used by a normal client application, unless it */
+39 -23
View File
@@ -38,66 +38,82 @@ FT_BEGIN_HEADER
/* create a new glyph object */
typedef FT_Error
(*FT_Glyph_Init_Func)( FT_Glyph glyph,
(*FT_Glyph_InitFunc)( FT_Glyph glyph,
FT_GlyphSlot slot );
/* destroys a given glyph object */
typedef void
(*FT_Glyph_Done_Func)( FT_Glyph glyph );
(*FT_Glyph_DoneFunc)( FT_Glyph glyph );
typedef void
(*FT_Glyph_Transform_Func)( FT_Glyph glyph,
(*FT_Glyph_TransformFunc)( FT_Glyph glyph,
FT_Matrix* matrix,
FT_Vector* delta );
typedef void
(*FT_Glyph_BBox_Func)( FT_Glyph glyph,
(*FT_Glyph_GetBBoxFunc)( FT_Glyph glyph,
FT_BBox* abbox );
typedef FT_Error
(*FT_Glyph_Copy_Func)( FT_Glyph source,
(*FT_Glyph_CopyFunc)( FT_Glyph source,
FT_Glyph target );
typedef FT_Error
(*FT_Glyph_Prepare_Func)( FT_Glyph glyph,
(*FT_Glyph_PrepareFunc)( FT_Glyph glyph,
FT_GlyphSlot slot );
/* deprecated */
#define FT_Glyph_Init_Func FT_Glyph_InitFunc
#define FT_Glyph_Done_Func FT_Glyph_DoneFunc
#define FT_Glyph_Transform_Func FT_Glyph_TransformFunc
#define FT_Glyph_BBox_Func FT_Glyph_GetBBoxFunc
#define FT_Glyph_Copy_Func FT_Glyph_CopyFunc
#define FT_Glyph_Prepare_Func FT_Glyph_PrepareFunc
struct FT_Glyph_Class_
{
FT_UInt glyph_size;
FT_Long glyph_size;
FT_Glyph_Format glyph_format;
FT_Glyph_Init_Func glyph_init;
FT_Glyph_Done_Func glyph_done;
FT_Glyph_Copy_Func glyph_copy;
FT_Glyph_Transform_Func glyph_transform;
FT_Glyph_BBox_Func glyph_bbox;
FT_Glyph_Prepare_Func glyph_prepare;
FT_Glyph_InitFunc glyph_init;
FT_Glyph_DoneFunc glyph_done;
FT_Glyph_CopyFunc glyph_copy;
FT_Glyph_TransformFunc glyph_transform;
FT_Glyph_GetBBoxFunc glyph_bbox;
FT_Glyph_PrepareFunc glyph_prepare;
};
typedef FT_Error
(*FTRenderer_render)( FT_Renderer renderer,
(*FT_Renderer_RenderFunc)( FT_Renderer renderer,
FT_GlyphSlot slot,
FT_UInt mode,
FT_Vector* origin );
typedef FT_Error
(*FTRenderer_transform)( FT_Renderer renderer,
(*FT_Renderer_TransformFunc)( FT_Renderer renderer,
FT_GlyphSlot slot,
FT_Matrix* matrix,
FT_Vector* delta );
typedef void
(*FTRenderer_getCBox)( FT_Renderer renderer,
(*FT_Renderer_GetCBoxFunc)( FT_Renderer renderer,
FT_GlyphSlot slot,
FT_BBox* cbox );
typedef FT_Error
(*FTRenderer_setMode)( FT_Renderer renderer,
(*FT_Renderer_SetModeFunc)( FT_Renderer renderer,
FT_ULong mode_tag,
FT_Pointer mode_ptr );
/* deprecated identifiers */
#define FTRenderer_render FT_Renderer_RenderFunc
#define FTRenderer_transform FT_Renderer_TransformFunc
#define FTRenderer_getCBox FT_Renderer_GetCBoxFunc
#define FTRenderer_setMode FT_Renderer_SetModeFunc
/*************************************************************************/
/* */
@@ -117,10 +133,10 @@ FT_BEGIN_HEADER
/* */
/* set_mode :: A method used to pass additional parameters. */
/* */
/* raster_class :: For `ft_glyph_format_outline' renderers only, this */
/* raster_class :: For `FT_GLYPH_FORMAT_OUTLINE' renderers only, this */
/* is a pointer to its raster's class. */
/* */
/* raster :: For `ft_glyph_format_outline' renderers only. this */
/* raster :: For `FT_GLYPH_FORMAT_OUTLINE' renderers only. this */
/* is a pointer to the corresponding raster object, */
/* if any. */
/* */
@@ -130,10 +146,10 @@ FT_BEGIN_HEADER
FT_Glyph_Format glyph_format;
FTRenderer_render render_glyph;
FTRenderer_transform transform_glyph;
FTRenderer_getCBox get_glyph_cbox;
FTRenderer_setMode set_mode;
FT_Renderer_RenderFunc render_glyph;
FT_Renderer_TransformFunc transform_glyph;
FT_Renderer_GetCBoxFunc get_glyph_cbox;
FT_Renderer_SetModeFunc set_mode;
FT_Raster_Funcs* raster_class;
+6 -8
View File
@@ -48,16 +48,14 @@ FT_BEGIN_HEADER
/* This code is completely experimental -- use with care! */
/* It will probably be completely rewritten in the future */
/* or even integrated into the library. */
FT_EXPORT( FT_Error )
FT_Outline_Embolden( FT_GlyphSlot original,
FT_Outline* outline,
FT_Pos* advance );
FT_EXPORT( void )
FT_GlyphSlot_Embolden( FT_GlyphSlot slot );
FT_EXPORT( FT_Error )
FT_Outline_Oblique( FT_GlyphSlot original,
FT_Outline* outline,
FT_Pos* advance );
FT_EXPORT( void )
FT_GlyphSlot_Oblique( FT_GlyphSlot slot );
/* */
FT_END_HEADER
+17 -6
View File
@@ -1,6 +1,16 @@
#ifndef __FT_SYSTEM_IO_H__
#define __FT_SYSTEM_IO_H__
/************************************************************************/
/************************************************************************/
/***** *****/
/***** NOTE: THE CONTENT OF THIS FILE IS NOT CURRENTLY USED *****/
/***** IN NORMAL BUILDS. CONSIDER IT EXPERIMENTAL. *****/
/***** *****/
/************************************************************************/
/************************************************************************/
/********************************************************************
*
* designing custom streams is a bit different now
@@ -35,7 +45,7 @@
FT_BEGIN_HEADER
/********************************************************************
/*@*******************************************************************
*
* @type: FT_Stream
*
@@ -45,7 +55,7 @@ FT_BEGIN_HEADER
typedef struct FT_StreamRec_* FT_Stream;
/********************************************************************
/*@*******************************************************************
*
* @type: FT_Stream_Class
*
@@ -56,7 +66,7 @@ FT_BEGIN_HEADER
typedef const struct FT_Stream_ClassRec_* FT_Stream_Class;
/********************************************************************
/*@*******************************************************************
*
* @functype: FT_Stream_ReadFunc
*
@@ -76,7 +86,7 @@ FT_BEGIN_HEADER
FT_ULong size );
/********************************************************************
/*@*******************************************************************
*
* @functype: FT_Stream_SeekFunc
*
@@ -93,7 +103,8 @@ FT_BEGIN_HEADER
typedef FT_Error (*FT_Stream_SeekFunc)( FT_Stream stream,
FT_ULong pos );
/********************************************************************
/*@*******************************************************************
*
* @struct: FT_Stream_ClassRec
*
@@ -119,7 +130,7 @@ FT_BEGIN_HEADER
#define FT_STREAM_CLASS__READ(x) FT_STREAM_CLASS(x)->stream_read
#define FT_STREAM_CLASS__SEEK(x) FT_STREAM_CLASS(x)->stream_seek;
/********************************************************************
/*@*******************************************************************
*
* @struct: FT_StreamRec
*
+20 -10
View File
@@ -5,7 +5,17 @@
FT_BEGIN_HEADER
/***********************************************************************
/************************************************************************/
/************************************************************************/
/***** *****/
/***** NOTE: THE CONTENT OF THIS FILE IS NOT CURRENTLY USED *****/
/***** IN NORMAL BUILDS. CONSIDER IT EXPERIMENTAL. *****/
/***** *****/
/************************************************************************/
/************************************************************************/
/*@**********************************************************************
*
* @type: FT_Memory
*
@@ -20,7 +30,7 @@ FT_BEGIN_HEADER
typedef struct FT_MemoryRec_* FT_Memory;
/***********************************************************************
/*@**********************************************************************
*
* @functype: FT_Memory_AllocFunc
*
@@ -39,7 +49,7 @@ FT_BEGIN_HEADER
FT_Pointer mem_data );
/***********************************************************************
/*@**********************************************************************
*
* @functype: FT_Memory_FreeFunc
*
@@ -56,7 +66,7 @@ FT_BEGIN_HEADER
FT_Pointer mem_data );
/***********************************************************************
/*@**********************************************************************
*
* @functype: FT_Memory_ReallocFunc
*
@@ -76,7 +86,7 @@ FT_BEGIN_HEADER
FT_Pointer mem_data );
/***********************************************************************
/*@**********************************************************************
*
* @functype: FT_Memory_CreateFunc
*
@@ -100,7 +110,7 @@ FT_BEGIN_HEADER
FT_Pointer *amem_data );
/***********************************************************************
/*@**********************************************************************
*
* @functype: FT_Memory_DestroyFunc
*
@@ -115,7 +125,7 @@ FT_BEGIN_HEADER
FT_Pointer mem_data );
/***********************************************************************
/*@**********************************************************************
*
* @struct: FT_Memory_FuncsRec
*
@@ -141,7 +151,7 @@ FT_BEGIN_HEADER
} FT_Memory_FuncsRec, *FT_Memory_Funcs;
/***********************************************************************
/*@**********************************************************************
*
* @type: FT_Memory_Funcs
*
@@ -152,7 +162,7 @@ FT_BEGIN_HEADER
typedef const FT_Memory_FuncsRec* FT_Memory_Funcs;
/***********************************************************************
/*@**********************************************************************
*
* @function: ft_memory_new
*
@@ -172,7 +182,7 @@ FT_BEGIN_HEADER
FT_Pointer mem_init_data );
/***********************************************************************
/*@**********************************************************************
*
* @function: ft_memory_destroy
*
+3 -2
View File
@@ -280,7 +280,7 @@ FT_BEGIN_HEADER
/* limit :: This field is set and used internally by FreeType */
/* when parsing frames. */
/* */
struct FT_StreamRec_
typedef struct FT_StreamRec_
{
unsigned char* base;
unsigned long size;
@@ -294,7 +294,8 @@ FT_BEGIN_HEADER
FT_Memory memory;
unsigned char* cursor;
unsigned char* limit;
};
} FT_StreamRec;
/* */
@@ -173,6 +173,28 @@ FT_BEGIN_HEADER
FT_Fixed y );
/*************************************************************************/
/* */
/* @function: */
/* FT_Angle_Diff */
/* */
/* @description: */
/* Return the difference between two angles. The result is always */
/* constrained to the ]-PI..PI] interval. */
/* */
/* @input: */
/* angle1 :: First angle. */
/* */
/* angle2 :: Second angle. */
/* */
/* @return: */
/* Contrainted value of `value2-value1'. */
/* */
FT_EXPORT( FT_Angle )
FT_Angle_Diff( FT_Angle angle1,
FT_Angle angle2 );
/*************************************************************************/
/* */
/* @function: */
@@ -270,6 +292,28 @@ FT_BEGIN_HEADER
FT_Vector_Polarize( FT_Vector* vec,
FT_Fixed *length,
FT_Angle *angle );
/*************************************************************************/
/* */
/* @function: */
/* FT_Vector_From_Polar */
/* */
/* @description: */
/* Compute vector coordinates from a length and angle. */
/* */
/* @output: */
/* vec :: The address of source vector. */
/* */
/* @input: */
/* length :: The vector length. */
/* angle :: The vector angle. */
/* */
FT_EXPORT( void )
FT_Vector_From_Polar( FT_Vector* vec,
FT_Fixed length,
FT_Angle angle );
/* */
+26
View File
@@ -21,6 +21,7 @@
#include <ft2build.h>
#include FT_CONFIG_CONFIG_H
#include FT_SYSTEM_H
#include FT_IMAGE_H
@@ -356,6 +357,27 @@ FT_BEGIN_HEADER
} FT_Matrix;
/*************************************************************************/
/* */
/* <Struct> */
/* FT_Data */
/* */
/* <Description> */
/* Read-only binary data represented as a pointer and a length. */
/* */
/* <Fields> */
/* pointer :: The data. */
/* */
/* length :: The length of the data in bytes. */
/* */
typedef struct FT_Data_
{
const FT_Byte* pointer;
FT_Int length;
} FT_Data;
/*************************************************************************/
/* */
/* <FuncType> */
@@ -418,6 +440,10 @@ FT_BEGIN_HEADER
/* This macro converts four letter tags which are used to label */
/* TrueType tables into an unsigned long to be used within FreeType. */
/* */
/* <Note> */
/* The produced values *must* be 32bit integers. Don't redefine this */
/* macro. */
/* */
#define FT_MAKE_TAG( _x1, _x2, _x3, _x4 ) \
( ( (FT_ULong)_x1 << 24 ) | \
( (FT_ULong)_x2 << 16 ) | \
@@ -176,7 +176,7 @@ FT_BEGIN_HEADER
FT_GlyphSlot slot,
FT_Size size,
FT_UInt glyph_index,
FT_ULong load_flags );
FT_Int32 load_flags );
/*************************************************************************/
@@ -68,8 +68,9 @@ FT_BEGIN_HEADER
FT_UInt format;
FT_ULong offset;
FT_UShort* sids;
FT_UShort* codes;
FT_UInt count;
FT_UShort sids [256]; /* avoid dynamic allocations */
FT_UShort codes[256];
} CFF_EncodingRec, *CFF_Encoding;
@@ -241,6 +242,9 @@ FT_BEGIN_HEADER
/* interface to PostScript hinter */
void* pshinter;
/* interface to Postscript Names service */
void* psnames;
} CFF_FontRec, *CFF_Font;
@@ -13,6 +13,11 @@
/* this file you indicate that you have read the license and */
/* understand and accept it fully. */
/* */
/* */
/* IMPORTANT: A description of FreeType's debugging support can be */
/* found in "docs/DEBUG.TXT". Read it if you need to use or */
/* understand this code. */
/* */
/***************************************************************************/
@@ -68,7 +68,7 @@ FT_BEGIN_HEADER
(*FT_Slot_LoadFunc)( FT_GlyphSlot slot,
FT_Size size,
FT_UInt glyph_index,
FT_Int load_flags );
FT_Int32 load_flags );
typedef FT_UInt
@@ -186,12 +186,10 @@ FT_BEGIN_HEADER
FT_Size_ResetPixelsFunc set_pixel_sizes;
FT_Slot_LoadFunc load_glyph;
FT_CharMap_CharIndexFunc get_char_index;
FT_Face_GetKerningFunc get_kerning;
FT_Face_AttachFunc attach_file;
FT_Face_GetAdvancesFunc get_advances;
FT_CharMap_CharNextFunc get_next_char;
} FT_Driver_ClassRec, *FT_Driver_Class;
@@ -59,7 +59,19 @@ FT_BEGIN_HEADER
/***********************************************************
*
* @type: FT_Hash_CompareFunc
* @type: FT_HashLookup
*
* @description:
* handle to a @FT_HashNode pointer. This is returned by
* the @ft_hash_lookup function and can later be used by
* @ft_hash_add or @ft_hash_remove
*/
typedef FT_HashNode* FT_HashLookup;
/***********************************************************
*
* @type: FT_Hash_EqualFunc
*
* @description:
* a function used to compare two nodes of the hash table
@@ -72,8 +84,8 @@ FT_BEGIN_HEADER
* 1 iff the 'keys' in 'node1' and 'node2' are identical.
* 0 otherwise.
*/
typedef FT_Int (*FT_Hash_CompareFunc)( const FT_HashNode node1,
const FT_HashNode node2 );
typedef FT_Int (*FT_Hash_EqualFunc)( FT_HashNode node1,
FT_HashNode node2 );
/***********************************************************
@@ -106,18 +118,14 @@ FT_BEGIN_HEADER
*/
typedef struct FT_HashRec_
{
FT_Memory memory;
FT_HashNode* buckets;
FT_UInt p;
FT_UInt mask; /* really maxp-1 */
FT_UInt slack;
FT_Long slack;
FT_Hash_EqualFunc node_equal;
FT_Memory memory;
FT_UInt node_size;
FT_Hash_CompareFunc node_compare;
FT_Hash_ComputeFunc node_hash;
} FT_HashRec, *FT_Hash;
} FT_HashRec;
/***********************************************************
@@ -169,35 +177,38 @@ FT_BEGIN_HEADER
*
* @input:
* table :: handle to target hash table structure
* compare :: node comparison function
* node_equal :: node comparison function
* memory :: memory manager handle used to allocate the
* buckets array within the hash table
*
* @return:
* error code. 0 means success
*
* @note:
* the node comparison function should only compare node _keys_
* and ignore values !! with good hashing computation (which the
* user must perform itself), the comparison function should be
* pretty selfom called.
* pretty seldom called.
*
* here is a simple example:
*
* {
* static int my_compare( const MyNode node1,
* const MyNode node2 )
* static int my_equal( MyNode node1,
* MyNode node2 )
* {
* // compare keys of 'node1' and 'node2'
* return strcmp( node1->key, node2->key );
* return (strcmp( node1->key, node2->key ) == 0);
* }
*
* ....
*
* ft_hash_init( &hash, (FT_Hash_CompareFunc) my_compare, memory );
* ft_hash_init( &hash, (FT_Hash_EqualFunc) my_compare, memory );
* ....
* }
*/
FT_BASE( void )
FT_BASE( FT_Error )
ft_hash_init( FT_Hash table,
FT_Hash_CompareFunc compare,
FT_Hash_EqualFunc compare,
FT_Memory memory );
@@ -257,9 +268,9 @@ FT_BEGIN_HEADER
* }
* }
*/
FT_BASE_DEF( FT_HashNode* )
FT_BASE_DEF( FT_HashLookup )
ft_hash_lookup( FT_Hash table,
FT_HashNode keynode )
FT_HashNode keynode );
/****************************************************************
@@ -273,10 +284,13 @@ FT_BEGIN_HEADER
*
* @input:
* table :: hash table handle
* pnode :: pointer-to-hash-node value returned by @ft_hash_lookup
* lookup :: pointer-to-hash-node value returned by @ft_hash_lookup
* new_node :: handle to new hash node. All its fields must be correctly
* set, including 'hash'.
*
* @return:
* error code. 0 means success
*
* @note:
* this function should always be used _after_ a call to @ft_hash_lookup
* that returns a pointer to a NULL handle. Here's an example:
@@ -308,17 +322,20 @@ FT_BEGIN_HEADER
*
* // allocate a new node - and set it up
* node = (MyNode) malloc( sizeof(*node) );
* if ( node == NULL ) .....
*
* node->hnode.hash = noderec.hnode.hash;
* node->key = key;
* node->value = value;
*
* // add it to the hash table
* ft_hash_add( table, pnode, node );
* error = ft_hash_add( table, pnode, node );
* if (error) ....
* }
*/
FT_BASE( void )
FT_BASE( FT_Error )
ft_hash_add( FT_Hash table,
FT_HashNode* pnode,
FT_HashLookup lookup,
FT_HashNode new_node );
@@ -332,7 +349,7 @@ FT_BEGIN_HEADER
*
* @input:
* table :: hash table handle
* pnode :: pointer-to-hash-node value returned by @ft_hash_lookup
* lookup :: pointer-to-hash-node value returned by @ft_hash_lookup
*
* @note:
* this function doesn't free the node itself !! Here's an example:
@@ -354,15 +371,16 @@ FT_BEGIN_HEADER
* node = *pnode;
* if ( node != NULL )
* {
* ft_hash_remove( table, pnode );
* error = ft_hash_remove( table, pnode );
* if ( !error )
* free( node );
* }
* }
* }
*/
FT_BASE( void )
FT_BASE( FT_Error )
ft_hash_remove( FT_Hash table,
FT_HashNode* pnode );
FT_HashLookup lookup );
@@ -140,13 +140,10 @@ FT_BEGIN_HEADER
* object :: target object handle
* init_data :: optional pointer to initialization data
*
* @throws: any
*
* the object is _assumed_ to be reachable from the cleanup
* stack when the constructor is called. This means that
* any exception can be thrown safely in it.
* @return:
* error code. 0 means success
*/
typedef void (*FT_Object_InitFunc)( FT_Object object,
typedef FT_Error (*FT_Object_InitFunc)( FT_Object object,
FT_Pointer init_data );
/**************************************************************
@@ -158,8 +155,6 @@ FT_BEGIN_HEADER
*
* @input:
* object :: handle to target object
*
* @throws: *never* !!
*/
typedef void (*FT_Object_DoneFunc)( FT_Object object );
@@ -179,12 +174,15 @@ FT_BEGIN_HEADER
* object sub-system.)
*
* magic :: a 32-bit magic number used for decoding
* super :: pointer to super class
* type :: the @FT_Type descriptor of this class
* memory :: the current memory manager handle
* library :: the current library handle
* info :: an opaque pointer to class-specific information
* managed by the FreeType object sub-system
*
* class_done :: the class destructor function
*
* obj_size :: size of class instances in bytes
* obj_init :: class instance constructor
* obj_done :: class instance destructor
@@ -193,11 +191,14 @@ FT_BEGIN_HEADER
{
FT_ObjectRec object;
FT_UInt32 magic;
FT_Class super;
FT_Type type;
FT_Memory memory;
FT_Library library;
FT_Pointer info;
FT_Object_DoneFunc class_done;
FT_UInt obj_size;
FT_Object_InitFunc obj_init;
FT_Object_DoneFunc obj_done;
@@ -287,14 +288,17 @@ FT_BEGIN_HEADER
*
* @note:
* if 'obj_init' is NULL, the class will use it's parent
* constructor.
* constructor, if any
*
* if 'obj_done' is NULL, the class will use it's parent
* finalizer.
* finalizer, if any
*
* the object sub-system allocates a new class, copies
* the content of its super-class into the new structure,
* _then_ calls 'clazz_init'.
*
* 'class_init' and 'class_done' can be NULL, in which case
* the parent's class constructor and destructor wil be used
*/
typedef struct FT_TypeRec_
{
@@ -336,7 +340,7 @@ FT_BEGIN_HEADER
* @return:
* 1 iff the handle points to a valid object. 0 otherwise
*/
FT_BASE_DEF( FT_Int )
FT_BASE( FT_Int )
ft_object_check( FT_Pointer obj );
@@ -356,88 +360,174 @@ FT_BEGIN_HEADER
* 1 iff the handle points to a valid 'clazz' instance. 0
* otherwise.
*/
FT_BASE_DEF( FT_Int )
FT_BASE( FT_Int )
ft_object_is_a( FT_Pointer obj,
FT_Class clazz );
/**************************************************************
*
* @function: ft_object_new
*
* @description:
* create a new object (class instance)
*
* @input:
* clazz :: object's class pointer
* init_data :: optional pointer to initialization data
*
* @return:
* handle to new object. Cannot be NULL !
*/
FT_BASE_DEF( FT_Object )
ft_object_new( FT_Class clazz,
FT_Pointer init_data );
/**************************************************************
*
* @function: ft_object_create
*
* @description:
* a variation of @ft_object_new that should be used when
* creating a new object that is owned by another object
* which is reachable from the cleanup stack.
*
* this function is a bit more akward to use but completely
* avoids push/pop pairs during object construction and is
* therefore faster.
* create a new object (class instance)
*
* @output:
* pobject :: new object handle
* aobject :: new object handle. NULL in case of error
*
* @input:
* clazz :: object's class pointer
* init_data :: optional pointer to initialization data
* push :: boolean. If true, the new object is pushed
* on top of the cleanup stack.
*
* @return:
* error code. 0 means success
*/
FT_BASE_DEF( void )
ft_object_create( FT_Object *pobject,
FT_BASE( FT_Error )
ft_object_create( FT_Object *aobject,
FT_Class clazz,
FT_Pointer init_data );
/* */
FT_BASE_DEF( FT_Class )
ft_class_find_by_type( FT_Type type,
FT_Memory memory );
FT_BASE_DEF( FT_Class )
ft_class_find_by_name( FT_CString class_name,
FT_Memory memory );
FT_BASE_DEF( FT_Object )
ft_object_new_from_type( FT_Type type,
FT_Pointer data,
FT_Memory memory );
FT_BASE_DEF( void )
ft_object_create_from_type( FT_Object *pobject,
/**************************************************************
*
* @function: ft_object_create_from_type
*
* @description:
* create a new object (class instance) from a @FT_Type
*
* @output:
* aobject :: new object handle. NULL in case of error
*
* @input:
* type :: object's type descriptor
* init_data :: optional pointer to initialization data
*
* @return:
* error code. 0 means success
*
* @note:
* this function is slower than @ft_object_create
*
* this is equivalent to calling @ft_class_from_type followed by
* @ft_object_create
*/
FT_BASE( FT_Error )
ft_object_create_from_type( FT_Object *aobject,
FT_Type type,
FT_Pointer init_data,
FT_Memory memory );
FT_Library library );
FT_BASE_DEF( void )
ft_object_push( FT_Object object );
FT_BASE_DEF( void )
ft_object_pop( FT_Object object );
FT_BASE_DEF( void )
ft_object_pop_destroy( FT_Object object );
/**************************************************************
*
* @macro FT_OBJ_CREATE (object,class,init)
*
* @description:
* a convenient macro used to create new objects. see
* @ft_object_create for details
*/
#define FT_OBJ_CREATE( _obj, _clazz, _init ) \
ft_object_create( FT_OBJECT_P(&(_obj)), _clazz, _init )
/**************************************************************
*
* @macro FT_CREATE (object,class,init)
*
* @description:
* a convenient macro used to create new objects. It also
* sets an _implicit_ local variable named "error" to the error
* code returned by the object constructor.
*/
#define FT_CREATE( _obj, _clazz, _init ) \
FT_SET_ERROR( FT_OBJ_CREATE( _obj, _clazz, _init ) )
/**************************************************************
*
* @macro FT_OBJ_CREATE_FROM_TYPE (object,type,init)
*
* @description:
* a convenient macro used to create new objects. see
* @ft_object_create_from_type for details
*/
#define FT_OBJ_CREATE_FROM_TYPE( _obj, _type, _init, _lib ) \
ft_object_create_from_type( FT_OBJECT_P(&(_obj)), _type, _init, _lib )
/**************************************************************
*
* @macro FT_CREATE_FROM_TYPE (object,type,init)
*
* @description:
* a convenient macro used to create new objects. It also
* sets an _implicit_ local variable named "error" to the error
* code returned by the object constructor.
*/
#define FT_CREATE_FROM_TYPE( _obj, _type, _init, _lib ) \
FT_SET_ERROR( FT_OBJ_CREATE_FROM_TYPE( _obj, _type, _init, _lib ) )
/* */
/**************************************************************
*
* @function: ft_class_from_type
*
* @description:
* retrieves the class object corresponding to a given type
* descriptor. The class is created when needed
*
* @output:
* aclass :: handle to corresponding class object. NULL in
* case of error
*
* @input:
* type :: type descriptor handle
* library :: library handle
*
* @return:
* error code. 0 means success
*/
FT_BASE( FT_Error )
ft_class_from_type( FT_Class *aclass,
FT_Type type,
FT_Library library );
/* */
#include FT_INTERNAL_HASH_H
typedef struct FT_ClassHNodeRec_* FT_ClassHNode;
typedef struct FT_ClassHNodeRec_
{
FT_HashNodeRec hnode;
FT_Type type;
FT_Class clazz;
} FT_ClassHNodeRec;
typedef struct FT_MetaClassRec_
{
FT_ClassRec clazz; /* the meta-class is a class itself */
FT_HashRec type_to_class; /* the type => class hash table */
} FT_MetaClassRec, *FT_MetaClass;
/* initialize meta class */
FT_BASE( FT_Error )
ft_metaclass_init( FT_MetaClass meta,
FT_Library library );
/* finalize meta class - destroy all registered class objects */
FT_BASE( void )
ft_metaclass_done( FT_MetaClass meta );
/* */
FT_END_HEADER
#endif /* __FT_OBJECT_H__ */
@@ -34,6 +34,11 @@
#include FT_INTERNAL_GLYPH_LOADER_H
#include FT_INTERNAL_DRIVER_H
#include FT_INTERNAL_AUTOHINT_H
#include FT_INTERNAL_OBJECT_H
#ifdef FT_CONFIG_OPTION_INCREMENTAL
#include FT_INCREMENTAL_H
#endif
FT_BEGIN_HEADER
@@ -291,8 +296,19 @@ FT_BEGIN_HEADER
/* transform_flags :: Some flags used to classify the transform. */
/* Only used by the convenience functions. */
/* */
/* hint_flags :: Some flags used to change the hinters' */
/* behaviour. Only used for debugging for now. */
/* */
/* postscript_name :: Postscript font name for this face. */
/* */
/* incremental_interface :: */
/* If non-null, the interface through */
/* which glyph data and metrics are loaded */
/* incrementally for faces that do not provide */
/* all of this data when first opened. */
/* This field exists only if */
/* @FT_CONFIG_OPTION_INCREMENTAL is defined. */
/* */
typedef struct FT_Face_InternalRec_
{
FT_UShort max_points;
@@ -302,8 +318,14 @@ FT_BEGIN_HEADER
FT_Vector transform_delta;
FT_Int transform_flags;
FT_UInt32 hint_flags;
const char* postscript_name;
#ifdef FT_CONFIG_OPTION_INCREMENTAL
FT_Incremental_InterfaceRec* incremental_interface;
#endif
} FT_Face_InternalRec;
@@ -541,7 +563,7 @@ FT_BEGIN_HEADER
FT_Raster raster;
FT_Raster_Render_Func raster_render;
FTRenderer_render render;
FT_Renderer_RenderFunc render;
} FT_RendererRec;
@@ -656,7 +678,7 @@ FT_BEGIN_HEADER
/* shortcut used to avoid parsing the list on */
/* each call to FT_Outline_Render(). It is a */
/* handle to the current renderer for the */
/* ft_glyph_format_outline format. */
/* FT_GLYPH_FORMAT_OUTLINE format. */
/* */
/* auto_hinter :: XXX */
/* */
@@ -690,6 +712,8 @@ FT_BEGIN_HEADER
FT_DebugHook_Func debug_hooks[4];
FT_MetaClassRec meta_class;
} FT_LibraryRec;
@@ -701,7 +725,7 @@ FT_BEGIN_HEADER
FT_BASE( FT_Error )
FT_Render_Glyph_Internal( FT_Library library,
FT_GlyphSlot slot,
FT_UInt render_mode );
FT_Render_Mode render_mode );
typedef const char*
(*FT_Face_GetPostscriptNameFunc)( FT_Face face );
@@ -21,6 +21,7 @@
#include <ft2build.h>
#include FT_SYSTEM_H
#include FT_INTERNAL_OBJECTS_H
@@ -35,6 +35,8 @@
#define FT_INTERNAL_TRACE_H <freetype/internal/fttrace.h>
#define FT_INTERNAL_GLYPH_LOADER_H <freetype/internal/ftgloadr.h>
#define FT_INTERNAL_SFNT_H <freetype/internal/sfnt.h>
#define FT_INTERNAL_HASH_H <freetype/internal/fthash.h>
#define FT_INTERNAL_OBJECT_H <freetype/internal/ftobject.h>
#define FT_INTERNAL_TRUETYPE_TYPES_H <freetype/internal/tttypes.h>
#define FT_INTERNAL_TYPE1_TYPES_H <freetype/internal/t1types.h>
@@ -42,7 +44,7 @@
#define FT_INTERNAL_CFF_TYPES_H <freetype/internal/cfftypes.h>
#define FT_INTERNAL_FNT_TYPES_H <freetype/internal/fnttypes.h>
#define FT_INTERNAL_BDF_TYPES_H <freetype/internal/bdftypes.h>
#define FT_INTERNAL_PCF_TYPES_H <freetype/internal/pcftypes.h>
#define FT_INTERNAL_PFR_H <freetype/internal/pfr.h>
#define FT_INTERNAL_POSTSCRIPT_NAMES_H <freetype/internal/psnames.h>
#define FT_INTERNAL_POSTSCRIPT_AUX_H <freetype/internal/psaux.h>
@@ -39,6 +39,8 @@ FT_BEGIN_HEADER
typedef struct PCF_Public_FaceRec_
{
FT_FaceRec root;
FT_StreamRec gzip_stream;
FT_Stream gzip_source;
char* charset_encoding;
char* charset_registry;
@@ -178,6 +178,7 @@ FT_BEGIN_HEADER
T1_FIELD_TYPE_INTEGER,
T1_FIELD_TYPE_FIXED,
T1_FIELD_TYPE_STRING,
T1_FIELD_TYPE_BBOX,
T1_FIELD_TYPE_INTEGER_ARRAY,
T1_FIELD_TYPE_FIXED_ARRAY,
T1_FIELD_TYPE_CALLBACK,
@@ -194,6 +195,7 @@ FT_BEGIN_HEADER
T1_FIELD_LOCATION_FONT_DICT,
T1_FIELD_LOCATION_FONT_INFO,
T1_FIELD_LOCATION_PRIVATE,
T1_FIELD_LOCATION_BBOX,
/* do not remove */
T1_FIELD_LOCATION_MAX
@@ -271,6 +273,10 @@ FT_BEGIN_HEADER
#define T1_FIELD_STRING( _ident, _fname ) \
T1_NEW_SIMPLE_FIELD( _ident, T1_FIELD_TYPE_STRING, _fname )
#define T1_FIELD_BBOX( _ident, _fname ) \
T1_NEW_SIMPLE_FIELD( _ident, T1_FIELD_TYPE_BBOX, _fname )
#define T1_FIELD_NUM_TABLE( _ident, _fname, _fmax ) \
T1_NEW_TABLE_FIELD( _ident, T1_FIELD_TYPE_INTEGER_ARRAY, \
_fname, _fmax )
@@ -604,6 +610,7 @@ FT_BEGIN_HEADER
FT_Byte** glyph_names,
PS_Blend blend,
FT_Bool hinting,
FT_Render_Mode hint_mode,
T1_Decoder_Callback callback );
void
@@ -645,6 +652,9 @@ FT_BEGIN_HEADER
PS_Blend blend; /* for multiple master support */
FT_UInt32 hint_flags;
FT_Render_Mode hint_mode;
T1_Decoder_Callback parse_callback;
T1_Decoder_FuncsRec funcs;
@@ -267,6 +267,8 @@ FT_BEGIN_HEADER
/* */
/* globals :: The hinter globals for this font. */
/* */
/* hint_flags :: Hinter bit flags. */
/* */
/* @return: */
/* FreeType error code. 0 means success. */
/* */
@@ -280,7 +282,8 @@ FT_BEGIN_HEADER
typedef FT_Error
(*T1_Hints_ApplyFunc)( T1_Hints hints,
FT_Outline* outline,
PSH_Globals globals );
PSH_Globals globals,
FT_Render_Mode hint_mode );
/*************************************************************************/
@@ -545,6 +548,8 @@ FT_BEGIN_HEADER
/* */
/* globals :: The hinter globals for this font. */
/* */
/* hint_flags :: Hinter bit flags. */
/* */
/* @return: */
/* FreeType error code. 0 means success. */
/* */
@@ -558,7 +563,8 @@ FT_BEGIN_HEADER
typedef FT_Error
(*T2_Hints_ApplyFunc)( T2_Hints hints,
FT_Outline* outline,
PSH_Globals globals );
PSH_Globals globals,
FT_Render_Mode hint_mode );
/*************************************************************************/
@@ -52,7 +52,7 @@ FT_BEGIN_HEADER
/* This function will not be compiled if the configuration macro */
/* FT_CONFIG_OPTION_ADOBE_GLYPH_LIST is undefined. */
/* */
typedef FT_ULong
typedef FT_UInt32
(*PS_Unicode_Value_Func)( const char* glyph_name );
@@ -100,6 +100,8 @@ FT_BEGIN_HEADER
FT_UShort entry_selector;
FT_UShort range_shift;
FT_ULong offset; /* not in file */
} SFNT_HeaderRec, *SFNT_Header;
@@ -1481,18 +1483,9 @@ FT_BEGIN_HEADER
TT_OS2 os2; /* TrueType OS/2 table */
TT_Postscript postscript; /* TrueType Postscript table */
#ifdef FT_CONFIG_OPTION_USE_CMAPS
FT_Byte* cmap_table; /* extracted 'cmap' table */
FT_ULong cmap_size;
#else /* !FT_CONFIG_OPTION_USE_CMAPS */
FT_Int num_charmaps;
TT_CharMap charmaps; /* array of TT_CharMapRec */
#endif /* !FT_CONFIG_OPTION_USE_CMAPS */
TT_Loader_GotoTableFunc goto_table;
TT_Loader_StartGlyphFunc access_glyph_frame;
@@ -1525,10 +1518,10 @@ FT_BEGIN_HEADER
TT_PCLT pclt;
/* embedded bitmaps support */
FT_Int num_sbit_strikes;
FT_ULong num_sbit_strikes;
TT_SBit_Strike sbit_strikes;
FT_Int num_sbit_scales;
FT_ULong num_sbit_scales;
TT_SBit_Scale sbit_scales;
/* postscript names table */
@@ -244,6 +244,8 @@ FT_BEGIN_HEADER
FT_ULong blend_bitflags;
FT_BBox* bboxes [T1_MAX_MM_DESIGNS + 1];
} PS_BlendRec, *PS_Blend;
+195 -38
View File
@@ -4,7 +4,7 @@
/* */
/* TrueType name ID definitions (specification only). */
/* */
/* Copyright 1996-2001 by */
/* Copyright 1996-2002 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -31,34 +31,134 @@ FT_BEGIN_HEADER
/* Possible values for the `platform' identifier code in the name */
/* records of the TTF `name' table. */
/* */
/*************************************************************************/
/***********************************************************************
*
* @enum:
* TT_PLATFORM_XXX
*
* @description:
* A list of valid values for the `platform_id' identifier code in
* @FT_CharmapRec and @FT_SfntName structures.
*
* @values:
* TT_PLATFORM_APPLE_UNICODE ::
* Used by Apple to indicate a Unicode character map and/or name entry.
* See @TT_APPLE_ID_XXX for corresponding `encoding_id' values. Note
* that name entries in this format are coded as big-endian UCS-2
* character codes _only_.
*
* TT_PLATFORM_MACINTOSH ::
* Used by Apple to indicate a MacOS-specific charmap and/or name entry.
* See @TT_MAC_ID_XXX for corresponding `encoding_id' values. Note that
* most TrueType fonts contain an Apple roman charmap to be usable on
* MacOS systems (even if they contain a Microsoft charmap as well).
*
* TT_PLATFORM_ISO ::
* This value was used to specify Unicode charmaps. It is however
* now deprecated. See @TT_ISO_ID_XXX for a list of corresponding
* `encoding_id' values.
*
* TT_PLATFORM_MICROSOFT ::
* Used by Microsoft to indicate Windows-specific charmaps. See
* @TT_MS_ID_XXX for a list of corresponding `encoding_id' values.
* Note that most fonts contain a Unicode charmap using
* (@TT_PLATFORM_MICROSOFT, @TT_MS_ID_UNICODE_CS).
*
* TT_PLATFORM_CUSTOM ::
* Used to indicate application-specific charmaps.
*
* TT_PLATFORM_ADOBE ::
* This value isn't part of any font format specification, but is used
* by FreeType to report Adobe-specific charmaps in an @FT_CharMapRec
* structure. See @TT_ADOBE_ID_XXX.
*/
#define TT_PLATFORM_APPLE_UNICODE 0
#define TT_PLATFORM_MACINTOSH 1
#define TT_PLATFORM_ISO 2 /* deprecated */
#define TT_PLATFORM_MICROSOFT 3
#define TT_PLATFORM_CUSTOM 4
/* artificial values defined ad-hoc by FreeType */
#define TT_PLATFORM_ADOBE 7
#define TT_PLATFORM_ADOBE 7 /* artificial */
/*************************************************************************/
/* */
/* Possible values of the platform specific encoding identifier field in */
/* the name records of the TTF `name' table if the `platform' identifier */
/* code is TT_PLATFORM_APPLE_UNICODE. */
/* */
/***********************************************************************
*
* @enum:
* TT_APPLE_ID_XXX
*
* @description:
* A list of valid values for the `encoding_id' for
* @TT_PLATFORM_APPLE_UNICODE charmaps and name entries.
*
* @values:
* TT_APPLE_ID_DEFAULT ::
* Unicode version 1.0.
* TT_APPLE_ID_UNICODE_1_1 ::
* Unicode 1.1; specifies Hangul characters starting at U+34xx.
* TT_APPLE_ID_ISO_10646 ::
* Deprecated.
* TT_APPLE_ID_UNICODE_2_0 ::
* Unicode 2.0 and beyond (UTF-16 BMP only).
* TT_APPLE_ID_UNICODE_32 ::
* UTF-32 (Adobe proposal for OpenType).
*/
#define TT_APPLE_ID_DEFAULT 0 /* Unicode 1.0 */
#define TT_APPLE_ID_UNICODE_1_1 1 /* specify Hangul at U+34xx */
#define TT_APPLE_ID_ISO_10646 2 /* deprecated */
#define TT_APPLE_ID_UNICODE_2_0 3 /* or later */
#define TT_APPLE_ID_UNICODE_32 4 /* Adobe proposal */
/*************************************************************************/
/* */
/* Possible values of the platform specific encoding identifier field in */
/* the name records of the TTF `name' table if the `platform' identifier */
/* code is TT_PLATFORM_MACINTOSH. */
/* */
/***********************************************************************
*
* @enum:
* TT_MAC_ID_XXX
*
* @description:
* A list of valid values for the `encoding_id' for
* @TT_PLATFORM_MACINTOSH charmaps and name entries.
*
* @values:
* TT_MAC_ID_ROMAN ::
* TT_MAC_ID_JAPANESE ::
* TT_MAC_ID_TRADITIONAL_CHINESE ::
* TT_MAC_ID_KOREAN ::
* TT_MAC_ID_ARABIC ::
* TT_MAC_ID_HEBREW ::
* TT_MAC_ID_GREEK ::
* TT_MAC_ID_RUSSIAN ::
* TT_MAC_ID_RSYMBOL ::
* TT_MAC_ID_DEVANAGARI ::
* TT_MAC_ID_GURMUKHI ::
* TT_MAC_ID_GUJARATI ::
* TT_MAC_ID_ORIYA ::
* TT_MAC_ID_BENGALI ::
* TT_MAC_ID_TAMIL ::
* TT_MAC_ID_TELUGU ::
* TT_MAC_ID_KANNADA ::
* TT_MAC_ID_MALAYALAM ::
* TT_MAC_ID_SINHALESE ::
* TT_MAC_ID_BURMESE ::
* TT_MAC_ID_KHMER ::
* TT_MAC_ID_THAI ::
* TT_MAC_ID_LAOTIAN ::
* TT_MAC_ID_GEORGIAN ::
* TT_MAC_ID_ARMENIAN ::
* TT_MAC_ID_MALDIVIAN ::
* TT_MAC_ID_SIMPLIFIED_CHINESE ::
* TT_MAC_ID_TIBETAN ::
* TT_MAC_ID_MONGOLIAN ::
* TT_MAC_ID_GEEZ ::
* TT_MAC_ID_SLAVIC ::
* TT_MAC_ID_VIETNAMESE ::
* TT_MAC_ID_SINDHI ::
* TT_MAC_ID_UNINTERP ::
*/
#define TT_MAC_ID_ROMAN 0
#define TT_MAC_ID_JAPANESE 1
#define TT_MAC_ID_TRADITIONAL_CHINESE 2
@@ -95,25 +195,72 @@ FT_BEGIN_HEADER
#define TT_MAC_ID_UNINTERP 32
/*************************************************************************/
/* */
/* Possible values of the platform specific encoding identifier field in */
/* the name records of the TTF `name' table if the `platform' identifier */
/* code is TT_PLATFORM_ISO. */
/* */
/* This use is now deprecated. */
/* */
/***********************************************************************
*
* @enum:
* TT_ISO_ID_XXX
*
* @description:
* A list of valid values for the `encoding_id' for
* @TT_PLATFORM_ISO charmaps and name entries.
*
* Their use is now deprecated.
*
* @values:
* TT_ISO_ID_7BIT_ASCII ::
* ASCII.
* TT_ISO_ID_10646 ::
* ISO/10646.
* TT_ISO_ID_8859_1 ::
* Also known as Latin-1.
*/
#define TT_ISO_ID_7BIT_ASCII 0
#define TT_ISO_ID_10646 1
#define TT_ISO_ID_8859_1 2
/*************************************************************************/
/* */
/* possible values of the platform specific encoding identifier field in */
/* the name records of the TTF `name' table if the `platform' identifier */
/* code is TT_PLATFORM_MICROSOFT. */
/* */
/***********************************************************************
*
* @enum:
* TT_MS_ID_XXX
*
* @description:
* A list of valid values for the `encoding_id' for
* @TT_PLATFORM_MICROSOFT charmaps and name entries.
*
* @values:
* TT_MS_ID_SYMBOL_CS ::
* Corresponds to symbol encodings. see @FT_ENCODING_MS_SYMBOL.
*
* TT_MS_ID_UNICODE_CS ::
* Corresponds to a Microsoft WGL4 charmap, matching Unicode. See
* @FT_ENCODING_UNICODE.
*
* TT_MS_ID_SJIS ::
* Corresponds to Microsoft SJIS Japanese encoding.
* See @FT_ENCODING_MS_SJIS.
*
* TT_MS_ID_GB2312 ::
* Corresponds to Microsoft Simplified Chinese as used in Mainland
* China. See @FT_ENCODING_MS_GB2312.
*
* TT_MS_ID_BIG_5 ::
* Corresponds to Microsoft Traditional Chinese as used in Taiwan and
* Hong Kong. See @FT_ENCODING_MS_BIG5.
*
* TT_MS_ID_WANSUNG ::
* Corresponds to Microsoft Korean Wansung encoding. See
* @FT_ENCODING_MS_WANSUNG.
*
* TT_MS_ID_JOHAB ::
* Corresponds to Microsoft Johab encoding. See @FT_ENCODING_MS_JOHAB.
*
* TT_MS_ID_UCS_4 ::
* Corresponds to UCS-4 or UTF-32 charmaps. This is a recent Adobe
* proposal for OpenType.
*/
#define TT_MS_ID_SYMBOL_CS 0
#define TT_MS_ID_UNICODE_CS 1
#define TT_MS_ID_SJIS 2
@@ -124,14 +271,24 @@ FT_BEGIN_HEADER
#define TT_MS_ID_UCS_4 10
/*************************************************************************/
/* */
/* possible values of the platform specific encoding identifier field in */
/* the name records of the TTF `name' table if the `platform' identifier */
/* code is TT_PLATFORM_ADOBE. */
/* */
/* These are artificial values defined ad-hoc by FreeType. */
/* */
/***********************************************************************
*
* @enum:
* TT_ADOBE_ID_XXX
*
* @description:
* A list of valid values for the `encoding_id' for
* @TT_PLATFORM_ADOBE charmaps. This is a FreeType-specific extension!
*
* @values:
* TT_ADOBE_ID_STANDARD ::
* Adobe standard encoding.
* TT_ADOBE_ID_EXPERT ::
* Adobe expert encoding.
* TT_ADOBE_ID_CUSTOM ::
* Adobe custom encoding.
*/
#define TT_ADOBE_ID_STANDARD 0
#define TT_ADOBE_ID_EXPERT 1
#define TT_ADOBE_ID_CUSTOM 2
+17
View File
@@ -127,4 +127,21 @@
}
FT_LOCAL_DEF( AH_Angle )
ah_angle_diff( AH_Angle angle1,
AH_Angle angle2 )
{
AH_Angle delta;
delta = ( angle2 - angle1 );
if ( delta < 0 )
delta += AH_2PI;
if ( delta > AH_PI )
delta -= AH_2PI;
return delta;
}
/* END */
+5
View File
@@ -51,6 +51,11 @@ FT_BEGIN_HEADER
ah_angle( FT_Vector* v );
FT_LOCAL( AH_Angle )
ah_angle_diff( AH_Angle angle1,
AH_Angle angle2 );
FT_END_HEADER
#endif /* __AHANGLES_H__ */
+19 -19
View File
@@ -28,7 +28,7 @@
#define MAX_TEST_CHARACTERS 12
static
const char* blue_chars[ah_blue_max] =
const char* blue_chars[AH_BLUE_MAX] =
{
"THEZOCQS",
"HEZLOCUS",
@@ -43,7 +43,8 @@
sort_values( FT_Int count,
FT_Pos* table )
{
FT_Int i, j, swap;
FT_Int i, j;
FT_Pos swap;
for ( i = 1; i < count; i++ )
@@ -62,10 +63,10 @@
static FT_Error
ah_hinter_compute_blues( AH_Hinter* hinter )
ah_hinter_compute_blues( AH_Hinter hinter )
{
AH_Blue blue;
AH_Globals* globals = &hinter->globals->design;
AH_Globals globals = &hinter->globals->design;
FT_Pos flats [MAX_TEST_CHARACTERS];
FT_Pos rounds[MAX_TEST_CHARACTERS];
FT_Int num_flats;
@@ -84,7 +85,7 @@
charmap = face->charmap;
/* do we have a Unicode charmap in there? */
error = FT_Select_Charmap( face, ft_encoding_unicode );
error = FT_Select_Charmap( face, FT_ENCODING_UNICODE );
if ( error )
goto Exit;
@@ -95,7 +96,7 @@
AH_LOG(( "blue zones computation\n" ));
AH_LOG(( "------------------------------------------------\n" ));
for ( blue = ah_blue_capital_top; blue < ah_blue_max; blue++ )
for ( blue = AH_BLUE_CAPITAL_TOP; blue < AH_BLUE_MAX; blue++ )
{
const char* p = blue_chars[blue];
const char* limit = p + MAX_TEST_CHARACTERS;
@@ -216,8 +217,8 @@
/* now, set the `round' flag depending on the segment's kind */
round = FT_BOOL(
FT_CURVE_TAG( glyph->outline.tags[prev] ) != FT_Curve_Tag_On ||
FT_CURVE_TAG( glyph->outline.tags[next] ) != FT_Curve_Tag_On );
FT_CURVE_TAG( glyph->outline.tags[prev] ) != FT_CURVE_TAG_ON ||
FT_CURVE_TAG( glyph->outline.tags[next] ) != FT_CURVE_TAG_ON );
AH_LOG(( "%c ", round ? 'r' : 'f' ));
}
@@ -286,13 +287,13 @@
static FT_Error
ah_hinter_compute_widths( AH_Hinter* hinter )
ah_hinter_compute_widths( AH_Hinter hinter )
{
/* scan the array of segments in each direction */
AH_Outline* outline = hinter->glyph;
AH_Segment* segments;
AH_Segment* limit;
AH_Globals* globals = &hinter->globals->design;
AH_Outline outline = hinter->glyph;
AH_Segment segments;
AH_Segment limit;
AH_Globals globals = &hinter->globals->design;
FT_Pos* widths;
FT_Int dimension;
FT_Int* p_num_widths;
@@ -334,8 +335,8 @@
for ( dimension = 1; dimension >= 0; dimension-- )
{
AH_Segment* seg = segments;
AH_Segment* link;
AH_Segment seg = segments;
AH_Segment link;
FT_Int num_widths = 0;
@@ -345,14 +346,14 @@
/* we only consider stem segments there! */
if ( link && link->link == seg && link > seg )
{
FT_Int dist;
FT_Pos dist;
dist = seg->pos - link->pos;
if ( dist < 0 )
dist = -dist;
if ( num_widths < 12 )
if ( num_widths < AH_MAX_WIDTHS )
widths[num_widths++] = dist;
}
}
@@ -368,7 +369,6 @@
limit = segments + outline->num_vsegments;
widths = globals->widths;
p_num_widths = &globals->num_widths;
}
/* Now, compute the edge distance threshold as a fraction of the */
@@ -385,7 +385,7 @@
FT_LOCAL_DEF( FT_Error )
ah_hinter_compute_globals( AH_Hinter* hinter )
ah_hinter_compute_globals( AH_Hinter hinter )
{
return ah_hinter_compute_widths( hinter ) ||
ah_hinter_compute_blues ( hinter );
+3 -3
View File
@@ -32,13 +32,13 @@
FT_BEGIN_HEADER
#define AH_IS_TOP_BLUE( b ) ( (b) == ah_blue_capital_top || \
(b) == ah_blue_small_top )
#define AH_IS_TOP_BLUE( b ) ( (b) == AH_BLUE_CAPITAL_TOP || \
(b) == AH_BLUE_SMALL_TOP )
/* compute global metrics automatically */
FT_LOCAL( FT_Error )
ah_hinter_compute_globals( AH_Hinter* hinter );
ah_hinter_compute_globals( AH_Hinter hinter );
FT_END_HEADER
+283 -163
View File
@@ -32,11 +32,11 @@
#include <stdio.h>
void
ah_dump_edges( AH_Outline* outline )
ah_dump_edges( AH_Outline outline )
{
AH_Edge* edges;
AH_Edge* edge_limit;
AH_Segment* segments;
AH_Edge edges;
AH_Edge edge_limit;
AH_Segment segments;
FT_Int dimension;
@@ -46,7 +46,7 @@
for ( dimension = 1; dimension >= 0; dimension-- )
{
AH_Edge* edge;
AH_Edge edge;
printf ( "Table of %s edges:\n",
@@ -59,13 +59,13 @@
printf ( " [ %5d | %4d | %5s | %4d | %5d | %c | %5.2f | %5.2f ]\n",
edge - edges,
(int)edge->fpos,
edge->dir == ah_dir_up
edge->dir == AH_DIR_UP
? "up"
: ( edge->dir == ah_dir_down
: ( edge->dir == AH_DIR_DOWN
? "down"
: ( edge->dir == ah_dir_left
: ( edge->dir == AH_DIR_LEFT
? "left"
: ( edge->dir == ah_dir_right
: ( edge->dir == AH_DIR_RIGHT
? "right"
: "none" ) ) ),
edge->link ? ( edge->link - edges ) : -1,
@@ -84,11 +84,11 @@
/* A function used to dump the array of linked segments */
void
ah_dump_segments( AH_Outline* outline )
ah_dump_segments( AH_Outline outline )
{
AH_Segment* segments;
AH_Segment* segment_limit;
AH_Point* points;
AH_Segment segments;
AH_Segment segment_limit;
AH_Point points;
FT_Int dimension;
@@ -98,7 +98,7 @@
for ( dimension = 1; dimension >= 0; dimension-- )
{
AH_Segment* seg;
AH_Segment seg;
printf ( "Table of %s segments:\n",
@@ -111,13 +111,13 @@
printf ( " [ %5d | %4d | %5s | %4d | %5d | %4d | %5d | %5d ]\n",
seg - segments,
(int)seg->pos,
seg->dir == ah_dir_up
seg->dir == AH_DIR_UP
? "up"
: ( seg->dir == ah_dir_down
: ( seg->dir == AH_DIR_DOWN
? "down"
: ( seg->dir == ah_dir_left
: ( seg->dir == AH_DIR_LEFT
? "left"
: ( seg->dir == ah_dir_right
: ( seg->dir == AH_DIR_RIGHT
? "right"
: "none" ) ) ),
seg->link ? (seg->link-segments) : -1,
@@ -145,17 +145,17 @@
FT_Pos ay = ABS( dy );
dir = ah_dir_none;
dir = AH_DIR_NONE;
/* test for vertical direction */
if ( ax * 12 < ay )
{
dir = dy > 0 ? ah_dir_up : ah_dir_down;
dir = dy > 0 ? AH_DIR_UP : AH_DIR_DOWN;
}
/* test for horizontal direction */
else if ( ay * 12 < ax )
{
dir = dx > 0 ? ah_dir_right : ah_dir_left;
dir = dx > 0 ? AH_DIR_RIGHT : AH_DIR_LEFT;
}
return dir;
@@ -164,13 +164,14 @@
/* this function is used by ah_get_orientation (see below) to test */
/* the fill direction of a given bbox extrema */
static int
static FT_Int
ah_test_extrema( FT_Outline* outline,
int n )
FT_Int n )
{
FT_Vector *prev, *cur, *next;
FT_Pos product;
FT_Int first, last, c;
FT_Int retval;
/* we need to compute the `previous' and `next' point */
@@ -201,15 +202,16 @@
next->x - cur->x, /* out.x */
0x40 );
retval = 0;
if ( product )
product = product > 0 ? 2 : 1;
retval = product > 0 ? 2 : 1;
return product;
return retval;
}
/* Compute the orientation of path filling. It differs between TrueType */
/* and Type1 formats. We could use the `ft_outline_reverse_fill' flag, */
/* and Type1 formats. We could use the `FT_OUTLINE_REVERSE_FILL' flag, */
/* but it is better to re-compute it directly (it seems that this flag */
/* isn't correctly set for some weird composite glyphs currently). */
/* */
@@ -218,18 +220,18 @@
/* */
/* The function returns either 1 or -1. */
/* */
static int
static FT_Int
ah_get_orientation( FT_Outline* outline )
{
FT_BBox box;
FT_BBox indices;
int n, last;
FT_Int indices_xMin, indices_yMin, indices_xMax, indices_yMax;
FT_Int n, last;
indices.xMin = -1;
indices.yMin = -1;
indices.xMax = -1;
indices.yMax = -1;
indices_xMin = -1;
indices_yMin = -1;
indices_xMax = -1;
indices_yMax = -1;
box.xMin = box.yMin = 32767L;
box.xMax = box.yMax = -32768L;
@@ -249,41 +251,41 @@
if ( x < box.xMin )
{
box.xMin = x;
indices.xMin = n;
indices_xMin = n;
}
if ( x > box.xMax )
{
box.xMax = x;
indices.xMax = n;
indices_xMax = n;
}
y = outline->points[n].y;
if ( y < box.yMin )
{
box.yMin = y;
indices.yMin = n;
indices_yMin = n;
}
if ( y > box.yMax )
{
box.yMax = y;
indices.yMax = n;
indices_yMax = n;
}
}
/* test orientation of the xmin */
n = ah_test_extrema( outline, indices.xMin );
n = ah_test_extrema( outline, indices_xMin );
if ( n )
goto Exit;
n = ah_test_extrema( outline, indices.yMin );
n = ah_test_extrema( outline, indices_yMin );
if ( n )
goto Exit;
n = ah_test_extrema( outline, indices.xMax );
n = ah_test_extrema( outline, indices_xMax );
if ( n )
goto Exit;
n = ah_test_extrema( outline, indices.yMax );
n = ah_test_extrema( outline, indices_yMax );
if ( !n )
n = 1;
@@ -298,14 +300,14 @@
/* ah_outline_new */
/* */
/* <Description> */
/* Creates a new and empty AH_Outline object. */
/* Creates a new and empty AH_OutlineRec object. */
/* */
FT_LOCAL_DEF( FT_Error )
ah_outline_new( FT_Memory memory,
AH_Outline** aoutline )
AH_Outline* aoutline )
{
FT_Error error;
AH_Outline* outline;
AH_Outline outline;
if ( !FT_NEW( outline ) )
@@ -324,10 +326,10 @@
/* ah_outline_done */
/* */
/* <Description> */
/* Destroys a given AH_Outline object. */
/* Destroys a given AH_OutlineRec object. */
/* */
FT_LOCAL_DEF( void )
ah_outline_done( AH_Outline* outline )
ah_outline_done( AH_Outline outline )
{
FT_Memory memory = outline->memory;
@@ -347,15 +349,15 @@
/* ah_outline_save */
/* */
/* <Description> */
/* Saves the content of a given AH_Outline object into a face's glyph */
/* slot. */
/* Saves the contents of a given AH_OutlineRec object into a face's */
/* glyph slot. */
/* */
FT_LOCAL_DEF( void )
ah_outline_save( AH_Outline* outline,
ah_outline_save( AH_Outline outline,
AH_Loader gloader )
{
AH_Point* point = outline->points;
AH_Point* point_limit = point + outline->num_points;
AH_Point point = outline->points;
AH_Point point_limit = point + outline->num_points;
FT_Vector* vec = gloader->current.outline.points;
char* tag = gloader->current.outline.tags;
@@ -366,12 +368,12 @@
vec->x = point->x;
vec->y = point->y;
if ( point->flags & ah_flag_conic )
tag[0] = FT_Curve_Tag_Conic;
else if ( point->flags & ah_flag_cubic )
tag[0] = FT_Curve_Tag_Cubic;
if ( point->flags & AH_FLAG_CONIC )
tag[0] = FT_CURVE_TAG_CONIC;
else if ( point->flags & AH_FLAG_CUBIC )
tag[0] = FT_CURVE_TAG_CUBIC;
else
tag[0] = FT_Curve_Tag_On;
tag[0] = FT_CURVE_TAG_ON;
}
}
@@ -382,11 +384,11 @@
/* ah_outline_load */
/* */
/* <Description> */
/* Loads an unscaled outline from a glyph slot into an AH_Outline */
/* Loads an unscaled outline from a glyph slot into an AH_OutlineRec */
/* object. */
/* */
FT_LOCAL_DEF( FT_Error )
ah_outline_load( AH_Outline* outline,
ah_outline_load( AH_Outline outline,
FT_Face face )
{
FT_Memory memory = outline->memory;
@@ -394,13 +396,13 @@
FT_Outline* source = &face->glyph->outline;
FT_Int num_points = source->n_points;
FT_Int num_contours = source->n_contours;
AH_Point* points;
AH_Point points;
/* check arguments */
if ( !face ||
!face->size ||
face->glyph->format != ft_glyph_format_outline )
face->glyph->format != FT_GLYPH_FORMAT_OUTLINE )
return AH_Err_Invalid_Argument;
/* first of all, reallocate the contours array if necessary */
@@ -450,13 +452,13 @@
/* direction used for a glyph, given that some fonts are broken (e.g. */
/* the Arphic ones). We thus recompute it each time we need to. */
/* */
outline->vert_major_dir = ah_dir_up;
outline->horz_major_dir = ah_dir_left;
outline->vert_major_dir = AH_DIR_UP;
outline->horz_major_dir = AH_DIR_LEFT;
if ( ah_get_orientation( source ) > 1 )
{
outline->vert_major_dir = ah_dir_down;
outline->horz_major_dir = ah_dir_right;
outline->vert_major_dir = AH_DIR_DOWN;
outline->horz_major_dir = AH_DIR_RIGHT;
}
outline->x_scale = face->size->metrics.x_scale;
@@ -469,8 +471,8 @@
{
/* do one thing at a time -- it is easier to understand, and */
/* the code is clearer */
AH_Point* point;
AH_Point* point_limit = points + outline->num_points;
AH_Point point;
AH_Point point_limit = points + outline->num_points;
/* compute coordinates */
@@ -500,10 +502,10 @@
{
switch ( FT_CURVE_TAG( *tag ) )
{
case FT_Curve_Tag_Conic:
point->flags = ah_flag_conic; break;
case FT_Curve_Tag_Cubic:
point->flags = ah_flag_cubic; break;
case FT_CURVE_TAG_CONIC:
point->flags = AH_FLAG_CONIC; break;
case FT_CURVE_TAG_CUBIC:
point->flags = AH_FLAG_CUBIC; break;
default:
;
}
@@ -513,9 +515,9 @@
/* compute `next' and `prev' */
{
FT_Int contour_index;
AH_Point* prev;
AH_Point* first;
AH_Point* end;
AH_Point prev;
AH_Point first;
AH_Point end;
contour_index = 0;
@@ -548,8 +550,8 @@
/* set-up the contours array */
{
AH_Point** contour = outline->contours;
AH_Point** contour_limit = contour + outline->num_contours;
AH_Point* contour = outline->contours;
AH_Point* contour_limit = contour + outline->num_contours;
short* end = source->contours;
short idx = 0;
@@ -565,8 +567,8 @@
{
for ( point = points; point < point_limit; point++ )
{
AH_Point* prev;
AH_Point* next;
AH_Point prev;
AH_Point next;
FT_Vector ivec, ovec;
@@ -583,17 +585,17 @@
point->out_dir = ah_compute_direction( ovec.x, ovec.y );
#ifndef AH_OPTION_NO_WEAK_INTERPOLATION
if ( point->flags & (ah_flag_conic | ah_flag_cubic) )
if ( point->flags & (AH_FLAG_CONIC | AH_FLAG_CUBIC) )
{
Is_Weak_Point:
point->flags |= ah_flag_weak_interpolation;
point->flags |= AH_FLAG_WEAK_INTERPOLATION;
}
else if ( point->out_dir == point->in_dir )
{
AH_Angle angle_in, angle_out, delta;
if ( point->out_dir != ah_dir_none )
if ( point->out_dir != AH_DIR_NONE )
goto Is_Weak_Point;
angle_in = ah_angle( &ivec );
@@ -622,11 +624,11 @@
FT_LOCAL_DEF( void )
ah_setup_uv( AH_Outline* outline,
ah_setup_uv( AH_Outline outline,
AH_UV source )
{
AH_Point* point = outline->points;
AH_Point* point_limit = point + outline->num_points;
AH_Point point = outline->points;
AH_Point point_limit = point + outline->num_points;
for ( ; point < point_limit; point++ )
@@ -636,31 +638,31 @@
switch ( source )
{
case ah_uv_fxy:
case AH_UV_FXY:
u = point->fx;
v = point->fy;
break;
case ah_uv_fyx:
case AH_UV_FYX:
u = point->fy;
v = point->fx;
break;
case ah_uv_oxy:
case AH_UV_OXY:
u = point->ox;
v = point->oy;
break;
case ah_uv_oyx:
case AH_UV_OYX:
u = point->oy;
v = point->ox;
break;
case ah_uv_yx:
case AH_UV_YX:
u = point->y;
v = point->x;
break;
case ah_uv_ox:
case AH_UV_OX:
u = point->x;
v = point->ox;
break;
case ah_uv_oy:
case AH_UV_OY:
u = point->y;
v = point->oy;
break;
@@ -675,11 +677,127 @@
}
/* compute all inflex points in a given glyph */
static void
ah_outline_compute_inflections( AH_Outline outline )
{
AH_Point* contour = outline->contours;
AH_Point* contour_limit = contour + outline->num_contours;
/* load original coordinates in (u,v) */
ah_setup_uv( outline, AH_UV_FXY );
/* do each contour separately */
for ( ; contour < contour_limit; contour++ )
{
FT_Vector vec;
AH_Point point = contour[0];
AH_Point first = point;
AH_Point start = point;
AH_Point end = point;
AH_Point before;
AH_Point after;
AH_Angle angle_in, angle_seg, angle_out;
AH_Angle diff_in, diff_out;
FT_Int finished = 0;
/* compute first segment in contour */
first = point;
start = end = first;
do
{
end = end->next;
if ( end == first )
goto Skip;
} while ( end->u == first->u && end->v == first->v );
vec.x = end->u - start->u;
vec.y = end->v - start->v;
angle_seg = ah_angle( &vec );
/* extend the segment start whenever possible */
before = start;
do
{
do
{
start = before;
before = before->prev;
if ( before == first )
goto Skip;
} while ( before->u == start->u && before->v == start->v );
vec.x = start->u - before->u;
vec.y = start->v - before->v;
angle_in = ah_angle( &vec );
} while ( angle_in == angle_seg );
first = start;
diff_in = ah_angle_diff( angle_in, angle_seg );
/* now, process all segments in the contour */
do
{
/* first, extend current segment's end whenever possible */
after = end;
do
{
do
{
end = after;
after = after->next;
if ( after == first )
finished = 1;
} while ( end->u == after->u && end->v == after->v );
vec.x = after->u - end->u;
vec.y = after->v - end->v;
angle_out = ah_angle( &vec );
} while ( angle_out == angle_seg );
diff_out = ah_angle_diff( angle_seg, angle_out );
if ( ( diff_in ^ diff_out ) < 0 )
{
/* diff_in and diff_out have different signs, we have */
/* inflection points here... */
do
{
start->flags |= AH_FLAG_INFLECTION;
start = start->next;
} while ( start != end );
start->flags |= AH_FLAG_INFLECTION;
}
start = end;
end = after;
angle_seg = angle_out;
diff_in = diff_out;
} while ( !finished );
Skip:
;
}
}
FT_LOCAL_DEF( void )
ah_outline_compute_segments( AH_Outline* outline )
ah_outline_compute_segments( AH_Outline outline )
{
int dimension;
AH_Segment* segments;
AH_Segment segments;
FT_Int* p_num_segments;
AH_Direction segment_dir;
AH_Direction major_dir;
@@ -687,22 +805,22 @@
segments = outline->horz_segments;
p_num_segments = &outline->num_hsegments;
major_dir = ah_dir_right; /* This value must be positive! */
major_dir = AH_DIR_RIGHT; /* This value must be positive! */
segment_dir = major_dir;
/* set up (u,v) in each point */
ah_setup_uv( outline, ah_uv_fyx );
ah_setup_uv( outline, AH_UV_FYX );
for ( dimension = 1; dimension >= 0; dimension-- )
{
AH_Point** contour = outline->contours;
AH_Point** contour_limit = contour + outline->num_contours;
AH_Segment* segment = segments;
AH_Point* contour = outline->contours;
AH_Point* contour_limit = contour + outline->num_contours;
AH_Segment segment = segments;
FT_Int num_segments = 0;
#ifdef AH_HINT_METRICS
AH_Point* min_point = 0;
AH_Point* max_point = 0;
AH_Point min_point = 0;
AH_Point max_point = 0;
FT_Pos min_coord = 32000;
FT_Pos max_coord = -32000;
#endif
@@ -711,8 +829,8 @@
/* do each contour separately */
for ( ; contour < contour_limit; contour++ )
{
AH_Point* point = contour[0];
AH_Point* last = point->prev;
AH_Point point = contour[0];
AH_Point last = point->prev;
int on_edge = 0;
FT_Pos min_pos = +32000; /* minimum segment pos != min_coord */
FT_Pos max_pos = -32000; /* maximum segment pos != max_coord */
@@ -779,8 +897,8 @@
/* a segment is round if either its first or last point */
/* is a control point */
if ( ( segment->first->flags | point->flags ) &
ah_flag_control )
segment->flags |= ah_edge_round;
AH_FLAG_CONTROL )
segment->flags |= AH_EDGE_ROUND;
/* compute segment size */
min_pos = max_pos = point->v;
@@ -815,10 +933,10 @@
segment_dir = point->out_dir;
/* clear all segment fields */
FT_MEM_SET( segment, 0, sizeof ( *segment ) );
FT_ZERO( segment );
segment->dir = segment_dir;
segment->flags = ah_edge_normal;
segment->flags = AH_EDGE_NORMAL;
min_pos = max_pos = point->u;
segment->first = point;
segment->last = point;
@@ -845,8 +963,8 @@
/* we do this by inserting fake segments when needed */
if ( dimension == 0 )
{
AH_Point* point = outline->points;
AH_Point* point_limit = point + outline->num_points;
AH_Point point = outline->points;
AH_Point point_limit = point + outline->num_points;
FT_Pos min_pos = 32000;
FT_Pos max_pos = -32000;
@@ -877,10 +995,10 @@
if ( min_point )
{
/* clear all segment fields */
FT_MEM_SET( segment, 0, sizeof ( *segment ) );
FT_ZERO( segment );
segment->dir = segment_dir;
segment->flags = ah_edge_normal;
segment->flags = AH_EDGE_NORMAL;
segment->first = min_point;
segment->last = min_point;
segment->pos = min_pos;
@@ -893,10 +1011,10 @@
if ( max_point )
{
/* clear all segment fields */
FT_MEM_SET( segment, 0, sizeof ( *segment ) );
FT_ZERO( segment );
segment->dir = segment_dir;
segment->flags = ah_edge_normal;
segment->flags = AH_EDGE_NORMAL;
segment->first = max_point;
segment->last = max_point;
segment->pos = max_pos;
@@ -910,36 +1028,38 @@
*p_num_segments = num_segments;
segments = outline->vert_segments;
major_dir = ah_dir_up;
major_dir = AH_DIR_UP;
p_num_segments = &outline->num_vsegments;
ah_setup_uv( outline, ah_uv_fxy );
ah_setup_uv( outline, AH_UV_FXY );
}
}
FT_LOCAL_DEF( void )
ah_outline_link_segments( AH_Outline* outline )
ah_outline_link_segments( AH_Outline outline )
{
AH_Segment* segments;
AH_Segment* segment_limit;
AH_Segment segments;
AH_Segment segment_limit;
int dimension;
ah_setup_uv( outline, ah_uv_fyx );
ah_setup_uv( outline, AH_UV_FYX );
segments = outline->horz_segments;
segment_limit = segments + outline->num_hsegments;
for ( dimension = 1; dimension >= 0; dimension-- )
{
AH_Segment* seg1;
AH_Segment* seg2;
AH_Segment seg1;
AH_Segment seg2;
/* now compare each segment to the others */
for ( seg1 = segments; seg1 < segment_limit; seg1++ )
{
FT_Pos best_score;
AH_Segment* best_segment;
AH_Segment best_segment;
/* the fake segments are introduced to hint the metrics -- */
/* we must never link them to anything */
@@ -984,14 +1104,13 @@
max = seg2->max_coord;
len = max - min;
if ( len >= 8 )
{
dist = seg2->pos - seg1->pos;
if ( dist < 0 )
dist = -dist;
if ( len < 8 )
score = 300*8 + dist - len*3;
else
score = dist + 300/len;
score = dist + 3000 / len;
if ( score < best_score )
{
@@ -1000,6 +1119,7 @@
}
}
}
}
if ( best_segment )
{
@@ -1009,7 +1129,6 @@
best_segment->num_linked++;
}
} /* edges 1 */
/* now, compute the `serif' segments */
@@ -1024,7 +1143,7 @@
}
}
ah_setup_uv( outline, ah_uv_fxy );
ah_setup_uv( outline, AH_UV_FXY );
segments = outline->vert_segments;
segment_limit = segments + outline->num_vsegments;
@@ -1033,11 +1152,11 @@
static void
ah_outline_compute_edges( AH_Outline* outline )
ah_outline_compute_edges( AH_Outline outline )
{
AH_Edge* edges;
AH_Segment* segments;
AH_Segment* segment_limit;
AH_Edge edges;
AH_Segment segments;
AH_Segment segment_limit;
AH_Direction up_dir;
FT_Int* p_num_edges;
FT_Int dimension;
@@ -1049,14 +1168,14 @@
segments = outline->horz_segments;
segment_limit = segments + outline->num_hsegments;
p_num_edges = &outline->num_hedges;
up_dir = ah_dir_right;
up_dir = AH_DIR_RIGHT;
scale = outline->y_scale;
for ( dimension = 1; dimension >= 0; dimension-- )
{
AH_Edge* edge;
AH_Edge* edge_limit; /* really == edge + num_edges */
AH_Segment* seg;
AH_Edge edge;
AH_Edge edge_limit; /* really == edge + num_edges */
AH_Segment seg;
/*********************************************************************/
@@ -1083,7 +1202,7 @@
edge_limit = edges;
for ( seg = segments; seg < segment_limit; seg++ )
{
AH_Edge* found = 0;
AH_Edge found = 0;
/* look for an edge corresponding to the segment */
@@ -1116,7 +1235,7 @@
edge_limit++;
/* clear all edge fields */
FT_MEM_SET( edge, 0, sizeof ( *edge ) );
FT_MEM_ZERO( edge, sizeof ( *edge ) );
/* add the segment to the new edge's list */
edge->first = seg;
@@ -1167,10 +1286,10 @@
/* now, compute each edge properties */
for ( edge = edges; edge < edge_limit; edge++ )
{
int is_round = 0; /* does it contain round segments? */
int is_straight = 0; /* does it contain straight segments? */
int ups = 0; /* number of upwards segments */
int downs = 0; /* number of downwards segments */
FT_Int is_round = 0; /* does it contain round segments? */
FT_Int is_straight = 0; /* does it contain straight segments? */
FT_Pos ups = 0; /* number of upwards segments */
FT_Pos downs = 0; /* number of downwards segments */
seg = edge->first;
@@ -1181,7 +1300,7 @@
/* check for roundness of segment */
if ( seg->flags & ah_edge_round )
if ( seg->flags & AH_EDGE_ROUND )
is_round++;
else
is_straight++;
@@ -1198,8 +1317,8 @@
if ( seg->link || is_serif )
{
AH_Edge* edge2;
AH_Segment* seg2;
AH_Edge edge2;
AH_Segment seg2;
edge2 = edge->link;
@@ -1242,13 +1361,13 @@
} while ( seg != edge->first );
/* set the round/straight flags */
edge->flags = ah_edge_normal;
edge->flags = AH_EDGE_NORMAL;
if ( is_round > 0 && is_round >= is_straight )
edge->flags |= ah_edge_round;
edge->flags |= AH_EDGE_ROUND;
/* set the edge's main direction */
edge->dir = ah_dir_none;
edge->dir = AH_DIR_NONE;
if ( ups > downs )
edge->dir = up_dir;
@@ -1271,7 +1390,7 @@
segments = outline->vert_segments;
segment_limit = segments + outline->num_vsegments;
p_num_edges = &outline->num_vedges;
up_dir = ah_dir_up;
up_dir = AH_DIR_UP;
scale = outline->x_scale;
}
}
@@ -1283,14 +1402,15 @@
/* ah_outline_detect_features */
/* */
/* <Description> */
/* Performs feature detection on a given AH_Outline object. */
/* Performs feature detection on a given AH_OutlineRec object. */
/* */
FT_LOCAL_DEF( void )
ah_outline_detect_features( AH_Outline* outline )
ah_outline_detect_features( AH_Outline outline )
{
ah_outline_compute_segments ( outline );
ah_outline_link_segments ( outline );
ah_outline_compute_edges ( outline );
ah_outline_compute_inflections( outline );
}
@@ -1304,15 +1424,15 @@
/* be snapped to a blue zone edge (top or bottom). */
/* */
FT_LOCAL_DEF( void )
ah_outline_compute_blue_edges( AH_Outline* outline,
AH_Face_Globals* face_globals )
ah_outline_compute_blue_edges( AH_Outline outline,
AH_Face_Globals face_globals )
{
AH_Edge* edge = outline->horz_edges;
AH_Edge* edge_limit = edge + outline->num_hedges;
AH_Globals* globals = &face_globals->design;
AH_Edge edge = outline->horz_edges;
AH_Edge edge_limit = edge + outline->num_hedges;
AH_Globals globals = &face_globals->design;
FT_Fixed y_scale = outline->y_scale;
FT_Bool blue_active[ah_blue_max];
FT_Bool blue_active[AH_BLUE_MAX];
/* compute which blue zones are active, i.e. have their scaled */
@@ -1322,7 +1442,7 @@
FT_Bool check = 0;
for ( blue = ah_blue_capital_top; blue < ah_blue_max; blue++ )
for ( blue = AH_BLUE_CAPITAL_TOP; blue < AH_BLUE_MAX; blue++ )
{
FT_Pos ref, shoot, dist;
@@ -1360,7 +1480,7 @@
if ( best_dist > 64 / 4 )
best_dist = 64 / 4;
for ( blue = ah_blue_capital_top; blue < ah_blue_max; blue++ )
for ( blue = AH_BLUE_CAPITAL_TOP; blue < AH_BLUE_MAX; blue++ )
{
/* if it is a top zone, check for right edges -- if it is a bottom */
/* zone, check for left edges */
@@ -1398,7 +1518,7 @@
/* now, compare it to the overshoot position if the edge is */
/* rounded, and if the edge is over the reference position of a */
/* top zone, or under the reference position of a bottom zone */
if ( edge->flags & ah_edge_round && dist != 0 )
if ( edge->flags & AH_EDGE_ROUND && dist != 0 )
{
FT_Bool is_under_ref = FT_BOOL( edge->fpos < *blue_pos );
@@ -1438,12 +1558,12 @@
/* edge' pointer from `design units' to `scaled ones'). */
/* */
FT_LOCAL_DEF( void )
ah_outline_scale_blue_edges( AH_Outline* outline,
AH_Face_Globals* globals )
ah_outline_scale_blue_edges( AH_Outline outline,
AH_Face_Globals globals )
{
AH_Edge* edge = outline->horz_edges;
AH_Edge* edge_limit = edge + outline->num_hedges;
FT_Int delta;
AH_Edge edge = outline->horz_edges;
AH_Edge edge_limit = edge + outline->num_hedges;
FT_Pos delta;
delta = globals->scaled.blue_refs - globals->design.blue_refs;
+21 -21
View File
@@ -33,56 +33,56 @@ FT_BEGIN_HEADER
typedef enum AH_UV_
{
ah_uv_fxy,
ah_uv_fyx,
ah_uv_oxy,
ah_uv_oyx,
ah_uv_ox,
ah_uv_oy,
ah_uv_yx,
ah_uv_xy /* should always be last! */
AH_UV_FXY,
AH_UV_FYX,
AH_UV_OXY,
AH_UV_OYX,
AH_UV_OX,
AH_UV_OY,
AH_UV_YX,
AH_UV_XY /* should always be last! */
} AH_UV;
FT_LOCAL( void )
ah_setup_uv( AH_Outline* outline,
ah_setup_uv( AH_Outline outline,
AH_UV source );
/* AH_Outline functions - they should be typically called in this order */
/* AH_OutlineRec functions - they should be typically called in this order */
FT_LOCAL( FT_Error )
ah_outline_new( FT_Memory memory,
AH_Outline** aoutline );
AH_Outline* aoutline );
FT_LOCAL( FT_Error )
ah_outline_load( AH_Outline* outline,
ah_outline_load( AH_Outline outline,
FT_Face face );
FT_LOCAL( void )
ah_outline_compute_segments( AH_Outline* outline );
ah_outline_compute_segments( AH_Outline outline );
FT_LOCAL( void )
ah_outline_link_segments( AH_Outline* outline );
ah_outline_link_segments( AH_Outline outline );
FT_LOCAL( void )
ah_outline_detect_features( AH_Outline* outline );
ah_outline_detect_features( AH_Outline outline );
FT_LOCAL( void )
ah_outline_compute_blue_edges( AH_Outline* outline,
AH_Face_Globals* globals );
ah_outline_compute_blue_edges( AH_Outline outline,
AH_Face_Globals globals );
FT_LOCAL( void )
ah_outline_scale_blue_edges( AH_Outline* outline,
AH_Face_Globals* globals );
ah_outline_scale_blue_edges( AH_Outline outline,
AH_Face_Globals globals );
FT_LOCAL( void )
ah_outline_save( AH_Outline* outline,
ah_outline_save( AH_Outline outline,
AH_Loader loader );
FT_LOCAL( void )
ah_outline_done( AH_Outline* outline );
ah_outline_done( AH_Outline outline );
FT_END_HEADER
+245 -184
View File
@@ -27,10 +27,10 @@
#include FT_OUTLINE_H
#define FACE_GLOBALS( face ) ((AH_Face_Globals*)(face)->autohint.data)
#define FACE_GLOBALS( face ) ((AH_Face_Globals)(face)->autohint.data)
#define AH_USE_IUP
#define OPTIM_STEM_SNAP
/*************************************************************************/
/*************************************************************************/
@@ -40,7 +40,6 @@
/*************************************************************************/
/*************************************************************************/
/* snap a given width in scaled coordinates to one of the */
/* current standard widths */
static FT_Pos
@@ -51,6 +50,7 @@
int n;
FT_Pos best = 64 + 32 + 2;
FT_Pos reference = width;
FT_Pos scaled;
for ( n = 0; n < count; n++ )
@@ -70,16 +70,16 @@
}
}
scaled = (reference+32) & -64;
if ( width >= reference )
{
width -= 0x21;
if ( width < reference )
if ( width < scaled + 48 )
width = reference;
}
else
{
width += 0x21;
if ( width > reference )
if ( width > scaled - 48 )
width = reference;
}
@@ -87,24 +87,70 @@
}
/* align one stem edge relative to the previous stem edge */
static void
ah_align_linked_edge( AH_Hinter* hinter,
AH_Edge* base_edge,
AH_Edge* stem_edge,
int vertical )
/* compute the snapped width of a given stem */
static FT_Pos
ah_compute_stem_width( AH_Hinter hinter,
int vertical,
FT_Pos width )
{
FT_Pos dist = stem_edge->opos - base_edge->opos;
AH_Globals* globals = &hinter->globals->scaled;
FT_Pos sign = 1;
AH_Globals globals = &hinter->globals->scaled;
FT_Pos dist = width;
FT_Int sign = 0;
if ( dist < 0 )
{
dist = -dist;
sign = -1;
dist = -width;
sign = 1;
}
if ( ( vertical && !hinter->do_vert_snapping ) ||
( !vertical && !hinter->do_horz_snapping ) )
{
/* smooth hinting process, very lightly quantize the stem width */
/* */
if ( dist < 64 )
dist = 64;
{
FT_Pos delta = dist - globals->stds[vertical];
if ( delta < 0 )
delta = -delta;
if ( delta < 40 )
{
dist = globals->stds[vertical];
if ( dist < 48 )
dist = 48;
}
if ( dist < 3 * 64 )
{
delta = ( dist & 63 );
dist &= -64;
if ( delta < 10 )
dist += delta;
else if ( delta < 32 )
dist += 10;
else if ( delta < 54 )
dist += 54;
else
dist += delta;
}
else
dist = ( dist + 32 ) & -64;
}
}
else
{
/* strong hinting process, snap the stem width to integer pixels */
/* */
if ( vertical )
{
dist = ah_snap_width( globals->heights, globals->num_heights, dist );
@@ -120,7 +166,7 @@
{
dist = ah_snap_width( globals->widths, globals->num_widths, dist );
if ( hinter->flags & ah_hinter_monochrome )
if ( hinter->flags & AH_HINTER_MONOCHROME )
{
/* monochrome horizontal hinting: snap widths to integer pixels */
/* with a different threshold */
@@ -138,21 +184,40 @@
dist = ( dist + 64 ) >> 1;
else if ( dist < 128 )
dist = ( dist + 42 ) & -64;
dist = ( dist + 22 ) & -64;
else
/* XXX: round otherwise, prevent color fringes in LCD mode */
dist = ( dist + 32 ) & -64;
}
}
}
stem_edge->pos = base_edge->pos + sign * dist;
if ( sign )
dist = -dist;
return dist;
}
/* align one stem edge relative to the previous stem edge */
static void
ah_align_linked_edge( AH_Hinter hinter,
AH_Edge base_edge,
AH_Edge stem_edge,
int vertical )
{
FT_Pos dist = stem_edge->opos - base_edge->opos;
stem_edge->pos = base_edge->pos +
ah_compute_stem_width( hinter, vertical, dist );
}
static void
ah_align_serif_edge( AH_Hinter* hinter,
AH_Edge* base,
AH_Edge* serif,
ah_align_serif_edge( AH_Hinter hinter,
AH_Edge base,
AH_Edge serif,
int vertical )
{
FT_Pos dist;
@@ -168,8 +233,9 @@
sign = -1;
}
/* do not strengthen serifs */
if ( base->flags & ah_edge_done )
/* do not touch serifs widths !! */
#if 0
if ( base->flags & AH_EDGE_DONE )
{
if ( dist >= 64 )
dist = (dist+8) & -64;
@@ -179,6 +245,7 @@
else
dist = 0;
}
#endif
serif->pos = base->pos + sign * dist;
}
@@ -197,11 +264,11 @@
/* Another alternative edge hinting algorithm */
static void
ah_hint_edges_3( AH_Hinter* hinter )
ah_hint_edges_3( AH_Hinter hinter )
{
AH_Edge* edges;
AH_Edge* edge_limit;
AH_Outline* outline = hinter->glyph;
AH_Edge edges;
AH_Edge edge_limit;
AH_Outline outline = hinter->glyph;
FT_Int dimension;
@@ -210,15 +277,15 @@
for ( dimension = 1; dimension >= 0; dimension-- )
{
AH_Edge* edge;
AH_Edge* anchor = 0;
AH_Edge edge;
AH_Edge anchor = 0;
int has_serifs = 0;
if ( ah_debug_disable_vert && !dimension )
if ( !hinter->do_horz_hints && !dimension )
goto Next_Dimension;
if ( ah_debug_disable_horz && dimension )
if ( !hinter->do_vert_hints && dimension )
goto Next_Dimension;
/* we begin by aligning all stems relative to the blue zone */
@@ -228,10 +295,10 @@
for ( edge = edges; edge < edge_limit; edge++ )
{
FT_Pos* blue;
AH_Edge *edge1, *edge2;
AH_EdgeRec *edge1, *edge2;
if ( edge->flags & ah_edge_done )
if ( edge->flags & AH_EDGE_DONE )
continue;
blue = edge->blue_edge;
@@ -253,12 +320,12 @@
continue;
edge1->pos = blue[0];
edge1->flags |= ah_edge_done;
edge1->flags |= AH_EDGE_DONE;
if ( edge2 && !edge2->blue_edge )
{
ah_align_linked_edge( hinter, edge1, edge2, dimension );
edge2->flags |= ah_edge_done;
edge2->flags |= AH_EDGE_DONE;
}
if ( !anchor )
@@ -270,10 +337,10 @@
/* relative order of stems in the glyph.. */
for ( edge = edges; edge < edge_limit; edge++ )
{
AH_Edge *edge2;
AH_EdgeRec* edge2;
if ( edge->flags & ah_edge_done )
if ( edge->flags & AH_EDGE_DONE )
continue;
/* skip all non-stem edges */
@@ -286,54 +353,54 @@
/* now, align the stem */
/* this should not happen, but it's better to be safe.. */
/* this should not happen, but it's better to be safe. */
if ( edge2->blue_edge || edge2 < edge )
{
#if 0
printf( "strange blue alignement, edge %d to %d\n",
edge - edges, edge2 - edges );
#endif
ah_align_linked_edge( hinter, edge2, edge, dimension );
edge->flags |= ah_edge_done;
edge->flags |= AH_EDGE_DONE;
continue;
}
{
FT_Bool min = 0;
FT_Pos delta;
if ( !anchor )
{
edge->pos = ( edge->opos + 32 ) & -64;
anchor = edge;
}
else
edge->pos = anchor->pos +
( ( edge->opos - anchor->opos + 32 ) & -64 );
edge->flags |= ah_edge_done;
if ( edge > edges && edge->pos < edge[-1].pos )
{
edge->pos = edge[-1].pos;
min = 1;
}
edge->flags |= AH_EDGE_DONE;
ah_align_linked_edge( hinter, edge, edge2, dimension );
delta = 0;
if ( edge2 + 1 < edge_limit &&
edge2[1].flags & ah_edge_done )
delta = edge2[1].pos - edge2->pos;
if ( delta < 0 )
{
edge2->pos += delta;
if ( !min )
edge->pos += delta;
}
edge2->flags |= ah_edge_done;
else
{
FT_Pos org_pos, org_len, org_center, cur_len;
FT_Pos cur_pos1, cur_pos2, delta1, delta2;
org_pos = anchor->pos + (edge->opos - anchor->opos);
org_len = edge2->opos - edge->opos;
org_center = org_pos + ( org_len >> 1 );
cur_len = ah_compute_stem_width( hinter, dimension, org_len );
cur_pos1 = ( org_pos + 32 ) & -64;
delta1 = ( cur_pos1 + ( cur_len >> 1 ) - org_center );
if ( delta1 < 0 )
delta1 = -delta1;
cur_pos2 = ( ( org_pos + org_len + 32 ) & -64 ) - cur_len;
delta2 = ( cur_pos2 + ( cur_len >> 1 ) - org_center );
if ( delta2 < 0 )
delta2 = -delta2;
edge->pos = ( delta1 <= delta2 ) ? cur_pos1 : cur_pos2;
edge2->pos = edge->pos + cur_len;
edge->flags |= AH_EDGE_DONE;
edge2->flags |= AH_EDGE_DONE;
if ( edge > edges && edge->pos < edge[-1].pos )
edge->pos = edge[-1].pos;
}
}
@@ -344,13 +411,11 @@
/* to complete our processing */
for ( edge = edges; edge < edge_limit; edge++ )
{
if ( edge->flags & ah_edge_done )
if ( edge->flags & AH_EDGE_DONE )
continue;
if ( edge->serif )
{
ah_align_serif_edge( hinter, edge->serif, edge, dimension );
}
else if ( !anchor )
{
edge->pos = ( edge->opos + 32 ) & -64;
@@ -360,13 +425,13 @@
edge->pos = anchor->pos +
( ( edge->opos-anchor->opos + 32 ) & -64 );
edge->flags |= ah_edge_done;
edge->flags |= AH_EDGE_DONE;
if ( edge > edges && edge->pos < edge[-1].pos )
edge->pos = edge[-1].pos;
if ( edge + 1 < edge_limit &&
edge[1].flags & ah_edge_done &&
edge[1].flags & AH_EDGE_DONE &&
edge->pos > edge[1].pos )
edge->pos = edge[1].pos;
}
@@ -379,38 +444,13 @@
FT_LOCAL_DEF( void )
ah_hinter_hint_edges( AH_Hinter* hinter,
FT_Bool no_horz_edges,
FT_Bool no_vert_edges )
ah_hinter_hint_edges( AH_Hinter hinter )
{
#if 0
ah_debug_disable_horz = no_horz_edges;
ah_debug_disable_vert = no_vert_edges;
#else
FT_UNUSED( no_horz_edges );
FT_UNUSED( no_vert_edges );
#endif
/* AH_Interpolate_Blue_Edges( hinter ); -- doesn't seem to help */
/* reduce the problem of the disappearing eye in the `e' of Times... */
/* also, creates some artifacts near the blue zones? */
{
ah_hint_edges_3( hinter );
#if 0
/* outline optimizer removed temporarily */
if ( hinter->flags & ah_hinter_optimize )
{
AH_Optimizer opt;
if ( !AH_Optimizer_Init( &opt, hinter->glyph, hinter->memory ) )
{
AH_Optimizer_Compute( &opt );
AH_Optimizer_Done( &opt );
}
}
#endif
}
}
@@ -426,11 +466,11 @@
/*************************************************************************/
static void
ah_hinter_align_edge_points( AH_Hinter* hinter )
ah_hinter_align_edge_points( AH_Hinter hinter )
{
AH_Outline* outline = hinter->glyph;
AH_Edge* edges;
AH_Edge* edge_limit;
AH_Outline outline = hinter->glyph;
AH_Edge edges;
AH_Edge edge_limit;
FT_Int dimension;
@@ -439,7 +479,7 @@
for ( dimension = 1; dimension >= 0; dimension-- )
{
AH_Edge* edge;
AH_Edge edge;
edge = edges;
@@ -447,12 +487,12 @@
{
/* move the points of each segment */
/* in each edge to the edge's position */
AH_Segment* seg = edge->first;
AH_Segment seg = edge->first;
do
{
AH_Point* point = seg->first;
AH_Point point = seg->first;
for (;;)
@@ -460,12 +500,12 @@
if ( dimension )
{
point->y = edge->pos;
point->flags |= ah_flag_touch_y;
point->flags |= AH_FLAG_TOUCH_Y;
}
else
{
point->x = edge->pos;
point->flags |= ah_flag_touch_x;
point->flags |= AH_FLAG_TOUCH_X;
}
if ( point == seg->last )
@@ -487,14 +527,14 @@
/* hint the strong points -- this is equivalent to the TrueType `IP' */
static void
ah_hinter_align_strong_points( AH_Hinter* hinter )
ah_hinter_align_strong_points( AH_Hinter hinter )
{
AH_Outline* outline = hinter->glyph;
AH_Outline outline = hinter->glyph;
FT_Int dimension;
AH_Edge* edges;
AH_Edge* edge_limit;
AH_Point* points;
AH_Point* point_limit;
AH_Edge edges;
AH_Edge edge_limit;
AH_Point points;
AH_Point point_limit;
AH_Flags touch_flag;
@@ -503,12 +543,12 @@
edges = outline->horz_edges;
edge_limit = edges + outline->num_hedges;
touch_flag = ah_flag_touch_y;
touch_flag = AH_FLAG_TOUCH_Y;
for ( dimension = 1; dimension >= 0; dimension-- )
{
AH_Point* point;
AH_Edge* edge;
AH_Point point;
AH_Edge edge;
if ( edges < edge_limit )
@@ -524,7 +564,8 @@
#ifndef AH_OPTION_NO_WEAK_INTERPOLATION
/* if this point is candidate to weak interpolation, we will */
/* interpolate it after all strong points have been processed */
if ( point->flags & ah_flag_weak_interpolation )
if ( ( point->flags & AH_FLAG_WEAK_INTERPOLATION ) &&
!( point->flags & AH_FLAG_INFLECTION ) )
continue;
#endif
@@ -561,8 +602,8 @@
/* otherwise, interpolate the point in between */
{
AH_Edge* before = 0;
AH_Edge* after = 0;
AH_Edge before = 0;
AH_Edge after = 0;
for ( edge = edges; edge < edge_limit; edge++ )
@@ -608,7 +649,7 @@
edges = outline->vert_edges;
edge_limit = edges + outline->num_vedges;
touch_flag = ah_flag_touch_x;
touch_flag = AH_FLAG_TOUCH_X;
}
}
@@ -616,11 +657,11 @@
#ifndef AH_OPTION_NO_WEAK_INTERPOLATION
static void
ah_iup_shift( AH_Point* p1,
AH_Point* p2,
AH_Point* ref )
ah_iup_shift( AH_Point p1,
AH_Point p2,
AH_Point ref )
{
AH_Point* p;
AH_Point p;
FT_Pos delta = ref->u - ref->v;
@@ -633,12 +674,12 @@
static void
ah_iup_interp( AH_Point* p1,
AH_Point* p2,
AH_Point* ref1,
AH_Point* ref2 )
ah_iup_interp( AH_Point p1,
AH_Point p2,
AH_Point ref1,
AH_Point ref2 )
{
AH_Point* p;
AH_Point p;
FT_Pos u;
FT_Pos v1 = ref1->v;
FT_Pos v2 = ref2->v;
@@ -702,13 +743,13 @@
/* interpolate weak points -- this is equivalent to the TrueType `IUP' */
static void
ah_hinter_align_weak_points( AH_Hinter* hinter )
ah_hinter_align_weak_points( AH_Hinter hinter )
{
AH_Outline* outline = hinter->glyph;
AH_Outline outline = hinter->glyph;
FT_Int dimension;
AH_Point* points;
AH_Point* point_limit;
AH_Point** contour_limit;
AH_Point points;
AH_Point point_limit;
AH_Point* contour_limit;
AH_Flags touch_flag;
@@ -717,18 +758,18 @@
/* PASS 1: Move segment points to edge positions */
touch_flag = ah_flag_touch_y;
touch_flag = AH_FLAG_TOUCH_Y;
contour_limit = outline->contours + outline->num_contours;
ah_setup_uv( outline, ah_uv_oy );
ah_setup_uv( outline, AH_UV_OY );
for ( dimension = 1; dimension >= 0; dimension-- )
{
AH_Point* point;
AH_Point* end_point;
AH_Point* first_point;
AH_Point** contour;
AH_Point point;
AH_Point end_point;
AH_Point first_point;
AH_Point* contour;
point = points;
@@ -745,8 +786,8 @@
if ( point <= end_point )
{
AH_Point* first_touched = point;
AH_Point* cur_touched = point;
AH_Point first_touched = point;
AH_Point cur_touched = point;
point++;
@@ -791,8 +832,8 @@
for ( point = points; point < point_limit; point++ )
point->y = point->u;
touch_flag = ah_flag_touch_x;
ah_setup_uv( outline, ah_uv_ox );
touch_flag = AH_FLAG_TOUCH_X;
ah_setup_uv( outline, AH_UV_OX );
}
else
{
@@ -808,7 +849,7 @@
FT_LOCAL_DEF( void )
ah_hinter_align_points( AH_Hinter* hinter )
ah_hinter_align_points( AH_Hinter hinter )
{
ah_hinter_align_edge_points( hinter );
@@ -835,14 +876,14 @@
/* scale and fit the global metrics */
static void
ah_hinter_scale_globals( AH_Hinter* hinter,
ah_hinter_scale_globals( AH_Hinter hinter,
FT_Fixed x_scale,
FT_Fixed y_scale )
{
FT_Int n;
AH_Face_Globals* globals = hinter->globals;
AH_Globals* design = &globals->design;
AH_Globals* scaled = &globals->scaled;
AH_Face_Globals globals = hinter->globals;
AH_Globals design = &globals->design;
AH_Globals scaled = &globals->scaled;
/* copy content */
@@ -855,8 +896,11 @@
for ( n = 0; n < design->num_heights; n++ )
scaled->heights[n] = FT_MulFix( design->heights[n], y_scale );
scaled->stds[0] = ( design->num_widths > 0 ) ? scaled->widths[0] : 32000;
scaled->stds[1] = ( design->num_heights > 0 ) ? scaled->heights[0] : 32000;
/* scale the blue zones */
for ( n = 0; n < ah_blue_max; n++ )
for ( n = 0; n < AH_BLUE_MAX; n++ )
{
FT_Pos delta, delta2;
@@ -888,7 +932,7 @@
static void
ah_hinter_align( AH_Hinter* hinter )
ah_hinter_align( AH_Hinter hinter )
{
ah_hinter_align_edge_points( hinter );
ah_hinter_align_points( hinter );
@@ -897,7 +941,7 @@
/* finalize a hinter object */
FT_LOCAL_DEF( void )
ah_hinter_done( AH_Hinter* hinter )
ah_hinter_done( AH_Hinter hinter )
{
if ( hinter )
{
@@ -921,9 +965,9 @@
/* create a new empty hinter object */
FT_LOCAL_DEF( FT_Error )
ah_hinter_new( FT_Library library,
AH_Hinter** ahinter )
AH_Hinter *ahinter )
{
AH_Hinter* hinter = 0;
AH_Hinter hinter = 0;
FT_Memory memory = library->memory;
FT_Error error;
@@ -956,13 +1000,13 @@
/* create a face's autohint globals */
FT_LOCAL_DEF( FT_Error )
ah_hinter_new_face_globals( AH_Hinter* hinter,
ah_hinter_new_face_globals( AH_Hinter hinter,
FT_Face face,
AH_Globals* globals )
AH_Globals globals )
{
FT_Error error;
FT_Memory memory = hinter->memory;
AH_Face_Globals* face_globals;
AH_Face_Globals face_globals;
if ( FT_NEW( face_globals ) )
@@ -988,7 +1032,7 @@
/* discard a face's autohint globals */
FT_LOCAL_DEF( void )
ah_hinter_done_face_globals( AH_Face_Globals* globals )
ah_hinter_done_face_globals( AH_Face_Globals globals )
{
FT_Face face = globals->face;
FT_Memory memory = face->memory;
@@ -999,9 +1043,9 @@
static FT_Error
ah_hinter_load( AH_Hinter* hinter,
ah_hinter_load( AH_Hinter hinter,
FT_UInt glyph_index,
FT_UInt load_flags,
FT_Int32 load_flags,
FT_UInt depth )
{
FT_Face face = hinter->face;
@@ -1010,12 +1054,8 @@
FT_Fixed x_scale = face->size->metrics.x_scale;
FT_Fixed y_scale = face->size->metrics.y_scale;
FT_Error error;
AH_Outline* outline = hinter->glyph;
AH_Outline outline = hinter->glyph;
AH_Loader gloader = hinter->loader;
FT_Bool no_horz_hints = FT_BOOL(
( load_flags & AH_HINT_NO_HORZ_EDGES ) != 0 );
FT_Bool no_vert_hints = FT_BOOL(
( load_flags & AH_HINT_NO_VERT_EDGES ) != 0 );
/* load the glyph */
@@ -1030,6 +1070,7 @@
{
FT_Matrix imatrix;
imatrix = internal->glyph_matrix;
hinter->trans_delta = internal->glyph_delta;
hinter->trans_matrix = imatrix;
@@ -1044,7 +1085,7 @@
switch ( slot->format )
{
case ft_glyph_format_outline:
case FT_GLYPH_FORMAT_OUTLINE:
/* translate glyph outline if we need to */
if ( hinter->transformed )
@@ -1098,14 +1139,14 @@
/* perform feature detection */
ah_outline_detect_features( outline );
if ( !no_horz_hints )
if ( hinter->do_vert_hints )
{
ah_outline_compute_blue_edges( outline, hinter->globals );
ah_outline_scale_blue_edges( outline, hinter->globals );
}
/* perform alignment control */
ah_hinter_hint_edges( hinter, no_horz_hints, no_vert_hints );
ah_hinter_hint_edges( hinter );
ah_hinter_align( hinter );
/* now save the current outline into the loader's current table */
@@ -1115,8 +1156,8 @@
/* width/positioning that occured during the hinting process */
{
FT_Pos old_advance, old_rsb, old_lsb, new_lsb;
AH_Edge* edge1 = outline->vert_edges; /* leftmost edge */
AH_Edge* edge2 = edge1 +
AH_Edge edge1 = outline->vert_edges; /* leftmost edge */
AH_Edge edge2 = edge1 +
outline->num_vedges - 1; /* rightmost edge */
@@ -1137,7 +1178,7 @@
ah_loader_add( gloader );
break;
case ft_glyph_format_composite:
case FT_GLYPH_FORMAT_COMPOSITE:
{
FT_UInt nn, num_subglyphs = slot->num_subglyphs;
FT_UInt num_base_subgs, start_point;
@@ -1314,7 +1355,7 @@
goto Exit;
slot->outline = slot->internal->loader->base.outline;
slot->format = ft_glyph_format_outline;
slot->format = FT_GLYPH_FORMAT_OUTLINE;
}
#ifdef DEBUG_HINTER
@@ -1328,17 +1369,18 @@
/* load and hint a given glyph */
FT_LOCAL_DEF( FT_Error )
ah_hinter_load_glyph( AH_Hinter* hinter,
ah_hinter_load_glyph( AH_Hinter hinter,
FT_GlyphSlot slot,
FT_Size size,
FT_UInt glyph_index,
FT_Int load_flags )
FT_Int32 load_flags )
{
FT_Face face = slot->face;
FT_Error error;
FT_Fixed x_scale = size->metrics.x_scale;
FT_Fixed y_scale = size->metrics.y_scale;
AH_Face_Globals* face_globals = FACE_GLOBALS( face );
AH_Face_Globals face_globals = FACE_GLOBALS( face );
FT_Render_Mode hint_mode = FT_LOAD_TARGET_MODE(load_flags);
/* first of all, we need to check that we're using the correct face and */
@@ -1366,6 +1408,25 @@
ah_loader_rewind( hinter->loader );
/* reset hinting flags according to load flags and current render target */
hinter->do_horz_hints = !FT_BOOL( load_flags & FT_LOAD_NO_AUTOHINT );
hinter->do_vert_hints = !FT_BOOL( load_flags & FT_LOAD_NO_AUTOHINT );
#ifdef DEBUG_HINTER
hinter->do_horz_hints = !ah_debug_disable_vert; /* not a bug, the meaning */
hinter->do_vert_hints = !ah_debug_disable_horz; /* of h/v is inverted! */
#endif
/* we snap the width of vertical stems for the monochrome and */
/* horizontal LCD rendering targets only. Corresponds to X snapping. */
hinter->do_horz_snapping = FT_BOOL( hint_mode == FT_RENDER_MODE_MONO ||
hint_mode == FT_RENDER_MODE_LCD );
/* we snap the width of horizontal stems for the monochrome and */
/* vertical LCD rendering targets only. Corresponds to Y snapping. */
hinter->do_vert_snapping = FT_BOOL( hint_mode == FT_RENDER_MODE_MONO ||
hint_mode == FT_RENDER_MODE_LCD_V );
#if 1
load_flags = FT_LOAD_NO_SCALE
| FT_LOAD_IGNORE_TRANSFORM ;
@@ -1382,12 +1443,12 @@
/* retrieve a face's autohint globals for client applications */
FT_LOCAL_DEF( void )
ah_hinter_get_global_hints( AH_Hinter* hinter,
ah_hinter_get_global_hints( AH_Hinter hinter,
FT_Face face,
void** global_hints,
long* global_len )
{
AH_Globals* globals = 0;
AH_Globals globals = 0;
FT_Memory memory = hinter->memory;
FT_Error error;
@@ -1419,7 +1480,7 @@
FT_LOCAL_DEF( void )
ah_hinter_done_global_hints( AH_Hinter* hinter,
ah_hinter_done_global_hints( AH_Hinter hinter,
void* global_hints )
{
FT_Memory memory = hinter->memory;
+9 -9
View File
@@ -32,38 +32,38 @@ FT_BEGIN_HEADER
#define AH_HINT_DEFAULT 0
#define AH_HINT_NO_ALIGNMENT 1
#define AH_HINT_NO_HORZ_EDGES 0x20000L
#define AH_HINT_NO_VERT_EDGES 0x40000L
#define AH_HINT_NO_HORZ_EDGES 0x200000L /* temporary hack */
#define AH_HINT_NO_VERT_EDGES 0x400000L /* temporary hack */
/* create a new empty hinter object */
FT_LOCAL( FT_Error )
ah_hinter_new( FT_Library library,
AH_Hinter** ahinter );
AH_Hinter* ahinter );
/* Load a hinted glyph in the hinter */
FT_LOCAL( FT_Error )
ah_hinter_load_glyph( AH_Hinter* hinter,
ah_hinter_load_glyph( AH_Hinter hinter,
FT_GlyphSlot slot,
FT_Size size,
FT_UInt glyph_index,
FT_Int load_flags );
FT_Int32 load_flags );
/* finalize a hinter object */
FT_LOCAL( void )
ah_hinter_done( AH_Hinter* hinter );
ah_hinter_done( AH_Hinter hinter );
FT_LOCAL( void )
ah_hinter_done_face_globals( AH_Face_Globals* globals );
ah_hinter_done_face_globals( AH_Face_Globals globals );
FT_LOCAL( void )
ah_hinter_get_global_hints( AH_Hinter* hinter,
ah_hinter_get_global_hints( AH_Hinter hinter,
FT_Face face,
void** global_hints,
long* global_len );
FT_LOCAL( void )
ah_hinter_done_global_hints( AH_Hinter* hinter,
ah_hinter_done_global_hints( AH_Hinter hinter,
void* global_hints );
+6 -6
View File
@@ -25,15 +25,15 @@
#ifdef DEBUG_HINTER
extern AH_Hinter* ah_debug_hinter = NULL;
extern FT_Bool ah_debug_disable_horz = 0;
extern FT_Bool ah_debug_disable_vert = 0;
AH_Hinter ah_debug_hinter = NULL;
FT_Bool ah_debug_disable_horz = 0;
FT_Bool ah_debug_disable_vert = 0;
#endif
typedef struct FT_AutoHinterRec_
{
FT_ModuleRec root;
AH_Hinter* hinter;
AH_Hinter hinter;
} FT_AutoHinterRec;
@@ -69,7 +69,7 @@
FT_GlyphSlot slot,
FT_Size size,
FT_UInt glyph_index,
FT_ULong load_flags )
FT_Int32 load_flags )
{
return ah_hinter_load_glyph( module->hinter,
slot, size, glyph_index, load_flags );
@@ -83,7 +83,7 @@
FT_UNUSED( module );
if ( face->autohint.data )
ah_hinter_done_face_globals( (AH_Face_Globals*)(face->autohint.data) );
ah_hinter_done_face_globals( (AH_Face_Globals)(face->autohint.data) );
}
+17 -17
View File
@@ -157,8 +157,8 @@
static int
valid_stem_segments( AH_Segment* seg1,
AH_Segment* seg2 )
valid_stem_segments( AH_Segment seg1,
AH_Segment seg2 )
{
return seg1->serif == 0 &&
seg2 &&
@@ -173,13 +173,13 @@
static int
optim_compute_stems( AH_Optimizer* optimizer )
{
AH_Outline* outline = optimizer->outline;
AH_Outline outline = optimizer->outline;
FT_Fixed scale;
FT_Memory memory = optimizer->memory;
FT_Error error = 0;
FT_Int dimension;
AH_Edge* edges;
AH_Edge* edge_limit;
AH_Edge edges;
AH_Edge edge_limit;
AH_Stem** p_stems;
FT_Int* p_num_stems;
@@ -195,13 +195,13 @@
{
AH_Stem* stems = 0;
FT_Int num_stems = 0;
AH_Edge* edge;
AH_Edge edge;
/* first of all, count the number of stems in this direction */
for ( edge = edges; edge < edge_limit; edge++ )
{
AH_Segment* seg = edge->first;
AH_Segment seg = edge->first;
do
@@ -226,8 +226,8 @@
stem = stems;
for ( edge = edges; edge < edge_limit; edge++ )
{
AH_Segment* seg = edge->first;
AH_Segment* seg2;
AH_Segment seg = edge->first;
AH_Segment seg2;
do
@@ -235,8 +235,8 @@
seg2 = seg->link;
if ( valid_stem_segments( seg, seg2 ) )
{
AH_Edge* edge1 = seg->edge;
AH_Edge* edge2 = seg2->edge;
AH_Edge edge1 = seg->edge;
AH_Edge edge2 = seg2->edge;
stem->edge1 = edge1;
@@ -721,8 +721,8 @@
stem->edge1->pos = pos;
stem->edge2->pos = pos + stem->width;
stem->edge1->flags |= ah_edge_done;
stem->edge2->flags |= ah_edge_done;
stem->edge1->flags |= AH_EDGE_DONE;
stem->edge2->flags |= AH_EDGE_DONE;
}
}
@@ -768,8 +768,8 @@
stem->edge1->pos = pos;
stem->edge2->pos = pos + stem->width;
stem->edge1->flags |= ah_edge_done;
stem->edge2->flags |= ah_edge_done;
stem->edge1->flags |= AH_EDGE_DONE;
stem->edge2->flags |= AH_EDGE_DONE;
}
}
@@ -808,13 +808,13 @@
/* loads the outline into the optimizer */
int
AH_Optimizer_Init( AH_Optimizer* optimizer,
AH_Outline* outline,
AH_Outline outline,
FT_Memory memory )
{
FT_Error error;
FT_MEM_SET( optimizer, 0, sizeof ( *optimizer ) );
FT_MEM_ZERO( optimizer, sizeof ( *optimizer ) );
optimizer->outline = outline;
optimizer->memory = memory;
+4 -4
View File
@@ -45,8 +45,8 @@ FT_BEGIN_HEADER
FT_Pos min_pos; /* minimum grid position */
FT_Pos max_pos; /* maximum grid position */
AH_Edge* edge1; /* left/bottom edge */
AH_Edge* edge2; /* right/top edge */
AH_Edge edge1; /* left/bottom edge */
AH_Edge edge2; /* right/top edge */
FT_Pos opos; /* original position */
FT_Pos owidth; /* original width */
@@ -81,7 +81,7 @@ FT_BEGIN_HEADER
typedef struct AH_Optimizer_
{
FT_Memory memory;
AH_Outline* outline;
AH_Outline outline;
FT_Int num_hstems;
AH_Stem* horz_stems;
@@ -115,7 +115,7 @@ FT_BEGIN_HEADER
/* loads the outline into the optimizer */
int
AH_Optimizer_Init( AH_Optimizer* optimizer,
AH_Outline* outline,
AH_Outline outline,
FT_Memory memory );
+91 -79
View File
@@ -92,7 +92,7 @@ FT_BEGIN_HEADER
/* no reason to do this (at least for non-CJK scripts), except for */
/* experimentation. */
/* */
#define AH_HINT_METRICS
#undef AH_HINT_METRICS
/*************************************************************************/
@@ -126,63 +126,65 @@ FT_BEGIN_HEADER
/* hint flags */
#define ah_flag_none 0
#define AH_FLAG_NONE 0
/* bezier control points flags */
#define ah_flag_conic 1
#define ah_flag_cubic 2
#define ah_flag_control ( ah_flag_conic | ah_flag_cubic )
#define AH_FLAG_CONIC 1
#define AH_FLAG_CUBIC 2
#define AH_FLAG_CONTROL ( AH_FLAG_CONIC | AH_FLAG_CUBIC )
/* extrema flags */
#define ah_flag_extrema_x 4
#define ah_flag_extrema_y 8
#define AH_FLAG_EXTREMA_X 4
#define AH_FLAG_EXTREMA_Y 8
/* roundness */
#define ah_flag_round_x 16
#define ah_flag_round_y 32
#define AH_FLAG_ROUND_X 16
#define AH_FLAG_ROUND_Y 32
/* touched */
#define ah_flag_touch_x 64
#define ah_flag_touch_y 128
#define AH_FLAG_TOUCH_X 64
#define AH_FLAG_TOUCH_Y 128
/* weak interpolation */
#define ah_flag_weak_interpolation 256
#define AH_FLAG_WEAK_INTERPOLATION 256
#define AH_FLAG_INFLECTION 512
typedef FT_Int AH_Flags;
/* edge hint flags */
#define ah_edge_normal 0
#define ah_edge_round 1
#define ah_edge_serif 2
#define ah_edge_done 4
#define AH_EDGE_NORMAL 0
#define AH_EDGE_ROUND 1
#define AH_EDGE_SERIF 2
#define AH_EDGE_DONE 4
typedef FT_Int AH_Edge_Flags;
/* hint directions -- the values are computed so that two vectors are */
/* in opposite directions iff `dir1+dir2 == 0' */
#define ah_dir_none 4
#define ah_dir_right 1
#define ah_dir_left -1
#define ah_dir_up 2
#define ah_dir_down -2
#define AH_DIR_NONE 4
#define AH_DIR_RIGHT 1
#define AH_DIR_LEFT -1
#define AH_DIR_UP 2
#define AH_DIR_DOWN -2
typedef FT_Int AH_Direction;
typedef struct AH_Point AH_Point;
typedef struct AH_Segment AH_Segment;
typedef struct AH_Edge AH_Edge;
typedef struct AH_PointRec_* AH_Point;
typedef struct AH_SegmentRec_* AH_Segment;
typedef struct AH_EdgeRec_* AH_Edge;
/*************************************************************************/
/* */
/* <Struct> */
/* AH_Point */
/* AH_PointRec */
/* */
/* <Description> */
/* A structure used to model an outline point to the AH_Outline type. */
/* A structure used to model an outline point to the AH_OutlineRec */
/* type. */
/* */
/* <Fields> */
/* flags :: The current point hint flags. */
@@ -207,7 +209,7 @@ FT_BEGIN_HEADER
/* */
/* prev :: The previous point in same contour. */
/* */
struct AH_Point
typedef struct AH_PointRec_
{
AH_Flags flags; /* point flags used by hinter */
FT_Pos ox, oy;
@@ -221,15 +223,16 @@ FT_BEGIN_HEADER
AH_Angle in_angle;
AH_Angle out_angle;
AH_Point* next; /* next point in contour */
AH_Point* prev; /* previous point in contour */
};
AH_Point next; /* next point in contour */
AH_Point prev; /* previous point in contour */
} AH_PointRec;
/*************************************************************************/
/* */
/* <Struct> */
/* AH_Segment */
/* AH_SegmentRec */
/* */
/* <Description> */
/* A structure used to describe an edge segment to the auto-hinter. */
@@ -264,33 +267,34 @@ FT_BEGIN_HEADER
/* */
/* score :: Used to score the segment when selecting them. */
/* */
struct AH_Segment
typedef struct AH_SegmentRec_
{
AH_Edge_Flags flags;
AH_Direction dir;
AH_Point* first; /* first point in edge segment */
AH_Point* last; /* last point in edge segment */
AH_Point** contour; /* ptr to first point of segment's contour */
AH_Point first; /* first point in edge segment */
AH_Point last; /* last point in edge segment */
AH_Point* contour; /* ptr to first point of segment's contour */
FT_Pos pos; /* position of segment */
FT_Pos min_coord; /* minimum coordinate of segment */
FT_Pos max_coord; /* maximum coordinate of segment */
AH_Edge* edge;
AH_Segment* edge_next;
AH_Edge edge;
AH_Segment edge_next;
AH_Segment* link; /* link segment */
AH_Segment* serif; /* primary segment for serifs */
AH_Segment link; /* link segment */
AH_Segment serif; /* primary segment for serifs */
FT_Pos num_linked; /* number of linked segments */
FT_Int score;
};
FT_Pos score;
} AH_SegmentRec;
/*************************************************************************/
/* */
/* <Struct> */
/* AH_Edge */
/* AH_EdgeRec */
/* */
/* <Description> */
/* A structure used to describe an edge, which really is a horizontal */
@@ -324,29 +328,30 @@ FT_BEGIN_HEADER
/* Only set for some of the horizontal edges in a Latin */
/* font. */
/* */
struct AH_Edge
typedef struct AH_EdgeRec_
{
AH_Edge_Flags flags;
AH_Direction dir;
AH_Segment* first;
AH_Segment* last;
AH_Segment first;
AH_Segment last;
FT_Pos fpos;
FT_Pos opos;
FT_Pos pos;
AH_Edge* link;
AH_Edge* serif;
AH_Edge link;
AH_Edge serif;
FT_Int num_linked;
FT_Int score;
FT_Pos* blue_edge;
};
} AH_EdgeRec;
/* an outline as seen by the hinter */
typedef struct AH_Outline_
typedef struct AH_OutlineRec_
{
FT_Memory memory;
@@ -359,39 +364,39 @@ FT_BEGIN_HEADER
FT_Int max_points;
FT_Int num_points;
AH_Point* points;
AH_Point points;
FT_Int max_contours;
FT_Int num_contours;
AH_Point** contours;
AH_Point * contours;
FT_Int num_hedges;
AH_Edge* horz_edges;
AH_Edge horz_edges;
FT_Int num_vedges;
AH_Edge* vert_edges;
AH_Edge vert_edges;
FT_Int num_hsegments;
AH_Segment* horz_segments;
AH_Segment horz_segments;
FT_Int num_vsegments;
AH_Segment* vert_segments;
AH_Segment vert_segments;
} AH_Outline;
} AH_OutlineRec, *AH_Outline;
#define ah_blue_capital_top 0 /* THEZOCQS */
#define ah_blue_capital_bottom ( ah_blue_capital_top + 1 ) /* HEZLOCUS */
#define ah_blue_small_top ( ah_blue_capital_bottom + 1 ) /* xzroesc */
#define ah_blue_small_bottom ( ah_blue_small_top + 1 ) /* xzroesc */
#define ah_blue_small_minor ( ah_blue_small_bottom + 1 ) /* pqgjy */
#define ah_blue_max ( ah_blue_small_minor + 1 )
#define AH_BLUE_CAPITAL_TOP 0 /* THEZOCQS */
#define AH_BLUE_CAPITAL_BOTTOM ( AH_BLUE_CAPITAL_TOP + 1 ) /* HEZLOCUS */
#define AH_BLUE_SMALL_TOP ( AH_BLUE_CAPITAL_BOTTOM + 1 ) /* xzroesc */
#define AH_BLUE_SMALL_BOTTOM ( AH_BLUE_SMALL_TOP + 1 ) /* xzroesc */
#define AH_BLUE_SMALL_MINOR ( AH_BLUE_SMALL_BOTTOM + 1 ) /* pqgjy */
#define AH_BLUE_MAX ( AH_BLUE_SMALL_MINOR + 1 )
typedef FT_Int AH_Blue;
#define ah_hinter_monochrome 1
#define ah_hinter_optimize 2
#define AH_HINTER_MONOCHROME 1
#define AH_HINTER_OPTIMIZE 2
typedef FT_Int AH_Hinter_Flags;
@@ -399,7 +404,7 @@ FT_BEGIN_HEADER
/*************************************************************************/
/* */
/* <Struct> */
/* AH_Globals */
/* AH_GlobalsRec */
/* */
/* <Description> */
/* Holds the global metrics for a given font face (be it in design */
@@ -418,24 +423,26 @@ FT_BEGIN_HEADER
/* */
/* blue_shoots :: The overshoot positions of blue zones. */
/* */
typedef struct AH_Globals_
typedef struct AH_GlobalsRec_
{
FT_Int num_widths;
FT_Int num_heights;
FT_Pos stds[2];
FT_Pos widths [AH_MAX_WIDTHS];
FT_Pos heights[AH_MAX_HEIGHTS];
FT_Pos blue_refs [ah_blue_max];
FT_Pos blue_shoots[ah_blue_max];
FT_Pos blue_refs [AH_BLUE_MAX];
FT_Pos blue_shoots[AH_BLUE_MAX];
} AH_Globals;
} AH_GlobalsRec, *AH_Globals;
/*************************************************************************/
/* */
/* <Struct> */
/* AH_Face_Globals */
/* AH_Face_GlobalsRec */
/* */
/* <Description> */
/* Holds the complete global metrics for a given font face (i.e., the */
@@ -453,19 +460,19 @@ FT_BEGIN_HEADER
/* */
/* y_scale :: The current vertical scale. */
/* */
typedef struct AH_Face_Globals_
typedef struct AH_Face_GlobalsRec_
{
FT_Face face;
AH_Globals design;
AH_Globals scaled;
AH_GlobalsRec design;
AH_GlobalsRec scaled;
FT_Fixed x_scale;
FT_Fixed y_scale;
FT_Bool control_overshoot;
} AH_Face_Globals;
} AH_Face_GlobalsRec, *AH_Face_Globals;
typedef struct AH_Hinter
typedef struct AH_HinterRec
{
FT_Memory memory;
AH_Hinter_Flags flags;
@@ -473,9 +480,9 @@ FT_BEGIN_HEADER
FT_Int algorithm;
FT_Face face;
AH_Face_Globals* globals;
AH_Face_Globals globals;
AH_Outline* glyph;
AH_Outline glyph;
AH_Loader loader;
FT_Vector pp1;
@@ -485,11 +492,16 @@ FT_BEGIN_HEADER
FT_Vector trans_delta;
FT_Matrix trans_matrix;
} AH_Hinter;
FT_Bool do_horz_hints; /* disable X hinting */
FT_Bool do_vert_hints; /* disable Y hinting */
FT_Bool do_horz_snapping; /* disable X stem size snapping */
FT_Bool do_vert_snapping; /* disable Y stem size snapping */
} AH_HinterRec, *AH_Hinter;
#ifdef DEBUG_HINTER
extern AH_Hinter* ah_debug_hinter;
extern AH_Hinter ah_debug_hinter;
extern FT_Bool ah_debug_disable_horz;
extern FT_Bool ah_debug_disable_vert;
#else
+1 -1
View File
@@ -15,7 +15,7 @@
CFLAGS=$(COMP_FLAGS)$(DEBUG)/include=([--.builds.vms],[--.include],[--.src.base])
OBJS=ftbase.obj,ftinit.obj,ftglyph.obj,ftdebug.obj,ftbdf.obj,ftmm.obj,fttype1.obj,ftxf86.obj
OBJS=ftbase.obj,ftinit.obj,ftglyph.obj,ftdebug.obj,ftbdf.obj,ftmm.obj,fttype1.obj,ftxf86.obj,ftpfr.obj
all : $(OBJS)
library [--.lib]freetype.olb $(OBJS)
+1 -1
View File
@@ -602,7 +602,7 @@
if ( y < cbox.yMin ) cbox.yMin = y;
if ( y > cbox.yMax ) cbox.yMax = y;
if ( FT_CURVE_TAG( outline->tags[n] ) == FT_Curve_Tag_On )
if ( FT_CURVE_TAG( outline->tags[n] ) == FT_CURVE_TAG_ON )
{
/* update bbox for `on' points only */
if ( x < bbox.xMin ) bbox.xMin = x;
+3 -3
View File
@@ -202,7 +202,7 @@
if ( new_buckets == NULL )
return;
FT_MEM_SET( new_buckets, 0, sizeof ( FT_MemNode ) * new_size );
FT_MEM_ZERO( new_buckets, sizeof ( FT_MemNode ) * new_size );
for ( i = 0; i < table->size; i++ )
{
@@ -243,7 +243,7 @@
if ( table == NULL )
goto Exit;
FT_MEM_SET( table, 0, sizeof ( *table ) );
FT_MEM_ZERO( table, sizeof ( *table ) );
table->size = FT_MEM_SIZE_MIN;
table->nodes = 0;
@@ -260,7 +260,7 @@
memory->alloc( memory,
table->size * sizeof ( FT_MemNode ) );
if ( table->buckets )
FT_MEM_SET( table->buckets, 0, sizeof ( FT_MemNode ) * table->size );
FT_MEM_ZERO( table->buckets, sizeof ( FT_MemNode ) * table->size );
else
{
memory->free( memory, table );
+8 -8
View File
@@ -98,9 +98,9 @@
/* */
/* Initialize the tracing sub-system. This is done by retrieving the */
/* value of the "FT2_DEBUG" environment variable. It must be a list of */
/* toggles, separated by spaces, `;' or `:'. Example: */
/* toggles, separated by spaces, `;' or `,'. Example: */
/* */
/* "any=3 memory=6 stream=5" */
/* "any:3 memory:6 stream:5" */
/* */
/* This will request that all levels be set to 3, except the trace level */
/* for the memory and stream components which are set to 6 and 5, */
@@ -126,18 +126,18 @@
for ( ; *p; p++ )
{
/* skip leading whitespace and separators */
if ( *p == ' ' || *p == '\t' || *p == ':' || *p == ';' || *p == '=' )
if ( *p == ' ' || *p == '\t' || *p == ',' || *p == ';' || *p == '=' )
continue;
/* read toggle name, followed by '=' */
/* read toggle name, followed by ':' */
q = p;
while ( *p && *p != '=' )
while ( *p && *p != ':' )
p++;
if ( *p == '=' && p > q )
if ( *p == ':' && p > q )
{
int n, i, len = p - q;
int level = -1, found = -1;
FT_Int n, i, len = (FT_Int)(p - q);
FT_Int level = -1, found = -1;
for ( n = 0; n < trace_count; n++ )
+30 -25
View File
@@ -147,7 +147,7 @@
FT_Memory memory = library->memory;
if ( slot->format != ft_glyph_format_bitmap )
if ( slot->format != FT_GLYPH_FORMAT_BITMAP )
{
error = FT_Err_Invalid_Glyph_Format;
goto Exit;
@@ -209,14 +209,14 @@
const FT_Glyph_Class ft_bitmap_glyph_class =
{
sizeof( FT_BitmapGlyphRec ),
ft_glyph_format_bitmap,
FT_GLYPH_FORMAT_BITMAP,
(FT_Glyph_Init_Func) ft_bitmap_glyph_init,
(FT_Glyph_Done_Func) ft_bitmap_glyph_done,
(FT_Glyph_Copy_Func) ft_bitmap_glyph_copy,
(FT_Glyph_Transform_Func)0,
(FT_Glyph_BBox_Func) ft_bitmap_glyph_bbox,
(FT_Glyph_Prepare_Func) 0
(FT_Glyph_InitFunc) ft_bitmap_glyph_init,
(FT_Glyph_DoneFunc) ft_bitmap_glyph_done,
(FT_Glyph_CopyFunc) ft_bitmap_glyph_copy,
(FT_Glyph_TransformFunc)0,
(FT_Glyph_GetBBoxFunc) ft_bitmap_glyph_bbox,
(FT_Glyph_PrepareFunc) 0
};
@@ -240,7 +240,7 @@
/* check format in glyph slot */
if ( slot->format != ft_glyph_format_outline )
if ( slot->format != FT_GLYPH_FORMAT_OUTLINE )
{
error = FT_Err_Invalid_Glyph_Format;
goto Exit;
@@ -262,8 +262,8 @@
FT_MEM_COPY( target->contours, source->contours,
source->n_contours * sizeof ( FT_Short ) );
/* copy all flags, except the `ft_outline_owner' one */
target->flags = source->flags | ft_outline_owner;
/* copy all flags, except the `FT_OUTLINE_OWNER' one */
target->flags = source->flags | FT_OUTLINE_OWNER;
Exit:
return error;
@@ -319,9 +319,9 @@
ft_outline_glyph_prepare( FT_OutlineGlyph glyph,
FT_GlyphSlot slot )
{
slot->format = ft_glyph_format_outline;
slot->format = FT_GLYPH_FORMAT_OUTLINE;
slot->outline = glyph->outline;
slot->outline.flags &= ~ft_outline_owner;
slot->outline.flags &= ~FT_OUTLINE_OWNER;
return FT_Err_Ok;
}
@@ -330,14 +330,14 @@
const FT_Glyph_Class ft_outline_glyph_class =
{
sizeof( FT_OutlineGlyphRec ),
ft_glyph_format_outline,
FT_GLYPH_FORMAT_OUTLINE,
(FT_Glyph_Init_Func) ft_outline_glyph_init,
(FT_Glyph_Done_Func) ft_outline_glyph_done,
(FT_Glyph_Copy_Func) ft_outline_glyph_copy,
(FT_Glyph_Transform_Func)ft_outline_glyph_transform,
(FT_Glyph_BBox_Func) ft_outline_glyph_bbox,
(FT_Glyph_Prepare_Func) ft_outline_glyph_prepare
(FT_Glyph_InitFunc) ft_outline_glyph_init,
(FT_Glyph_DoneFunc) ft_outline_glyph_done,
(FT_Glyph_CopyFunc) ft_outline_glyph_copy,
(FT_Glyph_TransformFunc)ft_outline_glyph_transform,
(FT_Glyph_GetBBoxFunc) ft_outline_glyph_bbox,
(FT_Glyph_PrepareFunc) ft_outline_glyph_prepare
};
@@ -435,11 +435,11 @@
return FT_Err_Invalid_Argument;
/* if it is a bitmap, that's easy :-) */
if ( slot->format == ft_glyph_format_bitmap )
if ( slot->format == FT_GLYPH_FORMAT_BITMAP )
clazz = &ft_bitmap_glyph_class;
/* it it is an outline too */
else if ( slot->format == ft_glyph_format_outline )
else if ( slot->format == FT_GLYPH_FORMAT_OUTLINE )
clazz = &ft_outline_glyph_class;
else
@@ -567,12 +567,12 @@
FT_EXPORT_DEF( FT_Error )
FT_Glyph_To_Bitmap( FT_Glyph* the_glyph,
FT_ULong render_mode,
FT_Render_Mode render_mode,
FT_Vector* origin,
FT_Bool destroy )
{
FT_GlyphSlotRec dummy;
FT_Error error;
FT_Error error = FT_Err_Ok;
FT_Glyph glyph;
FT_BitmapGlyph bitmap = NULL;
@@ -591,10 +591,15 @@
goto Bad;
clazz = glyph->clazz;
/* when called with a bitmap glyph, do nothing and return succesfully */
if ( clazz == &ft_bitmap_glyph_class )
goto Exit;
if ( !clazz || !clazz->glyph_prepare )
goto Bad;
FT_MEM_SET( &dummy, 0, sizeof ( dummy ) );
FT_MEM_ZERO( &dummy, sizeof ( dummy ) );
dummy.library = glyph->library;
dummy.format = clazz->glyph_format;
+57 -26
View File
@@ -1,4 +1,6 @@
#include "fthash.h"
#include <ft2build.h>
#include FT_TYPES_H
#include FT_INTERNAL_HASH_H
#include FT_INTERNAL_MEMORY_H
#include FT_INTERNAL_DEBUG_H
@@ -27,7 +29,7 @@
table->mask = 0;
table->slack = 0;
table->compare = NULL;
table->node_equal = NULL;
}
}
@@ -45,18 +47,22 @@
FT_BASE_DEF( void )
FT_BASE_DEF( FT_Error )
ft_hash_init( FT_Hash table,
FT_Hash_CompareFunc compare,
FT_Hash_EqualFunc equal,
FT_Memory memory )
{
hash->memory = memory;
hash->compare = node_compare;
hash->p = 0;
hash->mask = FT_HASH_INITIAL_SIZE-1;
hash->slack = FT_HASH_INITIAL_SIZE*FT_HASH_MAX_LOAD;
FT_Error error;
FT_NEW_ARRAY( hash->buckets, FT_HASH_INITIAL_SIZE*2 );
table->memory = memory;
table->p = 0;
table->mask = FT_HASH_INITIAL_SIZE-1;
table->slack = FT_HASH_INITIAL_SIZE*FT_HASH_MAX_LOAD;
table->node_equal = equal;
(void)FT_NEW_ARRAY( table->buckets, FT_HASH_INITIAL_SIZE*2 );
return error;
}
@@ -84,12 +90,13 @@
FT_BASE_DEF( FT_HashNode* )
FT_BASE_DEF( FT_HashLookup )
ft_hash_lookup( FT_Hash table,
FT_HashNode keynode )
{
FT_UInt index;
FT_UInt23 hash = keynode->hash;
FT_UInt32 hash = keynode->hash;
FT_HashNode node, *pnode;
index = (FT_UInt)(hash & table->mask);
if ( index < table->p )
@@ -102,7 +109,7 @@
if ( node == NULL )
break;
if ( node->hash == hash && table->compare( node, keynode ) )
if ( node->hash == hash && table->node_equal( node, keynode ) )
break;
pnode = &node->link;
@@ -114,20 +121,22 @@
FT_BASE_DEF( void )
FT_BASE_DEF( FT_Error )
ft_hash_add( FT_Hash table,
FT_HashNode* pnode,
FT_HashLookup lookup,
FT_HashNode new_node )
{
FT_Error error = 0;
/* add it to the hash table */
new_node->link = *pnode;
*pnode = new_node;
new_node->link = *lookup;
*lookup = new_node;
if ( --table->slack < 0 )
{
FT_UInt p = table->p;
FT_UInt mask = table->mask;
FT_HashNode new_list;
FT_HashNode new_list, node, *pnode;
/* split a single bucket */
new_list = NULL;
@@ -154,33 +163,41 @@
if ( p >= mask )
{
FT_RENEW_ARRAY( hash->buckets, (mask+1)*2, (mask+1)*4 );
FT_Memory memory = table->memory;
if (FT_RENEW_ARRAY( table->buckets, (mask+1)*2, (mask+1)*4 ))
goto Exit;
table->mask = 2*mask + 1;
table->p = 0;
}
else
table->p = p + 1;
}
Exit:
return error;
}
FT_BASE_DEF( FT_Int )
FT_BASE_DEF( FT_Error )
ft_hash_remove( FT_Hash table,
FT_HashNode* pnode )
FT_HashLookup lookup )
{
FT_HashNode node;
FT_UInt num_buckets;
FT_Error error = 0;
FT_ASSERT( pnode != NULL && node != NULL );
node = *pnode;
*pnode->link = node->link;
node = *lookup;
*lookup = node->link;
node->link = NULL;
num_buckets = ( table->p + table->mask + 1) ;
if ( ++ table->slack > num_buckets*FT_HASH_SUB_LOAD )
if ( ++ table->slack > (FT_Long)num_buckets*FT_HASH_SUB_LOAD )
{
FT_UInt p = table->p;
FT_UInt mask = table->mask;
@@ -189,14 +206,26 @@
FT_HashNode* pold;
if ( old_index < FT_HASH_INITIAL_SIZE )
return;
goto Exit;
if ( p == 0 )
{
FT_Memory memory = table->memory;
table->mask >>= 1;
p = table->mask;
FT_RENEW_ARRAY( hash->buckets, (mask+1)*2, (mask) );
if ( FT_RENEW_ARRAY( table->buckets, (mask+1)*2, (mask+1) ) )
{
/* this should never happen normally, but who knows :-) */
/* we need to re-inject the node in the hash table before */
/* returning there, since it's safer */
pnode = table->buckets;
node->link = *pnode;
*pnode = node;
goto Exit;
}
}
else
p--;
@@ -212,4 +241,6 @@
table->slack -= FT_HASH_MAX_LOAD;
table->p = p;
}
Exit:
return error;
}
+1 -1
View File
@@ -93,7 +93,7 @@
/* notify errors, but don't stop */
if ( error )
{
FT_ERROR(( "FT_Add_Default_Module: Cannot install `%s', error = %x\n",
FT_ERROR(( "FT_Add_Default_Module: Cannot install `%s', error = 0x%x\n",
(*cur)->module_name, error ));
}
cur++;
+3 -3
View File
@@ -530,11 +530,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 );
}
@@ -910,7 +910,7 @@
#endif
/* let it fall through to normal loader (.ttf, .otf, etc.) */
args.flags = ft_open_pathname;
args.flags = FT_OPEN_PATHNAME;
args.pathname = (char*)pathname;
return FT_Open_Face( library, &args, face_index, aface );
}
+231 -137
View File
@@ -1,14 +1,23 @@
#include "ftobject.c"
#include <ft2build.h>
#include FT_INTERNAL_OBJECT_H
#include FT_INTERNAL_DEBUG_H
#include FT_INTERNAL_OBJECTS_H
#define FT_MAGIC_DEATH 0xDEADdead
#define FT_MAGIC_CLASS 0x12345678
#define FT_TYPE_HASH(x) (( (FT_UInt32)(x) >> 2 )^( (FT_UInt32)(x) >> 10 ))
#define FT_OBJECT_CHECK(o) \
( FT_OBJECT(o) != NULL && \
FT_OBJECT(o)->clazz != NULL && \
FT_OBJECT(o)->ref_count >= 1 && \
FT_OBJECT(o)->clazz->magic == FT_MAGIC_CLASS )
#define FT_CLASS_CHECK(c) \
( FT_CLASS(c) != NULL && FT_CLASS(c)->magic == FT_MAGIC_CLASS )
#define FT_ASSERT_IS_CLASS(c) FT_ASSERT( FT_CLASS_CHECK(c) )
/*******************************************************************/
/*******************************************************************/
@@ -20,42 +29,43 @@
/*******************************************************************/
/*******************************************************************/
/* we use a dynamic hash table to map types to classes */
/* this structure defines the layout of each node of */
/* this table */
typedef struct FT_ClassHNodeRec_
{
FT_HashNodeRec hnode;
FT_Type ctype;
FT_Class clazz;
} FT_ClassHNodeRec, *FT_ClassHNode;
/* the meta class contains a type -> class mapping */
/* and owns all class objects.. */
/* */
typedef struct FT_MetaClassRec_
{
FT_ClassRec clazz;
FT_HashRec type_to_class;
} FT_MetaClassRec, *FT_MetaClass;
/* forward declaration */
FT_BASE_DEF( FT_Error )
ft_metaclass_init( FT_MetaClass meta,
FT_Library library );
/* forward declaration */
static const FT_TypeRec ft_meta_class_type;
FT_BASE_DEF( void )
ft_metaclass_done( FT_MetaClass meta );
/* class type for the meta-class itself */
static const FT_TypeRec ft_meta_class_type =
{
"FT2.MetaClass",
NULL,
sizeof( FT_MetaClassRec ),
(FT_Object_InitFunc) ft_metaclass_init,
(FT_Object_DoneFunc) ft_metaclass_done,
sizeof( FT_ClassRec ),
(FT_Object_InitFunc) NULL,
(FT_Object_DoneFunc) NULL
};
/* destroy a given class */
static void
ft_class_hnode_destroy( FT_ClassHNode node )
{
FT_Clazz clazz = node->clazz;
FT_Class clazz = node->clazz;
FT_Memory memory = clazz->memory;
FT_Type ctype = clazz->type;
if ( ctype->class_done )
ctype->class_done( clazz );
if ( clazz->class_done )
clazz->class_done( (FT_Object) clazz );
FT_FREE( clazz );
@@ -67,32 +77,81 @@
static FT_Int
ft_class_hnode_compare( const FT_ClassHNode node1,
ft_type_equal( FT_Type type1,
FT_Type type2 )
{
if ( type1 == type2 )
goto Ok;
if ( type1 == NULL || type2 == NULL )
goto Fail;
/* compare parent types */
if ( type1->super != type2->super )
{
if ( type1->super == NULL ||
type2->super == NULL ||
!ft_type_equal( type1, type2 ) )
goto Fail;
}
/* compare type names */
if ( type1->name != type2->name )
{
if ( type1->name == NULL ||
type2->name == NULL ||
ft_strcmp( type1->name, type2->name ) != 0 )
goto Fail;
}
/* compare the other type fields */
if ( type1->class_size != type2->class_size ||
type1->class_init != type2->class_init ||
type1->class_done != type2->class_done ||
type1->obj_size != type2->obj_size ||
type1->obj_init != type2->obj_init ||
type1->obj_done != type2->obj_done )
goto Fail;
Ok:
return 1;
Fail:
return 0;
}
static FT_Int
ft_class_hnode_equal( const FT_ClassHNode node1,
const FT_ClassHNode node2 )
{
return ( node1->type == node2->type );
FT_Type type1 = node1->type;
FT_Type type2 = node2->type;
/* comparing the pointers should work in 99% of cases */
return ( type1 == type2 ) ? 1 : ft_type_equal( type1, type2 );
}
static void
FT_BASE_DEF( void )
ft_metaclass_done( FT_MetaClass meta )
{
/* clear all objects */
/* clear all classes */
ft_hash_done( &meta->type_to_class,
(FT_Hash_ForeachFunc) ft_class_destroy,
(FT_Hash_ForeachFunc) ft_class_hnode_destroy,
NULL );
meta->clazz->object.clazz = NULL;
meta->clazz->object.ref_count = 0;
meta->clazz->magic = FT_MAGIC_DEATH;
meta->clazz.object.clazz = NULL;
meta->clazz.object.ref_count = 0;
meta->clazz.magic = FT_MAGIC_DEATH;
}
static void
FT_BASE_DEF( FT_Error )
ft_metaclass_init( FT_MetaClass meta,
FT_Library library )
{
FT_ClassRec* clazz = meta->clazz;
FT_ClassRec* clazz = (FT_ClassRec*) &meta->clazz;
/* the meta-class is its OWN class !! */
clazz->object.clazz = (FT_Class) clazz;
@@ -100,67 +159,133 @@
clazz->magic = FT_MAGIC_CLASS;
clazz->library = library;
clazz->memory = library->memory;
clazz->type = &ft_metaclass_type;
clazz->type = &ft_meta_class_type;
clazz->info = NULL;
clazz->class_done = (FT_Object_DoneFunc) ft_metaclass_done;
clazz->obj_size = sizeof( FT_ClassRec );
clazz->obj_init = NULL;
clazz->obj_done = NULL;
ft_hash_init( &meta->type_to_class,
(FT_Hash_CompareFunc) ft_class_hnode_compare,
return ft_hash_init( &meta->type_to_class,
(FT_Hash_EqualFunc) ft_class_hnode_equal,
library->memory );
}
/* find or create the class corresponding to a given type */
/* note that this function will retunr NULL in case of */
/* memory overflow */
/* */
static FT_Class
ft_metaclass_get_class( FT_MetaClass meta,
FT_Type ctype )
{
FT_ClassHNodeRec keynode, *node, **pnode;
FT_Memory memory;
FT_ClassRec* clazz;
FT_Class parent;
FT_Error error;
keynode.hnode.hash = (FT_UInt32)( ctype >> 2 );
keynode.type = type;
keynode.hnode.hash = FT_TYPE_HASH( ctype );
keynode.type = ctype;
pnode = (FT_ClassHNode) ft_hash_lookup( &meta->type_to_class,
&noderec );
pnode = (FT_ClassHNode*) ft_hash_lookup( &meta->type_to_class,
(FT_HashNode) &keynode );
node = *pnode;
if ( node != NULL )
return node->clazz;
{
clazz = (FT_ClassRec*) node->clazz;
goto Exit;
}
memory = FT_CLASS__MEMORY(meta);
node = FT_MEM_SAFE_ALLOC( sizeof(*node) );
if ( node != NULL )
clazz = NULL;
parent = NULL;
if ( ctype->super != NULL )
{
FT_ClassRec* clazz;
FT_ASSERT( ctype->super->class_size <= ctype->class_size );
FT_ASSERT( ctype->super->obj_size <= ctype->obj_size );
clazz = FT_MEM_SAFE_ALLOC( ctype->class_size );
if ( clazz == NULL )
parent = ft_metaclass_get_class( meta, ctype->super );
}
if ( !FT_NEW( node ) )
{
if ( !FT_ALLOC( clazz, ctype->class_size ) )
{
if ( parent )
FT_MEM_COPY( (FT_ClassRec*)clazz, parent, parent->type->class_size );
clazz->object.clazz = (FT_Class) meta;
clazz->object.ref_count = 1;
clazz->memory = memory;
clazz->library = FT_CLASS__LIBRARY(meta);
clazz->super = parent;
clazz->type = ctype;
clazz->info = NULL;
clazz->magic = FT_MAGIC_CLASS;
clazz->class_done = ctype->class_done;
clazz->obj_size = ctype->obj_size;
clazz->obj_init = ctype->obj_init;
clazz->obj_done = ctype->obj_done;
if ( parent )
{
if ( clazz->class_done == NULL )
clazz->class_done = parent->class_done;
if ( clazz->obj_init == NULL )
clazz->obj_init = parent->obj_init;
if ( clazz->obj_done == NULL )
clazz->obj_done = parent->obj_done;
}
/* find class initializer, if any */
{
FT_Type ztype = ctype;
FT_Object_InitFunc cinit = NULL;
do
{
cinit = ztype->class_init;
if ( cinit != NULL )
break;
ztype = ztype->super;
}
while ( ztype != NULL );
/* then call it when needed */
if ( cinit != NULL )
error = cinit( (FT_Object) clazz, NULL );
}
}
if (error)
{
if ( clazz )
{
/* we always call the class destructor when */
/* an error was detected in the constructor !! */
if ( clazz->class_done )
clazz->class_done( (FT_Object) clazz );
FT_FREE( clazz );
}
FT_FREE( node );
FT_XTHROW( FT_Err_Out_Of_Memory );
}
}
Exit:
return (FT_Class) clazz;
}
static const FT_TypeRec ft_meta_class_type =
{
"FT2.MetaClass",
NULL,
sizeof( FT_MetaClassRec ),
(FT_Object_InitFunc) ft_metaclass_init,
(FT_Object_DoneFunc) ft_metaclass_done,
sizeof( FT_ClassRec ),
(FT_Object_InitFunc) ft_class_init,
(FT_Object_DoneFunc) ft_class_done
};
@@ -186,7 +311,6 @@
{
if ( FT_OBJECT_CHECK(obj) )
{
FT_Object o = FT_OBJECT(obj);
FT_Class c = FT_OBJECT__CLASS(obj);
do
@@ -200,103 +324,73 @@
return (clazz == NULL);
}
return 0;
}
/* the cleanup routine for all objects */
static void
ft_object_cleanup( FT_Object object )
{
FT_Memory memory = FT_OBJECT__MEMORY(object);
FT_Class clazz = FT_OBJECT__CLASS(object);
if ( clazz->obj_done )
clazz->obj_done( object );
FT_FREE( object );
}
FT_BASE_DEF( FT_Object )
ft_object_new( FT_Class clazz,
FT_Pointer init_data )
{
FT_Memory memory;
FT_Object obj;
FT_ASSERT_IS_CLASS(clazz);
memory = FT_CLASS__MEMORY(clazz);
obj = ft_mem_alloc( clazz->obj_size, memory );
obj->clazz = clazz;
obj->ref_count = 1;
if ( clazz->obj_init )
{
FT_CleanupStack stack = FT_MEMORY__CLEANUP(memory);
ft_cleanup_push( stack, obj, (FT_CleanupFunc) ft_object_cleanup, NULL );
clazz->obj_init( obj, init_data );
ft_cleanup_pop( stack, obj, 0 );
}
return obj;
}
FT_BASE_DEF( void )
FT_BASE_DEF( FT_Error )
ft_object_create( FT_Object *pobject,
FT_Class clazz,
FT_Pointer init_data )
{
FT_Memory memory;
FT_Error error;
FT_Object obj;
FT_ASSERT_IS_CLASS(clazz);
memory = FT_CLASS__MEMORY(memory);
obj = ft_mem_alloc( clazz->obj_size, memory );
memory = FT_CLASS__MEMORY(clazz);
if ( !FT_ALLOC( obj, clazz->obj_size ) )
{
obj->clazz = clazz;
obj->ref_count = 1;
*pobject = obj;
if ( clazz->obj_init )
clazz->obj_init( obj, init_data );
{
error = clazz->obj_init( obj, init_data );
if ( error )
{
/* IMPORTANT: call the destructor when an error */
/* was detected in the constructor !! */
if ( clazz->obj_done )
clazz->obj_done( obj );
FT_FREE( obj );
}
}
}
*pobject = obj;
return error;
}
FT_BASE_DEF( FT_Class )
ft_class_find_by_type( FT_Type type,
FT_Memory memory )
FT_Library library )
{
FT_MetaClass meta = &library->meta_class;
return ft_metaclass_get_class( meta, type );
}
FT_BASE_DEF( FT_Class )
ft_class_find_by_name( FT_CString class_name,
FT_Memory memory );
FT_BASE_DEF( FT_Object )
ft_object_new_from_type( FT_Type type,
FT_Pointer data,
FT_Memory memory );
FT_BASE_DEF( void )
FT_BASE_DEF( FT_Error )
ft_object_create_from_type( FT_Object *pobject,
FT_Type type,
FT_Pointer init_data,
FT_Memory memory );
FT_Library library )
{
FT_Class clazz;
FT_Error error;
FT_BASE_DEF( void )
ft_object_push( FT_Object object );
FT_BASE_DEF( void )
ft_object_pop( FT_Object object );
FT_BASE_DEF( void )
ft_object_pop_destroy( FT_Object object );
clazz = ft_class_find_by_type( type, library );
if ( clazz )
error = ft_object_create( pobject, clazz, init_data );
else
{
*pobject = NULL;
error = FT_Err_Out_Of_Memory;
}
return error;
}
+106 -100
View File
@@ -76,7 +76,7 @@
/* */
static FT_Error
ft_input_stream_new( FT_Library library,
FT_Open_Args* args,
const FT_Open_Args* args,
FT_Stream* astream )
{
FT_Error error;
@@ -98,20 +98,20 @@
stream->memory = memory;
if ( args->flags & ft_open_memory )
if ( args->flags & FT_OPEN_MEMORY )
{
/* create a memory-based stream */
FT_Stream_OpenMemory( stream,
(const FT_Byte*)args->memory_base,
args->memory_size );
}
else if ( args->flags & ft_open_pathname )
else if ( args->flags & FT_OPEN_PATHNAME )
{
/* create a normal system stream */
error = FT_Stream_Open( stream, args->pathname );
stream->pathname.pointer = args->pathname;
}
else if ( ( args->flags & ft_open_stream ) && args->stream )
else if ( ( args->flags & FT_OPEN_STREAM ) && args->stream )
{
/* use an existing, user-provided stream */
@@ -211,9 +211,14 @@
}
/* clear all public fields in the glyph slot */
FT_MEM_SET( &slot->metrics, 0, sizeof ( slot->metrics ) );
FT_MEM_SET( &slot->outline, 0, sizeof ( slot->outline ) );
FT_MEM_SET( &slot->bitmap, 0, sizeof ( slot->bitmap ) );
FT_ZERO( &slot->metrics );
FT_ZERO( &slot->outline );
slot->bitmap.width = 0;
slot->bitmap.rows = 0;
slot->bitmap.pitch = 0;
slot->bitmap.pixel_mode = 0;
/* don't touch 'slot->bitmap.buffer' !! */
slot->bitmap_left = 0;
slot->bitmap_top = 0;
@@ -222,7 +227,7 @@
slot->control_data = 0;
slot->control_len = 0;
slot->other = 0;
slot->format = ft_glyph_format_none;
slot->format = FT_GLYPH_FORMAT_NONE;
slot->linearHoriAdvance = 0;
slot->linearVertAdvance = 0;
@@ -380,6 +385,23 @@
}
/* documentation is in freetype.h */
FT_EXPORT_DEF( void )
FT_Set_Hint_Flags( FT_Face face,
FT_ULong flags )
{
FT_Face_Internal internal;
if ( !face )
return;
internal = face->internal;
internal->hint_flags = (FT_UInt)flags;
}
static FT_Renderer
ft_lookup_glyph_renderer( FT_GlyphSlot slot );
@@ -389,7 +411,7 @@
FT_EXPORT_DEF( FT_Error )
FT_Load_Glyph( FT_Face face,
FT_UInt glyph_index,
FT_Int load_flags )
FT_Int32 load_flags )
{
FT_Error error;
FT_Driver driver;
@@ -416,6 +438,7 @@
/* disable scaling, hinting, and transformation */
load_flags |= FT_LOAD_NO_SCALE |
FT_LOAD_NO_HINTING |
FT_LOAD_NO_BITMAP |
FT_LOAD_IGNORE_TRANSFORM;
/* disable bitmap rendering */
@@ -427,7 +450,9 @@
hinter = library->auto_hinter;
autohint =
FT_BOOL( hinter &&
!( load_flags & ( FT_LOAD_NO_SCALE | FT_LOAD_NO_HINTING ) ) &&
!( load_flags & ( FT_LOAD_NO_SCALE |
FT_LOAD_NO_HINTING |
FT_LOAD_NO_AUTOHINT ) ) &&
FT_DRIVER_IS_SCALABLE( driver ) &&
FT_DRIVER_USES_OUTLINES( driver ) );
if ( autohint )
@@ -447,13 +472,14 @@
/* XXX: This is really a temporary hack that should disappear */
/* promptly with FreeType 2.1! */
/* */
if ( FT_HAS_FIXED_SIZES( face ) )
if ( FT_HAS_FIXED_SIZES( face ) &&
( load_flags & FT_LOAD_NO_BITMAP ) == 0 )
{
error = driver->clazz->load_glyph( slot, face->size,
glyph_index,
load_flags | FT_LOAD_SBITS_ONLY );
if ( !error && slot->format == ft_glyph_format_bitmap )
if ( !error && slot->format == FT_GLYPH_FORMAT_BITMAP )
goto Load_Ok;
}
@@ -530,14 +556,18 @@
/* do we need to render the image now? */
if ( !error &&
slot->format != ft_glyph_format_bitmap &&
slot->format != ft_glyph_format_composite &&
slot->format != FT_GLYPH_FORMAT_BITMAP &&
slot->format != FT_GLYPH_FORMAT_COMPOSITE &&
load_flags & FT_LOAD_RENDER )
{
error = FT_Render_Glyph( slot,
( load_flags & FT_LOAD_MONOCHROME )
? ft_render_mode_mono
: ft_render_mode_normal );
FT_Render_Mode mode = FT_LOAD_TARGET_MODE( load_flags );
if ( mode == FT_RENDER_MODE_NORMAL &&
(load_flags & FT_LOAD_MONOCHROME ) )
mode = FT_RENDER_MODE_MONO;
error = FT_Render_Glyph( slot, mode );
}
Exit:
@@ -550,7 +580,7 @@
FT_EXPORT_DEF( FT_Error )
FT_Load_Char( FT_Face face,
FT_ULong char_code,
FT_Int load_flags )
FT_Int32 load_flags )
{
FT_UInt glyph_index;
@@ -614,8 +644,6 @@
if ( face->generic.finalizer )
face->generic.finalizer( face );
#ifdef FT_CONFIG_OPTION_USE_CMAPS
/* discard charmaps */
{
FT_Int n;
@@ -635,8 +663,6 @@
face->num_charmaps = 0;
}
#endif /* FT_CONFIG_OPTION_USE_CMAPS */
/* finalize format-specific stuff */
if ( clazz->done_face )
@@ -712,14 +738,48 @@
face->memory = memory;
face->stream = stream;
#ifdef FT_CONFIG_OPTION_INCREMENTAL
{
int i;
face->internal->incremental_interface = 0;
for ( i = 0; i < num_params && !face->internal->incremental_interface;
i++ )
if ( params[i].tag == FT_PARAM_TAG_INCREMENTAL )
face->internal->incremental_interface = params[i].data;
}
#endif
error = clazz->init_face( stream,
face,
face_index,
(FT_Int)face_index,
num_params,
params );
if ( error )
goto Fail;
/* select Unicode charmap by default */
{
FT_Int nn;
FT_CharMap unicmap = NULL, cmap;
for ( nn = 0; nn < face->num_charmaps; nn++ )
{
cmap = face->charmaps[nn];
if ( cmap->encoding == FT_ENCODING_UNICODE )
{
unicmap = cmap;
break;
}
}
if ( unicmap != NULL )
face->charmap = unicmap;
}
*aface = face;
Fail:
@@ -755,7 +815,7 @@
if ( !pathname )
return FT_Err_Invalid_Argument;
args.flags = ft_open_pathname;
args.flags = FT_OPEN_PATHNAME;
args.pathname = (char*)pathname;
return FT_Open_Face( library, &args, face_index, aface );
@@ -780,7 +840,7 @@
if ( !file_base )
return FT_Err_Invalid_Argument;
args.flags = ft_open_memory;
args.flags = FT_OPEN_MEMORY;
args.memory_base = file_base;
args.memory_size = file_size;
@@ -792,7 +852,7 @@
FT_EXPORT_DEF( FT_Error )
FT_Open_Face( FT_Library library,
FT_Open_Args* args,
const FT_Open_Args* args,
FT_Long face_index,
FT_Face *aface )
{
@@ -813,7 +873,7 @@
*aface = 0;
external_stream = FT_BOOL( ( args->flags & ft_open_stream ) &&
external_stream = FT_BOOL( ( args->flags & FT_OPEN_STREAM ) &&
args->stream );
/* create input stream */
@@ -825,7 +885,7 @@
/* If the font driver is specified in the `args' structure, use */
/* it. Otherwise, we scan the list of registered drivers. */
if ( ( args->flags & ft_open_driver ) && args->driver )
if ( ( args->flags & FT_OPEN_DRIVER ) && args->driver )
{
driver = FT_DRIVER( args->driver );
@@ -836,7 +896,7 @@
FT_Parameter* params = 0;
if ( args->flags & ft_open_params )
if ( args->flags & FT_OPEN_PARAMS )
{
num_params = args->num_params;
params = args->params;
@@ -871,7 +931,7 @@
driver = FT_DRIVER( cur[0] );
if ( args->flags & ft_open_params )
if ( args->flags & FT_OPEN_PARAMS )
{
num_params = args->num_params;
params = args->params;
@@ -980,7 +1040,7 @@
if ( !filepathname )
return FT_Err_Invalid_Argument;
open.flags = ft_open_pathname;
open.flags = FT_OPEN_PATHNAME;
open.pathname = (char*)filepathname;
return FT_Attach_Stream( face, &open );
@@ -1024,7 +1084,7 @@
/* close the attached stream */
ft_input_stream_free( stream,
(FT_Bool)( parameters->stream &&
( parameters->flags & ft_open_stream ) ) );
( parameters->flags & FT_OPEN_STREAM ) ) );
Exit:
return error;
@@ -1350,12 +1410,12 @@
akerning );
if ( !error )
{
if ( kern_mode != ft_kerning_unscaled )
if ( kern_mode != FT_KERNING_UNSCALED )
{
akerning->x = FT_MulFix( akerning->x, face->size->metrics.x_scale );
akerning->y = FT_MulFix( akerning->y, face->size->metrics.y_scale );
if ( kern_mode != ft_kerning_unfitted )
if ( kern_mode != FT_KERNING_UNFITTED )
{
akerning->x = ( akerning->x + 32 ) & -64;
akerning->y = ( akerning->y + 32 ) & -64;
@@ -1503,8 +1563,6 @@
/* documentation is in freetype.h */
#ifdef FT_CONFIG_OPTION_USE_CMAPS
FT_EXPORT_DEF( FT_UInt )
FT_Get_Char_Index( FT_Face face,
FT_ULong charcode )
@@ -1522,25 +1580,6 @@
return result;
}
#else /* !FT_CONFIG_OPTION_USE_CMAPS */
FT_EXPORT_DEF( FT_UInt )
FT_Get_Char_Index( FT_Face face,
FT_ULong charcode )
{
FT_UInt result = 0;
FT_Driver driver;
if ( face && face->charmap )
{
driver = face->driver;
result = driver->clazz->get_char_index( face->charmap, charcode );
}
return result;
}
#endif /* !FT_CONFIG_OPTION_USE_CMAPS */
/* documentation is in freetype.h */
@@ -1569,8 +1608,6 @@
/* documentation is in freetype.h */
#ifdef FT_CONFIG_OPTION_USE_CMAPS
FT_EXPORT_DEF( FT_ULong )
FT_Get_Next_Char( FT_Face face,
FT_ULong charcode,
@@ -1596,37 +1633,6 @@
return result;
}
#else /* !FT_CONFIG_OPTION_USE_CMAPS */
FT_EXPORT_DEF( FT_ULong )
FT_Get_Next_Char( FT_Face face,
FT_ULong charcode,
FT_UInt *agindex )
{
FT_ULong result = 0;
FT_UInt gindex = 0;
FT_Driver driver;
if ( face && face->charmap )
{
driver = face->driver;
result = driver->clazz->get_next_char( face->charmap, charcode );
if ( result != 0 )
{
gindex = driver->clazz->get_char_index( face->charmap, result );
if ( gindex == 0 )
result = 0;
}
}
if ( agindex )
*agindex = gindex;
return result;
}
#endif /* !FT_CONFIG_OPTION_USE_CMAPS */
/* documentation is in freetype.h */
@@ -1858,7 +1864,7 @@
FT_Renderer renderer;
renderer = FT_Lookup_Renderer( library, ft_glyph_format_outline, 0 );
renderer = FT_Lookup_Renderer( library, FT_GLYPH_FORMAT_OUTLINE, 0 );
library->cur_renderer = renderer;
}
@@ -1884,7 +1890,7 @@
render->glyph_format = clazz->glyph_format;
/* allocate raster object if needed */
if ( clazz->glyph_format == ft_glyph_format_outline &&
if ( clazz->glyph_format == FT_GLYPH_FORMAT_OUTLINE &&
clazz->raster_class->raster_new )
{
error = clazz->raster_class->raster_new( memory, &render->raster );
@@ -1977,12 +1983,12 @@
FT_List_Up( &library->renderers, node );
if ( renderer->glyph_format == ft_glyph_format_outline )
if ( renderer->glyph_format == FT_GLYPH_FORMAT_OUTLINE )
library->cur_renderer = renderer;
if ( num_params > 0 )
{
FTRenderer_setMode set_mode = renderer->clazz->set_mode;
FT_Renderer_SetModeFunc set_mode = renderer->clazz->set_mode;
for ( ; num_params > 0; num_params-- )
@@ -2001,7 +2007,7 @@
FT_BASE_DEF( FT_Error )
FT_Render_Glyph_Internal( FT_Library library,
FT_GlyphSlot slot,
FT_UInt render_mode )
FT_Render_Mode render_mode )
{
FT_Error error = FT_Err_Ok;
FT_Renderer renderer;
@@ -2010,7 +2016,7 @@
/* if it is already a bitmap, no need to do anything */
switch ( slot->format )
{
case ft_glyph_format_bitmap: /* already a bitmap, don't do anything */
case FT_GLYPH_FORMAT_BITMAP: /* already a bitmap, don't do anything */
break;
default:
@@ -2020,7 +2026,7 @@
/* small shortcut for the very common case */
if ( slot->format == ft_glyph_format_outline )
if ( slot->format == FT_GLYPH_FORMAT_OUTLINE )
{
renderer = library->cur_renderer;
node = library->renderers.head;
@@ -2061,7 +2067,7 @@
FT_EXPORT_DEF( FT_Error )
FT_Render_Glyph( FT_GlyphSlot slot,
FT_UInt render_mode )
FT_Render_Mode render_mode )
{
FT_Library library;
@@ -2422,13 +2428,13 @@
patch = library->version_patch;
}
if ( *amajor )
if ( amajor )
*amajor = major;
if ( *aminor )
if ( aminor )
*aminor = minor;
if ( *apatch )
if ( apatch )
*apatch = patch;
}
+24 -22
View File
@@ -98,14 +98,14 @@
tag = FT_CURVE_TAG( tags[0] );
/* A contour cannot start with a cubic control point! */
if ( tag == FT_Curve_Tag_Cubic )
if ( tag == FT_CURVE_TAG_CUBIC )
goto Invalid_Outline;
/* check first point to determine origin */
if ( tag == FT_Curve_Tag_Conic )
if ( tag == FT_CURVE_TAG_CONIC )
{
/* first point is conic control. Yes, this happens. */
if ( FT_CURVE_TAG( outline->tags[last] ) == FT_Curve_Tag_On )
if ( FT_CURVE_TAG( outline->tags[last] ) == FT_CURVE_TAG_ON )
{
/* start at last point if it is on the curve */
v_start = v_last;
@@ -137,7 +137,7 @@
tag = FT_CURVE_TAG( tags[0] );
switch ( tag )
{
case FT_Curve_Tag_On: /* emit a single line_to */
case FT_CURVE_TAG_ON: /* emit a single line_to */
{
FT_Vector vec;
@@ -151,7 +151,7 @@
continue;
}
case FT_Curve_Tag_Conic: /* consume conic arcs */
case FT_CURVE_TAG_CONIC: /* consume conic arcs */
v_control.x = SCALED( point->x );
v_control.y = SCALED( point->y );
@@ -169,7 +169,7 @@
vec.x = SCALED( point->x );
vec.y = SCALED( point->y );
if ( tag == FT_Curve_Tag_On )
if ( tag == FT_CURVE_TAG_ON )
{
error = func_interface->conic_to( &v_control, &vec, user );
if ( error )
@@ -177,7 +177,7 @@
continue;
}
if ( tag != FT_Curve_Tag_Conic )
if ( tag != FT_CURVE_TAG_CONIC )
goto Invalid_Outline;
v_middle.x = ( v_control.x + vec.x ) / 2;
@@ -194,13 +194,13 @@
error = func_interface->conic_to( &v_control, &v_start, user );
goto Close;
default: /* FT_Curve_Tag_Cubic */
default: /* FT_CURVE_TAG_CUBIC */
{
FT_Vector vec1, vec2;
if ( point + 1 > limit ||
FT_CURVE_TAG( tags[1] ) != FT_Curve_Tag_Cubic )
FT_CURVE_TAG( tags[1] ) != FT_CURVE_TAG_CUBIC )
goto Invalid_Outline;
point += 2;
@@ -270,12 +270,12 @@
anoutline->n_points = (FT_UShort)numPoints;
anoutline->n_contours = (FT_Short)numContours;
anoutline->flags |= ft_outline_owner;
anoutline->flags |= FT_OUTLINE_OWNER;
return FT_Err_Ok;
Fail:
anoutline->flags |= ft_outline_owner;
anoutline->flags |= FT_OUTLINE_OWNER;
FT_Outline_Done_Internal( memory, anoutline );
return error;
@@ -334,7 +334,7 @@
if ( end != n_points - 1 )
goto Bad;
/* XXX: check the that array */
/* XXX: check the tags array */
return 0;
}
@@ -366,11 +366,11 @@
FT_MEM_COPY( target->contours, source->contours,
source->n_contours * sizeof ( FT_Short ) );
/* copy all flags, except the `ft_outline_owner' one */
is_owner = target->flags & ft_outline_owner;
/* copy all flags, except the `FT_OUTLINE_OWNER' one */
is_owner = target->flags & FT_OUTLINE_OWNER;
target->flags = source->flags;
target->flags &= ~ft_outline_owner;
target->flags &= ~FT_OUTLINE_OWNER;
target->flags |= is_owner;
return FT_Err_Ok;
@@ -383,7 +383,7 @@
{
if ( outline )
{
if ( outline->flags & ft_outline_owner )
if ( outline->flags & FT_OUTLINE_OWNER )
{
FT_FREE( outline->points );
FT_FREE( outline->tags );
@@ -535,7 +535,7 @@
first = last + 1;
}
outline->flags ^= ft_outline_reverse_fill;
outline->flags ^= FT_OUTLINE_REVERSE_FILL;
}
@@ -576,7 +576,7 @@
/* now, look for another renderer that supports the same */
/* format */
renderer = FT_Lookup_Renderer( library, ft_glyph_format_outline,
renderer = FT_Lookup_Renderer( library, FT_GLYPH_FORMAT_OUTLINE,
&node );
update = 1;
}
@@ -608,8 +608,10 @@
params.target = abitmap;
params.flags = 0;
if ( abitmap->pixel_mode == ft_pixel_mode_grays )
params.flags |= ft_raster_flag_aa;
if ( abitmap->pixel_mode == FT_PIXEL_MODE_GRAY ||
abitmap->pixel_mode == FT_PIXEL_MODE_LCD ||
abitmap->pixel_mode == FT_PIXEL_MODE_LCD_V )
params.flags |= FT_RASTER_FLAG_AA;
return FT_Outline_Render( library, outline, &params );
}
@@ -628,9 +630,9 @@
return;
xz = FT_MulFix( vector->x, matrix->xx ) +
FT_MulFix( vector->y, matrix->yx );
FT_MulFix( vector->y, matrix->xy );
yz = FT_MulFix( vector->x, matrix->xy ) +
yz = FT_MulFix( vector->x, matrix->yx ) +
FT_MulFix( vector->y, matrix->yy );
vector->x = xz;
+53 -166
View File
@@ -20,6 +20,7 @@
#include FT_INTERNAL_OBJECTS_H
#include FT_INTERNAL_CALC_H
#include FT_OUTLINE_H
#include FT_TRIGONOMETRY_H
#include FT_SYNTHESIS_H
@@ -34,18 +35,18 @@
/*************************************************************************/
/*************************************************************************/
FT_EXPORT_DEF( FT_Error )
FT_Outline_Oblique( FT_GlyphSlot original,
FT_Outline* outline,
FT_Pos* advance )
FT_EXPORT_DEF( void )
FT_GlyphSlot_Oblique( FT_GlyphSlot slot )
{
FT_Matrix transform;
FT_Outline* outline = &slot->outline;
/* only oblique outline glyphs */
if ( slot->format != FT_GLYPH_FORMAT_OUTLINE )
return;
FT_UNUSED( original );
/* we don't touch the advance width */
FT_UNUSED( advance );
/* For italic, simply apply a shear transform, with an angle */
/* of about 12 degrees. */
@@ -57,8 +58,6 @@
transform.yy = 0x10000L;
FT_Outline_Transform( outline, &transform );
return 0;
}
@@ -71,97 +70,6 @@
/*************************************************************************/
/* Compute the norm of a vector */
#ifdef FT_CONFIG_OPTION_OLD_CALCS
static FT_Pos
ft_norm( FT_Vector* vec )
{
FT_Int64 t1, t2;
MUL_64( vec->x, vec->x, t1 );
MUL_64( vec->y, vec->y, t2 );
ADD_64( t1, t2, t1 );
return (FT_Pos)SQRT_64( t1 );
}
#else /* FT_CONFIG_OPTION_OLD_CALCS */
static FT_Pos
ft_norm( FT_Vector* vec )
{
FT_F26Dot6 u, v, d;
FT_Int shift;
FT_ULong H, L, L2, hi, lo, med;
u = vec->x; if ( u < 0 ) u = -u;
v = vec->y; if ( v < 0 ) v = -v;
if ( u < v )
{
d = u;
u = v;
v = d;
}
/* check that we are not trying to normalize zero! */
if ( u == 0 )
return 0;
/* compute (u*u + v*v) on 64 bits with two 32-bit registers [H:L] */
hi = (FT_ULong)u >> 16;
lo = (FT_ULong)u & 0xFFFF;
med = hi * lo;
H = hi * hi + ( med >> 15 );
med <<= 17;
L = lo * lo + med;
if ( L < med )
H++;
hi = (FT_ULong)v >> 16;
lo = (FT_ULong)v & 0xFFFF;
med = hi * lo;
H += hi * hi + ( med >> 15 );
med <<= 17;
L2 = lo * lo + med;
if ( L2 < med )
H++;
L += L2;
if ( L < L2 )
H++;
/* if the value is smaller than 32 bits */
shift = 0;
if ( H == 0 )
{
while ( ( L & 0xC0000000UL ) == 0 )
{
L <<= 2;
shift++;
}
return ( FT_Sqrt32( L ) >> shift );
}
else
{
while ( H )
{
L = ( L >> 2 ) | ( H << 30 );
H >>= 2;
shift++;
}
return ( FT_Sqrt32( L ) << shift );
}
}
#endif /* FT_CONFIG_OPTION_OLD_CALCS */
static int
ft_test_extrema( FT_Outline* outline,
@@ -208,7 +116,7 @@
/* Compute the orientation of path filling. It differs between TrueType */
/* and Type1 formats. We could use the `ft_outline_reverse_fill' flag, */
/* and Type1 formats. We could use the `FT_OUTLINE_REVERSE_FILL' flag, */
/* but it is better to re-compute it directly (it seems that this flag */
/* isn't correctly set for some weird composite glyphs currently). */
/* */
@@ -291,28 +199,30 @@
}
FT_EXPORT_DEF( FT_Error )
FT_Outline_Embolden( FT_GlyphSlot original,
FT_Outline* outline,
FT_Pos* advance )
FT_EXPORT_DEF( void )
FT_GlyphSlot_Embolden( FT_GlyphSlot slot )
{
FT_Vector u, v;
FT_Vector* points;
FT_Vector cur, prev, next;
FT_Vector v_prev, v_first, v_next, v_cur;
FT_Pos distance;
FT_Face face = FT_SLOT_FACE( original );
int c, n, first, orientation;
FT_Outline* outline = &slot->outline;
FT_Face face = FT_SLOT_FACE( slot );
FT_Angle rotate, angle_in, angle_out;
FT_Int c, n, first, orientation;
FT_UNUSED( advance );
/* only embolden outline glyph images */
if ( slot->format != FT_GLYPH_FORMAT_OUTLINE )
return;
/* compute control distance */
distance = FT_MulFix( face->units_per_EM / 60,
face->size->metrics.y_scale );
orientation = ft_get_orientation( &original->outline );
orientation = ft_get_orientation( outline );
rotate = FT_ANGLE_PI2*orientation;
points = original->outline.points;
points = outline->points;
first = 0;
for ( c = 0; c < outline->n_contours; c++ )
@@ -320,79 +230,56 @@
int last = outline->contours[c];
prev = points[last];
v_first = points[first];
v_prev = points[last];
v_cur = v_first;
for ( n = first; n <= last; n++ )
{
FT_Pos norm, delta, d;
FT_Pos d;
FT_Vector in, out;
FT_Fixed scale;
FT_Angle angle_diff;
cur = points[n];
if ( n < last ) next = points[n + 1];
else next = points[first];
if ( n < last ) v_next = points[n + 1];
else v_next = v_first;
/* compute the in and out vectors */
in.x = cur.x - prev.x;
in.y = cur.y - prev.y;
in.x = v_cur.x - v_prev.x;
in.y = v_cur.y - v_prev.y;
out.x = next.x - cur.x;
out.y = next.y - cur.y;
out.x = v_next.x - v_cur.x;
out.y = v_next.y - v_cur.y;
/* compute U and V */
norm = ft_norm( &in );
u.x = orientation * FT_DivFix( in.y, norm );
u.y = orientation * -FT_DivFix( in.x, norm );
angle_in = FT_Atan2( in.x, in.y );
angle_out = FT_Atan2( out.x, out.y );
angle_diff = FT_Angle_Diff( angle_in, angle_out );
scale = FT_Cos( angle_diff/2 );
norm = ft_norm( &out );
v.x = orientation * FT_DivFix( out.y, norm );
v.y = orientation * -FT_DivFix( out.x, norm );
d = distance;
if ( ( outline->tags[n] & FT_Curve_Tag_On ) == 0 )
d *= 2;
/* Check discriminant for parallel vectors */
delta = FT_MulFix( u.x, v.y ) - FT_MulFix( u.y, v.x );
if ( delta > FT_BOLD_THRESHOLD || delta < -FT_BOLD_THRESHOLD )
if ( scale < 0x400L && scale > -0x400L )
{
/* Move point -- compute A and B */
FT_Pos x, y, A, B;
A = d + FT_MulFix( cur.x, u.x ) + FT_MulFix( cur.y, u.y );
B = d + FT_MulFix( cur.x, v.x ) + FT_MulFix( cur.y, v.y );
x = FT_MulFix( A, v.y ) - FT_MulFix( B, u.y );
y = FT_MulFix( B, u.x ) - FT_MulFix( A, v.x );
outline->points[n].x = distance + FT_DivFix( x, delta );
outline->points[n].y = distance + FT_DivFix( y, delta );
}
if ( scale >= 0 )
scale = 0x400L;
else
{
/* Vectors are nearly parallel */
FT_Pos x, y;
x = distance + cur.x + FT_MulFix( d, u.x + v.x ) / 2;
y = distance + cur.y + FT_MulFix( d, u.y + v.y ) / 2;
outline->points[n].x = x;
outline->points[n].y = y;
scale = -0x400L;
}
prev = cur;
d = FT_DivFix( distance, scale );
FT_Vector_From_Polar( &in, d, angle_in + angle_diff/2 - rotate );
outline->points[n].x = v_cur.x + distance + in.x;
outline->points[n].y = v_cur.y + distance + in.y;
v_prev = v_cur;
v_cur = v_next;
}
first = last + 1;
}
if ( advance )
*advance = ( *advance + distance * 4 ) & -64;
return 0;
slot->metrics.horiAdvance = ( slot->metrics.horiAdvance + distance*4 ) & -64;
}
+31
View File
@@ -451,4 +451,35 @@
}
/* documentation is in fttrigon.h */
FT_EXPORT_DEF( void )
FT_Vector_From_Polar( FT_Vector* vec,
FT_Fixed length,
FT_Angle angle )
{
vec->x = length;
vec->y = 0;
FT_Vector_Rotate( vec, angle );
}
/* documentation is in fttrigon.h */
FT_EXPORT_DEF( FT_Angle )
FT_Angle_Diff( FT_Angle angle1,
FT_Angle angle2 )
{
FT_Angle delta = angle2 - angle1;
delta %= FT_ANGLE_2PI;
if ( delta > FT_ANGLE_PI )
delta -= FT_ANGLE_2PI;
return delta;
}
/* END */
+2 -2
View File
@@ -64,7 +64,7 @@
return FT_Err_Out_Of_Memory;
}
FT_MEM_SET( *P, 0, size );
FT_MEM_ZERO( *P, size );
}
else
*P = NULL;
@@ -106,7 +106,7 @@
goto Fail;
if ( size > current )
FT_MEM_SET( (char*)Q + current, 0, size - current );
FT_MEM_ZERO( (char*)Q + current, size - current );
*P = Q;
return FT_Err_Ok;
+1
View File
@@ -54,6 +54,7 @@ BASE_EXT_SRC := $(BASE_)ftglyph.c \
$(BASE_)ftbdf.c \
$(BASE_)fttype1.c \
$(BASE_)ftxf86.c \
$(BASE_)ftpfr.c \
$(BASE_)ftbbox.c
# Default extensions objects
+14 -94
View File
@@ -46,9 +46,6 @@ THE SOFTWARE.
#define FT_COMPONENT trace_bdfdriver
#ifdef FT_CONFIG_OPTION_USE_CMAPS
typedef struct BDF_CMapRec_
{
FT_CMapRec cmap;
@@ -171,39 +168,6 @@ THE SOFTWARE.
};
#else /* !FT_CONFIG_OPTION_USE_CMAPS */
static FT_UInt
BDF_Get_Char_Index( FT_CharMap charmap,
FT_ULong char_code )
{
BDF_Face face = (BDF_Face)charmap->face;
BDF_encoding_el* en_table = face->en_table;
int low, high, mid;
FT_TRACE4(( "BDF_Get_Char_Index %ld\n", char_code ));
low = 0;
high = face->bdffont->glyphs_used - 1;
while ( low <= high )
{
mid = ( low + high ) / 2;
if ( char_code < en_table[mid].enc )
high = mid - 1;
else if ( char_code > en_table[mid].enc )
low = mid + 1;
else
return en_table[mid].glyph + 1;
}
return face->bdffont->default_glyph + 1;
}
#endif /* !FT_CONFIG_OPTION_USE_CMAPS */
FT_CALLBACK_DEF( FT_Error )
@@ -344,11 +308,11 @@ THE SOFTWARE.
prop = bdf_get_font_property( font, (char *)"AVERAGE_WIDTH" );
if ( ( prop != NULL ) && ( prop->value.int32 >= 10 ) )
root->available_sizes->width = prop->value.int32 / 10;
root->available_sizes->width = (short)( prop->value.int32 / 10 );
prop = bdf_get_font_property( font, (char *)"PIXEL_SIZE" );
if ( prop != NULL )
root->available_sizes->height = prop->value.int32;
root->available_sizes->height = (short) prop->value.int32;
else
{
prop = bdf_get_font_property( font, (char *)"POINT_SIZE" );
@@ -429,63 +393,43 @@ THE SOFTWARE.
!ft_strcmp( face->charset_encoding, "1" ) ) )
unicode_charmap = 1;
#ifdef FT_CONFIG_OPTION_USE_CMAPS
{
FT_CharMapRec charmap;
charmap.face = FT_FACE( face );
charmap.encoding = ft_encoding_none;
charmap.encoding = FT_ENCODING_NONE;
charmap.platform_id = 0;
charmap.encoding_id = 0;
if ( unicode_charmap )
{
charmap.encoding = ft_encoding_unicode;
charmap.encoding = FT_ENCODING_UNICODE;
charmap.platform_id = 3;
charmap.encoding_id = 1;
}
error = FT_CMap_New( &bdf_cmap_class, NULL, &charmap, NULL );
#if 0
/* Select default charmap */
if (root->num_charmaps)
root->charmap = root->charmaps[0];
#endif
}
#else /* !FT_CONFIG_OPTION_USE_CMAPS */
face->charmap.encoding = ft_encoding_none;
face->charmap.platform_id = 0;
face->charmap.encoding_id = 0;
if ( unicode_charmap )
{
face->charmap.encoding = ft_encoding_unicode;
face->charmap.platform_id = 3;
face->charmap.encoding_id = 1;
}
face->charmap.face = root;
face->charmap_handle = &face->charmap;
root->charmap = face->charmap_handle;
#endif /* !FT_CONFIG_OPTION_USE_CMAPS */
goto Exit;
}
}
/* otherwise assume Adobe standard encoding */
#ifdef FT_CONFIG_OPTION_USE_CMAPS
{
FT_CharMapRec charmap;
charmap.face = FT_FACE( face );
charmap.encoding = ft_encoding_adobe_standard;
charmap.encoding = FT_ENCODING_ADOBE_STANDARD;
charmap.platform_id = 7;
charmap.encoding_id = 0;
@@ -495,19 +439,6 @@ THE SOFTWARE.
if (root->num_charmaps)
root->charmap = root->charmaps[0];
}
#else /* !FT_CONFIG_OPTION_USE_CMAPS */
face->charmap.encoding = ft_encoding_adobe_standard;
face->charmap.platform_id = 7; /* taken from t1objs.c */
face->charmap.encoding_id = 0;
face->charmap.face = root;
face->charmap_handle = &face->charmap;
root->charmap = face->charmap_handle;
#endif /* !FT_CONFIG_OPTION_USE_CMAPS */
}
}
@@ -547,7 +478,7 @@ THE SOFTWARE.
BDF_Glyph_Load( FT_GlyphSlot slot,
FT_Size size,
FT_UInt glyph_index,
FT_Int load_flags )
FT_Int32 load_flags )
{
BDF_Face face = (BDF_Face)FT_SIZE_FACE( size );
FT_Error error = BDF_Err_Ok;
@@ -579,7 +510,7 @@ THE SOFTWARE.
if ( bpp == 1 )
{
bitmap->pixel_mode = ft_pixel_mode_mono;
bitmap->pixel_mode = FT_PIXEL_MODE_MONO;
bitmap->pitch = glyph.bpr;
if ( FT_NEW_ARRAY( bitmap->buffer, glyph.bytes ) )
@@ -589,7 +520,7 @@ THE SOFTWARE.
else
{
/* blow up pixmap to have 8 bits per pixel */
bitmap->pixel_mode = ft_pixel_mode_grays;
bitmap->pixel_mode = FT_PIXEL_MODE_GRAY;
bitmap->pitch = bitmap->width;
if ( FT_NEW_ARRAY( bitmap->buffer, bitmap->rows * bitmap->pitch ) )
@@ -686,12 +617,13 @@ THE SOFTWARE.
/* FZ XXX: TODO: vertical metrics */
slot->metrics.horiAdvance = glyph.dwidth << 6;
slot->metrics.horiBearingX = glyph.bbx.x_offset << 6;
slot->metrics.horiBearingY = glyph.bbx.y_offset << 6;
slot->metrics.horiBearingY = ( glyph.bbx.y_offset +
glyph.bbx.height ) << 6;
slot->metrics.width = bitmap->width << 6;
slot->metrics.height = bitmap->rows << 6;
slot->linearHoriAdvance = (FT_Fixed)glyph.dwidth << 16;
slot->format = ft_glyph_format_bitmap;
slot->format = FT_GLYPH_FORMAT_BITMAP;
slot->flags = FT_GLYPH_OWN_BITMAP;
Exit:
@@ -733,21 +665,9 @@ THE SOFTWARE.
(FT_Slot_LoadFunc) BDF_Glyph_Load,
#ifdef FT_CONFIG_OPTION_USE_CMAPS
(FT_CharMap_CharIndexFunc)0,
#else
(FT_CharMap_CharIndexFunc)BDF_Get_Char_Index,
#endif
(FT_Face_GetKerningFunc) 0,
(FT_Face_AttachFunc) 0,
(FT_Face_GetAdvancesFunc) 0,
#ifdef FT_CONFIG_OPTION_USE_CMAPS
(FT_CharMap_CharNextFunc) 0
#else
(FT_CharMap_CharNextFunc) 0 /* BDF_Get_Next_Char */
#endif
(FT_Face_GetAdvancesFunc) 0
};
+63 -56
View File
@@ -224,7 +224,7 @@
if ( FT_NEW_ARRAY( ht->table, ht->size ) )
goto Exit;
FT_MEM_SET( ht->table, 0, sizeof ( hashnode ) * ht->size );
FT_MEM_ZERO( ht->table, sizeof ( hashnode ) * ht->size );
for ( i = 0, bp = obp; i < sz; i++, bp++ )
{
@@ -255,7 +255,7 @@
if ( FT_NEW_ARRAY( ht->table, sz ) )
goto Exit;
FT_MEM_SET( ht->table, 0, sizeof ( hashnode ) * sz );
FT_MEM_ZERO( ht->table, sizeof ( hashnode ) * sz );
Exit:
return error;
@@ -427,7 +427,7 @@
}
/* Prepare the separator bitmap. */
FT_MEM_SET( seps, 0, 32 );
FT_MEM_ZERO( seps, 32 );
/* If the very last character of the separator string is a plus, then */
/* set the `mult' flag to indicate that multiple separators should be */
@@ -993,7 +993,7 @@
}
p = font->user_props + font->nuser_props;
FT_MEM_SET( p, 0, sizeof ( bdf_property_t ) );
FT_MEM_ZERO( p, sizeof ( bdf_property_t ) );
n = (unsigned long)( ft_strlen( name ) + 1 );
if ( FT_NEW_ARRAY( p->name, n ) )
@@ -1341,7 +1341,7 @@
}
fp = font->props + font->props_size;
FT_MEM_SET( fp, 0, sizeof ( bdf_property_t ) );
FT_MEM_ZERO( fp, sizeof ( bdf_property_t ) );
font->props_size++;
}
@@ -1599,8 +1599,7 @@
font->glyphs_size,
font->glyphs_size + 64 ) )
goto Exit;
FT_MEM_SET( font->glyphs + font->glyphs_size,
0,
FT_MEM_ZERO( font->glyphs + font->glyphs_size,
sizeof ( bdf_glyph_t ) * 64 ); /* FZ inutile */
font->glyphs_size += 64;
}
@@ -2203,96 +2202,98 @@
bdf_font_t* *font )
{
unsigned long lineno;
_bdf_parse_t p;
_bdf_parse_t *p;
FT_Memory memory = NULL;
FT_Memory memory = extmemory;
FT_Error error = BDF_Err_Ok;
FT_MEM_SET( &p, 0, sizeof ( _bdf_parse_t ) );
if ( FT_ALLOC( p, sizeof ( _bdf_parse_t ) ) )
goto Exit;
p.opts = (bdf_options_t*)( ( opts != 0 ) ? opts : &_bdf_opts );
p.minlb = 32767;
p.memory = extmemory; /* only during font creation */
memory = NULL;
p->opts = (bdf_options_t*)( ( opts != 0 ) ? opts : &_bdf_opts );
p->minlb = 32767;
p->memory = extmemory; /* only during font creation */
error = _bdf_readstream( stream, _bdf_parse_start,
(void *)&p, &lineno );
(void *)p, &lineno );
if ( error )
goto Exit;
if ( p.font != 0 )
if ( p->font != 0 )
{
/* If the font is not proportional, set the font's monowidth */
/* field to the width of the font bounding box. */
memory = p.font->memory;
memory = p->font->memory;
if ( p.font->spacing != BDF_PROPORTIONAL )
p.font->monowidth = p.font->bbx.width;
if ( p->font->spacing != BDF_PROPORTIONAL )
p->font->monowidth = p->font->bbx.width;
/* If the number of glyphs loaded is not that of the original count, */
/* indicate the difference. */
if ( p.cnt != p.font->glyphs_used + p.font->unencoded_used )
if ( p->cnt != p->font->glyphs_used + p->font->unencoded_used )
{
FT_TRACE2(( "bdf_load_font: " ACMSG15, p.cnt,
p.font->glyphs_used + p.font->unencoded_used ));
p.font->modified = 1;
FT_TRACE2(( "bdf_load_font: " ACMSG15, p->cnt,
p->font->glyphs_used + p->font->unencoded_used ));
p->font->modified = 1;
}
/* Once the font has been loaded, adjust the overall font metrics if */
/* necessary. */
if ( p.opts->correct_metrics != 0 &&
( p.font->glyphs_used > 0 || p.font->unencoded_used > 0 ) )
if ( p->opts->correct_metrics != 0 &&
( p->font->glyphs_used > 0 || p->font->unencoded_used > 0 ) )
{
if ( p.maxrb - p.minlb != p.font->bbx.width )
if ( p->maxrb - p->minlb != p->font->bbx.width )
{
FT_TRACE2(( "bdf_load_font: " ACMSG3,
p.font->bbx.width, p.maxrb - p.minlb ));
p.font->bbx.width = (unsigned short)( p.maxrb - p.minlb );
p.font->modified = 1;
p->font->bbx.width, p->maxrb - p->minlb ));
p->font->bbx.width = (unsigned short)( p->maxrb - p->minlb );
p->font->modified = 1;
}
if ( p.font->bbx.x_offset != p.minlb )
if ( p->font->bbx.x_offset != p->minlb )
{
FT_TRACE2(( "bdf_load_font: " ACMSG4,
p.font->bbx.x_offset, p.minlb ));
p.font->bbx.x_offset = p.minlb;
p.font->modified = 1;
p->font->bbx.x_offset, p->minlb ));
p->font->bbx.x_offset = p->minlb;
p->font->modified = 1;
}
if ( p.font->bbx.ascent != p.maxas )
if ( p->font->bbx.ascent != p->maxas )
{
FT_TRACE2(( "bdf_load_font: " ACMSG5,
p.font->bbx.ascent, p.maxas ));
p.font->bbx.ascent = p.maxas;
p.font->modified = 1;
p->font->bbx.ascent, p->maxas ));
p->font->bbx.ascent = p->maxas;
p->font->modified = 1;
}
if ( p.font->bbx.descent != p.maxds )
if ( p->font->bbx.descent != p->maxds )
{
FT_TRACE2(( "bdf_load_font: " ACMSG6,
p.font->bbx.descent, p.maxds ));
p.font->bbx.descent = p.maxds;
p.font->bbx.y_offset = (short)( -p.maxds );
p.font->modified = 1;
p->font->bbx.descent, p->maxds ));
p->font->bbx.descent = p->maxds;
p->font->bbx.y_offset = (short)( -p->maxds );
p->font->modified = 1;
}
if ( p.maxas + p.maxds != p.font->bbx.height )
if ( p->maxas + p->maxds != p->font->bbx.height )
{
FT_TRACE2(( "bdf_load_font: " ACMSG7,
p.font->bbx.height, p.maxas + p.maxds ));
p.font->bbx.height = (unsigned short)( p.maxas + p.maxds );
p->font->bbx.height, p->maxas + p->maxds ));
p->font->bbx.height = (unsigned short)( p->maxas + p->maxds );
}
if ( p.flags & _BDF_SWIDTH_ADJ )
if ( p->flags & _BDF_SWIDTH_ADJ )
FT_TRACE2(( "bdf_load_font: " ACMSG8 ));
}
}
if ( p.flags & _BDF_START )
if ( p->flags & _BDF_START )
{
{
/* The ENDFONT field was never reached or did not exist. */
if ( !( p.flags & _BDF_GLYPHS ) )
if ( !( p->flags & _BDF_GLYPHS ) )
/* Error happened while parsing header. */
FT_ERROR(( "bdf_load_font: " ERRMSG2, lineno ));
else
@@ -2303,28 +2304,34 @@
/* Free up the list used during the parsing. */
if ( memory != NULL )
FT_FREE( p.list.field );
FT_FREE( p->list.field );
if ( p.font != 0 )
if ( p->font != 0 )
{
/* Make sure the comments are NULL terminated if they exist. */
memory = p.font->memory;
memory = p->font->memory;
if ( p.font->comments_len > 0 ) {
if ( FT_RENEW_ARRAY( p.font->comments,
p.font->comments_len,
p.font->comments_len + 1 ) )
if ( p->font->comments_len > 0 ) {
if ( FT_RENEW_ARRAY( p->font->comments,
p->font->comments_len,
p->font->comments_len + 1 ) )
goto Exit;
p.font->comments[p.font->comments_len] = 0;
p->font->comments[p->font->comments_len] = 0;
}
}
else if ( error == BDF_Err_Ok )
error = BDF_Err_Invalid_File_Format;
*font = p.font;
*font = p->font;
Exit:
if ( p )
{
memory = extmemory;
FT_FREE( p );
}
return error;
}
+16 -241
View File
@@ -24,8 +24,6 @@
#include "ftcerror.h"
#ifdef FTC_CACHE_USE_LINEAR_HASHING
#define FTC_HASH_MAX_LOAD 2
#define FTC_HASH_MIN_LOAD 1
#define FTC_HASH_SUB_LOAD ( FTC_HASH_MAX_LOAD - FTC_HASH_MIN_LOAD )
@@ -33,7 +31,6 @@
/* this one _must_ be a power of 2! */
#define FTC_HASH_INITIAL_SIZE 8
#endif /* FTC_CACHE_USE_LINEAR_HASHING */
/*************************************************************************/
/*************************************************************************/
@@ -155,8 +152,6 @@
}
#ifdef FTC_CACHE_USE_LINEAR_HASHING
/* remove a node from its cache's hash table */
static FT_Error
ftc_node_hash_unlink( FTC_Node node,
@@ -164,14 +159,14 @@
{
FT_Error error = 0;
FTC_Node *pnode;
FT_UInt index, num_buckets;
FT_UInt idx, num_buckets;
index = (FT_UInt)( node->hash & cache->mask );
if ( index < cache->p )
index = (FT_UInt)( node->hash & ( 2 * cache->mask + 1 ) );
idx = (FT_UInt)( node->hash & cache->mask );
if ( idx < cache->p )
idx = (FT_UInt)( node->hash & ( 2 * cache->mask + 1 ) );
pnode = cache->buckets + index;
pnode = cache->buckets + idx;
for (;;)
{
@@ -236,41 +231,7 @@
return error;
}
#else /* !FTC_CACHE_USE_LINEAR_HASHING */
/* remove a node from its cache's hash table */
static void
ftc_node_hash_unlink( FTC_Node node,
FTC_Cache cache )
{
FTC_Node *pnode = cache->buckets + ( node->hash % cache->size );
for (;;)
{
if ( *pnode == NULL )
{
FT_ERROR(( "FreeType.cache.hash_unlink: unknown node!\n" ));
return;
}
if ( *pnode == node )
{
*pnode = node->link;
node->link = NULL;
cache->nodes--;
return;
}
pnode = &(*pnode)->link;
}
}
#endif /* !FTC_CACHE_USE_LINEAR_HASHING */
#ifdef FTC_CACHE_USE_LINEAR_HASHING
/* add a node to the "top" of its cache's hash table */
static FT_Error
@@ -278,15 +239,15 @@
FTC_Cache cache )
{
FTC_Node *pnode;
FT_UInt index;
FT_UInt idx;
FT_Error error = 0;
index = (FT_UInt)( node->hash & cache->mask );
if ( index < cache->p )
index = (FT_UInt)( node->hash & (2 * cache->mask + 1 ) );
idx = (FT_UInt)( node->hash & cache->mask );
if ( idx < cache->p )
idx = (FT_UInt)( node->hash & (2 * cache->mask + 1 ) );
pnode = cache->buckets + index;
pnode = cache->buckets + idx;
node->link = *pnode;
*pnode = node;
@@ -345,23 +306,6 @@
return error;
}
#else /* !FTC_CACHE_USE_LINEAR_HASHING */
/* add a node to the "top" of its cache's hash table */
static void
ftc_node_hash_link( FTC_Node node,
FTC_Cache cache )
{
FTC_Node *pnode = cache->buckets + ( node->hash % cache->size );
node->link = *pnode;
*pnode = node;
cache->nodes++;
}
#endif /* !FTC_CACHE_USE_LINEAR_HASHING */
@@ -476,125 +420,6 @@
/*************************************************************************/
/*************************************************************************/
#ifdef FTC_CACHE_USE_LINEAR_HASHING
/* nothing */
#else /* !FTC_CACHE_USE_LINEAR_HASHING */
#define FTC_PRIMES_MIN 7
#define FTC_PRIMES_MAX 13845163
static const FT_UInt ftc_primes[] =
{
7,
11,
19,
37,
73,
109,
163,
251,
367,
557,
823,
1237,
1861,
2777,
4177,
6247,
9371,
14057,
21089,
31627,
47431,
71143,
106721,
160073,
240101,
360163,
540217,
810343,
1215497,
1823231,
2734867,
4102283,
6153409,
9230113,
13845163,
};
static FT_UFast
ftc_prime_closest( FT_UFast num )
{
FT_UInt i;
for ( i = 0; i < sizeof ( ftc_primes ) / sizeof ( ftc_primes[0] ); i++ )
if ( ftc_primes[i] > num )
return ftc_primes[i];
return FTC_PRIMES_MAX;
}
#define FTC_CACHE_RESIZE_TEST( c ) \
( (c)->nodes*3 < (c)->size || \
(c)->size*3 < (c)->nodes )
static void
ftc_cache_resize( FTC_Cache cache )
{
FT_UFast new_size;
new_size = ftc_prime_closest( cache->nodes );
if ( new_size != cache->size )
{
FT_Memory memory = cache->memory;
FT_Error error;
FTC_Node* new_buckets ;
FT_ULong i;
/* no need to report an error; we'll simply keep using the same */
/* buckets number / size */
if ( FT_NEW_ARRAY( new_buckets, new_size ) )
return;
for ( i = 0; i < cache->size; i++ )
{
FTC_Node node, next, *pnode;
FT_UFast hash;
node = cache->buckets[i];
while ( node )
{
next = node->link;
hash = node->hash % new_size;
pnode = new_buckets + hash;
node->link = pnode[0];
pnode[0] = node;
node = next;
}
}
if ( cache->buckets )
FT_FREE( cache->buckets );
cache->buckets = new_buckets;
cache->size = new_size;
FT_UNUSED( error );
}
}
#endif /* !FTC_CACHE_USE_LINEAR_HASHING */
FT_EXPORT_DEF( FT_Error )
@@ -605,8 +430,6 @@
FT_Error error;
#ifdef FTC_CACHE_USE_LINEAR_HASHING
cache->p = 0;
cache->mask = FTC_HASH_INITIAL_SIZE - 1;
cache->slack = FTC_HASH_INITIAL_SIZE * FTC_HASH_MAX_LOAD;
@@ -614,16 +437,6 @@
if ( FT_NEW_ARRAY( cache->buckets, FTC_HASH_INITIAL_SIZE * 2 ) )
goto Exit;
#else /* !FTC_CACHE_USE_LINEAR_HASHING */
cache->nodes = 0;
cache->size = FTC_PRIMES_MIN;
if ( FT_NEW_ARRAY( cache->buckets, cache->size ) )
goto Exit;
#endif /* !FTC_CACHE_USE_LINEAR_HASHING */
/* now, initialize the lru list of families for this cache */
if ( clazz->family_size > 0 )
{
@@ -665,11 +478,7 @@
FT_UFast i;
FT_UInt count;
#ifdef FTC_CACHE_USE_LINEAR_HASHING
count = cache->p + cache->mask + 1;
#else
count = cache->size;
#endif
for ( i = 0; i < count; i++ )
{
@@ -696,11 +505,8 @@
cache->buckets[i] = NULL;
}
#ifdef FTC_CACHE_USE_LINEAR_HASHING
cache->p = 0;
#else
cache->nodes = 0;
#endif
/* destroy the families */
if ( cache->families )
FT_LruList_Reset( cache->families );
@@ -719,12 +525,8 @@
ftc_cache_clear( cache );
FT_FREE( cache->buckets );
#ifdef FTC_CACHE_USE_LINEAR_HASHING
cache->mask = 0;
cache->slack = 0;
#else
cache->size = 0;
#endif
if ( cache->families )
{
@@ -755,8 +557,6 @@
query->hash = 0;
query->family = NULL;
#if 1
/* XXX: we break encapsulation for the sake of speed! */
{
/* first of all, find the relevant family */
@@ -799,33 +599,18 @@
;
}
#else
error = FT_LruList_Lookup( cache->families, query, &lru );
if ( !error )
#endif
{
FTC_Family family = (FTC_Family) lru;
FT_UFast hash = query->hash;
FTC_Node* bucket;
#ifdef FTC_CACHE_USE_LINEAR_HASHING
FT_UInt index;
FT_UInt idx;
index = hash & cache->mask;
if ( index < cache->p )
index = hash & ( cache->mask * 2 + 1 );
idx = hash & cache->mask;
if ( idx < cache->p )
idx = hash & ( cache->mask * 2 + 1 );
bucket = cache->buckets + index;
#else
bucket = cache->buckets + (hash % cache->size);
#endif
bucket = cache->buckets + idx;
if ( query->family != family ||
@@ -897,7 +682,6 @@
goto Exit;
}
#ifdef FTC_CACHE_USE_LINEAR_HASHING
error = ftc_node_hash_link( node, cache );
if ( error )
{
@@ -905,9 +689,6 @@
FT_FREE( node );
goto Exit;
}
#else
ftc_node_hash_link( node, cache );
#endif
ftc_node_mru_link( node, cache->manager );
@@ -921,12 +702,6 @@
node->ref_count--;
}
#ifndef FTC_CACHE_USE_LINEAR_HASHING
/* try to resize the hash table if appropriate */
if ( FTC_CACHE_RESIZE_TEST( cache ) )
ftc_cache_resize( cache );
#endif
*anode = node;
}
}
+5 -19
View File
@@ -78,30 +78,16 @@
family = (FTC_Family)lru;
hash = query->hash;
#ifdef FTC_CACHE_USE_LINEAR_HASHING
{
FT_UInt index;
FT_UInt idx;
index = hash & cache->mask;
if ( index < cache->p )
index = hash & ( cache->mask * 2 + 1 );
idx = hash & cache->mask;
if ( idx < cache->p )
idx = hash & ( cache->mask * 2 + 1 );
bucket = cache->buckets + index;
bucket = cache->buckets + idx;
}
#else
bucket = cache->buckets + ( hash % cache->size );
#endif
#ifdef FT_DEBUG_LEVEL_ERROR
if ( query->family != family ||
family->fam_index >= cache->manager->families.size )
{
FT_ERROR((
"ftc_cache_lookup: invalid query (bad 'family' field)\n" ));
return FTC_Err_Invalid_Argument;
}
#endif
pnode = bucket;
+56 -45
View File
@@ -42,7 +42,7 @@
typedef struct FTC_ImageQueryRec_
{
FTC_GlyphQueryRec gquery;
FTC_ImageDesc desc;
FTC_ImageTypeRec type;
} FTC_ImageQueryRec, *FTC_ImageQuery;
@@ -54,7 +54,7 @@
typedef struct FTC_ImageFamilyRec_
{
FTC_GlyphFamilyRec gfam;
FTC_ImageDesc desc;
FTC_ImageTypeRec type;
} FTC_ImageFamilyRec, *FTC_ImageFamily;
@@ -106,45 +106,18 @@
/* we will now load the glyph image */
error = FTC_Manager_Lookup_Size( FTC_FAMILY( ifam )->cache->manager,
&ifam->desc.font,
&ifam->type.font,
&face, &size );
if ( !error )
{
FT_UInt gindex = FTC_GLYPH_NODE_GINDEX( inode );
FT_UInt load_flags = FT_LOAD_DEFAULT;
FT_UInt type = ifam->desc.type;
if ( FTC_IMAGE_FORMAT( type ) == ftc_image_format_bitmap )
{
load_flags |= FT_LOAD_RENDER;
if ( type & ftc_image_flag_monochrome )
load_flags |= FT_LOAD_MONOCHROME;
/* disable embedded bitmaps loading if necessary */
if ( type & ftc_image_flag_no_sbits )
load_flags |= FT_LOAD_NO_BITMAP;
}
else if ( FTC_IMAGE_FORMAT( type ) == ftc_image_format_outline )
{
/* disable embedded bitmaps loading */
load_flags |= FT_LOAD_NO_BITMAP;
if ( type & ftc_image_flag_unscaled )
load_flags |= FT_LOAD_NO_SCALE;
}
if ( type & ftc_image_flag_unhinted )
load_flags |= FT_LOAD_NO_HINTING;
if ( type & ftc_image_flag_autohinted )
load_flags |= FT_LOAD_FORCE_AUTOHINT;
error = FT_Load_Glyph( face, gindex, load_flags );
error = FT_Load_Glyph( face, gindex, ifam->type.flags );
if ( !error )
{
if ( face->glyph->format == ft_glyph_format_bitmap ||
face->glyph->format == ft_glyph_format_outline )
if ( face->glyph->format == FT_GLYPH_FORMAT_BITMAP ||
face->glyph->format == FT_GLYPH_FORMAT_OUTLINE )
{
/* ok, copy it */
FT_Glyph glyph;
@@ -179,7 +152,7 @@
switch ( glyph->format )
{
case ft_glyph_format_bitmap:
case FT_GLYPH_FORMAT_BITMAP:
{
FT_BitmapGlyph bitg;
@@ -190,7 +163,7 @@
}
break;
case ft_glyph_format_outline:
case FT_GLYPH_FORMAT_OUTLINE:
{
FT_OutlineGlyph outg;
@@ -231,16 +204,16 @@
FT_Face face;
ifam->desc = iquery->desc;
ifam->type = iquery->type;
/* we need to compute "iquery.item_total" now */
error = FTC_Manager_Lookup_Face( manager,
iquery->desc.font.face_id,
iquery->type.font.face_id,
&face );
if ( !error )
{
error = ftc_glyph_family_init( FTC_GLYPH_FAMILY( ifam ),
FTC_IMAGE_DESC_HASH( &ifam->desc ),
FTC_IMAGE_TYPE_HASH( &ifam->type ),
1,
face->num_glyphs,
FTC_GLYPH_QUERY( iquery ),
@@ -258,7 +231,7 @@
FT_Bool result;
result = FT_BOOL( FTC_IMAGE_DESC_COMPARE( &ifam->desc, &iquery->desc ) );
result = FT_BOOL( FTC_IMAGE_TYPE_COMPARE( &ifam->type, &iquery->type ) );
if ( result )
FTC_GLYPH_FAMILY_FOUND( ifam, iquery );
@@ -314,7 +287,7 @@
FT_EXPORT_DEF( FT_Error )
FTC_ImageCache_Lookup( FTC_ImageCache cache,
FTC_ImageDesc* desc,
FTC_ImageType type,
FT_UInt gindex,
FT_Glyph *aglyph,
FTC_Node *anode )
@@ -332,7 +305,7 @@
*anode = NULL;
iquery.gquery.gindex = gindex;
iquery.desc = *desc;
iquery.type = *type;
error = ftc_cache_lookup( FTC_CACHE( cache ),
FTC_QUERY( &iquery ),
@@ -368,17 +341,55 @@
FT_UInt gindex,
FT_Glyph *aglyph )
{
FTC_ImageDesc desc0;
FTC_ImageTypeRec type0;
if ( !desc )
return FTC_Err_Invalid_Argument;
desc0.font = desc->font;
desc0.type = (FT_UInt32)desc->image_type;
type0.font = desc->font;
/* convert image type flags to load flags */
{
FT_UInt load_flags = FT_LOAD_DEFAULT;
FT_UInt type = desc->image_type;
/* determine load flags, depending on the font description's */
/* image type */
if ( ftc_image_format( type ) == ftc_image_format_bitmap )
{
if ( type & ftc_image_flag_monochrome )
load_flags |= FT_LOAD_MONOCHROME;
/* disable embedded bitmaps loading if necessary */
if ( type & ftc_image_flag_no_sbits )
load_flags |= FT_LOAD_NO_BITMAP;
}
else
{
/* we want an outline, don't load embedded bitmaps */
load_flags |= FT_LOAD_NO_BITMAP;
if ( type & ftc_image_flag_unscaled )
load_flags |= FT_LOAD_NO_SCALE;
}
/* always render glyphs to bitmaps */
load_flags |= FT_LOAD_RENDER;
if ( type & ftc_image_flag_unhinted )
load_flags |= FT_LOAD_NO_HINTING;
if ( type & ftc_image_flag_autohinted )
load_flags |= FT_LOAD_FORCE_AUTOHINT;
type0.flags = load_flags;
}
return FTC_ImageCache_Lookup( (FTC_ImageCache)icache,
&desc0,
&type0,
gindex,
aglyph,
NULL );
+57 -56
View File
@@ -46,7 +46,7 @@
typedef struct FTC_SBitQueryRec_
{
FTC_GlyphQueryRec gquery;
FTC_ImageDesc desc;
FTC_ImageTypeRec type;
} FTC_SBitQueryRec, *FTC_SBitQuery;
@@ -60,7 +60,7 @@
typedef struct FTC_SBitFamilyRec_
{
FTC_GlyphFamilyRec gfam;
FTC_ImageDesc desc;
FTC_ImageTypeRec type;
} FTC_SBitFamilyRec;
@@ -142,48 +142,14 @@
sbit = snode->sbits + ( gindex - gnode->item_start );
error = FTC_Manager_Lookup_Size( manager, &sfam->desc.font,
error = FTC_Manager_Lookup_Size( manager, &sfam->type.font,
&face, &size );
if ( !error )
{
FT_UInt load_flags = FT_LOAD_DEFAULT;
FT_UInt type = sfam->desc.type;
/* determine load flags, depending on the font description's */
/* image type */
if ( FTC_IMAGE_FORMAT( type ) == ftc_image_format_bitmap )
{
if ( type & ftc_image_flag_monochrome )
load_flags |= FT_LOAD_MONOCHROME;
/* disable embedded bitmaps loading if necessary */
if ( type & ftc_image_flag_no_sbits )
load_flags |= FT_LOAD_NO_BITMAP;
}
else
{
FT_ERROR((
"ftc_sbit_node_load: cannot load scalable glyphs in an"
" sbit cache, please check your arguments!\n" ));
error = FTC_Err_Invalid_Argument;
goto Exit;
}
/* always render glyphs to bitmaps */
load_flags |= FT_LOAD_RENDER;
if ( type & ftc_image_flag_unhinted )
load_flags |= FT_LOAD_NO_HINTING;
if ( type & ftc_image_flag_autohinted )
load_flags |= FT_LOAD_FORCE_AUTOHINT;
/* by default, indicates a `missing' glyph */
sbit->buffer = 0;
error = FT_Load_Glyph( face, gindex, load_flags );
error = FT_Load_Glyph( face, gindex, sfam->type.flags | FT_LOAD_RENDER );
if ( !error )
{
FT_Int temp;
@@ -221,13 +187,9 @@
sbit->xadvance = (FT_Char)xadvance;
sbit->yadvance = (FT_Char)yadvance;
sbit->format = (FT_Byte)bitmap->pixel_mode;
/* XXX: Fixme: We don't handle the number of gray levels */
/* consistently -- we say num_grays == 1 for */
/* monochrome but num_grays == 256 for gray. It */
/* would be better to make this variable hold the */
/* highest possible value so that it fits into */
/* a single byte. */
sbit->num_grays = bitmap->num_grays;
sbit->max_grays = (FT_Byte)(bitmap->num_grays - 1);
#if 0 /* this doesn't work well with embedded bitmaps !! */
/* grab the bitmap when possible - this is a hack! */
if ( slot->flags & FT_GLYPH_OWN_BITMAP )
@@ -236,6 +198,7 @@
sbit->buffer = bitmap->buffer;
}
else
#endif
{
/* copy the bitmap into a new buffer -- ignore error */
error = ftc_sbit_copy_bitmap( sbit, bitmap, memory );
@@ -261,7 +224,6 @@
}
}
Exit:
return error;
}
@@ -380,16 +342,16 @@
FT_Face face;
sfam->desc = squery->desc;
sfam->type = squery->type;
/* we need to compute "cquery.item_total" now */
error = FTC_Manager_Lookup_Face( manager,
squery->desc.font.face_id,
squery->type.font.face_id,
&face );
if ( !error )
{
error = ftc_glyph_family_init( FTC_GLYPH_FAMILY( sfam ),
FTC_IMAGE_DESC_HASH( &sfam->desc ),
FTC_IMAGE_TYPE_HASH( &sfam->type ),
FTC_SBIT_ITEMS_PER_NODE,
face->num_glyphs,
FTC_GLYPH_QUERY( squery ),
@@ -410,7 +372,7 @@
/* we need to set the "cquery.cset" field or our query for */
/* faster glyph comparisons in ftc_sbit_node_compare */
/* */
result = FT_BOOL( FTC_IMAGE_DESC_COMPARE( &sfam->desc, &squery->desc ) );
result = FT_BOOL( FTC_IMAGE_TYPE_COMPARE( &sfam->type, &squery->type ) );
if ( result )
FTC_GLYPH_FAMILY_FOUND( sfam, squery );
@@ -481,7 +443,7 @@
FT_EXPORT_DEF( FT_Error )
FTC_SBitCache_Lookup( FTC_SBitCache cache,
FTC_ImageDesc* desc,
FTC_ImageType type,
FT_UInt gindex,
FTC_SBit *ansbit,
FTC_Node *anode )
@@ -501,7 +463,7 @@
*anode = NULL;
squery.gquery.gindex = gindex;
squery.desc = *desc;
squery.type = *type;
error = ftc_sbit_cache_lookup( FTC_CACHE( cache ),
FTC_QUERY( &squery ),
@@ -536,17 +498,56 @@
FT_UInt gindex,
FTC_SBit *ansbit )
{
FTC_ImageDesc desc0;
FTC_ImageTypeRec type0;
if ( !desc )
return FTC_Err_Invalid_Argument;
desc0.font = desc->font;
desc0.type = (FT_UInt32)desc->image_type;
type0.font = desc->font;
type0.flags = 0;
/* convert image type flags to load flags */
{
FT_UInt load_flags = FT_LOAD_DEFAULT;
FT_UInt type = desc->image_type;
/* determine load flags, depending on the font description's */
/* image type */
if ( ftc_image_format( type ) == ftc_image_format_bitmap )
{
if ( type & ftc_image_flag_monochrome )
load_flags |= FT_LOAD_MONOCHROME;
/* disable embedded bitmaps loading if necessary */
if ( type & ftc_image_flag_no_sbits )
load_flags |= FT_LOAD_NO_BITMAP;
}
else
{
/* we want an outline, don't load embedded bitmaps */
load_flags |= FT_LOAD_NO_BITMAP;
if ( type & ftc_image_flag_unscaled )
load_flags |= FT_LOAD_NO_SCALE;
}
/* always render glyphs to bitmaps */
load_flags |= FT_LOAD_RENDER;
if ( type & ftc_image_flag_unhinted )
load_flags |= FT_LOAD_NO_HINTING;
if ( type & ftc_image_flag_autohinted )
load_flags |= FT_LOAD_FORCE_AUTOHINT;
type0.flags = load_flags;
}
return FTC_SBitCache_Lookup( (FTC_SBitCache)cache,
&desc0,
&type0,
gindex,
ansbit,
NULL );
+1 -1
View File
@@ -24,6 +24,6 @@
#include "cffload.c"
#include "cffobjs.c"
#include "cffgload.c"
#include "cffcmap.c"
/* END */
+16 -107
View File
@@ -118,7 +118,7 @@
while ( left <= right )
{
FT_Int middle = left + ( ( right - left ) >> 1 );
FT_Long middle = left + ( ( right - left ) >> 1 );
FT_ULong cur_pair;
@@ -177,7 +177,7 @@
Load_Glyph( CFF_GlyphSlot slot,
CFF_Size size,
FT_UShort glyph_index,
FT_UInt load_flags )
FT_Int32 load_flags )
{
FT_Error error;
@@ -201,7 +201,7 @@
}
/* now load the glyph outline if necessary */
error = CFF_Load_Glyph( slot, size, glyph_index, load_flags );
error = cff_slot_load( slot, size, glyph_index, load_flags );
/* force drop-out mode to 2 - irrelevant now */
/* slot->outline.dropout_mode = 2; */
@@ -253,11 +253,11 @@
sid = font->charset.sids[glyph_index];
/* now, lookup the name itself */
gname = CFF_Get_String( &font->string_index, sid, psnames );
gname = cff_index_get_sid_string( &font->string_index, sid, psnames );
if ( buffer_max > 0 )
{
FT_UInt len = ft_strlen( gname );
FT_UInt len = (FT_UInt)ft_strlen( gname );
if ( len >= buffer_max )
@@ -275,94 +275,6 @@
}
/*************************************************************************/
/* */
/* <Function> */
/* cff_get_char_index */
/* */
/* <Description> */
/* Uses a charmap to return a given character code's glyph index. */
/* */
/* <Input> */
/* charmap :: A handle to the source charmap object. */
/* charcode :: The character code. */
/* */
/* <Return> */
/* Glyph index. 0 means `undefined character code'. */
/* */
static FT_UInt
cff_get_char_index( TT_CharMap charmap,
FT_Long charcode )
{
FT_Error error;
CFF_Face face;
TT_CMapTable cmap;
cmap = &charmap->cmap;
face = (CFF_Face)charmap->root.face;
/* Load table if needed */
if ( !cmap->loaded )
{
SFNT_Service sfnt = (SFNT_Service)face->sfnt;
error = sfnt->load_charmap( face, cmap, face->root.stream );
if ( error )
return 0;
cmap->loaded = TRUE;
}
return ( cmap->get_index ? cmap->get_index( cmap, charcode ) : 0 );
}
/*************************************************************************/
/* */
/* <Function> */
/* cff_get_next_char */
/* */
/* <Description> */
/* Uses a charmap to return the next encoded charcode. */
/* */
/* <Input> */
/* charmap :: A handle to the source charmap object. */
/* charcode :: The character code. */
/* */
/* <Return> */
/* Char code. 0 means `no encoded chars above the given one'. */
/* */
static FT_Long
cff_get_next_char( TT_CharMap charmap,
FT_Long charcode )
{
FT_Error error;
CFF_Face face;
TT_CMapTable cmap;
cmap = &charmap->cmap;
face = (CFF_Face)charmap->root.face;
/* Load table if needed */
if ( !cmap->loaded )
{
SFNT_Service sfnt = (SFNT_Service)face->sfnt;
error = sfnt->load_charmap( face, cmap, face->root.stream );
if ( error )
return 0;
cmap->loaded = TRUE;
}
return ( cmap->get_next_char ? cmap->get_next_char( cmap, charcode )
: 0 );
}
/*************************************************************************/
/* */
@@ -406,7 +318,7 @@
sid = charset->sids[i];
if ( sid > 390 )
name = CFF_Get_Name( &cff->string_index, sid - 391 );
name = cff_index_get_name( &cff->string_index, sid - 391 );
else
name = (FT_String *)psnames->adobe_std_strings( sid );
@@ -477,8 +389,8 @@
0, /* module-specific interface */
(FT_Module_Constructor)CFF_Driver_Init,
(FT_Module_Destructor) CFF_Driver_Done,
(FT_Module_Constructor)cff_driver_init,
(FT_Module_Destructor) cff_driver_done,
(FT_Module_Requester) cff_get_interface,
},
@@ -487,24 +399,21 @@
sizeof( FT_SizeRec ),
sizeof( CFF_GlyphSlotRec ),
(FT_Face_InitFunc) CFF_Face_Init,
(FT_Face_DoneFunc) CFF_Face_Done,
(FT_Size_InitFunc) CFF_Size_Init,
(FT_Size_DoneFunc) CFF_Size_Done,
(FT_Slot_InitFunc) CFF_GlyphSlot_Init,
(FT_Slot_DoneFunc) CFF_GlyphSlot_Done,
(FT_Face_InitFunc) cff_face_init,
(FT_Face_DoneFunc) cff_face_done,
(FT_Size_InitFunc) cff_size_init,
(FT_Size_DoneFunc) cff_size_done,
(FT_Slot_InitFunc) cff_slot_init,
(FT_Slot_DoneFunc) cff_slot_done,
(FT_Size_ResetPointsFunc) CFF_Size_Reset,
(FT_Size_ResetPixelsFunc) CFF_Size_Reset,
(FT_Size_ResetPointsFunc)cff_size_reset,
(FT_Size_ResetPixelsFunc)cff_size_reset,
(FT_Slot_LoadFunc) Load_Glyph,
(FT_CharMap_CharIndexFunc)cff_get_char_index,
(FT_Face_GetKerningFunc) Get_Kerning,
(FT_Face_AttachFunc) 0,
(FT_Face_GetAdvancesFunc)0,
(FT_CharMap_CharNextFunc) cff_get_next_char
};
+245 -129
View File
@@ -207,7 +207,7 @@
/*************************************************************************/
/* */
/* <Function> */
/* CFF_Builder_Init */
/* cff_builder_init */
/* */
/* <Description> */
/* Initializes a given glyph builder. */
@@ -223,7 +223,7 @@
/* glyph :: The current glyph object. */
/* */
static void
CFF_Builder_Init( CFF_Builder* builder,
cff_builder_init( CFF_Builder* builder,
TT_Face face,
CFF_Size size,
CFF_GlyphSlot glyph,
@@ -246,6 +246,7 @@
builder->current = &loader->current.outline;
FT_GlyphLoader_Rewind( loader );
builder->hint_flags = FT_FACE(face)->internal->hint_flags;
builder->hints_globals = 0;
builder->hints_funcs = 0;
@@ -275,7 +276,7 @@
/*************************************************************************/
/* */
/* <Function> */
/* CFF_Builder_Done */
/* cff_builder_done */
/* */
/* <Description> */
/* Finalizes a given glyph builder. Its contents can still be used */
@@ -286,7 +287,7 @@
/* builder :: A pointer to the glyph builder to finalize. */
/* */
static void
CFF_Builder_Done( CFF_Builder* builder )
cff_builder_done( CFF_Builder* builder )
{
CFF_GlyphSlot glyph = builder->glyph;
@@ -330,7 +331,7 @@
/*************************************************************************/
/* */
/* <Function> */
/* CFF_Init_Decoder */
/* cff_decoder_init */
/* */
/* <Description> */
/* Initializes a given glyph decoder. */
@@ -346,31 +347,34 @@
/* slot :: The current glyph object. */
/* */
FT_LOCAL_DEF( void )
CFF_Init_Decoder( CFF_Decoder* decoder,
cff_decoder_init( CFF_Decoder* decoder,
TT_Face face,
CFF_Size size,
CFF_GlyphSlot slot,
FT_Bool hinting )
FT_Bool hinting,
FT_Render_Mode hint_mode )
{
CFF_Font cff = (CFF_Font)face->extra.data;
/* clear everything */
FT_MEM_SET( decoder, 0, sizeof ( *decoder ) );
FT_MEM_ZERO( decoder, sizeof ( *decoder ) );
/* initialize builder */
CFF_Builder_Init( &decoder->builder, face, size, slot, hinting );
cff_builder_init( &decoder->builder, face, size, slot, hinting );
/* initialize Type2 decoder */
decoder->num_globals = cff->num_global_subrs;
decoder->globals = cff->global_subrs;
decoder->globals_bias = cff_compute_bias( decoder->num_globals );
decoder->hint_mode = hint_mode;
}
/* this function is used to select the locals subrs array */
FT_LOCAL_DEF( void )
CFF_Prepare_Decoder( CFF_Decoder* decoder,
cff_decoder_prepare( CFF_Decoder* decoder,
FT_UInt glyph_index )
{
CFF_Font cff = (CFF_Font)decoder->builder.face->extra.data;
@@ -380,7 +384,7 @@
/* manage CID fonts */
if ( cff->num_subfonts >= 1 )
{
FT_Byte fd_index = CFF_Get_FD( &cff->fd_select, glyph_index );
FT_Byte fd_index = cff_fd_select_get( &cff->fd_select, glyph_index );
sub = cff->subfonts[fd_index];
@@ -406,7 +410,7 @@
/* add a new point, do not check space */
static void
add_point( CFF_Builder* builder,
cff_builder_add_point( CFF_Builder* builder,
FT_Pos x,
FT_Pos y,
FT_Byte flag )
@@ -422,7 +426,7 @@
point->x = x >> 16;
point->y = y >> 16;
*control = (FT_Byte)( flag ? FT_Curve_Tag_On : FT_Curve_Tag_Cubic );
*control = (FT_Byte)( flag ? FT_CURVE_TAG_ON : FT_CURVE_TAG_CUBIC );
builder->last = *point;
}
@@ -433,7 +437,7 @@
/* check space for a new on-curve point, then add it */
static FT_Error
add_point1( CFF_Builder* builder,
cff_builder_add_point1( CFF_Builder* builder,
FT_Pos x,
FT_Pos y )
{
@@ -442,7 +446,7 @@
error = check_points( builder, 1 );
if ( !error )
add_point( builder, x, y, 1 );
cff_builder_add_point( builder, x, y, 1 );
return error;
}
@@ -450,7 +454,7 @@
/* check room for a new contour, then add it */
static FT_Error
add_contour( CFF_Builder* builder )
cff_builder_add_contour( CFF_Builder* builder )
{
FT_Outline* outline = builder->current;
FT_Error error;
@@ -478,7 +482,7 @@
/* if a path was begun, add its first on-curve point */
static FT_Error
start_point( CFF_Builder* builder,
cff_builder_start_point( CFF_Builder* builder,
FT_Pos x,
FT_Pos y )
{
@@ -489,9 +493,9 @@
if ( !builder->path_begun )
{
builder->path_begun = 1;
error = add_contour( builder );
error = cff_builder_add_contour( builder );
if ( !error )
error = add_point1( builder, x, y );
error = cff_builder_add_point1( builder, x, y );
}
return error;
@@ -500,7 +504,7 @@
/* close the current contour */
static void
close_contour( CFF_Builder* builder )
cff_builder_close_contour( CFF_Builder* builder )
{
FT_Outline* outline = builder->current;
@@ -524,7 +528,7 @@
/* `delete' last point only if it coincides with the first */
/* point and if it is not a control point (which can happen). */
if ( p1->x == p2->x && p1->y == p2->y )
if ( *control == FT_Curve_Tag_On )
if ( *control == FT_CURVE_TAG_ON )
outline->n_points--;
}
@@ -547,7 +551,7 @@
return -1;
/* Get code to SID mapping from `cff_standard_encoding'. */
glyph_sid = CFF_Get_Standard_Encoding( (FT_UInt)charcode );
glyph_sid = cff_get_standard_encoding( (FT_UInt)charcode );
for ( n = 0; n < cff->num_glyphs; n++ )
{
@@ -559,6 +563,77 @@
}
static FT_Error
cff_get_glyph_data( TT_Face face,
FT_UInt glyph_index,
FT_Byte** pointer,
FT_ULong* length )
{
#ifdef FT_CONFIG_OPTION_INCREMENTAL
/* For incremental fonts get the character data using the */
/* callback function. */
if ( face->root.internal->incremental_interface )
{
FT_Data data;
FT_Error error =
face->root.internal->incremental_interface->funcs->get_glyph_data(
face->root.internal->incremental_interface->object,
glyph_index, &data );
*pointer = (FT_Byte*)data.pointer;
*length = data.length;
return error;
}
else
#endif /* FT_CONFIG_OPTION_INCREMENTAL */
{
CFF_Font cff = (CFF_Font)(face->extra.data);
return cff_index_access_element( &cff->charstrings_index, glyph_index,
pointer, length );
}
}
static void
cff_free_glyph_data( TT_Face face,
FT_Byte** pointer,
FT_ULong length )
{
#ifndef FT_CONFIG_OPTION_INCREMENTAL
FT_UNUSED( length );
#endif
#ifdef FT_CONFIG_OPTION_INCREMENTAL
/* For incremental fonts get the character data using the */
/* callback function. */
if ( face->root.internal->incremental_interface )
{
FT_Data data;
data.pointer = *pointer;
data.length = length;
face->root.internal->incremental_interface->funcs->free_glyph_data(
face->root.internal->incremental_interface->object,&data );
}
else
#endif /* FT_CONFIG_OPTION_INCREMENTAL */
{
CFF_Font cff = (CFF_Font)(face->extra.data);
cff_index_forget_element( &cff->charstrings_index, pointer );
}
}
static FT_Error
cff_operator_seac( CFF_Decoder* decoder,
FT_Pos adx,
@@ -570,14 +645,28 @@
FT_Int bchar_index, achar_index, n_base_points;
FT_Outline* base = decoder->builder.base;
TT_Face face = decoder->builder.face;
CFF_Font cff = (CFF_Font)(face->extra.data);
FT_Vector left_bearing, advance;
FT_Byte* charstring;
FT_ULong charstring_len;
#ifdef FT_CONFIG_OPTION_INCREMENTAL
/* Incremental fonts don't necessarily have valid charsets. */
/* They use the character code, not the glyph index, in this case. */
if ( face->root.internal->incremental_interface )
{
bchar_index = bchar;
achar_index = achar;
}
else
#endif /* FT_CONFIG_OPTION_INCREMENTAL */
{
CFF_Font cff = (CFF_Font)(face->extra.data);
bchar_index = cff_lookup_glyph_by_stdcharcode( cff, bchar );
achar_index = cff_lookup_glyph_by_stdcharcode( cff, achar );
}
if ( bchar_index < 0 || achar_index < 0 )
{
@@ -613,28 +702,29 @@
/* subglyph 1 = accent character */
subg->index = achar_index;
subg->flags = FT_SUBGLYPH_FLAG_ARGS_ARE_XY_VALUES;
subg->arg1 = adx;
subg->arg2 = ady;
subg->arg1 = (FT_Int)adx;
subg->arg2 = (FT_Int)ady;
/* set up remaining glyph fields */
glyph->num_subglyphs = 2;
glyph->subglyphs = loader->base.subglyphs;
glyph->format = ft_glyph_format_composite;
glyph->format = FT_GLYPH_FORMAT_COMPOSITE;
loader->current.num_subglyphs = 2;
}
/* First load `bchar' in builder */
error = CFF_Access_Element( &cff->charstrings_index, bchar_index,
error = cff_get_glyph_data( face, bchar_index,
&charstring, &charstring_len );
if ( !error )
{
error = CFF_Parse_CharStrings( decoder, charstring, charstring_len );
error = cff_decoder_parse_charstrings( decoder, charstring,
charstring_len );
if ( error )
goto Exit;
CFF_Forget_Element( &cff->charstrings_index, &charstring );
cff_free_glyph_data( face, &charstring, charstring_len );
}
n_base_points = base->n_points;
@@ -649,16 +739,17 @@
decoder->builder.left_bearing.y = 0;
/* Now load `achar' on top of the base outline. */
error = CFF_Access_Element( &cff->charstrings_index, achar_index,
error = cff_get_glyph_data( face, achar_index,
&charstring, &charstring_len );
if ( !error )
{
error = CFF_Parse_CharStrings( decoder, charstring, charstring_len );
error = cff_decoder_parse_charstrings( decoder, charstring,
charstring_len );
if ( error )
goto Exit;
CFF_Forget_Element( &cff->charstrings_index, &charstring );
cff_free_glyph_data( face, &charstring, charstring_len );
}
/* Restore the left side bearing and advance width */
@@ -686,7 +777,7 @@
/*************************************************************************/
/* */
/* <Function> */
/* CFF_Parse_CharStrings */
/* cff_decoder_parse_charstrings */
/* */
/* <Description> */
/* Parses a given Type 2 charstrings program. */
@@ -703,9 +794,9 @@
/* FreeType error code. 0 means success. */
/* */
FT_LOCAL_DEF( FT_Error )
CFF_Parse_CharStrings( CFF_Decoder* decoder,
cff_decoder_parse_charstrings( CFF_Decoder* decoder,
FT_Byte* charstring_base,
FT_Int charstring_len )
FT_ULong charstring_len )
{
FT_Error error;
CFF_Decoder_Zone* zone;
@@ -822,7 +913,7 @@
else
{
FT_Fixed* args = decoder->top;
FT_Int num_args = args - decoder->stack;
FT_Int num_args = (FT_Int)( args - decoder->stack );
FT_Int req_args;
@@ -1146,7 +1237,7 @@
case cff_op_rmoveto:
FT_TRACE4(( " rmoveto" ));
close_contour( builder );
cff_builder_close_contour( builder );
builder->path_begun = 0;
x += args[0];
y += args[1];
@@ -1156,7 +1247,7 @@
case cff_op_vmoveto:
FT_TRACE4(( " vmoveto" ));
close_contour( builder );
cff_builder_close_contour( builder );
builder->path_begun = 0;
y += args[0];
args = stack;
@@ -1165,7 +1256,7 @@
case cff_op_hmoveto:
FT_TRACE4(( " hmoveto" ));
close_contour( builder );
cff_builder_close_contour( builder );
builder->path_begun = 0;
x += args[0];
args = stack;
@@ -1174,7 +1265,7 @@
case cff_op_rlineto:
FT_TRACE4(( " rlineto" ));
if ( start_point ( builder, x, y ) ||
if ( cff_builder_start_point ( builder, x, y ) ||
check_points( builder, num_args / 2 ) )
goto Memory_Error;
@@ -1186,7 +1277,7 @@
{
x += args[0];
y += args[1];
add_point( builder, x, y, 1 );
cff_builder_add_point( builder, x, y, 1 );
args += 2;
}
args = stack;
@@ -1201,7 +1292,7 @@
FT_TRACE4(( op == cff_op_hlineto ? " hlineto"
: " vlineto" ));
if ( start_point ( builder, x, y ) ||
if ( cff_builder_start_point ( builder, x, y ) ||
check_points( builder, num_args ) )
goto Memory_Error;
@@ -1213,7 +1304,7 @@
else
y += args[0];
if ( add_point1( builder, x, y ) )
if ( cff_builder_add_point1( builder, x, y ) )
goto Memory_Error;
args++;
@@ -1230,7 +1321,7 @@
if ( num_args % 6 != 0 )
goto Stack_Underflow;
if ( start_point ( builder, x, y ) ||
if ( cff_builder_start_point ( builder, x, y ) ||
check_points( builder, num_args / 2 ) )
goto Memory_Error;
@@ -1239,13 +1330,13 @@
{
x += args[0];
y += args[1];
add_point( builder, x, y, 0 );
cff_builder_add_point( builder, x, y, 0 );
x += args[2];
y += args[3];
add_point( builder, x, y, 0 );
cff_builder_add_point( builder, x, y, 0 );
x += args[4];
y += args[5];
add_point( builder, x, y, 1 );
cff_builder_add_point( builder, x, y, 1 );
args += 6;
}
args = stack;
@@ -1254,7 +1345,7 @@
case cff_op_vvcurveto:
FT_TRACE4(( " vvcurveto" ));
if ( start_point ( builder, x, y ) )
if ( cff_builder_start_point ( builder, x, y ) )
goto Memory_Error;
args = stack;
@@ -1274,12 +1365,12 @@
while ( args < decoder->top )
{
y += args[0];
add_point( builder, x, y, 0 );
cff_builder_add_point( builder, x, y, 0 );
x += args[1];
y += args[2];
add_point( builder, x, y, 0 );
cff_builder_add_point( builder, x, y, 0 );
y += args[3];
add_point( builder, x, y, 1 );
cff_builder_add_point( builder, x, y, 1 );
args += 4;
}
args = stack;
@@ -1288,7 +1379,7 @@
case cff_op_hhcurveto:
FT_TRACE4(( " hhcurveto" ));
if ( start_point ( builder, x, y ) )
if ( cff_builder_start_point ( builder, x, y ) )
goto Memory_Error;
args = stack;
@@ -1308,12 +1399,12 @@
while ( args < decoder->top )
{
x += args[0];
add_point( builder, x, y, 0 );
cff_builder_add_point( builder, x, y, 0 );
x += args[1];
y += args[2];
add_point( builder, x, y, 0 );
cff_builder_add_point( builder, x, y, 0 );
x += args[3];
add_point( builder, x, y, 1 );
cff_builder_add_point( builder, x, y, 1 );
args += 4;
}
args = stack;
@@ -1328,7 +1419,7 @@
FT_TRACE4(( op == cff_op_vhcurveto ? " vhcurveto"
: " hvcurveto" ));
if ( start_point ( builder, x, y ) )
if ( cff_builder_start_point ( builder, x, y ) )
goto Memory_Error;
args = stack;
@@ -1346,26 +1437,26 @@
if ( phase )
{
x += args[0];
add_point( builder, x, y, 0 );
cff_builder_add_point( builder, x, y, 0 );
x += args[1];
y += args[2];
add_point( builder, x, y, 0 );
cff_builder_add_point( builder, x, y, 0 );
y += args[3];
if ( num_args == 1 )
x += args[4];
add_point( builder, x, y, 1 );
cff_builder_add_point( builder, x, y, 1 );
}
else
{
y += args[0];
add_point( builder, x, y, 0 );
cff_builder_add_point( builder, x, y, 0 );
x += args[1];
y += args[2];
add_point( builder, x, y, 0 );
cff_builder_add_point( builder, x, y, 0 );
x += args[3];
if ( num_args == 1 )
y += args[4];
add_point( builder, x, y, 1 );
cff_builder_add_point( builder, x, y, 1 );
}
args += 4;
phase ^= 1;
@@ -1384,7 +1475,7 @@
if ( num_args < 8 || ( num_args - 6 ) & 1 )
goto Stack_Underflow;
if ( start_point( builder, x, y ) ||
if ( cff_builder_start_point( builder, x, y ) ||
check_points( builder, num_lines + 3 ) )
goto Memory_Error;
@@ -1395,7 +1486,7 @@
{
x += args[0];
y += args[1];
add_point( builder, x, y, 1 );
cff_builder_add_point( builder, x, y, 1 );
args += 2;
num_lines--;
}
@@ -1403,13 +1494,13 @@
/* then the curve */
x += args[0];
y += args[1];
add_point( builder, x, y, 0 );
cff_builder_add_point( builder, x, y, 0 );
x += args[2];
y += args[3];
add_point( builder, x, y, 0 );
cff_builder_add_point( builder, x, y, 0 );
x += args[4];
y += args[5];
add_point( builder, x, y, 1 );
cff_builder_add_point( builder, x, y, 1 );
args = stack;
}
break;
@@ -1424,7 +1515,7 @@
if ( num_args < 8 || ( num_args - 2 ) % 6 )
goto Stack_Underflow;
if ( start_point ( builder, x, y ) ||
if ( cff_builder_start_point ( builder, x, y ) ||
check_points( builder, num_curves*3 + 2 ) )
goto Memory_Error;
@@ -1435,13 +1526,13 @@
{
x += args[0];
y += args[1];
add_point( builder, x, y, 0 );
cff_builder_add_point( builder, x, y, 0 );
x += args[2];
y += args[3];
add_point( builder, x, y, 0 );
cff_builder_add_point( builder, x, y, 0 );
x += args[4];
y += args[5];
add_point( builder, x, y, 1 );
cff_builder_add_point( builder, x, y, 1 );
args += 6;
num_curves--;
}
@@ -1449,7 +1540,7 @@
/* then the final line */
x += args[0];
y += args[1];
add_point( builder, x, y, 1 );
cff_builder_add_point( builder, x, y, 1 );
args = stack;
}
break;
@@ -1466,7 +1557,7 @@
/* adding five more points; 4 control points, 1 on-curve point */
/* make sure we have enough space for the start point if it */
/* needs to be added.. */
if ( start_point( builder, x, y ) ||
if ( cff_builder_start_point( builder, x, y ) ||
check_points( builder, 6 ) )
goto Memory_Error;
@@ -1476,32 +1567,32 @@
/* first control point */
x += args[0];
y += args[1];
add_point( builder, x, y, 0 );
cff_builder_add_point( builder, x, y, 0 );
/* second control point */
x += args[2];
y += args[3];
add_point( builder, x, y, 0 );
cff_builder_add_point( builder, x, y, 0 );
/* join point; on curve, with y-value the same as the last */
/* control point's y-value */
x += args[4];
add_point( builder, x, y, 1 );
cff_builder_add_point( builder, x, y, 1 );
/* third control point, with y-value the same as the join */
/* point's y-value */
x += args[5];
add_point( builder, x, y, 0 );
cff_builder_add_point( builder, x, y, 0 );
/* fourth control point */
x += args[6];
y += args[7];
add_point( builder, x, y, 0 );
cff_builder_add_point( builder, x, y, 0 );
/* ending point, with y-value the same as the start */
x += args[8];
y = start_y;
add_point( builder, x, y, 1 );
cff_builder_add_point( builder, x, y, 1 );
args = stack;
break;
@@ -1517,7 +1608,7 @@
args = stack;
/* adding six more points; 4 control points, 2 on-curve points */
if ( start_point( builder, x, y ) ||
if ( cff_builder_start_point( builder, x, y ) ||
check_points ( builder, 6 ) )
goto Memory_Error;
@@ -1526,32 +1617,32 @@
/* first control point */
x += args[0];
add_point( builder, x, y, 0 );
cff_builder_add_point( builder, x, y, 0 );
/* second control point */
x += args[1];
y += args[2];
add_point( builder, x, y, 0 );
cff_builder_add_point( builder, x, y, 0 );
/* join point; on curve, with y-value the same as the last */
/* control point's y-value */
x += args[3];
add_point( builder, x, y, 1 );
cff_builder_add_point( builder, x, y, 1 );
/* third control point, with y-value the same as the join */
/* point's y-value */
x += args[4];
add_point( builder, x, y, 0 );
cff_builder_add_point( builder, x, y, 0 );
/* fourth control point */
x += args[5];
y = start_y;
add_point( builder, x, y, 0 );
cff_builder_add_point( builder, x, y, 0 );
/* ending point, with y-value the same as the start point's */
/* y-value -- we don't add this point, though */
x += args[6];
add_point( builder, x, y, 1 );
cff_builder_add_point( builder, x, y, 1 );
args = stack;
break;
@@ -1569,7 +1660,7 @@
FT_TRACE4(( " flex1" ));
/* adding six more points; 4 control points, 2 on-curve points */
if ( start_point( builder, x, y ) ||
if ( cff_builder_start_point( builder, x, y ) ||
check_points( builder, 6 ) )
goto Memory_Error;
@@ -1585,8 +1676,8 @@
/* grab up to the last argument */
for ( count = 5; count > 0; count-- )
{
dx += args[0];
dy += args[1];
dx += (FT_Int)args[0];
dy += (FT_Int)args[1];
args += 2;
}
@@ -1603,7 +1694,7 @@
{
x += args[0];
y += args[1];
add_point( builder, x, y, (FT_Bool)( count == 3 ) );
cff_builder_add_point( builder, x, y, (FT_Bool)( count == 3 ) );
args += 2;
}
@@ -1619,7 +1710,7 @@
y += args[0];
}
add_point( builder, x, y, 1 );
cff_builder_add_point( builder, x, y, 1 );
args = stack;
break;
@@ -1632,7 +1723,7 @@
FT_TRACE4(( " flex" ));
if ( start_point( builder, x, y ) ||
if ( cff_builder_start_point( builder, x, y ) ||
check_points( builder, 6 ) )
goto Memory_Error;
@@ -1641,7 +1732,7 @@
{
x += args[0];
y += args[1];
add_point( builder, x, y,
cff_builder_add_point( builder, x, y,
(FT_Bool)( count == 3 || count == 0 ) );
args += 2;
}
@@ -1657,15 +1748,17 @@
if ( num_args == 4 )
{
error = cff_operator_seac( decoder,
args[0] >> 16, args[1] >> 16,
args[2] >> 16, args[3] >> 16 );
args[0] >> 16,
args[1] >> 16,
(FT_Int)( args[2] >> 16 ),
(FT_Int)( args[3] >> 16 ) );
args += 4;
}
if ( !error )
error = CFF_Err_Ok;
close_contour( builder );
cff_builder_close_contour( builder );
/* close hints recording session */
if ( hinter )
@@ -1676,7 +1769,8 @@
/* apply hints to the loaded glyph outline now */
hinter->apply( hinter->hints,
builder->current,
(PSH_Globals)builder->hints_globals );
(PSH_Globals)builder->hints_globals,
builder->hint_flags );
}
/* add current outline to the glyph slot */
@@ -1794,7 +1888,7 @@
case cff_op_index:
{
FT_Int idx = args[0] >> 16;
FT_Int idx = (FT_Int)( args[0] >> 16 );
FT_TRACE4(( " index" ));
@@ -1965,14 +2059,15 @@
if ( idx >= decoder->num_locals )
{
FT_ERROR(( "CFF_Parse_CharStrings:" ));
FT_ERROR(( "cff_decoder_parse_charstrings:" ));
FT_ERROR(( " invalid local subr index\n" ));
goto Syntax_Error;
}
if ( zone - decoder->zones >= CFF_MAX_SUBRS_CALLS )
{
FT_ERROR(( "CFF_Parse_CharStrings: too many nested subrs\n" ));
FT_ERROR(( "cff_decoder_parse_charstrings:"
" too many nested subrs\n" ));
goto Syntax_Error;
}
@@ -1985,7 +2080,8 @@
if ( !zone->base )
{
FT_ERROR(( "CFF_Parse_CharStrings: invoking empty subrs!\n" ));
FT_ERROR(( "cff_decoder_parse_charstrings:"
" invoking empty subrs!\n" ));
goto Syntax_Error;
}
@@ -2005,14 +2101,15 @@
if ( idx >= decoder->num_globals )
{
FT_ERROR(( "CFF_Parse_CharStrings:" ));
FT_ERROR(( "cff_decoder_parse_charstrings:" ));
FT_ERROR(( " invalid global subr index\n" ));
goto Syntax_Error;
}
if ( zone - decoder->zones >= CFF_MAX_SUBRS_CALLS )
{
FT_ERROR(( "CFF_Parse_CharStrings: too many nested subrs\n" ));
FT_ERROR(( "cff_decoder_parse_charstrings:"
" too many nested subrs\n" ));
goto Syntax_Error;
}
@@ -2025,7 +2122,8 @@
if ( !zone->base )
{
FT_ERROR(( "CFF_Parse_CharStrings: invoking empty subrs!\n" ));
FT_ERROR(( "cff_decoder_parse_charstrings:"
" invoking empty subrs!\n" ));
goto Syntax_Error;
}
@@ -2040,7 +2138,8 @@
if ( decoder->zone <= decoder->zones )
{
FT_ERROR(( "CFF_Parse_CharStrings: unexpected return\n" ));
FT_ERROR(( "cff_decoder_parse_charstrings:"
" unexpected return\n" ));
goto Syntax_Error;
}
@@ -2072,15 +2171,15 @@
return error;
Syntax_Error:
FT_TRACE4(( "CFF_Parse_CharStrings: syntax error!" ));
FT_TRACE4(( "cff_decoder_parse_charstrings: syntax error!" ));
return CFF_Err_Invalid_File_Format;
Stack_Underflow:
FT_TRACE4(( "CFF_Parse_CharStrings: stack underflow!" ));
FT_TRACE4(( "cff_decoder_parse_charstrings: stack underflow!" ));
return CFF_Err_Too_Few_Arguments;
Stack_Overflow:
FT_TRACE4(( "CFF_Parse_CharStrings: stack overflow!" ));
FT_TRACE4(( "cff_decoder_parse_charstrings: stack overflow!" ));
return CFF_Err_Stack_Overflow;
Memory_Error:
@@ -2110,7 +2209,7 @@
FT_LOCAL_DEF( FT_Error )
CFF_Compute_Max_Advance( TT_Face face,
cff_compute_max_advance( TT_Face face,
FT_Int* max_advance )
{
FT_Error error = 0;
@@ -2122,7 +2221,7 @@
*max_advance = 0;
/* Initialize load decoder */
CFF_Init_Decoder( &decoder, face, 0, 0, 0 );
cff_decoder_init( &decoder, face, 0, 0, 0, 0 );
decoder.builder.metrics_only = 1;
decoder.builder.load_points = 0;
@@ -2137,14 +2236,15 @@
/* now get load the unscaled outline */
error = CFF_Access_Element( &cff->charstrings_index, glyph_index,
error = cff_get_glyph_data( face, glyph_index,
&charstring, &charstring_len );
if ( !error )
{
CFF_Prepare_Decoder( &decoder, glyph_index );
error = CFF_Parse_CharStrings( &decoder, charstring, charstring_len );
cff_decoder_prepare( &decoder, glyph_index );
error = cff_decoder_parse_charstrings( &decoder,
charstring, charstring_len );
CFF_Forget_Element( &cff->charstrings_index, &charstring );
cff_free_glyph_data( face, &charstring, &charstring_len );
}
/* ignore the error if one has occurred -- skip to next glyph */
@@ -2177,10 +2277,10 @@
FT_LOCAL_DEF( FT_Error )
CFF_Load_Glyph( CFF_GlyphSlot glyph,
cff_slot_load( CFF_GlyphSlot glyph,
CFF_Size size,
FT_Int glyph_index,
FT_Int load_flags )
FT_Int32 load_flags )
{
FT_Error error;
CFF_Decoder decoder;
@@ -2209,42 +2309,58 @@
hinting = FT_BOOL( ( load_flags & FT_LOAD_NO_SCALE ) == 0 &&
( load_flags & FT_LOAD_NO_HINTING ) == 0 );
glyph->root.format = ft_glyph_format_outline; /* by default */
glyph->root.format = FT_GLYPH_FORMAT_OUTLINE; /* by default */
{
FT_Byte* charstring;
FT_ULong charstring_len;
CFF_Init_Decoder( &decoder, face, size, glyph, hinting );
cff_decoder_init( &decoder, face, size, glyph, hinting,
FT_LOAD_TARGET_MODE(load_flags) );
decoder.builder.no_recurse =
(FT_Bool)( ( load_flags & FT_LOAD_NO_RECURSE ) != 0 );
/* now load the unscaled outline */
error = CFF_Access_Element( &cff->charstrings_index, glyph_index,
error = cff_get_glyph_data( face, glyph_index,
&charstring, &charstring_len );
if ( !error )
{
CFF_IndexRec csindex = cff->charstrings_index;
cff_decoder_prepare( &decoder, glyph_index );
error = cff_decoder_parse_charstrings( &decoder,
charstring, charstring_len );
cff_free_glyph_data( face, &charstring, charstring_len );
CFF_Prepare_Decoder( &decoder, glyph_index );
error = CFF_Parse_CharStrings( &decoder, charstring, charstring_len );
CFF_Forget_Element( &cff->charstrings_index, &charstring );
#ifdef FT_CONFIG_OPTION_INCREMENTAL
/* Control data and length may not be available for incremental */
/* fonts. */
if ( face->root.internal->incremental_interface )
{
glyph->root.control_data = 0;
glyph->root.control_len = 0;
}
else
#endif /* FT_CONFIG_OPTION_INCREMENTAL */
/* We set control_data and control_len if charstrings is loaded. */
/* See how charstring loads at CFF_Access_Element() in cffload.c. */
/* See how charstring loads at cff_index_access_element() in */
/* cffload.c. */
{
CFF_IndexRec csindex = cff->charstrings_index;
glyph->root.control_data =
csindex.bytes + csindex.offsets[glyph_index] - 1;
glyph->root.control_len =
charstring_len;
}
}
/* save new glyph tables */
CFF_Builder_Done( &decoder.builder );
cff_builder_done( &decoder.builder );
}
font_matrix = cff->top_font.font_dict.font_matrix;
@@ -2286,13 +2402,13 @@
glyph->root.linearVertAdvance = 0;
glyph->root.format = ft_glyph_format_outline;
glyph->root.format = FT_GLYPH_FORMAT_OUTLINE;
glyph->root.outline.flags = 0;
if ( size && size->metrics.y_ppem < 24 )
glyph->root.outline.flags |= ft_outline_high_precision;
glyph->root.outline.flags |= FT_OUTLINE_HIGH_PRECISION;
glyph->root.outline.flags |= ft_outline_reverse_fill;
glyph->root.outline.flags |= FT_OUTLINE_REVERSE_FILL;
/* apply the font matrix */
FT_Outline_Transform( &glyph->root.outline, &font_matrix );
+13 -8
View File
@@ -114,6 +114,8 @@ FT_BEGIN_HEADER
FT_Error error; /* only used for memory errors */
FT_Bool metrics_only;
FT_UInt32 hint_flags;
void* hints_funcs; /* hinter-specific */
void* hints_globals; /* hinter-specific */
@@ -166,39 +168,42 @@ FT_BEGIN_HEADER
FT_Byte** glyph_names; /* for pure CFF fonts only */
FT_UInt num_glyphs; /* number of glyphs in font */
FT_Render_Mode hint_mode;
} CFF_Decoder;
FT_LOCAL( void )
CFF_Init_Decoder( CFF_Decoder* decoder,
cff_decoder_init( CFF_Decoder* decoder,
TT_Face face,
CFF_Size size,
CFF_GlyphSlot slot,
FT_Bool hinting );
FT_Bool hinting,
FT_Render_Mode hint_mode );
FT_LOCAL( void )
CFF_Prepare_Decoder( CFF_Decoder* decoder,
cff_decoder_prepare( CFF_Decoder* decoder,
FT_UInt glyph_index );
#if 0 /* unused until we support pure CFF fonts */
/* Compute the maximum advance width of a font through quick parsing */
FT_LOCAL( FT_Error )
CFF_Compute_Max_Advance( TT_Face face,
cff_compute_max_advance( TT_Face face,
FT_Int* max_advance );
#endif /* 0 */
FT_LOCAL( FT_Error )
CFF_Parse_CharStrings( CFF_Decoder* decoder,
cff_decoder_parse_charstrings( CFF_Decoder* decoder,
FT_Byte* charstring_base,
FT_Int charstring_len );
FT_ULong charstring_len );
FT_LOCAL( FT_Error )
CFF_Load_Glyph( CFF_GlyphSlot glyph,
cff_slot_load( CFF_GlyphSlot glyph,
CFF_Size size,
FT_Int glyph_index,
FT_Int load_flags );
FT_Int32 load_flags );
FT_END_HEADER
+139 -169
View File
@@ -1047,7 +1047,7 @@
FT_LOCAL_DEF( FT_UShort )
CFF_Get_Standard_Encoding( FT_UInt charcode )
cff_get_standard_encoding( FT_UInt charcode )
{
return (FT_UShort)(charcode < 256 ? cff_standard_encoding[charcode] : 0);
}
@@ -1091,7 +1091,7 @@
FT_UShort count;
FT_MEM_SET( idx, 0, sizeof ( *idx ) );
FT_MEM_ZERO( idx, sizeof ( *idx ) );
idx->stream = stream;
if ( !FT_READ_USHORT( count ) &&
@@ -1167,18 +1167,19 @@
FT_FRAME_RELEASE( idx->bytes );
FT_FREE( idx->offsets );
FT_MEM_SET( idx, 0, sizeof ( *idx ) );
FT_MEM_ZERO( idx, sizeof ( *idx ) );
}
}
/* allocate a table containing pointers to an index's elements */
static FT_Error
cff_explicit_index( CFF_Index idx,
cff_index_get_pointers( CFF_Index idx,
FT_Byte*** table )
{
FT_Error error = 0;
FT_Memory memory = idx->stream->memory;
FT_UInt n, offset, old_offset;
FT_ULong n, offset, old_offset;
FT_Byte** t;
@@ -1205,7 +1206,7 @@
FT_LOCAL_DEF( FT_Error )
CFF_Access_Element( CFF_Index idx,
cff_index_access_element( CFF_Index idx,
FT_UInt element,
FT_Byte** pbytes,
FT_ULong* pbyte_len )
@@ -1270,7 +1271,7 @@
FT_LOCAL_DEF( void )
CFF_Forget_Element( CFF_Index idx,
cff_index_forget_element( CFF_Index idx,
FT_Byte** pbytes )
{
if ( idx->bytes == 0 )
@@ -1284,7 +1285,7 @@
FT_LOCAL_DEF( FT_String* )
CFF_Get_Name( CFF_Index idx,
cff_index_get_name( CFF_Index idx,
FT_UInt element )
{
FT_Memory memory = idx->stream->memory;
@@ -1294,7 +1295,7 @@
FT_String* name = 0;
error = CFF_Access_Element( idx, element, &bytes, &byte_len );
error = cff_index_access_element( idx, element, &bytes, &byte_len );
if ( error )
goto Exit;
@@ -1303,7 +1304,7 @@
FT_MEM_COPY( name, bytes, byte_len );
name[byte_len] = 0;
}
CFF_Forget_Element( idx, &bytes );
cff_index_forget_element( idx, &bytes );
Exit:
return name;
@@ -1311,18 +1312,18 @@
FT_LOCAL_DEF( FT_String* )
CFF_Get_String( CFF_Index idx,
cff_index_get_sid_string( CFF_Index idx,
FT_UInt sid,
PSNames_Service psnames_interface )
PSNames_Service psnames_service )
{
/* if it is not a standard string, return it */
if ( sid > 390 )
return CFF_Get_Name( idx, sid - 391 );
return cff_index_get_name( idx, sid - 391 );
/* that's a standard string, fetch a copy from the PSName module */
{
FT_String* name = 0;
const char* adobe_name = psnames_interface->adobe_std_strings( sid );
const char* adobe_name = psnames_service->adobe_std_strings( sid );
FT_UInt len;
@@ -1357,20 +1358,20 @@
static void
CFF_Done_FD_Select( CFF_FDSelect select,
CFF_Done_FD_Select( CFF_FDSelect fdselect,
FT_Stream stream )
{
if ( select->data )
FT_FRAME_RELEASE( select->data );
if ( fdselect->data )
FT_FRAME_RELEASE( fdselect->data );
select->data_size = 0;
select->format = 0;
select->range_count = 0;
fdselect->data_size = 0;
fdselect->format = 0;
fdselect->range_count = 0;
}
static FT_Error
CFF_Load_FD_Select( CFF_FDSelect select,
CFF_Load_FD_Select( CFF_FDSelect fdselect,
FT_UInt num_glyphs,
FT_Stream stream,
FT_ULong offset )
@@ -1384,23 +1385,23 @@
if ( FT_STREAM_SEEK( offset ) || FT_READ_BYTE( format ) )
goto Exit;
select->format = format;
select->cache_count = 0; /* clear cache */
fdselect->format = format;
fdselect->cache_count = 0; /* clear cache */
switch ( format )
{
case 0: /* format 0, that's simple */
select->data_size = num_glyphs;
fdselect->data_size = num_glyphs;
goto Load_Data;
case 3: /* format 3, a tad more complex */
if ( FT_READ_USHORT( num_ranges ) )
goto Exit;
select->data_size = num_ranges * 3 + 2;
fdselect->data_size = num_ranges * 3 + 2;
Load_Data:
if ( FT_FRAME_EXTRACT( select->data_size, select->data ) )
if ( FT_FRAME_EXTRACT( fdselect->data_size, fdselect->data ) )
goto Exit;
break;
@@ -1414,30 +1415,31 @@
FT_LOCAL_DEF( FT_Byte )
CFF_Get_FD( CFF_FDSelect select,
cff_fd_select_get( CFF_FDSelect fdselect,
FT_UInt glyph_index )
{
FT_Byte fd = 0;
switch ( select->format )
switch ( fdselect->format )
{
case 0:
fd = select->data[glyph_index];
fd = fdselect->data[glyph_index];
break;
case 3:
/* first, compare to cache */
if ( (FT_UInt)(glyph_index-select->cache_first) < select->cache_count )
if ( (FT_UInt)( glyph_index - fdselect->cache_first ) <
fdselect->cache_count )
{
fd = select->cache_fd;
fd = fdselect->cache_fd;
break;
}
/* then, lookup the ranges array */
{
FT_Byte* p = select->data;
FT_Byte* p_limit = p + select->data_size;
FT_Byte* p = fdselect->data;
FT_Byte* p_limit = p + fdselect->data_size;
FT_Byte fd2;
FT_UInt first, limit;
@@ -1456,9 +1458,9 @@
fd = fd2;
/* update cache */
select->cache_first = first;
select->cache_count = limit-first;
select->cache_fd = fd2;
fdselect->cache_first = first;
fdselect->cache_count = limit-first;
fdselect->cache_fd = fd2;
break;
}
first = limit;
@@ -1484,23 +1486,7 @@
/*************************************************************************/
static void
CFF_Done_Encoding( CFF_Encoding encoding,
FT_Stream stream )
{
FT_Memory memory = stream->memory;
FT_FREE( encoding->codes );
FT_FREE( encoding->sids );
encoding->format = 0;
encoding->offset = 0;
encoding->codes = 0;
encoding->sids = 0;
}
static void
CFF_Done_Charset( CFF_Charset charset,
cff_charset_done( CFF_Charset charset,
FT_Stream stream )
{
FT_Memory memory = stream->memory;
@@ -1509,12 +1495,11 @@
FT_FREE( charset->sids );
charset->format = 0;
charset->offset = 0;
charset->sids = 0;
}
static FT_Error
CFF_Load_Charset( CFF_Charset charset,
cff_charset_load( CFF_Charset charset,
FT_UInt num_glyphs,
FT_Stream stream,
FT_ULong base_offset,
@@ -1525,13 +1510,6 @@
FT_UShort glyph_sid;
charset->offset = base_offset + offset;
/* Get the format of the table. */
if ( FT_STREAM_SEEK( charset->offset ) ||
FT_READ_BYTE( charset->format ) )
goto Exit;
/* If the the offset is greater than 2, we have to parse the */
/* charset table. */
if ( offset > 2 )
@@ -1539,6 +1517,13 @@
FT_UInt j;
charset->offset = base_offset + offset;
/* Get the format of the table. */
if ( FT_STREAM_SEEK( charset->offset ) ||
FT_READ_BYTE( charset->format ) )
goto Exit;
/* Allocate memory for sids. */
if ( FT_NEW_ARRAY( charset->sids, num_glyphs ) )
goto Exit;
@@ -1549,12 +1534,15 @@
switch ( charset->format )
{
case 0:
for ( j = 1; j < num_glyphs; j++ )
if ( num_glyphs > 0 )
{
if ( FT_READ_USHORT( glyph_sid ) )
if ( FT_FRAME_ENTER( ( num_glyphs - 1 ) * 2 ) )
goto Exit;
charset->sids[j] = glyph_sid;
for ( j = 1; j < num_glyphs; j++ )
charset->sids[j] = FT_GET_USHORT();
FT_FRAME_EXIT();
}
break;
@@ -1587,14 +1575,14 @@
}
/* Fill in the range of sids -- `nleft + 1' glyphs. */
for ( i = 0; i <= nleft; i++, j++, glyph_sid++ )
for ( i = 0; j < num_glyphs && i <= nleft; i++, j++, glyph_sid++ )
charset->sids[j] = glyph_sid;
}
}
break;
default:
FT_ERROR(( "CFF_Load_Charset: invalid table format!\n" ));
FT_ERROR(( "cff_charset_load: invalid table format!\n" ));
error = CFF_Err_Invalid_File_Format;
goto Exit;
}
@@ -1610,12 +1598,14 @@
/* the first num_glyphs, and hence must match the predefined */
/* charset *exactly*. */
switch ( offset )
charset->offset = offset; /* record charset type */
switch ( (FT_UInt)offset )
{
case 0:
if ( num_glyphs != 229 )
{
FT_ERROR(("CFF_Load_Charset: implicit charset not equal to\n"
FT_ERROR(("cff_charset_load: implicit charset not equal to\n"
"predefined charset (Adobe ISO-Latin)!\n" ));
error = CFF_Err_Invalid_File_Format;
goto Exit;
@@ -1634,7 +1624,7 @@
case 1:
if ( num_glyphs != 166 )
{
FT_ERROR(( "CFF_Load_Charset: implicit charset not equal to\n"
FT_ERROR(( "cff_charset_load: implicit charset not equal to\n"
"predefined charset (Adobe Expert)!\n" ));
error = CFF_Err_Invalid_File_Format;
goto Exit;
@@ -1653,7 +1643,7 @@
case 2:
if ( num_glyphs != 87 )
{
FT_ERROR(( "CFF_Load_Charset: implicit charset not equal to\n"
FT_ERROR(( "cff_charset_load: implicit charset not equal to\n"
"predefined charset (Adobe Expert Subset)!\n" ));
error = CFF_Err_Invalid_File_Format;
goto Exit;
@@ -1681,7 +1671,6 @@
if ( error )
if ( charset->sids )
{
if ( charset->sids )
FT_FREE( charset->sids );
charset->format = 0;
charset->offset = 0;
@@ -1692,20 +1681,30 @@
}
static void
cff_encoding_done( CFF_Encoding encoding )
{
encoding->format = 0;
encoding->offset = 0;
encoding->count = 0;
}
static FT_Error
CFF_Load_Encoding( CFF_Encoding encoding,
cff_encoding_load( CFF_Encoding encoding,
CFF_Charset charset,
FT_UInt num_glyphs,
FT_Stream stream,
FT_ULong base_offset,
FT_ULong offset )
{
FT_Memory memory = stream->memory;
FT_Error error = 0;
FT_UInt count;
FT_UInt j;
FT_UShort glyph_sid;
FT_Byte glyph_code;
FT_UInt glyph_code;
/* Check for charset->sids. If we do not have this, we fail. */
@@ -1715,14 +1714,8 @@
goto Exit;
}
/* Allocate memory for sids/codes -- there are at most 256 sids/codes */
/* for an encoding. */
if ( FT_NEW_ARRAY( encoding->sids, 256 ) ||
FT_NEW_ARRAY( encoding->codes, 256 ) )
goto Exit;
/* Zero out the code to gid/sid mappings. */
for ( j = 0; j < 255; j++ )
for ( j = 0; j < 256; j++ )
{
encoding->sids [j] = 0;
encoding->codes[j] = 0;
@@ -1751,25 +1744,37 @@
FT_READ_BYTE( count ) )
goto Exit;
encoding->count = count + 1;
switch ( encoding->format & 0x7F )
{
case 0:
{
FT_Byte* p;
if ( FT_FRAME_ENTER( count ) )
goto Exit;
p = (FT_Byte*)stream->cursor;
for ( j = 1; j <= count; j++ )
{
if ( FT_READ_BYTE( glyph_code ) )
goto Exit;
glyph_code = *p++;
/* Make sure j is not too big. */
if ( j > num_glyphs )
goto Exit;
if ( (FT_UInt) glyph_code < num_glyphs )
{
/* Assign code to GID mapping. */
encoding->codes[glyph_code] = (FT_UShort)j;
/* Assign code to SID mapping. */
encoding->sids[glyph_code] = charset->sids[j];
}
}
FT_FRAME_EXIT();
}
break;
case 1:
@@ -1797,9 +1802,8 @@
for ( k = i; k < nleft + i; k++, glyph_code++ )
{
/* Make sure k is not too big. */
if ( k > num_glyphs )
goto Exit;
if ( k < num_glyphs && glyph_code < 256 )
{
/* Assign code to GID mapping. */
encoding->codes[glyph_code] = (FT_UShort)k;
@@ -1808,10 +1812,11 @@
}
}
}
}
break;
default:
FT_ERROR(( "CFF_Load_Encoding: invalid table format!\n" ));
FT_ERROR(( "cff_encoding_load: invalid table format!\n" ));
error = CFF_Err_Invalid_File_Format;
goto Exit;
}
@@ -1819,7 +1824,7 @@
/* Parse supplemental encodings, if any. */
if ( encoding->format & 0x80 )
{
FT_UInt glyph_id;
FT_UInt gindex;
/* count supplements */
@@ -1841,14 +1846,14 @@
/* First, lookup GID which has been assigned to */
/* SID glyph_sid. */
for ( glyph_id = 0; glyph_id < num_glyphs; glyph_id++ )
for ( gindex = 0; gindex < num_glyphs; gindex++ )
{
if ( charset->sids[glyph_id] == glyph_sid )
if ( charset->sids[gindex] == glyph_sid )
{
encoding->codes[glyph_code] = (FT_UShort) gindex;
break;
}
/* Now, make the assignment. */
encoding->codes[glyph_code] = (FT_UShort)glyph_id;
}
}
}
}
@@ -1862,44 +1867,23 @@
/* encoding (see the note at the end of section 12 in the CFF */
/* specification). */
switch ( offset )
encoding->count = 256;
switch ( (FT_UInt)offset )
{
case 0:
/* First, copy the code to SID mapping. */
FT_MEM_COPY( encoding->sids, cff_standard_encoding,
256 * sizeof ( FT_UShort ) );
/* Construct code to GID mapping from code */
/* to SID mapping and charset. */
for ( j = 0; j < 256; j++ )
{
/* If j is encoded, find the GID for it. */
if ( encoding->sids[j] )
{
for ( i = 1; i < num_glyphs; i++ )
/* We matched, so break. */
if ( charset->sids[i] == encoding->sids[j] )
break;
/* i will be equal to num_glyphs if we exited the above */
/* loop without a match. In this case, we also have to */
/* fix the code to SID mapping. */
if ( i == num_glyphs )
{
encoding->codes[j] = 0;
encoding->sids [j] = 0;
}
else
encoding->codes[j] = (FT_UShort)i;
}
}
break;
goto Populate;
case 1:
/* First, copy the code to SID mapping. */
FT_MEM_COPY( encoding->sids, cff_expert_encoding,
256 * sizeof ( FT_UShort ) );
Populate:
/* Construct code to GID mapping from code to SID mapping */
/* and charset. */
for ( j = 0; j < 256; j++ )
@@ -1927,7 +1911,7 @@
break;
default:
FT_ERROR(( "CFF_Load_Encoding: invalid table format!\n" ));
FT_ERROR(( "cff_encoding_load: invalid table format!\n" ));
error = CFF_Err_Invalid_File_Format;
goto Exit;
}
@@ -1936,28 +1920,12 @@
Exit:
/* Clean up if there was an error. */
if ( error )
{
if ( encoding->sids || encoding->codes )
{
if ( encoding->sids )
FT_FREE( encoding->sids );
if ( encoding->codes )
FT_FREE( encoding->codes );
charset->format = 0;
charset->offset = 0;
charset->sids = 0;
}
}
return error;
}
static FT_Error
CFF_Load_SubFont( CFF_SubFont font,
cff_subfont_load( CFF_SubFont font,
CFF_Index idx,
FT_UInt font_index,
FT_Stream stream,
@@ -1971,10 +1939,10 @@
CFF_Private priv = &font->private_dict;
CFF_Parser_Init( &parser, CFF_CODE_TOPDICT, &font->font_dict );
cff_parser_init( &parser, CFF_CODE_TOPDICT, &font->font_dict );
/* set defaults */
FT_MEM_SET( top, 0, sizeof ( *top ) );
FT_MEM_ZERO( top, sizeof ( *top ) );
top->underline_position = -100;
top->underline_thickness = 50;
@@ -1983,10 +1951,10 @@
top->font_matrix.yy = 0x10000L;
top->cid_count = 8720;
error = CFF_Access_Element( idx, font_index, &dict, &dict_len ) ||
CFF_Parser_Run( &parser, dict, dict + dict_len );
error = cff_index_access_element( idx, font_index, &dict, &dict_len ) ||
cff_parser_run( &parser, dict, dict + dict_len );
CFF_Forget_Element( idx, &dict );
cff_index_forget_element( idx, &dict );
if ( error )
goto Exit;
@@ -1999,7 +1967,7 @@
if ( top->private_offset && top->private_size )
{
/* set defaults */
FT_MEM_SET( priv, 0, sizeof ( *priv ) );
FT_MEM_ZERO( priv, sizeof ( *priv ) );
priv->blue_shift = 7;
priv->blue_fuzz = 1;
@@ -2007,13 +1975,13 @@
priv->expansion_factor = (FT_Fixed)0.06 * 0x10000L;
priv->blue_scale = (FT_Fixed)0.039625 * 0x10000L;
CFF_Parser_Init( &parser, CFF_CODE_PRIVATE, priv );
cff_parser_init( &parser, CFF_CODE_PRIVATE, priv );
if ( FT_STREAM_SEEK( base_offset + font->font_dict.private_offset ) ||
FT_FRAME_ENTER( font->font_dict.private_size ) )
goto Exit;
error = CFF_Parser_Run( &parser,
error = cff_parser_run( &parser,
(FT_Byte*)stream->cursor,
(FT_Byte*)stream->limit );
FT_FRAME_EXIT();
@@ -2033,7 +2001,7 @@
goto Exit;
font->num_local_subrs = font->local_subrs_index.count;
error = cff_explicit_index( &font->local_subrs_index,
error = cff_index_get_pointers( &font->local_subrs_index,
&font->local_subrs );
if ( error )
goto Exit;
@@ -2045,7 +2013,7 @@
static void
CFF_Done_SubFont( FT_Memory memory,
cff_subfont_done( FT_Memory memory,
CFF_SubFont subfont )
{
if ( subfont )
@@ -2057,7 +2025,7 @@
FT_LOCAL_DEF( FT_Error )
CFF_Load_Font( FT_Stream stream,
cff_font_load( FT_Stream stream,
FT_Int face_index,
CFF_Font font )
{
@@ -2079,8 +2047,7 @@
FT_ULong base_offset;
CFF_FontRecDict dict;
FT_MEM_SET( font, 0, sizeof ( *font ) );
FT_ZERO( font );
font->stream = stream;
font->memory = memory;
@@ -2116,7 +2083,7 @@
font->num_faces = font->name_index.count;
if ( face_index >= (FT_Int)font->num_faces )
{
FT_ERROR(( "CFF_Load_Font: incorrect face index = %d\n",
FT_ERROR(( "cff_font_load: incorrect face index = %d\n",
face_index ));
error = CFF_Err_Invalid_Argument;
}
@@ -2126,7 +2093,7 @@
goto Exit;
/* now, parse the top-level font dictionary */
error = CFF_Load_SubFont( &font->top_font,
error = cff_subfont_load( &font->top_font,
&font->font_dict_index,
face_index,
stream,
@@ -2153,7 +2120,7 @@
if ( fd_index.count > CFF_MAX_CID_FONTS )
{
FT_ERROR(( "CFF_Load_Font: FD array too large in CID font\n" ));
FT_ERROR(( "cff_font_load: FD array too large in CID font\n" ));
goto Fail_CID;
}
@@ -2170,7 +2137,7 @@
for ( idx = 0; idx < fd_index.count; idx++ )
{
sub = font->subfonts[idx];
error = CFF_Load_SubFont( sub, &fd_index, idx,
error = cff_subfont_load( sub, &fd_index, idx,
stream, base_offset );
if ( error )
goto Fail_CID;
@@ -2178,7 +2145,7 @@
/* now load the FD Select array */
error = CFF_Load_FD_Select( &font->fd_select,
dict->cid_count,
(FT_UInt)dict->cid_count,
stream,
base_offset + dict->cid_fd_select_offset );
@@ -2194,7 +2161,7 @@
/* read the charstrings index now */
if ( dict->charstrings_offset == 0 )
{
FT_ERROR(( "CFF_Load_Font: no charstrings offset!\n" ));
FT_ERROR(( "cff_font_load: no charstrings offset!\n" ));
error = CFF_Err_Unknown_File_Format;
goto Exit;
}
@@ -2210,19 +2177,21 @@
font->num_global_subrs = font->global_subrs_index.count;
font->num_glyphs = font->charstrings_index.count;
error = cff_explicit_index( &font->global_subrs_index,
error = cff_index_get_pointers( &font->global_subrs_index,
&font->global_subrs ) ;
if ( error )
goto Exit;
/* read the Charset and Encoding tables when available */
error = CFF_Load_Charset( &font->charset, font->num_glyphs, stream,
if ( font->num_glyphs > 0 )
{
error = cff_charset_load( &font->charset, font->num_glyphs, stream,
base_offset, dict->charset_offset );
if ( error )
goto Exit;
error = CFF_Load_Encoding( &font->encoding,
error = cff_encoding_load( &font->encoding,
&font->charset,
font->num_glyphs,
stream,
@@ -2230,9 +2199,10 @@
dict->encoding_offset );
if ( error )
goto Exit;
}
/* get the font name */
font->font_name = CFF_Get_Name( &font->name_index, face_index );
font->font_name = cff_index_get_name( &font->name_index, face_index );
Exit:
return error;
@@ -2240,7 +2210,7 @@
FT_LOCAL_DEF( void )
CFF_Done_Font( CFF_Font font )
cff_font_done( CFF_Font font )
{
FT_Memory memory = font->memory;
FT_UInt idx;
@@ -2257,15 +2227,15 @@
if ( font->num_subfonts > 0 )
{
for ( idx = 0; idx < font->num_subfonts; idx++ )
CFF_Done_SubFont( memory, font->subfonts[idx] );
cff_subfont_done( memory, font->subfonts[idx] );
FT_FREE( font->subfonts );
}
CFF_Done_Encoding( &font->encoding, font->stream );
CFF_Done_Charset( &font->charset, font->stream );
cff_encoding_done( &font->encoding );
cff_charset_done( &font->charset, font->stream );
CFF_Done_SubFont( memory, &font->top_font );
cff_subfont_done( memory, &font->top_font );
CFF_Done_FD_Select( &font->fd_select, font->stream );
+8 -8
View File
@@ -28,41 +28,41 @@
FT_BEGIN_HEADER
FT_LOCAL( FT_UShort )
CFF_Get_Standard_Encoding( FT_UInt charcode );
cff_get_standard_encoding( FT_UInt charcode );
FT_LOCAL( FT_String* )
CFF_Get_Name( CFF_Index idx,
cff_index_get_name( CFF_Index idx,
FT_UInt element );
FT_LOCAL( FT_String* )
CFF_Get_String( CFF_Index idx,
cff_index_get_sid_string( CFF_Index idx,
FT_UInt sid,
PSNames_Service psnames_interface );
FT_LOCAL( FT_Error )
CFF_Access_Element( CFF_Index idx,
cff_index_access_element( CFF_Index idx,
FT_UInt element,
FT_Byte** pbytes,
FT_ULong* pbyte_len );
FT_LOCAL( void )
CFF_Forget_Element( CFF_Index idx,
cff_index_forget_element( CFF_Index idx,
FT_Byte** pbytes );
FT_LOCAL( FT_Error )
CFF_Load_Font( FT_Stream stream,
cff_font_load( FT_Stream stream,
FT_Int face_index,
CFF_Font font );
FT_LOCAL( void )
CFF_Done_Font( CFF_Font font );
cff_font_done( CFF_Font font );
FT_LOCAL( FT_Byte )
CFF_Get_FD( CFF_FDSelect select,
cff_fd_select_get( CFF_FDSelect select,
FT_UInt glyph_index );
+101 -26
View File
@@ -28,7 +28,7 @@
#include FT_INTERNAL_POSTSCRIPT_HINTS_H
#include "cffobjs.h"
#include "cffload.h"
#include "cffcmap.h"
#include "cfferrs.h"
@@ -53,7 +53,7 @@
static PSH_Globals_Funcs
CFF_Size_Get_Globals_Funcs( CFF_Size size )
cff_size_get_globals_funcs( CFF_Size size )
{
CFF_Face face = (CFF_Face)size->face;
CFF_Font font = (CFF_FontRec *)face->extra.data;
@@ -70,14 +70,14 @@
FT_LOCAL_DEF( void )
CFF_Size_Done( CFF_Size size )
cff_size_done( CFF_Size size )
{
if ( size->internal )
{
PSH_Globals_Funcs funcs;
funcs = CFF_Size_Get_Globals_Funcs( size );
funcs = cff_size_get_globals_funcs( size );
if ( funcs )
funcs->destroy( (PSH_Globals)size->internal );
@@ -87,10 +87,10 @@
FT_LOCAL_DEF( FT_Error )
CFF_Size_Init( CFF_Size size )
cff_size_init( CFF_Size size )
{
FT_Error error = 0;
PSH_Globals_Funcs funcs = CFF_Size_Get_Globals_Funcs( size );
PSH_Globals_Funcs funcs = cff_size_get_globals_funcs( size );
if ( funcs )
@@ -112,7 +112,7 @@
FT_UInt n, count;
FT_MEM_SET( &priv, 0, sizeof ( priv ) );
FT_MEM_ZERO( &priv, sizeof ( priv ) );
count = priv.num_blue_values = cpriv->num_blue_values;
for ( n = 0; n < count; n++ )
@@ -131,8 +131,8 @@
priv.family_other_blues[n] = (FT_Short)cpriv->family_other_blues[n];
priv.blue_scale = cpriv->blue_scale;
priv.blue_shift = cpriv->blue_shift;
priv.blue_fuzz = cpriv->blue_fuzz;
priv.blue_shift = (FT_Int)cpriv->blue_shift;
priv.blue_fuzz = (FT_Int)cpriv->blue_fuzz;
priv.standard_width[0] = (FT_UShort)cpriv->standard_width;
priv.standard_height[0] = (FT_UShort)cpriv->standard_height;
@@ -160,9 +160,9 @@
FT_LOCAL_DEF( FT_Error )
CFF_Size_Reset( CFF_Size size )
cff_size_reset( CFF_Size size )
{
PSH_Globals_Funcs funcs = CFF_Size_Get_Globals_Funcs( size );
PSH_Globals_Funcs funcs = cff_size_get_globals_funcs( size );
FT_Error error = 0;
@@ -182,14 +182,14 @@
/*************************************************************************/
FT_LOCAL_DEF( void )
CFF_GlyphSlot_Done( CFF_GlyphSlot slot )
cff_slot_done( CFF_GlyphSlot slot )
{
slot->root.internal->glyph_hints = 0;
}
FT_LOCAL_DEF( FT_Error )
CFF_GlyphSlot_Init( CFF_GlyphSlot slot )
cff_slot_init( CFF_GlyphSlot slot )
{
CFF_Face face = (CFF_Face)slot->root.face;
CFF_Font font = (CFF_FontRec *)face->extra.data;
@@ -224,7 +224,7 @@
/*************************************************************************/
static FT_String*
CFF_StrCopy( FT_Memory memory,
cff_strcpy( FT_Memory memory,
const FT_String* source )
{
FT_Error error;
@@ -245,8 +245,9 @@
FT_LOCAL_DEF( FT_Error )
CFF_Face_Init( FT_Stream stream,
cff_face_init( FT_Stream stream,
CFF_Face face,
FT_Int face_index,
FT_Int num_params,
@@ -334,18 +335,19 @@
CFF_Font cff;
FT_Memory memory = face->root.memory;
FT_Face root;
FT_UInt flags;
FT_Int32 flags;
if ( FT_NEW( cff ) )
goto Exit;
face->extra.data = cff;
error = CFF_Load_Font( stream, face_index, cff );
error = cff_font_load( stream, face_index, cff );
if ( error )
goto Exit;
cff->pshinter = pshinter;
cff->psnames = psnames;
/* Complement the root flags with some interesting information. */
/* Note that this is only necessary for pure CFF and CEF fonts. */
@@ -361,7 +363,7 @@
/* we need the `PSNames' module for pure-CFF and CEF formats */
if ( !psnames )
{
FT_ERROR(( "CFF_Face_Init:" ));
FT_ERROR(( "cff_face_init:" ));
FT_ERROR(( " cannot open CFF & CEF fonts\n" ));
FT_ERROR(( " " ));
FT_ERROR(( " without the `PSNames' module\n" ));
@@ -395,11 +397,11 @@
root->units_per_EM = 1000;
/* retrieve font family & style name */
root->family_name = CFF_Get_Name( &cff->name_index, face_index );
root->family_name = cff_index_get_name( &cff->name_index, face_index );
if ( dict->cid_registry )
root->style_name = CFF_StrCopy( memory, "Regular" ); /* XXXX */
root->style_name = cff_strcpy( memory, "Regular" ); /* XXXX */
else
root->style_name = CFF_Get_String( &cff->string_index,
root->style_name = cff_index_get_sid_string( &cff->string_index,
dict->weight,
psnames );
@@ -444,8 +446,81 @@
flags |= FT_STYLE_FLAG_BOLD;
root->style_flags = flags;
}
/*******************************************************************/
/* */
/* Compute char maps. */
/* */
/* Try to synthetize a Unicode charmap if there is none available */
/* already. If an OpenType font contains a Unicode "cmap", we */
/* will use it, whatever be in the CFF part of the file. */
{
FT_CharMapRec cmaprec;
FT_CharMap cmap;
FT_UInt nn;
CFF_Encoding encoding = &cff->encoding;
for ( nn = 0; nn < (FT_UInt) root->num_charmaps; nn++ )
{
cmap = root->charmaps[nn];
/* Windows Unicode (3,1)? */
if ( cmap->platform_id == 3 && cmap->encoding_id == 1 )
goto Skip_Unicode;
/* Deprecated Unicode platform id? */
if ( cmap->platform_id == 0 )
goto Skip_Unicode; /* Standard Unicode (deprecated) */
}
/* we didn't find a Unicode charmap, synthetize one */
cmaprec.face = root;
cmaprec.platform_id = 3;
cmaprec.encoding_id = 1;
cmaprec.encoding = FT_ENCODING_UNICODE;
nn = (FT_UInt) root->num_charmaps;
FT_CMap_New( &cff_cmap_unicode_class_rec, NULL, &cmaprec, NULL );
/* if no Unicode charmap was previously selected, select this one */
if ( root->charmap == NULL && nn != (FT_UInt) root->num_charmaps )
root->charmap = root->charmaps[nn];
Skip_Unicode:
if ( encoding->count > 0 )
{
FT_CMap_Class clazz;
cmaprec.face = root;
cmaprec.platform_id = 7; /* Adobe platform id */
if ( encoding->offset == 0 )
{
cmaprec.encoding_id = 0;
cmaprec.encoding = FT_ENCODING_ADOBE_STANDARD;
clazz = &cff_cmap_encoding_class_rec;
}
else if ( encoding->offset == 1 )
{
cmaprec.encoding_id = 1;
cmaprec.encoding = FT_ENCODING_ADOBE_EXPERT;
clazz = &cff_cmap_encoding_class_rec;
}
else
{
cmaprec.encoding_id = 3;
cmaprec.encoding = FT_ENCODING_ADOBE_CUSTOM;
clazz = &cff_cmap_encoding_class_rec;
}
FT_CMap_New( clazz, NULL, &cmaprec, NULL );
}
/* XXX: no charmaps for pure CFF fonts currently! */
}
}
@@ -459,7 +534,7 @@
FT_LOCAL_DEF( void )
CFF_Face_Done( CFF_Face face )
cff_face_done( CFF_Face face )
{
FT_Memory memory = face->root.memory;
SFNT_Service sfnt = (SFNT_Service)face->sfnt;
@@ -474,7 +549,7 @@
if ( cff )
{
CFF_Done_Font( cff );
cff_font_done( cff );
FT_FREE( face->extra.data );
}
}
@@ -482,7 +557,7 @@
FT_LOCAL_DEF( FT_Error )
CFF_Driver_Init( CFF_Driver driver )
cff_driver_init( CFF_Driver driver )
{
FT_UNUSED( driver );
@@ -491,7 +566,7 @@
FT_LOCAL_DEF( void )
CFF_Driver_Done( CFF_Driver driver )
cff_driver_done( CFF_Driver driver )
{
FT_UNUSED( driver );
}
+10 -9
View File
@@ -23,6 +23,7 @@
#include <ft2build.h>
#include FT_INTERNAL_OBJECTS_H
#include FT_INTERNAL_CFF_TYPES_H
#include FT_INTERNAL_TRUETYPE_TYPES_H
#include FT_INTERNAL_POSTSCRIPT_NAMES_H
@@ -110,19 +111,19 @@ FT_BEGIN_HEADER
FT_LOCAL( FT_Error )
CFF_Size_Init( CFF_Size size );
cff_size_init( CFF_Size size );
FT_LOCAL( void )
CFF_Size_Done( CFF_Size size );
cff_size_done( CFF_Size size );
FT_LOCAL( FT_Error )
CFF_Size_Reset( CFF_Size size );
cff_size_reset( CFF_Size size );
FT_LOCAL( void )
CFF_GlyphSlot_Done( CFF_GlyphSlot slot );
cff_slot_done( CFF_GlyphSlot slot );
FT_LOCAL( FT_Error )
CFF_GlyphSlot_Init( CFF_GlyphSlot slot );
cff_slot_init( CFF_GlyphSlot slot );
/*************************************************************************/
@@ -130,14 +131,14 @@ FT_BEGIN_HEADER
/* Face functions */
/* */
FT_LOCAL( FT_Error )
CFF_Face_Init( FT_Stream stream,
cff_face_init( FT_Stream stream,
CFF_Face face,
FT_Int face_index,
FT_Int num_params,
FT_Parameter* params );
FT_LOCAL( void )
CFF_Face_Done( CFF_Face face );
cff_face_done( CFF_Face face );
/*************************************************************************/
@@ -145,10 +146,10 @@ FT_BEGIN_HEADER
/* Driver functions */
/* */
FT_LOCAL( FT_Error )
CFF_Driver_Init( CFF_Driver driver );
cff_driver_init( CFF_Driver driver );
FT_LOCAL( void )
CFF_Driver_Done( CFF_Driver driver );
cff_driver_done( CFF_Driver driver );
FT_END_HEADER
+12 -8
View File
@@ -64,11 +64,11 @@
FT_LOCAL_DEF( void )
CFF_Parser_Init( CFF_Parser parser,
cff_parser_init( CFF_Parser parser,
FT_UInt code,
void* object )
{
FT_MEM_SET( parser, 0, sizeof ( *parser ) );
FT_MEM_ZERO( parser, sizeof ( *parser ) );
parser->top = parser->stack;
parser->object_code = code;
@@ -244,7 +244,7 @@
if ( exp_sign )
exp = -exp;
power_ten += exp;
power_ten += (FT_Int)exp;
}
/* raise to power of ten if needed */
@@ -480,7 +480,7 @@
FT_LOCAL_DEF( FT_Error )
CFF_Parser_Run( CFF_Parser parser,
cff_parser_run( CFF_Parser parser,
FT_Byte* start,
FT_Byte* limit )
{
@@ -542,16 +542,15 @@
const CFF_Field_Handler* field;
/* first of all, a trivial check */
if ( num_args < 1 )
goto Stack_Underflow;
*parser->top = p;
code = v;
if ( v == 12 )
{
/* two byte operator */
p++;
if ( p >= limit )
goto Syntax_Error;
code = 0x100 | p[0];
}
code = code | parser->object_code;
@@ -565,6 +564,11 @@
FT_Byte* q = (FT_Byte*)parser->object + field->offset;
/* check that we have enough arguments -- except for */
/* delta encoded arrays, which can be empty */
if ( field->kind != cff_kind_delta && num_args < 1 )
goto Stack_Underflow;
switch ( field->kind )
{
case cff_kind_bool:
+2 -2
View File
@@ -50,12 +50,12 @@ FT_BEGIN_HEADER
FT_LOCAL( void )
CFF_Parser_Init( CFF_Parser parser,
cff_parser_init( CFF_Parser parser,
FT_UInt code,
void* object );
FT_LOCAL( FT_Error )
CFF_Parser_Run( CFF_Parser parser,
cff_parser_run( CFF_Parser parser,
FT_Byte* start,
FT_Byte* limit );
+1
View File
@@ -28,6 +28,7 @@ CFF_DRV_SRC := $(CFF_DIR_)cffobjs.c \
$(CFF_DIR_)cffload.c \
$(CFF_DIR_)cffgload.c \
$(CFF_DIR_)cffparse.c \
$(CFF_DIR_)cffcmap.c \
$(CFF_DIR_)cffdrivr.c
# CFF driver headers
+101 -33
View File
@@ -43,14 +43,61 @@
CID_Face face = (CID_Face)decoder->builder.face;
CID_FaceInfo cid = &face->cid;
FT_Byte* p;
FT_UInt entry_len = cid->fd_bytes + cid->gd_bytes;
FT_UInt fd_select;
FT_ULong off1, glyph_len;
FT_Stream stream = face->root.stream;
FT_Error error = 0;
FT_Byte* charstring = 0;
FT_Memory memory = face->root.memory;
FT_UInt glyph_length = 0;
#ifdef FT_CONFIG_OPTION_INCREMENTAL
/* For incremental fonts get the character data using */
/* the callback function. */
if ( face->root.internal->incremental_interface )
{
FT_Data glyph_data;
error = face->root.internal->incremental_interface->funcs->get_glyph_data(
face->root.internal->incremental_interface->object,
glyph_index,
&glyph_data );
if ( error )
goto Exit;
p = (FT_Byte*)glyph_data.pointer;
fd_select = (FT_UInt)cid_get_offset( &p, (FT_Byte)cid->fd_bytes );
if ( glyph_data.length != 0 )
{
glyph_length = glyph_data.length - cid->fd_bytes;
FT_ALLOC( charstring, glyph_length );
if ( !error )
ft_memcpy( charstring, glyph_data.pointer + cid->fd_bytes,
glyph_length );
}
face->root.internal->incremental_interface->funcs->free_glyph_data(
face->root.internal->incremental_interface->object,
&glyph_data );
if ( error )
goto Exit;
}
else
#endif
/* For ordinary fonts read the CID font dictionary index */
/* and charstring offset from the CIDMap. */
{
FT_UInt entry_len = cid->fd_bytes + cid->gd_bytes;
FT_ULong off1;
/* read the CID font dict index and charstring offset from the CIDMap */
if ( FT_STREAM_SEEK( cid->data_offset + cid->cidmap_offset +
glyph_index * entry_len ) ||
FT_FRAME_ENTER( 2 * entry_len ) )
@@ -60,58 +107,78 @@
fd_select = (FT_UInt) cid_get_offset( &p, (FT_Byte)cid->fd_bytes );
off1 = (FT_ULong)cid_get_offset( &p, (FT_Byte)cid->gd_bytes );
p += cid->fd_bytes;
glyph_len = cid_get_offset( &p, (FT_Byte)cid->gd_bytes ) - off1;
glyph_length = (FT_UInt) cid_get_offset(
&p, (FT_Byte)cid->gd_bytes ) - off1;
FT_FRAME_EXIT();
/* now, if the glyph is not empty, set up the subrs array, and parse */
/* the charstrings */
if ( glyph_len > 0 )
if ( glyph_length == 0 )
goto Exit;
if ( FT_ALLOC( charstring, glyph_length ) )
goto Exit;
if ( FT_STREAM_READ_AT( cid->data_offset + off1,
charstring, glyph_length ) )
goto Exit;
}
/* Now set up the subrs array and parse the charstrings. */
{
CID_FaceDict dict;
CID_Subrs cid_subrs = face->subrs + fd_select;
FT_Byte* charstring;
FT_Memory memory = face->root.memory;
FT_Int cs_offset;
/* setup subrs */
/* Set up subrs */
decoder->num_subrs = cid_subrs->num_subrs;
decoder->subrs = cid_subrs->code;
decoder->subrs_len = 0;
/* setup font matrix */
/* Set up font matrix */
dict = cid->font_dicts + fd_select;
decoder->font_matrix = dict->font_matrix;
decoder->font_offset = dict->font_offset;
decoder->lenIV = dict->private_dict.lenIV;
/* the charstrings are encoded (stupid!) */
/* load the charstrings, then execute it */
if ( FT_ALLOC( charstring, glyph_len ) )
goto Exit;
if ( !FT_STREAM_READ_AT( cid->data_offset + off1,
charstring, glyph_len ) )
{
FT_Int cs_offset;
/* Decode the charstring. */
/* Adjustment for seed bytes. */
cs_offset = ( decoder->lenIV >= 0 ? decoder->lenIV : 0 );
/* Decrypt only if lenIV >= 0. */
if ( decoder->lenIV >= 0 )
cid_decrypt( charstring, glyph_len, 4330 );
cid_decrypt( charstring, glyph_length, 4330 );
error = decoder->funcs.parse_charstrings( decoder,
charstring + cs_offset,
glyph_len - cs_offset );
glyph_length - cs_offset );
}
FT_FREE( charstring );
#ifdef FT_CONFIG_OPTION_INCREMENTAL
/* Incremental fonts can optionally override the metrics. */
if ( !error &&
face->root.internal->incremental_interface &&
face->root.internal->incremental_interface->funcs->get_glyph_metrics )
{
FT_Bool found = FALSE;
FT_Incremental_MetricsRec metrics;
error = face->root.internal->incremental_interface->funcs->get_glyph_metrics(
face->root.internal->incremental_interface->object,
glyph_index, FALSE, &metrics, &found );
if ( found )
{
decoder->builder.left_bearing.x = metrics.bearing_x;
decoder->builder.left_bearing.y = metrics.bearing_y;
decoder->builder.advance.x = metrics.advance;
decoder->builder.advance.y = 0;
}
}
#endif
Exit:
return error;
@@ -140,7 +207,7 @@
FT_LOCAL_DEF( FT_Error )
CID_Compute_Max_Advance( CID_Face face,
cid_face_compute_max_advance( CID_Face face,
FT_Int* max_advance )
{
FT_Error error;
@@ -203,10 +270,10 @@
FT_LOCAL_DEF( FT_Error )
CID_Load_Glyph( CID_GlyphSlot glyph,
cid_slot_load_glyph( CID_GlyphSlot glyph,
CID_Size size,
FT_Int glyph_index,
FT_Int load_flags )
FT_Int32 load_flags )
{
FT_Error error;
T1_DecoderRec decoder;
@@ -230,7 +297,7 @@
hinting = FT_BOOL( ( load_flags & FT_LOAD_NO_SCALE ) == 0 &&
( load_flags & FT_LOAD_NO_HINTING ) == 0 );
glyph->root.format = ft_glyph_format_outline;
glyph->root.format = FT_GLYPH_FORMAT_OUTLINE;
{
error = psaux->t1_decoder_funcs->init( &decoder,
@@ -240,6 +307,7 @@
0, /* glyph names -- XXX */
0, /* blend == 0 */
hinting,
FT_LOAD_TARGET_MODE(load_flags),
cid_load_glyph );
/* set up the decoder */
@@ -260,8 +328,8 @@
/* bearing the yMax */
if ( !error )
{
glyph->root.outline.flags &= ft_outline_owner;
glyph->root.outline.flags |= ft_outline_reverse_fill;
glyph->root.outline.flags &= FT_OUTLINE_OWNER;
glyph->root.outline.flags |= FT_OUTLINE_REVERSE_FILL;
/* for composite glyphs, return only left side bearing and */
/* advance width */
@@ -294,10 +362,10 @@
metrics->vertAdvance = 0;
glyph->root.linearVertAdvance = 0;
glyph->root.format = ft_glyph_format_outline;
glyph->root.format = FT_GLYPH_FORMAT_OUTLINE;
if ( size && size->root.metrics.y_ppem < 24 )
glyph->root.outline.flags |= ft_outline_high_precision;
glyph->root.outline.flags |= FT_OUTLINE_HIGH_PRECISION;
/* apply the font matrix */
FT_Outline_Transform( &glyph->root.outline, &font_matrix );
+3 -3
View File
@@ -31,16 +31,16 @@ FT_BEGIN_HEADER
/* Compute the maximum advance width of a font through quick parsing */
FT_LOCAL( FT_Error )
CID_Compute_Max_Advance( CID_Face face,
cid_face_compute_max_advance( CID_Face face,
FT_Int* max_advance );
#endif /* 0 */
FT_LOCAL( FT_Error )
CID_Load_Glyph( CID_GlyphSlot glyph,
cid_slot_load_glyph( CID_GlyphSlot glyph,
CID_Size size,
FT_Int glyph_index,
FT_Int load_flags );
FT_Int32 load_flags );
FT_END_HEADER
+12 -12
View File
@@ -146,10 +146,10 @@
/* now, load the keyword data in the object's field(s) */
if ( keyword->type == T1_FIELD_TYPE_INTEGER_ARRAY ||
keyword->type == T1_FIELD_TYPE_FIXED_ARRAY )
error = CID_Load_Field_Table( &loader->parser, keyword,
error = cid_parser_load_field_table( &loader->parser, keyword,
&dummy_object );
else
error = CID_Load_Field( &loader->parser, keyword, &dummy_object );
error = cid_parser_load_field( &loader->parser, keyword, &dummy_object );
Exit:
return error;
}
@@ -163,7 +163,7 @@
FT_BBox* bbox = &face->cid.font_bbox;
(void)CID_ToFixedArray( parser, 4, temp, 0 );
(void)cid_parser_to_fixed_array( parser, 4, temp, 0 );
bbox->xMin = FT_RoundFix( temp[0] );
bbox->yMin = FT_RoundFix( temp[1] );
bbox->xMax = FT_RoundFix( temp[2] );
@@ -192,7 +192,7 @@
matrix = &dict->font_matrix;
offset = &dict->font_offset;
(void)CID_ToFixedArray( parser, 6, temp, 3 );
(void)cid_parser_to_fixed_array( parser, 6, temp, 3 );
temp_scale = ABS( temp[3] );
@@ -238,7 +238,7 @@
FT_Long num_dicts;
num_dicts = CID_ToInt( parser );
num_dicts = cid_parser_to_int( parser );
if ( !cid->font_dicts )
{
@@ -362,7 +362,7 @@
{
/* we found it - run the parsing callback */
parser->root.cursor = cur2;
CID_Skip_Spaces( parser );
cid_parser_skip_spaces( parser );
parser->root.error = cid_load_keyword( face,
loader,
keyword );
@@ -448,7 +448,7 @@
/* set up pointers */
for ( count = 1; count <= num_subrs; count++ )
{
FT_UInt len;
FT_ULong len;
len = offsets[count] - offsets[count - 1];
@@ -460,7 +460,7 @@
{
for ( count = 0; count < num_subrs; count++ )
{
FT_UInt len;
FT_ULong len;
len = offsets[count + 1] - offsets[count];
@@ -497,7 +497,7 @@
{
FT_UNUSED( face );
FT_MEM_SET( loader, 0, sizeof ( *loader ) );
FT_MEM_ZERO( loader, sizeof ( *loader ) );
}
@@ -508,12 +508,12 @@
/* finalize parser */
CID_Done_Parser( parser );
cid_parser_done( parser );
}
FT_LOCAL_DEF( FT_Error )
CID_Open_Face( CID_Face face )
cid_face_open( CID_Face face )
{
CID_Loader loader;
CID_Parser* parser;
@@ -523,7 +523,7 @@
t1_init_loader( &loader, face );
parser = &loader.parser;
error = CID_New_Parser( parser, face->root.stream, face->root.memory,
error = cid_parser_new( parser, face->root.stream, face->root.memory,
(PSAux_Service)face->psaux );
if ( error )
goto Exit;
+1 -1
View File
@@ -46,7 +46,7 @@ FT_BEGIN_HEADER
FT_UShort seed );
FT_LOCAL( FT_Error )
CID_Open_Face( CID_Face face );
cid_face_open( CID_Face face );
FT_END_HEADER
+19 -19
View File
@@ -45,14 +45,14 @@
/*************************************************************************/
FT_LOCAL_DEF( void )
CID_GlyphSlot_Done( CID_GlyphSlot slot )
cid_slot_done( CID_GlyphSlot slot )
{
slot->root.internal->glyph_hints = 0;
}
FT_LOCAL_DEF( FT_Error )
CID_GlyphSlot_Init( CID_GlyphSlot slot )
cid_slot_init( CID_GlyphSlot slot )
{
CID_Face face;
PSHinter_Service pshinter;
@@ -90,7 +90,7 @@
static PSH_Globals_Funcs
CID_Size_Get_Globals_Funcs( CID_Size size )
cid_size_get_globals_funcs( CID_Size size )
{
CID_Face face = (CID_Face)size->root.face;
PSHinter_Service pshinter = (PSHinter_Service)face->pshinter;
@@ -106,14 +106,14 @@
FT_LOCAL_DEF( void )
CID_Size_Done( CID_Size size )
cid_size_done( CID_Size size )
{
if ( size->root.internal )
{
PSH_Globals_Funcs funcs;
funcs = CID_Size_Get_Globals_Funcs( size );
funcs = cid_size_get_globals_funcs( size );
if ( funcs )
funcs->destroy( (PSH_Globals)size->root.internal );
@@ -123,10 +123,10 @@
FT_LOCAL_DEF( FT_Error )
CID_Size_Init( CID_Size size )
cid_size_init( CID_Size size )
{
FT_Error error = 0;
PSH_Globals_Funcs funcs = CID_Size_Get_Globals_Funcs( size );
PSH_Globals_Funcs funcs = cid_size_get_globals_funcs( size );
if ( funcs )
@@ -147,9 +147,9 @@
FT_LOCAL_DEF( FT_Error )
CID_Size_Reset( CID_Size size )
cid_size_reset( CID_Size size )
{
PSH_Globals_Funcs funcs = CID_Size_Get_Globals_Funcs( size );
PSH_Globals_Funcs funcs = cid_size_get_globals_funcs( size );
FT_Error error = 0;
@@ -171,7 +171,7 @@
/*************************************************************************/
/* */
/* <Function> */
/* CID_Face_Done */
/* cid_face_done */
/* */
/* <Description> */
/* Finalizes a given face object. */
@@ -180,7 +180,7 @@
/* face :: A pointer to the face object to destroy. */
/* */
FT_LOCAL_DEF( void )
CID_Face_Done( CID_Face face )
cid_face_done( CID_Face face )
{
FT_Memory memory;
@@ -239,7 +239,7 @@
/*************************************************************************/
/* */
/* <Function> */
/* CID_Face_Init */
/* cid_face_init */
/* */
/* <Description> */
/* Initializes a given CID face object. */
@@ -260,7 +260,7 @@
/* FreeType error code. 0 means success. */
/* */
FT_LOCAL_DEF( FT_Error )
CID_Face_Init( FT_Stream stream,
cid_face_init( FT_Stream stream,
CID_Face face,
FT_Int face_index,
FT_Int num_params,
@@ -310,7 +310,7 @@
if ( FT_STREAM_SEEK( 0 ) )
goto Exit;
error = CID_Open_Face( face );
error = cid_face_open( face );
if ( error )
goto Exit;
@@ -321,7 +321,7 @@
/* check the face index */
if ( face_index != 0 )
{
FT_ERROR(( "CID_Face_Init: invalid face index\n" ));
FT_ERROR(( "cid_face_init: invalid face index\n" ));
error = CID_Err_Invalid_Argument;
goto Exit;
}
@@ -407,7 +407,7 @@
/*************************************************************************/
/* */
/* <Function> */
/* CID_Driver_Init */
/* cid_driver_init */
/* */
/* <Description> */
/* Initializes a given CID driver object. */
@@ -419,7 +419,7 @@
/* FreeType error code. 0 means success. */
/* */
FT_LOCAL_DEF( FT_Error )
CID_Driver_Init( CID_Driver driver )
cid_driver_init( CID_Driver driver )
{
FT_UNUSED( driver );
@@ -430,7 +430,7 @@
/*************************************************************************/
/* */
/* <Function> */
/* CID_Driver_Done */
/* cid_driver_done */
/* */
/* <Description> */
/* Finalizes a given CID driver. */
@@ -439,7 +439,7 @@
/* driver :: A handle to the target CID driver. */
/* */
FT_LOCAL_DEF( void )
CID_Driver_Done( CID_Driver driver )
cid_driver_done( CID_Driver driver )
{
FT_UNUSED( driver );
}
+9 -9
View File
@@ -112,26 +112,26 @@ FT_BEGIN_HEADER
FT_LOCAL( void )
CID_GlyphSlot_Done( CID_GlyphSlot slot );
cid_slot_done( CID_GlyphSlot slot );
FT_LOCAL( FT_Error )
CID_GlyphSlot_Init( CID_GlyphSlot slot );
cid_slot_init( CID_GlyphSlot slot );
FT_LOCAL( void )
CID_Size_Done( CID_Size size );
cid_size_done( CID_Size size );
FT_LOCAL( FT_Error )
CID_Size_Init( CID_Size size );
cid_size_init( CID_Size size );
FT_LOCAL( FT_Error )
CID_Size_Reset( CID_Size size );
cid_size_reset( CID_Size size );
FT_LOCAL( FT_Error )
CID_Face_Init( FT_Stream stream,
cid_face_init( FT_Stream stream,
CID_Face face,
FT_Int face_index,
FT_Int num_params,
@@ -139,15 +139,15 @@ FT_BEGIN_HEADER
FT_LOCAL( void )
CID_Face_Done( CID_Face face );
cid_face_done( CID_Face face );
FT_LOCAL( FT_Error )
CID_Driver_Init( CID_Driver driver );
cid_driver_init( CID_Driver driver );
FT_LOCAL( void )
CID_Driver_Done( CID_Driver driver );
cid_driver_done( CID_Driver driver );
FT_END_HEADER
+3 -3
View File
@@ -49,7 +49,7 @@
FT_LOCAL_DEF( FT_Error )
CID_New_Parser( CID_Parser* parser,
cid_parser_new( CID_Parser* parser,
FT_Stream stream,
FT_Memory memory,
PSAux_Service psaux )
@@ -60,7 +60,7 @@
FT_Int buff_len;
FT_MEM_SET( parser, 0, sizeof ( *parser ) );
FT_MEM_ZERO( parser, sizeof ( *parser ) );
psaux->ps_parser_funcs->init( &parser->root, 0, 0, memory );
parser->stream = stream;
@@ -138,7 +138,7 @@
FT_LOCAL_DEF( void )
CID_Done_Parser( CID_Parser* parser )
cid_parser_done( CID_Parser* parser )
{
/* always free the private dictionary */
if ( parser->postscript )
+13 -13
View File
@@ -61,7 +61,7 @@ FT_BEGIN_HEADER
FT_Stream stream;
FT_Byte* postscript;
FT_Int postscript_len;
FT_Long postscript_len;
FT_ULong data_offset;
@@ -72,13 +72,13 @@ FT_BEGIN_HEADER
FT_LOCAL( FT_Error )
CID_New_Parser( CID_Parser* parser,
cid_parser_new( CID_Parser* parser,
FT_Stream stream,
FT_Memory memory,
PSAux_Service psaux );
FT_LOCAL( void )
CID_Done_Parser( CID_Parser* parser );
cid_parser_done( CID_Parser* parser );
/*************************************************************************/
@@ -87,24 +87,24 @@ FT_BEGIN_HEADER
/* */
/*************************************************************************/
#define CID_Skip_Spaces( p ) (p)->root.funcs.skip_spaces( &(p)->root )
#define CID_Skip_Alpha( p ) (p)->root.funcs.skip_alpha ( &(p)->root )
#define cid_parser_skip_spaces( p ) (p)->root.funcs.skip_spaces( &(p)->root )
#define cid_parser_skip_alpha( p ) (p)->root.funcs.skip_alpha ( &(p)->root )
#define CID_ToInt( p ) (p)->root.funcs.to_int( &(p)->root )
#define CID_ToFixed( p, t ) (p)->root.funcs.to_fixed( &(p)->root, t )
#define cid_parser_to_int( p ) (p)->root.funcs.to_int( &(p)->root )
#define cid_parser_to_fixed( p, t ) (p)->root.funcs.to_fixed( &(p)->root, t )
#define CID_ToCoordArray( p, m, c ) \
#define cid_parser_to_coord_array( p, m, c ) \
(p)->root.funcs.to_coord_array( &(p)->root, m, c )
#define CID_ToFixedArray( p, m, f, t ) \
#define cid_parser_to_fixed_array( p, m, f, t ) \
(p)->root.funcs.to_fixed_array( &(p)->root, m, f, t )
#define CID_ToToken( p, t ) \
#define cid_parser_to_token( p, t ) \
(p)->root.funcs.to_token( &(p)->root, t )
#define CID_ToTokenArray( p, t, m, c ) \
#define cid_parser_to_token_array( p, t, m, c ) \
(p)->root.funcs.to_token_array( &(p)->root, t, m, c )
#define CID_Load_Field( p, f, o ) \
#define cid_parser_load_field( p, f, o ) \
(p)->root.funcs.load_field( &(p)->root, f, o, 0, 0 )
#define CID_Load_Field_Table( p, f, o ) \
#define cid_parser_load_field_table( p, f, o ) \
(p)->root.funcs.load_field_table( &(p)->root, f, o, 0, 0 )
+13 -237
View File
@@ -50,7 +50,7 @@
static FT_Module_Interface
CID_Get_Interface( FT_Driver driver,
cid_get_interface( FT_Driver driver,
const FT_String* cid_interface )
{
FT_UNUSED( driver );
@@ -63,227 +63,6 @@
}
#if 0 /* unimplemented yet */
static FT_Error
cid_Get_Kerning( T1_Face face,
FT_UInt left_glyph,
FT_UInt right_glyph,
FT_Vector* kerning )
{
CID_AFM* afm;
kerning->x = 0;
kerning->y = 0;
afm = (CID_AFM*)face->afm_data;
if ( afm )
CID_Get_Kerning( afm, left_glyph, right_glyph, kerning );
return CID_Err_Ok;
}
#endif /* 0 */
/*************************************************************************/
/* */
/* <Function> */
/* Cid_Get_Char_Index */
/* */
/* <Description> */
/* Uses a charmap to return a given character code's glyph index. */
/* */
/* <Input> */
/* charmap :: A handle to the source charmap object. */
/* */
/* charcode :: The character code. */
/* */
/* <Return> */
/* Glyph index. 0 means `undefined character code'. */
/* */
static FT_UInt
CID_Get_Char_Index( FT_CharMap charmap,
FT_Long charcode )
{
T1_Face face;
FT_UInt result = 0;
PSNames_Service psnames;
face = (T1_Face)charmap->face;
psnames = (PSNames_Service)face->psnames;
if ( psnames )
switch ( charmap->encoding )
{
/*******************************************************************/
/* */
/* Unicode encoding support */
/* */
case ft_encoding_unicode:
/* use the `PSNames' module to synthetize the Unicode charmap */
result = psnames->lookup_unicode( &face->unicode_map,
(FT_ULong)charcode );
/* the function returns 0xFFFF if the Unicode charcode has */
/* no corresponding glyph. */
if ( result == 0xFFFF )
result = 0;
goto Exit;
/*******************************************************************/
/* */
/* Custom Type 1 encoding */
/* */
case ft_encoding_adobe_custom:
{
T1_Encoding encoding = &face->type1.encoding;
if ( charcode >= encoding->code_first &&
charcode <= encoding->code_last )
result = encoding->char_index[charcode];
goto Exit;
}
/*******************************************************************/
/* */
/* Adobe Standard & Expert encoding support */
/* */
default:
if ( charcode < 256 )
{
FT_UInt code;
FT_Int n;
const char* glyph_name;
code = psnames->adobe_std_encoding[charcode];
if ( charmap->encoding == ft_encoding_adobe_expert )
code = psnames->adobe_expert_encoding[charcode];
glyph_name = psnames->adobe_std_strings( code );
if ( !glyph_name )
break;
for ( n = 0; n < face->type1.num_glyphs; n++ )
{
const char* gname = face->type1.glyph_names[n];
if ( gname && gname[0] == glyph_name[0] &&
ft_strcmp( gname, glyph_name ) == 0 )
{
result = n;
break;
}
}
}
}
Exit:
return result;
}
/*************************************************************************/
/* */
/* <Function> */
/* Cid_Get_Next_Char */
/* */
/* <Description> */
/* Uses a charmap to return the next encoded char after. */
/* */
/* <Input> */
/* charmap :: A handle to the source charmap object. */
/* */
/* charcode :: The character code. */
/* */
/* <Return> */
/* Next char code. 0 means `no more char codes'. */
/* */
static FT_Long
CID_Get_Next_Char( FT_CharMap charmap,
FT_Long charcode )
{
T1_Face face;
PSNames_Service psnames;
face = (T1_Face)charmap->face;
psnames = (PSNames_Service)face->psnames;
if ( psnames )
switch ( charmap->encoding )
{
/*******************************************************************/
/* */
/* Unicode encoding support */
/* */
case ft_encoding_unicode:
/* use the `PSNames' module to synthetize the Unicode charmap */
return psnames->next_unicode (&face->unicode_map,
(FT_ULong)charcode );
/*******************************************************************/
/* */
/* Custom Type 1 encoding */
/* */
case ft_encoding_adobe_custom:
{
T1_Encoding encoding = &face->type1.encoding;
charcode++;
if ( charcode < encoding->code_first )
charcode = encoding->code_first;
while ( charcode <= encoding->code_last )
{
if ( encoding->char_index[charcode] )
return charcode;
charcode++;
}
}
break;
/*******************************************************************/
/* */
/* Adobe Standard & Expert encoding support */
/* */
default:
while ( ++charcode < 256 )
{
FT_UInt code;
FT_Int n;
const char* glyph_name;
code = psnames->adobe_std_encoding[charcode];
if ( charmap->encoding == ft_encoding_adobe_expert )
code = psnames->adobe_expert_encoding[charcode];
glyph_name = psnames->adobe_std_strings( code );
if ( !glyph_name )
continue;
for ( n = 0; n < face->type1.num_glyphs; n++ )
{
const char* gname = face->type1.glyph_names[n];
if ( gname && gname[0] == glyph_name[0] &&
ft_strcmp( gname, glyph_name ) == 0 )
{
return charcode;
}
}
}
}
return 0;
}
FT_CALLBACK_TABLE_DEF
const FT_Driver_ClassRec t1cid_driver_class =
@@ -301,9 +80,9 @@
0,
(FT_Module_Constructor)CID_Driver_Init,
(FT_Module_Destructor) CID_Driver_Done,
(FT_Module_Requester) CID_Get_Interface
(FT_Module_Constructor)cid_driver_init,
(FT_Module_Destructor) cid_driver_done,
(FT_Module_Requester) cid_get_interface
},
/* then the other font drivers fields */
@@ -311,26 +90,23 @@
sizeof( CID_SizeRec ),
sizeof( CID_GlyphSlotRec ),
(FT_Face_InitFunc) CID_Face_Init,
(FT_Face_DoneFunc) CID_Face_Done,
(FT_Face_InitFunc) cid_face_init,
(FT_Face_DoneFunc) cid_face_done,
(FT_Size_InitFunc) CID_Size_Init,
(FT_Size_DoneFunc) CID_Size_Done,
(FT_Slot_InitFunc) CID_GlyphSlot_Init,
(FT_Slot_DoneFunc) CID_GlyphSlot_Done,
(FT_Size_InitFunc) cid_size_init,
(FT_Size_DoneFunc) cid_size_done,
(FT_Slot_InitFunc) cid_slot_init,
(FT_Slot_DoneFunc) cid_slot_done,
(FT_Size_ResetPointsFunc) CID_Size_Reset,
(FT_Size_ResetPixelsFunc) CID_Size_Reset,
(FT_Size_ResetPointsFunc)cid_size_reset,
(FT_Size_ResetPixelsFunc)cid_size_reset,
(FT_Slot_LoadFunc) CID_Load_Glyph,
(FT_CharMap_CharIndexFunc)CID_Get_Char_Index,
(FT_Slot_LoadFunc) cid_slot_load_glyph,
(FT_Face_GetKerningFunc) 0,
(FT_Face_AttachFunc) 0,
(FT_Face_GetAdvancesFunc)0,
(FT_CharMap_CharNextFunc) CID_Get_Next_Char
};
+39 -2
View File
@@ -24,9 +24,13 @@ OTL_BEGIN_HEADER
typedef int OTL_Int;
typedef unsigned int OTL_UInt;
typedef long OTL_Long;
typedef unsigned long OTL_ULong;
typedef short OTL_Int16;
typedef unsigned short OTL_UInt16;
#if OTL_SIZEOF_INT == 4
typedef int OTL_Int32;
@@ -58,9 +62,38 @@ OTL_BEGIN_HEADER
OTL_Err_InvalidFormat,
OTL_Err_InvalidOffset,
OTL_Err_Max
} OTL_Error;
/************************************************************************/
/************************************************************************/
/***** *****/
/***** MEMORY MANAGEMENT *****/
/***** *****/
/************************************************************************/
/************************************************************************/
typedef OTL_Pointer (*OTL_AllocFunc)( OTL_ULong size,
OTL_Pointer data );
typedef OTL_Pointer (*OTL_ReallocFunc)( OTL_Pointer block,
OTL_ULong size,
OTL_Pointer data );
typedef void (*OTL_FreeFunc)( OTL_Pointer block,
OTL_Pointer data );
typedef struct OTL_MemoryRec_
{
OTL_Pointer mem_data;
OTL_AllocFunc mem_alloc;
OTL_ReallocFunc mem_realloc;
OTL_FreeFunc mem_free;
} OTL_MemoryRec, *OTL_Memory;
/************************************************************************/
/************************************************************************/
/***** *****/
@@ -69,11 +102,15 @@ OTL_BEGIN_HEADER
/************************************************************************/
/************************************************************************/
/* re-define OTL_MAKE_TAG to something different if you're not */
/* using an ASCII-based character set (Vaxes anyone ?) */
#ifndef OTL_MAKE_TAG
#define OTL_MAKE_TAG(c1,c2,c3,c4) \
( ( (OTL_UInt32)(c1) << 24 ) | \
(OTL_UInt32)(c2) << 16 ) | \
(OTL_UInt32)(c3) << 8 ) | \
(OTL_UInt32)(c4) )
#endif
typedef enum OTL_ScriptTag_
{
@@ -153,8 +190,8 @@ OTL_BEGIN_HEADER
#define OTL_INVALID(e) otl_validator_error( valid, e )
#define OTL_INVALID_TOO_SHORT OTL_INVALID( OTL_Err_InvalidOffset );
#define OTL_INVALID_DATA OTL_INVALID( OTL_Err_InvalidFormat );
#define OTL_INVALID_TOO_SHORT OTL_INVALID( OTL_Err_InvalidOffset )
#define OTL_INVALID_DATA OTL_INVALID( OTL_Err_InvalidFormat )
#define OTL_CHECK(_count) OTL_BEGIN_STMNT \
if ( p + (_count) > valid->limit ) \
+6 -1
View File
@@ -43,7 +43,7 @@
#define OTL_BEGIN_STMNT do {
#define OTL_END_STMNT } while (0)
#define OTL_DUMMY_STMNT do { } while (0)
#define OTL_DUMMY_STMNT OTL_BEGIN_STMNT OTL_END_STMNT
#define OTL_UNUSED( x ) (x)=(x)
#define OTL_UNUSED_CONST(x) (void)(x)
@@ -68,6 +68,11 @@
# error "unsupported number of bytes in 'long' type!"
#endif
#include <setjmp.h>
#define OTL_jmp_buf jmp_buf
#define otl_setjmp setjmp
#define otl_longjmp longjmp
/* */
#endif /* __OT_LAYOUT_CONFIG_H__ */
+213
View File
@@ -9,6 +9,28 @@
/************************************************************************/
/************************************************************************/
/*
* 1: Single Substitution - Table format(s)
*
* This table is used to substiture individual glyph indices
* with another one. There are only two sub-formats:
*
* Name Offset Size Description
* ------------------------------------------
* format 0 2 sub-table format (1)
* offset 2 2 offset to coverage table
* delta 4 2 16-bit delta to apply on all
* covered glyph indices
*
* Name Offset Size Description
* ------------------------------------------
* format 0 2 sub-table format (2)
* offset 2 2 offset to coverage table
* count 4 2 coverage table count
* substs[] 6 2*count substituted glyph indices,
*
*/
static void
otl_gsub_lookup1_validate( OTL_Bytes table,
OTL_Validator valid )
@@ -42,6 +64,10 @@
otl_coverage_validate( table + coverage, valid );
OTL_CHECK( 2*count );
/* NB: we don't check that there are at most 'count' */
/* elements in the coverage table. This is delayed */
/* to the lookup function... */
}
break;
@@ -51,6 +77,63 @@
}
static OTL_Bool
otl_gsub_lookup1_apply( OTL_Bytes table,
OTL_Parser parser )
{
OTL_Bytes p = table;
OTL_Bytes coverage;
OTL_UInt format, gindex, property;
OTL_Int index;
OTL_Bool subst = 0;
if ( parser->context_len != 0xFFFF && parser->context_len < 1 )
goto Exit;
gindex = otl_parser_get_gindex( parser );
if ( !otl_parser_check_property( parser, gindex, &property ) )
goto Exit;
format = OTL_NEXT_USHORT(p);
coverage = table + OTL_NEXT_USHORT(p);
index = otl_coverage_lookup( coverage, gindex );
if ( index >= 0 )
{
switch ( format )
{
case 1:
{
OTL_Int delta = OTL_NEXT_SHORT(p);
gindex = ( gindex + delta ) & 0xFFFF;
otl_parser_replace_1( parser, gindex );
subst = 1;
}
break;
case 2:
{
OTL_UInt count = OTL_NEXT_USHORT(p);
if ( (OTL_UInt) index < count )
{
p += index*2;
otl_parser_replace_1( parser, OTL_PEEK_USHORT(p) );
subst = 1;
}
}
break;
default:
;
}
}
Exit:
return subst;
}
/************************************************************************/
/************************************************************************/
/***** *****/
@@ -59,6 +142,26 @@
/************************************************************************/
/************************************************************************/
/*
* 2: Multiple Substitution - Table format(s)
*
* Replaces a single glyph with one or more glyphs.
*
* Name Offset Size Description
* -----------------------------------------------------------
* format 0 2 sub-table format (1)
* offset 2 2 offset to coverage table
* count 4 2 coverage table count
* sequencess[] 6 2*count offsets to sequence items
*
* each sequence item has the following format:
*
* Name Offset Size Description
* -----------------------------------------------------------
* count 0 2 number of replacement glyphs
* gindices[] 2 2*count string of glyph indices
*/
static void
otl_seq_validate( OTL_Bytes table,
OTL_Validator valid )
@@ -69,6 +172,9 @@
OTL_CHECK( 2 );
count = OTL_NEXT_USHORT( p );
/* XXX: according to the spec, 'count' should be > 0 */
/* we can deal with these cases pretty well however */
OTL_CHECK( 2*count );
/* check glyph indices */
}
@@ -106,6 +212,45 @@
}
}
static OTL_Bool
otl_gsub_lookup2_apply( OTL_Bytes table,
OTL_Parser parser )
{
OTL_Bytes p = table;
OTL_Bytes coverage, sequence;
OTL_UInt format, gindex, index, property;
OTL_Int index;
OTL_Bool subst = 0;
if ( context_len != 0xFFFF && context_len < 1 )
goto Exit;
gindex = otl_parser_get_gindex( parser );
if ( !otl_parser_check_property( parser, gindex, &property ) )
goto Exit;
p += 2; /* skip format */
coverage = table + OTL_NEXT_USHORT(p);
seq_count = OTL_NEXT_USHORT(p);
index = otl_coverage_lookup( coverage, gindex );
if ( (OTL_UInt) index >= seq_count )
goto Exit;
p += index*2;
sequence = table + OTL_PEEK_USHORT(p);
p = sequence;
count = OTL_NEXT_USHORT(p);
otl_parser_replace_n( parser, count, p );
subst = 1;
Exit:
return subst;
}
/************************************************************************/
/************************************************************************/
/***** *****/
@@ -114,6 +259,28 @@
/************************************************************************/
/************************************************************************/
/*
* 3: Alternate Substitution - Table format(s)
*
* Replaces a single glyph by another one taken liberally
* in a list of alternatives
*
* Name Offset Size Description
* -----------------------------------------------------------
* format 0 2 sub-table format (1)
* offset 2 2 offset to coverage table
* count 4 2 coverage table count
* alternates[] 6 2*count offsets to alternate items
*
* each alternate item has the following format:
*
* Name Offset Size Description
* -----------------------------------------------------------
* count 0 2 number of replacement glyphs
* gindices[] 2 2*count string of glyph indices, each one
* is a valid alternative
*/
static void
otl_alternate_set_validate( OTL_Bytes table,
OTL_Validator valid )
@@ -162,6 +329,52 @@
}
static OTL_Bool
otl_gsub_lookup3_apply( OTL_Bytes table,
OTL_Parser parser )
{
OTL_Bytes p = table;
OTL_Bytes coverage, alternates;
OTL_UInt format, gindex, index, property;
OTL_Int index;
OTL_Bool subst = 0;
OTL_GSUB_Alternate alternate = parser->alternate;
if ( context_len != 0xFFFF && context_len < 1 )
goto Exit;
if ( alternate == NULL )
goto Exit;
gindex = otl_parser_get_gindex( parser );
if ( !otl_parser_check_property( parser, gindex, &property ) )
goto Exit;
p += 2; /* skip format */
coverage = table + OTL_NEXT_USHORT(p);
seq_count = OTL_NEXT_USHORT(p);
index = otl_coverage_lookup( coverage, gindex );
if ( (OTL_UInt) index >= seq_count )
goto Exit;
p += index*2;
alternates = table + OTL_PEEK_USHORT(p);
p = alternates;
count = OTL_NEXT_USHORT(p);
gindex = alternate->handler_func(
gindex, count, p, alternate->handler_data );
otl_parser_replace_1( parser, gindex );
subst = 1;
Exit:
return subst;
}
/************************************************************************/
/************************************************************************/
/***** *****/
+12
View File
@@ -5,6 +5,18 @@
OTL_BEGIN_HEADER
typedef OTL_UInt (*OTL_GSUB_AlternateFunc)( OTL_UInt gindex,
OTL_UInt count,
OTL_Bytes alternates,
OTL_Pointer data );
typedef struct OTL_GSUB_AlternateRec_
{
OTL_GSUB_AlternateFunc handler_func;
OTL_Pointer handler_data;
} OTL_GSUB_AlternateRec, *OTL_GSUB_Alternate;
OTL_LOCAL( void )
otl_gsub_validate( OTL_Bytes table,
OTL_Validator valid );
+4
View File
@@ -31,6 +31,7 @@ THE SOFTWARE.
#include <ft2build.h>
#include FT_INTERNAL_DRIVER_H
#include FT_INTERNAL_STREAM_H
FT_BEGIN_HEADER
@@ -135,6 +136,9 @@ FT_BEGIN_HEADER
{
FT_FaceRec root;
FT_StreamRec gzip_stream;
FT_Stream gzip_source;
char* charset_encoding;
char* charset_registry;
+41 -120
View File
@@ -30,6 +30,8 @@ THE SOFTWARE.
#include FT_INTERNAL_DEBUG_H
#include FT_INTERNAL_STREAM_H
#include FT_INTERNAL_OBJECTS_H
#include FT_GZIP_H
#include FT_ERRORS_H
#include "pcf.h"
#include "pcfdriver.h"
@@ -41,8 +43,6 @@ THE SOFTWARE.
#define FT_COMPONENT trace_pcfread
#ifdef FT_CONFIG_OPTION_USE_CMAPS
typedef struct PCF_CMapRec_
{
FT_CMapRec cmap;
@@ -164,77 +164,6 @@ THE SOFTWARE.
(FT_CMap_CharNextFunc) pcf_cmap_char_next
};
#else /* !FT_CONFIG_OPTION_USE_CMAPS */
static FT_UInt
PCF_Char_Get_Index( FT_CharMap charmap,
FT_Long char_code )
{
PCF_Face face = (PCF_Face)charmap->face;
PCF_Encoding en_table = face->encodings;
int low, high, mid;
FT_TRACE4(( "get_char_index %ld\n", char_code ));
low = 0;
high = face->nencodings - 1;
while ( low <= high )
{
mid = ( low + high ) / 2;
if ( char_code < en_table[mid].enc )
high = mid - 1;
else if ( char_code > en_table[mid].enc )
low = mid + 1;
else
return en_table[mid].glyph + 1;
}
return 0;
}
static FT_Long
PCF_Char_Get_Next( FT_CharMap charmap,
FT_Long char_code )
{
PCF_Face face = (PCF_Face)charmap->face;
PCF_Encoding en_table = face->encodings;
int low, high, mid;
FT_TRACE4(( "get_next_char %ld\n", char_code ));
char_code++;
low = 0;
high = face->nencodings - 1;
while ( low <= high )
{
mid = ( low + high ) / 2;
if ( char_code < en_table[mid].enc )
high = mid - 1;
else if ( char_code > en_table[mid].enc )
low = mid + 1;
else
return char_code;
}
if ( high < 0 )
high = 0;
while ( high < face->nencodings )
{
if ( en_table[high].enc >= char_code )
return en_table[high].enc;
high++;
}
return 0;
}
#endif /* !FT_CONFIG_OPTION_USE_CMAPS */
/*************************************************************************/
/* */
@@ -279,7 +208,14 @@ THE SOFTWARE.
FT_FREE( face->charset_encoding );
FT_FREE( face->charset_registry );
FT_TRACE4(( "DONE_FACE!!!\n" ));
FT_TRACE4(( "PCF_Face_Done: done face\n" ));
/* close gzip stream if any */
if ( face->root.stream == &face->gzip_stream )
{
FT_Stream_Close( &face->gzip_stream );
face->root.stream = face->gzip_source;
}
return PCF_Err_Ok;
}
@@ -301,8 +237,28 @@ THE SOFTWARE.
error = pcf_load_font( stream, face );
if ( error )
{
FT_Error error2;
/* this didn't work, try gzip support !! */
error2 = FT_Stream_OpenGzip( &face->gzip_stream, stream );
if ( error2 == FT_Err_Unimplemented_Feature )
goto Fail;
error = error2;
if ( error )
goto Fail;
face->gzip_source = stream;
face->root.stream = &face->gzip_stream;
stream = face->root.stream;
error = pcf_load_font( stream, face );
if ( error )
goto Fail;
}
/* set-up charmap */
{
FT_String *charset_registry, *charset_encoding;
@@ -321,54 +277,30 @@ THE SOFTWARE.
unicode_charmap = 1;
}
#ifdef FT_CONFIG_OPTION_USE_CMAPS
{
FT_CharMapRec charmap;
charmap.face = FT_FACE( face );
charmap.encoding = ft_encoding_none;
charmap.encoding = FT_ENCODING_NONE;
charmap.platform_id = 0;
charmap.encoding_id = 0;
if ( unicode_charmap )
{
charmap.encoding = ft_encoding_unicode;
charmap.encoding = FT_ENCODING_UNICODE;
charmap.platform_id = 3;
charmap.encoding_id = 1;
}
error = FT_CMap_New( &pcf_cmap_class, NULL, &charmap, NULL );
#if 0
/* Select default charmap */
if (face->root.num_charmaps)
face->root.charmap = face->root.charmaps[0];
#endif
}
#else /* !FT_CONFIG_OPTION_USE_CMAPS */
/* XXX: charmaps. For now, report unicode for Unicode and Latin 1 */
face->root.charmaps = &face->charmap_handle;
face->root.num_charmaps = 1;
face->charmap.encoding = ft_encoding_none;
face->charmap.platform_id = 0;
face->charmap.encoding_id = 0;
if ( unicode_charmap )
{
face->charmap.encoding = ft_encoding_unicode;
face->charmap.platform_id = 3;
face->charmap.encoding_id = 1;
}
face->charmap.face = &face->root;
face->charmap_handle = &face->charmap;
face->root.charmap = face->charmap_handle;
#endif /* !FT_CONFIG_OPTION_USE_CMAPS */
}
Exit:
@@ -416,7 +348,7 @@ THE SOFTWARE.
PCF_Glyph_Load( FT_GlyphSlot slot,
FT_Size size,
FT_UInt glyph_index,
FT_Int load_flags )
FT_Int32 load_flags )
{
PCF_Face face = (PCF_Face)FT_SIZE_FACE( size );
FT_Stream stream = face->root.stream;
@@ -445,7 +377,7 @@ THE SOFTWARE.
bitmap->rows = metric->ascent + metric->descent;
bitmap->width = metric->rightSideBearing - metric->leftSideBearing;
bitmap->num_grays = 1;
bitmap->pixel_mode = ft_pixel_mode_mono;
bitmap->pixel_mode = FT_PIXEL_MODE_MONO;
FT_TRACE6(( "BIT_ORDER %d ; BYTE_ORDER %d ; GLYPH_PAD %d\n",
PCF_BIT_ORDER( face->bitmapsFormat ),
@@ -509,13 +441,14 @@ THE SOFTWARE.
slot->bitmap_top = metric->ascent;
slot->metrics.horiAdvance = metric->characterWidth << 6 ;
slot->metrics.horiBearingX = metric->rightSideBearing << 6 ;
slot->metrics.horiBearingX = metric->leftSideBearing << 6 ;
slot->metrics.horiBearingY = metric->ascent << 6 ;
slot->metrics.width = metric->characterWidth << 6 ;
slot->metrics.width = ( metric->rightSideBearing -
metric->leftSideBearing ) << 6;
slot->metrics.height = bitmap->rows << 6;
slot->linearHoriAdvance = (FT_Fixed)bitmap->width << 16;
slot->format = ft_glyph_format_bitmap;
slot->format = FT_GLYPH_FORMAT_BITMAP;
slot->flags = FT_GLYPH_OWN_BITMAP;
FT_TRACE4(( " --- ok\n" ));
@@ -559,21 +492,9 @@ THE SOFTWARE.
(FT_Slot_LoadFunc) PCF_Glyph_Load,
#ifndef FT_CONFIG_OPTION_USE_CMAPS
(FT_CharMap_CharIndexFunc)PCF_Char_Get_Index,
#else
(FT_CharMap_CharIndexFunc)0,
#endif
(FT_Face_GetKerningFunc) 0,
(FT_Face_AttachFunc) 0,
(FT_Face_GetAdvancesFunc) 0,
#ifndef FT_CONFIG_OPTION_USE_CMAPS
(FT_CharMap_CharNextFunc) PCF_Char_Get_Next,
#else
(FT_CharMap_CharNextFunc) 0
#endif
(FT_Face_GetAdvancesFunc) 0
};
+1
View File
@@ -24,5 +24,6 @@
#include "pfrcmap.c"
#include "pfrobjs.c"
#include "pfrdrivr.c"
#include "pfrsbit.c"
/* END */
+104 -6
View File
@@ -19,10 +19,111 @@
#include <ft2build.h>
#include FT_INTERNAL_DEBUG_H
#include FT_INTERNAL_STREAM_H
#include FT_INTERNAL_PFR_H
#include "pfrdrivr.h"
#include "pfrobjs.h"
static FT_Error
pfr_get_kerning( PFR_Face face,
FT_UInt left,
FT_UInt right,
FT_Vector *avector )
{
FT_Error error;
error = pfr_face_get_kerning( face, left, right, avector );
if ( !error )
{
PFR_PhyFont phys = &face->phy_font;
/* convert from metrics to outline units when necessary */
if ( phys->outline_resolution != phys->metrics_resolution )
{
if ( avector->x != 0 )
avector->x = FT_MulDiv( avector->x, phys->outline_resolution,
phys->metrics_resolution );
if ( avector->y != 0 )
avector->y = FT_MulDiv( avector->x, phys->outline_resolution,
phys->metrics_resolution );
}
}
return error;
}
static FT_Error
pfr_get_advance( PFR_Face face,
FT_UInt gindex,
FT_Pos *aadvance )
{
FT_Error error = FT_Err_Bad_Argument;
*aadvance = 0;
if ( face )
{
PFR_PhyFont phys = &face->phy_font;
if ( gindex < phys->num_chars )
{
*aadvance = phys->chars[ gindex ].advance;
error = 0;
}
}
return error;
}
static FT_Error
pfr_get_metrics( PFR_Face face,
FT_UInt *aoutline_resolution,
FT_UInt *ametrics_resolution,
FT_Fixed *ametrics_x_scale,
FT_Fixed *ametrics_y_scale )
{
PFR_PhyFont phys = &face->phy_font;
FT_Fixed x_scale, y_scale;
FT_Size size = face->root.size;
if ( aoutline_resolution )
*aoutline_resolution = phys->outline_resolution;
if ( ametrics_resolution )
*ametrics_resolution = phys->metrics_resolution;
x_scale = 0x10000L;
y_scale = 0x10000L;
if ( size )
{
x_scale = FT_DivFix( size->metrics.x_ppem << 6,
phys->metrics_resolution );
y_scale = FT_DivFix( size->metrics.y_ppem << 6,
phys->metrics_resolution );
}
if ( ametrics_x_scale )
*ametrics_x_scale = x_scale;
if ( ametrics_y_scale )
*ametrics_y_scale = y_scale;
return 0;
}
FT_CALLBACK_TABLE_DEF
const FT_PFR_ServiceRec pfr_service_rec =
{
(FT_PFR_GetMetricsFunc) pfr_get_metrics,
(FT_PFR_GetKerningFunc) pfr_get_kerning,
(FT_PFR_GetAdvanceFunc) pfr_get_advance
};
FT_CALLBACK_TABLE_DEF
const FT_Driver_ClassRec pfr_driver_class =
{
@@ -36,7 +137,7 @@
0x10000L,
0x20000L,
0, /* format interface */
(FT_PFR_Service) &pfr_service_rec, /* format interface */
(FT_Module_Constructor)NULL,
(FT_Module_Destructor) NULL,
@@ -57,13 +158,10 @@
(FT_Size_ResetPointsFunc) NULL,
(FT_Size_ResetPixelsFunc) NULL,
(FT_Slot_LoadFunc) pfr_slot_load,
(FT_CharMap_CharIndexFunc)NULL,
(FT_Face_GetKerningFunc) pfr_face_get_kerning,
(FT_Face_GetKerningFunc) pfr_get_kerning,
(FT_Face_AttachFunc) 0,
(FT_Face_GetAdvancesFunc) 0,
(FT_CharMap_CharNextFunc) NULL
(FT_Face_GetAdvancesFunc) 0
};
+18 -11
View File
@@ -17,6 +17,7 @@
#include "pfrgload.h"
#include "pfrsbit.h"
#include "pfrload.h" /* for macro definitions */
#include FT_INTERNAL_DEBUG_H
@@ -139,7 +140,7 @@
outline->points[n] = *to;
outline->tags [n] = FT_Curve_Tag_On;
outline->tags [n] = FT_CURVE_TAG_ON;
outline->n_points++;
}
@@ -172,9 +173,9 @@
vec[0] = *control1;
vec[1] = *control2;
vec[2] = *to;
tag[0] = FT_Curve_Tag_Cubic;
tag[1] = FT_Curve_Tag_Cubic;
tag[2] = FT_Curve_Tag_On;
tag[0] = FT_CURVE_TAG_CUBIC;
tag[1] = FT_CURVE_TAG_CUBIC;
tag[2] = FT_CURVE_TAG_ON;
outline->n_points = (FT_Short)( outline->n_points + 3 );
}
@@ -409,7 +410,7 @@
cur = pos;
for ( n = 0; n < args_count; n++ )
{
FT_Int index, delta;
FT_Int idx, delta;
/* read the X argument */
@@ -417,9 +418,9 @@
{
case 0: /* 8-bit index */
PFR_CHECK( 1 );
index = PFR_NEXT_BYTE( p );
cur->x = glyph->x_control[index];
FT_TRACE7(( " cx#%d", index ));
idx = PFR_NEXT_BYTE( p );
cur->x = glyph->x_control[idx];
FT_TRACE7(( " cx#%d", idx ));
break;
case 1: /* 16-bit value */
@@ -445,9 +446,9 @@
{
case 0: /* 8-bit index */
PFR_CHECK( 1 );
index = PFR_NEXT_BYTE( p );
cur->y = glyph->y_control[index];
FT_TRACE7(( " cy#%d", index ));
idx = PFR_NEXT_BYTE( p );
cur->y = glyph->y_control[idx];
FT_TRACE7(( " cy#%d", idx ));
break;
case 1: /* 16-bit absolute value */
@@ -676,6 +677,9 @@
}
static FT_Error
pfr_glyph_load_rec( PFR_Glyph glyph,
FT_Stream stream,
@@ -776,6 +780,9 @@
}
FT_LOCAL_DEF( FT_Error )
pfr_glyph_load( PFR_Glyph glyph,
FT_Stream stream,
+3
View File
@@ -44,3 +44,6 @@ FT_END_HEADER
#endif /* __PFRGLOAD_H__ */
/* END */

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