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
+150 -5
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 I. IMPORTANT BUG FIXES
@@ -6,12 +151,12 @@ LATEST CHANGES BETWEEN 2.1.1 and 2.1.0
a new face was opened (with the FT_CONFIG_OPTION_USE_CMAPS options a new face was opened (with the FT_CONFIG_OPTION_USE_CMAPS options
enabled), causing many applications to not be able to display text enabled), causing many applications to not be able to display text
correctly with the 2.1.x releases. correctly with the 2.1.x releases.
- The PFR driver had a bug in its composite loading code that produces - The PFR driver had a bug in its composite loading code that produces
incorrectly placed accents with many fonts. incorrectly placed accents with many fonts.
- The Type42 driver crashed sometimes due to a nasty bug. - The Type42 driver crashed sometimes due to a nasty bug.
- The Type 1 custom encoding charmap didn't handle the case where the - The Type 1 custom encoding charmap didn't handle the case where the
first glyph index wasn't 0. first glyph index wasn't 0.
@@ -87,7 +232,7 @@ LATEST CHANGES BETWEEN 2.1.1 and 2.1.0
- The cache sub-system has been optimized in important ways. Cache hits - The cache sub-system has been optimized in important ways. Cache hits
are now significantly faster. For example, using the CMap cache is are now significantly faster. For example, using the CMap cache is
about twice faster than calling FT_Get_Char_Index on most platforms. about twice faster than calling FT_Get_Char_Index on most platforms.
Similarly, using an SBit cache is about five times faster than loading Similarly, using an SBit cache is about five times faster than loading
the bitmaps from a bitmap file, and 300 to 500 times faster than the bitmaps from a bitmap file, and 300 to 500 times faster than
generating them from a scalable format. generating them from a scalable format.
-8
View File
@@ -23,9 +23,6 @@
/* define to allow cache lookup inlining */ /* define to allow cache lookup inlining */
#define FTC_CACHE_USE_INLINE #define FTC_CACHE_USE_INLINE
/* define to use linear hash table */
#define FTC_CACHE_USE_LINEAR_HASHING
FT_BEGIN_HEADER FT_BEGIN_HEADER
@@ -181,14 +178,9 @@ FT_BEGIN_HEADER
FT_UInt cache_index; /* in manager's table */ FT_UInt cache_index; /* in manager's table */
FT_Pointer cache_data; /* used by cache node methods */ FT_Pointer cache_data; /* used by cache node methods */
#ifdef FTC_CACHE_USE_LINEAR_HASHING
FT_UFast p; FT_UFast p;
FT_UFast mask; FT_UFast mask;
FT_Long slack; FT_Long slack;
#else
FT_UFast nodes;
FT_UFast size;
#endif
FTC_Node* buckets; FTC_Node* buckets;
FT_LruList_ClassRec family_class; FT_LruList_ClassRec family_class;
+54 -53
View File
@@ -4,7 +4,7 @@
/* */ /* */
/* FreeType Image cache (specification). */ /* FreeType Image cache (specification). */
/* */ /* */
/* Copyright 2000-2001 by */ /* Copyright 2000-2001, 2002 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */ /* */
/* This file is part of the FreeType project, and may only be used, */ /* 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 ) /**************************************************************************
*
* @struct:
#define ftc_image_format_bitmap 0x0000 * FTC_ImageTypeRec
#define ftc_image_format_outline 0x0001 *
* @description:
#define ftc_image_format_mask 0x000F * A simple structure used to describe the type of glyph image to be
* loaded into the cache.
#define ftc_image_flag_monochrome 0x0010 *
#define ftc_image_flag_unhinted 0x0020 * @fields:
#define ftc_image_flag_autohinted 0x0040 * font :: An @FTC_FontRec used to describe the glyph's face and size.
#define ftc_image_flag_unscaled 0x0080 *
#define ftc_image_flag_no_sbits 0x0100 * flags :: The load flags to be applied when loading the glyph; see
* the @FT_LOAD_XXX constants for details.
/* monochrome bitmap */ *
#define ftc_image_mono ftc_image_format_bitmap | \ * @note:
ftc_image_flag_monochrome * This type completely replaces the @FTC_Image_Desc structure which is
* now obsolete.
/* anti-aliased bitmap */ */
#define ftc_image_grays ftc_image_format_bitmap typedef struct FTC_ImageTypeRec_
/* 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_
{ {
FTC_FontRec font; 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 ) && \ ( 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 ) ^ \ (FT_UFast)( FTC_FONT_HASH( &(d)->font ) ^ \
( (d)->type << 4 ) ) ( (d)->flags << 4 ) )
/*************************************************************************/ /*************************************************************************/
@@ -160,7 +138,7 @@ FT_BEGIN_HEADER
/* <Input> */ /* <Input> */
/* cache :: A handle to the source glyph image cache. */ /* 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. */ /* gindex :: The glyph index to retrieve. */
/* */ /* */
@@ -193,13 +171,36 @@ FT_BEGIN_HEADER
/* */ /* */
FT_EXPORT( FT_Error ) FT_EXPORT( FT_Error )
FTC_ImageCache_Lookup( FTC_ImageCache cache, FTC_ImageCache_Lookup( FTC_ImageCache cache,
FTC_ImageDesc* desc, FTC_ImageType type,
FT_UInt gindex, FT_UInt gindex,
FT_Glyph *aglyph, FT_Glyph *aglyph,
FTC_Node *anode ); 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
/*************************************************************************/ /*************************************************************************/
/* */ /* */
+7 -7
View File
@@ -4,7 +4,7 @@
/* */ /* */
/* A small-bitmap cache (specification). */ /* A small-bitmap cache (specification). */
/* */ /* */
/* Copyright 2000-2001 by */ /* Copyright 2000-2001, 2002 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */ /* */
/* This file is part of the FreeType project, and may only be used, */ /* 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). */ /* 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 */ /* pitch :: The number of bytes per bitmap line. May be positive */
/* or negative. */ /* or negative. */
@@ -91,8 +91,8 @@ FT_BEGIN_HEADER
FT_Char top; FT_Char top;
FT_Byte format; FT_Byte format;
FT_Short num_grays; /* XXX: Should be FT_Byte. See ftcsbits.c */ FT_Byte max_grays;
FT_Char pitch; FT_Short pitch;
FT_Char xadvance; FT_Char xadvance;
FT_Char yadvance; FT_Char yadvance;
@@ -113,7 +113,7 @@ FT_BEGIN_HEADER
/* implemented by @FTC_ImageCache. */ /* implemented by @FTC_ImageCache. */
/* */ /* */
typedef struct FTC_SBitCacheRec_* FTC_SBitCache; typedef struct FTC_SBitCacheRec_* FTC_SBitCache;
/*************************************************************************/ /*************************************************************************/
/* */ /* */
@@ -160,7 +160,7 @@ FT_BEGIN_HEADER
/* <Input> */ /* <Input> */
/* cache :: A handle to the source sbit cache. */ /* 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. */ /* gindex :: The glyph index. */
/* */ /* */
@@ -195,7 +195,7 @@ FT_BEGIN_HEADER
/* */ /* */
FT_EXPORT( FT_Error ) FT_EXPORT( FT_Error )
FTC_SBitCache_Lookup( FTC_SBitCache cache, FTC_SBitCache_Lookup( FTC_SBitCache cache,
FTC_ImageDesc* desc, FTC_ImageType type,
FT_UInt gindex, FT_UInt gindex,
FTC_SBit *sbit, FTC_SBit *sbit,
FTC_Node *anode ); FTC_Node *anode );
@@ -361,6 +361,17 @@
/* */ /* */
#define FT_BDF_H <freetype/ftbdf.h> #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_TRIGONOMETRY_H <freetype/fttrigon.h>
#define FT_STROKER_H <freetype/ftstroker.h>
#define FT_SYNTHESIS_H <freetype/ftsynth.h> #define FT_SYNTHESIS_H <freetype/ftsynth.h>
#define FT_ERROR_DEFINITIONS_H <freetype/fterrdef.h> #define FT_ERROR_DEFINITIONS_H <freetype/fterrdef.h>
@@ -498,6 +510,8 @@
#define FT_XFREE86_H <freetype/ftxf86.h> #define FT_XFREE86_H <freetype/ftxf86.h>
#define FT_INCREMENTAL_H <freetype/ftincrem.h>
/* now include internal headers definitions from <freetype/internal/...> */ /* now include internal headers definitions from <freetype/internal/...> */
#define FT_INTERNAL_INTERNAL_H <freetype/internal/internal.h> #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(ft_raster1_renderer_class)
FT_USE_MODULE(sfnt_module_class) FT_USE_MODULE(sfnt_module_class)
FT_USE_MODULE(ft_smooth_renderer_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(tt_driver_class)
FT_USE_MODULE(t1_driver_class) FT_USE_MODULE(t1_driver_class)
FT_USE_MODULE(t42_driver_class) FT_USE_MODULE(t42_driver_class)
FT_USE_MODULE(pfr_driver_class) FT_USE_MODULE(pfr_driver_class)
FT_USE_MODULE(winfnt_driver_class) FT_USE_MODULE(winfnt_driver_class)
+149 -135
View File
@@ -25,7 +25,6 @@
FT_BEGIN_HEADER FT_BEGIN_HEADER
/*************************************************************************/ /*************************************************************************/
/* */ /* */
/* USER-SELECTABLE CONFIGURATION MACROS */ /* 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 */ /* FreeType now handles font files that have been compressed with the */
/* for client applications and developers. However, they are not */ /* 'gzip' program. This is mostly used to parse many of the PCF files */
/* required to build and run the library itself. */ /* 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 */ /* Define this macro if you want to enable this "feature". Note that */
/* compilation of these functions at build time. This can be useful */ /* this will however force you to link the zlib to any program that */
/* to reduce the library's code size when you don't need any of */ /* also uses FreeType. */
/* these functions. */
/* */ /* */
/* All convenience functions are declared as such in their */ #define FT_CONFIG_OPTION_USE_ZLIB
/* documentation. */
/* */
#undef FT_CONFIG_OPTION_NO_CONVENIENCE_FUNCS
/*************************************************************************/ /*************************************************************************/
/* */ /* */
/* Module errors */ /* ZLib library selection */
/* */ /* */
/* If this macro is set (which is _not_ the default), the higher byte */ /* This macro is only used when FT_CONFIG_OPTION_USE_ZLIB is defined. */
/* of an error code gives the module in which the error has occurred, */ /* It allows FreeType's "ftgzip" component to link to the system's */
/* while the lower byte is the real error code. */ /* 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 */ /* If you let it undefined, the component will use its own copy */
/* it would break source compatibility of certain programs that use */ /* of the zlib sources instead. These have been modified to be */
/* FreeType 2. */ /* 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 */ /* When compiling FreeType as a DLL, some systems/compilers need a */
/* can either be a pixmap or a vectorial outline defined through */ /* special keyword in front OR after the return type of function */
/* Bezier control points. When defining the following configuration */ /* declarations. */
/* macro, some font drivers will be able to register alternate */
/* glyph image formats. */
/* */ /* */
/* Unset this macro if you are sure that you will never use a font */ /* Two macros are used within the FreeType source code to define */
/* driver with an alternate glyph format; this will reduce the size of */ /* exported library functions: FT_EXPORT and FT_EXPORT_DEF. */
/* the base layer code. */
/* */ /* */
/* Note that a few Type 1 fonts, as well as Windows `vector' fonts */ /* FT_EXPORT( return_type ) */
/* use a vector `plotter' format that isn't supported when this */
/* macro is undefined. */
/* */ /* */
#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 */ /* Allow the use of FT_Incremental_Interface to load typefaces that */
/* by FreeType to speed up some computations. However, this will create */ /* contain no glyph data, but supply it via a callback function. */
/* some problems when compiling the library in strict ANSI mode. */ /* 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 */ /* #define FT_CONFIG_OPTION_INCREMENTAL */
/* 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
/*************************************************************************/ /*************************************************************************/
@@ -291,9 +239,61 @@ FT_BEGIN_HEADER
/* FT_MAX_MODULES */ /* FT_MAX_MODULES */
/* */ /* */
/* The maximum number of modules that can be registered in a single */ /* 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 */ /* By undefining this, you will only compile the code necessary to load */
/* TrueType glyphs without hinting. */ /* 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_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_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 */ /* 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_width == (f2)->pix_width && \
(f1)->pix_height == (f2)->pix_height ) (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 ) \ #define FTC_FONT_HASH( f ) \
(FT_UInt32)( FTC_FACE_ID_HASH((f)->face_id) ^ \ (FT_UInt32)( FTC_FACE_ID_HASH((f)->face_id) ^ \
@@ -30,6 +30,7 @@
/* type1_tables */ /* type1_tables */
/* sfnt_names */ /* sfnt_names */
/* bdf_fonts */ /* bdf_fonts */
/* pfr_fonts */
/* */ /* */
/***************************************************************************/ /***************************************************************************/
+9 -9
View File
@@ -145,7 +145,7 @@ FT_BEGIN_HEADER
/* */ /* */
/* <Note> */ /* <Note> */
/* You can typecast FT_Glyph to FT_BitmapGlyph if you have */ /* 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 bitmap's contents easily. */
/* */ /* */
/* The corresponding pixel buffer is always owned by the BitmapGlyph */ /* The corresponding pixel buffer is always owned by the BitmapGlyph */
@@ -189,7 +189,7 @@ FT_BEGIN_HEADER
/* */ /* */
/* <Note> */ /* <Note> */
/* You can typecast FT_Glyph to FT_OutlineGlyph if you have */ /* 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. */ /* the outline's content easily. */
/* */ /* */
/* As the outline is extracted from a glyph slot, its coordinates are */ /* 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. */ /* the_glyph :: A pointer to a handle to the target glyph. */
/* */ /* */
/* <Input> */ /* <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 */ /* origin :: A pointer to a vector used to translate the glyph */
/* image before rendering. Can be 0 (if no */ /* image before rendering. Can be 0 (if no */
@@ -411,7 +411,7 @@ FT_BEGIN_HEADER
/* error = FT_Get_Glyph( face->glyph, &glyph ); */ /* error = FT_Get_Glyph( face->glyph, &glyph ); */
/* */ /* */
/* // convert to a bitmap (default render mode + destroy old) */ /* // 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, */ /* error = FT_Glyph_To_Bitmap( &glyph, ft_render_mode_default, */
/* 0, 1 ); */ /* 0, 1 ); */
@@ -434,10 +434,10 @@ FT_BEGIN_HEADER
/* scalable. */ /* scalable. */
/* */ /* */
FT_EXPORT( FT_Error ) FT_EXPORT( FT_Error )
FT_Glyph_To_Bitmap( FT_Glyph* the_glyph, FT_Glyph_To_Bitmap( FT_Glyph* the_glyph,
FT_ULong render_mode, FT_Render_Mode render_mode,
FT_Vector* origin, FT_Vector* origin,
FT_Bool destroy ); FT_Bool destroy );
/*************************************************************************/ /*************************************************************************/
+278 -148
View File
@@ -5,7 +5,7 @@
/* FreeType glyph image formats and default raster interface */ /* FreeType glyph image formats and default raster interface */
/* (specification). */ /* (specification). */
/* */ /* */
/* Copyright 1996-2001 by */ /* Copyright 1996-2001, 2002 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */ /* */
/* This file is part of the FreeType project, and may only be used, */ /* This file is part of the FreeType project, and may only be used, */
@@ -28,7 +28,10 @@
#define __FTIMAGE_H__ #define __FTIMAGE_H__
/* _STANDALONE_ is from ftgrays.c */
#ifndef _STANDALONE_
#include <ft2build.h> #include <ft2build.h>
#endif
FT_BEGIN_HEADER FT_BEGIN_HEADER
@@ -114,64 +117,92 @@ FT_BEGIN_HEADER
/* given bitmap. Note that additional formats may be added in the */ /* given bitmap. Note that additional formats may be added in the */
/* future. */ /* future. */
/* */ /* */
/* <Fields> */ /* <Values> */
/* ft_pixel_mode_mono :: A monochrome bitmap (1 bit/pixel). */ /* FT_PIXEL_MODE_NONE :: */
/* Value 0 is reserved. */
/* */ /* */
/* ft_pixel_mode_grays :: An 8-bit gray-levels bitmap. Note that the */ /* FT_PIXEL_MODE_MONO :: */
/* total number of gray levels is given in the */ /* A monochrome bitmap, using 1 bit per pixel. Note that pixels */
/* `num_grays' field of the FT_Bitmap */ /* are stored in most-significant order (MSB), which means that */
/* structure. */ /* the left-most pixel in a byte has value 128. */
/* */ /* */
/* ft_pixel_mode_pal2 :: A 2-bit paletted bitmap. */ /* FT_PIXEL_MODE_GRAY :: */
/* Currently unused by FreeType. */ /* 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. */ /* FT_PIXEL_MODE_GRAY2 :: */
/* Currently unused by FreeType. */ /* 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. */ /* FT_PIXEL_MODE_GRAY4 :: */
/* Currently unused by FreeType. */ /* 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. */ /* FT_PIXEL_MODE_LCD :: */
/* Currently unused by FreeType. */ /* 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. */ /* FT_PIXEL_MODE_LCD_V :: */
/* Currently unused by FreeType. */ /* An 8-bit bitmap, used to represent RGB or BGR decimated glyph */
/* */ /* images used for display on rotated LCD displays; the bitmap's */
/* ft_pixel_mode_rgb24 :: A 24-bit RGB bitmap. */ /* height is three times taller than the original glyph image. */
/* Currently unused by FreeType. */ /* See also @FT_RENDER_MODE_LCD_V. */
/* */
/* 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. */
/* */ /* */
typedef enum FT_Pixel_Mode_ typedef enum FT_Pixel_Mode_
{ {
ft_pixel_mode_none = 0, FT_PIXEL_MODE_NONE = 0,
ft_pixel_mode_mono, FT_PIXEL_MODE_MONO,
ft_pixel_mode_grays, FT_PIXEL_MODE_GRAY,
ft_pixel_mode_pal2, FT_PIXEL_MODE_GRAY2,
ft_pixel_mode_pal4, FT_PIXEL_MODE_GRAY4,
ft_pixel_mode_pal8, FT_PIXEL_MODE_LCD,
ft_pixel_mode_rgb15, FT_PIXEL_MODE_LCD_V,
ft_pixel_mode_rgb16,
ft_pixel_mode_rgb24,
ft_pixel_mode_rgb32,
ft_pixel_mode_max /* do not remove */ FT_PIXEL_MODE_MAX /* do not remove */
} FT_Pixel_Mode; } 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> */ /* <Enum> */
/* FT_Palette_Mode */ /* FT_Palette_Mode */
/* */ /* */
/* <Description> */ /* <Description> */
/* THIS TYPE IS DEPRECATED. DO NOT USE IT! */
/* */
/* An enumeration type used to describe the format of a bitmap */ /* An enumeration type used to describe the format of a bitmap */
/* palette, used with ft_pixel_mode_pal4 and ft_pixel_mode_pal8. */ /* palette, used with ft_pixel_mode_pal4 and ft_pixel_mode_pal8. */
/* */ /* */
@@ -195,6 +226,10 @@ FT_BEGIN_HEADER
} FT_Palette_Mode; } FT_Palette_Mode;
/* */
#endif
/*************************************************************************/ /*************************************************************************/
/* */ /* */
@@ -223,7 +258,7 @@ FT_BEGIN_HEADER
/* most cases. */ /* most cases. */
/* */ /* */
/* num_grays :: This field is only used with */ /* 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. */ /* levels used in the bitmap. */
/* */ /* */
/* pixel_mode :: The pixel_mode, i.e., how pixel bits are stored. */ /* 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 */ /* A simple type used to enumerates the flags in an outline's */
/* `outline_flags' field. */ /* `outline_flags' field. */
/* */ /* */
/* <Fields> */ /* <Values> */
/* ft_outline_owner :: If set, this flag indicates that the */ /* FT_OUTLINE_NONE :: Value 0 is reserved. */
/* */
/* FT_OUTLINE_OWNER :: If set, this flag indicates that the */
/* outline's field arrays (i.e. */ /* outline's field arrays (i.e. */
/* `points', `flags' & `contours') are */ /* `points', `flags' & `contours') are */
/* `owned' by the outline object, and */ /* `owned' by the outline object, and */
/* should thus be freed when it is */ /* should thus be freed when it is */
/* destroyed. */ /* 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 */ /* the non-zero winding rule. If set to */
/* 1, the outline will be filled using */ /* 1, the outline will be filled using */
/* the even-odd fill rule (only works */ /* the even-odd fill rule (only works */
/* with the smooth raster). */ /* 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 */ /* outline are oriented in clock-wise */
/* direction, as defined in the TrueType */ /* direction, as defined in the TrueType */
/* specification. This flag is set if */ /* specification. This flag is set if */
@@ -352,14 +389,14 @@ FT_BEGIN_HEADER
/* scan-converter. However, it is very */ /* scan-converter. However, it is very */
/* important for the auto-hinter. */ /* 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 */ /* try to detect drop-outs in an outline */
/* and correct the glyph bitmap to */ /* and correct the glyph bitmap to */
/* ensure consistent shape continuity. */ /* ensure consistent shape continuity. */
/* If set, this flag hints the scan-line */ /* If set, this flag hints the scan-line */
/* converter to ignore such cases. */ /* 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 */ /* scan-line converter should try to */
/* convert this outline to bitmaps with */ /* convert this outline to bitmaps with */
/* the highest possible quality. It is */ /* the highest possible quality. It is */
@@ -368,7 +405,7 @@ FT_BEGIN_HEADER
/* hint, that might be completely */ /* hint, that might be completely */
/* ignored by a given scan-converter. */ /* 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 */ /* scan-converter to only use a single */
/* pass over the outline to render a */ /* pass over the outline to render a */
/* bitmap glyph image. Normally, it is */ /* bitmap glyph image. Normally, it is */
@@ -379,35 +416,67 @@ FT_BEGIN_HEADER
/* */ /* */
typedef enum FT_Outline_Flags_ typedef enum FT_Outline_Flags_
{ {
ft_outline_none = 0, FT_OUTLINE_NONE = 0,
ft_outline_owner = 1, FT_OUTLINE_OWNER = 1,
ft_outline_even_odd_fill = 2, FT_OUTLINE_EVEN_ODD_FILL = 2,
ft_outline_reverse_fill = 4, FT_OUTLINE_REVERSE_FILL = 4,
ft_outline_ignore_dropouts = 8, FT_OUTLINE_IGNORE_DROPOUTS = 8,
ft_outline_high_precision = 256, FT_OUTLINE_HIGH_PRECISION = 256,
ft_outline_single_pass = 512 FT_OUTLINE_SINGLE_PASS = 512
} FT_Outline_Flags; } 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( flag ) ( flag & 3 )
#define FT_Curve_Tag_On 1 #define FT_CURVE_TAG_ON 1
#define FT_Curve_Tag_Conic 0 #define FT_CURVE_TAG_CONIC 0
#define FT_Curve_Tag_Cubic 2 #define FT_CURVE_TAG_CUBIC 2
#define FT_Curve_Tag_Touch_X 8 /* 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_Y 16 /* reserved for the TrueType hinter */
#define FT_Curve_Tag_Touch_Both ( FT_Curve_Tag_Touch_X | \ #define FT_CURVE_TAG_TOUCH_BOTH ( FT_CURVE_TAG_TOUCH_X | \
FT_Curve_Tag_Touch_Y ) FT_CURVE_TAG_TOUCH_Y )
#define FT_Curve_Tag_On FT_CURVE_TAG_ON
#define FT_Curve_Tag_Conic FT_CURVE_TAG_CONIC
#define FT_Curve_Tag_Cubic FT_CURVE_TAG_CUBIC
#define FT_Curve_Tag_Touch_X FT_CURVE_TAG_TOUCH_X
#define FT_Curve_Tag_Touch_Y FT_CURVE_TAG_TOUCH_Y
/*************************************************************************/ /*************************************************************************/
/* */ /* */
/* <FuncType> */ /* <FuncType> */
/* FT_Outline_MoveTo_Func */ /* FT_Outline_MoveToFunc */
/* */ /* */
/* <Description> */ /* <Description> */
/* A function pointer type used to describe the signature of a `move */ /* A function pointer type used to describe the signature of a `move */
@@ -425,14 +494,15 @@ FT_BEGIN_HEADER
/* Error code. 0 means success. */ /* Error code. 0 means success. */
/* */ /* */
typedef int typedef int
(*FT_Outline_MoveTo_Func)( FT_Vector* to, (*FT_Outline_MoveToFunc)( FT_Vector* to,
void* user ); void* user );
#define FT_Outline_MoveTo_Func FT_Outline_MoveToFunc
/*************************************************************************/ /*************************************************************************/
/* */ /* */
/* <FuncType> */ /* <FuncType> */
/* FT_Outline_LineTo_Func */ /* FT_Outline_LineToFunc */
/* */ /* */
/* <Description> */ /* <Description> */
/* A function pointer type used to describe the signature of a `line */ /* A function pointer type used to describe the signature of a `line */
@@ -450,14 +520,15 @@ FT_BEGIN_HEADER
/* Error code. 0 means success. */ /* Error code. 0 means success. */
/* */ /* */
typedef int typedef int
(*FT_Outline_LineTo_Func)( FT_Vector* to, (*FT_Outline_LineToFunc)( FT_Vector* to,
void* user ); void* user );
#define FT_Outline_LineTo_Func FT_Outline_LineToFunc
/*************************************************************************/ /*************************************************************************/
/* */ /* */
/* <FuncType> */ /* <FuncType> */
/* FT_Outline_ConicTo_Func */ /* FT_Outline_ConicToFunc */
/* */ /* */
/* <Description> */ /* <Description> */
/* A function pointer type use to describe the signature of a `conic */ /* A function pointer type use to describe the signature of a `conic */
@@ -479,15 +550,16 @@ FT_BEGIN_HEADER
/* Error code. 0 means success. */ /* Error code. 0 means success. */
/* */ /* */
typedef int typedef int
(*FT_Outline_ConicTo_Func)( FT_Vector* control, (*FT_Outline_ConicToFunc)( FT_Vector* control,
FT_Vector* to, FT_Vector* to,
void* user ); void* user );
#define FT_Outline_ConicTo_Func FT_Outline_ConicToFunc
/*************************************************************************/ /*************************************************************************/
/* */ /* */
/* <FuncType> */ /* <FuncType> */
/* FT_Outline_CubicTo_Func */ /* FT_Outline_CubicToFunc */
/* */ /* */
/* <Description> */ /* <Description> */
/* A function pointer type used to describe the signature of a `cubic */ /* A function pointer type used to describe the signature of a `cubic */
@@ -509,10 +581,12 @@ FT_BEGIN_HEADER
/* Error code. 0 means success. */ /* Error code. 0 means success. */
/* */ /* */
typedef int typedef int
(*FT_Outline_CubicTo_Func)( FT_Vector* control1, (*FT_Outline_CubicToFunc)( FT_Vector* control1,
FT_Vector* control2, FT_Vector* control2,
FT_Vector* to, FT_Vector* to,
void* user ); void* user );
#define FT_Outline_CubicTo_Func FT_Outline_CubicToFunc
/*************************************************************************/ /*************************************************************************/
@@ -553,13 +627,13 @@ FT_BEGIN_HEADER
/* */ /* */
typedef struct FT_Outline_Funcs_ typedef struct FT_Outline_Funcs_
{ {
FT_Outline_MoveTo_Func move_to; FT_Outline_MoveToFunc move_to;
FT_Outline_LineTo_Func line_to; FT_Outline_LineToFunc line_to;
FT_Outline_ConicTo_Func conic_to; FT_Outline_ConicToFunc conic_to;
FT_Outline_CubicTo_Func cubic_to; FT_Outline_CubicToFunc cubic_to;
int shift; int shift;
FT_Pos delta; FT_Pos delta;
} FT_Outline_Funcs; } FT_Outline_Funcs;
@@ -580,6 +654,15 @@ FT_BEGIN_HEADER
/* <Description> */ /* <Description> */
/* This macro converts four letter tags into an unsigned long. */ /* 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 #ifndef FT_IMAGE_TAG
#define FT_IMAGE_TAG( value, _x1, _x2, _x3, _x4 ) \ #define FT_IMAGE_TAG( value, _x1, _x2, _x3, _x4 ) \
value = ( ( (unsigned long)_x1 << 24 ) | \ value = ( ( (unsigned long)_x1 << 24 ) | \
@@ -600,37 +683,68 @@ FT_BEGIN_HEADER
/* formats, even though future font drivers will be able to register */ /* formats, even though future font drivers will be able to register */
/* their own format. */ /* their own format. */
/* */ /* */
/* <Fields> */ /* <Values> */
/* ft_glyph_format_composite :: The glyph image is a composite of */ /* FT_GLYPH_FORMAT_NONE :: */
/* several other images. This glyph */ /* The value 0 is reserved and does describe a glyph format. */
/* format is _only_ used with the */
/* FT_LOAD_FLAG_NO_RECURSE flag (XXX: */
/* Which is currently unimplemented). */
/* */ /* */
/* ft_glyph_format_bitmap :: The glyph image is a bitmap, and can */ /* FT_GLYPH_FORMAT_COMPOSITE :: */
/* be described as a FT_Bitmap. */ /* 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 */ /* FT_GLYPH_FORMAT_BITMAP :: */
/* made of bezier control points, and */ /* The glyph image is a bitmap, and can be described as an */
/* can be described as a FT_Outline. */ /* @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 */ /* FT_GLYPH_FORMAT_OUTLINE :: */
/* made of plotter lines (some T1 fonts */ /* The glyph image is a vertorial outline made of line segments */
/* like Hershey contain glyph in this */ /* and Bezier arcs; it can be described as an @FT_Outline; you */
/* format). */ /* 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_ 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_COMPOSITE, 'c', 'o', 'm', 'p' ),
FT_IMAGE_TAG( ft_glyph_format_bitmap, 'b', 'i', 't', 's' ), 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_OUTLINE, 'o', 'u', 't', 'l' ),
FT_IMAGE_TAG( ft_glyph_format_plotter, 'p', 'l', 'o', 't' ) FT_IMAGE_TAG( FT_GLYPH_FORMAT_PLOTTER, 'p', 'l', 'o', 't' )
} FT_Glyph_Format; } 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> */ /* <Section> */
/* Raster */ /* raster */
/* */ /* */
/* <Title> */ /* <Title> */
/* Scanline converter */ /* Scanline converter */
@@ -703,7 +817,7 @@ FT_BEGIN_HEADER
/* */ /* */
/* <Note> */ /* <Note> */
/* This structure is used by the span drawing callback type named */ /* 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. */ /* a parameter. */
/* */ /* */
/* The coverage value is always between 0 and 255, even if the number */ /* The coverage value is always between 0 and 255, even if the number */
@@ -721,7 +835,7 @@ FT_BEGIN_HEADER
/*************************************************************************/ /*************************************************************************/
/* */ /* */
/* <FuncType> */ /* <FuncType> */
/* FT_Raster_Span_Func */ /* FT_SpanFunc */
/* */ /* */
/* <Description> */ /* <Description> */
/* A function used as a call-back by the anti-aliased renderer in */ /* A function used as a call-back by the anti-aliased renderer in */
@@ -755,10 +869,12 @@ FT_BEGIN_HEADER
/* only for those scanlines that do have `gray' pixels on them. */ /* only for those scanlines that do have `gray' pixels on them. */
/* */ /* */
typedef void typedef void
(*FT_Raster_Span_Func)( int y, (*FT_SpanFunc)( int y,
int count, int count,
FT_Span* spans, FT_Span* spans,
void* user ); void* user );
#define FT_Raster_Span_Func FT_SpanFunc
/*************************************************************************/ /*************************************************************************/
@@ -767,6 +883,8 @@ FT_BEGIN_HEADER
/* FT_Raster_BitTest_Func */ /* FT_Raster_BitTest_Func */
/* */ /* */
/* <Description> */ /* <Description> */
/* THIS TYPE IS DEPRECATED. DO NOT USE IT. */
/* */
/* A function used as a call-back by the monochrome scan-converter */ /* 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 */ /* to test whether a given target pixel is already set to the drawing */
/* `color'. These tests are crucial to implement drop-out control */ /* `color'. These tests are crucial to implement drop-out control */
@@ -794,6 +912,8 @@ FT_BEGIN_HEADER
/* FT_Raster_BitSet_Func */ /* FT_Raster_BitSet_Func */
/* */ /* */
/* <Description> */ /* <Description> */
/* THIS TYPE IS DEPRECATED. DO NOT USE IT. */
/* */
/* A function used as a call-back by the monochrome scan-converter */ /* A function used as a call-back by the monochrome scan-converter */
/* to set an individual target pixel. This is crucial to implement */ /* to set an individual target pixel. This is crucial to implement */
/* drop-out control according to the TrueType specification. */ /* 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 */ /* An enumeration to list the bit flags as used in the `flags' field */
/* of a FT_Raster_Params structure. */ /* of a FT_Raster_Params structure. */
/* */ /* */
/* <Fields> */ /* <Values> */
/* ft_raster_flag_default :: This value is 0. */ /* 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 */ /* anti-aliased glyph image should be */
/* generated. Otherwise, it will be */ /* generated. Otherwise, it will be */
/* monochrome (1-bit) */ /* 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 */ /* rendering. In this mode, client */
/* applications must provide their own span */ /* applications must provide their own span */
/* callback. This lets them directly */ /* callback. This lets them directly */
@@ -843,7 +963,7 @@ FT_BEGIN_HEADER
/* Note that for now, direct rendering is */ /* Note that for now, direct rendering is */
/* only possible with anti-aliased glyphs. */ /* 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 */ /* rendering mode. If set, the output will */
/* be clipped to a box specified in the */ /* be clipped to a box specified in the */
/* "clip_box" field of the FT_Raster_Params */ /* "clip_box" field of the FT_Raster_Params */
@@ -856,13 +976,18 @@ FT_BEGIN_HEADER
/* */ /* */
typedef enum typedef enum
{ {
ft_raster_flag_default = 0, FT_RASTER_FLAG_DEFAULT = 0,
ft_raster_flag_aa = 1, FT_RASTER_FLAG_AA = 1,
ft_raster_flag_direct = 2, FT_RASTER_FLAG_DIRECT = 2,
ft_raster_flag_clip = 4 FT_RASTER_FLAG_CLIP = 4
} FT_Raster_Flag; } 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. */ /* 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 */ /* user :: User-supplied data that is passed to each drawing */
/* callback. */ /* callback. */
@@ -898,11 +1023,11 @@ FT_BEGIN_HEADER
/* 26.6 fixed-point units). */ /* 26.6 fixed-point units). */
/* */ /* */
/* <Note> */ /* <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 */ /* flag is set in the `flags' field, otherwise a monochrome bitmap */
/* will be generated. */ /* 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 */ /* raster will call the `gray_spans' callback to draw gray pixel */
/* spans, in the case of an aa glyph bitmap, it will call */ /* 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 */ /* `black_spans', and `bit_test' and `bit_set' in the case of a */
@@ -919,10 +1044,10 @@ FT_BEGIN_HEADER
FT_Bitmap* target; FT_Bitmap* target;
void* source; void* source;
int flags; int flags;
FT_Raster_Span_Func gray_spans; FT_SpanFunc gray_spans;
FT_Raster_Span_Func black_spans; FT_SpanFunc black_spans;
FT_Raster_BitTest_Func bit_test; FT_Raster_BitTest_Func bit_test; /* doesn't work! */
FT_Raster_BitSet_Func bit_set; FT_Raster_BitSet_Func bit_set; /* doesn't work! */
void* user; void* user;
FT_BBox clip_box; FT_BBox clip_box;
@@ -932,7 +1057,7 @@ FT_BEGIN_HEADER
/*************************************************************************/ /*************************************************************************/
/* */ /* */
/* <FuncType> */ /* <FuncType> */
/* FT_Raster_New_Func */ /* FT_Raster_NewFunc */
/* */ /* */
/* <Description> */ /* <Description> */
/* A function used to create a new raster object. */ /* A function used to create a new raster object. */
@@ -954,14 +1079,15 @@ FT_BEGIN_HEADER
/* ignored by a given raster implementation. */ /* ignored by a given raster implementation. */
/* */ /* */
typedef int typedef int
(*FT_Raster_New_Func)( void* memory, (*FT_Raster_NewFunc)( void* memory,
FT_Raster* raster ); FT_Raster* raster );
#define FT_Raster_New_Func FT_Raster_NewFunc
/*************************************************************************/ /*************************************************************************/
/* */ /* */
/* <FuncType> */ /* <FuncType> */
/* FT_Raster_Done_Func */ /* FT_Raster_DoneFunc */
/* */ /* */
/* <Description> */ /* <Description> */
/* A function used to destroy a given raster object. */ /* A function used to destroy a given raster object. */
@@ -970,13 +1096,14 @@ FT_BEGIN_HEADER
/* raster :: A handle to the raster object. */ /* raster :: A handle to the raster object. */
/* */ /* */
typedef void typedef void
(*FT_Raster_Done_Func)( FT_Raster raster ); (*FT_Raster_DoneFunc)( FT_Raster raster );
#define FT_Raster_Done_Func FT_Raster_DoneFunc
/*************************************************************************/ /*************************************************************************/
/* */ /* */
/* <FuncType> */ /* <FuncType> */
/* FT_Raster_Reset_Func */ /* FT_Raster_ResetFunc */
/* */ /* */
/* <Description> */ /* <Description> */
/* FreeType provides an area of memory called the `render pool', */ /* FreeType provides an area of memory called the `render pool', */
@@ -1001,15 +1128,16 @@ FT_BEGIN_HEADER
/* recommended for efficiency purposes. */ /* recommended for efficiency purposes. */
/* */ /* */
typedef void typedef void
(*FT_Raster_Reset_Func)( FT_Raster raster, (*FT_Raster_ResetFunc)( FT_Raster raster,
unsigned char* pool_base, unsigned char* pool_base,
unsigned long pool_size ); unsigned long pool_size );
#define FT_Raster_Reset_Func FT_Raster_ResetFunc
/*************************************************************************/ /*************************************************************************/
/* */ /* */
/* <FuncType> */ /* <FuncType> */
/* FT_Raster_Set_Mode_Func */ /* FT_Raster_SetModeFunc */
/* */ /* */
/* <Description> */ /* <Description> */
/* This function is a generic facility to change modes or attributes */ /* 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. */ /* args :: A pointer to the new mode/property to use. */
/* */ /* */
typedef int typedef int
(*FT_Raster_Set_Mode_Func)( FT_Raster raster, (*FT_Raster_SetModeFunc)( FT_Raster raster,
unsigned long mode, unsigned long mode,
void* args ); void* args );
#define FT_Raster_Set_Mode_Func FT_Raster_SetModeFunc
/*************************************************************************/ /*************************************************************************/
/* */ /* */
/* <FuncType> */ /* <FuncType> */
/* FT_Raster_Render_Func */ /* FT_Raster_RenderFunc */
/* */ /* */
/* <Description> */ /* <Description> */
/* Invokes a given raster to scan-convert a given glyph image into a */ /* Invokes a given raster to scan-convert a given glyph image into a */
@@ -1065,9 +1194,10 @@ FT_BEGIN_HEADER
/* composition). */ /* composition). */
/* */ /* */
typedef int typedef int
(*FT_Raster_Render_Func)( FT_Raster raster, (*FT_Raster_RenderFunc)( FT_Raster raster,
FT_Raster_Params* params ); FT_Raster_Params* params );
#define FT_Raster_Render_Func FT_Raster_RenderFunc
/*************************************************************************/ /*************************************************************************/
/* */ /* */
@@ -1090,12 +1220,12 @@ FT_BEGIN_HEADER
/* */ /* */
typedef struct FT_Raster_Funcs_ typedef struct FT_Raster_Funcs_
{ {
FT_Glyph_Format glyph_format; FT_Glyph_Format glyph_format;
FT_Raster_New_Func raster_new; FT_Raster_NewFunc raster_new;
FT_Raster_Reset_Func raster_reset; FT_Raster_ResetFunc raster_reset;
FT_Raster_Set_Mode_Func raster_set_mode; FT_Raster_SetModeFunc raster_set_mode;
FT_Raster_Render_Func raster_render; FT_Raster_RenderFunc raster_render;
FT_Raster_Done_Func raster_done; FT_Raster_DoneFunc raster_done;
} FT_Raster_Funcs; } FT_Raster_Funcs;
+1 -1
View File
@@ -111,7 +111,7 @@ FT_BEGIN_HEADER
typedef struct FT_Module_Class_ typedef struct FT_Module_Class_
{ {
FT_ULong module_flags; FT_ULong module_flags;
FT_Int module_size; FT_Long module_size;
const FT_String* module_name; const FT_String* module_name;
FT_Fixed module_version; FT_Fixed module_version;
FT_Fixed module_requires; FT_Fixed module_requires;
+1 -1
View File
@@ -310,7 +310,7 @@ FT_BEGIN_HEADER
/* outline :: A pointer to the target outline descriptor. */ /* outline :: A pointer to the target outline descriptor. */
/* */ /* */
/* <Note> */ /* <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. */ /* the outline's `flags' field. */
/* */ /* */
/* It shouldn't be used by a normal client application, unless it */ /* It shouldn't be used by a normal client application, unless it */
+57 -41
View File
@@ -38,65 +38,81 @@ FT_BEGIN_HEADER
/* create a new glyph object */ /* create a new glyph object */
typedef FT_Error typedef FT_Error
(*FT_Glyph_Init_Func)( FT_Glyph glyph, (*FT_Glyph_InitFunc)( FT_Glyph glyph,
FT_GlyphSlot slot ); FT_GlyphSlot slot );
/* destroys a given glyph object */ /* destroys a given glyph object */
typedef void typedef void
(*FT_Glyph_Done_Func)( FT_Glyph glyph ); (*FT_Glyph_DoneFunc)( FT_Glyph glyph );
typedef void typedef void
(*FT_Glyph_Transform_Func)( FT_Glyph glyph, (*FT_Glyph_TransformFunc)( FT_Glyph glyph,
FT_Matrix* matrix, FT_Matrix* matrix,
FT_Vector* delta ); FT_Vector* delta );
typedef void typedef void
(*FT_Glyph_BBox_Func)( FT_Glyph glyph, (*FT_Glyph_GetBBoxFunc)( FT_Glyph glyph,
FT_BBox* abbox ); FT_BBox* abbox );
typedef FT_Error typedef FT_Error
(*FT_Glyph_Copy_Func)( FT_Glyph source, (*FT_Glyph_CopyFunc)( FT_Glyph source,
FT_Glyph target ); FT_Glyph target );
typedef FT_Error typedef FT_Error
(*FT_Glyph_Prepare_Func)( FT_Glyph glyph, (*FT_Glyph_PrepareFunc)( FT_Glyph glyph,
FT_GlyphSlot slot ); 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_ struct FT_Glyph_Class_
{ {
FT_UInt glyph_size; FT_Long glyph_size;
FT_Glyph_Format glyph_format; FT_Glyph_Format glyph_format;
FT_Glyph_Init_Func glyph_init; FT_Glyph_InitFunc glyph_init;
FT_Glyph_Done_Func glyph_done; FT_Glyph_DoneFunc glyph_done;
FT_Glyph_Copy_Func glyph_copy; FT_Glyph_CopyFunc glyph_copy;
FT_Glyph_Transform_Func glyph_transform; FT_Glyph_TransformFunc glyph_transform;
FT_Glyph_BBox_Func glyph_bbox; FT_Glyph_GetBBoxFunc glyph_bbox;
FT_Glyph_Prepare_Func glyph_prepare; FT_Glyph_PrepareFunc glyph_prepare;
}; };
typedef FT_Error typedef FT_Error
(*FTRenderer_render)( FT_Renderer renderer, (*FT_Renderer_RenderFunc)( FT_Renderer renderer,
FT_GlyphSlot slot, FT_GlyphSlot slot,
FT_UInt mode, FT_UInt mode,
FT_Vector* origin ); FT_Vector* origin );
typedef FT_Error typedef FT_Error
(*FTRenderer_transform)( FT_Renderer renderer, (*FT_Renderer_TransformFunc)( FT_Renderer renderer,
FT_GlyphSlot slot, FT_GlyphSlot slot,
FT_Matrix* matrix, FT_Matrix* matrix,
FT_Vector* delta ); FT_Vector* delta );
typedef void typedef void
(*FTRenderer_getCBox)( FT_Renderer renderer, (*FT_Renderer_GetCBoxFunc)( FT_Renderer renderer,
FT_GlyphSlot slot, FT_GlyphSlot slot,
FT_BBox* cbox ); FT_BBox* cbox );
typedef FT_Error typedef FT_Error
(*FTRenderer_setMode)( FT_Renderer renderer, (*FT_Renderer_SetModeFunc)( FT_Renderer renderer,
FT_ULong mode_tag, FT_ULong mode_tag,
FT_Pointer mode_ptr ); 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. */ /* 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. */ /* 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, */ /* is a pointer to the corresponding raster object, */
/* if any. */ /* if any. */
/* */ /* */
@@ -130,12 +146,12 @@ FT_BEGIN_HEADER
FT_Glyph_Format glyph_format; FT_Glyph_Format glyph_format;
FTRenderer_render render_glyph; FT_Renderer_RenderFunc render_glyph;
FTRenderer_transform transform_glyph; FT_Renderer_TransformFunc transform_glyph;
FTRenderer_getCBox get_glyph_cbox; FT_Renderer_GetCBoxFunc get_glyph_cbox;
FTRenderer_setMode set_mode; FT_Renderer_SetModeFunc set_mode;
FT_Raster_Funcs* raster_class; FT_Raster_Funcs* raster_class;
} FT_Renderer_Class; } FT_Renderer_Class;
+6 -8
View File
@@ -48,16 +48,14 @@ FT_BEGIN_HEADER
/* This code is completely experimental -- use with care! */ /* This code is completely experimental -- use with care! */
/* It will probably be completely rewritten in the future */ /* It will probably be completely rewritten in the future */
/* or even integrated into the library. */ /* or even integrated into the library. */
FT_EXPORT( FT_Error ) FT_EXPORT( void )
FT_Outline_Embolden( FT_GlyphSlot original, FT_GlyphSlot_Embolden( FT_GlyphSlot slot );
FT_Outline* outline,
FT_Pos* advance );
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 FT_END_HEADER
+17 -6
View File
@@ -1,6 +1,16 @@
#ifndef __FT_SYSTEM_IO_H__ #ifndef __FT_SYSTEM_IO_H__
#define __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 * designing custom streams is a bit different now
@@ -35,7 +45,7 @@
FT_BEGIN_HEADER FT_BEGIN_HEADER
/******************************************************************** /*@*******************************************************************
* *
* @type: FT_Stream * @type: FT_Stream
* *
@@ -45,7 +55,7 @@ FT_BEGIN_HEADER
typedef struct FT_StreamRec_* FT_Stream; typedef struct FT_StreamRec_* FT_Stream;
/******************************************************************** /*@*******************************************************************
* *
* @type: FT_Stream_Class * @type: FT_Stream_Class
* *
@@ -56,7 +66,7 @@ FT_BEGIN_HEADER
typedef const struct FT_Stream_ClassRec_* FT_Stream_Class; typedef const struct FT_Stream_ClassRec_* FT_Stream_Class;
/******************************************************************** /*@*******************************************************************
* *
* @functype: FT_Stream_ReadFunc * @functype: FT_Stream_ReadFunc
* *
@@ -76,7 +86,7 @@ FT_BEGIN_HEADER
FT_ULong size ); FT_ULong size );
/******************************************************************** /*@*******************************************************************
* *
* @functype: FT_Stream_SeekFunc * @functype: FT_Stream_SeekFunc
* *
@@ -93,7 +103,8 @@ FT_BEGIN_HEADER
typedef FT_Error (*FT_Stream_SeekFunc)( FT_Stream stream, typedef FT_Error (*FT_Stream_SeekFunc)( FT_Stream stream,
FT_ULong pos ); FT_ULong pos );
/********************************************************************
/*@*******************************************************************
* *
* @struct: FT_Stream_ClassRec * @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__READ(x) FT_STREAM_CLASS(x)->stream_read
#define FT_STREAM_CLASS__SEEK(x) FT_STREAM_CLASS(x)->stream_seek; #define FT_STREAM_CLASS__SEEK(x) FT_STREAM_CLASS(x)->stream_seek;
/******************************************************************** /*@*******************************************************************
* *
* @struct: FT_StreamRec * @struct: FT_StreamRec
* *
+20 -10
View File
@@ -5,7 +5,17 @@
FT_BEGIN_HEADER FT_BEGIN_HEADER
/*********************************************************************** /************************************************************************/
/************************************************************************/
/***** *****/
/***** NOTE: THE CONTENT OF THIS FILE IS NOT CURRENTLY USED *****/
/***** IN NORMAL BUILDS. CONSIDER IT EXPERIMENTAL. *****/
/***** *****/
/************************************************************************/
/************************************************************************/
/*@**********************************************************************
* *
* @type: FT_Memory * @type: FT_Memory
* *
@@ -20,7 +30,7 @@ FT_BEGIN_HEADER
typedef struct FT_MemoryRec_* FT_Memory; typedef struct FT_MemoryRec_* FT_Memory;
/*********************************************************************** /*@**********************************************************************
* *
* @functype: FT_Memory_AllocFunc * @functype: FT_Memory_AllocFunc
* *
@@ -39,7 +49,7 @@ FT_BEGIN_HEADER
FT_Pointer mem_data ); FT_Pointer mem_data );
/*********************************************************************** /*@**********************************************************************
* *
* @functype: FT_Memory_FreeFunc * @functype: FT_Memory_FreeFunc
* *
@@ -56,7 +66,7 @@ FT_BEGIN_HEADER
FT_Pointer mem_data ); FT_Pointer mem_data );
/*********************************************************************** /*@**********************************************************************
* *
* @functype: FT_Memory_ReallocFunc * @functype: FT_Memory_ReallocFunc
* *
@@ -76,7 +86,7 @@ FT_BEGIN_HEADER
FT_Pointer mem_data ); FT_Pointer mem_data );
/*********************************************************************** /*@**********************************************************************
* *
* @functype: FT_Memory_CreateFunc * @functype: FT_Memory_CreateFunc
* *
@@ -100,7 +110,7 @@ FT_BEGIN_HEADER
FT_Pointer *amem_data ); FT_Pointer *amem_data );
/*********************************************************************** /*@**********************************************************************
* *
* @functype: FT_Memory_DestroyFunc * @functype: FT_Memory_DestroyFunc
* *
@@ -115,7 +125,7 @@ FT_BEGIN_HEADER
FT_Pointer mem_data ); FT_Pointer mem_data );
/*********************************************************************** /*@**********************************************************************
* *
* @struct: FT_Memory_FuncsRec * @struct: FT_Memory_FuncsRec
* *
@@ -141,7 +151,7 @@ FT_BEGIN_HEADER
} FT_Memory_FuncsRec, *FT_Memory_Funcs; } FT_Memory_FuncsRec, *FT_Memory_Funcs;
/*********************************************************************** /*@**********************************************************************
* *
* @type: FT_Memory_Funcs * @type: FT_Memory_Funcs
* *
@@ -152,7 +162,7 @@ FT_BEGIN_HEADER
typedef const FT_Memory_FuncsRec* FT_Memory_Funcs; typedef const FT_Memory_FuncsRec* FT_Memory_Funcs;
/*********************************************************************** /*@**********************************************************************
* *
* @function: ft_memory_new * @function: ft_memory_new
* *
@@ -172,7 +182,7 @@ FT_BEGIN_HEADER
FT_Pointer mem_init_data ); FT_Pointer mem_init_data );
/*********************************************************************** /*@**********************************************************************
* *
* @function: ft_memory_destroy * @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 */ /* limit :: This field is set and used internally by FreeType */
/* when parsing frames. */ /* when parsing frames. */
/* */ /* */
struct FT_StreamRec_ typedef struct FT_StreamRec_
{ {
unsigned char* base; unsigned char* base;
unsigned long size; unsigned long size;
@@ -294,7 +294,8 @@ FT_BEGIN_HEADER
FT_Memory memory; FT_Memory memory;
unsigned char* cursor; unsigned char* cursor;
unsigned char* limit; unsigned char* limit;
};
} FT_StreamRec;
/* */ /* */
@@ -173,6 +173,28 @@ FT_BEGIN_HEADER
FT_Fixed y ); 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: */ /* @function: */
@@ -270,6 +292,28 @@ FT_BEGIN_HEADER
FT_Vector_Polarize( FT_Vector* vec, FT_Vector_Polarize( FT_Vector* vec,
FT_Fixed *length, FT_Fixed *length,
FT_Angle *angle ); 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 );
/* */ /* */
+27 -1
View File
@@ -21,6 +21,7 @@
#include <ft2build.h> #include <ft2build.h>
#include FT_CONFIG_CONFIG_H
#include FT_SYSTEM_H #include FT_SYSTEM_H
#include FT_IMAGE_H #include FT_IMAGE_H
@@ -43,7 +44,7 @@ FT_BEGIN_HEADER
/* */ /* */
/* <Description> */ /* <Description> */
/* This section contains the basic data types defined by FreeType 2, */ /* This section contains the basic data types defined by FreeType 2, */
/* ranging from simple scalar types to bitmap descriptors. More */ /* ranging from simple scalar types to bitmap descriptors. More */
/* font-specific structures are defined in a different section. */ /* font-specific structures are defined in a different section. */
/* */ /* */
/* <Order> */ /* <Order> */
@@ -356,6 +357,27 @@ FT_BEGIN_HEADER
} FT_Matrix; } 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> */ /* <FuncType> */
@@ -418,6 +440,10 @@ FT_BEGIN_HEADER
/* This macro converts four letter tags which are used to label */ /* This macro converts four letter tags which are used to label */
/* TrueType tables into an unsigned long to be used within FreeType. */ /* 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 ) \ #define FT_MAKE_TAG( _x1, _x2, _x3, _x4 ) \
( ( (FT_ULong)_x1 << 24 ) | \ ( ( (FT_ULong)_x1 << 24 ) | \
( (FT_ULong)_x2 << 16 ) | \ ( (FT_ULong)_x2 << 16 ) | \
@@ -176,7 +176,7 @@ FT_BEGIN_HEADER
FT_GlyphSlot slot, FT_GlyphSlot slot,
FT_Size size, FT_Size size,
FT_UInt glyph_index, FT_UInt glyph_index,
FT_ULong load_flags ); FT_Int32 load_flags );
/*************************************************************************/ /*************************************************************************/
@@ -68,8 +68,9 @@ FT_BEGIN_HEADER
FT_UInt format; FT_UInt format;
FT_ULong offset; FT_ULong offset;
FT_UShort* sids; FT_UInt count;
FT_UShort* codes; FT_UShort sids [256]; /* avoid dynamic allocations */
FT_UShort codes[256];
} CFF_EncodingRec, *CFF_Encoding; } CFF_EncodingRec, *CFF_Encoding;
@@ -241,6 +242,9 @@ FT_BEGIN_HEADER
/* interface to PostScript hinter */ /* interface to PostScript hinter */
void* pshinter; void* pshinter;
/* interface to Postscript Names service */
void* psnames;
} CFF_FontRec, *CFF_Font; } CFF_FontRec, *CFF_Font;
@@ -13,6 +13,11 @@
/* this file you indicate that you have read the license and */ /* this file you indicate that you have read the license and */
/* understand and accept it fully. */ /* 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. */
/* */
/***************************************************************************/ /***************************************************************************/
@@ -47,10 +52,10 @@ FT_BEGIN_HEADER
#define FT_TRACE_DEF( x ) trace_ ## x , #define FT_TRACE_DEF( x ) trace_ ## x ,
/* defining the enumeration */ /* defining the enumeration */
typedef enum typedef enum
{ {
#include FT_INTERNAL_TRACE_H #include FT_INTERNAL_TRACE_H
trace_count trace_count
} FT_Trace; } FT_Trace;
@@ -68,7 +68,7 @@ FT_BEGIN_HEADER
(*FT_Slot_LoadFunc)( FT_GlyphSlot slot, (*FT_Slot_LoadFunc)( FT_GlyphSlot slot,
FT_Size size, FT_Size size,
FT_UInt glyph_index, FT_UInt glyph_index,
FT_Int load_flags ); FT_Int32 load_flags );
typedef FT_UInt typedef FT_UInt
@@ -186,12 +186,10 @@ FT_BEGIN_HEADER
FT_Size_ResetPixelsFunc set_pixel_sizes; FT_Size_ResetPixelsFunc set_pixel_sizes;
FT_Slot_LoadFunc load_glyph; FT_Slot_LoadFunc load_glyph;
FT_CharMap_CharIndexFunc get_char_index;
FT_Face_GetKerningFunc get_kerning; FT_Face_GetKerningFunc get_kerning;
FT_Face_AttachFunc attach_file; FT_Face_AttachFunc attach_file;
FT_Face_GetAdvancesFunc get_advances; FT_Face_GetAdvancesFunc get_advances;
FT_CharMap_CharNextFunc get_next_char;
} FT_Driver_ClassRec, *FT_Driver_Class; } 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: * @description:
* a function used to compare two nodes of the hash table * 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. * 1 iff the 'keys' in 'node1' and 'node2' are identical.
* 0 otherwise. * 0 otherwise.
*/ */
typedef FT_Int (*FT_Hash_CompareFunc)( const FT_HashNode node1, typedef FT_Int (*FT_Hash_EqualFunc)( FT_HashNode node1,
const FT_HashNode node2 ); FT_HashNode node2 );
/*********************************************************** /***********************************************************
@@ -106,18 +118,14 @@ FT_BEGIN_HEADER
*/ */
typedef struct FT_HashRec_ typedef struct FT_HashRec_
{ {
FT_Memory memory;
FT_HashNode* buckets; FT_HashNode* buckets;
FT_UInt p; FT_UInt p;
FT_UInt mask; /* really maxp-1 */ FT_UInt mask; /* really maxp-1 */
FT_UInt slack; FT_Long slack;
FT_Hash_EqualFunc node_equal;
FT_Memory memory;
} FT_HashRec;
FT_UInt node_size;
FT_Hash_CompareFunc node_compare;
FT_Hash_ComputeFunc node_hash;
} FT_HashRec, *FT_Hash;
/*********************************************************** /***********************************************************
@@ -168,36 +176,39 @@ FT_BEGIN_HEADER
* initialize a dynamic hash table * initialize a dynamic hash table
* *
* @input: * @input:
* table :: handle to target hash table structure * table :: handle to target hash table structure
* compare :: node comparison function * node_equal :: node comparison function
* memory :: memory manager handle used to allocate the * memory :: memory manager handle used to allocate the
* buckets array within the hash table * buckets array within the hash table
*
* @return:
* error code. 0 means success
* *
* @note: * @note:
* the node comparison function should only compare node _keys_ * the node comparison function should only compare node _keys_
* and ignore values !! with good hashing computation (which the * and ignore values !! with good hashing computation (which the
* user must perform itself), the comparison function should be * user must perform itself), the comparison function should be
* pretty selfom called. * pretty seldom called.
* *
* here is a simple example: * here is a simple example:
* *
* { * {
* static int my_compare( const MyNode node1, * static int my_equal( MyNode node1,
* const MyNode node2 ) * MyNode node2 )
* { * {
* // compare keys of 'node1' and '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_init( FT_Hash table,
FT_Hash_CompareFunc compare, FT_Hash_EqualFunc compare,
FT_Memory memory ); 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_hash_lookup( FT_Hash table,
FT_HashNode keynode ) FT_HashNode keynode );
/**************************************************************** /****************************************************************
@@ -273,10 +284,13 @@ FT_BEGIN_HEADER
* *
* @input: * @input:
* table :: hash table handle * 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 * new_node :: handle to new hash node. All its fields must be correctly
* set, including 'hash'. * set, including 'hash'.
* *
* @return:
* error code. 0 means success
*
* @note: * @note:
* this function should always be used _after_ a call to @ft_hash_lookup * 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: * that returns a pointer to a NULL handle. Here's an example:
@@ -308,18 +322,21 @@ FT_BEGIN_HEADER
* *
* // allocate a new node - and set it up * // allocate a new node - and set it up
* node = (MyNode) malloc( sizeof(*node) ); * node = (MyNode) malloc( sizeof(*node) );
* if ( node == NULL ) .....
*
* node->hnode.hash = noderec.hnode.hash; * node->hnode.hash = noderec.hnode.hash;
* node->key = key; * node->key = key;
* node->value = value; * node->value = value;
* *
* // add it to the hash table * // 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_hash_add( FT_Hash table,
FT_HashNode* pnode, FT_HashLookup lookup,
FT_HashNode new_node ); FT_HashNode new_node );
/**************************************************************** /****************************************************************
@@ -332,7 +349,7 @@ FT_BEGIN_HEADER
* *
* @input: * @input:
* table :: hash table handle * 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: * @note:
* this function doesn't free the node itself !! Here's an example: * this function doesn't free the node itself !! Here's an example:
@@ -354,15 +371,16 @@ FT_BEGIN_HEADER
* node = *pnode; * node = *pnode;
* if ( node != NULL ) * if ( node != NULL )
* { * {
* ft_hash_remove( table, pnode ); * error = ft_hash_remove( table, pnode );
* free( node ); * if ( !error )
* free( node );
* } * }
* } * }
* } * }
*/ */
FT_BASE( void ) FT_BASE( FT_Error )
ft_hash_remove( FT_Hash table, ft_hash_remove( FT_Hash table,
FT_HashNode* pnode ); FT_HashLookup lookup );
@@ -140,14 +140,11 @@ FT_BEGIN_HEADER
* object :: target object handle * object :: target object handle
* init_data :: optional pointer to initialization data * init_data :: optional pointer to initialization data
* *
* @throws: any * @return:
* * error code. 0 means success
* 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.
*/ */
typedef void (*FT_Object_InitFunc)( FT_Object object, typedef FT_Error (*FT_Object_InitFunc)( FT_Object object,
FT_Pointer init_data ); FT_Pointer init_data );
/************************************************************** /**************************************************************
* *
@@ -158,8 +155,6 @@ FT_BEGIN_HEADER
* *
* @input: * @input:
* object :: handle to target object * object :: handle to target object
*
* @throws: *never* !!
*/ */
typedef void (*FT_Object_DoneFunc)( FT_Object object ); typedef void (*FT_Object_DoneFunc)( FT_Object object );
@@ -179,12 +174,15 @@ FT_BEGIN_HEADER
* object sub-system.) * object sub-system.)
* *
* magic :: a 32-bit magic number used for decoding * magic :: a 32-bit magic number used for decoding
* super :: pointer to super class
* type :: the @FT_Type descriptor of this class * type :: the @FT_Type descriptor of this class
* memory :: the current memory manager handle * memory :: the current memory manager handle
* library :: the current library handle * library :: the current library handle
* info :: an opaque pointer to class-specific information * info :: an opaque pointer to class-specific information
* managed by the FreeType object sub-system * managed by the FreeType object sub-system
* *
* class_done :: the class destructor function
*
* obj_size :: size of class instances in bytes * obj_size :: size of class instances in bytes
* obj_init :: class instance constructor * obj_init :: class instance constructor
* obj_done :: class instance destructor * obj_done :: class instance destructor
@@ -193,11 +191,14 @@ FT_BEGIN_HEADER
{ {
FT_ObjectRec object; FT_ObjectRec object;
FT_UInt32 magic; FT_UInt32 magic;
FT_Class super;
FT_Type type; FT_Type type;
FT_Memory memory; FT_Memory memory;
FT_Library library; FT_Library library;
FT_Pointer info; FT_Pointer info;
FT_Object_DoneFunc class_done;
FT_UInt obj_size; FT_UInt obj_size;
FT_Object_InitFunc obj_init; FT_Object_InitFunc obj_init;
FT_Object_DoneFunc obj_done; FT_Object_DoneFunc obj_done;
@@ -287,14 +288,17 @@ FT_BEGIN_HEADER
* *
* @note: * @note:
* if 'obj_init' is NULL, the class will use it's parent * 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 * 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 object sub-system allocates a new class, copies
* the content of its super-class into the new structure, * the content of its super-class into the new structure,
* _then_ calls 'clazz_init'. * _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_ typedef struct FT_TypeRec_
{ {
@@ -336,7 +340,7 @@ FT_BEGIN_HEADER
* @return: * @return:
* 1 iff the handle points to a valid object. 0 otherwise * 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 ); ft_object_check( FT_Pointer obj );
@@ -356,88 +360,174 @@ FT_BEGIN_HEADER
* 1 iff the handle points to a valid 'clazz' instance. 0 * 1 iff the handle points to a valid 'clazz' instance. 0
* otherwise. * otherwise.
*/ */
FT_BASE_DEF( FT_Int ) FT_BASE( FT_Int )
ft_object_is_a( FT_Pointer obj, ft_object_is_a( FT_Pointer obj,
FT_Class clazz ); 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 * @function: ft_object_create
* *
* @description: * @description:
* a variation of @ft_object_new that should be used when * create a new object (class instance)
* 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.
* *
* @output: * @output:
* pobject :: new object handle * aobject :: new object handle. NULL in case of error
* *
* @input: * @input:
* clazz :: object's class pointer * clazz :: object's class pointer
* init_data :: optional pointer to initialization data * 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_BASE( FT_Error )
ft_object_create( FT_Object *pobject, ft_object_create( FT_Object *aobject,
FT_Class clazz, FT_Class clazz,
FT_Pointer init_data ); FT_Pointer init_data );
/* */
FT_BASE_DEF( FT_Class ) /**************************************************************
ft_class_find_by_type( FT_Type type, *
FT_Memory memory ); * @function: ft_object_create_from_type
*
FT_BASE_DEF( FT_Class ) * @description:
ft_class_find_by_name( FT_CString class_name, * create a new object (class instance) from a @FT_Type
FT_Memory memory ); *
* @output:
FT_BASE_DEF( FT_Object ) * aobject :: new object handle. NULL in case of error
ft_object_new_from_type( FT_Type type, *
FT_Pointer data, * @input:
FT_Memory memory ); * type :: object's type descriptor
* init_data :: optional pointer to initialization data
FT_BASE_DEF( void ) *
ft_object_create_from_type( FT_Object *pobject, * @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_Type type,
FT_Pointer init_data, 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 FT_END_HEADER
#endif /* __FT_OBJECT_H__ */ #endif /* __FT_OBJECT_H__ */
@@ -34,6 +34,11 @@
#include FT_INTERNAL_GLYPH_LOADER_H #include FT_INTERNAL_GLYPH_LOADER_H
#include FT_INTERNAL_DRIVER_H #include FT_INTERNAL_DRIVER_H
#include FT_INTERNAL_AUTOHINT_H #include FT_INTERNAL_AUTOHINT_H
#include FT_INTERNAL_OBJECT_H
#ifdef FT_CONFIG_OPTION_INCREMENTAL
#include FT_INCREMENTAL_H
#endif
FT_BEGIN_HEADER FT_BEGIN_HEADER
@@ -291,8 +296,19 @@ FT_BEGIN_HEADER
/* transform_flags :: Some flags used to classify the transform. */ /* transform_flags :: Some flags used to classify the transform. */
/* Only used by the convenience functions. */ /* 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. */ /* 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_ typedef struct FT_Face_InternalRec_
{ {
FT_UShort max_points; FT_UShort max_points;
@@ -302,8 +318,14 @@ FT_BEGIN_HEADER
FT_Vector transform_delta; FT_Vector transform_delta;
FT_Int transform_flags; FT_Int transform_flags;
FT_UInt32 hint_flags;
const char* postscript_name; const char* postscript_name;
#ifdef FT_CONFIG_OPTION_INCREMENTAL
FT_Incremental_InterfaceRec* incremental_interface;
#endif
} FT_Face_InternalRec; } FT_Face_InternalRec;
@@ -534,14 +556,14 @@ FT_BEGIN_HEADER
typedef struct FT_RendererRec_ typedef struct FT_RendererRec_
{ {
FT_ModuleRec root; FT_ModuleRec root;
FT_Renderer_Class* clazz; FT_Renderer_Class* clazz;
FT_Glyph_Format glyph_format; FT_Glyph_Format glyph_format;
FT_Glyph_Class glyph_class; FT_Glyph_Class glyph_class;
FT_Raster raster; FT_Raster raster;
FT_Raster_Render_Func raster_render; FT_Raster_Render_Func raster_render;
FTRenderer_render render; FT_Renderer_RenderFunc render;
} FT_RendererRec; } FT_RendererRec;
@@ -656,7 +678,7 @@ FT_BEGIN_HEADER
/* shortcut used to avoid parsing the list on */ /* shortcut used to avoid parsing the list on */
/* each call to FT_Outline_Render(). It is a */ /* each call to FT_Outline_Render(). It is a */
/* handle to the current renderer for the */ /* handle to the current renderer for the */
/* ft_glyph_format_outline format. */ /* FT_GLYPH_FORMAT_OUTLINE format. */
/* */ /* */
/* auto_hinter :: XXX */ /* auto_hinter :: XXX */
/* */ /* */
@@ -690,6 +712,8 @@ FT_BEGIN_HEADER
FT_DebugHook_Func debug_hooks[4]; FT_DebugHook_Func debug_hooks[4];
FT_MetaClassRec meta_class;
} FT_LibraryRec; } FT_LibraryRec;
@@ -699,9 +723,9 @@ FT_BEGIN_HEADER
FT_ListNode* node ); FT_ListNode* node );
FT_BASE( FT_Error ) FT_BASE( FT_Error )
FT_Render_Glyph_Internal( FT_Library library, FT_Render_Glyph_Internal( FT_Library library,
FT_GlyphSlot slot, FT_GlyphSlot slot,
FT_UInt render_mode ); FT_Render_Mode render_mode );
typedef const char* typedef const char*
(*FT_Face_GetPostscriptNameFunc)( FT_Face face ); (*FT_Face_GetPostscriptNameFunc)( FT_Face face );
@@ -21,6 +21,7 @@
#include <ft2build.h> #include <ft2build.h>
#include FT_SYSTEM_H
#include FT_INTERNAL_OBJECTS_H #include FT_INTERNAL_OBJECTS_H
@@ -387,7 +388,7 @@ FT_BEGIN_HEADER
FT_BASE( void ) FT_BASE( void )
FT_Stream_ReleaseFrame( FT_Stream stream, FT_Stream_ReleaseFrame( FT_Stream stream,
FT_Byte** pbytes ); FT_Byte** pbytes );
/* read a byte from an entered frame */ /* read a byte from an entered frame */
FT_BASE( FT_Char ) FT_BASE( FT_Char )
FT_Stream_GetChar( FT_Stream stream ); FT_Stream_GetChar( FT_Stream stream );
@@ -35,6 +35,8 @@
#define FT_INTERNAL_TRACE_H <freetype/internal/fttrace.h> #define FT_INTERNAL_TRACE_H <freetype/internal/fttrace.h>
#define FT_INTERNAL_GLYPH_LOADER_H <freetype/internal/ftgloadr.h> #define FT_INTERNAL_GLYPH_LOADER_H <freetype/internal/ftgloadr.h>
#define FT_INTERNAL_SFNT_H <freetype/internal/sfnt.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_TRUETYPE_TYPES_H <freetype/internal/tttypes.h>
#define FT_INTERNAL_TYPE1_TYPES_H <freetype/internal/t1types.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_CFF_TYPES_H <freetype/internal/cfftypes.h>
#define FT_INTERNAL_FNT_TYPES_H <freetype/internal/fnttypes.h> #define FT_INTERNAL_FNT_TYPES_H <freetype/internal/fnttypes.h>
#define FT_INTERNAL_BDF_TYPES_H <freetype/internal/bdftypes.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_NAMES_H <freetype/internal/psnames.h>
#define FT_INTERNAL_POSTSCRIPT_AUX_H <freetype/internal/psaux.h> #define FT_INTERNAL_POSTSCRIPT_AUX_H <freetype/internal/psaux.h>
@@ -38,10 +38,12 @@ FT_BEGIN_HEADER
typedef struct PCF_Public_FaceRec_ typedef struct PCF_Public_FaceRec_
{ {
FT_FaceRec root; FT_FaceRec root;
FT_StreamRec gzip_stream;
FT_Stream gzip_source;
char* charset_encoding; char* charset_encoding;
char* charset_registry; char* charset_registry;
} PCF_Public_FaceRec, *PCF_Public_Face; } PCF_Public_FaceRec, *PCF_Public_Face;
@@ -142,10 +142,10 @@ FT_BEGIN_HEADER
typedef struct PS_ParserRec_* PS_Parser; typedef struct PS_ParserRec_* PS_Parser;
typedef struct T1_TokenRec_* T1_Token; typedef struct T1_TokenRec_* T1_Token;
typedef struct T1_FieldRec_* T1_Field; typedef struct T1_FieldRec_* T1_Field;
/* simple enumeration type used to identify token types */ /* simple enumeration type used to identify token types */
typedef enum T1_TokenType_ typedef enum T1_TokenType_
{ {
@@ -178,6 +178,7 @@ FT_BEGIN_HEADER
T1_FIELD_TYPE_INTEGER, T1_FIELD_TYPE_INTEGER,
T1_FIELD_TYPE_FIXED, T1_FIELD_TYPE_FIXED,
T1_FIELD_TYPE_STRING, T1_FIELD_TYPE_STRING,
T1_FIELD_TYPE_BBOX,
T1_FIELD_TYPE_INTEGER_ARRAY, T1_FIELD_TYPE_INTEGER_ARRAY,
T1_FIELD_TYPE_FIXED_ARRAY, T1_FIELD_TYPE_FIXED_ARRAY,
T1_FIELD_TYPE_CALLBACK, T1_FIELD_TYPE_CALLBACK,
@@ -194,6 +195,7 @@ FT_BEGIN_HEADER
T1_FIELD_LOCATION_FONT_DICT, T1_FIELD_LOCATION_FONT_DICT,
T1_FIELD_LOCATION_FONT_INFO, T1_FIELD_LOCATION_FONT_INFO,
T1_FIELD_LOCATION_PRIVATE, T1_FIELD_LOCATION_PRIVATE,
T1_FIELD_LOCATION_BBOX,
/* do not remove */ /* do not remove */
T1_FIELD_LOCATION_MAX T1_FIELD_LOCATION_MAX
@@ -271,6 +273,10 @@ FT_BEGIN_HEADER
#define T1_FIELD_STRING( _ident, _fname ) \ #define T1_FIELD_STRING( _ident, _fname ) \
T1_NEW_SIMPLE_FIELD( _ident, T1_FIELD_TYPE_STRING, _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 ) \ #define T1_FIELD_NUM_TABLE( _ident, _fname, _fmax ) \
T1_NEW_TABLE_FIELD( _ident, T1_FIELD_TYPE_INTEGER_ARRAY, \ T1_NEW_TABLE_FIELD( _ident, T1_FIELD_TYPE_INTEGER_ARRAY, \
_fname, _fmax ) _fname, _fmax )
@@ -388,7 +394,7 @@ FT_BEGIN_HEADER
FT_Memory memory; FT_Memory memory;
PS_Parser_FuncsRec funcs; PS_Parser_FuncsRec funcs;
} PS_ParserRec; } PS_ParserRec;
@@ -544,7 +550,7 @@ FT_BEGIN_HEADER
void* hints_globals; /* hinter-specific */ void* hints_globals; /* hinter-specific */
T1_Builder_FuncsRec funcs; T1_Builder_FuncsRec funcs;
} T1_BuilderRec; } T1_BuilderRec;
@@ -604,6 +610,7 @@ FT_BEGIN_HEADER
FT_Byte** glyph_names, FT_Byte** glyph_names,
PS_Blend blend, PS_Blend blend,
FT_Bool hinting, FT_Bool hinting,
FT_Render_Mode hint_mode,
T1_Decoder_Callback callback ); T1_Decoder_Callback callback );
void void
@@ -613,7 +620,7 @@ FT_BEGIN_HEADER
(*parse_charstrings)( T1_Decoder decoder, (*parse_charstrings)( T1_Decoder decoder,
FT_Byte* base, FT_Byte* base,
FT_UInt len ); FT_UInt len );
} T1_Decoder_FuncsRec; } T1_Decoder_FuncsRec;
@@ -645,9 +652,12 @@ FT_BEGIN_HEADER
PS_Blend blend; /* for multiple master support */ PS_Blend blend; /* for multiple master support */
FT_UInt32 hint_flags;
FT_Render_Mode hint_mode;
T1_Decoder_Callback parse_callback; T1_Decoder_Callback parse_callback;
T1_Decoder_FuncsRec funcs; T1_Decoder_FuncsRec funcs;
} T1_DecoderRec; } T1_DecoderRec;
@@ -667,9 +677,9 @@ FT_BEGIN_HEADER
FT_CMap_Class expert; FT_CMap_Class expert;
FT_CMap_Class custom; FT_CMap_Class custom;
FT_CMap_Class unicode; FT_CMap_Class unicode;
} T1_CMap_ClassesRec; } T1_CMap_ClassesRec;
/*************************************************************************/ /*************************************************************************/
/*************************************************************************/ /*************************************************************************/
@@ -261,11 +261,13 @@ FT_BEGIN_HEADER
/* been recorded. */ /* been recorded. */
/* */ /* */
/* @input: */ /* @input: */
/* hints :: A handle to the Type 1 hints recorder. */ /* hints :: A handle to the Type 1 hints recorder. */
/* */ /* */
/* outline :: A pointer to the target outline descriptor. */ /* outline :: A pointer to the target outline descriptor. */
/* */ /* */
/* globals :: The hinter globals for this font. */ /* globals :: The hinter globals for this font. */
/* */
/* hint_flags :: Hinter bit flags. */
/* */ /* */
/* @return: */ /* @return: */
/* FreeType error code. 0 means success. */ /* FreeType error code. 0 means success. */
@@ -278,9 +280,10 @@ FT_BEGIN_HEADER
/* which must correspond to the same font as the glyph. */ /* which must correspond to the same font as the glyph. */
/* */ /* */
typedef FT_Error typedef FT_Error
(*T1_Hints_ApplyFunc)( T1_Hints hints, (*T1_Hints_ApplyFunc)( T1_Hints hints,
FT_Outline* outline, FT_Outline* outline,
PSH_Globals globals ); PSH_Globals globals,
FT_Render_Mode hint_mode );
/*************************************************************************/ /*************************************************************************/
@@ -539,11 +542,13 @@ FT_BEGIN_HEADER
/* method. */ /* method. */
/* */ /* */
/* @input: */ /* @input: */
/* hints :: A handle to the Type 2 hints recorder. */ /* hints :: A handle to the Type 2 hints recorder. */
/* */ /* */
/* outline :: A pointer to the target outline descriptor. */ /* outline :: A pointer to the target outline descriptor. */
/* */ /* */
/* globals :: The hinter globals for this font. */ /* globals :: The hinter globals for this font. */
/* */
/* hint_flags :: Hinter bit flags. */
/* */ /* */
/* @return: */ /* @return: */
/* FreeType error code. 0 means success. */ /* FreeType error code. 0 means success. */
@@ -556,9 +561,10 @@ FT_BEGIN_HEADER
/* which must correspond to the same font than the glyph. */ /* which must correspond to the same font than the glyph. */
/* */ /* */
typedef FT_Error typedef FT_Error
(*T2_Hints_ApplyFunc)( T2_Hints hints, (*T2_Hints_ApplyFunc)( T2_Hints hints,
FT_Outline* outline, 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 */ /* This function will not be compiled if the configuration macro */
/* FT_CONFIG_OPTION_ADOBE_GLYPH_LIST is undefined. */ /* FT_CONFIG_OPTION_ADOBE_GLYPH_LIST is undefined. */
/* */ /* */
typedef FT_ULong typedef FT_UInt32
(*PS_Unicode_Value_Func)( const char* glyph_name ); (*PS_Unicode_Value_Func)( const char* glyph_name );
@@ -100,6 +100,8 @@ FT_BEGIN_HEADER
FT_UShort entry_selector; FT_UShort entry_selector;
FT_UShort range_shift; FT_UShort range_shift;
FT_ULong offset; /* not in file */
} SFNT_HeaderRec, *SFNT_Header; } SFNT_HeaderRec, *SFNT_Header;
@@ -1481,18 +1483,9 @@ FT_BEGIN_HEADER
TT_OS2 os2; /* TrueType OS/2 table */ TT_OS2 os2; /* TrueType OS/2 table */
TT_Postscript postscript; /* TrueType Postscript table */ TT_Postscript postscript; /* TrueType Postscript table */
#ifdef FT_CONFIG_OPTION_USE_CMAPS
FT_Byte* cmap_table; /* extracted 'cmap' table */ FT_Byte* cmap_table; /* extracted 'cmap' table */
FT_ULong cmap_size; 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_GotoTableFunc goto_table;
TT_Loader_StartGlyphFunc access_glyph_frame; TT_Loader_StartGlyphFunc access_glyph_frame;
@@ -1525,10 +1518,10 @@ FT_BEGIN_HEADER
TT_PCLT pclt; TT_PCLT pclt;
/* embedded bitmaps support */ /* embedded bitmaps support */
FT_Int num_sbit_strikes; FT_ULong num_sbit_strikes;
TT_SBit_Strike sbit_strikes; TT_SBit_Strike sbit_strikes;
FT_Int num_sbit_scales; FT_ULong num_sbit_scales;
TT_SBit_Scale sbit_scales; TT_SBit_Scale sbit_scales;
/* postscript names table */ /* postscript names table */
+3 -1
View File
@@ -208,7 +208,7 @@ FT_BEGIN_HEADER
#define T1_MAX_MM_DESIGNS 16 #define T1_MAX_MM_DESIGNS 16
/* maximum number of Multiple Masters axes, as defined in the spec */ /* maximum number of Multiple Masters axes, as defined in the spec */
#define T1_MAX_MM_AXIS 4 #define T1_MAX_MM_AXIS 4
/* maximum number of elements in a design map */ /* maximum number of elements in a design map */
#define T1_MAX_MM_MAP_POINTS 20 #define T1_MAX_MM_MAP_POINTS 20
@@ -244,6 +244,8 @@ FT_BEGIN_HEADER
FT_ULong blend_bitflags; FT_ULong blend_bitflags;
FT_BBox* bboxes [T1_MAX_MM_DESIGNS + 1];
} PS_BlendRec, *PS_Blend; } PS_BlendRec, *PS_Blend;
+196 -39
View File
@@ -4,7 +4,7 @@
/* */ /* */
/* TrueType name ID definitions (specification only). */ /* TrueType name ID definitions (specification only). */
/* */ /* */
/* Copyright 1996-2001 by */ /* Copyright 1996-2002 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */ /* */
/* This file is part of the FreeType project, and may only be used, */ /* 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 */ /* Possible values for the `platform' identifier code in the name */
/* records of the TTF `name' table. */ /* 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_APPLE_UNICODE 0
#define TT_PLATFORM_MACINTOSH 1 #define TT_PLATFORM_MACINTOSH 1
#define TT_PLATFORM_ISO 2 /* deprecated */ #define TT_PLATFORM_ISO 2 /* deprecated */
#define TT_PLATFORM_MICROSOFT 3 #define TT_PLATFORM_MICROSOFT 3
#define TT_PLATFORM_CUSTOM 4 #define TT_PLATFORM_CUSTOM 4
#define TT_PLATFORM_ADOBE 7 /* artificial */
/* artificial values defined ad-hoc by FreeType */
#define TT_PLATFORM_ADOBE 7
/*************************************************************************/ /***********************************************************************
/* */ *
/* Possible values of the platform specific encoding identifier field in */ * @enum:
/* the name records of the TTF `name' table if the `platform' identifier */ * TT_APPLE_ID_XXX
/* code is TT_PLATFORM_APPLE_UNICODE. */ *
/* */ * @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_DEFAULT 0 /* Unicode 1.0 */
#define TT_APPLE_ID_UNICODE_1_1 1 /* specify Hangul at U+34xx */ #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_ISO_10646 2 /* deprecated */
#define TT_APPLE_ID_UNICODE_2_0 3 /* or later */ #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 */ * @enum:
/* the name records of the TTF `name' table if the `platform' identifier */ * TT_MAC_ID_XXX
/* code is TT_PLATFORM_MACINTOSH. */ *
/* */ * @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_ROMAN 0
#define TT_MAC_ID_JAPANESE 1 #define TT_MAC_ID_JAPANESE 1
#define TT_MAC_ID_TRADITIONAL_CHINESE 2 #define TT_MAC_ID_TRADITIONAL_CHINESE 2
@@ -95,25 +195,72 @@ FT_BEGIN_HEADER
#define TT_MAC_ID_UNINTERP 32 #define TT_MAC_ID_UNINTERP 32
/*************************************************************************/ /***********************************************************************
/* */ *
/* Possible values of the platform specific encoding identifier field in */ * @enum:
/* the name records of the TTF `name' table if the `platform' identifier */ * TT_ISO_ID_XXX
/* code is TT_PLATFORM_ISO. */ *
/* */ * @description:
/* This use is now deprecated. */ * 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_7BIT_ASCII 0
#define TT_ISO_ID_10646 1 #define TT_ISO_ID_10646 1
#define TT_ISO_ID_8859_1 2 #define TT_ISO_ID_8859_1 2
/*************************************************************************/ /***********************************************************************
/* */ *
/* possible values of the platform specific encoding identifier field in */ * @enum:
/* the name records of the TTF `name' table if the `platform' identifier */ * TT_MS_ID_XXX
/* code is TT_PLATFORM_MICROSOFT. */ *
/* */ * @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_SYMBOL_CS 0
#define TT_MS_ID_UNICODE_CS 1 #define TT_MS_ID_UNICODE_CS 1
#define TT_MS_ID_SJIS 2 #define TT_MS_ID_SJIS 2
@@ -124,14 +271,24 @@ FT_BEGIN_HEADER
#define TT_MS_ID_UCS_4 10 #define TT_MS_ID_UCS_4 10
/*************************************************************************/ /***********************************************************************
/* */ *
/* possible values of the platform specific encoding identifier field in */ * @enum:
/* the name records of the TTF `name' table if the `platform' identifier */ * TT_ADOBE_ID_XXX
/* code is TT_PLATFORM_ADOBE. */ *
/* */ * @description:
/* These are artificial values defined ad-hoc by FreeType. */ * 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_STANDARD 0
#define TT_ADOBE_ID_EXPERT 1 #define TT_ADOBE_ID_EXPERT 1
#define TT_ADOBE_ID_CUSTOM 2 #define TT_ADOBE_ID_CUSTOM 2
@@ -545,7 +702,7 @@ FT_BEGIN_HEADER
/* sublanguage > 0x1F. */ /* sublanguage > 0x1F. */
#define TT_MS_LANGID_SPANISH_LATIN_AMERICA 0xE40a #define TT_MS_LANGID_SPANISH_LATIN_AMERICA 0xE40a
#define TT_MS_LANGID_FRENCH_NORTH_AFRICA 0xE40c #define TT_MS_LANGID_FRENCH_NORTH_AFRICA 0xE40c
#define TT_MS_LANGID_FRENCH_MOROCCO 0x380c #define TT_MS_LANGID_FRENCH_MOROCCO 0x380c
#define TT_MS_LANGID_FRENCH_HAITI 0x3c0c #define TT_MS_LANGID_FRENCH_HAITI 0x3c0c
#define TT_MS_LANGID_BENGALI_BANGLADESH 0x0845 #define TT_MS_LANGID_BENGALI_BANGLADESH 0x0845
+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 */ /* END */
+5
View File
@@ -51,6 +51,11 @@ FT_BEGIN_HEADER
ah_angle( FT_Vector* v ); ah_angle( FT_Vector* v );
FT_LOCAL( AH_Angle )
ah_angle_diff( AH_Angle angle1,
AH_Angle angle2 );
FT_END_HEADER FT_END_HEADER
#endif /* __AHANGLES_H__ */ #endif /* __AHANGLES_H__ */
+25 -25
View File
@@ -28,7 +28,7 @@
#define MAX_TEST_CHARACTERS 12 #define MAX_TEST_CHARACTERS 12
static static
const char* blue_chars[ah_blue_max] = const char* blue_chars[AH_BLUE_MAX] =
{ {
"THEZOCQS", "THEZOCQS",
"HEZLOCUS", "HEZLOCUS",
@@ -43,7 +43,8 @@
sort_values( FT_Int count, sort_values( FT_Int count,
FT_Pos* table ) FT_Pos* table )
{ {
FT_Int i, j, swap; FT_Int i, j;
FT_Pos swap;
for ( i = 1; i < count; i++ ) for ( i = 1; i < count; i++ )
@@ -62,10 +63,10 @@
static FT_Error static FT_Error
ah_hinter_compute_blues( AH_Hinter* hinter ) ah_hinter_compute_blues( AH_Hinter hinter )
{ {
AH_Blue blue; AH_Blue blue;
AH_Globals* globals = &hinter->globals->design; AH_Globals globals = &hinter->globals->design;
FT_Pos flats [MAX_TEST_CHARACTERS]; FT_Pos flats [MAX_TEST_CHARACTERS];
FT_Pos rounds[MAX_TEST_CHARACTERS]; FT_Pos rounds[MAX_TEST_CHARACTERS];
FT_Int num_flats; FT_Int num_flats;
@@ -84,7 +85,7 @@
charmap = face->charmap; charmap = face->charmap;
/* do we have a Unicode charmap in there? */ /* 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 ) if ( error )
goto Exit; goto Exit;
@@ -95,7 +96,7 @@
AH_LOG(( "blue zones computation\n" )); AH_LOG(( "blue zones computation\n" ));
AH_LOG(( "------------------------------------------------\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* p = blue_chars[blue];
const char* limit = p + MAX_TEST_CHARACTERS; const char* limit = p + MAX_TEST_CHARACTERS;
@@ -216,8 +217,8 @@
/* now, set the `round' flag depending on the segment's kind */ /* now, set the `round' flag depending on the segment's kind */
round = FT_BOOL( round = FT_BOOL(
FT_CURVE_TAG( glyph->outline.tags[prev] ) != 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 ); FT_CURVE_TAG( glyph->outline.tags[next] ) != FT_CURVE_TAG_ON );
AH_LOG(( "%c ", round ? 'r' : 'f' )); AH_LOG(( "%c ", round ? 'r' : 'f' ));
} }
@@ -286,18 +287,18 @@
static FT_Error 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 */ /* scan the array of segments in each direction */
AH_Outline* outline = hinter->glyph; AH_Outline outline = hinter->glyph;
AH_Segment* segments; AH_Segment segments;
AH_Segment* limit; AH_Segment limit;
AH_Globals* globals = &hinter->globals->design; AH_Globals globals = &hinter->globals->design;
FT_Pos* widths; FT_Pos* widths;
FT_Int dimension; FT_Int dimension;
FT_Int* p_num_widths; FT_Int* p_num_widths;
FT_Error error = 0; FT_Error error = 0;
FT_Pos edge_distance_threshold = 32000; FT_Pos edge_distance_threshold = 32000;
globals->num_widths = 0; globals->num_widths = 0;
@@ -334,9 +335,9 @@
for ( dimension = 1; dimension >= 0; dimension-- ) for ( dimension = 1; dimension >= 0; dimension-- )
{ {
AH_Segment* seg = segments; AH_Segment seg = segments;
AH_Segment* link; AH_Segment link;
FT_Int num_widths = 0; FT_Int num_widths = 0;
for ( ; seg < limit; seg++ ) for ( ; seg < limit; seg++ )
@@ -345,14 +346,14 @@
/* we only consider stem segments there! */ /* we only consider stem segments there! */
if ( link && link->link == seg && link > seg ) if ( link && link->link == seg && link > seg )
{ {
FT_Int dist; FT_Pos dist;
dist = seg->pos - link->pos; dist = seg->pos - link->pos;
if ( dist < 0 ) if ( dist < 0 )
dist = -dist; dist = -dist;
if ( num_widths < 12 ) if ( num_widths < AH_MAX_WIDTHS )
widths[num_widths++] = dist; widths[num_widths++] = dist;
} }
} }
@@ -368,7 +369,6 @@
limit = segments + outline->num_vsegments; limit = segments + outline->num_vsegments;
widths = globals->widths; widths = globals->widths;
p_num_widths = &globals->num_widths; p_num_widths = &globals->num_widths;
} }
/* Now, compute the edge distance threshold as a fraction of the */ /* Now, compute the edge distance threshold as a fraction of the */
@@ -385,7 +385,7 @@
FT_LOCAL_DEF( FT_Error ) 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 ) || return ah_hinter_compute_widths( hinter ) ||
ah_hinter_compute_blues ( hinter ); ah_hinter_compute_blues ( hinter );
+3 -3
View File
@@ -32,13 +32,13 @@
FT_BEGIN_HEADER FT_BEGIN_HEADER
#define AH_IS_TOP_BLUE( b ) ( (b) == ah_blue_capital_top || \ #define AH_IS_TOP_BLUE( b ) ( (b) == AH_BLUE_CAPITAL_TOP || \
(b) == ah_blue_small_top ) (b) == AH_BLUE_SMALL_TOP )
/* compute global metrics automatically */ /* compute global metrics automatically */
FT_LOCAL( FT_Error ) FT_LOCAL( FT_Error )
ah_hinter_compute_globals( AH_Hinter* hinter ); ah_hinter_compute_globals( AH_Hinter hinter );
FT_END_HEADER FT_END_HEADER
+321 -201
View File
@@ -32,12 +32,12 @@
#include <stdio.h> #include <stdio.h>
void void
ah_dump_edges( AH_Outline* outline ) ah_dump_edges( AH_Outline outline )
{ {
AH_Edge* edges; AH_Edge edges;
AH_Edge* edge_limit; AH_Edge edge_limit;
AH_Segment* segments; AH_Segment segments;
FT_Int dimension; FT_Int dimension;
edges = outline->horz_edges; edges = outline->horz_edges;
@@ -46,7 +46,7 @@
for ( dimension = 1; dimension >= 0; dimension-- ) for ( dimension = 1; dimension >= 0; dimension-- )
{ {
AH_Edge* edge; AH_Edge edge;
printf ( "Table of %s edges:\n", printf ( "Table of %s edges:\n",
@@ -59,13 +59,13 @@
printf ( " [ %5d | %4d | %5s | %4d | %5d | %c | %5.2f | %5.2f ]\n", printf ( " [ %5d | %4d | %5s | %4d | %5d | %c | %5.2f | %5.2f ]\n",
edge - edges, edge - edges,
(int)edge->fpos, (int)edge->fpos,
edge->dir == ah_dir_up edge->dir == AH_DIR_UP
? "up" ? "up"
: ( edge->dir == ah_dir_down : ( edge->dir == AH_DIR_DOWN
? "down" ? "down"
: ( edge->dir == ah_dir_left : ( edge->dir == AH_DIR_LEFT
? "left" ? "left"
: ( edge->dir == ah_dir_right : ( edge->dir == AH_DIR_RIGHT
? "right" ? "right"
: "none" ) ) ), : "none" ) ) ),
edge->link ? ( edge->link - edges ) : -1, edge->link ? ( edge->link - edges ) : -1,
@@ -84,12 +84,12 @@
/* A function used to dump the array of linked segments */ /* A function used to dump the array of linked segments */
void void
ah_dump_segments( AH_Outline* outline ) ah_dump_segments( AH_Outline outline )
{ {
AH_Segment* segments; AH_Segment segments;
AH_Segment* segment_limit; AH_Segment segment_limit;
AH_Point* points; AH_Point points;
FT_Int dimension; FT_Int dimension;
points = outline->points; points = outline->points;
@@ -98,7 +98,7 @@
for ( dimension = 1; dimension >= 0; dimension-- ) for ( dimension = 1; dimension >= 0; dimension-- )
{ {
AH_Segment* seg; AH_Segment seg;
printf ( "Table of %s segments:\n", printf ( "Table of %s segments:\n",
@@ -111,13 +111,13 @@
printf ( " [ %5d | %4d | %5s | %4d | %5d | %4d | %5d | %5d ]\n", printf ( " [ %5d | %4d | %5s | %4d | %5d | %4d | %5d | %5d ]\n",
seg - segments, seg - segments,
(int)seg->pos, (int)seg->pos,
seg->dir == ah_dir_up seg->dir == AH_DIR_UP
? "up" ? "up"
: ( seg->dir == ah_dir_down : ( seg->dir == AH_DIR_DOWN
? "down" ? "down"
: ( seg->dir == ah_dir_left : ( seg->dir == AH_DIR_LEFT
? "left" ? "left"
: ( seg->dir == ah_dir_right : ( seg->dir == AH_DIR_RIGHT
? "right" ? "right"
: "none" ) ) ), : "none" ) ) ),
seg->link ? (seg->link-segments) : -1, seg->link ? (seg->link-segments) : -1,
@@ -145,17 +145,17 @@
FT_Pos ay = ABS( dy ); FT_Pos ay = ABS( dy );
dir = ah_dir_none; dir = AH_DIR_NONE;
/* test for vertical direction */ /* test for vertical direction */
if ( ax * 12 < ay ) 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 */ /* test for horizontal direction */
else if ( ay * 12 < ax ) 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; return dir;
@@ -164,13 +164,14 @@
/* this function is used by ah_get_orientation (see below) to test */ /* this function is used by ah_get_orientation (see below) to test */
/* the fill direction of a given bbox extrema */ /* the fill direction of a given bbox extrema */
static int static FT_Int
ah_test_extrema( FT_Outline* outline, ah_test_extrema( FT_Outline* outline,
int n ) FT_Int n )
{ {
FT_Vector *prev, *cur, *next; FT_Vector *prev, *cur, *next;
FT_Pos product; FT_Pos product;
FT_Int first, last, c; FT_Int first, last, c;
FT_Int retval;
/* we need to compute the `previous' and `next' point */ /* we need to compute the `previous' and `next' point */
@@ -201,15 +202,16 @@
next->x - cur->x, /* out.x */ next->x - cur->x, /* out.x */
0x40 ); 0x40 );
retval = 0;
if ( product ) 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 */ /* 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 */ /* but it is better to re-compute it directly (it seems that this flag */
/* isn't correctly set for some weird composite glyphs currently). */ /* isn't correctly set for some weird composite glyphs currently). */
/* */ /* */
@@ -218,18 +220,18 @@
/* */ /* */
/* The function returns either 1 or -1. */ /* The function returns either 1 or -1. */
/* */ /* */
static int static FT_Int
ah_get_orientation( FT_Outline* outline ) ah_get_orientation( FT_Outline* outline )
{ {
FT_BBox box; FT_BBox box;
FT_BBox indices; FT_Int indices_xMin, indices_yMin, indices_xMax, indices_yMax;
int n, last; FT_Int n, last;
indices.xMin = -1; indices_xMin = -1;
indices.yMin = -1; indices_yMin = -1;
indices.xMax = -1; indices_xMax = -1;
indices.yMax = -1; indices_yMax = -1;
box.xMin = box.yMin = 32767L; box.xMin = box.yMin = 32767L;
box.xMax = box.yMax = -32768L; box.xMax = box.yMax = -32768L;
@@ -249,41 +251,41 @@
if ( x < box.xMin ) if ( x < box.xMin )
{ {
box.xMin = x; box.xMin = x;
indices.xMin = n; indices_xMin = n;
} }
if ( x > box.xMax ) if ( x > box.xMax )
{ {
box.xMax = x; box.xMax = x;
indices.xMax = n; indices_xMax = n;
} }
y = outline->points[n].y; y = outline->points[n].y;
if ( y < box.yMin ) if ( y < box.yMin )
{ {
box.yMin = y; box.yMin = y;
indices.yMin = n; indices_yMin = n;
} }
if ( y > box.yMax ) if ( y > box.yMax )
{ {
box.yMax = y; box.yMax = y;
indices.yMax = n; indices_yMax = n;
} }
} }
/* test orientation of the xmin */ /* test orientation of the xmin */
n = ah_test_extrema( outline, indices.xMin ); n = ah_test_extrema( outline, indices_xMin );
if ( n ) if ( n )
goto Exit; goto Exit;
n = ah_test_extrema( outline, indices.yMin ); n = ah_test_extrema( outline, indices_yMin );
if ( n ) if ( n )
goto Exit; goto Exit;
n = ah_test_extrema( outline, indices.xMax ); n = ah_test_extrema( outline, indices_xMax );
if ( n ) if ( n )
goto Exit; goto Exit;
n = ah_test_extrema( outline, indices.yMax ); n = ah_test_extrema( outline, indices_yMax );
if ( !n ) if ( !n )
n = 1; n = 1;
@@ -298,14 +300,14 @@
/* ah_outline_new */ /* ah_outline_new */
/* */ /* */
/* <Description> */ /* <Description> */
/* Creates a new and empty AH_Outline object. */ /* Creates a new and empty AH_OutlineRec object. */
/* */ /* */
FT_LOCAL_DEF( FT_Error ) FT_LOCAL_DEF( FT_Error )
ah_outline_new( FT_Memory memory, ah_outline_new( FT_Memory memory,
AH_Outline** aoutline ) AH_Outline* aoutline )
{ {
FT_Error error; FT_Error error;
AH_Outline* outline; AH_Outline outline;
if ( !FT_NEW( outline ) ) if ( !FT_NEW( outline ) )
@@ -324,10 +326,10 @@
/* ah_outline_done */ /* ah_outline_done */
/* */ /* */
/* <Description> */ /* <Description> */
/* Destroys a given AH_Outline object. */ /* Destroys a given AH_OutlineRec object. */
/* */ /* */
FT_LOCAL_DEF( void ) FT_LOCAL_DEF( void )
ah_outline_done( AH_Outline* outline ) ah_outline_done( AH_Outline outline )
{ {
FT_Memory memory = outline->memory; FT_Memory memory = outline->memory;
@@ -347,15 +349,15 @@
/* ah_outline_save */ /* ah_outline_save */
/* */ /* */
/* <Description> */ /* <Description> */
/* Saves the content of a given AH_Outline object into a face's glyph */ /* Saves the contents of a given AH_OutlineRec object into a face's */
/* slot. */ /* glyph slot. */
/* */ /* */
FT_LOCAL_DEF( void ) FT_LOCAL_DEF( void )
ah_outline_save( AH_Outline* outline, ah_outline_save( AH_Outline outline,
AH_Loader gloader ) AH_Loader gloader )
{ {
AH_Point* point = outline->points; AH_Point point = outline->points;
AH_Point* point_limit = point + outline->num_points; AH_Point point_limit = point + outline->num_points;
FT_Vector* vec = gloader->current.outline.points; FT_Vector* vec = gloader->current.outline.points;
char* tag = gloader->current.outline.tags; char* tag = gloader->current.outline.tags;
@@ -366,12 +368,12 @@
vec->x = point->x; vec->x = point->x;
vec->y = point->y; vec->y = point->y;
if ( point->flags & ah_flag_conic ) if ( point->flags & AH_FLAG_CONIC )
tag[0] = FT_Curve_Tag_Conic; tag[0] = FT_CURVE_TAG_CONIC;
else if ( point->flags & ah_flag_cubic ) else if ( point->flags & AH_FLAG_CUBIC )
tag[0] = FT_Curve_Tag_Cubic; tag[0] = FT_CURVE_TAG_CUBIC;
else else
tag[0] = FT_Curve_Tag_On; tag[0] = FT_CURVE_TAG_ON;
} }
} }
@@ -382,25 +384,25 @@
/* ah_outline_load */ /* ah_outline_load */
/* */ /* */
/* <Description> */ /* <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. */ /* object. */
/* */ /* */
FT_LOCAL_DEF( FT_Error ) FT_LOCAL_DEF( FT_Error )
ah_outline_load( AH_Outline* outline, ah_outline_load( AH_Outline outline,
FT_Face face ) FT_Face face )
{ {
FT_Memory memory = outline->memory; FT_Memory memory = outline->memory;
FT_Error error = AH_Err_Ok; FT_Error error = AH_Err_Ok;
FT_Outline* source = &face->glyph->outline; FT_Outline* source = &face->glyph->outline;
FT_Int num_points = source->n_points; FT_Int num_points = source->n_points;
FT_Int num_contours = source->n_contours; FT_Int num_contours = source->n_contours;
AH_Point* points; AH_Point points;
/* check arguments */ /* check arguments */
if ( !face || if ( !face ||
!face->size || !face->size ||
face->glyph->format != ft_glyph_format_outline ) face->glyph->format != FT_GLYPH_FORMAT_OUTLINE )
return AH_Err_Invalid_Argument; return AH_Err_Invalid_Argument;
/* first of all, reallocate the contours array if necessary */ /* 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. */ /* 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. */ /* the Arphic ones). We thus recompute it each time we need to. */
/* */ /* */
outline->vert_major_dir = ah_dir_up; outline->vert_major_dir = AH_DIR_UP;
outline->horz_major_dir = ah_dir_left; outline->horz_major_dir = AH_DIR_LEFT;
if ( ah_get_orientation( source ) > 1 ) if ( ah_get_orientation( source ) > 1 )
{ {
outline->vert_major_dir = ah_dir_down; outline->vert_major_dir = AH_DIR_DOWN;
outline->horz_major_dir = ah_dir_right; outline->horz_major_dir = AH_DIR_RIGHT;
} }
outline->x_scale = face->size->metrics.x_scale; outline->x_scale = face->size->metrics.x_scale;
@@ -469,8 +471,8 @@
{ {
/* do one thing at a time -- it is easier to understand, and */ /* do one thing at a time -- it is easier to understand, and */
/* the code is clearer */ /* the code is clearer */
AH_Point* point; AH_Point point;
AH_Point* point_limit = points + outline->num_points; AH_Point point_limit = points + outline->num_points;
/* compute coordinates */ /* compute coordinates */
@@ -500,10 +502,10 @@
{ {
switch ( FT_CURVE_TAG( *tag ) ) switch ( FT_CURVE_TAG( *tag ) )
{ {
case FT_Curve_Tag_Conic: case FT_CURVE_TAG_CONIC:
point->flags = ah_flag_conic; break; point->flags = AH_FLAG_CONIC; break;
case FT_Curve_Tag_Cubic: case FT_CURVE_TAG_CUBIC:
point->flags = ah_flag_cubic; break; point->flags = AH_FLAG_CUBIC; break;
default: default:
; ;
} }
@@ -512,10 +514,10 @@
/* compute `next' and `prev' */ /* compute `next' and `prev' */
{ {
FT_Int contour_index; FT_Int contour_index;
AH_Point* prev; AH_Point prev;
AH_Point* first; AH_Point first;
AH_Point* end; AH_Point end;
contour_index = 0; contour_index = 0;
@@ -548,10 +550,10 @@
/* set-up the contours array */ /* set-up the contours array */
{ {
AH_Point** contour = outline->contours; AH_Point* contour = outline->contours;
AH_Point** contour_limit = contour + outline->num_contours; AH_Point* contour_limit = contour + outline->num_contours;
short* end = source->contours; short* end = source->contours;
short idx = 0; short idx = 0;
for ( ; contour < contour_limit; contour++, end++ ) for ( ; contour < contour_limit; contour++, end++ )
@@ -565,8 +567,8 @@
{ {
for ( point = points; point < point_limit; point++ ) for ( point = points; point < point_limit; point++ )
{ {
AH_Point* prev; AH_Point prev;
AH_Point* next; AH_Point next;
FT_Vector ivec, ovec; FT_Vector ivec, ovec;
@@ -583,17 +585,17 @@
point->out_dir = ah_compute_direction( ovec.x, ovec.y ); point->out_dir = ah_compute_direction( ovec.x, ovec.y );
#ifndef AH_OPTION_NO_WEAK_INTERPOLATION #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: Is_Weak_Point:
point->flags |= ah_flag_weak_interpolation; point->flags |= AH_FLAG_WEAK_INTERPOLATION;
} }
else if ( point->out_dir == point->in_dir ) else if ( point->out_dir == point->in_dir )
{ {
AH_Angle angle_in, angle_out, delta; 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; goto Is_Weak_Point;
angle_in = ah_angle( &ivec ); angle_in = ah_angle( &ivec );
@@ -622,11 +624,11 @@
FT_LOCAL_DEF( void ) FT_LOCAL_DEF( void )
ah_setup_uv( AH_Outline* outline, ah_setup_uv( AH_Outline outline,
AH_UV source ) AH_UV source )
{ {
AH_Point* point = outline->points; AH_Point point = outline->points;
AH_Point* point_limit = point + outline->num_points; AH_Point point_limit = point + outline->num_points;
for ( ; point < point_limit; point++ ) for ( ; point < point_limit; point++ )
@@ -636,31 +638,31 @@
switch ( source ) switch ( source )
{ {
case ah_uv_fxy: case AH_UV_FXY:
u = point->fx; u = point->fx;
v = point->fy; v = point->fy;
break; break;
case ah_uv_fyx: case AH_UV_FYX:
u = point->fy; u = point->fy;
v = point->fx; v = point->fx;
break; break;
case ah_uv_oxy: case AH_UV_OXY:
u = point->ox; u = point->ox;
v = point->oy; v = point->oy;
break; break;
case ah_uv_oyx: case AH_UV_OYX:
u = point->oy; u = point->oy;
v = point->ox; v = point->ox;
break; break;
case ah_uv_yx: case AH_UV_YX:
u = point->y; u = point->y;
v = point->x; v = point->x;
break; break;
case ah_uv_ox: case AH_UV_OX:
u = point->x; u = point->x;
v = point->ox; v = point->ox;
break; break;
case ah_uv_oy: case AH_UV_OY:
u = point->y; u = point->y;
v = point->oy; v = point->oy;
break; 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 ) FT_LOCAL_DEF( void )
ah_outline_compute_segments( AH_Outline* outline ) ah_outline_compute_segments( AH_Outline outline )
{ {
int dimension; int dimension;
AH_Segment* segments; AH_Segment segments;
FT_Int* p_num_segments; FT_Int* p_num_segments;
AH_Direction segment_dir; AH_Direction segment_dir;
AH_Direction major_dir; AH_Direction major_dir;
@@ -687,36 +805,36 @@
segments = outline->horz_segments; segments = outline->horz_segments;
p_num_segments = &outline->num_hsegments; 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; segment_dir = major_dir;
/* set up (u,v) in each point */ /* 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-- ) for ( dimension = 1; dimension >= 0; dimension-- )
{ {
AH_Point** contour = outline->contours; AH_Point* contour = outline->contours;
AH_Point** contour_limit = contour + outline->num_contours; AH_Point* contour_limit = contour + outline->num_contours;
AH_Segment* segment = segments; AH_Segment segment = segments;
FT_Int num_segments = 0; FT_Int num_segments = 0;
#ifdef AH_HINT_METRICS #ifdef AH_HINT_METRICS
AH_Point* min_point = 0; AH_Point min_point = 0;
AH_Point* max_point = 0; AH_Point max_point = 0;
FT_Pos min_coord = 32000; FT_Pos min_coord = 32000;
FT_Pos max_coord = -32000; FT_Pos max_coord = -32000;
#endif #endif
/* do each contour separately */ /* do each contour separately */
for ( ; contour < contour_limit; contour++ ) for ( ; contour < contour_limit; contour++ )
{ {
AH_Point* point = contour[0]; AH_Point point = contour[0];
AH_Point* last = point->prev; AH_Point last = point->prev;
int on_edge = 0; int on_edge = 0;
FT_Pos min_pos = +32000; /* minimum segment pos != min_coord */ FT_Pos min_pos = +32000; /* minimum segment pos != min_coord */
FT_Pos max_pos = -32000; /* maximum segment pos != max_coord */ FT_Pos max_pos = -32000; /* maximum segment pos != max_coord */
FT_Bool passed; FT_Bool passed;
#ifdef AH_HINT_METRICS #ifdef AH_HINT_METRICS
@@ -779,8 +897,8 @@
/* a segment is round if either its first or last point */ /* a segment is round if either its first or last point */
/* is a control point */ /* is a control point */
if ( ( segment->first->flags | point->flags ) & if ( ( segment->first->flags | point->flags ) &
ah_flag_control ) AH_FLAG_CONTROL )
segment->flags |= ah_edge_round; segment->flags |= AH_EDGE_ROUND;
/* compute segment size */ /* compute segment size */
min_pos = max_pos = point->v; min_pos = max_pos = point->v;
@@ -815,10 +933,10 @@
segment_dir = point->out_dir; segment_dir = point->out_dir;
/* clear all segment fields */ /* clear all segment fields */
FT_MEM_SET( segment, 0, sizeof ( *segment ) ); FT_ZERO( segment );
segment->dir = segment_dir; segment->dir = segment_dir;
segment->flags = ah_edge_normal; segment->flags = AH_EDGE_NORMAL;
min_pos = max_pos = point->u; min_pos = max_pos = point->u;
segment->first = point; segment->first = point;
segment->last = point; segment->last = point;
@@ -845,11 +963,11 @@
/* we do this by inserting fake segments when needed */ /* we do this by inserting fake segments when needed */
if ( dimension == 0 ) if ( dimension == 0 )
{ {
AH_Point* point = outline->points; AH_Point point = outline->points;
AH_Point* point_limit = point + outline->num_points; AH_Point point_limit = point + outline->num_points;
FT_Pos min_pos = 32000; FT_Pos min_pos = 32000;
FT_Pos max_pos = -32000; FT_Pos max_pos = -32000;
min_point = 0; min_point = 0;
@@ -877,10 +995,10 @@
if ( min_point ) if ( min_point )
{ {
/* clear all segment fields */ /* clear all segment fields */
FT_MEM_SET( segment, 0, sizeof ( *segment ) ); FT_ZERO( segment );
segment->dir = segment_dir; segment->dir = segment_dir;
segment->flags = ah_edge_normal; segment->flags = AH_EDGE_NORMAL;
segment->first = min_point; segment->first = min_point;
segment->last = min_point; segment->last = min_point;
segment->pos = min_pos; segment->pos = min_pos;
@@ -893,10 +1011,10 @@
if ( max_point ) if ( max_point )
{ {
/* clear all segment fields */ /* clear all segment fields */
FT_MEM_SET( segment, 0, sizeof ( *segment ) ); FT_ZERO( segment );
segment->dir = segment_dir; segment->dir = segment_dir;
segment->flags = ah_edge_normal; segment->flags = AH_EDGE_NORMAL;
segment->first = max_point; segment->first = max_point;
segment->last = max_point; segment->last = max_point;
segment->pos = max_pos; segment->pos = max_pos;
@@ -910,36 +1028,38 @@
*p_num_segments = num_segments; *p_num_segments = num_segments;
segments = outline->vert_segments; segments = outline->vert_segments;
major_dir = ah_dir_up; major_dir = AH_DIR_UP;
p_num_segments = &outline->num_vsegments; p_num_segments = &outline->num_vsegments;
ah_setup_uv( outline, ah_uv_fxy ); ah_setup_uv( outline, AH_UV_FXY );
} }
} }
FT_LOCAL_DEF( void ) FT_LOCAL_DEF( void )
ah_outline_link_segments( AH_Outline* outline ) ah_outline_link_segments( AH_Outline outline )
{ {
AH_Segment* segments; AH_Segment segments;
AH_Segment* segment_limit; AH_Segment segment_limit;
int dimension; int dimension;
ah_setup_uv( outline, ah_uv_fyx ); ah_setup_uv( outline, AH_UV_FYX );
segments = outline->horz_segments; segments = outline->horz_segments;
segment_limit = segments + outline->num_hsegments; segment_limit = segments + outline->num_hsegments;
for ( dimension = 1; dimension >= 0; dimension-- ) for ( dimension = 1; dimension >= 0; dimension-- )
{ {
AH_Segment* seg1; AH_Segment seg1;
AH_Segment* seg2; AH_Segment seg2;
/* now compare each segment to the others */ /* now compare each segment to the others */
for ( seg1 = segments; seg1 < segment_limit; seg1++ ) for ( seg1 = segments; seg1 < segment_limit; seg1++ )
{ {
FT_Pos best_score; FT_Pos best_score;
AH_Segment* best_segment; AH_Segment best_segment;
/* the fake segments are introduced to hint the metrics -- */ /* the fake segments are introduced to hint the metrics -- */
/* we must never link them to anything */ /* we must never link them to anything */
@@ -983,20 +1103,20 @@
if ( max > seg2->max_coord ) if ( max > seg2->max_coord )
max = seg2->max_coord; max = seg2->max_coord;
len = max - min; len = max - min;
dist = seg2->pos - seg1->pos; if ( len >= 8 )
if ( dist < 0 )
dist = -dist;
if ( len < 8 )
score = 300*8 + dist - len*3;
else
score = dist + 300/len;
if ( score < best_score )
{ {
best_score = score; dist = seg2->pos - seg1->pos;
best_segment = seg2; if ( dist < 0 )
dist = -dist;
score = dist + 3000 / len;
if ( score < best_score )
{
best_score = score;
best_segment = seg2;
}
} }
} }
} }
@@ -1009,7 +1129,6 @@
best_segment->num_linked++; best_segment->num_linked++;
} }
} /* edges 1 */ } /* edges 1 */
/* now, compute the `serif' segments */ /* 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; segments = outline->vert_segments;
segment_limit = segments + outline->num_vsegments; segment_limit = segments + outline->num_vsegments;
@@ -1033,11 +1152,11 @@
static void static void
ah_outline_compute_edges( AH_Outline* outline ) ah_outline_compute_edges( AH_Outline outline )
{ {
AH_Edge* edges; AH_Edge edges;
AH_Segment* segments; AH_Segment segments;
AH_Segment* segment_limit; AH_Segment segment_limit;
AH_Direction up_dir; AH_Direction up_dir;
FT_Int* p_num_edges; FT_Int* p_num_edges;
FT_Int dimension; FT_Int dimension;
@@ -1049,14 +1168,14 @@
segments = outline->horz_segments; segments = outline->horz_segments;
segment_limit = segments + outline->num_hsegments; segment_limit = segments + outline->num_hsegments;
p_num_edges = &outline->num_hedges; p_num_edges = &outline->num_hedges;
up_dir = ah_dir_right; up_dir = AH_DIR_RIGHT;
scale = outline->y_scale; scale = outline->y_scale;
for ( dimension = 1; dimension >= 0; dimension-- ) for ( dimension = 1; dimension >= 0; dimension-- )
{ {
AH_Edge* edge; AH_Edge edge;
AH_Edge* edge_limit; /* really == edge + num_edges */ AH_Edge edge_limit; /* really == edge + num_edges */
AH_Segment* seg; AH_Segment seg;
/*********************************************************************/ /*********************************************************************/
@@ -1083,7 +1202,7 @@
edge_limit = edges; edge_limit = edges;
for ( seg = segments; seg < segment_limit; seg++ ) for ( seg = segments; seg < segment_limit; seg++ )
{ {
AH_Edge* found = 0; AH_Edge found = 0;
/* look for an edge corresponding to the segment */ /* look for an edge corresponding to the segment */
@@ -1116,7 +1235,7 @@
edge_limit++; edge_limit++;
/* clear all edge fields */ /* 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 */ /* add the segment to the new edge's list */
edge->first = seg; edge->first = seg;
@@ -1167,10 +1286,10 @@
/* now, compute each edge properties */ /* now, compute each edge properties */
for ( edge = edges; edge < edge_limit; edge++ ) for ( edge = edges; edge < edge_limit; edge++ )
{ {
int is_round = 0; /* does it contain round segments? */ FT_Int is_round = 0; /* does it contain round segments? */
int is_straight = 0; /* does it contain straight segments? */ FT_Int is_straight = 0; /* does it contain straight segments? */
int ups = 0; /* number of upwards segments */ FT_Pos ups = 0; /* number of upwards segments */
int downs = 0; /* number of downwards segments */ FT_Pos downs = 0; /* number of downwards segments */
seg = edge->first; seg = edge->first;
@@ -1181,7 +1300,7 @@
/* check for roundness of segment */ /* check for roundness of segment */
if ( seg->flags & ah_edge_round ) if ( seg->flags & AH_EDGE_ROUND )
is_round++; is_round++;
else else
is_straight++; is_straight++;
@@ -1198,8 +1317,8 @@
if ( seg->link || is_serif ) if ( seg->link || is_serif )
{ {
AH_Edge* edge2; AH_Edge edge2;
AH_Segment* seg2; AH_Segment seg2;
edge2 = edge->link; edge2 = edge->link;
@@ -1242,13 +1361,13 @@
} while ( seg != edge->first ); } while ( seg != edge->first );
/* set the round/straight flags */ /* set the round/straight flags */
edge->flags = ah_edge_normal; edge->flags = AH_EDGE_NORMAL;
if ( is_round > 0 && is_round >= is_straight ) if ( is_round > 0 && is_round >= is_straight )
edge->flags |= ah_edge_round; edge->flags |= AH_EDGE_ROUND;
/* set the edge's main direction */ /* set the edge's main direction */
edge->dir = ah_dir_none; edge->dir = AH_DIR_NONE;
if ( ups > downs ) if ( ups > downs )
edge->dir = up_dir; edge->dir = up_dir;
@@ -1271,7 +1390,7 @@
segments = outline->vert_segments; segments = outline->vert_segments;
segment_limit = segments + outline->num_vsegments; segment_limit = segments + outline->num_vsegments;
p_num_edges = &outline->num_vedges; p_num_edges = &outline->num_vedges;
up_dir = ah_dir_up; up_dir = AH_DIR_UP;
scale = outline->x_scale; scale = outline->x_scale;
} }
} }
@@ -1283,14 +1402,15 @@
/* ah_outline_detect_features */ /* ah_outline_detect_features */
/* */ /* */
/* <Description> */ /* <Description> */
/* Performs feature detection on a given AH_Outline object. */ /* Performs feature detection on a given AH_OutlineRec object. */
/* */ /* */
FT_LOCAL_DEF( void ) 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_compute_segments ( outline );
ah_outline_link_segments ( outline ); ah_outline_link_segments ( outline );
ah_outline_compute_edges ( 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). */ /* be snapped to a blue zone edge (top or bottom). */
/* */ /* */
FT_LOCAL_DEF( void ) FT_LOCAL_DEF( void )
ah_outline_compute_blue_edges( AH_Outline* outline, ah_outline_compute_blue_edges( AH_Outline outline,
AH_Face_Globals* face_globals ) AH_Face_Globals face_globals )
{ {
AH_Edge* edge = outline->horz_edges; AH_Edge edge = outline->horz_edges;
AH_Edge* edge_limit = edge + outline->num_hedges; AH_Edge edge_limit = edge + outline->num_hedges;
AH_Globals* globals = &face_globals->design; AH_Globals globals = &face_globals->design;
FT_Fixed y_scale = outline->y_scale; 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 */ /* compute which blue zones are active, i.e. have their scaled */
@@ -1322,7 +1442,7 @@
FT_Bool check = 0; 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; FT_Pos ref, shoot, dist;
@@ -1360,7 +1480,7 @@
if ( best_dist > 64 / 4 ) if ( best_dist > 64 / 4 )
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 */ /* if it is a top zone, check for right edges -- if it is a bottom */
/* zone, check for left edges */ /* zone, check for left edges */
@@ -1398,7 +1518,7 @@
/* now, compare it to the overshoot position if the edge is */ /* now, compare it to the overshoot position if the edge is */
/* rounded, and if the edge is over the reference position of a */ /* rounded, and if the edge is over the reference position of a */
/* top zone, or under the reference position of a bottom zone */ /* 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 ); FT_Bool is_under_ref = FT_BOOL( edge->fpos < *blue_pos );
@@ -1438,12 +1558,12 @@
/* edge' pointer from `design units' to `scaled ones'). */ /* edge' pointer from `design units' to `scaled ones'). */
/* */ /* */
FT_LOCAL_DEF( void ) FT_LOCAL_DEF( void )
ah_outline_scale_blue_edges( AH_Outline* outline, ah_outline_scale_blue_edges( AH_Outline outline,
AH_Face_Globals* globals ) AH_Face_Globals globals )
{ {
AH_Edge* edge = outline->horz_edges; AH_Edge edge = outline->horz_edges;
AH_Edge* edge_limit = edge + outline->num_hedges; AH_Edge edge_limit = edge + outline->num_hedges;
FT_Int delta; FT_Pos delta;
delta = globals->scaled.blue_refs - globals->design.blue_refs; delta = globals->scaled.blue_refs - globals->design.blue_refs;
+25 -25
View File
@@ -33,56 +33,56 @@ FT_BEGIN_HEADER
typedef enum AH_UV_ typedef enum AH_UV_
{ {
ah_uv_fxy, AH_UV_FXY,
ah_uv_fyx, AH_UV_FYX,
ah_uv_oxy, AH_UV_OXY,
ah_uv_oyx, AH_UV_OYX,
ah_uv_ox, AH_UV_OX,
ah_uv_oy, AH_UV_OY,
ah_uv_yx, AH_UV_YX,
ah_uv_xy /* should always be last! */ AH_UV_XY /* should always be last! */
} AH_UV; } AH_UV;
FT_LOCAL( void ) FT_LOCAL( void )
ah_setup_uv( AH_Outline* outline, ah_setup_uv( AH_Outline outline,
AH_UV source ); 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 ) FT_LOCAL( FT_Error )
ah_outline_new( FT_Memory memory, ah_outline_new( FT_Memory memory,
AH_Outline** aoutline ); AH_Outline* aoutline );
FT_LOCAL( FT_Error ) FT_LOCAL( FT_Error )
ah_outline_load( AH_Outline* outline, ah_outline_load( AH_Outline outline,
FT_Face face ); FT_Face face );
FT_LOCAL( void ) FT_LOCAL( void )
ah_outline_compute_segments( AH_Outline* outline ); ah_outline_compute_segments( AH_Outline outline );
FT_LOCAL( void ) FT_LOCAL( void )
ah_outline_link_segments( AH_Outline* outline ); ah_outline_link_segments( AH_Outline outline );
FT_LOCAL( void ) FT_LOCAL( void )
ah_outline_detect_features( AH_Outline* outline ); ah_outline_detect_features( AH_Outline outline );
FT_LOCAL( void ) FT_LOCAL( void )
ah_outline_compute_blue_edges( AH_Outline* outline, ah_outline_compute_blue_edges( AH_Outline outline,
AH_Face_Globals* globals ); AH_Face_Globals globals );
FT_LOCAL( void ) FT_LOCAL( void )
ah_outline_scale_blue_edges( AH_Outline* outline, ah_outline_scale_blue_edges( AH_Outline outline,
AH_Face_Globals* globals ); AH_Face_Globals globals );
FT_LOCAL( void ) FT_LOCAL( void )
ah_outline_save( AH_Outline* outline, ah_outline_save( AH_Outline outline,
AH_Loader loader ); AH_Loader loader );
FT_LOCAL( void ) FT_LOCAL( void )
ah_outline_done( AH_Outline* outline ); ah_outline_done( AH_Outline outline );
FT_END_HEADER FT_END_HEADER
+309 -248
View File
@@ -27,10 +27,10 @@
#include FT_OUTLINE_H #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 AH_USE_IUP
#define OPTIM_STEM_SNAP
/*************************************************************************/ /*************************************************************************/
/*************************************************************************/ /*************************************************************************/
@@ -40,7 +40,6 @@
/*************************************************************************/ /*************************************************************************/
/*************************************************************************/ /*************************************************************************/
/* snap a given width in scaled coordinates to one of the */ /* snap a given width in scaled coordinates to one of the */
/* current standard widths */ /* current standard widths */
static FT_Pos static FT_Pos
@@ -51,6 +50,7 @@
int n; int n;
FT_Pos best = 64 + 32 + 2; FT_Pos best = 64 + 32 + 2;
FT_Pos reference = width; FT_Pos reference = width;
FT_Pos scaled;
for ( n = 0; n < count; n++ ) for ( n = 0; n < count; n++ )
@@ -70,16 +70,16 @@
} }
} }
scaled = (reference+32) & -64;
if ( width >= reference ) if ( width >= reference )
{ {
width -= 0x21; if ( width < scaled + 48 )
if ( width < reference )
width = reference; width = reference;
} }
else else
{ {
width += 0x21; if ( width > scaled - 48 )
if ( width > reference )
width = reference; width = reference;
} }
@@ -87,73 +87,138 @@
} }
/* align one stem edge relative to the previous stem edge */ /* compute the snapped width of a given stem */
static void static FT_Pos
ah_align_linked_edge( AH_Hinter* hinter, ah_compute_stem_width( AH_Hinter hinter,
AH_Edge* base_edge, int vertical,
AH_Edge* stem_edge, FT_Pos width )
int vertical )
{ {
FT_Pos dist = stem_edge->opos - base_edge->opos; AH_Globals globals = &hinter->globals->scaled;
AH_Globals* globals = &hinter->globals->scaled; FT_Pos dist = width;
FT_Pos sign = 1; FT_Int sign = 0;
if ( dist < 0 ) if ( dist < 0 )
{ {
dist = -dist; dist = -width;
sign = -1; sign = 1;
} }
if ( vertical ) if ( ( vertical && !hinter->do_vert_snapping ) ||
( !vertical && !hinter->do_horz_snapping ) )
{ {
dist = ah_snap_width( globals->heights, globals->num_heights, dist ); /* smooth hinting process, very lightly quantize the stem width */
/* */
/* in the case of vertical hinting, always round */ if ( dist < 64 )
/* the stem heights to integer pixels */
if ( dist >= 64 )
dist = ( dist + 16 ) & -64;
else
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 else
{ {
dist = ah_snap_width( globals->widths, globals->num_widths, dist ); /* strong hinting process, snap the stem width to integer pixels */
/* */
if ( hinter->flags & ah_hinter_monochrome ) if ( vertical )
{ {
/* monochrome horizontal hinting: snap widths to integer pixels */ dist = ah_snap_width( globals->heights, globals->num_heights, dist );
/* with a different threshold */
if ( dist < 64 ) /* in the case of vertical hinting, always round */
dist = 64; /* the stem heights to integer pixels */
if ( dist >= 64 )
dist = ( dist + 16 ) & -64;
else else
dist = ( dist + 32 ) & -64; dist = 64;
} }
else else
{ {
/* for horizontal anti-aliased hinting, we adopt a more subtle */ dist = ah_snap_width( globals->widths, globals->num_widths, dist );
/* approach: we strengthen small stems, round stems whose size */
/* is between 1 and 2 pixels to an integer, otherwise nothing */
if ( dist < 48 )
dist = ( dist + 64 ) >> 1;
else if ( dist < 128 ) if ( hinter->flags & AH_HINTER_MONOCHROME )
dist = ( dist + 42 ) & -64; {
/* monochrome horizontal hinting: snap widths to integer pixels */
/* with a different threshold */
if ( dist < 64 )
dist = 64;
else
dist = ( dist + 32 ) & -64;
}
else else
/* XXX: round otherwise, prevent color fringes in LCD mode */ {
dist = ( dist + 32 ) & -64; /* for horizontal anti-aliased hinting, we adopt a more subtle */
/* approach: we strengthen small stems, round stems whose size */
/* is between 1 and 2 pixels to an integer, otherwise nothing */
if ( dist < 48 )
dist = ( dist + 64 ) >> 1;
else if ( dist < 128 )
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 static void
ah_align_serif_edge( AH_Hinter* hinter, ah_align_serif_edge( AH_Hinter hinter,
AH_Edge* base, AH_Edge base,
AH_Edge* serif, AH_Edge serif,
int vertical ) int vertical )
{ {
FT_Pos dist; FT_Pos dist;
FT_Pos sign = 1; FT_Pos sign = 1;
@@ -168,8 +233,9 @@
sign = -1; sign = -1;
} }
/* do not strengthen serifs */ /* do not touch serifs widths !! */
if ( base->flags & ah_edge_done ) #if 0
if ( base->flags & AH_EDGE_DONE )
{ {
if ( dist >= 64 ) if ( dist >= 64 )
dist = (dist+8) & -64; dist = (dist+8) & -64;
@@ -179,6 +245,7 @@
else else
dist = 0; dist = 0;
} }
#endif
serif->pos = base->pos + sign * dist; serif->pos = base->pos + sign * dist;
} }
@@ -197,12 +264,12 @@
/* Another alternative edge hinting algorithm */ /* Another alternative edge hinting algorithm */
static void static void
ah_hint_edges_3( AH_Hinter* hinter ) ah_hint_edges_3( AH_Hinter hinter )
{ {
AH_Edge* edges; AH_Edge edges;
AH_Edge* edge_limit; AH_Edge edge_limit;
AH_Outline* outline = hinter->glyph; AH_Outline outline = hinter->glyph;
FT_Int dimension; FT_Int dimension;
edges = outline->horz_edges; edges = outline->horz_edges;
@@ -210,15 +277,15 @@
for ( dimension = 1; dimension >= 0; dimension-- ) for ( dimension = 1; dimension >= 0; dimension-- )
{ {
AH_Edge* edge; AH_Edge edge;
AH_Edge* anchor = 0; AH_Edge anchor = 0;
int has_serifs = 0; int has_serifs = 0;
if ( ah_debug_disable_vert && !dimension ) if ( !hinter->do_horz_hints && !dimension )
goto Next_Dimension; goto Next_Dimension;
if ( ah_debug_disable_horz && dimension ) if ( !hinter->do_vert_hints && dimension )
goto Next_Dimension; goto Next_Dimension;
/* we begin by aligning all stems relative to the blue zone */ /* we begin by aligning all stems relative to the blue zone */
@@ -227,11 +294,11 @@
{ {
for ( edge = edges; edge < edge_limit; edge++ ) for ( edge = edges; edge < edge_limit; edge++ )
{ {
FT_Pos* blue; FT_Pos* blue;
AH_Edge *edge1, *edge2; AH_EdgeRec *edge1, *edge2;
if ( edge->flags & ah_edge_done ) if ( edge->flags & AH_EDGE_DONE )
continue; continue;
blue = edge->blue_edge; blue = edge->blue_edge;
@@ -253,12 +320,12 @@
continue; continue;
edge1->pos = blue[0]; edge1->pos = blue[0];
edge1->flags |= ah_edge_done; edge1->flags |= AH_EDGE_DONE;
if ( edge2 && !edge2->blue_edge ) if ( edge2 && !edge2->blue_edge )
{ {
ah_align_linked_edge( hinter, edge1, edge2, dimension ); ah_align_linked_edge( hinter, edge1, edge2, dimension );
edge2->flags |= ah_edge_done; edge2->flags |= AH_EDGE_DONE;
} }
if ( !anchor ) if ( !anchor )
@@ -270,10 +337,10 @@
/* relative order of stems in the glyph.. */ /* relative order of stems in the glyph.. */
for ( edge = edges; edge < edge_limit; edge++ ) 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; continue;
/* skip all non-stem edges */ /* skip all non-stem edges */
@@ -286,54 +353,54 @@
/* now, align the stem */ /* 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 ( 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 ); ah_align_linked_edge( hinter, edge2, edge, dimension );
edge->flags |= ah_edge_done; edge->flags |= AH_EDGE_DONE;
continue; continue;
} }
if ( !anchor )
{ {
FT_Bool min = 0; edge->pos = ( edge->opos + 32 ) & -64;
FT_Pos delta; anchor = edge;
if ( !anchor ) edge->flags |= AH_EDGE_DONE;
{
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;
}
ah_align_linked_edge( hinter, edge, edge2, dimension ); ah_align_linked_edge( hinter, edge, edge2, dimension );
delta = 0; }
if ( edge2 + 1 < edge_limit && else
edge2[1].flags & ah_edge_done ) {
delta = edge2[1].pos - edge2->pos; FT_Pos org_pos, org_len, org_center, cur_len;
FT_Pos cur_pos1, cur_pos2, delta1, delta2;
if ( delta < 0 )
{ org_pos = anchor->pos + (edge->opos - anchor->opos);
edge2->pos += delta; org_len = edge2->opos - edge->opos;
if ( !min ) org_center = org_pos + ( org_len >> 1 );
edge->pos += delta;
} cur_len = ah_compute_stem_width( hinter, dimension, org_len );
edge2->flags |= ah_edge_done;
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 */ /* to complete our processing */
for ( edge = edges; edge < edge_limit; edge++ ) for ( edge = edges; edge < edge_limit; edge++ )
{ {
if ( edge->flags & ah_edge_done ) if ( edge->flags & AH_EDGE_DONE )
continue; continue;
if ( edge->serif ) if ( edge->serif )
{
ah_align_serif_edge( hinter, edge->serif, edge, dimension ); ah_align_serif_edge( hinter, edge->serif, edge, dimension );
}
else if ( !anchor ) else if ( !anchor )
{ {
edge->pos = ( edge->opos + 32 ) & -64; edge->pos = ( edge->opos + 32 ) & -64;
@@ -360,13 +425,13 @@
edge->pos = anchor->pos + edge->pos = anchor->pos +
( ( edge->opos-anchor->opos + 32 ) & -64 ); ( ( edge->opos-anchor->opos + 32 ) & -64 );
edge->flags |= ah_edge_done; edge->flags |= AH_EDGE_DONE;
if ( edge > edges && edge->pos < edge[-1].pos ) if ( edge > edges && edge->pos < edge[-1].pos )
edge->pos = edge[-1].pos; edge->pos = edge[-1].pos;
if ( edge + 1 < edge_limit && 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 )
edge->pos = edge[1].pos; edge->pos = edge[1].pos;
} }
@@ -379,38 +444,13 @@
FT_LOCAL_DEF( void ) FT_LOCAL_DEF( void )
ah_hinter_hint_edges( AH_Hinter* hinter, ah_hinter_hint_edges( AH_Hinter hinter )
FT_Bool no_horz_edges,
FT_Bool no_vert_edges )
{ {
#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 */ /* AH_Interpolate_Blue_Edges( hinter ); -- doesn't seem to help */
/* reduce the problem of the disappearing eye in the `e' of Times... */ /* reduce the problem of the disappearing eye in the `e' of Times... */
/* also, creates some artifacts near the blue zones? */ /* also, creates some artifacts near the blue zones? */
{ {
ah_hint_edges_3( hinter ); 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,12 +466,12 @@
/*************************************************************************/ /*************************************************************************/
static void static void
ah_hinter_align_edge_points( AH_Hinter* hinter ) ah_hinter_align_edge_points( AH_Hinter hinter )
{ {
AH_Outline* outline = hinter->glyph; AH_Outline outline = hinter->glyph;
AH_Edge* edges; AH_Edge edges;
AH_Edge* edge_limit; AH_Edge edge_limit;
FT_Int dimension; FT_Int dimension;
edges = outline->horz_edges; edges = outline->horz_edges;
@@ -439,7 +479,7 @@
for ( dimension = 1; dimension >= 0; dimension-- ) for ( dimension = 1; dimension >= 0; dimension-- )
{ {
AH_Edge* edge; AH_Edge edge;
edge = edges; edge = edges;
@@ -447,12 +487,12 @@
{ {
/* move the points of each segment */ /* move the points of each segment */
/* in each edge to the edge's position */ /* in each edge to the edge's position */
AH_Segment* seg = edge->first; AH_Segment seg = edge->first;
do do
{ {
AH_Point* point = seg->first; AH_Point point = seg->first;
for (;;) for (;;)
@@ -460,12 +500,12 @@
if ( dimension ) if ( dimension )
{ {
point->y = edge->pos; point->y = edge->pos;
point->flags |= ah_flag_touch_y; point->flags |= AH_FLAG_TOUCH_Y;
} }
else else
{ {
point->x = edge->pos; point->x = edge->pos;
point->flags |= ah_flag_touch_x; point->flags |= AH_FLAG_TOUCH_X;
} }
if ( point == seg->last ) if ( point == seg->last )
@@ -487,15 +527,15 @@
/* hint the strong points -- this is equivalent to the TrueType `IP' */ /* hint the strong points -- this is equivalent to the TrueType `IP' */
static void 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; FT_Int dimension;
AH_Edge* edges; AH_Edge edges;
AH_Edge* edge_limit; AH_Edge edge_limit;
AH_Point* points; AH_Point points;
AH_Point* point_limit; AH_Point point_limit;
AH_Flags touch_flag; AH_Flags touch_flag;
points = outline->points; points = outline->points;
@@ -503,12 +543,12 @@
edges = outline->horz_edges; edges = outline->horz_edges;
edge_limit = edges + outline->num_hedges; edge_limit = edges + outline->num_hedges;
touch_flag = ah_flag_touch_y; touch_flag = AH_FLAG_TOUCH_Y;
for ( dimension = 1; dimension >= 0; dimension-- ) for ( dimension = 1; dimension >= 0; dimension-- )
{ {
AH_Point* point; AH_Point point;
AH_Edge* edge; AH_Edge edge;
if ( edges < edge_limit ) if ( edges < edge_limit )
@@ -524,7 +564,8 @@
#ifndef AH_OPTION_NO_WEAK_INTERPOLATION #ifndef AH_OPTION_NO_WEAK_INTERPOLATION
/* if this point is candidate to weak interpolation, we will */ /* if this point is candidate to weak interpolation, we will */
/* interpolate it after all strong points have been processed */ /* 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; continue;
#endif #endif
@@ -561,8 +602,8 @@
/* otherwise, interpolate the point in between */ /* otherwise, interpolate the point in between */
{ {
AH_Edge* before = 0; AH_Edge before = 0;
AH_Edge* after = 0; AH_Edge after = 0;
for ( edge = edges; edge < edge_limit; edge++ ) for ( edge = edges; edge < edge_limit; edge++ )
@@ -608,7 +649,7 @@
edges = outline->vert_edges; edges = outline->vert_edges;
edge_limit = edges + outline->num_vedges; edge_limit = edges + outline->num_vedges;
touch_flag = ah_flag_touch_x; touch_flag = AH_FLAG_TOUCH_X;
} }
} }
@@ -616,12 +657,12 @@
#ifndef AH_OPTION_NO_WEAK_INTERPOLATION #ifndef AH_OPTION_NO_WEAK_INTERPOLATION
static void static void
ah_iup_shift( AH_Point* p1, ah_iup_shift( AH_Point p1,
AH_Point* p2, AH_Point p2,
AH_Point* ref ) AH_Point ref )
{ {
AH_Point* p; AH_Point p;
FT_Pos delta = ref->u - ref->v; FT_Pos delta = ref->u - ref->v;
for ( p = p1; p < ref; p++ ) for ( p = p1; p < ref; p++ )
@@ -633,17 +674,17 @@
static void static void
ah_iup_interp( AH_Point* p1, ah_iup_interp( AH_Point p1,
AH_Point* p2, AH_Point p2,
AH_Point* ref1, AH_Point ref1,
AH_Point* ref2 ) AH_Point ref2 )
{ {
AH_Point* p; AH_Point p;
FT_Pos u; FT_Pos u;
FT_Pos v1 = ref1->v; FT_Pos v1 = ref1->v;
FT_Pos v2 = ref2->v; FT_Pos v2 = ref2->v;
FT_Pos d1 = ref1->u - v1; FT_Pos d1 = ref1->u - v1;
FT_Pos d2 = ref2->u - v2; FT_Pos d2 = ref2->u - v2;
if ( p1 > p2 ) if ( p1 > p2 )
@@ -702,14 +743,14 @@
/* interpolate weak points -- this is equivalent to the TrueType `IUP' */ /* interpolate weak points -- this is equivalent to the TrueType `IUP' */
static void 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; FT_Int dimension;
AH_Point* points; AH_Point points;
AH_Point* point_limit; AH_Point point_limit;
AH_Point** contour_limit; AH_Point* contour_limit;
AH_Flags touch_flag; AH_Flags touch_flag;
points = outline->points; points = outline->points;
@@ -717,18 +758,18 @@
/* PASS 1: Move segment points to edge positions */ /* 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; 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-- ) for ( dimension = 1; dimension >= 0; dimension-- )
{ {
AH_Point* point; AH_Point point;
AH_Point* end_point; AH_Point end_point;
AH_Point* first_point; AH_Point first_point;
AH_Point** contour; AH_Point* contour;
point = points; point = points;
@@ -745,8 +786,8 @@
if ( point <= end_point ) if ( point <= end_point )
{ {
AH_Point* first_touched = point; AH_Point first_touched = point;
AH_Point* cur_touched = point; AH_Point cur_touched = point;
point++; point++;
@@ -791,8 +832,8 @@
for ( point = points; point < point_limit; point++ ) for ( point = points; point < point_limit; point++ )
point->y = point->u; point->y = point->u;
touch_flag = ah_flag_touch_x; touch_flag = AH_FLAG_TOUCH_X;
ah_setup_uv( outline, ah_uv_ox ); ah_setup_uv( outline, AH_UV_OX );
} }
else else
{ {
@@ -808,7 +849,7 @@
FT_LOCAL_DEF( void ) FT_LOCAL_DEF( void )
ah_hinter_align_points( AH_Hinter* hinter ) ah_hinter_align_points( AH_Hinter hinter )
{ {
ah_hinter_align_edge_points( hinter ); ah_hinter_align_edge_points( hinter );
@@ -835,14 +876,14 @@
/* scale and fit the global metrics */ /* scale and fit the global metrics */
static void static void
ah_hinter_scale_globals( AH_Hinter* hinter, ah_hinter_scale_globals( AH_Hinter hinter,
FT_Fixed x_scale, FT_Fixed x_scale,
FT_Fixed y_scale ) FT_Fixed y_scale )
{ {
FT_Int n; FT_Int n;
AH_Face_Globals* globals = hinter->globals; AH_Face_Globals globals = hinter->globals;
AH_Globals* design = &globals->design; AH_Globals design = &globals->design;
AH_Globals* scaled = &globals->scaled; AH_Globals scaled = &globals->scaled;
/* copy content */ /* copy content */
@@ -855,8 +896,11 @@
for ( n = 0; n < design->num_heights; n++ ) for ( n = 0; n < design->num_heights; n++ )
scaled->heights[n] = FT_MulFix( design->heights[n], y_scale ); 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 */ /* scale the blue zones */
for ( n = 0; n < ah_blue_max; n++ ) for ( n = 0; n < AH_BLUE_MAX; n++ )
{ {
FT_Pos delta, delta2; FT_Pos delta, delta2;
@@ -888,7 +932,7 @@
static void static void
ah_hinter_align( AH_Hinter* hinter ) ah_hinter_align( AH_Hinter hinter )
{ {
ah_hinter_align_edge_points( hinter ); ah_hinter_align_edge_points( hinter );
ah_hinter_align_points( hinter ); ah_hinter_align_points( hinter );
@@ -897,7 +941,7 @@
/* finalize a hinter object */ /* finalize a hinter object */
FT_LOCAL_DEF( void ) FT_LOCAL_DEF( void )
ah_hinter_done( AH_Hinter* hinter ) ah_hinter_done( AH_Hinter hinter )
{ {
if ( hinter ) if ( hinter )
{ {
@@ -920,12 +964,12 @@
/* create a new empty hinter object */ /* create a new empty hinter object */
FT_LOCAL_DEF( FT_Error ) FT_LOCAL_DEF( FT_Error )
ah_hinter_new( FT_Library library, 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_Memory memory = library->memory;
FT_Error error; FT_Error error;
*ahinter = 0; *ahinter = 0;
@@ -956,13 +1000,13 @@
/* create a face's autohint globals */ /* create a face's autohint globals */
FT_LOCAL_DEF( FT_Error ) FT_LOCAL_DEF( FT_Error )
ah_hinter_new_face_globals( AH_Hinter* hinter, ah_hinter_new_face_globals( AH_Hinter hinter,
FT_Face face, FT_Face face,
AH_Globals* globals ) AH_Globals globals )
{ {
FT_Error error; FT_Error error;
FT_Memory memory = hinter->memory; FT_Memory memory = hinter->memory;
AH_Face_Globals* face_globals; AH_Face_Globals face_globals;
if ( FT_NEW( face_globals ) ) if ( FT_NEW( face_globals ) )
@@ -988,7 +1032,7 @@
/* discard a face's autohint globals */ /* discard a face's autohint globals */
FT_LOCAL_DEF( void ) 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_Face face = globals->face;
FT_Memory memory = face->memory; FT_Memory memory = face->memory;
@@ -999,10 +1043,10 @@
static FT_Error static FT_Error
ah_hinter_load( AH_Hinter* hinter, ah_hinter_load( AH_Hinter hinter,
FT_UInt glyph_index, FT_UInt glyph_index,
FT_UInt load_flags, FT_Int32 load_flags,
FT_UInt depth ) FT_UInt depth )
{ {
FT_Face face = hinter->face; FT_Face face = hinter->face;
FT_GlyphSlot slot = face->glyph; FT_GlyphSlot slot = face->glyph;
@@ -1010,12 +1054,8 @@
FT_Fixed x_scale = face->size->metrics.x_scale; FT_Fixed x_scale = face->size->metrics.x_scale;
FT_Fixed y_scale = face->size->metrics.y_scale; FT_Fixed y_scale = face->size->metrics.y_scale;
FT_Error error; FT_Error error;
AH_Outline* outline = hinter->glyph; AH_Outline outline = hinter->glyph;
AH_Loader gloader = hinter->loader; 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 */ /* load the glyph */
@@ -1030,6 +1070,7 @@
{ {
FT_Matrix imatrix; FT_Matrix imatrix;
imatrix = internal->glyph_matrix; imatrix = internal->glyph_matrix;
hinter->trans_delta = internal->glyph_delta; hinter->trans_delta = internal->glyph_delta;
hinter->trans_matrix = imatrix; hinter->trans_matrix = imatrix;
@@ -1044,7 +1085,7 @@
switch ( slot->format ) switch ( slot->format )
{ {
case ft_glyph_format_outline: case FT_GLYPH_FORMAT_OUTLINE:
/* translate glyph outline if we need to */ /* translate glyph outline if we need to */
if ( hinter->transformed ) if ( hinter->transformed )
@@ -1098,14 +1139,14 @@
/* perform feature detection */ /* perform feature detection */
ah_outline_detect_features( outline ); ah_outline_detect_features( outline );
if ( !no_horz_hints ) if ( hinter->do_vert_hints )
{ {
ah_outline_compute_blue_edges( outline, hinter->globals ); ah_outline_compute_blue_edges( outline, hinter->globals );
ah_outline_scale_blue_edges( outline, hinter->globals ); ah_outline_scale_blue_edges( outline, hinter->globals );
} }
/* perform alignment control */ /* perform alignment control */
ah_hinter_hint_edges( hinter, no_horz_hints, no_vert_hints ); ah_hinter_hint_edges( hinter );
ah_hinter_align( hinter ); ah_hinter_align( hinter );
/* now save the current outline into the loader's current table */ /* now save the current outline into the loader's current table */
@@ -1114,10 +1155,10 @@
/* we now need to hint the metrics according to the change in */ /* we now need to hint the metrics according to the change in */
/* width/positioning that occured during the hinting process */ /* width/positioning that occured during the hinting process */
{ {
FT_Pos old_advance, old_rsb, old_lsb, new_lsb; FT_Pos old_advance, old_rsb, old_lsb, new_lsb;
AH_Edge* edge1 = outline->vert_edges; /* leftmost edge */ AH_Edge edge1 = outline->vert_edges; /* leftmost edge */
AH_Edge* edge2 = edge1 + AH_Edge edge2 = edge1 +
outline->num_vedges - 1; /* rightmost edge */ outline->num_vedges - 1; /* rightmost edge */
old_advance = hinter->pp2.x; old_advance = hinter->pp2.x;
@@ -1137,7 +1178,7 @@
ah_loader_add( gloader ); ah_loader_add( gloader );
break; break;
case ft_glyph_format_composite: case FT_GLYPH_FORMAT_COMPOSITE:
{ {
FT_UInt nn, num_subglyphs = slot->num_subglyphs; FT_UInt nn, num_subglyphs = slot->num_subglyphs;
FT_UInt num_base_subgs, start_point; FT_UInt num_base_subgs, start_point;
@@ -1314,7 +1355,7 @@
goto Exit; goto Exit;
slot->outline = slot->internal->loader->base.outline; slot->outline = slot->internal->loader->base.outline;
slot->format = ft_glyph_format_outline; slot->format = FT_GLYPH_FORMAT_OUTLINE;
} }
#ifdef DEBUG_HINTER #ifdef DEBUG_HINTER
@@ -1328,17 +1369,18 @@
/* load and hint a given glyph */ /* load and hint a given glyph */
FT_LOCAL_DEF( FT_Error ) FT_LOCAL_DEF( FT_Error )
ah_hinter_load_glyph( AH_Hinter* hinter, ah_hinter_load_glyph( AH_Hinter hinter,
FT_GlyphSlot slot, FT_GlyphSlot slot,
FT_Size size, FT_Size size,
FT_UInt glyph_index, FT_UInt glyph_index,
FT_Int load_flags ) FT_Int32 load_flags )
{ {
FT_Face face = slot->face; FT_Face face = slot->face;
FT_Error error; FT_Error error;
FT_Fixed x_scale = size->metrics.x_scale; FT_Fixed x_scale = size->metrics.x_scale;
FT_Fixed y_scale = size->metrics.y_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 */ /* first of all, we need to check that we're using the correct face and */
@@ -1366,6 +1408,25 @@
ah_loader_rewind( hinter->loader ); 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 #if 1
load_flags = FT_LOAD_NO_SCALE load_flags = FT_LOAD_NO_SCALE
| FT_LOAD_IGNORE_TRANSFORM ; | FT_LOAD_IGNORE_TRANSFORM ;
@@ -1382,14 +1443,14 @@
/* retrieve a face's autohint globals for client applications */ /* retrieve a face's autohint globals for client applications */
FT_LOCAL_DEF( void ) FT_LOCAL_DEF( void )
ah_hinter_get_global_hints( AH_Hinter* hinter, ah_hinter_get_global_hints( AH_Hinter hinter,
FT_Face face, FT_Face face,
void** global_hints, void** global_hints,
long* global_len ) long* global_len )
{ {
AH_Globals* globals = 0; AH_Globals globals = 0;
FT_Memory memory = hinter->memory; FT_Memory memory = hinter->memory;
FT_Error error; FT_Error error;
/* allocate new master globals */ /* allocate new master globals */
@@ -1419,8 +1480,8 @@
FT_LOCAL_DEF( void ) FT_LOCAL_DEF( void )
ah_hinter_done_global_hints( AH_Hinter* hinter, ah_hinter_done_global_hints( AH_Hinter hinter,
void* global_hints ) void* global_hints )
{ {
FT_Memory memory = hinter->memory; FT_Memory memory = hinter->memory;
+14 -14
View File
@@ -32,39 +32,39 @@ FT_BEGIN_HEADER
#define AH_HINT_DEFAULT 0 #define AH_HINT_DEFAULT 0
#define AH_HINT_NO_ALIGNMENT 1 #define AH_HINT_NO_ALIGNMENT 1
#define AH_HINT_NO_HORZ_EDGES 0x20000L #define AH_HINT_NO_HORZ_EDGES 0x200000L /* temporary hack */
#define AH_HINT_NO_VERT_EDGES 0x40000L #define AH_HINT_NO_VERT_EDGES 0x400000L /* temporary hack */
/* create a new empty hinter object */ /* create a new empty hinter object */
FT_LOCAL( FT_Error ) FT_LOCAL( FT_Error )
ah_hinter_new( FT_Library library, ah_hinter_new( FT_Library library,
AH_Hinter** ahinter ); AH_Hinter* ahinter );
/* Load a hinted glyph in the hinter */ /* Load a hinted glyph in the hinter */
FT_LOCAL( FT_Error ) FT_LOCAL( FT_Error )
ah_hinter_load_glyph( AH_Hinter* hinter, ah_hinter_load_glyph( AH_Hinter hinter,
FT_GlyphSlot slot, FT_GlyphSlot slot,
FT_Size size, FT_Size size,
FT_UInt glyph_index, FT_UInt glyph_index,
FT_Int load_flags ); FT_Int32 load_flags );
/* finalize a hinter object */ /* finalize a hinter object */
FT_LOCAL( void ) FT_LOCAL( void )
ah_hinter_done( AH_Hinter* hinter ); ah_hinter_done( AH_Hinter hinter );
FT_LOCAL( void ) FT_LOCAL( void )
ah_hinter_done_face_globals( AH_Face_Globals* globals ); ah_hinter_done_face_globals( AH_Face_Globals globals );
FT_LOCAL( void ) FT_LOCAL( void )
ah_hinter_get_global_hints( AH_Hinter* hinter, ah_hinter_get_global_hints( AH_Hinter hinter,
FT_Face face, FT_Face face,
void** global_hints, void** global_hints,
long* global_len ); long* global_len );
FT_LOCAL( void ) FT_LOCAL( void )
ah_hinter_done_global_hints( AH_Hinter* hinter, ah_hinter_done_global_hints( AH_Hinter hinter,
void* global_hints ); void* global_hints );
FT_END_HEADER FT_END_HEADER
+6 -6
View File
@@ -25,15 +25,15 @@
#ifdef DEBUG_HINTER #ifdef DEBUG_HINTER
extern AH_Hinter* ah_debug_hinter = NULL; AH_Hinter ah_debug_hinter = NULL;
extern FT_Bool ah_debug_disable_horz = 0; FT_Bool ah_debug_disable_horz = 0;
extern FT_Bool ah_debug_disable_vert = 0; FT_Bool ah_debug_disable_vert = 0;
#endif #endif
typedef struct FT_AutoHinterRec_ typedef struct FT_AutoHinterRec_
{ {
FT_ModuleRec root; FT_ModuleRec root;
AH_Hinter* hinter; AH_Hinter hinter;
} FT_AutoHinterRec; } FT_AutoHinterRec;
@@ -69,7 +69,7 @@
FT_GlyphSlot slot, FT_GlyphSlot slot,
FT_Size size, FT_Size size,
FT_UInt glyph_index, FT_UInt glyph_index,
FT_ULong load_flags ) FT_Int32 load_flags )
{ {
return ah_hinter_load_glyph( module->hinter, return ah_hinter_load_glyph( module->hinter,
slot, size, glyph_index, load_flags ); slot, size, glyph_index, load_flags );
@@ -83,7 +83,7 @@
FT_UNUSED( module ); FT_UNUSED( module );
if ( face->autohint.data ) 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) );
} }
+23 -23
View File
@@ -157,8 +157,8 @@
static int static int
valid_stem_segments( AH_Segment* seg1, valid_stem_segments( AH_Segment seg1,
AH_Segment* seg2 ) AH_Segment seg2 )
{ {
return seg1->serif == 0 && return seg1->serif == 0 &&
seg2 && seg2 &&
@@ -173,15 +173,15 @@
static int static int
optim_compute_stems( AH_Optimizer* optimizer ) optim_compute_stems( AH_Optimizer* optimizer )
{ {
AH_Outline* outline = optimizer->outline; AH_Outline outline = optimizer->outline;
FT_Fixed scale; FT_Fixed scale;
FT_Memory memory = optimizer->memory; FT_Memory memory = optimizer->memory;
FT_Error error = 0; FT_Error error = 0;
FT_Int dimension; FT_Int dimension;
AH_Edge* edges; AH_Edge edges;
AH_Edge* edge_limit; AH_Edge edge_limit;
AH_Stem** p_stems; AH_Stem** p_stems;
FT_Int* p_num_stems; FT_Int* p_num_stems;
edges = outline->horz_edges; edges = outline->horz_edges;
@@ -195,13 +195,13 @@
{ {
AH_Stem* stems = 0; AH_Stem* stems = 0;
FT_Int num_stems = 0; FT_Int num_stems = 0;
AH_Edge* edge; AH_Edge edge;
/* first of all, count the number of stems in this direction */ /* first of all, count the number of stems in this direction */
for ( edge = edges; edge < edge_limit; edge++ ) for ( edge = edges; edge < edge_limit; edge++ )
{ {
AH_Segment* seg = edge->first; AH_Segment seg = edge->first;
do do
@@ -226,8 +226,8 @@
stem = stems; stem = stems;
for ( edge = edges; edge < edge_limit; edge++ ) for ( edge = edges; edge < edge_limit; edge++ )
{ {
AH_Segment* seg = edge->first; AH_Segment seg = edge->first;
AH_Segment* seg2; AH_Segment seg2;
do do
@@ -235,8 +235,8 @@
seg2 = seg->link; seg2 = seg->link;
if ( valid_stem_segments( seg, seg2 ) ) if ( valid_stem_segments( seg, seg2 ) )
{ {
AH_Edge* edge1 = seg->edge; AH_Edge edge1 = seg->edge;
AH_Edge* edge2 = seg2->edge; AH_Edge edge2 = seg2->edge;
stem->edge1 = edge1; stem->edge1 = edge1;
@@ -721,8 +721,8 @@
stem->edge1->pos = pos; stem->edge1->pos = pos;
stem->edge2->pos = pos + stem->width; stem->edge2->pos = pos + stem->width;
stem->edge1->flags |= ah_edge_done; stem->edge1->flags |= AH_EDGE_DONE;
stem->edge2->flags |= ah_edge_done; stem->edge2->flags |= AH_EDGE_DONE;
} }
} }
@@ -768,8 +768,8 @@
stem->edge1->pos = pos; stem->edge1->pos = pos;
stem->edge2->pos = pos + stem->width; stem->edge2->pos = pos + stem->width;
stem->edge1->flags |= ah_edge_done; stem->edge1->flags |= AH_EDGE_DONE;
stem->edge2->flags |= ah_edge_done; stem->edge2->flags |= AH_EDGE_DONE;
} }
} }
@@ -808,13 +808,13 @@
/* loads the outline into the optimizer */ /* loads the outline into the optimizer */
int int
AH_Optimizer_Init( AH_Optimizer* optimizer, AH_Optimizer_Init( AH_Optimizer* optimizer,
AH_Outline* outline, AH_Outline outline,
FT_Memory memory ) FT_Memory memory )
{ {
FT_Error error; FT_Error error;
FT_MEM_SET( optimizer, 0, sizeof ( *optimizer ) ); FT_MEM_ZERO( optimizer, sizeof ( *optimizer ) );
optimizer->outline = outline; optimizer->outline = outline;
optimizer->memory = memory; optimizer->memory = memory;
+14 -14
View File
@@ -37,22 +37,22 @@ FT_BEGIN_HEADER
typedef struct AH_Stem_ typedef struct AH_Stem_
{ {
FT_Pos pos; /* current position */ FT_Pos pos; /* current position */
FT_Pos velocity; /* current velocity */ FT_Pos velocity; /* current velocity */
FT_Pos force; /* sum of current forces */ FT_Pos force; /* sum of current forces */
FT_Pos width; /* normalized width */ FT_Pos width; /* normalized width */
FT_Pos min_pos; /* minimum grid position */ FT_Pos min_pos; /* minimum grid position */
FT_Pos max_pos; /* maximum grid position */ FT_Pos max_pos; /* maximum grid position */
AH_Edge* edge1; /* left/bottom edge */ AH_Edge edge1; /* left/bottom edge */
AH_Edge* edge2; /* right/top edge */ AH_Edge edge2; /* right/top edge */
FT_Pos opos; /* original position */ FT_Pos opos; /* original position */
FT_Pos owidth; /* original width */ FT_Pos owidth; /* original width */
FT_Pos min_coord; /* minimum coordinate */ FT_Pos min_coord; /* minimum coordinate */
FT_Pos max_coord; /* maximum coordinate */ FT_Pos max_coord; /* maximum coordinate */
} AH_Stem; } AH_Stem;
@@ -81,7 +81,7 @@ FT_BEGIN_HEADER
typedef struct AH_Optimizer_ typedef struct AH_Optimizer_
{ {
FT_Memory memory; FT_Memory memory;
AH_Outline* outline; AH_Outline outline;
FT_Int num_hstems; FT_Int num_hstems;
AH_Stem* horz_stems; AH_Stem* horz_stems;
@@ -115,7 +115,7 @@ FT_BEGIN_HEADER
/* loads the outline into the optimizer */ /* loads the outline into the optimizer */
int int
AH_Optimizer_Init( AH_Optimizer* optimizer, AH_Optimizer_Init( AH_Optimizer* optimizer,
AH_Outline* outline, AH_Outline outline,
FT_Memory memory ); 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 */ /* no reason to do this (at least for non-CJK scripts), except for */
/* experimentation. */ /* experimentation. */
/* */ /* */
#define AH_HINT_METRICS #undef AH_HINT_METRICS
/*************************************************************************/ /*************************************************************************/
@@ -126,63 +126,65 @@ FT_BEGIN_HEADER
/* hint flags */ /* hint flags */
#define ah_flag_none 0 #define AH_FLAG_NONE 0
/* bezier control points flags */ /* bezier control points flags */
#define ah_flag_conic 1 #define AH_FLAG_CONIC 1
#define ah_flag_cubic 2 #define AH_FLAG_CUBIC 2
#define ah_flag_control ( ah_flag_conic | ah_flag_cubic ) #define AH_FLAG_CONTROL ( AH_FLAG_CONIC | AH_FLAG_CUBIC )
/* extrema flags */ /* extrema flags */
#define ah_flag_extrema_x 4 #define AH_FLAG_EXTREMA_X 4
#define ah_flag_extrema_y 8 #define AH_FLAG_EXTREMA_Y 8
/* roundness */ /* roundness */
#define ah_flag_round_x 16 #define AH_FLAG_ROUND_X 16
#define ah_flag_round_y 32 #define AH_FLAG_ROUND_Y 32
/* touched */ /* touched */
#define ah_flag_touch_x 64 #define AH_FLAG_TOUCH_X 64
#define ah_flag_touch_y 128 #define AH_FLAG_TOUCH_Y 128
/* weak interpolation */ /* weak interpolation */
#define ah_flag_weak_interpolation 256 #define AH_FLAG_WEAK_INTERPOLATION 256
#define AH_FLAG_INFLECTION 512
typedef FT_Int AH_Flags; typedef FT_Int AH_Flags;
/* edge hint flags */ /* edge hint flags */
#define ah_edge_normal 0 #define AH_EDGE_NORMAL 0
#define ah_edge_round 1 #define AH_EDGE_ROUND 1
#define ah_edge_serif 2 #define AH_EDGE_SERIF 2
#define ah_edge_done 4 #define AH_EDGE_DONE 4
typedef FT_Int AH_Edge_Flags; typedef FT_Int AH_Edge_Flags;
/* hint directions -- the values are computed so that two vectors are */ /* hint directions -- the values are computed so that two vectors are */
/* in opposite directions iff `dir1+dir2 == 0' */ /* in opposite directions iff `dir1+dir2 == 0' */
#define ah_dir_none 4 #define AH_DIR_NONE 4
#define ah_dir_right 1 #define AH_DIR_RIGHT 1
#define ah_dir_left -1 #define AH_DIR_LEFT -1
#define ah_dir_up 2 #define AH_DIR_UP 2
#define ah_dir_down -2 #define AH_DIR_DOWN -2
typedef FT_Int AH_Direction; typedef FT_Int AH_Direction;
typedef struct AH_Point AH_Point; typedef struct AH_PointRec_* AH_Point;
typedef struct AH_Segment AH_Segment; typedef struct AH_SegmentRec_* AH_Segment;
typedef struct AH_Edge AH_Edge; typedef struct AH_EdgeRec_* AH_Edge;
/*************************************************************************/ /*************************************************************************/
/* */ /* */
/* <Struct> */ /* <Struct> */
/* AH_Point */ /* AH_PointRec */
/* */ /* */
/* <Description> */ /* <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> */ /* <Fields> */
/* flags :: The current point hint flags. */ /* flags :: The current point hint flags. */
@@ -207,7 +209,7 @@ FT_BEGIN_HEADER
/* */ /* */
/* prev :: The previous point in same contour. */ /* prev :: The previous point in same contour. */
/* */ /* */
struct AH_Point typedef struct AH_PointRec_
{ {
AH_Flags flags; /* point flags used by hinter */ AH_Flags flags; /* point flags used by hinter */
FT_Pos ox, oy; FT_Pos ox, oy;
@@ -221,15 +223,16 @@ FT_BEGIN_HEADER
AH_Angle in_angle; AH_Angle in_angle;
AH_Angle out_angle; AH_Angle out_angle;
AH_Point* next; /* next point in contour */ AH_Point next; /* next point in contour */
AH_Point* prev; /* previous point in contour */ AH_Point prev; /* previous point in contour */
};
} AH_PointRec;
/*************************************************************************/ /*************************************************************************/
/* */ /* */
/* <Struct> */ /* <Struct> */
/* AH_Segment */ /* AH_SegmentRec */
/* */ /* */
/* <Description> */ /* <Description> */
/* A structure used to describe an edge segment to the auto-hinter. */ /* 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. */ /* score :: Used to score the segment when selecting them. */
/* */ /* */
struct AH_Segment typedef struct AH_SegmentRec_
{ {
AH_Edge_Flags flags; AH_Edge_Flags flags;
AH_Direction dir; AH_Direction dir;
AH_Point* first; /* first point in edge segment */ AH_Point first; /* first point in edge segment */
AH_Point* last; /* last 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* contour; /* ptr to first point of segment's contour */
FT_Pos pos; /* position of segment */ FT_Pos pos; /* position of segment */
FT_Pos min_coord; /* minimum coordinate of segment */ FT_Pos min_coord; /* minimum coordinate of segment */
FT_Pos max_coord; /* maximum coordinate of segment */ FT_Pos max_coord; /* maximum coordinate of segment */
AH_Edge* edge; AH_Edge edge;
AH_Segment* edge_next; AH_Segment edge_next;
AH_Segment* link; /* link segment */ AH_Segment link; /* link segment */
AH_Segment* serif; /* primary segment for serifs */ AH_Segment serif; /* primary segment for serifs */
FT_Pos num_linked; /* number of linked segments */ FT_Pos num_linked; /* number of linked segments */
FT_Int score; FT_Pos score;
};
} AH_SegmentRec;
/*************************************************************************/ /*************************************************************************/
/* */ /* */
/* <Struct> */ /* <Struct> */
/* AH_Edge */ /* AH_EdgeRec */
/* */ /* */
/* <Description> */ /* <Description> */
/* A structure used to describe an edge, which really is a horizontal */ /* 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 */ /* Only set for some of the horizontal edges in a Latin */
/* font. */ /* font. */
/* */ /* */
struct AH_Edge typedef struct AH_EdgeRec_
{ {
AH_Edge_Flags flags; AH_Edge_Flags flags;
AH_Direction dir; AH_Direction dir;
AH_Segment* first; AH_Segment first;
AH_Segment* last; AH_Segment last;
FT_Pos fpos; FT_Pos fpos;
FT_Pos opos; FT_Pos opos;
FT_Pos pos; FT_Pos pos;
AH_Edge* link; AH_Edge link;
AH_Edge* serif; AH_Edge serif;
FT_Int num_linked; FT_Int num_linked;
FT_Int score; FT_Int score;
FT_Pos* blue_edge; FT_Pos* blue_edge;
};
} AH_EdgeRec;
/* an outline as seen by the hinter */ /* an outline as seen by the hinter */
typedef struct AH_Outline_ typedef struct AH_OutlineRec_
{ {
FT_Memory memory; FT_Memory memory;
@@ -359,39 +364,39 @@ FT_BEGIN_HEADER
FT_Int max_points; FT_Int max_points;
FT_Int num_points; FT_Int num_points;
AH_Point* points; AH_Point points;
FT_Int max_contours; FT_Int max_contours;
FT_Int num_contours; FT_Int num_contours;
AH_Point** contours; AH_Point * contours;
FT_Int num_hedges; FT_Int num_hedges;
AH_Edge* horz_edges; AH_Edge horz_edges;
FT_Int num_vedges; FT_Int num_vedges;
AH_Edge* vert_edges; AH_Edge vert_edges;
FT_Int num_hsegments; FT_Int num_hsegments;
AH_Segment* horz_segments; AH_Segment horz_segments;
FT_Int num_vsegments; 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_TOP 0 /* THEZOCQS */
#define ah_blue_capital_bottom ( ah_blue_capital_top + 1 ) /* HEZLOCUS */ #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_TOP ( AH_BLUE_CAPITAL_BOTTOM + 1 ) /* xzroesc */
#define ah_blue_small_bottom ( ah_blue_small_top + 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_SMALL_MINOR ( AH_BLUE_SMALL_BOTTOM + 1 ) /* pqgjy */
#define ah_blue_max ( ah_blue_small_minor + 1 ) #define AH_BLUE_MAX ( AH_BLUE_SMALL_MINOR + 1 )
typedef FT_Int AH_Blue; typedef FT_Int AH_Blue;
#define ah_hinter_monochrome 1 #define AH_HINTER_MONOCHROME 1
#define ah_hinter_optimize 2 #define AH_HINTER_OPTIMIZE 2
typedef FT_Int AH_Hinter_Flags; typedef FT_Int AH_Hinter_Flags;
@@ -399,7 +404,7 @@ FT_BEGIN_HEADER
/*************************************************************************/ /*************************************************************************/
/* */ /* */
/* <Struct> */ /* <Struct> */
/* AH_Globals */ /* AH_GlobalsRec */
/* */ /* */
/* <Description> */ /* <Description> */
/* Holds the global metrics for a given font face (be it in design */ /* 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. */ /* blue_shoots :: The overshoot positions of blue zones. */
/* */ /* */
typedef struct AH_Globals_ typedef struct AH_GlobalsRec_
{ {
FT_Int num_widths; FT_Int num_widths;
FT_Int num_heights; FT_Int num_heights;
FT_Pos stds[2];
FT_Pos widths [AH_MAX_WIDTHS]; FT_Pos widths [AH_MAX_WIDTHS];
FT_Pos heights[AH_MAX_HEIGHTS]; FT_Pos heights[AH_MAX_HEIGHTS];
FT_Pos blue_refs [ah_blue_max]; FT_Pos blue_refs [AH_BLUE_MAX];
FT_Pos blue_shoots[ah_blue_max]; FT_Pos blue_shoots[AH_BLUE_MAX];
} AH_Globals; } AH_GlobalsRec, *AH_Globals;
/*************************************************************************/ /*************************************************************************/
/* */ /* */
/* <Struct> */ /* <Struct> */
/* AH_Face_Globals */ /* AH_Face_GlobalsRec */
/* */ /* */
/* <Description> */ /* <Description> */
/* Holds the complete global metrics for a given font face (i.e., the */ /* 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. */ /* y_scale :: The current vertical scale. */
/* */ /* */
typedef struct AH_Face_Globals_ typedef struct AH_Face_GlobalsRec_
{ {
FT_Face face; FT_Face face;
AH_Globals design; AH_GlobalsRec design;
AH_Globals scaled; AH_GlobalsRec scaled;
FT_Fixed x_scale; FT_Fixed x_scale;
FT_Fixed y_scale; FT_Fixed y_scale;
FT_Bool control_overshoot; FT_Bool control_overshoot;
} AH_Face_Globals; } AH_Face_GlobalsRec, *AH_Face_Globals;
typedef struct AH_Hinter typedef struct AH_HinterRec
{ {
FT_Memory memory; FT_Memory memory;
AH_Hinter_Flags flags; AH_Hinter_Flags flags;
@@ -473,9 +480,9 @@ FT_BEGIN_HEADER
FT_Int algorithm; FT_Int algorithm;
FT_Face face; FT_Face face;
AH_Face_Globals* globals; AH_Face_Globals globals;
AH_Outline* glyph; AH_Outline glyph;
AH_Loader loader; AH_Loader loader;
FT_Vector pp1; FT_Vector pp1;
@@ -485,11 +492,16 @@ FT_BEGIN_HEADER
FT_Vector trans_delta; FT_Vector trans_delta;
FT_Matrix trans_matrix; 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 #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_horz;
extern FT_Bool ah_debug_disable_vert; extern FT_Bool ah_debug_disable_vert;
#else #else
+1 -1
View File
@@ -15,7 +15,7 @@
CFLAGS=$(COMP_FLAGS)$(DEBUG)/include=([--.builds.vms],[--.include],[--.src.base]) 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) all : $(OBJS)
library [--.lib]freetype.olb $(OBJS) library [--.lib]freetype.olb $(OBJS)
+1 -1
View File
@@ -602,7 +602,7 @@
if ( y < cbox.yMin ) cbox.yMin = y; if ( y < cbox.yMin ) cbox.yMin = y;
if ( y > cbox.yMax ) cbox.yMax = 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 */ /* update bbox for `on' points only */
if ( x < bbox.xMin ) bbox.xMin = x; if ( x < bbox.xMin ) bbox.xMin = x;
+3 -3
View File
@@ -202,7 +202,7 @@
if ( new_buckets == NULL ) if ( new_buckets == NULL )
return; 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++ ) for ( i = 0; i < table->size; i++ )
{ {
@@ -243,7 +243,7 @@
if ( table == NULL ) if ( table == NULL )
goto Exit; goto Exit;
FT_MEM_SET( table, 0, sizeof ( *table ) ); FT_MEM_ZERO( table, sizeof ( *table ) );
table->size = FT_MEM_SIZE_MIN; table->size = FT_MEM_SIZE_MIN;
table->nodes = 0; table->nodes = 0;
@@ -260,7 +260,7 @@
memory->alloc( memory, memory->alloc( memory,
table->size * sizeof ( FT_MemNode ) ); table->size * sizeof ( FT_MemNode ) );
if ( table->buckets ) 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 else
{ {
memory->free( memory, table ); memory->free( memory, table );
+17 -17
View File
@@ -86,7 +86,7 @@
#define FT_TRACE_DEF(x) #x , #define FT_TRACE_DEF(x) #x ,
static const char* ft_trace_toggles[trace_count + 1] = static const char* ft_trace_toggles[trace_count + 1] =
{ {
#include FT_INTERNAL_TRACE_H #include FT_INTERNAL_TRACE_H
NULL NULL
}; };
@@ -98,9 +98,9 @@
/* */ /* */
/* Initialize the tracing sub-system. This is done by retrieving the */ /* Initialize the tracing sub-system. This is done by retrieving the */
/* value of the "FT2_DEBUG" environment variable. It must be a list of */ /* 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 */ /* 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, */ /* for the memory and stream components which are set to 6 and 5, */
@@ -116,48 +116,48 @@
ft_debug_init( void ) ft_debug_init( void )
{ {
const char* ft2_debug = getenv( "FT2_DEBUG" ); const char* ft2_debug = getenv( "FT2_DEBUG" );
if ( ft2_debug ) if ( ft2_debug )
{ {
const char* p = ft2_debug; const char* p = ft2_debug;
const char* q; const char* q;
for ( ; *p; p++ ) for ( ; *p; p++ )
{ {
/* skip leading whitespace and separators */ /* skip leading whitespace and separators */
if ( *p == ' ' || *p == '\t' || *p == ':' || *p == ';' || *p == '=' ) if ( *p == ' ' || *p == '\t' || *p == ',' || *p == ';' || *p == '=' )
continue; continue;
/* read toggle name, followed by '=' */ /* read toggle name, followed by ':' */
q = p; q = p;
while ( *p && *p != '=' ) while ( *p && *p != ':' )
p++; p++;
if ( *p == '=' && p > q ) if ( *p == ':' && p > q )
{ {
int n, i, len = p - q; FT_Int n, i, len = (FT_Int)(p - q);
int level = -1, found = -1; FT_Int level = -1, found = -1;
for ( n = 0; n < trace_count; n++ ) for ( n = 0; n < trace_count; n++ )
{ {
const char* toggle = ft_trace_toggles[n]; const char* toggle = ft_trace_toggles[n];
for ( i = 0; i < len; i++ ) for ( i = 0; i < len; i++ )
{ {
if ( toggle[i] != q[i] ) if ( toggle[i] != q[i] )
break; break;
} }
if ( i == len && toggle[i] == 0 ) if ( i == len && toggle[i] == 0 )
{ {
found = n; found = n;
break; break;
} }
} }
/* read level */ /* read level */
p++; p++;
if ( *p ) if ( *p )
@@ -166,7 +166,7 @@
if ( level < 0 || level > 6 ) if ( level < 0 || level > 6 )
level = -1; level = -1;
} }
if ( found >= 0 && level >= 0 ) if ( found >= 0 && level >= 0 )
{ {
if ( found == trace_any ) if ( found == trace_any )
+33 -28
View File
@@ -147,7 +147,7 @@
FT_Memory memory = library->memory; 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; error = FT_Err_Invalid_Glyph_Format;
goto Exit; goto Exit;
@@ -209,14 +209,14 @@
const FT_Glyph_Class ft_bitmap_glyph_class = const FT_Glyph_Class ft_bitmap_glyph_class =
{ {
sizeof( FT_BitmapGlyphRec ), sizeof( FT_BitmapGlyphRec ),
ft_glyph_format_bitmap, FT_GLYPH_FORMAT_BITMAP,
(FT_Glyph_Init_Func) ft_bitmap_glyph_init, (FT_Glyph_InitFunc) ft_bitmap_glyph_init,
(FT_Glyph_Done_Func) ft_bitmap_glyph_done, (FT_Glyph_DoneFunc) ft_bitmap_glyph_done,
(FT_Glyph_Copy_Func) ft_bitmap_glyph_copy, (FT_Glyph_CopyFunc) ft_bitmap_glyph_copy,
(FT_Glyph_Transform_Func)0, (FT_Glyph_TransformFunc)0,
(FT_Glyph_BBox_Func) ft_bitmap_glyph_bbox, (FT_Glyph_GetBBoxFunc) ft_bitmap_glyph_bbox,
(FT_Glyph_Prepare_Func) 0 (FT_Glyph_PrepareFunc) 0
}; };
@@ -240,7 +240,7 @@
/* check format in glyph slot */ /* 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; error = FT_Err_Invalid_Glyph_Format;
goto Exit; goto Exit;
@@ -262,8 +262,8 @@
FT_MEM_COPY( target->contours, source->contours, FT_MEM_COPY( target->contours, source->contours,
source->n_contours * sizeof ( FT_Short ) ); source->n_contours * sizeof ( FT_Short ) );
/* copy all flags, except the `ft_outline_owner' one */ /* copy all flags, except the `FT_OUTLINE_OWNER' one */
target->flags = source->flags | ft_outline_owner; target->flags = source->flags | FT_OUTLINE_OWNER;
Exit: Exit:
return error; return error;
@@ -319,9 +319,9 @@
ft_outline_glyph_prepare( FT_OutlineGlyph glyph, ft_outline_glyph_prepare( FT_OutlineGlyph glyph,
FT_GlyphSlot slot ) FT_GlyphSlot slot )
{ {
slot->format = ft_glyph_format_outline; slot->format = FT_GLYPH_FORMAT_OUTLINE;
slot->outline = glyph->outline; slot->outline = glyph->outline;
slot->outline.flags &= ~ft_outline_owner; slot->outline.flags &= ~FT_OUTLINE_OWNER;
return FT_Err_Ok; return FT_Err_Ok;
} }
@@ -330,14 +330,14 @@
const FT_Glyph_Class ft_outline_glyph_class = const FT_Glyph_Class ft_outline_glyph_class =
{ {
sizeof( FT_OutlineGlyphRec ), sizeof( FT_OutlineGlyphRec ),
ft_glyph_format_outline, FT_GLYPH_FORMAT_OUTLINE,
(FT_Glyph_Init_Func) ft_outline_glyph_init, (FT_Glyph_InitFunc) ft_outline_glyph_init,
(FT_Glyph_Done_Func) ft_outline_glyph_done, (FT_Glyph_DoneFunc) ft_outline_glyph_done,
(FT_Glyph_Copy_Func) ft_outline_glyph_copy, (FT_Glyph_CopyFunc) ft_outline_glyph_copy,
(FT_Glyph_Transform_Func)ft_outline_glyph_transform, (FT_Glyph_TransformFunc)ft_outline_glyph_transform,
(FT_Glyph_BBox_Func) ft_outline_glyph_bbox, (FT_Glyph_GetBBoxFunc) ft_outline_glyph_bbox,
(FT_Glyph_Prepare_Func) ft_outline_glyph_prepare (FT_Glyph_PrepareFunc) ft_outline_glyph_prepare
}; };
@@ -435,11 +435,11 @@
return FT_Err_Invalid_Argument; return FT_Err_Invalid_Argument;
/* if it is a bitmap, that's easy :-) */ /* 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; clazz = &ft_bitmap_glyph_class;
/* it it is an outline too */ /* 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; clazz = &ft_outline_glyph_class;
else else
@@ -566,13 +566,13 @@
/* documentation is in ftglyph.h */ /* documentation is in ftglyph.h */
FT_EXPORT_DEF( FT_Error ) FT_EXPORT_DEF( FT_Error )
FT_Glyph_To_Bitmap( FT_Glyph* the_glyph, FT_Glyph_To_Bitmap( FT_Glyph* the_glyph,
FT_ULong render_mode, FT_Render_Mode render_mode,
FT_Vector* origin, FT_Vector* origin,
FT_Bool destroy ) FT_Bool destroy )
{ {
FT_GlyphSlotRec dummy; FT_GlyphSlotRec dummy;
FT_Error error; FT_Error error = FT_Err_Ok;
FT_Glyph glyph; FT_Glyph glyph;
FT_BitmapGlyph bitmap = NULL; FT_BitmapGlyph bitmap = NULL;
@@ -591,10 +591,15 @@
goto Bad; goto Bad;
clazz = glyph->clazz; 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 ) if ( !clazz || !clazz->glyph_prepare )
goto Bad; goto Bad;
FT_MEM_SET( &dummy, 0, sizeof ( dummy ) ); FT_MEM_ZERO( &dummy, sizeof ( dummy ) );
dummy.library = glyph->library; dummy.library = glyph->library;
dummy.format = clazz->glyph_format; dummy.format = clazz->glyph_format;
+64 -33
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_MEMORY_H
#include FT_INTERNAL_DEBUG_H #include FT_INTERNAL_DEBUG_H
@@ -27,7 +29,7 @@
table->mask = 0; table->mask = 0;
table->slack = 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_init( FT_Hash table,
FT_Hash_CompareFunc compare, FT_Hash_EqualFunc equal,
FT_Memory memory ) FT_Memory memory )
{ {
hash->memory = memory; FT_Error error;
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_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_hash_lookup( FT_Hash table,
FT_HashNode keynode ) FT_HashNode keynode )
{ {
FT_UInt index; FT_UInt index;
FT_UInt23 hash = keynode->hash; FT_UInt32 hash = keynode->hash;
FT_HashNode node, *pnode;
index = (FT_UInt)(hash & table->mask); index = (FT_UInt)(hash & table->mask);
if ( index < table->p ) if ( index < table->p )
@@ -102,7 +109,7 @@
if ( node == NULL ) if ( node == NULL )
break; break;
if ( node->hash == hash && table->compare( node, keynode ) ) if ( node->hash == hash && table->node_equal( node, keynode ) )
break; break;
pnode = &node->link; pnode = &node->link;
@@ -114,20 +121,22 @@
FT_BASE_DEF( void ) FT_BASE_DEF( FT_Error )
ft_hash_add( FT_Hash table, ft_hash_add( FT_Hash table,
FT_HashNode* pnode, FT_HashLookup lookup,
FT_HashNode new_node ) FT_HashNode new_node )
{ {
FT_Error error = 0;
/* add it to the hash table */ /* add it to the hash table */
new_node->link = *pnode; new_node->link = *lookup;
*pnode = new_node; *lookup = new_node;
if ( --table->slack < 0 ) if ( --table->slack < 0 )
{ {
FT_UInt p = table->p; FT_UInt p = table->p;
FT_UInt mask = table->mask; FT_UInt mask = table->mask;
FT_HashNode new_list; FT_HashNode new_list, node, *pnode;
/* split a single bucket */ /* split a single bucket */
new_list = NULL; new_list = NULL;
@@ -154,33 +163,41 @@
if ( p >= mask ) 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->mask = 2*mask + 1;
table->p = 0; table->p = 0;
} }
else else
table->p = p + 1; table->p = p + 1;
} }
Exit:
return error;
} }
FT_BASE_DEF( FT_Int ) FT_BASE_DEF( FT_Error )
ft_hash_remove( FT_Hash table, ft_hash_remove( FT_Hash table,
FT_HashNode* pnode ) FT_HashLookup lookup )
{ {
FT_HashNode node; FT_HashNode node;
FT_UInt num_buckets; FT_UInt num_buckets;
FT_Error error = 0;
FT_ASSERT( pnode != NULL && node != NULL ); FT_ASSERT( pnode != NULL && node != NULL );
node = *pnode; node = *lookup;
*pnode->link = node->link; *lookup = node->link;
node->link = NULL; node->link = NULL;
num_buckets = ( table->p + table->mask + 1) ; 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 p = table->p;
FT_UInt mask = table->mask; FT_UInt mask = table->mask;
@@ -189,14 +206,26 @@
FT_HashNode* pold; FT_HashNode* pold;
if ( old_index < FT_HASH_INITIAL_SIZE ) if ( old_index < FT_HASH_INITIAL_SIZE )
return; goto Exit;
if ( p == 0 ) if ( p == 0 )
{ {
FT_Memory memory = table->memory;
table->mask >>= 1; table->mask >>= 1;
p = table->mask; 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 else
p--; p--;
@@ -212,4 +241,6 @@
table->slack -= FT_HASH_MAX_LOAD; table->slack -= FT_HASH_MAX_LOAD;
table->p = p; table->p = p;
} }
Exit:
return error;
} }
+1 -1
View File
@@ -93,7 +93,7 @@
/* notify errors, but don't stop */ /* notify errors, but don't stop */
if ( error ) 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)->module_name, error ));
} }
cur++; cur++;
+3 -3
View File
@@ -530,11 +530,11 @@
return error; return error;
} }
args.flags = ft_open_stream; args.flags = FT_OPEN_STREAM;
args.stream = stream; args.stream = stream;
if ( driver_name ) 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 ); args.driver = FT_Get_Module( library, driver_name );
} }
@@ -910,7 +910,7 @@
#endif #endif
/* let it fall through to normal loader (.ttf, .otf, etc.) */ /* let it fall through to normal loader (.ttf, .otf, etc.) */
args.flags = ft_open_pathname; args.flags = FT_OPEN_PATHNAME;
args.pathname = (char*)pathname; args.pathname = (char*)pathname;
return FT_Open_Face( library, &args, face_index, aface ); return FT_Open_Face( library, &args, face_index, aface );
} }
+241 -147
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_DEATH 0xDEADdead
#define FT_MAGIC_CLASS 0x12345678 #define FT_MAGIC_CLASS 0x12345678
#define FT_TYPE_HASH(x) (( (FT_UInt32)(x) >> 2 )^( (FT_UInt32)(x) >> 10 ))
#define FT_OBJECT_CHECK(o) \ #define FT_OBJECT_CHECK(o) \
( FT_OBJECT(o) != NULL && \ ( FT_OBJECT(o) != NULL && \
FT_OBJECT(o)->clazz != NULL && \ FT_OBJECT(o)->clazz != NULL && \
FT_OBJECT(o)->ref_count >= 1 && \ FT_OBJECT(o)->ref_count >= 1 && \
FT_OBJECT(o)->clazz->magic == FT_MAGIC_CLASS ) 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 */ /* forward declaration */
static const FT_TypeRec ft_meta_class_type; FT_BASE_DEF( FT_Error )
ft_metaclass_init( FT_MetaClass meta,
FT_Library library );
/* forward declaration */
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 */ /* destroy a given class */
static void static void
ft_class_hnode_destroy( FT_ClassHNode node ) ft_class_hnode_destroy( FT_ClassHNode node )
{ {
FT_Clazz clazz = node->clazz; FT_Class clazz = node->clazz;
FT_Memory memory = clazz->memory; FT_Memory memory = clazz->memory;
FT_Type ctype = clazz->type;
if ( ctype->class_done ) if ( clazz->class_done )
ctype->class_done( clazz ); clazz->class_done( (FT_Object) clazz );
FT_FREE( clazz ); FT_FREE( clazz );
@@ -67,32 +77,81 @@
static FT_Int static FT_Int
ft_class_hnode_compare( const FT_ClassHNode node1, ft_type_equal( FT_Type type1,
const FT_ClassHNode node2 ) FT_Type type2 )
{ {
return ( node1->type == node2->type ); 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 void static FT_Int
ft_class_hnode_equal( const FT_ClassHNode node1,
const FT_ClassHNode node2 )
{
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 );
}
FT_BASE_DEF( void )
ft_metaclass_done( FT_MetaClass meta ) ft_metaclass_done( FT_MetaClass meta )
{ {
/* clear all objects */ /* clear all classes */
ft_hash_done( &meta->type_to_class, ft_hash_done( &meta->type_to_class,
(FT_Hash_ForeachFunc) ft_class_destroy, (FT_Hash_ForeachFunc) ft_class_hnode_destroy,
NULL ); NULL );
meta->clazz->object.clazz = NULL; meta->clazz.object.clazz = NULL;
meta->clazz->object.ref_count = 0; meta->clazz.object.ref_count = 0;
meta->clazz->magic = FT_MAGIC_DEATH; meta->clazz.magic = FT_MAGIC_DEATH;
} }
static void FT_BASE_DEF( FT_Error )
ft_metaclass_init( FT_MetaClass meta, ft_metaclass_init( FT_MetaClass meta,
FT_Library library ) FT_Library library )
{ {
FT_ClassRec* clazz = meta->clazz; FT_ClassRec* clazz = (FT_ClassRec*) &meta->clazz;
/* the meta-class is its OWN class !! */ /* the meta-class is its OWN class !! */
clazz->object.clazz = (FT_Class) clazz; clazz->object.clazz = (FT_Class) clazz;
@@ -100,67 +159,133 @@
clazz->magic = FT_MAGIC_CLASS; clazz->magic = FT_MAGIC_CLASS;
clazz->library = library; clazz->library = library;
clazz->memory = library->memory; clazz->memory = library->memory;
clazz->type = &ft_metaclass_type; clazz->type = &ft_meta_class_type;
clazz->info = NULL; clazz->info = NULL;
clazz->class_done = (FT_Object_DoneFunc) ft_metaclass_done;
clazz->obj_size = sizeof( FT_ClassRec ); clazz->obj_size = sizeof( FT_ClassRec );
clazz->obj_init = NULL; clazz->obj_init = NULL;
clazz->obj_done = NULL; clazz->obj_done = NULL;
ft_hash_init( &meta->type_to_class, return ft_hash_init( &meta->type_to_class,
(FT_Hash_CompareFunc) ft_class_hnode_compare, (FT_Hash_EqualFunc) ft_class_hnode_equal,
library->memory ); library->memory );
} }
/* find or create the class corresponding to a given type */ /* 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 static FT_Class
ft_metaclass_get_class( FT_MetaClass meta, ft_metaclass_get_class( FT_MetaClass meta,
FT_Type ctype ) FT_Type ctype )
{ {
FT_ClassHNodeRec keynode, *node, **pnode; FT_ClassHNodeRec keynode, *node, **pnode;
FT_Memory memory; FT_Memory memory;
FT_ClassRec* clazz;
FT_Class parent;
FT_Error error;
keynode.hnode.hash = (FT_UInt32)( ctype >> 2 ); keynode.hnode.hash = FT_TYPE_HASH( ctype );
keynode.type = type; keynode.type = ctype;
pnode = (FT_ClassHNode) ft_hash_lookup( &meta->type_to_class, pnode = (FT_ClassHNode*) ft_hash_lookup( &meta->type_to_class,
&noderec ); (FT_HashNode) &keynode );
node = *pnode; node = *pnode;
if ( node != NULL ) if ( node != NULL )
return node->clazz; {
clazz = (FT_ClassRec*) node->clazz;
goto Exit;
}
memory = FT_CLASS__MEMORY(meta); memory = FT_CLASS__MEMORY(meta);
node = FT_MEM_SAFE_ALLOC( sizeof(*node) ); clazz = NULL;
if ( node != 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 ); parent = ft_metaclass_get_class( meta, ctype->super );
if ( clazz == NULL ) }
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_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) ) if ( FT_OBJECT_CHECK(obj) )
{ {
FT_Object o = FT_OBJECT(obj);
FT_Class c = FT_OBJECT__CLASS(obj); FT_Class c = FT_OBJECT__CLASS(obj);
do do
@@ -200,103 +324,73 @@
return (clazz == NULL); return (clazz == NULL);
} }
return 0;
} }
/* the cleanup routine for all objects */ FT_BASE_DEF( FT_Error )
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_object_create( FT_Object *pobject, ft_object_create( FT_Object *pobject,
FT_Class clazz, FT_Class clazz,
FT_Pointer init_data ) FT_Pointer init_data )
{ {
FT_Memory memory; FT_Memory memory;
FT_Error error;
FT_Object obj; FT_Object obj;
FT_ASSERT_IS_CLASS(clazz); FT_ASSERT_IS_CLASS(clazz);
memory = FT_CLASS__MEMORY(memory); memory = FT_CLASS__MEMORY(clazz);
obj = ft_mem_alloc( clazz->obj_size, memory ); if ( !FT_ALLOC( obj, clazz->obj_size ) )
obj->clazz = clazz; {
obj->ref_count = 1; obj->clazz = clazz;
*pobject = obj; obj->ref_count = 1;
if ( clazz->obj_init ) 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_BASE_DEF( FT_Class )
ft_class_find_by_type( FT_Type type, 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_BASE_DEF( FT_Error )
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, ft_object_create_from_type( FT_Object *pobject,
FT_Type type, FT_Type type,
FT_Pointer init_data, FT_Pointer init_data,
FT_Memory memory ); FT_Library library )
{
FT_Class clazz;
FT_Error error;
FT_BASE_DEF( void ) clazz = ft_class_find_by_type( type, library );
ft_object_push( FT_Object object ); if ( clazz )
error = ft_object_create( pobject, clazz, init_data );
FT_BASE_DEF( void ) else
ft_object_pop( FT_Object object ); {
*pobject = NULL;
FT_BASE_DEF( void ) error = FT_Err_Out_Of_Memory;
ft_object_pop_destroy( FT_Object object ); }
return error;
}
+121 -115
View File
@@ -75,9 +75,9 @@
/* create a new input stream from a FT_Open_Args structure */ /* create a new input stream from a FT_Open_Args structure */
/* */ /* */
static FT_Error static FT_Error
ft_input_stream_new( FT_Library library, ft_input_stream_new( FT_Library library,
FT_Open_Args* args, const FT_Open_Args* args,
FT_Stream* astream ) FT_Stream* astream )
{ {
FT_Error error; FT_Error error;
FT_Memory memory; FT_Memory memory;
@@ -98,20 +98,20 @@
stream->memory = memory; stream->memory = memory;
if ( args->flags & ft_open_memory ) if ( args->flags & FT_OPEN_MEMORY )
{ {
/* create a memory-based stream */ /* create a memory-based stream */
FT_Stream_OpenMemory( stream, FT_Stream_OpenMemory( stream,
(const FT_Byte*)args->memory_base, (const FT_Byte*)args->memory_base,
args->memory_size ); args->memory_size );
} }
else if ( args->flags & ft_open_pathname ) else if ( args->flags & FT_OPEN_PATHNAME )
{ {
/* create a normal system stream */ /* create a normal system stream */
error = FT_Stream_Open( stream, args->pathname ); error = FT_Stream_Open( stream, args->pathname );
stream->pathname.pointer = 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 */ /* use an existing, user-provided stream */
@@ -211,9 +211,14 @@
} }
/* clear all public fields in the glyph slot */ /* clear all public fields in the glyph slot */
FT_MEM_SET( &slot->metrics, 0, sizeof ( slot->metrics ) ); FT_ZERO( &slot->metrics );
FT_MEM_SET( &slot->outline, 0, sizeof ( slot->outline ) ); FT_ZERO( &slot->outline );
FT_MEM_SET( &slot->bitmap, 0, sizeof ( slot->bitmap ) );
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_left = 0;
slot->bitmap_top = 0; slot->bitmap_top = 0;
@@ -222,7 +227,7 @@
slot->control_data = 0; slot->control_data = 0;
slot->control_len = 0; slot->control_len = 0;
slot->other = 0; slot->other = 0;
slot->format = ft_glyph_format_none; slot->format = FT_GLYPH_FORMAT_NONE;
slot->linearHoriAdvance = 0; slot->linearHoriAdvance = 0;
slot->linearVertAdvance = 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 static FT_Renderer
ft_lookup_glyph_renderer( FT_GlyphSlot slot ); ft_lookup_glyph_renderer( FT_GlyphSlot slot );
@@ -387,9 +409,9 @@
/* documentation is in freetype.h */ /* documentation is in freetype.h */
FT_EXPORT_DEF( FT_Error ) FT_EXPORT_DEF( FT_Error )
FT_Load_Glyph( FT_Face face, FT_Load_Glyph( FT_Face face,
FT_UInt glyph_index, FT_UInt glyph_index,
FT_Int load_flags ) FT_Int32 load_flags )
{ {
FT_Error error; FT_Error error;
FT_Driver driver; FT_Driver driver;
@@ -416,6 +438,7 @@
/* disable scaling, hinting, and transformation */ /* disable scaling, hinting, and transformation */
load_flags |= FT_LOAD_NO_SCALE | load_flags |= FT_LOAD_NO_SCALE |
FT_LOAD_NO_HINTING | FT_LOAD_NO_HINTING |
FT_LOAD_NO_BITMAP |
FT_LOAD_IGNORE_TRANSFORM; FT_LOAD_IGNORE_TRANSFORM;
/* disable bitmap rendering */ /* disable bitmap rendering */
@@ -426,10 +449,12 @@
library = driver->root.library; library = driver->root.library;
hinter = library->auto_hinter; hinter = library->auto_hinter;
autohint = autohint =
FT_BOOL( hinter && FT_BOOL( hinter &&
!( load_flags & ( FT_LOAD_NO_SCALE | FT_LOAD_NO_HINTING ) ) && !( load_flags & ( FT_LOAD_NO_SCALE |
FT_DRIVER_IS_SCALABLE( driver ) && FT_LOAD_NO_HINTING |
FT_DRIVER_USES_OUTLINES( driver ) ); FT_LOAD_NO_AUTOHINT ) ) &&
FT_DRIVER_IS_SCALABLE( driver ) &&
FT_DRIVER_USES_OUTLINES( driver ) );
if ( autohint ) if ( autohint )
{ {
if ( FT_DRIVER_HAS_HINTER( driver ) && if ( FT_DRIVER_HAS_HINTER( driver ) &&
@@ -447,13 +472,14 @@
/* XXX: This is really a temporary hack that should disappear */ /* XXX: This is really a temporary hack that should disappear */
/* promptly with FreeType 2.1! */ /* 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, error = driver->clazz->load_glyph( slot, face->size,
glyph_index, glyph_index,
load_flags | FT_LOAD_SBITS_ONLY ); 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; goto Load_Ok;
} }
@@ -530,14 +556,18 @@
/* do we need to render the image now? */ /* do we need to render the image now? */
if ( !error && if ( !error &&
slot->format != ft_glyph_format_bitmap && slot->format != FT_GLYPH_FORMAT_BITMAP &&
slot->format != ft_glyph_format_composite && slot->format != FT_GLYPH_FORMAT_COMPOSITE &&
load_flags & FT_LOAD_RENDER ) load_flags & FT_LOAD_RENDER )
{ {
error = FT_Render_Glyph( slot, FT_Render_Mode mode = FT_LOAD_TARGET_MODE( load_flags );
( load_flags & FT_LOAD_MONOCHROME )
? ft_render_mode_mono
: ft_render_mode_normal ); if ( mode == FT_RENDER_MODE_NORMAL &&
(load_flags & FT_LOAD_MONOCHROME ) )
mode = FT_RENDER_MODE_MONO;
error = FT_Render_Glyph( slot, mode );
} }
Exit: Exit:
@@ -550,7 +580,7 @@
FT_EXPORT_DEF( FT_Error ) FT_EXPORT_DEF( FT_Error )
FT_Load_Char( FT_Face face, FT_Load_Char( FT_Face face,
FT_ULong char_code, FT_ULong char_code,
FT_Int load_flags ) FT_Int32 load_flags )
{ {
FT_UInt glyph_index; FT_UInt glyph_index;
@@ -614,8 +644,6 @@
if ( face->generic.finalizer ) if ( face->generic.finalizer )
face->generic.finalizer( face ); face->generic.finalizer( face );
#ifdef FT_CONFIG_OPTION_USE_CMAPS
/* discard charmaps */ /* discard charmaps */
{ {
FT_Int n; FT_Int n;
@@ -635,8 +663,6 @@
face->num_charmaps = 0; face->num_charmaps = 0;
} }
#endif /* FT_CONFIG_OPTION_USE_CMAPS */
/* finalize format-specific stuff */ /* finalize format-specific stuff */
if ( clazz->done_face ) if ( clazz->done_face )
@@ -712,14 +738,48 @@
face->memory = memory; face->memory = memory;
face->stream = stream; 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, error = clazz->init_face( stream,
face, face,
face_index, (FT_Int)face_index,
num_params, num_params,
params ); params );
if ( error ) if ( error )
goto Fail; 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; *aface = face;
Fail: Fail:
@@ -755,7 +815,7 @@
if ( !pathname ) if ( !pathname )
return FT_Err_Invalid_Argument; return FT_Err_Invalid_Argument;
args.flags = ft_open_pathname; args.flags = FT_OPEN_PATHNAME;
args.pathname = (char*)pathname; args.pathname = (char*)pathname;
return FT_Open_Face( library, &args, face_index, aface ); return FT_Open_Face( library, &args, face_index, aface );
@@ -780,7 +840,7 @@
if ( !file_base ) if ( !file_base )
return FT_Err_Invalid_Argument; return FT_Err_Invalid_Argument;
args.flags = ft_open_memory; args.flags = FT_OPEN_MEMORY;
args.memory_base = file_base; args.memory_base = file_base;
args.memory_size = file_size; args.memory_size = file_size;
@@ -791,10 +851,10 @@
/* documentation is in freetype.h */ /* documentation is in freetype.h */
FT_EXPORT_DEF( FT_Error ) FT_EXPORT_DEF( FT_Error )
FT_Open_Face( FT_Library library, FT_Open_Face( FT_Library library,
FT_Open_Args* args, const FT_Open_Args* args,
FT_Long face_index, FT_Long face_index,
FT_Face *aface ) FT_Face *aface )
{ {
FT_Error error; FT_Error error;
FT_Driver driver; FT_Driver driver;
@@ -813,7 +873,7 @@
*aface = 0; *aface = 0;
external_stream = FT_BOOL( ( args->flags & ft_open_stream ) && external_stream = FT_BOOL( ( args->flags & FT_OPEN_STREAM ) &&
args->stream ); args->stream );
/* create input stream */ /* create input stream */
@@ -825,7 +885,7 @@
/* If the font driver is specified in the `args' structure, use */ /* If the font driver is specified in the `args' structure, use */
/* it. Otherwise, we scan the list of registered drivers. */ /* 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 ); driver = FT_DRIVER( args->driver );
@@ -836,7 +896,7 @@
FT_Parameter* params = 0; FT_Parameter* params = 0;
if ( args->flags & ft_open_params ) if ( args->flags & FT_OPEN_PARAMS )
{ {
num_params = args->num_params; num_params = args->num_params;
params = args->params; params = args->params;
@@ -871,14 +931,14 @@
driver = FT_DRIVER( cur[0] ); driver = FT_DRIVER( cur[0] );
if ( args->flags & ft_open_params ) if ( args->flags & FT_OPEN_PARAMS )
{ {
num_params = args->num_params; num_params = args->num_params;
params = args->params; params = args->params;
} }
error = open_face( driver, stream, face_index, error = open_face( driver, stream, face_index,
num_params, params, &face ); num_params, params, &face );
if ( !error ) if ( !error )
goto Success; goto Success;
@@ -980,7 +1040,7 @@
if ( !filepathname ) if ( !filepathname )
return FT_Err_Invalid_Argument; return FT_Err_Invalid_Argument;
open.flags = ft_open_pathname; open.flags = FT_OPEN_PATHNAME;
open.pathname = (char*)filepathname; open.pathname = (char*)filepathname;
return FT_Attach_Stream( face, &open ); return FT_Attach_Stream( face, &open );
@@ -1024,7 +1084,7 @@
/* close the attached stream */ /* close the attached stream */
ft_input_stream_free( stream, ft_input_stream_free( stream,
(FT_Bool)( parameters->stream && (FT_Bool)( parameters->stream &&
( parameters->flags & ft_open_stream ) ) ); ( parameters->flags & FT_OPEN_STREAM ) ) );
Exit: Exit:
return error; return error;
@@ -1350,12 +1410,12 @@
akerning ); akerning );
if ( !error ) 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->x = FT_MulFix( akerning->x, face->size->metrics.x_scale );
akerning->y = FT_MulFix( akerning->y, face->size->metrics.y_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->x = ( akerning->x + 32 ) & -64;
akerning->y = ( akerning->y + 32 ) & -64; akerning->y = ( akerning->y + 32 ) & -64;
@@ -1503,8 +1563,6 @@
/* documentation is in freetype.h */ /* documentation is in freetype.h */
#ifdef FT_CONFIG_OPTION_USE_CMAPS
FT_EXPORT_DEF( FT_UInt ) FT_EXPORT_DEF( FT_UInt )
FT_Get_Char_Index( FT_Face face, FT_Get_Char_Index( FT_Face face,
FT_ULong charcode ) FT_ULong charcode )
@@ -1522,25 +1580,6 @@
return result; 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 */ /* documentation is in freetype.h */
@@ -1569,8 +1608,6 @@
/* documentation is in freetype.h */ /* documentation is in freetype.h */
#ifdef FT_CONFIG_OPTION_USE_CMAPS
FT_EXPORT_DEF( FT_ULong ) FT_EXPORT_DEF( FT_ULong )
FT_Get_Next_Char( FT_Face face, FT_Get_Next_Char( FT_Face face,
FT_ULong charcode, FT_ULong charcode,
@@ -1596,37 +1633,6 @@
return result; 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 */ /* documentation is in freetype.h */
@@ -1858,7 +1864,7 @@
FT_Renderer renderer; 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; library->cur_renderer = renderer;
} }
@@ -1884,7 +1890,7 @@
render->glyph_format = clazz->glyph_format; render->glyph_format = clazz->glyph_format;
/* allocate raster object if needed */ /* 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 ) clazz->raster_class->raster_new )
{ {
error = clazz->raster_class->raster_new( memory, &render->raster ); error = clazz->raster_class->raster_new( memory, &render->raster );
@@ -1977,12 +1983,12 @@
FT_List_Up( &library->renderers, node ); 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; library->cur_renderer = renderer;
if ( num_params > 0 ) 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-- ) for ( ; num_params > 0; num_params-- )
@@ -1999,9 +2005,9 @@
FT_BASE_DEF( FT_Error ) FT_BASE_DEF( FT_Error )
FT_Render_Glyph_Internal( FT_Library library, FT_Render_Glyph_Internal( FT_Library library,
FT_GlyphSlot slot, FT_GlyphSlot slot,
FT_UInt render_mode ) FT_Render_Mode render_mode )
{ {
FT_Error error = FT_Err_Ok; FT_Error error = FT_Err_Ok;
FT_Renderer renderer; FT_Renderer renderer;
@@ -2010,7 +2016,7 @@
/* if it is already a bitmap, no need to do anything */ /* if it is already a bitmap, no need to do anything */
switch ( slot->format ) 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; break;
default: default:
@@ -2020,7 +2026,7 @@
/* small shortcut for the very common case */ /* 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; renderer = library->cur_renderer;
node = library->renderers.head; node = library->renderers.head;
@@ -2060,8 +2066,8 @@
/* documentation is in freetype.h */ /* documentation is in freetype.h */
FT_EXPORT_DEF( FT_Error ) FT_EXPORT_DEF( FT_Error )
FT_Render_Glyph( FT_GlyphSlot slot, FT_Render_Glyph( FT_GlyphSlot slot,
FT_UInt render_mode ) FT_Render_Mode render_mode )
{ {
FT_Library library; FT_Library library;
@@ -2187,7 +2193,7 @@
} }
/* allocate module object */ /* allocate module object */
if ( FT_ALLOC( module,clazz->module_size ) ) if ( FT_ALLOC( module, clazz->module_size ) )
goto Exit; goto Exit;
/* base initialization */ /* base initialization */
@@ -2422,13 +2428,13 @@
patch = library->version_patch; patch = library->version_patch;
} }
if ( *amajor ) if ( amajor )
*amajor = major; *amajor = major;
if ( *aminor ) if ( aminor )
*aminor = minor; *aminor = minor;
if ( *apatch ) if ( apatch )
*apatch = patch; *apatch = patch;
} }
+24 -22
View File
@@ -98,14 +98,14 @@
tag = FT_CURVE_TAG( tags[0] ); tag = FT_CURVE_TAG( tags[0] );
/* A contour cannot start with a cubic control point! */ /* A contour cannot start with a cubic control point! */
if ( tag == FT_Curve_Tag_Cubic ) if ( tag == FT_CURVE_TAG_CUBIC )
goto Invalid_Outline; goto Invalid_Outline;
/* check first point to determine origin */ /* 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. */ /* 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 */ /* start at last point if it is on the curve */
v_start = v_last; v_start = v_last;
@@ -137,7 +137,7 @@
tag = FT_CURVE_TAG( tags[0] ); tag = FT_CURVE_TAG( tags[0] );
switch ( tag ) 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; FT_Vector vec;
@@ -151,7 +151,7 @@
continue; 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.x = SCALED( point->x );
v_control.y = SCALED( point->y ); v_control.y = SCALED( point->y );
@@ -169,7 +169,7 @@
vec.x = SCALED( point->x ); vec.x = SCALED( point->x );
vec.y = SCALED( point->y ); 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 ); error = func_interface->conic_to( &v_control, &vec, user );
if ( error ) if ( error )
@@ -177,7 +177,7 @@
continue; continue;
} }
if ( tag != FT_Curve_Tag_Conic ) if ( tag != FT_CURVE_TAG_CONIC )
goto Invalid_Outline; goto Invalid_Outline;
v_middle.x = ( v_control.x + vec.x ) / 2; v_middle.x = ( v_control.x + vec.x ) / 2;
@@ -194,13 +194,13 @@
error = func_interface->conic_to( &v_control, &v_start, user ); error = func_interface->conic_to( &v_control, &v_start, user );
goto Close; goto Close;
default: /* FT_Curve_Tag_Cubic */ default: /* FT_CURVE_TAG_CUBIC */
{ {
FT_Vector vec1, vec2; FT_Vector vec1, vec2;
if ( point + 1 > limit || 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; goto Invalid_Outline;
point += 2; point += 2;
@@ -270,12 +270,12 @@
anoutline->n_points = (FT_UShort)numPoints; anoutline->n_points = (FT_UShort)numPoints;
anoutline->n_contours = (FT_Short)numContours; anoutline->n_contours = (FT_Short)numContours;
anoutline->flags |= ft_outline_owner; anoutline->flags |= FT_OUTLINE_OWNER;
return FT_Err_Ok; return FT_Err_Ok;
Fail: Fail:
anoutline->flags |= ft_outline_owner; anoutline->flags |= FT_OUTLINE_OWNER;
FT_Outline_Done_Internal( memory, anoutline ); FT_Outline_Done_Internal( memory, anoutline );
return error; return error;
@@ -334,7 +334,7 @@
if ( end != n_points - 1 ) if ( end != n_points - 1 )
goto Bad; goto Bad;
/* XXX: check the that array */ /* XXX: check the tags array */
return 0; return 0;
} }
@@ -366,11 +366,11 @@
FT_MEM_COPY( target->contours, source->contours, FT_MEM_COPY( target->contours, source->contours,
source->n_contours * sizeof ( FT_Short ) ); source->n_contours * sizeof ( FT_Short ) );
/* copy all flags, except the `ft_outline_owner' one */ /* copy all flags, except the `FT_OUTLINE_OWNER' one */
is_owner = target->flags & ft_outline_owner; is_owner = target->flags & FT_OUTLINE_OWNER;
target->flags = source->flags; target->flags = source->flags;
target->flags &= ~ft_outline_owner; target->flags &= ~FT_OUTLINE_OWNER;
target->flags |= is_owner; target->flags |= is_owner;
return FT_Err_Ok; return FT_Err_Ok;
@@ -383,7 +383,7 @@
{ {
if ( outline ) if ( outline )
{ {
if ( outline->flags & ft_outline_owner ) if ( outline->flags & FT_OUTLINE_OWNER )
{ {
FT_FREE( outline->points ); FT_FREE( outline->points );
FT_FREE( outline->tags ); FT_FREE( outline->tags );
@@ -535,7 +535,7 @@
first = last + 1; 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 */ /* now, look for another renderer that supports the same */
/* format */ /* format */
renderer = FT_Lookup_Renderer( library, ft_glyph_format_outline, renderer = FT_Lookup_Renderer( library, FT_GLYPH_FORMAT_OUTLINE,
&node ); &node );
update = 1; update = 1;
} }
@@ -608,8 +608,10 @@
params.target = abitmap; params.target = abitmap;
params.flags = 0; params.flags = 0;
if ( abitmap->pixel_mode == ft_pixel_mode_grays ) if ( abitmap->pixel_mode == FT_PIXEL_MODE_GRAY ||
params.flags |= ft_raster_flag_aa; 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 ); return FT_Outline_Render( library, outline, &params );
} }
@@ -628,9 +630,9 @@
return; return;
xz = FT_MulFix( vector->x, matrix->xx ) + 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 ); FT_MulFix( vector->y, matrix->yy );
vector->x = xz; vector->x = xz;
+57 -170
View File
@@ -20,6 +20,7 @@
#include FT_INTERNAL_OBJECTS_H #include FT_INTERNAL_OBJECTS_H
#include FT_INTERNAL_CALC_H #include FT_INTERNAL_CALC_H
#include FT_OUTLINE_H #include FT_OUTLINE_H
#include FT_TRIGONOMETRY_H
#include FT_SYNTHESIS_H #include FT_SYNTHESIS_H
@@ -34,18 +35,18 @@
/*************************************************************************/ /*************************************************************************/
/*************************************************************************/ /*************************************************************************/
FT_EXPORT_DEF( FT_Error ) FT_EXPORT_DEF( void )
FT_Outline_Oblique( FT_GlyphSlot original, FT_GlyphSlot_Oblique( FT_GlyphSlot slot )
FT_Outline* outline,
FT_Pos* advance )
{ {
FT_Matrix transform; 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 */ /* we don't touch the advance width */
FT_UNUSED( advance );
/* For italic, simply apply a shear transform, with an angle */ /* For italic, simply apply a shear transform, with an angle */
/* of about 12 degrees. */ /* of about 12 degrees. */
@@ -57,8 +58,6 @@
transform.yy = 0x10000L; transform.yy = 0x10000L;
FT_Outline_Transform( outline, &transform ); 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 static int
ft_test_extrema( FT_Outline* outline, ft_test_extrema( FT_Outline* outline,
@@ -208,7 +116,7 @@
/* Compute the orientation of path filling. It differs between TrueType */ /* 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 */ /* but it is better to re-compute it directly (it seems that this flag */
/* isn't correctly set for some weird composite glyphs currently). */ /* isn't correctly set for some weird composite glyphs currently). */
/* */ /* */
@@ -291,28 +199,30 @@
} }
FT_EXPORT_DEF( FT_Error ) FT_EXPORT_DEF( void )
FT_Outline_Embolden( FT_GlyphSlot original, FT_GlyphSlot_Embolden( FT_GlyphSlot slot )
FT_Outline* outline,
FT_Pos* advance )
{ {
FT_Vector u, v; FT_Vector* points;
FT_Vector* points; FT_Vector v_prev, v_first, v_next, v_cur;
FT_Vector cur, prev, next; FT_Pos distance;
FT_Pos distance; FT_Outline* outline = &slot->outline;
FT_Face face = FT_SLOT_FACE( original ); FT_Face face = FT_SLOT_FACE( slot );
int c, n, first, orientation; 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 */ /* compute control distance */
distance = FT_MulFix( face->units_per_EM / 60, distance = FT_MulFix( face->units_per_EM / 60,
face->size->metrics.y_scale ); 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; first = 0;
for ( c = 0; c < outline->n_contours; c++ ) for ( c = 0; c < outline->n_contours; c++ )
@@ -320,79 +230,56 @@
int last = outline->contours[c]; 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++ ) for ( n = first; n <= last; n++ )
{ {
FT_Pos norm, delta, d; FT_Pos d;
FT_Vector in, out; FT_Vector in, out;
FT_Fixed scale;
FT_Angle angle_diff;
cur = points[n]; if ( n < last ) v_next = points[n + 1];
if ( n < last ) next = points[n + 1]; else v_next = v_first;
else next = points[first];
/* compute the in and out vectors */ /* compute the in and out vectors */
in.x = cur.x - prev.x; in.x = v_cur.x - v_prev.x;
in.y = cur.y - prev.y; in.y = v_cur.y - v_prev.y;
out.x = next.x - cur.x; out.x = v_next.x - v_cur.x;
out.y = next.y - cur.y; out.y = v_next.y - v_cur.y;
/* compute U and V */ angle_in = FT_Atan2( in.x, in.y );
norm = ft_norm( &in ); angle_out = FT_Atan2( out.x, out.y );
u.x = orientation * FT_DivFix( in.y, norm ); angle_diff = FT_Angle_Diff( angle_in, angle_out );
u.y = orientation * -FT_DivFix( in.x, norm ); scale = FT_Cos( angle_diff/2 );
norm = ft_norm( &out ); if ( scale < 0x400L && scale > -0x400L )
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 )
{ {
/* Move point -- compute A and B */ if ( scale >= 0 )
FT_Pos x, y, A, B; scale = 0x400L;
else
scale = -0x400L;
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 );
}
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;
} }
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; first = last + 1;
} }
if ( advance ) slot->metrics.horiAdvance = ( slot->metrics.horiAdvance + distance*4 ) & -64;
*advance = ( *advance + distance * 4 ) & -64;
return 0;
} }
+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 */ /* END */
+2 -2
View File
@@ -64,7 +64,7 @@
return FT_Err_Out_Of_Memory; return FT_Err_Out_Of_Memory;
} }
FT_MEM_SET( *P, 0, size ); FT_MEM_ZERO( *P, size );
} }
else else
*P = NULL; *P = NULL;
@@ -106,7 +106,7 @@
goto Fail; goto Fail;
if ( size > current ) if ( size > current )
FT_MEM_SET( (char*)Q + current, 0, size - current ); FT_MEM_ZERO( (char*)Q + current, size - current );
*P = Q; *P = Q;
return FT_Err_Ok; return FT_Err_Ok;
+1
View File
@@ -54,6 +54,7 @@ BASE_EXT_SRC := $(BASE_)ftglyph.c \
$(BASE_)ftbdf.c \ $(BASE_)ftbdf.c \
$(BASE_)fttype1.c \ $(BASE_)fttype1.c \
$(BASE_)ftxf86.c \ $(BASE_)ftxf86.c \
$(BASE_)ftpfr.c \
$(BASE_)ftbbox.c $(BASE_)ftbbox.c
# Default extensions objects # Default extensions objects
+14 -94
View File
@@ -46,9 +46,6 @@ THE SOFTWARE.
#define FT_COMPONENT trace_bdfdriver #define FT_COMPONENT trace_bdfdriver
#ifdef FT_CONFIG_OPTION_USE_CMAPS
typedef struct BDF_CMapRec_ typedef struct BDF_CMapRec_
{ {
FT_CMapRec cmap; 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 ) FT_CALLBACK_DEF( FT_Error )
@@ -344,11 +308,11 @@ THE SOFTWARE.
prop = bdf_get_font_property( font, (char *)"AVERAGE_WIDTH" ); prop = bdf_get_font_property( font, (char *)"AVERAGE_WIDTH" );
if ( ( prop != NULL ) && ( prop->value.int32 >= 10 ) ) 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" ); prop = bdf_get_font_property( font, (char *)"PIXEL_SIZE" );
if ( prop != NULL ) if ( prop != NULL )
root->available_sizes->height = prop->value.int32; root->available_sizes->height = (short) prop->value.int32;
else else
{ {
prop = bdf_get_font_property( font, (char *)"POINT_SIZE" ); prop = bdf_get_font_property( font, (char *)"POINT_SIZE" );
@@ -429,63 +393,43 @@ THE SOFTWARE.
!ft_strcmp( face->charset_encoding, "1" ) ) ) !ft_strcmp( face->charset_encoding, "1" ) ) )
unicode_charmap = 1; unicode_charmap = 1;
#ifdef FT_CONFIG_OPTION_USE_CMAPS
{ {
FT_CharMapRec charmap; FT_CharMapRec charmap;
charmap.face = FT_FACE( face ); charmap.face = FT_FACE( face );
charmap.encoding = ft_encoding_none; charmap.encoding = FT_ENCODING_NONE;
charmap.platform_id = 0; charmap.platform_id = 0;
charmap.encoding_id = 0; charmap.encoding_id = 0;
if ( unicode_charmap ) if ( unicode_charmap )
{ {
charmap.encoding = ft_encoding_unicode; charmap.encoding = FT_ENCODING_UNICODE;
charmap.platform_id = 3; charmap.platform_id = 3;
charmap.encoding_id = 1; charmap.encoding_id = 1;
} }
error = FT_CMap_New( &bdf_cmap_class, NULL, &charmap, NULL ); error = FT_CMap_New( &bdf_cmap_class, NULL, &charmap, NULL );
#if 0
/* Select default charmap */ /* Select default charmap */
if (root->num_charmaps) if (root->num_charmaps)
root->charmap = root->charmaps[0]; 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; goto Exit;
} }
} }
/* otherwise assume Adobe standard encoding */ /* otherwise assume Adobe standard encoding */
#ifdef FT_CONFIG_OPTION_USE_CMAPS
{ {
FT_CharMapRec charmap; FT_CharMapRec charmap;
charmap.face = FT_FACE( face ); charmap.face = FT_FACE( face );
charmap.encoding = ft_encoding_adobe_standard; charmap.encoding = FT_ENCODING_ADOBE_STANDARD;
charmap.platform_id = 7; charmap.platform_id = 7;
charmap.encoding_id = 0; charmap.encoding_id = 0;
@@ -495,19 +439,6 @@ THE SOFTWARE.
if (root->num_charmaps) if (root->num_charmaps)
root->charmap = root->charmaps[0]; 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, BDF_Glyph_Load( FT_GlyphSlot slot,
FT_Size size, FT_Size size,
FT_UInt glyph_index, FT_UInt glyph_index,
FT_Int load_flags ) FT_Int32 load_flags )
{ {
BDF_Face face = (BDF_Face)FT_SIZE_FACE( size ); BDF_Face face = (BDF_Face)FT_SIZE_FACE( size );
FT_Error error = BDF_Err_Ok; FT_Error error = BDF_Err_Ok;
@@ -579,7 +510,7 @@ THE SOFTWARE.
if ( bpp == 1 ) if ( bpp == 1 )
{ {
bitmap->pixel_mode = ft_pixel_mode_mono; bitmap->pixel_mode = FT_PIXEL_MODE_MONO;
bitmap->pitch = glyph.bpr; bitmap->pitch = glyph.bpr;
if ( FT_NEW_ARRAY( bitmap->buffer, glyph.bytes ) ) if ( FT_NEW_ARRAY( bitmap->buffer, glyph.bytes ) )
@@ -589,7 +520,7 @@ THE SOFTWARE.
else else
{ {
/* blow up pixmap to have 8 bits per pixel */ /* 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; bitmap->pitch = bitmap->width;
if ( FT_NEW_ARRAY( bitmap->buffer, bitmap->rows * bitmap->pitch ) ) if ( FT_NEW_ARRAY( bitmap->buffer, bitmap->rows * bitmap->pitch ) )
@@ -686,12 +617,13 @@ THE SOFTWARE.
/* FZ XXX: TODO: vertical metrics */ /* FZ XXX: TODO: vertical metrics */
slot->metrics.horiAdvance = glyph.dwidth << 6; slot->metrics.horiAdvance = glyph.dwidth << 6;
slot->metrics.horiBearingX = glyph.bbx.x_offset << 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.width = bitmap->width << 6;
slot->metrics.height = bitmap->rows << 6; slot->metrics.height = bitmap->rows << 6;
slot->linearHoriAdvance = (FT_Fixed)glyph.dwidth << 16; 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; slot->flags = FT_GLYPH_OWN_BITMAP;
Exit: Exit:
@@ -733,21 +665,9 @@ THE SOFTWARE.
(FT_Slot_LoadFunc) BDF_Glyph_Load, (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_GetKerningFunc) 0,
(FT_Face_AttachFunc) 0, (FT_Face_AttachFunc) 0,
(FT_Face_GetAdvancesFunc) 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
}; };
+64 -57
View File
@@ -224,7 +224,7 @@
if ( FT_NEW_ARRAY( ht->table, ht->size ) ) if ( FT_NEW_ARRAY( ht->table, ht->size ) )
goto Exit; 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++ ) for ( i = 0, bp = obp; i < sz; i++, bp++ )
{ {
@@ -255,7 +255,7 @@
if ( FT_NEW_ARRAY( ht->table, sz ) ) if ( FT_NEW_ARRAY( ht->table, sz ) )
goto Exit; goto Exit;
FT_MEM_SET( ht->table, 0, sizeof ( hashnode ) * sz ); FT_MEM_ZERO( ht->table, sizeof ( hashnode ) * sz );
Exit: Exit:
return error; return error;
@@ -427,7 +427,7 @@
} }
/* Prepare the separator bitmap. */ /* 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 */ /* If the very last character of the separator string is a plus, then */
/* set the `mult' flag to indicate that multiple separators should be */ /* set the `mult' flag to indicate that multiple separators should be */
@@ -993,7 +993,7 @@
} }
p = font->user_props + font->nuser_props; 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 ); n = (unsigned long)( ft_strlen( name ) + 1 );
if ( FT_NEW_ARRAY( p->name, n ) ) if ( FT_NEW_ARRAY( p->name, n ) )
@@ -1341,7 +1341,7 @@
} }
fp = font->props + font->props_size; 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++; font->props_size++;
} }
@@ -1599,9 +1599,8 @@
font->glyphs_size, font->glyphs_size,
font->glyphs_size + 64 ) ) font->glyphs_size + 64 ) )
goto Exit; goto Exit;
FT_MEM_SET( font->glyphs + font->glyphs_size, FT_MEM_ZERO( font->glyphs + font->glyphs_size,
0, sizeof ( bdf_glyph_t ) * 64 ); /* FZ inutile */
sizeof ( bdf_glyph_t ) * 64 ); /* FZ inutile */
font->glyphs_size += 64; font->glyphs_size += 64;
} }
@@ -2203,96 +2202,98 @@
bdf_font_t* *font ) bdf_font_t* *font )
{ {
unsigned long lineno; 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_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 ); memory = NULL;
p.minlb = 32767; p->opts = (bdf_options_t*)( ( opts != 0 ) ? opts : &_bdf_opts );
p.memory = extmemory; /* only during font creation */ p->minlb = 32767;
p->memory = extmemory; /* only during font creation */
error = _bdf_readstream( stream, _bdf_parse_start, error = _bdf_readstream( stream, _bdf_parse_start,
(void *)&p, &lineno ); (void *)p, &lineno );
if ( error ) if ( error )
goto Exit; goto Exit;
if ( p.font != 0 ) if ( p->font != 0 )
{ {
/* If the font is not proportional, set the font's monowidth */ /* If the font is not proportional, set the font's monowidth */
/* field to the width of the font bounding box. */ /* field to the width of the font bounding box. */
memory = p.font->memory; memory = p->font->memory;
if ( p.font->spacing != BDF_PROPORTIONAL ) if ( p->font->spacing != BDF_PROPORTIONAL )
p.font->monowidth = p.font->bbx.width; p->font->monowidth = p->font->bbx.width;
/* If the number of glyphs loaded is not that of the original count, */ /* If the number of glyphs loaded is not that of the original count, */
/* indicate the difference. */ /* 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, FT_TRACE2(( "bdf_load_font: " ACMSG15, p->cnt,
p.font->glyphs_used + p.font->unencoded_used )); p->font->glyphs_used + p->font->unencoded_used ));
p.font->modified = 1; p->font->modified = 1;
} }
/* Once the font has been loaded, adjust the overall font metrics if */ /* Once the font has been loaded, adjust the overall font metrics if */
/* necessary. */ /* necessary. */
if ( p.opts->correct_metrics != 0 && if ( p->opts->correct_metrics != 0 &&
( p.font->glyphs_used > 0 || p.font->unencoded_used > 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, FT_TRACE2(( "bdf_load_font: " ACMSG3,
p.font->bbx.width, p.maxrb - p.minlb )); p->font->bbx.width, p->maxrb - p->minlb ));
p.font->bbx.width = (unsigned short)( p.maxrb - p.minlb ); p->font->bbx.width = (unsigned short)( p->maxrb - p->minlb );
p.font->modified = 1; 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, FT_TRACE2(( "bdf_load_font: " ACMSG4,
p.font->bbx.x_offset, p.minlb )); p->font->bbx.x_offset, p->minlb ));
p.font->bbx.x_offset = p.minlb; p->font->bbx.x_offset = p->minlb;
p.font->modified = 1; p->font->modified = 1;
} }
if ( p.font->bbx.ascent != p.maxas ) if ( p->font->bbx.ascent != p->maxas )
{ {
FT_TRACE2(( "bdf_load_font: " ACMSG5, FT_TRACE2(( "bdf_load_font: " ACMSG5,
p.font->bbx.ascent, p.maxas )); p->font->bbx.ascent, p->maxas ));
p.font->bbx.ascent = p.maxas; p->font->bbx.ascent = p->maxas;
p.font->modified = 1; p->font->modified = 1;
} }
if ( p.font->bbx.descent != p.maxds ) if ( p->font->bbx.descent != p->maxds )
{ {
FT_TRACE2(( "bdf_load_font: " ACMSG6, FT_TRACE2(( "bdf_load_font: " ACMSG6,
p.font->bbx.descent, p.maxds )); p->font->bbx.descent, p->maxds ));
p.font->bbx.descent = p.maxds; p->font->bbx.descent = p->maxds;
p.font->bbx.y_offset = (short)( -p.maxds ); p->font->bbx.y_offset = (short)( -p->maxds );
p.font->modified = 1; 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, FT_TRACE2(( "bdf_load_font: " ACMSG7,
p.font->bbx.height, p.maxas + p.maxds )); p->font->bbx.height, p->maxas + p->maxds ));
p.font->bbx.height = (unsigned short)( 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 )); 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. */ /* 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. */ /* Error happened while parsing header. */
FT_ERROR(( "bdf_load_font: " ERRMSG2, lineno )); FT_ERROR(( "bdf_load_font: " ERRMSG2, lineno ));
else else
@@ -2303,28 +2304,34 @@
/* Free up the list used during the parsing. */ /* Free up the list used during the parsing. */
if ( memory != NULL ) 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. */ /* 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 ( p->font->comments_len > 0 ) {
if ( FT_RENEW_ARRAY( p.font->comments, if ( FT_RENEW_ARRAY( p->font->comments,
p.font->comments_len, p->font->comments_len,
p.font->comments_len + 1 ) ) p->font->comments_len + 1 ) )
goto Exit; goto Exit;
p.font->comments[p.font->comments_len] = 0; p->font->comments[p->font->comments_len] = 0;
} }
} }
else if ( error == BDF_Err_Ok ) else if ( error == BDF_Err_Ok )
error = BDF_Err_Invalid_File_Format; error = BDF_Err_Invalid_File_Format;
*font = p.font; *font = p->font;
Exit: Exit:
if ( p )
{
memory = extmemory;
FT_FREE( p );
}
return error; return error;
} }
+17 -242
View File
@@ -24,8 +24,6 @@
#include "ftcerror.h" #include "ftcerror.h"
#ifdef FTC_CACHE_USE_LINEAR_HASHING
#define FTC_HASH_MAX_LOAD 2 #define FTC_HASH_MAX_LOAD 2
#define FTC_HASH_MIN_LOAD 1 #define FTC_HASH_MIN_LOAD 1
#define FTC_HASH_SUB_LOAD ( FTC_HASH_MAX_LOAD - FTC_HASH_MIN_LOAD ) #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! */ /* this one _must_ be a power of 2! */
#define FTC_HASH_INITIAL_SIZE 8 #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 */ /* remove a node from its cache's hash table */
static FT_Error static FT_Error
ftc_node_hash_unlink( FTC_Node node, ftc_node_hash_unlink( FTC_Node node,
@@ -164,14 +159,14 @@
{ {
FT_Error error = 0; FT_Error error = 0;
FTC_Node *pnode; 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 ) );
pnode = cache->buckets + index; idx = (FT_UInt)( node->hash & cache->mask );
if ( idx < cache->p )
idx = (FT_UInt)( node->hash & ( 2 * cache->mask + 1 ) );
pnode = cache->buckets + idx;
for (;;) for (;;)
{ {
@@ -236,41 +231,7 @@
return error; 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 */ /* add a node to the "top" of its cache's hash table */
static FT_Error static FT_Error
@@ -278,15 +239,15 @@
FTC_Cache cache ) FTC_Cache cache )
{ {
FTC_Node *pnode; FTC_Node *pnode;
FT_UInt index; FT_UInt idx;
FT_Error error = 0; FT_Error error = 0;
index = (FT_UInt)( node->hash & cache->mask ); idx = (FT_UInt)( node->hash & cache->mask );
if ( index < cache->p ) if ( idx < cache->p )
index = (FT_UInt)( node->hash & (2 * cache->mask + 1 ) ); idx = (FT_UInt)( node->hash & (2 * cache->mask + 1 ) );
pnode = cache->buckets + index; pnode = cache->buckets + idx;
node->link = *pnode; node->link = *pnode;
*pnode = node; *pnode = node;
@@ -345,23 +306,6 @@
return error; 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 ) FT_EXPORT_DEF( FT_Error )
@@ -605,8 +430,6 @@
FT_Error error; FT_Error error;
#ifdef FTC_CACHE_USE_LINEAR_HASHING
cache->p = 0; cache->p = 0;
cache->mask = FTC_HASH_INITIAL_SIZE - 1; cache->mask = FTC_HASH_INITIAL_SIZE - 1;
cache->slack = FTC_HASH_INITIAL_SIZE * FTC_HASH_MAX_LOAD; 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 ) ) if ( FT_NEW_ARRAY( cache->buckets, FTC_HASH_INITIAL_SIZE * 2 ) )
goto Exit; 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 */ /* now, initialize the lru list of families for this cache */
if ( clazz->family_size > 0 ) if ( clazz->family_size > 0 )
{ {
@@ -665,11 +478,7 @@
FT_UFast i; FT_UFast i;
FT_UInt count; FT_UInt count;
#ifdef FTC_CACHE_USE_LINEAR_HASHING
count = cache->p + cache->mask + 1; count = cache->p + cache->mask + 1;
#else
count = cache->size;
#endif
for ( i = 0; i < count; i++ ) for ( i = 0; i < count; i++ )
{ {
@@ -696,11 +505,8 @@
cache->buckets[i] = NULL; cache->buckets[i] = NULL;
} }
#ifdef FTC_CACHE_USE_LINEAR_HASHING
cache->p = 0; cache->p = 0;
#else
cache->nodes = 0;
#endif
/* destroy the families */ /* destroy the families */
if ( cache->families ) if ( cache->families )
FT_LruList_Reset( cache->families ); FT_LruList_Reset( cache->families );
@@ -719,12 +525,8 @@
ftc_cache_clear( cache ); ftc_cache_clear( cache );
FT_FREE( cache->buckets ); FT_FREE( cache->buckets );
#ifdef FTC_CACHE_USE_LINEAR_HASHING
cache->mask = 0; cache->mask = 0;
cache->slack = 0; cache->slack = 0;
#else
cache->size = 0;
#endif
if ( cache->families ) if ( cache->families )
{ {
@@ -755,8 +557,6 @@
query->hash = 0; query->hash = 0;
query->family = NULL; query->family = NULL;
#if 1
/* XXX: we break encapsulation for the sake of speed! */ /* XXX: we break encapsulation for the sake of speed! */
{ {
/* first of all, find the relevant family */ /* 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; FTC_Family family = (FTC_Family) lru;
FT_UFast hash = query->hash; FT_UFast hash = query->hash;
FTC_Node* bucket; FTC_Node* bucket;
FT_UInt idx;
#ifdef FTC_CACHE_USE_LINEAR_HASHING
FT_UInt index;
index = hash & cache->mask; idx = hash & cache->mask;
if ( index < cache->p ) if ( idx < cache->p )
index = hash & ( cache->mask * 2 + 1 ); idx = hash & ( cache->mask * 2 + 1 );
bucket = cache->buckets + index; bucket = cache->buckets + idx;
#else
bucket = cache->buckets + (hash % cache->size);
#endif
if ( query->family != family || if ( query->family != family ||
@@ -897,7 +682,6 @@
goto Exit; goto Exit;
} }
#ifdef FTC_CACHE_USE_LINEAR_HASHING
error = ftc_node_hash_link( node, cache ); error = ftc_node_hash_link( node, cache );
if ( error ) if ( error )
{ {
@@ -905,9 +689,6 @@
FT_FREE( node ); FT_FREE( node );
goto Exit; goto Exit;
} }
#else
ftc_node_hash_link( node, cache );
#endif
ftc_node_mru_link( node, cache->manager ); ftc_node_mru_link( node, cache->manager );
@@ -921,12 +702,6 @@
node->ref_count--; 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; *anode = node;
} }
} }
+5 -19
View File
@@ -78,30 +78,16 @@
family = (FTC_Family)lru; family = (FTC_Family)lru;
hash = query->hash; hash = query->hash;
#ifdef FTC_CACHE_USE_LINEAR_HASHING
{ {
FT_UInt index; FT_UInt idx;
index = hash & cache->mask; idx = hash & cache->mask;
if ( index < cache->p ) if ( idx < cache->p )
index = hash & ( cache->mask * 2 + 1 ); 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; pnode = bucket;
+57 -46
View File
@@ -42,7 +42,7 @@
typedef struct FTC_ImageQueryRec_ typedef struct FTC_ImageQueryRec_
{ {
FTC_GlyphQueryRec gquery; FTC_GlyphQueryRec gquery;
FTC_ImageDesc desc; FTC_ImageTypeRec type;
} FTC_ImageQueryRec, *FTC_ImageQuery; } FTC_ImageQueryRec, *FTC_ImageQuery;
@@ -54,7 +54,7 @@
typedef struct FTC_ImageFamilyRec_ typedef struct FTC_ImageFamilyRec_
{ {
FTC_GlyphFamilyRec gfam; FTC_GlyphFamilyRec gfam;
FTC_ImageDesc desc; FTC_ImageTypeRec type;
} FTC_ImageFamilyRec, *FTC_ImageFamily; } FTC_ImageFamilyRec, *FTC_ImageFamily;
@@ -106,45 +106,18 @@
/* we will now load the glyph image */ /* we will now load the glyph image */
error = FTC_Manager_Lookup_Size( FTC_FAMILY( ifam )->cache->manager, error = FTC_Manager_Lookup_Size( FTC_FAMILY( ifam )->cache->manager,
&ifam->desc.font, &ifam->type.font,
&face, &size ); &face, &size );
if ( !error ) if ( !error )
{ {
FT_UInt gindex = FTC_GLYPH_NODE_GINDEX( inode ); 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 ) error = FT_Load_Glyph( face, gindex, ifam->type.flags );
{
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 );
if ( !error ) if ( !error )
{ {
if ( face->glyph->format == ft_glyph_format_bitmap || if ( face->glyph->format == FT_GLYPH_FORMAT_BITMAP ||
face->glyph->format == ft_glyph_format_outline ) face->glyph->format == FT_GLYPH_FORMAT_OUTLINE )
{ {
/* ok, copy it */ /* ok, copy it */
FT_Glyph glyph; FT_Glyph glyph;
@@ -179,7 +152,7 @@
switch ( glyph->format ) switch ( glyph->format )
{ {
case ft_glyph_format_bitmap: case FT_GLYPH_FORMAT_BITMAP:
{ {
FT_BitmapGlyph bitg; FT_BitmapGlyph bitg;
@@ -190,7 +163,7 @@
} }
break; break;
case ft_glyph_format_outline: case FT_GLYPH_FORMAT_OUTLINE:
{ {
FT_OutlineGlyph outg; FT_OutlineGlyph outg;
@@ -231,16 +204,16 @@
FT_Face face; FT_Face face;
ifam->desc = iquery->desc; ifam->type = iquery->type;
/* we need to compute "iquery.item_total" now */ /* we need to compute "iquery.item_total" now */
error = FTC_Manager_Lookup_Face( manager, error = FTC_Manager_Lookup_Face( manager,
iquery->desc.font.face_id, iquery->type.font.face_id,
&face ); &face );
if ( !error ) if ( !error )
{ {
error = ftc_glyph_family_init( FTC_GLYPH_FAMILY( ifam ), error = ftc_glyph_family_init( FTC_GLYPH_FAMILY( ifam ),
FTC_IMAGE_DESC_HASH( &ifam->desc ), FTC_IMAGE_TYPE_HASH( &ifam->type ),
1, 1,
face->num_glyphs, face->num_glyphs,
FTC_GLYPH_QUERY( iquery ), FTC_GLYPH_QUERY( iquery ),
@@ -258,7 +231,7 @@
FT_Bool result; 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 ) if ( result )
FTC_GLYPH_FAMILY_FOUND( ifam, iquery ); FTC_GLYPH_FAMILY_FOUND( ifam, iquery );
@@ -314,7 +287,7 @@
FT_EXPORT_DEF( FT_Error ) FT_EXPORT_DEF( FT_Error )
FTC_ImageCache_Lookup( FTC_ImageCache cache, FTC_ImageCache_Lookup( FTC_ImageCache cache,
FTC_ImageDesc* desc, FTC_ImageType type,
FT_UInt gindex, FT_UInt gindex,
FT_Glyph *aglyph, FT_Glyph *aglyph,
FTC_Node *anode ) FTC_Node *anode )
@@ -332,7 +305,7 @@
*anode = NULL; *anode = NULL;
iquery.gquery.gindex = gindex; iquery.gquery.gindex = gindex;
iquery.desc = *desc; iquery.type = *type;
error = ftc_cache_lookup( FTC_CACHE( cache ), error = ftc_cache_lookup( FTC_CACHE( cache ),
FTC_QUERY( &iquery ), FTC_QUERY( &iquery ),
@@ -368,17 +341,55 @@
FT_UInt gindex, FT_UInt gindex,
FT_Glyph *aglyph ) FT_Glyph *aglyph )
{ {
FTC_ImageDesc desc0; FTC_ImageTypeRec type0;
if ( !desc ) if ( !desc )
return FTC_Err_Invalid_Argument; return FTC_Err_Invalid_Argument;
desc0.font = desc->font; type0.font = desc->font;
desc0.type = (FT_UInt32)desc->image_type;
/* 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, return FTC_ImageCache_Lookup( (FTC_ImageCache)icache,
&desc0, &type0,
gindex, gindex,
aglyph, aglyph,
NULL ); NULL );
+59 -58
View File
@@ -46,7 +46,7 @@
typedef struct FTC_SBitQueryRec_ typedef struct FTC_SBitQueryRec_
{ {
FTC_GlyphQueryRec gquery; FTC_GlyphQueryRec gquery;
FTC_ImageDesc desc; FTC_ImageTypeRec type;
} FTC_SBitQueryRec, *FTC_SBitQuery; } FTC_SBitQueryRec, *FTC_SBitQuery;
@@ -60,7 +60,7 @@
typedef struct FTC_SBitFamilyRec_ typedef struct FTC_SBitFamilyRec_
{ {
FTC_GlyphFamilyRec gfam; FTC_GlyphFamilyRec gfam;
FTC_ImageDesc desc; FTC_ImageTypeRec type;
} FTC_SBitFamilyRec; } FTC_SBitFamilyRec;
@@ -104,8 +104,8 @@
ftc_sbit_node_done( FTC_SBitNode snode, ftc_sbit_node_done( FTC_SBitNode snode,
FTC_Cache cache ) FTC_Cache cache )
{ {
FTC_SBit sbit = snode->sbits; FTC_SBit sbit = snode->sbits;
FT_UInt count = FTC_GLYPH_NODE( snode )->item_count; FT_UInt count = FTC_GLYPH_NODE( snode )->item_count;
FT_Memory memory = cache->memory; FT_Memory memory = cache->memory;
@@ -142,48 +142,14 @@
sbit = snode->sbits + ( gindex - gnode->item_start ); 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 ); &face, &size );
if ( !error ) 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 */ /* by default, indicates a `missing' glyph */
sbit->buffer = 0; 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 ) if ( !error )
{ {
FT_Int temp; FT_Int temp;
@@ -221,13 +187,9 @@
sbit->xadvance = (FT_Char)xadvance; sbit->xadvance = (FT_Char)xadvance;
sbit->yadvance = (FT_Char)yadvance; sbit->yadvance = (FT_Char)yadvance;
sbit->format = (FT_Byte)bitmap->pixel_mode; sbit->format = (FT_Byte)bitmap->pixel_mode;
/* XXX: Fixme: We don't handle the number of gray levels */ sbit->max_grays = (FT_Byte)(bitmap->num_grays - 1);
/* consistently -- we say num_grays == 1 for */
/* monochrome but num_grays == 256 for gray. It */ #if 0 /* this doesn't work well with embedded bitmaps !! */
/* 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;
/* grab the bitmap when possible - this is a hack! */ /* grab the bitmap when possible - this is a hack! */
if ( slot->flags & FT_GLYPH_OWN_BITMAP ) if ( slot->flags & FT_GLYPH_OWN_BITMAP )
@@ -236,6 +198,7 @@
sbit->buffer = bitmap->buffer; sbit->buffer = bitmap->buffer;
} }
else else
#endif
{ {
/* copy the bitmap into a new buffer -- ignore error */ /* copy the bitmap into a new buffer -- ignore error */
error = ftc_sbit_copy_bitmap( sbit, bitmap, memory ); error = ftc_sbit_copy_bitmap( sbit, bitmap, memory );
@@ -261,7 +224,6 @@
} }
} }
Exit:
return error; return error;
} }
@@ -380,16 +342,16 @@
FT_Face face; FT_Face face;
sfam->desc = squery->desc; sfam->type = squery->type;
/* we need to compute "cquery.item_total" now */ /* we need to compute "cquery.item_total" now */
error = FTC_Manager_Lookup_Face( manager, error = FTC_Manager_Lookup_Face( manager,
squery->desc.font.face_id, squery->type.font.face_id,
&face ); &face );
if ( !error ) if ( !error )
{ {
error = ftc_glyph_family_init( FTC_GLYPH_FAMILY( sfam ), 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, FTC_SBIT_ITEMS_PER_NODE,
face->num_glyphs, face->num_glyphs,
FTC_GLYPH_QUERY( squery ), FTC_GLYPH_QUERY( squery ),
@@ -410,7 +372,7 @@
/* we need to set the "cquery.cset" field or our query for */ /* we need to set the "cquery.cset" field or our query for */
/* faster glyph comparisons in ftc_sbit_node_compare */ /* 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 ) if ( result )
FTC_GLYPH_FAMILY_FOUND( sfam, squery ); FTC_GLYPH_FAMILY_FOUND( sfam, squery );
@@ -481,7 +443,7 @@
FT_EXPORT_DEF( FT_Error ) FT_EXPORT_DEF( FT_Error )
FTC_SBitCache_Lookup( FTC_SBitCache cache, FTC_SBitCache_Lookup( FTC_SBitCache cache,
FTC_ImageDesc* desc, FTC_ImageType type,
FT_UInt gindex, FT_UInt gindex,
FTC_SBit *ansbit, FTC_SBit *ansbit,
FTC_Node *anode ) FTC_Node *anode )
@@ -501,7 +463,7 @@
*anode = NULL; *anode = NULL;
squery.gquery.gindex = gindex; squery.gquery.gindex = gindex;
squery.desc = *desc; squery.type = *type;
error = ftc_sbit_cache_lookup( FTC_CACHE( cache ), error = ftc_sbit_cache_lookup( FTC_CACHE( cache ),
FTC_QUERY( &squery ), FTC_QUERY( &squery ),
@@ -536,17 +498,56 @@
FT_UInt gindex, FT_UInt gindex,
FTC_SBit *ansbit ) FTC_SBit *ansbit )
{ {
FTC_ImageDesc desc0; FTC_ImageTypeRec type0;
if ( !desc ) if ( !desc )
return FTC_Err_Invalid_Argument; return FTC_Err_Invalid_Argument;
desc0.font = desc->font; type0.font = desc->font;
desc0.type = (FT_UInt32)desc->image_type; 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, return FTC_SBitCache_Lookup( (FTC_SBitCache)cache,
&desc0, &type0,
gindex, gindex,
ansbit, ansbit,
NULL ); NULL );
+1 -1
View File
@@ -24,6 +24,6 @@
#include "cffload.c" #include "cffload.c"
#include "cffobjs.c" #include "cffobjs.c"
#include "cffgload.c" #include "cffgload.c"
#include "cffcmap.c"
/* END */ /* END */
+21 -112
View File
@@ -118,7 +118,7 @@
while ( left <= right ) while ( left <= right )
{ {
FT_Int middle = left + ( ( right - left ) >> 1 ); FT_Long middle = left + ( ( right - left ) >> 1 );
FT_ULong cur_pair; FT_ULong cur_pair;
@@ -177,7 +177,7 @@
Load_Glyph( CFF_GlyphSlot slot, Load_Glyph( CFF_GlyphSlot slot,
CFF_Size size, CFF_Size size,
FT_UShort glyph_index, FT_UShort glyph_index,
FT_UInt load_flags ) FT_Int32 load_flags )
{ {
FT_Error error; FT_Error error;
@@ -201,7 +201,7 @@
} }
/* now load the glyph outline if necessary */ /* 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 */ /* force drop-out mode to 2 - irrelevant now */
/* slot->outline.dropout_mode = 2; */ /* slot->outline.dropout_mode = 2; */
@@ -253,11 +253,11 @@
sid = font->charset.sids[glyph_index]; sid = font->charset.sids[glyph_index];
/* now, lookup the name itself */ /* 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 ) if ( buffer_max > 0 )
{ {
FT_UInt len = ft_strlen( gname ); FT_UInt len = (FT_UInt)ft_strlen( gname );
if ( len >= buffer_max ) 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]; sid = charset->sids[i];
if ( sid > 390 ) if ( sid > 390 )
name = CFF_Get_Name( &cff->string_index, sid - 391 ); name = cff_index_get_name( &cff->string_index, sid - 391 );
else else
name = (FT_String *)psnames->adobe_std_strings( sid ); name = (FT_String *)psnames->adobe_std_strings( sid );
@@ -469,7 +381,7 @@
ft_module_font_driver | ft_module_font_driver |
ft_module_driver_scalable | ft_module_driver_scalable |
ft_module_driver_has_hinter, ft_module_driver_has_hinter,
sizeof( CFF_DriverRec ), sizeof( CFF_DriverRec ),
"cff", "cff",
0x10000L, 0x10000L,
@@ -477,8 +389,8 @@
0, /* module-specific interface */ 0, /* module-specific interface */
(FT_Module_Constructor)CFF_Driver_Init, (FT_Module_Constructor)cff_driver_init,
(FT_Module_Destructor) CFF_Driver_Done, (FT_Module_Destructor) cff_driver_done,
(FT_Module_Requester) cff_get_interface, (FT_Module_Requester) cff_get_interface,
}, },
@@ -487,24 +399,21 @@
sizeof( FT_SizeRec ), sizeof( FT_SizeRec ),
sizeof( CFF_GlyphSlotRec ), sizeof( CFF_GlyphSlotRec ),
(FT_Face_InitFunc) CFF_Face_Init, (FT_Face_InitFunc) cff_face_init,
(FT_Face_DoneFunc) CFF_Face_Done, (FT_Face_DoneFunc) cff_face_done,
(FT_Size_InitFunc) CFF_Size_Init, (FT_Size_InitFunc) cff_size_init,
(FT_Size_DoneFunc) CFF_Size_Done, (FT_Size_DoneFunc) cff_size_done,
(FT_Slot_InitFunc) CFF_GlyphSlot_Init, (FT_Slot_InitFunc) cff_slot_init,
(FT_Slot_DoneFunc) CFF_GlyphSlot_Done, (FT_Slot_DoneFunc) cff_slot_done,
(FT_Size_ResetPointsFunc) CFF_Size_Reset, (FT_Size_ResetPointsFunc)cff_size_reset,
(FT_Size_ResetPixelsFunc) CFF_Size_Reset, (FT_Size_ResetPixelsFunc)cff_size_reset,
(FT_Slot_LoadFunc) Load_Glyph, (FT_Slot_LoadFunc) Load_Glyph,
(FT_CharMap_CharIndexFunc)cff_get_char_index,
(FT_Face_GetKerningFunc) Get_Kerning, (FT_Face_GetKerningFunc) Get_Kerning,
(FT_Face_AttachFunc) 0, (FT_Face_AttachFunc) 0,
(FT_Face_GetAdvancesFunc) 0, (FT_Face_GetAdvancesFunc)0,
(FT_CharMap_CharNextFunc) cff_get_next_char
}; };
File diff suppressed because it is too large Load Diff
+19 -14
View File
@@ -114,6 +114,8 @@ FT_BEGIN_HEADER
FT_Error error; /* only used for memory errors */ FT_Error error; /* only used for memory errors */
FT_Bool metrics_only; FT_Bool metrics_only;
FT_UInt32 hint_flags;
void* hints_funcs; /* hinter-specific */ void* hints_funcs; /* hinter-specific */
void* hints_globals; /* hinter-specific */ void* hints_globals; /* hinter-specific */
@@ -166,39 +168,42 @@ FT_BEGIN_HEADER
FT_Byte** glyph_names; /* for pure CFF fonts only */ FT_Byte** glyph_names; /* for pure CFF fonts only */
FT_UInt num_glyphs; /* number of glyphs in font */ FT_UInt num_glyphs; /* number of glyphs in font */
FT_Render_Mode hint_mode;
} CFF_Decoder; } CFF_Decoder;
FT_LOCAL( void ) FT_LOCAL( void )
CFF_Init_Decoder( CFF_Decoder* decoder, cff_decoder_init( CFF_Decoder* decoder,
TT_Face face, TT_Face face,
CFF_Size size, CFF_Size size,
CFF_GlyphSlot slot, CFF_GlyphSlot slot,
FT_Bool hinting ); FT_Bool hinting,
FT_Render_Mode hint_mode );
FT_LOCAL( void ) FT_LOCAL( void )
CFF_Prepare_Decoder( CFF_Decoder* decoder, cff_decoder_prepare( CFF_Decoder* decoder,
FT_UInt glyph_index ); FT_UInt glyph_index );
#if 0 /* unused until we support pure CFF fonts */ #if 0 /* unused until we support pure CFF fonts */
/* Compute the maximum advance width of a font through quick parsing */ /* Compute the maximum advance width of a font through quick parsing */
FT_LOCAL( FT_Error ) FT_LOCAL( FT_Error )
CFF_Compute_Max_Advance( TT_Face face, cff_compute_max_advance( TT_Face face,
FT_Int* max_advance ); FT_Int* max_advance );
#endif /* 0 */ #endif /* 0 */
FT_LOCAL( FT_Error ) FT_LOCAL( FT_Error )
CFF_Parse_CharStrings( CFF_Decoder* decoder, cff_decoder_parse_charstrings( CFF_Decoder* decoder,
FT_Byte* charstring_base, FT_Byte* charstring_base,
FT_Int charstring_len ); FT_ULong charstring_len );
FT_LOCAL( FT_Error ) FT_LOCAL( FT_Error )
CFF_Load_Glyph( CFF_GlyphSlot glyph, cff_slot_load( CFF_GlyphSlot glyph,
CFF_Size size, CFF_Size size,
FT_Int glyph_index, FT_Int glyph_index,
FT_Int load_flags ); FT_Int32 load_flags );
FT_END_HEADER FT_END_HEADER
+171 -201
View File
@@ -1047,7 +1047,7 @@
FT_LOCAL_DEF( FT_UShort ) 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); return (FT_UShort)(charcode < 256 ? cff_standard_encoding[charcode] : 0);
} }
@@ -1091,7 +1091,7 @@
FT_UShort count; FT_UShort count;
FT_MEM_SET( idx, 0, sizeof ( *idx ) ); FT_MEM_ZERO( idx, sizeof ( *idx ) );
idx->stream = stream; idx->stream = stream;
if ( !FT_READ_USHORT( count ) && if ( !FT_READ_USHORT( count ) &&
@@ -1167,18 +1167,19 @@
FT_FRAME_RELEASE( idx->bytes ); FT_FRAME_RELEASE( idx->bytes );
FT_FREE( idx->offsets ); 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 static FT_Error
cff_explicit_index( CFF_Index idx, cff_index_get_pointers( CFF_Index idx,
FT_Byte*** table ) FT_Byte*** table )
{ {
FT_Error error = 0; FT_Error error = 0;
FT_Memory memory = idx->stream->memory; FT_Memory memory = idx->stream->memory;
FT_UInt n, offset, old_offset; FT_ULong n, offset, old_offset;
FT_Byte** t; FT_Byte** t;
@@ -1205,10 +1206,10 @@
FT_LOCAL_DEF( FT_Error ) FT_LOCAL_DEF( FT_Error )
CFF_Access_Element( CFF_Index idx, cff_index_access_element( CFF_Index idx,
FT_UInt element, FT_UInt element,
FT_Byte** pbytes, FT_Byte** pbytes,
FT_ULong* pbyte_len ) FT_ULong* pbyte_len )
{ {
FT_Error error = 0; FT_Error error = 0;
@@ -1270,8 +1271,8 @@
FT_LOCAL_DEF( void ) FT_LOCAL_DEF( void )
CFF_Forget_Element( CFF_Index idx, cff_index_forget_element( CFF_Index idx,
FT_Byte** pbytes ) FT_Byte** pbytes )
{ {
if ( idx->bytes == 0 ) if ( idx->bytes == 0 )
{ {
@@ -1284,8 +1285,8 @@
FT_LOCAL_DEF( FT_String* ) FT_LOCAL_DEF( FT_String* )
CFF_Get_Name( CFF_Index idx, cff_index_get_name( CFF_Index idx,
FT_UInt element ) FT_UInt element )
{ {
FT_Memory memory = idx->stream->memory; FT_Memory memory = idx->stream->memory;
FT_Byte* bytes; FT_Byte* bytes;
@@ -1294,7 +1295,7 @@
FT_String* name = 0; 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 ) if ( error )
goto Exit; goto Exit;
@@ -1303,7 +1304,7 @@
FT_MEM_COPY( name, bytes, byte_len ); FT_MEM_COPY( name, bytes, byte_len );
name[byte_len] = 0; name[byte_len] = 0;
} }
CFF_Forget_Element( idx, &bytes ); cff_index_forget_element( idx, &bytes );
Exit: Exit:
return name; return name;
@@ -1311,18 +1312,18 @@
FT_LOCAL_DEF( FT_String* ) FT_LOCAL_DEF( FT_String* )
CFF_Get_String( CFF_Index idx, cff_index_get_sid_string( CFF_Index idx,
FT_UInt sid, FT_UInt sid,
PSNames_Service psnames_interface ) PSNames_Service psnames_service )
{ {
/* if it is not a standard string, return it */ /* if it is not a standard string, return it */
if ( sid > 390 ) 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 */ /* that's a standard string, fetch a copy from the PSName module */
{ {
FT_String* name = 0; 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; FT_UInt len;
@@ -1357,20 +1358,20 @@
static void static void
CFF_Done_FD_Select( CFF_FDSelect select, CFF_Done_FD_Select( CFF_FDSelect fdselect,
FT_Stream stream ) FT_Stream stream )
{ {
if ( select->data ) if ( fdselect->data )
FT_FRAME_RELEASE( select->data ); FT_FRAME_RELEASE( fdselect->data );
select->data_size = 0; fdselect->data_size = 0;
select->format = 0; fdselect->format = 0;
select->range_count = 0; fdselect->range_count = 0;
} }
static FT_Error static FT_Error
CFF_Load_FD_Select( CFF_FDSelect select, CFF_Load_FD_Select( CFF_FDSelect fdselect,
FT_UInt num_glyphs, FT_UInt num_glyphs,
FT_Stream stream, FT_Stream stream,
FT_ULong offset ) FT_ULong offset )
@@ -1384,23 +1385,23 @@
if ( FT_STREAM_SEEK( offset ) || FT_READ_BYTE( format ) ) if ( FT_STREAM_SEEK( offset ) || FT_READ_BYTE( format ) )
goto Exit; goto Exit;
select->format = format; fdselect->format = format;
select->cache_count = 0; /* clear cache */ fdselect->cache_count = 0; /* clear cache */
switch ( format ) switch ( format )
{ {
case 0: /* format 0, that's simple */ case 0: /* format 0, that's simple */
select->data_size = num_glyphs; fdselect->data_size = num_glyphs;
goto Load_Data; goto Load_Data;
case 3: /* format 3, a tad more complex */ case 3: /* format 3, a tad more complex */
if ( FT_READ_USHORT( num_ranges ) ) if ( FT_READ_USHORT( num_ranges ) )
goto Exit; goto Exit;
select->data_size = num_ranges * 3 + 2; fdselect->data_size = num_ranges * 3 + 2;
Load_Data: Load_Data:
if ( FT_FRAME_EXTRACT( select->data_size, select->data ) ) if ( FT_FRAME_EXTRACT( fdselect->data_size, fdselect->data ) )
goto Exit; goto Exit;
break; break;
@@ -1414,30 +1415,31 @@
FT_LOCAL_DEF( FT_Byte ) FT_LOCAL_DEF( FT_Byte )
CFF_Get_FD( CFF_FDSelect select, cff_fd_select_get( CFF_FDSelect fdselect,
FT_UInt glyph_index ) FT_UInt glyph_index )
{ {
FT_Byte fd = 0; FT_Byte fd = 0;
switch ( select->format ) switch ( fdselect->format )
{ {
case 0: case 0:
fd = select->data[glyph_index]; fd = fdselect->data[glyph_index];
break; break;
case 3: case 3:
/* first, compare to cache */ /* 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; break;
} }
/* then, lookup the ranges array */ /* then, lookup the ranges array */
{ {
FT_Byte* p = select->data; FT_Byte* p = fdselect->data;
FT_Byte* p_limit = p + select->data_size; FT_Byte* p_limit = p + fdselect->data_size;
FT_Byte fd2; FT_Byte fd2;
FT_UInt first, limit; FT_UInt first, limit;
@@ -1456,9 +1458,9 @@
fd = fd2; fd = fd2;
/* update cache */ /* update cache */
select->cache_first = first; fdselect->cache_first = first;
select->cache_count = limit-first; fdselect->cache_count = limit-first;
select->cache_fd = fd2; fdselect->cache_fd = fd2;
break; break;
} }
first = limit; first = limit;
@@ -1484,23 +1486,7 @@
/*************************************************************************/ /*************************************************************************/
static void static void
CFF_Done_Encoding( CFF_Encoding encoding, cff_charset_done( CFF_Charset charset,
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,
FT_Stream stream ) FT_Stream stream )
{ {
FT_Memory memory = stream->memory; FT_Memory memory = stream->memory;
@@ -1509,12 +1495,11 @@
FT_FREE( charset->sids ); FT_FREE( charset->sids );
charset->format = 0; charset->format = 0;
charset->offset = 0; charset->offset = 0;
charset->sids = 0;
} }
static FT_Error static FT_Error
CFF_Load_Charset( CFF_Charset charset, cff_charset_load( CFF_Charset charset,
FT_UInt num_glyphs, FT_UInt num_glyphs,
FT_Stream stream, FT_Stream stream,
FT_ULong base_offset, FT_ULong base_offset,
@@ -1525,13 +1510,6 @@
FT_UShort glyph_sid; 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 */ /* If the the offset is greater than 2, we have to parse the */
/* charset table. */ /* charset table. */
if ( offset > 2 ) if ( offset > 2 )
@@ -1539,6 +1517,13 @@
FT_UInt j; 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. */ /* Allocate memory for sids. */
if ( FT_NEW_ARRAY( charset->sids, num_glyphs ) ) if ( FT_NEW_ARRAY( charset->sids, num_glyphs ) )
goto Exit; goto Exit;
@@ -1549,12 +1534,15 @@
switch ( charset->format ) switch ( charset->format )
{ {
case 0: 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; goto Exit;
charset->sids[j] = glyph_sid; for ( j = 1; j < num_glyphs; j++ )
charset->sids[j] = FT_GET_USHORT();
FT_FRAME_EXIT();
} }
break; break;
@@ -1587,14 +1575,14 @@
} }
/* Fill in the range of sids -- `nleft + 1' glyphs. */ /* 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; charset->sids[j] = glyph_sid;
} }
} }
break; break;
default: 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; error = CFF_Err_Invalid_File_Format;
goto Exit; goto Exit;
} }
@@ -1610,12 +1598,14 @@
/* the first num_glyphs, and hence must match the predefined */ /* the first num_glyphs, and hence must match the predefined */
/* charset *exactly*. */ /* charset *exactly*. */
switch ( offset ) charset->offset = offset; /* record charset type */
switch ( (FT_UInt)offset )
{ {
case 0: case 0:
if ( num_glyphs != 229 ) 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" )); "predefined charset (Adobe ISO-Latin)!\n" ));
error = CFF_Err_Invalid_File_Format; error = CFF_Err_Invalid_File_Format;
goto Exit; goto Exit;
@@ -1634,7 +1624,7 @@
case 1: case 1:
if ( num_glyphs != 166 ) 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" )); "predefined charset (Adobe Expert)!\n" ));
error = CFF_Err_Invalid_File_Format; error = CFF_Err_Invalid_File_Format;
goto Exit; goto Exit;
@@ -1653,7 +1643,7 @@
case 2: case 2:
if ( num_glyphs != 87 ) 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" )); "predefined charset (Adobe Expert Subset)!\n" ));
error = CFF_Err_Invalid_File_Format; error = CFF_Err_Invalid_File_Format;
goto Exit; goto Exit;
@@ -1681,8 +1671,7 @@
if ( error ) if ( error )
if ( charset->sids ) if ( charset->sids )
{ {
if ( charset->sids ) FT_FREE( charset->sids );
FT_FREE( charset->sids );
charset->format = 0; charset->format = 0;
charset->offset = 0; charset->offset = 0;
charset->sids = 0; charset->sids = 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 static FT_Error
CFF_Load_Encoding( CFF_Encoding encoding, cff_encoding_load( CFF_Encoding encoding,
CFF_Charset charset, CFF_Charset charset,
FT_UInt num_glyphs, FT_UInt num_glyphs,
FT_Stream stream, FT_Stream stream,
FT_ULong base_offset, FT_ULong base_offset,
FT_ULong offset ) FT_ULong offset )
{ {
FT_Memory memory = stream->memory;
FT_Error error = 0; FT_Error error = 0;
FT_UInt count; FT_UInt count;
FT_UInt j; FT_UInt j;
FT_UShort glyph_sid; FT_UShort glyph_sid;
FT_Byte glyph_code; FT_UInt glyph_code;
/* Check for charset->sids. If we do not have this, we fail. */ /* Check for charset->sids. If we do not have this, we fail. */
@@ -1715,14 +1714,8 @@
goto Exit; 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. */ /* 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->sids [j] = 0;
encoding->codes[j] = 0; encoding->codes[j] = 0;
@@ -1751,25 +1744,37 @@
FT_READ_BYTE( count ) ) FT_READ_BYTE( count ) )
goto Exit; goto Exit;
encoding->count = count + 1;
switch ( encoding->format & 0x7F ) switch ( encoding->format & 0x7F )
{ {
case 0: case 0:
for ( j = 1; j <= count; j++ )
{ {
if ( FT_READ_BYTE( glyph_code ) ) FT_Byte* p;
if ( FT_FRAME_ENTER( count ) )
goto Exit; goto Exit;
/* Make sure j is not too big. */ p = (FT_Byte*)stream->cursor;
if ( j > num_glyphs )
goto Exit; for ( j = 1; j <= count; j++ )
{
glyph_code = *p++;
/* Assign code to GID mapping. */ /* Make sure j is not too big. */
encoding->codes[glyph_code] = (FT_UShort)j; if ( (FT_UInt) glyph_code < num_glyphs )
{
/* Assign code to GID mapping. */
encoding->codes[glyph_code] = (FT_UShort)j;
/* Assign code to SID mapping. */ /* Assign code to SID mapping. */
encoding->sids[glyph_code] = charset->sids[j]; encoding->sids[glyph_code] = charset->sids[j];
}
}
FT_FRAME_EXIT();
} }
break; break;
case 1: case 1:
@@ -1797,21 +1802,21 @@
for ( k = i; k < nleft + i; k++, glyph_code++ ) for ( k = i; k < nleft + i; k++, glyph_code++ )
{ {
/* Make sure k is not too big. */ /* Make sure k is not too big. */
if ( k > num_glyphs ) if ( k < num_glyphs && glyph_code < 256 )
goto Exit; {
/* Assign code to GID mapping. */
encoding->codes[glyph_code] = (FT_UShort)k;
/* Assign code to GID mapping. */ /* Assign code to SID mapping. */
encoding->codes[glyph_code] = (FT_UShort)k; encoding->sids[glyph_code] = charset->sids[k];
}
/* Assign code to SID mapping. */
encoding->sids[glyph_code] = charset->sids[k];
} }
} }
} }
break; break;
default: 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; error = CFF_Err_Invalid_File_Format;
goto Exit; goto Exit;
} }
@@ -1819,7 +1824,7 @@
/* Parse supplemental encodings, if any. */ /* Parse supplemental encodings, if any. */
if ( encoding->format & 0x80 ) if ( encoding->format & 0x80 )
{ {
FT_UInt glyph_id; FT_UInt gindex;
/* count supplements */ /* count supplements */
@@ -1841,14 +1846,14 @@
/* First, lookup GID which has been assigned to */ /* First, lookup GID which has been assigned to */
/* SID glyph_sid. */ /* 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; 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 */ /* encoding (see the note at the end of section 12 in the CFF */
/* specification). */ /* specification). */
switch ( offset ) encoding->count = 256;
switch ( (FT_UInt)offset )
{ {
case 0: case 0:
/* First, copy the code to SID mapping. */ /* First, copy the code to SID mapping. */
FT_MEM_COPY( encoding->sids, cff_standard_encoding, FT_MEM_COPY( encoding->sids, cff_standard_encoding,
256 * sizeof ( FT_UShort ) ); 256 * sizeof ( FT_UShort ) );
/* Construct code to GID mapping from code */ goto Populate;
/* 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;
case 1: case 1:
/* First, copy the code to SID mapping. */ /* First, copy the code to SID mapping. */
FT_MEM_COPY( encoding->sids, cff_expert_encoding, FT_MEM_COPY( encoding->sids, cff_expert_encoding,
256 * sizeof ( FT_UShort ) ); 256 * sizeof ( FT_UShort ) );
Populate:
/* Construct code to GID mapping from code to SID mapping */ /* Construct code to GID mapping from code to SID mapping */
/* and charset. */ /* and charset. */
for ( j = 0; j < 256; j++ ) for ( j = 0; j < 256; j++ )
@@ -1927,7 +1911,7 @@
break; break;
default: 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; error = CFF_Err_Invalid_File_Format;
goto Exit; goto Exit;
} }
@@ -1936,28 +1920,12 @@
Exit: Exit:
/* Clean up if there was an error. */ /* 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; return error;
} }
static FT_Error static FT_Error
CFF_Load_SubFont( CFF_SubFont font, cff_subfont_load( CFF_SubFont font,
CFF_Index idx, CFF_Index idx,
FT_UInt font_index, FT_UInt font_index,
FT_Stream stream, FT_Stream stream,
@@ -1971,10 +1939,10 @@
CFF_Private priv = &font->private_dict; 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 */ /* set defaults */
FT_MEM_SET( top, 0, sizeof ( *top ) ); FT_MEM_ZERO( top, sizeof ( *top ) );
top->underline_position = -100; top->underline_position = -100;
top->underline_thickness = 50; top->underline_thickness = 50;
@@ -1983,10 +1951,10 @@
top->font_matrix.yy = 0x10000L; top->font_matrix.yy = 0x10000L;
top->cid_count = 8720; top->cid_count = 8720;
error = CFF_Access_Element( idx, font_index, &dict, &dict_len ) || error = cff_index_access_element( idx, font_index, &dict, &dict_len ) ||
CFF_Parser_Run( &parser, dict, dict + dict_len ); cff_parser_run( &parser, dict, dict + dict_len );
CFF_Forget_Element( idx, &dict ); cff_index_forget_element( idx, &dict );
if ( error ) if ( error )
goto Exit; goto Exit;
@@ -1999,7 +1967,7 @@
if ( top->private_offset && top->private_size ) if ( top->private_offset && top->private_size )
{ {
/* set defaults */ /* set defaults */
FT_MEM_SET( priv, 0, sizeof ( *priv ) ); FT_MEM_ZERO( priv, sizeof ( *priv ) );
priv->blue_shift = 7; priv->blue_shift = 7;
priv->blue_fuzz = 1; priv->blue_fuzz = 1;
@@ -2007,15 +1975,15 @@
priv->expansion_factor = (FT_Fixed)0.06 * 0x10000L; priv->expansion_factor = (FT_Fixed)0.06 * 0x10000L;
priv->blue_scale = (FT_Fixed)0.039625 * 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 ) || if ( FT_STREAM_SEEK( base_offset + font->font_dict.private_offset ) ||
FT_FRAME_ENTER( font->font_dict.private_size ) ) FT_FRAME_ENTER( font->font_dict.private_size ) )
goto Exit; goto Exit;
error = CFF_Parser_Run( &parser, error = cff_parser_run( &parser,
(FT_Byte*)stream->cursor, (FT_Byte*)stream->cursor,
(FT_Byte*)stream->limit ); (FT_Byte*)stream->limit );
FT_FRAME_EXIT(); FT_FRAME_EXIT();
if ( error ) if ( error )
goto Exit; goto Exit;
@@ -2033,8 +2001,8 @@
goto Exit; goto Exit;
font->num_local_subrs = font->local_subrs_index.count; 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 ); &font->local_subrs );
if ( error ) if ( error )
goto Exit; goto Exit;
} }
@@ -2045,7 +2013,7 @@
static void static void
CFF_Done_SubFont( FT_Memory memory, cff_subfont_done( FT_Memory memory,
CFF_SubFont subfont ) CFF_SubFont subfont )
{ {
if ( subfont ) if ( subfont )
@@ -2057,7 +2025,7 @@
FT_LOCAL_DEF( FT_Error ) FT_LOCAL_DEF( FT_Error )
CFF_Load_Font( FT_Stream stream, cff_font_load( FT_Stream stream,
FT_Int face_index, FT_Int face_index,
CFF_Font font ) CFF_Font font )
{ {
@@ -2079,8 +2047,7 @@
FT_ULong base_offset; FT_ULong base_offset;
CFF_FontRecDict dict; CFF_FontRecDict dict;
FT_ZERO( font );
FT_MEM_SET( font, 0, sizeof ( *font ) );
font->stream = stream; font->stream = stream;
font->memory = memory; font->memory = memory;
@@ -2116,7 +2083,7 @@
font->num_faces = font->name_index.count; font->num_faces = font->name_index.count;
if ( face_index >= (FT_Int)font->num_faces ) 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 )); face_index ));
error = CFF_Err_Invalid_Argument; error = CFF_Err_Invalid_Argument;
} }
@@ -2126,7 +2093,7 @@
goto Exit; goto Exit;
/* now, parse the top-level font dictionary */ /* 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, &font->font_dict_index,
face_index, face_index,
stream, stream,
@@ -2153,7 +2120,7 @@
if ( fd_index.count > CFF_MAX_CID_FONTS ) 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; goto Fail_CID;
} }
@@ -2170,7 +2137,7 @@
for ( idx = 0; idx < fd_index.count; idx++ ) for ( idx = 0; idx < fd_index.count; idx++ )
{ {
sub = font->subfonts[idx]; sub = font->subfonts[idx];
error = CFF_Load_SubFont( sub, &fd_index, idx, error = cff_subfont_load( sub, &fd_index, idx,
stream, base_offset ); stream, base_offset );
if ( error ) if ( error )
goto Fail_CID; goto Fail_CID;
@@ -2178,7 +2145,7 @@
/* now load the FD Select array */ /* now load the FD Select array */
error = CFF_Load_FD_Select( &font->fd_select, error = CFF_Load_FD_Select( &font->fd_select,
dict->cid_count, (FT_UInt)dict->cid_count,
stream, stream,
base_offset + dict->cid_fd_select_offset ); base_offset + dict->cid_fd_select_offset );
@@ -2194,7 +2161,7 @@
/* read the charstrings index now */ /* read the charstrings index now */
if ( dict->charstrings_offset == 0 ) 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; error = CFF_Err_Unknown_File_Format;
goto Exit; goto Exit;
} }
@@ -2210,29 +2177,32 @@
font->num_global_subrs = font->global_subrs_index.count; font->num_global_subrs = font->global_subrs_index.count;
font->num_glyphs = font->charstrings_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 ) ; &font->global_subrs ) ;
if ( error ) if ( error )
goto Exit; goto Exit;
/* read the Charset and Encoding tables when available */ /* 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 ); base_offset, dict->charset_offset );
if ( error ) if ( error )
goto Exit; goto Exit;
error = CFF_Load_Encoding( &font->encoding, error = cff_encoding_load( &font->encoding,
&font->charset, &font->charset,
font->num_glyphs, font->num_glyphs,
stream, stream,
base_offset, base_offset,
dict->encoding_offset ); dict->encoding_offset );
if ( error ) if ( error )
goto Exit; goto Exit;
}
/* get the font name */ /* 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: Exit:
return error; return error;
@@ -2240,7 +2210,7 @@
FT_LOCAL_DEF( void ) FT_LOCAL_DEF( void )
CFF_Done_Font( CFF_Font font ) cff_font_done( CFF_Font font )
{ {
FT_Memory memory = font->memory; FT_Memory memory = font->memory;
FT_UInt idx; FT_UInt idx;
@@ -2257,15 +2227,15 @@
if ( font->num_subfonts > 0 ) if ( font->num_subfonts > 0 )
{ {
for ( idx = 0; idx < font->num_subfonts; idx++ ) 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 ); FT_FREE( font->subfonts );
} }
CFF_Done_Encoding( &font->encoding, font->stream ); cff_encoding_done( &font->encoding );
CFF_Done_Charset( &font->charset, font->stream ); 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 ); CFF_Done_FD_Select( &font->fd_select, font->stream );
+16 -16
View File
@@ -28,42 +28,42 @@
FT_BEGIN_HEADER FT_BEGIN_HEADER
FT_LOCAL( FT_UShort ) FT_LOCAL( FT_UShort )
CFF_Get_Standard_Encoding( FT_UInt charcode ); cff_get_standard_encoding( FT_UInt charcode );
FT_LOCAL( FT_String* ) FT_LOCAL( FT_String* )
CFF_Get_Name( CFF_Index idx, cff_index_get_name( CFF_Index idx,
FT_UInt element ); FT_UInt element );
FT_LOCAL( FT_String* ) FT_LOCAL( FT_String* )
CFF_Get_String( CFF_Index idx, cff_index_get_sid_string( CFF_Index idx,
FT_UInt sid, FT_UInt sid,
PSNames_Service psnames_interface ); PSNames_Service psnames_interface );
FT_LOCAL( FT_Error ) FT_LOCAL( FT_Error )
CFF_Access_Element( CFF_Index idx, cff_index_access_element( CFF_Index idx,
FT_UInt element, FT_UInt element,
FT_Byte** pbytes, FT_Byte** pbytes,
FT_ULong* pbyte_len ); FT_ULong* pbyte_len );
FT_LOCAL( void ) FT_LOCAL( void )
CFF_Forget_Element( CFF_Index idx, cff_index_forget_element( CFF_Index idx,
FT_Byte** pbytes ); FT_Byte** pbytes );
FT_LOCAL( FT_Error ) FT_LOCAL( FT_Error )
CFF_Load_Font( FT_Stream stream, cff_font_load( FT_Stream stream,
FT_Int face_index, FT_Int face_index,
CFF_Font font ); CFF_Font font );
FT_LOCAL( void ) FT_LOCAL( void )
CFF_Done_Font( CFF_Font font ); cff_font_done( CFF_Font font );
FT_LOCAL( FT_Byte ) FT_LOCAL( FT_Byte )
CFF_Get_FD( CFF_FDSelect select, cff_fd_select_get( CFF_FDSelect select,
FT_UInt glyph_index ); FT_UInt glyph_index );
FT_END_HEADER FT_END_HEADER
+105 -30
View File
@@ -28,7 +28,7 @@
#include FT_INTERNAL_POSTSCRIPT_HINTS_H #include FT_INTERNAL_POSTSCRIPT_HINTS_H
#include "cffobjs.h" #include "cffobjs.h"
#include "cffload.h" #include "cffload.h"
#include "cffcmap.h"
#include "cfferrs.h" #include "cfferrs.h"
@@ -53,7 +53,7 @@
static PSH_Globals_Funcs 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_Face face = (CFF_Face)size->face;
CFF_Font font = (CFF_FontRec *)face->extra.data; CFF_Font font = (CFF_FontRec *)face->extra.data;
@@ -70,14 +70,14 @@
FT_LOCAL_DEF( void ) FT_LOCAL_DEF( void )
CFF_Size_Done( CFF_Size size ) cff_size_done( CFF_Size size )
{ {
if ( size->internal ) if ( size->internal )
{ {
PSH_Globals_Funcs funcs; PSH_Globals_Funcs funcs;
funcs = CFF_Size_Get_Globals_Funcs( size ); funcs = cff_size_get_globals_funcs( size );
if ( funcs ) if ( funcs )
funcs->destroy( (PSH_Globals)size->internal ); funcs->destroy( (PSH_Globals)size->internal );
@@ -87,10 +87,10 @@
FT_LOCAL_DEF( FT_Error ) FT_LOCAL_DEF( FT_Error )
CFF_Size_Init( CFF_Size size ) cff_size_init( CFF_Size size )
{ {
FT_Error error = 0; 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 ) if ( funcs )
@@ -112,7 +112,7 @@
FT_UInt n, count; 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; count = priv.num_blue_values = cpriv->num_blue_values;
for ( n = 0; n < count; n++ ) for ( n = 0; n < count; n++ )
@@ -131,8 +131,8 @@
priv.family_other_blues[n] = (FT_Short)cpriv->family_other_blues[n]; priv.family_other_blues[n] = (FT_Short)cpriv->family_other_blues[n];
priv.blue_scale = cpriv->blue_scale; priv.blue_scale = cpriv->blue_scale;
priv.blue_shift = cpriv->blue_shift; priv.blue_shift = (FT_Int)cpriv->blue_shift;
priv.blue_fuzz = cpriv->blue_fuzz; priv.blue_fuzz = (FT_Int)cpriv->blue_fuzz;
priv.standard_width[0] = (FT_UShort)cpriv->standard_width; priv.standard_width[0] = (FT_UShort)cpriv->standard_width;
priv.standard_height[0] = (FT_UShort)cpriv->standard_height; priv.standard_height[0] = (FT_UShort)cpriv->standard_height;
@@ -160,9 +160,9 @@
FT_LOCAL_DEF( FT_Error ) 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; FT_Error error = 0;
@@ -182,14 +182,14 @@
/*************************************************************************/ /*************************************************************************/
FT_LOCAL_DEF( void ) FT_LOCAL_DEF( void )
CFF_GlyphSlot_Done( CFF_GlyphSlot slot ) cff_slot_done( CFF_GlyphSlot slot )
{ {
slot->root.internal->glyph_hints = 0; slot->root.internal->glyph_hints = 0;
} }
FT_LOCAL_DEF( FT_Error ) 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_Face face = (CFF_Face)slot->root.face;
CFF_Font font = (CFF_FontRec *)face->extra.data; CFF_Font font = (CFF_FontRec *)face->extra.data;
@@ -224,8 +224,8 @@
/*************************************************************************/ /*************************************************************************/
static FT_String* static FT_String*
CFF_StrCopy( FT_Memory memory, cff_strcpy( FT_Memory memory,
const FT_String* source ) const FT_String* source )
{ {
FT_Error error; FT_Error error;
FT_String* result = 0; FT_String* result = 0;
@@ -245,8 +245,9 @@
FT_LOCAL_DEF( FT_Error ) FT_LOCAL_DEF( FT_Error )
CFF_Face_Init( FT_Stream stream, cff_face_init( FT_Stream stream,
CFF_Face face, CFF_Face face,
FT_Int face_index, FT_Int face_index,
FT_Int num_params, FT_Int num_params,
@@ -334,18 +335,19 @@
CFF_Font cff; CFF_Font cff;
FT_Memory memory = face->root.memory; FT_Memory memory = face->root.memory;
FT_Face root; FT_Face root;
FT_UInt flags; FT_Int32 flags;
if ( FT_NEW( cff ) ) if ( FT_NEW( cff ) )
goto Exit; goto Exit;
face->extra.data = cff; face->extra.data = cff;
error = CFF_Load_Font( stream, face_index, cff ); error = cff_font_load( stream, face_index, cff );
if ( error ) if ( error )
goto Exit; goto Exit;
cff->pshinter = pshinter; cff->pshinter = pshinter;
cff->psnames = psnames;
/* Complement the root flags with some interesting information. */ /* Complement the root flags with some interesting information. */
/* Note that this is only necessary for pure CFF and CEF fonts. */ /* 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 */ /* we need the `PSNames' module for pure-CFF and CEF formats */
if ( !psnames ) if ( !psnames )
{ {
FT_ERROR(( "CFF_Face_Init:" )); FT_ERROR(( "cff_face_init:" ));
FT_ERROR(( " cannot open CFF & CEF fonts\n" )); FT_ERROR(( " cannot open CFF & CEF fonts\n" ));
FT_ERROR(( " " )); FT_ERROR(( " " ));
FT_ERROR(( " without the `PSNames' module\n" )); FT_ERROR(( " without the `PSNames' module\n" ));
@@ -395,13 +397,13 @@
root->units_per_EM = 1000; root->units_per_EM = 1000;
/* retrieve font family & style name */ /* 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 ) if ( dict->cid_registry )
root->style_name = CFF_StrCopy( memory, "Regular" ); /* XXXX */ root->style_name = cff_strcpy( memory, "Regular" ); /* XXXX */
else else
root->style_name = CFF_Get_String( &cff->string_index, root->style_name = cff_index_get_sid_string( &cff->string_index,
dict->weight, dict->weight,
psnames ); psnames );
/*******************************************************************/ /*******************************************************************/
/* */ /* */
@@ -444,8 +446,81 @@
flags |= FT_STYLE_FLAG_BOLD; flags |= FT_STYLE_FLAG_BOLD;
root->style_flags = flags; root->style_flags = flags;
}
/* XXX: no charmaps for pure CFF fonts currently! */
/*******************************************************************/
/* */
/* 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 );
}
} }
} }
@@ -459,7 +534,7 @@
FT_LOCAL_DEF( void ) FT_LOCAL_DEF( void )
CFF_Face_Done( CFF_Face face ) cff_face_done( CFF_Face face )
{ {
FT_Memory memory = face->root.memory; FT_Memory memory = face->root.memory;
SFNT_Service sfnt = (SFNT_Service)face->sfnt; SFNT_Service sfnt = (SFNT_Service)face->sfnt;
@@ -474,7 +549,7 @@
if ( cff ) if ( cff )
{ {
CFF_Done_Font( cff ); cff_font_done( cff );
FT_FREE( face->extra.data ); FT_FREE( face->extra.data );
} }
} }
@@ -482,7 +557,7 @@
FT_LOCAL_DEF( FT_Error ) FT_LOCAL_DEF( FT_Error )
CFF_Driver_Init( CFF_Driver driver ) cff_driver_init( CFF_Driver driver )
{ {
FT_UNUSED( driver ); FT_UNUSED( driver );
@@ -491,7 +566,7 @@
FT_LOCAL_DEF( void ) FT_LOCAL_DEF( void )
CFF_Driver_Done( CFF_Driver driver ) cff_driver_done( CFF_Driver driver )
{ {
FT_UNUSED( driver ); FT_UNUSED( driver );
} }
+10 -9
View File
@@ -23,6 +23,7 @@
#include <ft2build.h> #include <ft2build.h>
#include FT_INTERNAL_OBJECTS_H #include FT_INTERNAL_OBJECTS_H
#include FT_INTERNAL_CFF_TYPES_H #include FT_INTERNAL_CFF_TYPES_H
#include FT_INTERNAL_TRUETYPE_TYPES_H
#include FT_INTERNAL_POSTSCRIPT_NAMES_H #include FT_INTERNAL_POSTSCRIPT_NAMES_H
@@ -110,19 +111,19 @@ FT_BEGIN_HEADER
FT_LOCAL( FT_Error ) FT_LOCAL( FT_Error )
CFF_Size_Init( CFF_Size size ); cff_size_init( CFF_Size size );
FT_LOCAL( void ) FT_LOCAL( void )
CFF_Size_Done( CFF_Size size ); cff_size_done( CFF_Size size );
FT_LOCAL( FT_Error ) FT_LOCAL( FT_Error )
CFF_Size_Reset( CFF_Size size ); cff_size_reset( CFF_Size size );
FT_LOCAL( void ) FT_LOCAL( void )
CFF_GlyphSlot_Done( CFF_GlyphSlot slot ); cff_slot_done( CFF_GlyphSlot slot );
FT_LOCAL( FT_Error ) 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 */ /* Face functions */
/* */ /* */
FT_LOCAL( FT_Error ) FT_LOCAL( FT_Error )
CFF_Face_Init( FT_Stream stream, cff_face_init( FT_Stream stream,
CFF_Face face, CFF_Face face,
FT_Int face_index, FT_Int face_index,
FT_Int num_params, FT_Int num_params,
FT_Parameter* params ); FT_Parameter* params );
FT_LOCAL( void ) FT_LOCAL( void )
CFF_Face_Done( CFF_Face face ); cff_face_done( CFF_Face face );
/*************************************************************************/ /*************************************************************************/
@@ -145,10 +146,10 @@ FT_BEGIN_HEADER
/* Driver functions */ /* Driver functions */
/* */ /* */
FT_LOCAL( FT_Error ) FT_LOCAL( FT_Error )
CFF_Driver_Init( CFF_Driver driver ); cff_driver_init( CFF_Driver driver );
FT_LOCAL( void ) FT_LOCAL( void )
CFF_Driver_Done( CFF_Driver driver ); cff_driver_done( CFF_Driver driver );
FT_END_HEADER FT_END_HEADER
+12 -8
View File
@@ -64,11 +64,11 @@
FT_LOCAL_DEF( void ) FT_LOCAL_DEF( void )
CFF_Parser_Init( CFF_Parser parser, cff_parser_init( CFF_Parser parser,
FT_UInt code, FT_UInt code,
void* object ) void* object )
{ {
FT_MEM_SET( parser, 0, sizeof ( *parser ) ); FT_MEM_ZERO( parser, sizeof ( *parser ) );
parser->top = parser->stack; parser->top = parser->stack;
parser->object_code = code; parser->object_code = code;
@@ -244,7 +244,7 @@
if ( exp_sign ) if ( exp_sign )
exp = -exp; exp = -exp;
power_ten += exp; power_ten += (FT_Int)exp;
} }
/* raise to power of ten if needed */ /* raise to power of ten if needed */
@@ -480,7 +480,7 @@
FT_LOCAL_DEF( FT_Error ) FT_LOCAL_DEF( FT_Error )
CFF_Parser_Run( CFF_Parser parser, cff_parser_run( CFF_Parser parser,
FT_Byte* start, FT_Byte* start,
FT_Byte* limit ) FT_Byte* limit )
{ {
@@ -542,16 +542,15 @@
const CFF_Field_Handler* field; const CFF_Field_Handler* field;
/* first of all, a trivial check */
if ( num_args < 1 )
goto Stack_Underflow;
*parser->top = p; *parser->top = p;
code = v; code = v;
if ( v == 12 ) if ( v == 12 )
{ {
/* two byte operator */ /* two byte operator */
p++; p++;
if ( p >= limit )
goto Syntax_Error;
code = 0x100 | p[0]; code = 0x100 | p[0];
} }
code = code | parser->object_code; code = code | parser->object_code;
@@ -565,6 +564,11 @@
FT_Byte* q = (FT_Byte*)parser->object + field->offset; 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 ) switch ( field->kind )
{ {
case cff_kind_bool: case cff_kind_bool:
+2 -2
View File
@@ -50,12 +50,12 @@ FT_BEGIN_HEADER
FT_LOCAL( void ) FT_LOCAL( void )
CFF_Parser_Init( CFF_Parser parser, cff_parser_init( CFF_Parser parser,
FT_UInt code, FT_UInt code,
void* object ); void* object );
FT_LOCAL( FT_Error ) FT_LOCAL( FT_Error )
CFF_Parser_Run( CFF_Parser parser, cff_parser_run( CFF_Parser parser,
FT_Byte* start, FT_Byte* start,
FT_Byte* limit ); FT_Byte* limit );
+1
View File
@@ -28,6 +28,7 @@ CFF_DRV_SRC := $(CFF_DIR_)cffobjs.c \
$(CFF_DIR_)cffload.c \ $(CFF_DIR_)cffload.c \
$(CFF_DIR_)cffgload.c \ $(CFF_DIR_)cffgload.c \
$(CFF_DIR_)cffparse.c \ $(CFF_DIR_)cffparse.c \
$(CFF_DIR_)cffcmap.c \
$(CFF_DIR_)cffdrivr.c $(CFF_DIR_)cffdrivr.c
# CFF driver headers # CFF driver headers
+121 -53
View File
@@ -43,76 +43,143 @@
CID_Face face = (CID_Face)decoder->builder.face; CID_Face face = (CID_Face)decoder->builder.face;
CID_FaceInfo cid = &face->cid; CID_FaceInfo cid = &face->cid;
FT_Byte* p; FT_Byte* p;
FT_UInt entry_len = cid->fd_bytes + cid->gd_bytes;
FT_UInt fd_select; FT_UInt fd_select;
FT_ULong off1, glyph_len;
FT_Stream stream = face->root.stream; FT_Stream stream = face->root.stream;
FT_Error error = 0; FT_Error error = 0;
FT_Byte* charstring = 0;
FT_Memory memory = face->root.memory;
FT_UInt glyph_length = 0;
/* read the CID font dict index and charstring offset from the CIDMap */ #ifdef FT_CONFIG_OPTION_INCREMENTAL
if ( FT_STREAM_SEEK( cid->data_offset + cid->cidmap_offset +
glyph_index * entry_len ) ||
FT_FRAME_ENTER( 2 * entry_len ) )
goto Exit;
p = (FT_Byte*)stream->cursor; /* For incremental fonts get the character data using */
fd_select = (FT_UInt) cid_get_offset( &p, (FT_Byte)cid->fd_bytes ); /* the callback function. */
off1 = (FT_ULong)cid_get_offset( &p, (FT_Byte)cid->gd_bytes ); if ( face->root.internal->incremental_interface )
p += cid->fd_bytes; {
glyph_len = cid_get_offset( &p, (FT_Byte)cid->gd_bytes ) - off1; FT_Data glyph_data;
FT_FRAME_EXIT();
/* now, if the glyph is not empty, set up the subrs array, and parse */ error = face->root.internal->incremental_interface->funcs->get_glyph_data(
/* the charstrings */ face->root.internal->incremental_interface->object,
if ( glyph_len > 0 ) 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;
if ( FT_STREAM_SEEK( cid->data_offset + cid->cidmap_offset +
glyph_index * entry_len ) ||
FT_FRAME_ENTER( 2 * entry_len ) )
goto Exit;
p = (FT_Byte*)stream->cursor;
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_length = (FT_UInt) cid_get_offset(
&p, (FT_Byte)cid->gd_bytes ) - off1;
FT_FRAME_EXIT();
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_FaceDict dict;
CID_Subrs cid_subrs = face->subrs + fd_select; CID_Subrs cid_subrs = face->subrs + fd_select;
FT_Byte* charstring; FT_Int cs_offset;
FT_Memory memory = face->root.memory;
/* setup subrs */ /* Set up subrs */
decoder->num_subrs = cid_subrs->num_subrs; decoder->num_subrs = cid_subrs->num_subrs;
decoder->subrs = cid_subrs->code; decoder->subrs = cid_subrs->code;
decoder->subrs_len = 0; decoder->subrs_len = 0;
/* setup font matrix */ /* Set up font matrix */
dict = cid->font_dicts + fd_select; dict = cid->font_dicts + fd_select;
decoder->font_matrix = dict->font_matrix; decoder->font_matrix = dict->font_matrix;
decoder->font_offset = dict->font_offset; decoder->font_offset = dict->font_offset;
decoder->lenIV = dict->private_dict.lenIV; decoder->lenIV = dict->private_dict.lenIV;
/* the charstrings are encoded (stupid!) */ /* Decode the charstring. */
/* load the charstrings, then execute it */
if ( FT_ALLOC( charstring, glyph_len ) ) /* Adjustment for seed bytes. */
goto Exit; cs_offset = ( decoder->lenIV >= 0 ? decoder->lenIV : 0 );
if ( !FT_STREAM_READ_AT( cid->data_offset + off1, /* Decrypt only if lenIV >= 0. */
charstring, glyph_len ) ) if ( decoder->lenIV >= 0 )
{ cid_decrypt( charstring, glyph_length, 4330 );
FT_Int cs_offset;
error = decoder->funcs.parse_charstrings( decoder,
/* Adjustment for seed bytes. */ charstring + cs_offset,
cs_offset = ( decoder->lenIV >= 0 ? decoder->lenIV : 0 ); glyph_length - cs_offset );
/* Decrypt only if lenIV >= 0. */
if ( decoder->lenIV >= 0 )
cid_decrypt( charstring, glyph_len, 4330 );
error = decoder->funcs.parse_charstrings( decoder,
charstring + cs_offset,
glyph_len - cs_offset );
}
FT_FREE( charstring );
} }
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: Exit:
return error; return error;
} }
@@ -140,8 +207,8 @@
FT_LOCAL_DEF( FT_Error ) 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_Int* max_advance )
{ {
FT_Error error; FT_Error error;
T1_DecoderRec decoder; T1_DecoderRec decoder;
@@ -203,10 +270,10 @@
FT_LOCAL_DEF( FT_Error ) FT_LOCAL_DEF( FT_Error )
CID_Load_Glyph( CID_GlyphSlot glyph, cid_slot_load_glyph( CID_GlyphSlot glyph,
CID_Size size, CID_Size size,
FT_Int glyph_index, FT_Int glyph_index,
FT_Int load_flags ) FT_Int32 load_flags )
{ {
FT_Error error; FT_Error error;
T1_DecoderRec decoder; T1_DecoderRec decoder;
@@ -230,7 +297,7 @@
hinting = FT_BOOL( ( load_flags & FT_LOAD_NO_SCALE ) == 0 && hinting = FT_BOOL( ( load_flags & FT_LOAD_NO_SCALE ) == 0 &&
( load_flags & FT_LOAD_NO_HINTING ) == 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, error = psaux->t1_decoder_funcs->init( &decoder,
@@ -240,6 +307,7 @@
0, /* glyph names -- XXX */ 0, /* glyph names -- XXX */
0, /* blend == 0 */ 0, /* blend == 0 */
hinting, hinting,
FT_LOAD_TARGET_MODE(load_flags),
cid_load_glyph ); cid_load_glyph );
/* set up the decoder */ /* set up the decoder */
@@ -260,8 +328,8 @@
/* bearing the yMax */ /* bearing the yMax */
if ( !error ) if ( !error )
{ {
glyph->root.outline.flags &= ft_outline_owner; glyph->root.outline.flags &= FT_OUTLINE_OWNER;
glyph->root.outline.flags |= ft_outline_reverse_fill; glyph->root.outline.flags |= FT_OUTLINE_REVERSE_FILL;
/* for composite glyphs, return only left side bearing and */ /* for composite glyphs, return only left side bearing and */
/* advance width */ /* advance width */
@@ -294,10 +362,10 @@
metrics->vertAdvance = 0; metrics->vertAdvance = 0;
glyph->root.linearVertAdvance = 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 ) 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 */ /* apply the font matrix */
FT_Outline_Transform( &glyph->root.outline, &font_matrix ); FT_Outline_Transform( &glyph->root.outline, &font_matrix );
+6 -6
View File
@@ -31,16 +31,16 @@ FT_BEGIN_HEADER
/* Compute the maximum advance width of a font through quick parsing */ /* Compute the maximum advance width of a font through quick parsing */
FT_LOCAL( FT_Error ) FT_LOCAL( FT_Error )
CID_Compute_Max_Advance( CID_Face face, cid_face_compute_max_advance( CID_Face face,
FT_Int* max_advance ); FT_Int* max_advance );
#endif /* 0 */ #endif /* 0 */
FT_LOCAL( FT_Error ) FT_LOCAL( FT_Error )
CID_Load_Glyph( CID_GlyphSlot glyph, cid_slot_load_glyph( CID_GlyphSlot glyph,
CID_Size size, CID_Size size,
FT_Int glyph_index, FT_Int glyph_index,
FT_Int load_flags ); FT_Int32 load_flags );
FT_END_HEADER FT_END_HEADER
+12 -12
View File
@@ -146,10 +146,10 @@
/* now, load the keyword data in the object's field(s) */ /* now, load the keyword data in the object's field(s) */
if ( keyword->type == T1_FIELD_TYPE_INTEGER_ARRAY || if ( keyword->type == T1_FIELD_TYPE_INTEGER_ARRAY ||
keyword->type == T1_FIELD_TYPE_FIXED_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 ); &dummy_object );
else else
error = CID_Load_Field( &loader->parser, keyword, &dummy_object ); error = cid_parser_load_field( &loader->parser, keyword, &dummy_object );
Exit: Exit:
return error; return error;
} }
@@ -163,7 +163,7 @@
FT_BBox* bbox = &face->cid.font_bbox; 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->xMin = FT_RoundFix( temp[0] );
bbox->yMin = FT_RoundFix( temp[1] ); bbox->yMin = FT_RoundFix( temp[1] );
bbox->xMax = FT_RoundFix( temp[2] ); bbox->xMax = FT_RoundFix( temp[2] );
@@ -192,7 +192,7 @@
matrix = &dict->font_matrix; matrix = &dict->font_matrix;
offset = &dict->font_offset; 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] ); temp_scale = ABS( temp[3] );
@@ -238,7 +238,7 @@
FT_Long num_dicts; FT_Long num_dicts;
num_dicts = CID_ToInt( parser ); num_dicts = cid_parser_to_int( parser );
if ( !cid->font_dicts ) if ( !cid->font_dicts )
{ {
@@ -362,7 +362,7 @@
{ {
/* we found it - run the parsing callback */ /* we found it - run the parsing callback */
parser->root.cursor = cur2; parser->root.cursor = cur2;
CID_Skip_Spaces( parser ); cid_parser_skip_spaces( parser );
parser->root.error = cid_load_keyword( face, parser->root.error = cid_load_keyword( face,
loader, loader,
keyword ); keyword );
@@ -448,7 +448,7 @@
/* set up pointers */ /* set up pointers */
for ( count = 1; count <= num_subrs; count++ ) for ( count = 1; count <= num_subrs; count++ )
{ {
FT_UInt len; FT_ULong len;
len = offsets[count] - offsets[count - 1]; len = offsets[count] - offsets[count - 1];
@@ -460,7 +460,7 @@
{ {
for ( count = 0; count < num_subrs; count++ ) for ( count = 0; count < num_subrs; count++ )
{ {
FT_UInt len; FT_ULong len;
len = offsets[count + 1] - offsets[count]; len = offsets[count + 1] - offsets[count];
@@ -497,7 +497,7 @@
{ {
FT_UNUSED( face ); FT_UNUSED( face );
FT_MEM_SET( loader, 0, sizeof ( *loader ) ); FT_MEM_ZERO( loader, sizeof ( *loader ) );
} }
@@ -508,12 +508,12 @@
/* finalize parser */ /* finalize parser */
CID_Done_Parser( parser ); cid_parser_done( parser );
} }
FT_LOCAL_DEF( FT_Error ) FT_LOCAL_DEF( FT_Error )
CID_Open_Face( CID_Face face ) cid_face_open( CID_Face face )
{ {
CID_Loader loader; CID_Loader loader;
CID_Parser* parser; CID_Parser* parser;
@@ -523,7 +523,7 @@
t1_init_loader( &loader, face ); t1_init_loader( &loader, face );
parser = &loader.parser; 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 ); (PSAux_Service)face->psaux );
if ( error ) if ( error )
goto Exit; goto Exit;
+1 -1
View File
@@ -46,7 +46,7 @@ FT_BEGIN_HEADER
FT_UShort seed ); FT_UShort seed );
FT_LOCAL( FT_Error ) FT_LOCAL( FT_Error )
CID_Open_Face( CID_Face face ); cid_face_open( CID_Face face );
FT_END_HEADER FT_END_HEADER
+19 -19
View File
@@ -45,14 +45,14 @@
/*************************************************************************/ /*************************************************************************/
FT_LOCAL_DEF( void ) FT_LOCAL_DEF( void )
CID_GlyphSlot_Done( CID_GlyphSlot slot ) cid_slot_done( CID_GlyphSlot slot )
{ {
slot->root.internal->glyph_hints = 0; slot->root.internal->glyph_hints = 0;
} }
FT_LOCAL_DEF( FT_Error ) FT_LOCAL_DEF( FT_Error )
CID_GlyphSlot_Init( CID_GlyphSlot slot ) cid_slot_init( CID_GlyphSlot slot )
{ {
CID_Face face; CID_Face face;
PSHinter_Service pshinter; PSHinter_Service pshinter;
@@ -90,7 +90,7 @@
static PSH_Globals_Funcs 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; CID_Face face = (CID_Face)size->root.face;
PSHinter_Service pshinter = (PSHinter_Service)face->pshinter; PSHinter_Service pshinter = (PSHinter_Service)face->pshinter;
@@ -106,14 +106,14 @@
FT_LOCAL_DEF( void ) FT_LOCAL_DEF( void )
CID_Size_Done( CID_Size size ) cid_size_done( CID_Size size )
{ {
if ( size->root.internal ) if ( size->root.internal )
{ {
PSH_Globals_Funcs funcs; PSH_Globals_Funcs funcs;
funcs = CID_Size_Get_Globals_Funcs( size ); funcs = cid_size_get_globals_funcs( size );
if ( funcs ) if ( funcs )
funcs->destroy( (PSH_Globals)size->root.internal ); funcs->destroy( (PSH_Globals)size->root.internal );
@@ -123,10 +123,10 @@
FT_LOCAL_DEF( FT_Error ) FT_LOCAL_DEF( FT_Error )
CID_Size_Init( CID_Size size ) cid_size_init( CID_Size size )
{ {
FT_Error error = 0; 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 ) if ( funcs )
@@ -147,9 +147,9 @@
FT_LOCAL_DEF( FT_Error ) 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; FT_Error error = 0;
@@ -171,7 +171,7 @@
/*************************************************************************/ /*************************************************************************/
/* */ /* */
/* <Function> */ /* <Function> */
/* CID_Face_Done */ /* cid_face_done */
/* */ /* */
/* <Description> */ /* <Description> */
/* Finalizes a given face object. */ /* Finalizes a given face object. */
@@ -180,7 +180,7 @@
/* face :: A pointer to the face object to destroy. */ /* face :: A pointer to the face object to destroy. */
/* */ /* */
FT_LOCAL_DEF( void ) FT_LOCAL_DEF( void )
CID_Face_Done( CID_Face face ) cid_face_done( CID_Face face )
{ {
FT_Memory memory; FT_Memory memory;
@@ -239,7 +239,7 @@
/*************************************************************************/ /*************************************************************************/
/* */ /* */
/* <Function> */ /* <Function> */
/* CID_Face_Init */ /* cid_face_init */
/* */ /* */
/* <Description> */ /* <Description> */
/* Initializes a given CID face object. */ /* Initializes a given CID face object. */
@@ -260,7 +260,7 @@
/* FreeType error code. 0 means success. */ /* FreeType error code. 0 means success. */
/* */ /* */
FT_LOCAL_DEF( FT_Error ) FT_LOCAL_DEF( FT_Error )
CID_Face_Init( FT_Stream stream, cid_face_init( FT_Stream stream,
CID_Face face, CID_Face face,
FT_Int face_index, FT_Int face_index,
FT_Int num_params, FT_Int num_params,
@@ -310,7 +310,7 @@
if ( FT_STREAM_SEEK( 0 ) ) if ( FT_STREAM_SEEK( 0 ) )
goto Exit; goto Exit;
error = CID_Open_Face( face ); error = cid_face_open( face );
if ( error ) if ( error )
goto Exit; goto Exit;
@@ -321,7 +321,7 @@
/* check the face index */ /* check the face index */
if ( face_index != 0 ) 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; error = CID_Err_Invalid_Argument;
goto Exit; goto Exit;
} }
@@ -407,7 +407,7 @@
/*************************************************************************/ /*************************************************************************/
/* */ /* */
/* <Function> */ /* <Function> */
/* CID_Driver_Init */ /* cid_driver_init */
/* */ /* */
/* <Description> */ /* <Description> */
/* Initializes a given CID driver object. */ /* Initializes a given CID driver object. */
@@ -419,7 +419,7 @@
/* FreeType error code. 0 means success. */ /* FreeType error code. 0 means success. */
/* */ /* */
FT_LOCAL_DEF( FT_Error ) FT_LOCAL_DEF( FT_Error )
CID_Driver_Init( CID_Driver driver ) cid_driver_init( CID_Driver driver )
{ {
FT_UNUSED( driver ); FT_UNUSED( driver );
@@ -430,7 +430,7 @@
/*************************************************************************/ /*************************************************************************/
/* */ /* */
/* <Function> */ /* <Function> */
/* CID_Driver_Done */ /* cid_driver_done */
/* */ /* */
/* <Description> */ /* <Description> */
/* Finalizes a given CID driver. */ /* Finalizes a given CID driver. */
@@ -439,7 +439,7 @@
/* driver :: A handle to the target CID driver. */ /* driver :: A handle to the target CID driver. */
/* */ /* */
FT_LOCAL_DEF( void ) FT_LOCAL_DEF( void )
CID_Driver_Done( CID_Driver driver ) cid_driver_done( CID_Driver driver )
{ {
FT_UNUSED( driver ); FT_UNUSED( driver );
} }
+9 -9
View File
@@ -112,26 +112,26 @@ FT_BEGIN_HEADER
FT_LOCAL( void ) FT_LOCAL( void )
CID_GlyphSlot_Done( CID_GlyphSlot slot ); cid_slot_done( CID_GlyphSlot slot );
FT_LOCAL( FT_Error ) FT_LOCAL( FT_Error )
CID_GlyphSlot_Init( CID_GlyphSlot slot ); cid_slot_init( CID_GlyphSlot slot );
FT_LOCAL( void ) FT_LOCAL( void )
CID_Size_Done( CID_Size size ); cid_size_done( CID_Size size );
FT_LOCAL( FT_Error ) FT_LOCAL( FT_Error )
CID_Size_Init( CID_Size size ); cid_size_init( CID_Size size );
FT_LOCAL( FT_Error ) FT_LOCAL( FT_Error )
CID_Size_Reset( CID_Size size ); cid_size_reset( CID_Size size );
FT_LOCAL( FT_Error ) FT_LOCAL( FT_Error )
CID_Face_Init( FT_Stream stream, cid_face_init( FT_Stream stream,
CID_Face face, CID_Face face,
FT_Int face_index, FT_Int face_index,
FT_Int num_params, FT_Int num_params,
@@ -139,15 +139,15 @@ FT_BEGIN_HEADER
FT_LOCAL( void ) FT_LOCAL( void )
CID_Face_Done( CID_Face face ); cid_face_done( CID_Face face );
FT_LOCAL( FT_Error ) FT_LOCAL( FT_Error )
CID_Driver_Init( CID_Driver driver ); cid_driver_init( CID_Driver driver );
FT_LOCAL( void ) FT_LOCAL( void )
CID_Driver_Done( CID_Driver driver ); cid_driver_done( CID_Driver driver );
FT_END_HEADER FT_END_HEADER
+3 -3
View File
@@ -49,7 +49,7 @@
FT_LOCAL_DEF( FT_Error ) FT_LOCAL_DEF( FT_Error )
CID_New_Parser( CID_Parser* parser, cid_parser_new( CID_Parser* parser,
FT_Stream stream, FT_Stream stream,
FT_Memory memory, FT_Memory memory,
PSAux_Service psaux ) PSAux_Service psaux )
@@ -60,7 +60,7 @@
FT_Int buff_len; 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 ); psaux->ps_parser_funcs->init( &parser->root, 0, 0, memory );
parser->stream = stream; parser->stream = stream;
@@ -138,7 +138,7 @@
FT_LOCAL_DEF( void ) FT_LOCAL_DEF( void )
CID_Done_Parser( CID_Parser* parser ) cid_parser_done( CID_Parser* parser )
{ {
/* always free the private dictionary */ /* always free the private dictionary */
if ( parser->postscript ) if ( parser->postscript )
+13 -13
View File
@@ -61,7 +61,7 @@ FT_BEGIN_HEADER
FT_Stream stream; FT_Stream stream;
FT_Byte* postscript; FT_Byte* postscript;
FT_Int postscript_len; FT_Long postscript_len;
FT_ULong data_offset; FT_ULong data_offset;
@@ -72,13 +72,13 @@ FT_BEGIN_HEADER
FT_LOCAL( FT_Error ) FT_LOCAL( FT_Error )
CID_New_Parser( CID_Parser* parser, cid_parser_new( CID_Parser* parser,
FT_Stream stream, FT_Stream stream,
FT_Memory memory, FT_Memory memory,
PSAux_Service psaux ); PSAux_Service psaux );
FT_LOCAL( void ) 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_parser_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_alpha( p ) (p)->root.funcs.skip_alpha ( &(p)->root )
#define CID_ToInt( p ) (p)->root.funcs.to_int( &(p)->root ) #define cid_parser_to_int( 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_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 ) (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 ) (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 ) (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 ) (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 ) (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 ) (p)->root.funcs.load_field_table( &(p)->root, f, o, 0, 0 )
+19 -243
View File
@@ -40,17 +40,17 @@
cid_get_postscript_name( CID_Face face ) cid_get_postscript_name( CID_Face face )
{ {
const char* result = face->cid.cid_font_name; const char* result = face->cid.cid_font_name;
if ( result && result[0] == '/' ) if ( result && result[0] == '/' )
result++; result++;
return result; return result;
} }
static FT_Module_Interface static FT_Module_Interface
CID_Get_Interface( FT_Driver driver, cid_get_interface( FT_Driver driver,
const FT_String* cid_interface ) const FT_String* cid_interface )
{ {
FT_UNUSED( driver ); 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 FT_CALLBACK_TABLE_DEF
const FT_Driver_ClassRec t1cid_driver_class = const FT_Driver_ClassRec t1cid_driver_class =
@@ -293,7 +72,7 @@
ft_module_font_driver | ft_module_font_driver |
ft_module_driver_scalable | ft_module_driver_scalable |
ft_module_driver_has_hinter , ft_module_driver_has_hinter ,
sizeof( FT_DriverRec ), sizeof( FT_DriverRec ),
"t1cid", /* module name */ "t1cid", /* module name */
0x10000L, /* version 1.0 of driver */ 0x10000L, /* version 1.0 of driver */
@@ -301,9 +80,9 @@
0, 0,
(FT_Module_Constructor)CID_Driver_Init, (FT_Module_Constructor)cid_driver_init,
(FT_Module_Destructor) CID_Driver_Done, (FT_Module_Destructor) cid_driver_done,
(FT_Module_Requester) CID_Get_Interface (FT_Module_Requester) cid_get_interface
}, },
/* then the other font drivers fields */ /* then the other font drivers fields */
@@ -311,26 +90,23 @@
sizeof( CID_SizeRec ), sizeof( CID_SizeRec ),
sizeof( CID_GlyphSlotRec ), sizeof( CID_GlyphSlotRec ),
(FT_Face_InitFunc) CID_Face_Init, (FT_Face_InitFunc) cid_face_init,
(FT_Face_DoneFunc) CID_Face_Done, (FT_Face_DoneFunc) cid_face_done,
(FT_Size_InitFunc) CID_Size_Init, (FT_Size_InitFunc) cid_size_init,
(FT_Size_DoneFunc) CID_Size_Done, (FT_Size_DoneFunc) cid_size_done,
(FT_Slot_InitFunc) CID_GlyphSlot_Init, (FT_Slot_InitFunc) cid_slot_init,
(FT_Slot_DoneFunc) CID_GlyphSlot_Done, (FT_Slot_DoneFunc) cid_slot_done,
(FT_Size_ResetPointsFunc) CID_Size_Reset, (FT_Size_ResetPointsFunc)cid_size_reset,
(FT_Size_ResetPixelsFunc) CID_Size_Reset, (FT_Size_ResetPixelsFunc)cid_size_reset,
(FT_Slot_LoadFunc) CID_Load_Glyph, (FT_Slot_LoadFunc) cid_slot_load_glyph,
(FT_CharMap_CharIndexFunc)CID_Get_Char_Index,
(FT_Face_GetKerningFunc) 0, (FT_Face_GetKerningFunc) 0,
(FT_Face_AttachFunc) 0, (FT_Face_AttachFunc) 0,
(FT_Face_GetAdvancesFunc) 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 int OTL_Int;
typedef unsigned int OTL_UInt; typedef unsigned int OTL_UInt;
typedef long OTL_Long;
typedef unsigned long OTL_ULong;
typedef short OTL_Int16; typedef short OTL_Int16;
typedef unsigned short OTL_UInt16; typedef unsigned short OTL_UInt16;
#if OTL_SIZEOF_INT == 4 #if OTL_SIZEOF_INT == 4
typedef int OTL_Int32; typedef int OTL_Int32;
@@ -58,9 +62,38 @@ OTL_BEGIN_HEADER
OTL_Err_InvalidFormat, OTL_Err_InvalidFormat,
OTL_Err_InvalidOffset, OTL_Err_InvalidOffset,
OTL_Err_Max
} OTL_Error; } 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) \ #define OTL_MAKE_TAG(c1,c2,c3,c4) \
( ( (OTL_UInt32)(c1) << 24 ) | \ ( ( (OTL_UInt32)(c1) << 24 ) | \
(OTL_UInt32)(c2) << 16 ) | \ (OTL_UInt32)(c2) << 16 ) | \
(OTL_UInt32)(c3) << 8 ) | \ (OTL_UInt32)(c3) << 8 ) | \
(OTL_UInt32)(c4) ) (OTL_UInt32)(c4) )
#endif
typedef enum OTL_ScriptTag_ typedef enum OTL_ScriptTag_
{ {
@@ -153,8 +190,8 @@ OTL_BEGIN_HEADER
#define OTL_INVALID(e) otl_validator_error( valid, e ) #define OTL_INVALID(e) otl_validator_error( valid, e )
#define OTL_INVALID_TOO_SHORT OTL_INVALID( OTL_Err_InvalidOffset ); #define OTL_INVALID_TOO_SHORT OTL_INVALID( OTL_Err_InvalidOffset )
#define OTL_INVALID_DATA OTL_INVALID( OTL_Err_InvalidFormat ); #define OTL_INVALID_DATA OTL_INVALID( OTL_Err_InvalidFormat )
#define OTL_CHECK(_count) OTL_BEGIN_STMNT \ #define OTL_CHECK(_count) OTL_BEGIN_STMNT \
if ( p + (_count) > valid->limit ) \ if ( p + (_count) > valid->limit ) \
+7 -2
View File
@@ -43,10 +43,10 @@
#define OTL_BEGIN_STMNT do { #define OTL_BEGIN_STMNT do {
#define OTL_END_STMNT } while (0) #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( x ) (x)=(x)
#define OTL_UNUSED_CONST(x) (void)(x) #define OTL_UNUSED_CONST(x) (void)(x)
#include <limits.h> #include <limits.h>
@@ -68,6 +68,11 @@
# error "unsupported number of bytes in 'long' type!" # error "unsupported number of bytes in 'long' type!"
#endif #endif
#include <setjmp.h>
#define OTL_jmp_buf jmp_buf
#define otl_setjmp setjmp
#define otl_longjmp longjmp
/* */ /* */
#endif /* __OT_LAYOUT_CONFIG_H__ */ #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 static void
otl_gsub_lookup1_validate( OTL_Bytes table, otl_gsub_lookup1_validate( OTL_Bytes table,
OTL_Validator valid ) OTL_Validator valid )
@@ -42,6 +64,10 @@
otl_coverage_validate( table + coverage, valid ); otl_coverage_validate( table + coverage, valid );
OTL_CHECK( 2*count ); 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; 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 static void
otl_seq_validate( OTL_Bytes table, otl_seq_validate( OTL_Bytes table,
OTL_Validator valid ) OTL_Validator valid )
@@ -69,6 +172,9 @@
OTL_CHECK( 2 ); OTL_CHECK( 2 );
count = OTL_NEXT_USHORT( p ); 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 ); OTL_CHECK( 2*count );
/* check glyph indices */ /* 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 static void
otl_alternate_set_validate( OTL_Bytes table, otl_alternate_set_validate( OTL_Bytes table,
OTL_Validator valid ) 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 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_LOCAL( void )
otl_gsub_validate( OTL_Bytes table, otl_gsub_validate( OTL_Bytes table,
OTL_Validator valid ); OTL_Validator valid );
+4
View File
@@ -31,6 +31,7 @@ THE SOFTWARE.
#include <ft2build.h> #include <ft2build.h>
#include FT_INTERNAL_DRIVER_H #include FT_INTERNAL_DRIVER_H
#include FT_INTERNAL_STREAM_H
FT_BEGIN_HEADER FT_BEGIN_HEADER
@@ -135,6 +136,9 @@ FT_BEGIN_HEADER
{ {
FT_FaceRec root; FT_FaceRec root;
FT_StreamRec gzip_stream;
FT_Stream gzip_source;
char* charset_encoding; char* charset_encoding;
char* charset_registry; char* charset_registry;
+43 -122
View File
@@ -30,6 +30,8 @@ THE SOFTWARE.
#include FT_INTERNAL_DEBUG_H #include FT_INTERNAL_DEBUG_H
#include FT_INTERNAL_STREAM_H #include FT_INTERNAL_STREAM_H
#include FT_INTERNAL_OBJECTS_H #include FT_INTERNAL_OBJECTS_H
#include FT_GZIP_H
#include FT_ERRORS_H
#include "pcf.h" #include "pcf.h"
#include "pcfdriver.h" #include "pcfdriver.h"
@@ -41,8 +43,6 @@ THE SOFTWARE.
#define FT_COMPONENT trace_pcfread #define FT_COMPONENT trace_pcfread
#ifdef FT_CONFIG_OPTION_USE_CMAPS
typedef struct PCF_CMapRec_ typedef struct PCF_CMapRec_
{ {
FT_CMapRec cmap; FT_CMapRec cmap;
@@ -164,77 +164,6 @@ THE SOFTWARE.
(FT_CMap_CharNextFunc) pcf_cmap_char_next (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_encoding );
FT_FREE( face->charset_registry ); 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; return PCF_Err_Ok;
} }
@@ -301,7 +237,27 @@ THE SOFTWARE.
error = pcf_load_font( stream, face ); error = pcf_load_font( stream, face );
if ( error ) if ( error )
goto Fail; {
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 */ /* set-up charmap */
{ {
@@ -321,54 +277,30 @@ THE SOFTWARE.
unicode_charmap = 1; unicode_charmap = 1;
} }
#ifdef FT_CONFIG_OPTION_USE_CMAPS
{ {
FT_CharMapRec charmap; FT_CharMapRec charmap;
charmap.face = FT_FACE( face ); charmap.face = FT_FACE( face );
charmap.encoding = ft_encoding_none; charmap.encoding = FT_ENCODING_NONE;
charmap.platform_id = 0; charmap.platform_id = 0;
charmap.encoding_id = 0; charmap.encoding_id = 0;
if ( unicode_charmap ) if ( unicode_charmap )
{ {
charmap.encoding = ft_encoding_unicode; charmap.encoding = FT_ENCODING_UNICODE;
charmap.platform_id = 3; charmap.platform_id = 3;
charmap.encoding_id = 1; charmap.encoding_id = 1;
} }
error = FT_CMap_New( &pcf_cmap_class, NULL, &charmap, NULL ); error = FT_CMap_New( &pcf_cmap_class, NULL, &charmap, NULL );
#if 0
/* Select default charmap */ /* Select default charmap */
if (face->root.num_charmaps) if (face->root.num_charmaps)
face->root.charmap = face->root.charmaps[0]; 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: Exit:
@@ -416,7 +348,7 @@ THE SOFTWARE.
PCF_Glyph_Load( FT_GlyphSlot slot, PCF_Glyph_Load( FT_GlyphSlot slot,
FT_Size size, FT_Size size,
FT_UInt glyph_index, FT_UInt glyph_index,
FT_Int load_flags ) FT_Int32 load_flags )
{ {
PCF_Face face = (PCF_Face)FT_SIZE_FACE( size ); PCF_Face face = (PCF_Face)FT_SIZE_FACE( size );
FT_Stream stream = face->root.stream; FT_Stream stream = face->root.stream;
@@ -445,7 +377,7 @@ THE SOFTWARE.
bitmap->rows = metric->ascent + metric->descent; bitmap->rows = metric->ascent + metric->descent;
bitmap->width = metric->rightSideBearing - metric->leftSideBearing; bitmap->width = metric->rightSideBearing - metric->leftSideBearing;
bitmap->num_grays = 1; 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", FT_TRACE6(( "BIT_ORDER %d ; BYTE_ORDER %d ; GLYPH_PAD %d\n",
PCF_BIT_ORDER( face->bitmapsFormat ), PCF_BIT_ORDER( face->bitmapsFormat ),
@@ -485,7 +417,7 @@ THE SOFTWARE.
goto Exit; goto Exit;
if ( PCF_BIT_ORDER( face->bitmapsFormat ) != MSBFirst ) if ( PCF_BIT_ORDER( face->bitmapsFormat ) != MSBFirst )
BitOrderInvert( bitmap->buffer,bytes ); BitOrderInvert( bitmap->buffer, bytes );
if ( ( PCF_BYTE_ORDER( face->bitmapsFormat ) != if ( ( PCF_BYTE_ORDER( face->bitmapsFormat ) !=
PCF_BIT_ORDER( face->bitmapsFormat ) ) ) PCF_BIT_ORDER( face->bitmapsFormat ) ) )
@@ -509,13 +441,14 @@ THE SOFTWARE.
slot->bitmap_top = metric->ascent; slot->bitmap_top = metric->ascent;
slot->metrics.horiAdvance = metric->characterWidth << 6 ; 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.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->metrics.height = bitmap->rows << 6;
slot->linearHoriAdvance = (FT_Fixed)bitmap->width << 16; 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; slot->flags = FT_GLYPH_OWN_BITMAP;
FT_TRACE4(( " --- ok\n" )); FT_TRACE4(( " --- ok\n" ));
@@ -559,21 +492,9 @@ THE SOFTWARE.
(FT_Slot_LoadFunc) PCF_Glyph_Load, (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_GetKerningFunc) 0,
(FT_Face_AttachFunc) 0, (FT_Face_AttachFunc) 0,
(FT_Face_GetAdvancesFunc) 0, (FT_Face_GetAdvancesFunc) 0
#ifndef FT_CONFIG_OPTION_USE_CMAPS
(FT_CharMap_CharNextFunc) PCF_Char_Get_Next,
#else
(FT_CharMap_CharNextFunc) 0
#endif
}; };
+1
View File
@@ -24,5 +24,6 @@
#include "pfrcmap.c" #include "pfrcmap.c"
#include "pfrobjs.c" #include "pfrobjs.c"
#include "pfrdrivr.c" #include "pfrdrivr.c"
#include "pfrsbit.c"
/* END */ /* END */
+104 -6
View File
@@ -19,10 +19,111 @@
#include <ft2build.h> #include <ft2build.h>
#include FT_INTERNAL_DEBUG_H #include FT_INTERNAL_DEBUG_H
#include FT_INTERNAL_STREAM_H #include FT_INTERNAL_STREAM_H
#include FT_INTERNAL_PFR_H
#include "pfrdrivr.h" #include "pfrdrivr.h"
#include "pfrobjs.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 FT_CALLBACK_TABLE_DEF
const FT_Driver_ClassRec pfr_driver_class = const FT_Driver_ClassRec pfr_driver_class =
{ {
@@ -36,7 +137,7 @@
0x10000L, 0x10000L,
0x20000L, 0x20000L,
0, /* format interface */ (FT_PFR_Service) &pfr_service_rec, /* format interface */
(FT_Module_Constructor)NULL, (FT_Module_Constructor)NULL,
(FT_Module_Destructor) NULL, (FT_Module_Destructor) NULL,
@@ -57,13 +158,10 @@
(FT_Size_ResetPointsFunc) NULL, (FT_Size_ResetPointsFunc) NULL,
(FT_Size_ResetPixelsFunc) NULL, (FT_Size_ResetPixelsFunc) NULL,
(FT_Slot_LoadFunc) pfr_slot_load, (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_AttachFunc) 0,
(FT_Face_GetAdvancesFunc) 0, (FT_Face_GetAdvancesFunc) 0
(FT_CharMap_CharNextFunc) NULL
}; };
+18 -11
View File
@@ -17,6 +17,7 @@
#include "pfrgload.h" #include "pfrgload.h"
#include "pfrsbit.h"
#include "pfrload.h" /* for macro definitions */ #include "pfrload.h" /* for macro definitions */
#include FT_INTERNAL_DEBUG_H #include FT_INTERNAL_DEBUG_H
@@ -139,7 +140,7 @@
outline->points[n] = *to; outline->points[n] = *to;
outline->tags [n] = FT_Curve_Tag_On; outline->tags [n] = FT_CURVE_TAG_ON;
outline->n_points++; outline->n_points++;
} }
@@ -172,9 +173,9 @@
vec[0] = *control1; vec[0] = *control1;
vec[1] = *control2; vec[1] = *control2;
vec[2] = *to; vec[2] = *to;
tag[0] = FT_Curve_Tag_Cubic; tag[0] = FT_CURVE_TAG_CUBIC;
tag[1] = FT_Curve_Tag_Cubic; tag[1] = FT_CURVE_TAG_CUBIC;
tag[2] = FT_Curve_Tag_On; tag[2] = FT_CURVE_TAG_ON;
outline->n_points = (FT_Short)( outline->n_points + 3 ); outline->n_points = (FT_Short)( outline->n_points + 3 );
} }
@@ -409,7 +410,7 @@
cur = pos; cur = pos;
for ( n = 0; n < args_count; n++ ) for ( n = 0; n < args_count; n++ )
{ {
FT_Int index, delta; FT_Int idx, delta;
/* read the X argument */ /* read the X argument */
@@ -417,9 +418,9 @@
{ {
case 0: /* 8-bit index */ case 0: /* 8-bit index */
PFR_CHECK( 1 ); PFR_CHECK( 1 );
index = PFR_NEXT_BYTE( p ); idx = PFR_NEXT_BYTE( p );
cur->x = glyph->x_control[index]; cur->x = glyph->x_control[idx];
FT_TRACE7(( " cx#%d", index )); FT_TRACE7(( " cx#%d", idx ));
break; break;
case 1: /* 16-bit value */ case 1: /* 16-bit value */
@@ -445,9 +446,9 @@
{ {
case 0: /* 8-bit index */ case 0: /* 8-bit index */
PFR_CHECK( 1 ); PFR_CHECK( 1 );
index = PFR_NEXT_BYTE( p ); idx = PFR_NEXT_BYTE( p );
cur->y = glyph->y_control[index]; cur->y = glyph->y_control[idx];
FT_TRACE7(( " cy#%d", index )); FT_TRACE7(( " cy#%d", idx ));
break; break;
case 1: /* 16-bit absolute value */ case 1: /* 16-bit absolute value */
@@ -676,6 +677,9 @@
} }
static FT_Error static FT_Error
pfr_glyph_load_rec( PFR_Glyph glyph, pfr_glyph_load_rec( PFR_Glyph glyph,
FT_Stream stream, FT_Stream stream,
@@ -776,6 +780,9 @@
} }
FT_LOCAL_DEF( FT_Error ) FT_LOCAL_DEF( FT_Error )
pfr_glyph_load( PFR_Glyph glyph, pfr_glyph_load( PFR_Glyph glyph,
FT_Stream stream, FT_Stream stream,
+3
View File
@@ -44,3 +44,6 @@ FT_END_HEADER
#endif /* __PFRGLOAD_H__ */ #endif /* __PFRGLOAD_H__ */
/* END */

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