From 389d57611de20b567189170252c821ac0c8a2a73 Mon Sep 17 00:00:00 2001 From: Ingo Weinhold Date: Wed, 20 Nov 2002 19:21:05 +0000 Subject: [PATCH] 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 --- docs/freetype2/CHANGES | 155 ++- .../libs/freetype2/freetype/cache/ftccache.h | 8 - .../libs/freetype2/freetype/cache/ftcimage.h | 107 +- .../libs/freetype2/freetype/cache/ftcsbits.h | 14 +- .../libs/freetype2/freetype/config/ftheader.h | 14 + .../libs/freetype2/freetype/config/ftmodule.h | 3 + .../libs/freetype2/freetype/config/ftoption.h | 228 +-- headers/libs/freetype2/freetype/freetype.h | 1230 +++++++++-------- headers/libs/freetype2/freetype/ftcache.h | 6 +- headers/libs/freetype2/freetype/ftchapters.h | 1 + headers/libs/freetype2/freetype/ftglyph.h | 18 +- headers/libs/freetype2/freetype/ftimage.h | 444 +++--- headers/libs/freetype2/freetype/ftmodule.h | 2 +- headers/libs/freetype2/freetype/ftoutln.h | 2 +- headers/libs/freetype2/freetype/ftrender.h | 98 +- headers/libs/freetype2/freetype/ftsynth.h | 14 +- headers/libs/freetype2/freetype/ftsysio.h | 23 +- headers/libs/freetype2/freetype/ftsysmem.h | 30 +- headers/libs/freetype2/freetype/ftsystem.h | 5 +- headers/libs/freetype2/freetype/fttrigon.h | 44 + headers/libs/freetype2/freetype/fttypes.h | 28 +- .../freetype2/freetype/internal/autohint.h | 2 +- .../freetype2/freetype/internal/cfftypes.h | 8 +- .../freetype2/freetype/internal/ftdebug.h | 9 +- .../freetype2/freetype/internal/ftdriver.h | 4 +- .../libs/freetype2/freetype/internal/fthash.h | 90 +- .../freetype2/freetype/internal/ftobject.h | 200 ++- .../libs/freetype2/freetype/internal/ftobjs.h | 46 +- .../freetype2/freetype/internal/ftstream.h | 3 +- .../freetype2/freetype/internal/internal.h | 4 +- .../freetype2/freetype/internal/pcftypes.h | 8 +- .../libs/freetype2/freetype/internal/psaux.h | 26 +- .../freetype2/freetype/internal/pshints.h | 30 +- .../freetype2/freetype/internal/psnames.h | 2 +- .../freetype2/freetype/internal/tttypes.h | 15 +- headers/libs/freetype2/freetype/t1tables.h | 4 +- headers/libs/freetype2/freetype/ttnameid.h | 239 +++- src/libs/freetype2/autohint/ahangles.c | 17 + src/libs/freetype2/autohint/ahangles.h | 5 + src/libs/freetype2/autohint/ahglobal.c | 50 +- src/libs/freetype2/autohint/ahglobal.h | 6 +- src/libs/freetype2/autohint/ahglyph.c | 520 ++++--- src/libs/freetype2/autohint/ahglyph.h | 50 +- src/libs/freetype2/autohint/ahhint.c | 557 ++++---- src/libs/freetype2/autohint/ahhint.h | 28 +- src/libs/freetype2/autohint/ahmodule.c | 12 +- src/libs/freetype2/autohint/ahoptim.c | 46 +- src/libs/freetype2/autohint/ahoptim.h | 28 +- src/libs/freetype2/autohint/ahtypes.h | 170 +-- src/libs/freetype2/base/descrip.mms | 2 +- src/libs/freetype2/base/ftbbox.c | 2 +- src/libs/freetype2/base/ftdbgmem.c | 6 +- src/libs/freetype2/base/ftdebug.c | 34 +- src/libs/freetype2/base/ftglyph.c | 65 +- src/libs/freetype2/base/fthash.c | 97 +- src/libs/freetype2/base/ftinit.c | 2 +- src/libs/freetype2/base/ftmac.c | 6 +- src/libs/freetype2/base/ftobject.c | 378 +++-- src/libs/freetype2/base/ftobjs.c | 236 ++-- src/libs/freetype2/base/ftoutln.c | 46 +- src/libs/freetype2/base/ftsynth.c | 219 +-- src/libs/freetype2/base/fttrigon.c | 31 + src/libs/freetype2/base/ftutil.c | 4 +- src/libs/freetype2/base/rules.mk | 1 + src/libs/freetype2/bdf/bdfdrivr.c | 108 +- src/libs/freetype2/bdf/bdflib.c | 121 +- src/libs/freetype2/cache/ftccache.c | 259 +--- src/libs/freetype2/cache/ftccache.i | 24 +- src/libs/freetype2/cache/ftcimage.c | 103 +- src/libs/freetype2/cache/ftcsbits.c | 117 +- src/libs/freetype2/cff/cff.c | 2 +- src/libs/freetype2/cff/cffdrivr.c | 133 +- src/libs/freetype2/cff/cffgload.c | 426 +++--- src/libs/freetype2/cff/cffgload.h | 33 +- src/libs/freetype2/cff/cffload.c | 374 +++-- src/libs/freetype2/cff/cffload.h | 32 +- src/libs/freetype2/cff/cffobjs.c | 135 +- src/libs/freetype2/cff/cffobjs.h | 19 +- src/libs/freetype2/cff/cffparse.c | 20 +- src/libs/freetype2/cff/cffparse.h | 4 +- src/libs/freetype2/cff/rules.mk | 1 + src/libs/freetype2/cid/cidgload.c | 166 ++- src/libs/freetype2/cid/cidgload.h | 12 +- src/libs/freetype2/cid/cidload.c | 24 +- src/libs/freetype2/cid/cidload.h | 2 +- src/libs/freetype2/cid/cidobjs.c | 38 +- src/libs/freetype2/cid/cidobjs.h | 18 +- src/libs/freetype2/cid/cidparse.c | 6 +- src/libs/freetype2/cid/cidparse.h | 26 +- src/libs/freetype2/cid/cidriver.c | 262 +--- src/libs/freetype2/otlayout/otlayout.h | 41 +- src/libs/freetype2/otlayout/otlconf.h | 9 +- src/libs/freetype2/otlayout/otlgsub.c | 213 +++ src/libs/freetype2/otlayout/otlgsub.h | 12 + src/libs/freetype2/pcf/pcf.h | 4 + src/libs/freetype2/pcf/pcfdriver.c | 165 +-- src/libs/freetype2/pfr/pfr.c | 1 + src/libs/freetype2/pfr/pfrdrivr.c | 110 +- src/libs/freetype2/pfr/pfrgload.c | 29 +- src/libs/freetype2/pfr/pfrgload.h | 3 + src/libs/freetype2/pfr/pfrload.c | 255 +++- src/libs/freetype2/pfr/pfrobjs.c | 136 +- src/libs/freetype2/pfr/pfrobjs.h | 21 +- src/libs/freetype2/pfr/pfrtypes.h | 85 +- src/libs/freetype2/psaux/psauxmod.c | 56 +- src/libs/freetype2/psaux/psobjs.c | 173 ++- src/libs/freetype2/psaux/psobjs.h | 86 +- src/libs/freetype2/psaux/t1decode.c | 86 +- src/libs/freetype2/psaux/t1decode.h | 9 +- src/libs/freetype2/pshinter/pshalgo.h | 21 +- src/libs/freetype2/pshinter/pshalgo1.c | 15 +- src/libs/freetype2/pshinter/pshalgo1.h | 7 +- src/libs/freetype2/pshinter/pshalgo2.c | 21 +- src/libs/freetype2/pshinter/pshalgo2.h | 7 +- src/libs/freetype2/pshinter/pshglob.c | 19 +- src/libs/freetype2/pshinter/pshglob.h | 1 + src/libs/freetype2/pshinter/pshinter.c | 1 + src/libs/freetype2/pshinter/pshrec.c | 12 +- src/libs/freetype2/pshinter/rules.mk | 3 +- src/libs/freetype2/psnames/psmodule.c | 32 +- src/libs/freetype2/raster/ftraster.c | 72 +- src/libs/freetype2/raster/ftrend1.c | 52 +- src/libs/freetype2/sfnt/sfdriver.c | 66 +- src/libs/freetype2/sfnt/sfobjs.c | 115 +- src/libs/freetype2/sfnt/sfobjs.h | 6 +- src/libs/freetype2/sfnt/ttcmap.c | 47 +- src/libs/freetype2/sfnt/ttcmap.h | 10 +- src/libs/freetype2/sfnt/ttcmap0.c | 82 +- src/libs/freetype2/sfnt/ttcmap0.h | 8 +- src/libs/freetype2/sfnt/ttload.c | 409 +++--- src/libs/freetype2/sfnt/ttload.h | 90 +- src/libs/freetype2/sfnt/ttpost.c | 153 +- src/libs/freetype2/sfnt/ttpost.h | 8 +- src/libs/freetype2/sfnt/ttsbit.c | 78 +- src/libs/freetype2/sfnt/ttsbit.h | 28 +- src/libs/freetype2/smooth/ftgrays.c | 197 +-- src/libs/freetype2/smooth/ftsmooth.c | 186 ++- src/libs/freetype2/smooth/ftsmooth.h | 5 + src/libs/freetype2/tools/cordic.py | 2 +- src/libs/freetype2/tools/test_bbox.c | 8 +- src/libs/freetype2/truetype/ttdriver.c | 131 +- src/libs/freetype2/truetype/ttgload.c | 272 +++- src/libs/freetype2/truetype/ttgload.h | 2 +- src/libs/freetype2/truetype/ttinterp.c | 72 +- src/libs/freetype2/truetype/ttobjs.c | 71 +- src/libs/freetype2/truetype/ttobjs.h | 18 +- src/libs/freetype2/truetype/ttpload.c | 16 +- src/libs/freetype2/truetype/ttpload.h | 10 +- src/libs/freetype2/type1/t1afm.c | 10 +- src/libs/freetype2/type1/t1driver.c | 232 +--- src/libs/freetype2/type1/t1gload.c | 129 +- src/libs/freetype2/type1/t1gload.h | 2 +- src/libs/freetype2/type1/t1load.c | 101 +- src/libs/freetype2/type1/t1objs.c | 89 +- src/libs/freetype2/type1/t1parse.c | 2 +- src/libs/freetype2/type1/t1parse.h | 4 +- src/libs/freetype2/type1/t1tokens.h | 7 + src/libs/freetype2/type42/t42drivr.c | 9 +- src/libs/freetype2/type42/t42objs.c | 310 +---- src/libs/freetype2/type42/t42objs.h | 11 +- src/libs/freetype2/type42/t42parse.c | 2 +- src/libs/freetype2/winfonts/winfnt.c | 97 +- 162 files changed, 7026 insertions(+), 6073 deletions(-) diff --git a/docs/freetype2/CHANGES b/docs/freetype2/CHANGES index a11c021d7f3..26138b28240 100644 --- a/docs/freetype2/CHANGES +++ b/docs/freetype2/CHANGES @@ -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= + 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 + 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 @@ -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 enabled), causing many applications to not be able to display text correctly with the 2.1.x releases. - + - The PFR driver had a bug in its composite loading code that produces incorrectly placed accents with many fonts. - + - The Type42 driver crashed sometimes due to a nasty bug. - + - The Type 1 custom encoding charmap didn't handle the case where the 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 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 the bitmaps from a bitmap file, and 300 to 500 times faster than generating them from a scalable format. diff --git a/headers/libs/freetype2/freetype/cache/ftccache.h b/headers/libs/freetype2/freetype/cache/ftccache.h index 1871a0f19a2..701b13eb0ee 100644 --- a/headers/libs/freetype2/freetype/cache/ftccache.h +++ b/headers/libs/freetype2/freetype/cache/ftccache.h @@ -23,9 +23,6 @@ /* define to allow cache lookup inlining */ #define FTC_CACHE_USE_INLINE -/* define to use linear hash table */ -#define FTC_CACHE_USE_LINEAR_HASHING - FT_BEGIN_HEADER @@ -181,14 +178,9 @@ FT_BEGIN_HEADER FT_UInt cache_index; /* in manager's table */ FT_Pointer cache_data; /* used by cache node methods */ -#ifdef FTC_CACHE_USE_LINEAR_HASHING FT_UFast p; FT_UFast mask; FT_Long slack; -#else - FT_UFast nodes; - FT_UFast size; -#endif FTC_Node* buckets; FT_LruList_ClassRec family_class; diff --git a/headers/libs/freetype2/freetype/cache/ftcimage.h b/headers/libs/freetype2/freetype/cache/ftcimage.h index e3a40090669..382d991d3a9 100644 --- a/headers/libs/freetype2/freetype/cache/ftcimage.h +++ b/headers/libs/freetype2/freetype/cache/ftcimage.h @@ -4,7 +4,7 @@ /* */ /* FreeType Image cache (specification). */ /* */ -/* Copyright 2000-2001 by */ +/* Copyright 2000-2001, 2002 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -53,65 +53,43 @@ FT_BEGIN_HEADER /*************************************************************************/ -#define FTC_IMAGE_FORMAT( x ) ( (x) & 7 ) - - -#define ftc_image_format_bitmap 0x0000 -#define ftc_image_format_outline 0x0001 - -#define ftc_image_format_mask 0x000F - -#define ftc_image_flag_monochrome 0x0010 -#define ftc_image_flag_unhinted 0x0020 -#define ftc_image_flag_autohinted 0x0040 -#define ftc_image_flag_unscaled 0x0080 -#define ftc_image_flag_no_sbits 0x0100 - - /* monochrome bitmap */ -#define ftc_image_mono ftc_image_format_bitmap | \ - ftc_image_flag_monochrome - - /* anti-aliased bitmap */ -#define ftc_image_grays ftc_image_format_bitmap - - /* scaled outline */ -#define ftc_image_outline ftc_image_format_outline - - - /*************************************************************************/ - /* */ - /* */ - /* FTC_ImageDesc */ - /* */ - /* */ - /* A simple structure used to describe a given glyph image category. */ - /* Note that this is different from @FTC_Image_Desc. */ - /* */ - /* */ - /* 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. */ - /* */ - /* */ - /* This type deprecates @FTC_Image_Desc. */ - /* */ - typedef struct FTC_ImageDesc_ + /************************************************************************** + * + * @struct: + * FTC_ImageTypeRec + * + * @description: + * A simple structure used to describe the type of glyph image to be + * loaded into the cache. + * + * @fields: + * font :: An @FTC_FontRec used to describe the glyph's face and size. + * + * flags :: The load flags to be applied when loading the glyph; see + * the @FT_LOAD_XXX constants for details. + * + * @note: + * This type completely replaces the @FTC_Image_Desc structure which is + * now obsolete. + */ + typedef struct FTC_ImageTypeRec_ { FTC_FontRec font; - FT_UInt32 type; + FT_Int32 flags; - } FTC_ImageDesc; + } FTC_ImageTypeRec; + + typedef struct FTC_ImageTypeRec_* FTC_ImageType; /* */ -#define FTC_IMAGE_DESC_COMPARE( d1, d2 ) \ +#define FTC_IMAGE_TYPE_COMPARE( d1, d2 ) \ ( FTC_FONT_COMPARE( &(d1)->font, &(d2)->font ) && \ - (d1)->type == (d2)->type ) + (d1)->flags == (d2)->flags ) -#define FTC_IMAGE_DESC_HASH( d ) \ +#define FTC_IMAGE_TYPE_HASH( d ) \ (FT_UFast)( FTC_FONT_HASH( &(d)->font ) ^ \ - ( (d)->type << 4 ) ) + ( (d)->flags << 4 ) ) /*************************************************************************/ @@ -160,7 +138,7 @@ FT_BEGIN_HEADER /* */ /* cache :: A handle to the source glyph image cache. */ /* */ - /* desc :: A pointer to a glyph image descriptor. */ + /* type :: A pointer to a glyph image type descriptor. */ /* */ /* gindex :: The glyph index to retrieve. */ /* */ @@ -193,13 +171,36 @@ FT_BEGIN_HEADER /* */ FT_EXPORT( FT_Error ) FTC_ImageCache_Lookup( FTC_ImageCache cache, - FTC_ImageDesc* desc, + FTC_ImageType type, FT_UInt gindex, FT_Glyph *aglyph, FTC_Node *anode ); /* */ +#define ftc_image_format( x ) ( (x) & 7 ) + + +#define ftc_image_format_bitmap 0x0000 +#define ftc_image_format_outline 0x0001 + +#define ftc_image_format_mask 0x000F + +#define ftc_image_flag_monochrome 0x0010 +#define ftc_image_flag_unhinted 0x0020 +#define ftc_image_flag_autohinted 0x0040 +#define ftc_image_flag_unscaled 0x0080 +#define ftc_image_flag_no_sbits 0x0100 + + /* monochrome bitmap */ +#define ftc_image_mono ftc_image_format_bitmap | \ + ftc_image_flag_monochrome + + /* anti-aliased bitmap */ +#define ftc_image_grays ftc_image_format_bitmap + + /* scaled outline */ +#define ftc_image_outline ftc_image_format_outline /*************************************************************************/ /* */ diff --git a/headers/libs/freetype2/freetype/cache/ftcsbits.h b/headers/libs/freetype2/freetype/cache/ftcsbits.h index 4e5ab1d2aa1..6f8ef99cf78 100644 --- a/headers/libs/freetype2/freetype/cache/ftcsbits.h +++ b/headers/libs/freetype2/freetype/cache/ftcsbits.h @@ -4,7 +4,7 @@ /* */ /* A small-bitmap cache (specification). */ /* */ -/* Copyright 2000-2001 by */ +/* Copyright 2000-2001, 2002 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -72,7 +72,7 @@ FT_BEGIN_HEADER /* */ /* format :: The format of the glyph bitmap (monochrome or gray). */ /* */ - /* num_grays :: The number of gray levels. */ + /* max_grays :: Maximum gray level value (in the range 1 to 255). */ /* */ /* pitch :: The number of bytes per bitmap line. May be positive */ /* or negative. */ @@ -91,8 +91,8 @@ FT_BEGIN_HEADER FT_Char top; FT_Byte format; - FT_Short num_grays; /* XXX: Should be FT_Byte. See ftcsbits.c */ - FT_Char pitch; + FT_Byte max_grays; + FT_Short pitch; FT_Char xadvance; FT_Char yadvance; @@ -113,7 +113,7 @@ FT_BEGIN_HEADER /* implemented by @FTC_ImageCache. */ /* */ typedef struct FTC_SBitCacheRec_* FTC_SBitCache; - + /*************************************************************************/ /* */ @@ -160,7 +160,7 @@ FT_BEGIN_HEADER /* */ /* cache :: A handle to the source sbit cache. */ /* */ - /* desc :: A pointer to the glyph image descriptor. */ + /* type :: A pointer to the glyph image type descriptor. */ /* */ /* gindex :: The glyph index. */ /* */ @@ -195,7 +195,7 @@ FT_BEGIN_HEADER /* */ FT_EXPORT( FT_Error ) FTC_SBitCache_Lookup( FTC_SBitCache cache, - FTC_ImageDesc* desc, + FTC_ImageType type, FT_UInt gindex, FTC_SBit *sbit, FTC_Node *anode ); diff --git a/headers/libs/freetype2/freetype/config/ftheader.h b/headers/libs/freetype2/freetype/config/ftheader.h index 5c9d427f3a4..3ce17738848 100644 --- a/headers/libs/freetype2/freetype/config/ftheader.h +++ b/headers/libs/freetype2/freetype/config/ftheader.h @@ -361,6 +361,17 @@ /* */ #define FT_BDF_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 + /*************************************************************************/ /* */ @@ -487,6 +498,7 @@ /* */ #define FT_TRIGONOMETRY_H +#define FT_STROKER_H #define FT_SYNTHESIS_H #define FT_ERROR_DEFINITIONS_H @@ -498,6 +510,8 @@ #define FT_XFREE86_H +#define FT_INCREMENTAL_H + /* now include internal headers definitions from */ #define FT_INTERNAL_INTERNAL_H diff --git a/headers/libs/freetype2/freetype/config/ftmodule.h b/headers/libs/freetype2/freetype/config/ftmodule.h index 589e9203852..d0e6f16a3cc 100644 --- a/headers/libs/freetype2/freetype/config/ftmodule.h +++ b/headers/libs/freetype2/freetype/config/ftmodule.h @@ -9,8 +9,11 @@ FT_USE_MODULE(pshinter_module_class) FT_USE_MODULE(ft_raster1_renderer_class) FT_USE_MODULE(sfnt_module_class) FT_USE_MODULE(ft_smooth_renderer_class) +FT_USE_MODULE(ft_smooth_lcd_renderer_class) +FT_USE_MODULE(ft_smooth_lcdv_renderer_class) FT_USE_MODULE(tt_driver_class) FT_USE_MODULE(t1_driver_class) FT_USE_MODULE(t42_driver_class) FT_USE_MODULE(pfr_driver_class) FT_USE_MODULE(winfnt_driver_class) + diff --git a/headers/libs/freetype2/freetype/config/ftoption.h b/headers/libs/freetype2/freetype/config/ftoption.h index 9fd37ee51e6..85c9e45bea7 100644 --- a/headers/libs/freetype2/freetype/config/ftoption.h +++ b/headers/libs/freetype2/freetype/config/ftoption.h @@ -25,7 +25,6 @@ FT_BEGIN_HEADER - /*************************************************************************/ /* */ /* USER-SELECTABLE CONFIGURATION MACROS */ @@ -78,68 +77,98 @@ FT_BEGIN_HEADER /*************************************************************************/ /* */ - /* CMap support */ + /* Many compilers provide a non-ANSI 64-bit data type that can be used */ + /* by FreeType to speed up some computations. However, this will create */ + /* some problems when compiling the library in strict ANSI mode. */ + /* */ + /* For this reason, the use of 64-bit ints is normally disabled when */ + /* the __STDC__ macro is defined. You can however disable this by */ + /* defining here the macro FT_CONFIG_OPTION_FORCE_INT64. */ + /* */ + /* For most compilers, this will only create compilation warnings */ + /* when building the library. */ /* */ - /* Define this if you want generic cmap support. */ + /* ObNote: The compiler-specific 64-bit integers are detected in the */ + /* file "ftconfig.h" either statically, or through Autoconf */ + /* on platforms that support it. */ /* */ -#define FT_CONFIG_OPTION_USE_CMAPS +#undef FT_CONFIG_OPTION_FORCE_INT64 /*************************************************************************/ /* */ - /* Convenience functions support */ + /* Gzip-compressed file support. */ /* */ - /* Some functions of the FreeType 2 API are provided as a convenience */ - /* for client applications and developers. However, they are not */ - /* required to build and run the library itself. */ + /* FreeType now handles font files that have been compressed with the */ + /* 'gzip' program. This is mostly used to parse many of the PCF files */ + /* that come with XFree86. The implementation uses 'zlib' to */ + /* partially uncompress the file on the fly (see src/base/ftgzip.c). */ /* */ - /* By defining this configuration macro, you'll disable the */ - /* compilation of these functions at build time. This can be useful */ - /* to reduce the library's code size when you don't need any of */ - /* these functions. */ + /* Define this macro if you want to enable this "feature". Note that */ + /* this will however force you to link the zlib to any program that */ + /* also uses FreeType. */ /* */ - /* All convenience functions are declared as such in their */ - /* documentation. */ - /* */ -#undef FT_CONFIG_OPTION_NO_CONVENIENCE_FUNCS +#define FT_CONFIG_OPTION_USE_ZLIB /*************************************************************************/ /* */ - /* Module errors */ + /* ZLib library selection */ /* */ - /* If this macro is set (which is _not_ the default), the higher byte */ - /* of an error code gives the module in which the error has occurred, */ - /* while the lower byte is the real error code. */ + /* This macro is only used when FT_CONFIG_OPTION_USE_ZLIB is defined. */ + /* It allows FreeType's "ftgzip" component to link to the system's */ + /* installation of the ZLib library. This is useful on systems like */ + /* Unix or VMS where it generally is already available. */ /* */ - /* Setting this macro makes sense for debugging purposes only, since */ - /* it would break source compatibility of certain programs that use */ - /* FreeType 2. */ + /* If you let it undefined, the component will use its own copy */ + /* of the zlib sources instead. These have been modified to be */ + /* included directly within the component and *not* export external */ + /* function names. This allows you to link any program with FreeType */ + /* _and_ ZLib without linking conflicts. */ /* */ - /* More details can be found in the files ftmoderr.h and fterrors.h. */ + /* do not #undef this macro here, since the build system might */ + /* define for certain configurations */ /* */ -#undef FT_CONFIG_OPTION_USE_MODULE_ERRORS +/* #define FT_CONFIG_OPTION_SYSTEM_ZLIB */ /*************************************************************************/ /* */ - /* Alternate Glyph Image Format support */ + /* DLL export compilation */ + /* */ + /* 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 */ /* */ - /* By default, the glyph images returned by the FreeType glyph loader */ - /* can either be a pixmap or a vectorial outline defined through */ - /* Bezier control points. When defining the following configuration */ - /* macro, some font drivers will be able to register alternate */ - /* glyph image formats. */ + /* FT_EXPORT( FT_Error ) */ + /* FT_Init_FreeType( FT_Library* alibrary ); */ /* */ - /* Unset this macro if you are sure that you will never use a font */ - /* driver with an alternate glyph format; this will reduce the size of */ - /* the base layer code. */ /* */ - /* Note that a few Type 1 fonts, as well as Windows `vector' fonts */ - /* use a vector `plotter' format that isn't supported when this */ - /* macro is undefined. */ + /* FT_EXPORT_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_CONFIG_OPTION_ALTERNATE_GLYPH_FORMATS +/* #define FT_EXPORT(x) extern x */ +/* #define FT_EXPORT_DEF(x) x */ /*************************************************************************/ @@ -187,61 +216,33 @@ FT_BEGIN_HEADER /*************************************************************************/ /* */ - /* Many compilers provide a non-ANSI 64-bit data type that can be used */ - /* by FreeType to speed up some computations. However, this will create */ - /* some problems when compiling the library in strict ANSI mode. */ + /* Allow the use of FT_Incremental_Interface to load typefaces that */ + /* contain no glyph data, but supply it via a callback function. */ + /* This allows FreeType to be used with the PostScript language, using */ + /* the GhostScript interpreter. */ /* */ - /* For this reason, the use of 64-bit ints is normally disabled when */ - /* the __STDC__ macro is defined. You can however disable this by */ - /* defining here the macro FT_CONFIG_OPTION_FORCE_INT64. */ - /* */ - /* For most compilers, this will only create compilation warnings */ - /* when building the library. */ - /* */ - /* ObNote: The compiler-specific 64-bit integers are detected in the */ - /* file "ftconfig.h" either statically, or through Autoconf */ - /* on platforms that support it. */ - /* */ -#undef FT_CONFIG_OPTION_FORCE_INT64 +/* #define FT_CONFIG_OPTION_INCREMENTAL */ /*************************************************************************/ /* */ - /* 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 ); */ - /* */ + /* The size in bytes of the render pool used by the scan-line converter */ + /* to do all of its work. */ /* */ - /* FT_EXPORT_DEF( return_type ) */ + /* This must be greater than 4kByte. */ /* */ - /* is used in a function definition, as in */ +#define FT_RENDER_POOL_SIZE 16384L + + + /*************************************************************************/ /* */ - /* FT_EXPORT_DEF( FT_Error ) */ - /* FT_Init_FreeType( FT_Library* alibrary ) */ - /* { */ - /* ... some code ... */ - /* return FT_Err_Ok; */ - /* } */ + /* FT_MAX_MODULES */ /* */ - /* 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. */ + /* The maximum number of modules that can be registered in a single */ + /* FreeType library object. 32 is the default. */ /* */ -#undef FT_EXPORT -#undef FT_EXPORT_DEF +#define FT_MAX_MODULES 32 + /*************************************************************************/ /* */ @@ -257,8 +258,8 @@ FT_BEGIN_HEADER /* */ /* Don't define any of these macros to compile in `release' mode! */ /* */ -#undef FT_DEBUG_LEVEL_ERROR -#undef FT_DEBUG_LEVEL_TRACE +/* #define FT_DEBUG_LEVEL_ERROR */ +/* #define FT_DEBUG_LEVEL_TRACE */ /*************************************************************************/ @@ -273,27 +274,26 @@ FT_BEGIN_HEADER /* Note that the memory debugger is only activated at runtime when */ /* when the _environment_ variable "FT_DEBUG_MEMORY" is also defined! */ /* */ -#undef FT_DEBUG_MEMORY +/* #define FT_DEBUG_MEMORY */ + /*************************************************************************/ /* */ - /* The size in bytes of the render pool used by the scan-line converter */ - /* to do all of its work. */ - /* */ - /* This must be greater than 4kByte. */ + /* Module errors */ /* */ -#define FT_RENDER_POOL_SIZE 16384L - - - /*************************************************************************/ + /* 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. */ /* */ - /* FT_MAX_MODULES */ + /* Setting this macro makes sense for debugging purposes only, since */ + /* it would break source compatibility of certain programs that use */ + /* FreeType 2. */ /* */ - /* The maximum number of modules that can be registered in a single */ - /* FreeType library object. 16 is the default. */ + /* More details can be found in the files ftmoderr.h and fterrors.h. */ /* */ -#define FT_MAX_MODULES 16 +#undef FT_CONFIG_OPTION_USE_MODULE_ERRORS + /*************************************************************************/ @@ -375,7 +375,10 @@ FT_BEGIN_HEADER /* By undefining this, you will only compile the code necessary to load */ /* TrueType glyphs without hinting. */ /* */ -#undef TT_CONFIG_OPTION_BYTECODE_INTERPRETER + /* do not #undef this macro here, since the build system might */ + /* define for certain configurations */ + /* */ +/* #define TT_CONFIG_OPTION_BYTECODE_INTERPRETER */ /*************************************************************************/ @@ -391,6 +394,25 @@ FT_BEGIN_HEADER #define TT_CONFIG_OPTION_INTERPRETER_SWITCH + /*************************************************************************/ + /* */ + /* Define TT_CONFIG_OPTION_COMPONENT_OFFSET_SCALED to compile the */ + /* TrueType glyph loader to use Apple's definition of how to handle */ + /* component offsets in composite glyphs. */ + /* */ + /* Apple and MS disagree on the default behavior of component offsets */ + /* in composites. Apple says that they should be scaled by the scale */ + /* factors in the transformation matrix (roughly, it's more complex) */ + /* while MS says they should not. OpenType defines two bits in the */ + /* composite flags array which can be used to disambiguate, but old */ + /* fonts will not have them. */ + /* */ + /* http://partners.adobe.com/asn/developer/opentype/glyf.html */ + /* http://fonts.apple.com/TTRefMan/RM06/Chap6glyf.html */ + /* */ +#undef TT_CONFIG_OPTION_COMPONENT_OFFSET_SCALED + + /*************************************************************************/ /*************************************************************************/ /**** ****/ @@ -427,14 +449,6 @@ FT_BEGIN_HEADER #define T1_MAX_CHARSTRINGS_OPERANDS 256 - /*************************************************************************/ - /* */ - /* Define T1_CONFIG_OPTION_DISABLE_HINTER if you want to generate a */ - /* driver with no hinter. This can be useful to debug the parser. */ - /* */ -#undef T1_CONFIG_OPTION_DISABLE_HINTER - - /*************************************************************************/ /* */ /* Define this configuration macro if you want to prevent the */ diff --git a/headers/libs/freetype2/freetype/freetype.h b/headers/libs/freetype2/freetype/freetype.h index 0102a372f1b..3a41daf6a2b 100644 --- a/headers/libs/freetype2/freetype/freetype.h +++ b/headers/libs/freetype2/freetype/freetype.h @@ -35,7 +35,7 @@ /* */ #define FREETYPE_MAJOR 2 #define FREETYPE_MINOR 1 -#define FREETYPE_PATCH 0 +#define FREETYPE_PATCH 3 #include @@ -246,7 +246,7 @@ FT_BEGIN_HEADER /* */ /* */ /* Library objects are normally created by @FT_Init_FreeType, and */ - /* destroyed with @FT_Done_FreeType */ + /* destroyed with @FT_Done_FreeType. */ /* */ typedef struct FT_LibraryRec_ *FT_Library; @@ -303,13 +303,13 @@ FT_BEGIN_HEADER /* Each face object also owns a single @FT_GlyphSlot object, as well */ /* as one or more @FT_Size objects. */ /* */ - /* use @FT_New_Face or @FT_Open_Face to create a new face object from */ + /* Use @FT_New_Face or @FT_Open_Face to create a new face object from */ /* a given filepathname or a custom input stream. */ /* */ - /* use @FT_Done_Face to destroy it (along with its slot and sizes) */ + /* Use @FT_Done_Face to destroy it (along with its slot and sizes). */ /* */ /* */ - /* the @FT_FaceRec details the publicly accessible fields of a given */ + /* The @FT_FaceRec details the publicly accessible fields of a given */ /* face object. */ /* */ typedef struct FT_FaceRec_* FT_Face; @@ -321,21 +321,21 @@ FT_BEGIN_HEADER /* FT_Size */ /* */ /* */ - /* A handle to a given size object. Such an object models the */ - /* data that depends on the current _resolution_ and _character_ */ - /* _size_ in a given @FT_Face. */ + /* A handle to a given size object. Such an object models the data */ + /* that depends on the current _resolution_ and _character size_ in a */ + /* given @FT_Face. */ /* */ /* */ - /* Each face object owns one or more sizes. There is however a */ - /* single _active_ size for the face at any time that will be */ - /* used by functions like @FT_Load_Glyph, @FT_Get_Kerning, etc... */ + /* Each face object owns one or more sizes. There is however a */ + /* single _active_ size for the face at any time that will be used by */ + /* functions like @FT_Load_Glyph, @FT_Get_Kerning, etc. */ /* */ - /* you can use the @FT_Activate_Size API to change the current */ - /* active size of any given face */ + /* You can use the @FT_Activate_Size API to change the current */ + /* active size of any given face. */ /* */ /* */ - /* the @FT_SizeRec structure details the publicly accessible fields */ - /* of a given face object. */ + /* The @FT_SizeRec structure details the publicly accessible fields */ + /* of a given face object. */ /* */ typedef struct FT_SizeRec_* FT_Size; @@ -353,10 +353,10 @@ FT_BEGIN_HEADER /* In other words, each time you call @FT_Load_Glyph or */ /* @FT_Load_Char, the slot's content is erased by the new glyph data, */ /* i.e. the glyph's metrics, its image (bitmap or outline), and */ - /* other control information */ + /* other control information. */ /* */ /* */ - /* @FT_GlyphSlotRec details the publicly accessible glyph fields */ + /* @FT_GlyphSlotRec details the publicly accessible glyph fields. */ /* */ typedef struct FT_GlyphSlotRec_* FT_GlyphSlot; @@ -372,20 +372,19 @@ FT_BEGIN_HEADER /* parent's face. Some font formats may provide several charmaps per */ /* font. */ /* */ - /* Each face object owns zero or more charmaps, but only one of */ - /* them can be "active" and used by @FT_Get_Char_Index or */ - /* @FT_Load_Char */ + /* Each face object owns zero or more charmaps, but only one of them */ + /* can be "active" and used by @FT_Get_Char_Index or @FT_Load_Char. */ /* */ /* The list of available charmaps in a face is available through the */ - /* "face->num_charmaps" and "face->charmaps" fields of @FT_FaceRec */ + /* "face->num_charmaps" and "face->charmaps" fields of @FT_FaceRec. */ /* */ - /* the currently active charmap is available as "face->charmap". */ - /* You should call @FT_Set_Charmap to change it */ + /* The currently active charmap is available as "face->charmap". */ + /* You should call @FT_Set_Charmap to change it. */ /* */ /* */ - /* when a new face is created (either through @FT_New_Face or */ + /* When a new face is created (either through @FT_New_Face or */ /* @FT_Open_Face), the library looks for a Unicode charmap within */ - /* the list and automatically activates it */ + /* the list and automatically activates it. */ /* */ typedef struct FT_CharMapRec_* FT_CharMap; @@ -396,16 +395,26 @@ FT_BEGIN_HEADER /* FT_ENC_TAG */ /* */ /* */ - /* This macro converts four letter tags into an unsigned long. */ - /* It is used to define "encoding" identifiers (see @FT_Encoding) */ + /* This macro converts four letter tags into an unsigned long. It is */ + /* used to define "encoding" identifiers (see @FT_Encoding). */ /* */ + /* */ + /* Since many 16bit compilers don't like 32bit enumerations, you */ + /* should redefine this macro in case of problems to something like */ + /* this: */ + /* */ + /* #define FT_ENC_TAG( value, a, b, c, d ) (value) */ + /* */ + /* to get a simple enumeration without assigning special numbers. */ /* */ + #ifndef FT_ENC_TAG -#define FT_ENC_TAG( value, _x1, _x2, _x3, _x4 ) \ - value = ( ( (unsigned long)_x1 << 24 ) | \ - ( (unsigned long)_x2 << 16 ) | \ - ( (unsigned long)_x3 << 8 ) | \ - (unsigned long)_x4 ) +#define FT_ENC_TAG( value, a, b, c, d ) \ + value = ( ( (FT_UInt32)(a) << 24 ) | \ + ( (FT_UInt32)(b) << 16 ) | \ + ( (FT_UInt32)(c) << 8 ) | \ + (FT_UInt32)(d) ) + #endif /* FT_ENC_TAG */ @@ -416,37 +425,161 @@ FT_BEGIN_HEADER /* */ /* */ /* An enumeration used to specify encodings supported by charmaps. */ - /* Used in the FT_Select_Charmap() API function. */ + /* Used in the @FT_Select_Charmap API function. */ /* */ /* */ /* Because of 32-bit charcodes defined in Unicode (i.e., surrogates), */ /* all character codes must be expressed as FT_Longs. */ /* */ + /* The values of this type correspond to specific character */ + /* repertories (i.e. charsets), and not to text encoding methods */ + /* (like UTF-8, UTF-16, GB2312_EUC, etc.). */ + /* */ /* Other encodings might be defined in the future. */ /* */ + /* */ + /* FT_ENCODING_NONE :: */ + /* The encoding value 0 is reserved. */ + /* */ + /* FT_ENCODING_UNICODE :: */ + /* Corresponds to the Unicode character set. This value covers */ + /* all versions of the Unicode repertoire, including ASCII and */ + /* Latin-1. Most fonts include a Unicode charmap, but not all */ + /* of them. */ + /* */ + /* FT_ENCODING_MS_SYMBOL :: */ + /* Corresponds to the Microsoft Symbol encoding, used to encode */ + /* mathematical symbols in the 32..255 character code range. For */ + /* more information, see `http://www.ceviz.net/symbol.htm'. */ + /* */ + /* FT_ENCODING_MS_SJIS :: */ + /* Corresponds to Microsoft's Japanese SJIS encoding. More info */ + /* at `http://langsupport.japanreference.com/encoding.shtml'. */ + /* See note on multi-byte encodings below. */ + /* */ + /* FT_ENCODING_MS_GB2312 :: */ + /* Corresponds to the encoding system for Simplified Chinese, as */ + /* used in China. Only found in some TrueType fonts. */ + /* */ + /* FT_ENCODING_MS_BIG5 :: */ + /* Corresponds to the encoding system for Traditional Chinese, as */ + /* used in Taiwan and Hong Kong. Only found in some TrueType fonts. */ + /* */ + /* FT_ENCODING_MS_WANSUNG :: */ + /* Corresponds to the Korean encoding system known as Wansung. */ + /* This is a Microsoft encoding that is only found in some TrueType */ + /* fonts. For more information, see */ + /* `http://www.microsoft.com/typography/unicode/949.txt'. */ + /* */ + /* FT_ENCODING_MS_JOHAB :: */ + /* The Korean standard character set (KS C-5601-1992), which */ + /* corresponds to Windows code page 1361. This character set */ + /* includes all possible Hangeul character combinations. */ + /* Only found on some rare TrueType fonts. */ + /* */ + /* FT_ENCODING_ADOBE_LATIN_1 :: */ + /* Corresponds to a Latin-1 encoding as defined in a Type 1 */ + /* Postscript font. It is limited to 256 character codes. */ + /* */ + /* FT_ENCODING_ADOBE_STANDARD :: */ + /* Corresponds to the Adobe Standard encoding, as found in Type 1, */ + /* CFF, and OpenType/CFF fonts. It is limited to 256character */ + /* codes. */ + /* */ + /* FT_ENCODING_ADOBE_EXPERT :: */ + /* Corresponds to the Adobe Expert encoding, as found in Type 1, */ + /* CFF, and OpenType/CFF fonts. It is limited to 256 character */ + /* codes. */ + /* */ + /* FT_ENCODING_ADOBE_CUSTOM :: */ + /* Corresponds to a custom encoding, as found in Type 1, CFF, and */ + /* OpenType/CFF fonts. It is limited to 256 character codes. */ + /* */ + /* FT_ENCODING_APPLE_ROMAN :: */ + /* Corresponds to the 8-bit Apple roman encoding. Many TrueType and */ + /* OpenType fonts contain a charmap for this encoding, since older */ + /* versions of Mac OS are able to use it. */ + /* */ + /* FT_ENCODING_OLD_LATIN_2 :: */ + /* This value is deprecated and was never used nor reported by */ + /* FreeType. Don't use or test for it. */ + /* */ + /* */ + /* By default, FreeType automatically synthetizes a Unicode charmap */ + /* for Postscript fonts, using their glyph names dictionaries. */ + /* However, it will also report the encodings defined explicitly in */ + /* the font file, for the cases when they are needed, with the Adobe */ + /* values as well. */ + /* */ typedef enum FT_Encoding_ { - FT_ENC_TAG( ft_encoding_none, 0, 0, 0, 0 ), + FT_ENC_TAG( FT_ENCODING_NONE, 0, 0, 0, 0 ), + + FT_ENC_TAG( FT_ENCODING_MS_SYMBOL, 's', 'y', 'm', 'b' ), + FT_ENC_TAG( FT_ENCODING_UNICODE, 'u', 'n', 'i', 'c' ), - FT_ENC_TAG( ft_encoding_symbol, 's', 'y', 'm', 'b' ), - FT_ENC_TAG( ft_encoding_unicode, 'u', 'n', 'i', 'c' ), - FT_ENC_TAG( ft_encoding_latin_1, 'l', 'a', 't', '1' ), - FT_ENC_TAG( ft_encoding_latin_2, 'l', 'a', 't', '2' ), - FT_ENC_TAG( ft_encoding_sjis, 's', 'j', 'i', 's' ), - FT_ENC_TAG( ft_encoding_gb2312, 'g', 'b', ' ', ' ' ), - FT_ENC_TAG( ft_encoding_big5, 'b', 'i', 'g', '5' ), - FT_ENC_TAG( ft_encoding_wansung, 'w', 'a', 'n', 's' ), - FT_ENC_TAG( ft_encoding_johab, 'j', 'o', 'h', 'a' ), + FT_ENC_TAG( FT_ENCODING_MS_SJIS, 's', 'j', 'i', 's' ), + FT_ENC_TAG( FT_ENCODING_MS_GB2312, 'g', 'b', ' ', ' ' ), + FT_ENC_TAG( FT_ENCODING_MS_BIG5, 'b', 'i', 'g', '5' ), + FT_ENC_TAG( FT_ENCODING_MS_WANSUNG, 'w', 'a', 'n', 's' ), + FT_ENC_TAG( FT_ENCODING_MS_JOHAB, 'j', 'o', 'h', 'a' ), - FT_ENC_TAG( ft_encoding_adobe_standard, 'A', 'D', 'O', 'B' ), - FT_ENC_TAG( ft_encoding_adobe_expert, 'A', 'D', 'B', 'E' ), - FT_ENC_TAG( ft_encoding_adobe_custom, 'A', 'D', 'B', 'C' ), + FT_ENC_TAG( FT_ENCODING_ADOBE_STANDARD, 'A', 'D', 'O', 'B' ), + FT_ENC_TAG( FT_ENCODING_ADOBE_EXPERT, 'A', 'D', 'B', 'E' ), + FT_ENC_TAG( FT_ENCODING_ADOBE_CUSTOM, 'A', 'D', 'B', 'C' ), + FT_ENC_TAG( FT_ENCODING_ADOBE_LATIN_1, 'l', 'a', 't', '1' ), - FT_ENC_TAG( ft_encoding_apple_roman, 'a', 'r', 'm', 'n' ) + FT_ENC_TAG( FT_ENCODING_OLD_LATIN_2, 'l', 'a', 't', '2' ), + + FT_ENC_TAG( FT_ENCODING_APPLE_ROMAN, 'a', 'r', 'm', 'n' ) } FT_Encoding; + /*************************************************************************/ + /* */ + /* */ + /* ft_encoding_xxx */ + /* */ + /* */ + /* These constants are deprecated; use the corresponding @FT_Encoding */ + /* values instead. */ + /* */ + /* */ + /* ft_encoding_none :: see @FT_ENCODING_NONE */ + /* ft_encoding_unicode :: see @FT_ENCODING_UNICODE */ + /* ft_encoding_latin_2 :: see @FT_ENCODING_OLD_LATIN_2 */ + /* ft_encoding_symbol :: see @FT_ENCODING_MS_SYMBOL */ + /* ft_encoding_sjis :: see @FT_ENCODING_MS_SJIS */ + /* ft_encoding_gb2312 :: see @FT_ENCODING_MS_GB2312 */ + /* ft_encoding_big5 :: see @FT_ENCODING_MS_BIG5 */ + /* ft_encoding_wansung :: see @FT_ENCODING_MS_WANSUNG */ + /* ft_encoding_johab :: see @FT_ENCODING_MS_JOHAB */ + /* */ + /* ft_encoding_adobe_standard :: see @FT_ENCODING_ADOBE_STANDARD */ + /* ft_encoding_adobe_expert :: see @FT_ENCODING_ADOBE_EXPERT */ + /* ft_encoding_adobe_custom :: see @FT_ENCODING_ADOBE_CUSTOM */ + /* ft_encoding_latin_1 :: see @FT_ENCODING_ADOBE_LATIN_1 */ + /* */ + /* ft_encoding_apple_roman :: see @FT_ENCODING_APPLE_ROMAN */ + /* */ +#define ft_encoding_none FT_ENCODING_NONE +#define ft_encoding_unicode FT_ENCODING_UNICODE +#define ft_encoding_symbol FT_ENCODING_MS_SYMBOL +#define ft_encoding_latin_1 FT_ENCODING_ADOBE_LATIN_1 +#define ft_encoding_latin_2 FT_ENCODING_OLD_LATIN_2 +#define ft_encoding_sjis FT_ENCODING_MS_SJIS +#define ft_encoding_gb2312 FT_ENCODING_MS_GB2312 +#define ft_encoding_big5 FT_ENCODING_MS_BIG5 +#define ft_encoding_wansung FT_ENCODING_MS_WANSUNG +#define ft_encoding_johab FT_ENCODING_MS_JOHAB + +#define ft_encoding_adobe_standard FT_ENCODING_ADOBE_STANDARD +#define ft_encoding_adobe_expert FT_ENCODING_ADOBE_EXPERT +#define ft_encoding_adobe_custom FT_ENCODING_ADOBE_CUSTOM +#define ft_encoding_apple_roman FT_ENCODING_APPLE_ROMAN + + /*************************************************************************/ /* */ /* */ @@ -458,8 +591,8 @@ FT_BEGIN_HEADER /* */ /* face :: A handle to the parent face object. */ /* */ - /* encoding :: A @FT_Encoding tag identifying the charmap. Use */ - /* this with @FT_Select_Charmap(). */ + /* encoding :: An @FT_Encoding tag identifying the charmap. Use */ + /* this with @FT_Select_Charmap. */ /* */ /* platform_id :: An ID number describing the platform for the */ /* following encoding ID. This comes directly from */ @@ -498,7 +631,7 @@ FT_BEGIN_HEADER /* An opaque handle to an FT_Face_InternalRec structure, used to */ /* model private data of a given @FT_Face object. */ /* */ - /* This structure might change between releases of FreeType 2 and are */ + /* This structure might change between releases of FreeType 2 and is */ /* not generally available to client applications. */ /* */ typedef struct FT_Face_InternalRec_* FT_Face_Internal; @@ -506,8 +639,6 @@ FT_BEGIN_HEADER /*************************************************************************/ /* */ - /* FreeType base face object */ - /* */ /* */ /* FT_FaceRec */ /* */ @@ -517,7 +648,7 @@ FT_BEGIN_HEADER /* */ /* */ /* num_faces :: In the case where the face is located in a */ - /* collection (i.e., a file which embed */ + /* collection (i.e., a file which embeds */ /* several faces), this is the total number of */ /* faces found in the resource. 1 by default. */ /* */ @@ -529,11 +660,12 @@ FT_BEGIN_HEADER /* */ /* face_flags :: A set of bit flags that give important */ /* information about the face; see the */ - /* FT_FACE_FLAG_XXX constants for details. */ + /* @FT_FACE_FLAG_XXX constants for details. */ /* */ /* style_flags :: A set of bit flags indicating the style of */ /* the face (i.e., italic, bold, underline, */ - /* etc). */ + /* etc). See the @FT_STYLE_FLAG_XXX */ + /* constants. */ /* */ /* num_glyphs :: The total number of glyphs in the face. */ /* */ @@ -566,7 +698,7 @@ FT_BEGIN_HEADER /* */ /* available_sizes :: An array of sizes specifying the available */ /* bitmap/graymap sizes that are contained in */ - /* in the font face. Should be set to NULL if */ + /* in the font face. Should be set to NULL if */ /* the field `num_fixed_sizes' is set to 0. */ /* */ /* num_charmaps :: The total number of character maps in the */ @@ -576,7 +708,7 @@ FT_BEGIN_HEADER /* Used to scan the list of available charmaps */ /* -- this table might change after a call to */ /* @FT_Attach_File or @FT_Attach_Stream (e.g. */ - /* when used to hook an additional encoding or */ + /* if used to hook an additional encoding or */ /* CMap to the face object). */ /* */ /* generic :: A field reserved for client uses. See the */ @@ -611,9 +743,9 @@ FT_BEGIN_HEADER /* descender :: The face's descender is the vertical */ /* distance from the baseline to the */ /* bottommost point of any glyph in the face. */ - /* This field's value is positive, expressed */ + /* This field's value is *negative*, expressed */ /* in font units. Some font designs use a */ - /* value different from `-bbox.yMin'. Only */ + /* value different from `bbox.yMin'. Only */ /* relevant for scalable formats. */ /* */ /* height :: The face's height is the vertical distance */ @@ -655,9 +787,9 @@ FT_BEGIN_HEADER /* can need more than one slot to ease their */ /* task. */ /* */ - /* size :: the current active size for this face */ + /* size :: The current active size for this face. */ /* */ - /* charmap :: the current active charmap for this face */ + /* charmap :: The current active charmap for this face. */ /* */ typedef struct FT_FaceRec_ { @@ -718,170 +850,92 @@ FT_BEGIN_HEADER /*************************************************************************/ /* */ - /* */ - /* FT_FACE_FLAG_SCALABLE */ - /* */ - /* */ - /* A bit-field constant, used to indicate that a given face provides */ - /* vectorial outlines (i.e., TrueType or Type1). This doesn't */ - /* prevent embedding of bitmap strikes though, i.e., a given face can */ - /* have both this bit set, and a `num_fixed_sizes' property > 0. */ - /* */ -#define FT_FACE_FLAG_SCALABLE 1 - - - /*************************************************************************/ - /* */ - /* */ - /* FT_FACE_FLAG_FIXED_SIZES */ - /* */ - /* */ - /* A bit-field constant, used to indicate that a given face contains */ - /* `fixed sizes', i.e., bitmap strikes for some given pixel sizes. */ - /* See the `num_fixed_sizes' and `available_sizes' face properties */ - /* for more information. */ - /* */ -#define FT_FACE_FLAG_FIXED_SIZES 2 - - - /*************************************************************************/ - /* */ - /* */ - /* FT_FACE_FLAG_FIXED_WIDTH */ - /* */ - /* */ - /* A bit-field constant, used to indicate that a given face contains */ - /* fixed-width characters (like Courier, Lucida, MonoType, etc.). */ - /* */ -#define FT_FACE_FLAG_FIXED_WIDTH 4 - - - /*************************************************************************/ - /* */ - /* */ - /* FT_FACE_FLAG_SFNT */ - /* */ - /* */ - /* A bit-field constant, used to indicate that a given face uses the */ - /* `sfnt' storage fomat. For now, this means TrueType or OpenType. */ - /* */ -#define FT_FACE_FLAG_SFNT 8 - - - /*************************************************************************/ - /* */ - /* */ - /* FT_FACE_FLAG_HORIZONTAL */ - /* */ - /* */ - /* A bit-field constant, used to indicate that a given face contains */ - /* horizontal glyph metrics. This should be set for all common */ - /* formats, but who knows. */ - /* */ -#define FT_FACE_FLAG_HORIZONTAL 0x10 - - - /*************************************************************************/ - /* */ - /* */ - /* FT_FACE_FLAG_VERTICAL */ - /* */ - /* */ - /* A bit-field constant, used to indicate that a given face contains */ - /* vertical glyph metrics. If not set, the glyph loader will */ - /* synthetize vertical metrics itself to help display vertical text */ - /* correctly. */ - /* */ -#define FT_FACE_FLAG_VERTICAL 0x20 - - - /*************************************************************************/ - /* */ - /* */ - /* FT_FACE_FLAG_KERNING */ - /* */ - /* */ - /* A bit-field constant, used to indicate that a given face contains */ - /* kerning information. When set, this information can be retrieved */ - /* through the function @FT_Get_Kerning(). Note that when unset, */ - /* this function will always return the kerning vector (0,0). */ - /* */ -#define FT_FACE_FLAG_KERNING 0x40 - - - /*************************************************************************/ - /* */ - /* */ - /* FT_FACE_FLAG_FAST_GLYPHS */ - /* */ - /* */ - /* A bit-field constant, used to indicate that the glyphs in a given */ - /* font can be retrieved very quickly, and that a glyph cache is thus */ - /* not necessary for any of its child size objects. */ - /* */ - /* This flag should really be set for fixed-size formats like FNT, */ - /* where each glyph bitmap is available directly in binary form */ - /* without any kind of compression. */ - /* */ - /* */ - /* This bit flag is deprecated, because even if the bitmaps are */ - /* available directly in the font file, the glyph sub-system is */ - /* very likely to be faster anyway... */ - /* */ -#define FT_FACE_FLAG_FAST_GLYPHS 0x80 - - - /*************************************************************************/ - /* */ - /* */ - /* FT_FACE_FLAG_MULTIPLE_MASTERS */ - /* */ - /* */ - /* A bit-field constant, used to indicate that the font contains */ - /* multiple masters and is capable of interpolating between them. */ - /* See the multiple-masters specific API for more details */ - /* */ -#define FT_FACE_FLAG_MULTIPLE_MASTERS 0x100 - - - /*************************************************************************/ - /* */ - /* */ - /* FT_FACE_FLAG_GLYPH_NAMES */ - /* */ - /* */ - /* A bit-field constant, used to indicate that the font contains */ - /* glyph names that can be retrieved through @FT_Get_Glyph_Name(). */ - /* */ -#define FT_FACE_FLAG_GLYPH_NAMES 0x200 - - - /*************************************************************************/ - /* */ - /* */ - /* FT_FACE_FLAG_EXTERNAL_STREAM */ - /* */ - /* */ - /* This bit field is used internally by FreeType to indicate that */ - /* a face's stream was provided by the client application and should */ - /* not be destroyed by @FT_Done_Face(). */ - /* */ -#define FT_FACE_FLAG_EXTERNAL_STREAM 0x4000 - + /* */ + /* FT_FACE_FLAG_XXX */ + /* */ + /* */ + /* A list of bit flags used in the 'face_flags' field of the */ + /* @FT_FaceRec structure. They inform client applications of */ + /* properties of the corresponding face. */ + /* */ + /* */ + /* FT_FACE_FLAG_SCALABLE :: */ + /* Indicates that the face provides vectorial outlines. This */ + /* doesn't prevent embedded bitmaps, i.e., a face can have both */ + /* this bit and @FT_FACE_FLAG_FIXED_SIZES set */ + /* */ + /* FT_FACE_FLAG_FIXED_SIZES :: */ + /* Indicates that the face contains `fixed sizes', i.e., bitmap */ + /* strikes for some given pixel sizes. See the `num_fixed_sizes' */ + /* and `available_sizes' fields of @FT_FaceRec. */ + /* */ + /* FT_FACE_FLAG_FIXED_WIDTH :: */ + /* Indicates that the face contains fixed-width characters (like */ + /* Courier, Lucido, MonoType, etc.). */ + /* */ + /* FT_FACE_FLAG_SFNT :: */ + /* Indicates that the face uses the `sfnt' storage scheme. For */ + /* now, this means TrueType and OpenType. */ + /* */ + /* FT_FACE_FLAG_HORIZONTAL :: */ + /* Indicates that the face contains horizontal glyph metrics. This */ + /* should be set for all common formats. */ + /* */ + /* FT_FACE_FLAG_VERTICAL :: */ + /* Indicates that the face contains vertical glyph metrics. This */ + /* is only available in some formats, not all of them. */ + /* */ + /* FT_FACE_FLAG_KERNING :: */ + /* Indicates that the face contains kerning information. If set, */ + /* the kerning distance can be retrieved through the function */ + /* @FT_Get_Kerning. Note that if unset, this function will always */ + /* return the vector (0,0). */ + /* */ + /* FT_FACE_FLAG_FAST_GLYPHS :: */ + /* THIS FLAG IS DEPRECATED. DO NOT USE OR TEST IT. */ + /* */ + /* FT_FACE_FLAG_MULTIPLE_MASTERS :: */ + /* Indicates that the font contains multiple masters and is capable */ + /* of interpolating between them. See the multiple-masters */ + /* specific API for details. */ + /* */ + /* FT_FACE_FLAG_GLYPH_NAMES :: */ + /* Indicates that the font contains glyph names that can be */ + /* retrieved through @FT_Get_Glyph_Names. Note that some TrueType */ + /* fonts contain broken glyph name tables. Use the function */ + /* @FT_Has_PS_Glyph_Name when needed. */ + /* */ + /* FT_FACE_FLAG_EXTERNAL_STREAM :: */ + /* Used internally by FreeType to indicate that a face's stream was */ + /* provided by the client application and should not be destroyed */ + /* when @FT_Done_Face is called. Don't read or test this flag. */ + /* */ +#define FT_FACE_FLAG_SCALABLE ( 1L << 0 ) +#define FT_FACE_FLAG_FIXED_SIZES ( 1L << 1 ) +#define FT_FACE_FLAG_FIXED_WIDTH ( 1L << 2 ) +#define FT_FACE_FLAG_SFNT ( 1L << 3 ) +#define FT_FACE_FLAG_HORIZONTAL ( 1L << 4 ) +#define FT_FACE_FLAG_VERTICAL ( 1L << 5 ) +#define FT_FACE_FLAG_KERNING ( 1L << 6 ) +#define FT_FACE_FLAG_FAST_GLYPHS ( 1L << 7 ) +#define FT_FACE_FLAG_MULTIPLE_MASTERS ( 1L << 8 ) +#define FT_FACE_FLAG_GLYPH_NAMES ( 1L << 9 ) +#define FT_FACE_FLAG_EXTERNAL_STREAM ( 1L << 10 ) /* */ /*************************************************************************/ /* */ - /* @macro: FT_HAS_HORIZONTAL (face) */ + /* @macro: */ + /* FT_HAS_HORIZONTAL( face ) */ /* */ /* @description: */ - /* A macro that returns true whenever a face object contains */ - /* horizontal metrics (this is true for all font formats though). */ + /* A macro that returns true whenever a face object contains */ + /* horizontal metrics (this is true for all font formats though). */ /* */ /* @also: */ - /* @FT_HAS_VERTICAL can be used to check for vertical metrics. */ + /* @FT_HAS_VERTICAL can be used to check for vertical metrics. */ /* */ #define FT_HAS_HORIZONTAL( face ) \ ( face->face_flags & FT_FACE_FLAG_HORIZONTAL ) @@ -889,11 +943,12 @@ FT_BEGIN_HEADER /*************************************************************************/ /* */ - /* @macro: FT_HAS_VERTICAL (face) */ + /* @macro: */ + /* FT_HAS_VERTICAL( face ) */ /* */ /* @description: */ - /* A macro that returns true whenever a face object contains vertical */ - /* metrics. */ + /* A macro that returns true whenever a face object contains vertical */ + /* metrics. */ /* */ #define FT_HAS_VERTICAL( face ) \ ( face->face_flags & FT_FACE_FLAG_VERTICAL ) @@ -901,11 +956,12 @@ FT_BEGIN_HEADER /*************************************************************************/ /* */ - /* @macro: FT_HAS_KERNING (face) */ + /* @macro: */ + /* FT_HAS_KERNING( face ) */ /* */ /* @description: */ - /* A macro that returns true whenever a face object contains kerning */ - /* data that can be accessed with @FT_Get_Kerning. */ + /* A macro that returns true whenever a face object contains kerning */ + /* data that can be accessed with @FT_Get_Kerning. */ /* */ #define FT_HAS_KERNING( face ) \ ( face->face_flags & FT_FACE_FLAG_KERNING ) @@ -913,12 +969,13 @@ FT_BEGIN_HEADER /*************************************************************************/ /* */ - /* @macro: FT_IS_SCALABLE (face) */ + /* @macro: */ + /* FT_IS_SCALABLE( face ) */ /* */ /* @description: */ - /* A macro that returns true whenever a face object contains a */ - /* scalable font face (true for TrueType, Type 1, CID, and */ - /* OpenType/CFF font formats. */ + /* A macro that returns true whenever a face object contains a */ + /* scalable font face (true for TrueType, Type 1, CID, and */ + /* OpenType/CFF font formats. */ /* */ #define FT_IS_SCALABLE( face ) \ ( face->face_flags & FT_FACE_FLAG_SCALABLE ) @@ -926,16 +983,17 @@ FT_BEGIN_HEADER /*************************************************************************/ /* */ - /* @macro: FT_IS_SFNT (face) */ + /* @macro: */ + /* FT_IS_SFNT( face ) */ /* */ /* @description: */ - /* A macro that returns true whenever a face object contains a font */ - /* whose format is based on the SFNT storage scheme. This usually */ - /* means: TrueType fonts, OpenType fonts, as well as SFNT-based */ - /* embedded bitmap fonts. */ + /* A macro that returns true whenever a face object contains a font */ + /* whose format is based on the SFNT storage scheme. This usually */ + /* means: TrueType fonts, OpenType fonts, as well as SFNT-based */ + /* embedded bitmap fonts. */ /* */ - /* If this macro is true, all functions defined in @FT_SFNT_NAMES_H */ - /* and @FT_TRUETYPE_TABLES_H are available. */ + /* If this macro is true, all functions defined in @FT_SFNT_NAMES_H */ + /* and @FT_TRUETYPE_TABLES_H are available. */ /* */ #define FT_IS_SFNT( face ) \ ( face->face_flags & FT_FACE_FLAG_SFNT ) @@ -943,12 +1001,13 @@ FT_BEGIN_HEADER /*************************************************************************/ /* */ - /* @macro: FT_IS_FIXED_WIDTH (face) */ + /* @macro: */ + /* FT_IS_FIXED_WIDTH( face ) */ /* */ /* @description: */ - /* A macro that returns true whenever a face object contains a font */ - /* face that contains fixed-width (or "monospace", "fixed-pitch", */ - /* etc.) glyphs. */ + /* A macro that returns true whenever a face object contains a font */ + /* face that contains fixed-width (or "monospace", "fixed-pitch", */ + /* etc.) glyphs. */ /* */ #define FT_IS_FIXED_WIDTH( face ) \ ( face->face_flags & FT_FACE_FLAG_FIXED_WIDTH ) @@ -956,12 +1015,13 @@ FT_BEGIN_HEADER /*************************************************************************/ /* */ - /* @macro: FT_IS_FIXED_SIZES (face) */ + /* @macro: */ + /* FT_IS_FIXED_SIZES( face ) */ /* */ /* @description: */ - /* A macro that returns true whenever a face object contains some */ - /* embedded bitmaps. See the `fixed_sizes' field of the @FT_FaceRec */ - /* structure. */ + /* A macro that returns true whenever a face object contains some */ + /* embedded bitmaps. See the `fixed_sizes' field of the @FT_FaceRec */ + /* structure. */ /* */ #define FT_HAS_FIXED_SIZES( face ) \ ( face->face_flags & FT_FACE_FLAG_FIXED_SIZES ) @@ -972,11 +1032,12 @@ FT_BEGIN_HEADER /*************************************************************************/ /* */ - /* @macro: FT_HAS_FAST_GLYPHS (face) */ + /* @macro: */ + /* FT_HAS_FAST_GLYPHS( face ) */ /* */ /* @description: */ - /* Deprecated, indicates that the face contains so-called "fast" */ - /* glyph bitmaps. */ + /* Deprecated; indicates that the face contains so-called "fast" */ + /* glyph bitmaps. */ /* */ #define FT_HAS_FAST_GLYPHS( face ) \ ( face->face_flags & FT_FACE_FLAG_FAST_GLYPHS ) @@ -984,11 +1045,12 @@ FT_BEGIN_HEADER /*************************************************************************/ /* */ - /* @macro: FT_HAS_GLYPH_NAMES (face) */ + /* @macro: */ + /* FT_HAS_GLYPH_NAMES( face ) */ /* */ /* @description: */ - /* A macro that returns true whenever a face object contains some */ - /* glyph names that can be accessed through @FT_Get_Glyph_Names. */ + /* A macro that returns true whenever a face object contains some */ + /* glyph names that can be accessed through @FT_Get_Glyph_Names. */ /* */ #define FT_HAS_GLYPH_NAMES( face ) \ ( face->face_flags & FT_FACE_FLAG_GLYPH_NAMES ) @@ -996,13 +1058,14 @@ FT_BEGIN_HEADER /*************************************************************************/ /* */ - /* @macro: FT_HAS_MULTIPLE_MASTERS (face) */ + /* @macro: */ + /* FT_HAS_MULTIPLE_MASTERS( face ) */ /* */ /* @description: */ - /* A macro that returns true whenever a face object contains some */ - /* multiple masters. The functions provided by */ - /* @FT_MULTIPLE_MASTERS_H are then available to choose the exact */ - /* design you want. */ + /* A macro that returns true whenever a face object contains some */ + /* multiple masters. The functions provided by */ + /* @FT_MULTIPLE_MASTERS_H are then available to choose the exact */ + /* design you want. */ /* */ #define FT_HAS_MULTIPLE_MASTERS( face ) \ ( face->face_flags & FT_FACE_FLAG_MULTIPLE_MASTERS ) @@ -1011,25 +1074,21 @@ FT_BEGIN_HEADER /*************************************************************************/ /* */ /* */ - /* FT_STYLE_FLAG_ITALIC */ + /* FT_STYLE_FLAG_XXX */ /* */ /* */ - /* A bit-field constant, used to indicate that a given face is */ - /* italicized. */ + /* A list of bit-flags used to indicate the style of a given face. */ + /* These are used in the `style_flags' field of @FT_FaceRec. */ /* */ -#define FT_STYLE_FLAG_ITALIC 1 - - - /*************************************************************************/ + /* */ + /* FT_STYLE_FLAG_ITALIC :: */ + /* Indicates that a given face is italicized. */ /* */ - /* */ - /* FT_STYLE_FLAG_BOLD */ + /* FT_STYLE_FLAG_BOLD :: */ + /* Indicates that a given face is bold. */ /* */ - /* */ - /* A bit-field constant, used to indicate that a given face is */ - /* emboldened. */ - /* */ -#define FT_STYLE_FLAG_BOLD 2 +#define FT_STYLE_FLAG_ITALIC ( 1 << 0 ) +#define FT_STYLE_FLAG_BOLD ( 1 << 1 ) /*************************************************************************/ @@ -1116,8 +1175,6 @@ FT_BEGIN_HEADER /*************************************************************************/ /* */ - /* FreeType base size class */ - /* */ /* */ /* FT_SizeRec */ /* */ @@ -1175,8 +1232,6 @@ FT_BEGIN_HEADER /*************************************************************************/ /* */ - /* FreeType Glyph Slot base class */ - /* */ /* */ /* FT_GlyphSlotRec */ /* */ @@ -1204,7 +1259,7 @@ FT_BEGIN_HEADER /* */ /* metrics :: The metrics of the last loaded glyph in the */ /* slot. The returned values depend on the last */ - /* load flags (see the FT_Load_Glyph() API */ + /* load flags (see the @FT_Load_Glyph API */ /* function) and can be expressed either in 26.6 */ /* fractional pixels or font units. */ /* */ @@ -1233,22 +1288,22 @@ FT_BEGIN_HEADER /* */ /* format :: This field indicates the format of the image */ /* contained in the glyph slot. Typically */ - /* ft_glyph_format_bitmap, */ - /* ft_glyph_format_outline, and */ - /* ft_glyph_format_composite, but others are */ + /* FT_GLYPH_FORMAT_BITMAP, */ + /* FT_GLYPH_FORMAT_OUTLINE, and */ + /* FT_GLYPH_FORMAT_COMPOSITE, but others are */ /* possible. */ /* */ /* bitmap :: This field is used as a bitmap descriptor */ /* when the slot format is */ - /* ft_glyph_format_bitmap. Note that the */ + /* FT_GLYPH_FORMAT_BITMAP. Note that the */ /* address and content of the bitmap buffer can */ - /* change between calls of @FT_Load_Glyph() and */ - /* a few other functions. */ + /* change between calls of @FT_Load_Glyph and a */ + /* few other functions. */ /* */ /* bitmap_left :: This is the bitmap's left bearing expressed */ /* in integer pixels. Of course, this is only */ /* valid if the format is */ - /* ft_glyph_format_bitmap. */ + /* FT_GLYPH_FORMAT_BITMAP. */ /* */ /* bitmap_top :: This is the bitmap's top bearing expressed in */ /* integer pixels. Remember that this is the */ @@ -1283,13 +1338,13 @@ FT_BEGIN_HEADER /* image format. */ /* */ /* */ - /* If @FT_Load_Glyph() is called with default flags (see */ - /* @FT_LOAD_DEFAULT ) the glyph image is loaded in the glyph slot in */ + /* If @FT_Load_Glyph is called with default flags (see */ + /* @FT_LOAD_DEFAULT) the glyph image is loaded in the glyph slot in */ /* its native format (e.g. a vectorial outline for TrueType and */ /* Type 1 formats). */ /* */ /* This image can later be converted into a bitmap by calling */ - /* FT_Render_Glyph(). This function finds the current renderer for */ + /* @FT_Render_Glyph. This function finds the current renderer for */ /* the native image's format then invokes it. */ /* */ /* The renderer is in charge of transforming the native image through */ @@ -1299,7 +1354,7 @@ FT_BEGIN_HEADER /* Note that `slot->bitmap_left' and `slot->bitmap_top' are also used */ /* to specify the position of the bitmap relative to the current pen */ /* position (e.g. coordinates [0,0] on the baseline). Of course, */ - /* `slot->format' is also changed to `ft_glyph_format_bitmap' . */ + /* `slot->format' is also changed to `FT_GLYPH_FORMAT_BITMAP' . */ /* */ typedef struct FT_GlyphSlotRec_ { @@ -1428,30 +1483,37 @@ FT_BEGIN_HEADER /* `flags' field of the @FT_Open_Args structure. */ /* */ /* */ - /* ft_open_memory :: This is a memory-based stream. */ + /* FT_OPEN_MEMORY :: This is a memory-based stream. */ /* */ - /* ft_open_stream :: Copy the stream from the `stream' field. */ + /* FT_OPEN_STREAM :: Copy the stream from the `stream' field. */ /* */ - /* ft_open_pathname :: Create a new input stream from a C pathname. */ + /* FT_OPEN_PATHNAME :: Create a new input stream from a C */ + /* path name. */ /* */ - /* ft_open_driver :: Use the `driver' field. */ + /* FT_OPEN_DRIVER :: Use the `driver' field. */ /* */ - /* ft_open_params :: Use the `num_params' & `params' field. */ + /* FT_OPEN_PARAMS :: Use the `num_params' & `params' field. */ /* */ /* */ - /* The `ft_open_memory', `ft_open_stream', and `ft_open_pathname' */ + /* The `FT_OPEN_MEMORY', `FT_OPEN_STREAM', and `FT_OPEN_PATHNAME' */ /* flags are mutually exclusive. */ /* */ typedef enum { - ft_open_memory = 1, - ft_open_stream = 2, - ft_open_pathname = 4, - ft_open_driver = 8, - ft_open_params = 16 + FT_OPEN_MEMORY = 1, + FT_OPEN_STREAM = 2, + FT_OPEN_PATHNAME = 4, + FT_OPEN_DRIVER = 8, + FT_OPEN_PARAMS = 16 } FT_Open_Flags; +#define FT_OPEN_MEMORY FT_OPEN_MEMORY +#define FT_OPEN_STREAM FT_OPEN_STREAM +#define FT_OPEN_PATHNAME FT_OPEN_PATHNAME +#define FT_OPEN_DRIVER FT_OPEN_DRIVER +#define FT_OPEN_PARAMS FT_OPEN_PARAMS + /*************************************************************************/ /* */ @@ -1460,7 +1522,7 @@ FT_BEGIN_HEADER /* */ /* */ /* A simple structure used to pass more or less generic parameters */ - /* to FT_Open_Face(). */ + /* to @FT_Open_Face. */ /* */ /* */ /* tag :: A 4-byte identification tag. */ @@ -1486,7 +1548,7 @@ FT_BEGIN_HEADER /* */ /* A structure used to indicate how to open a new font file/stream. */ /* A pointer to such a structure can be used as a parameter for the */ - /* functions @FT_Open_Face() & @FT_Attach_Stream(). */ + /* functions @FT_Open_Face and @FT_Attach_Stream. */ /* */ /* */ /* flags :: A set of bit flags indicating how to use the */ @@ -1500,7 +1562,7 @@ FT_BEGIN_HEADER /* */ /* stream :: A handle to a source stream object. */ /* */ - /* driver :: This field is exclusively used by FT_Open_Face(); */ + /* driver :: This field is exclusively used by @FT_Open_Face; */ /* it simply specifies the font driver to use to open */ /* the face. If set to 0, FreeType will try to load */ /* the face with each one of the drivers in its list. */ @@ -1514,32 +1576,32 @@ FT_BEGIN_HEADER /* The stream type is determined by the contents of `flags' which */ /* are tested in the following order by @FT_Open_Face: */ /* */ - /* If the `ft_open_memory' bit is set, assume that this is a */ + /* If the `FT_OPEN_MEMORY' bit is set, assume that this is a */ /* memory file of `memory_size' bytes,located at `memory_address'. */ /* */ - /* Otherwise, if the `ft_open_stream' bit is set, assume that a */ + /* Otherwise, if the `FT_OPEN_STREAM' bit is set, assume that a */ /* custom input stream `stream' is used. */ /* */ - /* Otherwise, if the `ft_open_pathname' bit is set, assume that this */ + /* Otherwise, if the `FT_OPEN_PATHNAME' bit is set, assume that this */ /* is a normal file and use `pathname' to open it. */ /* */ - /* If the `ft_open_driver' bit is set, @FT_Open_Face() will only */ - /* try to open the file with the driver whose handler is in `driver'. */ + /* If the `FT_OPEN_DRIVER' bit is set, @FT_Open_Face will only try to */ + /* open the file with the driver whose handler is in `driver'. */ /* */ - /* If the `ft_open_params' bit is set, the parameters given by */ + /* If the `FT_OPEN_PARAMS' bit is set, the parameters given by */ /* `num_params' and `params' will be used. They are ignored */ /* otherwise. */ /* */ typedef struct FT_Open_Args_ { - FT_Open_Flags flags; - const FT_Byte* memory_base; - FT_Long memory_size; - FT_String* pathname; - FT_Stream stream; - FT_Module driver; - FT_Int num_params; - FT_Parameter* params; + FT_Open_Flags flags; + const FT_Byte* memory_base; + FT_Long memory_size; + FT_String* pathname; + FT_Stream stream; + FT_Module driver; + FT_Int num_params; + FT_Parameter* params; } FT_Open_Args; @@ -1572,14 +1634,14 @@ FT_BEGIN_HEADER /* slot for the face object which can be accessed directly through */ /* `face->glyph'. */ /* */ - /* FT_New_Face() can be used to determine and/or check the font */ - /* format of a given font resource. If the `face_index' field is */ - /* negative, the function will _not_ return any face handle in */ - /* `aface'. Its return value should be 0 if the font format is */ - /* recognized, or non-zero otherwise. */ + /* @FT_New_Face can be used to determine and/or check the font format */ + /* of a given font resource. If the `face_index' field is negative, */ + /* the function will _not_ return any face handle in `aface'. Its */ + /* return value should be 0 if the font format is recognized, or */ + /* non-zero otherwise. */ /* */ /* Each new face object created with this function also owns a */ - /* default @FT_Size object, accessible as `face->size' */ + /* default @FT_Size object, accessible as `face->size'. */ /* */ FT_EXPORT( FT_Error ) FT_New_Face( FT_Library library, @@ -1623,9 +1685,9 @@ FT_BEGIN_HEADER /* slot for the face object which can be accessed directly through */ /* `face->glyph'. */ /* */ - /* FT_New_Memory_Face() can be used to determine and/or check the */ - /* font format of a given font resource. If the `face_index' field */ - /* is negative, the function will _not_ return any face handle in */ + /* @FT_New_Memory_Face can be used to determine and/or check the font */ + /* format of a given font resource. If the `face_index' field is */ + /* negative, the function will _not_ return any face handle in */ /* `aface'. Its return value should be 0 if the font format is */ /* recognized, or non-zero otherwise. */ /* */ @@ -1667,17 +1729,17 @@ FT_BEGIN_HEADER /* slot for the face object which can be accessed directly through */ /* `face->glyph'. */ /* */ - /* FT_Open_Face() can be used to determine and/or check the font */ + /* @FT_Open_Face can be used to determine and/or check the font */ /* format of a given font resource. If the `face_index' field is */ /* negative, the function will _not_ return any face handle in */ /* `*face'. Its return value should be 0 if the font format is */ /* recognized, or non-zero otherwise. */ /* */ FT_EXPORT( FT_Error ) - FT_Open_Face( FT_Library library, - FT_Open_Args* args, - FT_Long face_index, - FT_Face *aface ); + FT_Open_Face( FT_Library library, + const FT_Open_Args* args, + FT_Long face_index, + FT_Face *aface ); /*************************************************************************/ @@ -1702,7 +1764,7 @@ FT_BEGIN_HEADER /* */ /* */ /* If your font file is in memory, or if you want to provide your */ - /* own input stream object, use FT_Attach_Stream(). */ + /* own input stream object, use @FT_Attach_Stream. */ /* */ /* The meaning of the `attach' action (i.e., what really happens when */ /* the new file is read) is not fixed by FreeType itself. It really */ @@ -1723,7 +1785,7 @@ FT_BEGIN_HEADER /* FT_Attach_Stream */ /* */ /* */ - /* This function is similar to FT_Attach_File() with the exception */ + /* This function is similar to @FT_Attach_File with the exception */ /* that it reads the attachment from an arbitrary stream. */ /* */ /* */ @@ -1800,7 +1862,7 @@ FT_BEGIN_HEADER /* */ /* */ /* When dealing with fixed-size faces (i.e., non-scalable formats), */ - /* use the function FT_Set_Pixel_Sizes(). */ + /* use the function @FT_Set_Pixel_Sizes. */ /* */ FT_EXPORT( FT_Error ) FT_Set_Char_Size( FT_Face face, @@ -1872,7 +1934,7 @@ FT_BEGIN_HEADER /* glyph_index :: The index of the glyph in the font file. */ /* */ /* load_flags :: A flag indicating what to load for this glyph. The */ - /* FT_LOAD_XXX constants can be used to control the */ + /* @FT_LOAD_XXX constants can be used to control the */ /* glyph loading process (e.g., whether the outline */ /* should be scaled, whether to load bitmaps or not, */ /* whether to hint the outline, etc). */ @@ -1884,15 +1946,15 @@ FT_BEGIN_HEADER /* If the glyph image is not a bitmap, and if the bit flag */ /* FT_LOAD_IGNORE_TRANSFORM is unset, the glyph image will be */ /* transformed with the information passed to a previous call to */ - /* FT_Set_Transform(). */ + /* @FT_Set_Transform. */ /* */ /* Note that this also transforms the `face.glyph.advance' field, but */ /* *not* the values in `face.glyph.metrics'. */ /* */ FT_EXPORT( FT_Error ) - FT_Load_Glyph( FT_Face face, - FT_UInt glyph_index, - FT_Int load_flags ); + FT_Load_Glyph( FT_Face face, + FT_UInt glyph_index, + FT_Int32 load_flags ); /*************************************************************************/ @@ -1913,7 +1975,7 @@ FT_BEGIN_HEADER /* current charmap used in the face. */ /* */ /* load_flags :: A flag indicating what to load for this glyph. The */ - /* FT_LOAD_XXX constants can be used to control the */ + /* @FT_LOAD_XXX constants can be used to control the */ /* glyph loading process (e.g., whether the outline */ /* should be scaled, whether to load bitmaps or not, */ /* whether to hint the outline, etc). */ @@ -1929,7 +1991,7 @@ FT_BEGIN_HEADER /* If the glyph image is not a bitmap, and if the bit flag */ /* FT_LOAD_IGNORE_TRANSFORM is unset, the glyph image will be */ /* transformed with the information passed to a previous call to */ - /* FT_Set_Transform(). */ + /* @FT_Set_Transform. */ /* */ /* Note that this also transforms the `face.glyph.advance' field, but */ /* *not* the values in `face.glyph.metrics'. */ @@ -1937,218 +1999,160 @@ FT_BEGIN_HEADER FT_EXPORT( FT_Error ) FT_Load_Char( FT_Face face, FT_ULong char_code, - FT_Int load_flags ); - - - /*************************************************************************/ - /* */ - /* */ - /* FT_LOAD_NO_SCALE */ - /* */ - /* */ - /* A bit field constant, used with FT_Load_Glyph() to indicate that */ - /* the vector outline being loaded should not be scaled to 26.6 */ - /* fractional pixels, but kept in notional units. */ - /* */ -#define FT_LOAD_NO_SCALE 1 - - - /*************************************************************************/ - /* */ - /* */ - /* FT_LOAD_NO_HINTING */ - /* */ - /* */ - /* A bit-field constant, used with FT_Load_Glyph() to indicate that */ - /* the vector outline being loaded should not be fitted to the pixel */ - /* grid but simply scaled to 26.6 fractional pixels. */ - /* */ - /* This flag is ignored if FT_LOAD_NO_SCALE is set. */ - /* */ -#define FT_LOAD_NO_HINTING 2 - - - /*************************************************************************/ - /* */ - /* */ - /* FT_LOAD_RENDER */ - /* */ - /* */ - /* A bit-field constant, used with FT_Load_Glyph() to indicate that */ - /* the function should load the glyph and immediately convert it into */ - /* a bitmap, if necessary, by calling FT_Render_Glyph(). */ - /* */ - /* Note that by default, FT_Load_Glyph() loads the glyph image in its */ - /* native format. */ - /* */ -#define FT_LOAD_RENDER 4 - - - /*************************************************************************/ - /* */ - /* */ - /* FT_LOAD_NO_BITMAP */ - /* */ - /* */ - /* A bit-field constant, used with FT_Load_Glyph() to indicate that */ - /* the function should not load the bitmap or pixmap of a given */ - /* glyph. This is useful when you do not want to load the embedded */ - /* bitmaps of scalable formats, as the native glyph image will be */ - /* loaded, and can then be rendered through FT_Render_Glyph(). */ - /* */ -#define FT_LOAD_NO_BITMAP 8 - - - /*************************************************************************/ - /* */ - /* */ - /* FT_LOAD_VERTICAL_LAYOUT */ - /* */ - /* */ - /* A bit-field constant, used with FT_Load_Glyph() to indicate that */ - /* the glyph image should be prepared for vertical layout. This */ - /* basically means that `face.glyph.advance' will correspond to the */ - /* vertical advance height (instead of the default horizontal */ - /* advance width), and that the glyph image will translated to match */ - /* the vertical bearings positions. */ - /* */ -#define FT_LOAD_VERTICAL_LAYOUT 16 - - - /*************************************************************************/ - /* */ - /* */ - /* FT_LOAD_FORCE_AUTOHINT */ - /* */ - /* */ - /* A bit-field constant, used with FT_Load_Glyph() to indicate that */ - /* the function should try to auto-hint the glyphs, even if a driver */ - /* specific hinter is available. */ - /* */ -#define FT_LOAD_FORCE_AUTOHINT 32 - - - /*************************************************************************/ - /* */ - /* */ - /* FT_LOAD_CROP_BITMAP */ - /* */ - /* */ - /* A bit-field constant, used with FT_Load_Glyph() to indicate that */ - /* the font driver should try to crop the bitmap (i.e. remove all */ - /* space around its black bits) when loading it. For now, this */ - /* really only works with embedded bitmaps in TrueType fonts. */ - /* */ -#define FT_LOAD_CROP_BITMAP 64 - - - /*************************************************************************/ - /* */ - /* */ - /* FT_LOAD_PEDANTIC */ - /* */ - /* */ - /* A bit-field constant, used with FT_Load_Glyph() to indicate that */ - /* the glyph loader should perform a pedantic bytecode */ - /* interpretation. Many popular fonts come with broken glyph */ - /* programs. When this flag is set, loading them will return an */ - /* error. Otherwise, errors are ignored by the loader, sometimes */ - /* resulting in ugly glyphs. */ - /* */ -#define FT_LOAD_PEDANTIC 128 - - - /*************************************************************************/ - /* */ - /* */ - /* FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH */ - /* */ - /* */ - /* A bit-field constant, used with FT_Load_Glyph() to indicate that */ - /* the glyph loader should ignore the global advance width defined */ - /* in the font. As far as we know, this is only used by the */ - /* X-TrueType font server, in order to deal correctly with the */ - /* incorrect metrics contained in DynaLab's TrueType CJK fonts. */ - /* */ -#define FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH 512 - - - /*************************************************************************/ - /* */ - /* */ - /* FT_LOAD_NO_RECURSE */ - /* */ - /* */ - /* A bit-field constant, used with FT_Load_Glyph() to indicate that */ - /* the glyph loader should not load composite glyph recursively. */ - /* Rather, when a composite glyph is encountered, it should set */ - /* the values of `num_subglyphs' and `subglyphs', as well as set */ - /* `face->glyph.format' to ft_glyph_format_composite. */ - /* */ - /* This is for use by the auto-hinter and possibly other tools. */ - /* For nearly all applications, this flags should be left unset */ - /* when invoking FT_Load_Glyph(). */ - /* */ - /* Note that the flag forces the load of unscaled glyphs. */ - /* */ -#define FT_LOAD_NO_RECURSE 1024 - - - /*************************************************************************/ - /* */ - /* */ - /* FT_LOAD_IGNORE_TRANSFORM */ - /* */ - /* */ - /* A bit-field constant, used with FT_Load_Glyph() to indicate that */ - /* the glyph loader should not try to transform the loaded glyph */ - /* image. */ - /* */ -#define FT_LOAD_IGNORE_TRANSFORM 2048 - - - /*************************************************************************/ - /* */ - /* */ - /* FT_LOAD_MONOCHROME */ - /* */ - /* */ - /* Only used with FT_LOAD_RENDER set, it indicates that the returned */ - /* glyph image should be 1-bit monochrome. This really tells the */ - /* glyph loader to use `ft_render_mode_mono' when calling */ - /* FT_Render_Glyph(). */ - /* */ -#define FT_LOAD_MONOCHROME 4096 + FT_Int32 load_flags ); + + + /**************************************************************************** + * + * @enum: + * FT_LOAD_XXX + * + * @description: + * A list of bit-field constants, used with @FT_Load_Glyph to indicate + * what kind of operations to perform during glyph loading. + * + * @values: + * FT_LOAD_DEFAULT :: + * Corresponding to 0, this value is used a default glyph load. In this + * case, the following will happen: + * + * 1. FreeType looks for a bitmap for the glyph corresponding to the + * face's current size. If one is found, the function returns. The + * bitmap data can be accessed from the glyph slot (see note below). + * + * 2. If no embedded bitmap is searched or found, FreeType looks for a + * scalable outline. If one is found, it is loaded from the font + * file, scaled to device pixels, then "hinted" to the pixel grid in + * order to optimize it. The outline data can be accessed from the + * glyph slot (see note below). + * + * Note that by default, the glyph loader doesn't render outlines into + * bitmaps. The following flags are used to modify this default + * behaviour to more specific and useful cases. + * + * FT_LOAD_NO_SCALE :: + * Don't scale the vector outline being loaded to 26.6 fractional + * pixels, but kept in font units. Note that this also disables + * hinting and the loading of embedded bitmaps. You should only use it + * when you want to retrieve the original glyph outlines in font units. + * + * FT_LOAD_NO_HINTING :: + * Don't hint glyph outlines after their scaling to device pixels. + * This generally generates "blurrier" glyphs in anti-aliased modes. + * + * This flag is ignored if @FT_LOAD_NO_SCALE is set. + * + * FT_LOAD_RENDER :: + * Render the glyph outline immediately into a bitmap before the glyph + * loader returns. By default, the glyph is rendered for the + * @FT_RENDER_MODE_NORMAL mode, which corresponds to 8-bit anti-aliased + * bitmaps using 256 opacity levels. You can use either + * @FT_LOAD_TARGET_MONO or @FT_LOAD_MONOCHROME to render 1-bit + * monochrome bitmaps. + * + * This flag is ignored if @FT_LOAD_NO_SCALE is set. + * + * FT_LOAD_NO_BITMAP :: + * Don't look for bitmaps when loading the glyph. Only scalable + * outlines will be loaded when available, and scaled, hinted, or + * rendered depending on other bit flags. + * + * This does not prevent you from rendering outlines to bitmaps + * with @FT_LOAD_RENDER, however. + * + * FT_LOAD_VERTICAL_LAYOUT :: + * Prepare the glyph image for vertical text layout. This basically + * means that `face.glyph.advance' will correspond to the vertical + * advance height (instead of the default horizontal advance width), + * and that the glyph image will be translated to match the vertical + * bearings positions. + * + * FT_LOAD_FORCE_AUTOHINT :: + * Force the use of the FreeType auto-hinter when a glyph outline is + * loaded. You shouldn't need this in a typical application, since it + * is mostly used to experiment with its algorithm. + * + * FT_LOAD_CROP_BITMAP :: + * Indicates that the glyph loader should try to crop the bitmap (i.e., + * remove all space around its black bits) when loading it. This is + * only useful when loading embedded bitmaps in certain fonts, since + * bitmaps rendered with @FT_LOAD_RENDER are always cropped by default. + * + * FT_LOAD_PEDANTIC :: + * Indicates that the glyph loader should perform pedantic + * verifications during glyph loading, rejecting invalid fonts. This + * is mostly used to detect broken glyphs in fonts. By default, + * FreeType tries to handle broken fonts also. + * + * FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH :: + * Indicates that the glyph loader should ignore the global advance + * width defined in the font. As far as we know, this is only used by + * the X-TrueType font server, in order to deal correctly with the + * incorrect metrics contained in DynaLab's TrueType CJK fonts. + * + * FT_LOAD_NO_RECURSE :: + * This flag is only used internally. It merely indicates that the + * glyph loader should not load composite glyphs recursively. Instead, + * it should set the `num_subglyph' and `subglyphs' values of the glyph + * slot accordingly, and set "glyph->format" to + * @FT_GLYPH_FORMAT_COMPOSITE. + * + * The description of sub-glyphs is not available to client + * applications for now. + * + * FT_LOAD_IGNORE_TRANSFORM :: + * Indicates that the glyph loader should not try to transform the + * loaded glyph image. This doesn't prevent scaling, hinting, or + * rendering. + * + * FT_LOAD_MONOCHROME :: + * This flag is used with @FT_LOAD_RENDER to indicate that you want + * to render a 1-bit monochrome glyph bitmap from a vectorial outline. + * + * Note that this has no effect on the hinting algorithm used by the + * glyph loader. You should better use @FT_LOAD_TARGET_MONO if you + * want to render monochrome-optimized glyph images instead. + * + * FT_LOAD_LINEAR_DESIGN :: + * Return the linearly scaled metrics expressed in original font units + * instead of the default 16.16 pixel values. + * + * FT_LOAD_NO_AUTOHINT :: + * Indicates that the auto-hinter should never be used to hint glyph + * outlines. This doesn't prevent native format-specific hinters from + * being used. This can be important for certain fonts where unhinted + * output is better than auto-hinted one. + */ +#define FT_LOAD_NO_SCALE 0x1 +#define FT_LOAD_NO_HINTING 0x2 +#define FT_LOAD_RENDER 0x4 +#define FT_LOAD_NO_BITMAP 0x8 +#define FT_LOAD_VERTICAL_LAYOUT 0x10 +#define FT_LOAD_FORCE_AUTOHINT 0x20 +#define FT_LOAD_CROP_BITMAP 0x40 +#define FT_LOAD_PEDANTIC 0x80 +#define FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH 0x200 +#define FT_LOAD_NO_RECURSE 0x400 +#define FT_LOAD_IGNORE_TRANSFORM 0x800 +#define FT_LOAD_MONOCHROME 0x1000 +#define FT_LOAD_LINEAR_DESIGN 0x2000 + /* temporary hack! */ +#define FT_LOAD_SBITS_ONLY 0x4000 +#define FT_LOAD_NO_AUTOHINT 0x8000U - /*************************************************************************/ - /* */ - /* */ - /* FT_LOAD_LINEAR_DESIGN */ - /* */ - /* */ - /* A bit-field constant, used with FT_Load_Glyph() to indicate that */ - /* the function should return the linearly scaled metrics expressed */ - /* in original font units, instead of the default 16.16 pixel values. */ - /* */ -#define FT_LOAD_LINEAR_DESIGN 8192 + /* */ - /* temporary hack! */ -#define FT_LOAD_SBITS_ONLY 16384 +#define FT_LOAD_TARGET_( x ) ( (FT_Int32)( (x) & 15 ) << 16 ) +#define FT_LOAD_TARGET_MODE( x ) ( (FT_Render_Mode)( ( (x) >> 16 ) & 15 ) ) +#define FT_LOAD_TARGET_NORMAL FT_LOAD_TARGET_( FT_RENDER_MODE_NORMAL ) +#define FT_LOAD_TARGET_LIGHT FT_LOAD_TARGET_( FT_RENDER_MODE_LIGHT ) +#define FT_LOAD_TARGET_MONO FT_LOAD_TARGET_( FT_RENDER_MODE_MONO ) +#define FT_LOAD_TARGET_LCD FT_LOAD_TARGET_( FT_RENDER_MODE_LCD ) +#define FT_LOAD_TARGET_LCD_V FT_LOAD_TARGET_( FT_RENDER_MODE_LCD_V ) - /*************************************************************************/ - /* */ - /* */ - /* FT_LOAD_DEFAULT */ - /* */ - /* */ - /* A bit-field constant, used with FT_Load_Glyph() to indicate that */ - /* the function should try to load the glyph normally, i.e., */ - /* embedded bitmaps are favored over outlines, vectors are always */ - /* scaled and grid-fitted. */ - /* */ -#define FT_LOAD_DEFAULT 0 +#define FT_LOAD_DEFAULT 0x0 /*************************************************************************/ @@ -2159,7 +2163,7 @@ FT_BEGIN_HEADER /* */ /* A function used to set the transformation that is applied to glyph */ /* images just before they are converted to bitmaps in a glyph slot */ - /* when FT_Render_Glyph() is called. */ + /* when @FT_Render_Glyph is called. */ /* */ /* */ /* face :: A handle to the source face object. */ @@ -2174,7 +2178,7 @@ FT_BEGIN_HEADER /* The transformation is only applied to scalable image formats after */ /* the glyph has been loaded. It means that hinting is unaltered by */ /* the transformation and is performed on the character size given in */ - /* the last call to FT_Set_Char_Sizes() or FT_Set_Pixel_Sizes(). */ + /* the last call to @FT_Set_Char_Sizes or @FT_Set_Pixel_Sizes. */ /* */ FT_EXPORT( void ) FT_Set_Transform( FT_Face face, @@ -2188,35 +2192,76 @@ FT_BEGIN_HEADER /* FT_Render_Mode */ /* */ /* */ - /* An enumeration type that lists the render modes supported by the */ - /* FreeType 2 renderer(s). A renderer is in charge of converting a */ - /* glyph image into a bitmap. */ - /* */ - /* */ - /* ft_render_mode_normal :: This is the default render mode; it */ - /* corresponds to 8-bit anti-aliased */ - /* bitmaps, using 256 levels of gray. */ - /* */ - /* ft_render_mode_mono :: This render mode is used to produce 1-bit */ - /* monochrome bitmaps. */ + /* An enumeration type that lists the render modes supported by */ + /* FreeType 2. Each mode corresponds to a specific type of scanline */ + /* conversion performed on the outline, as well as specific */ + /* hinting optimizations. */ + /* */ + /* */ + /* FT_RENDER_MODE_NORMAL :: */ + /* This is the default render mode; it corresponds to 8-bit */ + /* anti-aliased bitmaps, using 256 levels of opacity. */ + /* */ + /* FT_RENDER_MODE_LIGHT :: */ + /* This is similar to @FT_RENDER_MODE_NORMAL, except that this */ + /* changes the hinting to prevent stem width quantization. This */ + /* results in glyph shapes that are more similar to the original, */ + /* while being a bit more fuzzy ("better shapes", instead of */ + /* "better contrast" if you want :-) THIS IS STILL EXPERIMENTAL, */ + /* FOR NOW, THIS WILL PRODUCE RESULTS SIMILAR TO NORMAL MODE !! */ + /* */ + /* FT_RENDER_MODE_MONO :: */ + /* This mode corresponds to 1-bit bitmaps. */ + /* */ + /* FT_RENDER_MODE_LCD :: */ + /* This mode corresponds to horizontal RGB/BGR sub-pixel displays, */ + /* like LCD-screens. It produces 8-bit bitmaps that are 3 times */ + /* the width of the original glyph outline in pixels, and which use */ + /* the @FT_PIXEL_MODE_LCD mode. THIS IS STILL EXPERIMENTAL, DO NOT */ + /* USE FOR NOW !! */ + /* */ + /* FT_RENDER_MODE_LCD_V :: */ + /* This mode corresponds to vertical RGB/BGR sub-pixel displays */ + /* (like PDA screens, rotated LCD displays, etc.). It produces */ + /* 8-bit bitmaps that are 3 times the height of the original */ + /* glyph outline in pixels and use the @FT_PIXEL_MODE_LCD_V mode. */ /* */ /* */ - /* There is no render mode to produce 8-bit `monochrome' bitmaps -- */ - /* you have to make the conversion yourself if you need such things */ - /* (besides, FreeType is not a graphics library). */ - /* */ - /* More modes might appear later for specific display modes (e.g. TV, */ - /* LCDs, etc.). They will be supported through the simple addition */ - /* of a renderer module, with no changes to the rest of the engine. */ + /* The LCD-optimized glyph bitmaps produced by FT_Render_Glyph are */ + /* _not filtered_ to reduce color-fringes. It is up to the caller to */ + /* perform this pass. THIS IS STILL EXPERIMENTAL, DO NOT USE FOR NOW */ + /* !! */ /* */ typedef enum FT_Render_Mode_ { - ft_render_mode_normal = 0, - ft_render_mode_mono = 1 + FT_RENDER_MODE_NORMAL = 0, + FT_RENDER_MODE_LIGHT, + FT_RENDER_MODE_MONO, + FT_RENDER_MODE_LCD, + FT_RENDER_MODE_LCD_V, + + FT_RENDER_MODE_MAX } FT_Render_Mode; + /*************************************************************************/ + /* */ + /* */ + /* ft_render_mode_xxx */ + /* */ + /* */ + /* These constats are deprecated. Use the corresponding */ + /* @FT_Render_Mode values instead. */ + /* */ + /* */ + /* ft_render_mode_normal :: see @FT_RENDER_MODE_NORMAL */ + /* ft_render_mode_mono :: see @FT_RENDER_MODE_MONO */ + /* */ +#define ft_render_mode_normal FT_RENDER_MODE_NORMAL +#define ft_render_mode_mono FT_RENDER_MODE_MONO + + /*************************************************************************/ /* */ /* */ @@ -2240,8 +2285,8 @@ FT_BEGIN_HEADER /* FreeType error code. 0 means success. */ /* */ FT_EXPORT( FT_Error ) - FT_Render_Glyph( FT_GlyphSlot slot, - FT_UInt render_mode ); + FT_Render_Glyph( FT_GlyphSlot slot, + FT_Render_Mode render_mode ); /*************************************************************************/ @@ -2251,27 +2296,63 @@ FT_BEGIN_HEADER /* */ /* */ /* An enumeration used to specify which kerning values to return in */ - /* FT_Get_Kerning(). */ + /* @FT_Get_Kerning. */ /* */ - /* */ - /* ft_kerning_default :: Return scaled and grid-fitted kerning */ + /* */ + /* FT_KERNING_DEFAULT :: Return scaled and grid-fitted kerning */ /* distances (value is 0). */ /* */ - /* ft_kerning_unfitted :: Return scaled but un-grid-fitted kerning */ + /* FT_KERNING_UNFITTED :: Return scaled but un-grid-fitted kerning */ /* distances. */ /* */ - /* ft_kerning_unscaled :: Return the kerning vector in original font */ + /* FT_KERNING_UNSCALED :: Return the kerning vector in original font */ /* units. */ /* */ typedef enum FT_Kerning_Mode_ { - ft_kerning_default = 0, - ft_kerning_unfitted, - ft_kerning_unscaled + FT_KERNING_DEFAULT = 0, + FT_KERNING_UNFITTED, + FT_KERNING_UNSCALED } FT_Kerning_Mode; + /*************************************************************************/ + /* */ + /* */ + /* ft_kerning_default */ + /* */ + /* */ + /* This constant is deprecated. Please use @FT_KERNING_DEFAULT */ + /* instead. */ + /* */ +#define ft_kerning_default FT_KERNING_DEFAULT + + + /*************************************************************************/ + /* */ + /* */ + /* ft_kerning_unfitted */ + /* */ + /* */ + /* This constant is deprecated. Please use @FT_KERNING_UNFITTED */ + /* instead. */ + /* */ +#define ft_kerning_unfitted FT_KERNING_UNFITTED + + + /*************************************************************************/ + /* */ + /* */ + /* ft_kerning_unscaled */ + /* */ + /* */ + /* This constant is deprecated. Please use @FT_KERNING_UNSCALED */ + /* instead. */ + /* */ +#define ft_kerning_unscaled FT_KERNING_UNSCALED + + /*************************************************************************/ /* */ /* */ @@ -2287,7 +2368,7 @@ FT_BEGIN_HEADER /* */ /* right_glyph :: The index of the right glyph in the kern pair. */ /* */ - /* kern_mode :: See FT_Kerning_Mode() for more information. */ + /* kern_mode :: See @FT_Kerning_Mode for more information. */ /* Determines the scale/dimension of the returned */ /* kerning vector. */ /* */ @@ -2681,7 +2762,7 @@ FT_BEGIN_HEADER /* */ /* The optimization for FT_DivFix() is simple: If (a << 16) fits in */ /* 32 bits, then the division is computed directly. Otherwise, we */ - /* use a specialized version of the old FT_MulDiv64(). */ + /* use a specialized version of the old @FT_MulDiv64. */ /* */ FT_EXPORT( FT_Long ) FT_DivFix( FT_Long a, @@ -2768,6 +2849,7 @@ FT_BEGIN_HEADER /* */ + FT_END_HEADER #endif /* __FREETYPE_H__ */ diff --git a/headers/libs/freetype2/freetype/ftcache.h b/headers/libs/freetype2/freetype/ftcache.h index 97962753e38..82af39142ad 100644 --- a/headers/libs/freetype2/freetype/ftcache.h +++ b/headers/libs/freetype2/freetype/ftcache.h @@ -183,7 +183,11 @@ FT_BEGIN_HEADER (f1)->pix_width == (f2)->pix_width && \ (f1)->pix_height == (f2)->pix_height ) -#define FTC_FACE_ID_HASH( i ) ((FT_UInt32)(FT_Pointer)( i )) +#define FT_POINTER_TO_ULONG( p ) ((FT_ULong)(FT_Pointer)(p)) + +#define FTC_FACE_ID_HASH( i ) \ + ((FT_UInt32)(( FT_POINTER_TO_ULONG( i ) >> 3 ) ^ \ + ( FT_POINTER_TO_ULONG( i ) << 7 ) ) ) #define FTC_FONT_HASH( f ) \ (FT_UInt32)( FTC_FACE_ID_HASH((f)->face_id) ^ \ diff --git a/headers/libs/freetype2/freetype/ftchapters.h b/headers/libs/freetype2/freetype/ftchapters.h index 6c201997a66..c134ec122a1 100644 --- a/headers/libs/freetype2/freetype/ftchapters.h +++ b/headers/libs/freetype2/freetype/ftchapters.h @@ -30,6 +30,7 @@ /* type1_tables */ /* sfnt_names */ /* bdf_fonts */ +/* pfr_fonts */ /* */ /***************************************************************************/ diff --git a/headers/libs/freetype2/freetype/ftglyph.h b/headers/libs/freetype2/freetype/ftglyph.h index abf9a646190..67a698f55aa 100644 --- a/headers/libs/freetype2/freetype/ftglyph.h +++ b/headers/libs/freetype2/freetype/ftglyph.h @@ -145,7 +145,7 @@ FT_BEGIN_HEADER /* */ /* */ /* You can typecast FT_Glyph to FT_BitmapGlyph if you have */ - /* glyph->format == ft_glyph_format_bitmap. This lets you access */ + /* glyph->format == FT_GLYPH_FORMAT_BITMAP. This lets you access */ /* the bitmap's contents easily. */ /* */ /* The corresponding pixel buffer is always owned by the BitmapGlyph */ @@ -189,7 +189,7 @@ FT_BEGIN_HEADER /* */ /* */ /* You can typecast FT_Glyph to FT_OutlineGlyph if you have */ - /* glyph->format == ft_glyph_format_outline. This lets you access */ + /* glyph->format == FT_GLYPH_FORMAT_OUTLINE. This lets you access */ /* the outline's content easily. */ /* */ /* As the outline is extracted from a glyph slot, its coordinates are */ @@ -374,8 +374,8 @@ FT_BEGIN_HEADER /* the_glyph :: A pointer to a handle to the target glyph. */ /* */ /* */ - /* render_mode :: A set of bit flags that describe how the data is */ - /* */ + /* render_mode :: An enumeration that describe how the data is */ + /* rendered. */ /* */ /* origin :: A pointer to a vector used to translate the glyph */ /* image before rendering. Can be 0 (if no */ @@ -411,7 +411,7 @@ FT_BEGIN_HEADER /* error = FT_Get_Glyph( face->glyph, &glyph ); */ /* */ /* // convert to a bitmap (default render mode + destroy old) */ - /* if ( glyph->format != ft_glyph_format_bitmap ) */ + /* if ( glyph->format != FT_GLYPH_FORMAT_BITMAP ) */ /* { */ /* error = FT_Glyph_To_Bitmap( &glyph, ft_render_mode_default, */ /* 0, 1 ); */ @@ -434,10 +434,10 @@ FT_BEGIN_HEADER /* scalable. */ /* */ FT_EXPORT( FT_Error ) - FT_Glyph_To_Bitmap( FT_Glyph* the_glyph, - FT_ULong render_mode, - FT_Vector* origin, - FT_Bool destroy ); + FT_Glyph_To_Bitmap( FT_Glyph* the_glyph, + FT_Render_Mode render_mode, + FT_Vector* origin, + FT_Bool destroy ); /*************************************************************************/ diff --git a/headers/libs/freetype2/freetype/ftimage.h b/headers/libs/freetype2/freetype/ftimage.h index 007e2d17762..fe46bf529bf 100644 --- a/headers/libs/freetype2/freetype/ftimage.h +++ b/headers/libs/freetype2/freetype/ftimage.h @@ -5,7 +5,7 @@ /* FreeType glyph image formats and default raster interface */ /* (specification). */ /* */ -/* Copyright 1996-2001 by */ +/* Copyright 1996-2001, 2002 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -28,7 +28,10 @@ #define __FTIMAGE_H__ +/* _STANDALONE_ is from ftgrays.c */ +#ifndef _STANDALONE_ #include +#endif FT_BEGIN_HEADER @@ -114,57 +117,83 @@ FT_BEGIN_HEADER /* given bitmap. Note that additional formats may be added in the */ /* future. */ /* */ - /* */ - /* ft_pixel_mode_mono :: A monochrome bitmap (1 bit/pixel). */ - /* */ - /* ft_pixel_mode_grays :: An 8-bit gray-levels bitmap. Note that the */ - /* total number of gray levels is given in the */ - /* `num_grays' field of the FT_Bitmap */ - /* structure. */ - /* */ - /* ft_pixel_mode_pal2 :: A 2-bit paletted bitmap. */ - /* Currently unused by FreeType. */ - /* */ - /* ft_pixel_mode_pal4 :: A 4-bit paletted bitmap. */ - /* Currently unused by FreeType. */ + /* */ + /* FT_PIXEL_MODE_NONE :: */ + /* Value 0 is reserved. */ + /* */ + /* FT_PIXEL_MODE_MONO :: */ + /* A monochrome bitmap, using 1 bit per pixel. Note that pixels */ + /* are stored in most-significant order (MSB), which means that */ + /* the left-most pixel in a byte has value 128. */ + /* */ + /* FT_PIXEL_MODE_GRAY :: */ + /* An 8-bit bitmap, generally used to represent anti-aliased glyph */ + /* images. Each pixel is stored in one byte. Note that the number */ + /* of value "gray" levels is stored in the `num_bytes' field of */ + /* the @FT_Bitmap structure (it generally is 256). */ + /* */ + /* FT_PIXEL_MODE_GRAY2 :: */ + /* A 2-bit/pixel bitmap, used to represent embedded anti-aliased */ + /* bitmaps in font files according to the OpenType specification. */ + /* We haven't found a single font using this format, however. */ + /* */ + /* FT_PIXEL_MODE_GRAY4 :: */ + /* A 4-bit/pixel bitmap, used to represent embedded anti-aliased */ + /* bitmaps in font files according to the OpenType specification. */ + /* We haven't found a single font using this format, however. */ + /* */ + /* FT_PIXEL_MODE_LCD :: */ + /* An 8-bit bitmap, used to represent RGB or BGR decimated glyph */ + /* images used for display on LCD displays; the bitmap's width is */ + /* three times wider than the original glyph image. See also */ + /* @FT_RENDER_MODE_LCD. */ + /* */ + /* FT_PIXEL_MODE_LCD_V :: */ + /* An 8-bit bitmap, used to represent RGB or BGR decimated glyph */ + /* images used for display on rotated LCD displays; the bitmap's */ + /* height is three times taller than the original glyph image. */ + /* See also @FT_RENDER_MODE_LCD_V. */ /* */ - /* ft_pixel_mode_pal8 :: An 8-bit paletted bitmap. */ - /* Currently unused by FreeType. */ - /* */ - /* ft_pixel_mode_rgb15 :: A 15-bit RGB bitmap. Uses 5:5:5 encoding. */ - /* Currently unused by FreeType. */ - /* */ - /* ft_pixel_mode_rgb16 :: A 16-bit RGB bitmap. Uses 5:6:5 encoding. */ - /* Currently unused by FreeType. */ + typedef enum FT_Pixel_Mode_ + { + FT_PIXEL_MODE_NONE = 0, + FT_PIXEL_MODE_MONO, + FT_PIXEL_MODE_GRAY, + FT_PIXEL_MODE_GRAY2, + FT_PIXEL_MODE_GRAY4, + FT_PIXEL_MODE_LCD, + FT_PIXEL_MODE_LCD_V, + + FT_PIXEL_MODE_MAX /* do not remove */ + + } FT_Pixel_Mode; + + + /*************************************************************************/ /* */ - /* ft_pixel_mode_rgb24 :: A 24-bit RGB bitmap. */ - /* Currently unused by FreeType. */ + /* */ + /* ft_pixel_mode_xxx */ /* */ - /* ft_pixel_mode_rgb32 :: A 32-bit RGB bitmap. */ - /* Currently unused by FreeType. */ + /* */ + /* A list of deprecated constants. Use the corresponding */ + /* @FT_Pixel_Mode values instead. */ /* */ - /* */ - /* Some anti-aliased bitmaps might be embedded in TrueType fonts */ - /* using formats pal2 or pal4, though no fonts presenting those have */ - /* been found to date. */ + /* */ + /* ft_pixel_mode_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 */ /* */ - typedef enum FT_Pixel_Mode_ - { - ft_pixel_mode_none = 0, - ft_pixel_mode_mono, - ft_pixel_mode_grays, - ft_pixel_mode_pal2, - ft_pixel_mode_pal4, - ft_pixel_mode_pal8, - ft_pixel_mode_rgb15, - ft_pixel_mode_rgb16, - ft_pixel_mode_rgb24, - ft_pixel_mode_rgb32, - - ft_pixel_mode_max /* do not remove */ +#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 - } FT_Pixel_Mode; + /* */ +#if 0 /*************************************************************************/ /* */ @@ -172,6 +201,8 @@ FT_BEGIN_HEADER /* FT_Palette_Mode */ /* */ /* */ + /* THIS TYPE IS DEPRECATED. DO NOT USE IT! */ + /* */ /* An enumeration type used to describe the format of a bitmap */ /* palette, used with ft_pixel_mode_pal4 and ft_pixel_mode_pal8. */ /* */ @@ -195,6 +226,10 @@ FT_BEGIN_HEADER } FT_Palette_Mode; + /* */ + +#endif + /*************************************************************************/ /* */ @@ -223,7 +258,7 @@ FT_BEGIN_HEADER /* most cases. */ /* */ /* num_grays :: This field is only used with */ - /* `ft_pixel_mode_grays'; it gives the number of gray */ + /* `FT_PIXEL_MODE_GRAY'; it gives the number of gray */ /* levels used in the bitmap. */ /* */ /* pixel_mode :: The pixel_mode, i.e., how pixel bits are stored. */ @@ -328,21 +363,23 @@ FT_BEGIN_HEADER /* A simple type used to enumerates the flags in an outline's */ /* `outline_flags' field. */ /* */ - /* */ - /* 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. */ /* `points', `flags' & `contours') are */ /* `owned' by the outline object, and */ /* should thus be freed when it is */ /* destroyed. */ /* */ - /* ft_outline_even_odd_fill :: By default, outlines are filled using */ + /* FT_OUTLINE_EVEN_ODD_FILL :: By default, outlines are filled using */ /* the non-zero winding rule. If set to */ /* 1, the outline will be filled using */ /* the even-odd fill rule (only works */ /* with the smooth raster). */ /* */ - /* ft_outline_reverse_fill :: By default, outside contours of an */ + /* FT_OUTLINE_REVERSE_FILL :: By default, outside contours of an */ /* outline are oriented in clock-wise */ /* direction, as defined in the TrueType */ /* specification. This flag is set if */ @@ -352,14 +389,14 @@ FT_BEGIN_HEADER /* scan-converter. However, it is very */ /* important for the auto-hinter. */ /* */ - /* ft_outline_ignore_dropouts :: By default, the scan converter will */ + /* FT_OUTLINE_IGNORE_DROPOUTS :: By default, the scan converter will */ /* try to detect drop-outs in an outline */ /* and correct the glyph bitmap to */ /* ensure consistent shape continuity. */ /* If set, this flag hints the scan-line */ /* converter to ignore such cases. */ /* */ - /* ft_outline_high_precision :: This flag indicates that the */ + /* FT_OUTLINE_HIGH_PRECISION :: This flag indicates that the */ /* scan-line converter should try to */ /* convert this outline to bitmaps with */ /* the highest possible quality. It is */ @@ -368,7 +405,7 @@ FT_BEGIN_HEADER /* hint, that might be completely */ /* ignored by a given scan-converter. */ /* */ - /* ft_outline_single_pass :: This flag is set to force a given */ + /* FT_OUTLINE_SINGLE_PASS :: This flag is set to force a given */ /* scan-converter to only use a single */ /* pass over the outline to render a */ /* bitmap glyph image. Normally, it is */ @@ -379,35 +416,67 @@ FT_BEGIN_HEADER /* */ typedef enum FT_Outline_Flags_ { - ft_outline_none = 0, - ft_outline_owner = 1, - ft_outline_even_odd_fill = 2, - ft_outline_reverse_fill = 4, - ft_outline_ignore_dropouts = 8, - ft_outline_high_precision = 256, - ft_outline_single_pass = 512 + FT_OUTLINE_NONE = 0, + FT_OUTLINE_OWNER = 1, + FT_OUTLINE_EVEN_ODD_FILL = 2, + FT_OUTLINE_REVERSE_FILL = 4, + FT_OUTLINE_IGNORE_DROPOUTS = 8, + FT_OUTLINE_HIGH_PRECISION = 256, + FT_OUTLINE_SINGLE_PASS = 512 } FT_Outline_Flags; + + /************************************************************************* + * + * @enum: + * ft_outline_xxx + * + * @description: + * These constants are deprecated. Please use the corresponding + * @FT_OUTLINE_XXX values. + * + * @values: + * ft_outline_none :: See @FT_OUTLINE_NONE. + * ft_outline_owner :: See @FT_OUTLINE_OWNER. + * ft_outline_even_odd_fill :: See @FT_OUTLINE_EVEN_ODD_FILL. + * ft_outline_reverse_fill :: See @FT_OUTLINE_REVERSE_FILL. + * ft_outline_ignore_dropouts :: See @FT_OUTLINE_IGNORE_DROPOUTS. + * ft_outline_high_precision :: See @FT_OUTLINE_HIGH_PRECISION. + * ft_outline_single_pass :: See @FT_OUTLINE_SINGLE_PASS. + */ +#define ft_outline_none FT_OUTLINE_NONE +#define ft_outline_owner FT_OUTLINE_OWNER +#define ft_outline_even_odd_fill FT_OUTLINE_EVEN_ODD_FILL +#define ft_outline_reverse_fill FT_OUTLINE_REVERSE_FILL +#define ft_outline_ignore_dropouts FT_OUTLINE_IGNORE_DROPOUTS +#define ft_outline_high_precision FT_OUTLINE_HIGH_PRECISION +#define ft_outline_single_pass FT_OUTLINE_SINGLE_PASS + /* */ #define FT_CURVE_TAG( flag ) ( flag & 3 ) -#define FT_Curve_Tag_On 1 -#define FT_Curve_Tag_Conic 0 -#define FT_Curve_Tag_Cubic 2 +#define FT_CURVE_TAG_ON 1 +#define FT_CURVE_TAG_CONIC 0 +#define FT_CURVE_TAG_CUBIC 2 -#define FT_Curve_Tag_Touch_X 8 /* reserved for the TrueType hinter */ -#define FT_Curve_Tag_Touch_Y 16 /* reserved for the TrueType hinter */ +#define FT_CURVE_TAG_TOUCH_X 8 /* reserved for the TrueType hinter */ +#define FT_CURVE_TAG_TOUCH_Y 16 /* reserved for the TrueType hinter */ -#define FT_Curve_Tag_Touch_Both ( FT_Curve_Tag_Touch_X | \ - FT_Curve_Tag_Touch_Y ) +#define FT_CURVE_TAG_TOUCH_BOTH ( FT_CURVE_TAG_TOUCH_X | \ + FT_CURVE_TAG_TOUCH_Y ) +#define FT_Curve_Tag_On FT_CURVE_TAG_ON +#define FT_Curve_Tag_Conic FT_CURVE_TAG_CONIC +#define FT_Curve_Tag_Cubic FT_CURVE_TAG_CUBIC +#define FT_Curve_Tag_Touch_X FT_CURVE_TAG_TOUCH_X +#define FT_Curve_Tag_Touch_Y FT_CURVE_TAG_TOUCH_Y /*************************************************************************/ /* */ /* */ - /* FT_Outline_MoveTo_Func */ + /* FT_Outline_MoveToFunc */ /* */ /* */ /* A function pointer type used to describe the signature of a `move */ @@ -425,14 +494,15 @@ FT_BEGIN_HEADER /* Error code. 0 means success. */ /* */ typedef int - (*FT_Outline_MoveTo_Func)( FT_Vector* to, - void* user ); + (*FT_Outline_MoveToFunc)( FT_Vector* to, + void* user ); +#define FT_Outline_MoveTo_Func FT_Outline_MoveToFunc /*************************************************************************/ /* */ /* */ - /* FT_Outline_LineTo_Func */ + /* FT_Outline_LineToFunc */ /* */ /* */ /* A function pointer type used to describe the signature of a `line */ @@ -450,14 +520,15 @@ FT_BEGIN_HEADER /* Error code. 0 means success. */ /* */ typedef int - (*FT_Outline_LineTo_Func)( FT_Vector* to, - void* user ); + (*FT_Outline_LineToFunc)( FT_Vector* to, + void* user ); +#define FT_Outline_LineTo_Func FT_Outline_LineToFunc /*************************************************************************/ /* */ /* */ - /* FT_Outline_ConicTo_Func */ + /* FT_Outline_ConicToFunc */ /* */ /* */ /* A function pointer type use to describe the signature of a `conic */ @@ -479,15 +550,16 @@ FT_BEGIN_HEADER /* Error code. 0 means success. */ /* */ typedef int - (*FT_Outline_ConicTo_Func)( FT_Vector* control, - FT_Vector* to, - void* user ); + (*FT_Outline_ConicToFunc)( FT_Vector* control, + FT_Vector* to, + void* user ); +#define FT_Outline_ConicTo_Func FT_Outline_ConicToFunc /*************************************************************************/ /* */ /* */ - /* FT_Outline_CubicTo_Func */ + /* FT_Outline_CubicToFunc */ /* */ /* */ /* A function pointer type used to describe the signature of a `cubic */ @@ -509,10 +581,12 @@ FT_BEGIN_HEADER /* Error code. 0 means success. */ /* */ typedef int - (*FT_Outline_CubicTo_Func)( FT_Vector* control1, - FT_Vector* control2, - FT_Vector* to, - void* user ); + (*FT_Outline_CubicToFunc)( FT_Vector* control1, + FT_Vector* control2, + FT_Vector* to, + void* user ); + +#define FT_Outline_CubicTo_Func FT_Outline_CubicToFunc /*************************************************************************/ @@ -553,13 +627,13 @@ FT_BEGIN_HEADER /* */ typedef struct FT_Outline_Funcs_ { - FT_Outline_MoveTo_Func move_to; - FT_Outline_LineTo_Func line_to; - FT_Outline_ConicTo_Func conic_to; - FT_Outline_CubicTo_Func cubic_to; + FT_Outline_MoveToFunc move_to; + FT_Outline_LineToFunc line_to; + FT_Outline_ConicToFunc conic_to; + FT_Outline_CubicToFunc cubic_to; - int shift; - FT_Pos delta; + int shift; + FT_Pos delta; } FT_Outline_Funcs; @@ -580,6 +654,15 @@ FT_BEGIN_HEADER /* */ /* This macro converts four letter tags into an unsigned long. */ /* */ + /* */ + /* Since many 16bit compilers don't like 32bit enumerations, you */ + /* should redefine this macro in case of problems to something like */ + /* this: */ + /* */ + /* #define FT_IMAGE_TAG( value, _x1, _x2, _x3, _x4 ) (value) */ + /* */ + /* to get a simple enumeration without assigning special numbers. */ + /* */ #ifndef FT_IMAGE_TAG #define FT_IMAGE_TAG( value, _x1, _x2, _x3, _x4 ) \ value = ( ( (unsigned long)_x1 << 24 ) | \ @@ -600,37 +683,68 @@ FT_BEGIN_HEADER /* formats, even though future font drivers will be able to register */ /* their own format. */ /* */ - /* */ - /* ft_glyph_format_composite :: The glyph image is a composite of */ - /* several other images. This glyph */ - /* format is _only_ used with the */ - /* FT_LOAD_FLAG_NO_RECURSE flag (XXX: */ - /* Which is currently unimplemented). */ - /* */ - /* ft_glyph_format_bitmap :: The glyph image is a bitmap, and can */ - /* be described as a FT_Bitmap. */ - /* */ - /* ft_glyph_format_outline :: The glyph image is a vectorial image */ - /* made of bezier control points, and */ - /* can be described as a FT_Outline. */ - /* */ - /* ft_glyph_format_plotter :: The glyph image is a vectorial image */ - /* made of plotter lines (some T1 fonts */ - /* like Hershey contain glyph in this */ - /* format). */ + /* */ + /* FT_GLYPH_FORMAT_NONE :: */ + /* The value 0 is reserved and does describe a glyph format. */ + /* */ + /* FT_GLYPH_FORMAT_COMPOSITE :: */ + /* The glyph image is a composite of several other images. This */ + /* format is _only_ used with @FT_LOAD_FLAG_NO_RECURSE, and is */ + /* used to report compound glyphs (like accented characters). */ + /* */ + /* FT_GLYPH_FORMAT_BITMAP :: */ + /* The glyph image is a bitmap, and can be described as an */ + /* @FT_Bitmap. You generally need to access the `bitmap' field of */ + /* the @FT_GlyphSlotRec structure to read it. */ + /* */ + /* FT_GLYPH_FORMAT_OUTLINE :: */ + /* The glyph image is a vertorial outline made of line segments */ + /* and Bezier arcs; it can be described as an @FT_Outline; you */ + /* generally want to access the `outline' field of the */ + /* @FT_GlyphSlotRec structure to read it. */ + /* */ + /* FT_GLYPH_FORMAT_PLOTTER :: */ + /* The glyph image is a vectorial path with no inside/outside */ + /* contours. Some Type 1 fonts, like those in the Hershey family, */ + /* contain glyphs in this format. These are described as */ + /* @FT_Outline, but FreeType isn't currently capable of rendering */ + /* them correctly. */ /* */ typedef enum FT_Glyph_Format_ { - FT_IMAGE_TAG( ft_glyph_format_none, 0, 0, 0, 0 ), + FT_IMAGE_TAG( FT_GLYPH_FORMAT_NONE, 0, 0, 0, 0 ), - FT_IMAGE_TAG( ft_glyph_format_composite, 'c', 'o', 'm', 'p' ), - FT_IMAGE_TAG( ft_glyph_format_bitmap, 'b', 'i', 't', 's' ), - FT_IMAGE_TAG( ft_glyph_format_outline, 'o', 'u', 't', 'l' ), - FT_IMAGE_TAG( ft_glyph_format_plotter, 'p', 'l', 'o', 't' ) + FT_IMAGE_TAG( FT_GLYPH_FORMAT_COMPOSITE, 'c', 'o', 'm', 'p' ), + FT_IMAGE_TAG( FT_GLYPH_FORMAT_BITMAP, 'b', 'i', 't', 's' ), + FT_IMAGE_TAG( FT_GLYPH_FORMAT_OUTLINE, 'o', 'u', 't', 'l' ), + FT_IMAGE_TAG( FT_GLYPH_FORMAT_PLOTTER, 'p', 'l', 'o', 't' ) } FT_Glyph_Format; + /*************************************************************************/ + /* */ + /* */ + /* ft_glyph_format_xxx */ + /* */ + /* */ + /* A list of decprecated constants. Use the corresponding */ + /* @FT_Glyph_Format values instead. */ + /* */ + /* */ + /* 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 /*************************************************************************/ /* */ /*
*/ - /* Raster */ + /* raster */ /* */ /* */ /* Scanline converter */ @@ -703,7 +817,7 @@ FT_BEGIN_HEADER /* */ /* <Note> */ /* This structure is used by the span drawing callback type named */ - /* FT_Raster_Span_Func(), which takes the y-coordinate of the span as */ + /* FT_SpanFunc which takes the y-coordinate of the span as a */ /* a parameter. */ /* */ /* The coverage value is always between 0 and 255, even if the number */ @@ -721,7 +835,7 @@ FT_BEGIN_HEADER /*************************************************************************/ /* */ /* <FuncType> */ - /* FT_Raster_Span_Func */ + /* FT_SpanFunc */ /* */ /* <Description> */ /* A function used as a call-back by the anti-aliased renderer in */ @@ -755,10 +869,12 @@ FT_BEGIN_HEADER /* only for those scanlines that do have `gray' pixels on them. */ /* */ typedef void - (*FT_Raster_Span_Func)( int y, - int count, - FT_Span* spans, - void* user ); + (*FT_SpanFunc)( int y, + int count, + FT_Span* spans, + void* user ); + +#define FT_Raster_Span_Func FT_SpanFunc /*************************************************************************/ @@ -767,6 +883,8 @@ FT_BEGIN_HEADER /* FT_Raster_BitTest_Func */ /* */ /* <Description> */ + /* THIS TYPE IS DEPRECATED. DO NOT USE IT. */ + /* */ /* A function used as a call-back by the monochrome scan-converter */ /* to test whether a given target pixel is already set to the drawing */ /* `color'. These tests are crucial to implement drop-out control */ @@ -794,6 +912,8 @@ FT_BEGIN_HEADER /* FT_Raster_BitSet_Func */ /* */ /* <Description> */ + /* THIS TYPE IS DEPRECATED. DO NOT USE IT. */ + /* */ /* A function used as a call-back by the monochrome scan-converter */ /* to set an individual target pixel. This is crucial to implement */ /* drop-out control according to the TrueType specification. */ @@ -823,15 +943,15 @@ FT_BEGIN_HEADER /* An enumeration to list the bit flags as used in the `flags' field */ /* of a FT_Raster_Params structure. */ /* */ - /* <Fields> */ - /* ft_raster_flag_default :: This value is 0. */ + /* <Values> */ + /* FT_RASTER_FLAG_DEFAULT :: This value is 0. */ /* */ - /* ft_raster_flag_aa :: This flag is set to indicate that an */ + /* FT_RASTER_FLAG_AA :: This flag is set to indicate that an */ /* anti-aliased glyph image should be */ /* generated. Otherwise, it will be */ /* monochrome (1-bit) */ /* */ - /* ft_raster_flag_direct :: This flag is set to indicate direct */ + /* FT_RASTER_FLAG_DIRECT :: This flag is set to indicate direct */ /* rendering. In this mode, client */ /* applications must provide their own span */ /* callback. This lets them directly */ @@ -843,7 +963,7 @@ FT_BEGIN_HEADER /* Note that for now, direct rendering is */ /* only possible with anti-aliased glyphs. */ /* */ - /* ft_raster_flag_clip :: This flag is only used in direct */ + /* FT_RASTER_FLAG_CLIP :: This flag is only used in direct */ /* rendering mode. If set, the output will */ /* be clipped to a box specified in the */ /* "clip_box" field of the FT_Raster_Params */ @@ -856,13 +976,18 @@ FT_BEGIN_HEADER /* */ typedef enum { - ft_raster_flag_default = 0, - ft_raster_flag_aa = 1, - ft_raster_flag_direct = 2, - ft_raster_flag_clip = 4 + FT_RASTER_FLAG_DEFAULT = 0, + FT_RASTER_FLAG_AA = 1, + FT_RASTER_FLAG_DIRECT = 2, + FT_RASTER_FLAG_CLIP = 4 } FT_Raster_Flag; +#define ft_raster_flag_default FT_RASTER_FLAG_DEFAULT +#define ft_raster_flag_aa FT_RASTER_FLAG_AA +#define ft_raster_flag_direct FT_RASTER_FLAG_DIRECT +#define ft_raster_flag_clip FT_RASTER_FLAG_CLIP + /*************************************************************************/ /* */ @@ -885,9 +1010,9 @@ FT_BEGIN_HEADER /* */ /* black_spans :: The black span drawing callback. */ /* */ - /* bit_test :: The bit test callback. */ + /* bit_test :: The bit test callback. UNIMPLEMENTED! */ /* */ - /* bit_set :: The bit set callback. */ + /* bit_set :: The bit set callback. UNIMPLEMENTED! */ /* */ /* user :: User-supplied data that is passed to each drawing */ /* callback. */ @@ -898,11 +1023,11 @@ FT_BEGIN_HEADER /* 26.6 fixed-point units). */ /* */ /* <Note> */ - /* An anti-aliased glyph bitmap is drawn if the ft_raster_flag_aa bit */ + /* An anti-aliased glyph bitmap is drawn if the FT_RASTER_FLAG_AA bit */ /* flag is set in the `flags' field, otherwise a monochrome bitmap */ /* will be generated. */ /* */ - /* If the ft_raster_flag_direct bit flag is set in `flags', the */ + /* If the FT_RASTER_FLAG_DIRECT bit flag is set in `flags', the */ /* raster will call the `gray_spans' callback to draw gray pixel */ /* spans, in the case of an aa glyph bitmap, it will call */ /* `black_spans', and `bit_test' and `bit_set' in the case of a */ @@ -919,10 +1044,10 @@ FT_BEGIN_HEADER FT_Bitmap* target; void* source; int flags; - FT_Raster_Span_Func gray_spans; - FT_Raster_Span_Func black_spans; - FT_Raster_BitTest_Func bit_test; - FT_Raster_BitSet_Func bit_set; + FT_SpanFunc gray_spans; + FT_SpanFunc black_spans; + FT_Raster_BitTest_Func bit_test; /* doesn't work! */ + FT_Raster_BitSet_Func bit_set; /* doesn't work! */ void* user; FT_BBox clip_box; @@ -932,7 +1057,7 @@ FT_BEGIN_HEADER /*************************************************************************/ /* */ /* <FuncType> */ - /* FT_Raster_New_Func */ + /* FT_Raster_NewFunc */ /* */ /* <Description> */ /* A function used to create a new raster object. */ @@ -954,14 +1079,15 @@ FT_BEGIN_HEADER /* ignored by a given raster implementation. */ /* */ typedef int - (*FT_Raster_New_Func)( void* memory, - FT_Raster* raster ); + (*FT_Raster_NewFunc)( void* memory, + FT_Raster* raster ); +#define FT_Raster_New_Func FT_Raster_NewFunc /*************************************************************************/ /* */ /* <FuncType> */ - /* FT_Raster_Done_Func */ + /* FT_Raster_DoneFunc */ /* */ /* <Description> */ /* A function used to destroy a given raster object. */ @@ -970,13 +1096,14 @@ FT_BEGIN_HEADER /* raster :: A handle to the raster object. */ /* */ typedef void - (*FT_Raster_Done_Func)( FT_Raster raster ); + (*FT_Raster_DoneFunc)( FT_Raster raster ); +#define FT_Raster_Done_Func FT_Raster_DoneFunc /*************************************************************************/ /* */ /* <FuncType> */ - /* FT_Raster_Reset_Func */ + /* FT_Raster_ResetFunc */ /* */ /* <Description> */ /* FreeType provides an area of memory called the `render pool', */ @@ -1001,15 +1128,16 @@ FT_BEGIN_HEADER /* recommended for efficiency purposes. */ /* */ typedef void - (*FT_Raster_Reset_Func)( FT_Raster raster, - unsigned char* pool_base, - unsigned long pool_size ); + (*FT_Raster_ResetFunc)( FT_Raster raster, + unsigned char* pool_base, + unsigned long pool_size ); +#define FT_Raster_Reset_Func FT_Raster_ResetFunc /*************************************************************************/ /* */ /* <FuncType> */ - /* FT_Raster_Set_Mode_Func */ + /* FT_Raster_SetModeFunc */ /* */ /* <Description> */ /* This function is a generic facility to change modes or attributes */ @@ -1025,15 +1153,16 @@ FT_BEGIN_HEADER /* args :: A pointer to the new mode/property to use. */ /* */ typedef int - (*FT_Raster_Set_Mode_Func)( FT_Raster raster, - unsigned long mode, - void* args ); + (*FT_Raster_SetModeFunc)( FT_Raster raster, + unsigned long mode, + void* args ); +#define FT_Raster_Set_Mode_Func FT_Raster_SetModeFunc /*************************************************************************/ /* */ /* <FuncType> */ - /* FT_Raster_Render_Func */ + /* FT_Raster_RenderFunc */ /* */ /* <Description> */ /* Invokes a given raster to scan-convert a given glyph image into a */ @@ -1065,9 +1194,10 @@ FT_BEGIN_HEADER /* composition). */ /* */ typedef int - (*FT_Raster_Render_Func)( FT_Raster raster, - FT_Raster_Params* params ); + (*FT_Raster_RenderFunc)( FT_Raster raster, + FT_Raster_Params* params ); +#define FT_Raster_Render_Func FT_Raster_RenderFunc /*************************************************************************/ /* */ @@ -1090,12 +1220,12 @@ FT_BEGIN_HEADER /* */ typedef struct FT_Raster_Funcs_ { - FT_Glyph_Format glyph_format; - FT_Raster_New_Func raster_new; - FT_Raster_Reset_Func raster_reset; - FT_Raster_Set_Mode_Func raster_set_mode; - FT_Raster_Render_Func raster_render; - FT_Raster_Done_Func raster_done; + FT_Glyph_Format glyph_format; + FT_Raster_NewFunc raster_new; + FT_Raster_ResetFunc raster_reset; + FT_Raster_SetModeFunc raster_set_mode; + FT_Raster_RenderFunc raster_render; + FT_Raster_DoneFunc raster_done; } FT_Raster_Funcs; diff --git a/headers/libs/freetype2/freetype/ftmodule.h b/headers/libs/freetype2/freetype/ftmodule.h index 97718ad4bdc..2ec5a030790 100644 --- a/headers/libs/freetype2/freetype/ftmodule.h +++ b/headers/libs/freetype2/freetype/ftmodule.h @@ -111,7 +111,7 @@ FT_BEGIN_HEADER typedef struct FT_Module_Class_ { FT_ULong module_flags; - FT_Int module_size; + FT_Long module_size; const FT_String* module_name; FT_Fixed module_version; FT_Fixed module_requires; diff --git a/headers/libs/freetype2/freetype/ftoutln.h b/headers/libs/freetype2/freetype/ftoutln.h index 977a122959f..fdf7ed29834 100644 --- a/headers/libs/freetype2/freetype/ftoutln.h +++ b/headers/libs/freetype2/freetype/ftoutln.h @@ -310,7 +310,7 @@ FT_BEGIN_HEADER /* outline :: A pointer to the target outline descriptor. */ /* */ /* <Note> */ - /* This functions toggles the bit flag `ft_outline_reverse_fill' in */ + /* This functions toggles the bit flag `FT_OUTLINE_REVERSE_FILL' in */ /* the outline's `flags' field. */ /* */ /* It shouldn't be used by a normal client application, unless it */ diff --git a/headers/libs/freetype2/freetype/ftrender.h b/headers/libs/freetype2/freetype/ftrender.h index 2a0b12224a6..db3ca94dd7c 100644 --- a/headers/libs/freetype2/freetype/ftrender.h +++ b/headers/libs/freetype2/freetype/ftrender.h @@ -38,65 +38,81 @@ FT_BEGIN_HEADER /* create a new glyph object */ typedef FT_Error - (*FT_Glyph_Init_Func)( FT_Glyph glyph, - FT_GlyphSlot slot ); + (*FT_Glyph_InitFunc)( FT_Glyph glyph, + FT_GlyphSlot slot ); /* destroys a given glyph object */ typedef void - (*FT_Glyph_Done_Func)( FT_Glyph glyph ); + (*FT_Glyph_DoneFunc)( FT_Glyph glyph ); typedef void - (*FT_Glyph_Transform_Func)( FT_Glyph glyph, - FT_Matrix* matrix, - FT_Vector* delta ); + (*FT_Glyph_TransformFunc)( FT_Glyph glyph, + FT_Matrix* matrix, + FT_Vector* delta ); typedef void - (*FT_Glyph_BBox_Func)( FT_Glyph glyph, - FT_BBox* abbox ); + (*FT_Glyph_GetBBoxFunc)( FT_Glyph glyph, + FT_BBox* abbox ); typedef FT_Error - (*FT_Glyph_Copy_Func)( FT_Glyph source, - FT_Glyph target ); + (*FT_Glyph_CopyFunc)( FT_Glyph source, + FT_Glyph target ); typedef FT_Error - (*FT_Glyph_Prepare_Func)( FT_Glyph glyph, - FT_GlyphSlot slot ); + (*FT_Glyph_PrepareFunc)( FT_Glyph glyph, + FT_GlyphSlot slot ); + +/* deprecated */ +#define FT_Glyph_Init_Func FT_Glyph_InitFunc +#define FT_Glyph_Done_Func FT_Glyph_DoneFunc +#define FT_Glyph_Transform_Func FT_Glyph_TransformFunc +#define FT_Glyph_BBox_Func FT_Glyph_GetBBoxFunc +#define FT_Glyph_Copy_Func FT_Glyph_CopyFunc +#define FT_Glyph_Prepare_Func FT_Glyph_PrepareFunc struct FT_Glyph_Class_ { - FT_UInt glyph_size; - FT_Glyph_Format glyph_format; - FT_Glyph_Init_Func glyph_init; - FT_Glyph_Done_Func glyph_done; - FT_Glyph_Copy_Func glyph_copy; - FT_Glyph_Transform_Func glyph_transform; - FT_Glyph_BBox_Func glyph_bbox; - FT_Glyph_Prepare_Func glyph_prepare; + FT_Long glyph_size; + FT_Glyph_Format glyph_format; + FT_Glyph_InitFunc glyph_init; + FT_Glyph_DoneFunc glyph_done; + FT_Glyph_CopyFunc glyph_copy; + FT_Glyph_TransformFunc glyph_transform; + FT_Glyph_GetBBoxFunc glyph_bbox; + FT_Glyph_PrepareFunc glyph_prepare; }; typedef FT_Error - (*FTRenderer_render)( FT_Renderer renderer, - FT_GlyphSlot slot, - FT_UInt mode, - FT_Vector* origin ); + (*FT_Renderer_RenderFunc)( FT_Renderer renderer, + FT_GlyphSlot slot, + FT_UInt mode, + FT_Vector* origin ); typedef FT_Error - (*FTRenderer_transform)( FT_Renderer renderer, - FT_GlyphSlot slot, - FT_Matrix* matrix, - FT_Vector* delta ); + (*FT_Renderer_TransformFunc)( FT_Renderer renderer, + FT_GlyphSlot slot, + FT_Matrix* matrix, + FT_Vector* delta ); + typedef void - (*FTRenderer_getCBox)( FT_Renderer renderer, - FT_GlyphSlot slot, - FT_BBox* cbox ); + (*FT_Renderer_GetCBoxFunc)( FT_Renderer renderer, + FT_GlyphSlot slot, + FT_BBox* cbox ); + typedef FT_Error - (*FTRenderer_setMode)( FT_Renderer renderer, - FT_ULong mode_tag, - FT_Pointer mode_ptr ); + (*FT_Renderer_SetModeFunc)( FT_Renderer renderer, + FT_ULong mode_tag, + FT_Pointer mode_ptr ); + +/* deprecated identifiers */ +#define FTRenderer_render FT_Renderer_RenderFunc +#define FTRenderer_transform FT_Renderer_TransformFunc +#define FTRenderer_getCBox FT_Renderer_GetCBoxFunc +#define FTRenderer_setMode FT_Renderer_SetModeFunc /*************************************************************************/ @@ -117,10 +133,10 @@ FT_BEGIN_HEADER /* */ /* set_mode :: A method used to pass additional parameters. */ /* */ - /* raster_class :: For `ft_glyph_format_outline' renderers only, this */ + /* raster_class :: For `FT_GLYPH_FORMAT_OUTLINE' renderers only, this */ /* is a pointer to its raster's class. */ /* */ - /* raster :: For `ft_glyph_format_outline' renderers only. this */ + /* raster :: For `FT_GLYPH_FORMAT_OUTLINE' renderers only. this */ /* is a pointer to the corresponding raster object, */ /* if any. */ /* */ @@ -130,12 +146,12 @@ FT_BEGIN_HEADER FT_Glyph_Format glyph_format; - FTRenderer_render render_glyph; - FTRenderer_transform transform_glyph; - FTRenderer_getCBox get_glyph_cbox; - FTRenderer_setMode set_mode; + FT_Renderer_RenderFunc render_glyph; + FT_Renderer_TransformFunc transform_glyph; + FT_Renderer_GetCBoxFunc get_glyph_cbox; + FT_Renderer_SetModeFunc set_mode; - FT_Raster_Funcs* raster_class; + FT_Raster_Funcs* raster_class; } FT_Renderer_Class; diff --git a/headers/libs/freetype2/freetype/ftsynth.h b/headers/libs/freetype2/freetype/ftsynth.h index 4c7752ae222..2424ff6273c 100644 --- a/headers/libs/freetype2/freetype/ftsynth.h +++ b/headers/libs/freetype2/freetype/ftsynth.h @@ -48,16 +48,14 @@ FT_BEGIN_HEADER /* This code is completely experimental -- use with care! */ /* It will probably be completely rewritten in the future */ /* or even integrated into the library. */ - FT_EXPORT( FT_Error ) - FT_Outline_Embolden( FT_GlyphSlot original, - FT_Outline* outline, - FT_Pos* advance ); + FT_EXPORT( void ) + FT_GlyphSlot_Embolden( FT_GlyphSlot slot ); - FT_EXPORT( FT_Error ) - FT_Outline_Oblique( FT_GlyphSlot original, - FT_Outline* outline, - FT_Pos* advance ); + FT_EXPORT( void ) + FT_GlyphSlot_Oblique( FT_GlyphSlot slot ); + + /* */ FT_END_HEADER diff --git a/headers/libs/freetype2/freetype/ftsysio.h b/headers/libs/freetype2/freetype/ftsysio.h index f28d0ed0c06..f8e49543f33 100644 --- a/headers/libs/freetype2/freetype/ftsysio.h +++ b/headers/libs/freetype2/freetype/ftsysio.h @@ -1,6 +1,16 @@ #ifndef __FT_SYSTEM_IO_H__ #define __FT_SYSTEM_IO_H__ + /************************************************************************/ + /************************************************************************/ + /***** *****/ + /***** NOTE: THE CONTENT OF THIS FILE IS NOT CURRENTLY USED *****/ + /***** IN NORMAL BUILDS. CONSIDER IT EXPERIMENTAL. *****/ + /***** *****/ + /************************************************************************/ + /************************************************************************/ + + /******************************************************************** * * designing custom streams is a bit different now @@ -35,7 +45,7 @@ FT_BEGIN_HEADER - /******************************************************************** + /*@******************************************************************* * * @type: FT_Stream * @@ -45,7 +55,7 @@ FT_BEGIN_HEADER typedef struct FT_StreamRec_* FT_Stream; - /******************************************************************** + /*@******************************************************************* * * @type: FT_Stream_Class * @@ -56,7 +66,7 @@ FT_BEGIN_HEADER typedef const struct FT_Stream_ClassRec_* FT_Stream_Class; - /******************************************************************** + /*@******************************************************************* * * @functype: FT_Stream_ReadFunc * @@ -76,7 +86,7 @@ FT_BEGIN_HEADER FT_ULong size ); - /******************************************************************** + /*@******************************************************************* * * @functype: FT_Stream_SeekFunc * @@ -93,7 +103,8 @@ FT_BEGIN_HEADER typedef FT_Error (*FT_Stream_SeekFunc)( FT_Stream stream, FT_ULong pos ); - /******************************************************************** + + /*@******************************************************************* * * @struct: FT_Stream_ClassRec * @@ -119,7 +130,7 @@ FT_BEGIN_HEADER #define FT_STREAM_CLASS__READ(x) FT_STREAM_CLASS(x)->stream_read #define FT_STREAM_CLASS__SEEK(x) FT_STREAM_CLASS(x)->stream_seek; - /******************************************************************** + /*@******************************************************************* * * @struct: FT_StreamRec * diff --git a/headers/libs/freetype2/freetype/ftsysmem.h b/headers/libs/freetype2/freetype/ftsysmem.h index 70fe6b5201f..8de0c4db037 100644 --- a/headers/libs/freetype2/freetype/ftsysmem.h +++ b/headers/libs/freetype2/freetype/ftsysmem.h @@ -5,7 +5,17 @@ FT_BEGIN_HEADER - /*********************************************************************** + /************************************************************************/ + /************************************************************************/ + /***** *****/ + /***** NOTE: THE CONTENT OF THIS FILE IS NOT CURRENTLY USED *****/ + /***** IN NORMAL BUILDS. CONSIDER IT EXPERIMENTAL. *****/ + /***** *****/ + /************************************************************************/ + /************************************************************************/ + + + /*@********************************************************************** * * @type: FT_Memory * @@ -20,7 +30,7 @@ FT_BEGIN_HEADER typedef struct FT_MemoryRec_* FT_Memory; - /*********************************************************************** + /*@********************************************************************** * * @functype: FT_Memory_AllocFunc * @@ -39,7 +49,7 @@ FT_BEGIN_HEADER FT_Pointer mem_data ); - /*********************************************************************** + /*@********************************************************************** * * @functype: FT_Memory_FreeFunc * @@ -56,7 +66,7 @@ FT_BEGIN_HEADER FT_Pointer mem_data ); - /*********************************************************************** + /*@********************************************************************** * * @functype: FT_Memory_ReallocFunc * @@ -76,7 +86,7 @@ FT_BEGIN_HEADER FT_Pointer mem_data ); - /*********************************************************************** + /*@********************************************************************** * * @functype: FT_Memory_CreateFunc * @@ -100,7 +110,7 @@ FT_BEGIN_HEADER FT_Pointer *amem_data ); - /*********************************************************************** + /*@********************************************************************** * * @functype: FT_Memory_DestroyFunc * @@ -115,7 +125,7 @@ FT_BEGIN_HEADER FT_Pointer mem_data ); - /*********************************************************************** + /*@********************************************************************** * * @struct: FT_Memory_FuncsRec * @@ -141,7 +151,7 @@ FT_BEGIN_HEADER } FT_Memory_FuncsRec, *FT_Memory_Funcs; - /*********************************************************************** + /*@********************************************************************** * * @type: FT_Memory_Funcs * @@ -152,7 +162,7 @@ FT_BEGIN_HEADER typedef const FT_Memory_FuncsRec* FT_Memory_Funcs; - /*********************************************************************** + /*@********************************************************************** * * @function: ft_memory_new * @@ -172,7 +182,7 @@ FT_BEGIN_HEADER FT_Pointer mem_init_data ); - /*********************************************************************** + /*@********************************************************************** * * @function: ft_memory_destroy * diff --git a/headers/libs/freetype2/freetype/ftsystem.h b/headers/libs/freetype2/freetype/ftsystem.h index 1d22ec155e1..d1c55f7aeab 100644 --- a/headers/libs/freetype2/freetype/ftsystem.h +++ b/headers/libs/freetype2/freetype/ftsystem.h @@ -280,7 +280,7 @@ FT_BEGIN_HEADER /* limit :: This field is set and used internally by FreeType */ /* when parsing frames. */ /* */ - struct FT_StreamRec_ + typedef struct FT_StreamRec_ { unsigned char* base; unsigned long size; @@ -294,7 +294,8 @@ FT_BEGIN_HEADER FT_Memory memory; unsigned char* cursor; unsigned char* limit; - }; + + } FT_StreamRec; /* */ diff --git a/headers/libs/freetype2/freetype/fttrigon.h b/headers/libs/freetype2/freetype/fttrigon.h index 9762189e5d7..3b8257b6d61 100644 --- a/headers/libs/freetype2/freetype/fttrigon.h +++ b/headers/libs/freetype2/freetype/fttrigon.h @@ -173,6 +173,28 @@ FT_BEGIN_HEADER FT_Fixed y ); + /*************************************************************************/ + /* */ + /* @function: */ + /* FT_Angle_Diff */ + /* */ + /* @description: */ + /* Return the difference between two angles. The result is always */ + /* constrained to the ]-PI..PI] interval. */ + /* */ + /* @input: */ + /* angle1 :: First angle. */ + /* */ + /* angle2 :: Second angle. */ + /* */ + /* @return: */ + /* Contrainted value of `value2-value1'. */ + /* */ + FT_EXPORT( FT_Angle ) + FT_Angle_Diff( FT_Angle angle1, + FT_Angle angle2 ); + + /*************************************************************************/ /* */ /* @function: */ @@ -270,6 +292,28 @@ FT_BEGIN_HEADER FT_Vector_Polarize( FT_Vector* vec, FT_Fixed *length, FT_Angle *angle ); + + + /*************************************************************************/ + /* */ + /* @function: */ + /* FT_Vector_From_Polar */ + /* */ + /* @description: */ + /* Compute vector coordinates from a length and angle. */ + /* */ + /* @output: */ + /* vec :: The address of source vector. */ + /* */ + /* @input: */ + /* length :: The vector length. */ + /* angle :: The vector angle. */ + /* */ + FT_EXPORT( void ) + FT_Vector_From_Polar( FT_Vector* vec, + FT_Fixed length, + FT_Angle angle ); + /* */ diff --git a/headers/libs/freetype2/freetype/fttypes.h b/headers/libs/freetype2/freetype/fttypes.h index 757817f5639..2782f74d583 100644 --- a/headers/libs/freetype2/freetype/fttypes.h +++ b/headers/libs/freetype2/freetype/fttypes.h @@ -21,6 +21,7 @@ #include <ft2build.h> +#include FT_CONFIG_CONFIG_H #include FT_SYSTEM_H #include FT_IMAGE_H @@ -43,7 +44,7 @@ FT_BEGIN_HEADER /* */ /* <Description> */ /* 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. */ /* */ /* <Order> */ @@ -356,6 +357,27 @@ FT_BEGIN_HEADER } FT_Matrix; + /*************************************************************************/ + /* */ + /* <Struct> */ + /* FT_Data */ + /* */ + /* <Description> */ + /* Read-only binary data represented as a pointer and a length. */ + /* */ + /* <Fields> */ + /* pointer :: The data. */ + /* */ + /* length :: The length of the data in bytes. */ + /* */ + typedef struct FT_Data_ + { + const FT_Byte* pointer; + FT_Int length; + + } FT_Data; + + /*************************************************************************/ /* */ /* <FuncType> */ @@ -418,6 +440,10 @@ FT_BEGIN_HEADER /* This macro converts four letter tags which are used to label */ /* TrueType tables into an unsigned long to be used within FreeType. */ /* */ + /* <Note> */ + /* The produced values *must* be 32bit integers. Don't redefine this */ + /* macro. */ + /* */ #define FT_MAKE_TAG( _x1, _x2, _x3, _x4 ) \ ( ( (FT_ULong)_x1 << 24 ) | \ ( (FT_ULong)_x2 << 16 ) | \ diff --git a/headers/libs/freetype2/freetype/internal/autohint.h b/headers/libs/freetype2/freetype/internal/autohint.h index cf1568e4519..22340afc3fe 100644 --- a/headers/libs/freetype2/freetype/internal/autohint.h +++ b/headers/libs/freetype2/freetype/internal/autohint.h @@ -176,7 +176,7 @@ FT_BEGIN_HEADER FT_GlyphSlot slot, FT_Size size, FT_UInt glyph_index, - FT_ULong load_flags ); + FT_Int32 load_flags ); /*************************************************************************/ diff --git a/headers/libs/freetype2/freetype/internal/cfftypes.h b/headers/libs/freetype2/freetype/internal/cfftypes.h index ab951091752..82e1e91b4ed 100644 --- a/headers/libs/freetype2/freetype/internal/cfftypes.h +++ b/headers/libs/freetype2/freetype/internal/cfftypes.h @@ -68,8 +68,9 @@ FT_BEGIN_HEADER FT_UInt format; FT_ULong offset; - FT_UShort* sids; - FT_UShort* codes; + FT_UInt count; + FT_UShort sids [256]; /* avoid dynamic allocations */ + FT_UShort codes[256]; } CFF_EncodingRec, *CFF_Encoding; @@ -241,6 +242,9 @@ FT_BEGIN_HEADER /* interface to PostScript hinter */ void* pshinter; + /* interface to Postscript Names service */ + void* psnames; + } CFF_FontRec, *CFF_Font; diff --git a/headers/libs/freetype2/freetype/internal/ftdebug.h b/headers/libs/freetype2/freetype/internal/ftdebug.h index 039b17b5d5c..129c91f6ade 100644 --- a/headers/libs/freetype2/freetype/internal/ftdebug.h +++ b/headers/libs/freetype2/freetype/internal/ftdebug.h @@ -13,6 +13,11 @@ /* this file you indicate that you have read the license and */ /* understand and accept it fully. */ /* */ +/* */ +/* IMPORTANT: A description of FreeType's debugging support can be */ +/* found in "docs/DEBUG.TXT". Read it if you need to use or */ +/* understand this code. */ +/* */ /***************************************************************************/ @@ -47,10 +52,10 @@ FT_BEGIN_HEADER #define FT_TRACE_DEF( x ) trace_ ## x , - /* defining the enumeration */ + /* defining the enumeration */ typedef enum { -#include FT_INTERNAL_TRACE_H +#include FT_INTERNAL_TRACE_H trace_count } FT_Trace; diff --git a/headers/libs/freetype2/freetype/internal/ftdriver.h b/headers/libs/freetype2/freetype/internal/ftdriver.h index 875d0909d2f..9323910b255 100644 --- a/headers/libs/freetype2/freetype/internal/ftdriver.h +++ b/headers/libs/freetype2/freetype/internal/ftdriver.h @@ -68,7 +68,7 @@ FT_BEGIN_HEADER (*FT_Slot_LoadFunc)( FT_GlyphSlot slot, FT_Size size, FT_UInt glyph_index, - FT_Int load_flags ); + FT_Int32 load_flags ); typedef FT_UInt @@ -186,12 +186,10 @@ FT_BEGIN_HEADER FT_Size_ResetPixelsFunc set_pixel_sizes; FT_Slot_LoadFunc load_glyph; - FT_CharMap_CharIndexFunc get_char_index; FT_Face_GetKerningFunc get_kerning; FT_Face_AttachFunc attach_file; FT_Face_GetAdvancesFunc get_advances; - FT_CharMap_CharNextFunc get_next_char; } FT_Driver_ClassRec, *FT_Driver_Class; diff --git a/headers/libs/freetype2/freetype/internal/fthash.h b/headers/libs/freetype2/freetype/internal/fthash.h index 551f9f5dc7d..b95b6c92504 100644 --- a/headers/libs/freetype2/freetype/internal/fthash.h +++ b/headers/libs/freetype2/freetype/internal/fthash.h @@ -59,7 +59,19 @@ FT_BEGIN_HEADER /*********************************************************** * - * @type: FT_Hash_CompareFunc + * @type: FT_HashLookup + * + * @description: + * handle to a @FT_HashNode pointer. This is returned by + * the @ft_hash_lookup function and can later be used by + * @ft_hash_add or @ft_hash_remove + */ + typedef FT_HashNode* FT_HashLookup; + + + /*********************************************************** + * + * @type: FT_Hash_EqualFunc * * @description: * a function used to compare two nodes of the hash table @@ -72,8 +84,8 @@ FT_BEGIN_HEADER * 1 iff the 'keys' in 'node1' and 'node2' are identical. * 0 otherwise. */ - typedef FT_Int (*FT_Hash_CompareFunc)( const FT_HashNode node1, - const FT_HashNode node2 ); + typedef FT_Int (*FT_Hash_EqualFunc)( FT_HashNode node1, + FT_HashNode node2 ); /*********************************************************** @@ -106,18 +118,14 @@ FT_BEGIN_HEADER */ typedef struct FT_HashRec_ { - FT_Memory memory; FT_HashNode* buckets; FT_UInt p; FT_UInt mask; /* really maxp-1 */ - FT_UInt slack; - - - FT_UInt node_size; - FT_Hash_CompareFunc node_compare; - FT_Hash_ComputeFunc node_hash; + FT_Long slack; + FT_Hash_EqualFunc node_equal; + FT_Memory memory; - } FT_HashRec, *FT_Hash; + } FT_HashRec; /*********************************************************** @@ -168,36 +176,39 @@ FT_BEGIN_HEADER * initialize a dynamic hash table * * @input: - * table :: handle to target hash table structure - * compare :: node comparison function - * memory :: memory manager handle used to allocate the - * buckets array within the hash table + * table :: handle to target hash table structure + * node_equal :: node comparison function + * memory :: memory manager handle used to allocate the + * buckets array within the hash table + * + * @return: + * error code. 0 means success * * @note: * the node comparison function should only compare node _keys_ * and ignore values !! with good hashing computation (which the * user must perform itself), the comparison function should be - * pretty selfom called. + * pretty seldom called. * * here is a simple example: * * { - * static int my_compare( const MyNode node1, - * const MyNode node2 ) + * static int my_equal( MyNode node1, + * MyNode node2 ) * { * // compare keys of 'node1' and 'node2' - * return strcmp( node1->key, node2->key ); + * return (strcmp( node1->key, node2->key ) == 0); * } * * .... * - * ft_hash_init( &hash, (FT_Hash_CompareFunc) my_compare, memory ); + * ft_hash_init( &hash, (FT_Hash_EqualFunc) my_compare, memory ); * .... * } */ - FT_BASE( void ) + FT_BASE( FT_Error ) ft_hash_init( FT_Hash table, - FT_Hash_CompareFunc compare, + FT_Hash_EqualFunc compare, FT_Memory memory ); @@ -257,9 +268,9 @@ FT_BEGIN_HEADER * } * } */ - FT_BASE_DEF( FT_HashNode* ) + FT_BASE_DEF( FT_HashLookup ) ft_hash_lookup( FT_Hash table, - FT_HashNode keynode ) + FT_HashNode keynode ); /**************************************************************** @@ -273,10 +284,13 @@ FT_BEGIN_HEADER * * @input: * table :: hash table handle - * pnode :: pointer-to-hash-node value returned by @ft_hash_lookup + * lookup :: pointer-to-hash-node value returned by @ft_hash_lookup * new_node :: handle to new hash node. All its fields must be correctly * set, including 'hash'. * + * @return: + * error code. 0 means success + * * @note: * this function should always be used _after_ a call to @ft_hash_lookup * that returns a pointer to a NULL handle. Here's an example: @@ -308,18 +322,21 @@ FT_BEGIN_HEADER * * // allocate a new node - and set it up * node = (MyNode) malloc( sizeof(*node) ); + * if ( node == NULL ) ..... + * * node->hnode.hash = noderec.hnode.hash; * node->key = key; * node->value = value; * * // add it to the hash table - * ft_hash_add( table, pnode, node ); + * error = ft_hash_add( table, pnode, node ); + * if (error) .... * } */ - FT_BASE( void ) - ft_hash_add( FT_Hash table, - FT_HashNode* pnode, - FT_HashNode new_node ); + FT_BASE( FT_Error ) + ft_hash_add( FT_Hash table, + FT_HashLookup lookup, + FT_HashNode new_node ); /**************************************************************** @@ -332,7 +349,7 @@ FT_BEGIN_HEADER * * @input: * table :: hash table handle - * pnode :: pointer-to-hash-node value returned by @ft_hash_lookup + * lookup :: pointer-to-hash-node value returned by @ft_hash_lookup * * @note: * this function doesn't free the node itself !! Here's an example: @@ -354,15 +371,16 @@ FT_BEGIN_HEADER * node = *pnode; * if ( node != NULL ) * { - * ft_hash_remove( table, pnode ); - * free( node ); + * error = ft_hash_remove( table, pnode ); + * if ( !error ) + * free( node ); * } * } * } */ - FT_BASE( void ) - ft_hash_remove( FT_Hash table, - FT_HashNode* pnode ); + FT_BASE( FT_Error ) + ft_hash_remove( FT_Hash table, + FT_HashLookup lookup ); diff --git a/headers/libs/freetype2/freetype/internal/ftobject.h b/headers/libs/freetype2/freetype/internal/ftobject.h index e1faf545a6d..f285d9e207b 100644 --- a/headers/libs/freetype2/freetype/internal/ftobject.h +++ b/headers/libs/freetype2/freetype/internal/ftobject.h @@ -140,14 +140,11 @@ FT_BEGIN_HEADER * object :: target object handle * init_data :: optional pointer to initialization data * - * @throws: any - * - * the object is _assumed_ to be reachable from the cleanup - * stack when the constructor is called. This means that - * any exception can be thrown safely in it. + * @return: + * error code. 0 means success */ - typedef void (*FT_Object_InitFunc)( FT_Object object, - FT_Pointer init_data ); + typedef FT_Error (*FT_Object_InitFunc)( FT_Object object, + FT_Pointer init_data ); /************************************************************** * @@ -158,8 +155,6 @@ FT_BEGIN_HEADER * * @input: * object :: handle to target object - * - * @throws: *never* !! */ typedef void (*FT_Object_DoneFunc)( FT_Object object ); @@ -179,12 +174,15 @@ FT_BEGIN_HEADER * object sub-system.) * * magic :: a 32-bit magic number used for decoding + * super :: pointer to super class * type :: the @FT_Type descriptor of this class * memory :: the current memory manager handle * library :: the current library handle * info :: an opaque pointer to class-specific information * managed by the FreeType object sub-system * + * class_done :: the class destructor function + * * obj_size :: size of class instances in bytes * obj_init :: class instance constructor * obj_done :: class instance destructor @@ -193,11 +191,14 @@ FT_BEGIN_HEADER { FT_ObjectRec object; FT_UInt32 magic; + FT_Class super; FT_Type type; FT_Memory memory; FT_Library library; FT_Pointer info; + FT_Object_DoneFunc class_done; + FT_UInt obj_size; FT_Object_InitFunc obj_init; FT_Object_DoneFunc obj_done; @@ -287,14 +288,17 @@ FT_BEGIN_HEADER * * @note: * if 'obj_init' is NULL, the class will use it's parent - * constructor. + * constructor, if any * * if 'obj_done' is NULL, the class will use it's parent - * finalizer. + * finalizer, if any * * the object sub-system allocates a new class, copies * the content of its super-class into the new structure, * _then_ calls 'clazz_init'. + * + * 'class_init' and 'class_done' can be NULL, in which case + * the parent's class constructor and destructor wil be used */ typedef struct FT_TypeRec_ { @@ -336,7 +340,7 @@ FT_BEGIN_HEADER * @return: * 1 iff the handle points to a valid object. 0 otherwise */ - FT_BASE_DEF( FT_Int ) + FT_BASE( FT_Int ) ft_object_check( FT_Pointer obj ); @@ -356,88 +360,174 @@ FT_BEGIN_HEADER * 1 iff the handle points to a valid 'clazz' instance. 0 * otherwise. */ - FT_BASE_DEF( FT_Int ) + FT_BASE( FT_Int ) ft_object_is_a( FT_Pointer obj, FT_Class clazz ); /************************************************************** * - * @function: ft_object_new + * @function: ft_object_create * * @description: * create a new object (class instance) * + * @output: + * aobject :: new object handle. NULL in case of error + * * @input: * clazz :: object's class pointer * init_data :: optional pointer to initialization data * * @return: - * handle to new object. Cannot be NULL ! + * error code. 0 means success */ - FT_BASE_DEF( FT_Object ) - ft_object_new( FT_Class clazz, - FT_Pointer init_data ); + FT_BASE( FT_Error ) + ft_object_create( FT_Object *aobject, + FT_Class clazz, + FT_Pointer init_data ); /************************************************************** * - * @function: ft_object_create + * @function: ft_object_create_from_type * * @description: - * a variation of @ft_object_new that should be used when - * creating a new object that is owned by another object - * which is reachable from the cleanup stack. - * - * this function is a bit more akward to use but completely - * avoids push/pop pairs during object construction and is - * therefore faster. + * create a new object (class instance) from a @FT_Type * * @output: - * pobject :: new object handle + * aobject :: new object handle. NULL in case of error * * @input: - * clazz :: object's class pointer + * type :: object's type descriptor * 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 + * + * @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_DEF( void ) - ft_object_create( FT_Object *pobject, - FT_Class clazz, - FT_Pointer init_data ); + FT_BASE( FT_Error ) + ft_object_create_from_type( FT_Object *aobject, + FT_Type type, + FT_Pointer init_data, + FT_Library library ); + + + + /************************************************************** + * + * @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 ) ) + /* */ - FT_BASE_DEF( FT_Class ) - ft_class_find_by_type( FT_Type type, - FT_Memory memory ); + /************************************************************** + * + * @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 ); - FT_BASE_DEF( FT_Class ) - ft_class_find_by_name( FT_CString class_name, - FT_Memory memory ); - FT_BASE_DEF( FT_Object ) - ft_object_new_from_type( FT_Type type, - FT_Pointer data, - FT_Memory memory ); + /* */ - FT_BASE_DEF( void ) - ft_object_create_from_type( FT_Object *pobject, - FT_Type type, - FT_Pointer init_data, - FT_Memory memory ); +#include FT_INTERNAL_HASH_H + + typedef struct FT_ClassHNodeRec_* FT_ClassHNode; - FT_BASE_DEF( void ) - ft_object_push( FT_Object object ); + typedef struct FT_ClassHNodeRec_ + { + FT_HashNodeRec hnode; + FT_Type type; + FT_Class clazz; - FT_BASE_DEF( void ) - ft_object_pop( FT_Object object ); + } 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_BASE_DEF( void ) - ft_object_pop_destroy( FT_Object object ); + } FT_MetaClassRec, *FT_MetaClass; + /* initialize meta class */ + FT_BASE( FT_Error ) + ft_metaclass_init( FT_MetaClass meta, + FT_Library library ); + + /* finalize meta class - destroy all registered class objects */ + FT_BASE( void ) + ft_metaclass_done( FT_MetaClass meta ); + + /* */ + FT_END_HEADER #endif /* __FT_OBJECT_H__ */ diff --git a/headers/libs/freetype2/freetype/internal/ftobjs.h b/headers/libs/freetype2/freetype/internal/ftobjs.h index f92115c6a3a..5ccd5dc087c 100644 --- a/headers/libs/freetype2/freetype/internal/ftobjs.h +++ b/headers/libs/freetype2/freetype/internal/ftobjs.h @@ -34,6 +34,11 @@ #include FT_INTERNAL_GLYPH_LOADER_H #include FT_INTERNAL_DRIVER_H #include FT_INTERNAL_AUTOHINT_H +#include FT_INTERNAL_OBJECT_H + +#ifdef FT_CONFIG_OPTION_INCREMENTAL +#include FT_INCREMENTAL_H +#endif FT_BEGIN_HEADER @@ -291,8 +296,19 @@ FT_BEGIN_HEADER /* transform_flags :: Some flags used to classify the transform. */ /* Only used by the convenience functions. */ /* */ + /* hint_flags :: Some flags used to change the hinters' */ + /* behaviour. Only used for debugging for now. */ + /* */ /* postscript_name :: Postscript font name for this face. */ /* */ + /* incremental_interface :: */ + /* If non-null, the interface through */ + /* which glyph data and metrics are loaded */ + /* incrementally for faces that do not provide */ + /* all of this data when first opened. */ + /* This field exists only if */ + /* @FT_CONFIG_OPTION_INCREMENTAL is defined. */ + /* */ typedef struct FT_Face_InternalRec_ { FT_UShort max_points; @@ -302,8 +318,14 @@ FT_BEGIN_HEADER FT_Vector transform_delta; FT_Int transform_flags; + FT_UInt32 hint_flags; + const char* postscript_name; +#ifdef FT_CONFIG_OPTION_INCREMENTAL + FT_Incremental_InterfaceRec* incremental_interface; +#endif + } FT_Face_InternalRec; @@ -534,14 +556,14 @@ FT_BEGIN_HEADER typedef struct FT_RendererRec_ { - FT_ModuleRec root; - FT_Renderer_Class* clazz; - FT_Glyph_Format glyph_format; - FT_Glyph_Class glyph_class; + FT_ModuleRec root; + FT_Renderer_Class* clazz; + FT_Glyph_Format glyph_format; + FT_Glyph_Class glyph_class; - FT_Raster raster; - FT_Raster_Render_Func raster_render; - FTRenderer_render render; + FT_Raster raster; + FT_Raster_Render_Func raster_render; + FT_Renderer_RenderFunc render; } FT_RendererRec; @@ -656,7 +678,7 @@ FT_BEGIN_HEADER /* shortcut used to avoid parsing the list on */ /* each call to FT_Outline_Render(). It is a */ /* handle to the current renderer for the */ - /* ft_glyph_format_outline format. */ + /* FT_GLYPH_FORMAT_OUTLINE format. */ /* */ /* auto_hinter :: XXX */ /* */ @@ -690,6 +712,8 @@ FT_BEGIN_HEADER FT_DebugHook_Func debug_hooks[4]; + FT_MetaClassRec meta_class; + } FT_LibraryRec; @@ -699,9 +723,9 @@ FT_BEGIN_HEADER FT_ListNode* node ); FT_BASE( FT_Error ) - FT_Render_Glyph_Internal( FT_Library library, - FT_GlyphSlot slot, - FT_UInt render_mode ); + FT_Render_Glyph_Internal( FT_Library library, + FT_GlyphSlot slot, + FT_Render_Mode render_mode ); typedef const char* (*FT_Face_GetPostscriptNameFunc)( FT_Face face ); diff --git a/headers/libs/freetype2/freetype/internal/ftstream.h b/headers/libs/freetype2/freetype/internal/ftstream.h index 1b5e4d1a41d..618f64aacd9 100644 --- a/headers/libs/freetype2/freetype/internal/ftstream.h +++ b/headers/libs/freetype2/freetype/internal/ftstream.h @@ -21,6 +21,7 @@ #include <ft2build.h> +#include FT_SYSTEM_H #include FT_INTERNAL_OBJECTS_H @@ -387,7 +388,7 @@ FT_BEGIN_HEADER FT_BASE( void ) FT_Stream_ReleaseFrame( FT_Stream stream, FT_Byte** pbytes ); - + /* read a byte from an entered frame */ FT_BASE( FT_Char ) FT_Stream_GetChar( FT_Stream stream ); diff --git a/headers/libs/freetype2/freetype/internal/internal.h b/headers/libs/freetype2/freetype/internal/internal.h index cfae9605bea..872f6ac7977 100644 --- a/headers/libs/freetype2/freetype/internal/internal.h +++ b/headers/libs/freetype2/freetype/internal/internal.h @@ -35,6 +35,8 @@ #define FT_INTERNAL_TRACE_H <freetype/internal/fttrace.h> #define FT_INTERNAL_GLYPH_LOADER_H <freetype/internal/ftgloadr.h> #define FT_INTERNAL_SFNT_H <freetype/internal/sfnt.h> +#define FT_INTERNAL_HASH_H <freetype/internal/fthash.h> +#define FT_INTERNAL_OBJECT_H <freetype/internal/ftobject.h> #define FT_INTERNAL_TRUETYPE_TYPES_H <freetype/internal/tttypes.h> #define FT_INTERNAL_TYPE1_TYPES_H <freetype/internal/t1types.h> @@ -42,7 +44,7 @@ #define FT_INTERNAL_CFF_TYPES_H <freetype/internal/cfftypes.h> #define FT_INTERNAL_FNT_TYPES_H <freetype/internal/fnttypes.h> #define FT_INTERNAL_BDF_TYPES_H <freetype/internal/bdftypes.h> -#define FT_INTERNAL_PCF_TYPES_H <freetype/internal/pcftypes.h> +#define FT_INTERNAL_PFR_H <freetype/internal/pfr.h> #define FT_INTERNAL_POSTSCRIPT_NAMES_H <freetype/internal/psnames.h> #define FT_INTERNAL_POSTSCRIPT_AUX_H <freetype/internal/psaux.h> diff --git a/headers/libs/freetype2/freetype/internal/pcftypes.h b/headers/libs/freetype2/freetype/internal/pcftypes.h index 2ad4acef585..2c924d7d1a7 100644 --- a/headers/libs/freetype2/freetype/internal/pcftypes.h +++ b/headers/libs/freetype2/freetype/internal/pcftypes.h @@ -38,10 +38,12 @@ FT_BEGIN_HEADER typedef struct PCF_Public_FaceRec_ { - FT_FaceRec root; + FT_FaceRec root; + FT_StreamRec gzip_stream; + FT_Stream gzip_source; - char* charset_encoding; - char* charset_registry; + char* charset_encoding; + char* charset_registry; } PCF_Public_FaceRec, *PCF_Public_Face; diff --git a/headers/libs/freetype2/freetype/internal/psaux.h b/headers/libs/freetype2/freetype/internal/psaux.h index a2cf527a8ab..e79f83aa4f3 100644 --- a/headers/libs/freetype2/freetype/internal/psaux.h +++ b/headers/libs/freetype2/freetype/internal/psaux.h @@ -142,10 +142,10 @@ FT_BEGIN_HEADER typedef struct PS_ParserRec_* PS_Parser; typedef struct T1_TokenRec_* T1_Token; - + typedef struct T1_FieldRec_* T1_Field; - + /* simple enumeration type used to identify token types */ typedef enum T1_TokenType_ { @@ -178,6 +178,7 @@ FT_BEGIN_HEADER T1_FIELD_TYPE_INTEGER, T1_FIELD_TYPE_FIXED, T1_FIELD_TYPE_STRING, + T1_FIELD_TYPE_BBOX, T1_FIELD_TYPE_INTEGER_ARRAY, T1_FIELD_TYPE_FIXED_ARRAY, T1_FIELD_TYPE_CALLBACK, @@ -194,6 +195,7 @@ FT_BEGIN_HEADER T1_FIELD_LOCATION_FONT_DICT, T1_FIELD_LOCATION_FONT_INFO, T1_FIELD_LOCATION_PRIVATE, + T1_FIELD_LOCATION_BBOX, /* do not remove */ T1_FIELD_LOCATION_MAX @@ -271,6 +273,10 @@ FT_BEGIN_HEADER #define T1_FIELD_STRING( _ident, _fname ) \ T1_NEW_SIMPLE_FIELD( _ident, T1_FIELD_TYPE_STRING, _fname ) +#define T1_FIELD_BBOX( _ident, _fname ) \ + T1_NEW_SIMPLE_FIELD( _ident, T1_FIELD_TYPE_BBOX, _fname ) + + #define T1_FIELD_NUM_TABLE( _ident, _fname, _fmax ) \ T1_NEW_TABLE_FIELD( _ident, T1_FIELD_TYPE_INTEGER_ARRAY, \ _fname, _fmax ) @@ -388,7 +394,7 @@ FT_BEGIN_HEADER FT_Memory memory; PS_Parser_FuncsRec funcs; - + } PS_ParserRec; @@ -544,7 +550,7 @@ FT_BEGIN_HEADER void* hints_globals; /* hinter-specific */ T1_Builder_FuncsRec funcs; - + } T1_BuilderRec; @@ -604,6 +610,7 @@ FT_BEGIN_HEADER FT_Byte** glyph_names, PS_Blend blend, FT_Bool hinting, + FT_Render_Mode hint_mode, T1_Decoder_Callback callback ); void @@ -613,7 +620,7 @@ FT_BEGIN_HEADER (*parse_charstrings)( T1_Decoder decoder, FT_Byte* base, FT_UInt len ); - + } T1_Decoder_FuncsRec; @@ -645,9 +652,12 @@ FT_BEGIN_HEADER PS_Blend blend; /* for multiple master support */ + FT_UInt32 hint_flags; + FT_Render_Mode hint_mode; + T1_Decoder_Callback parse_callback; T1_Decoder_FuncsRec funcs; - + } T1_DecoderRec; @@ -667,9 +677,9 @@ FT_BEGIN_HEADER FT_CMap_Class expert; FT_CMap_Class custom; FT_CMap_Class unicode; - + } T1_CMap_ClassesRec; - + /*************************************************************************/ /*************************************************************************/ diff --git a/headers/libs/freetype2/freetype/internal/pshints.h b/headers/libs/freetype2/freetype/internal/pshints.h index 9b85065b97f..15571d9bc5d 100644 --- a/headers/libs/freetype2/freetype/internal/pshints.h +++ b/headers/libs/freetype2/freetype/internal/pshints.h @@ -261,11 +261,13 @@ FT_BEGIN_HEADER /* been recorded. */ /* */ /* @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: */ /* FreeType error code. 0 means success. */ @@ -278,9 +280,10 @@ FT_BEGIN_HEADER /* which must correspond to the same font as the glyph. */ /* */ typedef FT_Error - (*T1_Hints_ApplyFunc)( T1_Hints hints, - FT_Outline* outline, - PSH_Globals globals ); + (*T1_Hints_ApplyFunc)( T1_Hints hints, + FT_Outline* outline, + PSH_Globals globals, + FT_Render_Mode hint_mode ); /*************************************************************************/ @@ -539,11 +542,13 @@ FT_BEGIN_HEADER /* method. */ /* */ /* @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: */ /* FreeType error code. 0 means success. */ @@ -556,9 +561,10 @@ FT_BEGIN_HEADER /* which must correspond to the same font than the glyph. */ /* */ typedef FT_Error - (*T2_Hints_ApplyFunc)( T2_Hints hints, - FT_Outline* outline, - PSH_Globals globals ); + (*T2_Hints_ApplyFunc)( T2_Hints hints, + FT_Outline* outline, + PSH_Globals globals, + FT_Render_Mode hint_mode ); /*************************************************************************/ diff --git a/headers/libs/freetype2/freetype/internal/psnames.h b/headers/libs/freetype2/freetype/internal/psnames.h index d9f15568199..0f4ec86a839 100644 --- a/headers/libs/freetype2/freetype/internal/psnames.h +++ b/headers/libs/freetype2/freetype/internal/psnames.h @@ -52,7 +52,7 @@ FT_BEGIN_HEADER /* This function will not be compiled if the configuration macro */ /* FT_CONFIG_OPTION_ADOBE_GLYPH_LIST is undefined. */ /* */ - typedef FT_ULong + typedef FT_UInt32 (*PS_Unicode_Value_Func)( const char* glyph_name ); diff --git a/headers/libs/freetype2/freetype/internal/tttypes.h b/headers/libs/freetype2/freetype/internal/tttypes.h index b440aa58a1e..4097ac8f52f 100644 --- a/headers/libs/freetype2/freetype/internal/tttypes.h +++ b/headers/libs/freetype2/freetype/internal/tttypes.h @@ -100,6 +100,8 @@ FT_BEGIN_HEADER FT_UShort entry_selector; FT_UShort range_shift; + FT_ULong offset; /* not in file */ + } SFNT_HeaderRec, *SFNT_Header; @@ -1481,18 +1483,9 @@ FT_BEGIN_HEADER TT_OS2 os2; /* TrueType OS/2 table */ TT_Postscript postscript; /* TrueType Postscript table */ -#ifdef FT_CONFIG_OPTION_USE_CMAPS - FT_Byte* cmap_table; /* extracted 'cmap' table */ FT_ULong cmap_size; -#else /* !FT_CONFIG_OPTION_USE_CMAPS */ - - FT_Int num_charmaps; - TT_CharMap charmaps; /* array of TT_CharMapRec */ - -#endif /* !FT_CONFIG_OPTION_USE_CMAPS */ - TT_Loader_GotoTableFunc goto_table; TT_Loader_StartGlyphFunc access_glyph_frame; @@ -1525,10 +1518,10 @@ FT_BEGIN_HEADER TT_PCLT pclt; /* embedded bitmaps support */ - FT_Int num_sbit_strikes; + FT_ULong num_sbit_strikes; TT_SBit_Strike sbit_strikes; - FT_Int num_sbit_scales; + FT_ULong num_sbit_scales; TT_SBit_Scale sbit_scales; /* postscript names table */ diff --git a/headers/libs/freetype2/freetype/t1tables.h b/headers/libs/freetype2/freetype/t1tables.h index 660ea8a44f0..200ba9be58c 100644 --- a/headers/libs/freetype2/freetype/t1tables.h +++ b/headers/libs/freetype2/freetype/t1tables.h @@ -208,7 +208,7 @@ FT_BEGIN_HEADER #define T1_MAX_MM_DESIGNS 16 /* 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 */ #define T1_MAX_MM_MAP_POINTS 20 @@ -244,6 +244,8 @@ FT_BEGIN_HEADER FT_ULong blend_bitflags; + FT_BBox* bboxes [T1_MAX_MM_DESIGNS + 1]; + } PS_BlendRec, *PS_Blend; diff --git a/headers/libs/freetype2/freetype/ttnameid.h b/headers/libs/freetype2/freetype/ttnameid.h index e0f56b840e5..2111d43fa47 100644 --- a/headers/libs/freetype2/freetype/ttnameid.h +++ b/headers/libs/freetype2/freetype/ttnameid.h @@ -4,7 +4,7 @@ /* */ /* TrueType name ID definitions (specification only). */ /* */ -/* Copyright 1996-2001 by */ +/* Copyright 1996-2002 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -31,34 +31,134 @@ FT_BEGIN_HEADER /* Possible values for the `platform' identifier code in the name */ /* records of the TTF `name' table. */ /* */ + /*************************************************************************/ + + + /*********************************************************************** + * + * @enum: + * TT_PLATFORM_XXX + * + * @description: + * A list of valid values for the `platform_id' identifier code in + * @FT_CharmapRec and @FT_SfntName structures. + * + * @values: + * TT_PLATFORM_APPLE_UNICODE :: + * Used by Apple to indicate a Unicode character map and/or name entry. + * See @TT_APPLE_ID_XXX for corresponding `encoding_id' values. Note + * that name entries in this format are coded as big-endian UCS-2 + * character codes _only_. + * + * TT_PLATFORM_MACINTOSH :: + * Used by Apple to indicate a MacOS-specific charmap and/or name entry. + * See @TT_MAC_ID_XXX for corresponding `encoding_id' values. Note that + * most TrueType fonts contain an Apple roman charmap to be usable on + * MacOS systems (even if they contain a Microsoft charmap as well). + * + * TT_PLATFORM_ISO :: + * This value was used to specify Unicode charmaps. It is however + * now deprecated. See @TT_ISO_ID_XXX for a list of corresponding + * `encoding_id' values. + * + * TT_PLATFORM_MICROSOFT :: + * Used by Microsoft to indicate Windows-specific charmaps. See + * @TT_MS_ID_XXX for a list of corresponding `encoding_id' values. + * Note that most fonts contain a Unicode charmap using + * (@TT_PLATFORM_MICROSOFT, @TT_MS_ID_UNICODE_CS). + * + * TT_PLATFORM_CUSTOM :: + * Used to indicate application-specific charmaps. + * + * TT_PLATFORM_ADOBE :: + * This value isn't part of any font format specification, but is used + * by FreeType to report Adobe-specific charmaps in an @FT_CharMapRec + * structure. See @TT_ADOBE_ID_XXX. + */ + #define TT_PLATFORM_APPLE_UNICODE 0 #define TT_PLATFORM_MACINTOSH 1 #define TT_PLATFORM_ISO 2 /* deprecated */ #define TT_PLATFORM_MICROSOFT 3 #define TT_PLATFORM_CUSTOM 4 +#define TT_PLATFORM_ADOBE 7 /* artificial */ + + + /*********************************************************************** + * + * @enum: + * TT_APPLE_ID_XXX + * + * @description: + * A list of valid values for the `encoding_id' for + * @TT_PLATFORM_APPLE_UNICODE charmaps and name entries. + * + * @values: + * TT_APPLE_ID_DEFAULT :: + * Unicode version 1.0. + * TT_APPLE_ID_UNICODE_1_1 :: + * Unicode 1.1; specifies Hangul characters starting at U+34xx. + * TT_APPLE_ID_ISO_10646 :: + * Deprecated. + * TT_APPLE_ID_UNICODE_2_0 :: + * Unicode 2.0 and beyond (UTF-16 BMP only). + * TT_APPLE_ID_UNICODE_32 :: + * UTF-32 (Adobe proposal for OpenType). + */ - /* artificial values defined ad-hoc by FreeType */ -#define TT_PLATFORM_ADOBE 7 - - - /*************************************************************************/ - /* */ - /* Possible values of the platform specific encoding identifier field in */ - /* the name records of the TTF `name' table if the `platform' identifier */ - /* code is TT_PLATFORM_APPLE_UNICODE. */ - /* */ #define TT_APPLE_ID_DEFAULT 0 /* Unicode 1.0 */ #define TT_APPLE_ID_UNICODE_1_1 1 /* specify Hangul at U+34xx */ #define TT_APPLE_ID_ISO_10646 2 /* deprecated */ #define TT_APPLE_ID_UNICODE_2_0 3 /* or later */ +#define TT_APPLE_ID_UNICODE_32 4 /* Adobe proposal */ + + + /*********************************************************************** + * + * @enum: + * TT_MAC_ID_XXX + * + * @description: + * A list of valid values for the `encoding_id' for + * @TT_PLATFORM_MACINTOSH charmaps and name entries. + * + * @values: + * TT_MAC_ID_ROMAN :: + * TT_MAC_ID_JAPANESE :: + * TT_MAC_ID_TRADITIONAL_CHINESE :: + * TT_MAC_ID_KOREAN :: + * TT_MAC_ID_ARABIC :: + * TT_MAC_ID_HEBREW :: + * TT_MAC_ID_GREEK :: + * TT_MAC_ID_RUSSIAN :: + * TT_MAC_ID_RSYMBOL :: + * TT_MAC_ID_DEVANAGARI :: + * TT_MAC_ID_GURMUKHI :: + * TT_MAC_ID_GUJARATI :: + * TT_MAC_ID_ORIYA :: + * TT_MAC_ID_BENGALI :: + * TT_MAC_ID_TAMIL :: + * TT_MAC_ID_TELUGU :: + * TT_MAC_ID_KANNADA :: + * TT_MAC_ID_MALAYALAM :: + * TT_MAC_ID_SINHALESE :: + * TT_MAC_ID_BURMESE :: + * TT_MAC_ID_KHMER :: + * TT_MAC_ID_THAI :: + * TT_MAC_ID_LAOTIAN :: + * TT_MAC_ID_GEORGIAN :: + * TT_MAC_ID_ARMENIAN :: + * TT_MAC_ID_MALDIVIAN :: + * TT_MAC_ID_SIMPLIFIED_CHINESE :: + * TT_MAC_ID_TIBETAN :: + * TT_MAC_ID_MONGOLIAN :: + * TT_MAC_ID_GEEZ :: + * TT_MAC_ID_SLAVIC :: + * TT_MAC_ID_VIETNAMESE :: + * TT_MAC_ID_SINDHI :: + * TT_MAC_ID_UNINTERP :: + */ - - /*************************************************************************/ - /* */ - /* Possible values of the platform specific encoding identifier field in */ - /* the name records of the TTF `name' table if the `platform' identifier */ - /* code is TT_PLATFORM_MACINTOSH. */ - /* */ #define TT_MAC_ID_ROMAN 0 #define TT_MAC_ID_JAPANESE 1 #define TT_MAC_ID_TRADITIONAL_CHINESE 2 @@ -95,25 +195,72 @@ FT_BEGIN_HEADER #define TT_MAC_ID_UNINTERP 32 - /*************************************************************************/ - /* */ - /* Possible values of the platform specific encoding identifier field in */ - /* the name records of the TTF `name' table if the `platform' identifier */ - /* code is TT_PLATFORM_ISO. */ - /* */ - /* This use is now deprecated. */ - /* */ + /*********************************************************************** + * + * @enum: + * TT_ISO_ID_XXX + * + * @description: + * A list of valid values for the `encoding_id' for + * @TT_PLATFORM_ISO charmaps and name entries. + * + * Their use is now deprecated. + * + * @values: + * TT_ISO_ID_7BIT_ASCII :: + * ASCII. + * TT_ISO_ID_10646 :: + * ISO/10646. + * TT_ISO_ID_8859_1 :: + * Also known as Latin-1. + */ + #define TT_ISO_ID_7BIT_ASCII 0 #define TT_ISO_ID_10646 1 #define TT_ISO_ID_8859_1 2 - /*************************************************************************/ - /* */ - /* possible values of the platform specific encoding identifier field in */ - /* the name records of the TTF `name' table if the `platform' identifier */ - /* code is TT_PLATFORM_MICROSOFT. */ - /* */ + /*********************************************************************** + * + * @enum: + * TT_MS_ID_XXX + * + * @description: + * A list of valid values for the `encoding_id' for + * @TT_PLATFORM_MICROSOFT charmaps and name entries. + * + * @values: + * TT_MS_ID_SYMBOL_CS :: + * Corresponds to symbol encodings. see @FT_ENCODING_MS_SYMBOL. + * + * TT_MS_ID_UNICODE_CS :: + * Corresponds to a Microsoft WGL4 charmap, matching Unicode. See + * @FT_ENCODING_UNICODE. + * + * TT_MS_ID_SJIS :: + * Corresponds to Microsoft SJIS Japanese encoding. + * See @FT_ENCODING_MS_SJIS. + * + * TT_MS_ID_GB2312 :: + * Corresponds to Microsoft Simplified Chinese as used in Mainland + * China. See @FT_ENCODING_MS_GB2312. + * + * TT_MS_ID_BIG_5 :: + * Corresponds to Microsoft Traditional Chinese as used in Taiwan and + * Hong Kong. See @FT_ENCODING_MS_BIG5. + * + * TT_MS_ID_WANSUNG :: + * Corresponds to Microsoft Korean Wansung encoding. See + * @FT_ENCODING_MS_WANSUNG. + * + * TT_MS_ID_JOHAB :: + * Corresponds to Microsoft Johab encoding. See @FT_ENCODING_MS_JOHAB. + * + * TT_MS_ID_UCS_4 :: + * Corresponds to UCS-4 or UTF-32 charmaps. This is a recent Adobe + * proposal for OpenType. + */ + #define TT_MS_ID_SYMBOL_CS 0 #define TT_MS_ID_UNICODE_CS 1 #define TT_MS_ID_SJIS 2 @@ -124,14 +271,24 @@ FT_BEGIN_HEADER #define TT_MS_ID_UCS_4 10 - /*************************************************************************/ - /* */ - /* possible values of the platform specific encoding identifier field in */ - /* the name records of the TTF `name' table if the `platform' identifier */ - /* code is TT_PLATFORM_ADOBE. */ - /* */ - /* These are artificial values defined ad-hoc by FreeType. */ - /* */ + /*********************************************************************** + * + * @enum: + * TT_ADOBE_ID_XXX + * + * @description: + * A list of valid values for the `encoding_id' for + * @TT_PLATFORM_ADOBE charmaps. This is a FreeType-specific extension! + * + * @values: + * TT_ADOBE_ID_STANDARD :: + * Adobe standard encoding. + * TT_ADOBE_ID_EXPERT :: + * Adobe expert encoding. + * TT_ADOBE_ID_CUSTOM :: + * Adobe custom encoding. + */ + #define TT_ADOBE_ID_STANDARD 0 #define TT_ADOBE_ID_EXPERT 1 #define TT_ADOBE_ID_CUSTOM 2 @@ -545,7 +702,7 @@ FT_BEGIN_HEADER /* sublanguage > 0x1F. */ #define TT_MS_LANGID_SPANISH_LATIN_AMERICA 0xE40a #define TT_MS_LANGID_FRENCH_NORTH_AFRICA 0xE40c - + #define TT_MS_LANGID_FRENCH_MOROCCO 0x380c #define TT_MS_LANGID_FRENCH_HAITI 0x3c0c #define TT_MS_LANGID_BENGALI_BANGLADESH 0x0845 diff --git a/src/libs/freetype2/autohint/ahangles.c b/src/libs/freetype2/autohint/ahangles.c index 1a13b2771f2..ef5a88ee66f 100644 --- a/src/libs/freetype2/autohint/ahangles.c +++ b/src/libs/freetype2/autohint/ahangles.c @@ -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 */ diff --git a/src/libs/freetype2/autohint/ahangles.h b/src/libs/freetype2/autohint/ahangles.h index d509e003968..f46bfaad780 100644 --- a/src/libs/freetype2/autohint/ahangles.h +++ b/src/libs/freetype2/autohint/ahangles.h @@ -51,6 +51,11 @@ FT_BEGIN_HEADER ah_angle( FT_Vector* v ); + FT_LOCAL( AH_Angle ) + ah_angle_diff( AH_Angle angle1, + AH_Angle angle2 ); + + FT_END_HEADER #endif /* __AHANGLES_H__ */ diff --git a/src/libs/freetype2/autohint/ahglobal.c b/src/libs/freetype2/autohint/ahglobal.c index 93bb91a2068..2ce8ac35c34 100644 --- a/src/libs/freetype2/autohint/ahglobal.c +++ b/src/libs/freetype2/autohint/ahglobal.c @@ -28,7 +28,7 @@ #define MAX_TEST_CHARACTERS 12 static - const char* blue_chars[ah_blue_max] = + const char* blue_chars[AH_BLUE_MAX] = { "THEZOCQS", "HEZLOCUS", @@ -43,7 +43,8 @@ sort_values( FT_Int count, FT_Pos* table ) { - FT_Int i, j, swap; + FT_Int i, j; + FT_Pos swap; for ( i = 1; i < count; i++ ) @@ -62,10 +63,10 @@ static FT_Error - ah_hinter_compute_blues( AH_Hinter* hinter ) + ah_hinter_compute_blues( AH_Hinter hinter ) { AH_Blue blue; - AH_Globals* globals = &hinter->globals->design; + AH_Globals globals = &hinter->globals->design; FT_Pos flats [MAX_TEST_CHARACTERS]; FT_Pos rounds[MAX_TEST_CHARACTERS]; FT_Int num_flats; @@ -84,7 +85,7 @@ charmap = face->charmap; /* do we have a Unicode charmap in there? */ - error = FT_Select_Charmap( face, ft_encoding_unicode ); + error = FT_Select_Charmap( face, FT_ENCODING_UNICODE ); if ( error ) goto Exit; @@ -95,7 +96,7 @@ AH_LOG(( "blue zones computation\n" )); AH_LOG(( "------------------------------------------------\n" )); - for ( blue = ah_blue_capital_top; blue < ah_blue_max; blue++ ) + for ( blue = AH_BLUE_CAPITAL_TOP; blue < AH_BLUE_MAX; blue++ ) { const char* p = blue_chars[blue]; const char* limit = p + MAX_TEST_CHARACTERS; @@ -216,8 +217,8 @@ /* now, set the `round' flag depending on the segment's kind */ round = FT_BOOL( - FT_CURVE_TAG( glyph->outline.tags[prev] ) != FT_Curve_Tag_On || - FT_CURVE_TAG( glyph->outline.tags[next] ) != FT_Curve_Tag_On ); + FT_CURVE_TAG( glyph->outline.tags[prev] ) != FT_CURVE_TAG_ON || + FT_CURVE_TAG( glyph->outline.tags[next] ) != FT_CURVE_TAG_ON ); AH_LOG(( "%c ", round ? 'r' : 'f' )); } @@ -286,18 +287,18 @@ static FT_Error - ah_hinter_compute_widths( AH_Hinter* hinter ) + ah_hinter_compute_widths( AH_Hinter hinter ) { /* scan the array of segments in each direction */ - AH_Outline* outline = hinter->glyph; - AH_Segment* segments; - AH_Segment* limit; - AH_Globals* globals = &hinter->globals->design; - FT_Pos* widths; - FT_Int dimension; - FT_Int* p_num_widths; - FT_Error error = 0; - FT_Pos edge_distance_threshold = 32000; + AH_Outline outline = hinter->glyph; + AH_Segment segments; + AH_Segment limit; + AH_Globals globals = &hinter->globals->design; + FT_Pos* widths; + FT_Int dimension; + FT_Int* p_num_widths; + FT_Error error = 0; + FT_Pos edge_distance_threshold = 32000; globals->num_widths = 0; @@ -334,9 +335,9 @@ for ( dimension = 1; dimension >= 0; dimension-- ) { - AH_Segment* seg = segments; - AH_Segment* link; - FT_Int num_widths = 0; + AH_Segment seg = segments; + AH_Segment link; + FT_Int num_widths = 0; for ( ; seg < limit; seg++ ) @@ -345,14 +346,14 @@ /* we only consider stem segments there! */ if ( link && link->link == seg && link > seg ) { - FT_Int dist; + FT_Pos dist; dist = seg->pos - link->pos; if ( dist < 0 ) dist = -dist; - if ( num_widths < 12 ) + if ( num_widths < AH_MAX_WIDTHS ) widths[num_widths++] = dist; } } @@ -368,7 +369,6 @@ limit = segments + outline->num_vsegments; widths = globals->widths; p_num_widths = &globals->num_widths; - } /* Now, compute the edge distance threshold as a fraction of the */ @@ -385,7 +385,7 @@ FT_LOCAL_DEF( FT_Error ) - ah_hinter_compute_globals( AH_Hinter* hinter ) + ah_hinter_compute_globals( AH_Hinter hinter ) { return ah_hinter_compute_widths( hinter ) || ah_hinter_compute_blues ( hinter ); diff --git a/src/libs/freetype2/autohint/ahglobal.h b/src/libs/freetype2/autohint/ahglobal.h index 6dbd7110571..9d557b92c94 100644 --- a/src/libs/freetype2/autohint/ahglobal.h +++ b/src/libs/freetype2/autohint/ahglobal.h @@ -32,13 +32,13 @@ FT_BEGIN_HEADER -#define AH_IS_TOP_BLUE( b ) ( (b) == ah_blue_capital_top || \ - (b) == ah_blue_small_top ) +#define AH_IS_TOP_BLUE( b ) ( (b) == AH_BLUE_CAPITAL_TOP || \ + (b) == AH_BLUE_SMALL_TOP ) /* compute global metrics automatically */ FT_LOCAL( FT_Error ) - ah_hinter_compute_globals( AH_Hinter* hinter ); + ah_hinter_compute_globals( AH_Hinter hinter ); FT_END_HEADER diff --git a/src/libs/freetype2/autohint/ahglyph.c b/src/libs/freetype2/autohint/ahglyph.c index 2fd219e3244..ee628be3bcf 100644 --- a/src/libs/freetype2/autohint/ahglyph.c +++ b/src/libs/freetype2/autohint/ahglyph.c @@ -32,12 +32,12 @@ #include <stdio.h> void - ah_dump_edges( AH_Outline* outline ) + ah_dump_edges( AH_Outline outline ) { - AH_Edge* edges; - AH_Edge* edge_limit; - AH_Segment* segments; - FT_Int dimension; + AH_Edge edges; + AH_Edge edge_limit; + AH_Segment segments; + FT_Int dimension; edges = outline->horz_edges; @@ -46,7 +46,7 @@ for ( dimension = 1; dimension >= 0; dimension-- ) { - AH_Edge* edge; + AH_Edge edge; printf ( "Table of %s edges:\n", @@ -59,13 +59,13 @@ printf ( " [ %5d | %4d | %5s | %4d | %5d | %c | %5.2f | %5.2f ]\n", edge - edges, (int)edge->fpos, - edge->dir == ah_dir_up + edge->dir == AH_DIR_UP ? "up" - : ( edge->dir == ah_dir_down + : ( edge->dir == AH_DIR_DOWN ? "down" - : ( edge->dir == ah_dir_left + : ( edge->dir == AH_DIR_LEFT ? "left" - : ( edge->dir == ah_dir_right + : ( edge->dir == AH_DIR_RIGHT ? "right" : "none" ) ) ), edge->link ? ( edge->link - edges ) : -1, @@ -84,12 +84,12 @@ /* A function used to dump the array of linked segments */ void - ah_dump_segments( AH_Outline* outline ) + ah_dump_segments( AH_Outline outline ) { - AH_Segment* segments; - AH_Segment* segment_limit; - AH_Point* points; - FT_Int dimension; + AH_Segment segments; + AH_Segment segment_limit; + AH_Point points; + FT_Int dimension; points = outline->points; @@ -98,7 +98,7 @@ for ( dimension = 1; dimension >= 0; dimension-- ) { - AH_Segment* seg; + AH_Segment seg; printf ( "Table of %s segments:\n", @@ -111,13 +111,13 @@ printf ( " [ %5d | %4d | %5s | %4d | %5d | %4d | %5d | %5d ]\n", seg - segments, (int)seg->pos, - seg->dir == ah_dir_up + seg->dir == AH_DIR_UP ? "up" - : ( seg->dir == ah_dir_down + : ( seg->dir == AH_DIR_DOWN ? "down" - : ( seg->dir == ah_dir_left + : ( seg->dir == AH_DIR_LEFT ? "left" - : ( seg->dir == ah_dir_right + : ( seg->dir == AH_DIR_RIGHT ? "right" : "none" ) ) ), seg->link ? (seg->link-segments) : -1, @@ -145,17 +145,17 @@ FT_Pos ay = ABS( dy ); - dir = ah_dir_none; + dir = AH_DIR_NONE; /* test for vertical direction */ if ( ax * 12 < ay ) { - dir = dy > 0 ? ah_dir_up : ah_dir_down; + dir = dy > 0 ? AH_DIR_UP : AH_DIR_DOWN; } /* test for horizontal direction */ else if ( ay * 12 < ax ) { - dir = dx > 0 ? ah_dir_right : ah_dir_left; + dir = dx > 0 ? AH_DIR_RIGHT : AH_DIR_LEFT; } return dir; @@ -164,13 +164,14 @@ /* this function is used by ah_get_orientation (see below) to test */ /* the fill direction of a given bbox extrema */ - static int + static FT_Int ah_test_extrema( FT_Outline* outline, - int n ) + FT_Int n ) { FT_Vector *prev, *cur, *next; FT_Pos product; FT_Int first, last, c; + FT_Int retval; /* we need to compute the `previous' and `next' point */ @@ -201,15 +202,16 @@ next->x - cur->x, /* out.x */ 0x40 ); + retval = 0; if ( product ) - product = product > 0 ? 2 : 1; + retval = product > 0 ? 2 : 1; - return product; + return retval; } /* Compute the orientation of path filling. It differs between TrueType */ - /* and Type1 formats. We could use the `ft_outline_reverse_fill' flag, */ + /* and Type1 formats. We could use the `FT_OUTLINE_REVERSE_FILL' flag, */ /* but it is better to re-compute it directly (it seems that this flag */ /* isn't correctly set for some weird composite glyphs currently). */ /* */ @@ -218,18 +220,18 @@ /* */ /* The function returns either 1 or -1. */ /* */ - static int + static FT_Int ah_get_orientation( FT_Outline* outline ) { FT_BBox box; - FT_BBox indices; - int n, last; + FT_Int indices_xMin, indices_yMin, indices_xMax, indices_yMax; + FT_Int n, last; - indices.xMin = -1; - indices.yMin = -1; - indices.xMax = -1; - indices.yMax = -1; + indices_xMin = -1; + indices_yMin = -1; + indices_xMax = -1; + indices_yMax = -1; box.xMin = box.yMin = 32767L; box.xMax = box.yMax = -32768L; @@ -249,41 +251,41 @@ if ( x < box.xMin ) { box.xMin = x; - indices.xMin = n; + indices_xMin = n; } if ( x > box.xMax ) { box.xMax = x; - indices.xMax = n; + indices_xMax = n; } y = outline->points[n].y; if ( y < box.yMin ) { box.yMin = y; - indices.yMin = n; + indices_yMin = n; } if ( y > box.yMax ) { box.yMax = y; - indices.yMax = n; + indices_yMax = n; } } /* test orientation of the xmin */ - n = ah_test_extrema( outline, indices.xMin ); + n = ah_test_extrema( outline, indices_xMin ); if ( n ) goto Exit; - n = ah_test_extrema( outline, indices.yMin ); + n = ah_test_extrema( outline, indices_yMin ); if ( n ) goto Exit; - n = ah_test_extrema( outline, indices.xMax ); + n = ah_test_extrema( outline, indices_xMax ); if ( n ) goto Exit; - n = ah_test_extrema( outline, indices.yMax ); + n = ah_test_extrema( outline, indices_yMax ); if ( !n ) n = 1; @@ -298,14 +300,14 @@ /* ah_outline_new */ /* */ /* <Description> */ - /* Creates a new and empty AH_Outline object. */ + /* Creates a new and empty AH_OutlineRec object. */ /* */ FT_LOCAL_DEF( FT_Error ) - ah_outline_new( FT_Memory memory, - AH_Outline** aoutline ) + ah_outline_new( FT_Memory memory, + AH_Outline* aoutline ) { FT_Error error; - AH_Outline* outline; + AH_Outline outline; if ( !FT_NEW( outline ) ) @@ -324,10 +326,10 @@ /* ah_outline_done */ /* */ /* <Description> */ - /* Destroys a given AH_Outline object. */ + /* Destroys a given AH_OutlineRec object. */ /* */ FT_LOCAL_DEF( void ) - ah_outline_done( AH_Outline* outline ) + ah_outline_done( AH_Outline outline ) { FT_Memory memory = outline->memory; @@ -347,15 +349,15 @@ /* ah_outline_save */ /* */ /* <Description> */ - /* Saves the content of a given AH_Outline object into a face's glyph */ - /* slot. */ + /* Saves the contents of a given AH_OutlineRec object into a face's */ + /* glyph slot. */ /* */ FT_LOCAL_DEF( void ) - ah_outline_save( AH_Outline* outline, - AH_Loader gloader ) + ah_outline_save( AH_Outline outline, + AH_Loader gloader ) { - AH_Point* point = outline->points; - AH_Point* point_limit = point + outline->num_points; + AH_Point point = outline->points; + AH_Point point_limit = point + outline->num_points; FT_Vector* vec = gloader->current.outline.points; char* tag = gloader->current.outline.tags; @@ -366,12 +368,12 @@ vec->x = point->x; vec->y = point->y; - if ( point->flags & ah_flag_conic ) - tag[0] = FT_Curve_Tag_Conic; - else if ( point->flags & ah_flag_cubic ) - tag[0] = FT_Curve_Tag_Cubic; + if ( point->flags & AH_FLAG_CONIC ) + tag[0] = FT_CURVE_TAG_CONIC; + else if ( point->flags & AH_FLAG_CUBIC ) + tag[0] = FT_CURVE_TAG_CUBIC; else - tag[0] = FT_Curve_Tag_On; + tag[0] = FT_CURVE_TAG_ON; } } @@ -382,25 +384,25 @@ /* ah_outline_load */ /* */ /* <Description> */ - /* Loads an unscaled outline from a glyph slot into an AH_Outline */ + /* Loads an unscaled outline from a glyph slot into an AH_OutlineRec */ /* object. */ /* */ FT_LOCAL_DEF( FT_Error ) - ah_outline_load( AH_Outline* outline, - FT_Face face ) + ah_outline_load( AH_Outline outline, + FT_Face face ) { - FT_Memory memory = outline->memory; - FT_Error error = AH_Err_Ok; - FT_Outline* source = &face->glyph->outline; - FT_Int num_points = source->n_points; - FT_Int num_contours = source->n_contours; - AH_Point* points; + FT_Memory memory = outline->memory; + FT_Error error = AH_Err_Ok; + FT_Outline* source = &face->glyph->outline; + FT_Int num_points = source->n_points; + FT_Int num_contours = source->n_contours; + AH_Point points; /* check arguments */ if ( !face || !face->size || - face->glyph->format != ft_glyph_format_outline ) + face->glyph->format != FT_GLYPH_FORMAT_OUTLINE ) return AH_Err_Invalid_Argument; /* first of all, reallocate the contours array if necessary */ @@ -450,13 +452,13 @@ /* direction used for a glyph, given that some fonts are broken (e.g. */ /* the Arphic ones). We thus recompute it each time we need to. */ /* */ - outline->vert_major_dir = ah_dir_up; - outline->horz_major_dir = ah_dir_left; + outline->vert_major_dir = AH_DIR_UP; + outline->horz_major_dir = AH_DIR_LEFT; if ( ah_get_orientation( source ) > 1 ) { - outline->vert_major_dir = ah_dir_down; - outline->horz_major_dir = ah_dir_right; + outline->vert_major_dir = AH_DIR_DOWN; + outline->horz_major_dir = AH_DIR_RIGHT; } outline->x_scale = face->size->metrics.x_scale; @@ -469,8 +471,8 @@ { /* do one thing at a time -- it is easier to understand, and */ /* the code is clearer */ - AH_Point* point; - AH_Point* point_limit = points + outline->num_points; + AH_Point point; + AH_Point point_limit = points + outline->num_points; /* compute coordinates */ @@ -500,10 +502,10 @@ { switch ( FT_CURVE_TAG( *tag ) ) { - case FT_Curve_Tag_Conic: - point->flags = ah_flag_conic; break; - case FT_Curve_Tag_Cubic: - point->flags = ah_flag_cubic; break; + case FT_CURVE_TAG_CONIC: + point->flags = AH_FLAG_CONIC; break; + case FT_CURVE_TAG_CUBIC: + point->flags = AH_FLAG_CUBIC; break; default: ; } @@ -512,10 +514,10 @@ /* compute `next' and `prev' */ { - FT_Int contour_index; - AH_Point* prev; - AH_Point* first; - AH_Point* end; + FT_Int contour_index; + AH_Point prev; + AH_Point first; + AH_Point end; contour_index = 0; @@ -548,10 +550,10 @@ /* set-up the contours array */ { - AH_Point** contour = outline->contours; - AH_Point** contour_limit = contour + outline->num_contours; - short* end = source->contours; - short idx = 0; + AH_Point* contour = outline->contours; + AH_Point* contour_limit = contour + outline->num_contours; + short* end = source->contours; + short idx = 0; for ( ; contour < contour_limit; contour++, end++ ) @@ -565,8 +567,8 @@ { for ( point = points; point < point_limit; point++ ) { - AH_Point* prev; - AH_Point* next; + AH_Point prev; + AH_Point next; FT_Vector ivec, ovec; @@ -583,17 +585,17 @@ point->out_dir = ah_compute_direction( ovec.x, ovec.y ); #ifndef AH_OPTION_NO_WEAK_INTERPOLATION - if ( point->flags & (ah_flag_conic | ah_flag_cubic) ) + if ( point->flags & (AH_FLAG_CONIC | AH_FLAG_CUBIC) ) { Is_Weak_Point: - point->flags |= ah_flag_weak_interpolation; + point->flags |= AH_FLAG_WEAK_INTERPOLATION; } else if ( point->out_dir == point->in_dir ) { AH_Angle angle_in, angle_out, delta; - if ( point->out_dir != ah_dir_none ) + if ( point->out_dir != AH_DIR_NONE ) goto Is_Weak_Point; angle_in = ah_angle( &ivec ); @@ -622,11 +624,11 @@ FT_LOCAL_DEF( void ) - ah_setup_uv( AH_Outline* outline, - AH_UV source ) + ah_setup_uv( AH_Outline outline, + AH_UV source ) { - AH_Point* point = outline->points; - AH_Point* point_limit = point + outline->num_points; + AH_Point point = outline->points; + AH_Point point_limit = point + outline->num_points; for ( ; point < point_limit; point++ ) @@ -636,31 +638,31 @@ switch ( source ) { - case ah_uv_fxy: + case AH_UV_FXY: u = point->fx; v = point->fy; break; - case ah_uv_fyx: + case AH_UV_FYX: u = point->fy; v = point->fx; break; - case ah_uv_oxy: + case AH_UV_OXY: u = point->ox; v = point->oy; break; - case ah_uv_oyx: + case AH_UV_OYX: u = point->oy; v = point->ox; break; - case ah_uv_yx: + case AH_UV_YX: u = point->y; v = point->x; break; - case ah_uv_ox: + case AH_UV_OX: u = point->x; v = point->ox; break; - case ah_uv_oy: + case AH_UV_OY: u = point->y; v = point->oy; break; @@ -675,11 +677,127 @@ } + /* compute all inflex points in a given glyph */ + static void + ah_outline_compute_inflections( AH_Outline outline ) + { + AH_Point* contour = outline->contours; + AH_Point* contour_limit = contour + outline->num_contours; + + + /* load original coordinates in (u,v) */ + ah_setup_uv( outline, AH_UV_FXY ); + + /* do each contour separately */ + for ( ; contour < contour_limit; contour++ ) + { + FT_Vector vec; + AH_Point point = contour[0]; + AH_Point first = point; + AH_Point start = point; + AH_Point end = point; + AH_Point before; + AH_Point after; + AH_Angle angle_in, angle_seg, angle_out; + AH_Angle diff_in, diff_out; + FT_Int finished = 0; + + + /* compute first segment in contour */ + first = point; + + start = end = first; + do + { + end = end->next; + if ( end == first ) + goto Skip; + + } while ( end->u == first->u && end->v == first->v ); + + vec.x = end->u - start->u; + vec.y = end->v - start->v; + angle_seg = ah_angle( &vec ); + + /* extend the segment start whenever possible */ + before = start; + do + { + do + { + start = before; + before = before->prev; + if ( before == first ) + goto Skip; + + } while ( before->u == start->u && before->v == start->v ); + + vec.x = start->u - before->u; + vec.y = start->v - before->v; + angle_in = ah_angle( &vec ); + + } while ( angle_in == angle_seg ); + + first = start; + diff_in = ah_angle_diff( angle_in, angle_seg ); + + /* now, process all segments in the contour */ + do + { + /* first, extend current segment's end whenever possible */ + after = end; + do + { + do + { + end = after; + after = after->next; + if ( after == first ) + finished = 1; + + } while ( end->u == after->u && end->v == after->v ); + + vec.x = after->u - end->u; + vec.y = after->v - end->v; + angle_out = ah_angle( &vec ); + + } while ( angle_out == angle_seg ); + + diff_out = ah_angle_diff( angle_seg, angle_out ); + + if ( ( diff_in ^ diff_out ) < 0 ) + { + /* diff_in and diff_out have different signs, we have */ + /* inflection points here... */ + + do + { + start->flags |= AH_FLAG_INFLECTION; + start = start->next; + + } while ( start != end ); + + start->flags |= AH_FLAG_INFLECTION; + } + + start = end; + end = after; + angle_seg = angle_out; + diff_in = diff_out; + + } while ( !finished ); + + Skip: + ; + } + } + + FT_LOCAL_DEF( void ) - ah_outline_compute_segments( AH_Outline* outline ) + ah_outline_compute_segments( AH_Outline outline ) { int dimension; - AH_Segment* segments; + AH_Segment segments; FT_Int* p_num_segments; AH_Direction segment_dir; AH_Direction major_dir; @@ -687,36 +805,36 @@ segments = outline->horz_segments; p_num_segments = &outline->num_hsegments; - major_dir = ah_dir_right; /* This value must be positive! */ + major_dir = AH_DIR_RIGHT; /* This value must be positive! */ segment_dir = major_dir; /* set up (u,v) in each point */ - ah_setup_uv( outline, ah_uv_fyx ); + ah_setup_uv( outline, AH_UV_FYX ); for ( dimension = 1; dimension >= 0; dimension-- ) { - AH_Point** contour = outline->contours; - AH_Point** contour_limit = contour + outline->num_contours; - AH_Segment* segment = segments; - FT_Int num_segments = 0; + AH_Point* contour = outline->contours; + AH_Point* contour_limit = contour + outline->num_contours; + AH_Segment segment = segments; + FT_Int num_segments = 0; #ifdef AH_HINT_METRICS - AH_Point* min_point = 0; - AH_Point* max_point = 0; - FT_Pos min_coord = 32000; - FT_Pos max_coord = -32000; + AH_Point min_point = 0; + AH_Point max_point = 0; + FT_Pos min_coord = 32000; + FT_Pos max_coord = -32000; #endif /* do each contour separately */ for ( ; contour < contour_limit; contour++ ) { - AH_Point* point = contour[0]; - AH_Point* last = point->prev; - int on_edge = 0; - FT_Pos min_pos = +32000; /* minimum segment pos != min_coord */ - FT_Pos max_pos = -32000; /* maximum segment pos != max_coord */ - FT_Bool passed; + AH_Point point = contour[0]; + AH_Point last = point->prev; + int on_edge = 0; + FT_Pos min_pos = +32000; /* minimum segment pos != min_coord */ + FT_Pos max_pos = -32000; /* maximum segment pos != max_coord */ + FT_Bool passed; #ifdef AH_HINT_METRICS @@ -779,8 +897,8 @@ /* a segment is round if either its first or last point */ /* is a control point */ if ( ( segment->first->flags | point->flags ) & - ah_flag_control ) - segment->flags |= ah_edge_round; + AH_FLAG_CONTROL ) + segment->flags |= AH_EDGE_ROUND; /* compute segment size */ min_pos = max_pos = point->v; @@ -815,10 +933,10 @@ segment_dir = point->out_dir; /* clear all segment fields */ - FT_MEM_SET( segment, 0, sizeof ( *segment ) ); + FT_ZERO( segment ); segment->dir = segment_dir; - segment->flags = ah_edge_normal; + segment->flags = AH_EDGE_NORMAL; min_pos = max_pos = point->u; segment->first = point; segment->last = point; @@ -845,11 +963,11 @@ /* we do this by inserting fake segments when needed */ if ( dimension == 0 ) { - AH_Point* point = outline->points; - AH_Point* point_limit = point + outline->num_points; + AH_Point point = outline->points; + AH_Point point_limit = point + outline->num_points; - FT_Pos min_pos = 32000; - FT_Pos max_pos = -32000; + FT_Pos min_pos = 32000; + FT_Pos max_pos = -32000; min_point = 0; @@ -877,10 +995,10 @@ if ( min_point ) { /* clear all segment fields */ - FT_MEM_SET( segment, 0, sizeof ( *segment ) ); + FT_ZERO( segment ); segment->dir = segment_dir; - segment->flags = ah_edge_normal; + segment->flags = AH_EDGE_NORMAL; segment->first = min_point; segment->last = min_point; segment->pos = min_pos; @@ -893,10 +1011,10 @@ if ( max_point ) { /* clear all segment fields */ - FT_MEM_SET( segment, 0, sizeof ( *segment ) ); + FT_ZERO( segment ); segment->dir = segment_dir; - segment->flags = ah_edge_normal; + segment->flags = AH_EDGE_NORMAL; segment->first = max_point; segment->last = max_point; segment->pos = max_pos; @@ -910,36 +1028,38 @@ *p_num_segments = num_segments; segments = outline->vert_segments; - major_dir = ah_dir_up; + major_dir = AH_DIR_UP; p_num_segments = &outline->num_vsegments; - ah_setup_uv( outline, ah_uv_fxy ); + ah_setup_uv( outline, AH_UV_FXY ); } } FT_LOCAL_DEF( void ) - ah_outline_link_segments( AH_Outline* outline ) + ah_outline_link_segments( AH_Outline outline ) { - AH_Segment* segments; - AH_Segment* segment_limit; - int dimension; + AH_Segment segments; + AH_Segment segment_limit; + int dimension; - ah_setup_uv( outline, ah_uv_fyx ); + ah_setup_uv( outline, AH_UV_FYX ); segments = outline->horz_segments; segment_limit = segments + outline->num_hsegments; for ( dimension = 1; dimension >= 0; dimension-- ) { - AH_Segment* seg1; - AH_Segment* seg2; + AH_Segment seg1; + AH_Segment seg2; + /* now compare each segment to the others */ for ( seg1 = segments; seg1 < segment_limit; seg1++ ) { - FT_Pos best_score; - AH_Segment* best_segment; + FT_Pos best_score; + AH_Segment best_segment; + /* the fake segments are introduced to hint the metrics -- */ /* we must never link them to anything */ @@ -983,20 +1103,20 @@ if ( max > seg2->max_coord ) max = seg2->max_coord; - len = max - min; - dist = seg2->pos - seg1->pos; - if ( dist < 0 ) - dist = -dist; + len = max - min; + if ( len >= 8 ) + { + dist = seg2->pos - seg1->pos; + if ( dist < 0 ) + dist = -dist; - if ( len < 8 ) - score = 300*8 + dist - len*3; - else - score = dist + 300/len; + score = dist + 3000 / len; - if ( score < best_score ) - { - best_score = score; - best_segment = seg2; + if ( score < best_score ) + { + best_score = score; + best_segment = seg2; + } } } } @@ -1009,7 +1129,6 @@ best_segment->num_linked++; } - } /* edges 1 */ /* now, compute the `serif' segments */ @@ -1024,7 +1143,7 @@ } } - ah_setup_uv( outline, ah_uv_fxy ); + ah_setup_uv( outline, AH_UV_FXY ); segments = outline->vert_segments; segment_limit = segments + outline->num_vsegments; @@ -1033,11 +1152,11 @@ static void - ah_outline_compute_edges( AH_Outline* outline ) + ah_outline_compute_edges( AH_Outline outline ) { - AH_Edge* edges; - AH_Segment* segments; - AH_Segment* segment_limit; + AH_Edge edges; + AH_Segment segments; + AH_Segment segment_limit; AH_Direction up_dir; FT_Int* p_num_edges; FT_Int dimension; @@ -1049,14 +1168,14 @@ segments = outline->horz_segments; segment_limit = segments + outline->num_hsegments; p_num_edges = &outline->num_hedges; - up_dir = ah_dir_right; + up_dir = AH_DIR_RIGHT; scale = outline->y_scale; for ( dimension = 1; dimension >= 0; dimension-- ) { - AH_Edge* edge; - AH_Edge* edge_limit; /* really == edge + num_edges */ - AH_Segment* seg; + AH_Edge edge; + AH_Edge edge_limit; /* really == edge + num_edges */ + AH_Segment seg; /*********************************************************************/ @@ -1083,7 +1202,7 @@ edge_limit = edges; for ( seg = segments; seg < segment_limit; seg++ ) { - AH_Edge* found = 0; + AH_Edge found = 0; /* look for an edge corresponding to the segment */ @@ -1116,7 +1235,7 @@ edge_limit++; /* clear all edge fields */ - FT_MEM_SET( edge, 0, sizeof ( *edge ) ); + FT_MEM_ZERO( edge, sizeof ( *edge ) ); /* add the segment to the new edge's list */ edge->first = seg; @@ -1167,10 +1286,10 @@ /* now, compute each edge properties */ for ( edge = edges; edge < edge_limit; edge++ ) { - int is_round = 0; /* does it contain round segments? */ - int is_straight = 0; /* does it contain straight segments? */ - int ups = 0; /* number of upwards segments */ - int downs = 0; /* number of downwards segments */ + FT_Int is_round = 0; /* does it contain round segments? */ + FT_Int is_straight = 0; /* does it contain straight segments? */ + FT_Pos ups = 0; /* number of upwards segments */ + FT_Pos downs = 0; /* number of downwards segments */ seg = edge->first; @@ -1181,7 +1300,7 @@ /* check for roundness of segment */ - if ( seg->flags & ah_edge_round ) + if ( seg->flags & AH_EDGE_ROUND ) is_round++; else is_straight++; @@ -1198,8 +1317,8 @@ if ( seg->link || is_serif ) { - AH_Edge* edge2; - AH_Segment* seg2; + AH_Edge edge2; + AH_Segment seg2; edge2 = edge->link; @@ -1242,13 +1361,13 @@ } while ( seg != edge->first ); /* set the round/straight flags */ - edge->flags = ah_edge_normal; + edge->flags = AH_EDGE_NORMAL; if ( is_round > 0 && is_round >= is_straight ) - edge->flags |= ah_edge_round; + edge->flags |= AH_EDGE_ROUND; /* set the edge's main direction */ - edge->dir = ah_dir_none; + edge->dir = AH_DIR_NONE; if ( ups > downs ) edge->dir = up_dir; @@ -1271,7 +1390,7 @@ segments = outline->vert_segments; segment_limit = segments + outline->num_vsegments; p_num_edges = &outline->num_vedges; - up_dir = ah_dir_up; + up_dir = AH_DIR_UP; scale = outline->x_scale; } } @@ -1283,14 +1402,15 @@ /* ah_outline_detect_features */ /* */ /* <Description> */ - /* Performs feature detection on a given AH_Outline object. */ + /* Performs feature detection on a given AH_OutlineRec object. */ /* */ FT_LOCAL_DEF( void ) - ah_outline_detect_features( AH_Outline* outline ) + ah_outline_detect_features( AH_Outline outline ) { - ah_outline_compute_segments( outline ); - ah_outline_link_segments ( outline ); - ah_outline_compute_edges ( outline ); + ah_outline_compute_segments ( outline ); + ah_outline_link_segments ( outline ); + ah_outline_compute_edges ( outline ); + ah_outline_compute_inflections( outline ); } @@ -1304,15 +1424,15 @@ /* be snapped to a blue zone edge (top or bottom). */ /* */ FT_LOCAL_DEF( void ) - ah_outline_compute_blue_edges( AH_Outline* outline, - AH_Face_Globals* face_globals ) + ah_outline_compute_blue_edges( AH_Outline outline, + AH_Face_Globals face_globals ) { - AH_Edge* edge = outline->horz_edges; - AH_Edge* edge_limit = edge + outline->num_hedges; - AH_Globals* globals = &face_globals->design; - FT_Fixed y_scale = outline->y_scale; + AH_Edge edge = outline->horz_edges; + AH_Edge edge_limit = edge + outline->num_hedges; + AH_Globals globals = &face_globals->design; + FT_Fixed y_scale = outline->y_scale; - FT_Bool blue_active[ah_blue_max]; + FT_Bool blue_active[AH_BLUE_MAX]; /* compute which blue zones are active, i.e. have their scaled */ @@ -1322,7 +1442,7 @@ FT_Bool check = 0; - for ( blue = ah_blue_capital_top; blue < ah_blue_max; blue++ ) + for ( blue = AH_BLUE_CAPITAL_TOP; blue < AH_BLUE_MAX; blue++ ) { FT_Pos ref, shoot, dist; @@ -1360,7 +1480,7 @@ if ( best_dist > 64 / 4 ) best_dist = 64 / 4; - for ( blue = ah_blue_capital_top; blue < ah_blue_max; blue++ ) + for ( blue = AH_BLUE_CAPITAL_TOP; blue < AH_BLUE_MAX; blue++ ) { /* if it is a top zone, check for right edges -- if it is a bottom */ /* zone, check for left edges */ @@ -1398,7 +1518,7 @@ /* now, compare it to the overshoot position if the edge is */ /* rounded, and if the edge is over the reference position of a */ /* top zone, or under the reference position of a bottom zone */ - if ( edge->flags & ah_edge_round && dist != 0 ) + if ( edge->flags & AH_EDGE_ROUND && dist != 0 ) { FT_Bool is_under_ref = FT_BOOL( edge->fpos < *blue_pos ); @@ -1438,12 +1558,12 @@ /* edge' pointer from `design units' to `scaled ones'). */ /* */ FT_LOCAL_DEF( void ) - ah_outline_scale_blue_edges( AH_Outline* outline, - AH_Face_Globals* globals ) + ah_outline_scale_blue_edges( AH_Outline outline, + AH_Face_Globals globals ) { - AH_Edge* edge = outline->horz_edges; - AH_Edge* edge_limit = edge + outline->num_hedges; - FT_Int delta; + AH_Edge edge = outline->horz_edges; + AH_Edge edge_limit = edge + outline->num_hedges; + FT_Pos delta; delta = globals->scaled.blue_refs - globals->design.blue_refs; diff --git a/src/libs/freetype2/autohint/ahglyph.h b/src/libs/freetype2/autohint/ahglyph.h index 8089f41925f..b116ed988d6 100644 --- a/src/libs/freetype2/autohint/ahglyph.h +++ b/src/libs/freetype2/autohint/ahglyph.h @@ -33,56 +33,56 @@ FT_BEGIN_HEADER typedef enum AH_UV_ { - ah_uv_fxy, - ah_uv_fyx, - ah_uv_oxy, - ah_uv_oyx, - ah_uv_ox, - ah_uv_oy, - ah_uv_yx, - ah_uv_xy /* should always be last! */ + AH_UV_FXY, + AH_UV_FYX, + AH_UV_OXY, + AH_UV_OYX, + AH_UV_OX, + AH_UV_OY, + AH_UV_YX, + AH_UV_XY /* should always be last! */ } AH_UV; FT_LOCAL( void ) - ah_setup_uv( AH_Outline* outline, - AH_UV source ); + ah_setup_uv( AH_Outline outline, + AH_UV source ); - /* AH_Outline functions - they should be typically called in this order */ + /* AH_OutlineRec functions - they should be typically called in this order */ FT_LOCAL( FT_Error ) - ah_outline_new( FT_Memory memory, - AH_Outline** aoutline ); + ah_outline_new( FT_Memory memory, + AH_Outline* aoutline ); FT_LOCAL( FT_Error ) - ah_outline_load( AH_Outline* outline, - FT_Face face ); + ah_outline_load( AH_Outline outline, + FT_Face face ); FT_LOCAL( void ) - ah_outline_compute_segments( AH_Outline* outline ); + ah_outline_compute_segments( AH_Outline outline ); FT_LOCAL( void ) - ah_outline_link_segments( AH_Outline* outline ); + ah_outline_link_segments( AH_Outline outline ); FT_LOCAL( void ) - ah_outline_detect_features( AH_Outline* outline ); + ah_outline_detect_features( AH_Outline outline ); FT_LOCAL( void ) - ah_outline_compute_blue_edges( AH_Outline* outline, - AH_Face_Globals* globals ); + ah_outline_compute_blue_edges( AH_Outline outline, + AH_Face_Globals globals ); FT_LOCAL( void ) - ah_outline_scale_blue_edges( AH_Outline* outline, - AH_Face_Globals* globals ); + ah_outline_scale_blue_edges( AH_Outline outline, + AH_Face_Globals globals ); FT_LOCAL( void ) - ah_outline_save( AH_Outline* outline, - AH_Loader loader ); + ah_outline_save( AH_Outline outline, + AH_Loader loader ); FT_LOCAL( void ) - ah_outline_done( AH_Outline* outline ); + ah_outline_done( AH_Outline outline ); FT_END_HEADER diff --git a/src/libs/freetype2/autohint/ahhint.c b/src/libs/freetype2/autohint/ahhint.c index be5c0a2a9df..dacde6eea68 100644 --- a/src/libs/freetype2/autohint/ahhint.c +++ b/src/libs/freetype2/autohint/ahhint.c @@ -27,10 +27,10 @@ #include FT_OUTLINE_H -#define FACE_GLOBALS( face ) ((AH_Face_Globals*)(face)->autohint.data) +#define FACE_GLOBALS( face ) ((AH_Face_Globals)(face)->autohint.data) #define AH_USE_IUP - +#define OPTIM_STEM_SNAP /*************************************************************************/ /*************************************************************************/ @@ -40,7 +40,6 @@ /*************************************************************************/ /*************************************************************************/ - /* snap a given width in scaled coordinates to one of the */ /* current standard widths */ static FT_Pos @@ -51,6 +50,7 @@ int n; FT_Pos best = 64 + 32 + 2; FT_Pos reference = width; + FT_Pos scaled; for ( n = 0; n < count; n++ ) @@ -70,16 +70,16 @@ } } + scaled = (reference+32) & -64; + if ( width >= reference ) { - width -= 0x21; - if ( width < reference ) + if ( width < scaled + 48 ) width = reference; } else { - width += 0x21; - if ( width > reference ) + if ( width > scaled - 48 ) width = reference; } @@ -87,73 +87,138 @@ } - /* align one stem edge relative to the previous stem edge */ - static void - ah_align_linked_edge( AH_Hinter* hinter, - AH_Edge* base_edge, - AH_Edge* stem_edge, - int vertical ) + /* compute the snapped width of a given stem */ + static FT_Pos + ah_compute_stem_width( AH_Hinter hinter, + int vertical, + FT_Pos width ) { - FT_Pos dist = stem_edge->opos - base_edge->opos; - AH_Globals* globals = &hinter->globals->scaled; - FT_Pos sign = 1; + AH_Globals globals = &hinter->globals->scaled; + FT_Pos dist = width; + FT_Int sign = 0; if ( dist < 0 ) { - dist = -dist; - sign = -1; + dist = -width; + sign = 1; } - if ( vertical ) + if ( ( vertical && !hinter->do_vert_snapping ) || + ( !vertical && !hinter->do_horz_snapping ) ) { - dist = ah_snap_width( globals->heights, globals->num_heights, dist ); - - /* in the case of vertical hinting, always round */ - /* the stem heights to integer pixels */ - if ( dist >= 64 ) - dist = ( dist + 16 ) & -64; - else + /* smooth hinting process, very lightly quantize the stem width */ + /* */ + if ( dist < 64 ) dist = 64; + + { + FT_Pos delta = dist - globals->stds[vertical]; + + + if ( delta < 0 ) + delta = -delta; + + if ( delta < 40 ) + { + dist = globals->stds[vertical]; + if ( dist < 48 ) + dist = 48; + } + + if ( dist < 3 * 64 ) + { + delta = ( dist & 63 ); + dist &= -64; + + if ( delta < 10 ) + dist += delta; + + else if ( delta < 32 ) + dist += 10; + + else if ( delta < 54 ) + dist += 54; + + else + dist += delta; + } + else + dist = ( dist + 32 ) & -64; + } } else { - dist = ah_snap_width( globals->widths, globals->num_widths, dist ); - - if ( hinter->flags & ah_hinter_monochrome ) + /* strong hinting process, snap the stem width to integer pixels */ + /* */ + if ( vertical ) { - /* monochrome horizontal hinting: snap widths to integer pixels */ - /* with a different threshold */ - if ( dist < 64 ) - dist = 64; + dist = ah_snap_width( globals->heights, globals->num_heights, dist ); + + /* in the case of vertical hinting, always round */ + /* the stem heights to integer pixels */ + if ( dist >= 64 ) + dist = ( dist + 16 ) & -64; else - dist = ( dist + 32 ) & -64; + dist = 64; } else { - /* 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 + 42 ) & -64; + dist = ah_snap_width( globals->widths, globals->num_widths, dist ); + + if ( hinter->flags & AH_HINTER_MONOCHROME ) + { + /* monochrome horizontal hinting: snap widths to integer pixels */ + /* with a different threshold */ + if ( dist < 64 ) + dist = 64; + else + dist = ( dist + 32 ) & -64; + } 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_serif_edge( AH_Hinter* hinter, - AH_Edge* base, - AH_Edge* serif, - int vertical ) + ah_align_linked_edge( AH_Hinter hinter, + AH_Edge base_edge, + AH_Edge stem_edge, + int vertical ) + { + FT_Pos dist = stem_edge->opos - base_edge->opos; + + + stem_edge->pos = base_edge->pos + + ah_compute_stem_width( hinter, vertical, dist ); + } + + + static void + ah_align_serif_edge( AH_Hinter hinter, + AH_Edge base, + AH_Edge serif, + int vertical ) { FT_Pos dist; FT_Pos sign = 1; @@ -168,8 +233,9 @@ sign = -1; } - /* do not strengthen serifs */ - if ( base->flags & ah_edge_done ) + /* do not touch serifs widths !! */ +#if 0 + if ( base->flags & AH_EDGE_DONE ) { if ( dist >= 64 ) dist = (dist+8) & -64; @@ -179,6 +245,7 @@ else dist = 0; } +#endif serif->pos = base->pos + sign * dist; } @@ -197,12 +264,12 @@ /* Another alternative edge hinting algorithm */ static void - ah_hint_edges_3( AH_Hinter* hinter ) + ah_hint_edges_3( AH_Hinter hinter ) { - AH_Edge* edges; - AH_Edge* edge_limit; - AH_Outline* outline = hinter->glyph; - FT_Int dimension; + AH_Edge edges; + AH_Edge edge_limit; + AH_Outline outline = hinter->glyph; + FT_Int dimension; edges = outline->horz_edges; @@ -210,15 +277,15 @@ for ( dimension = 1; dimension >= 0; dimension-- ) { - AH_Edge* edge; - AH_Edge* anchor = 0; - int has_serifs = 0; + AH_Edge edge; + AH_Edge anchor = 0; + int has_serifs = 0; - if ( ah_debug_disable_vert && !dimension ) + if ( !hinter->do_horz_hints && !dimension ) goto Next_Dimension; - if ( ah_debug_disable_horz && dimension ) + if ( !hinter->do_vert_hints && dimension ) goto Next_Dimension; /* we begin by aligning all stems relative to the blue zone */ @@ -227,11 +294,11 @@ { for ( edge = edges; edge < edge_limit; edge++ ) { - FT_Pos* blue; - AH_Edge *edge1, *edge2; + FT_Pos* blue; + AH_EdgeRec *edge1, *edge2; - if ( edge->flags & ah_edge_done ) + if ( edge->flags & AH_EDGE_DONE ) continue; blue = edge->blue_edge; @@ -253,12 +320,12 @@ continue; edge1->pos = blue[0]; - edge1->flags |= ah_edge_done; + edge1->flags |= AH_EDGE_DONE; if ( edge2 && !edge2->blue_edge ) { ah_align_linked_edge( hinter, edge1, edge2, dimension ); - edge2->flags |= ah_edge_done; + edge2->flags |= AH_EDGE_DONE; } if ( !anchor ) @@ -270,10 +337,10 @@ /* relative order of stems in the glyph.. */ for ( edge = edges; edge < edge_limit; edge++ ) { - AH_Edge *edge2; + AH_EdgeRec* edge2; - if ( edge->flags & ah_edge_done ) + if ( edge->flags & AH_EDGE_DONE ) continue; /* skip all non-stem edges */ @@ -286,54 +353,54 @@ /* now, align the stem */ - /* this should not happen, but it's better to be safe.. */ + /* this should not happen, but it's better to be safe. */ if ( edge2->blue_edge || edge2 < edge ) { -#if 0 - printf( "strange blue alignement, edge %d to %d\n", - edge - edges, edge2 - edges ); -#endif - ah_align_linked_edge( hinter, edge2, edge, dimension ); - edge->flags |= ah_edge_done; + edge->flags |= AH_EDGE_DONE; continue; } + if ( !anchor ) { - FT_Bool min = 0; - FT_Pos delta; + edge->pos = ( edge->opos + 32 ) & -64; + anchor = edge; - if ( !anchor ) - { - edge->pos = ( edge->opos + 32 ) & -64; - anchor = edge; - } - else - edge->pos = anchor->pos + - ( ( edge->opos - anchor->opos + 32 ) & -64 ); + edge->flags |= AH_EDGE_DONE; - edge->flags |= ah_edge_done; + ah_align_linked_edge( hinter, edge, edge2, dimension ); + } + else + { + FT_Pos org_pos, org_len, org_center, cur_len; + FT_Pos cur_pos1, cur_pos2, delta1, delta2; - if ( edge > edges && edge->pos < edge[-1].pos ) - { - edge->pos = edge[-1].pos; - min = 1; - } - ah_align_linked_edge( hinter, edge, edge2, dimension ); - delta = 0; - if ( edge2 + 1 < edge_limit && - edge2[1].flags & ah_edge_done ) - delta = edge2[1].pos - edge2->pos; + org_pos = anchor->pos + (edge->opos - anchor->opos); + org_len = edge2->opos - edge->opos; + org_center = org_pos + ( org_len >> 1 ); - if ( delta < 0 ) - { - edge2->pos += delta; - if ( !min ) - edge->pos += delta; - } - edge2->flags |= ah_edge_done; + cur_len = ah_compute_stem_width( hinter, dimension, org_len ); + + cur_pos1 = ( org_pos + 32 ) & -64; + delta1 = ( cur_pos1 + ( cur_len >> 1 ) - org_center ); + if ( delta1 < 0 ) + delta1 = -delta1; + + cur_pos2 = ( ( org_pos + org_len + 32 ) & -64 ) - cur_len; + delta2 = ( cur_pos2 + ( cur_len >> 1 ) - org_center ); + if ( delta2 < 0 ) + delta2 = -delta2; + + edge->pos = ( delta1 <= delta2 ) ? cur_pos1 : cur_pos2; + edge2->pos = edge->pos + cur_len; + + edge->flags |= AH_EDGE_DONE; + edge2->flags |= AH_EDGE_DONE; + + if ( edge > edges && edge->pos < edge[-1].pos ) + edge->pos = edge[-1].pos; } } @@ -344,13 +411,11 @@ /* to complete our processing */ for ( edge = edges; edge < edge_limit; edge++ ) { - if ( edge->flags & ah_edge_done ) + if ( edge->flags & AH_EDGE_DONE ) continue; if ( edge->serif ) - { ah_align_serif_edge( hinter, edge->serif, edge, dimension ); - } else if ( !anchor ) { edge->pos = ( edge->opos + 32 ) & -64; @@ -360,13 +425,13 @@ edge->pos = anchor->pos + ( ( edge->opos-anchor->opos + 32 ) & -64 ); - edge->flags |= ah_edge_done; + edge->flags |= AH_EDGE_DONE; if ( edge > edges && edge->pos < edge[-1].pos ) edge->pos = edge[-1].pos; if ( edge + 1 < edge_limit && - edge[1].flags & ah_edge_done && + edge[1].flags & AH_EDGE_DONE && edge->pos > edge[1].pos ) edge->pos = edge[1].pos; } @@ -379,38 +444,13 @@ FT_LOCAL_DEF( void ) - ah_hinter_hint_edges( AH_Hinter* hinter, - FT_Bool no_horz_edges, - FT_Bool no_vert_edges ) + ah_hinter_hint_edges( AH_Hinter hinter ) { -#if 0 - ah_debug_disable_horz = no_horz_edges; - ah_debug_disable_vert = no_vert_edges; -#else - FT_UNUSED( no_horz_edges ); - FT_UNUSED( no_vert_edges ); -#endif /* AH_Interpolate_Blue_Edges( hinter ); -- doesn't seem to help */ /* reduce the problem of the disappearing eye in the `e' of Times... */ /* also, creates some artifacts near the blue zones? */ { ah_hint_edges_3( hinter ); - -#if 0 - /* outline optimizer removed temporarily */ - if ( hinter->flags & ah_hinter_optimize ) - { - AH_Optimizer opt; - - - if ( !AH_Optimizer_Init( &opt, hinter->glyph, hinter->memory ) ) - { - AH_Optimizer_Compute( &opt ); - AH_Optimizer_Done( &opt ); - } - } -#endif - } } @@ -426,12 +466,12 @@ /*************************************************************************/ static void - ah_hinter_align_edge_points( AH_Hinter* hinter ) + ah_hinter_align_edge_points( AH_Hinter hinter ) { - AH_Outline* outline = hinter->glyph; - AH_Edge* edges; - AH_Edge* edge_limit; - FT_Int dimension; + AH_Outline outline = hinter->glyph; + AH_Edge edges; + AH_Edge edge_limit; + FT_Int dimension; edges = outline->horz_edges; @@ -439,7 +479,7 @@ for ( dimension = 1; dimension >= 0; dimension-- ) { - AH_Edge* edge; + AH_Edge edge; edge = edges; @@ -447,12 +487,12 @@ { /* move the points of each segment */ /* in each edge to the edge's position */ - AH_Segment* seg = edge->first; + AH_Segment seg = edge->first; do { - AH_Point* point = seg->first; + AH_Point point = seg->first; for (;;) @@ -460,12 +500,12 @@ if ( dimension ) { point->y = edge->pos; - point->flags |= ah_flag_touch_y; + point->flags |= AH_FLAG_TOUCH_Y; } else { point->x = edge->pos; - point->flags |= ah_flag_touch_x; + point->flags |= AH_FLAG_TOUCH_X; } if ( point == seg->last ) @@ -487,15 +527,15 @@ /* hint the strong points -- this is equivalent to the TrueType `IP' */ static void - ah_hinter_align_strong_points( AH_Hinter* hinter ) + ah_hinter_align_strong_points( AH_Hinter hinter ) { - AH_Outline* outline = hinter->glyph; - FT_Int dimension; - AH_Edge* edges; - AH_Edge* edge_limit; - AH_Point* points; - AH_Point* point_limit; - AH_Flags touch_flag; + AH_Outline outline = hinter->glyph; + FT_Int dimension; + AH_Edge edges; + AH_Edge edge_limit; + AH_Point points; + AH_Point point_limit; + AH_Flags touch_flag; points = outline->points; @@ -503,12 +543,12 @@ edges = outline->horz_edges; edge_limit = edges + outline->num_hedges; - touch_flag = ah_flag_touch_y; + touch_flag = AH_FLAG_TOUCH_Y; for ( dimension = 1; dimension >= 0; dimension-- ) { - AH_Point* point; - AH_Edge* edge; + AH_Point point; + AH_Edge edge; if ( edges < edge_limit ) @@ -524,7 +564,8 @@ #ifndef AH_OPTION_NO_WEAK_INTERPOLATION /* if this point is candidate to weak interpolation, we will */ /* interpolate it after all strong points have been processed */ - if ( point->flags & ah_flag_weak_interpolation ) + if ( ( point->flags & AH_FLAG_WEAK_INTERPOLATION ) && + !( point->flags & AH_FLAG_INFLECTION ) ) continue; #endif @@ -561,8 +602,8 @@ /* otherwise, interpolate the point in between */ { - AH_Edge* before = 0; - AH_Edge* after = 0; + AH_Edge before = 0; + AH_Edge after = 0; for ( edge = edges; edge < edge_limit; edge++ ) @@ -608,7 +649,7 @@ edges = outline->vert_edges; edge_limit = edges + outline->num_vedges; - touch_flag = ah_flag_touch_x; + touch_flag = AH_FLAG_TOUCH_X; } } @@ -616,12 +657,12 @@ #ifndef AH_OPTION_NO_WEAK_INTERPOLATION static void - ah_iup_shift( AH_Point* p1, - AH_Point* p2, - AH_Point* ref ) + ah_iup_shift( AH_Point p1, + AH_Point p2, + AH_Point ref ) { - AH_Point* p; - FT_Pos delta = ref->u - ref->v; + AH_Point p; + FT_Pos delta = ref->u - ref->v; for ( p = p1; p < ref; p++ ) @@ -633,17 +674,17 @@ static void - ah_iup_interp( AH_Point* p1, - AH_Point* p2, - AH_Point* ref1, - AH_Point* ref2 ) + ah_iup_interp( AH_Point p1, + AH_Point p2, + AH_Point ref1, + AH_Point ref2 ) { - AH_Point* p; - FT_Pos u; - FT_Pos v1 = ref1->v; - FT_Pos v2 = ref2->v; - FT_Pos d1 = ref1->u - v1; - FT_Pos d2 = ref2->u - v2; + AH_Point p; + FT_Pos u; + FT_Pos v1 = ref1->v; + FT_Pos v2 = ref2->v; + FT_Pos d1 = ref1->u - v1; + FT_Pos d2 = ref2->u - v2; if ( p1 > p2 ) @@ -702,14 +743,14 @@ /* interpolate weak points -- this is equivalent to the TrueType `IUP' */ static void - ah_hinter_align_weak_points( AH_Hinter* hinter ) + ah_hinter_align_weak_points( AH_Hinter hinter ) { - AH_Outline* outline = hinter->glyph; - FT_Int dimension; - AH_Point* points; - AH_Point* point_limit; - AH_Point** contour_limit; - AH_Flags touch_flag; + AH_Outline outline = hinter->glyph; + FT_Int dimension; + AH_Point points; + AH_Point point_limit; + AH_Point* contour_limit; + AH_Flags touch_flag; points = outline->points; @@ -717,18 +758,18 @@ /* PASS 1: Move segment points to edge positions */ - touch_flag = ah_flag_touch_y; + touch_flag = AH_FLAG_TOUCH_Y; contour_limit = outline->contours + outline->num_contours; - ah_setup_uv( outline, ah_uv_oy ); + ah_setup_uv( outline, AH_UV_OY ); for ( dimension = 1; dimension >= 0; dimension-- ) { - AH_Point* point; - AH_Point* end_point; - AH_Point* first_point; - AH_Point** contour; + AH_Point point; + AH_Point end_point; + AH_Point first_point; + AH_Point* contour; point = points; @@ -745,8 +786,8 @@ if ( point <= end_point ) { - AH_Point* first_touched = point; - AH_Point* cur_touched = point; + AH_Point first_touched = point; + AH_Point cur_touched = point; point++; @@ -791,8 +832,8 @@ for ( point = points; point < point_limit; point++ ) point->y = point->u; - touch_flag = ah_flag_touch_x; - ah_setup_uv( outline, ah_uv_ox ); + touch_flag = AH_FLAG_TOUCH_X; + ah_setup_uv( outline, AH_UV_OX ); } else { @@ -808,7 +849,7 @@ FT_LOCAL_DEF( void ) - ah_hinter_align_points( AH_Hinter* hinter ) + ah_hinter_align_points( AH_Hinter hinter ) { ah_hinter_align_edge_points( hinter ); @@ -835,14 +876,14 @@ /* scale and fit the global metrics */ static void - ah_hinter_scale_globals( AH_Hinter* hinter, - FT_Fixed x_scale, - FT_Fixed y_scale ) + ah_hinter_scale_globals( AH_Hinter hinter, + FT_Fixed x_scale, + FT_Fixed y_scale ) { - FT_Int n; - AH_Face_Globals* globals = hinter->globals; - AH_Globals* design = &globals->design; - AH_Globals* scaled = &globals->scaled; + FT_Int n; + AH_Face_Globals globals = hinter->globals; + AH_Globals design = &globals->design; + AH_Globals scaled = &globals->scaled; /* copy content */ @@ -855,8 +896,11 @@ for ( n = 0; n < design->num_heights; n++ ) scaled->heights[n] = FT_MulFix( design->heights[n], y_scale ); + scaled->stds[0] = ( design->num_widths > 0 ) ? scaled->widths[0] : 32000; + scaled->stds[1] = ( design->num_heights > 0 ) ? scaled->heights[0] : 32000; + /* scale the blue zones */ - for ( n = 0; n < ah_blue_max; n++ ) + for ( n = 0; n < AH_BLUE_MAX; n++ ) { FT_Pos delta, delta2; @@ -888,7 +932,7 @@ static void - ah_hinter_align( AH_Hinter* hinter ) + ah_hinter_align( AH_Hinter hinter ) { ah_hinter_align_edge_points( hinter ); ah_hinter_align_points( hinter ); @@ -897,7 +941,7 @@ /* finalize a hinter object */ FT_LOCAL_DEF( void ) - ah_hinter_done( AH_Hinter* hinter ) + ah_hinter_done( AH_Hinter hinter ) { if ( hinter ) { @@ -920,12 +964,12 @@ /* create a new empty hinter object */ FT_LOCAL_DEF( FT_Error ) - ah_hinter_new( FT_Library library, - AH_Hinter** ahinter ) + ah_hinter_new( FT_Library library, + AH_Hinter *ahinter ) { - AH_Hinter* hinter = 0; - FT_Memory memory = library->memory; - FT_Error error; + AH_Hinter hinter = 0; + FT_Memory memory = library->memory; + FT_Error error; *ahinter = 0; @@ -956,13 +1000,13 @@ /* create a face's autohint globals */ FT_LOCAL_DEF( FT_Error ) - ah_hinter_new_face_globals( AH_Hinter* hinter, - FT_Face face, - AH_Globals* globals ) + ah_hinter_new_face_globals( AH_Hinter hinter, + FT_Face face, + AH_Globals globals ) { - FT_Error error; - FT_Memory memory = hinter->memory; - AH_Face_Globals* face_globals; + FT_Error error; + FT_Memory memory = hinter->memory; + AH_Face_Globals face_globals; if ( FT_NEW( face_globals ) ) @@ -988,7 +1032,7 @@ /* discard a face's autohint globals */ FT_LOCAL_DEF( void ) - ah_hinter_done_face_globals( AH_Face_Globals* globals ) + ah_hinter_done_face_globals( AH_Face_Globals globals ) { FT_Face face = globals->face; FT_Memory memory = face->memory; @@ -999,10 +1043,10 @@ static FT_Error - ah_hinter_load( AH_Hinter* hinter, - FT_UInt glyph_index, - FT_UInt load_flags, - FT_UInt depth ) + ah_hinter_load( AH_Hinter hinter, + FT_UInt glyph_index, + FT_Int32 load_flags, + FT_UInt depth ) { FT_Face face = hinter->face; FT_GlyphSlot slot = face->glyph; @@ -1010,12 +1054,8 @@ FT_Fixed x_scale = face->size->metrics.x_scale; FT_Fixed y_scale = face->size->metrics.y_scale; FT_Error error; - AH_Outline* outline = hinter->glyph; + AH_Outline outline = hinter->glyph; AH_Loader gloader = hinter->loader; - FT_Bool no_horz_hints = FT_BOOL( - ( load_flags & AH_HINT_NO_HORZ_EDGES ) != 0 ); - FT_Bool no_vert_hints = FT_BOOL( - ( load_flags & AH_HINT_NO_VERT_EDGES ) != 0 ); /* load the glyph */ @@ -1030,6 +1070,7 @@ { FT_Matrix imatrix; + imatrix = internal->glyph_matrix; hinter->trans_delta = internal->glyph_delta; hinter->trans_matrix = imatrix; @@ -1044,7 +1085,7 @@ switch ( slot->format ) { - case ft_glyph_format_outline: + case FT_GLYPH_FORMAT_OUTLINE: /* translate glyph outline if we need to */ if ( hinter->transformed ) @@ -1098,14 +1139,14 @@ /* perform feature detection */ ah_outline_detect_features( outline ); - if ( !no_horz_hints ) + if ( hinter->do_vert_hints ) { ah_outline_compute_blue_edges( outline, hinter->globals ); ah_outline_scale_blue_edges( outline, hinter->globals ); } /* perform alignment control */ - ah_hinter_hint_edges( hinter, no_horz_hints, no_vert_hints ); + ah_hinter_hint_edges( hinter ); ah_hinter_align( hinter ); /* now save the current outline into the loader's current table */ @@ -1114,10 +1155,10 @@ /* we now need to hint the metrics according to the change in */ /* width/positioning that occured during the hinting process */ { - FT_Pos old_advance, old_rsb, old_lsb, new_lsb; - AH_Edge* edge1 = outline->vert_edges; /* leftmost edge */ - AH_Edge* edge2 = edge1 + - outline->num_vedges - 1; /* rightmost edge */ + FT_Pos old_advance, old_rsb, old_lsb, new_lsb; + AH_Edge edge1 = outline->vert_edges; /* leftmost edge */ + AH_Edge edge2 = edge1 + + outline->num_vedges - 1; /* rightmost edge */ old_advance = hinter->pp2.x; @@ -1137,7 +1178,7 @@ ah_loader_add( gloader ); break; - case ft_glyph_format_composite: + case FT_GLYPH_FORMAT_COMPOSITE: { FT_UInt nn, num_subglyphs = slot->num_subglyphs; FT_UInt num_base_subgs, start_point; @@ -1314,7 +1355,7 @@ goto Exit; slot->outline = slot->internal->loader->base.outline; - slot->format = ft_glyph_format_outline; + slot->format = FT_GLYPH_FORMAT_OUTLINE; } #ifdef DEBUG_HINTER @@ -1328,17 +1369,18 @@ /* load and hint a given glyph */ FT_LOCAL_DEF( FT_Error ) - ah_hinter_load_glyph( AH_Hinter* hinter, + ah_hinter_load_glyph( AH_Hinter hinter, FT_GlyphSlot slot, FT_Size size, FT_UInt glyph_index, - FT_Int load_flags ) + FT_Int32 load_flags ) { - FT_Face face = slot->face; - FT_Error error; - FT_Fixed x_scale = size->metrics.x_scale; - FT_Fixed y_scale = size->metrics.y_scale; - AH_Face_Globals* face_globals = FACE_GLOBALS( face ); + FT_Face face = slot->face; + FT_Error error; + FT_Fixed x_scale = size->metrics.x_scale; + FT_Fixed y_scale = size->metrics.y_scale; + AH_Face_Globals face_globals = FACE_GLOBALS( face ); + FT_Render_Mode hint_mode = FT_LOAD_TARGET_MODE(load_flags); /* first of all, we need to check that we're using the correct face and */ @@ -1366,6 +1408,25 @@ ah_loader_rewind( hinter->loader ); + /* reset hinting flags according to load flags and current render target */ + hinter->do_horz_hints = !FT_BOOL( load_flags & FT_LOAD_NO_AUTOHINT ); + hinter->do_vert_hints = !FT_BOOL( load_flags & FT_LOAD_NO_AUTOHINT ); + +#ifdef DEBUG_HINTER + hinter->do_horz_hints = !ah_debug_disable_vert; /* not a bug, the meaning */ + hinter->do_vert_hints = !ah_debug_disable_horz; /* of h/v is inverted! */ +#endif + + /* we snap the width of vertical stems for the monochrome and */ + /* horizontal LCD rendering targets only. Corresponds to X snapping. */ + hinter->do_horz_snapping = FT_BOOL( hint_mode == FT_RENDER_MODE_MONO || + hint_mode == FT_RENDER_MODE_LCD ); + + /* we snap the width of horizontal stems for the monochrome and */ + /* vertical LCD rendering targets only. Corresponds to Y snapping. */ + hinter->do_vert_snapping = FT_BOOL( hint_mode == FT_RENDER_MODE_MONO || + hint_mode == FT_RENDER_MODE_LCD_V ); + #if 1 load_flags = FT_LOAD_NO_SCALE | FT_LOAD_IGNORE_TRANSFORM ; @@ -1382,14 +1443,14 @@ /* retrieve a face's autohint globals for client applications */ FT_LOCAL_DEF( void ) - ah_hinter_get_global_hints( AH_Hinter* hinter, - FT_Face face, - void** global_hints, - long* global_len ) + ah_hinter_get_global_hints( AH_Hinter hinter, + FT_Face face, + void** global_hints, + long* global_len ) { - AH_Globals* globals = 0; - FT_Memory memory = hinter->memory; - FT_Error error; + AH_Globals globals = 0; + FT_Memory memory = hinter->memory; + FT_Error error; /* allocate new master globals */ @@ -1419,8 +1480,8 @@ FT_LOCAL_DEF( void ) - ah_hinter_done_global_hints( AH_Hinter* hinter, - void* global_hints ) + ah_hinter_done_global_hints( AH_Hinter hinter, + void* global_hints ) { FT_Memory memory = hinter->memory; diff --git a/src/libs/freetype2/autohint/ahhint.h b/src/libs/freetype2/autohint/ahhint.h index b0857f38483..2c352d0c99c 100644 --- a/src/libs/freetype2/autohint/ahhint.h +++ b/src/libs/freetype2/autohint/ahhint.h @@ -32,39 +32,39 @@ FT_BEGIN_HEADER #define AH_HINT_DEFAULT 0 #define AH_HINT_NO_ALIGNMENT 1 -#define AH_HINT_NO_HORZ_EDGES 0x20000L -#define AH_HINT_NO_VERT_EDGES 0x40000L +#define AH_HINT_NO_HORZ_EDGES 0x200000L /* temporary hack */ +#define AH_HINT_NO_VERT_EDGES 0x400000L /* temporary hack */ /* create a new empty hinter object */ FT_LOCAL( FT_Error ) - ah_hinter_new( FT_Library library, - AH_Hinter** ahinter ); + ah_hinter_new( FT_Library library, + AH_Hinter* ahinter ); /* Load a hinted glyph in the hinter */ FT_LOCAL( FT_Error ) - ah_hinter_load_glyph( AH_Hinter* hinter, + ah_hinter_load_glyph( AH_Hinter hinter, FT_GlyphSlot slot, FT_Size size, FT_UInt glyph_index, - FT_Int load_flags ); + FT_Int32 load_flags ); /* finalize a hinter object */ FT_LOCAL( void ) - ah_hinter_done( AH_Hinter* hinter ); + ah_hinter_done( AH_Hinter hinter ); FT_LOCAL( void ) - ah_hinter_done_face_globals( AH_Face_Globals* globals ); + ah_hinter_done_face_globals( AH_Face_Globals globals ); FT_LOCAL( void ) - ah_hinter_get_global_hints( AH_Hinter* hinter, - FT_Face face, - void** global_hints, - long* global_len ); + ah_hinter_get_global_hints( AH_Hinter hinter, + FT_Face face, + void** global_hints, + long* global_len ); FT_LOCAL( void ) - ah_hinter_done_global_hints( AH_Hinter* hinter, - void* global_hints ); + ah_hinter_done_global_hints( AH_Hinter hinter, + void* global_hints ); FT_END_HEADER diff --git a/src/libs/freetype2/autohint/ahmodule.c b/src/libs/freetype2/autohint/ahmodule.c index 5da456b1c90..1819e9ef92c 100644 --- a/src/libs/freetype2/autohint/ahmodule.c +++ b/src/libs/freetype2/autohint/ahmodule.c @@ -25,15 +25,15 @@ #ifdef DEBUG_HINTER - extern AH_Hinter* ah_debug_hinter = NULL; - extern FT_Bool ah_debug_disable_horz = 0; - extern FT_Bool ah_debug_disable_vert = 0; + AH_Hinter ah_debug_hinter = NULL; + FT_Bool ah_debug_disable_horz = 0; + FT_Bool ah_debug_disable_vert = 0; #endif typedef struct FT_AutoHinterRec_ { FT_ModuleRec root; - AH_Hinter* hinter; + AH_Hinter hinter; } FT_AutoHinterRec; @@ -69,7 +69,7 @@ FT_GlyphSlot slot, FT_Size size, FT_UInt glyph_index, - FT_ULong load_flags ) + FT_Int32 load_flags ) { return ah_hinter_load_glyph( module->hinter, slot, size, glyph_index, load_flags ); @@ -83,7 +83,7 @@ FT_UNUSED( module ); if ( face->autohint.data ) - ah_hinter_done_face_globals( (AH_Face_Globals*)(face->autohint.data) ); + ah_hinter_done_face_globals( (AH_Face_Globals)(face->autohint.data) ); } diff --git a/src/libs/freetype2/autohint/ahoptim.c b/src/libs/freetype2/autohint/ahoptim.c index 6b4cdf0c6cb..8d10f4a4dba 100644 --- a/src/libs/freetype2/autohint/ahoptim.c +++ b/src/libs/freetype2/autohint/ahoptim.c @@ -157,8 +157,8 @@ static int - valid_stem_segments( AH_Segment* seg1, - AH_Segment* seg2 ) + valid_stem_segments( AH_Segment seg1, + AH_Segment seg2 ) { return seg1->serif == 0 && seg2 && @@ -173,15 +173,15 @@ static int optim_compute_stems( AH_Optimizer* optimizer ) { - AH_Outline* outline = optimizer->outline; - FT_Fixed scale; - FT_Memory memory = optimizer->memory; - FT_Error error = 0; - FT_Int dimension; - AH_Edge* edges; - AH_Edge* edge_limit; - AH_Stem** p_stems; - FT_Int* p_num_stems; + AH_Outline outline = optimizer->outline; + FT_Fixed scale; + FT_Memory memory = optimizer->memory; + FT_Error error = 0; + FT_Int dimension; + AH_Edge edges; + AH_Edge edge_limit; + AH_Stem** p_stems; + FT_Int* p_num_stems; edges = outline->horz_edges; @@ -195,13 +195,13 @@ { AH_Stem* stems = 0; FT_Int num_stems = 0; - AH_Edge* edge; + AH_Edge edge; /* first of all, count the number of stems in this direction */ for ( edge = edges; edge < edge_limit; edge++ ) { - AH_Segment* seg = edge->first; + AH_Segment seg = edge->first; do @@ -226,8 +226,8 @@ stem = stems; for ( edge = edges; edge < edge_limit; edge++ ) { - AH_Segment* seg = edge->first; - AH_Segment* seg2; + AH_Segment seg = edge->first; + AH_Segment seg2; do @@ -235,8 +235,8 @@ seg2 = seg->link; if ( valid_stem_segments( seg, seg2 ) ) { - AH_Edge* edge1 = seg->edge; - AH_Edge* edge2 = seg2->edge; + AH_Edge edge1 = seg->edge; + AH_Edge edge2 = seg2->edge; stem->edge1 = edge1; @@ -721,8 +721,8 @@ stem->edge1->pos = pos; stem->edge2->pos = pos + stem->width; - stem->edge1->flags |= ah_edge_done; - stem->edge2->flags |= ah_edge_done; + stem->edge1->flags |= AH_EDGE_DONE; + stem->edge2->flags |= AH_EDGE_DONE; } } @@ -768,8 +768,8 @@ stem->edge1->pos = pos; stem->edge2->pos = pos + stem->width; - stem->edge1->flags |= ah_edge_done; - stem->edge2->flags |= ah_edge_done; + stem->edge1->flags |= AH_EDGE_DONE; + stem->edge2->flags |= AH_EDGE_DONE; } } @@ -808,13 +808,13 @@ /* loads the outline into the optimizer */ int AH_Optimizer_Init( AH_Optimizer* optimizer, - AH_Outline* outline, + AH_Outline outline, FT_Memory memory ) { FT_Error error; - FT_MEM_SET( optimizer, 0, sizeof ( *optimizer ) ); + FT_MEM_ZERO( optimizer, sizeof ( *optimizer ) ); optimizer->outline = outline; optimizer->memory = memory; diff --git a/src/libs/freetype2/autohint/ahoptim.h b/src/libs/freetype2/autohint/ahoptim.h index c3e927d117a..d7862ba9656 100644 --- a/src/libs/freetype2/autohint/ahoptim.h +++ b/src/libs/freetype2/autohint/ahoptim.h @@ -37,22 +37,22 @@ FT_BEGIN_HEADER typedef struct AH_Stem_ { - FT_Pos pos; /* current position */ - FT_Pos velocity; /* current velocity */ - FT_Pos force; /* sum of current forces */ - FT_Pos width; /* normalized width */ + FT_Pos pos; /* current position */ + FT_Pos velocity; /* current velocity */ + FT_Pos force; /* sum of current forces */ + FT_Pos width; /* normalized width */ - FT_Pos min_pos; /* minimum grid position */ - FT_Pos max_pos; /* maximum grid position */ + FT_Pos min_pos; /* minimum grid position */ + FT_Pos max_pos; /* maximum grid position */ - AH_Edge* edge1; /* left/bottom edge */ - AH_Edge* edge2; /* right/top edge */ + AH_Edge edge1; /* left/bottom edge */ + AH_Edge edge2; /* right/top edge */ - FT_Pos opos; /* original position */ - FT_Pos owidth; /* original width */ + FT_Pos opos; /* original position */ + FT_Pos owidth; /* original width */ - FT_Pos min_coord; /* minimum coordinate */ - FT_Pos max_coord; /* maximum coordinate */ + FT_Pos min_coord; /* minimum coordinate */ + FT_Pos max_coord; /* maximum coordinate */ } AH_Stem; @@ -81,7 +81,7 @@ FT_BEGIN_HEADER typedef struct AH_Optimizer_ { FT_Memory memory; - AH_Outline* outline; + AH_Outline outline; FT_Int num_hstems; AH_Stem* horz_stems; @@ -115,7 +115,7 @@ FT_BEGIN_HEADER /* loads the outline into the optimizer */ int AH_Optimizer_Init( AH_Optimizer* optimizer, - AH_Outline* outline, + AH_Outline outline, FT_Memory memory ); diff --git a/src/libs/freetype2/autohint/ahtypes.h b/src/libs/freetype2/autohint/ahtypes.h index 60f278d6a5d..50d0f86ebfc 100644 --- a/src/libs/freetype2/autohint/ahtypes.h +++ b/src/libs/freetype2/autohint/ahtypes.h @@ -92,7 +92,7 @@ FT_BEGIN_HEADER /* no reason to do this (at least for non-CJK scripts), except for */ /* experimentation. */ /* */ -#define AH_HINT_METRICS +#undef AH_HINT_METRICS /*************************************************************************/ @@ -126,63 +126,65 @@ FT_BEGIN_HEADER /* hint flags */ -#define ah_flag_none 0 +#define AH_FLAG_NONE 0 /* bezier control points flags */ -#define ah_flag_conic 1 -#define ah_flag_cubic 2 -#define ah_flag_control ( ah_flag_conic | ah_flag_cubic ) +#define AH_FLAG_CONIC 1 +#define AH_FLAG_CUBIC 2 +#define AH_FLAG_CONTROL ( AH_FLAG_CONIC | AH_FLAG_CUBIC ) /* extrema flags */ -#define ah_flag_extrema_x 4 -#define ah_flag_extrema_y 8 +#define AH_FLAG_EXTREMA_X 4 +#define AH_FLAG_EXTREMA_Y 8 /* roundness */ -#define ah_flag_round_x 16 -#define ah_flag_round_y 32 +#define AH_FLAG_ROUND_X 16 +#define AH_FLAG_ROUND_Y 32 /* touched */ -#define ah_flag_touch_x 64 -#define ah_flag_touch_y 128 +#define AH_FLAG_TOUCH_X 64 +#define AH_FLAG_TOUCH_Y 128 /* weak interpolation */ -#define ah_flag_weak_interpolation 256 +#define AH_FLAG_WEAK_INTERPOLATION 256 +#define AH_FLAG_INFLECTION 512 typedef FT_Int AH_Flags; /* edge hint flags */ -#define ah_edge_normal 0 -#define ah_edge_round 1 -#define ah_edge_serif 2 -#define ah_edge_done 4 +#define AH_EDGE_NORMAL 0 +#define AH_EDGE_ROUND 1 +#define AH_EDGE_SERIF 2 +#define AH_EDGE_DONE 4 typedef FT_Int AH_Edge_Flags; /* hint directions -- the values are computed so that two vectors are */ /* in opposite directions iff `dir1+dir2 == 0' */ -#define ah_dir_none 4 -#define ah_dir_right 1 -#define ah_dir_left -1 -#define ah_dir_up 2 -#define ah_dir_down -2 +#define AH_DIR_NONE 4 +#define AH_DIR_RIGHT 1 +#define AH_DIR_LEFT -1 +#define AH_DIR_UP 2 +#define AH_DIR_DOWN -2 typedef FT_Int AH_Direction; - typedef struct AH_Point AH_Point; - typedef struct AH_Segment AH_Segment; - typedef struct AH_Edge AH_Edge; + typedef struct AH_PointRec_* AH_Point; + typedef struct AH_SegmentRec_* AH_Segment; + typedef struct AH_EdgeRec_* AH_Edge; /*************************************************************************/ /* */ /* <Struct> */ - /* AH_Point */ + /* AH_PointRec */ /* */ /* <Description> */ - /* A structure used to model an outline point to the AH_Outline type. */ + /* A structure used to model an outline point to the AH_OutlineRec */ + /* type. */ /* */ /* <Fields> */ /* flags :: The current point hint flags. */ @@ -207,7 +209,7 @@ FT_BEGIN_HEADER /* */ /* prev :: The previous point in same contour. */ /* */ - struct AH_Point + typedef struct AH_PointRec_ { AH_Flags flags; /* point flags used by hinter */ FT_Pos ox, oy; @@ -221,15 +223,16 @@ FT_BEGIN_HEADER AH_Angle in_angle; AH_Angle out_angle; - AH_Point* next; /* next point in contour */ - AH_Point* prev; /* previous point in contour */ - }; + AH_Point next; /* next point in contour */ + AH_Point prev; /* previous point in contour */ + + } AH_PointRec; /*************************************************************************/ /* */ /* <Struct> */ - /* AH_Segment */ + /* AH_SegmentRec */ /* */ /* <Description> */ /* A structure used to describe an edge segment to the auto-hinter. */ @@ -264,33 +267,34 @@ FT_BEGIN_HEADER /* */ /* score :: Used to score the segment when selecting them. */ /* */ - struct AH_Segment + typedef struct AH_SegmentRec_ { AH_Edge_Flags flags; AH_Direction dir; - AH_Point* first; /* first point in edge segment */ - AH_Point* last; /* last point in edge segment */ - AH_Point** contour; /* ptr to first point of segment's contour */ + AH_Point first; /* first point in edge segment */ + AH_Point last; /* last point in edge segment */ + AH_Point* contour; /* ptr to first point of segment's contour */ FT_Pos pos; /* position of segment */ FT_Pos min_coord; /* minimum coordinate of segment */ FT_Pos max_coord; /* maximum coordinate of segment */ - AH_Edge* edge; - AH_Segment* edge_next; + AH_Edge edge; + AH_Segment edge_next; - AH_Segment* link; /* link segment */ - AH_Segment* serif; /* primary segment for serifs */ + AH_Segment link; /* link segment */ + AH_Segment serif; /* primary segment for serifs */ FT_Pos num_linked; /* number of linked segments */ - FT_Int score; - }; + FT_Pos score; + + } AH_SegmentRec; /*************************************************************************/ /* */ /* <Struct> */ - /* AH_Edge */ + /* AH_EdgeRec */ /* */ /* <Description> */ /* A structure used to describe an edge, which really is a horizontal */ @@ -324,29 +328,30 @@ FT_BEGIN_HEADER /* Only set for some of the horizontal edges in a Latin */ /* font. */ /* */ - struct AH_Edge + typedef struct AH_EdgeRec_ { AH_Edge_Flags flags; AH_Direction dir; - AH_Segment* first; - AH_Segment* last; + AH_Segment first; + AH_Segment last; FT_Pos fpos; FT_Pos opos; FT_Pos pos; - AH_Edge* link; - AH_Edge* serif; + AH_Edge link; + AH_Edge serif; FT_Int num_linked; FT_Int score; FT_Pos* blue_edge; - }; + + } AH_EdgeRec; /* an outline as seen by the hinter */ - typedef struct AH_Outline_ + typedef struct AH_OutlineRec_ { FT_Memory memory; @@ -359,39 +364,39 @@ FT_BEGIN_HEADER FT_Int max_points; FT_Int num_points; - AH_Point* points; + AH_Point points; FT_Int max_contours; FT_Int num_contours; - AH_Point** contours; + AH_Point * contours; FT_Int num_hedges; - AH_Edge* horz_edges; + AH_Edge horz_edges; FT_Int num_vedges; - AH_Edge* vert_edges; + AH_Edge vert_edges; FT_Int num_hsegments; - AH_Segment* horz_segments; + AH_Segment horz_segments; FT_Int num_vsegments; - AH_Segment* vert_segments; + AH_Segment vert_segments; - } AH_Outline; + } AH_OutlineRec, *AH_Outline; -#define ah_blue_capital_top 0 /* THEZOCQS */ -#define ah_blue_capital_bottom ( ah_blue_capital_top + 1 ) /* HEZLOCUS */ -#define ah_blue_small_top ( ah_blue_capital_bottom + 1 ) /* xzroesc */ -#define ah_blue_small_bottom ( ah_blue_small_top + 1 ) /* xzroesc */ -#define ah_blue_small_minor ( ah_blue_small_bottom + 1 ) /* pqgjy */ -#define ah_blue_max ( ah_blue_small_minor + 1 ) +#define AH_BLUE_CAPITAL_TOP 0 /* THEZOCQS */ +#define AH_BLUE_CAPITAL_BOTTOM ( AH_BLUE_CAPITAL_TOP + 1 ) /* HEZLOCUS */ +#define AH_BLUE_SMALL_TOP ( AH_BLUE_CAPITAL_BOTTOM + 1 ) /* xzroesc */ +#define AH_BLUE_SMALL_BOTTOM ( AH_BLUE_SMALL_TOP + 1 ) /* xzroesc */ +#define AH_BLUE_SMALL_MINOR ( AH_BLUE_SMALL_BOTTOM + 1 ) /* pqgjy */ +#define AH_BLUE_MAX ( AH_BLUE_SMALL_MINOR + 1 ) typedef FT_Int AH_Blue; -#define ah_hinter_monochrome 1 -#define ah_hinter_optimize 2 +#define AH_HINTER_MONOCHROME 1 +#define AH_HINTER_OPTIMIZE 2 typedef FT_Int AH_Hinter_Flags; @@ -399,7 +404,7 @@ FT_BEGIN_HEADER /*************************************************************************/ /* */ /* <Struct> */ - /* AH_Globals */ + /* AH_GlobalsRec */ /* */ /* <Description> */ /* Holds the global metrics for a given font face (be it in design */ @@ -418,24 +423,26 @@ FT_BEGIN_HEADER /* */ /* blue_shoots :: The overshoot positions of blue zones. */ /* */ - typedef struct AH_Globals_ + typedef struct AH_GlobalsRec_ { FT_Int num_widths; FT_Int num_heights; + FT_Pos stds[2]; + FT_Pos widths [AH_MAX_WIDTHS]; FT_Pos heights[AH_MAX_HEIGHTS]; - FT_Pos blue_refs [ah_blue_max]; - FT_Pos blue_shoots[ah_blue_max]; + FT_Pos blue_refs [AH_BLUE_MAX]; + FT_Pos blue_shoots[AH_BLUE_MAX]; - } AH_Globals; + } AH_GlobalsRec, *AH_Globals; /*************************************************************************/ /* */ /* <Struct> */ - /* AH_Face_Globals */ + /* AH_Face_GlobalsRec */ /* */ /* <Description> */ /* Holds the complete global metrics for a given font face (i.e., the */ @@ -453,19 +460,19 @@ FT_BEGIN_HEADER /* */ /* y_scale :: The current vertical scale. */ /* */ - typedef struct AH_Face_Globals_ + typedef struct AH_Face_GlobalsRec_ { FT_Face face; - AH_Globals design; - AH_Globals scaled; + AH_GlobalsRec design; + AH_GlobalsRec scaled; FT_Fixed x_scale; FT_Fixed y_scale; FT_Bool control_overshoot; - } AH_Face_Globals; + } AH_Face_GlobalsRec, *AH_Face_Globals; - typedef struct AH_Hinter + typedef struct AH_HinterRec { FT_Memory memory; AH_Hinter_Flags flags; @@ -473,9 +480,9 @@ FT_BEGIN_HEADER FT_Int algorithm; FT_Face face; - AH_Face_Globals* globals; + AH_Face_Globals globals; - AH_Outline* glyph; + AH_Outline glyph; AH_Loader loader; FT_Vector pp1; @@ -485,11 +492,16 @@ FT_BEGIN_HEADER FT_Vector trans_delta; FT_Matrix trans_matrix; - } AH_Hinter; + FT_Bool do_horz_hints; /* disable X hinting */ + FT_Bool do_vert_hints; /* disable Y hinting */ + FT_Bool do_horz_snapping; /* disable X stem size snapping */ + FT_Bool do_vert_snapping; /* disable Y stem size snapping */ + + } AH_HinterRec, *AH_Hinter; #ifdef DEBUG_HINTER - extern AH_Hinter* ah_debug_hinter; + extern AH_Hinter ah_debug_hinter; extern FT_Bool ah_debug_disable_horz; extern FT_Bool ah_debug_disable_vert; #else diff --git a/src/libs/freetype2/base/descrip.mms b/src/libs/freetype2/base/descrip.mms index 8639e04d57b..ac304d0aa8f 100644 --- a/src/libs/freetype2/base/descrip.mms +++ b/src/libs/freetype2/base/descrip.mms @@ -15,7 +15,7 @@ CFLAGS=$(COMP_FLAGS)$(DEBUG)/include=([--.builds.vms],[--.include],[--.src.base]) -OBJS=ftbase.obj,ftinit.obj,ftglyph.obj,ftdebug.obj,ftbdf.obj,ftmm.obj,fttype1.obj,ftxf86.obj +OBJS=ftbase.obj,ftinit.obj,ftglyph.obj,ftdebug.obj,ftbdf.obj,ftmm.obj,fttype1.obj,ftxf86.obj,ftpfr.obj all : $(OBJS) library [--.lib]freetype.olb $(OBJS) diff --git a/src/libs/freetype2/base/ftbbox.c b/src/libs/freetype2/base/ftbbox.c index 2e080517ded..dd445d810d6 100644 --- a/src/libs/freetype2/base/ftbbox.c +++ b/src/libs/freetype2/base/ftbbox.c @@ -602,7 +602,7 @@ if ( y < cbox.yMin ) cbox.yMin = y; if ( y > cbox.yMax ) cbox.yMax = y; - if ( FT_CURVE_TAG( outline->tags[n] ) == FT_Curve_Tag_On ) + if ( FT_CURVE_TAG( outline->tags[n] ) == FT_CURVE_TAG_ON ) { /* update bbox for `on' points only */ if ( x < bbox.xMin ) bbox.xMin = x; diff --git a/src/libs/freetype2/base/ftdbgmem.c b/src/libs/freetype2/base/ftdbgmem.c index 6ca02dadff3..125b5b70aff 100644 --- a/src/libs/freetype2/base/ftdbgmem.c +++ b/src/libs/freetype2/base/ftdbgmem.c @@ -202,7 +202,7 @@ if ( new_buckets == NULL ) return; - FT_MEM_SET( new_buckets, 0, sizeof ( FT_MemNode ) * new_size ); + FT_MEM_ZERO( new_buckets, sizeof ( FT_MemNode ) * new_size ); for ( i = 0; i < table->size; i++ ) { @@ -243,7 +243,7 @@ if ( table == NULL ) goto Exit; - FT_MEM_SET( table, 0, sizeof ( *table ) ); + FT_MEM_ZERO( table, sizeof ( *table ) ); table->size = FT_MEM_SIZE_MIN; table->nodes = 0; @@ -260,7 +260,7 @@ memory->alloc( memory, table->size * sizeof ( FT_MemNode ) ); if ( table->buckets ) - FT_MEM_SET( table->buckets, 0, sizeof ( FT_MemNode ) * table->size ); + FT_MEM_ZERO( table->buckets, sizeof ( FT_MemNode ) * table->size ); else { memory->free( memory, table ); diff --git a/src/libs/freetype2/base/ftdebug.c b/src/libs/freetype2/base/ftdebug.c index 4c6bcc55ccc..48a214380f6 100644 --- a/src/libs/freetype2/base/ftdebug.c +++ b/src/libs/freetype2/base/ftdebug.c @@ -86,7 +86,7 @@ #define FT_TRACE_DEF(x) #x , static const char* ft_trace_toggles[trace_count + 1] = - { + { #include FT_INTERNAL_TRACE_H NULL }; @@ -98,9 +98,9 @@ /* */ /* Initialize the tracing sub-system. This is done by retrieving the */ /* value of the "FT2_DEBUG" environment variable. It must be a list of */ - /* toggles, separated by spaces, `;' or `:'. Example: */ + /* toggles, separated by spaces, `;' or `,'. Example: */ /* */ - /* "any=3 memory=6 stream=5" */ + /* "any:3 memory:6 stream:5" */ /* */ /* This will request that all levels be set to 3, except the trace level */ /* for the memory and stream components which are set to 6 and 5, */ @@ -116,48 +116,48 @@ ft_debug_init( void ) { const char* ft2_debug = getenv( "FT2_DEBUG" ); - + if ( ft2_debug ) { const char* p = ft2_debug; const char* q; - + for ( ; *p; p++ ) { /* skip leading whitespace and separators */ - if ( *p == ' ' || *p == '\t' || *p == ':' || *p == ';' || *p == '=' ) + if ( *p == ' ' || *p == '\t' || *p == ',' || *p == ';' || *p == '=' ) continue; - - /* read toggle name, followed by '=' */ + + /* read toggle name, followed by ':' */ q = p; - while ( *p && *p != '=' ) + while ( *p && *p != ':' ) p++; - if ( *p == '=' && p > q ) + if ( *p == ':' && p > q ) { - int n, i, len = p - q; - int level = -1, found = -1; - + FT_Int n, i, len = (FT_Int)(p - q); + FT_Int level = -1, found = -1; + for ( n = 0; n < trace_count; n++ ) { const char* toggle = ft_trace_toggles[n]; - + for ( i = 0; i < len; i++ ) { if ( toggle[i] != q[i] ) break; } - + if ( i == len && toggle[i] == 0 ) { found = n; break; } } - + /* read level */ p++; if ( *p ) @@ -166,7 +166,7 @@ if ( level < 0 || level > 6 ) level = -1; } - + if ( found >= 0 && level >= 0 ) { if ( found == trace_any ) diff --git a/src/libs/freetype2/base/ftglyph.c b/src/libs/freetype2/base/ftglyph.c index 1f0989fe5a3..9f3d6fd4b00 100644 --- a/src/libs/freetype2/base/ftglyph.c +++ b/src/libs/freetype2/base/ftglyph.c @@ -147,7 +147,7 @@ FT_Memory memory = library->memory; - if ( slot->format != ft_glyph_format_bitmap ) + if ( slot->format != FT_GLYPH_FORMAT_BITMAP ) { error = FT_Err_Invalid_Glyph_Format; goto Exit; @@ -209,14 +209,14 @@ const FT_Glyph_Class ft_bitmap_glyph_class = { sizeof( FT_BitmapGlyphRec ), - ft_glyph_format_bitmap, - - (FT_Glyph_Init_Func) ft_bitmap_glyph_init, - (FT_Glyph_Done_Func) ft_bitmap_glyph_done, - (FT_Glyph_Copy_Func) ft_bitmap_glyph_copy, - (FT_Glyph_Transform_Func)0, - (FT_Glyph_BBox_Func) ft_bitmap_glyph_bbox, - (FT_Glyph_Prepare_Func) 0 + FT_GLYPH_FORMAT_BITMAP, + + (FT_Glyph_InitFunc) ft_bitmap_glyph_init, + (FT_Glyph_DoneFunc) ft_bitmap_glyph_done, + (FT_Glyph_CopyFunc) ft_bitmap_glyph_copy, + (FT_Glyph_TransformFunc)0, + (FT_Glyph_GetBBoxFunc) ft_bitmap_glyph_bbox, + (FT_Glyph_PrepareFunc) 0 }; @@ -240,7 +240,7 @@ /* check format in glyph slot */ - if ( slot->format != ft_glyph_format_outline ) + if ( slot->format != FT_GLYPH_FORMAT_OUTLINE ) { error = FT_Err_Invalid_Glyph_Format; goto Exit; @@ -262,8 +262,8 @@ FT_MEM_COPY( target->contours, source->contours, source->n_contours * sizeof ( FT_Short ) ); - /* copy all flags, except the `ft_outline_owner' one */ - target->flags = source->flags | ft_outline_owner; + /* copy all flags, except the `FT_OUTLINE_OWNER' one */ + target->flags = source->flags | FT_OUTLINE_OWNER; Exit: return error; @@ -319,9 +319,9 @@ ft_outline_glyph_prepare( FT_OutlineGlyph glyph, FT_GlyphSlot slot ) { - slot->format = ft_glyph_format_outline; + slot->format = FT_GLYPH_FORMAT_OUTLINE; slot->outline = glyph->outline; - slot->outline.flags &= ~ft_outline_owner; + slot->outline.flags &= ~FT_OUTLINE_OWNER; return FT_Err_Ok; } @@ -330,14 +330,14 @@ const FT_Glyph_Class ft_outline_glyph_class = { sizeof( FT_OutlineGlyphRec ), - ft_glyph_format_outline, - - (FT_Glyph_Init_Func) ft_outline_glyph_init, - (FT_Glyph_Done_Func) ft_outline_glyph_done, - (FT_Glyph_Copy_Func) ft_outline_glyph_copy, - (FT_Glyph_Transform_Func)ft_outline_glyph_transform, - (FT_Glyph_BBox_Func) ft_outline_glyph_bbox, - (FT_Glyph_Prepare_Func) ft_outline_glyph_prepare + FT_GLYPH_FORMAT_OUTLINE, + + (FT_Glyph_InitFunc) ft_outline_glyph_init, + (FT_Glyph_DoneFunc) ft_outline_glyph_done, + (FT_Glyph_CopyFunc) ft_outline_glyph_copy, + (FT_Glyph_TransformFunc)ft_outline_glyph_transform, + (FT_Glyph_GetBBoxFunc) ft_outline_glyph_bbox, + (FT_Glyph_PrepareFunc) ft_outline_glyph_prepare }; @@ -435,11 +435,11 @@ return FT_Err_Invalid_Argument; /* if it is a bitmap, that's easy :-) */ - if ( slot->format == ft_glyph_format_bitmap ) + if ( slot->format == FT_GLYPH_FORMAT_BITMAP ) clazz = &ft_bitmap_glyph_class; /* it it is an outline too */ - else if ( slot->format == ft_glyph_format_outline ) + else if ( slot->format == FT_GLYPH_FORMAT_OUTLINE ) clazz = &ft_outline_glyph_class; else @@ -566,13 +566,13 @@ /* documentation is in ftglyph.h */ FT_EXPORT_DEF( FT_Error ) - FT_Glyph_To_Bitmap( FT_Glyph* the_glyph, - FT_ULong render_mode, - FT_Vector* origin, - FT_Bool destroy ) + FT_Glyph_To_Bitmap( FT_Glyph* the_glyph, + FT_Render_Mode render_mode, + FT_Vector* origin, + FT_Bool destroy ) { FT_GlyphSlotRec dummy; - FT_Error error; + FT_Error error = FT_Err_Ok; FT_Glyph glyph; FT_BitmapGlyph bitmap = NULL; @@ -591,10 +591,15 @@ goto Bad; clazz = glyph->clazz; + + /* when called with a bitmap glyph, do nothing and return succesfully */ + if ( clazz == &ft_bitmap_glyph_class ) + goto Exit; + if ( !clazz || !clazz->glyph_prepare ) goto Bad; - FT_MEM_SET( &dummy, 0, sizeof ( dummy ) ); + FT_MEM_ZERO( &dummy, sizeof ( dummy ) ); dummy.library = glyph->library; dummy.format = clazz->glyph_format; diff --git a/src/libs/freetype2/base/fthash.c b/src/libs/freetype2/base/fthash.c index bd3cb21ffcd..c42b1dcf4b3 100644 --- a/src/libs/freetype2/base/fthash.c +++ b/src/libs/freetype2/base/fthash.c @@ -1,4 +1,6 @@ -#include "fthash.h" +#include <ft2build.h> +#include FT_TYPES_H +#include FT_INTERNAL_HASH_H #include FT_INTERNAL_MEMORY_H #include FT_INTERNAL_DEBUG_H @@ -27,7 +29,7 @@ table->mask = 0; table->slack = 0; - table->compare = NULL; + table->node_equal = NULL; } } @@ -45,18 +47,22 @@ - FT_BASE_DEF( void ) - ft_hash_init( FT_Hash table, - FT_Hash_CompareFunc compare, - FT_Memory memory ) + FT_BASE_DEF( FT_Error ) + ft_hash_init( FT_Hash table, + FT_Hash_EqualFunc equal, + FT_Memory memory ) { - hash->memory = memory; - hash->compare = node_compare; - hash->p = 0; - hash->mask = FT_HASH_INITIAL_SIZE-1; - hash->slack = FT_HASH_INITIAL_SIZE*FT_HASH_MAX_LOAD; + FT_Error error; + + 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 ); - FT_NEW_ARRAY( hash->buckets, FT_HASH_INITIAL_SIZE*2 ); + return error; } @@ -84,12 +90,13 @@ - FT_BASE_DEF( FT_HashNode* ) + FT_BASE_DEF( FT_HashLookup ) ft_hash_lookup( FT_Hash table, FT_HashNode keynode ) { - FT_UInt index; - FT_UInt23 hash = keynode->hash; + FT_UInt index; + FT_UInt32 hash = keynode->hash; + FT_HashNode node, *pnode; index = (FT_UInt)(hash & table->mask); if ( index < table->p ) @@ -102,7 +109,7 @@ if ( node == NULL ) break; - if ( node->hash == hash && table->compare( node, keynode ) ) + if ( node->hash == hash && table->node_equal( node, keynode ) ) break; pnode = &node->link; @@ -114,20 +121,22 @@ - FT_BASE_DEF( void ) - ft_hash_add( FT_Hash table, - FT_HashNode* pnode, - FT_HashNode new_node ) + FT_BASE_DEF( FT_Error ) + ft_hash_add( FT_Hash table, + FT_HashLookup lookup, + FT_HashNode new_node ) { + FT_Error error = 0; + /* add it to the hash table */ - new_node->link = *pnode; - *pnode = new_node; + new_node->link = *lookup; + *lookup = new_node; if ( --table->slack < 0 ) { FT_UInt p = table->p; FT_UInt mask = table->mask; - FT_HashNode new_list; + FT_HashNode new_list, node, *pnode; /* split a single bucket */ new_list = NULL; @@ -154,33 +163,41 @@ if ( p >= mask ) { - FT_RENEW_ARRAY( hash->buckets, (mask+1)*2, (mask+1)*4 ); + FT_Memory memory = table->memory; + + + if (FT_RENEW_ARRAY( table->buckets, (mask+1)*2, (mask+1)*4 )) + goto Exit; + table->mask = 2*mask + 1; table->p = 0; } else table->p = p + 1; } + Exit: + return error; } - FT_BASE_DEF( FT_Int ) - ft_hash_remove( FT_Hash table, - FT_HashNode* pnode ) + FT_BASE_DEF( FT_Error ) + ft_hash_remove( FT_Hash table, + FT_HashLookup lookup ) { FT_HashNode node; FT_UInt num_buckets; + FT_Error error = 0; FT_ASSERT( pnode != NULL && node != NULL ); - node = *pnode; - *pnode->link = node->link; - node->link = NULL; + node = *lookup; + *lookup = node->link; + node->link = NULL; num_buckets = ( table->p + table->mask + 1) ; - if ( ++ table->slack > num_buckets*FT_HASH_SUB_LOAD ) + if ( ++ table->slack > (FT_Long)num_buckets*FT_HASH_SUB_LOAD ) { FT_UInt p = table->p; FT_UInt mask = table->mask; @@ -189,14 +206,26 @@ FT_HashNode* pold; if ( old_index < FT_HASH_INITIAL_SIZE ) - return; + goto Exit; if ( p == 0 ) { + FT_Memory memory = table->memory; + table->mask >>= 1; p = table->mask; - FT_RENEW_ARRAY( hash->buckets, (mask+1)*2, (mask) ); + if ( FT_RENEW_ARRAY( table->buckets, (mask+1)*2, (mask+1) ) ) + { + /* this should never happen normally, but who knows :-) */ + /* we need to re-inject the node in the hash table before */ + /* returning there, since it's safer */ + pnode = table->buckets; + node->link = *pnode; + *pnode = node; + + goto Exit; + } } else p--; @@ -212,4 +241,6 @@ table->slack -= FT_HASH_MAX_LOAD; table->p = p; } + Exit: + return error; } diff --git a/src/libs/freetype2/base/ftinit.c b/src/libs/freetype2/base/ftinit.c index 7b92dc49f6c..79ba9f0bd2a 100644 --- a/src/libs/freetype2/base/ftinit.c +++ b/src/libs/freetype2/base/ftinit.c @@ -93,7 +93,7 @@ /* notify errors, but don't stop */ if ( error ) { - FT_ERROR(( "FT_Add_Default_Module: Cannot install `%s', error = %x\n", + FT_ERROR(( "FT_Add_Default_Module: Cannot install `%s', error = 0x%x\n", (*cur)->module_name, error )); } cur++; diff --git a/src/libs/freetype2/base/ftmac.c b/src/libs/freetype2/base/ftmac.c index d433992e389..2d37d397e03 100644 --- a/src/libs/freetype2/base/ftmac.c +++ b/src/libs/freetype2/base/ftmac.c @@ -530,11 +530,11 @@ return error; } - args.flags = ft_open_stream; + args.flags = FT_OPEN_STREAM; args.stream = stream; if ( driver_name ) { - args.flags = args.flags | ft_open_driver; + args.flags = args.flags | FT_OPEN_DRIVER; args.driver = FT_Get_Module( library, driver_name ); } @@ -910,7 +910,7 @@ #endif /* let it fall through to normal loader (.ttf, .otf, etc.) */ - args.flags = ft_open_pathname; + args.flags = FT_OPEN_PATHNAME; args.pathname = (char*)pathname; return FT_Open_Face( library, &args, face_index, aface ); } diff --git a/src/libs/freetype2/base/ftobject.c b/src/libs/freetype2/base/ftobject.c index db8565ba0d1..34e41e943f5 100644 --- a/src/libs/freetype2/base/ftobject.c +++ b/src/libs/freetype2/base/ftobject.c @@ -1,14 +1,23 @@ -#include "ftobject.c" +#include <ft2build.h> +#include FT_INTERNAL_OBJECT_H +#include FT_INTERNAL_DEBUG_H +#include FT_INTERNAL_OBJECTS_H #define FT_MAGIC_DEATH 0xDEADdead #define FT_MAGIC_CLASS 0x12345678 +#define FT_TYPE_HASH(x) (( (FT_UInt32)(x) >> 2 )^( (FT_UInt32)(x) >> 10 )) + #define FT_OBJECT_CHECK(o) \ - ( FT_OBJECT(o) != NULL && \ - FT_OBJECT(o)->clazz != NULL && \ - FT_OBJECT(o)->ref_count >= 1 && \ + ( FT_OBJECT(o) != NULL && \ + FT_OBJECT(o)->clazz != NULL && \ + FT_OBJECT(o)->ref_count >= 1 && \ FT_OBJECT(o)->clazz->magic == FT_MAGIC_CLASS ) +#define FT_CLASS_CHECK(c) \ + ( FT_CLASS(c) != NULL && FT_CLASS(c)->magic == FT_MAGIC_CLASS ) + +#define FT_ASSERT_IS_CLASS(c) FT_ASSERT( FT_CLASS_CHECK(c) ) /*******************************************************************/ /*******************************************************************/ @@ -20,42 +29,43 @@ /*******************************************************************/ /*******************************************************************/ - /* we use a dynamic hash table to map types to classes */ - /* this structure defines the layout of each node of */ - /* this table */ - typedef struct FT_ClassHNodeRec_ - { - FT_HashNodeRec hnode; - FT_Type ctype; - FT_Class clazz; + /* forward declaration */ + FT_BASE_DEF( FT_Error ) + ft_metaclass_init( FT_MetaClass meta, + FT_Library library ); - } FT_ClassHNodeRec, *FT_ClassHNode; + /* forward declaration */ + FT_BASE_DEF( void ) + ft_metaclass_done( FT_MetaClass meta ); - /* the meta class contains a type -> class mapping */ - /* and owns all class objects.. */ - /* */ - typedef struct FT_MetaClassRec_ + /* class type for the meta-class itself */ + static const FT_TypeRec ft_meta_class_type = { - FT_ClassRec clazz; - FT_HashRec type_to_class; + "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 + }; - } FT_MetaClassRec, *FT_MetaClass; - /* forward declaration */ - static const FT_TypeRec ft_meta_class_type; /* destroy a given class */ static void ft_class_hnode_destroy( FT_ClassHNode node ) { - FT_Clazz clazz = node->clazz; + FT_Class clazz = node->clazz; FT_Memory memory = clazz->memory; - FT_Type ctype = clazz->type; - if ( ctype->class_done ) - ctype->class_done( clazz ); + if ( clazz->class_done ) + clazz->class_done( (FT_Object) clazz ); FT_FREE( clazz ); @@ -67,32 +77,81 @@ static FT_Int - ft_class_hnode_compare( const FT_ClassHNode node1, - const FT_ClassHNode node2 ) + ft_type_equal( FT_Type type1, + FT_Type type2 ) + { + if ( type1 == type2 ) + goto Ok; + + if ( type1 == NULL || type2 == NULL ) + goto Fail; + + /* compare parent types */ + if ( type1->super != type2->super ) + { + if ( type1->super == NULL || + type2->super == NULL || + !ft_type_equal( type1, type2 ) ) + goto Fail; + } + + /* compare type names */ + if ( type1->name != type2->name ) + { + if ( type1->name == NULL || + type2->name == NULL || + ft_strcmp( type1->name, type2->name ) != 0 ) + goto Fail; + } + + /* compare the other type fields */ + if ( type1->class_size != type2->class_size || + type1->class_init != type2->class_init || + type1->class_done != type2->class_done || + type1->obj_size != type2->obj_size || + type1->obj_init != type2->obj_init || + type1->obj_done != type2->obj_done ) + goto Fail; + + Ok: + return 1; + + Fail: + return 0; + } + + + static FT_Int + ft_class_hnode_equal( const FT_ClassHNode node1, + const FT_ClassHNode node2 ) { - return ( node1->type == node2->type ); + FT_Type type1 = node1->type; + FT_Type type2 = node2->type; + + /* comparing the pointers should work in 99% of cases */ + return ( type1 == type2 ) ? 1 : ft_type_equal( type1, type2 ); } - static void + FT_BASE_DEF( void ) ft_metaclass_done( FT_MetaClass meta ) { - /* clear all objects */ + /* clear all classes */ ft_hash_done( &meta->type_to_class, - (FT_Hash_ForeachFunc) ft_class_destroy, + (FT_Hash_ForeachFunc) ft_class_hnode_destroy, NULL ); - meta->clazz->object.clazz = NULL; - meta->clazz->object.ref_count = 0; - meta->clazz->magic = FT_MAGIC_DEATH; + meta->clazz.object.clazz = NULL; + meta->clazz.object.ref_count = 0; + meta->clazz.magic = FT_MAGIC_DEATH; } - static void + FT_BASE_DEF( FT_Error ) ft_metaclass_init( FT_MetaClass meta, FT_Library library ) { - FT_ClassRec* clazz = meta->clazz; + FT_ClassRec* clazz = (FT_ClassRec*) &meta->clazz; /* the meta-class is its OWN class !! */ clazz->object.clazz = (FT_Class) clazz; @@ -100,65 +159,131 @@ clazz->magic = FT_MAGIC_CLASS; clazz->library = library; clazz->memory = library->memory; - clazz->type = &ft_metaclass_type; + clazz->type = &ft_meta_class_type; clazz->info = NULL; + clazz->class_done = (FT_Object_DoneFunc) ft_metaclass_done; + clazz->obj_size = sizeof( FT_ClassRec ); clazz->obj_init = NULL; clazz->obj_done = NULL; - ft_hash_init( &meta->type_to_class, - (FT_Hash_CompareFunc) ft_class_hnode_compare, - library->memory ); + return ft_hash_init( &meta->type_to_class, + (FT_Hash_EqualFunc) ft_class_hnode_equal, + library->memory ); } /* find or create the class corresponding to a given type */ + /* note that this function will retunr NULL in case of */ + /* memory overflow */ + /* */ static FT_Class ft_metaclass_get_class( FT_MetaClass meta, FT_Type ctype ) { FT_ClassHNodeRec keynode, *node, **pnode; FT_Memory memory; + FT_ClassRec* clazz; + FT_Class parent; + FT_Error error; - keynode.hnode.hash = (FT_UInt32)( ctype >> 2 ); - keynode.type = type; + keynode.hnode.hash = FT_TYPE_HASH( ctype ); + keynode.type = ctype; - pnode = (FT_ClassHNode) ft_hash_lookup( &meta->type_to_class, - &noderec ); + pnode = (FT_ClassHNode*) ft_hash_lookup( &meta->type_to_class, + (FT_HashNode) &keynode ); node = *pnode; if ( node != NULL ) - return node->clazz; + { + clazz = (FT_ClassRec*) node->clazz; + goto Exit; + } memory = FT_CLASS__MEMORY(meta); - node = FT_MEM_SAFE_ALLOC( sizeof(*node) ); - if ( node != NULL ) + clazz = NULL; + parent = NULL; + if ( ctype->super != NULL ) { - FT_ClassRec* clazz; + FT_ASSERT( ctype->super->class_size <= ctype->class_size ); + FT_ASSERT( ctype->super->obj_size <= ctype->obj_size ); + + parent = ft_metaclass_get_class( meta, ctype->super ); + } + + if ( !FT_NEW( node ) ) + { + if ( !FT_ALLOC( clazz, ctype->class_size ) ) + { + if ( parent ) + FT_MEM_COPY( (FT_ClassRec*)clazz, parent, parent->type->class_size ); + + clazz->object.clazz = (FT_Class) meta; + clazz->object.ref_count = 1; + + clazz->memory = memory; + clazz->library = FT_CLASS__LIBRARY(meta); + clazz->super = parent; + clazz->type = ctype; + clazz->info = NULL; + clazz->magic = FT_MAGIC_CLASS; + + clazz->class_done = ctype->class_done; + clazz->obj_size = ctype->obj_size; + clazz->obj_init = ctype->obj_init; + clazz->obj_done = ctype->obj_done; + + if ( parent ) + { + if ( clazz->class_done == NULL ) + clazz->class_done = parent->class_done; + + if ( clazz->obj_init == NULL ) + clazz->obj_init = parent->obj_init; + + if ( clazz->obj_done == NULL ) + clazz->obj_done = parent->obj_done; + } + + /* find class initializer, if any */ + { + FT_Type ztype = ctype; + FT_Object_InitFunc cinit = NULL; + + do + { + cinit = ztype->class_init; + if ( cinit != NULL ) + break; + + ztype = ztype->super; + } + while ( ztype != NULL ); + + /* then call it when needed */ + if ( cinit != NULL ) + error = cinit( (FT_Object) clazz, NULL ); + } + } - clazz = FT_MEM_SAFE_ALLOC( ctype->class_size ); - if ( clazz == NULL ) + if (error) { + if ( clazz ) + { + /* we always call the class destructor when */ + /* an error was detected in the constructor !! */ + if ( clazz->class_done ) + clazz->class_done( (FT_Object) clazz ); + + FT_FREE( clazz ); + } FT_FREE( node ); - FT_XTHROW( FT_Err_Out_Of_Memory ); } } - } - - - 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 - }; + Exit: + return (FT_Class) clazz; + } @@ -186,7 +311,6 @@ { if ( FT_OBJECT_CHECK(obj) ) { - FT_Object o = FT_OBJECT(obj); FT_Class c = FT_OBJECT__CLASS(obj); do @@ -200,103 +324,73 @@ return (clazz == NULL); } + return 0; } - /* the cleanup routine for all objects */ - static void - ft_object_cleanup( FT_Object object ) - { - FT_Memory memory = FT_OBJECT__MEMORY(object); - FT_Class clazz = FT_OBJECT__CLASS(object); - - if ( clazz->obj_done ) - clazz->obj_done( object ); - - FT_FREE( object ); - } - - - FT_BASE_DEF( FT_Object ) - ft_object_new( FT_Class clazz, - FT_Pointer init_data ) - { - FT_Memory memory; - FT_Object obj; - - - FT_ASSERT_IS_CLASS(clazz); - - memory = FT_CLASS__MEMORY(clazz); - obj = ft_mem_alloc( clazz->obj_size, memory ); - obj->clazz = clazz; - obj->ref_count = 1; - - if ( clazz->obj_init ) - { - FT_CleanupStack stack = FT_MEMORY__CLEANUP(memory); - - - ft_cleanup_push( stack, obj, (FT_CleanupFunc) ft_object_cleanup, NULL ); - - clazz->obj_init( obj, init_data ); - - ft_cleanup_pop( stack, obj, 0 ); - } - return obj; - } - - - - FT_BASE_DEF( void ) + FT_BASE_DEF( FT_Error ) ft_object_create( FT_Object *pobject, FT_Class clazz, FT_Pointer init_data ) { FT_Memory memory; + FT_Error error; FT_Object obj; FT_ASSERT_IS_CLASS(clazz); - memory = FT_CLASS__MEMORY(memory); - obj = ft_mem_alloc( clazz->obj_size, memory ); - obj->clazz = clazz; - obj->ref_count = 1; - *pobject = obj; + memory = FT_CLASS__MEMORY(clazz); + if ( !FT_ALLOC( obj, clazz->obj_size ) ) + { + obj->clazz = clazz; + obj->ref_count = 1; - if ( clazz->obj_init ) - clazz->obj_init( obj, init_data ); + if ( clazz->obj_init ) + { + error = clazz->obj_init( obj, init_data ); + if ( error ) + { + /* IMPORTANT: call the destructor when an error */ + /* was detected in the constructor !! */ + if ( clazz->obj_done ) + clazz->obj_done( obj ); + + FT_FREE( obj ); + } + } + } + *pobject = obj; + return error; } FT_BASE_DEF( FT_Class ) - ft_class_find_by_type( FT_Type type, - FT_Memory memory ) + ft_class_find_by_type( FT_Type type, + FT_Library library ) { - } + FT_MetaClass meta = &library->meta_class; + return ft_metaclass_get_class( meta, type ); + } - FT_BASE_DEF( FT_Class ) - ft_class_find_by_name( FT_CString class_name, - FT_Memory memory ); - - FT_BASE_DEF( FT_Object ) - ft_object_new_from_type( FT_Type type, - FT_Pointer data, - FT_Memory memory ); - FT_BASE_DEF( void ) + FT_BASE_DEF( FT_Error ) ft_object_create_from_type( FT_Object *pobject, FT_Type type, FT_Pointer init_data, - FT_Memory memory ); - - FT_BASE_DEF( void ) - ft_object_push( FT_Object object ); - - FT_BASE_DEF( void ) - ft_object_pop( FT_Object object ); + FT_Library library ) + { + FT_Class clazz; + FT_Error error; - FT_BASE_DEF( void ) - ft_object_pop_destroy( FT_Object object ); + clazz = ft_class_find_by_type( type, library ); + if ( clazz ) + error = ft_object_create( pobject, clazz, init_data ); + else + { + *pobject = NULL; + error = FT_Err_Out_Of_Memory; + } + return error; + } diff --git a/src/libs/freetype2/base/ftobjs.c b/src/libs/freetype2/base/ftobjs.c index 0fce50cd720..4f53ca1416b 100644 --- a/src/libs/freetype2/base/ftobjs.c +++ b/src/libs/freetype2/base/ftobjs.c @@ -75,9 +75,9 @@ /* create a new input stream from a FT_Open_Args structure */ /* */ static FT_Error - ft_input_stream_new( FT_Library library, - FT_Open_Args* args, - FT_Stream* astream ) + ft_input_stream_new( FT_Library library, + const FT_Open_Args* args, + FT_Stream* astream ) { FT_Error error; FT_Memory memory; @@ -98,20 +98,20 @@ stream->memory = memory; - if ( args->flags & ft_open_memory ) + if ( args->flags & FT_OPEN_MEMORY ) { /* create a memory-based stream */ FT_Stream_OpenMemory( stream, (const FT_Byte*)args->memory_base, args->memory_size ); } - else if ( args->flags & ft_open_pathname ) + else if ( args->flags & FT_OPEN_PATHNAME ) { /* create a normal system stream */ error = FT_Stream_Open( stream, args->pathname ); stream->pathname.pointer = args->pathname; } - else if ( ( args->flags & ft_open_stream ) && args->stream ) + else if ( ( args->flags & FT_OPEN_STREAM ) && args->stream ) { /* use an existing, user-provided stream */ @@ -211,9 +211,14 @@ } /* clear all public fields in the glyph slot */ - FT_MEM_SET( &slot->metrics, 0, sizeof ( slot->metrics ) ); - FT_MEM_SET( &slot->outline, 0, sizeof ( slot->outline ) ); - FT_MEM_SET( &slot->bitmap, 0, sizeof ( slot->bitmap ) ); + FT_ZERO( &slot->metrics ); + FT_ZERO( &slot->outline ); + + slot->bitmap.width = 0; + slot->bitmap.rows = 0; + slot->bitmap.pitch = 0; + slot->bitmap.pixel_mode = 0; + /* don't touch 'slot->bitmap.buffer' !! */ slot->bitmap_left = 0; slot->bitmap_top = 0; @@ -222,7 +227,7 @@ slot->control_data = 0; slot->control_len = 0; slot->other = 0; - slot->format = ft_glyph_format_none; + slot->format = FT_GLYPH_FORMAT_NONE; slot->linearHoriAdvance = 0; slot->linearVertAdvance = 0; @@ -380,6 +385,23 @@ } + /* documentation is in freetype.h */ + + FT_EXPORT_DEF( void ) + FT_Set_Hint_Flags( FT_Face face, + FT_ULong flags ) + { + FT_Face_Internal internal; + + if ( !face ) + return; + + internal = face->internal; + + internal->hint_flags = (FT_UInt)flags; + } + + static FT_Renderer ft_lookup_glyph_renderer( FT_GlyphSlot slot ); @@ -387,9 +409,9 @@ /* documentation is in freetype.h */ FT_EXPORT_DEF( FT_Error ) - FT_Load_Glyph( FT_Face face, - FT_UInt glyph_index, - FT_Int load_flags ) + FT_Load_Glyph( FT_Face face, + FT_UInt glyph_index, + FT_Int32 load_flags ) { FT_Error error; FT_Driver driver; @@ -416,6 +438,7 @@ /* disable scaling, hinting, and transformation */ load_flags |= FT_LOAD_NO_SCALE | FT_LOAD_NO_HINTING | + FT_LOAD_NO_BITMAP | FT_LOAD_IGNORE_TRANSFORM; /* disable bitmap rendering */ @@ -426,10 +449,12 @@ library = driver->root.library; hinter = library->auto_hinter; autohint = - FT_BOOL( hinter && - !( load_flags & ( FT_LOAD_NO_SCALE | FT_LOAD_NO_HINTING ) ) && - FT_DRIVER_IS_SCALABLE( driver ) && - FT_DRIVER_USES_OUTLINES( driver ) ); + FT_BOOL( hinter && + !( load_flags & ( FT_LOAD_NO_SCALE | + FT_LOAD_NO_HINTING | + FT_LOAD_NO_AUTOHINT ) ) && + FT_DRIVER_IS_SCALABLE( driver ) && + FT_DRIVER_USES_OUTLINES( driver ) ); if ( autohint ) { if ( FT_DRIVER_HAS_HINTER( driver ) && @@ -447,13 +472,14 @@ /* XXX: This is really a temporary hack that should disappear */ /* promptly with FreeType 2.1! */ /* */ - if ( FT_HAS_FIXED_SIZES( face ) ) + if ( FT_HAS_FIXED_SIZES( face ) && + ( load_flags & FT_LOAD_NO_BITMAP ) == 0 ) { error = driver->clazz->load_glyph( slot, face->size, glyph_index, load_flags | FT_LOAD_SBITS_ONLY ); - if ( !error && slot->format == ft_glyph_format_bitmap ) + if ( !error && slot->format == FT_GLYPH_FORMAT_BITMAP ) goto Load_Ok; } @@ -530,14 +556,18 @@ /* do we need to render the image now? */ if ( !error && - slot->format != ft_glyph_format_bitmap && - slot->format != ft_glyph_format_composite && + slot->format != FT_GLYPH_FORMAT_BITMAP && + slot->format != FT_GLYPH_FORMAT_COMPOSITE && load_flags & FT_LOAD_RENDER ) { - error = FT_Render_Glyph( slot, - ( load_flags & FT_LOAD_MONOCHROME ) - ? ft_render_mode_mono - : ft_render_mode_normal ); + FT_Render_Mode mode = FT_LOAD_TARGET_MODE( load_flags ); + + + if ( mode == FT_RENDER_MODE_NORMAL && + (load_flags & FT_LOAD_MONOCHROME ) ) + mode = FT_RENDER_MODE_MONO; + + error = FT_Render_Glyph( slot, mode ); } Exit: @@ -550,7 +580,7 @@ FT_EXPORT_DEF( FT_Error ) FT_Load_Char( FT_Face face, FT_ULong char_code, - FT_Int load_flags ) + FT_Int32 load_flags ) { FT_UInt glyph_index; @@ -614,8 +644,6 @@ if ( face->generic.finalizer ) face->generic.finalizer( face ); -#ifdef FT_CONFIG_OPTION_USE_CMAPS - /* discard charmaps */ { FT_Int n; @@ -635,8 +663,6 @@ face->num_charmaps = 0; } -#endif /* FT_CONFIG_OPTION_USE_CMAPS */ - /* finalize format-specific stuff */ if ( clazz->done_face ) @@ -712,14 +738,48 @@ face->memory = memory; face->stream = stream; +#ifdef FT_CONFIG_OPTION_INCREMENTAL + { + int i; + + + face->internal->incremental_interface = 0; + for ( i = 0; i < num_params && !face->internal->incremental_interface; + i++ ) + if ( params[i].tag == FT_PARAM_TAG_INCREMENTAL ) + face->internal->incremental_interface = params[i].data; + } +#endif + error = clazz->init_face( stream, face, - face_index, + (FT_Int)face_index, num_params, params ); if ( error ) goto Fail; + /* select Unicode charmap by default */ + { + FT_Int nn; + FT_CharMap unicmap = NULL, cmap; + + + for ( nn = 0; nn < face->num_charmaps; nn++ ) + { + cmap = face->charmaps[nn]; + + if ( cmap->encoding == FT_ENCODING_UNICODE ) + { + unicmap = cmap; + break; + } + } + + if ( unicmap != NULL ) + face->charmap = unicmap; + } + *aface = face; Fail: @@ -755,7 +815,7 @@ if ( !pathname ) return FT_Err_Invalid_Argument; - args.flags = ft_open_pathname; + args.flags = FT_OPEN_PATHNAME; args.pathname = (char*)pathname; return FT_Open_Face( library, &args, face_index, aface ); @@ -780,7 +840,7 @@ if ( !file_base ) return FT_Err_Invalid_Argument; - args.flags = ft_open_memory; + args.flags = FT_OPEN_MEMORY; args.memory_base = file_base; args.memory_size = file_size; @@ -791,10 +851,10 @@ /* documentation is in freetype.h */ FT_EXPORT_DEF( FT_Error ) - FT_Open_Face( FT_Library library, - FT_Open_Args* args, - FT_Long face_index, - FT_Face *aface ) + FT_Open_Face( FT_Library library, + const FT_Open_Args* args, + FT_Long face_index, + FT_Face *aface ) { FT_Error error; FT_Driver driver; @@ -813,7 +873,7 @@ *aface = 0; - external_stream = FT_BOOL( ( args->flags & ft_open_stream ) && + external_stream = FT_BOOL( ( args->flags & FT_OPEN_STREAM ) && args->stream ); /* create input stream */ @@ -825,7 +885,7 @@ /* If the font driver is specified in the `args' structure, use */ /* it. Otherwise, we scan the list of registered drivers. */ - if ( ( args->flags & ft_open_driver ) && args->driver ) + if ( ( args->flags & FT_OPEN_DRIVER ) && args->driver ) { driver = FT_DRIVER( args->driver ); @@ -836,7 +896,7 @@ FT_Parameter* params = 0; - if ( args->flags & ft_open_params ) + if ( args->flags & FT_OPEN_PARAMS ) { num_params = args->num_params; params = args->params; @@ -871,14 +931,14 @@ driver = FT_DRIVER( cur[0] ); - if ( args->flags & ft_open_params ) + if ( args->flags & FT_OPEN_PARAMS ) { num_params = args->num_params; params = args->params; } error = open_face( driver, stream, face_index, - num_params, params, &face ); + num_params, params, &face ); if ( !error ) goto Success; @@ -980,7 +1040,7 @@ if ( !filepathname ) return FT_Err_Invalid_Argument; - open.flags = ft_open_pathname; + open.flags = FT_OPEN_PATHNAME; open.pathname = (char*)filepathname; return FT_Attach_Stream( face, &open ); @@ -1024,7 +1084,7 @@ /* close the attached stream */ ft_input_stream_free( stream, (FT_Bool)( parameters->stream && - ( parameters->flags & ft_open_stream ) ) ); + ( parameters->flags & FT_OPEN_STREAM ) ) ); Exit: return error; @@ -1350,12 +1410,12 @@ akerning ); if ( !error ) { - if ( kern_mode != ft_kerning_unscaled ) + if ( kern_mode != FT_KERNING_UNSCALED ) { akerning->x = FT_MulFix( akerning->x, face->size->metrics.x_scale ); akerning->y = FT_MulFix( akerning->y, face->size->metrics.y_scale ); - if ( kern_mode != ft_kerning_unfitted ) + if ( kern_mode != FT_KERNING_UNFITTED ) { akerning->x = ( akerning->x + 32 ) & -64; akerning->y = ( akerning->y + 32 ) & -64; @@ -1503,8 +1563,6 @@ /* documentation is in freetype.h */ -#ifdef FT_CONFIG_OPTION_USE_CMAPS - FT_EXPORT_DEF( FT_UInt ) FT_Get_Char_Index( FT_Face face, FT_ULong charcode ) @@ -1522,25 +1580,6 @@ return result; } -#else /* !FT_CONFIG_OPTION_USE_CMAPS */ - - FT_EXPORT_DEF( FT_UInt ) - FT_Get_Char_Index( FT_Face face, - FT_ULong charcode ) - { - FT_UInt result = 0; - FT_Driver driver; - - - if ( face && face->charmap ) - { - driver = face->driver; - result = driver->clazz->get_char_index( face->charmap, charcode ); - } - return result; - } - -#endif /* !FT_CONFIG_OPTION_USE_CMAPS */ /* documentation is in freetype.h */ @@ -1569,8 +1608,6 @@ /* documentation is in freetype.h */ -#ifdef FT_CONFIG_OPTION_USE_CMAPS - FT_EXPORT_DEF( FT_ULong ) FT_Get_Next_Char( FT_Face face, FT_ULong charcode, @@ -1596,37 +1633,6 @@ return result; } -#else /* !FT_CONFIG_OPTION_USE_CMAPS */ - - FT_EXPORT_DEF( FT_ULong ) - FT_Get_Next_Char( FT_Face face, - FT_ULong charcode, - FT_UInt *agindex ) - { - FT_ULong result = 0; - FT_UInt gindex = 0; - FT_Driver driver; - - - if ( face && face->charmap ) - { - driver = face->driver; - result = driver->clazz->get_next_char( face->charmap, charcode ); - if ( result != 0 ) - { - gindex = driver->clazz->get_char_index( face->charmap, result ); - if ( gindex == 0 ) - result = 0; - } - } - - if ( agindex ) - *agindex = gindex; - - return result; - } - -#endif /* !FT_CONFIG_OPTION_USE_CMAPS */ /* documentation is in freetype.h */ @@ -1858,7 +1864,7 @@ FT_Renderer renderer; - renderer = FT_Lookup_Renderer( library, ft_glyph_format_outline, 0 ); + renderer = FT_Lookup_Renderer( library, FT_GLYPH_FORMAT_OUTLINE, 0 ); library->cur_renderer = renderer; } @@ -1884,7 +1890,7 @@ render->glyph_format = clazz->glyph_format; /* allocate raster object if needed */ - if ( clazz->glyph_format == ft_glyph_format_outline && + if ( clazz->glyph_format == FT_GLYPH_FORMAT_OUTLINE && clazz->raster_class->raster_new ) { error = clazz->raster_class->raster_new( memory, &render->raster ); @@ -1977,12 +1983,12 @@ FT_List_Up( &library->renderers, node ); - if ( renderer->glyph_format == ft_glyph_format_outline ) + if ( renderer->glyph_format == FT_GLYPH_FORMAT_OUTLINE ) library->cur_renderer = renderer; if ( num_params > 0 ) { - FTRenderer_setMode set_mode = renderer->clazz->set_mode; + FT_Renderer_SetModeFunc set_mode = renderer->clazz->set_mode; for ( ; num_params > 0; num_params-- ) @@ -1999,9 +2005,9 @@ FT_BASE_DEF( FT_Error ) - FT_Render_Glyph_Internal( FT_Library library, - FT_GlyphSlot slot, - FT_UInt render_mode ) + FT_Render_Glyph_Internal( FT_Library library, + FT_GlyphSlot slot, + FT_Render_Mode render_mode ) { FT_Error error = FT_Err_Ok; FT_Renderer renderer; @@ -2010,7 +2016,7 @@ /* if it is already a bitmap, no need to do anything */ switch ( slot->format ) { - case ft_glyph_format_bitmap: /* already a bitmap, don't do anything */ + case FT_GLYPH_FORMAT_BITMAP: /* already a bitmap, don't do anything */ break; default: @@ -2020,7 +2026,7 @@ /* small shortcut for the very common case */ - if ( slot->format == ft_glyph_format_outline ) + if ( slot->format == FT_GLYPH_FORMAT_OUTLINE ) { renderer = library->cur_renderer; node = library->renderers.head; @@ -2060,8 +2066,8 @@ /* documentation is in freetype.h */ FT_EXPORT_DEF( FT_Error ) - FT_Render_Glyph( FT_GlyphSlot slot, - FT_UInt render_mode ) + FT_Render_Glyph( FT_GlyphSlot slot, + FT_Render_Mode render_mode ) { FT_Library library; @@ -2187,7 +2193,7 @@ } /* allocate module object */ - if ( FT_ALLOC( module,clazz->module_size ) ) + if ( FT_ALLOC( module, clazz->module_size ) ) goto Exit; /* base initialization */ @@ -2422,13 +2428,13 @@ patch = library->version_patch; } - if ( *amajor ) + if ( amajor ) *amajor = major; - if ( *aminor ) + if ( aminor ) *aminor = minor; - if ( *apatch ) + if ( apatch ) *apatch = patch; } diff --git a/src/libs/freetype2/base/ftoutln.c b/src/libs/freetype2/base/ftoutln.c index cbf2e0f2413..c59043bc049 100644 --- a/src/libs/freetype2/base/ftoutln.c +++ b/src/libs/freetype2/base/ftoutln.c @@ -98,14 +98,14 @@ tag = FT_CURVE_TAG( tags[0] ); /* A contour cannot start with a cubic control point! */ - if ( tag == FT_Curve_Tag_Cubic ) + if ( tag == FT_CURVE_TAG_CUBIC ) goto Invalid_Outline; /* check first point to determine origin */ - if ( tag == FT_Curve_Tag_Conic ) + if ( tag == FT_CURVE_TAG_CONIC ) { /* first point is conic control. Yes, this happens. */ - if ( FT_CURVE_TAG( outline->tags[last] ) == FT_Curve_Tag_On ) + if ( FT_CURVE_TAG( outline->tags[last] ) == FT_CURVE_TAG_ON ) { /* start at last point if it is on the curve */ v_start = v_last; @@ -137,7 +137,7 @@ tag = FT_CURVE_TAG( tags[0] ); switch ( tag ) { - case FT_Curve_Tag_On: /* emit a single line_to */ + case FT_CURVE_TAG_ON: /* emit a single line_to */ { FT_Vector vec; @@ -151,7 +151,7 @@ continue; } - case FT_Curve_Tag_Conic: /* consume conic arcs */ + case FT_CURVE_TAG_CONIC: /* consume conic arcs */ v_control.x = SCALED( point->x ); v_control.y = SCALED( point->y ); @@ -169,7 +169,7 @@ vec.x = SCALED( point->x ); vec.y = SCALED( point->y ); - if ( tag == FT_Curve_Tag_On ) + if ( tag == FT_CURVE_TAG_ON ) { error = func_interface->conic_to( &v_control, &vec, user ); if ( error ) @@ -177,7 +177,7 @@ continue; } - if ( tag != FT_Curve_Tag_Conic ) + if ( tag != FT_CURVE_TAG_CONIC ) goto Invalid_Outline; v_middle.x = ( v_control.x + vec.x ) / 2; @@ -194,13 +194,13 @@ error = func_interface->conic_to( &v_control, &v_start, user ); goto Close; - default: /* FT_Curve_Tag_Cubic */ + default: /* FT_CURVE_TAG_CUBIC */ { FT_Vector vec1, vec2; if ( point + 1 > limit || - FT_CURVE_TAG( tags[1] ) != FT_Curve_Tag_Cubic ) + FT_CURVE_TAG( tags[1] ) != FT_CURVE_TAG_CUBIC ) goto Invalid_Outline; point += 2; @@ -270,12 +270,12 @@ anoutline->n_points = (FT_UShort)numPoints; anoutline->n_contours = (FT_Short)numContours; - anoutline->flags |= ft_outline_owner; + anoutline->flags |= FT_OUTLINE_OWNER; return FT_Err_Ok; Fail: - anoutline->flags |= ft_outline_owner; + anoutline->flags |= FT_OUTLINE_OWNER; FT_Outline_Done_Internal( memory, anoutline ); return error; @@ -334,7 +334,7 @@ if ( end != n_points - 1 ) goto Bad; - /* XXX: check the that array */ + /* XXX: check the tags array */ return 0; } @@ -366,11 +366,11 @@ FT_MEM_COPY( target->contours, source->contours, source->n_contours * sizeof ( FT_Short ) ); - /* copy all flags, except the `ft_outline_owner' one */ - is_owner = target->flags & ft_outline_owner; + /* copy all flags, except the `FT_OUTLINE_OWNER' one */ + is_owner = target->flags & FT_OUTLINE_OWNER; target->flags = source->flags; - target->flags &= ~ft_outline_owner; + target->flags &= ~FT_OUTLINE_OWNER; target->flags |= is_owner; return FT_Err_Ok; @@ -383,7 +383,7 @@ { if ( outline ) { - if ( outline->flags & ft_outline_owner ) + if ( outline->flags & FT_OUTLINE_OWNER ) { FT_FREE( outline->points ); FT_FREE( outline->tags ); @@ -535,7 +535,7 @@ first = last + 1; } - outline->flags ^= ft_outline_reverse_fill; + outline->flags ^= FT_OUTLINE_REVERSE_FILL; } @@ -576,7 +576,7 @@ /* now, look for another renderer that supports the same */ /* format */ - renderer = FT_Lookup_Renderer( library, ft_glyph_format_outline, + renderer = FT_Lookup_Renderer( library, FT_GLYPH_FORMAT_OUTLINE, &node ); update = 1; } @@ -608,8 +608,10 @@ params.target = abitmap; params.flags = 0; - if ( abitmap->pixel_mode == ft_pixel_mode_grays ) - params.flags |= ft_raster_flag_aa; + if ( abitmap->pixel_mode == FT_PIXEL_MODE_GRAY || + abitmap->pixel_mode == FT_PIXEL_MODE_LCD || + abitmap->pixel_mode == FT_PIXEL_MODE_LCD_V ) + params.flags |= FT_RASTER_FLAG_AA; return FT_Outline_Render( library, outline, ¶ms ); } @@ -628,9 +630,9 @@ return; xz = FT_MulFix( vector->x, matrix->xx ) + - FT_MulFix( vector->y, matrix->yx ); + FT_MulFix( vector->y, matrix->xy ); - yz = FT_MulFix( vector->x, matrix->xy ) + + yz = FT_MulFix( vector->x, matrix->yx ) + FT_MulFix( vector->y, matrix->yy ); vector->x = xz; diff --git a/src/libs/freetype2/base/ftsynth.c b/src/libs/freetype2/base/ftsynth.c index e82747be977..45459f3ee56 100644 --- a/src/libs/freetype2/base/ftsynth.c +++ b/src/libs/freetype2/base/ftsynth.c @@ -20,6 +20,7 @@ #include FT_INTERNAL_OBJECTS_H #include FT_INTERNAL_CALC_H #include FT_OUTLINE_H +#include FT_TRIGONOMETRY_H #include FT_SYNTHESIS_H @@ -34,18 +35,18 @@ /*************************************************************************/ /*************************************************************************/ - FT_EXPORT_DEF( FT_Error ) - FT_Outline_Oblique( FT_GlyphSlot original, - FT_Outline* outline, - FT_Pos* advance ) + FT_EXPORT_DEF( void ) + FT_GlyphSlot_Oblique( FT_GlyphSlot slot ) { - FT_Matrix transform; + FT_Matrix transform; + FT_Outline* outline = &slot->outline; - FT_UNUSED( original ); - /* we don't touch the advance width */ - FT_UNUSED( advance ); + /* only oblique outline glyphs */ + if ( slot->format != FT_GLYPH_FORMAT_OUTLINE ) + return; + /* we don't touch the advance width */ /* For italic, simply apply a shear transform, with an angle */ /* of about 12 degrees. */ @@ -57,8 +58,6 @@ transform.yy = 0x10000L; FT_Outline_Transform( outline, &transform ); - - return 0; } @@ -71,97 +70,6 @@ /*************************************************************************/ - /* Compute the norm of a vector */ - -#ifdef FT_CONFIG_OPTION_OLD_CALCS - - static FT_Pos - ft_norm( FT_Vector* vec ) - { - FT_Int64 t1, t2; - - - MUL_64( vec->x, vec->x, t1 ); - MUL_64( vec->y, vec->y, t2 ); - ADD_64( t1, t2, t1 ); - - return (FT_Pos)SQRT_64( t1 ); - } - -#else /* FT_CONFIG_OPTION_OLD_CALCS */ - - static FT_Pos - ft_norm( FT_Vector* vec ) - { - FT_F26Dot6 u, v, d; - FT_Int shift; - FT_ULong H, L, L2, hi, lo, med; - - - u = vec->x; if ( u < 0 ) u = -u; - v = vec->y; if ( v < 0 ) v = -v; - - if ( u < v ) - { - d = u; - u = v; - v = d; - } - - /* check that we are not trying to normalize zero! */ - if ( u == 0 ) - return 0; - - /* compute (u*u + v*v) on 64 bits with two 32-bit registers [H:L] */ - hi = (FT_ULong)u >> 16; - lo = (FT_ULong)u & 0xFFFF; - med = hi * lo; - - H = hi * hi + ( med >> 15 ); - med <<= 17; - L = lo * lo + med; - if ( L < med ) - H++; - - hi = (FT_ULong)v >> 16; - lo = (FT_ULong)v & 0xFFFF; - med = hi * lo; - - H += hi * hi + ( med >> 15 ); - med <<= 17; - L2 = lo * lo + med; - if ( L2 < med ) - H++; - - L += L2; - if ( L < L2 ) - H++; - - /* if the value is smaller than 32 bits */ - shift = 0; - if ( H == 0 ) - { - while ( ( L & 0xC0000000UL ) == 0 ) - { - L <<= 2; - shift++; - } - return ( FT_Sqrt32( L ) >> shift ); - } - else - { - while ( H ) - { - L = ( L >> 2 ) | ( H << 30 ); - H >>= 2; - shift++; - } - return ( FT_Sqrt32( L ) << shift ); - } - } - -#endif /* FT_CONFIG_OPTION_OLD_CALCS */ - static int ft_test_extrema( FT_Outline* outline, @@ -208,7 +116,7 @@ /* Compute the orientation of path filling. It differs between TrueType */ - /* and Type1 formats. We could use the `ft_outline_reverse_fill' flag, */ + /* and Type1 formats. We could use the `FT_OUTLINE_REVERSE_FILL' flag, */ /* but it is better to re-compute it directly (it seems that this flag */ /* isn't correctly set for some weird composite glyphs currently). */ /* */ @@ -291,28 +199,30 @@ } - FT_EXPORT_DEF( FT_Error ) - FT_Outline_Embolden( FT_GlyphSlot original, - FT_Outline* outline, - FT_Pos* advance ) + FT_EXPORT_DEF( void ) + FT_GlyphSlot_Embolden( FT_GlyphSlot slot ) { - FT_Vector u, v; - FT_Vector* points; - FT_Vector cur, prev, next; - FT_Pos distance; - FT_Face face = FT_SLOT_FACE( original ); - int c, n, first, orientation; + FT_Vector* points; + FT_Vector v_prev, v_first, v_next, v_cur; + FT_Pos distance; + FT_Outline* outline = &slot->outline; + FT_Face face = FT_SLOT_FACE( slot ); + FT_Angle rotate, angle_in, angle_out; + FT_Int c, n, first, orientation; - FT_UNUSED( advance ); + /* only embolden outline glyph images */ + if ( slot->format != FT_GLYPH_FORMAT_OUTLINE ) + return; /* compute control distance */ distance = FT_MulFix( face->units_per_EM / 60, face->size->metrics.y_scale ); - orientation = ft_get_orientation( &original->outline ); + orientation = ft_get_orientation( outline ); + rotate = FT_ANGLE_PI2*orientation; - points = original->outline.points; + points = outline->points; first = 0; for ( c = 0; c < outline->n_contours; c++ ) @@ -320,79 +230,56 @@ int last = outline->contours[c]; - prev = points[last]; + v_first = points[first]; + v_prev = points[last]; + v_cur = v_first; for ( n = first; n <= last; n++ ) { - FT_Pos norm, delta, d; + FT_Pos d; FT_Vector in, out; + FT_Fixed scale; + FT_Angle angle_diff; - cur = points[n]; - if ( n < last ) next = points[n + 1]; - else next = points[first]; + if ( n < last ) v_next = points[n + 1]; + else v_next = v_first; /* compute the in and out vectors */ - in.x = cur.x - prev.x; - in.y = cur.y - prev.y; + in.x = v_cur.x - v_prev.x; + in.y = v_cur.y - v_prev.y; - out.x = next.x - cur.x; - out.y = next.y - cur.y; + out.x = v_next.x - v_cur.x; + out.y = v_next.y - v_cur.y; - /* compute U and V */ - norm = ft_norm( &in ); - u.x = orientation * FT_DivFix( in.y, norm ); - u.y = orientation * -FT_DivFix( in.x, norm ); + angle_in = FT_Atan2( in.x, in.y ); + angle_out = FT_Atan2( out.x, out.y ); + angle_diff = FT_Angle_Diff( angle_in, angle_out ); + scale = FT_Cos( angle_diff/2 ); - norm = ft_norm( &out ); - v.x = orientation * FT_DivFix( out.y, norm ); - v.y = orientation * -FT_DivFix( out.x, norm ); - - d = distance; - - if ( ( outline->tags[n] & FT_Curve_Tag_On ) == 0 ) - d *= 2; - - /* Check discriminant for parallel vectors */ - delta = FT_MulFix( u.x, v.y ) - FT_MulFix( u.y, v.x ); - if ( delta > FT_BOLD_THRESHOLD || delta < -FT_BOLD_THRESHOLD ) + if ( scale < 0x400L && scale > -0x400L ) { - /* Move point -- compute A and B */ - FT_Pos x, y, A, B; - - - A = d + FT_MulFix( cur.x, u.x ) + FT_MulFix( cur.y, u.y ); - B = d + FT_MulFix( cur.x, v.x ) + FT_MulFix( cur.y, v.y ); - - x = FT_MulFix( A, v.y ) - FT_MulFix( B, u.y ); - y = FT_MulFix( B, u.x ) - FT_MulFix( A, v.x ); - - outline->points[n].x = distance + FT_DivFix( x, delta ); - outline->points[n].y = distance + FT_DivFix( y, delta ); + if ( scale >= 0 ) + scale = 0x400L; + else + scale = -0x400L; } - else - { - /* Vectors are nearly parallel */ - FT_Pos x, y; + d = FT_DivFix( distance, scale ); - x = distance + cur.x + FT_MulFix( d, u.x + v.x ) / 2; - y = distance + cur.y + FT_MulFix( d, u.y + v.y ) / 2; + FT_Vector_From_Polar( &in, d, angle_in + angle_diff/2 - rotate ); - outline->points[n].x = x; - outline->points[n].y = y; - } + outline->points[n].x = v_cur.x + distance + in.x; + outline->points[n].y = v_cur.y + distance + in.y; - prev = cur; + v_prev = v_cur; + v_cur = v_next; } first = last + 1; } - if ( advance ) - *advance = ( *advance + distance * 4 ) & -64; - - return 0; + slot->metrics.horiAdvance = ( slot->metrics.horiAdvance + distance*4 ) & -64; } diff --git a/src/libs/freetype2/base/fttrigon.c b/src/libs/freetype2/base/fttrigon.c index 155fc5ff26c..744f9a9b56c 100644 --- a/src/libs/freetype2/base/fttrigon.c +++ b/src/libs/freetype2/base/fttrigon.c @@ -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 */ diff --git a/src/libs/freetype2/base/ftutil.c b/src/libs/freetype2/base/ftutil.c index 27dfbf0498f..451bee524c5 100644 --- a/src/libs/freetype2/base/ftutil.c +++ b/src/libs/freetype2/base/ftutil.c @@ -64,7 +64,7 @@ return FT_Err_Out_Of_Memory; } - FT_MEM_SET( *P, 0, size ); + FT_MEM_ZERO( *P, size ); } else *P = NULL; @@ -106,7 +106,7 @@ goto Fail; if ( size > current ) - FT_MEM_SET( (char*)Q + current, 0, size - current ); + FT_MEM_ZERO( (char*)Q + current, size - current ); *P = Q; return FT_Err_Ok; diff --git a/src/libs/freetype2/base/rules.mk b/src/libs/freetype2/base/rules.mk index 5f7816dbf74..0a38faefa90 100644 --- a/src/libs/freetype2/base/rules.mk +++ b/src/libs/freetype2/base/rules.mk @@ -54,6 +54,7 @@ BASE_EXT_SRC := $(BASE_)ftglyph.c \ $(BASE_)ftbdf.c \ $(BASE_)fttype1.c \ $(BASE_)ftxf86.c \ + $(BASE_)ftpfr.c \ $(BASE_)ftbbox.c # Default extensions objects diff --git a/src/libs/freetype2/bdf/bdfdrivr.c b/src/libs/freetype2/bdf/bdfdrivr.c index e0e894b187c..0e9197f07af 100644 --- a/src/libs/freetype2/bdf/bdfdrivr.c +++ b/src/libs/freetype2/bdf/bdfdrivr.c @@ -46,9 +46,6 @@ THE SOFTWARE. #define FT_COMPONENT trace_bdfdriver -#ifdef FT_CONFIG_OPTION_USE_CMAPS - - typedef struct BDF_CMapRec_ { FT_CMapRec cmap; @@ -171,39 +168,6 @@ THE SOFTWARE. }; -#else /* !FT_CONFIG_OPTION_USE_CMAPS */ - - - static FT_UInt - BDF_Get_Char_Index( FT_CharMap charmap, - FT_ULong char_code ) - { - BDF_Face face = (BDF_Face)charmap->face; - BDF_encoding_el* en_table = face->en_table; - int low, high, mid; - - - FT_TRACE4(( "BDF_Get_Char_Index %ld\n", char_code )); - - low = 0; - high = face->bdffont->glyphs_used - 1; - - while ( low <= high ) - { - mid = ( low + high ) / 2; - if ( char_code < en_table[mid].enc ) - high = mid - 1; - else if ( char_code > en_table[mid].enc ) - low = mid + 1; - else - return en_table[mid].glyph + 1; - } - - return face->bdffont->default_glyph + 1; - } - - -#endif /* !FT_CONFIG_OPTION_USE_CMAPS */ FT_CALLBACK_DEF( FT_Error ) @@ -344,11 +308,11 @@ THE SOFTWARE. prop = bdf_get_font_property( font, (char *)"AVERAGE_WIDTH" ); if ( ( prop != NULL ) && ( prop->value.int32 >= 10 ) ) - root->available_sizes->width = prop->value.int32 / 10; + root->available_sizes->width = (short)( prop->value.int32 / 10 ); prop = bdf_get_font_property( font, (char *)"PIXEL_SIZE" ); if ( prop != NULL ) - root->available_sizes->height = prop->value.int32; + root->available_sizes->height = (short) prop->value.int32; else { prop = bdf_get_font_property( font, (char *)"POINT_SIZE" ); @@ -429,63 +393,43 @@ THE SOFTWARE. !ft_strcmp( face->charset_encoding, "1" ) ) ) unicode_charmap = 1; -#ifdef FT_CONFIG_OPTION_USE_CMAPS - { FT_CharMapRec charmap; charmap.face = FT_FACE( face ); - charmap.encoding = ft_encoding_none; + charmap.encoding = FT_ENCODING_NONE; charmap.platform_id = 0; charmap.encoding_id = 0; if ( unicode_charmap ) { - charmap.encoding = ft_encoding_unicode; + charmap.encoding = FT_ENCODING_UNICODE; charmap.platform_id = 3; charmap.encoding_id = 1; } error = FT_CMap_New( &bdf_cmap_class, NULL, &charmap, NULL ); +#if 0 /* Select default charmap */ if (root->num_charmaps) root->charmap = root->charmaps[0]; +#endif } -#else /* !FT_CONFIG_OPTION_USE_CMAPS */ - - face->charmap.encoding = ft_encoding_none; - face->charmap.platform_id = 0; - face->charmap.encoding_id = 0; - if ( unicode_charmap ) - { - face->charmap.encoding = ft_encoding_unicode; - face->charmap.platform_id = 3; - face->charmap.encoding_id = 1; - } - face->charmap.face = root; - face->charmap_handle = &face->charmap; - - root->charmap = face->charmap_handle; - -#endif /* !FT_CONFIG_OPTION_USE_CMAPS */ - goto Exit; } } /* otherwise assume Adobe standard encoding */ -#ifdef FT_CONFIG_OPTION_USE_CMAPS - { FT_CharMapRec charmap; charmap.face = FT_FACE( face ); - charmap.encoding = ft_encoding_adobe_standard; + charmap.encoding = FT_ENCODING_ADOBE_STANDARD; charmap.platform_id = 7; charmap.encoding_id = 0; @@ -495,19 +439,6 @@ THE SOFTWARE. if (root->num_charmaps) root->charmap = root->charmaps[0]; } - -#else /* !FT_CONFIG_OPTION_USE_CMAPS */ - - face->charmap.encoding = ft_encoding_adobe_standard; - face->charmap.platform_id = 7; /* taken from t1objs.c */ - face->charmap.encoding_id = 0; - face->charmap.face = root; - face->charmap_handle = &face->charmap; - - root->charmap = face->charmap_handle; - -#endif /* !FT_CONFIG_OPTION_USE_CMAPS */ - } } @@ -547,7 +478,7 @@ THE SOFTWARE. BDF_Glyph_Load( FT_GlyphSlot slot, FT_Size size, FT_UInt glyph_index, - FT_Int load_flags ) + FT_Int32 load_flags ) { BDF_Face face = (BDF_Face)FT_SIZE_FACE( size ); FT_Error error = BDF_Err_Ok; @@ -579,7 +510,7 @@ THE SOFTWARE. if ( bpp == 1 ) { - bitmap->pixel_mode = ft_pixel_mode_mono; + bitmap->pixel_mode = FT_PIXEL_MODE_MONO; bitmap->pitch = glyph.bpr; if ( FT_NEW_ARRAY( bitmap->buffer, glyph.bytes ) ) @@ -589,7 +520,7 @@ THE SOFTWARE. else { /* blow up pixmap to have 8 bits per pixel */ - bitmap->pixel_mode = ft_pixel_mode_grays; + bitmap->pixel_mode = FT_PIXEL_MODE_GRAY; bitmap->pitch = bitmap->width; if ( FT_NEW_ARRAY( bitmap->buffer, bitmap->rows * bitmap->pitch ) ) @@ -686,12 +617,13 @@ THE SOFTWARE. /* FZ XXX: TODO: vertical metrics */ slot->metrics.horiAdvance = glyph.dwidth << 6; slot->metrics.horiBearingX = glyph.bbx.x_offset << 6; - slot->metrics.horiBearingY = glyph.bbx.y_offset << 6; + slot->metrics.horiBearingY = ( glyph.bbx.y_offset + + glyph.bbx.height ) << 6; slot->metrics.width = bitmap->width << 6; slot->metrics.height = bitmap->rows << 6; slot->linearHoriAdvance = (FT_Fixed)glyph.dwidth << 16; - slot->format = ft_glyph_format_bitmap; + slot->format = FT_GLYPH_FORMAT_BITMAP; slot->flags = FT_GLYPH_OWN_BITMAP; Exit: @@ -733,21 +665,9 @@ THE SOFTWARE. (FT_Slot_LoadFunc) BDF_Glyph_Load, -#ifdef FT_CONFIG_OPTION_USE_CMAPS - (FT_CharMap_CharIndexFunc)0, -#else - (FT_CharMap_CharIndexFunc)BDF_Get_Char_Index, -#endif - (FT_Face_GetKerningFunc) 0, (FT_Face_AttachFunc) 0, - (FT_Face_GetAdvancesFunc) 0, - -#ifdef FT_CONFIG_OPTION_USE_CMAPS - (FT_CharMap_CharNextFunc) 0 -#else - (FT_CharMap_CharNextFunc) 0 /* BDF_Get_Next_Char */ -#endif + (FT_Face_GetAdvancesFunc) 0 }; diff --git a/src/libs/freetype2/bdf/bdflib.c b/src/libs/freetype2/bdf/bdflib.c index f34760e5473..7496e6061c4 100644 --- a/src/libs/freetype2/bdf/bdflib.c +++ b/src/libs/freetype2/bdf/bdflib.c @@ -224,7 +224,7 @@ if ( FT_NEW_ARRAY( ht->table, ht->size ) ) goto Exit; - FT_MEM_SET( ht->table, 0, sizeof ( hashnode ) * ht->size ); + FT_MEM_ZERO( ht->table, sizeof ( hashnode ) * ht->size ); for ( i = 0, bp = obp; i < sz; i++, bp++ ) { @@ -255,7 +255,7 @@ if ( FT_NEW_ARRAY( ht->table, sz ) ) goto Exit; - FT_MEM_SET( ht->table, 0, sizeof ( hashnode ) * sz ); + FT_MEM_ZERO( ht->table, sizeof ( hashnode ) * sz ); Exit: return error; @@ -427,7 +427,7 @@ } /* Prepare the separator bitmap. */ - FT_MEM_SET( seps, 0, 32 ); + FT_MEM_ZERO( seps, 32 ); /* If the very last character of the separator string is a plus, then */ /* set the `mult' flag to indicate that multiple separators should be */ @@ -993,7 +993,7 @@ } p = font->user_props + font->nuser_props; - FT_MEM_SET( p, 0, sizeof ( bdf_property_t ) ); + FT_MEM_ZERO( p, sizeof ( bdf_property_t ) ); n = (unsigned long)( ft_strlen( name ) + 1 ); if ( FT_NEW_ARRAY( p->name, n ) ) @@ -1341,7 +1341,7 @@ } fp = font->props + font->props_size; - FT_MEM_SET( fp, 0, sizeof ( bdf_property_t ) ); + FT_MEM_ZERO( fp, sizeof ( bdf_property_t ) ); font->props_size++; } @@ -1599,9 +1599,8 @@ font->glyphs_size, font->glyphs_size + 64 ) ) goto Exit; - FT_MEM_SET( font->glyphs + font->glyphs_size, - 0, - sizeof ( bdf_glyph_t ) * 64 ); /* FZ inutile */ + FT_MEM_ZERO( font->glyphs + font->glyphs_size, + sizeof ( bdf_glyph_t ) * 64 ); /* FZ inutile */ font->glyphs_size += 64; } @@ -2203,96 +2202,98 @@ bdf_font_t* *font ) { unsigned long lineno; - _bdf_parse_t p; + _bdf_parse_t *p; - FT_Memory memory = NULL; + FT_Memory memory = extmemory; FT_Error error = BDF_Err_Ok; - FT_MEM_SET( &p, 0, sizeof ( _bdf_parse_t ) ); + if ( FT_ALLOC( p, sizeof ( _bdf_parse_t ) ) ) + goto Exit; - p.opts = (bdf_options_t*)( ( opts != 0 ) ? opts : &_bdf_opts ); - p.minlb = 32767; - p.memory = extmemory; /* only during font creation */ + memory = NULL; + p->opts = (bdf_options_t*)( ( opts != 0 ) ? opts : &_bdf_opts ); + p->minlb = 32767; + p->memory = extmemory; /* only during font creation */ error = _bdf_readstream( stream, _bdf_parse_start, - (void *)&p, &lineno ); + (void *)p, &lineno ); if ( error ) goto Exit; - if ( p.font != 0 ) + if ( p->font != 0 ) { /* If the font is not proportional, set the font's monowidth */ /* field to the width of the font bounding box. */ - memory = p.font->memory; + memory = p->font->memory; - if ( p.font->spacing != BDF_PROPORTIONAL ) - p.font->monowidth = p.font->bbx.width; + if ( p->font->spacing != BDF_PROPORTIONAL ) + p->font->monowidth = p->font->bbx.width; /* If the number of glyphs loaded is not that of the original count, */ /* indicate the difference. */ - if ( p.cnt != p.font->glyphs_used + p.font->unencoded_used ) + if ( p->cnt != p->font->glyphs_used + p->font->unencoded_used ) { - FT_TRACE2(( "bdf_load_font: " ACMSG15, p.cnt, - p.font->glyphs_used + p.font->unencoded_used )); - p.font->modified = 1; + FT_TRACE2(( "bdf_load_font: " ACMSG15, p->cnt, + p->font->glyphs_used + p->font->unencoded_used )); + p->font->modified = 1; } /* Once the font has been loaded, adjust the overall font metrics if */ /* necessary. */ - if ( p.opts->correct_metrics != 0 && - ( p.font->glyphs_used > 0 || p.font->unencoded_used > 0 ) ) + if ( p->opts->correct_metrics != 0 && + ( p->font->glyphs_used > 0 || p->font->unencoded_used > 0 ) ) { - if ( p.maxrb - p.minlb != p.font->bbx.width ) + if ( p->maxrb - p->minlb != p->font->bbx.width ) { FT_TRACE2(( "bdf_load_font: " ACMSG3, - p.font->bbx.width, p.maxrb - p.minlb )); - p.font->bbx.width = (unsigned short)( p.maxrb - p.minlb ); - p.font->modified = 1; + p->font->bbx.width, p->maxrb - p->minlb )); + p->font->bbx.width = (unsigned short)( p->maxrb - p->minlb ); + p->font->modified = 1; } - if ( p.font->bbx.x_offset != p.minlb ) + if ( p->font->bbx.x_offset != p->minlb ) { FT_TRACE2(( "bdf_load_font: " ACMSG4, - p.font->bbx.x_offset, p.minlb )); - p.font->bbx.x_offset = p.minlb; - p.font->modified = 1; + p->font->bbx.x_offset, p->minlb )); + p->font->bbx.x_offset = p->minlb; + p->font->modified = 1; } - if ( p.font->bbx.ascent != p.maxas ) + if ( p->font->bbx.ascent != p->maxas ) { FT_TRACE2(( "bdf_load_font: " ACMSG5, - p.font->bbx.ascent, p.maxas )); - p.font->bbx.ascent = p.maxas; - p.font->modified = 1; + p->font->bbx.ascent, p->maxas )); + p->font->bbx.ascent = p->maxas; + p->font->modified = 1; } - if ( p.font->bbx.descent != p.maxds ) + if ( p->font->bbx.descent != p->maxds ) { FT_TRACE2(( "bdf_load_font: " ACMSG6, - p.font->bbx.descent, p.maxds )); - p.font->bbx.descent = p.maxds; - p.font->bbx.y_offset = (short)( -p.maxds ); - p.font->modified = 1; + p->font->bbx.descent, p->maxds )); + p->font->bbx.descent = p->maxds; + p->font->bbx.y_offset = (short)( -p->maxds ); + p->font->modified = 1; } - if ( p.maxas + p.maxds != p.font->bbx.height ) + if ( p->maxas + p->maxds != p->font->bbx.height ) { FT_TRACE2(( "bdf_load_font: " ACMSG7, - p.font->bbx.height, p.maxas + p.maxds )); - p.font->bbx.height = (unsigned short)( p.maxas + p.maxds ); + p->font->bbx.height, p->maxas + p->maxds )); + p->font->bbx.height = (unsigned short)( p->maxas + p->maxds ); } - if ( p.flags & _BDF_SWIDTH_ADJ ) + if ( p->flags & _BDF_SWIDTH_ADJ ) FT_TRACE2(( "bdf_load_font: " ACMSG8 )); } } - if ( p.flags & _BDF_START ) + if ( p->flags & _BDF_START ) { { /* The ENDFONT field was never reached or did not exist. */ - if ( !( p.flags & _BDF_GLYPHS ) ) + if ( !( p->flags & _BDF_GLYPHS ) ) /* Error happened while parsing header. */ FT_ERROR(( "bdf_load_font: " ERRMSG2, lineno )); else @@ -2303,28 +2304,34 @@ /* Free up the list used during the parsing. */ if ( memory != NULL ) - FT_FREE( p.list.field ); + FT_FREE( p->list.field ); - if ( p.font != 0 ) + if ( p->font != 0 ) { /* Make sure the comments are NULL terminated if they exist. */ - memory = p.font->memory; + memory = p->font->memory; - if ( p.font->comments_len > 0 ) { - if ( FT_RENEW_ARRAY( p.font->comments, - p.font->comments_len, - p.font->comments_len + 1 ) ) + if ( p->font->comments_len > 0 ) { + if ( FT_RENEW_ARRAY( p->font->comments, + p->font->comments_len, + p->font->comments_len + 1 ) ) goto Exit; - p.font->comments[p.font->comments_len] = 0; + p->font->comments[p->font->comments_len] = 0; } } else if ( error == BDF_Err_Ok ) error = BDF_Err_Invalid_File_Format; - *font = p.font; + *font = p->font; Exit: + if ( p ) + { + memory = extmemory; + FT_FREE( p ); + } + return error; } diff --git a/src/libs/freetype2/cache/ftccache.c b/src/libs/freetype2/cache/ftccache.c index 00ec2ac1253..14cb725b2c0 100644 --- a/src/libs/freetype2/cache/ftccache.c +++ b/src/libs/freetype2/cache/ftccache.c @@ -24,8 +24,6 @@ #include "ftcerror.h" -#ifdef FTC_CACHE_USE_LINEAR_HASHING - #define FTC_HASH_MAX_LOAD 2 #define FTC_HASH_MIN_LOAD 1 #define FTC_HASH_SUB_LOAD ( FTC_HASH_MAX_LOAD - FTC_HASH_MIN_LOAD ) @@ -33,7 +31,6 @@ /* this one _must_ be a power of 2! */ #define FTC_HASH_INITIAL_SIZE 8 -#endif /* FTC_CACHE_USE_LINEAR_HASHING */ /*************************************************************************/ /*************************************************************************/ @@ -155,8 +152,6 @@ } -#ifdef FTC_CACHE_USE_LINEAR_HASHING - /* remove a node from its cache's hash table */ static FT_Error ftc_node_hash_unlink( FTC_Node node, @@ -164,14 +159,14 @@ { FT_Error error = 0; FTC_Node *pnode; - FT_UInt index, num_buckets; + FT_UInt idx, num_buckets; - - index = (FT_UInt)( node->hash & cache->mask ); - if ( index < cache->p ) - index = (FT_UInt)( node->hash & ( 2 * cache->mask + 1 ) ); - 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 (;;) { @@ -236,41 +231,7 @@ return error; } -#else /* !FTC_CACHE_USE_LINEAR_HASHING */ - - /* remove a node from its cache's hash table */ - static void - ftc_node_hash_unlink( FTC_Node node, - FTC_Cache cache ) - { - FTC_Node *pnode = cache->buckets + ( node->hash % cache->size ); - - - for (;;) - { - if ( *pnode == NULL ) - { - FT_ERROR(( "FreeType.cache.hash_unlink: unknown node!\n" )); - return; - } - - if ( *pnode == node ) - { - *pnode = node->link; - node->link = NULL; - - cache->nodes--; - return; - } - - pnode = &(*pnode)->link; - } - } -#endif /* !FTC_CACHE_USE_LINEAR_HASHING */ - - -#ifdef FTC_CACHE_USE_LINEAR_HASHING /* add a node to the "top" of its cache's hash table */ static FT_Error @@ -278,15 +239,15 @@ FTC_Cache cache ) { FTC_Node *pnode; - FT_UInt index; + FT_UInt idx; FT_Error error = 0; - index = (FT_UInt)( node->hash & cache->mask ); - if ( index < cache->p ) - index = (FT_UInt)( node->hash & (2 * cache->mask + 1 ) ); + idx = (FT_UInt)( node->hash & cache->mask ); + if ( idx < cache->p ) + idx = (FT_UInt)( node->hash & (2 * cache->mask + 1 ) ); - pnode = cache->buckets + index; + pnode = cache->buckets + idx; node->link = *pnode; *pnode = node; @@ -345,23 +306,6 @@ return error; } -#else /* !FTC_CACHE_USE_LINEAR_HASHING */ - - /* add a node to the "top" of its cache's hash table */ - static void - ftc_node_hash_link( FTC_Node node, - FTC_Cache cache ) - { - FTC_Node *pnode = cache->buckets + ( node->hash % cache->size ); - - - node->link = *pnode; - *pnode = node; - - cache->nodes++; - } - -#endif /* !FTC_CACHE_USE_LINEAR_HASHING */ @@ -476,125 +420,6 @@ /*************************************************************************/ /*************************************************************************/ -#ifdef FTC_CACHE_USE_LINEAR_HASHING - - /* nothing */ - -#else /* !FTC_CACHE_USE_LINEAR_HASHING */ - -#define FTC_PRIMES_MIN 7 -#define FTC_PRIMES_MAX 13845163 - - static const FT_UInt ftc_primes[] = - { - 7, - 11, - 19, - 37, - 73, - 109, - 163, - 251, - 367, - 557, - 823, - 1237, - 1861, - 2777, - 4177, - 6247, - 9371, - 14057, - 21089, - 31627, - 47431, - 71143, - 106721, - 160073, - 240101, - 360163, - 540217, - 810343, - 1215497, - 1823231, - 2734867, - 4102283, - 6153409, - 9230113, - 13845163, - }; - - - static FT_UFast - ftc_prime_closest( FT_UFast num ) - { - FT_UInt i; - - - for ( i = 0; i < sizeof ( ftc_primes ) / sizeof ( ftc_primes[0] ); i++ ) - if ( ftc_primes[i] > num ) - return ftc_primes[i]; - - return FTC_PRIMES_MAX; - } - - -#define FTC_CACHE_RESIZE_TEST( c ) \ - ( (c)->nodes*3 < (c)->size || \ - (c)->size*3 < (c)->nodes ) - - - static void - ftc_cache_resize( FTC_Cache cache ) - { - FT_UFast new_size; - - - new_size = ftc_prime_closest( cache->nodes ); - if ( new_size != cache->size ) - { - FT_Memory memory = cache->memory; - FT_Error error; - FTC_Node* new_buckets ; - FT_ULong i; - - - /* no need to report an error; we'll simply keep using the same */ - /* buckets number / size */ - if ( FT_NEW_ARRAY( new_buckets, new_size ) ) - return; - - for ( i = 0; i < cache->size; i++ ) - { - FTC_Node node, next, *pnode; - FT_UFast hash; - - - node = cache->buckets[i]; - while ( node ) - { - next = node->link; - hash = node->hash % new_size; - pnode = new_buckets + hash; - - node->link = pnode[0]; - pnode[0] = node; - - node = next; - } - } - - if ( cache->buckets ) - FT_FREE( cache->buckets ); - - cache->buckets = new_buckets; - cache->size = new_size; - - FT_UNUSED( error ); - } - } - -#endif /* !FTC_CACHE_USE_LINEAR_HASHING */ FT_EXPORT_DEF( FT_Error ) @@ -605,8 +430,6 @@ FT_Error error; -#ifdef FTC_CACHE_USE_LINEAR_HASHING - cache->p = 0; cache->mask = FTC_HASH_INITIAL_SIZE - 1; cache->slack = FTC_HASH_INITIAL_SIZE * FTC_HASH_MAX_LOAD; @@ -614,16 +437,6 @@ if ( FT_NEW_ARRAY( cache->buckets, FTC_HASH_INITIAL_SIZE * 2 ) ) goto Exit; -#else /* !FTC_CACHE_USE_LINEAR_HASHING */ - - cache->nodes = 0; - cache->size = FTC_PRIMES_MIN; - - if ( FT_NEW_ARRAY( cache->buckets, cache->size ) ) - goto Exit; - -#endif /* !FTC_CACHE_USE_LINEAR_HASHING */ - /* now, initialize the lru list of families for this cache */ if ( clazz->family_size > 0 ) { @@ -665,11 +478,7 @@ FT_UFast i; FT_UInt count; -#ifdef FTC_CACHE_USE_LINEAR_HASHING count = cache->p + cache->mask + 1; -#else - count = cache->size; -#endif for ( i = 0; i < count; i++ ) { @@ -696,11 +505,8 @@ cache->buckets[i] = NULL; } -#ifdef FTC_CACHE_USE_LINEAR_HASHING cache->p = 0; -#else - cache->nodes = 0; -#endif + /* destroy the families */ if ( cache->families ) FT_LruList_Reset( cache->families ); @@ -719,12 +525,8 @@ ftc_cache_clear( cache ); FT_FREE( cache->buckets ); -#ifdef FTC_CACHE_USE_LINEAR_HASHING cache->mask = 0; cache->slack = 0; -#else - cache->size = 0; -#endif if ( cache->families ) { @@ -755,8 +557,6 @@ query->hash = 0; query->family = NULL; -#if 1 - /* XXX: we break encapsulation for the sake of speed! */ { /* first of all, find the relevant family */ @@ -799,33 +599,18 @@ ; } -#else - - error = FT_LruList_Lookup( cache->families, query, &lru ); - if ( !error ) - -#endif { FTC_Family family = (FTC_Family) lru; FT_UFast hash = query->hash; FTC_Node* bucket; + FT_UInt idx; -#ifdef FTC_CACHE_USE_LINEAR_HASHING - - FT_UInt index; - - - index = hash & cache->mask; - if ( index < cache->p ) - index = hash & ( cache->mask * 2 + 1 ); - bucket = cache->buckets + index; + idx = hash & cache->mask; + if ( idx < cache->p ) + idx = hash & ( cache->mask * 2 + 1 ); -#else - - bucket = cache->buckets + (hash % cache->size); - -#endif + bucket = cache->buckets + idx; if ( query->family != family || @@ -897,7 +682,6 @@ goto Exit; } -#ifdef FTC_CACHE_USE_LINEAR_HASHING error = ftc_node_hash_link( node, cache ); if ( error ) { @@ -905,9 +689,6 @@ FT_FREE( node ); goto Exit; } -#else - ftc_node_hash_link( node, cache ); -#endif ftc_node_mru_link( node, cache->manager ); @@ -921,12 +702,6 @@ node->ref_count--; } -#ifndef FTC_CACHE_USE_LINEAR_HASHING - /* try to resize the hash table if appropriate */ - if ( FTC_CACHE_RESIZE_TEST( cache ) ) - ftc_cache_resize( cache ); -#endif - *anode = node; } } diff --git a/src/libs/freetype2/cache/ftccache.i b/src/libs/freetype2/cache/ftccache.i index 4cd38db86bf..bb6e631a25b 100644 --- a/src/libs/freetype2/cache/ftccache.i +++ b/src/libs/freetype2/cache/ftccache.i @@ -78,30 +78,16 @@ family = (FTC_Family)lru; hash = query->hash; -#ifdef FTC_CACHE_USE_LINEAR_HASHING { - FT_UInt index; + FT_UInt idx; - index = hash & cache->mask; - if ( index < cache->p ) - index = hash & ( cache->mask * 2 + 1 ); + idx = hash & cache->mask; + if ( idx < cache->p ) + idx = hash & ( cache->mask * 2 + 1 ); - bucket = cache->buckets + index; + bucket = cache->buckets + idx; } -#else - bucket = cache->buckets + ( hash % cache->size ); -#endif - -#ifdef FT_DEBUG_LEVEL_ERROR - if ( query->family != family || - family->fam_index >= cache->manager->families.size ) - { - FT_ERROR(( - "ftc_cache_lookup: invalid query (bad 'family' field)\n" )); - return FTC_Err_Invalid_Argument; - } -#endif pnode = bucket; diff --git a/src/libs/freetype2/cache/ftcimage.c b/src/libs/freetype2/cache/ftcimage.c index 101db8574ea..fa1b6ac7177 100644 --- a/src/libs/freetype2/cache/ftcimage.c +++ b/src/libs/freetype2/cache/ftcimage.c @@ -42,7 +42,7 @@ typedef struct FTC_ImageQueryRec_ { FTC_GlyphQueryRec gquery; - FTC_ImageDesc desc; + FTC_ImageTypeRec type; } FTC_ImageQueryRec, *FTC_ImageQuery; @@ -54,7 +54,7 @@ typedef struct FTC_ImageFamilyRec_ { FTC_GlyphFamilyRec gfam; - FTC_ImageDesc desc; + FTC_ImageTypeRec type; } FTC_ImageFamilyRec, *FTC_ImageFamily; @@ -106,45 +106,18 @@ /* we will now load the glyph image */ error = FTC_Manager_Lookup_Size( FTC_FAMILY( ifam )->cache->manager, - &ifam->desc.font, + &ifam->type.font, &face, &size ); if ( !error ) { - FT_UInt gindex = FTC_GLYPH_NODE_GINDEX( inode ); - FT_UInt load_flags = FT_LOAD_DEFAULT; - FT_UInt type = ifam->desc.type; - - - if ( FTC_IMAGE_FORMAT( type ) == ftc_image_format_bitmap ) - { - load_flags |= FT_LOAD_RENDER; - if ( type & ftc_image_flag_monochrome ) - load_flags |= FT_LOAD_MONOCHROME; - - /* disable embedded bitmaps loading if necessary */ - if ( type & ftc_image_flag_no_sbits ) - load_flags |= FT_LOAD_NO_BITMAP; - } - else if ( FTC_IMAGE_FORMAT( type ) == ftc_image_format_outline ) - { - /* disable embedded bitmaps loading */ - load_flags |= FT_LOAD_NO_BITMAP; + FT_UInt gindex = FTC_GLYPH_NODE_GINDEX( inode ); - if ( type & ftc_image_flag_unscaled ) - load_flags |= FT_LOAD_NO_SCALE; - } - if ( type & ftc_image_flag_unhinted ) - load_flags |= FT_LOAD_NO_HINTING; - - if ( type & ftc_image_flag_autohinted ) - load_flags |= FT_LOAD_FORCE_AUTOHINT; - - error = FT_Load_Glyph( face, gindex, load_flags ); + error = FT_Load_Glyph( face, gindex, ifam->type.flags ); if ( !error ) { - if ( face->glyph->format == ft_glyph_format_bitmap || - face->glyph->format == ft_glyph_format_outline ) + if ( face->glyph->format == FT_GLYPH_FORMAT_BITMAP || + face->glyph->format == FT_GLYPH_FORMAT_OUTLINE ) { /* ok, copy it */ FT_Glyph glyph; @@ -179,7 +152,7 @@ switch ( glyph->format ) { - case ft_glyph_format_bitmap: + case FT_GLYPH_FORMAT_BITMAP: { FT_BitmapGlyph bitg; @@ -190,7 +163,7 @@ } break; - case ft_glyph_format_outline: + case FT_GLYPH_FORMAT_OUTLINE: { FT_OutlineGlyph outg; @@ -231,16 +204,16 @@ FT_Face face; - ifam->desc = iquery->desc; + ifam->type = iquery->type; /* we need to compute "iquery.item_total" now */ error = FTC_Manager_Lookup_Face( manager, - iquery->desc.font.face_id, + iquery->type.font.face_id, &face ); if ( !error ) { error = ftc_glyph_family_init( FTC_GLYPH_FAMILY( ifam ), - FTC_IMAGE_DESC_HASH( &ifam->desc ), + FTC_IMAGE_TYPE_HASH( &ifam->type ), 1, face->num_glyphs, FTC_GLYPH_QUERY( iquery ), @@ -258,7 +231,7 @@ FT_Bool result; - result = FT_BOOL( FTC_IMAGE_DESC_COMPARE( &ifam->desc, &iquery->desc ) ); + result = FT_BOOL( FTC_IMAGE_TYPE_COMPARE( &ifam->type, &iquery->type ) ); if ( result ) FTC_GLYPH_FAMILY_FOUND( ifam, iquery ); @@ -314,7 +287,7 @@ FT_EXPORT_DEF( FT_Error ) FTC_ImageCache_Lookup( FTC_ImageCache cache, - FTC_ImageDesc* desc, + FTC_ImageType type, FT_UInt gindex, FT_Glyph *aglyph, FTC_Node *anode ) @@ -332,7 +305,7 @@ *anode = NULL; iquery.gquery.gindex = gindex; - iquery.desc = *desc; + iquery.type = *type; error = ftc_cache_lookup( FTC_CACHE( cache ), FTC_QUERY( &iquery ), @@ -368,17 +341,55 @@ FT_UInt gindex, FT_Glyph *aglyph ) { - FTC_ImageDesc desc0; + FTC_ImageTypeRec type0; if ( !desc ) return FTC_Err_Invalid_Argument; - desc0.font = desc->font; - desc0.type = (FT_UInt32)desc->image_type; + type0.font = desc->font; + + /* convert image type flags to load flags */ + { + FT_UInt load_flags = FT_LOAD_DEFAULT; + FT_UInt type = desc->image_type; + + + /* determine load flags, depending on the font description's */ + /* image type */ + + if ( ftc_image_format( type ) == ftc_image_format_bitmap ) + { + if ( type & ftc_image_flag_monochrome ) + load_flags |= FT_LOAD_MONOCHROME; + + /* disable embedded bitmaps loading if necessary */ + if ( type & ftc_image_flag_no_sbits ) + load_flags |= FT_LOAD_NO_BITMAP; + } + else + { + /* we want an outline, don't load embedded bitmaps */ + load_flags |= FT_LOAD_NO_BITMAP; + + if ( type & ftc_image_flag_unscaled ) + load_flags |= FT_LOAD_NO_SCALE; + } + + /* always render glyphs to bitmaps */ + load_flags |= FT_LOAD_RENDER; + + if ( type & ftc_image_flag_unhinted ) + load_flags |= FT_LOAD_NO_HINTING; + + if ( type & ftc_image_flag_autohinted ) + load_flags |= FT_LOAD_FORCE_AUTOHINT; + + type0.flags = load_flags; + } return FTC_ImageCache_Lookup( (FTC_ImageCache)icache, - &desc0, + &type0, gindex, aglyph, NULL ); diff --git a/src/libs/freetype2/cache/ftcsbits.c b/src/libs/freetype2/cache/ftcsbits.c index 5b8ff1e29a4..663467616a9 100644 --- a/src/libs/freetype2/cache/ftcsbits.c +++ b/src/libs/freetype2/cache/ftcsbits.c @@ -46,7 +46,7 @@ typedef struct FTC_SBitQueryRec_ { FTC_GlyphQueryRec gquery; - FTC_ImageDesc desc; + FTC_ImageTypeRec type; } FTC_SBitQueryRec, *FTC_SBitQuery; @@ -60,7 +60,7 @@ typedef struct FTC_SBitFamilyRec_ { FTC_GlyphFamilyRec gfam; - FTC_ImageDesc desc; + FTC_ImageTypeRec type; } FTC_SBitFamilyRec; @@ -104,8 +104,8 @@ ftc_sbit_node_done( FTC_SBitNode snode, FTC_Cache cache ) { - FTC_SBit sbit = snode->sbits; - FT_UInt count = FTC_GLYPH_NODE( snode )->item_count; + FTC_SBit sbit = snode->sbits; + FT_UInt count = FTC_GLYPH_NODE( snode )->item_count; FT_Memory memory = cache->memory; @@ -142,48 +142,14 @@ sbit = snode->sbits + ( gindex - gnode->item_start ); - error = FTC_Manager_Lookup_Size( manager, &sfam->desc.font, + error = FTC_Manager_Lookup_Size( manager, &sfam->type.font, &face, &size ); if ( !error ) { - FT_UInt load_flags = FT_LOAD_DEFAULT; - FT_UInt type = sfam->desc.type; - - - /* determine load flags, depending on the font description's */ - /* image type */ - - if ( FTC_IMAGE_FORMAT( type ) == ftc_image_format_bitmap ) - { - if ( type & ftc_image_flag_monochrome ) - load_flags |= FT_LOAD_MONOCHROME; - - /* disable embedded bitmaps loading if necessary */ - if ( type & ftc_image_flag_no_sbits ) - load_flags |= FT_LOAD_NO_BITMAP; - } - else - { - FT_ERROR(( - "ftc_sbit_node_load: cannot load scalable glyphs in an" - " sbit cache, please check your arguments!\n" )); - error = FTC_Err_Invalid_Argument; - goto Exit; - } - - /* always render glyphs to bitmaps */ - load_flags |= FT_LOAD_RENDER; - - if ( type & ftc_image_flag_unhinted ) - load_flags |= FT_LOAD_NO_HINTING; - - if ( type & ftc_image_flag_autohinted ) - load_flags |= FT_LOAD_FORCE_AUTOHINT; - /* by default, indicates a `missing' glyph */ sbit->buffer = 0; - error = FT_Load_Glyph( face, gindex, load_flags ); + error = FT_Load_Glyph( face, gindex, sfam->type.flags | FT_LOAD_RENDER ); if ( !error ) { FT_Int temp; @@ -221,13 +187,9 @@ sbit->xadvance = (FT_Char)xadvance; sbit->yadvance = (FT_Char)yadvance; sbit->format = (FT_Byte)bitmap->pixel_mode; - /* XXX: Fixme: We don't handle the number of gray levels */ - /* consistently -- we say num_grays == 1 for */ - /* monochrome but num_grays == 256 for gray. It */ - /* would be better to make this variable hold the */ - /* highest possible value so that it fits into */ - /* a single byte. */ - sbit->num_grays = bitmap->num_grays; + sbit->max_grays = (FT_Byte)(bitmap->num_grays - 1); + +#if 0 /* this doesn't work well with embedded bitmaps !! */ /* grab the bitmap when possible - this is a hack! */ if ( slot->flags & FT_GLYPH_OWN_BITMAP ) @@ -236,6 +198,7 @@ sbit->buffer = bitmap->buffer; } else +#endif { /* copy the bitmap into a new buffer -- ignore error */ error = ftc_sbit_copy_bitmap( sbit, bitmap, memory ); @@ -261,7 +224,6 @@ } } - Exit: return error; } @@ -380,16 +342,16 @@ FT_Face face; - sfam->desc = squery->desc; + sfam->type = squery->type; /* we need to compute "cquery.item_total" now */ error = FTC_Manager_Lookup_Face( manager, - squery->desc.font.face_id, + squery->type.font.face_id, &face ); if ( !error ) { error = ftc_glyph_family_init( FTC_GLYPH_FAMILY( sfam ), - FTC_IMAGE_DESC_HASH( &sfam->desc ), + FTC_IMAGE_TYPE_HASH( &sfam->type ), FTC_SBIT_ITEMS_PER_NODE, face->num_glyphs, FTC_GLYPH_QUERY( squery ), @@ -410,7 +372,7 @@ /* we need to set the "cquery.cset" field or our query for */ /* faster glyph comparisons in ftc_sbit_node_compare */ /* */ - result = FT_BOOL( FTC_IMAGE_DESC_COMPARE( &sfam->desc, &squery->desc ) ); + result = FT_BOOL( FTC_IMAGE_TYPE_COMPARE( &sfam->type, &squery->type ) ); if ( result ) FTC_GLYPH_FAMILY_FOUND( sfam, squery ); @@ -481,7 +443,7 @@ FT_EXPORT_DEF( FT_Error ) FTC_SBitCache_Lookup( FTC_SBitCache cache, - FTC_ImageDesc* desc, + FTC_ImageType type, FT_UInt gindex, FTC_SBit *ansbit, FTC_Node *anode ) @@ -501,7 +463,7 @@ *anode = NULL; squery.gquery.gindex = gindex; - squery.desc = *desc; + squery.type = *type; error = ftc_sbit_cache_lookup( FTC_CACHE( cache ), FTC_QUERY( &squery ), @@ -536,17 +498,56 @@ FT_UInt gindex, FTC_SBit *ansbit ) { - FTC_ImageDesc desc0; + FTC_ImageTypeRec type0; if ( !desc ) return FTC_Err_Invalid_Argument; - desc0.font = desc->font; - desc0.type = (FT_UInt32)desc->image_type; + type0.font = desc->font; + type0.flags = 0; + + /* convert image type flags to load flags */ + { + FT_UInt load_flags = FT_LOAD_DEFAULT; + FT_UInt type = desc->image_type; + + + /* determine load flags, depending on the font description's */ + /* image type */ + + if ( ftc_image_format( type ) == ftc_image_format_bitmap ) + { + if ( type & ftc_image_flag_monochrome ) + load_flags |= FT_LOAD_MONOCHROME; + + /* disable embedded bitmaps loading if necessary */ + if ( type & ftc_image_flag_no_sbits ) + load_flags |= FT_LOAD_NO_BITMAP; + } + else + { + /* we want an outline, don't load embedded bitmaps */ + load_flags |= FT_LOAD_NO_BITMAP; + + if ( type & ftc_image_flag_unscaled ) + load_flags |= FT_LOAD_NO_SCALE; + } + + /* always render glyphs to bitmaps */ + load_flags |= FT_LOAD_RENDER; + + if ( type & ftc_image_flag_unhinted ) + load_flags |= FT_LOAD_NO_HINTING; + + if ( type & ftc_image_flag_autohinted ) + load_flags |= FT_LOAD_FORCE_AUTOHINT; + + type0.flags = load_flags; + } return FTC_SBitCache_Lookup( (FTC_SBitCache)cache, - &desc0, + &type0, gindex, ansbit, NULL ); diff --git a/src/libs/freetype2/cff/cff.c b/src/libs/freetype2/cff/cff.c index 19883f2ebb8..013c329cab3 100644 --- a/src/libs/freetype2/cff/cff.c +++ b/src/libs/freetype2/cff/cff.c @@ -24,6 +24,6 @@ #include "cffload.c" #include "cffobjs.c" #include "cffgload.c" - +#include "cffcmap.c" /* END */ diff --git a/src/libs/freetype2/cff/cffdrivr.c b/src/libs/freetype2/cff/cffdrivr.c index 7a0c0df20a5..34ed2bf76e2 100644 --- a/src/libs/freetype2/cff/cffdrivr.c +++ b/src/libs/freetype2/cff/cffdrivr.c @@ -118,7 +118,7 @@ while ( left <= right ) { - FT_Int middle = left + ( ( right - left ) >> 1 ); + FT_Long middle = left + ( ( right - left ) >> 1 ); FT_ULong cur_pair; @@ -177,7 +177,7 @@ Load_Glyph( CFF_GlyphSlot slot, CFF_Size size, FT_UShort glyph_index, - FT_UInt load_flags ) + FT_Int32 load_flags ) { FT_Error error; @@ -201,7 +201,7 @@ } /* now load the glyph outline if necessary */ - error = CFF_Load_Glyph( slot, size, glyph_index, load_flags ); + error = cff_slot_load( slot, size, glyph_index, load_flags ); /* force drop-out mode to 2 - irrelevant now */ /* slot->outline.dropout_mode = 2; */ @@ -253,11 +253,11 @@ sid = font->charset.sids[glyph_index]; /* now, lookup the name itself */ - gname = CFF_Get_String( &font->string_index, sid, psnames ); + gname = cff_index_get_sid_string( &font->string_index, sid, psnames ); if ( buffer_max > 0 ) { - FT_UInt len = ft_strlen( gname ); + FT_UInt len = (FT_UInt)ft_strlen( gname ); if ( len >= buffer_max ) @@ -275,94 +275,6 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* cff_get_char_index */ - /* */ - /* <Description> */ - /* Uses a charmap to return a given character code's glyph index. */ - /* */ - /* <Input> */ - /* charmap :: A handle to the source charmap object. */ - /* charcode :: The character code. */ - /* */ - /* <Return> */ - /* Glyph index. 0 means `undefined character code'. */ - /* */ - static FT_UInt - cff_get_char_index( TT_CharMap charmap, - FT_Long charcode ) - { - FT_Error error; - CFF_Face face; - TT_CMapTable cmap; - - - cmap = &charmap->cmap; - face = (CFF_Face)charmap->root.face; - - /* Load table if needed */ - if ( !cmap->loaded ) - { - SFNT_Service sfnt = (SFNT_Service)face->sfnt; - - - error = sfnt->load_charmap( face, cmap, face->root.stream ); - if ( error ) - return 0; - - cmap->loaded = TRUE; - } - - return ( cmap->get_index ? cmap->get_index( cmap, charcode ) : 0 ); - } - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* cff_get_next_char */ - /* */ - /* <Description> */ - /* Uses a charmap to return the next encoded charcode. */ - /* */ - /* <Input> */ - /* charmap :: A handle to the source charmap object. */ - /* charcode :: The character code. */ - /* */ - /* <Return> */ - /* Char code. 0 means `no encoded chars above the given one'. */ - /* */ - static FT_Long - cff_get_next_char( TT_CharMap charmap, - FT_Long charcode ) - { - FT_Error error; - CFF_Face face; - TT_CMapTable cmap; - - - cmap = &charmap->cmap; - face = (CFF_Face)charmap->root.face; - - /* Load table if needed */ - if ( !cmap->loaded ) - { - SFNT_Service sfnt = (SFNT_Service)face->sfnt; - - - error = sfnt->load_charmap( face, cmap, face->root.stream ); - if ( error ) - return 0; - - cmap->loaded = TRUE; - } - - return ( cmap->get_next_char ? cmap->get_next_char( cmap, charcode ) - : 0 ); - } - /*************************************************************************/ /* */ @@ -406,7 +318,7 @@ sid = charset->sids[i]; if ( sid > 390 ) - name = CFF_Get_Name( &cff->string_index, sid - 391 ); + name = cff_index_get_name( &cff->string_index, sid - 391 ); else name = (FT_String *)psnames->adobe_std_strings( sid ); @@ -469,7 +381,7 @@ ft_module_font_driver | ft_module_driver_scalable | ft_module_driver_has_hinter, - + sizeof( CFF_DriverRec ), "cff", 0x10000L, @@ -477,8 +389,8 @@ 0, /* module-specific interface */ - (FT_Module_Constructor)CFF_Driver_Init, - (FT_Module_Destructor) CFF_Driver_Done, + (FT_Module_Constructor)cff_driver_init, + (FT_Module_Destructor) cff_driver_done, (FT_Module_Requester) cff_get_interface, }, @@ -487,24 +399,21 @@ sizeof( FT_SizeRec ), sizeof( CFF_GlyphSlotRec ), - (FT_Face_InitFunc) CFF_Face_Init, - (FT_Face_DoneFunc) CFF_Face_Done, - (FT_Size_InitFunc) CFF_Size_Init, - (FT_Size_DoneFunc) CFF_Size_Done, - (FT_Slot_InitFunc) CFF_GlyphSlot_Init, - (FT_Slot_DoneFunc) CFF_GlyphSlot_Done, + (FT_Face_InitFunc) cff_face_init, + (FT_Face_DoneFunc) cff_face_done, + (FT_Size_InitFunc) cff_size_init, + (FT_Size_DoneFunc) cff_size_done, + (FT_Slot_InitFunc) cff_slot_init, + (FT_Slot_DoneFunc) cff_slot_done, - (FT_Size_ResetPointsFunc) CFF_Size_Reset, - (FT_Size_ResetPixelsFunc) CFF_Size_Reset, + (FT_Size_ResetPointsFunc)cff_size_reset, + (FT_Size_ResetPixelsFunc)cff_size_reset, - (FT_Slot_LoadFunc) Load_Glyph, - (FT_CharMap_CharIndexFunc)cff_get_char_index, + (FT_Slot_LoadFunc) Load_Glyph, - (FT_Face_GetKerningFunc) Get_Kerning, - (FT_Face_AttachFunc) 0, - (FT_Face_GetAdvancesFunc) 0, - - (FT_CharMap_CharNextFunc) cff_get_next_char + (FT_Face_GetKerningFunc) Get_Kerning, + (FT_Face_AttachFunc) 0, + (FT_Face_GetAdvancesFunc)0, }; diff --git a/src/libs/freetype2/cff/cffgload.c b/src/libs/freetype2/cff/cffgload.c index 07a137c447d..69277ae59e3 100644 --- a/src/libs/freetype2/cff/cffgload.c +++ b/src/libs/freetype2/cff/cffgload.c @@ -207,7 +207,7 @@ /*************************************************************************/ /* */ /* <Function> */ - /* CFF_Builder_Init */ + /* cff_builder_init */ /* */ /* <Description> */ /* Initializes a given glyph builder. */ @@ -223,7 +223,7 @@ /* glyph :: The current glyph object. */ /* */ static void - CFF_Builder_Init( CFF_Builder* builder, + cff_builder_init( CFF_Builder* builder, TT_Face face, CFF_Size size, CFF_GlyphSlot glyph, @@ -246,6 +246,7 @@ builder->current = &loader->current.outline; FT_GlyphLoader_Rewind( loader ); + builder->hint_flags = FT_FACE(face)->internal->hint_flags; builder->hints_globals = 0; builder->hints_funcs = 0; @@ -275,7 +276,7 @@ /*************************************************************************/ /* */ /* <Function> */ - /* CFF_Builder_Done */ + /* cff_builder_done */ /* */ /* <Description> */ /* Finalizes a given glyph builder. Its contents can still be used */ @@ -286,7 +287,7 @@ /* builder :: A pointer to the glyph builder to finalize. */ /* */ static void - CFF_Builder_Done( CFF_Builder* builder ) + cff_builder_done( CFF_Builder* builder ) { CFF_GlyphSlot glyph = builder->glyph; @@ -330,7 +331,7 @@ /*************************************************************************/ /* */ /* <Function> */ - /* CFF_Init_Decoder */ + /* cff_decoder_init */ /* */ /* <Description> */ /* Initializes a given glyph decoder. */ @@ -346,31 +347,34 @@ /* slot :: The current glyph object. */ /* */ FT_LOCAL_DEF( void ) - CFF_Init_Decoder( CFF_Decoder* decoder, - TT_Face face, - CFF_Size size, - CFF_GlyphSlot slot, - FT_Bool hinting ) + cff_decoder_init( CFF_Decoder* decoder, + TT_Face face, + CFF_Size size, + CFF_GlyphSlot slot, + FT_Bool hinting, + FT_Render_Mode hint_mode ) { CFF_Font cff = (CFF_Font)face->extra.data; /* clear everything */ - FT_MEM_SET( decoder, 0, sizeof ( *decoder ) ); + FT_MEM_ZERO( decoder, sizeof ( *decoder ) ); /* initialize builder */ - CFF_Builder_Init( &decoder->builder, face, size, slot, hinting ); + cff_builder_init( &decoder->builder, face, size, slot, hinting ); /* initialize Type2 decoder */ decoder->num_globals = cff->num_global_subrs; decoder->globals = cff->global_subrs; decoder->globals_bias = cff_compute_bias( decoder->num_globals ); + + decoder->hint_mode = hint_mode; } /* this function is used to select the locals subrs array */ FT_LOCAL_DEF( void ) - CFF_Prepare_Decoder( CFF_Decoder* decoder, + cff_decoder_prepare( CFF_Decoder* decoder, FT_UInt glyph_index ) { CFF_Font cff = (CFF_Font)decoder->builder.face->extra.data; @@ -380,7 +384,7 @@ /* manage CID fonts */ if ( cff->num_subfonts >= 1 ) { - FT_Byte fd_index = CFF_Get_FD( &cff->fd_select, glyph_index ); + FT_Byte fd_index = cff_fd_select_get( &cff->fd_select, glyph_index ); sub = cff->subfonts[fd_index]; @@ -406,10 +410,10 @@ /* add a new point, do not check space */ static void - add_point( CFF_Builder* builder, - FT_Pos x, - FT_Pos y, - FT_Byte flag ) + cff_builder_add_point( CFF_Builder* builder, + FT_Pos x, + FT_Pos y, + FT_Byte flag ) { FT_Outline* outline = builder->current; @@ -422,7 +426,7 @@ point->x = x >> 16; point->y = y >> 16; - *control = (FT_Byte)( flag ? FT_Curve_Tag_On : FT_Curve_Tag_Cubic ); + *control = (FT_Byte)( flag ? FT_CURVE_TAG_ON : FT_CURVE_TAG_CUBIC ); builder->last = *point; } @@ -433,16 +437,16 @@ /* check space for a new on-curve point, then add it */ static FT_Error - add_point1( CFF_Builder* builder, - FT_Pos x, - FT_Pos y ) + cff_builder_add_point1( CFF_Builder* builder, + FT_Pos x, + FT_Pos y ) { FT_Error error; error = check_points( builder, 1 ); if ( !error ) - add_point( builder, x, y, 1 ); + cff_builder_add_point( builder, x, y, 1 ); return error; } @@ -450,7 +454,7 @@ /* check room for a new contour, then add it */ static FT_Error - add_contour( CFF_Builder* builder ) + cff_builder_add_contour( CFF_Builder* builder ) { FT_Outline* outline = builder->current; FT_Error error; @@ -478,9 +482,9 @@ /* if a path was begun, add its first on-curve point */ static FT_Error - start_point( CFF_Builder* builder, - FT_Pos x, - FT_Pos y ) + cff_builder_start_point( CFF_Builder* builder, + FT_Pos x, + FT_Pos y ) { FT_Error error = 0; @@ -489,9 +493,9 @@ if ( !builder->path_begun ) { builder->path_begun = 1; - error = add_contour( builder ); + error = cff_builder_add_contour( builder ); if ( !error ) - error = add_point1( builder, x, y ); + error = cff_builder_add_point1( builder, x, y ); } return error; @@ -500,7 +504,7 @@ /* close the current contour */ static void - close_contour( CFF_Builder* builder ) + cff_builder_close_contour( CFF_Builder* builder ) { FT_Outline* outline = builder->current; @@ -524,7 +528,7 @@ /* `delete' last point only if it coincides with the first */ /* point and if it is not a control point (which can happen). */ if ( p1->x == p2->x && p1->y == p2->y ) - if ( *control == FT_Curve_Tag_On ) + if ( *control == FT_CURVE_TAG_ON ) outline->n_points--; } @@ -547,7 +551,7 @@ return -1; /* Get code to SID mapping from `cff_standard_encoding'. */ - glyph_sid = CFF_Get_Standard_Encoding( (FT_UInt)charcode ); + glyph_sid = cff_get_standard_encoding( (FT_UInt)charcode ); for ( n = 0; n < cff->num_glyphs; n++ ) { @@ -559,6 +563,77 @@ } + static FT_Error + cff_get_glyph_data( TT_Face face, + FT_UInt glyph_index, + FT_Byte** pointer, + FT_ULong* length ) + { +#ifdef FT_CONFIG_OPTION_INCREMENTAL + /* For incremental fonts get the character data using the */ + /* callback function. */ + if ( face->root.internal->incremental_interface ) + { + FT_Data data; + FT_Error error = + face->root.internal->incremental_interface->funcs->get_glyph_data( + face->root.internal->incremental_interface->object, + glyph_index, &data ); + + + *pointer = (FT_Byte*)data.pointer; + *length = data.length; + + return error; + } + else +#endif /* FT_CONFIG_OPTION_INCREMENTAL */ + + { + CFF_Font cff = (CFF_Font)(face->extra.data); + + + return cff_index_access_element( &cff->charstrings_index, glyph_index, + pointer, length ); + } + } + + + static void + cff_free_glyph_data( TT_Face face, + FT_Byte** pointer, + FT_ULong length ) + { +#ifndef FT_CONFIG_OPTION_INCREMENTAL + FT_UNUSED( length ); +#endif + +#ifdef FT_CONFIG_OPTION_INCREMENTAL + /* For incremental fonts get the character data using the */ + /* callback function. */ + if ( face->root.internal->incremental_interface ) + { + FT_Data data; + + + data.pointer = *pointer; + data.length = length; + + face->root.internal->incremental_interface->funcs->free_glyph_data( + face->root.internal->incremental_interface->object,&data ); + } + else +#endif /* FT_CONFIG_OPTION_INCREMENTAL */ + + { + CFF_Font cff = (CFF_Font)(face->extra.data); + + + cff_index_forget_element( &cff->charstrings_index, pointer ); + } + } + + static FT_Error cff_operator_seac( CFF_Decoder* decoder, FT_Pos adx, @@ -570,14 +645,28 @@ FT_Int bchar_index, achar_index, n_base_points; FT_Outline* base = decoder->builder.base; TT_Face face = decoder->builder.face; - CFF_Font cff = (CFF_Font)(face->extra.data); FT_Vector left_bearing, advance; FT_Byte* charstring; FT_ULong charstring_len; - bchar_index = cff_lookup_glyph_by_stdcharcode( cff, bchar ); - achar_index = cff_lookup_glyph_by_stdcharcode( cff, achar ); +#ifdef FT_CONFIG_OPTION_INCREMENTAL + /* Incremental fonts don't necessarily have valid charsets. */ + /* They use the character code, not the glyph index, in this case. */ + if ( face->root.internal->incremental_interface ) + { + bchar_index = bchar; + achar_index = achar; + } + else +#endif /* FT_CONFIG_OPTION_INCREMENTAL */ + { + CFF_Font cff = (CFF_Font)(face->extra.data); + + + bchar_index = cff_lookup_glyph_by_stdcharcode( cff, bchar ); + achar_index = cff_lookup_glyph_by_stdcharcode( cff, achar ); + } if ( bchar_index < 0 || achar_index < 0 ) { @@ -613,28 +702,29 @@ /* subglyph 1 = accent character */ subg->index = achar_index; subg->flags = FT_SUBGLYPH_FLAG_ARGS_ARE_XY_VALUES; - subg->arg1 = adx; - subg->arg2 = ady; + subg->arg1 = (FT_Int)adx; + subg->arg2 = (FT_Int)ady; /* set up remaining glyph fields */ glyph->num_subglyphs = 2; glyph->subglyphs = loader->base.subglyphs; - glyph->format = ft_glyph_format_composite; + glyph->format = FT_GLYPH_FORMAT_COMPOSITE; loader->current.num_subglyphs = 2; } /* First load `bchar' in builder */ - error = CFF_Access_Element( &cff->charstrings_index, bchar_index, + error = cff_get_glyph_data( face, bchar_index, &charstring, &charstring_len ); if ( !error ) { - error = CFF_Parse_CharStrings( decoder, charstring, charstring_len ); + error = cff_decoder_parse_charstrings( decoder, charstring, + charstring_len ); if ( error ) goto Exit; - CFF_Forget_Element( &cff->charstrings_index, &charstring ); + cff_free_glyph_data( face, &charstring, charstring_len ); } n_base_points = base->n_points; @@ -649,16 +739,17 @@ decoder->builder.left_bearing.y = 0; /* Now load `achar' on top of the base outline. */ - error = CFF_Access_Element( &cff->charstrings_index, achar_index, + error = cff_get_glyph_data( face, achar_index, &charstring, &charstring_len ); if ( !error ) { - error = CFF_Parse_CharStrings( decoder, charstring, charstring_len ); + error = cff_decoder_parse_charstrings( decoder, charstring, + charstring_len ); if ( error ) goto Exit; - CFF_Forget_Element( &cff->charstrings_index, &charstring ); + cff_free_glyph_data( face, &charstring, charstring_len ); } /* Restore the left side bearing and advance width */ @@ -686,7 +777,7 @@ /*************************************************************************/ /* */ /* <Function> */ - /* CFF_Parse_CharStrings */ + /* cff_decoder_parse_charstrings */ /* */ /* <Description> */ /* Parses a given Type 2 charstrings program. */ @@ -703,9 +794,9 @@ /* FreeType error code. 0 means success. */ /* */ FT_LOCAL_DEF( FT_Error ) - CFF_Parse_CharStrings( CFF_Decoder* decoder, - FT_Byte* charstring_base, - FT_Int charstring_len ) + cff_decoder_parse_charstrings( CFF_Decoder* decoder, + FT_Byte* charstring_base, + FT_ULong charstring_len ) { FT_Error error; CFF_Decoder_Zone* zone; @@ -822,7 +913,7 @@ else { FT_Fixed* args = decoder->top; - FT_Int num_args = args - decoder->stack; + FT_Int num_args = (FT_Int)( args - decoder->stack ); FT_Int req_args; @@ -1146,7 +1237,7 @@ case cff_op_rmoveto: FT_TRACE4(( " rmoveto" )); - close_contour( builder ); + cff_builder_close_contour( builder ); builder->path_begun = 0; x += args[0]; y += args[1]; @@ -1156,7 +1247,7 @@ case cff_op_vmoveto: FT_TRACE4(( " vmoveto" )); - close_contour( builder ); + cff_builder_close_contour( builder ); builder->path_begun = 0; y += args[0]; args = stack; @@ -1165,7 +1256,7 @@ case cff_op_hmoveto: FT_TRACE4(( " hmoveto" )); - close_contour( builder ); + cff_builder_close_contour( builder ); builder->path_begun = 0; x += args[0]; args = stack; @@ -1174,8 +1265,8 @@ case cff_op_rlineto: FT_TRACE4(( " rlineto" )); - if ( start_point ( builder, x, y ) || - check_points( builder, num_args / 2 ) ) + if ( cff_builder_start_point ( builder, x, y ) || + check_points( builder, num_args / 2 ) ) goto Memory_Error; if ( num_args < 2 || num_args & 1 ) @@ -1186,7 +1277,7 @@ { x += args[0]; y += args[1]; - add_point( builder, x, y, 1 ); + cff_builder_add_point( builder, x, y, 1 ); args += 2; } args = stack; @@ -1201,7 +1292,7 @@ FT_TRACE4(( op == cff_op_hlineto ? " hlineto" : " vlineto" )); - if ( start_point ( builder, x, y ) || + if ( cff_builder_start_point ( builder, x, y ) || check_points( builder, num_args ) ) goto Memory_Error; @@ -1213,7 +1304,7 @@ else y += args[0]; - if ( add_point1( builder, x, y ) ) + if ( cff_builder_add_point1( builder, x, y ) ) goto Memory_Error; args++; @@ -1230,8 +1321,8 @@ if ( num_args % 6 != 0 ) goto Stack_Underflow; - if ( start_point ( builder, x, y ) || - check_points( builder, num_args / 2 ) ) + if ( cff_builder_start_point ( builder, x, y ) || + check_points( builder, num_args / 2 ) ) goto Memory_Error; args = stack; @@ -1239,13 +1330,13 @@ { x += args[0]; y += args[1]; - add_point( builder, x, y, 0 ); + cff_builder_add_point( builder, x, y, 0 ); x += args[2]; y += args[3]; - add_point( builder, x, y, 0 ); + cff_builder_add_point( builder, x, y, 0 ); x += args[4]; y += args[5]; - add_point( builder, x, y, 1 ); + cff_builder_add_point( builder, x, y, 1 ); args += 6; } args = stack; @@ -1254,7 +1345,7 @@ case cff_op_vvcurveto: FT_TRACE4(( " vvcurveto" )); - if ( start_point ( builder, x, y ) ) + if ( cff_builder_start_point ( builder, x, y ) ) goto Memory_Error; args = stack; @@ -1274,12 +1365,12 @@ while ( args < decoder->top ) { y += args[0]; - add_point( builder, x, y, 0 ); + cff_builder_add_point( builder, x, y, 0 ); x += args[1]; y += args[2]; - add_point( builder, x, y, 0 ); + cff_builder_add_point( builder, x, y, 0 ); y += args[3]; - add_point( builder, x, y, 1 ); + cff_builder_add_point( builder, x, y, 1 ); args += 4; } args = stack; @@ -1288,7 +1379,7 @@ case cff_op_hhcurveto: FT_TRACE4(( " hhcurveto" )); - if ( start_point ( builder, x, y ) ) + if ( cff_builder_start_point ( builder, x, y ) ) goto Memory_Error; args = stack; @@ -1308,12 +1399,12 @@ while ( args < decoder->top ) { x += args[0]; - add_point( builder, x, y, 0 ); + cff_builder_add_point( builder, x, y, 0 ); x += args[1]; y += args[2]; - add_point( builder, x, y, 0 ); + cff_builder_add_point( builder, x, y, 0 ); x += args[3]; - add_point( builder, x, y, 1 ); + cff_builder_add_point( builder, x, y, 1 ); args += 4; } args = stack; @@ -1328,7 +1419,7 @@ FT_TRACE4(( op == cff_op_vhcurveto ? " vhcurveto" : " hvcurveto" )); - if ( start_point ( builder, x, y ) ) + if ( cff_builder_start_point ( builder, x, y ) ) goto Memory_Error; args = stack; @@ -1346,26 +1437,26 @@ if ( phase ) { x += args[0]; - add_point( builder, x, y, 0 ); + cff_builder_add_point( builder, x, y, 0 ); x += args[1]; y += args[2]; - add_point( builder, x, y, 0 ); + cff_builder_add_point( builder, x, y, 0 ); y += args[3]; if ( num_args == 1 ) x += args[4]; - add_point( builder, x, y, 1 ); + cff_builder_add_point( builder, x, y, 1 ); } else { y += args[0]; - add_point( builder, x, y, 0 ); + cff_builder_add_point( builder, x, y, 0 ); x += args[1]; y += args[2]; - add_point( builder, x, y, 0 ); + cff_builder_add_point( builder, x, y, 0 ); x += args[3]; if ( num_args == 1 ) y += args[4]; - add_point( builder, x, y, 1 ); + cff_builder_add_point( builder, x, y, 1 ); } args += 4; phase ^= 1; @@ -1384,8 +1475,8 @@ if ( num_args < 8 || ( num_args - 6 ) & 1 ) goto Stack_Underflow; - if ( start_point( builder, x, y ) || - check_points( builder, num_lines + 3 ) ) + if ( cff_builder_start_point( builder, x, y ) || + check_points( builder, num_lines + 3 ) ) goto Memory_Error; args = stack; @@ -1395,7 +1486,7 @@ { x += args[0]; y += args[1]; - add_point( builder, x, y, 1 ); + cff_builder_add_point( builder, x, y, 1 ); args += 2; num_lines--; } @@ -1403,13 +1494,13 @@ /* then the curve */ x += args[0]; y += args[1]; - add_point( builder, x, y, 0 ); + cff_builder_add_point( builder, x, y, 0 ); x += args[2]; y += args[3]; - add_point( builder, x, y, 0 ); + cff_builder_add_point( builder, x, y, 0 ); x += args[4]; y += args[5]; - add_point( builder, x, y, 1 ); + cff_builder_add_point( builder, x, y, 1 ); args = stack; } break; @@ -1424,7 +1515,7 @@ if ( num_args < 8 || ( num_args - 2 ) % 6 ) goto Stack_Underflow; - if ( start_point ( builder, x, y ) || + if ( cff_builder_start_point ( builder, x, y ) || check_points( builder, num_curves*3 + 2 ) ) goto Memory_Error; @@ -1435,13 +1526,13 @@ { x += args[0]; y += args[1]; - add_point( builder, x, y, 0 ); + cff_builder_add_point( builder, x, y, 0 ); x += args[2]; y += args[3]; - add_point( builder, x, y, 0 ); + cff_builder_add_point( builder, x, y, 0 ); x += args[4]; y += args[5]; - add_point( builder, x, y, 1 ); + cff_builder_add_point( builder, x, y, 1 ); args += 6; num_curves--; } @@ -1449,7 +1540,7 @@ /* then the final line */ x += args[0]; y += args[1]; - add_point( builder, x, y, 1 ); + cff_builder_add_point( builder, x, y, 1 ); args = stack; } break; @@ -1466,8 +1557,8 @@ /* adding five more points; 4 control points, 1 on-curve point */ /* make sure we have enough space for the start point if it */ /* needs to be added.. */ - if ( start_point( builder, x, y ) || - check_points( builder, 6 ) ) + if ( cff_builder_start_point( builder, x, y ) || + check_points( builder, 6 ) ) goto Memory_Error; /* Record the starting point's y postion for later use */ @@ -1476,32 +1567,32 @@ /* first control point */ x += args[0]; y += args[1]; - add_point( builder, x, y, 0 ); + cff_builder_add_point( builder, x, y, 0 ); /* second control point */ x += args[2]; y += args[3]; - add_point( builder, x, y, 0 ); + cff_builder_add_point( builder, x, y, 0 ); /* join point; on curve, with y-value the same as the last */ /* control point's y-value */ x += args[4]; - add_point( builder, x, y, 1 ); + cff_builder_add_point( builder, x, y, 1 ); /* third control point, with y-value the same as the join */ /* point's y-value */ x += args[5]; - add_point( builder, x, y, 0 ); + cff_builder_add_point( builder, x, y, 0 ); /* fourth control point */ x += args[6]; y += args[7]; - add_point( builder, x, y, 0 ); + cff_builder_add_point( builder, x, y, 0 ); /* ending point, with y-value the same as the start */ x += args[8]; y = start_y; - add_point( builder, x, y, 1 ); + cff_builder_add_point( builder, x, y, 1 ); args = stack; break; @@ -1517,8 +1608,8 @@ args = stack; /* adding six more points; 4 control points, 2 on-curve points */ - if ( start_point( builder, x, y ) || - check_points ( builder, 6 ) ) + if ( cff_builder_start_point( builder, x, y ) || + check_points ( builder, 6 ) ) goto Memory_Error; /* record the starting point's y-position for later use */ @@ -1526,32 +1617,32 @@ /* first control point */ x += args[0]; - add_point( builder, x, y, 0 ); + cff_builder_add_point( builder, x, y, 0 ); /* second control point */ x += args[1]; y += args[2]; - add_point( builder, x, y, 0 ); + cff_builder_add_point( builder, x, y, 0 ); /* join point; on curve, with y-value the same as the last */ /* control point's y-value */ x += args[3]; - add_point( builder, x, y, 1 ); + cff_builder_add_point( builder, x, y, 1 ); /* third control point, with y-value the same as the join */ /* point's y-value */ x += args[4]; - add_point( builder, x, y, 0 ); + cff_builder_add_point( builder, x, y, 0 ); /* fourth control point */ x += args[5]; y = start_y; - add_point( builder, x, y, 0 ); + cff_builder_add_point( builder, x, y, 0 ); /* ending point, with y-value the same as the start point's */ /* y-value -- we don't add this point, though */ x += args[6]; - add_point( builder, x, y, 1 ); + cff_builder_add_point( builder, x, y, 1 ); args = stack; break; @@ -1569,8 +1660,8 @@ FT_TRACE4(( " flex1" )); /* adding six more points; 4 control points, 2 on-curve points */ - if ( start_point( builder, x, y ) || - check_points( builder, 6 ) ) + if ( cff_builder_start_point( builder, x, y ) || + check_points( builder, 6 ) ) goto Memory_Error; /* record the starting point's x, y postion for later use */ @@ -1585,8 +1676,8 @@ /* grab up to the last argument */ for ( count = 5; count > 0; count-- ) { - dx += args[0]; - dy += args[1]; + dx += (FT_Int)args[0]; + dy += (FT_Int)args[1]; args += 2; } @@ -1603,7 +1694,7 @@ { x += args[0]; y += args[1]; - add_point( builder, x, y, (FT_Bool)( count == 3 ) ); + cff_builder_add_point( builder, x, y, (FT_Bool)( count == 3 ) ); args += 2; } @@ -1619,7 +1710,7 @@ y += args[0]; } - add_point( builder, x, y, 1 ); + cff_builder_add_point( builder, x, y, 1 ); args = stack; break; @@ -1632,8 +1723,8 @@ FT_TRACE4(( " flex" )); - if ( start_point( builder, x, y ) || - check_points( builder, 6 ) ) + if ( cff_builder_start_point( builder, x, y ) || + check_points( builder, 6 ) ) goto Memory_Error; args = stack; @@ -1641,8 +1732,8 @@ { x += args[0]; y += args[1]; - add_point( builder, x, y, - (FT_Bool)( count == 3 || count == 0 ) ); + cff_builder_add_point( builder, x, y, + (FT_Bool)( count == 3 || count == 0 ) ); args += 2; } @@ -1657,15 +1748,17 @@ if ( num_args == 4 ) { error = cff_operator_seac( decoder, - args[0] >> 16, args[1] >> 16, - args[2] >> 16, args[3] >> 16 ); + args[0] >> 16, + args[1] >> 16, + (FT_Int)( args[2] >> 16 ), + (FT_Int)( args[3] >> 16 ) ); args += 4; } if ( !error ) error = CFF_Err_Ok; - close_contour( builder ); + cff_builder_close_contour( builder ); /* close hints recording session */ if ( hinter ) @@ -1676,7 +1769,8 @@ /* apply hints to the loaded glyph outline now */ hinter->apply( hinter->hints, builder->current, - (PSH_Globals)builder->hints_globals ); + (PSH_Globals)builder->hints_globals, + builder->hint_flags ); } /* add current outline to the glyph slot */ @@ -1794,7 +1888,7 @@ case cff_op_index: { - FT_Int idx = args[0] >> 16; + FT_Int idx = (FT_Int)( args[0] >> 16 ); FT_TRACE4(( " index" )); @@ -1965,14 +2059,15 @@ if ( idx >= decoder->num_locals ) { - FT_ERROR(( "CFF_Parse_CharStrings:" )); + FT_ERROR(( "cff_decoder_parse_charstrings:" )); FT_ERROR(( " invalid local subr index\n" )); goto Syntax_Error; } if ( zone - decoder->zones >= CFF_MAX_SUBRS_CALLS ) { - FT_ERROR(( "CFF_Parse_CharStrings: too many nested subrs\n" )); + FT_ERROR(( "cff_decoder_parse_charstrings:" + " too many nested subrs\n" )); goto Syntax_Error; } @@ -1985,7 +2080,8 @@ if ( !zone->base ) { - FT_ERROR(( "CFF_Parse_CharStrings: invoking empty subrs!\n" )); + FT_ERROR(( "cff_decoder_parse_charstrings:" + " invoking empty subrs!\n" )); goto Syntax_Error; } @@ -2005,14 +2101,15 @@ if ( idx >= decoder->num_globals ) { - FT_ERROR(( "CFF_Parse_CharStrings:" )); + FT_ERROR(( "cff_decoder_parse_charstrings:" )); FT_ERROR(( " invalid global subr index\n" )); goto Syntax_Error; } if ( zone - decoder->zones >= CFF_MAX_SUBRS_CALLS ) { - FT_ERROR(( "CFF_Parse_CharStrings: too many nested subrs\n" )); + FT_ERROR(( "cff_decoder_parse_charstrings:" + " too many nested subrs\n" )); goto Syntax_Error; } @@ -2025,7 +2122,8 @@ if ( !zone->base ) { - FT_ERROR(( "CFF_Parse_CharStrings: invoking empty subrs!\n" )); + FT_ERROR(( "cff_decoder_parse_charstrings:" + " invoking empty subrs!\n" )); goto Syntax_Error; } @@ -2040,7 +2138,8 @@ if ( decoder->zone <= decoder->zones ) { - FT_ERROR(( "CFF_Parse_CharStrings: unexpected return\n" )); + FT_ERROR(( "cff_decoder_parse_charstrings:" + " unexpected return\n" )); goto Syntax_Error; } @@ -2072,15 +2171,15 @@ return error; Syntax_Error: - FT_TRACE4(( "CFF_Parse_CharStrings: syntax error!" )); + FT_TRACE4(( "cff_decoder_parse_charstrings: syntax error!" )); return CFF_Err_Invalid_File_Format; Stack_Underflow: - FT_TRACE4(( "CFF_Parse_CharStrings: stack underflow!" )); + FT_TRACE4(( "cff_decoder_parse_charstrings: stack underflow!" )); return CFF_Err_Too_Few_Arguments; Stack_Overflow: - FT_TRACE4(( "CFF_Parse_CharStrings: stack overflow!" )); + FT_TRACE4(( "cff_decoder_parse_charstrings: stack overflow!" )); return CFF_Err_Stack_Overflow; Memory_Error: @@ -2110,7 +2209,7 @@ FT_LOCAL_DEF( FT_Error ) - CFF_Compute_Max_Advance( TT_Face face, + cff_compute_max_advance( TT_Face face, FT_Int* max_advance ) { FT_Error error = 0; @@ -2122,7 +2221,7 @@ *max_advance = 0; /* Initialize load decoder */ - CFF_Init_Decoder( &decoder, face, 0, 0, 0 ); + cff_decoder_init( &decoder, face, 0, 0, 0, 0 ); decoder.builder.metrics_only = 1; decoder.builder.load_points = 0; @@ -2137,14 +2236,15 @@ /* now get load the unscaled outline */ - error = CFF_Access_Element( &cff->charstrings_index, glyph_index, + error = cff_get_glyph_data( face, glyph_index, &charstring, &charstring_len ); if ( !error ) { - CFF_Prepare_Decoder( &decoder, glyph_index ); - error = CFF_Parse_CharStrings( &decoder, charstring, charstring_len ); + cff_decoder_prepare( &decoder, glyph_index ); + error = cff_decoder_parse_charstrings( &decoder, + charstring, charstring_len ); - CFF_Forget_Element( &cff->charstrings_index, &charstring ); + cff_free_glyph_data( face, &charstring, &charstring_len ); } /* ignore the error if one has occurred -- skip to next glyph */ @@ -2177,10 +2277,10 @@ FT_LOCAL_DEF( FT_Error ) - CFF_Load_Glyph( CFF_GlyphSlot glyph, - CFF_Size size, - FT_Int glyph_index, - FT_Int load_flags ) + cff_slot_load( CFF_GlyphSlot glyph, + CFF_Size size, + FT_Int glyph_index, + FT_Int32 load_flags ) { FT_Error error; CFF_Decoder decoder; @@ -2209,42 +2309,58 @@ hinting = FT_BOOL( ( load_flags & FT_LOAD_NO_SCALE ) == 0 && ( load_flags & FT_LOAD_NO_HINTING ) == 0 ); - glyph->root.format = ft_glyph_format_outline; /* by default */ + glyph->root.format = FT_GLYPH_FORMAT_OUTLINE; /* by default */ { FT_Byte* charstring; FT_ULong charstring_len; - CFF_Init_Decoder( &decoder, face, size, glyph, hinting ); + cff_decoder_init( &decoder, face, size, glyph, hinting, + FT_LOAD_TARGET_MODE(load_flags) ); decoder.builder.no_recurse = (FT_Bool)( ( load_flags & FT_LOAD_NO_RECURSE ) != 0 ); /* now load the unscaled outline */ - error = CFF_Access_Element( &cff->charstrings_index, glyph_index, + error = cff_get_glyph_data( face, glyph_index, &charstring, &charstring_len ); if ( !error ) { - CFF_IndexRec csindex = cff->charstrings_index; + cff_decoder_prepare( &decoder, glyph_index ); + error = cff_decoder_parse_charstrings( &decoder, + charstring, charstring_len ); + cff_free_glyph_data( face, &charstring, charstring_len ); - CFF_Prepare_Decoder( &decoder, glyph_index ); - error = CFF_Parse_CharStrings( &decoder, charstring, charstring_len ); - CFF_Forget_Element( &cff->charstrings_index, &charstring ); +#ifdef FT_CONFIG_OPTION_INCREMENTAL + /* Control data and length may not be available for incremental */ + /* fonts. */ + if ( face->root.internal->incremental_interface ) + { + glyph->root.control_data = 0; + glyph->root.control_len = 0; + } + else +#endif /* FT_CONFIG_OPTION_INCREMENTAL */ /* We set control_data and control_len if charstrings is loaded. */ - /* See how charstring loads at CFF_Access_Element() in cffload.c. */ + /* See how charstring loads at cff_index_access_element() in */ + /* cffload.c. */ + { + CFF_IndexRec csindex = cff->charstrings_index; + - glyph->root.control_data = - csindex.bytes + csindex.offsets[glyph_index] - 1; - glyph->root.control_len = - charstring_len; + glyph->root.control_data = + csindex.bytes + csindex.offsets[glyph_index] - 1; + glyph->root.control_len = + charstring_len; + } } /* save new glyph tables */ - CFF_Builder_Done( &decoder.builder ); + cff_builder_done( &decoder.builder ); } font_matrix = cff->top_font.font_dict.font_matrix; @@ -2286,13 +2402,13 @@ glyph->root.linearVertAdvance = 0; - glyph->root.format = ft_glyph_format_outline; + glyph->root.format = FT_GLYPH_FORMAT_OUTLINE; glyph->root.outline.flags = 0; if ( size && size->metrics.y_ppem < 24 ) - glyph->root.outline.flags |= ft_outline_high_precision; + glyph->root.outline.flags |= FT_OUTLINE_HIGH_PRECISION; - glyph->root.outline.flags |= ft_outline_reverse_fill; + glyph->root.outline.flags |= FT_OUTLINE_REVERSE_FILL; /* apply the font matrix */ FT_Outline_Transform( &glyph->root.outline, &font_matrix ); diff --git a/src/libs/freetype2/cff/cffgload.h b/src/libs/freetype2/cff/cffgload.h index b749d1d976a..a1be92cb001 100644 --- a/src/libs/freetype2/cff/cffgload.h +++ b/src/libs/freetype2/cff/cffgload.h @@ -114,6 +114,8 @@ FT_BEGIN_HEADER FT_Error error; /* only used for memory errors */ FT_Bool metrics_only; + FT_UInt32 hint_flags; + void* hints_funcs; /* hinter-specific */ void* hints_globals; /* hinter-specific */ @@ -166,39 +168,42 @@ FT_BEGIN_HEADER FT_Byte** glyph_names; /* for pure CFF fonts only */ FT_UInt num_glyphs; /* number of glyphs in font */ + FT_Render_Mode hint_mode; + } CFF_Decoder; FT_LOCAL( void ) - CFF_Init_Decoder( CFF_Decoder* decoder, - TT_Face face, - CFF_Size size, - CFF_GlyphSlot slot, - FT_Bool hinting ); + cff_decoder_init( CFF_Decoder* decoder, + TT_Face face, + CFF_Size size, + CFF_GlyphSlot slot, + FT_Bool hinting, + FT_Render_Mode hint_mode ); FT_LOCAL( void ) - CFF_Prepare_Decoder( CFF_Decoder* decoder, + cff_decoder_prepare( CFF_Decoder* decoder, FT_UInt glyph_index ); #if 0 /* unused until we support pure CFF fonts */ /* Compute the maximum advance width of a font through quick parsing */ FT_LOCAL( FT_Error ) - CFF_Compute_Max_Advance( TT_Face face, + cff_compute_max_advance( TT_Face face, FT_Int* max_advance ); #endif /* 0 */ FT_LOCAL( FT_Error ) - CFF_Parse_CharStrings( CFF_Decoder* decoder, - FT_Byte* charstring_base, - FT_Int charstring_len ); + cff_decoder_parse_charstrings( CFF_Decoder* decoder, + FT_Byte* charstring_base, + FT_ULong charstring_len ); FT_LOCAL( FT_Error ) - CFF_Load_Glyph( CFF_GlyphSlot glyph, - CFF_Size size, - FT_Int glyph_index, - FT_Int load_flags ); + cff_slot_load( CFF_GlyphSlot glyph, + CFF_Size size, + FT_Int glyph_index, + FT_Int32 load_flags ); FT_END_HEADER diff --git a/src/libs/freetype2/cff/cffload.c b/src/libs/freetype2/cff/cffload.c index 692eea79ec0..b21cfc3cae7 100644 --- a/src/libs/freetype2/cff/cffload.c +++ b/src/libs/freetype2/cff/cffload.c @@ -1047,7 +1047,7 @@ FT_LOCAL_DEF( FT_UShort ) - CFF_Get_Standard_Encoding( FT_UInt charcode ) + cff_get_standard_encoding( FT_UInt charcode ) { return (FT_UShort)(charcode < 256 ? cff_standard_encoding[charcode] : 0); } @@ -1091,7 +1091,7 @@ FT_UShort count; - FT_MEM_SET( idx, 0, sizeof ( *idx ) ); + FT_MEM_ZERO( idx, sizeof ( *idx ) ); idx->stream = stream; if ( !FT_READ_USHORT( count ) && @@ -1167,18 +1167,19 @@ FT_FRAME_RELEASE( idx->bytes ); FT_FREE( idx->offsets ); - FT_MEM_SET( idx, 0, sizeof ( *idx ) ); + FT_MEM_ZERO( idx, sizeof ( *idx ) ); } } + /* allocate a table containing pointers to an index's elements */ static FT_Error - cff_explicit_index( CFF_Index idx, - FT_Byte*** table ) + cff_index_get_pointers( CFF_Index idx, + FT_Byte*** table ) { FT_Error error = 0; FT_Memory memory = idx->stream->memory; - FT_UInt n, offset, old_offset; + FT_ULong n, offset, old_offset; FT_Byte** t; @@ -1205,10 +1206,10 @@ FT_LOCAL_DEF( FT_Error ) - CFF_Access_Element( CFF_Index idx, - FT_UInt element, - FT_Byte** pbytes, - FT_ULong* pbyte_len ) + cff_index_access_element( CFF_Index idx, + FT_UInt element, + FT_Byte** pbytes, + FT_ULong* pbyte_len ) { FT_Error error = 0; @@ -1270,8 +1271,8 @@ FT_LOCAL_DEF( void ) - CFF_Forget_Element( CFF_Index idx, - FT_Byte** pbytes ) + cff_index_forget_element( CFF_Index idx, + FT_Byte** pbytes ) { if ( idx->bytes == 0 ) { @@ -1284,8 +1285,8 @@ FT_LOCAL_DEF( FT_String* ) - CFF_Get_Name( CFF_Index idx, - FT_UInt element ) + cff_index_get_name( CFF_Index idx, + FT_UInt element ) { FT_Memory memory = idx->stream->memory; FT_Byte* bytes; @@ -1294,7 +1295,7 @@ FT_String* name = 0; - error = CFF_Access_Element( idx, element, &bytes, &byte_len ); + error = cff_index_access_element( idx, element, &bytes, &byte_len ); if ( error ) goto Exit; @@ -1303,7 +1304,7 @@ FT_MEM_COPY( name, bytes, byte_len ); name[byte_len] = 0; } - CFF_Forget_Element( idx, &bytes ); + cff_index_forget_element( idx, &bytes ); Exit: return name; @@ -1311,18 +1312,18 @@ FT_LOCAL_DEF( FT_String* ) - CFF_Get_String( CFF_Index idx, - FT_UInt sid, - PSNames_Service psnames_interface ) + cff_index_get_sid_string( CFF_Index idx, + FT_UInt sid, + PSNames_Service psnames_service ) { /* if it is not a standard string, return it */ if ( sid > 390 ) - return CFF_Get_Name( idx, sid - 391 ); + return cff_index_get_name( idx, sid - 391 ); /* that's a standard string, fetch a copy from the PSName module */ { FT_String* name = 0; - const char* adobe_name = psnames_interface->adobe_std_strings( sid ); + const char* adobe_name = psnames_service->adobe_std_strings( sid ); FT_UInt len; @@ -1357,20 +1358,20 @@ static void - CFF_Done_FD_Select( CFF_FDSelect select, + CFF_Done_FD_Select( CFF_FDSelect fdselect, FT_Stream stream ) { - if ( select->data ) - FT_FRAME_RELEASE( select->data ); + if ( fdselect->data ) + FT_FRAME_RELEASE( fdselect->data ); - select->data_size = 0; - select->format = 0; - select->range_count = 0; + fdselect->data_size = 0; + fdselect->format = 0; + fdselect->range_count = 0; } static FT_Error - CFF_Load_FD_Select( CFF_FDSelect select, + CFF_Load_FD_Select( CFF_FDSelect fdselect, FT_UInt num_glyphs, FT_Stream stream, FT_ULong offset ) @@ -1384,23 +1385,23 @@ if ( FT_STREAM_SEEK( offset ) || FT_READ_BYTE( format ) ) goto Exit; - select->format = format; - select->cache_count = 0; /* clear cache */ + fdselect->format = format; + fdselect->cache_count = 0; /* clear cache */ switch ( format ) { case 0: /* format 0, that's simple */ - select->data_size = num_glyphs; + fdselect->data_size = num_glyphs; goto Load_Data; case 3: /* format 3, a tad more complex */ if ( FT_READ_USHORT( num_ranges ) ) goto Exit; - select->data_size = num_ranges * 3 + 2; + fdselect->data_size = num_ranges * 3 + 2; Load_Data: - if ( FT_FRAME_EXTRACT( select->data_size, select->data ) ) + if ( FT_FRAME_EXTRACT( fdselect->data_size, fdselect->data ) ) goto Exit; break; @@ -1414,30 +1415,31 @@ FT_LOCAL_DEF( FT_Byte ) - CFF_Get_FD( CFF_FDSelect select, - FT_UInt glyph_index ) + cff_fd_select_get( CFF_FDSelect fdselect, + FT_UInt glyph_index ) { FT_Byte fd = 0; - switch ( select->format ) + switch ( fdselect->format ) { case 0: - fd = select->data[glyph_index]; + fd = fdselect->data[glyph_index]; break; case 3: /* first, compare to cache */ - if ( (FT_UInt)(glyph_index-select->cache_first) < select->cache_count ) + if ( (FT_UInt)( glyph_index - fdselect->cache_first ) < + fdselect->cache_count ) { - fd = select->cache_fd; + fd = fdselect->cache_fd; break; } /* then, lookup the ranges array */ { - FT_Byte* p = select->data; - FT_Byte* p_limit = p + select->data_size; + FT_Byte* p = fdselect->data; + FT_Byte* p_limit = p + fdselect->data_size; FT_Byte fd2; FT_UInt first, limit; @@ -1456,9 +1458,9 @@ fd = fd2; /* update cache */ - select->cache_first = first; - select->cache_count = limit-first; - select->cache_fd = fd2; + fdselect->cache_first = first; + fdselect->cache_count = limit-first; + fdselect->cache_fd = fd2; break; } first = limit; @@ -1484,23 +1486,7 @@ /*************************************************************************/ static void - CFF_Done_Encoding( CFF_Encoding encoding, - FT_Stream stream ) - { - FT_Memory memory = stream->memory; - - - FT_FREE( encoding->codes ); - FT_FREE( encoding->sids ); - encoding->format = 0; - encoding->offset = 0; - encoding->codes = 0; - encoding->sids = 0; - } - - - static void - CFF_Done_Charset( CFF_Charset charset, + cff_charset_done( CFF_Charset charset, FT_Stream stream ) { FT_Memory memory = stream->memory; @@ -1509,12 +1495,11 @@ FT_FREE( charset->sids ); charset->format = 0; charset->offset = 0; - charset->sids = 0; } static FT_Error - CFF_Load_Charset( CFF_Charset charset, + cff_charset_load( CFF_Charset charset, FT_UInt num_glyphs, FT_Stream stream, FT_ULong base_offset, @@ -1525,13 +1510,6 @@ FT_UShort glyph_sid; - charset->offset = base_offset + offset; - - /* Get the format of the table. */ - if ( FT_STREAM_SEEK( charset->offset ) || - FT_READ_BYTE( charset->format ) ) - goto Exit; - /* If the the offset is greater than 2, we have to parse the */ /* charset table. */ if ( offset > 2 ) @@ -1539,6 +1517,13 @@ FT_UInt j; + charset->offset = base_offset + offset; + + /* Get the format of the table. */ + if ( FT_STREAM_SEEK( charset->offset ) || + FT_READ_BYTE( charset->format ) ) + goto Exit; + /* Allocate memory for sids. */ if ( FT_NEW_ARRAY( charset->sids, num_glyphs ) ) goto Exit; @@ -1549,12 +1534,15 @@ switch ( charset->format ) { case 0: - for ( j = 1; j < num_glyphs; j++ ) + if ( num_glyphs > 0 ) { - if ( FT_READ_USHORT( glyph_sid ) ) + if ( FT_FRAME_ENTER( ( num_glyphs - 1 ) * 2 ) ) goto Exit; - - charset->sids[j] = glyph_sid; + + for ( j = 1; j < num_glyphs; j++ ) + charset->sids[j] = FT_GET_USHORT(); + + FT_FRAME_EXIT(); } break; @@ -1587,14 +1575,14 @@ } /* Fill in the range of sids -- `nleft + 1' glyphs. */ - for ( i = 0; i <= nleft; i++, j++, glyph_sid++ ) + for ( i = 0; j < num_glyphs && i <= nleft; i++, j++, glyph_sid++ ) charset->sids[j] = glyph_sid; } } break; default: - FT_ERROR(( "CFF_Load_Charset: invalid table format!\n" )); + FT_ERROR(( "cff_charset_load: invalid table format!\n" )); error = CFF_Err_Invalid_File_Format; goto Exit; } @@ -1610,12 +1598,14 @@ /* the first num_glyphs, and hence must match the predefined */ /* charset *exactly*. */ - switch ( offset ) + charset->offset = offset; /* record charset type */ + + switch ( (FT_UInt)offset ) { case 0: if ( num_glyphs != 229 ) { - FT_ERROR(("CFF_Load_Charset: implicit charset not equal to\n" + FT_ERROR(("cff_charset_load: implicit charset not equal to\n" "predefined charset (Adobe ISO-Latin)!\n" )); error = CFF_Err_Invalid_File_Format; goto Exit; @@ -1634,7 +1624,7 @@ case 1: if ( num_glyphs != 166 ) { - FT_ERROR(( "CFF_Load_Charset: implicit charset not equal to\n" + FT_ERROR(( "cff_charset_load: implicit charset not equal to\n" "predefined charset (Adobe Expert)!\n" )); error = CFF_Err_Invalid_File_Format; goto Exit; @@ -1653,7 +1643,7 @@ case 2: if ( num_glyphs != 87 ) { - FT_ERROR(( "CFF_Load_Charset: implicit charset not equal to\n" + FT_ERROR(( "cff_charset_load: implicit charset not equal to\n" "predefined charset (Adobe Expert Subset)!\n" )); error = CFF_Err_Invalid_File_Format; goto Exit; @@ -1681,8 +1671,7 @@ if ( error ) if ( charset->sids ) { - if ( charset->sids ) - FT_FREE( charset->sids ); + FT_FREE( charset->sids ); charset->format = 0; charset->offset = 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 - CFF_Load_Encoding( CFF_Encoding encoding, + cff_encoding_load( CFF_Encoding encoding, CFF_Charset charset, FT_UInt num_glyphs, FT_Stream stream, FT_ULong base_offset, FT_ULong offset ) { - FT_Memory memory = stream->memory; FT_Error error = 0; FT_UInt count; FT_UInt j; FT_UShort glyph_sid; - FT_Byte glyph_code; + FT_UInt glyph_code; /* Check for charset->sids. If we do not have this, we fail. */ @@ -1715,14 +1714,8 @@ goto Exit; } - /* Allocate memory for sids/codes -- there are at most 256 sids/codes */ - /* for an encoding. */ - if ( FT_NEW_ARRAY( encoding->sids, 256 ) || - FT_NEW_ARRAY( encoding->codes, 256 ) ) - goto Exit; - /* Zero out the code to gid/sid mappings. */ - for ( j = 0; j < 255; j++ ) + for ( j = 0; j < 256; j++ ) { encoding->sids [j] = 0; encoding->codes[j] = 0; @@ -1751,25 +1744,37 @@ FT_READ_BYTE( count ) ) goto Exit; + encoding->count = count + 1; + switch ( encoding->format & 0x7F ) { case 0: - for ( j = 1; j <= count; j++ ) { - if ( FT_READ_BYTE( glyph_code ) ) - goto Exit; + FT_Byte* p; + - /* Make sure j is not too big. */ - if ( j > num_glyphs ) + if ( FT_FRAME_ENTER( count ) ) goto Exit; - /* Assign code to GID mapping. */ - encoding->codes[glyph_code] = (FT_UShort)j; + p = (FT_Byte*)stream->cursor; + + for ( j = 1; j <= count; j++ ) + { + glyph_code = *p++; - /* Assign code to SID mapping. */ - encoding->sids[glyph_code] = charset->sids[j]; - } + /* Make sure j is not too big. */ + if ( (FT_UInt) glyph_code < num_glyphs ) + { + /* Assign code to GID mapping. */ + encoding->codes[glyph_code] = (FT_UShort)j; + /* Assign code to SID mapping. */ + encoding->sids[glyph_code] = charset->sids[j]; + } + } + + FT_FRAME_EXIT(); + } break; case 1: @@ -1797,21 +1802,21 @@ for ( k = i; k < nleft + i; k++, glyph_code++ ) { /* Make sure k is not too big. */ - if ( k > num_glyphs ) - goto Exit; - - /* Assign code to GID mapping. */ - encoding->codes[glyph_code] = (FT_UShort)k; - - /* Assign code to SID mapping. */ - encoding->sids[glyph_code] = charset->sids[k]; + if ( k < num_glyphs && glyph_code < 256 ) + { + /* Assign code to GID mapping. */ + encoding->codes[glyph_code] = (FT_UShort)k; + + /* Assign code to SID mapping. */ + encoding->sids[glyph_code] = charset->sids[k]; + } } } } break; default: - FT_ERROR(( "CFF_Load_Encoding: invalid table format!\n" )); + FT_ERROR(( "cff_encoding_load: invalid table format!\n" )); error = CFF_Err_Invalid_File_Format; goto Exit; } @@ -1819,7 +1824,7 @@ /* Parse supplemental encodings, if any. */ if ( encoding->format & 0x80 ) { - FT_UInt glyph_id; + FT_UInt gindex; /* count supplements */ @@ -1841,14 +1846,14 @@ /* First, lookup GID which has been assigned to */ /* SID glyph_sid. */ - for ( glyph_id = 0; glyph_id < num_glyphs; glyph_id++ ) + for ( gindex = 0; gindex < num_glyphs; gindex++ ) { - if ( charset->sids[glyph_id] == glyph_sid ) + if ( charset->sids[gindex] == glyph_sid ) + { + encoding->codes[glyph_code] = (FT_UShort) gindex; break; + } } - - /* Now, make the assignment. */ - encoding->codes[glyph_code] = (FT_UShort)glyph_id; } } } @@ -1862,44 +1867,23 @@ /* encoding (see the note at the end of section 12 in the CFF */ /* specification). */ - switch ( offset ) + encoding->count = 256; + + switch ( (FT_UInt)offset ) { case 0: /* First, copy the code to SID mapping. */ FT_MEM_COPY( encoding->sids, cff_standard_encoding, 256 * sizeof ( FT_UShort ) ); - /* Construct code to GID mapping from code */ - /* to SID mapping and charset. */ - for ( j = 0; j < 256; j++ ) - { - /* If j is encoded, find the GID for it. */ - if ( encoding->sids[j] ) - { - for ( i = 1; i < num_glyphs; i++ ) - /* We matched, so break. */ - if ( charset->sids[i] == encoding->sids[j] ) - break; - - /* i will be equal to num_glyphs if we exited the above */ - /* loop without a match. In this case, we also have to */ - /* fix the code to SID mapping. */ - if ( i == num_glyphs ) - { - encoding->codes[j] = 0; - encoding->sids [j] = 0; - } - else - encoding->codes[j] = (FT_UShort)i; - } - } - break; + goto Populate; case 1: /* First, copy the code to SID mapping. */ FT_MEM_COPY( encoding->sids, cff_expert_encoding, 256 * sizeof ( FT_UShort ) ); + Populate: /* Construct code to GID mapping from code to SID mapping */ /* and charset. */ for ( j = 0; j < 256; j++ ) @@ -1927,7 +1911,7 @@ break; default: - FT_ERROR(( "CFF_Load_Encoding: invalid table format!\n" )); + FT_ERROR(( "cff_encoding_load: invalid table format!\n" )); error = CFF_Err_Invalid_File_Format; goto Exit; } @@ -1936,28 +1920,12 @@ Exit: /* Clean up if there was an error. */ - if ( error ) - { - if ( encoding->sids || encoding->codes ) - { - if ( encoding->sids ) - FT_FREE( encoding->sids ); - - if ( encoding->codes ) - FT_FREE( encoding->codes ); - - charset->format = 0; - charset->offset = 0; - charset->sids = 0; - } - } - return error; } static FT_Error - CFF_Load_SubFont( CFF_SubFont font, + cff_subfont_load( CFF_SubFont font, CFF_Index idx, FT_UInt font_index, FT_Stream stream, @@ -1971,10 +1939,10 @@ CFF_Private priv = &font->private_dict; - CFF_Parser_Init( &parser, CFF_CODE_TOPDICT, &font->font_dict ); + cff_parser_init( &parser, CFF_CODE_TOPDICT, &font->font_dict ); /* set defaults */ - FT_MEM_SET( top, 0, sizeof ( *top ) ); + FT_MEM_ZERO( top, sizeof ( *top ) ); top->underline_position = -100; top->underline_thickness = 50; @@ -1983,10 +1951,10 @@ top->font_matrix.yy = 0x10000L; top->cid_count = 8720; - error = CFF_Access_Element( idx, font_index, &dict, &dict_len ) || - CFF_Parser_Run( &parser, dict, dict + dict_len ); + error = cff_index_access_element( idx, font_index, &dict, &dict_len ) || + cff_parser_run( &parser, dict, dict + dict_len ); - CFF_Forget_Element( idx, &dict ); + cff_index_forget_element( idx, &dict ); if ( error ) goto Exit; @@ -1999,7 +1967,7 @@ if ( top->private_offset && top->private_size ) { /* set defaults */ - FT_MEM_SET( priv, 0, sizeof ( *priv ) ); + FT_MEM_ZERO( priv, sizeof ( *priv ) ); priv->blue_shift = 7; priv->blue_fuzz = 1; @@ -2007,15 +1975,15 @@ priv->expansion_factor = (FT_Fixed)0.06 * 0x10000L; priv->blue_scale = (FT_Fixed)0.039625 * 0x10000L; - CFF_Parser_Init( &parser, CFF_CODE_PRIVATE, priv ); + cff_parser_init( &parser, CFF_CODE_PRIVATE, priv ); if ( FT_STREAM_SEEK( base_offset + font->font_dict.private_offset ) || FT_FRAME_ENTER( font->font_dict.private_size ) ) goto Exit; - error = CFF_Parser_Run( &parser, - (FT_Byte*)stream->cursor, - (FT_Byte*)stream->limit ); + error = cff_parser_run( &parser, + (FT_Byte*)stream->cursor, + (FT_Byte*)stream->limit ); FT_FRAME_EXIT(); if ( error ) goto Exit; @@ -2033,8 +2001,8 @@ goto Exit; font->num_local_subrs = font->local_subrs_index.count; - error = cff_explicit_index( &font->local_subrs_index, - &font->local_subrs ); + error = cff_index_get_pointers( &font->local_subrs_index, + &font->local_subrs ); if ( error ) goto Exit; } @@ -2045,7 +2013,7 @@ static void - CFF_Done_SubFont( FT_Memory memory, + cff_subfont_done( FT_Memory memory, CFF_SubFont subfont ) { if ( subfont ) @@ -2057,7 +2025,7 @@ FT_LOCAL_DEF( FT_Error ) - CFF_Load_Font( FT_Stream stream, + cff_font_load( FT_Stream stream, FT_Int face_index, CFF_Font font ) { @@ -2079,8 +2047,7 @@ FT_ULong base_offset; CFF_FontRecDict dict; - - FT_MEM_SET( font, 0, sizeof ( *font ) ); + FT_ZERO( font ); font->stream = stream; font->memory = memory; @@ -2116,7 +2083,7 @@ font->num_faces = font->name_index.count; if ( face_index >= (FT_Int)font->num_faces ) { - FT_ERROR(( "CFF_Load_Font: incorrect face index = %d\n", + FT_ERROR(( "cff_font_load: incorrect face index = %d\n", face_index )); error = CFF_Err_Invalid_Argument; } @@ -2126,7 +2093,7 @@ goto Exit; /* now, parse the top-level font dictionary */ - error = CFF_Load_SubFont( &font->top_font, + error = cff_subfont_load( &font->top_font, &font->font_dict_index, face_index, stream, @@ -2153,7 +2120,7 @@ if ( fd_index.count > CFF_MAX_CID_FONTS ) { - FT_ERROR(( "CFF_Load_Font: FD array too large in CID font\n" )); + FT_ERROR(( "cff_font_load: FD array too large in CID font\n" )); goto Fail_CID; } @@ -2170,7 +2137,7 @@ for ( idx = 0; idx < fd_index.count; idx++ ) { sub = font->subfonts[idx]; - error = CFF_Load_SubFont( sub, &fd_index, idx, + error = cff_subfont_load( sub, &fd_index, idx, stream, base_offset ); if ( error ) goto Fail_CID; @@ -2178,7 +2145,7 @@ /* now load the FD Select array */ error = CFF_Load_FD_Select( &font->fd_select, - dict->cid_count, + (FT_UInt)dict->cid_count, stream, base_offset + dict->cid_fd_select_offset ); @@ -2194,7 +2161,7 @@ /* read the charstrings index now */ if ( dict->charstrings_offset == 0 ) { - FT_ERROR(( "CFF_Load_Font: no charstrings offset!\n" )); + FT_ERROR(( "cff_font_load: no charstrings offset!\n" )); error = CFF_Err_Unknown_File_Format; goto Exit; } @@ -2210,29 +2177,32 @@ font->num_global_subrs = font->global_subrs_index.count; font->num_glyphs = font->charstrings_index.count; - error = cff_explicit_index( &font->global_subrs_index, - &font->global_subrs ) ; + error = cff_index_get_pointers( &font->global_subrs_index, + &font->global_subrs ) ; if ( error ) goto Exit; /* read the Charset and Encoding tables when available */ - error = CFF_Load_Charset( &font->charset, font->num_glyphs, stream, + if ( font->num_glyphs > 0 ) + { + error = cff_charset_load( &font->charset, font->num_glyphs, stream, base_offset, dict->charset_offset ); - if ( error ) - goto Exit; + if ( error ) + goto Exit; - error = CFF_Load_Encoding( &font->encoding, - &font->charset, - font->num_glyphs, - stream, - base_offset, - dict->encoding_offset ); - if ( error ) - goto Exit; + error = cff_encoding_load( &font->encoding, + &font->charset, + font->num_glyphs, + stream, + base_offset, + dict->encoding_offset ); + if ( error ) + goto Exit; + } /* get the font name */ - font->font_name = CFF_Get_Name( &font->name_index, face_index ); + font->font_name = cff_index_get_name( &font->name_index, face_index ); Exit: return error; @@ -2240,7 +2210,7 @@ FT_LOCAL_DEF( void ) - CFF_Done_Font( CFF_Font font ) + cff_font_done( CFF_Font font ) { FT_Memory memory = font->memory; FT_UInt idx; @@ -2257,15 +2227,15 @@ if ( font->num_subfonts > 0 ) { for ( idx = 0; idx < font->num_subfonts; idx++ ) - CFF_Done_SubFont( memory, font->subfonts[idx] ); + cff_subfont_done( memory, font->subfonts[idx] ); FT_FREE( font->subfonts ); } - CFF_Done_Encoding( &font->encoding, font->stream ); - CFF_Done_Charset( &font->charset, font->stream ); + cff_encoding_done( &font->encoding ); + cff_charset_done( &font->charset, font->stream ); - CFF_Done_SubFont( memory, &font->top_font ); + cff_subfont_done( memory, &font->top_font ); CFF_Done_FD_Select( &font->fd_select, font->stream ); diff --git a/src/libs/freetype2/cff/cffload.h b/src/libs/freetype2/cff/cffload.h index 2057308cb5b..4cadfe6bbbf 100644 --- a/src/libs/freetype2/cff/cffload.h +++ b/src/libs/freetype2/cff/cffload.h @@ -28,42 +28,42 @@ FT_BEGIN_HEADER FT_LOCAL( FT_UShort ) - CFF_Get_Standard_Encoding( FT_UInt charcode ); + cff_get_standard_encoding( FT_UInt charcode ); FT_LOCAL( FT_String* ) - CFF_Get_Name( CFF_Index idx, - FT_UInt element ); + cff_index_get_name( CFF_Index idx, + FT_UInt element ); FT_LOCAL( FT_String* ) - CFF_Get_String( CFF_Index idx, - FT_UInt sid, - PSNames_Service psnames_interface ); + cff_index_get_sid_string( CFF_Index idx, + FT_UInt sid, + PSNames_Service psnames_interface ); FT_LOCAL( FT_Error ) - CFF_Access_Element( CFF_Index idx, - FT_UInt element, - FT_Byte** pbytes, - FT_ULong* pbyte_len ); + cff_index_access_element( CFF_Index idx, + FT_UInt element, + FT_Byte** pbytes, + FT_ULong* pbyte_len ); FT_LOCAL( void ) - CFF_Forget_Element( CFF_Index idx, - FT_Byte** pbytes ); + cff_index_forget_element( CFF_Index idx, + FT_Byte** pbytes ); FT_LOCAL( FT_Error ) - CFF_Load_Font( FT_Stream stream, + cff_font_load( FT_Stream stream, FT_Int face_index, CFF_Font font ); FT_LOCAL( void ) - CFF_Done_Font( CFF_Font font ); + cff_font_done( CFF_Font font ); FT_LOCAL( FT_Byte ) - CFF_Get_FD( CFF_FDSelect select, - FT_UInt glyph_index ); + cff_fd_select_get( CFF_FDSelect select, + FT_UInt glyph_index ); FT_END_HEADER diff --git a/src/libs/freetype2/cff/cffobjs.c b/src/libs/freetype2/cff/cffobjs.c index 49b67369210..830f46269fe 100644 --- a/src/libs/freetype2/cff/cffobjs.c +++ b/src/libs/freetype2/cff/cffobjs.c @@ -28,7 +28,7 @@ #include FT_INTERNAL_POSTSCRIPT_HINTS_H #include "cffobjs.h" #include "cffload.h" - +#include "cffcmap.h" #include "cfferrs.h" @@ -53,7 +53,7 @@ static PSH_Globals_Funcs - CFF_Size_Get_Globals_Funcs( CFF_Size size ) + cff_size_get_globals_funcs( CFF_Size size ) { CFF_Face face = (CFF_Face)size->face; CFF_Font font = (CFF_FontRec *)face->extra.data; @@ -70,14 +70,14 @@ FT_LOCAL_DEF( void ) - CFF_Size_Done( CFF_Size size ) + cff_size_done( CFF_Size size ) { if ( size->internal ) { PSH_Globals_Funcs funcs; - funcs = CFF_Size_Get_Globals_Funcs( size ); + funcs = cff_size_get_globals_funcs( size ); if ( funcs ) funcs->destroy( (PSH_Globals)size->internal ); @@ -87,10 +87,10 @@ FT_LOCAL_DEF( FT_Error ) - CFF_Size_Init( CFF_Size size ) + cff_size_init( CFF_Size size ) { FT_Error error = 0; - PSH_Globals_Funcs funcs = CFF_Size_Get_Globals_Funcs( size ); + PSH_Globals_Funcs funcs = cff_size_get_globals_funcs( size ); if ( funcs ) @@ -112,7 +112,7 @@ FT_UInt n, count; - FT_MEM_SET( &priv, 0, sizeof ( priv ) ); + FT_MEM_ZERO( &priv, sizeof ( priv ) ); count = priv.num_blue_values = cpriv->num_blue_values; for ( n = 0; n < count; n++ ) @@ -131,8 +131,8 @@ priv.family_other_blues[n] = (FT_Short)cpriv->family_other_blues[n]; priv.blue_scale = cpriv->blue_scale; - priv.blue_shift = cpriv->blue_shift; - priv.blue_fuzz = cpriv->blue_fuzz; + priv.blue_shift = (FT_Int)cpriv->blue_shift; + priv.blue_fuzz = (FT_Int)cpriv->blue_fuzz; priv.standard_width[0] = (FT_UShort)cpriv->standard_width; priv.standard_height[0] = (FT_UShort)cpriv->standard_height; @@ -160,9 +160,9 @@ FT_LOCAL_DEF( FT_Error ) - CFF_Size_Reset( CFF_Size size ) + cff_size_reset( CFF_Size size ) { - PSH_Globals_Funcs funcs = CFF_Size_Get_Globals_Funcs( size ); + PSH_Globals_Funcs funcs = cff_size_get_globals_funcs( size ); FT_Error error = 0; @@ -182,14 +182,14 @@ /*************************************************************************/ FT_LOCAL_DEF( void ) - CFF_GlyphSlot_Done( CFF_GlyphSlot slot ) + cff_slot_done( CFF_GlyphSlot slot ) { slot->root.internal->glyph_hints = 0; } FT_LOCAL_DEF( FT_Error ) - CFF_GlyphSlot_Init( CFF_GlyphSlot slot ) + cff_slot_init( CFF_GlyphSlot slot ) { CFF_Face face = (CFF_Face)slot->root.face; CFF_Font font = (CFF_FontRec *)face->extra.data; @@ -224,8 +224,8 @@ /*************************************************************************/ static FT_String* - CFF_StrCopy( FT_Memory memory, - const FT_String* source ) + cff_strcpy( FT_Memory memory, + const FT_String* source ) { FT_Error error; FT_String* result = 0; @@ -245,8 +245,9 @@ + FT_LOCAL_DEF( FT_Error ) - CFF_Face_Init( FT_Stream stream, + cff_face_init( FT_Stream stream, CFF_Face face, FT_Int face_index, FT_Int num_params, @@ -334,18 +335,19 @@ CFF_Font cff; FT_Memory memory = face->root.memory; FT_Face root; - FT_UInt flags; + FT_Int32 flags; if ( FT_NEW( cff ) ) goto Exit; face->extra.data = cff; - error = CFF_Load_Font( stream, face_index, cff ); + error = cff_font_load( stream, face_index, cff ); if ( error ) goto Exit; cff->pshinter = pshinter; + cff->psnames = psnames; /* Complement the root flags with some interesting information. */ /* Note that this is only necessary for pure CFF and CEF fonts. */ @@ -361,7 +363,7 @@ /* we need the `PSNames' module for pure-CFF and CEF formats */ if ( !psnames ) { - FT_ERROR(( "CFF_Face_Init:" )); + FT_ERROR(( "cff_face_init:" )); FT_ERROR(( " cannot open CFF & CEF fonts\n" )); FT_ERROR(( " " )); FT_ERROR(( " without the `PSNames' module\n" )); @@ -395,13 +397,13 @@ root->units_per_EM = 1000; /* retrieve font family & style name */ - root->family_name = CFF_Get_Name( &cff->name_index, face_index ); + root->family_name = cff_index_get_name( &cff->name_index, face_index ); if ( dict->cid_registry ) - root->style_name = CFF_StrCopy( memory, "Regular" ); /* XXXX */ + root->style_name = cff_strcpy( memory, "Regular" ); /* XXXX */ else - root->style_name = CFF_Get_String( &cff->string_index, - dict->weight, - psnames ); + root->style_name = cff_index_get_sid_string( &cff->string_index, + dict->weight, + psnames ); /*******************************************************************/ /* */ @@ -444,8 +446,81 @@ flags |= FT_STYLE_FLAG_BOLD; root->style_flags = flags; - - /* 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 ) - CFF_Face_Done( CFF_Face face ) + cff_face_done( CFF_Face face ) { FT_Memory memory = face->root.memory; SFNT_Service sfnt = (SFNT_Service)face->sfnt; @@ -474,7 +549,7 @@ if ( cff ) { - CFF_Done_Font( cff ); + cff_font_done( cff ); FT_FREE( face->extra.data ); } } @@ -482,7 +557,7 @@ FT_LOCAL_DEF( FT_Error ) - CFF_Driver_Init( CFF_Driver driver ) + cff_driver_init( CFF_Driver driver ) { FT_UNUSED( driver ); @@ -491,7 +566,7 @@ FT_LOCAL_DEF( void ) - CFF_Driver_Done( CFF_Driver driver ) + cff_driver_done( CFF_Driver driver ) { FT_UNUSED( driver ); } diff --git a/src/libs/freetype2/cff/cffobjs.h b/src/libs/freetype2/cff/cffobjs.h index 6610952e75c..cf60ecfb254 100644 --- a/src/libs/freetype2/cff/cffobjs.h +++ b/src/libs/freetype2/cff/cffobjs.h @@ -23,6 +23,7 @@ #include <ft2build.h> #include FT_INTERNAL_OBJECTS_H #include FT_INTERNAL_CFF_TYPES_H +#include FT_INTERNAL_TRUETYPE_TYPES_H #include FT_INTERNAL_POSTSCRIPT_NAMES_H @@ -110,19 +111,19 @@ FT_BEGIN_HEADER FT_LOCAL( FT_Error ) - CFF_Size_Init( CFF_Size size ); + cff_size_init( CFF_Size size ); FT_LOCAL( void ) - CFF_Size_Done( CFF_Size size ); + cff_size_done( CFF_Size size ); FT_LOCAL( FT_Error ) - CFF_Size_Reset( CFF_Size size ); + cff_size_reset( CFF_Size size ); FT_LOCAL( void ) - CFF_GlyphSlot_Done( CFF_GlyphSlot slot ); + cff_slot_done( CFF_GlyphSlot slot ); FT_LOCAL( FT_Error ) - CFF_GlyphSlot_Init( CFF_GlyphSlot slot ); + cff_slot_init( CFF_GlyphSlot slot ); /*************************************************************************/ @@ -130,14 +131,14 @@ FT_BEGIN_HEADER /* Face functions */ /* */ FT_LOCAL( FT_Error ) - CFF_Face_Init( FT_Stream stream, + cff_face_init( FT_Stream stream, CFF_Face face, FT_Int face_index, FT_Int num_params, FT_Parameter* params ); FT_LOCAL( void ) - CFF_Face_Done( CFF_Face face ); + cff_face_done( CFF_Face face ); /*************************************************************************/ @@ -145,10 +146,10 @@ FT_BEGIN_HEADER /* Driver functions */ /* */ FT_LOCAL( FT_Error ) - CFF_Driver_Init( CFF_Driver driver ); + cff_driver_init( CFF_Driver driver ); FT_LOCAL( void ) - CFF_Driver_Done( CFF_Driver driver ); + cff_driver_done( CFF_Driver driver ); FT_END_HEADER diff --git a/src/libs/freetype2/cff/cffparse.c b/src/libs/freetype2/cff/cffparse.c index 8f35020286c..3e1f8408e8f 100644 --- a/src/libs/freetype2/cff/cffparse.c +++ b/src/libs/freetype2/cff/cffparse.c @@ -64,11 +64,11 @@ FT_LOCAL_DEF( void ) - CFF_Parser_Init( CFF_Parser parser, + cff_parser_init( CFF_Parser parser, FT_UInt code, void* object ) { - FT_MEM_SET( parser, 0, sizeof ( *parser ) ); + FT_MEM_ZERO( parser, sizeof ( *parser ) ); parser->top = parser->stack; parser->object_code = code; @@ -244,7 +244,7 @@ if ( exp_sign ) exp = -exp; - power_ten += exp; + power_ten += (FT_Int)exp; } /* raise to power of ten if needed */ @@ -480,7 +480,7 @@ FT_LOCAL_DEF( FT_Error ) - CFF_Parser_Run( CFF_Parser parser, + cff_parser_run( CFF_Parser parser, FT_Byte* start, FT_Byte* limit ) { @@ -542,16 +542,15 @@ const CFF_Field_Handler* field; - /* first of all, a trivial check */ - if ( num_args < 1 ) - goto Stack_Underflow; - *parser->top = p; code = v; if ( v == 12 ) { /* two byte operator */ p++; + if ( p >= limit ) + goto Syntax_Error; + code = 0x100 | p[0]; } code = code | parser->object_code; @@ -565,6 +564,11 @@ FT_Byte* q = (FT_Byte*)parser->object + field->offset; + /* check that we have enough arguments -- except for */ + /* delta encoded arrays, which can be empty */ + if ( field->kind != cff_kind_delta && num_args < 1 ) + goto Stack_Underflow; + switch ( field->kind ) { case cff_kind_bool: diff --git a/src/libs/freetype2/cff/cffparse.h b/src/libs/freetype2/cff/cffparse.h index f2a935cb0ad..2de95a2c5bb 100644 --- a/src/libs/freetype2/cff/cffparse.h +++ b/src/libs/freetype2/cff/cffparse.h @@ -50,12 +50,12 @@ FT_BEGIN_HEADER FT_LOCAL( void ) - CFF_Parser_Init( CFF_Parser parser, + cff_parser_init( CFF_Parser parser, FT_UInt code, void* object ); FT_LOCAL( FT_Error ) - CFF_Parser_Run( CFF_Parser parser, + cff_parser_run( CFF_Parser parser, FT_Byte* start, FT_Byte* limit ); diff --git a/src/libs/freetype2/cff/rules.mk b/src/libs/freetype2/cff/rules.mk index 6f0b9e4e7a8..b53fdd83a2c 100644 --- a/src/libs/freetype2/cff/rules.mk +++ b/src/libs/freetype2/cff/rules.mk @@ -28,6 +28,7 @@ CFF_DRV_SRC := $(CFF_DIR_)cffobjs.c \ $(CFF_DIR_)cffload.c \ $(CFF_DIR_)cffgload.c \ $(CFF_DIR_)cffparse.c \ + $(CFF_DIR_)cffcmap.c \ $(CFF_DIR_)cffdrivr.c # CFF driver headers diff --git a/src/libs/freetype2/cid/cidgload.c b/src/libs/freetype2/cid/cidgload.c index 3c0a898acf3..9e606742a66 100644 --- a/src/libs/freetype2/cid/cidgload.c +++ b/src/libs/freetype2/cid/cidgload.c @@ -43,76 +43,143 @@ CID_Face face = (CID_Face)decoder->builder.face; CID_FaceInfo cid = &face->cid; FT_Byte* p; - FT_UInt entry_len = cid->fd_bytes + cid->gd_bytes; FT_UInt fd_select; - FT_ULong off1, glyph_len; FT_Stream stream = face->root.stream; FT_Error error = 0; + FT_Byte* charstring = 0; + FT_Memory memory = face->root.memory; + FT_UInt glyph_length = 0; - /* read the CID font dict index and charstring offset from the CIDMap */ - if ( FT_STREAM_SEEK( cid->data_offset + cid->cidmap_offset + - glyph_index * entry_len ) || - FT_FRAME_ENTER( 2 * entry_len ) ) - goto Exit; +#ifdef FT_CONFIG_OPTION_INCREMENTAL + + /* For incremental fonts get the character data using */ + /* the callback function. */ + if ( face->root.internal->incremental_interface ) + { + FT_Data glyph_data; - 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_len = cid_get_offset( &p, (FT_Byte)cid->gd_bytes ) - off1; - FT_FRAME_EXIT(); + error = face->root.internal->incremental_interface->funcs->get_glyph_data( + face->root.internal->incremental_interface->object, + glyph_index, + &glyph_data ); + if ( error ) + goto Exit; - /* now, if the glyph is not empty, set up the subrs array, and parse */ - /* the charstrings */ - if ( glyph_len > 0 ) + 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_Subrs cid_subrs = face->subrs + fd_select; - FT_Byte* charstring; - FT_Memory memory = face->root.memory; + FT_Int cs_offset; - /* setup subrs */ + /* Set up subrs */ decoder->num_subrs = cid_subrs->num_subrs; decoder->subrs = cid_subrs->code; decoder->subrs_len = 0; - /* setup font matrix */ + /* Set up font matrix */ dict = cid->font_dicts + fd_select; decoder->font_matrix = dict->font_matrix; decoder->font_offset = dict->font_offset; decoder->lenIV = dict->private_dict.lenIV; - /* the charstrings are encoded (stupid!) */ - /* load the charstrings, then execute it */ + /* Decode the charstring. */ - if ( FT_ALLOC( charstring, glyph_len ) ) - goto Exit; + /* Adjustment for seed bytes. */ + cs_offset = ( decoder->lenIV >= 0 ? decoder->lenIV : 0 ); - if ( !FT_STREAM_READ_AT( cid->data_offset + off1, - charstring, glyph_len ) ) - { - FT_Int cs_offset; + /* Decrypt only if lenIV >= 0. */ + if ( decoder->lenIV >= 0 ) + cid_decrypt( charstring, glyph_length, 4330 ); + error = decoder->funcs.parse_charstrings( decoder, + charstring + cs_offset, + glyph_length - cs_offset ); + } - /* Adjustment for seed bytes. */ - cs_offset = ( decoder->lenIV >= 0 ? decoder->lenIV : 0 ); + FT_FREE( charstring ); - /* Decrypt only if lenIV >= 0. */ - if ( decoder->lenIV >= 0 ) - cid_decrypt( charstring, glyph_len, 4330 ); +#ifdef FT_CONFIG_OPTION_INCREMENTAL - error = decoder->funcs.parse_charstrings( decoder, - charstring + cs_offset, - glyph_len - cs_offset ); - } + /* 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; - FT_FREE( charstring ); + + error = face->root.internal->incremental_interface->funcs->get_glyph_metrics( + face->root.internal->incremental_interface->object, + glyph_index, FALSE, &metrics, &found ); + if ( found ) + { + decoder->builder.left_bearing.x = metrics.bearing_x; + decoder->builder.left_bearing.y = metrics.bearing_y; + decoder->builder.advance.x = metrics.advance; + decoder->builder.advance.y = 0; + } } +#endif + Exit: return error; } @@ -140,8 +207,8 @@ FT_LOCAL_DEF( FT_Error ) - CID_Compute_Max_Advance( CID_Face face, - FT_Int* max_advance ) + cid_face_compute_max_advance( CID_Face face, + FT_Int* max_advance ) { FT_Error error; T1_DecoderRec decoder; @@ -203,10 +270,10 @@ FT_LOCAL_DEF( FT_Error ) - CID_Load_Glyph( CID_GlyphSlot glyph, - CID_Size size, - FT_Int glyph_index, - FT_Int load_flags ) + cid_slot_load_glyph( CID_GlyphSlot glyph, + CID_Size size, + FT_Int glyph_index, + FT_Int32 load_flags ) { FT_Error error; T1_DecoderRec decoder; @@ -230,7 +297,7 @@ hinting = FT_BOOL( ( load_flags & FT_LOAD_NO_SCALE ) == 0 && ( load_flags & FT_LOAD_NO_HINTING ) == 0 ); - glyph->root.format = ft_glyph_format_outline; + glyph->root.format = FT_GLYPH_FORMAT_OUTLINE; { error = psaux->t1_decoder_funcs->init( &decoder, @@ -240,6 +307,7 @@ 0, /* glyph names -- XXX */ 0, /* blend == 0 */ hinting, + FT_LOAD_TARGET_MODE(load_flags), cid_load_glyph ); /* set up the decoder */ @@ -260,8 +328,8 @@ /* bearing the yMax */ if ( !error ) { - glyph->root.outline.flags &= ft_outline_owner; - glyph->root.outline.flags |= ft_outline_reverse_fill; + glyph->root.outline.flags &= FT_OUTLINE_OWNER; + glyph->root.outline.flags |= FT_OUTLINE_REVERSE_FILL; /* for composite glyphs, return only left side bearing and */ /* advance width */ @@ -294,10 +362,10 @@ metrics->vertAdvance = 0; glyph->root.linearVertAdvance = 0; - glyph->root.format = ft_glyph_format_outline; + glyph->root.format = FT_GLYPH_FORMAT_OUTLINE; if ( size && size->root.metrics.y_ppem < 24 ) - glyph->root.outline.flags |= ft_outline_high_precision; + glyph->root.outline.flags |= FT_OUTLINE_HIGH_PRECISION; /* apply the font matrix */ FT_Outline_Transform( &glyph->root.outline, &font_matrix ); diff --git a/src/libs/freetype2/cid/cidgload.h b/src/libs/freetype2/cid/cidgload.h index 20cdba10457..93858e86505 100644 --- a/src/libs/freetype2/cid/cidgload.h +++ b/src/libs/freetype2/cid/cidgload.h @@ -31,16 +31,16 @@ FT_BEGIN_HEADER /* Compute the maximum advance width of a font through quick parsing */ FT_LOCAL( FT_Error ) - CID_Compute_Max_Advance( CID_Face face, - FT_Int* max_advance ); + cid_face_compute_max_advance( CID_Face face, + FT_Int* max_advance ); #endif /* 0 */ FT_LOCAL( FT_Error ) - CID_Load_Glyph( CID_GlyphSlot glyph, - CID_Size size, - FT_Int glyph_index, - FT_Int load_flags ); + cid_slot_load_glyph( CID_GlyphSlot glyph, + CID_Size size, + FT_Int glyph_index, + FT_Int32 load_flags ); FT_END_HEADER diff --git a/src/libs/freetype2/cid/cidload.c b/src/libs/freetype2/cid/cidload.c index 95f1965c23c..19cfab50ff0 100644 --- a/src/libs/freetype2/cid/cidload.c +++ b/src/libs/freetype2/cid/cidload.c @@ -146,10 +146,10 @@ /* now, load the keyword data in the object's field(s) */ if ( keyword->type == T1_FIELD_TYPE_INTEGER_ARRAY || keyword->type == T1_FIELD_TYPE_FIXED_ARRAY ) - error = CID_Load_Field_Table( &loader->parser, keyword, + error = cid_parser_load_field_table( &loader->parser, keyword, &dummy_object ); else - error = CID_Load_Field( &loader->parser, keyword, &dummy_object ); + error = cid_parser_load_field( &loader->parser, keyword, &dummy_object ); Exit: return error; } @@ -163,7 +163,7 @@ FT_BBox* bbox = &face->cid.font_bbox; - (void)CID_ToFixedArray( parser, 4, temp, 0 ); + (void)cid_parser_to_fixed_array( parser, 4, temp, 0 ); bbox->xMin = FT_RoundFix( temp[0] ); bbox->yMin = FT_RoundFix( temp[1] ); bbox->xMax = FT_RoundFix( temp[2] ); @@ -192,7 +192,7 @@ matrix = &dict->font_matrix; offset = &dict->font_offset; - (void)CID_ToFixedArray( parser, 6, temp, 3 ); + (void)cid_parser_to_fixed_array( parser, 6, temp, 3 ); temp_scale = ABS( temp[3] ); @@ -238,7 +238,7 @@ FT_Long num_dicts; - num_dicts = CID_ToInt( parser ); + num_dicts = cid_parser_to_int( parser ); if ( !cid->font_dicts ) { @@ -362,7 +362,7 @@ { /* we found it - run the parsing callback */ parser->root.cursor = cur2; - CID_Skip_Spaces( parser ); + cid_parser_skip_spaces( parser ); parser->root.error = cid_load_keyword( face, loader, keyword ); @@ -448,7 +448,7 @@ /* set up pointers */ for ( count = 1; count <= num_subrs; count++ ) { - FT_UInt len; + FT_ULong len; len = offsets[count] - offsets[count - 1]; @@ -460,7 +460,7 @@ { for ( count = 0; count < num_subrs; count++ ) { - FT_UInt len; + FT_ULong len; len = offsets[count + 1] - offsets[count]; @@ -497,7 +497,7 @@ { FT_UNUSED( face ); - FT_MEM_SET( loader, 0, sizeof ( *loader ) ); + FT_MEM_ZERO( loader, sizeof ( *loader ) ); } @@ -508,12 +508,12 @@ /* finalize parser */ - CID_Done_Parser( parser ); + cid_parser_done( parser ); } FT_LOCAL_DEF( FT_Error ) - CID_Open_Face( CID_Face face ) + cid_face_open( CID_Face face ) { CID_Loader loader; CID_Parser* parser; @@ -523,7 +523,7 @@ t1_init_loader( &loader, face ); parser = &loader.parser; - error = CID_New_Parser( parser, face->root.stream, face->root.memory, + error = cid_parser_new( parser, face->root.stream, face->root.memory, (PSAux_Service)face->psaux ); if ( error ) goto Exit; diff --git a/src/libs/freetype2/cid/cidload.h b/src/libs/freetype2/cid/cidload.h index 66e6d2f9537..8fc577db5ee 100644 --- a/src/libs/freetype2/cid/cidload.h +++ b/src/libs/freetype2/cid/cidload.h @@ -46,7 +46,7 @@ FT_BEGIN_HEADER FT_UShort seed ); FT_LOCAL( FT_Error ) - CID_Open_Face( CID_Face face ); + cid_face_open( CID_Face face ); FT_END_HEADER diff --git a/src/libs/freetype2/cid/cidobjs.c b/src/libs/freetype2/cid/cidobjs.c index f003a285574..ac5f16e4a9f 100644 --- a/src/libs/freetype2/cid/cidobjs.c +++ b/src/libs/freetype2/cid/cidobjs.c @@ -45,14 +45,14 @@ /*************************************************************************/ FT_LOCAL_DEF( void ) - CID_GlyphSlot_Done( CID_GlyphSlot slot ) + cid_slot_done( CID_GlyphSlot slot ) { slot->root.internal->glyph_hints = 0; } FT_LOCAL_DEF( FT_Error ) - CID_GlyphSlot_Init( CID_GlyphSlot slot ) + cid_slot_init( CID_GlyphSlot slot ) { CID_Face face; PSHinter_Service pshinter; @@ -90,7 +90,7 @@ static PSH_Globals_Funcs - CID_Size_Get_Globals_Funcs( CID_Size size ) + cid_size_get_globals_funcs( CID_Size size ) { CID_Face face = (CID_Face)size->root.face; PSHinter_Service pshinter = (PSHinter_Service)face->pshinter; @@ -106,14 +106,14 @@ FT_LOCAL_DEF( void ) - CID_Size_Done( CID_Size size ) + cid_size_done( CID_Size size ) { if ( size->root.internal ) { PSH_Globals_Funcs funcs; - funcs = CID_Size_Get_Globals_Funcs( size ); + funcs = cid_size_get_globals_funcs( size ); if ( funcs ) funcs->destroy( (PSH_Globals)size->root.internal ); @@ -123,10 +123,10 @@ FT_LOCAL_DEF( FT_Error ) - CID_Size_Init( CID_Size size ) + cid_size_init( CID_Size size ) { FT_Error error = 0; - PSH_Globals_Funcs funcs = CID_Size_Get_Globals_Funcs( size ); + PSH_Globals_Funcs funcs = cid_size_get_globals_funcs( size ); if ( funcs ) @@ -147,9 +147,9 @@ FT_LOCAL_DEF( FT_Error ) - CID_Size_Reset( CID_Size size ) + cid_size_reset( CID_Size size ) { - PSH_Globals_Funcs funcs = CID_Size_Get_Globals_Funcs( size ); + PSH_Globals_Funcs funcs = cid_size_get_globals_funcs( size ); FT_Error error = 0; @@ -171,7 +171,7 @@ /*************************************************************************/ /* */ /* <Function> */ - /* CID_Face_Done */ + /* cid_face_done */ /* */ /* <Description> */ /* Finalizes a given face object. */ @@ -180,7 +180,7 @@ /* face :: A pointer to the face object to destroy. */ /* */ FT_LOCAL_DEF( void ) - CID_Face_Done( CID_Face face ) + cid_face_done( CID_Face face ) { FT_Memory memory; @@ -239,7 +239,7 @@ /*************************************************************************/ /* */ /* <Function> */ - /* CID_Face_Init */ + /* cid_face_init */ /* */ /* <Description> */ /* Initializes a given CID face object. */ @@ -260,7 +260,7 @@ /* FreeType error code. 0 means success. */ /* */ FT_LOCAL_DEF( FT_Error ) - CID_Face_Init( FT_Stream stream, + cid_face_init( FT_Stream stream, CID_Face face, FT_Int face_index, FT_Int num_params, @@ -310,7 +310,7 @@ if ( FT_STREAM_SEEK( 0 ) ) goto Exit; - error = CID_Open_Face( face ); + error = cid_face_open( face ); if ( error ) goto Exit; @@ -321,7 +321,7 @@ /* check the face index */ if ( face_index != 0 ) { - FT_ERROR(( "CID_Face_Init: invalid face index\n" )); + FT_ERROR(( "cid_face_init: invalid face index\n" )); error = CID_Err_Invalid_Argument; goto Exit; } @@ -407,7 +407,7 @@ /*************************************************************************/ /* */ /* <Function> */ - /* CID_Driver_Init */ + /* cid_driver_init */ /* */ /* <Description> */ /* Initializes a given CID driver object. */ @@ -419,7 +419,7 @@ /* FreeType error code. 0 means success. */ /* */ FT_LOCAL_DEF( FT_Error ) - CID_Driver_Init( CID_Driver driver ) + cid_driver_init( CID_Driver driver ) { FT_UNUSED( driver ); @@ -430,7 +430,7 @@ /*************************************************************************/ /* */ /* <Function> */ - /* CID_Driver_Done */ + /* cid_driver_done */ /* */ /* <Description> */ /* Finalizes a given CID driver. */ @@ -439,7 +439,7 @@ /* driver :: A handle to the target CID driver. */ /* */ FT_LOCAL_DEF( void ) - CID_Driver_Done( CID_Driver driver ) + cid_driver_done( CID_Driver driver ) { FT_UNUSED( driver ); } diff --git a/src/libs/freetype2/cid/cidobjs.h b/src/libs/freetype2/cid/cidobjs.h index e8d665377af..2d72d73e2f9 100644 --- a/src/libs/freetype2/cid/cidobjs.h +++ b/src/libs/freetype2/cid/cidobjs.h @@ -112,26 +112,26 @@ FT_BEGIN_HEADER FT_LOCAL( void ) - CID_GlyphSlot_Done( CID_GlyphSlot slot ); + cid_slot_done( CID_GlyphSlot slot ); FT_LOCAL( FT_Error ) - CID_GlyphSlot_Init( CID_GlyphSlot slot ); + cid_slot_init( CID_GlyphSlot slot ); FT_LOCAL( void ) - CID_Size_Done( CID_Size size ); + cid_size_done( CID_Size size ); FT_LOCAL( FT_Error ) - CID_Size_Init( CID_Size size ); + cid_size_init( CID_Size size ); FT_LOCAL( FT_Error ) - CID_Size_Reset( CID_Size size ); + cid_size_reset( CID_Size size ); FT_LOCAL( FT_Error ) - CID_Face_Init( FT_Stream stream, + cid_face_init( FT_Stream stream, CID_Face face, FT_Int face_index, FT_Int num_params, @@ -139,15 +139,15 @@ FT_BEGIN_HEADER FT_LOCAL( void ) - CID_Face_Done( CID_Face face ); + cid_face_done( CID_Face face ); FT_LOCAL( FT_Error ) - CID_Driver_Init( CID_Driver driver ); + cid_driver_init( CID_Driver driver ); FT_LOCAL( void ) - CID_Driver_Done( CID_Driver driver ); + cid_driver_done( CID_Driver driver ); FT_END_HEADER diff --git a/src/libs/freetype2/cid/cidparse.c b/src/libs/freetype2/cid/cidparse.c index 3de73b5b3c3..397a66ff8f0 100644 --- a/src/libs/freetype2/cid/cidparse.c +++ b/src/libs/freetype2/cid/cidparse.c @@ -49,7 +49,7 @@ FT_LOCAL_DEF( FT_Error ) - CID_New_Parser( CID_Parser* parser, + cid_parser_new( CID_Parser* parser, FT_Stream stream, FT_Memory memory, PSAux_Service psaux ) @@ -60,7 +60,7 @@ FT_Int buff_len; - FT_MEM_SET( parser, 0, sizeof ( *parser ) ); + FT_MEM_ZERO( parser, sizeof ( *parser ) ); psaux->ps_parser_funcs->init( &parser->root, 0, 0, memory ); parser->stream = stream; @@ -138,7 +138,7 @@ FT_LOCAL_DEF( void ) - CID_Done_Parser( CID_Parser* parser ) + cid_parser_done( CID_Parser* parser ) { /* always free the private dictionary */ if ( parser->postscript ) diff --git a/src/libs/freetype2/cid/cidparse.h b/src/libs/freetype2/cid/cidparse.h index 7cf255c2cd6..1b3e0b9670a 100644 --- a/src/libs/freetype2/cid/cidparse.h +++ b/src/libs/freetype2/cid/cidparse.h @@ -61,7 +61,7 @@ FT_BEGIN_HEADER FT_Stream stream; FT_Byte* postscript; - FT_Int postscript_len; + FT_Long postscript_len; FT_ULong data_offset; @@ -72,13 +72,13 @@ FT_BEGIN_HEADER FT_LOCAL( FT_Error ) - CID_New_Parser( CID_Parser* parser, + cid_parser_new( CID_Parser* parser, FT_Stream stream, FT_Memory memory, PSAux_Service psaux ); FT_LOCAL( void ) - CID_Done_Parser( CID_Parser* parser ); + cid_parser_done( CID_Parser* parser ); /*************************************************************************/ @@ -87,24 +87,24 @@ FT_BEGIN_HEADER /* */ /*************************************************************************/ -#define CID_Skip_Spaces( p ) (p)->root.funcs.skip_spaces( &(p)->root ) -#define CID_Skip_Alpha( p ) (p)->root.funcs.skip_alpha ( &(p)->root ) +#define cid_parser_skip_spaces( p ) (p)->root.funcs.skip_spaces( &(p)->root ) +#define cid_parser_skip_alpha( p ) (p)->root.funcs.skip_alpha ( &(p)->root ) -#define CID_ToInt( p ) (p)->root.funcs.to_int( &(p)->root ) -#define CID_ToFixed( p, t ) (p)->root.funcs.to_fixed( &(p)->root, t ) +#define cid_parser_to_int( p ) (p)->root.funcs.to_int( &(p)->root ) +#define cid_parser_to_fixed( p, t ) (p)->root.funcs.to_fixed( &(p)->root, t ) -#define CID_ToCoordArray( p, m, c ) \ +#define cid_parser_to_coord_array( p, m, c ) \ (p)->root.funcs.to_coord_array( &(p)->root, m, c ) -#define CID_ToFixedArray( p, m, f, t ) \ +#define cid_parser_to_fixed_array( p, m, f, t ) \ (p)->root.funcs.to_fixed_array( &(p)->root, m, f, t ) -#define CID_ToToken( p, t ) \ +#define cid_parser_to_token( p, t ) \ (p)->root.funcs.to_token( &(p)->root, t ) -#define CID_ToTokenArray( p, t, m, c ) \ +#define cid_parser_to_token_array( p, t, m, c ) \ (p)->root.funcs.to_token_array( &(p)->root, t, m, c ) -#define CID_Load_Field( p, f, o ) \ +#define cid_parser_load_field( p, f, o ) \ (p)->root.funcs.load_field( &(p)->root, f, o, 0, 0 ) -#define CID_Load_Field_Table( p, f, o ) \ +#define cid_parser_load_field_table( p, f, o ) \ (p)->root.funcs.load_field_table( &(p)->root, f, o, 0, 0 ) diff --git a/src/libs/freetype2/cid/cidriver.c b/src/libs/freetype2/cid/cidriver.c index 0d0a5fbfa12..4d6f442c067 100644 --- a/src/libs/freetype2/cid/cidriver.c +++ b/src/libs/freetype2/cid/cidriver.c @@ -40,17 +40,17 @@ cid_get_postscript_name( CID_Face face ) { const char* result = face->cid.cid_font_name; - + if ( result && result[0] == '/' ) result++; - + return result; } static FT_Module_Interface - CID_Get_Interface( FT_Driver driver, + cid_get_interface( FT_Driver driver, const FT_String* cid_interface ) { FT_UNUSED( driver ); @@ -63,227 +63,6 @@ } -#if 0 /* unimplemented yet */ - - static FT_Error - cid_Get_Kerning( T1_Face face, - FT_UInt left_glyph, - FT_UInt right_glyph, - FT_Vector* kerning ) - { - CID_AFM* afm; - - - kerning->x = 0; - kerning->y = 0; - - afm = (CID_AFM*)face->afm_data; - if ( afm ) - CID_Get_Kerning( afm, left_glyph, right_glyph, kerning ); - - return CID_Err_Ok; - } - -#endif /* 0 */ - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* Cid_Get_Char_Index */ - /* */ - /* <Description> */ - /* Uses a charmap to return a given character code's glyph index. */ - /* */ - /* <Input> */ - /* charmap :: A handle to the source charmap object. */ - /* */ - /* charcode :: The character code. */ - /* */ - /* <Return> */ - /* Glyph index. 0 means `undefined character code'. */ - /* */ - static FT_UInt - CID_Get_Char_Index( FT_CharMap charmap, - FT_Long charcode ) - { - T1_Face face; - FT_UInt result = 0; - PSNames_Service psnames; - - - face = (T1_Face)charmap->face; - psnames = (PSNames_Service)face->psnames; - if ( psnames ) - switch ( charmap->encoding ) - { - /*******************************************************************/ - /* */ - /* Unicode encoding support */ - /* */ - case ft_encoding_unicode: - /* use the `PSNames' module to synthetize the Unicode charmap */ - result = psnames->lookup_unicode( &face->unicode_map, - (FT_ULong)charcode ); - - /* the function returns 0xFFFF if the Unicode charcode has */ - /* no corresponding glyph. */ - if ( result == 0xFFFF ) - result = 0; - goto Exit; - - /*******************************************************************/ - /* */ - /* Custom Type 1 encoding */ - /* */ - case ft_encoding_adobe_custom: - { - T1_Encoding encoding = &face->type1.encoding; - - - if ( charcode >= encoding->code_first && - charcode <= encoding->code_last ) - result = encoding->char_index[charcode]; - goto Exit; - } - - /*******************************************************************/ - /* */ - /* Adobe Standard & Expert encoding support */ - /* */ - default: - if ( charcode < 256 ) - { - FT_UInt code; - FT_Int n; - const char* glyph_name; - - - code = psnames->adobe_std_encoding[charcode]; - if ( charmap->encoding == ft_encoding_adobe_expert ) - code = psnames->adobe_expert_encoding[charcode]; - - glyph_name = psnames->adobe_std_strings( code ); - if ( !glyph_name ) - break; - - for ( n = 0; n < face->type1.num_glyphs; n++ ) - { - const char* gname = face->type1.glyph_names[n]; - - - if ( gname && gname[0] == glyph_name[0] && - ft_strcmp( gname, glyph_name ) == 0 ) - { - result = n; - break; - } - } - } - } - - Exit: - return result; - } - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* Cid_Get_Next_Char */ - /* */ - /* <Description> */ - /* Uses a charmap to return the next encoded char after. */ - /* */ - /* <Input> */ - /* charmap :: A handle to the source charmap object. */ - /* */ - /* charcode :: The character code. */ - /* */ - /* <Return> */ - /* Next char code. 0 means `no more char codes'. */ - /* */ - static FT_Long - CID_Get_Next_Char( FT_CharMap charmap, - FT_Long charcode ) - { - T1_Face face; - PSNames_Service psnames; - - - face = (T1_Face)charmap->face; - psnames = (PSNames_Service)face->psnames; - - if ( psnames ) - switch ( charmap->encoding ) - { - /*******************************************************************/ - /* */ - /* Unicode encoding support */ - /* */ - case ft_encoding_unicode: - /* use the `PSNames' module to synthetize the Unicode charmap */ - return psnames->next_unicode (&face->unicode_map, - (FT_ULong)charcode ); - - /*******************************************************************/ - /* */ - /* Custom Type 1 encoding */ - /* */ - case ft_encoding_adobe_custom: - { - T1_Encoding encoding = &face->type1.encoding; - - - charcode++; - if ( charcode < encoding->code_first ) - charcode = encoding->code_first; - while ( charcode <= encoding->code_last ) - { - if ( encoding->char_index[charcode] ) - return charcode; - charcode++; - } - } - break; - - /*******************************************************************/ - /* */ - /* Adobe Standard & Expert encoding support */ - /* */ - default: - while ( ++charcode < 256 ) - { - FT_UInt code; - FT_Int n; - const char* glyph_name; - - - code = psnames->adobe_std_encoding[charcode]; - if ( charmap->encoding == ft_encoding_adobe_expert ) - code = psnames->adobe_expert_encoding[charcode]; - - glyph_name = psnames->adobe_std_strings( code ); - if ( !glyph_name ) - continue; - - for ( n = 0; n < face->type1.num_glyphs; n++ ) - { - const char* gname = face->type1.glyph_names[n]; - - - if ( gname && gname[0] == glyph_name[0] && - ft_strcmp( gname, glyph_name ) == 0 ) - { - return charcode; - } - } - } - } - - return 0; - } - FT_CALLBACK_TABLE_DEF const FT_Driver_ClassRec t1cid_driver_class = @@ -293,7 +72,7 @@ ft_module_font_driver | ft_module_driver_scalable | ft_module_driver_has_hinter , - + sizeof( FT_DriverRec ), "t1cid", /* module name */ 0x10000L, /* version 1.0 of driver */ @@ -301,9 +80,9 @@ 0, - (FT_Module_Constructor)CID_Driver_Init, - (FT_Module_Destructor) CID_Driver_Done, - (FT_Module_Requester) CID_Get_Interface + (FT_Module_Constructor)cid_driver_init, + (FT_Module_Destructor) cid_driver_done, + (FT_Module_Requester) cid_get_interface }, /* then the other font drivers fields */ @@ -311,26 +90,23 @@ sizeof( CID_SizeRec ), sizeof( CID_GlyphSlotRec ), - (FT_Face_InitFunc) CID_Face_Init, - (FT_Face_DoneFunc) CID_Face_Done, + (FT_Face_InitFunc) cid_face_init, + (FT_Face_DoneFunc) cid_face_done, - (FT_Size_InitFunc) CID_Size_Init, - (FT_Size_DoneFunc) CID_Size_Done, - (FT_Slot_InitFunc) CID_GlyphSlot_Init, - (FT_Slot_DoneFunc) CID_GlyphSlot_Done, + (FT_Size_InitFunc) cid_size_init, + (FT_Size_DoneFunc) cid_size_done, + (FT_Slot_InitFunc) cid_slot_init, + (FT_Slot_DoneFunc) cid_slot_done, - (FT_Size_ResetPointsFunc) CID_Size_Reset, - (FT_Size_ResetPixelsFunc) CID_Size_Reset, + (FT_Size_ResetPointsFunc)cid_size_reset, + (FT_Size_ResetPixelsFunc)cid_size_reset, - (FT_Slot_LoadFunc) CID_Load_Glyph, - (FT_CharMap_CharIndexFunc)CID_Get_Char_Index, + (FT_Slot_LoadFunc) cid_slot_load_glyph, - (FT_Face_GetKerningFunc) 0, - (FT_Face_AttachFunc) 0, + (FT_Face_GetKerningFunc) 0, + (FT_Face_AttachFunc) 0, - (FT_Face_GetAdvancesFunc) 0, - - (FT_CharMap_CharNextFunc) CID_Get_Next_Char + (FT_Face_GetAdvancesFunc)0, }; diff --git a/src/libs/freetype2/otlayout/otlayout.h b/src/libs/freetype2/otlayout/otlayout.h index 2802f394608..2cd67f568fb 100644 --- a/src/libs/freetype2/otlayout/otlayout.h +++ b/src/libs/freetype2/otlayout/otlayout.h @@ -24,9 +24,13 @@ OTL_BEGIN_HEADER typedef int OTL_Int; typedef unsigned int OTL_UInt; + typedef long OTL_Long; + typedef unsigned long OTL_ULong; + typedef short OTL_Int16; typedef unsigned short OTL_UInt16; + #if OTL_SIZEOF_INT == 4 typedef int OTL_Int32; @@ -58,9 +62,38 @@ OTL_BEGIN_HEADER OTL_Err_InvalidFormat, OTL_Err_InvalidOffset, + OTL_Err_Max + } OTL_Error; + /************************************************************************/ + /************************************************************************/ + /***** *****/ + /***** MEMORY MANAGEMENT *****/ + /***** *****/ + /************************************************************************/ + /************************************************************************/ + + typedef OTL_Pointer (*OTL_AllocFunc)( OTL_ULong size, + OTL_Pointer data ); + + typedef OTL_Pointer (*OTL_ReallocFunc)( OTL_Pointer block, + OTL_ULong size, + OTL_Pointer data ); + + typedef void (*OTL_FreeFunc)( OTL_Pointer block, + OTL_Pointer data ); + + typedef struct OTL_MemoryRec_ + { + OTL_Pointer mem_data; + OTL_AllocFunc mem_alloc; + OTL_ReallocFunc mem_realloc; + OTL_FreeFunc mem_free; + + } OTL_MemoryRec, *OTL_Memory; + /************************************************************************/ /************************************************************************/ /***** *****/ @@ -69,11 +102,15 @@ OTL_BEGIN_HEADER /************************************************************************/ /************************************************************************/ +/* re-define OTL_MAKE_TAG to something different if you're not */ +/* using an ASCII-based character set (Vaxes anyone ?) */ +#ifndef OTL_MAKE_TAG #define OTL_MAKE_TAG(c1,c2,c3,c4) \ ( ( (OTL_UInt32)(c1) << 24 ) | \ (OTL_UInt32)(c2) << 16 ) | \ (OTL_UInt32)(c3) << 8 ) | \ (OTL_UInt32)(c4) ) +#endif typedef enum OTL_ScriptTag_ { @@ -153,8 +190,8 @@ OTL_BEGIN_HEADER #define OTL_INVALID(e) otl_validator_error( valid, e ) -#define OTL_INVALID_TOO_SHORT OTL_INVALID( OTL_Err_InvalidOffset ); -#define OTL_INVALID_DATA OTL_INVALID( OTL_Err_InvalidFormat ); +#define OTL_INVALID_TOO_SHORT OTL_INVALID( OTL_Err_InvalidOffset ) +#define OTL_INVALID_DATA OTL_INVALID( OTL_Err_InvalidFormat ) #define OTL_CHECK(_count) OTL_BEGIN_STMNT \ if ( p + (_count) > valid->limit ) \ diff --git a/src/libs/freetype2/otlayout/otlconf.h b/src/libs/freetype2/otlayout/otlconf.h index 155b0db80c3..3ef17a07997 100644 --- a/src/libs/freetype2/otlayout/otlconf.h +++ b/src/libs/freetype2/otlayout/otlconf.h @@ -43,10 +43,10 @@ #define OTL_BEGIN_STMNT do { #define OTL_END_STMNT } while (0) -#define OTL_DUMMY_STMNT do { } while (0) +#define OTL_DUMMY_STMNT OTL_BEGIN_STMNT OTL_END_STMNT #define OTL_UNUSED( x ) (x)=(x) -#define OTL_UNUSED_CONST(x) (void)(x) +#define OTL_UNUSED_CONST(x) (void)(x) #include <limits.h> @@ -68,6 +68,11 @@ # error "unsupported number of bytes in 'long' type!" #endif +#include <setjmp.h> +#define OTL_jmp_buf jmp_buf +#define otl_setjmp setjmp +#define otl_longjmp longjmp + /* */ #endif /* __OT_LAYOUT_CONFIG_H__ */ diff --git a/src/libs/freetype2/otlayout/otlgsub.c b/src/libs/freetype2/otlayout/otlgsub.c index 41e603da1e0..817760a7c86 100644 --- a/src/libs/freetype2/otlayout/otlgsub.c +++ b/src/libs/freetype2/otlayout/otlgsub.c @@ -9,6 +9,28 @@ /************************************************************************/ /************************************************************************/ + /* + * 1: Single Substitution - Table format(s) + * + * This table is used to substiture individual glyph indices + * with another one. There are only two sub-formats: + * + * Name Offset Size Description + * ------------------------------------------ + * format 0 2 sub-table format (1) + * offset 2 2 offset to coverage table + * delta 4 2 16-bit delta to apply on all + * covered glyph indices + * + * Name Offset Size Description + * ------------------------------------------ + * format 0 2 sub-table format (2) + * offset 2 2 offset to coverage table + * count 4 2 coverage table count + * substs[] 6 2*count substituted glyph indices, + * + */ + static void otl_gsub_lookup1_validate( OTL_Bytes table, OTL_Validator valid ) @@ -42,6 +64,10 @@ otl_coverage_validate( table + coverage, valid ); OTL_CHECK( 2*count ); + + /* NB: we don't check that there are at most 'count' */ + /* elements in the coverage table. This is delayed */ + /* to the lookup function... */ } break; @@ -51,6 +77,63 @@ } + static OTL_Bool + otl_gsub_lookup1_apply( OTL_Bytes table, + OTL_Parser parser ) + { + OTL_Bytes p = table; + OTL_Bytes coverage; + OTL_UInt format, gindex, property; + OTL_Int index; + OTL_Bool subst = 0; + + if ( parser->context_len != 0xFFFF && parser->context_len < 1 ) + goto Exit; + + gindex = otl_parser_get_gindex( parser ); + + if ( !otl_parser_check_property( parser, gindex, &property ) ) + goto Exit; + + format = OTL_NEXT_USHORT(p); + coverage = table + OTL_NEXT_USHORT(p); + index = otl_coverage_lookup( coverage, gindex ); + + if ( index >= 0 ) + { + switch ( format ) + { + case 1: + { + OTL_Int delta = OTL_NEXT_SHORT(p); + + gindex = ( gindex + delta ) & 0xFFFF; + otl_parser_replace_1( parser, gindex ); + subst = 1; + } + break; + + case 2: + { + OTL_UInt count = OTL_NEXT_USHORT(p); + + if ( (OTL_UInt) index < count ) + { + p += index*2; + otl_parser_replace_1( parser, OTL_PEEK_USHORT(p) ); + subst = 1; + } + } + break; + + default: + ; + } + } + Exit: + return subst; + } + /************************************************************************/ /************************************************************************/ /***** *****/ @@ -59,6 +142,26 @@ /************************************************************************/ /************************************************************************/ + /* + * 2: Multiple Substitution - Table format(s) + * + * Replaces a single glyph with one or more glyphs. + * + * Name Offset Size Description + * ----------------------------------------------------------- + * format 0 2 sub-table format (1) + * offset 2 2 offset to coverage table + * count 4 2 coverage table count + * sequencess[] 6 2*count offsets to sequence items + * + * each sequence item has the following format: + * + * Name Offset Size Description + * ----------------------------------------------------------- + * count 0 2 number of replacement glyphs + * gindices[] 2 2*count string of glyph indices + */ + static void otl_seq_validate( OTL_Bytes table, OTL_Validator valid ) @@ -69,6 +172,9 @@ OTL_CHECK( 2 ); count = OTL_NEXT_USHORT( p ); + /* XXX: according to the spec, 'count' should be > 0 */ + /* we can deal with these cases pretty well however */ + OTL_CHECK( 2*count ); /* check glyph indices */ } @@ -106,6 +212,45 @@ } } + + static OTL_Bool + otl_gsub_lookup2_apply( OTL_Bytes table, + OTL_Parser parser ) + { + OTL_Bytes p = table; + OTL_Bytes coverage, sequence; + OTL_UInt format, gindex, index, property; + OTL_Int index; + OTL_Bool subst = 0; + + if ( context_len != 0xFFFF && context_len < 1 ) + goto Exit; + + gindex = otl_parser_get_gindex( parser ); + + if ( !otl_parser_check_property( parser, gindex, &property ) ) + goto Exit; + + p += 2; /* skip format */ + coverage = table + OTL_NEXT_USHORT(p); + seq_count = OTL_NEXT_USHORT(p); + index = otl_coverage_lookup( coverage, gindex ); + + if ( (OTL_UInt) index >= seq_count ) + goto Exit; + + p += index*2; + sequence = table + OTL_PEEK_USHORT(p); + p = sequence; + count = OTL_NEXT_USHORT(p); + + otl_parser_replace_n( parser, count, p ); + subst = 1; + + Exit: + return subst; + } + /************************************************************************/ /************************************************************************/ /***** *****/ @@ -114,6 +259,28 @@ /************************************************************************/ /************************************************************************/ + /* + * 3: Alternate Substitution - Table format(s) + * + * Replaces a single glyph by another one taken liberally + * in a list of alternatives + * + * Name Offset Size Description + * ----------------------------------------------------------- + * format 0 2 sub-table format (1) + * offset 2 2 offset to coverage table + * count 4 2 coverage table count + * alternates[] 6 2*count offsets to alternate items + * + * each alternate item has the following format: + * + * Name Offset Size Description + * ----------------------------------------------------------- + * count 0 2 number of replacement glyphs + * gindices[] 2 2*count string of glyph indices, each one + * is a valid alternative + */ + static void otl_alternate_set_validate( OTL_Bytes table, OTL_Validator valid ) @@ -162,6 +329,52 @@ } + static OTL_Bool + otl_gsub_lookup3_apply( OTL_Bytes table, + OTL_Parser parser ) + { + OTL_Bytes p = table; + OTL_Bytes coverage, alternates; + OTL_UInt format, gindex, index, property; + OTL_Int index; + OTL_Bool subst = 0; + + OTL_GSUB_Alternate alternate = parser->alternate; + + if ( context_len != 0xFFFF && context_len < 1 ) + goto Exit; + + if ( alternate == NULL ) + goto Exit; + + gindex = otl_parser_get_gindex( parser ); + + if ( !otl_parser_check_property( parser, gindex, &property ) ) + goto Exit; + + p += 2; /* skip format */ + coverage = table + OTL_NEXT_USHORT(p); + seq_count = OTL_NEXT_USHORT(p); + index = otl_coverage_lookup( coverage, gindex ); + + if ( (OTL_UInt) index >= seq_count ) + goto Exit; + + p += index*2; + alternates = table + OTL_PEEK_USHORT(p); + p = alternates; + count = OTL_NEXT_USHORT(p); + + gindex = alternate->handler_func( + gindex, count, p, alternate->handler_data ); + + otl_parser_replace_1( parser, gindex ); + subst = 1; + + Exit: + return subst; + } + /************************************************************************/ /************************************************************************/ /***** *****/ diff --git a/src/libs/freetype2/otlayout/otlgsub.h b/src/libs/freetype2/otlayout/otlgsub.h index af57b168122..db5edecf125 100644 --- a/src/libs/freetype2/otlayout/otlgsub.h +++ b/src/libs/freetype2/otlayout/otlgsub.h @@ -5,6 +5,18 @@ OTL_BEGIN_HEADER + typedef OTL_UInt (*OTL_GSUB_AlternateFunc)( OTL_UInt gindex, + OTL_UInt count, + OTL_Bytes alternates, + OTL_Pointer data ); + + typedef struct OTL_GSUB_AlternateRec_ + { + OTL_GSUB_AlternateFunc handler_func; + OTL_Pointer handler_data; + + } OTL_GSUB_AlternateRec, *OTL_GSUB_Alternate; + OTL_LOCAL( void ) otl_gsub_validate( OTL_Bytes table, OTL_Validator valid ); diff --git a/src/libs/freetype2/pcf/pcf.h b/src/libs/freetype2/pcf/pcf.h index 74b14c7b8bd..949d1b8aaab 100644 --- a/src/libs/freetype2/pcf/pcf.h +++ b/src/libs/freetype2/pcf/pcf.h @@ -31,6 +31,7 @@ THE SOFTWARE. #include <ft2build.h> #include FT_INTERNAL_DRIVER_H +#include FT_INTERNAL_STREAM_H FT_BEGIN_HEADER @@ -135,6 +136,9 @@ FT_BEGIN_HEADER { FT_FaceRec root; + FT_StreamRec gzip_stream; + FT_Stream gzip_source; + char* charset_encoding; char* charset_registry; diff --git a/src/libs/freetype2/pcf/pcfdriver.c b/src/libs/freetype2/pcf/pcfdriver.c index c86bbfb8c1f..e995b8eef08 100644 --- a/src/libs/freetype2/pcf/pcfdriver.c +++ b/src/libs/freetype2/pcf/pcfdriver.c @@ -30,6 +30,8 @@ THE SOFTWARE. #include FT_INTERNAL_DEBUG_H #include FT_INTERNAL_STREAM_H #include FT_INTERNAL_OBJECTS_H +#include FT_GZIP_H +#include FT_ERRORS_H #include "pcf.h" #include "pcfdriver.h" @@ -41,8 +43,6 @@ THE SOFTWARE. #define FT_COMPONENT trace_pcfread -#ifdef FT_CONFIG_OPTION_USE_CMAPS - typedef struct PCF_CMapRec_ { FT_CMapRec cmap; @@ -164,77 +164,6 @@ THE SOFTWARE. (FT_CMap_CharNextFunc) pcf_cmap_char_next }; -#else /* !FT_CONFIG_OPTION_USE_CMAPS */ - - static FT_UInt - PCF_Char_Get_Index( FT_CharMap charmap, - FT_Long char_code ) - { - PCF_Face face = (PCF_Face)charmap->face; - PCF_Encoding en_table = face->encodings; - int low, high, mid; - - - FT_TRACE4(( "get_char_index %ld\n", char_code )); - - low = 0; - high = face->nencodings - 1; - while ( low <= high ) - { - mid = ( low + high ) / 2; - if ( char_code < en_table[mid].enc ) - high = mid - 1; - else if ( char_code > en_table[mid].enc ) - low = mid + 1; - else - return en_table[mid].glyph + 1; - } - - return 0; - } - - - static FT_Long - PCF_Char_Get_Next( FT_CharMap charmap, - FT_Long char_code ) - { - PCF_Face face = (PCF_Face)charmap->face; - PCF_Encoding en_table = face->encodings; - int low, high, mid; - - - FT_TRACE4(( "get_next_char %ld\n", char_code )); - - char_code++; - low = 0; - high = face->nencodings - 1; - - while ( low <= high ) - { - mid = ( low + high ) / 2; - if ( char_code < en_table[mid].enc ) - high = mid - 1; - else if ( char_code > en_table[mid].enc ) - low = mid + 1; - else - return char_code; - } - - if ( high < 0 ) - high = 0; - - while ( high < face->nencodings ) - { - if ( en_table[high].enc >= char_code ) - return en_table[high].enc; - high++; - } - - return 0; - } - -#endif /* !FT_CONFIG_OPTION_USE_CMAPS */ - /*************************************************************************/ /* */ @@ -279,7 +208,14 @@ THE SOFTWARE. FT_FREE( face->charset_encoding ); FT_FREE( face->charset_registry ); - FT_TRACE4(( "DONE_FACE!!!\n" )); + FT_TRACE4(( "PCF_Face_Done: done face\n" )); + + /* close gzip stream if any */ + if ( face->root.stream == &face->gzip_stream ) + { + FT_Stream_Close( &face->gzip_stream ); + face->root.stream = face->gzip_source; + } return PCF_Err_Ok; } @@ -301,7 +237,27 @@ THE SOFTWARE. error = pcf_load_font( stream, face ); 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 */ { @@ -321,54 +277,30 @@ THE SOFTWARE. unicode_charmap = 1; } -#ifdef FT_CONFIG_OPTION_USE_CMAPS - { FT_CharMapRec charmap; charmap.face = FT_FACE( face ); - charmap.encoding = ft_encoding_none; + charmap.encoding = FT_ENCODING_NONE; charmap.platform_id = 0; charmap.encoding_id = 0; if ( unicode_charmap ) { - charmap.encoding = ft_encoding_unicode; + charmap.encoding = FT_ENCODING_UNICODE; charmap.platform_id = 3; charmap.encoding_id = 1; } error = FT_CMap_New( &pcf_cmap_class, NULL, &charmap, NULL ); +#if 0 /* Select default charmap */ if (face->root.num_charmaps) face->root.charmap = face->root.charmaps[0]; +#endif } - -#else /* !FT_CONFIG_OPTION_USE_CMAPS */ - - /* XXX: charmaps. For now, report unicode for Unicode and Latin 1 */ - face->root.charmaps = &face->charmap_handle; - face->root.num_charmaps = 1; - - face->charmap.encoding = ft_encoding_none; - face->charmap.platform_id = 0; - face->charmap.encoding_id = 0; - - if ( unicode_charmap ) - { - face->charmap.encoding = ft_encoding_unicode; - face->charmap.platform_id = 3; - face->charmap.encoding_id = 1; - } - - face->charmap.face = &face->root; - face->charmap_handle = &face->charmap; - face->root.charmap = face->charmap_handle; - -#endif /* !FT_CONFIG_OPTION_USE_CMAPS */ - } Exit: @@ -416,7 +348,7 @@ THE SOFTWARE. PCF_Glyph_Load( FT_GlyphSlot slot, FT_Size size, FT_UInt glyph_index, - FT_Int load_flags ) + FT_Int32 load_flags ) { PCF_Face face = (PCF_Face)FT_SIZE_FACE( size ); FT_Stream stream = face->root.stream; @@ -445,7 +377,7 @@ THE SOFTWARE. bitmap->rows = metric->ascent + metric->descent; bitmap->width = metric->rightSideBearing - metric->leftSideBearing; bitmap->num_grays = 1; - bitmap->pixel_mode = ft_pixel_mode_mono; + bitmap->pixel_mode = FT_PIXEL_MODE_MONO; FT_TRACE6(( "BIT_ORDER %d ; BYTE_ORDER %d ; GLYPH_PAD %d\n", PCF_BIT_ORDER( face->bitmapsFormat ), @@ -485,7 +417,7 @@ THE SOFTWARE. goto Exit; if ( PCF_BIT_ORDER( face->bitmapsFormat ) != MSBFirst ) - BitOrderInvert( bitmap->buffer,bytes ); + BitOrderInvert( bitmap->buffer, bytes ); if ( ( PCF_BYTE_ORDER( face->bitmapsFormat ) != PCF_BIT_ORDER( face->bitmapsFormat ) ) ) @@ -509,13 +441,14 @@ THE SOFTWARE. slot->bitmap_top = metric->ascent; slot->metrics.horiAdvance = metric->characterWidth << 6 ; - slot->metrics.horiBearingX = metric->rightSideBearing << 6 ; + slot->metrics.horiBearingX = metric->leftSideBearing << 6 ; slot->metrics.horiBearingY = metric->ascent << 6 ; - slot->metrics.width = metric->characterWidth << 6 ; + slot->metrics.width = ( metric->rightSideBearing - + metric->leftSideBearing ) << 6; slot->metrics.height = bitmap->rows << 6; slot->linearHoriAdvance = (FT_Fixed)bitmap->width << 16; - slot->format = ft_glyph_format_bitmap; + slot->format = FT_GLYPH_FORMAT_BITMAP; slot->flags = FT_GLYPH_OWN_BITMAP; FT_TRACE4(( " --- ok\n" )); @@ -559,21 +492,9 @@ THE SOFTWARE. (FT_Slot_LoadFunc) PCF_Glyph_Load, -#ifndef FT_CONFIG_OPTION_USE_CMAPS - (FT_CharMap_CharIndexFunc)PCF_Char_Get_Index, -#else - (FT_CharMap_CharIndexFunc)0, -#endif - (FT_Face_GetKerningFunc) 0, (FT_Face_AttachFunc) 0, - (FT_Face_GetAdvancesFunc) 0, - -#ifndef FT_CONFIG_OPTION_USE_CMAPS - (FT_CharMap_CharNextFunc) PCF_Char_Get_Next, -#else - (FT_CharMap_CharNextFunc) 0 -#endif + (FT_Face_GetAdvancesFunc) 0 }; diff --git a/src/libs/freetype2/pfr/pfr.c b/src/libs/freetype2/pfr/pfr.c index 63282084237..eb2c4edb7ec 100644 --- a/src/libs/freetype2/pfr/pfr.c +++ b/src/libs/freetype2/pfr/pfr.c @@ -24,5 +24,6 @@ #include "pfrcmap.c" #include "pfrobjs.c" #include "pfrdrivr.c" +#include "pfrsbit.c" /* END */ diff --git a/src/libs/freetype2/pfr/pfrdrivr.c b/src/libs/freetype2/pfr/pfrdrivr.c index 64041f3061a..07ba9b4cd31 100644 --- a/src/libs/freetype2/pfr/pfrdrivr.c +++ b/src/libs/freetype2/pfr/pfrdrivr.c @@ -19,10 +19,111 @@ #include <ft2build.h> #include FT_INTERNAL_DEBUG_H #include FT_INTERNAL_STREAM_H +#include FT_INTERNAL_PFR_H #include "pfrdrivr.h" #include "pfrobjs.h" + static FT_Error + pfr_get_kerning( PFR_Face face, + FT_UInt left, + FT_UInt right, + FT_Vector *avector ) + { + FT_Error error; + + error = pfr_face_get_kerning( face, left, right, avector ); + if ( !error ) + { + PFR_PhyFont phys = &face->phy_font; + + /* convert from metrics to outline units when necessary */ + if ( phys->outline_resolution != phys->metrics_resolution ) + { + if ( avector->x != 0 ) + avector->x = FT_MulDiv( avector->x, phys->outline_resolution, + phys->metrics_resolution ); + + if ( avector->y != 0 ) + avector->y = FT_MulDiv( avector->x, phys->outline_resolution, + phys->metrics_resolution ); + } + } + return error; + } + + + static FT_Error + pfr_get_advance( PFR_Face face, + FT_UInt gindex, + FT_Pos *aadvance ) + { + FT_Error error = FT_Err_Bad_Argument; + + *aadvance = 0; + if ( face ) + { + PFR_PhyFont phys = &face->phy_font; + + if ( gindex < phys->num_chars ) + { + *aadvance = phys->chars[ gindex ].advance; + error = 0; + } + } + + return error; + } + + + static FT_Error + pfr_get_metrics( PFR_Face face, + FT_UInt *aoutline_resolution, + FT_UInt *ametrics_resolution, + FT_Fixed *ametrics_x_scale, + FT_Fixed *ametrics_y_scale ) + { + PFR_PhyFont phys = &face->phy_font; + FT_Fixed x_scale, y_scale; + FT_Size size = face->root.size; + + if ( aoutline_resolution ) + *aoutline_resolution = phys->outline_resolution; + + if ( ametrics_resolution ) + *ametrics_resolution = phys->metrics_resolution; + + x_scale = 0x10000L; + y_scale = 0x10000L; + + if ( size ) + { + x_scale = FT_DivFix( size->metrics.x_ppem << 6, + phys->metrics_resolution ); + + y_scale = FT_DivFix( size->metrics.y_ppem << 6, + phys->metrics_resolution ); + } + + if ( ametrics_x_scale ) + *ametrics_x_scale = x_scale; + + if ( ametrics_y_scale ) + *ametrics_y_scale = y_scale; + + return 0; + } + + + FT_CALLBACK_TABLE_DEF + const FT_PFR_ServiceRec pfr_service_rec = + { + (FT_PFR_GetMetricsFunc) pfr_get_metrics, + (FT_PFR_GetKerningFunc) pfr_get_kerning, + (FT_PFR_GetAdvanceFunc) pfr_get_advance + }; + + FT_CALLBACK_TABLE_DEF const FT_Driver_ClassRec pfr_driver_class = { @@ -36,7 +137,7 @@ 0x10000L, 0x20000L, - 0, /* format interface */ + (FT_PFR_Service) &pfr_service_rec, /* format interface */ (FT_Module_Constructor)NULL, (FT_Module_Destructor) NULL, @@ -57,13 +158,10 @@ (FT_Size_ResetPointsFunc) NULL, (FT_Size_ResetPixelsFunc) NULL, (FT_Slot_LoadFunc) pfr_slot_load, - (FT_CharMap_CharIndexFunc)NULL, - (FT_Face_GetKerningFunc) pfr_face_get_kerning, + (FT_Face_GetKerningFunc) pfr_get_kerning, (FT_Face_AttachFunc) 0, - (FT_Face_GetAdvancesFunc) 0, - - (FT_CharMap_CharNextFunc) NULL + (FT_Face_GetAdvancesFunc) 0 }; diff --git a/src/libs/freetype2/pfr/pfrgload.c b/src/libs/freetype2/pfr/pfrgload.c index a914707a27b..cb5c60b88e3 100644 --- a/src/libs/freetype2/pfr/pfrgload.c +++ b/src/libs/freetype2/pfr/pfrgload.c @@ -17,6 +17,7 @@ #include "pfrgload.h" +#include "pfrsbit.h" #include "pfrload.h" /* for macro definitions */ #include FT_INTERNAL_DEBUG_H @@ -139,7 +140,7 @@ outline->points[n] = *to; - outline->tags [n] = FT_Curve_Tag_On; + outline->tags [n] = FT_CURVE_TAG_ON; outline->n_points++; } @@ -172,9 +173,9 @@ vec[0] = *control1; vec[1] = *control2; vec[2] = *to; - tag[0] = FT_Curve_Tag_Cubic; - tag[1] = FT_Curve_Tag_Cubic; - tag[2] = FT_Curve_Tag_On; + tag[0] = FT_CURVE_TAG_CUBIC; + tag[1] = FT_CURVE_TAG_CUBIC; + tag[2] = FT_CURVE_TAG_ON; outline->n_points = (FT_Short)( outline->n_points + 3 ); } @@ -409,7 +410,7 @@ cur = pos; for ( n = 0; n < args_count; n++ ) { - FT_Int index, delta; + FT_Int idx, delta; /* read the X argument */ @@ -417,9 +418,9 @@ { case 0: /* 8-bit index */ PFR_CHECK( 1 ); - index = PFR_NEXT_BYTE( p ); - cur->x = glyph->x_control[index]; - FT_TRACE7(( " cx#%d", index )); + idx = PFR_NEXT_BYTE( p ); + cur->x = glyph->x_control[idx]; + FT_TRACE7(( " cx#%d", idx )); break; case 1: /* 16-bit value */ @@ -445,9 +446,9 @@ { case 0: /* 8-bit index */ PFR_CHECK( 1 ); - index = PFR_NEXT_BYTE( p ); - cur->y = glyph->y_control[index]; - FT_TRACE7(( " cy#%d", index )); + idx = PFR_NEXT_BYTE( p ); + cur->y = glyph->y_control[idx]; + FT_TRACE7(( " cy#%d", idx )); break; case 1: /* 16-bit absolute value */ @@ -676,6 +677,9 @@ } + + + static FT_Error pfr_glyph_load_rec( PFR_Glyph glyph, FT_Stream stream, @@ -776,6 +780,9 @@ } + + + FT_LOCAL_DEF( FT_Error ) pfr_glyph_load( PFR_Glyph glyph, FT_Stream stream, diff --git a/src/libs/freetype2/pfr/pfrgload.h b/src/libs/freetype2/pfr/pfrgload.h index 76916e55999..7cc7a8702a4 100644 --- a/src/libs/freetype2/pfr/pfrgload.h +++ b/src/libs/freetype2/pfr/pfrgload.h @@ -44,3 +44,6 @@ FT_END_HEADER #endif /* __PFRGLOAD_H__ */ + + +/* END */ diff --git a/src/libs/freetype2/pfr/pfrload.c b/src/libs/freetype2/pfr/pfrload.c index 32c2f8279e8..0cb32f4cfa3 100644 --- a/src/libs/freetype2/pfr/pfrload.c +++ b/src/libs/freetype2/pfr/pfrload.c @@ -52,7 +52,7 @@ FT_Error error = 0; FT_Byte* p = *pp; FT_UInt num_items, item_type, item_size; - + PFR_CHECK( 1 ); num_items = PFR_NEXT_BYTE( p ); @@ -62,11 +62,11 @@ PFR_CHECK( 2 ); item_size = PFR_NEXT_BYTE( p ); item_type = PFR_NEXT_BYTE( p ); - + PFR_CHECK( item_size ); if ( item_list ) - { + { PFR_ExtraItem extra = item_list; @@ -76,19 +76,19 @@ { error = extra->parser( p, p + item_size, item_data ); if ( error ) goto Exit; - + break; } } } - + p += item_size; } Exit: *pp = p; return error; - + Too_Short: FT_ERROR(( "pfr_extra_items_parse: invalid extra items table\n" )); error = PFR_Err_Invalid_Table; @@ -204,23 +204,23 @@ FT_Error error; FT_UInt count; FT_UInt result = 0; - + if ( FT_STREAM_SEEK( section_offset ) || FT_READ_USHORT( count ) ) goto Exit; - + result = count; - + Exit: *acount = result; return error; - } + } FT_LOCAL_DEF( FT_Error ) pfr_log_font_load( PFR_LogFont log_font, FT_Stream stream, - FT_UInt index, + FT_UInt idx, FT_UInt32 section_offset, FT_Bool size_increment ) { @@ -235,10 +235,10 @@ FT_READ_USHORT( num_log_fonts ) ) goto Exit; - if ( index >= num_log_fonts ) + if ( idx >= num_log_fonts ) return PFR_Err_Invalid_Argument; - if ( FT_STREAM_SKIP( index * 5 ) || + if ( FT_STREAM_SKIP( idx * 5 ) || FT_READ_USHORT( size ) || FT_READ_UOFF3 ( offset ) ) goto Exit; @@ -252,30 +252,30 @@ FT_Byte* p; FT_Byte* limit; FT_UInt local; - + if ( FT_STREAM_SEEK( offset ) || FT_FRAME_ENTER( size ) ) goto Exit; p = stream->cursor; limit = p + size; - + PFR_CHECK(13); - + log_font->matrix[0] = PFR_NEXT_LONG( p ); log_font->matrix[1] = PFR_NEXT_LONG( p ); log_font->matrix[2] = PFR_NEXT_LONG( p ); log_font->matrix[3] = PFR_NEXT_LONG( p ); - + flags = PFR_NEXT_BYTE( p ); - + local = 0; if ( flags & PFR_LOG_STROKE ) { local++; if ( flags & PFR_LOG_2BYTE_STROKE ) local++; - + if ( (flags & PFR_LINE_JOIN_MASK) == PFR_LINE_JOIN_MITER ) local += 3; } @@ -293,18 +293,18 @@ log_font->stroke_thickness = ( flags & PFR_LOG_2BYTE_STROKE ) ? PFR_NEXT_SHORT( p ) : PFR_NEXT_BYTE( p ); - + if ( ( flags & PFR_LINE_JOIN_MASK ) == PFR_LINE_JOIN_MITER ) log_font->miter_limit = PFR_NEXT_LONG( p ); } - + if ( flags & PFR_LOG_BOLD ) { log_font->bold_thickness = ( flags & PFR_LOG_2BYTE_BOLD ) ? PFR_NEXT_SHORT( p ) : PFR_NEXT_BYTE( p ); } - + if ( flags & PFR_LOG_EXTRA_ITEMS ) { error = pfr_extra_items_skip( &p, limit ); @@ -326,7 +326,7 @@ Exit: return error; - + Too_Short: FT_ERROR(( "pfr_log_font_load: invalid logical font table\n" )); error = PFR_Err_Invalid_Table; @@ -355,7 +355,7 @@ FT_UInt n, count, size1; FT_Error error = 0; - + PFR_CHECK( 5 ); p += 3; /* skip bctSize */ @@ -366,12 +366,12 @@ if ( phy_font->num_strikes + count > phy_font->max_strikes ) { FT_UInt new_max = (phy_font->num_strikes + count + 3) & -4; - + if ( FT_RENEW_ARRAY( phy_font->strikes, phy_font->num_strikes, new_max ) ) goto Exit; - + phy_font->max_strikes = new_max; } @@ -421,15 +421,15 @@ } phy_font->num_strikes += count; - + Exit: return error; - + Too_Short: error = PFR_Err_Invalid_Table; FT_ERROR(( "pfr_extra_item_load_bitmap_info: invalid bitmap info table\n" )); goto Exit; - } + } /* load font ID, i.e. name */ @@ -441,18 +441,18 @@ FT_Error error = 0; FT_Memory memory = phy_font->memory; FT_UInt len = (FT_UInt)( limit - p ); - + if ( phy_font->font_id != NULL ) goto Exit; - + if ( FT_ALLOC( phy_font->font_id, len+1 ) ) goto Exit; /* copy font ID name, and terminate it for safety */ FT_MEM_COPY( phy_font->font_id, p, len ); phy_font->font_id[len] = 0; - + Exit: return error; } @@ -472,35 +472,37 @@ if ( phy_font->vertical.stem_snaps != NULL ) goto Exit; - + PFR_CHECK( 1 ); count = PFR_NEXT_BYTE( p ); - + num_vert = count & 15; num_horz = count >> 4; count = num_vert + num_horz; - + PFR_CHECK( count * 2 ); - + if ( FT_NEW_ARRAY( snaps, count ) ) goto Exit; - + phy_font->vertical.stem_snaps = snaps; phy_font->horizontal.stem_snaps = snaps + num_vert; - + for ( ; count > 0; count--, snaps++ ) *snaps = FT_NEXT_SHORT( p ); - + Exit: return error; - + Too_Short: error = PFR_Err_Invalid_Table; FT_ERROR(( "pfr_exta_item_load_stem_snaps: invalid stem snaps table\n" )); goto Exit; - } + } +#if 0 + /* load kerning pair data */ FT_CALLBACK_DEF( FT_Error ) pfr_extra_item_load_kerning_pairs( FT_Byte* p, @@ -516,24 +518,25 @@ FT_Memory memory = phy_font->memory; + /* allocate a new kerning item */ /* XXX: there may be multiple extra items for kerning */ if ( phy_font->kern_pairs != NULL ) goto Exit; FT_TRACE2(( "pfr_extra_item_load_kerning_pairs()\n" )); - + PFR_CHECK( 4 ); num_pairs = PFR_NEXT_BYTE( p ); base_adj = PFR_NEXT_SHORT( p ); flags = PFR_NEXT_BYTE( p ); - + #ifndef PFR_CONFIG_NO_CHECKS count = 3; - + if ( flags & PFR_KERN_2BYTE_CHAR ) count += 2; - + if ( flags & PFR_KERN_2BYTE_ADJ ) count += 1; @@ -542,10 +545,10 @@ if ( FT_NEW_ARRAY( pairs, num_pairs ) ) goto Exit; - + phy_font->num_kern_pairs = num_pairs; phy_font->kern_pairs = pairs; - + for (count = num_pairs ; count > 0; count--, pairs++ ) { if ( flags & PFR_KERN_2BYTE_CHAR ) @@ -558,7 +561,7 @@ pairs->glyph1 = PFR_NEXT_BYTE( p ); pairs->glyph2 = PFR_NEXT_BYTE( p ); } - + if ( flags & PFR_KERN_2BYTE_ADJ ) pairs->kerning.x = base_adj + PFR_NEXT_SHORT( p ); else @@ -569,16 +572,115 @@ FT_TRACE2(( "kerning %d <-> %d : %ld\n", pairs->glyph1, pairs->glyph2, pairs->kerning.x )); } - + + Exit: + return error; + + Too_Short: + error = PFR_Err_Invalid_Table; + FT_ERROR(( "pfr_extra_item_load_kerning_pairs: " + "invalid kerning pairs table\n" )); + goto Exit; + } + +#else /* 0 */ + + /* load kerning pair data */ + FT_CALLBACK_DEF( FT_Error ) + pfr_extra_item_load_kerning_pairs( FT_Byte* p, + FT_Byte* limit, + PFR_PhyFont phy_font ) + { + PFR_KernItem item; + FT_Error error = 0; + FT_Memory memory = phy_font->memory; + + + FT_TRACE2(( "pfr_extra_item_load_kerning_pairs()\n" )); + + if ( FT_NEW( item ) ) + goto Exit; + + PFR_CHECK( 4 ); + + item->pair_count = PFR_NEXT_BYTE( p ); + item->base_adj = PFR_NEXT_SHORT( p ); + item->flags = PFR_NEXT_BYTE( p ); + item->offset = phy_font->offset + ( p - phy_font->cursor ); + +#ifndef PFR_CONFIG_NO_CHECKS + item->pair_size = 3; + + if ( item->flags & PFR_KERN_2BYTE_CHAR ) + item->pair_size += 2; + + if ( item->flags & PFR_KERN_2BYTE_ADJ ) + item->pair_size += 1; + + PFR_CHECK( item->pair_count * item->pair_size ); +#endif + + /* load first and last pairs into the item to speed up */ + /* lookup later... */ + if ( item->pair_count > 0 ) + { + FT_UInt char1, char2; + FT_Byte* q; + + + if ( item->flags & PFR_KERN_2BYTE_CHAR ) + { + q = p; + char1 = PFR_NEXT_USHORT( q ); + char2 = PFR_NEXT_USHORT( q ); + + item->pair1 = PFR_KERN_INDEX( char1, char2 ); + + q = p + item->pair_size * ( item->pair_count - 1 ); + char1 = PFR_NEXT_USHORT( q ); + char2 = PFR_NEXT_USHORT( q ); + + item->pair2 = PFR_KERN_INDEX( char1, char2 ); + } + else + { + q = p; + char1 = PFR_NEXT_BYTE( q ); + char2 = PFR_NEXT_BYTE( q ); + + item->pair1 = PFR_KERN_INDEX( char1, char2 ); + + q = p + item->pair_size * ( item->pair_count - 1 ); + char1 = PFR_NEXT_BYTE( q ); + char2 = PFR_NEXT_BYTE( q ); + + item->pair2 = PFR_KERN_INDEX( char1, char2 ); + } + + /* add new item to the current list */ + item->next = NULL; + *phy_font->kern_items_tail = item; + phy_font->kern_items_tail = &item->next; + phy_font->num_kern_pairs += item->pair_count; + } + else + { + /* empty item! */ + FT_FREE( item ); + } + Exit: return error; - + Too_Short: + FT_FREE( item ); + error = PFR_Err_Invalid_Table; FT_ERROR(( "pfr_extra_item_load_kerning_pairs: " "invalid kerning pairs table\n" )); goto Exit; - } + } +#endif /* 0 */ static const PFR_ExtraItemRec pfr_phy_font_extra_items[] = @@ -607,7 +709,7 @@ FT_FREE( phy_font->strikes ); phy_font->num_strikes = 0; phy_font->max_strikes = 0; - + FT_FREE( phy_font->chars ); phy_font->num_chars = 0; phy_font->chars_offset = 0; @@ -615,10 +717,24 @@ FT_FREE( phy_font->blue_values ); phy_font->num_blue_values = 0; - FT_FREE( phy_font->kern_pairs ); + { + PFR_KernItem item, next; + + + item = phy_font->kern_items; + while ( item ) + { + next = item->next; + FT_FREE( item ); + item = next; + } + phy_font->kern_items = NULL; + phy_font->kern_items_tail = NULL; + } + phy_font->num_kern_pairs = 0; } - + FT_LOCAL_DEF( FT_Error ) pfr_phy_font_load( PFR_PhyFont phy_font, @@ -636,9 +752,14 @@ phy_font->memory = memory; phy_font->offset = offset; + phy_font->kern_items = NULL; + phy_font->kern_items_tail = &phy_font->kern_items; + if ( FT_STREAM_SEEK( offset ) || FT_FRAME_ENTER( size ) ) goto Exit; + phy_font->cursor = stream->cursor; + p = stream->cursor; limit = p + size; @@ -664,15 +785,15 @@ { error = pfr_extra_items_parse( &p, limit, pfr_phy_font_extra_items, phy_font ); - + if ( error ) goto Fail; } - + /* skip the aux bytes */ PFR_CHECK( 3 ); num_aux = PFR_NEXT_ULONG( p ); - + PFR_CHECK( num_aux ); p += num_aux; @@ -684,7 +805,7 @@ phy_font->num_blue_values = count = PFR_NEXT_BYTE( p ); PFR_CHECK( count * 2 ); - + if ( FT_NEW_ARRAY( phy_font->blue_values, count ) ) goto Fail; @@ -713,19 +834,19 @@ Size = 1 + 1 + 2; if ( flags & PFR_PHY_2BYTE_CHARCODE ) Size += 1; - + if ( flags & PFR_PHY_PROPORTIONAL ) Size += 2; - + if ( flags & PFR_PHY_ASCII_CODE ) Size += 1; - + if ( flags & PFR_PHY_2BYTE_GPS_SIZE ) Size += 1; - + if ( flags & PFR_PHY_3BYTE_GPS_OFFSET ) Size += 1; - + PFR_CHECK( count * Size ); for ( n = 0; n < count; n++ ) @@ -739,7 +860,7 @@ cur->advance = ( flags & PFR_PHY_PROPORTIONAL ) ? PFR_NEXT_SHORT( p ) - : phy_font->standard_advance; + : (FT_Int) phy_font->standard_advance; #if 0 cur->ascii = ( flags & PFR_PHY_ASCII_CODE ) @@ -763,9 +884,13 @@ Fail: FT_FRAME_EXIT(); + /* save position of bitmap info */ + phy_font->bct_offset = FT_STREAM_POS(); + phy_font->cursor = NULL; + Exit: return error; - + Too_Short: error = PFR_Err_Invalid_Table; FT_ERROR(( "pfr_phy_font_load: invalid physical font table\n" )); diff --git a/src/libs/freetype2/pfr/pfrobjs.c b/src/libs/freetype2/pfr/pfrobjs.c index fc76462522f..8ede63a955d 100644 --- a/src/libs/freetype2/pfr/pfrobjs.c +++ b/src/libs/freetype2/pfr/pfrobjs.c @@ -20,6 +20,7 @@ #include "pfrload.h" #include "pfrgload.h" #include "pfrcmap.h" +#include "pfrsbit.h" #include FT_OUTLINE_H #include FT_INTERNAL_DEBUG_H @@ -48,12 +49,17 @@ FT_LOCAL_DEF( FT_Error ) - pfr_face_init( FT_Stream stream, - PFR_Face face, - FT_Int face_index ) + pfr_face_init( FT_Stream stream, + PFR_Face face, + FT_Int face_index, + FT_Int num_params, + FT_Parameter* params ) { FT_Error error; + FT_UNUSED( num_params ); + FT_UNUSED( params ); + /* load the header and check it */ error = pfr_header_load( &face->header, stream ); @@ -124,7 +130,11 @@ else root->face_flags |= FT_FACE_FLAG_HORIZONTAL; - /* XXX: kerning and embedded bitmap support isn't there yet */ + if ( phy_font->num_strikes > 0 ) + root->face_flags |= FT_FACE_FLAG_FIXED_SIZES; + + if ( phy_font->num_kern_pairs > 0 ) + root->face_flags |= FT_FACE_FLAG_KERNING; root->family_name = phy_font->font_id; root->style_name = NULL; /* no style name in font file */ @@ -167,18 +177,20 @@ /* create charmap */ { FT_CharMapRec charmap; - + charmap.face = root; charmap.platform_id = 3; charmap.encoding_id = 1; - charmap.encoding = ft_encoding_unicode; - + charmap.encoding = FT_ENCODING_UNICODE; + FT_CMap_New( &pfr_cmap_class_rec, NULL, &charmap, NULL ); +#if 0 /* Select default charmap */ if (root->num_charmaps) root->charmap = root->charmaps[0]; +#endif } /* check whether we've loaded any kerning pairs */ @@ -221,7 +233,7 @@ pfr_slot_load( PFR_Slot slot, PFR_Size size, FT_UInt gindex, - FT_Int load_flags ) + FT_Int32 load_flags ) { FT_Error error; PFR_Face face = (PFR_Face)slot->root.face; @@ -235,8 +247,16 @@ /* check that the glyph index is correct */ FT_ASSERT( gindex < face->phy_font.num_chars ); + /* try to load an embedded bitmap */ + if ( ( load_flags & ( FT_LOAD_NO_SCALE | FT_LOAD_NO_BITMAP ) ) == 0 ) + { + error = pfr_slot_load_bitmap( slot, size, gindex ); + if ( error == 0 ) + goto Exit; + } + gchar = face->phy_font.chars + gindex; - slot->root.format = ft_glyph_format_outline; + slot->root.format = FT_GLYPH_FORMAT_OUTLINE; outline->n_points = 0; outline->n_contours = 0; gps_offset = face->header.gps_section_offset; @@ -259,11 +279,11 @@ /* copy outline data */ *outline = slot->glyph.loader->base.outline; - outline->flags &= ~ft_outline_owner; - outline->flags |= ft_outline_reverse_fill; + outline->flags &= ~FT_OUTLINE_OWNER; + outline->flags |= FT_OUTLINE_REVERSE_FILL; if ( size && size->root.metrics.y_ppem < 24 ) - outline->flags |= ft_outline_high_precision; + outline->flags |= FT_OUTLINE_HIGH_PRECISION; /* compute the advance vector */ metrics->horiAdvance = 0; @@ -277,9 +297,9 @@ advance = FT_MulDiv( advance, em_outline, em_metrics ); if ( face->phy_font.flags & PFR_PHY_VERTICAL ) - metrics->vertAdvance = gchar->advance; + metrics->vertAdvance = advance; else - metrics->horiAdvance = gchar->advance; + metrics->horiAdvance = advance; slot->root.linearHoriAdvance = metrics->horiAdvance; slot->root.linearVertAdvance = metrics->vertAdvance; @@ -318,6 +338,7 @@ metrics->horiBearingY = cbox.yMax - metrics->height; } + Exit: return error; } @@ -330,52 +351,85 @@ /*************************************************************************/ /*************************************************************************/ - /* XXX: This relies on the font being spec-conformant, i.e., that the - kerning pairs are sorted. We might want to sort it just to make - sure */ - -#undef PFR_KERN_INDEX -#define PFR_KERN_INDEX( g1, g2 ) ( ( (FT_ULong)g1 << 16 ) | g2 ) - - /* find the kerning for a given glyph pair */ FT_LOCAL_DEF( FT_Error ) pfr_face_get_kerning( PFR_Face face, FT_UInt glyph1, FT_UInt glyph2, FT_Vector* kerning ) { + FT_Error error; PFR_PhyFont phy_font = &face->phy_font; - PFR_KernPair min, mid, max; - FT_ULong idx = PFR_KERN_INDEX( glyph1, glyph2 ); + PFR_KernItem item = phy_font->kern_items; + FT_UInt32 idx = PFR_KERN_INDEX( glyph1, glyph2 ); - /* simple binary search */ - min = phy_font->kern_pairs; - max = min + phy_font->num_kern_pairs; + kerning->x = 0; + kerning->y = 0; - while ( min < max ) + /* find the kerning item containing our pair */ + while ( item ) { - FT_ULong midi; + if ( item->pair1 <= idx && idx <= item->pair2 ) + goto Found_Item; + item = item->next; + } - mid = min + ( max - min ) / 2; - midi = PFR_KERN_INDEX( mid->glyph1, mid->glyph2 ); + /* not found */ + goto Exit; - if ( midi == idx ) - { - *kerning = mid->kerning; + Found_Item: + { + /* perform simply binary search within the item */ + FT_UInt min, mid, max; + FT_Stream stream = face->root.stream; + FT_Byte* p; + + + if ( FT_STREAM_SEEK( item->offset ) || + FT_FRAME_ENTER( item->pair_count * item->pair_size ) ) goto Exit; + + min = 0; + max = item->pair_count; + while ( min < max ) + { + FT_UInt char1, char2, charcode; + + + mid = ( min + max ) >> 1; + p = stream->cursor + mid*item->pair_size; + + if ( item->flags & PFR_KERN_2BYTE_CHAR ) + { + char1 = FT_NEXT_USHORT( p ); + char2 = FT_NEXT_USHORT( p ); + } + else + { + char1 = FT_NEXT_USHORT( p ); + char2 = FT_NEXT_USHORT( p ); + } + charcode = PFR_KERN_INDEX( char1, char2 ); + + if ( idx == charcode ) + { + if ( item->flags & PFR_KERN_2BYTE_ADJ ) + kerning->x = item->base_adj + FT_NEXT_SHORT( p ); + else + kerning->x = item->base_adj + FT_NEXT_CHAR( p ); + + break; + } + if ( idx > charcode ) + min = mid + 1; + else + max = mid; } - if ( midi < idx ) - min = mid + 1; - else - max = mid; + FT_FRAME_EXIT(); } - kerning->x = 0; - kerning->y = 0; - Exit: return 0; } diff --git a/src/libs/freetype2/pfr/pfrobjs.h b/src/libs/freetype2/pfr/pfrobjs.h index 5b749316fb5..b29b64c6cdd 100644 --- a/src/libs/freetype2/pfr/pfrobjs.h +++ b/src/libs/freetype2/pfr/pfrobjs.h @@ -25,9 +25,9 @@ FT_BEGIN_HEADER typedef struct PFR_FaceRec_* PFR_Face; - + typedef struct PFR_SizeRec_* PFR_Size; - + typedef struct PFR_SlotRec_* PFR_Slot; @@ -44,7 +44,7 @@ FT_BEGIN_HEADER typedef struct PFR_SizeRec_ { FT_SizeRec root; - + } PFR_SizeRec; @@ -52,14 +52,16 @@ FT_BEGIN_HEADER { FT_GlyphSlotRec root; PFR_GlyphRec glyph; - + } PFR_SlotRec; FT_LOCAL( FT_Error ) - pfr_face_init( FT_Stream stream, - PFR_Face face, - FT_Int face_index ); + pfr_face_init( FT_Stream stream, + PFR_Face face, + FT_Int face_index, + FT_Int num_params, + FT_Parameter* params ); FT_LOCAL( void ) pfr_face_done( PFR_Face face ); @@ -83,9 +85,12 @@ FT_BEGIN_HEADER pfr_slot_load( PFR_Slot slot, PFR_Size size, FT_UInt gindex, - FT_Int load_flags ); + FT_Int32 load_flags ); FT_END_HEADER #endif /* __PFROBJS_H__ */ + + +/* END */ diff --git a/src/libs/freetype2/pfr/pfrtypes.h b/src/libs/freetype2/pfr/pfrtypes.h index b3cd4dfb4bb..3b419da5d93 100644 --- a/src/libs/freetype2/pfr/pfrtypes.h +++ b/src/libs/freetype2/pfr/pfrtypes.h @@ -52,19 +52,19 @@ FT_BEGIN_HEADER FT_UInt max_blue_values; FT_UInt max_x_orus; FT_UInt max_y_orus; - + FT_UInt phy_font_max_size_high; FT_UInt color_flags; - + FT_UInt32 bct_max_size; - FT_UInt32 bct_set_max_size; + FT_UInt32 bct_set_max_size; FT_UInt32 phy_bct_set_max_size; - + FT_UInt num_phy_fonts; FT_UInt max_vert_stem_snap; FT_UInt max_horz_stem_snap; FT_UInt max_chars; - + } PFR_HeaderRec, *PFR_Header; @@ -73,7 +73,7 @@ FT_BEGIN_HEADER { PFR_FLAG_BLACK_PIXEL = 1, PFR_FLAG_INVERT_BITMAP = 2 - + } PFR_HeaderFlags; @@ -83,16 +83,16 @@ FT_BEGIN_HEADER { FT_UInt32 size; FT_UInt32 offset; - + FT_Int32 matrix[4]; FT_UInt stroke_flags; FT_Int stroke_thickness; FT_Int bold_thickness; FT_Int32 miter_limit; - + FT_UInt32 phys_size; FT_UInt32 phys_offset; - + } PFR_LogFontRec, *PFR_LogFont; @@ -104,7 +104,7 @@ FT_BEGIN_HEADER PFR_LOG_2BYTE_STROKE = 8, PFR_LOG_STROKE = 4, PFR_LINE_JOIN_MASK = 3 - + } PFR_LogFlags; @@ -113,7 +113,7 @@ FT_BEGIN_HEADER PFR_LINE_JOIN_MITER = 0, PFR_LINE_JOIN_ROUND = 1, PFR_LINE_JOIN_BEVEL = 2 - + } PFR_LineJoinFlags; @@ -124,7 +124,7 @@ FT_BEGIN_HEADER PFR_BITMAP_3BYTE_OFFSET = 4, PFR_BITMAP_2BYTE_SIZE = 2, PFR_BITMAP_2BYTE_CHARCODE = 1 - + } PFR_BitmapFlags; @@ -133,7 +133,7 @@ FT_BEGIN_HEADER FT_UInt char_code; FT_UInt gps_size; FT_UInt32 gps_offset; - + } PFR_BitmapCharRec, *PFR_BitmapChar; @@ -153,17 +153,17 @@ FT_BEGIN_HEADER FT_UInt x_ppm; FT_UInt y_ppm; FT_UInt flags; - + FT_UInt32 gps_size; FT_UInt32 gps_offset; - + FT_UInt32 bct_size; FT_UInt32 bct_offset; - + /* optional */ FT_UInt num_bitmaps; PFR_BitmapChar bitmaps; - + } PFR_StrikeRec, *PFR_Strike; @@ -175,7 +175,7 @@ FT_BEGIN_HEADER FT_Int advance; FT_UInt gps_size; FT_UInt32 gps_offset; - + } PFR_CharRec, *PFR_Char; @@ -186,11 +186,29 @@ FT_BEGIN_HEADER FT_UInt standard; FT_UInt num_stem_snaps; FT_Int* stem_snaps; - + } PFR_DimensionRec, *PFR_Dimension; /************************************************************************/ + typedef struct PFR_KernItemRec_* PFR_KernItem; + + typedef struct PFR_KernItemRec_ + { + PFR_KernItem next; + FT_UInt pair_count; + FT_UInt pair_size; + FT_Int base_adj; + FT_UInt flags; + FT_UInt32 offset; + FT_UInt32 pair1; + FT_UInt32 pair2; + + } PFR_KernItemRec; + +#define PFR_KERN_INDEX( g1, g2 ) \ + ( ( (FT_UInt32)(g1) << 16 ) | (FT_UInt16)(g2) ) + typedef struct PFR_KernPairRec_ { FT_UInt glyph1; @@ -212,7 +230,7 @@ FT_BEGIN_HEADER FT_BBox bbox; FT_UInt flags; FT_UInt standard_advance; - + PFR_DimensionRec horizontal; PFR_DimensionRec vertical; @@ -221,18 +239,23 @@ FT_BEGIN_HEADER FT_UInt num_strikes; FT_UInt max_strikes; PFR_StrikeRec* strikes; - + FT_UInt num_blue_values; FT_Int *blue_values; FT_UInt blue_fuzz; FT_UInt blue_scale; - + FT_UInt num_chars; FT_UInt32 chars_offset; PFR_Char chars; FT_UInt num_kern_pairs; - PFR_KernPairRec *kern_pairs; + PFR_KernItem kern_items; + PFR_KernItem* kern_items_tail; + + /* not part of the spec, but used during load */ + FT_UInt32 bct_offset; + FT_Byte* cursor; } PFR_PhyFontRec, *PFR_PhyFont; @@ -254,7 +277,7 @@ FT_BEGIN_HEADER { PFR_KERN_2BYTE_ADJ = 0x01, PFR_KERN_2BYTE_CHAR = 0x02 - + } PFR_KernFlags; @@ -267,7 +290,7 @@ FT_BEGIN_HEADER PFR_GLYPH_1BYTE_XYCOUNT = 0x04, PFR_GLYPH_XCOUNT = 0x02, PFR_GLYPH_YCOUNT = 0x01 - + } PFR_GlyphFlags; @@ -276,7 +299,7 @@ FT_BEGIN_HEADER { FT_UInt org; FT_UInt cur; - + } PFR_CoordRec, *PFR_Coord; @@ -288,7 +311,7 @@ FT_BEGIN_HEADER FT_Int y_delta; FT_UInt32 gps_offset; FT_UInt gps_size; - + } PFR_SubGlyphRec, *PFR_SubGlyph; @@ -298,14 +321,14 @@ FT_BEGIN_HEADER PFR_SUBGLYPH_2BYTE_SIZE = 0x40, PFR_SUBGLYPH_YSCALE = 0x20, PFR_SUBGLYPH_XSCALE = 0x10 - + } PFR_SubGlyphFlags; typedef struct PFR_GlyphRec_ { FT_Byte format; - + FT_UInt num_x_control; FT_UInt num_y_control; FT_UInt max_xy_control; @@ -316,10 +339,10 @@ FT_BEGIN_HEADER FT_UInt num_subs; FT_UInt max_subs; PFR_SubGlyphRec* subs; - + FT_GlyphLoader loader; FT_Bool path_begun; - + } PFR_GlyphRec, *PFR_Glyph; diff --git a/src/libs/freetype2/psaux/psauxmod.c b/src/libs/freetype2/psaux/psauxmod.c index f2f935a078f..fa0c4aa8ce7 100644 --- a/src/libs/freetype2/psaux/psauxmod.c +++ b/src/libs/freetype2/psaux/psauxmod.c @@ -26,51 +26,51 @@ FT_CALLBACK_TABLE_DEF const PS_Table_FuncsRec ps_table_funcs = { - PS_Table_New, - PS_Table_Done, - PS_Table_Add, - PS_Table_Release + ps_table_new, + ps_table_done, + ps_table_add, + ps_table_release }; FT_CALLBACK_TABLE_DEF const PS_Parser_FuncsRec ps_parser_funcs = { - PS_Parser_Init, - PS_Parser_Done, - PS_Parser_SkipSpaces, - PS_Parser_SkipAlpha, - PS_Parser_ToInt, - PS_Parser_ToFixed, - PS_Parser_ToCoordArray, - PS_Parser_ToFixedArray, - PS_Parser_ToToken, - PS_Parser_ToTokenArray, - PS_Parser_LoadField, - PS_Parser_LoadFieldTable + ps_parser_init, + ps_parser_done, + ps_parser_skip_spaces, + ps_parser_skip_alpha, + ps_parser_to_int, + ps_parser_to_fixed, + ps_parser_to_coord_array, + ps_parser_to_fixed_array, + ps_parser_to_token, + ps_parser_to_token_array, + ps_parser_load_field, + ps_parser_load_field_table }; FT_CALLBACK_TABLE_DEF const T1_Builder_FuncsRec t1_builder_funcs = { - T1_Builder_Init, - T1_Builder_Done, - T1_Builder_Check_Points, - T1_Builder_Add_Point, - T1_Builder_Add_Point1, - T1_Builder_Add_Contour, - T1_Builder_Start_Point, - T1_Builder_Close_Contour + t1_builder_init, + t1_builder_done, + t1_builder_check_points, + t1_builder_add_point, + t1_builder_add_point1, + t1_builder_add_contour, + t1_builder_start_point, + t1_builder_close_contour }; FT_CALLBACK_TABLE_DEF const T1_Decoder_FuncsRec t1_decoder_funcs = { - T1_Decoder_Init, - T1_Decoder_Done, - T1_Decoder_Parse_Charstrings + t1_decoder_init, + t1_decoder_done, + t1_decoder_parse_charstrings }; @@ -92,7 +92,7 @@ &t1_builder_funcs, &t1_decoder_funcs, - T1_Decrypt, + t1_decrypt, (const T1_CMap_ClassesRec*) &t1_cmap_classes, }; diff --git a/src/libs/freetype2/psaux/psobjs.c b/src/libs/freetype2/psaux/psobjs.c index c24a0c7245a..60359506253 100644 --- a/src/libs/freetype2/psaux/psobjs.c +++ b/src/libs/freetype2/psaux/psobjs.c @@ -36,7 +36,7 @@ /*************************************************************************/ /* */ /* <Function> */ - /* PS_Table_New */ + /* ps_table_new */ /* */ /* <Description> */ /* Initializes a PS_Table. */ @@ -54,7 +54,7 @@ /* FreeType error code. 0 means success. */ /* */ FT_LOCAL_DEF( FT_Error ) - PS_Table_New( PS_Table table, + ps_table_new( PS_Table table, FT_Int count, FT_Memory memory ) { @@ -72,7 +72,7 @@ table->block = 0; table->capacity = 0; table->cursor = 0; - + *(PS_Table_FuncsRec*)&table->funcs = ps_table_funcs; Exit: @@ -102,7 +102,7 @@ static FT_Error reallocate_t1_table( PS_Table table, - FT_Int new_size ) + FT_Long new_size ) { FT_Memory memory = table->memory; FT_Byte* old_base = table->block; @@ -130,7 +130,7 @@ /*************************************************************************/ /* */ /* <Function> */ - /* PS_Table_Add */ + /* ps_table_add */ /* */ /* <Description> */ /* Adds an object to a PS_Table, possibly growing its memory block. */ @@ -150,14 +150,14 @@ /* reallocation fails. */ /* */ FT_LOCAL_DEF( FT_Error ) - PS_Table_Add( PS_Table table, + ps_table_add( PS_Table table, FT_Int idx, void* object, FT_Int length ) { if ( idx < 0 || idx > table->max_elems ) { - FT_ERROR(( "PS_Table_Add: invalid index\n" )); + FT_ERROR(( "ps_table_add: invalid index\n" )); return PSaux_Err_Invalid_Argument; } @@ -174,7 +174,11 @@ in_offset = -1; while ( new_size < table->cursor + length ) - new_size += 1024; + { + /* increase size by 25% and round up to the nearest multiple of 1024 */ + new_size += (new_size >> 2) + 1; + new_size = ( new_size + 1023 ) & -1024; + } error = reallocate_t1_table( table, new_size ); if ( error ) @@ -197,7 +201,7 @@ /*************************************************************************/ /* */ /* <Function> */ - /* PS_Table_Done */ + /* ps_table_done */ /* */ /* <Description> */ /* Finalizes a PS_TableRec (i.e., reallocate it to its current */ @@ -211,7 +215,7 @@ /* to the caller to clean it, or reference it in its own structures. */ /* */ FT_LOCAL_DEF( void ) - PS_Table_Done( PS_Table table ) + ps_table_done( PS_Table table ) { FT_Memory memory = table->memory; FT_Error error; @@ -235,7 +239,7 @@ FT_LOCAL_DEF( void ) - PS_Table_Release( PS_Table table ) + ps_table_release( PS_Table table ) { FT_Memory memory = table->memory; @@ -266,7 +270,7 @@ FT_LOCAL_DEF( void ) - PS_Parser_SkipSpaces( PS_Parser parser ) + ps_parser_skip_spaces( PS_Parser parser ) { FT_Byte* cur = parser->cursor; FT_Byte* limit = parser->limit; @@ -286,7 +290,7 @@ FT_LOCAL_DEF( void ) - PS_Parser_SkipAlpha( PS_Parser parser ) + ps_parser_skip_alpha( PS_Parser parser ) { FT_Byte* cur = parser->cursor; FT_Byte* limit = parser->limit; @@ -306,8 +310,8 @@ FT_LOCAL_DEF( void ) - PS_Parser_ToToken( PS_Parser parser, - T1_Token token ) + ps_parser_to_token( PS_Parser parser, + T1_Token token ) { FT_Byte* cur; FT_Byte* limit; @@ -320,7 +324,7 @@ token->limit = 0; /* first of all, skip space */ - PS_Parser_SkipSpaces( parser ); + ps_parser_skip_spaces( parser ); cur = parser->cursor; limit = parser->limit; @@ -389,17 +393,17 @@ FT_LOCAL_DEF( void ) - PS_Parser_ToTokenArray( PS_Parser parser, - T1_Token tokens, - FT_UInt max_tokens, - FT_Int* pnum_tokens ) + ps_parser_to_token_array( PS_Parser parser, + T1_Token tokens, + FT_UInt max_tokens, + FT_Int* pnum_tokens ) { T1_TokenRec master; *pnum_tokens = -1; - PS_Parser_ToToken( parser, &master ); + ps_parser_to_token( parser, &master ); if ( master.type == T1_TOKEN_TYPE_ARRAY ) { FT_Byte* old_cursor = parser->cursor; @@ -416,7 +420,7 @@ T1_TokenRec token; - PS_Parser_ToToken( parser, &token ); + ps_parser_to_token( parser, &token ); if ( !token.type ) break; @@ -739,7 +743,7 @@ FT_Memory memory ) { FT_Byte* cur = *cursor; - FT_Int len = 0; + FT_PtrDist len = 0; FT_Int count; FT_String* result; FT_Error error; @@ -829,11 +833,11 @@ /* Load a simple field (i.e. non-table) into the current list of objects */ FT_LOCAL_DEF( FT_Error ) - PS_Parser_LoadField( PS_Parser parser, - const T1_Field field, - void** objects, - FT_UInt max_objects, - FT_ULong* pflags ) + ps_parser_load_field( PS_Parser parser, + const T1_Field field, + void** objects, + FT_UInt max_objects, + FT_ULong* pflags ) { T1_TokenRec token; FT_Byte* cur; @@ -843,7 +847,7 @@ FT_Error error; - PS_Parser_ToToken( parser, &token ); + ps_parser_to_token( parser, &token ); if ( !token.type ) goto Fail; @@ -852,8 +856,27 @@ cur = token.start; limit = token.limit; - if ( token.type == T1_TOKEN_TYPE_ARRAY ) + /* we must detect arrays */ + if ( field->type == T1_FIELD_TYPE_BBOX ) { + T1_TokenRec token2; + FT_Byte* old_cur = parser->cursor; + FT_Byte* old_limit = parser->limit; + + + parser->cursor = token.start; + parser->limit = token.limit; + + ps_parser_to_token( parser, &token2 ); + parser->cursor = old_cur; + parser->limit = old_limit; + + if ( token2.type == T1_TOKEN_TYPE_ARRAY ) + goto FieldArray; + } + else if ( token.type == T1_TOKEN_TYPE_ARRAY ) + { + FieldArray: /* if this is an array, and we have no blend, an error occurs */ if ( max_objects == 0 ) goto Fail; @@ -922,6 +945,24 @@ } break; + case T1_FIELD_TYPE_BBOX: + { + FT_Fixed temp[4]; + FT_BBox* bbox = (FT_BBox*)q; + + + /* we need the '[' and ']' delimiters */ + token.start--; + token.limit++; + (void)t1_tofixedarray( &token.start, token.limit, 4, temp, 0 ); + + bbox->xMin = FT_RoundFix( temp[0] ); + bbox->yMin = FT_RoundFix( temp[1] ); + bbox->xMax = FT_RoundFix( temp[2] ); + bbox->yMax = FT_RoundFix( temp[3] ); + } + break; + default: /* an error occured */ goto Fail; @@ -950,11 +991,11 @@ FT_LOCAL_DEF( FT_Error ) - PS_Parser_LoadFieldTable( PS_Parser parser, - const T1_Field field, - void** objects, - FT_UInt max_objects, - FT_ULong* pflags ) + ps_parser_load_field_table( PS_Parser parser, + const T1_Field field, + void** objects, + FT_UInt max_objects, + FT_ULong* pflags ) { T1_TokenRec elements[T1_MAX_TABLE_ELEMENTS]; T1_Token token; @@ -971,7 +1012,7 @@ fieldrec.type = T1_FIELD_TYPE_FIXED; #endif - PS_Parser_ToTokenArray( parser, elements, 32, &num_elements ); + ps_parser_to_token_array( parser, elements, 32, &num_elements ); if ( num_elements < 0 ) goto Fail; @@ -991,7 +1032,7 @@ { parser->cursor = token->start; parser->limit = token->limit; - PS_Parser_LoadField( parser, &fieldrec, objects, max_objects, 0 ); + ps_parser_load_field( parser, &fieldrec, objects, max_objects, 0 ); fieldrec.offset += fieldrec.size; } @@ -1015,24 +1056,24 @@ FT_LOCAL_DEF( FT_Long ) - PS_Parser_ToInt( PS_Parser parser ) + ps_parser_to_int( PS_Parser parser ) { return t1_toint( &parser->cursor, parser->limit ); } FT_LOCAL_DEF( FT_Fixed ) - PS_Parser_ToFixed( PS_Parser parser, - FT_Int power_ten ) + ps_parser_to_fixed( PS_Parser parser, + FT_Int power_ten ) { return t1_tofixed( &parser->cursor, parser->limit, power_ten ); } FT_LOCAL_DEF( FT_Int ) - PS_Parser_ToCoordArray( PS_Parser parser, - FT_Int max_coords, - FT_Short* coords ) + ps_parser_to_coord_array( PS_Parser parser, + FT_Int max_coords, + FT_Short* coords ) { return t1_tocoordarray( &parser->cursor, parser->limit, max_coords, coords ); @@ -1040,10 +1081,10 @@ FT_LOCAL_DEF( FT_Int ) - PS_Parser_ToFixedArray( PS_Parser parser, - FT_Int max_values, - FT_Fixed* values, - FT_Int power_ten ) + ps_parser_to_fixed_array( PS_Parser parser, + FT_Int max_values, + FT_Fixed* values, + FT_Int power_ten ) { return t1_tofixedarray( &parser->cursor, parser->limit, max_values, values, power_ten ); @@ -1069,7 +1110,7 @@ FT_LOCAL_DEF( void ) - PS_Parser_Init( PS_Parser parser, + ps_parser_init( PS_Parser parser, FT_Byte* base, FT_Byte* limit, FT_Memory memory ) @@ -1084,7 +1125,7 @@ FT_LOCAL_DEF( void ) - PS_Parser_Done( PS_Parser parser ) + ps_parser_done( PS_Parser parser ) { FT_UNUSED( parser ); } @@ -1101,7 +1142,7 @@ /*************************************************************************/ /* */ /* <Function> */ - /* T1_Builder_Init */ + /* t1_builder_init */ /* */ /* <Description> */ /* Initializes a given glyph builder. */ @@ -1119,7 +1160,7 @@ /* hinting :: Whether hinting should be applied. */ /* */ FT_LOCAL_DEF( void ) - T1_Builder_Init( T1_Builder builder, + t1_builder_init( T1_Builder builder, FT_Face face, FT_Size size, FT_GlyphSlot glyph, @@ -1170,7 +1211,7 @@ /*************************************************************************/ /* */ /* <Function> */ - /* T1_Builder_Done */ + /* t1_builder_done */ /* */ /* <Description> */ /* Finalizes a given glyph builder. Its contents can still be used */ @@ -1181,7 +1222,7 @@ /* builder :: A pointer to the glyph builder to finalize. */ /* */ FT_LOCAL_DEF( void ) - T1_Builder_Done( T1_Builder builder ) + t1_builder_done( T1_Builder builder ) { FT_GlyphSlot glyph = builder->glyph; @@ -1193,7 +1234,7 @@ /* check that there is enough space for `count' more points */ FT_LOCAL_DEF( FT_Error ) - T1_Builder_Check_Points( T1_Builder builder, + t1_builder_check_points( T1_Builder builder, FT_Int count ) { return FT_GlyphLoader_CheckPoints( builder->loader, count, 0 ); @@ -1202,7 +1243,7 @@ /* add a new point, do not check space */ FT_LOCAL_DEF( void ) - T1_Builder_Add_Point( T1_Builder builder, + t1_builder_add_point( T1_Builder builder, FT_Pos x, FT_Pos y, FT_Byte flag ) @@ -1223,7 +1264,7 @@ } point->x = x; point->y = y; - *control = (FT_Byte)( flag ? FT_Curve_Tag_On : FT_Curve_Tag_Cubic ); + *control = (FT_Byte)( flag ? FT_CURVE_TAG_ON : FT_CURVE_TAG_CUBIC ); builder->last = *point; } @@ -1233,16 +1274,16 @@ /* check space for a new on-curve point, then add it */ FT_LOCAL_DEF( FT_Error ) - T1_Builder_Add_Point1( T1_Builder builder, + t1_builder_add_point1( T1_Builder builder, FT_Pos x, FT_Pos y ) { FT_Error error; - error = T1_Builder_Check_Points( builder, 1 ); + error = t1_builder_check_points( builder, 1 ); if ( !error ) - T1_Builder_Add_Point( builder, x, y, 1 ); + t1_builder_add_point( builder, x, y, 1 ); return error; } @@ -1250,7 +1291,7 @@ /* check room for a new contour, then add it */ FT_LOCAL_DEF( FT_Error ) - T1_Builder_Add_Contour( T1_Builder builder ) + t1_builder_add_contour( T1_Builder builder ) { FT_Outline* outline = builder->current; FT_Error error; @@ -1278,7 +1319,7 @@ /* if a path was begun, add its first on-curve point */ FT_LOCAL_DEF( FT_Error ) - T1_Builder_Start_Point( T1_Builder builder, + t1_builder_start_point( T1_Builder builder, FT_Pos x, FT_Pos y ) { @@ -1289,9 +1330,9 @@ if ( !builder->path_begun ) { builder->path_begun = 1; - error = T1_Builder_Add_Contour( builder ); + error = t1_builder_add_contour( builder ); if ( !error ) - error = T1_Builder_Add_Point1( builder, x, y ); + error = t1_builder_add_point1( builder, x, y ); } return error; } @@ -1299,7 +1340,7 @@ /* close the current contour */ FT_LOCAL_DEF( void ) - T1_Builder_Close_Contour( T1_Builder builder ) + t1_builder_close_contour( T1_Builder builder ) { FT_Outline* outline = builder->current; @@ -1323,7 +1364,7 @@ /* `delete' last point only if it coincides with the first */ /* point and it is not a control point (which can happen). */ if ( p1->x == p2->x && p1->y == p2->y ) - if ( *control == FT_Curve_Tag_On ) + if ( *control == FT_CURVE_TAG_ON ) outline->n_points--; } @@ -1342,7 +1383,7 @@ /*************************************************************************/ FT_LOCAL_DEF( void ) - T1_Decrypt( FT_Byte* buffer, + t1_decrypt( FT_Byte* buffer, FT_Offset length, FT_UShort seed ) { diff --git a/src/libs/freetype2/psaux/psobjs.h b/src/libs/freetype2/psaux/psobjs.h index f748085f3fc..9e81675bb12 100644 --- a/src/libs/freetype2/psaux/psobjs.h +++ b/src/libs/freetype2/psaux/psobjs.h @@ -47,22 +47,22 @@ FT_BEGIN_HEADER FT_LOCAL( FT_Error ) - PS_Table_New( PS_Table table, + ps_table_new( PS_Table table, FT_Int count, FT_Memory memory ); FT_LOCAL( FT_Error ) - PS_Table_Add( PS_Table table, + ps_table_add( PS_Table table, FT_Int idx, void* object, FT_Int length ); FT_LOCAL( void ) - PS_Table_Done( PS_Table table ); + ps_table_done( PS_Table table ); FT_LOCAL( void ) - PS_Table_Release( PS_Table table ); + ps_table_release( PS_Table table ); /*************************************************************************/ @@ -75,64 +75,64 @@ FT_BEGIN_HEADER FT_LOCAL( void ) - PS_Parser_SkipSpaces( PS_Parser parser ); + ps_parser_skip_spaces( PS_Parser parser ); FT_LOCAL( void ) - PS_Parser_SkipAlpha( PS_Parser parser ); + ps_parser_skip_alpha( PS_Parser parser ); FT_LOCAL( void ) - PS_Parser_ToToken( PS_Parser parser, - T1_Token token ); + ps_parser_to_token( PS_Parser parser, + T1_Token token ); FT_LOCAL( void ) - PS_Parser_ToTokenArray( PS_Parser parser, - T1_Token tokens, - FT_UInt max_tokens, - FT_Int* pnum_tokens ); + ps_parser_to_token_array( PS_Parser parser, + T1_Token tokens, + FT_UInt max_tokens, + FT_Int* pnum_tokens ); FT_LOCAL( FT_Error ) - PS_Parser_LoadField( PS_Parser parser, - const T1_Field field, - void** objects, - FT_UInt max_objects, - FT_ULong* pflags ); + ps_parser_load_field( PS_Parser parser, + const T1_Field field, + void** objects, + FT_UInt max_objects, + FT_ULong* pflags ); FT_LOCAL( FT_Error ) - PS_Parser_LoadFieldTable( PS_Parser parser, - const T1_Field field, - void** objects, - FT_UInt max_objects, - FT_ULong* pflags ); + ps_parser_load_field_table( PS_Parser parser, + const T1_Field field, + void** objects, + FT_UInt max_objects, + FT_ULong* pflags ); FT_LOCAL( FT_Long ) - PS_Parser_ToInt( PS_Parser parser ); + ps_parser_to_int( PS_Parser parser ); FT_LOCAL( FT_Fixed ) - PS_Parser_ToFixed( PS_Parser parser, - FT_Int power_ten ); + ps_parser_to_fixed( PS_Parser parser, + FT_Int power_ten ); FT_LOCAL( FT_Int ) - PS_Parser_ToCoordArray( PS_Parser parser, - FT_Int max_coords, - FT_Short* coords ); + ps_parser_to_coord_array( PS_Parser parser, + FT_Int max_coords, + FT_Short* coords ); FT_LOCAL( FT_Int ) - PS_Parser_ToFixedArray( PS_Parser parser, - FT_Int max_values, - FT_Fixed* values, - FT_Int power_ten ); + ps_parser_to_fixed_array( PS_Parser parser, + FT_Int max_values, + FT_Fixed* values, + FT_Int power_ten ); FT_LOCAL( void ) - PS_Parser_Init( PS_Parser parser, + ps_parser_init( PS_Parser parser, FT_Byte* base, FT_Byte* limit, FT_Memory memory ); FT_LOCAL( void ) - PS_Parser_Done( PS_Parser parser ); + ps_parser_done( PS_Parser parser ); /*************************************************************************/ @@ -144,42 +144,42 @@ FT_BEGIN_HEADER /*************************************************************************/ FT_LOCAL( void ) - T1_Builder_Init( T1_Builder builder, + t1_builder_init( T1_Builder builder, FT_Face face, FT_Size size, FT_GlyphSlot glyph, FT_Bool hinting ); FT_LOCAL( void ) - T1_Builder_Done( T1_Builder builder ); + t1_builder_done( T1_Builder builder ); FT_LOCAL( FT_Error ) - T1_Builder_Check_Points( T1_Builder builder, + t1_builder_check_points( T1_Builder builder, FT_Int count ); FT_LOCAL( void ) - T1_Builder_Add_Point( T1_Builder builder, + t1_builder_add_point( T1_Builder builder, FT_Pos x, FT_Pos y, FT_Byte flag ); FT_LOCAL( FT_Error ) - T1_Builder_Add_Point1( T1_Builder builder, + t1_builder_add_point1( T1_Builder builder, FT_Pos x, FT_Pos y ); FT_LOCAL( FT_Error ) - T1_Builder_Add_Contour( T1_Builder builder ); + t1_builder_add_contour( T1_Builder builder ); FT_LOCAL( FT_Error ) - T1_Builder_Start_Point( T1_Builder builder, + t1_builder_start_point( T1_Builder builder, FT_Pos x, FT_Pos y ); FT_LOCAL( void ) - T1_Builder_Close_Contour( T1_Builder builder ); + t1_builder_close_contour( T1_Builder builder ); /*************************************************************************/ @@ -191,7 +191,7 @@ FT_BEGIN_HEADER /*************************************************************************/ FT_LOCAL( void ) - T1_Decrypt( FT_Byte* buffer, + t1_decrypt( FT_Byte* buffer, FT_Offset length, FT_UShort seed ); diff --git a/src/libs/freetype2/psaux/t1decode.c b/src/libs/freetype2/psaux/t1decode.c index 4544ad1fb47..27b4e877c61 100644 --- a/src/libs/freetype2/psaux/t1decode.c +++ b/src/libs/freetype2/psaux/t1decode.c @@ -247,7 +247,7 @@ /* set up remaining glyph fields */ glyph->num_subglyphs = 2; glyph->subglyphs = loader->base.subglyphs; - glyph->format = ft_glyph_format_composite; + glyph->format = FT_GLYPH_FORMAT_COMPOSITE; loader->current.num_subglyphs = 2; goto Exit; @@ -258,7 +258,7 @@ FT_GlyphLoader_Prepare( decoder->builder.loader ); /* prepare loader */ - error = T1_Decoder_Parse_Glyph( decoder, bchar_index ); + error = t1_decoder_parse_glyph( decoder, bchar_index ); if ( error ) goto Exit; @@ -280,7 +280,7 @@ /* Now load `achar' on top of */ /* the base outline */ - error = T1_Decoder_Parse_Glyph( decoder, achar_index ); + error = t1_decoder_parse_glyph( decoder, achar_index ); if ( error ) goto Exit; @@ -316,7 +316,7 @@ /*************************************************************************/ /* */ /* <Function> */ - /* T1_Decoder_Parse_Charstrings */ + /* t1_decoder_parse_charstrings */ /* */ /* <Description> */ /* Parses a given Type 1 charstrings program. */ @@ -332,7 +332,7 @@ /* FreeType error code. 0 means success. */ /* */ FT_LOCAL_DEF( FT_Error ) - T1_Decoder_Parse_Charstrings( T1_Decoder decoder, + t1_decoder_parse_charstrings( T1_Decoder decoder, FT_Byte* charstring_base, FT_UInt charstring_len ) { @@ -347,12 +347,12 @@ /* we don't want to touch the source code -- use macro trick */ -#define start_point T1_Builder_Start_Point -#define check_points T1_Builder_Check_Points -#define add_point T1_Builder_Add_Point -#define add_point1 T1_Builder_Add_Point1 -#define add_contour T1_Builder_Add_Contour -#define close_contour T1_Builder_Close_Contour +#define start_point t1_builder_start_point +#define check_points t1_builder_check_points +#define add_point t1_builder_add_point +#define add_point1 t1_builder_add_point1 +#define add_contour t1_builder_add_contour +#define close_contour t1_builder_close_contour /* First of all, initialize the decoder */ decoder->top = decoder->stack; @@ -453,7 +453,7 @@ case 12: if ( ip > limit ) { - FT_ERROR(( "T1_Decoder_Parse_Charstrings: " + FT_ERROR(( "t1_decoder_parse_charstrings: " "invalid escape (12+EOF)\n" )); goto Syntax_Error; } @@ -489,7 +489,7 @@ break; default: - FT_ERROR(( "T1_Decoder_Parse_Charstrings: " + FT_ERROR(( "t1_decoder_parse_charstrings: " "invalid escape (12+%d)\n", ip[-1] )); goto Syntax_Error; @@ -499,7 +499,7 @@ case 255: /* four bytes integer */ if ( ip + 4 > limit ) { - FT_ERROR(( "T1_Decoder_Parse_Charstrings: " + FT_ERROR(( "t1_decoder_parse_charstrings: " "unexpected EOF in integer\n" )); goto Syntax_Error; } @@ -520,7 +520,7 @@ { if ( ++ip > limit ) { - FT_ERROR(( "T1_Decoder_Parse_Charstrings: " )); + FT_ERROR(( "t1_decoder_parse_charstrings: " )); FT_ERROR(( "unexpected EOF in integer\n" )); goto Syntax_Error; } @@ -533,7 +533,7 @@ } else { - FT_ERROR(( "T1_Decoder_Parse_Charstrings: " + FT_ERROR(( "t1_decoder_parse_charstrings: " "invalid byte (%d)\n", ip[-1] )); goto Syntax_Error; } @@ -548,7 +548,7 @@ { if ( top - decoder->stack >= T1_MAX_CHARSTRINGS_OPERANDS ) { - FT_ERROR(( "T1_Decoder_Parse_Charstrings: stack overflow!\n" )); + FT_ERROR(( "t1_decoder_parse_charstrings: stack overflow!\n" )); goto Syntax_Error; } @@ -605,7 +605,7 @@ if ( decoder->flex_state == 0 || decoder->num_flex_vectors != 7 ) { - FT_ERROR(( "T1_Decoder_Parse_Charstrings: " + FT_ERROR(( "t1_decoder_parse_charstrings: " "unexpected flex end\n" )); goto Syntax_Error; } @@ -616,7 +616,7 @@ ip[2] != 12 || ip[3] != 17 || /* pop */ ip[4] != 12 || ip[5] != 33 ) /* setcurpoint */ { - FT_ERROR(( "T1_Decoder_Parse_Charstrings: " + FT_ERROR(( "t1_decoder_parse_charstrings: " "invalid flex charstring\n" )); goto Syntax_Error; } @@ -632,14 +632,14 @@ /* eat the following `pop' */ if ( ip + 2 > limit ) { - FT_ERROR(( "T1_Decoder_Parse_Charstrings: " + FT_ERROR(( "t1_decoder_parse_charstrings: " "invalid escape (12+%d)\n", ip[-1] )); goto Syntax_Error; } if ( ip[0] != 12 || ip[1] != 17 ) { - FT_ERROR(( "T1_Decoder_Parse_Charstrings: " )); + FT_ERROR(( "t1_decoder_parse_charstrings: " )); FT_ERROR(( "`pop' expected, found (%d %d)\n", ip[0], ip[1] )); goto Syntax_Error; } @@ -670,15 +670,15 @@ if ( !blend ) { - FT_ERROR(( "T1_Decoder_Parse_Charstrings: " )); + FT_ERROR(( "t1_decoder_parse_charstrings: " )); FT_ERROR(( "unexpected multiple masters operator!\n" )); goto Syntax_Error; } - num_points = top[1] - 13 + ( top[1] == 18 ); + num_points = (FT_UInt)top[1] - 13 + ( top[1] == 18 ); if ( top[0] != (FT_Int)( num_points * blend->num_designs ) ) { - FT_ERROR(( "T1_Decoder_Parse_Charstrings: " )); + FT_ERROR(( "t1_decoder_parse_charstrings: " )); FT_ERROR(( "incorrect number of mm arguments\n" )); goto Syntax_Error; } @@ -720,7 +720,7 @@ default: Unexpected_OtherSubr: - FT_ERROR(( "T1_Decoder_Parse_Charstrings: " + FT_ERROR(( "t1_decoder_parse_charstrings: " "invalid othersubr [%d %d]!\n", top[0], top[1] )); goto Syntax_Error; } @@ -752,7 +752,8 @@ /* apply hints to the loaded glyph outline now */ hinter->apply( hinter->hints, builder->current, - (PSH_Globals)builder->hints_globals ); + (PSH_Globals) builder->hints_globals, + decoder->hint_mode ); } /* add current outline to the glyph slot */ @@ -932,7 +933,7 @@ } else { - FT_ERROR(( "T1_Decoder_Parse_Charstrings: division by 0\n" )); + FT_ERROR(( "t1_decoder_parse_charstrings: division by 0\n" )); goto Syntax_Error; } break; @@ -947,14 +948,14 @@ idx = top[0]; if ( idx < 0 || idx >= (FT_Int)decoder->num_subrs ) { - FT_ERROR(( "T1_Decoder_Parse_Charstrings: " + FT_ERROR(( "t1_decoder_parse_charstrings: " "invalid subrs index\n" )); goto Syntax_Error; } if ( zone - decoder->zones >= T1_MAX_SUBRS_CALLS ) { - FT_ERROR(( "T1_Decoder_Parse_Charstrings: " + FT_ERROR(( "t1_decoder_parse_charstrings: " "too many nested subrs\n" )); goto Syntax_Error; } @@ -982,7 +983,7 @@ if ( !zone->base ) { - FT_ERROR(( "T1_Decoder_Parse_Charstrings: " + FT_ERROR(( "t1_decoder_parse_charstrings: " "invoking empty subrs!\n" )); goto Syntax_Error; } @@ -1005,7 +1006,7 @@ if ( zone <= decoder->zones ) { - FT_ERROR(( "T1_Decoder_Parse_Charstrings: unexpected return\n" )); + FT_ERROR(( "t1_decoder_parse_charstrings: unexpected return\n" )); goto Syntax_Error; } @@ -1072,12 +1073,12 @@ case op_setcurrentpoint: FT_TRACE4(( " setcurrentpoint" )); - FT_ERROR(( "T1_Decoder_Parse_Charstrings: " )); + FT_ERROR(( "t1_decoder_parse_charstrings: " )); FT_ERROR(( "unexpected `setcurrentpoint'\n" )); goto Syntax_Error; default: - FT_ERROR(( "T1_Decoder_Parse_Charstrings: " + FT_ERROR(( "t1_decoder_parse_charstrings: " "unhandled opcode %d\n", op )); goto Syntax_Error; } @@ -1105,7 +1106,7 @@ /* parse a single Type 1 glyph */ FT_LOCAL_DEF( FT_Error ) - T1_Decoder_Parse_Glyph( T1_Decoder decoder, + t1_decoder_parse_glyph( T1_Decoder decoder, FT_UInt glyph ) { return decoder->parse_callback( decoder, glyph ); @@ -1114,16 +1115,17 @@ /* initialize T1 decoder */ FT_LOCAL_DEF( FT_Error ) - T1_Decoder_Init( T1_Decoder decoder, + t1_decoder_init( T1_Decoder decoder, FT_Face face, FT_Size size, FT_GlyphSlot slot, FT_Byte** glyph_names, PS_Blend blend, FT_Bool hinting, + FT_Render_Mode hint_mode, T1_Decoder_Callback parse_callback ) { - FT_MEM_SET( decoder, 0, sizeof ( *decoder ) ); + FT_MEM_ZERO( decoder, sizeof ( *decoder ) ); /* retrieve PSNames interface from list of current modules */ { @@ -1134,7 +1136,7 @@ FT_FACE_LIBRARY(face), "psnames" ); if ( !psnames ) { - FT_ERROR(( "T1_Decoder_Init: " )); + FT_ERROR(( "t1_decoder_init: " )); FT_ERROR(( "the `psnames' module is not available\n" )); return PSaux_Err_Unimplemented_Feature; } @@ -1142,10 +1144,12 @@ decoder->psnames = psnames; } - T1_Builder_Init( &decoder->builder, face, size, slot, hinting ); + t1_builder_init( &decoder->builder, face, size, slot, hinting ); - decoder->num_glyphs = face->num_glyphs; + decoder->num_glyphs = (FT_UInt)face->num_glyphs; decoder->glyph_names = glyph_names; + decoder->hint_flags = face->internal->hint_flags; + decoder->hint_mode = hint_mode; decoder->blend = blend; decoder->parse_callback = parse_callback; @@ -1157,9 +1161,9 @@ /* finalize T1 decoder */ FT_LOCAL_DEF( void ) - T1_Decoder_Done( T1_Decoder decoder ) + t1_decoder_done( T1_Decoder decoder ) { - T1_Builder_Done( &decoder->builder ); + t1_builder_done( &decoder->builder ); } diff --git a/src/libs/freetype2/psaux/t1decode.h b/src/libs/freetype2/psaux/t1decode.h index 70fe647c9c8..fcb853ce804 100644 --- a/src/libs/freetype2/psaux/t1decode.h +++ b/src/libs/freetype2/psaux/t1decode.h @@ -34,26 +34,27 @@ FT_BEGIN_HEADER FT_LOCAL( FT_Error ) - T1_Decoder_Parse_Glyph( T1_Decoder decoder, + t1_decoder_parse_glyph( T1_Decoder decoder, FT_UInt glyph_index ); FT_LOCAL( FT_Error ) - T1_Decoder_Parse_Charstrings( T1_Decoder decoder, + t1_decoder_parse_charstrings( T1_Decoder decoder, FT_Byte* base, FT_UInt len ); FT_LOCAL( FT_Error ) - T1_Decoder_Init( T1_Decoder decoder, + t1_decoder_init( T1_Decoder decoder, FT_Face face, FT_Size size, FT_GlyphSlot slot, FT_Byte** glyph_names, PS_Blend blend, FT_Bool hinting, + FT_Render_Mode hint_mode, T1_Decoder_Callback parse_glyph ); FT_LOCAL( void ) - T1_Decoder_Done( T1_Decoder decoder ); + t1_decoder_done( T1_Decoder decoder ); FT_END_HEADER diff --git a/src/libs/freetype2/pshinter/pshalgo.h b/src/libs/freetype2/pshinter/pshalgo.h index 6097671b663..e79ad029554 100644 --- a/src/libs/freetype2/pshinter/pshalgo.h +++ b/src/libs/freetype2/pshinter/pshalgo.h @@ -22,17 +22,26 @@ FT_BEGIN_HEADER /* define to choose hinting algorithm */ -#define PSH_ALGORITHM_2 +#define PSH_ALGORITHM_3 -#ifdef PSH_ALGORITHM_1 +#if defined(PSH_ALGORITHM_1) -#include "pshalgo1.h" -#define PS_HINTS_APPLY_FUNC ps1_hints_apply +# include "pshalgo1.h" +# define PS_HINTS_APPLY_FUNC ps1_hints_apply + +#elif defined(PSH_ALGORITHM_2) + +# include "pshalgo2.h" +# define PS_HINTS_APPLY_FUNC ps2_hints_apply + +#elif defined(PSH_ALGORITHM_3) + +# include "pshalgo3.h" +# define PS_HINTS_APPLY_FUNC ps3_hints_apply #else -#include "pshalgo2.h" -#define PS_HINTS_APPLY_FUNC ps2_hints_apply +# error "invalid Postscript Hinter algorithm selection" #endif diff --git a/src/libs/freetype2/pshinter/pshalgo1.c b/src/libs/freetype2/pshinter/pshalgo1.c index 8fa03256ec7..06da5977d0e 100644 --- a/src/libs/freetype2/pshinter/pshalgo1.c +++ b/src/libs/freetype2/pshinter/pshalgo1.c @@ -25,8 +25,8 @@ #define FT_COMPONENT trace_pshalgo1 #ifdef DEBUG_HINTER - extern PSH1_Hint_Table ps1_debug_hint_table = 0; - extern PSH1_HintFunc ps1_debug_hint_func = 0; + PSH1_Hint_Table ps1_debug_hint_table = 0; + PSH1_HintFunc ps1_debug_hint_func = 0; #endif @@ -742,22 +742,25 @@ /*************************************************************************/ FT_Error - ps1_hints_apply( PS_Hints ps_hints, - FT_Outline* outline, - PSH_Globals globals ) + ps1_hints_apply( PS_Hints ps_hints, + FT_Outline* outline, + PSH_Globals globals, + FT_Render_Mode hint_mode ) { PSH1_Hint_TableRec hints; FT_Error error = 0; FT_Int dimension; + FT_UNUSED( hint_mode ); + for ( dimension = 1; dimension >= 0; dimension-- ) { PS_Dimension dim = &ps_hints->dimension[dimension]; /* initialize hints table */ - ft_memset( &hints, 0, sizeof ( hints ) ); + FT_MEM_ZERO( &hints, sizeof ( hints ) ); error = psh1_hint_table_init( &hints, &dim->hints, &dim->masks, diff --git a/src/libs/freetype2/pshinter/pshalgo1.h b/src/libs/freetype2/pshinter/pshalgo1.h index ed1031fd6cb..2f795a6a587 100644 --- a/src/libs/freetype2/pshinter/pshalgo1.h +++ b/src/libs/freetype2/pshinter/pshalgo1.h @@ -86,9 +86,10 @@ FT_BEGIN_HEADER extern FT_Error - ps1_hints_apply( PS_Hints ps_hints, - FT_Outline* outline, - PSH_Globals globals ); + ps1_hints_apply( PS_Hints ps_hints, + FT_Outline* outline, + PSH_Globals globals, + FT_Render_Mode hint_mode ); #ifdef DEBUG_HINTER diff --git a/src/libs/freetype2/pshinter/pshalgo2.c b/src/libs/freetype2/pshinter/pshalgo2.c index 2cd3911cc62..c0a9265b616 100644 --- a/src/libs/freetype2/pshinter/pshalgo2.c +++ b/src/libs/freetype2/pshinter/pshalgo2.c @@ -25,9 +25,9 @@ #define FT_COMPONENT trace_pshalgo2 #ifdef DEBUG_HINTER - extern PSH2_Hint_Table ps2_debug_hint_table = 0; - extern PSH2_HintFunc ps2_debug_hint_func = 0; - extern PSH2_Glyph ps2_debug_glyph = 0; + PSH2_Hint_Table ps2_debug_hint_table = 0; + PSH2_HintFunc ps2_debug_hint_func = 0; + PSH2_Glyph ps2_debug_glyph = 0; #endif @@ -861,7 +861,7 @@ /* clear all fields */ - ft_memset( glyph, 0, sizeof ( *glyph ) ); + FT_MEM_ZERO( glyph, sizeof ( *glyph ) ); memory = globals->memory; @@ -927,7 +927,7 @@ FT_Pos dxi, dyi, dxo, dyo; - if ( !( outline->tags[n] & FT_Curve_Tag_On ) ) + if ( !( outline->tags[n] & FT_CURVE_TAG_ON ) ) point->flags = PSH2_POINT_OFF; dxi = vec[n].x - vec[n_prev].x; @@ -1128,8 +1128,9 @@ /* process secondary hints to "selected" points */ - if ( num_masks > 1 ) + if ( num_masks > 1 && glyph->num_points > 0 ) { + first = mask->end_point; mask++; for ( ; num_masks > 1; num_masks--, mask++ ) { @@ -1491,9 +1492,10 @@ /*************************************************************************/ FT_Error - ps2_hints_apply( PS_Hints ps_hints, - FT_Outline* outline, - PSH_Globals globals ) + ps2_hints_apply( PS_Hints ps_hints, + FT_Outline* outline, + PSH_Globals globals, + FT_Render_Mode hint_mode ) { PSH2_GlyphRec glyphrec; PSH2_Glyph glyph = &glyphrec; @@ -1503,6 +1505,7 @@ #endif FT_Int dimension; + FT_UNUSED( hint_mode ); #ifdef DEBUG_HINTER memory = globals->memory; diff --git a/src/libs/freetype2/pshinter/pshalgo2.h b/src/libs/freetype2/pshinter/pshalgo2.h index 5d6a61ee761..405d34b565a 100644 --- a/src/libs/freetype2/pshinter/pshalgo2.h +++ b/src/libs/freetype2/pshinter/pshalgo2.h @@ -188,9 +188,10 @@ FT_BEGIN_HEADER extern FT_Error - ps2_hints_apply( PS_Hints ps_hints, - FT_Outline* outline, - PSH_Globals globals ); + ps2_hints_apply( PS_Hints ps_hints, + FT_Outline* outline, + PSH_Globals globals, + FT_Render_Mode hint_mode ); FT_END_HEADER diff --git a/src/libs/freetype2/pshinter/pshglob.c b/src/libs/freetype2/pshinter/pshglob.c index 58c77b54544..e5ead545102 100644 --- a/src/libs/freetype2/pshinter/pshglob.c +++ b/src/libs/freetype2/pshinter/pshglob.c @@ -23,7 +23,7 @@ #include "pshglob.h" #ifdef DEBUG_HINTER - extern PSH_Globals ps_debug_globals = 0; + PSH_Globals ps_debug_globals = 0; #endif @@ -534,10 +534,10 @@ for ( ; count > 0; count--, zone++ ) { delta = stem_top - zone->org_bottom; - if ( delta < 0 ) + if ( delta < -blues->blue_fuzz ) break; - if ( stem_top <= zone->org_top ) + if ( stem_top <= zone->org_top + blues->blue_fuzz ) { if ( no_shoots || delta <= blues->blue_threshold ) { @@ -556,10 +556,10 @@ for ( ; count > 0; count--, zone-- ) { delta = zone->org_top - stem_bot; - if ( delta < 0 ) + if ( delta < -blues->blue_fuzz ) break; - if ( stem_bot >= zone->org_bottom ) + if ( stem_bot >= zone->org_bottom - blues->blue_fuzz ) { if ( no_shoots || delta < blues->blue_shift ) { @@ -629,7 +629,7 @@ PSH_Width write = dim->stdw.widths; - write->org = priv->standard_width[1]; + write->org = priv->standard_width[0]; write++; read = priv->snap_widths; @@ -649,9 +649,8 @@ PSH_Width write = dim->stdw.widths; - write->org = priv->standard_height[1]; - write++; - + write->org = priv->standard_height[0]; + write++; read = priv->snap_heights; for ( count = priv->num_snap_heights; count > 0; count-- ) { @@ -680,6 +679,8 @@ ? priv->blue_shift : 7; + globals->blues.blue_fuzz = priv->blue_fuzz; + globals->dimension[0].scale_mult = 0; globals->dimension[0].scale_delta = 0; globals->dimension[1].scale_mult = 0; diff --git a/src/libs/freetype2/pshinter/pshglob.h b/src/libs/freetype2/pshinter/pshglob.h index fcda9dac775..0a3a96ab155 100644 --- a/src/libs/freetype2/pshinter/pshglob.h +++ b/src/libs/freetype2/pshinter/pshglob.h @@ -123,6 +123,7 @@ FT_BEGIN_HEADER FT_Fixed blue_scale; FT_Int blue_shift; FT_Int blue_threshold; + FT_Int blue_fuzz; FT_Bool no_overshoots; } PSH_BluesRec, *PSH_Blues; diff --git a/src/libs/freetype2/pshinter/pshinter.c b/src/libs/freetype2/pshinter/pshinter.c index 6b991821bf4..180f6c89c46 100644 --- a/src/libs/freetype2/pshinter/pshinter.c +++ b/src/libs/freetype2/pshinter/pshinter.c @@ -23,6 +23,7 @@ #include "pshglob.c" #include "pshalgo1.c" #include "pshalgo2.c" +#include "pshalgo3.c" #include "pshmod.c" diff --git a/src/libs/freetype2/pshinter/pshrec.c b/src/libs/freetype2/pshinter/pshrec.c index 208cf78d425..21ced1e2984 100644 --- a/src/libs/freetype2/pshinter/pshrec.c +++ b/src/libs/freetype2/pshinter/pshrec.c @@ -27,9 +27,9 @@ #define FT_COMPONENT trace_pshrec #ifdef DEBUG_HINTER - extern PS_Hints ps_debug_hints = 0; - extern int ps_debug_no_horz_hints = 0; - extern int ps_debug_no_vert_hints = 0; + PS_Hints ps_debug_hints = 0; + int ps_debug_no_horz_hints = 0; + int ps_debug_no_vert_hints = 0; #endif @@ -797,7 +797,7 @@ ps_hints_init( PS_Hints hints, FT_Memory memory ) { - ft_memset( hints, 0, sizeof ( *hints ) ); + FT_MEM_ZERO( hints, sizeof ( *hints ) ); hints->memory = memory; return 0; } @@ -1132,7 +1132,7 @@ FT_LOCAL_DEF( void ) t1_hints_funcs_init( T1_Hints_FuncsRec* funcs ) { - ft_memset( (char*)funcs, 0, sizeof ( *funcs ) ); + FT_MEM_ZERO( (char*)funcs, sizeof ( *funcs ) ); funcs->open = (T1_Hints_OpenFunc) t1_hints_open; funcs->close = (T1_Hints_CloseFunc) ps_hints_close; @@ -1197,7 +1197,7 @@ FT_LOCAL_DEF( void ) t2_hints_funcs_init( T2_Hints_FuncsRec* funcs ) { - ft_memset( funcs, 0, sizeof ( *funcs ) ); + FT_MEM_ZERO( funcs, sizeof ( *funcs ) ); funcs->open = (T2_Hints_OpenFunc) t2_hints_open; funcs->close = (T2_Hints_CloseFunc) ps_hints_close; diff --git a/src/libs/freetype2/pshinter/rules.mk b/src/libs/freetype2/pshinter/rules.mk index 409a7900a03..207d3494aed 100644 --- a/src/libs/freetype2/pshinter/rules.mk +++ b/src/libs/freetype2/pshinter/rules.mk @@ -30,7 +30,8 @@ PSHINTER_DRV_SRC := $(PSHINTER_DIR_)pshrec.c \ $(PSHINTER_DIR_)pshglob.c \ $(PSHINTER_DIR_)pshmod.c \ $(PSHINTER_DIR_)pshalgo1.c \ - $(PSHINTER_DIR_)pshalgo2.c + $(PSHINTER_DIR_)pshalgo2.c \ + $(PSHINTER_DIR_)pshalgo3.c # PSHINTER driver headers diff --git a/src/libs/freetype2/psnames/psmodule.c b/src/libs/freetype2/psnames/psmodule.c index a0e0386aafb..b2ddcb7e4d2 100644 --- a/src/libs/freetype2/psnames/psmodule.c +++ b/src/libs/freetype2/psnames/psmodule.c @@ -36,8 +36,8 @@ /* we do deal with glyph variants by detecting a non-initial dot in */ /* the name, as in `A.swash' or `e.final', etc. */ /* */ - static FT_ULong - PS_Unicode_Value( const char* glyph_name ) + static FT_UInt32 + ps_unicode_value( const char* glyph_name ) { FT_Int n; char first = glyph_name[0]; @@ -139,7 +139,7 @@ /* Builds a table that maps Unicode values to glyph indices */ static FT_Error - PS_Build_Unicode_Table( FT_Memory memory, + ps_build_unicode_table( FT_Memory memory, FT_UInt num_glyphs, const char** glyph_names, PS_Unicodes* table ) @@ -156,7 +156,7 @@ FT_UInt n; FT_UInt count; PS_UniMap* map; - FT_ULong uni_char; + FT_UInt32 uni_char; map = table->maps; @@ -168,7 +168,7 @@ if ( gname ) { - uni_char = PS_Unicode_Value( gname ); + uni_char = ps_unicode_value( gname ); if ( uni_char != 0 && uni_char != 0xFFFF ) { @@ -205,7 +205,7 @@ static FT_UInt - PS_Lookup_Unicode( PS_Unicodes* table, + ps_lookup_unicode( PS_Unicodes* table, FT_ULong unicode ) { PS_UniMap *min, *max, *mid; @@ -236,7 +236,7 @@ static FT_ULong - PS_Next_Unicode( PS_Unicodes* table, + ps_next_unicode( PS_Unicodes* table, FT_ULong unicode ) { PS_UniMap *min, *max, *mid; @@ -265,7 +265,7 @@ if ( max < table->maps ) max = table->maps; - + while ( max < table->maps + table->num_maps ) { if ( unicode < max->unicode ) @@ -281,7 +281,7 @@ static const char* - PS_Macintosh_Name( FT_UInt name_index ) + ps_get_macintosh_name( FT_UInt name_index ) { if ( name_index >= 258 ) name_index = 0; @@ -291,7 +291,7 @@ static const char* - PS_Standard_Strings( FT_UInt sid ) + ps_get_standard_strings( FT_UInt sid ) { return ( sid < NUM_SID_GLYPHS ? sid_standard_names[sid] : 0 ); } @@ -302,9 +302,9 @@ { #ifdef FT_CONFIG_OPTION_ADOBE_GLYPH_LIST - (PS_Unicode_Value_Func) PS_Unicode_Value, - (PS_Build_Unicodes_Func) PS_Build_Unicode_Table, - (PS_Lookup_Unicode_Func) PS_Lookup_Unicode, + (PS_Unicode_Value_Func) ps_unicode_value, + (PS_Build_Unicodes_Func) ps_build_unicode_table, + (PS_Lookup_Unicode_Func) ps_lookup_unicode, #else @@ -314,14 +314,14 @@ #endif /* FT_CONFIG_OPTION_ADOBE_GLYPH_LIST */ - (PS_Macintosh_Name_Func) PS_Macintosh_Name, - (PS_Adobe_Std_Strings_Func)PS_Standard_Strings, + (PS_Macintosh_Name_Func) ps_get_macintosh_name, + (PS_Adobe_Std_Strings_Func) ps_get_standard_strings, t1_standard_encoding, t1_expert_encoding, #ifdef FT_CONFIG_OPTION_ADOBE_GLYPH_LIST - (PS_Next_Unicode_Func) PS_Next_Unicode + (PS_Next_Unicode_Func) ps_next_unicode #else 0 #endif /* FT_CONFIG_OPTION_ADOBE_GLYPH_LIST */ diff --git a/src/libs/freetype2/raster/ftraster.c b/src/libs/freetype2/raster/ftraster.c index d756563e11b..654a81ec37e 100644 --- a/src/libs/freetype2/raster/ftraster.c +++ b/src/libs/freetype2/raster/ftraster.c @@ -539,7 +539,7 @@ FT_TRACE6(( "Set_High_Precision(%s)\n", High ? "true" : "false" )); - ras.precision = 1L << ras.precision_bits; + ras.precision = 1 << ras.precision_bits; ras.precision_half = ras.precision / 2; ras.precision_shift = ras.precision_bits - Pixel_Bits; ras.precision_mask = -ras.precision; @@ -702,7 +702,7 @@ if ( n >= 0 && y > y_turns[n] ) while ( n >= 0 ) { - y2 = y_turns[n]; + y2 = (Int)y_turns[n]; y_turns[n] = y; y = y2; n--; @@ -758,16 +758,16 @@ switch ( p->flow ) { case Flow_Down: - bottom = p->start - p->height+1; - top = p->start; + bottom = (Int)( p->start - p->height + 1 ); + top = (Int)p->start; p->start = bottom; p->offset += p->height - 1; break; case Flow_Up: default: - bottom = p->start; - top = p->start + p->height - 1; + bottom = (Int)p->start; + top = (Int)( p->start + p->height - 1 ); } if ( Insert_Y_Turn( RAS_VARS bottom ) || @@ -922,20 +922,20 @@ } else { - e1 = TRUNC( y1 ); - f1 = FRAC( y1 ); + e1 = (Int)TRUNC( y1 ); + f1 = (Int)FRAC( y1 ); } if ( y2 > maxy ) { /* x2 += FMulDiv( Dx, maxy - y2, Dy ); UNNECESSARY */ - e2 = TRUNC( maxy ); + e2 = (Int)TRUNC( maxy ); f2 = 0; } else { - e2 = TRUNC( y2 ); - f2 = FRAC( y2 ); + e2 = (Int)TRUNC( y2 ); + f2 = (Int)FRAC( y2 ); } if ( f1 > 0 ) @@ -1635,14 +1635,14 @@ tag = FT_CURVE_TAG( tags[0] ); /* A contour cannot start with a cubic control point! */ - if ( tag == FT_Curve_Tag_Cubic ) + if ( tag == FT_CURVE_TAG_CUBIC ) goto Invalid_Outline; /* check first point to determine origin */ - if ( tag == FT_Curve_Tag_Conic ) + if ( tag == FT_CURVE_TAG_CONIC ) { /* first point is conic control. Yes, this happens. */ - if ( FT_CURVE_TAG( ras.outline.tags[last] ) == FT_Curve_Tag_On ) + if ( FT_CURVE_TAG( ras.outline.tags[last] ) == FT_CURVE_TAG_ON ) { /* start at last point if it is on the curve */ v_start = v_last; @@ -1674,7 +1674,7 @@ switch ( tag ) { - case FT_Curve_Tag_On: /* emit a single line_to */ + case FT_CURVE_TAG_ON: /* emit a single line_to */ { Long x, y; @@ -1689,7 +1689,7 @@ continue; } - case FT_Curve_Tag_Conic: /* consume conic arcs */ + case FT_CURVE_TAG_CONIC: /* consume conic arcs */ v_control.x = SCALED( point[0].x ); v_control.y = SCALED( point[0].y ); @@ -1713,14 +1713,14 @@ if ( flipped ) SWAP_( x, y ); - if ( tag == FT_Curve_Tag_On ) + if ( tag == FT_CURVE_TAG_ON ) { if ( Conic_To( RAS_VARS v_control.x, v_control.y, x, y ) ) goto Fail; continue; } - if ( tag != FT_Curve_Tag_Conic ) + if ( tag != FT_CURVE_TAG_CONIC ) goto Invalid_Outline; v_middle.x = ( v_control.x + x ) / 2; @@ -1742,13 +1742,13 @@ goto Close; - default: /* FT_Curve_Tag_Cubic */ + default: /* FT_CURVE_TAG_CUBIC */ { Long x1, y1, x2, y2, x3, y3; if ( point + 1 > limit || - FT_CURVE_TAG( tags[1] ) != FT_Curve_Tag_Cubic ) + FT_CURVE_TAG( tags[1] ) != FT_CURVE_TAG_CUBIC ) goto Invalid_Outline; point += 2; @@ -2652,13 +2652,13 @@ Long x1, x2, xs, e1, e2; - TProfileList wait; + TProfileList waiting; TProfileList draw_left, draw_right; /* Init empty linked lists */ - Init_Linked( &wait ); + Init_Linked( &waiting ); Init_Linked( &draw_left ); Init_Linked( &draw_right ); @@ -2680,7 +2680,7 @@ if ( max_Y < top ) max_Y = top; P->X = 0; - InsNew( &wait, P ); + InsNew( &waiting, P ); P = Q; } @@ -2698,7 +2698,7 @@ /* Then compute the distance of each profile from min_Y */ - P = wait; + P = waiting; while ( P ) { @@ -2717,9 +2717,9 @@ while ( ras.numTurns > 0 ) { - /* look in the wait list for new activations */ + /* look in the waiting list for new activations */ - P = wait; + P = waiting; while ( P ) { @@ -2727,7 +2727,7 @@ P->countL -= y_height; if ( P->countL == 0 ) { - DelOld( &wait, P ); + DelOld( &waiting, P ); switch ( P->flow ) { @@ -2972,11 +2972,11 @@ Set_High_Precision( RAS_VARS ras.outline.flags & - ft_outline_high_precision ); + FT_OUTLINE_HIGH_PRECISION ); ras.scale_shift = ras.precision_shift; ras.dropOutControl = 2; ras.second_pass = (FT_Byte)( !( ras.outline.flags & - ft_outline_single_pass ) ); + FT_OUTLINE_SINGLE_PASS ) ); /* Vertical Sweep */ ras.Proc_Sweep_Init = Vertical_Sweep_Init; @@ -3036,10 +3036,10 @@ Set_High_Precision( RAS_VARS ras.outline.flags & - ft_outline_high_precision ); + FT_OUTLINE_HIGH_PRECISION ); ras.scale_shift = ras.precision_shift + 1; ras.dropOutControl = 2; - ras.second_pass = !( ras.outline.flags & ft_outline_single_pass ); + ras.second_pass = !( ras.outline.flags & FT_OUTLINE_SINGLE_PASS ); /* Vertical Sweep */ @@ -3116,7 +3116,7 @@ ( ( c << 2 ) & 0x0030 ) | (c & 0x0003 ); - raster->count_table[n] = c; + raster->count_table[n] = (UInt)c; } #ifdef FT_RASTER_OPTION_ANTI_ALIASING @@ -3146,7 +3146,7 @@ *araster = &the_raster; - FT_MEM_SET( &the_raster, sizeof ( the_raster ), 0 ); + FT_MEM_ZERO( &the_raster, sizeof ( the_raster ) ); ft_black_init( &the_raster ); return 0; @@ -3259,7 +3259,7 @@ return Raster_Err_Invalid; /* this version of the raster does not support direct rendering, sorry */ - if ( params->flags & ft_raster_flag_direct ) + if ( params->flags & FT_RASTER_FLAG_DIRECT ) return Raster_Err_Unsupported; if ( !target_map || !target_map->buffer ) @@ -3268,7 +3268,7 @@ ras.outline = *outline; ras.target = *target_map; - return ( ( params->flags & ft_raster_flag_aa ) + return ( ( params->flags & FT_RASTER_FLAG_AA ) ? Render_Gray_Glyph( raster ) : Render_Glyph( raster ) ); } @@ -3276,7 +3276,7 @@ const FT_Raster_Funcs ft_standard_raster = { - ft_glyph_format_outline, + FT_GLYPH_FORMAT_OUTLINE, (FT_Raster_New_Func) ft_black_new, (FT_Raster_Reset_Func) ft_black_reset, (FT_Raster_Set_Mode_Func)ft_black_set_mode, diff --git a/src/libs/freetype2/raster/ftrend1.c b/src/libs/freetype2/raster/ftrend1.c index 0b67bbcb554..86b170cfe96 100644 --- a/src/libs/freetype2/raster/ftrend1.c +++ b/src/libs/freetype2/raster/ftrend1.c @@ -86,7 +86,7 @@ FT_GlyphSlot slot, FT_BBox* cbox ) { - FT_MEM_SET( cbox, 0, sizeof ( *cbox ) ); + FT_MEM_ZERO( cbox, sizeof ( *cbox ) ); if ( slot->format == render->glyph_format ) FT_Outline_Get_CBox( &slot->outline, cbox ); @@ -95,10 +95,10 @@ /* convert a slot's glyph image into a bitmap */ static FT_Error - ft_raster1_render( FT_Renderer render, - FT_GlyphSlot slot, - FT_UInt mode, - FT_Vector* origin ) + ft_raster1_render( FT_Renderer render, + FT_GlyphSlot slot, + FT_Render_Mode mode, + FT_Vector* origin ) { FT_Error error; FT_Outline* outline; @@ -118,7 +118,7 @@ } /* check rendering mode */ - if ( mode != ft_render_mode_mono ) + if ( mode != FT_RENDER_MODE_MONO ) { /* raster1 is only capable of producing monochrome bitmaps */ if ( render->clazz == &ft_raster1_renderer_class ) @@ -145,8 +145,8 @@ cbox.xMax = ( cbox.xMax + 63 ) & -64; cbox.yMax = ( cbox.yMax + 63 ) & -64; - width = ( cbox.xMax - cbox.xMin ) >> 6; - height = ( cbox.yMax - cbox.yMin ) >> 6; + width = (FT_UInt)( ( cbox.xMax - cbox.xMin ) >> 6 ); + height = (FT_UInt)( ( cbox.yMax - cbox.yMin ) >> 6 ); bitmap = &slot->bitmap; memory = render->root.memory; @@ -158,17 +158,17 @@ } /* allocate new one, depends on pixel format */ - if ( !( mode & ft_render_mode_mono ) ) + if ( !( mode & FT_RENDER_MODE_MONO ) ) { /* we pad to 32 bits, only for backwards compatibility with FT 1.x */ pitch = ( width + 3 ) & -4; - bitmap->pixel_mode = ft_pixel_mode_grays; + bitmap->pixel_mode = FT_PIXEL_MODE_GRAY; bitmap->num_grays = 256; } else { pitch = ( ( width + 15 ) >> 4 ) << 1; - bitmap->pixel_mode = ft_pixel_mode_mono; + bitmap->pixel_mode = FT_PIXEL_MODE_MONO; } bitmap->width = width; @@ -188,8 +188,8 @@ params.source = outline; params.flags = 0; - if ( bitmap->pixel_mode == ft_pixel_mode_grays ) - params.flags |= ft_raster_flag_aa; + if ( bitmap->pixel_mode == FT_PIXEL_MODE_GRAY ) + params.flags |= FT_RASTER_FLAG_AA; /* render outline into the bitmap */ error = render->raster_render( render->raster, ¶ms ); @@ -199,9 +199,9 @@ if ( error ) goto Exit; - slot->format = ft_glyph_format_bitmap; - slot->bitmap_left = cbox.xMin >> 6; - slot->bitmap_top = cbox.yMax >> 6; + slot->format = FT_GLYPH_FORMAT_BITMAP; + slot->bitmap_left = (FT_Int)( cbox.xMin >> 6 ); + slot->bitmap_top = (FT_Int)( cbox.yMax >> 6 ); Exit: return error; @@ -226,12 +226,12 @@ (FT_Module_Requester) 0 }, - ft_glyph_format_outline, + FT_GLYPH_FORMAT_OUTLINE, - (FTRenderer_render) ft_raster1_render, - (FTRenderer_transform)ft_raster1_transform, - (FTRenderer_getCBox) ft_raster1_get_cbox, - (FTRenderer_setMode) ft_raster1_set_mode, + (FT_Renderer_RenderFunc) ft_raster1_render, + (FT_Renderer_TransformFunc)ft_raster1_transform, + (FT_Renderer_GetCBoxFunc) ft_raster1_get_cbox, + (FT_Renderer_SetModeFunc) ft_raster1_set_mode, (FT_Raster_Funcs*) &ft_standard_raster }; @@ -259,12 +259,12 @@ (FT_Module_Requester) 0 }, - ft_glyph_format_outline, + FT_GLYPH_FORMAT_OUTLINE, - (FTRenderer_render) ft_raster1_render, - (FTRenderer_transform)ft_raster1_transform, - (FTRenderer_getCBox) ft_raster1_get_cbox, - (FTRenderer_setMode) ft_raster1_set_mode, + (FT_Renderer_RenderFunc) ft_raster1_render, + (FT_Renderer_TransformFunc)ft_raster1_transform, + (FT_Renderer_GetCBoxFunc) ft_raster1_get_cbox, + (FT_Renderer_SetModeFunc) ft_raster1_set_mode, (FT_Raster_Funcs*) &ft_standard_raster }; diff --git a/src/libs/freetype2/sfnt/sfdriver.c b/src/libs/freetype2/sfnt/sfdriver.c index f0316e29370..f2fa7b46e8c 100644 --- a/src/libs/freetype2/sfnt/sfdriver.c +++ b/src/libs/freetype2/sfnt/sfdriver.c @@ -92,7 +92,7 @@ FT_Error error; - error = TT_Get_PS_Name( face, glyph_index, &gname ); + error = tt_face_get_ps_name( face, glyph_index, &gname ); if ( !error && buffer_max > 0 ) { FT_UInt len = (FT_UInt)( ft_strlen( gname ) ); @@ -220,7 +220,7 @@ FT_CALLBACK_DEF( FT_Module_Interface ) - SFNT_Get_Interface( FT_Module module, + sfnt_get_interface( FT_Module module, const char* module_interface ) { FT_UNUSED( module ); @@ -243,44 +243,44 @@ static const SFNT_Interface sfnt_interface = { - TT_Goto_Table, + tt_face_goto_table, - SFNT_Init_Face, - SFNT_Load_Face, - SFNT_Done_Face, - SFNT_Get_Interface, + sfnt_init_face, + sfnt_load_face, + sfnt_done_face, + sfnt_get_interface, - TT_Load_Any, - TT_Load_SFNT_HeaderRec, - TT_Load_Directory, + tt_face_load_any, + tt_face_load_sfnt_header, + tt_face_load_directory, - TT_Load_Header, - TT_Load_Metrics_Header, - TT_Load_CMap, - TT_Load_MaxProfile, - TT_Load_OS2, - TT_Load_PostScript, + tt_face_load_header, + tt_face_load_metrics_header, + tt_face_load_cmap, + tt_face_load_max_profile, + tt_face_load_os2, + tt_face_load_postscript, - TT_Load_Names, - TT_Free_Names, + tt_face_load_names, + tt_face_free_names, - TT_Load_Hdmx, - TT_Free_Hdmx, + tt_face_load_hdmx, + tt_face_free_hdmx, - TT_Load_Kern, - TT_Load_Gasp, - TT_Load_PCLT, + tt_face_load_kern, + tt_face_load_gasp, + tt_face_load_pclt, #ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS /* see `ttload.h' */ - TT_Load_Bitmap_Header, + tt_face_load_bitmap_header, /* see `ttsbit.h' */ - TT_Set_SBit_Strike, - TT_Load_SBit_Strikes, - TT_Load_SBit_Image, - TT_Free_SBit_Strikes, + tt_face_set_sbit_strike, + tt_face_load_sbit_strikes, + tt_face_load_sbit_image, + tt_face_free_sbit_strikes, #else /* TT_CONFIG_OPTION_EMBEDDED_BITMAPS */ @@ -295,8 +295,8 @@ #ifdef TT_CONFIG_OPTION_POSTSCRIPT_NAMES /* see `ttpost.h' */ - TT_Get_PS_Name, - TT_Free_Post_Names, + tt_face_get_ps_name, + tt_face_free_ps_names, #else /* TT_CONFIG_OPTION_POSTSCRIPT_NAMES */ @@ -306,8 +306,8 @@ #endif /* TT_CONFIG_OPTION_POSTSCRIPT_NAMES */ /* see `ttcmap.h' */ - TT_CharMap_Load, - TT_CharMap_Free, + tt_face_load_charmap, + tt_face_free_charmap, }; @@ -325,7 +325,7 @@ (FT_Module_Constructor)0, (FT_Module_Destructor) 0, - (FT_Module_Requester) SFNT_Get_Interface + (FT_Module_Requester) sfnt_get_interface }; diff --git a/src/libs/freetype2/sfnt/sfobjs.c b/src/libs/freetype2/sfnt/sfobjs.c index fb672356b5f..adaca244039 100644 --- a/src/libs/freetype2/sfnt/sfobjs.c +++ b/src/libs/freetype2/sfnt/sfobjs.c @@ -86,7 +86,7 @@ for ( n = 0; n < len; n++ ) { - code = FT_NEXT_ULONG( read ); + code = (FT_UInt)FT_NEXT_ULONG( read ); if ( code < 32 || code > 127 ) code = '?'; @@ -296,20 +296,20 @@ static const TEncoding tt_encodings[] = { - { TT_PLATFORM_ISO, -1, ft_encoding_unicode }, + { TT_PLATFORM_ISO, -1, FT_ENCODING_UNICODE }, - { TT_PLATFORM_APPLE_UNICODE, -1, ft_encoding_unicode }, + { TT_PLATFORM_APPLE_UNICODE, -1, FT_ENCODING_UNICODE }, - { TT_PLATFORM_MACINTOSH, TT_MAC_ID_ROMAN, ft_encoding_apple_roman }, + { TT_PLATFORM_MACINTOSH, TT_MAC_ID_ROMAN, FT_ENCODING_APPLE_ROMAN }, - { TT_PLATFORM_MICROSOFT, TT_MS_ID_SYMBOL_CS, ft_encoding_symbol }, - { TT_PLATFORM_MICROSOFT, TT_MS_ID_UCS_4, ft_encoding_unicode }, - { TT_PLATFORM_MICROSOFT, TT_MS_ID_UNICODE_CS, ft_encoding_unicode }, - { TT_PLATFORM_MICROSOFT, TT_MS_ID_SJIS, ft_encoding_sjis }, - { TT_PLATFORM_MICROSOFT, TT_MS_ID_GB2312, ft_encoding_gb2312 }, - { TT_PLATFORM_MICROSOFT, TT_MS_ID_BIG_5, ft_encoding_big5 }, - { TT_PLATFORM_MICROSOFT, TT_MS_ID_WANSUNG, ft_encoding_wansung }, - { TT_PLATFORM_MICROSOFT, TT_MS_ID_JOHAB, ft_encoding_johab } + { TT_PLATFORM_MICROSOFT, TT_MS_ID_SYMBOL_CS, FT_ENCODING_MS_SYMBOL }, + { TT_PLATFORM_MICROSOFT, TT_MS_ID_UCS_4, FT_ENCODING_UNICODE }, + { TT_PLATFORM_MICROSOFT, TT_MS_ID_UNICODE_CS, FT_ENCODING_UNICODE }, + { TT_PLATFORM_MICROSOFT, TT_MS_ID_SJIS, FT_ENCODING_MS_SJIS }, + { TT_PLATFORM_MICROSOFT, TT_MS_ID_GB2312, FT_ENCODING_MS_GB2312 }, + { TT_PLATFORM_MICROSOFT, TT_MS_ID_BIG_5, FT_ENCODING_MS_BIG5 }, + { TT_PLATFORM_MICROSOFT, TT_MS_ID_WANSUNG, FT_ENCODING_MS_WANSUNG }, + { TT_PLATFORM_MICROSOFT, TT_MS_ID_JOHAB, FT_ENCODING_MS_JOHAB } }; const TEncoding *cur, *limit; @@ -328,12 +328,12 @@ } } - return ft_encoding_none; + return FT_ENCODING_NONE; } FT_LOCAL_DEF( FT_Error ) - SFNT_Init_Face( FT_Stream stream, + sfnt_init_face( FT_Stream stream, TT_Face face, FT_Int face_index, FT_Int num_params, @@ -397,7 +397,7 @@ FT_LOCAL_DEF( FT_Error ) - SFNT_Load_Face( FT_Stream stream, + sfnt_load_face( FT_Stream stream, TT_Face face, FT_Int face_index, FT_Int num_params, @@ -432,8 +432,15 @@ /* */ /* do we have outlines in there? */ - has_outline = FT_BOOL( ( TT_LookUp_Table( face, TTAG_glyf ) != 0 ) || - ( TT_LookUp_Table( face, TTAG_CFF ) != 0 ) ); +#ifdef FT_CONFIG_OPTION_INCREMENTAL + has_outline = FT_BOOL( face->root.internal->incremental_interface != 0 || + tt_face_lookup_table( face, TTAG_glyf ) != 0 || + tt_face_lookup_table( face, TTAG_CFF ) != 0 ); +#else + has_outline = FT_BOOL( tt_face_lookup_table( face, TTAG_glyf ) != 0 || + tt_face_lookup_table( face, TTAG_CFF ) != 0 ); +#endif + is_apple_sbit = 0; #ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS @@ -508,8 +515,7 @@ /* now set up root fields */ { FT_Face root = &face->root; - FT_Int flags = 0; - FT_Int n; + FT_Int32 flags = 0; FT_Memory memory; @@ -578,9 +584,8 @@ /* Try to set the charmap encoding according to the platform & */ /* encoding ID of each charmap. */ /* */ -#ifdef FT_CONFIG_OPTION_USE_CMAPS - TT_Build_CMaps( face ); /* ignore errors */ + tt_face_build_cmaps( face ); /* ignore errors */ /* set the encoding fields */ @@ -596,56 +601,25 @@ charmap->encoding = sfnt_find_encoding( charmap->platform_id, charmap->encoding_id ); +#if 0 if ( root->charmap == NULL && - charmap->encoding == ft_encoding_unicode ) + charmap->encoding == FT_ENCODING_UNICODE ) { /* set 'root->charmap' to the first Unicode encoding we find */ root->charmap = charmap; } +#endif } } -#else /* !FT_CONFIG_OPTION_USE_CMAPS */ - - { - TT_CharMap charmap = face->charmaps; - - - charmap = face->charmaps; - root->num_charmaps = face->num_charmaps; - - /* allocate table of pointers */ - if ( FT_NEW_ARRAY( root->charmaps, root->num_charmaps ) ) - goto Exit; - - for ( n = 0; n < root->num_charmaps; n++, charmap++ ) - { - FT_Int platform = charmap->cmap.platformID; - FT_Int encoding = charmap->cmap.platformEncodingID; - - - charmap->root.face = (FT_Face)face; - charmap->root.platform_id = (FT_UShort)platform; - charmap->root.encoding_id = (FT_UShort)encoding; - charmap->root.encoding = sfnt_find_encoding( platform, encoding ); - - /* now, set root->charmap with a unicode charmap */ - /* wherever available */ - if ( !root->charmap && - charmap->root.encoding == ft_encoding_unicode ) - root->charmap = (FT_CharMap)charmap; - - root->charmaps[n] = (FT_CharMap)charmap; - } - } - -#endif /* !FT_CONFIG_OPTION_USE_CMAPS */ - #ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS if ( face->num_sbit_strikes ) { + FT_ULong n; + + root->face_flags |= FT_FACE_FLAG_FIXED_SIZES; #if 0 @@ -779,7 +753,7 @@ FT_LOCAL_DEF( void ) - SFNT_Done_Face( TT_Face face ) + sfnt_done_face( TT_Face face ) { FT_Memory memory = face->root.memory; SFNT_Service sfnt = (SFNT_Service)face->sfnt; @@ -808,8 +782,6 @@ FT_FREE( face->dir_tables ); face->num_tables = 0; -#ifdef FT_CONFIG_OPTION_USE_CMAPS - { FT_Stream stream = FT_FACE_STREAM( face ); @@ -819,27 +791,6 @@ face->cmap_size = 0; } -#else /* !FT_CONFIG_OPTION_USE_CMAPS */ - - /* freeing the character mapping tables */ - if ( sfnt && sfnt->load_charmaps ) - { - FT_UShort n; - - - for ( n = 0; n < face->num_charmaps; n++ ) - sfnt->free_charmap( face, &face->charmaps[n].cmap ); - } - - FT_FREE( face->charmaps ); - face->num_charmaps = 0; - - FT_FREE( face->root.charmaps ); - face->root.num_charmaps = 0; - face->root.charmap = 0; - -#endif /* !FT_CONFIG_OPTION_USE_CMAPS */ - /* freeing the horizontal metrics */ FT_FREE( face->horizontal.long_metrics ); FT_FREE( face->horizontal.short_metrics ); diff --git a/src/libs/freetype2/sfnt/sfobjs.h b/src/libs/freetype2/sfnt/sfobjs.h index f30c1985eee..6241c93b392 100644 --- a/src/libs/freetype2/sfnt/sfobjs.h +++ b/src/libs/freetype2/sfnt/sfobjs.h @@ -29,21 +29,21 @@ FT_BEGIN_HEADER FT_LOCAL( FT_Error ) - SFNT_Init_Face( FT_Stream stream, + sfnt_init_face( FT_Stream stream, TT_Face face, FT_Int face_index, FT_Int num_params, FT_Parameter* params ); FT_LOCAL( FT_Error ) - SFNT_Load_Face( FT_Stream stream, + sfnt_load_face( FT_Stream stream, TT_Face face, FT_Int face_index, FT_Int num_params, FT_Parameter* params ); FT_LOCAL( void ) - SFNT_Done_Face( TT_Face face ); + sfnt_done_face( TT_Face face ); FT_END_HEADER diff --git a/src/libs/freetype2/sfnt/ttcmap.c b/src/libs/freetype2/sfnt/ttcmap.c index 5d0a61a2c22..f6aabfeec23 100644 --- a/src/libs/freetype2/sfnt/ttcmap.c +++ b/src/libs/freetype2/sfnt/ttcmap.c @@ -86,7 +86,7 @@ /*************************************************************************/ /* */ /* <Function> */ - /* TT_CharMap_Load */ + /* tt_face_load_charmap */ /* */ /* <Description> */ /* Loads a given TrueType character map into memory. */ @@ -108,9 +108,9 @@ /* released. */ /* */ FT_LOCAL_DEF( FT_Error ) - TT_CharMap_Load( TT_Face face, - TT_CMapTable cmap, - FT_Stream stream ) + tt_face_load_charmap( TT_Face face, + TT_CMapTable cmap, + FT_Stream stream ) { FT_Error error; FT_Memory memory; @@ -391,7 +391,7 @@ return SFNT_Err_Ok; Fail: - TT_CharMap_Free( face, cmap ); + tt_face_free_charmap( face, cmap ); return error; } @@ -399,7 +399,7 @@ /*************************************************************************/ /* */ /* <Function> */ - /* TT_CharMap_Free */ + /* tt_face_free_charmap */ /* */ /* <Description> */ /* Destroys a character mapping table. */ @@ -413,8 +413,8 @@ /* FreeType error code. 0 means success. */ /* */ FT_LOCAL_DEF( FT_Error ) - TT_CharMap_Free( TT_Face face, - TT_CMapTable cmap ) + tt_face_free_charmap( TT_Face face, + TT_CMapTable cmap ) { FT_Memory memory; @@ -629,11 +629,11 @@ * This is relatively simplistic -- look for a subHeader containing * glyphs and then walk to the first glyph in that subHeader. */ - while ( charCode < 0x10000 ) + while ( charCode < 0x10000L ) { char_lo = (FT_UInt)( charCode & 0xFF ); char_hi = charCode >> 8; - + if ( char_hi == 0 ) { /* an 8-bit character code -- we use the subHeader 0 in this case */ @@ -655,16 +655,16 @@ continue; } } - + sh2 = cmap2->subHeaders + index1; char_lo -= sh2->firstCode; - + if ( char_lo > (FT_UInt)sh2->entryCount ) { charCode = ( char_hi + 1 ) << 8; continue; } - + offset = sh2->idRangeOffset / 2 + char_lo; if ( offset >= (FT_UInt)cmap2->numGlyphId || cmap2->glyphIdArray[offset] == 0 ) @@ -672,7 +672,7 @@ charCode++; continue; } - + return charCode; } return 0; @@ -746,7 +746,7 @@ /* directly */ if ( seg4->idRangeOffset == 0 ) - result = ( charCode + seg4->idDelta ) & 0xFFFFU; + result = (FT_UInt)( charCode + seg4->idDelta ) & 0xFFFFU; else { /* otherwise, we must use the glyphIdArray to do it */ @@ -813,7 +813,7 @@ if ( seg4->idRangeOffset == 0 ) return ( charCode ); - + while ( charCode <= (FT_UInt) seg4->endCount ) { /* otherwise, we must use the glyphIdArray to do it */ @@ -890,12 +890,12 @@ charCode++; - + cmap6 = &cmap->c.cmap6; - + if ( charCode < (FT_ULong) cmap6->firstCode ) charCode = cmap6->firstCode; - + charCode -= cmap6->firstCode; while ( charCode < (FT_UInt)cmap6->entryCount ) @@ -971,7 +971,8 @@ cmap8_12->last_group = group; Found1: - return group->startGlyphID + (FT_UInt)( charCode - group->startCharCode ); + return (FT_UInt)( group->startGlyphID + + ( charCode - group->startCharCode ) ); } @@ -1016,7 +1017,7 @@ Found: if ( charCode < group->startCharCode ) charCode = group->startCharCode; - + return charCode; } @@ -1085,10 +1086,10 @@ charCode++; cmap10 = &cmap->c.cmap10; - + if ( charCode < cmap10->startCharCode ) charCode = cmap10->startCharCode; - + charCode -= cmap10->startCharCode; /* the overflow trick for comparison works here also since the number */ diff --git a/src/libs/freetype2/sfnt/ttcmap.h b/src/libs/freetype2/sfnt/ttcmap.h index 6ddb79ef43a..cd19a6b7344 100644 --- a/src/libs/freetype2/sfnt/ttcmap.h +++ b/src/libs/freetype2/sfnt/ttcmap.h @@ -28,13 +28,13 @@ FT_BEGIN_HEADER FT_LOCAL( FT_Error ) - TT_CharMap_Load( TT_Face face, - TT_CMapTable cmap, - FT_Stream input ); + tt_face_load_charmap( TT_Face face, + TT_CMapTable cmap, + FT_Stream input ); FT_LOCAL( FT_Error ) - TT_CharMap_Free( TT_Face face, - TT_CMapTable cmap ); + tt_face_free_charmap( TT_Face face, + TT_CMapTable cmap ); FT_END_HEADER diff --git a/src/libs/freetype2/sfnt/ttcmap0.c b/src/libs/freetype2/sfnt/ttcmap0.c index 17bb776de9e..40533457798 100644 --- a/src/libs/freetype2/sfnt/ttcmap0.c +++ b/src/libs/freetype2/sfnt/ttcmap0.c @@ -579,6 +579,12 @@ /* Otherwise, a glyph index is taken from the glyph ids sub-array for */ /* the segment, and the value of `idDelta' is added to it. */ /* */ + /* */ + /* Finally, note that certain fonts contain invalid charmaps that */ + /* contain end=0xFFFF, start=0xFFFF, delta=0x0001, offset=0xFFFF at the */ + /* of their charmaps (e.g. opens___.ttf which comes with OpenOffice.org) */ + /* we need special code to deal with them correctly... */ + /* */ #ifdef TT_CONFIG_CMAP_FORMAT_4 @@ -592,9 +598,19 @@ FT_UInt num_segs; - if ( table + length > valid->limit || length < 16 ) + /* in certain fonts, the `length' field is invalid and goes */ + /* out of bound. We try to correct this here... */ + if ( length < 16 ) FT_INVALID_TOO_SHORT; + if ( table + length > valid->limit ) + { + if ( valid->level >= FT_VALIDATE_TIGHT ) + FT_INVALID_TOO_SHORT; + + length = (FT_UInt)( valid->limit - table ); + } + p = table + 6; num_segs = TT_NEXT_USHORT( p ); /* read segCountX2 */ @@ -680,7 +696,7 @@ FT_INVALID_DATA; } - if ( offset ) + if ( offset && offset != 0xFFFFU ) { p += offset; /* start of glyph id array */ @@ -692,10 +708,10 @@ /* check glyph indices within the segment range */ if ( valid->level >= FT_VALIDATE_TIGHT ) { - FT_UInt idx; + FT_UInt i, idx; - for ( ; start < end; ) + for ( i = start; i < end; i++ ) { idx = FT_NEXT_USHORT( p ); if ( idx != 0 ) @@ -708,6 +724,16 @@ } } } + else if ( offset == 0xFFFFU ) + { + /* Some fonts (erroneously?) use a range offset of 0xFFFF */ + /* to mean missing glyph in cmap table */ + /* */ + if ( valid->level >= FT_VALIDATE_PARANOID || + n != num_segs - 1 || + !( start == 0xFFFFU && end == 0xFFFFU && delta == 0x1U ) ) + FT_INVALID_DATA; + } last = end; } @@ -769,6 +795,9 @@ p += num_segs2; offset = TT_PEEK_USHORT( p ); + if ( offset == 0xFFFFU ) + goto Exit; + if ( offset != 0 ) { p += offset + 2 * ( idx - start ); @@ -813,6 +842,9 @@ p += num_segs2; offset = TT_PEEK_USHORT( p ); + if ( offset == 0xFFFFU ) + goto Exit; + if ( offset != 0 ) { p += offset + 2 * ( idx - start ); @@ -879,7 +911,7 @@ p += num_segs2; offset = TT_PEEK_USHORT( p ); - if ( offset != 0 ) + if ( offset != 0 && offset != 0xFFFFU ) { /* parse the glyph ids array for non-0 index */ p += offset + ( code - start ) * 2; @@ -895,6 +927,12 @@ code++; } } + else if ( offset == 0xFFFFU ) + { + /* an offset of 0xFFFF means an empty glyph in certain fonts! */ + code = end; + break; + } else gindex = (FT_UInt)( code + delta ) & 0xFFFFU; @@ -912,7 +950,7 @@ code++; } - return result; + return (FT_UInt)result; Exit: *pchar_code = result; @@ -1253,7 +1291,7 @@ if ( char_code <= end ) { - result = start_id + char_code - start; + result = (FT_UInt)( start_id + char_code - start ); break; } } @@ -1271,12 +1309,12 @@ FT_Byte* table = cmap->data; FT_Byte* p = table + 8204; FT_UInt32 num_groups = TT_NEXT_ULONG( p ); - FT_UInt32 n, start, end, start_id; + FT_UInt32 start, end, start_id; p = table + 8208; - for ( n = 0; n < num_groups++; n++ ) + for ( ; num_groups > 0; num_groups-- ) { start = TT_NEXT_ULONG( p ); end = TT_NEXT_ULONG( p ); @@ -1560,7 +1598,7 @@ if ( char_code <= end ) { - result = start_id + char_code - start; + result = (FT_UInt)( start_id + char_code - start ); break; } } @@ -1578,12 +1616,12 @@ FT_UInt gindex = 0; FT_Byte* p = table + 12; FT_UInt32 num_groups = TT_NEXT_ULONG( p ); - FT_UInt32 n, start, end, start_id; + FT_UInt32 start, end, start_id; p = table + 16; - for ( n = 0; n < num_groups++; n++ ) + for ( ; num_groups > 0; num_groups-- ) { start = TT_NEXT_ULONG( p ); end = TT_NEXT_ULONG( p ); @@ -1628,8 +1666,6 @@ #endif /* TT_CONFIG_CMAP_FORMAT_12 */ -#ifdef FT_CONFIG_OPTION_USE_CMAPS - static const TT_CMap_Class tt_cmap_classes[] = { #ifdef TT_CONFIG_CMAP_FORMAT_0 @@ -1668,12 +1704,12 @@ /* in the current face */ /* */ FT_LOCAL_DEF( FT_Error ) - TT_Build_CMaps( TT_Face face ) + tt_face_build_cmaps( TT_Face face ) { FT_Byte* table = face->cmap_table; FT_Byte* limit = table + face->cmap_size; - volatile FT_UInt num_cmaps; - volatile FT_Byte* p = table; + FT_UInt volatile num_cmaps; + FT_Byte* volatile p = table; if ( p + 4 > limit ) @@ -1683,7 +1719,7 @@ if ( TT_NEXT_USHORT( p ) != 0 ) { p -= 2; - FT_ERROR(( "TT_Build_CMaps: unsupported `cmap' table format = %d\n", + FT_ERROR(( "tt_face_build_cmaps: unsupported `cmap' table format = %d\n", TT_PEEK_USHORT( p ) )); return FT_Err_Invalid_Table; } @@ -1699,14 +1735,14 @@ charmap.platform_id = TT_NEXT_USHORT( p ); charmap.encoding_id = TT_NEXT_USHORT( p ); charmap.face = FT_FACE( face ); - charmap.encoding = ft_encoding_none; /* will be filled later */ + charmap.encoding = FT_ENCODING_NONE; /* will be filled later */ offset = TT_NEXT_ULONG( p ); if ( offset && table + offset + 2 < limit ) { FT_Byte* cmap = table + offset; FT_UInt format = TT_PEEK_USHORT( cmap ); - volatile const TT_CMap_Class* pclazz = tt_cmap_classes; + const TT_CMap_Class* volatile pclazz = tt_cmap_classes; TT_CMap_Class clazz; @@ -1721,7 +1757,7 @@ ft_validator_init( FT_VALIDATOR( &valid ), cmap, limit, FT_VALIDATE_DEFAULT ); - valid.num_glyphs = face->root.num_glyphs; + valid.num_glyphs = (FT_UInt)face->root.num_glyphs; if ( ft_setjmp( FT_VALIDATOR( &valid )->jump_buffer ) == 0 ) { @@ -1733,7 +1769,7 @@ (void)FT_CMap_New( (FT_CMap_Class)clazz, cmap, &charmap, NULL ); else { - FT_ERROR(( "TT_Build_CMaps:" )); + FT_ERROR(( "tt_face_build_cmaps:" )); FT_ERROR(( " broken cmap sub-table ignored!\n" )); } } @@ -1744,7 +1780,5 @@ return 0; } -#endif /* FT_CONFIG_OPTION_USE_CMAPS */ - /* END */ diff --git a/src/libs/freetype2/sfnt/ttcmap0.h b/src/libs/freetype2/sfnt/ttcmap0.h index a37e909c69f..ff1276e09b0 100644 --- a/src/libs/freetype2/sfnt/ttcmap0.h +++ b/src/libs/freetype2/sfnt/ttcmap0.h @@ -54,7 +54,7 @@ FT_BEGIN_HEADER { FT_ValidatorRec validator; FT_UInt num_glyphs; - + } TT_ValidatorRec, *TT_Validator; @@ -62,12 +62,8 @@ FT_BEGIN_HEADER #define TT_VALID_GLYPH_COUNT( x ) TT_VALIDATOR( x )->num_glyphs -#ifdef FT_CONFIG_OPTION_USE_CMAPS - FT_LOCAL( FT_Error ) - TT_Build_CMaps( TT_Face face ); - -#endif + tt_face_build_cmaps( TT_Face face ); FT_END_HEADER diff --git a/src/libs/freetype2/sfnt/ttload.c b/src/libs/freetype2/sfnt/ttload.c index e3dada29619..669f365e488 100644 --- a/src/libs/freetype2/sfnt/ttload.c +++ b/src/libs/freetype2/sfnt/ttload.c @@ -40,7 +40,7 @@ /*************************************************************************/ /* */ /* <Function> */ - /* TT_LookUp_Table */ + /* tt_face_lookup_table */ /* */ /* <Description> */ /* Looks for a TrueType table by name. */ @@ -54,14 +54,14 @@ /* A pointer to the table directory entry. 0 if not found. */ /* */ FT_LOCAL_DEF( TT_Table ) - TT_LookUp_Table( TT_Face face, - FT_ULong tag ) + tt_face_lookup_table( TT_Face face, + FT_ULong tag ) { TT_Table entry; TT_Table limit; - FT_TRACE3(( "TT_LookUp_Table: %08p, `%c%c%c%c' -- ", + FT_TRACE3(( "tt_face_lookup_table: %08p, `%c%c%c%c' -- ", face, (FT_Char)( tag >> 24 ), (FT_Char)( tag >> 16 ), @@ -90,7 +90,7 @@ /*************************************************************************/ /* */ /* <Function> */ - /* TT_Goto_Table */ + /* tt_face_goto_table */ /* */ /* <Description> */ /* Looks for a TrueType table by name, then seek a stream to it. */ @@ -109,16 +109,16 @@ /* FreeType error code. 0 means success. */ /* */ FT_LOCAL_DEF( FT_Error ) - TT_Goto_Table( TT_Face face, - FT_ULong tag, - FT_Stream stream, - FT_ULong* length ) + tt_face_goto_table( TT_Face face, + FT_ULong tag, + FT_Stream stream, + FT_ULong* length ) { TT_Table table; FT_Error error; - table = TT_LookUp_Table( face, tag ); + table = tt_face_lookup_table( face, tag ); if ( table ) { if ( length ) @@ -135,10 +135,111 @@ } + /* In theory, we should check the values of `search_range', */ + /* `entry_selector', and `range_shift' to detect non-SFNT based files */ + /* whose header might also start with 0x100000L (yes, these exist). */ + /* */ + /* Very unfortunately, many TrueType fonts don't have these fields */ + /* set correctly and we must ignore them to support them. An alternative */ + /* way to check the font file is thus to: */ + /* */ + /* - check that `num_tables' is valid */ + /* - look for a "head" table, check its size, and parse it to */ + /* see if its "magic" field is correctly set */ + /* */ + /* When checking directory entries, ignore the tables `glyx' and `locx' */ + /* which are hacked-out versions of `glyf' and `loca' in some PostScript */ + /* Type 42 fonts, and will generally be invalid. */ + /* */ + static FT_Error + sfnt_dir_check( FT_Stream stream, + FT_ULong offset, + FT_UInt num_tables ) + { + FT_Error error; + FT_UInt nn, has_head = 0; + + const FT_ULong glyx_tag = FT_MAKE_TAG( 'g', 'l', 'y', 'x' ); + const FT_ULong locx_tag = FT_MAKE_TAG( 'l', 'o', 'c', 'x' ); + + static const FT_Frame_Field sfnt_dir_entry_fields[] = + { +#undef FT_STRUCTURE +#define FT_STRUCTURE TT_TableRec + + FT_FRAME_START( 16 ), + FT_FRAME_ULONG( Tag ), + FT_FRAME_ULONG( CheckSum ), + FT_FRAME_ULONG( Offset ), + FT_FRAME_ULONG( Length ), + FT_FRAME_END + }; + + + /* if 'num_tables' is 0, read the table count from the file */ + if ( num_tables == 0 ) + { + FT_ULong format_tag; + + + if ( FT_STREAM_SEEK( offset ) || + FT_READ_ULONG ( format_tag ) || + FT_READ_USHORT( num_tables ) || + FT_STREAM_SKIP( 6 ) ) + goto Bad_Format; + + if ( offset + 12 + num_tables*16 > stream->size ) + goto Bad_Format; + } + else if ( FT_STREAM_SEEK( offset + 12 ) ) + goto Bad_Format; + + for ( nn = 0; nn < num_tables; nn++ ) + { + TT_TableRec table; + + + if ( FT_STREAM_READ_FIELDS( sfnt_dir_entry_fields, &table ) ) + goto Bad_Format; + + if ( table.Offset + table.Length > stream->size && + table.Tag != glyx_tag && table.Tag != locx_tag ) + goto Bad_Format; + + if ( table.Tag == TTAG_head ) + { + FT_UInt32 magic; + + + has_head = 1; + + if ( table.Length != 0x36 || + FT_STREAM_SEEK( table.Offset + 12 ) || + FT_READ_ULONG( magic ) || + magic != 0x5F0F3CF5UL ) + goto Bad_Format; + + if ( FT_STREAM_SEEK( offset + 28 + 16*nn ) ) + goto Bad_Format; + } + } + + if ( has_head == 0 ) + goto Bad_Format; + + Exit: + return error; + + Bad_Format: + error = FT_Err_Unknown_File_Format; + goto Exit; + } + + /*************************************************************************/ /* */ /* <Function> */ - /* TT_Load_SFNT_HeaderRec */ + /* tt_face_load_sfnt_header */ /* */ /* <Description> */ /* Loads the header of a SFNT font file. Supports collections. */ @@ -166,16 +267,16 @@ /* values of `search_range', `entry_selector', and `range_shift'. */ /* */ FT_LOCAL_DEF( FT_Error ) - TT_Load_SFNT_HeaderRec( TT_Face face, - FT_Stream stream, - FT_Long face_index, - SFNT_Header sfnt ) + tt_face_load_sfnt_header( TT_Face face, + FT_Stream stream, + FT_Long face_index, + SFNT_Header sfnt ) { FT_Error error; - FT_ULong format_tag; + FT_ULong format_tag, offset; FT_Memory memory = stream->memory; - const FT_Frame_Field sfnt_header_fields[] = + static const FT_Frame_Field sfnt_header_fields[] = { #undef FT_STRUCTURE #define FT_STRUCTURE SFNT_HeaderRec @@ -188,7 +289,7 @@ FT_FRAME_END }; - const FT_Frame_Field ttc_header_fields[] = + static const FT_Frame_Field ttc_header_fields[] = { #undef FT_STRUCTURE #define FT_STRUCTURE TTC_HeaderRec @@ -200,7 +301,7 @@ }; - FT_TRACE2(( "TT_Load_SFNT_HeaderRec: %08p, %ld\n", + FT_TRACE2(( "tt_face_load_sfnt_header: %08p, %ld\n", face, face_index )); face->ttc_header.tag = 0; @@ -213,6 +314,8 @@ /* file is a TrueType collection, otherwise it can be any other */ /* kind of font. */ /* */ + offset = FT_STREAM_POS(); + if ( FT_READ_ULONG( format_tag ) ) goto Exit; @@ -221,7 +324,7 @@ FT_Int n; - FT_TRACE3(( "TT_Load_SFNT_HeaderRec: file is a collection\n" )); + FT_TRACE3(( "tt_face_load_sfnt_header: file is a collection\n" )); /* It is a TrueType collection, i.e. a file containing several */ /* font files. Read the font directory now */ @@ -246,32 +349,26 @@ } /* seek to the appropriate TrueType file, then read tag */ - if ( FT_STREAM_SEEK( face->ttc_header.offsets[face_index] ) || + offset = face->ttc_header.offsets[face_index]; + + if ( FT_STREAM_SEEK( offset ) || FT_READ_LONG( format_tag ) ) goto Exit; } /* the format tag was read, now check the rest of the header */ sfnt->format_tag = format_tag; + sfnt->offset = offset; + if ( FT_STREAM_READ_FIELDS( sfnt_header_fields, sfnt ) ) goto Exit; - /* now, check the values of `num_tables', `seach_range', etc. */ + /* now check the sfnt directory */ + error = sfnt_dir_check( stream, offset, sfnt->num_tables ); + if ( error ) { - FT_UInt num_tables = sfnt->num_tables; - FT_ULong entry_selector = 1L << sfnt->entry_selector; - - - /* IMPORTANT: Many fonts have an incorrect `search_range' value, so */ - /* we only check the `entry_selector' correctness here. */ - /* */ - if ( num_tables == 0 || - entry_selector > num_tables || - entry_selector * 2 <= num_tables ) - { - FT_TRACE2(( "TT_Load_SFNT_HeaderRec: file is not SFNT!\n" )); - error = SFNT_Err_Unknown_File_Format; - } + FT_TRACE2(( "tt_face_load_sfnt_header: file is not SFNT!\n" )); + error = SFNT_Err_Unknown_File_Format; } Exit: @@ -282,7 +379,7 @@ /*************************************************************************/ /* */ /* <Function> */ - /* TT_Load_Directory */ + /* tt_face_load_directory */ /* */ /* <Description> */ /* Loads the table directory into a face object. */ @@ -302,9 +399,9 @@ /* The stream cursor must be at the font file's origin. */ /* */ FT_LOCAL_DEF( FT_Error ) - TT_Load_Directory( TT_Face face, - FT_Stream stream, - SFNT_Header sfnt ) + tt_face_load_directory( TT_Face face, + FT_Stream stream, + SFNT_Header sfnt ) { FT_Error error; FT_Memory memory = stream->memory; @@ -312,7 +409,7 @@ TT_TableRec *entry, *limit; - FT_TRACE2(( "TT_Load_Directory: %08p\n", face )); + FT_TRACE2(( "tt_face_load_directory: %08p\n", face )); FT_TRACE2(( "-- Tables count: %12u\n", sfnt->num_tables )); FT_TRACE2(( "-- Format version: %08lx\n", sfnt->format_tag )); @@ -322,7 +419,8 @@ if ( FT_NEW_ARRAY( face->dir_tables, face->num_tables ) ) goto Exit; - if ( FT_FRAME_ENTER( face->num_tables * 16L ) ) + if ( FT_STREAM_SEEK( sfnt->offset + 12 ) || + FT_FRAME_ENTER( face->num_tables * 16L ) ) goto Exit; entry = face->dir_tables; @@ -356,7 +454,7 @@ /*************************************************************************/ /* */ /* <Function> */ - /* TT_Load_Any */ + /* tt_face_load_any */ /* */ /* <Description> */ /* Loads any font table into client memory. */ @@ -394,11 +492,11 @@ /* FreeType error code. 0 means success. */ /* */ FT_LOCAL_DEF( FT_Error ) - TT_Load_Any( TT_Face face, - FT_ULong tag, - FT_Long offset, - FT_Byte* buffer, - FT_ULong* length ) + tt_face_load_any( TT_Face face, + FT_ULong tag, + FT_Long offset, + FT_Byte* buffer, + FT_ULong* length ) { FT_Error error; FT_Stream stream; @@ -409,7 +507,7 @@ if ( tag != 0 ) { /* look for tag in font directory */ - table = TT_LookUp_Table( face, tag ); + table = tt_face_lookup_table( face, tag ); if ( !table ) { error = SFNT_Err_Table_Missing; @@ -446,7 +544,7 @@ /*************************************************************************/ /* */ /* <Function> */ - /* TT_Load_Generic_Header */ + /* tt_face_load_generic_header */ /* */ /* <Description> */ /* Loads the TrueType table `head' or `bhed'. */ @@ -460,9 +558,9 @@ /* FreeType error code. 0 means success. */ /* */ static FT_Error - TT_Load_Generic_Header( TT_Face face, - FT_Stream stream, - FT_ULong tag ) + tt_face_load_generic_header( TT_Face face, + FT_Stream stream, + FT_ULong tag ) { FT_Error error; TT_Header* header; @@ -496,7 +594,7 @@ }; - FT_TRACE2(( "TT_Load_Generic_Header: " + FT_TRACE2(( "tt_face_load_generic_header: " "%08p, looking up font table `%c%c%c%c'.\n", face, (FT_Char)( tag >> 24 ), @@ -507,7 +605,7 @@ error = face->goto_table( face, tag, stream, 0 ); if ( error ) { - FT_TRACE2(( "TT_Load_Generic_Header: Font table is missing!\n" )); + FT_TRACE2(( "tt_face_load_generic_header: Font table is missing!\n" )); goto Exit; } @@ -518,7 +616,7 @@ FT_TRACE2(( " Units per EM: %8u\n", header->Units_Per_EM )); FT_TRACE2(( " IndexToLoc: %8d\n", header->Index_To_Loc_Format )); - FT_TRACE2(( "TT_Load_Generic_Header: Font table loaded.\n" )); + FT_TRACE2(( "tt_face_load_generic_header: Font table loaded.\n" )); Exit: return error; @@ -526,20 +624,20 @@ FT_LOCAL_DEF( FT_Error ) - TT_Load_Header( TT_Face face, - FT_Stream stream ) + tt_face_load_header( TT_Face face, + FT_Stream stream ) { - return TT_Load_Generic_Header( face, stream, TTAG_head ); + return tt_face_load_generic_header( face, stream, TTAG_head ); } #ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS FT_LOCAL_DEF( FT_Error ) - TT_Load_Bitmap_Header( TT_Face face, - FT_Stream stream ) + tt_face_load_bitmap_header( TT_Face face, + FT_Stream stream ) { - return TT_Load_Generic_Header( face, stream, TTAG_bhed ); + return tt_face_load_generic_header( face, stream, TTAG_bhed ); } #endif /* TT_CONFIG_OPTION_EMBEDDED_BITMAPS */ @@ -548,7 +646,7 @@ /*************************************************************************/ /* */ /* <Function> */ - /* TT_Load_MaxProfile */ + /* tt_face_load_max_profile */ /* */ /* <Description> */ /* Loads the maximum profile into a face object. */ @@ -562,8 +660,8 @@ /* FreeType error code. 0 means success. */ /* */ FT_LOCAL_DEF( FT_Error ) - TT_Load_MaxProfile( TT_Face face, - FT_Stream stream ) + tt_face_load_max_profile( TT_Face face, + FT_Stream stream ) { FT_Error error; TT_MaxProfile* maxProfile = &face->max_profile; @@ -670,7 +768,7 @@ /*************************************************************************/ /* */ /* <Function> */ - /* TT_Load_Metrics */ + /* tt_face_load_metrics */ /* */ /* <Description> */ /* Loads the horizontal or vertical metrics table into a face object. */ @@ -686,9 +784,9 @@ /* FreeType error code. 0 means success. */ /* */ static FT_Error - TT_Load_Metrics( TT_Face face, - FT_Stream stream, - FT_Bool vertical ) + tt_face_load_metrics( TT_Face face, + FT_Stream stream, + FT_Bool vertical ) { FT_Error error; FT_Memory memory = stream->memory; @@ -813,7 +911,7 @@ /*************************************************************************/ /* */ /* <Function> */ - /* TT_Load_Metrics_Header */ + /* tt_face_load_metrics_header */ /* */ /* <Description> */ /* Loads the horizontal or vertical header in a face object. */ @@ -829,9 +927,9 @@ /* FreeType error code. 0 means success. */ /* */ FT_LOCAL_DEF( FT_Error ) - TT_Load_Metrics_Header( TT_Face face, - FT_Stream stream, - FT_Bool vertical ) + tt_face_load_metrics_header( TT_Face face, + FT_Stream stream, + FT_Bool vertical ) { FT_Error error; TT_HoriHeader* header; @@ -905,7 +1003,7 @@ /* Now try to load the corresponding metrics */ - error = TT_Load_Metrics( face, stream, vertical ); + error = tt_face_load_metrics( face, stream, vertical ); Exit: return error; @@ -915,7 +1013,7 @@ /*************************************************************************/ /* */ /* <Function> */ - /* TT_Load_Names */ + /* tt_face_load_names */ /* */ /* <Description> */ /* Loads the name records. */ @@ -929,8 +1027,8 @@ /* FreeType error code. 0 means success. */ /* */ FT_LOCAL_DEF( FT_Error ) - TT_Load_Names( TT_Face face, - FT_Stream stream ) + tt_face_load_names( TT_Face face, + FT_Stream stream ) { FT_Error error; FT_Memory memory = stream->memory; @@ -999,7 +1097,7 @@ if ( storage_start > storage_limit ) { - FT_ERROR(( "TT_Load_Names: invalid `name' table\n" )); + FT_ERROR(( "tt_face_load_names: invalid `name' table\n" )); error = SFNT_Err_Name_Table_Missing; goto Exit; } @@ -1041,7 +1139,7 @@ entry++; } - table->numNameRecords = entry - table->names; + table->numNameRecords = (FT_UInt)( entry - table->names ); } FT_FRAME_EXIT(); @@ -1059,7 +1157,7 @@ /*************************************************************************/ /* */ /* <Function> */ - /* TT_Free_Names */ + /* tt_face_free_names */ /* */ /* <Description> */ /* Frees the name records. */ @@ -1068,7 +1166,7 @@ /* face :: A handle to the target face object. */ /* */ FT_LOCAL_DEF( void ) - TT_Free_Names( TT_Face face ) + tt_face_free_names( TT_Face face ) { FT_Memory memory = face->root.driver->root.memory; TT_NameTable table = &face->name_table; @@ -1094,7 +1192,7 @@ /*************************************************************************/ /* */ /* <Function> */ - /* TT_Load_CMap */ + /* tt_face_load_cmap */ /* */ /* <Description> */ /* Loads the cmap directory in a face object. The cmaps itselves are */ @@ -1109,11 +1207,9 @@ /* FreeType error code. 0 means success. */ /* */ -#ifdef FT_CONFIG_OPTION_USE_CMAPS - FT_LOCAL_DEF( FT_Error ) - TT_Load_CMap( TT_Face face, - FT_Stream stream ) + tt_face_load_cmap( TT_Face face, + FT_Stream stream ) { FT_Error error; @@ -1138,111 +1234,12 @@ return error; } -#else /* !FT_CONFIG_OPTION_USE_CMAPS */ - - FT_LOCAL_DEF( FT_Error ) - TT_Load_CMap( TT_Face face, - FT_Stream stream ) - { - FT_Error error; - FT_Memory memory = stream->memory; - FT_Long table_start; - TT_CMapDirRec cmap_dir; - - const FT_Frame_Field cmap_fields[] = - { -#undef FT_STRUCTURE -#define FT_STRUCTURE TT_CMapDirRec - - FT_FRAME_START( 4 ), - FT_FRAME_USHORT( tableVersionNumber ), - FT_FRAME_USHORT( numCMaps ), - FT_FRAME_END - }; - - const FT_Frame_Field cmap_rec_fields[] = - { -#undef FT_STRUCTURE -#define FT_STRUCTURE TT_CMapTableRec - - FT_FRAME_START( 4 ), - FT_FRAME_USHORT( format ), - FT_FRAME_USHORT( length ), - FT_FRAME_END - }; - - - FT_TRACE2(( "CMaps " )); - - error = face->goto_table( face, TTAG_cmap, stream, 0 ); - if ( error ) - { - error = SFNT_Err_CMap_Table_Missing; - goto Exit; - } - - table_start = FT_STREAM_POS(); - - if ( FT_STREAM_READ_FIELDS( cmap_fields, &cmap_dir ) ) - goto Exit; - - /* reserve space in face table for cmap tables */ - if ( FT_NEW_ARRAY( face->charmaps, cmap_dir.numCMaps ) ) - goto Exit; - - face->num_charmaps = cmap_dir.numCMaps; - { - TT_CharMap charmap = face->charmaps; - TT_CharMap limit = charmap + face->num_charmaps; - - - /* read the header of each charmap first */ - if ( FT_FRAME_ENTER( face->num_charmaps * 8L ) ) - goto Exit; - - for ( ; charmap < limit; charmap++ ) - { - TT_CMapTable cmap; - - - charmap->root.face = (FT_Face)face; - cmap = &charmap->cmap; - - cmap->loaded = FALSE; - cmap->platformID = FT_GET_USHORT(); - cmap->platformEncodingID = FT_GET_USHORT(); - cmap->offset = (FT_ULong)FT_GET_LONG(); - } - - FT_FRAME_EXIT(); - - /* now read the rest of each table */ - for ( charmap = face->charmaps; charmap < limit; charmap++ ) - { - TT_CMapTable cmap = &charmap->cmap; - - - if ( FT_STREAM_SEEK( table_start + (FT_Long)cmap->offset ) || - FT_STREAM_READ_FIELDS( cmap_rec_fields, cmap ) ) - goto Exit; - - cmap->offset = FT_STREAM_POS(); - } - } - - FT_TRACE2(( "loaded\n" )); - - Exit: - return error; - } - -#endif /* !FT_CONFIG_OPTION_USE_CMAPS */ /*************************************************************************/ /* */ /* <Function> */ - /* TT_Load_OS2 */ + /* tt_face_load_os2 */ /* */ /* <Description> */ /* Loads the OS2 table. */ @@ -1256,8 +1253,8 @@ /* FreeType error code. 0 means success. */ /* */ FT_LOCAL_DEF( FT_Error ) - TT_Load_OS2( TT_Face face, - FT_Stream stream ) + tt_face_load_os2( TT_Face face, + FT_Stream stream ) { FT_Error error; TT_OS2* os2; @@ -1385,7 +1382,7 @@ /*************************************************************************/ /* */ /* <Function> */ - /* TT_Load_Postscript */ + /* tt_face_load_postscript */ /* */ /* <Description> */ /* Loads the Postscript table. */ @@ -1399,8 +1396,8 @@ /* FreeType error code. 0 means success. */ /* */ FT_LOCAL_DEF( FT_Error ) - TT_Load_PostScript( TT_Face face, - FT_Stream stream ) + tt_face_load_postscript( TT_Face face, + FT_Stream stream ) { FT_Error error; TT_Postscript* post = &face->postscript; @@ -1444,7 +1441,7 @@ /*************************************************************************/ /* */ /* <Function> */ - /* TT_Load_PCLT */ + /* tt_face_load_pclt */ /* */ /* <Description> */ /* Loads the PCL 5 Table. */ @@ -1458,8 +1455,8 @@ /* FreeType error code. 0 means success. */ /* */ FT_LOCAL_DEF( FT_Error ) - TT_Load_PCLT( TT_Face face, - FT_Stream stream ) + tt_face_load_pclt( TT_Face face, + FT_Stream stream ) { static const FT_Frame_Field pclt_fields[] = { @@ -1512,7 +1509,7 @@ /*************************************************************************/ /* */ /* <Function> */ - /* TT_Load_Gasp */ + /* tt_face_load_gasp */ /* */ /* <Description> */ /* Loads the `gasp' table into a face object. */ @@ -1526,8 +1523,8 @@ /* FreeType error code. 0 means success. */ /* */ FT_LOCAL_DEF( FT_Error ) - TT_Load_Gasp( TT_Face face, - FT_Stream stream ) + tt_face_load_gasp( TT_Face face, + FT_Stream stream ) { FT_Error error; FT_Memory memory = stream->memory; @@ -1536,7 +1533,7 @@ TT_GaspRange gaspranges; - FT_TRACE2(( "TT_Load_Gasp: %08p\n", face )); + FT_TRACE2(( "tt_face_load_gasp: %08p\n", face )); /* the gasp table is optional */ error = face->goto_table( face, TTAG_gasp, stream, 0 ); @@ -1587,7 +1584,7 @@ /*************************************************************************/ /* */ /* <Function> */ - /* TT_Load_Kern */ + /* tt_face_load_kern */ /* */ /* <Description> */ /* Loads the first kerning table with format 0 in the font. Only */ @@ -1604,8 +1601,8 @@ /* FreeType error code. 0 means success. */ /* */ FT_LOCAL_DEF( FT_Error ) - TT_Load_Kern( TT_Face face, - FT_Stream stream ) + tt_face_load_kern( TT_Face face, + FT_Stream stream ) { FT_Error error; FT_Memory memory = stream->memory; @@ -1740,7 +1737,7 @@ /*************************************************************************/ /* */ /* <Function> */ - /* TT_Load_Hdmx */ + /* tt_face_load_hdmx */ /* */ /* <Description> */ /* Loads the horizontal device metrics table. */ @@ -1754,8 +1751,8 @@ /* FreeType error code. 0 means success. */ /* */ FT_LOCAL_DEF( FT_Error ) - TT_Load_Hdmx( TT_Face face, - FT_Stream stream ) + tt_face_load_hdmx( TT_Face face, + FT_Stream stream ) { FT_Error error; FT_Memory memory = stream->memory; @@ -1823,7 +1820,7 @@ /*************************************************************************/ /* */ /* <Function> */ - /* TT_Free_Hdmx */ + /* tt_face_free_hdmx */ /* */ /* <Description> */ /* Frees the horizontal device metrics table. */ @@ -1832,7 +1829,7 @@ /* face :: A handle to the target face object. */ /* */ FT_LOCAL_DEF( void ) - TT_Free_Hdmx( TT_Face face ) + tt_face_free_hdmx( TT_Face face ) { if ( face ) { diff --git a/src/libs/freetype2/sfnt/ttload.h b/src/libs/freetype2/sfnt/ttload.h index 67ec052fd62..27c41b50b9f 100644 --- a/src/libs/freetype2/sfnt/ttload.h +++ b/src/libs/freetype2/sfnt/ttload.h @@ -30,101 +30,101 @@ FT_BEGIN_HEADER FT_LOCAL( TT_Table ) - TT_LookUp_Table( TT_Face face, - FT_ULong tag ); + tt_face_lookup_table( TT_Face face, + FT_ULong tag ); FT_LOCAL( FT_Error ) - TT_Goto_Table( TT_Face face, - FT_ULong tag, - FT_Stream stream, - FT_ULong* length ); + tt_face_goto_table( TT_Face face, + FT_ULong tag, + FT_Stream stream, + FT_ULong* length ); FT_LOCAL( FT_Error ) - TT_Load_SFNT_HeaderRec( TT_Face face, - FT_Stream stream, - FT_Long face_index, - SFNT_Header sfnt ); + tt_face_load_sfnt_header( TT_Face face, + FT_Stream stream, + FT_Long face_index, + SFNT_Header sfnt ); FT_LOCAL( FT_Error ) - TT_Load_Directory( TT_Face face, - FT_Stream stream, - SFNT_Header sfnt ); + tt_face_load_directory( TT_Face face, + FT_Stream stream, + SFNT_Header sfnt ); FT_LOCAL( FT_Error ) - TT_Load_Any( TT_Face face, - FT_ULong tag, - FT_Long offset, - FT_Byte* buffer, - FT_ULong* length ); + tt_face_load_any( TT_Face face, + FT_ULong tag, + FT_Long offset, + FT_Byte* buffer, + FT_ULong* length ); FT_LOCAL( FT_Error ) - TT_Load_Header( TT_Face face, - FT_Stream stream ); + tt_face_load_header( TT_Face face, + FT_Stream stream ); FT_LOCAL( FT_Error ) - TT_Load_Metrics_Header( TT_Face face, - FT_Stream stream, - FT_Bool vertical ); + tt_face_load_metrics_header( TT_Face face, + FT_Stream stream, + FT_Bool vertical ); FT_LOCAL( FT_Error ) - TT_Load_CMap( TT_Face face, - FT_Stream stream ); + tt_face_load_cmap( TT_Face face, + FT_Stream stream ); FT_LOCAL( FT_Error ) - TT_Load_MaxProfile( TT_Face face, - FT_Stream stream ); + tt_face_load_max_profile( TT_Face face, + FT_Stream stream ); FT_LOCAL( FT_Error ) - TT_Load_Names( TT_Face face, - FT_Stream stream ); + tt_face_load_names( TT_Face face, + FT_Stream stream ); FT_LOCAL( FT_Error ) - TT_Load_OS2( TT_Face face, - FT_Stream stream ); + tt_face_load_os2( TT_Face face, + FT_Stream stream ); FT_LOCAL( FT_Error ) - TT_Load_PostScript( TT_Face face, - FT_Stream stream ); + tt_face_load_postscript( TT_Face face, + FT_Stream stream ); FT_LOCAL( FT_Error ) - TT_Load_Hdmx( TT_Face face, - FT_Stream stream ); + tt_face_load_hdmx( TT_Face face, + FT_Stream stream ); FT_LOCAL( FT_Error ) - TT_Load_PCLT( TT_Face face, - FT_Stream stream ); + tt_face_load_pclt( TT_Face face, + FT_Stream stream ); FT_LOCAL( void ) - TT_Free_Names( TT_Face face ); + tt_face_free_names( TT_Face face ); FT_LOCAL( void ) - TT_Free_Hdmx ( TT_Face face ); + tt_face_free_hdmx ( TT_Face face ); FT_LOCAL( FT_Error ) - TT_Load_Kern( TT_Face face, - FT_Stream stream ); + tt_face_load_kern( TT_Face face, + FT_Stream stream ); FT_LOCAL( FT_Error ) - TT_Load_Gasp( TT_Face face, - FT_Stream stream ); + tt_face_load_gasp( TT_Face face, + FT_Stream stream ); #ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS FT_LOCAL( FT_Error ) - TT_Load_Bitmap_Header( TT_Face face, - FT_Stream stream ); + tt_face_load_bitmap_header( TT_Face face, + FT_Stream stream ); #endif /* TT_CONFIG_OPTION_EMBEDDED_BITMAPS */ diff --git a/src/libs/freetype2/sfnt/ttpost.c b/src/libs/freetype2/sfnt/ttpost.c index 686a9876415..486ba3dd255 100644 --- a/src/libs/freetype2/sfnt/ttpost.c +++ b/src/libs/freetype2/sfnt/ttpost.c @@ -62,11 +62,11 @@ /* table of Mac names. Thus, it is possible to build a version of */ /* FreeType without the Type 1 driver & PSNames module. */ -#define MAC_NAME( x ) TT_Post_Default_Names[x] +#define MAC_NAME( x ) tt_post_default_names[x] /* the 258 default Mac PS glyph names */ - FT_String* TT_Post_Default_Names[258] = + static const FT_String* tt_post_default_names[258] = { /* 0 */ ".notdef", ".null", "CR", "space", "exclam", @@ -153,7 +153,7 @@ static FT_Error - Load_Format_20( TT_Face face, + load_format_20( TT_Face face, FT_Stream stream ) { FT_Memory memory = stream->memory; @@ -271,7 +271,7 @@ static FT_Error - Load_Format_25( TT_Face face, + load_format_25( TT_Face face, FT_Stream stream ) { FT_Memory memory = stream->memory; @@ -334,7 +334,7 @@ static FT_Error - Load_Post_Names( TT_Face face ) + load_post_names( TT_Face face ) { FT_Stream stream; FT_Error error; @@ -356,19 +356,12 @@ goto Exit; /* now read postscript table */ - switch ( format ) - { - case 0x00020000L: - error = Load_Format_20( face, stream ); - break; - - case 0x00028000L: - error = Load_Format_25( face, stream ); - break; - - default: + if ( format == 0x00020000L ) + error = load_format_20( face, stream ); + else if ( format == 0x00028000L ) + error = load_format_25( face, stream ); + else error = SFNT_Err_Invalid_File_Format; - } face->postscript_names.loaded = 1; @@ -378,42 +371,39 @@ FT_LOCAL_DEF( void ) - TT_Free_Post_Names( TT_Face face ) + tt_face_free_ps_names( TT_Face face ) { FT_Memory memory = face->root.memory; TT_Post_Names names = &face->postscript_names; + FT_Fixed format; if ( names->loaded ) { - switch ( face->postscript.FormatType ) - { - case 0x00020000L: - { - TT_Post_20 table = &names->names.format_20; - FT_UShort n; + format = face->postscript.FormatType; + if ( format == 0x00020000L ) + { + TT_Post_20 table = &names->names.format_20; + FT_UShort n; - FT_FREE( table->glyph_indices ); - table->num_glyphs = 0; - for ( n = 0; n < table->num_names; n++ ) - FT_FREE( table->glyph_names[n] ); + FT_FREE( table->glyph_indices ); + table->num_glyphs = 0; - FT_FREE( table->glyph_names ); - table->num_names = 0; - } - break; + for ( n = 0; n < table->num_names; n++ ) + FT_FREE( table->glyph_names[n] ); - case 0x00028000L: - { - TT_Post_25 table = &names->names.format_25; + FT_FREE( table->glyph_names ); + table->num_names = 0; + } + else if ( format == 0x00028000L ) + { + TT_Post_25 table = &names->names.format_25; - FT_FREE( table->offsets ); - table->num_glyphs = 0; - } - break; + FT_FREE( table->offsets ); + table->num_glyphs = 0; } } names->loaded = 0; @@ -423,7 +413,7 @@ /*************************************************************************/ /* */ /* <Function> */ - /* TT_Get_PS_Name */ + /* tt_face_get_ps_name */ /* */ /* <Description> */ /* Gets the PostScript glyph name of a glyph. */ @@ -442,12 +432,13 @@ /* FreeType error code. 0 means success. */ /* */ FT_LOCAL_DEF( FT_Error ) - TT_Get_PS_Name( TT_Face face, - FT_UInt idx, - FT_String** PSname ) + tt_face_get_ps_name( TT_Face face, + FT_UInt idx, + FT_String** PSname ) { FT_Error error; TT_Post_Names names; + FT_Fixed format; #ifdef FT_CONFIG_OPTION_POSTSCRIPT_NAMES PSNames_Service psnames; @@ -471,62 +462,58 @@ /* `.notdef' by default */ *PSname = MAC_NAME( 0 ); - switch ( face->postscript.FormatType ) + format = face->postscript.FormatType; + + if ( format == 0x00010000L ) { - case 0x00010000L: if ( idx < 258 ) /* paranoid checking */ *PSname = MAC_NAME( idx ); - break; + } + else if ( format == 0x00020000L ) + { + TT_Post_20 table = &names->names.format_20; - case 0x00020000L: + + if ( !names->loaded ) { - TT_Post_20 table = &names->names.format_20; + error = load_post_names( face ); + if ( error ) + goto End; + } + if ( idx < (FT_UInt)table->num_glyphs ) + { + FT_UShort name_index = table->glyph_indices[idx]; - if ( !names->loaded ) - { - error = Load_Post_Names( face ); - if ( error ) - break; - } - if ( idx < (FT_UInt)table->num_glyphs ) - { - FT_UShort name_index = table->glyph_indices[idx]; + if ( name_index < 258 ) + *PSname = MAC_NAME( name_index ); + else + *PSname = (FT_String*)table->glyph_names[name_index - 258]; + } + } + else if ( format == 0x00028000L ) + { + TT_Post_25 table = &names->names.format_25; - if ( name_index < 258 ) - *PSname = MAC_NAME( name_index ); - else - *PSname = (FT_String*)table->glyph_names[name_index - 258]; - } + if ( !names->loaded ) + { + error = load_post_names( face ); + if ( error ) + goto End; } - break; - case 0x00028000L: + if ( idx < (FT_UInt)table->num_glyphs ) /* paranoid checking */ { - TT_Post_25 table = &names->names.format_25; - - - if ( !names->loaded ) - { - error = Load_Post_Names( face ); - if ( error ) - break; - } - - if ( idx < (FT_UInt)table->num_glyphs ) /* paranoid checking */ - { - idx += table->offsets[idx]; - *PSname = MAC_NAME( idx ); - } + idx += table->offsets[idx]; + *PSname = MAC_NAME( idx ); } - break; - - case 0x00030000L: - break; /* nothing to do */ } + + /* nothing to do for format == 0x00030000L */ + End: return SFNT_Err_Ok; } diff --git a/src/libs/freetype2/sfnt/ttpost.h b/src/libs/freetype2/sfnt/ttpost.h index 57b1c8c70a5..6f06d75a719 100644 --- a/src/libs/freetype2/sfnt/ttpost.h +++ b/src/libs/freetype2/sfnt/ttpost.h @@ -30,12 +30,12 @@ FT_BEGIN_HEADER FT_LOCAL( FT_Error ) - TT_Get_PS_Name( TT_Face face, - FT_UInt idx, - FT_String** PSname ); + tt_face_get_ps_name( TT_Face face, + FT_UInt idx, + FT_String** PSname ); FT_LOCAL( void ) - TT_Free_Post_Names( TT_Face face ); + tt_face_free_ps_names( TT_Face face ); FT_END_HEADER diff --git a/src/libs/freetype2/sfnt/ttsbit.c b/src/libs/freetype2/sfnt/ttsbit.c index d72c83d9214..a554060d19e 100644 --- a/src/libs/freetype2/sfnt/ttsbit.c +++ b/src/libs/freetype2/sfnt/ttsbit.c @@ -377,7 +377,7 @@ /*************************************************************************/ /* */ /* <Function> */ - /* TT_Load_SBit_Strikes */ + /* tt_face_load_sbit_strikes */ /* */ /* <Description> */ /* Loads the table of embedded bitmap sizes for this face. */ @@ -391,8 +391,8 @@ /* FreeType error code. 0 means success. */ /* */ FT_LOCAL_DEF( FT_Error ) - TT_Load_SBit_Strikes( TT_Face face, - FT_Stream stream ) + tt_face_load_sbit_strikes( TT_Face face, + FT_Stream stream ) { FT_Error error = 0; FT_Memory memory = stream->memory; @@ -471,7 +471,7 @@ if ( version != 0x00020000L || num_strikes >= 0x10000L ) { - FT_ERROR(( "TT_Load_SBit_Strikes: invalid table version!\n" )); + FT_ERROR(( "tt_face_load_sbit_strikes: invalid table version!\n" )); error = SFNT_Err_Invalid_File_Format; goto Exit; @@ -577,7 +577,7 @@ /*************************************************************************/ /* */ /* <Function> */ - /* TT_Free_SBit_Strikes */ + /* tt_face_free_sbit_strikes */ /* */ /* <Description> */ /* Releases the embedded bitmap tables. */ @@ -586,7 +586,7 @@ /* face :: The target face object. */ /* */ FT_LOCAL_DEF( void ) - TT_Free_SBit_Strikes( TT_Face face ) + tt_face_free_sbit_strikes( TT_Face face ) { FT_Memory memory = face->root.memory; TT_SBit_Strike strike = face->sbit_strikes; @@ -621,12 +621,12 @@ FT_LOCAL_DEF( FT_Error ) - TT_Set_SBit_Strike( TT_Face face, - FT_Int x_ppem, - FT_Int y_ppem, - FT_ULong *astrike_index ) + tt_face_set_sbit_strike( TT_Face face, + FT_Int x_ppem, + FT_Int y_ppem, + FT_ULong *astrike_index ) { - FT_Int i; + FT_ULong i; if ( x_ppem < 0 || x_ppem > 255 || @@ -651,7 +651,7 @@ /*************************************************************************/ /* */ /* <Function> */ - /* Find_SBit_Range */ + /* find_sbit_range */ /* */ /* <Description> */ /* Scans a given strike's ranges and return, for a given glyph */ @@ -671,7 +671,7 @@ /* FreeType error code. 0 means the glyph index was found. */ /* */ static FT_Error - Find_SBit_Range( FT_UInt glyph_index, + find_sbit_range( FT_UInt glyph_index, TT_SBit_Strike strike, TT_SBit_Range *arange, FT_ULong *aglyph_offset ) @@ -754,7 +754,7 @@ /*************************************************************************/ /* */ /* <Function> */ - /* Find_SBit_Image */ + /* find_sbit_image */ /* */ /* <Description> */ /* Checks whether an embedded bitmap (an `sbit') exists for a given */ @@ -780,7 +780,7 @@ /* glyph. */ /* */ static FT_Error - Find_SBit_Image( TT_Face face, + find_sbit_image( TT_Face face, FT_UInt glyph_index, FT_ULong strike_index, TT_SBit_Range *arange, @@ -791,13 +791,13 @@ TT_SBit_Strike strike; - if ( !face->sbit_strikes || - ( face->num_sbit_strikes <= (FT_Int)strike_index ) ) + if ( !face->sbit_strikes || + ( face->num_sbit_strikes <= strike_index ) ) goto Fail; strike = &face->sbit_strikes[strike_index]; - error = Find_SBit_Range( glyph_index, strike, + error = find_sbit_range( glyph_index, strike, arange, aglyph_offset ); if ( error ) goto Fail; @@ -819,7 +819,7 @@ /*************************************************************************/ /* */ /* <Function> */ - /* Load_SBit_Metrics */ + /* load_sbit_metrics */ /* */ /* <Description> */ /* Gets the big metrics for a given SBit. */ @@ -844,7 +844,7 @@ /* function exit. */ /* */ static FT_Error - Load_SBit_Metrics( FT_Stream stream, + load_sbit_metrics( FT_Stream stream, TT_SBit_Range range, TT_SBit_Metrics metrics ) { @@ -918,7 +918,7 @@ /*************************************************************************/ /* */ /* <Function> */ - /* Crop_Bitmap */ + /* crop_bitmap */ /* */ /* <Description> */ /* Crops a bitmap to its tightest bounding box, and adjusts its */ @@ -930,7 +930,7 @@ /* metrics :: The corresponding metrics structure. */ /* */ static void - Crop_Bitmap( FT_Bitmap* map, + crop_bitmap( FT_Bitmap* map, TT_SBit_Metrics metrics ) { /***********************************************************************/ @@ -1116,7 +1116,7 @@ map->width = 0; map->rows = 0; map->pitch = 0; - map->pixel_mode = ft_pixel_mode_mono; + map->pixel_mode = FT_PIXEL_MODE_MONO; } @@ -1226,7 +1226,7 @@ if ( FT_STREAM_SEEK( ebdt_pos + glyph_offset ) ) goto Exit; - error = Load_SBit_Metrics( stream, range, metrics ); + error = load_sbit_metrics( stream, range, metrics ); if ( error ) goto Exit; @@ -1245,22 +1245,22 @@ switch ( strike->bit_depth ) { case 1: - map->pixel_mode = ft_pixel_mode_mono; + map->pixel_mode = FT_PIXEL_MODE_MONO; map->pitch = ( map->width + 7 ) >> 3; break; case 2: - map->pixel_mode = ft_pixel_mode_pal2; + map->pixel_mode = FT_PIXEL_MODE_GRAY2; map->pitch = ( map->width + 3 ) >> 2; break; case 4: - map->pixel_mode = ft_pixel_mode_pal4; + map->pixel_mode = FT_PIXEL_MODE_GRAY4; map->pitch = ( map->width + 1 ) >> 1; break; case 8: - map->pixel_mode = ft_pixel_mode_grays; + map->pixel_mode = FT_PIXEL_MODE_GRAY; map->pitch = map->width; break; @@ -1336,7 +1336,7 @@ /* find the range for this element */ - error = Find_SBit_Range( comp->glyph_code, + error = find_sbit_range( comp->glyph_code, strike, &elem_range, &elem_offset ); @@ -1369,7 +1369,7 @@ /*************************************************************************/ /* */ /* <Function> */ - /* TT_Load_SBit_Image */ + /* tt_face_load_sbit_image */ /* */ /* <Description> */ /* Loads a given glyph sbit image from the font resource. This also */ @@ -1400,13 +1400,13 @@ /* The `map.buffer' field is always freed before the glyph is loaded. */ /* */ FT_LOCAL_DEF( FT_Error ) - TT_Load_SBit_Image( TT_Face face, - FT_ULong strike_index, - FT_UInt glyph_index, - FT_UInt load_flags, - FT_Stream stream, - FT_Bitmap *map, - TT_SBit_MetricsRec *metrics ) + tt_face_load_sbit_image( TT_Face face, + FT_ULong strike_index, + FT_UInt glyph_index, + FT_UInt load_flags, + FT_Stream stream, + FT_Bitmap *map, + TT_SBit_MetricsRec *metrics ) { FT_Error error; FT_Memory memory = stream->memory; @@ -1417,7 +1417,7 @@ /* Check whether there is a glyph sbit for the current index */ - error = Find_SBit_Image( face, glyph_index, strike_index, + error = find_sbit_image( face, glyph_index, strike_index, &range, &strike, &glyph_offset ); if ( error ) goto Exit; @@ -1464,7 +1464,7 @@ /* Crop the bitmap now, unless specified otherwise */ if ( load_flags & FT_LOAD_CROP_BITMAP ) - Crop_Bitmap( map, metrics ); + crop_bitmap( map, metrics ); Exit: return error; diff --git a/src/libs/freetype2/sfnt/ttsbit.h b/src/libs/freetype2/sfnt/ttsbit.h index f38123d7aa3..edc858a60c4 100644 --- a/src/libs/freetype2/sfnt/ttsbit.h +++ b/src/libs/freetype2/sfnt/ttsbit.h @@ -28,27 +28,27 @@ FT_BEGIN_HEADER FT_LOCAL( FT_Error ) - TT_Load_SBit_Strikes( TT_Face face, - FT_Stream stream ); + tt_face_load_sbit_strikes( TT_Face face, + FT_Stream stream ); FT_LOCAL( void ) - TT_Free_SBit_Strikes( TT_Face face ); + tt_face_free_sbit_strikes( TT_Face face ); FT_LOCAL( FT_Error ) - TT_Set_SBit_Strike( TT_Face face, - FT_Int x_ppem, - FT_Int y_ppem, - FT_ULong *astrike_index ); + tt_face_set_sbit_strike( TT_Face face, + FT_Int x_ppem, + FT_Int y_ppem, + FT_ULong *astrike_index ); FT_LOCAL( FT_Error ) - TT_Load_SBit_Image( TT_Face face, - FT_ULong strike_index, - FT_UInt glyph_index, - FT_UInt load_flags, - FT_Stream stream, - FT_Bitmap *map, - TT_SBit_MetricsRec *metrics ); + tt_face_load_sbit_image( TT_Face face, + FT_ULong strike_index, + FT_UInt glyph_index, + FT_UInt load_flags, + FT_Stream stream, + FT_Bitmap *map, + TT_SBit_MetricsRec *metrics ); FT_END_HEADER diff --git a/src/libs/freetype2/smooth/ftgrays.c b/src/libs/freetype2/smooth/ftgrays.c index cafcd2a7ff4..f6723af678e 100644 --- a/src/libs/freetype2/smooth/ftgrays.c +++ b/src/libs/freetype2/smooth/ftgrays.c @@ -22,18 +22,18 @@ /* put the files `ftgrays.h' and `ftimage.h' into the current */ /* compilation directory. Typically, you could do something like */ /* */ - /* - copy `src/base/ftgrays.c' to your current directory */ + /* - copy `src/smooth/ftgrays.c' (this file) to your current directory */ /* */ - /* - copy `include/freetype/ftimage.h' and `include/freetype/ftgrays.h' */ - /* to the same directory */ + /* - copy `include/freetype/ftimage.h' and `src/smooth/ftgrays.h' to the */ + /* same directory */ /* */ /* - compile `ftgrays' with the _STANDALONE_ macro defined, as in */ /* */ /* cc -c -D_STANDALONE_ ftgrays.c */ /* */ /* The renderer can be initialized with a call to */ - /* `ft_gray_raster.gray_raster_new'; an anti-aliased bitmap can be */ - /* generated with a call to `ft_gray_raster.gray_raster_render'. */ + /* `ft_gray_raster.raster_new'; an anti-aliased bitmap can be generated */ + /* with a call to `ft_gray_raster.raster_render'. */ /* */ /* See the comments and documentation in the file `ftimage.h' for more */ /* details on how the raster works. */ @@ -106,14 +106,19 @@ #include <limits.h> #define FT_UINT_MAX UINT_MAX -#define ft_setjmp setjmp -#define ft_longjmp longjmp -#define ft_jmp_buf jmp_buf +#define ft_memset memset + +#define ft_setjmp setjmp +#define ft_longjmp longjmp +#define ft_jmp_buf jmp_buf #define ErrRaster_Invalid_Mode -2 #define ErrRaster_Invalid_Outline -1 +#define FT_BEGIN_HEADER +#define FT_END_HEADER + #include "ftimage.h" #include "ftgrays.h" @@ -154,6 +159,10 @@ #ifndef FT_MEM_SET #define FT_MEM_SET( d, s, c ) ft_memset( d, s, c ) +#endif + +#ifndef FT_MEM_ZERO +#define FT_MEM_ZERO( dest, count ) FT_MEM_SET( dest, 0, count ) #endif /* define this to dump debugging information */ @@ -192,8 +201,8 @@ #define ONE_PIXEL ( 1L << PIXEL_BITS ) #define PIXEL_MASK ( -1L << PIXEL_BITS ) -#define TRUNC( x ) ( (x) >> PIXEL_BITS ) -#define SUBPIXELS( x ) ( (x) << PIXEL_BITS ) +#define TRUNC( x ) ( (TCoord)((x) >> PIXEL_BITS) ) +#define SUBPIXELS( x ) ( (TPos)(x) << PIXEL_BITS ) #define FLOOR( x ) ( (x) & -ONE_PIXEL ) #define CEILING( x ) ( ( (x) + ONE_PIXEL - 1 ) & -ONE_PIXEL ) #define ROUND( x ) ( ( (x) + ONE_PIXEL / 2 ) & -ONE_PIXEL ) @@ -210,7 +219,7 @@ /* increases the number of cells available in the render pool but slows */ /* down the rendering a bit. It is useful if you have a really tiny */ /* render pool. */ -#undef GRAYS_COMPACT +#undef GRAYS_COMPACT /*************************************************************************/ @@ -280,8 +289,8 @@ int max_cells; int num_cells; - TCoord min_ex, max_ex; - TCoord min_ey, max_ey; + TPos min_ex, max_ex; + TPos min_ey, max_ey; TArea area; int cover; @@ -291,7 +300,7 @@ TCoord cx, cy; TPos x, y; - TCoord last_ey; + TPos last_ey; FT_Vector bez_stack[32 * 3 + 1]; int lev_stack[32]; @@ -316,7 +325,7 @@ ft_jmp_buf jump_buffer; #ifdef GRAYS_USE_GAMMA - FT_Byte gamma[257]; + unsigned char gamma[257]; #endif } TRaster, *PRaster; @@ -399,8 +408,8 @@ ft_longjmp( ras.jump_buffer, 1 ); cell = ras.cells + ras.num_cells++; - cell->x = ras.ex - ras.min_ex; - cell->y = ras.ey - ras.min_ey; + cell->x = (TCoord)(ras.ex - ras.min_ex); + cell->y = (TCoord)(ras.ey - ras.min_ey); cell->area = ras.area; cell->cover = ras.cover; } @@ -437,7 +446,7 @@ /* All cells that are on the left of the clipping region go to the */ /* min_ex - 1 horizontal position. */ if ( ex < ras.min_ex ) - ex = ras.min_ex - 1; + ex = (TCoord)(ras.min_ex - 1); /* if our position is new, then record the previous cell */ if ( ex != ras.ex || ey != ras.ey ) @@ -473,7 +482,7 @@ TCoord ey ) { if ( ex < ras.min_ex ) - ex = ras.min_ex - 1; + ex = (TCoord)(ras.min_ex - 1); ras.area = 0; ras.cover = 0; @@ -506,8 +515,8 @@ ex1 = TRUNC( x1 ); /* if (ex1 >= ras.max_ex) ex1 = ras.max_ex-1; */ ex2 = TRUNC( x2 ); /* if (ex2 >= ras.max_ex) ex2 = ras.max_ex-1; */ - fx1 = x1 - SUBPIXELS( ex1 ); - fx2 = x2 - SUBPIXELS( ex2 ); + fx1 = (TCoord)( x1 - SUBPIXELS( ex1 ) ); + fx2 = (TCoord)( x2 - SUBPIXELS( ex2 ) ); /* trivial case. Happens often */ if ( y1 == y2 ) @@ -541,12 +550,12 @@ dx = -dx; } - delta = p / dx; - mod = p % dx; + delta = (TCoord)( p / dx ); + mod = (TCoord)( p % dx ); if ( mod < 0 ) { delta--; - mod += dx; + mod += (TCoord)dx; } ras.area += (TArea)( fx1 + first ) * delta; @@ -559,12 +568,12 @@ if ( ex1 != ex2 ) { p = ONE_PIXEL * ( y2 - y1 + delta ); - lift = p / dx; - rem = p % dx; + lift = (TCoord)( p / dx ); + rem = (TCoord)( p % dx ); if ( rem < 0 ) { lift--; - rem += dx; + rem += (TCoord)dx; } mod -= dx; @@ -575,7 +584,7 @@ mod += rem; if ( mod >= 0 ) { - mod -= dx; + mod -= (TCoord)dx; delta++; } @@ -603,13 +612,14 @@ { TCoord ey1, ey2, fy1, fy2; TPos dx, dy, x, x2; - int p, rem, mod, lift, delta, first, incr; + long p, first; + int delta, rem, mod, lift, incr; ey1 = TRUNC( ras.last_ey ); ey2 = TRUNC( to_y ); /* if (ey2 >= ras.max_ey) ey2 = ras.max_ey-1; */ - fy1 = ras.y - ras.last_ey; - fy2 = to_y - SUBPIXELS( ey2 ); + fy1 = (TCoord)( ras.y - ras.last_ey ); + fy2 = (TCoord)( to_y - SUBPIXELS( ey2 ) ); dx = to_x - ras.x; dy = to_y - ras.y; @@ -646,7 +656,7 @@ if ( dx == 0 ) { TCoord ex = TRUNC( ras.x ); - TCoord two_fx = ( ras.x - SUBPIXELS( ex ) ) << 1; + TCoord two_fx = (TCoord)( ( ras.x - SUBPIXELS( ex ) ) << 1 ); TPos area; @@ -657,16 +667,16 @@ incr = -1; } - delta = first - fy1; + delta = (int)( first - fy1 ); ras.area += (TArea)two_fx * delta; ras.cover += delta; ey1 += incr; gray_set_cell( raster, ex, ey1 ); - delta = first + first - ONE_PIXEL; + delta = (int)( first + first - ONE_PIXEL ); area = (TArea)two_fx * delta; - while( ey1 != ey2 ) + while ( ey1 != ey2 ) { ras.area += area; ras.cover += delta; @@ -674,7 +684,7 @@ gray_set_cell( raster, ex, ey1 ); } - delta = fy2 - ONE_PIXEL + first; + delta = (int)( fy2 - ONE_PIXEL + first ); ras.area += (TArea)two_fx * delta; ras.cover += delta; goto End; @@ -693,16 +703,16 @@ dy = -dy; } - delta = p / dy; - mod = p % dy; + delta = (int)( p / dy ); + mod = (int)( p % dy ); if ( mod < 0 ) { delta--; - mod += dy; + mod += (TCoord)dy; } x = ras.x + delta; - gray_render_scanline( RAS_VAR_ ey1, ras.x, fy1, x, first ); + gray_render_scanline( RAS_VAR_ ey1, ras.x, fy1, x, (TCoord)first ); ey1 += incr; gray_set_cell( RAS_VAR_ TRUNC( x ), ey1 ); @@ -710,14 +720,14 @@ if ( ey1 != ey2 ) { p = ONE_PIXEL * dx; - lift = p / dy; - rem = p % dy; + lift = (int)( p / dy ); + rem = (int)( p % dy ); if ( rem < 0 ) { lift--; - rem += dy; + rem += (int)dy; } - mod -= dy; + mod -= (int)dy; while ( ey1 != ey2 ) { @@ -725,12 +735,14 @@ mod += rem; if ( mod >= 0 ) { - mod -= dy; + mod -= (int)dy; delta++; } x2 = x + delta; - gray_render_scanline( RAS_VAR_ ey1, x, ONE_PIXEL - first, x2, first ); + gray_render_scanline( RAS_VAR_ ey1, x, + (TCoord)( ONE_PIXEL - first ), x2, + (TCoord)first ); x = x2; ey1 += incr; @@ -738,7 +750,9 @@ } } - gray_render_scanline( RAS_VAR_ ey1, x, ONE_PIXEL - first, to_x, fy2 ); + gray_render_scanline( RAS_VAR_ ey1, x, + (TCoord)( ONE_PIXEL - first ), to_x, + fy2 ); End: ras.x = to_x; @@ -1284,11 +1298,11 @@ for ( ; count > 0; count--, spans++ ) { - FT_UInt coverage = spans->coverage; + unsigned char coverage = spans->coverage; #ifdef GRAYS_USE_GAMMA - coverage = raster->gamma[(FT_Byte)coverage]; + coverage = raster->gamma[coverage]; #endif if ( coverage ) @@ -1352,12 +1366,12 @@ /* */ /* the coverage percentage is area/(PIXEL_BITS*PIXEL_BITS*2) */ /* */ - coverage = area >> ( PIXEL_BITS * 2 + 1 - 8); /* use range 0..256 */ - + coverage = (int)( area >> ( PIXEL_BITS * 2 + 1 - 8 ) ); + /* use range 0..256 */ if ( coverage < 0 ) coverage = -coverage; - if ( ras.outline.flags & ft_outline_even_odd_fill ) + if ( ras.outline.flags & FT_OUTLINE_EVEN_ODD_FILL ) { coverage &= 511; @@ -1373,9 +1387,8 @@ coverage = 255; } - - y += ras.min_ey; - x += ras.min_ex; + y += (TCoord)ras.min_ey; + x += (TCoord)ras.min_ex; if ( coverage ) { @@ -1489,15 +1502,15 @@ /* draw a gray span between the start cell and the current one */ if ( cur->x > x ) gray_hline( RAS_VAR_ x, y, - cover * ( ONE_PIXEL * 2 ), cur->x - x ); + cover * ( ONE_PIXEL * 2 ), cur->x - x ); } else { /* draw a gray span until the end of the clipping region */ if ( cover && x < ras.max_ex - ras.min_ex ) gray_hline( RAS_VAR_ x, y, - cover * ( ONE_PIXEL * 2 ), - ras.max_ex - x - ras.min_ex ); + cover * ( ONE_PIXEL * 2 ), + (int)( ras.max_ex - x - ras.min_ex ) ); cover = 0; } @@ -1584,14 +1597,14 @@ FT_Vector* limit; char* tags; - int n; /* index of contour in outline */ - int first; /* index of first point in contour */ - int error; - char tag; /* current point's state */ + int n; /* index of contour in outline */ + int first; /* index of first point in contour */ + int error; + char tag; /* current point's state */ #if 0 - int shift = func_interface->shift; - FT_Pos delta = func_interface->delta; + int shift = func_interface->shift; + TPos delta = func_interface->delta; #endif @@ -1618,14 +1631,14 @@ tag = FT_CURVE_TAG( tags[0] ); /* A contour cannot start with a cubic control point! */ - if ( tag == FT_Curve_Tag_Cubic ) + if ( tag == FT_CURVE_TAG_CUBIC ) goto Invalid_Outline; /* check first point to determine origin */ - if ( tag == FT_Curve_Tag_Conic ) + if ( tag == FT_CURVE_TAG_CONIC ) { /* first point is conic control. Yes, this happens. */ - if ( FT_CURVE_TAG( outline->tags[last] ) == FT_Curve_Tag_On ) + if ( FT_CURVE_TAG( outline->tags[last] ) == FT_CURVE_TAG_ON ) { /* start at last point if it is on the curve */ v_start = v_last; @@ -1657,7 +1670,7 @@ tag = FT_CURVE_TAG( tags[0] ); switch ( tag ) { - case FT_Curve_Tag_On: /* emit a single line_to */ + case FT_CURVE_TAG_ON: /* emit a single line_to */ { FT_Vector vec; @@ -1671,7 +1684,7 @@ continue; } - case FT_Curve_Tag_Conic: /* consume conic arcs */ + case FT_CURVE_TAG_CONIC: /* consume conic arcs */ { v_control.x = SCALED( point->x ); v_control.y = SCALED( point->y ); @@ -1690,7 +1703,7 @@ vec.x = SCALED( point->x ); vec.y = SCALED( point->y ); - if ( tag == FT_Curve_Tag_On ) + if ( tag == FT_CURVE_TAG_ON ) { error = func_interface->conic_to( &v_control, &vec, user ); if ( error ) @@ -1698,7 +1711,7 @@ continue; } - if ( tag != FT_Curve_Tag_Conic ) + if ( tag != FT_CURVE_TAG_CONIC ) goto Invalid_Outline; v_middle.x = ( v_control.x + vec.x ) / 2; @@ -1716,13 +1729,13 @@ goto Close; } - default: /* FT_Curve_Tag_Cubic */ + default: /* FT_CURVE_TAG_CUBIC */ { FT_Vector vec1, vec2; if ( point + 1 > limit || - FT_CURVE_TAG( tags[1] ) != FT_Curve_Tag_Cubic ) + FT_CURVE_TAG( tags[1] ) != FT_CURVE_TAG_CUBIC ) goto Invalid_Outline; point += 2; @@ -1775,7 +1788,7 @@ typedef struct TBand_ { - FT_Pos min, max; + TPos min, max; } TBand; @@ -1813,11 +1826,11 @@ static int gray_convert_glyph( RAS_ARG ) { - TBand bands[40]; - volatile TBand* band; - volatile int n, num_bands; - volatile TPos min, max, max_y; - FT_BBox* clip; + TBand bands[40]; + volatile TBand* band; + volatile int n, num_bands; + volatile TPos min, max, max_y; + FT_BBox* clip; /* Set up state in the raster object */ @@ -1856,7 +1869,7 @@ } /* setup vertical bands */ - num_bands = ( ras.max_ey - ras.min_ey ) / ras.band_size; + num_bands = (int)( ( ras.max_ey - ras.min_ey ) / ras.band_size ); if ( num_bands == 0 ) num_bands = 1; if ( num_bands >= 39 ) num_bands = 39; @@ -1877,8 +1890,8 @@ while ( band >= bands ) { - FT_Pos bottom, top, middle; - int error; + TPos bottom, top, middle; + int error; ras.num_cells = 0; @@ -1969,16 +1982,16 @@ return ErrRaster_Invalid_Outline; /* if direct mode is not set, we must have a target bitmap */ - if ( ( params->flags & ft_raster_flag_direct ) == 0 && + if ( ( params->flags & FT_RASTER_FLAG_DIRECT ) == 0 && ( !target_map || !target_map->buffer ) ) return -1; /* this version does not support monochrome rendering */ - if ( !( params->flags & ft_raster_flag_aa ) ) + if ( !( params->flags & FT_RASTER_FLAG_AA ) ) return ErrRaster_Invalid_Mode; /* compute clipping box */ - if ( ( params->flags & ft_raster_flag_direct ) == 0 ) + if ( ( params->flags & FT_RASTER_FLAG_DIRECT ) == 0 ) { /* compute clip box from target pixmap */ ras.clip_box.xMin = 0; @@ -1986,7 +1999,7 @@ ras.clip_box.xMax = target_map->width; ras.clip_box.yMax = target_map->rows; } - else if ( params->flags & ft_raster_flag_clip ) + else if ( params->flags & FT_RASTER_FLAG_CLIP ) { ras.clip_box = params->clip_box; } @@ -2008,7 +2021,7 @@ ras.render_span = (FT_Raster_Span_Func)gray_render_span; ras.render_span_data = &ras; - if ( params->flags & ft_raster_flag_direct ) + if ( params->flags & FT_RASTER_FLAG_DIRECT ) { ras.render_span = (FT_Raster_Span_Func)params->gray_spans; ras.render_span_data = params->user; @@ -2033,7 +2046,7 @@ static void grays_init_gamma( PRaster raster ) { - FT_UInt x, a; + unsigned int x, a; for ( x = 0; x < 256; x++ ) @@ -2044,7 +2057,7 @@ a = M_Y + ( ( x - M_X ) * ( M_MAX - M_Y ) + ( M_MAX - M_X ) / 2 ) / ( M_MAX - M_X ); - raster->gamma[x] = (FT_Byte)a; + raster->gamma[x] = (unsigned char)a; } } @@ -2062,7 +2075,7 @@ *araster = (FT_Raster)&the_raster; - FT_MEM_SET( &the_raster, 0, sizeof ( the_raster ) ); + FT_MEM_ZERO( &the_raster, sizeof ( the_raster ) ); #ifdef GRAYS_USE_GAMMA grays_init_gamma( (PRaster)*araster ); @@ -2127,13 +2140,13 @@ if ( raster && pool_base && pool_size >= 4096 ) gray_init_cells( rast, (char*)pool_base, pool_size ); - rast->band_size = ( pool_size / sizeof ( TCell ) ) / 8; + rast->band_size = (int)( ( pool_size / sizeof ( TCell ) ) / 8 ); } const FT_Raster_Funcs ft_grays_raster = { - ft_glyph_format_outline, + FT_GLYPH_FORMAT_OUTLINE, (FT_Raster_New_Func) gray_raster_new, (FT_Raster_Reset_Func) gray_raster_reset, diff --git a/src/libs/freetype2/smooth/ftsmooth.c b/src/libs/freetype2/smooth/ftsmooth.c index b717926db2d..131b17eba02 100644 --- a/src/libs/freetype2/smooth/ftsmooth.c +++ b/src/libs/freetype2/smooth/ftsmooth.c @@ -85,7 +85,7 @@ FT_GlyphSlot slot, FT_BBox* cbox ) { - FT_MEM_SET( cbox, 0, sizeof ( *cbox ) ); + FT_MEM_ZERO( cbox, sizeof ( *cbox ) ); if ( slot->format == render->glyph_format ) FT_Outline_Get_CBox( &slot->outline, cbox ); @@ -94,10 +94,13 @@ /* convert a slot's glyph image into a bitmap */ static FT_Error - ft_smooth_render( FT_Renderer render, - FT_GlyphSlot slot, - FT_UInt mode, - FT_Vector* origin ) + ft_smooth_render_generic( FT_Renderer render, + FT_GlyphSlot slot, + FT_Render_Mode mode, + FT_Vector* origin, + FT_Render_Mode required_mode, + FT_Int hmul, + FT_Int vmul ) { FT_Error error; FT_Outline* outline = NULL; @@ -117,7 +120,7 @@ } /* check mode */ - if ( mode != ft_render_mode_normal ) + if ( mode != required_mode ) return Smooth_Err_Cannot_Render_Glyph; outline = &slot->outline; @@ -148,7 +151,16 @@ /* allocate new one, depends on pixel format */ pitch = width; - bitmap->pixel_mode = ft_pixel_mode_grays; + if ( hmul ) + { + width = width * hmul; + pitch = ( width + 3 ) & -4; + } + + if ( vmul ) + height *= vmul; + + bitmap->pixel_mode = FT_PIXEL_MODE_GRAY; bitmap->num_grays = 256; bitmap->width = width; bitmap->rows = height; @@ -165,19 +177,49 @@ /* set up parameters */ params.target = bitmap; params.source = outline; - params.flags = ft_raster_flag_aa; + params.flags = FT_RASTER_FLAG_AA; + + /* implode outline if needed */ + { + FT_Int n; + FT_Vector* vec; + + + if ( hmul ) + for ( vec = outline->points, n = 0; n < outline->n_points; n++, vec++ ) + vec->x *= hmul; + + if ( vmul ) + for ( vec = outline->points, n = 0; n < outline->n_points; n++, vec++ ) + vec->y *= vmul; + } /* render outline into the bitmap */ error = render->raster_render( render->raster, ¶ms ); - + + /* deflate outline if needed */ + { + FT_Int n; + FT_Vector* vec; + + + if ( hmul ) + for ( vec = outline->points, n = 0; n < outline->n_points; n++, vec++ ) + vec->x /= hmul; + + if ( vmul ) + for ( vec = outline->points, n = 0; n < outline->n_points; n++, vec++ ) + vec->y /= vmul; + } + FT_Outline_Translate( outline, cbox.xMin, cbox.yMin ); if ( error ) goto Exit; - slot->format = ft_glyph_format_bitmap; - slot->bitmap_left = cbox.xMin >> 6; - slot->bitmap_top = cbox.yMax >> 6; + slot->format = FT_GLYPH_FORMAT_BITMAP; + slot->bitmap_left = (FT_Int)( cbox.xMin >> 6 ); + slot->bitmap_top = (FT_Int)( cbox.yMax >> 6 ); Exit: if ( outline && origin ) @@ -187,6 +229,57 @@ } + /* convert a slot's glyph image into a bitmap */ + static FT_Error + ft_smooth_render( FT_Renderer render, + FT_GlyphSlot slot, + FT_Render_Mode mode, + FT_Vector* origin ) + { + return ft_smooth_render_generic( render, slot, mode, origin, + FT_RENDER_MODE_NORMAL, + 0, 0 ); + } + + + /* convert a slot's glyph image into a horizontal LCD bitmap */ + static FT_Error + ft_smooth_render_lcd( FT_Renderer render, + FT_GlyphSlot slot, + FT_Render_Mode mode, + FT_Vector* origin ) + { + FT_Error error; + + error = ft_smooth_render_generic( render, slot, mode, origin, + FT_RENDER_MODE_LCD, + 3, 0 ); + if ( !error ) + slot->bitmap.pixel_mode = FT_PIXEL_MODE_LCD; + + return error; + } + + + /* convert a slot's glyph image into a vertical LCD bitmap */ + static FT_Error + ft_smooth_render_lcd_v( FT_Renderer render, + FT_GlyphSlot slot, + FT_Render_Mode mode, + FT_Vector* origin ) + { + FT_Error error; + + error = ft_smooth_render_generic( render, slot, mode, origin, + FT_RENDER_MODE_LCD_V, + 0, 3 ); + if ( !error ) + slot->bitmap.pixel_mode = FT_PIXEL_MODE_LCD_V; + + return error; + } + + FT_CALLBACK_TABLE_DEF const FT_Renderer_Class ft_smooth_renderer_class = { @@ -205,12 +298,71 @@ (FT_Module_Requester) 0 }, - ft_glyph_format_outline, + FT_GLYPH_FORMAT_OUTLINE, + + (FT_Renderer_RenderFunc) ft_smooth_render, + (FT_Renderer_TransformFunc)ft_smooth_transform, + (FT_Renderer_GetCBoxFunc) ft_smooth_get_cbox, + (FT_Renderer_SetModeFunc) ft_smooth_set_mode, + + (FT_Raster_Funcs*) &ft_grays_raster + }; + + + FT_CALLBACK_TABLE_DEF + const FT_Renderer_Class ft_smooth_lcd_renderer_class = + { + { + ft_module_renderer, + sizeof( FT_RendererRec ), + + "smooth-lcd", + 0x10000L, + 0x20000L, + + 0, /* module specific interface */ + + (FT_Module_Constructor)ft_smooth_init, + (FT_Module_Destructor) 0, + (FT_Module_Requester) 0 + }, + + FT_GLYPH_FORMAT_OUTLINE, + + (FT_Renderer_RenderFunc) ft_smooth_render_lcd, + (FT_Renderer_TransformFunc)ft_smooth_transform, + (FT_Renderer_GetCBoxFunc) ft_smooth_get_cbox, + (FT_Renderer_SetModeFunc) ft_smooth_set_mode, + + (FT_Raster_Funcs*) &ft_grays_raster + }; + + + + FT_CALLBACK_TABLE_DEF + const FT_Renderer_Class ft_smooth_lcdv_renderer_class = + { + { + ft_module_renderer, + sizeof( FT_RendererRec ), + + "smooth-lcdv", + 0x10000L, + 0x20000L, + + 0, /* module specific interface */ + + (FT_Module_Constructor)ft_smooth_init, + (FT_Module_Destructor) 0, + (FT_Module_Requester) 0 + }, + + FT_GLYPH_FORMAT_OUTLINE, - (FTRenderer_render) ft_smooth_render, - (FTRenderer_transform)ft_smooth_transform, - (FTRenderer_getCBox) ft_smooth_get_cbox, - (FTRenderer_setMode) ft_smooth_set_mode, + (FT_Renderer_RenderFunc) ft_smooth_render_lcd_v, + (FT_Renderer_TransformFunc)ft_smooth_transform, + (FT_Renderer_GetCBoxFunc) ft_smooth_get_cbox, + (FT_Renderer_SetModeFunc) ft_smooth_set_mode, (FT_Raster_Funcs*) &ft_grays_raster }; diff --git a/src/libs/freetype2/smooth/ftsmooth.h b/src/libs/freetype2/smooth/ftsmooth.h index ec011219b84..62cced44873 100644 --- a/src/libs/freetype2/smooth/ftsmooth.h +++ b/src/libs/freetype2/smooth/ftsmooth.h @@ -33,9 +33,14 @@ FT_BEGIN_HEADER #ifndef FT_CONFIG_OPTION_NO_SMOOTH_RASTER FT_EXPORT_VAR( const FT_Renderer_Class ) ft_smooth_renderer_class; + + FT_EXPORT_VAR( const FT_Renderer_Class ) ft_smooth_lcd_renderer_class; + + FT_EXPORT_VAR( const FT_Renderer_Class ) ft_smooth_lcd_v_renderer_class; #endif + FT_END_HEADER #endif /* __FTSMOOTH_H__ */ diff --git a/src/libs/freetype2/tools/cordic.py b/src/libs/freetype2/tools/cordic.py index 515fbcc5d69..bb1a238e01c 100755 --- a/src/libs/freetype2/tools/cordic.py +++ b/src/libs/freetype2/tools/cordic.py @@ -1,7 +1,7 @@ # compute arctangent table for CORDIC computations in fttrigon.c import sys, math -units = 180*65536 # don't change !! +units = 64*65536.0 # don't change !! scale = units/math.pi shrink = 1.0 comma = "" diff --git a/src/libs/freetype2/tools/test_bbox.c b/src/libs/freetype2/tools/test_bbox.c index 5ac9894335c..e085c5b3d6c 100644 --- a/src/libs/freetype2/tools/test_bbox.c +++ b/src/libs/freetype2/tools/test_bbox.c @@ -46,10 +46,10 @@ static char dummy_tag_1[4] = { - FT_Curve_Tag_On, - FT_Curve_Tag_Cubic, - FT_Curve_Tag_Cubic, - FT_Curve_Tag_On + FT_CURVE_TAG_ON, + FT_CURVE_TAG_CUBIC, + FT_CURVE_TAG_CUBIC, + FT_CURVE_TAG_ON }; static short dummy_contour_1[1] = diff --git a/src/libs/freetype2/truetype/ttdriver.c b/src/libs/freetype2/truetype/ttdriver.c index d0678a3c89a..c61c4eb7067 100644 --- a/src/libs/freetype2/truetype/ttdriver.c +++ b/src/libs/freetype2/truetype/ttdriver.c @@ -222,7 +222,7 @@ size->strike_index = 0xFFFF; #endif - return TT_Size_Reset( size ); + return tt_size_reset( size ); } @@ -261,7 +261,7 @@ size->strike_index = 0xFFFF; #endif - return TT_Size_Reset( size ); + return tt_size_reset( size ); } @@ -295,7 +295,7 @@ Load_Glyph( TT_GlyphSlot slot, TT_Size size, FT_UShort glyph_index, - FT_UInt load_flags ) + FT_Int32 load_flags ) { FT_Error error; @@ -319,7 +319,7 @@ if ( !size->ttmetrics.valid ) { - if ( FT_SET_ERROR( TT_Size_Reset( size ) ) ) + if ( FT_SET_ERROR( tt_size_reset( size ) ) ) return error; } } @@ -334,112 +334,6 @@ } - /*************************************************************************/ - /*************************************************************************/ - /*************************************************************************/ - /**** ****/ - /**** ****/ - /**** C H A R A C T E R M A P P I N G S ****/ - /**** ****/ - /**** ****/ - /*************************************************************************/ - /*************************************************************************/ - /*************************************************************************/ - - /*************************************************************************/ - /* */ - /* <Function> */ - /* 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 - Get_Char_Index( TT_CharMap charmap, - FT_Long charcode ) - { - FT_Error error; - TT_Face face; - TT_CMapTable cmap; - - - cmap = &charmap->cmap; - face = (TT_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; - } - - if ( cmap->get_index ) - return cmap->get_index( cmap, charcode ); - else - return 0; - } - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* Get_Next_Char */ - /* */ - /* <Description> */ - /* Uses a charmap to return the next encoded char. */ - /* */ - /* <Input> */ - /* charmap :: A handle to the source charmap object. */ - /* charcode :: The character code. */ - /* */ - /* <Return> */ - /* Next char code. 0 means `no more encoded characters'. */ - /* */ - static FT_UInt - Get_Next_Char( TT_CharMap charmap, - FT_Long charcode ) - { - FT_Error error; - TT_Face face; - TT_CMapTable cmap; - - - cmap = &charmap->cmap; - face = (TT_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; - } - - if ( cmap->get_next_char ) - return cmap->get_next_char ( cmap, charcode ); - else - return 0; - } - - /*************************************************************************/ /*************************************************************************/ /*************************************************************************/ @@ -496,8 +390,8 @@ (void*)0, /* driver specific interface */ - (FT_Module_Constructor)TT_Driver_Init, - (FT_Module_Destructor) TT_Driver_Done, + (FT_Module_Constructor)tt_driver_init, + (FT_Module_Destructor) tt_driver_done, (FT_Module_Requester) tt_get_interface, }, @@ -506,23 +400,20 @@ sizeof ( FT_GlyphSlotRec ), - (FT_Face_InitFunc) TT_Face_Init, - (FT_Face_DoneFunc) TT_Face_Done, - (FT_Size_InitFunc) TT_Size_Init, - (FT_Size_DoneFunc) TT_Size_Done, + (FT_Face_InitFunc) tt_face_init, + (FT_Face_DoneFunc) tt_face_done, + (FT_Size_InitFunc) tt_size_init, + (FT_Size_DoneFunc) tt_size_done, (FT_Slot_InitFunc) 0, (FT_Slot_DoneFunc) 0, (FT_Size_ResetPointsFunc) Set_Char_Sizes, (FT_Size_ResetPixelsFunc) Set_Pixel_Sizes, (FT_Slot_LoadFunc) Load_Glyph, - (FT_CharMap_CharIndexFunc)Get_Char_Index, (FT_Face_GetKerningFunc) Get_Kerning, (FT_Face_AttachFunc) 0, - (FT_Face_GetAdvancesFunc) 0, - - (FT_CharMap_CharNextFunc) Get_Next_Char + (FT_Face_GetAdvancesFunc) 0 }; diff --git a/src/libs/freetype2/truetype/ttgload.c b/src/libs/freetype2/truetype/ttgload.c index 8cb80ac7be7..c5f26542b6b 100644 --- a/src/libs/freetype2/truetype/ttgload.c +++ b/src/libs/freetype2/truetype/ttgload.c @@ -43,17 +43,19 @@ /* */ /* Composite font flags. */ /* */ -#define ARGS_ARE_WORDS 0x001 -#define ARGS_ARE_XY_VALUES 0x002 -#define ROUND_XY_TO_GRID 0x004 -#define WE_HAVE_A_SCALE 0x008 -/* reserved 0x010 */ -#define MORE_COMPONENTS 0x020 -#define WE_HAVE_AN_XY_SCALE 0x040 -#define WE_HAVE_A_2X2 0x080 -#define WE_HAVE_INSTR 0x100 -#define USE_MY_METRICS 0x200 - +#define ARGS_ARE_WORDS 0x0001 +#define ARGS_ARE_XY_VALUES 0x0002 +#define ROUND_XY_TO_GRID 0x0004 +#define WE_HAVE_A_SCALE 0x0008 +/* reserved 0x0010 */ +#define MORE_COMPONENTS 0x0020 +#define WE_HAVE_AN_XY_SCALE 0x0040 +#define WE_HAVE_A_2X2 0x0080 +#define WE_HAVE_INSTR 0x0100 +#define USE_MY_METRICS 0x0200 +#define OVERLAP_COMPOUND 0x0400 +#define SCALED_COMPONENT_OFFSET 0x0800 +#define UNSCALED_COMPONENT_OFFSET 0x1000 /*************************************************************************/ @@ -91,6 +93,12 @@ FT_UShort k = header->number_Of_HMetrics; + if ( k == 0 ) + { + *bearing = *advance = 0; + return; + } + if ( idx < (FT_UInt)k ) { longs_m = (TT_LongMetrics )header->long_metrics + idx; @@ -450,7 +458,7 @@ /* clear the touch tags */ for ( n = 0; n < n_points; n++ ) - outline->tags[n] &= FT_Curve_Tag_On; + outline->tags[n] &= FT_CURVE_TAG_ON; outline->n_points = (FT_UShort)n_points; outline->n_contours = (FT_Short) n_contours; @@ -544,8 +552,8 @@ else if ( subglyph->flags & WE_HAVE_A_2X2 ) { xx = (FT_Fixed)FT_GET_SHORT() << 2; - xy = (FT_Fixed)FT_GET_SHORT() << 2; yx = (FT_Fixed)FT_GET_SHORT() << 2; + xy = (FT_Fixed)FT_GET_SHORT() << 2; yy = (FT_Fixed)FT_GET_SHORT() << 2; } @@ -750,15 +758,20 @@ TT_Face face = (TT_Face)loader->face; FT_ULong offset; FT_Int contours_count; - FT_UInt idx, num_points, count; + FT_UInt num_points, count; FT_Fixed x_scale, y_scale; FT_GlyphLoader gloader = loader->gloader; FT_Bool opened_frame = 0; +#ifdef FT_CONFIG_OPTION_INCREMENTAL + struct FT_StreamRec_ inc_stream; + FT_Data glyph_data; + FT_Bool glyph_data_loaded = 0; +#endif + /* check glyph index */ - idx = glyph_index; - if ( idx >= (FT_UInt)face->root.num_glyphs ) + if ( glyph_index >= (FT_UInt)face->root.num_glyphs ) { error = TT_Err_Invalid_Glyph_Index; goto Exit; @@ -777,16 +790,47 @@ /* get horizontal metrics */ { - FT_Short left_bearing; - FT_UShort advance_width; + FT_Short left_bearing = 0; + FT_UShort advance_width = 0; + +#ifdef FT_CONFIG_OPTION_INCREMENTAL + FT_Bool metrics_found = FALSE; + + /* If this is an incrementally loaded font see if there are */ + /* overriding metrics for this glyph. */ + if ( face->root.internal->incremental_interface && + face->root.internal->incremental_interface->funcs->get_glyph_metrics ) + { + FT_Incremental_MetricsRec m; + + + error = face->root.internal->incremental_interface->funcs->get_glyph_metrics( + face->root.internal->incremental_interface->object, + glyph_index, FALSE, &m, &metrics_found ); + if ( error ) + goto Exit; + left_bearing = (FT_Short)m.bearing_x; + advance_width = (FT_UShort)m.advance; + } + + if ( !metrics_found ) + Get_HMetrics( face, glyph_index, + (FT_Bool)!( loader->load_flags & + FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH ), + &left_bearing, + &advance_width ); - Get_HMetrics( face, idx, +#else + + Get_HMetrics( face, glyph_index, (FT_Bool)!( loader->load_flags & FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH ), &left_bearing, &advance_width ); +#endif /* FT_CONFIG_OPTION_INCREMENTAL */ + loader->left_bearing = left_bearing; loader->advance = advance_width; @@ -797,11 +841,45 @@ } } - offset = face->glyph_locations[idx]; - count = 0; +#ifdef FT_CONFIG_OPTION_INCREMENTAL - if ( idx < (FT_UInt)face->num_locations - 1 ) - count = face->glyph_locations[idx + 1] - offset; + /* Set `offset' to the start of the glyph program relative to the */ + /* start of the 'glyf' table, and `count' to the length of the */ + /* glyph program in bytes. */ + /* */ + /* If we are loading glyph data via the incremental interface, set */ + /* the loader stream to a memory stream reading the data returned */ + /* by the interface. */ + + if ( face->root.internal->incremental_interface ) + { + error = face->root.internal->incremental_interface->funcs->get_glyph_data( + face->root.internal->incremental_interface->object, + glyph_index, &glyph_data ); + if ( error ) + goto Exit; + + glyph_data_loaded = 1; + offset = 0; + count = glyph_data.length; + + FT_MEM_ZERO( &inc_stream, sizeof ( inc_stream ) ); + FT_Stream_OpenMemory( &inc_stream, + glyph_data.pointer, glyph_data.length ); + + loader->stream = &inc_stream; + } + else + +#endif /* FT_CONFIG_OPTION_INCREMENTAL */ + + { + offset = face->glyph_locations[glyph_index]; + count = 0; + + if ( glyph_index < (FT_UInt)face->num_locations - 1 ) + count = face->glyph_locations[glyph_index + 1] - offset; + } if ( count == 0 ) { @@ -935,7 +1013,7 @@ /* if the flag FT_LOAD_NO_RECURSE is set, we return the subglyph */ /* `as is' in the glyph slot (the client application will be */ - /* responsible for interpreting this data)... */ + /* responsible for interpreting these data)... */ /* */ if ( loader->load_flags & FT_LOAD_NO_RECURSE ) { @@ -943,7 +1021,7 @@ FT_GlyphLoader_Add( gloader ); glyph->num_subglyphs = gloader->base.num_subglyphs; - glyph->format = ft_glyph_format_composite; + glyph->format = FT_GLYPH_FORMAT_COMPOSITE; glyph->subglyphs = gloader->base.subglyphs; goto Exit; @@ -1053,6 +1131,68 @@ x = subglyph->arg1; y = subglyph->arg2; + /* Use a default value dependent on */ + /* TT_CONFIG_OPTION_COMPONENT_OFFSET_SCALED. This is useful for old TT */ + /* fonts which don't set the xxx_COMPONENT_OFFSET bit. */ + +#ifdef TT_CONFIG_OPTION_COMPONENT_OFFSET_SCALED + if ( !( subglyph->flags & UNSCALED_COMPONENT_OFFSET ) && +#else + if ( ( subglyph->flags & SCALED_COMPONENT_OFFSET ) && +#endif + ( subglyph->flags & ( WE_HAVE_A_SCALE | + WE_HAVE_AN_XY_SCALE | + WE_HAVE_A_2X2 )) ) + { +#if 0 + + /*************************************************************************/ + /* */ + /* This algorithm is what Apple documents. But it doesn't work. */ + /* */ + int a = subglyph->transform.xx > 0 ? subglyph->transform.xx + : -subglyph->transform.xx; + int b = subglyph->transform.yx > 0 ? subglyph->transform.yx + : -subglyph->transform.yx; + int c = subglyph->transform.xy > 0 ? subglyph->transform.xy + : -subglyph->transform.xy; + int d = subglyph->transform.yy > 0 ? subglyph->transform.yy + : -subglyph->transform.yy; + int m = a > b ? a : b; + int n = c > d ? c : d; + + + if ( a - b <= 33 && a - b >= -33 ) + m *= 2; + if ( c - d <= 33 && c - d >= -33 ) + n *= 2; + x = FT_MulFix( x, m ); + y = FT_MulFix( y, n ); + +#else /* 0 */ + + /*************************************************************************/ + /* */ + /* This algorithm is a guess and works much better than the above. */ + /* */ + int mac_xscale = FT_SqrtFixed( + FT_MulFix( subglyph->transform.xx, + subglyph->transform.xx ) + + FT_MulFix( subglyph->transform.xy, + subglyph->transform.xy) ); + int mac_yscale = FT_SqrtFixed( + FT_MulFix( subglyph->transform.yy, + subglyph->transform.yy ) + + FT_MulFix( subglyph->transform.yx, + subglyph->transform.yx ) ); + + + x = FT_MulFix( x, mac_xscale ); + y = FT_MulFix( y, mac_yscale ); +#endif /* 0 */ + + } + if ( !( loader->load_flags & FT_LOAD_NO_SCALE ) ) { x = FT_MulFix( x, x_scale ); @@ -1159,7 +1299,7 @@ for ( k = 0; k < num_points; k++ ) - pts->tags[k] &= FT_Curve_Tag_On; + pts->tags[k] &= FT_CURVE_TAG_ON; } cur_to_org( num_points + 2, pts ); @@ -1196,11 +1336,19 @@ face->forget_glyph_frame( loader ); Exit: + +#ifdef FT_CONFIG_OPTION_INCREMENTAL + if ( glyph_data_loaded ) + face->root.internal->incremental_interface->funcs->free_glyph_data( + face->root.internal->incremental_interface->object, + &glyph_data ); +#endif + return error; } - static void + static FT_Error compute_glyph_metrics( TT_Loader loader, FT_UInt glyph_index ) { @@ -1215,9 +1363,9 @@ if ( ( loader->load_flags & FT_LOAD_NO_SCALE ) == 0 ) y_scale = size->root.metrics.y_scale; - if ( glyph->format != ft_glyph_format_composite ) + if ( glyph->format != FT_GLYPH_FORMAT_COMPOSITE ) { - glyph->outline.flags &= ~ft_outline_single_pass; + glyph->outline.flags &= ~FT_OUTLINE_SINGLE_PASS; /* copy outline to our glyph slot */ FT_GlyphLoader_CopyPoints( glyph->internal->loader, loader->gloader ); @@ -1279,10 +1427,33 @@ FT_Pos left; /* scaled vertical left side bearing */ FT_Pos top; /* scaled vertical top side bearing */ FT_Pos advance; /* scaled vertical advance height */ + FT_Bool metrics_found = FALSE; +#ifdef FT_CONFIG_OPTION_INCREMENTAL + + /* If this is an incrementally loaded font see if there are */ + /* overriding metrics for this glyph. */ + if ( face->root.internal->incremental_interface && + face->root.internal->incremental_interface->funcs->get_glyph_metrics ) + { + FT_Incremental_MetricsRec m; + FT_Error error = + face->root.internal->incremental_interface->funcs->get_glyph_metrics( + face->root.internal->incremental_interface->object, + glyph_index, TRUE, &m, &metrics_found ); + + + if ( error ) + return error; - /* Get the unscaled `tsb' and `ah' */ - if ( face->vertical_info && + top_bearing = (FT_Short)m.bearing_y; + advance_height = (FT_UShort)m.advance; + } + +#endif /* FT_CONFIG_OPTION_INCREMENTAL */ + + /* Get the unscaled top bearing and advance height. */ + if ( !metrics_found && face->vertical_info && face->vertical.number_Of_VMetrics > 0 ) { /* Don't assume that both the vertical header and vertical */ @@ -1377,6 +1548,8 @@ /* set glyph dimensions */ glyph->metrics.width = bbox.xMax - bbox.xMin; glyph->metrics.height = bbox.yMax - bbox.yMin; + + return 0; } @@ -1411,7 +1584,7 @@ TT_Load_Glyph( TT_Size size, TT_GlyphSlot glyph, FT_UShort glyph_index, - FT_UInt load_flags ) + FT_Int32 load_flags ) { SFNT_Service sfnt; TT_Face face; @@ -1474,7 +1647,7 @@ glyph->metrics.vertBearingY = (FT_Pos)metrics.vertBearingY << 6; glyph->metrics.vertAdvance = (FT_Pos)metrics.vertAdvance << 6; - glyph->format = ft_glyph_format_bitmap; + glyph->format = FT_GLYPH_FORMAT_BITMAP; if ( load_flags & FT_LOAD_VERTICAL_LAYOUT ) { glyph->bitmap_left = metrics.vertBearingX; @@ -1499,14 +1672,23 @@ /* the table might be accessed from a Postscript stream or something */ /* else... */ - error = face->goto_table( face, TTAG_glyf, stream, 0 ); - if ( error ) +#ifdef FT_CONFIG_OPTION_INCREMENTAL + + /* Don't look for the glyph table if this is an incremental font. */ + if ( !face->root.internal->incremental_interface ) + +#endif + { - FT_ERROR(( "TT_Load_Glyph: could not access glyph table\n" )); - goto Exit; + error = face->goto_table( face, TTAG_glyf, stream, 0 ); + if ( error ) + { + FT_ERROR(( "TT_Load_Glyph: could not access glyph table\n" )); + goto Exit; + } } - FT_MEM_SET( &loader, 0, sizeof ( loader ) ); + FT_MEM_ZERO( &loader, sizeof ( loader ) ); /* update the glyph zone bounds */ { @@ -1552,7 +1734,15 @@ loader.glyph = (FT_GlyphSlot)glyph; loader.stream = stream; - loader.glyf_offset = FT_STREAM_POS(); +#ifdef FT_CONFIG_OPTION_INCREMENTAL + + if ( face->root.internal->incremental_interface ) + loader.glyf_offset = 0; + else + +#endif + + loader.glyf_offset = FT_STREAM_POS(); #ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER @@ -1564,7 +1754,7 @@ #endif /* TT_CONFIG_OPTION_BYTECODE_INTERPRETER */ /* Main loading loop */ - glyph->format = ft_glyph_format_outline; + glyph->format = FT_GLYPH_FORMAT_OUTLINE; glyph->num_subglyphs = 0; error = load_truetype_glyph( &loader, glyph_index ); @@ -1583,7 +1773,7 @@ /* TrueType glyphs at all sizes using the bytecode interpreter. */ /* */ if ( size && size->root.metrics.y_ppem < 24 ) - glyph->outline.flags |= ft_outline_high_precision; + glyph->outline.flags |= FT_OUTLINE_HIGH_PRECISION; Exit: return error; diff --git a/src/libs/freetype2/truetype/ttgload.h b/src/libs/freetype2/truetype/ttgload.h index 37445238efa..04097134f58 100644 --- a/src/libs/freetype2/truetype/ttgload.h +++ b/src/libs/freetype2/truetype/ttgload.h @@ -44,7 +44,7 @@ FT_BEGIN_HEADER TT_Load_Glyph( TT_Size size, TT_GlyphSlot glyph, FT_UShort glyph_index, - FT_UInt load_flags ); + FT_Int32 load_flags ); FT_END_HEADER diff --git a/src/libs/freetype2/truetype/ttinterp.c b/src/libs/freetype2/truetype/ttinterp.c index 28587e6143e..cee0f78a254 100644 --- a/src/libs/freetype2/truetype/ttinterp.c +++ b/src/libs/freetype2/truetype/ttinterp.c @@ -1175,15 +1175,15 @@ { FT_Int32 m, s, hi; FT_UInt32 l, lo; - + /* compute ax*bx as 64-bit value */ l = (FT_UInt32)( ( a & 0xFFFFU ) * b ); m = ( a >> 16 ) * b; - + lo = l + (FT_UInt32)( m << 16 ); hi = ( m >> 16 ) + ( (FT_Int32)l >> 31 ) + ( lo < l ); - + /* divide the result by 2^14 with rounding */ s = hi >> 31; l = lo + (FT_UInt32)s; @@ -1192,7 +1192,7 @@ l = lo + 0x2000U; hi += (l < lo); - + return ( hi << 18 ) | ( l >> 14 ); } @@ -1206,26 +1206,26 @@ { FT_Int32 m, s, hi1, hi2, hi; FT_UInt32 l, lo1, lo2, lo; - + /* compute ax*bx as 64-bit value */ l = (FT_UInt32)( ( ax & 0xFFFFU ) * bx ); m = ( ax >> 16 ) * bx; - + lo1 = l + (FT_UInt32)( m << 16 ); hi1 = ( m >> 16 ) + ( (FT_Int32)l >> 31 ) + ( lo1 < l ); - + /* compute ay*by as 64-bit value */ l = (FT_UInt32)( ( ay & 0xFFFFU ) * by ); m = ( ay >> 16 ) * by; - + lo2 = l + (FT_UInt32)( m << 16 ); hi2 = ( m >> 16 ) + ( (FT_Int32)l >> 31 ) + ( lo2 < l ); - + /* add them */ lo = lo1 + lo2; hi = hi1 + hi2 + ( lo < lo1 ); - + /* divide the result by 2^14 with rounding */ s = hi >> 31; l = lo + (FT_UInt32)s; @@ -1234,7 +1234,7 @@ l = lo + 0x2000U; hi += ( l < lo ); - + return ( hi << 18 ) | ( l >> 14 ); } @@ -1250,33 +1250,33 @@ FT_Int32 m, hi1, hi2, hi; FT_UInt32 l, lo1, lo2, lo; - + /* compute x*x as 64-bit value */ lo = (FT_UInt32)( x & 0xFFFFU ); hi = x >> 16; - + l = lo * lo; m = hi * lo; hi = hi * hi; - + lo1 = l + (FT_UInt32)( m << 17 ); hi1 = hi + ( m >> 15 ) + ( lo1 < l ); - + /* compute y*y as 64-bit value */ lo = (FT_UInt32)( y & 0xFFFFU ); hi = y >> 16; - + l = lo * lo; m = hi * lo; hi = hi * hi; - + lo2 = l + (FT_UInt32)( m << 17 ); hi2 = hi + ( m >> 15 ) + ( lo2 < l ); - + /* add them to get 'x*x+y*y' as 64-bit value */ lo = lo1 + lo2; hi = hi1 + hi2 + ( lo < lo1 ); - + /* compute the square root of this value */ { FT_UInt32 root, rem, test_div; @@ -1303,13 +1303,13 @@ } } while ( --count ); } - + return (FT_Int32)root; } } #else - + /* this version uses FT_Vector_Length which computes the same value */ /* much, much faster.. */ /* */ @@ -1325,7 +1325,7 @@ return FT_Vector_Length( &v ); } - + #endif @@ -1550,7 +1550,7 @@ #endif - zone->tags[point] |= FT_Curve_Tag_Touch_X; + zone->tags[point] |= FT_CURVE_TAG_TOUCH_X; } v = CUR.GS.freeVector.y; @@ -1571,7 +1571,7 @@ #endif - zone->tags[point] |= FT_Curve_Tag_Touch_Y; + zone->tags[point] |= FT_CURVE_TAG_TOUCH_Y; } } @@ -1594,7 +1594,7 @@ FT_UNUSED_EXEC; zone->cur[point].x += distance; - zone->tags[point] |= FT_Curve_Tag_Touch_X; + zone->tags[point] |= FT_CURVE_TAG_TOUCH_X; } @@ -1606,7 +1606,7 @@ FT_UNUSED_EXEC; zone->cur[point].y += distance; - zone->tags[point] |= FT_Curve_Tag_Touch_Y; + zone->tags[point] |= FT_CURVE_TAG_TOUCH_Y; } @@ -5023,7 +5023,7 @@ } } else - CUR.pts.tags[point] ^= FT_Curve_Tag_On; + CUR.pts.tags[point] ^= FT_CURVE_TAG_ON; CUR.GS.loop--; } @@ -5057,7 +5057,7 @@ } for ( I = L; I <= K; I++ ) - CUR.pts.tags[I] |= FT_Curve_Tag_On; + CUR.pts.tags[I] |= FT_CURVE_TAG_ON; } @@ -5085,7 +5085,7 @@ } for ( I = L; I <= K; I++ ) - CUR.pts.tags[I] &= ~FT_Curve_Tag_On; + CUR.pts.tags[I] &= ~FT_CURVE_TAG_ON; } @@ -5153,14 +5153,14 @@ { CUR.zp2.cur[point].x += dx; if ( touch ) - CUR.zp2.tags[point] |= FT_Curve_Tag_Touch_X; + CUR.zp2.tags[point] |= FT_CURVE_TAG_TOUCH_X; } if ( CUR.GS.freeVector.y != 0 ) { CUR.zp2.cur[point].y += dy; if ( touch ) - CUR.zp2.tags[point] |= FT_Curve_Tag_Touch_Y; + CUR.zp2.tags[point] |= FT_CURVE_TAG_TOUCH_Y; } } @@ -5828,7 +5828,7 @@ dx = CUR.zp0.cur[b0].x - CUR.zp1.cur[a0].x; dy = CUR.zp0.cur[b0].y - CUR.zp1.cur[a0].y; - CUR.zp2.tags[point] |= FT_Curve_Tag_Touch_Both; + CUR.zp2.tags[point] |= FT_CURVE_TAG_TOUCH_BOTH; discriminant = TT_MULDIV( dax, -dby, 0x40 ) + TT_MULDIV( day, dbx, 0x40 ); @@ -6006,10 +6006,10 @@ mask = 0xFF; if ( CUR.GS.freeVector.x != 0 ) - mask &= ~FT_Curve_Tag_Touch_X; + mask &= ~FT_CURVE_TAG_TOUCH_X; if ( CUR.GS.freeVector.y != 0 ) - mask &= ~FT_Curve_Tag_Touch_Y; + mask &= ~FT_CURVE_TAG_TOUCH_Y; CUR.zp0.tags[point] &= mask; } @@ -6149,13 +6149,13 @@ if ( CUR.opcode & 1 ) { - mask = FT_Curve_Tag_Touch_X; + mask = FT_CURVE_TAG_TOUCH_X; V.orgs = CUR.pts.org; V.curs = CUR.pts.cur; } else { - mask = FT_Curve_Tag_Touch_Y; + mask = FT_CURVE_TAG_TOUCH_Y; V.orgs = (FT_Vector*)( (FT_Pos*)CUR.pts.org + 1 ); V.curs = (FT_Vector*)( (FT_Pos*)CUR.pts.cur + 1 ); } diff --git a/src/libs/freetype2/truetype/ttobjs.c b/src/libs/freetype2/truetype/ttobjs.c index cab9d1bb263..636d32fa47a 100644 --- a/src/libs/freetype2/truetype/ttobjs.c +++ b/src/libs/freetype2/truetype/ttobjs.c @@ -57,7 +57,7 @@ /*************************************************************************/ /* */ /* <Function> */ - /* TT_Done_GlyphZone */ + /* tt_glyphzone_done */ /* */ /* <Description> */ /* Deallocates a glyph zone. */ @@ -66,7 +66,7 @@ /* zone :: A pointer to the target glyph zone. */ /* */ FT_LOCAL_DEF( void ) - TT_Done_GlyphZone( TT_GlyphZone zone ) + tt_glyphzone_done( TT_GlyphZone zone ) { FT_Memory memory = zone->memory; @@ -84,7 +84,7 @@ /*************************************************************************/ /* */ /* <Function> */ - /* TT_New_GlyphZone */ + /* tt_glyphzone_new */ /* */ /* <Description> */ /* Allocates a new glyph zone. */ @@ -103,7 +103,7 @@ /* FreeType error code. 0 means success. */ /* */ FT_LOCAL_DEF( FT_Error ) - TT_New_GlyphZone( FT_Memory memory, + tt_glyphzone_new( FT_Memory memory, FT_UShort maxPoints, FT_Short maxContours, TT_GlyphZone zone ) @@ -114,7 +114,7 @@ if ( maxPoints > 0 ) maxPoints += 2; - FT_MEM_SET( zone, 0, sizeof ( *zone ) ); + FT_MEM_ZERO( zone, sizeof ( *zone ) ); zone->memory = memory; if ( FT_NEW_ARRAY( zone->org, maxPoints * 2 ) || @@ -122,7 +122,7 @@ FT_NEW_ARRAY( zone->tags, maxPoints ) || FT_NEW_ARRAY( zone->contours, maxContours ) ) { - TT_Done_GlyphZone( zone ); + tt_glyphzone_done( zone ); } return error; @@ -133,7 +133,7 @@ /*************************************************************************/ /* */ /* <Function> */ - /* TT_Face_Init */ + /* tt_face_init */ /* */ /* <Description> */ /* Initializes a given TrueType face object. */ @@ -154,7 +154,7 @@ /* FreeType error code. 0 means success. */ /* */ FT_LOCAL_DEF( FT_Error ) - TT_Face_Init( FT_Stream stream, + tt_face_init( FT_Stream stream, TT_Face face, FT_Int face_index, FT_Int num_params, @@ -197,9 +197,26 @@ goto Exit; if ( face->root.face_flags & FT_FACE_FLAG_SCALABLE ) - error = TT_Load_Locations( face, stream ) || - TT_Load_CVT ( face, stream ) || - TT_Load_Programs ( face, stream ); + { + +#ifdef FT_CONFIG_OPTION_INCREMENTAL + + if ( !face->root.internal->incremental_interface ) + error = tt_face_load_loca( face, stream ); + if ( !error ) + error = tt_face_load_cvt ( face, stream ) || + tt_face_load_fpgm ( face, stream ); + +#else + + if ( !error ) + error = tt_face_load_loca( face, stream ) || + tt_face_load_cvt ( face, stream ) || + tt_face_load_fpgm ( face, stream ); + +#endif + + } /* initialize standard glyph loading routines */ TT_Init_Glyph_Loading( face ); @@ -216,7 +233,7 @@ /*************************************************************************/ /* */ /* <Function> */ - /* TT_Face_Done */ + /* tt_face_done */ /* */ /* <Description> */ /* Finalizes a given face object. */ @@ -225,7 +242,7 @@ /* face :: A pointer to the face object to destroy. */ /* */ FT_LOCAL_DEF( void ) - TT_Face_Done( TT_Face face ) + tt_face_done( TT_Face face ) { FT_Memory memory = face->root.memory; FT_Stream stream = face->root.stream; @@ -266,7 +283,7 @@ /*************************************************************************/ /* */ /* <Function> */ - /* TT_Size_Init */ + /* tt_size_init */ /* */ /* <Description> */ /* Initializes a new TrueType size object. */ @@ -278,7 +295,7 @@ /* FreeType error code. 0 means success. */ /* */ FT_LOCAL_DEF( FT_Error ) - TT_Size_Init( TT_Size size ) + tt_size_init( TT_Size size ) { FT_Error error = TT_Err_Ok; @@ -335,7 +352,7 @@ /* reserve twilight zone */ n_twilight = maxp->maxTwilightPoints; - error = TT_New_GlyphZone( memory, n_twilight, 0, &size->twilight ); + error = tt_glyphzone_new( memory, n_twilight, 0, &size->twilight ); if ( error ) goto Fail_Memory; @@ -436,7 +453,7 @@ Fail_Memory: - TT_Size_Done( size ); + tt_size_done( size ); return error; #endif /* TT_CONFIG_OPTION_BYTECODE_INTERPRETER */ @@ -447,7 +464,7 @@ /*************************************************************************/ /* */ /* <Function> */ - /* TT_Size_Done */ + /* tt_size_done */ /* */ /* <Description> */ /* The TrueType size object finalizer. */ @@ -456,7 +473,7 @@ /* size :: A handle to the target size object. */ /* */ FT_LOCAL_DEF( void ) - TT_Size_Done( TT_Size size ) + tt_size_done( TT_Size size ) { #ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER @@ -479,7 +496,7 @@ size->storage_size = 0; /* twilight zone */ - TT_Done_GlyphZone( &size->twilight ); + tt_glyphzone_done( &size->twilight ); FT_FREE( size->function_defs ); FT_FREE( size->instruction_defs ); @@ -703,7 +720,7 @@ sbit_metrics->y_scale = 1 << 16; #endif - sbit_metrics->ascender = strike->hori.ascender << 6; + sbit_metrics->ascender = strike->hori.ascender << 6; sbit_metrics->descender = strike->hori.descender << 6; /* XXX: Is this correct? */ @@ -738,7 +755,7 @@ /*************************************************************************/ /* */ /* <Function> */ - /* TT_Size_Reset */ + /* tt_size_reset */ /* */ /* <Description> */ /* Resets a TrueType size when resolutions and character dimensions */ @@ -748,7 +765,7 @@ /* size :: A handle to the target size object. */ /* */ FT_LOCAL_DEF( FT_Error ) - TT_Size_Reset( TT_Size size ) + tt_size_reset( TT_Size size ) { FT_Face face; FT_Error error = TT_Err_Ok; @@ -788,7 +805,7 @@ /*************************************************************************/ /* */ /* <Function> */ - /* TT_Driver_Init */ + /* tt_driver_init */ /* */ /* <Description> */ /* Initializes a given TrueType driver object. */ @@ -800,7 +817,7 @@ /* FreeType error code. 0 means success. */ /* */ FT_LOCAL_DEF( FT_Error ) - TT_Driver_Init( TT_Driver driver ) + tt_driver_init( TT_Driver driver ) { FT_Error error; @@ -815,7 +832,7 @@ /*************************************************************************/ /* */ /* <Function> */ - /* TT_Driver_Done */ + /* tt_driver_done */ /* */ /* <Description> */ /* Finalizes a given TrueType driver. */ @@ -824,7 +841,7 @@ /* driver :: A handle to the target TrueType driver. */ /* */ FT_LOCAL_DEF( void ) - TT_Driver_Done( TT_Driver driver ) + tt_driver_done( TT_Driver driver ) { #ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER diff --git a/src/libs/freetype2/truetype/ttobjs.h b/src/libs/freetype2/truetype/ttobjs.h index 4fb48d04106..28bcdc4258c 100644 --- a/src/libs/freetype2/truetype/ttobjs.h +++ b/src/libs/freetype2/truetype/ttobjs.h @@ -108,10 +108,10 @@ FT_BEGIN_HEADER #ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER FT_LOCAL( void ) - TT_Done_GlyphZone( TT_GlyphZone zone ); + tt_glyphzone_done( TT_GlyphZone zone ); FT_LOCAL( FT_Error ) - TT_New_GlyphZone( FT_Memory memory, + tt_glyphzone_new( FT_Memory memory, FT_UShort maxPoints, FT_Short maxContours, TT_GlyphZone zone ); @@ -379,14 +379,14 @@ FT_BEGIN_HEADER /* Face functions */ /* */ FT_LOCAL( FT_Error ) - TT_Face_Init( FT_Stream stream, + tt_face_init( FT_Stream stream, TT_Face face, FT_Int face_index, FT_Int num_params, FT_Parameter* params ); FT_LOCAL( void ) - TT_Face_Done( TT_Face face ); + tt_face_done( TT_Face face ); /*************************************************************************/ @@ -394,13 +394,13 @@ FT_BEGIN_HEADER /* Size functions */ /* */ FT_LOCAL( FT_Error ) - TT_Size_Init( TT_Size size ); + tt_size_init( TT_Size size ); FT_LOCAL( void ) - TT_Size_Done( TT_Size size ); + tt_size_done( TT_Size size ); FT_LOCAL( FT_Error ) - TT_Size_Reset( TT_Size size ); + tt_size_reset( TT_Size size ); /*************************************************************************/ @@ -408,10 +408,10 @@ FT_BEGIN_HEADER /* Driver functions */ /* */ FT_LOCAL( FT_Error ) - TT_Driver_Init( TT_Driver driver ); + tt_driver_init( TT_Driver driver ); FT_LOCAL( void ) - TT_Driver_Done( TT_Driver driver ); + tt_driver_done( TT_Driver driver ); FT_END_HEADER diff --git a/src/libs/freetype2/truetype/ttpload.c b/src/libs/freetype2/truetype/ttpload.c index 19bd0f87c28..4066cd7c282 100644 --- a/src/libs/freetype2/truetype/ttpload.c +++ b/src/libs/freetype2/truetype/ttpload.c @@ -40,7 +40,7 @@ /*************************************************************************/ /* */ /* <Function> */ - /* TT_Load_Locations */ + /* tt_face_load_loca */ /* */ /* <Description> */ /* Loads the locations table. */ @@ -55,7 +55,7 @@ /* FreeType error code. 0 means success. */ /* */ FT_LOCAL_DEF( FT_Error ) - TT_Load_Locations( TT_Face face, + tt_face_load_loca( TT_Face face, FT_Stream stream ) { FT_Error error; @@ -129,7 +129,7 @@ /*************************************************************************/ /* */ /* <Function> */ - /* TT_Load_CVT */ + /* tt_face_load_cvt */ /* */ /* <Description> */ /* Loads the control value table into a face object. */ @@ -144,8 +144,8 @@ /* FreeType error code. 0 means success. */ /* */ FT_LOCAL_DEF( FT_Error ) - TT_Load_CVT( TT_Face face, - FT_Stream stream ) + tt_face_load_cvt( TT_Face face, + FT_Stream stream ) { FT_Error error; FT_Memory memory = stream->memory; @@ -194,7 +194,7 @@ /*************************************************************************/ /* */ /* <Function> */ - /* TT_Load_Progams */ + /* tt_face_load_fpgm */ /* */ /* <Description> */ /* Loads the font program and the cvt program. */ @@ -209,8 +209,8 @@ /* FreeType error code. 0 means success. */ /* */ FT_LOCAL_DEF( FT_Error ) - TT_Load_Programs( TT_Face face, - FT_Stream stream ) + tt_face_load_fpgm( TT_Face face, + FT_Stream stream ) { FT_Error error; FT_ULong table_len; diff --git a/src/libs/freetype2/truetype/ttpload.h b/src/libs/freetype2/truetype/ttpload.h index c83b2f269a5..3f8cd64ff72 100644 --- a/src/libs/freetype2/truetype/ttpload.h +++ b/src/libs/freetype2/truetype/ttpload.h @@ -28,16 +28,16 @@ FT_BEGIN_HEADER FT_LOCAL( FT_Error ) - TT_Load_Locations( TT_Face face, + tt_face_load_loca( TT_Face face, FT_Stream stream ); FT_LOCAL( FT_Error ) - TT_Load_CVT( TT_Face face, - FT_Stream stream ); + tt_face_load_cvt( TT_Face face, + FT_Stream stream ); FT_LOCAL( FT_Error ) - TT_Load_Programs( TT_Face face, - FT_Stream stream ); + tt_face_load_fpgm( TT_Face face, + FT_Stream stream ); FT_END_HEADER diff --git a/src/libs/freetype2/type1/t1afm.c b/src/libs/freetype2/type1/t1afm.c index a8f993f0920..71ccd1ea74b 100644 --- a/src/libs/freetype2/type1/t1afm.c +++ b/src/libs/freetype2/type1/t1afm.c @@ -56,10 +56,10 @@ FT_Byte* limit, T1_Font type1 ) { - FT_Byte* p = *start; - FT_Int len; - FT_UInt result = 0; - char temp[64]; + FT_Byte* p = *start; + FT_PtrDist len; + FT_UInt result = 0; + char temp[64]; /* skip whitespace */ @@ -72,7 +72,7 @@ while ( IS_ALPHANUM( *p ) && p < limit ) p++; - len = (FT_Int)( p - *start ); + len = p - *start; if ( len > 0 && len < 64 ) { diff --git a/src/libs/freetype2/type1/t1driver.c b/src/libs/freetype2/type1/t1driver.c index 968f767dfd8..b255f9d7cb5 100644 --- a/src/libs/freetype2/type1/t1driver.c +++ b/src/libs/freetype2/type1/t1driver.c @@ -227,233 +227,6 @@ #endif /* T1_CONFIG_OPTION_NO_AFM */ - /*************************************************************************/ - /* */ - /* <Function> */ - /* 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 - 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 == 0xFFFFU ) - result = 0; - goto Exit; - - /*******************************************************************/ - /* */ - /* ISOLatin1 encoding support */ - /* */ - case ft_encoding_latin_1: - /* ISOLatin1 is the first page of Unicode */ - if ( charcode < 256 && psnames->unicode_value ) - { - result = psnames->lookup_unicode( &face->unicode_map, - (FT_ULong)charcode ); - - /* the function returns 0xFFFF if the Unicode charcode has */ - /* no corresponding glyph */ - if ( result == 0xFFFFU ) - 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> */ - /* Get_Next_Char */ - /* */ - /* <Description> */ - /* Uses a charmap to return the next encoded char. */ - /* */ - /* <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 - 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 ); - - /*******************************************************************/ - /* */ - /* ISOLatin1 encoding support */ - /* */ - case ft_encoding_latin_1: - { - FT_Long code; - - - /* use the `PSNames' module to synthetize the Unicode charmap */ - code = psnames->next_unicode( &face->unicode_map, - (FT_ULong)charcode ); - if ( code < 256 ) - return code; - break; - } - - /*******************************************************************/ - /* */ - /* 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++; - } - } - - /*******************************************************************/ - /* */ - /* 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 @@ -491,7 +264,6 @@ (FT_Size_ResetPointsFunc) T1_Size_Reset, (FT_Size_ResetPixelsFunc) T1_Size_Reset, (FT_Slot_LoadFunc) T1_Load_Glyph, - (FT_CharMap_CharIndexFunc)Get_Char_Index, #ifdef T1_CONFIG_OPTION_NO_AFM (FT_Face_GetKerningFunc) 0, @@ -500,9 +272,7 @@ (FT_Face_GetKerningFunc) Get_Kerning, (FT_Face_AttachFunc) T1_Read_AFM, #endif - (FT_Face_GetAdvancesFunc) 0, - - (FT_CharMap_CharNextFunc) Get_Next_Char + (FT_Face_GetAdvancesFunc) 0 }; diff --git a/src/libs/freetype2/type1/t1gload.c b/src/libs/freetype2/type1/t1gload.c index 6bf71cfcf6c..0a3155db3fc 100644 --- a/src/libs/freetype2/type1/t1gload.c +++ b/src/libs/freetype2/type1/t1gload.c @@ -53,21 +53,93 @@ /*************************************************************************/ + FT_LOCAL_DEF( FT_Error ) + T1_Parse_Glyph_And_Get_Char_String( T1_Decoder decoder, + FT_UInt glyph_index, + FT_Data* char_string ) + { + T1_Face face = (T1_Face)decoder->builder.face; + T1_Font type1 = &face->type1; + FT_Error error = 0; + + + decoder->font_matrix = type1->font_matrix; + decoder->font_offset = type1->font_offset; + +#ifdef FT_CONFIG_OPTION_INCREMENTAL + + /* For incremental fonts get the character data using the */ + /* callback function. */ + if ( face->root.internal->incremental_interface ) + error = face->root.internal->incremental_interface->funcs->get_glyph_data( + face->root.internal->incremental_interface->object, + glyph_index, char_string ); + else + +#endif + + /* For ordinary fonts get the character data stored in the face record. */ + { + char_string->pointer = type1->charstrings[glyph_index]; + char_string->length = type1->charstrings_len[glyph_index]; + } + + if ( !error ) + error = decoder->funcs.parse_charstrings( + decoder, (FT_Byte*)char_string->pointer, + char_string->length ); + +#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 + + return error; + } + + FT_CALLBACK_DEF( FT_Error ) T1_Parse_Glyph( T1_Decoder decoder, FT_UInt glyph_index ) { - T1_Face face = (T1_Face)decoder->builder.face; - T1_Font type1 = &face->type1; + FT_Data glyph_data; + FT_Error error = T1_Parse_Glyph_And_Get_Char_String( + decoder, glyph_index, &glyph_data ); - decoder->font_matrix = type1->font_matrix; - decoder->font_offset = type1->font_offset; +#ifdef FT_CONFIG_OPTION_INCREMENTAL + if ( !error ) + { + T1_Face face = (T1_Face)decoder->builder.face; + - return decoder->funcs.parse_charstrings( - decoder, - type1->charstrings [glyph_index], - type1->charstrings_len[glyph_index] ); + if ( face->root.internal->incremental_interface ) + face->root.internal->incremental_interface->funcs->free_glyph_data( + face->root.internal->incremental_interface->object, + &glyph_data ); + } +#endif + + return error; } @@ -92,6 +164,7 @@ (FT_Byte**)type1->glyph_names, face->blend, 0, + FT_RENDER_MODE_NORMAL, T1_Parse_Glyph ); if ( error ) return error; @@ -142,7 +215,7 @@ T1_Load_Glyph( T1_GlyphSlot glyph, T1_Size size, FT_UInt glyph_index, - FT_Int load_flags ) + FT_Int32 load_flags ) { FT_Error error; T1_DecoderRec decoder; @@ -154,6 +227,8 @@ FT_Matrix font_matrix; FT_Vector font_offset; + FT_Data glyph_data; + FT_Bool glyph_data_loaded = 0; if ( load_flags & FT_LOAD_NO_RECURSE ) @@ -168,7 +243,7 @@ hinting = FT_BOOL( ( load_flags & FT_LOAD_NO_SCALE ) == 0 && ( load_flags & FT_LOAD_NO_HINTING ) == 0 ); - glyph->root.format = ft_glyph_format_outline; + glyph->root.format = FT_GLYPH_FORMAT_OUTLINE; error = decoder_funcs->init( &decoder, (FT_Face)face, @@ -177,6 +252,7 @@ (FT_Byte**)type1->glyph_names, face->blend, FT_BOOL( hinting ), + FT_LOAD_TARGET_MODE(load_flags), T1_Parse_Glyph ); if ( error ) goto Exit; @@ -188,11 +264,12 @@ decoder.subrs = type1->subrs; decoder.subrs_len = type1->subrs_len; - /* now load the unscaled outline */ - error = T1_Parse_Glyph( &decoder, glyph_index ); + error = T1_Parse_Glyph_And_Get_Char_String( &decoder, glyph_index, + &glyph_data ); if ( error ) goto Exit; + glyph_data_loaded = 1; font_matrix = decoder.font_matrix; font_offset = decoder.font_offset; @@ -205,8 +282,8 @@ /* bearing the yMax */ if ( !error ) { - glyph->root.outline.flags &= ft_outline_owner; - glyph->root.outline.flags |= ft_outline_reverse_fill; + glyph->root.outline.flags &= FT_OUTLINE_OWNER; + glyph->root.outline.flags |= FT_OUTLINE_REVERSE_FILL; /* for composite glyphs, return only left side bearing and */ /* advance width */ @@ -239,10 +316,10 @@ glyph->root.linearVertAdvance = 0; - glyph->root.format = ft_glyph_format_outline; + glyph->root.format = FT_GLYPH_FORMAT_OUTLINE; if ( size && size->root.metrics.y_ppem < 24 ) - glyph->root.outline.flags |= ft_outline_high_precision; + glyph->root.outline.flags |= FT_OUTLINE_HIGH_PRECISION; #if 1 /* apply the font matrix, if any */ @@ -311,11 +388,27 @@ /* Set control data to the glyph charstrings. Note that this is */ /* _not_ zero-terminated. */ - glyph->root.control_data = type1->charstrings [glyph_index]; - glyph->root.control_len = type1->charstrings_len[glyph_index]; + glyph->root.control_data = (FT_Byte*)glyph_data.pointer; + glyph->root.control_len = glyph_data.length; } + Exit: + +#ifdef FT_CONFIG_OPTION_INCREMENTAL + if ( glyph_data_loaded && face->root.internal->incremental_interface ) + { + face->root.internal->incremental_interface->funcs->free_glyph_data( + face->root.internal->incremental_interface->object, + &glyph_data ); + + /* Set the control data to null - it is no longer available if */ + /* loaded incrementally. */ + glyph->root.control_data = 0; + glyph->root.control_len = 0; + } +#endif + return error; } diff --git a/src/libs/freetype2/type1/t1gload.h b/src/libs/freetype2/type1/t1gload.h index 4b7ba5d62de..0324a0d1546 100644 --- a/src/libs/freetype2/type1/t1gload.h +++ b/src/libs/freetype2/type1/t1gload.h @@ -35,7 +35,7 @@ FT_BEGIN_HEADER T1_Load_Glyph( T1_GlyphSlot glyph, T1_Size size, FT_UInt glyph_index, - FT_Int load_flags ); + FT_Int32 load_flags ); FT_END_HEADER diff --git a/src/libs/freetype2/type1/t1load.c b/src/libs/freetype2/type1/t1load.c index d2f810d942c..70fda88d7a1 100644 --- a/src/libs/freetype2/type1/t1load.c +++ b/src/libs/freetype2/type1/t1load.c @@ -123,6 +123,7 @@ /* allocate the blend `private' and `font_info' dictionaries */ if ( FT_NEW_ARRAY( blend->font_infos[1], num_designs ) || FT_NEW_ARRAY( blend->privates[1], num_designs ) || + FT_NEW_ARRAY( blend->bboxes[1], num_designs ) || FT_NEW_ARRAY( blend->weight_vector, num_designs * 2 ) ) goto Exit; @@ -130,11 +131,13 @@ blend->font_infos[0] = &face->type1.font_info; blend->privates [0] = &face->type1.private_dict; + blend->bboxes [0] = &face->type1.font_bbox; for ( nn = 2; nn <= num_designs; nn++ ) { blend->privates[nn] = blend->privates [nn - 1] + 1; blend->font_infos[nn] = blend->font_infos[nn - 1] + 1; + blend->bboxes[nn] = blend->bboxes [nn - 1] + 1; } blend->num_designs = num_designs; @@ -347,11 +350,13 @@ /* release blend `private' and `font info' dictionaries */ FT_FREE( blend->privates[1] ); FT_FREE( blend->font_infos[1] ); + FT_FREE( blend->bboxes[1] ); for ( n = 0; n < num_designs; n++ ) { blend->privates [n] = 0; blend->font_infos[n] = 0; + blend->bboxes [n] = 0; } /* release weight vectors */ @@ -410,16 +415,16 @@ /* each token is an immediate containing the name of the axis */ for ( n = 0; n < num_axis; n++ ) { - T1_Token token = axis_tokens + n; - FT_Byte* name; - FT_Int len; + T1_Token token = axis_tokens + n; + FT_Byte* name; + FT_PtrDist len; /* skip first slash, if any */ if ( token->start[0] == '/' ) token->start++; - len = (FT_Int)( token->limit - token->start ); + len = token->limit - token->start; if ( len <= 0 ) { error = T1_Err_Invalid_File_Format; @@ -735,6 +740,18 @@ } break; + case T1_FIELD_LOCATION_BBOX: + dummy_object = &face->type1.font_bbox; + objects = &dummy_object; + max_objects = 0; + + if ( blend ) + { + objects = (void**)blend->bboxes; + max_objects = blend->num_designs; + } + break; + default: dummy_object = &face->type1; objects = &dummy_object; @@ -777,7 +794,7 @@ static int read_binary_data( T1_Parser parser, - FT_Int* size, + FT_Long* size, FT_Byte** base ) { FT_Byte* cur; @@ -821,13 +838,13 @@ parse_font_name( T1_Face face, T1_Loader loader ) { - T1_Parser parser = &loader->parser; - FT_Error error; - FT_Memory memory = parser->root.memory; - FT_Int len; - FT_Byte* cur; - FT_Byte* cur2; - FT_Byte* limit; + T1_Parser parser = &loader->parser; + FT_Error error; + FT_Memory memory = parser->root.memory; + FT_PtrDist len; + FT_Byte* cur; + FT_Byte* cur2; + FT_Byte* limit; if ( face->type1.font_name ) @@ -847,7 +864,7 @@ while ( cur2 < limit && is_alpha( *cur2 ) ) cur2++; - len = (FT_Int)( cur2 - cur ); + len = cur2 - cur; if ( len > 0 ) { if ( FT_ALLOC( face->type1.font_name, len + 1 ) ) @@ -863,6 +880,7 @@ } +#if 0 static void parse_font_bbox( T1_Face face, T1_Loader loader ) @@ -878,6 +896,7 @@ bbox->xMax = FT_RoundFix( temp[2] ); bbox->yMax = FT_RoundFix( temp[3] ); } +#endif static void @@ -968,7 +987,7 @@ return; /* read the number of entries in the encoding, should be 256 */ - count = T1_ToInt( parser ); + count = (FT_Int)T1_ToInt( parser ); if ( parser->root.error ) return; @@ -1036,7 +1055,7 @@ parser->root.cursor = cur; - charcode = T1_ToInt( parser ); + charcode = (FT_Int)T1_ToInt( parser ); cur = parser->root.cursor; /* skip whitespace */ @@ -1047,14 +1066,14 @@ { /* bingo, we have an immediate name -- it must be a */ /* character name */ - FT_Byte* cur2 = cur + 1; - FT_Int len; + FT_Byte* cur2 = cur + 1; + FT_PtrDist len; while ( cur2 < limit && is_alpha( *cur2 ) ) cur2++; - len = (FT_Int)( cur2 - cur - 1 ); + len = cur2 - cur - 1; parser->root.error = T1_Add_Table( char_table, charcode, cur + 1, len + 1 ); @@ -1114,7 +1133,7 @@ /* with synthetic fonts, it's possible we get here twice */ return; - loader->num_subrs = T1_ToInt( parser ); + loader->num_subrs = (FT_Int)T1_ToInt( parser ); if ( parser->root.error ) return; @@ -1134,7 +1153,7 @@ /* */ for ( n = 0; n < loader->num_subrs; n++ ) { - FT_Int idx, size; + FT_Long idx, size; FT_Byte* base; @@ -1218,7 +1237,7 @@ /* with synthetic fonts, it's possible we get here twice */ return; - loader->num_glyphs = T1_ToInt( parser ); + loader->num_glyphs = (FT_Int)T1_ToInt( parser ); if ( parser->root.error ) return; @@ -1249,7 +1268,7 @@ for (;;) { - FT_Int size; + FT_Long size; FT_Byte* base; @@ -1281,13 +1300,13 @@ T1_Skip_Alpha( parser ); else { - FT_Byte* cur2 = cur + 1; - FT_Int len; + FT_Byte* cur2 = cur + 1; + FT_PtrDist len; while ( cur2 < limit && is_alpha( *cur2 ) ) cur2++; - len = (FT_Int)( cur2 - cur - 1 ); + len = cur2 - cur - 1; error = T1_Add_Table( name_table, n, cur + 1, len + 1 ); if ( error ) @@ -1464,7 +1483,9 @@ /* now add the special functions... */ T1_FIELD_CALLBACK( "FontName", parse_font_name ) +#if 0 T1_FIELD_CALLBACK( "FontBBox", parse_font_bbox ) +#endif T1_FIELD_CALLBACK( "FontMatrix", parse_font_matrix ) T1_FIELD_CALLBACK( "Encoding", parse_encoding ) T1_FIELD_CALLBACK( "Subrs", parse_subrs ) @@ -1537,8 +1558,8 @@ /* look for immediates */ else if ( *cur == '/' && cur + 2 < limit ) { - FT_Byte* cur2; - FT_Int len; + FT_Byte* cur2; + FT_PtrDist len; cur++; @@ -1546,7 +1567,7 @@ while ( cur2 < limit && is_alpha( *cur2 ) ) cur2++; - len = (FT_Int)( cur2 - cur ); + len = cur2 - cur; if ( len > 0 && len < 22 ) { { @@ -1563,10 +1584,10 @@ if ( !name ) break; - if ( cur[0] == name[0] && - len == (FT_Int)ft_strlen( (const char*)name ) ) + if ( cur[0] == name[0] && + len == ft_strlen( (const char*)name ) ) { - FT_Int n; + FT_PtrDist n; for ( n = 1; n < len; n++ ) @@ -1605,7 +1626,7 @@ { FT_UNUSED( face ); - FT_MEM_SET( loader, 0, sizeof ( *loader ) ); + FT_MEM_ZERO( loader, sizeof ( *loader ) ); loader->num_glyphs = 0; loader->num_chars = 0; @@ -1653,6 +1674,9 @@ /* default lenIV */ type1->private_dict.lenIV = 4; + /* default blue fuzz, we put it there since 0 is a valid value */ + type1->private_dict.blue_fuzz = 1; + parser = &loader.parser; error = T1_New_Parser( parser, face->root.stream, @@ -1687,11 +1711,14 @@ type1->subrs_len = loader.subrs.lengths; } - if ( !loader.charstrings.init ) - { - FT_ERROR(( "T1_Open_Face: no charstrings array in face!\n" )); - error = T1_Err_Invalid_File_Format; - } +#ifdef FT_CONFIG_OPTION_INCREMENTAL + if ( !face->root.internal->incremental_interface ) +#endif + if ( !loader.charstrings.init ) + { + FT_ERROR(( "T1_Open_Face: no charstrings array in face!\n" )); + error = T1_Err_Invalid_File_Format; + } loader.charstrings.init = 0; type1->charstrings_block = loader.charstrings.block; diff --git a/src/libs/freetype2/type1/t1objs.c b/src/libs/freetype2/type1/t1objs.c index 5a6008d290e..59e7cb68649 100644 --- a/src/libs/freetype2/type1/t1objs.c +++ b/src/libs/freetype2/type1/t1objs.c @@ -427,8 +427,6 @@ root->internal->max_contours = 0; } -#ifdef FT_CONFIG_OPTION_USE_CMAPS - { FT_Face root = &face->root; @@ -445,7 +443,7 @@ /* first of all, try to synthetize a Unicode charmap */ charmap.platform_id = 3; charmap.encoding_id = 1; - charmap.encoding = ft_encoding_unicode; + charmap.encoding = FT_ENCODING_UNICODE; FT_CMap_New( cmap_classes->unicode, NULL, &charmap, NULL ); @@ -456,25 +454,25 @@ switch ( face->type1.encoding_type ) { case T1_ENCODING_TYPE_STANDARD: - charmap.encoding = ft_encoding_adobe_standard; + charmap.encoding = FT_ENCODING_ADOBE_STANDARD; charmap.encoding_id = 0; clazz = cmap_classes->standard; break; case T1_ENCODING_TYPE_EXPERT: - charmap.encoding = ft_encoding_adobe_expert; + charmap.encoding = FT_ENCODING_ADOBE_EXPERT; charmap.encoding_id = 1; clazz = cmap_classes->expert; break; case T1_ENCODING_TYPE_ARRAY: - charmap.encoding = ft_encoding_adobe_custom; + charmap.encoding = FT_ENCODING_ADOBE_CUSTOM; charmap.encoding_id = 2; clazz = cmap_classes->custom; break; case T1_ENCODING_TYPE_ISOLATIN1: - charmap.encoding = ft_encoding_latin_1; + charmap.encoding = FT_ENCODING_ADOBE_LATIN_1; charmap.encoding_id = 3; clazz = cmap_classes->unicode; break; @@ -486,87 +484,14 @@ if ( clazz ) FT_CMap_New( clazz, NULL, &charmap, NULL ); +#if 0 /* Select default charmap */ if (root->num_charmaps) root->charmap = root->charmaps[0]; +#endif } } -#else /* !FT_CONFIG_OPTION_USE_CMAPS */ - - /* charmap support -- synthetize unicode charmap if possible */ - { - FT_Face root = &face->root; - FT_CharMap charmap = face->charmaprecs; - - - /* synthesize a Unicode charmap if there is support in the `PSNames' */ - /* module */ - if ( psnames ) - { - if ( psnames->unicode_value ) - { - error = psnames->build_unicodes( - root->memory, - face->type1.num_glyphs, - (const char**)face->type1.glyph_names, - &face->unicode_map ); - if ( !error ) - { - root->charmap = charmap; - charmap->face = (FT_Face)face; - charmap->encoding = ft_encoding_unicode; - charmap->platform_id = 3; - charmap->encoding_id = 1; - charmap++; - } - - /* simply clear the error in case of failure (which really) */ - /* means that out of memory or no unicode glyph names */ - error = T1_Err_Ok; - } - } - - /* now, support either the standard, expert, or custom encoding */ - charmap->face = (FT_Face)face; - charmap->platform_id = 7; /* a new platform id for Adobe fonts? */ - - switch ( face->type1.encoding_type ) - { - case T1_ENCODING_TYPE_STANDARD: - charmap->encoding = ft_encoding_adobe_standard; - charmap->encoding_id = 0; - break; - - case T1_ENCODING_TYPE_EXPERT: - charmap->encoding = ft_encoding_adobe_expert; - charmap->encoding_id = 1; - break; - - case T1_ENCODING_TYPE_ARRAY: - charmap->encoding = ft_encoding_adobe_custom; - charmap->encoding_id = 2; - break; - - case T1_ENCODING_TYPE_ISOLATIN1: - charmap->encoding = ft_encoding_latin_1; - charmap->encoding_id = 3; - break; - - default: - FT_ERROR(( "T1_Face_Init: invalid encoding\n" )); - error = T1_Err_Invalid_File_Format; - goto Exit; - } - - root->charmaps = face->charmaps; - root->num_charmaps = charmap - face->charmaprecs + 1; - face->charmaps[0] = &face->charmaprecs[0]; - face->charmaps[1] = &face->charmaprecs[1]; - } - -#endif /* !FT_CONFIG_OPTION_USE_CMAPS */ - Exit: return error; } diff --git a/src/libs/freetype2/type1/t1parse.c b/src/libs/freetype2/type1/t1parse.c index 3107e0a08ec..c1783f02936 100644 --- a/src/libs/freetype2/type1/t1parse.c +++ b/src/libs/freetype2/type1/t1parse.c @@ -440,7 +440,7 @@ } /* put a safeguard */ - parser->private_len = (FT_Int)( write - parser->private_dict ); + parser->private_len = write - parser->private_dict; *write++ = 0; } } diff --git a/src/libs/freetype2/type1/t1parse.h b/src/libs/freetype2/type1/t1parse.h index 1341493a740..ecc206739ef 100644 --- a/src/libs/freetype2/type1/t1parse.h +++ b/src/libs/freetype2/type1/t1parse.h @@ -64,10 +64,10 @@ FT_BEGIN_HEADER FT_Stream stream; FT_Byte* base_dict; - FT_Int base_len; + FT_Long base_len; FT_Byte* private_dict; - FT_Int private_len; + FT_Long private_len; FT_Byte in_pfb; FT_Byte in_memory; diff --git a/src/libs/freetype2/type1/t1tokens.h b/src/libs/freetype2/type1/t1tokens.h index 5f5d8ceef63..dea50547b89 100644 --- a/src/libs/freetype2/type1/t1tokens.h +++ b/src/libs/freetype2/type1/t1tokens.h @@ -69,5 +69,12 @@ T1_FIELD_NUM( "FontType", font_type ) T1_FIELD_NUM( "StrokeWidth", stroke_width ) +#undef FT_STRUCTURE +#define FT_STRUCTURE FT_BBox +#undef T1CODE +#define T1CODE T1_FIELD_LOCATION_BBOX + + T1_FIELD_BBOX("FontBBox", xMin ) + /* END */ diff --git a/src/libs/freetype2/type42/t42drivr.c b/src/libs/freetype2/type42/t42drivr.c index a053318513a..65bf2e8aaf9 100644 --- a/src/libs/freetype2/type42/t42drivr.c +++ b/src/libs/freetype2/type42/t42drivr.c @@ -61,10 +61,10 @@ { FT_UInt len = (FT_UInt)( ft_strlen( gname ) ); - + if ( len >= buffer_max ) len = buffer_max - 1; - + FT_MEM_COPY( buffer, gname, len ); ((FT_Byte*)buffer)[len] = 0; } @@ -158,14 +158,11 @@ (FT_Size_ResetPointsFunc) T42_Size_SetChars, (FT_Size_ResetPixelsFunc) T42_Size_SetPixels, (FT_Slot_LoadFunc) T42_GlyphSlot_Load, - (FT_CharMap_CharIndexFunc)T42_CMap_CharIndex, (FT_Face_GetKerningFunc) 0, (FT_Face_AttachFunc) 0, - (FT_Face_GetAdvancesFunc) 0, - - (FT_CharMap_CharNextFunc) T42_CMap_CharNext, + (FT_Face_GetAdvancesFunc) 0 }; diff --git a/src/libs/freetype2/type42/t42objs.c b/src/libs/freetype2/type42/t42objs.c index 7e90cfc50e2..dcc807701fb 100644 --- a/src/libs/freetype2/type42/t42objs.c +++ b/src/libs/freetype2/type42/t42objs.c @@ -147,7 +147,7 @@ T42_Face face, FT_Int face_index, FT_Int num_params, - FT_Parameter* params) + FT_Parameter* params ) { FT_Error error; PSNames_Service psnames; @@ -283,8 +283,6 @@ if ( face->ttf_face->face_flags & FT_FACE_FLAG_VERTICAL ) root->face_flags |= FT_FACE_FLAG_VERTICAL; -#ifdef FT_CONFIG_OPTION_USE_CMAPS - { if ( psnames && psaux ) { @@ -298,7 +296,7 @@ /* first of all, try to synthetize a Unicode charmap */ charmap.platform_id = 3; charmap.encoding_id = 1; - charmap.encoding = ft_encoding_unicode; + charmap.encoding = FT_ENCODING_UNICODE; FT_CMap_New( cmap_classes->unicode, NULL, &charmap, NULL ); @@ -309,25 +307,25 @@ switch ( face->type1.encoding_type ) { case T1_ENCODING_TYPE_STANDARD: - charmap.encoding = ft_encoding_adobe_standard; + charmap.encoding = FT_ENCODING_ADOBE_STANDARD; charmap.encoding_id = 0; clazz = cmap_classes->standard; break; case T1_ENCODING_TYPE_EXPERT: - charmap.encoding = ft_encoding_adobe_expert; + charmap.encoding = FT_ENCODING_ADOBE_EXPERT; charmap.encoding_id = 1; clazz = cmap_classes->expert; break; case T1_ENCODING_TYPE_ARRAY: - charmap.encoding = ft_encoding_adobe_custom; + charmap.encoding = FT_ENCODING_ADOBE_CUSTOM; charmap.encoding_id = 2; clazz = cmap_classes->custom; break; case T1_ENCODING_TYPE_ISOLATIN1: - charmap.encoding = ft_encoding_latin_1; + charmap.encoding = FT_ENCODING_ADOBE_LATIN_1; charmap.encoding_id = 3; clazz = cmap_classes->unicode; break; @@ -339,84 +337,13 @@ if ( clazz ) FT_CMap_New( clazz, NULL, &charmap, NULL ); +#if 0 /* Select default charmap */ if (root->num_charmaps) root->charmap = root->charmaps[0]; +#endif } } - -#else /* !FT_CONFIG_OPTION_USE_CMAPS */ - - /* charmap support -- synthetize unicode charmap if possible */ - { - FT_CharMap charmap = face->charmaprecs; - - - /* synthesize a Unicode charmap if there is support in the `PSNames' */ - /* module */ - if ( psnames && psnames->unicode_value ) - { - error = psnames->build_unicodes( root->memory, - face->type1.num_glyphs, - (const char**)face->type1.glyph_names, - &face->unicode_map ); - if ( !error ) - { - root->charmap = charmap; - charmap->face = (FT_Face)face; - charmap->encoding = ft_encoding_unicode; - charmap->platform_id = 3; - charmap->encoding_id = 1; - charmap++; - } - - /* XXX: Is the following code correct? It is used in t1objs.c */ - - /* simply clear the error in case of failure (which really) */ - /* means that out of memory or no unicode glyph names */ - error = T42_Err_Ok; - } - - /* now, support either the standard, expert, or custom encoding */ - charmap->face = (FT_Face)face; - charmap->platform_id = 7; /* a new platform id for Adobe fonts? */ - - switch ( face->type1.encoding_type ) - { - case T1_ENCODING_TYPE_STANDARD: - charmap->encoding = ft_encoding_adobe_standard; - charmap->encoding_id = 0; - break; - - case T1_ENCODING_TYPE_EXPERT: - charmap->encoding = ft_encoding_adobe_expert; - charmap->encoding_id = 1; - break; - - case T1_ENCODING_TYPE_ARRAY: - charmap->encoding = ft_encoding_adobe_custom; - charmap->encoding_id = 2; - break; - - case T1_ENCODING_TYPE_ISOLATIN1: - charmap->encoding = ft_encoding_latin_1; - charmap->encoding_id = 3; - break; - - default: - FT_ERROR(( "T42_Face_Init: invalid encoding\n" )); - error = T42_Err_Invalid_File_Format; - goto Exit; - } - - root->charmaps = face->charmaps; - root->num_charmaps = charmap - face->charmaprecs + 1; - face->charmaps[0] = &face->charmaprecs[0]; - face->charmaps[1] = &face->charmaprecs[1]; - } - -#endif /* !FT_CONFIG_OPTION_USE_CMAPS */ - Exit: return error; } @@ -511,118 +438,6 @@ } - FT_LOCAL_DEF( FT_UInt ) - T42_CMap_CharIndex( FT_CharMap charmap, - FT_Long charcode ) - { - T42_Face face; - FT_UInt result = 0; - PSNames_Service psnames; - - - face = (T42_Face)charmap->face; - psnames = (PSNames_Service)face->psnames; - if (!psnames ) - goto Exit; - - switch ( charmap->encoding ) - { - /*******************************************************************/ - /* */ - /* Unicode encoding support */ - /* */ - case ft_encoding_unicode: - /* if this charmap is used, we ignore the encoding of the font and */ - /* 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 == 0xFFFFU ) - result = 0; - - /* The result returned is the index (position)in the CharStrings */ - /* array. This must be used now to get the value associated to */ - /* that glyph_name, which is the real index within the truetype */ - /* structure. */ - result = ft_atoi( (const char*)face->type1.charstrings[result] ); - goto Exit; - - /*******************************************************************/ - /* */ - /* ISOLatin1 encoding support */ - /* */ - case ft_encoding_latin_1: - /* ISOLatin1 is the first page of Unicode */ - if ( charcode < 256 && psnames->unicode_value ) - { - result = psnames->lookup_unicode( &face->unicode_map, - (FT_ULong)charcode ); - - /* the function returns 0xFFFF if the Unicode charcode has */ - /* no corresponding glyph */ - if ( result == 0xFFFFU ) - 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 ) - { - FT_UInt idx = encoding->char_index[charcode]; - - - result = ft_atoi( (const char *)face->type1.charstrings[idx] ); - } - 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 && ( ft_strcmp( gname, glyph_name ) == 0 ) ) - { - result = ft_atoi( (const char *)face->type1.charstrings[n] ); - break; - } - } - } - } - - Exit: - return result; - } FT_LOCAL_DEF( FT_Error ) @@ -718,7 +533,7 @@ FT_Activate_Size(size->ttsize); - + return FT_Set_Char_Size( t42face->ttf_face, char_width, char_height, @@ -737,7 +552,7 @@ FT_Activate_Size(size->ttsize); - + return FT_Set_Pixel_Sizes( t42face->ttf_face, pixel_width, pixel_height ); @@ -769,7 +584,7 @@ slot->control_data = 0; slot->control_len = 0; slot->other = 0; - slot->format = ft_glyph_format_none; + slot->format = FT_GLYPH_FORMAT_NONE; slot->linearHoriAdvance = 0; slot->linearVertAdvance = 0; @@ -780,7 +595,7 @@ T42_GlyphSlot_Load( FT_GlyphSlot glyph, FT_Size size, FT_Int glyph_index, - FT_Int load_flags ) + FT_Int32 load_flags ) { FT_Error error; T42_GlyphSlot t42slot = (T42_GlyphSlot)glyph; @@ -807,10 +622,10 @@ glyph->bitmap = t42slot->ttslot->bitmap; glyph->bitmap_left = t42slot->ttslot->bitmap_left; glyph->bitmap_top = t42slot->ttslot->bitmap_top; - + glyph->num_subglyphs = t42slot->ttslot->num_subglyphs; glyph->subglyphs = t42slot->ttslot->subglyphs; - + glyph->control_data = t42slot->ttslot->control_data; glyph->control_len = t42slot->ttslot->control_len; } @@ -819,101 +634,4 @@ } - - FT_LOCAL_DEF( FT_Long ) - T42_CMap_CharNext( FT_CharMap charmap, - FT_Long charcode ) - { - T42_Face face; - PSNames_Service psnames; - - - face = (T42_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 ); - - /*******************************************************************/ - /* */ - /* ISOLatin1 encoding support */ - /* */ - case ft_encoding_latin_1: - { - FT_ULong code; - - - /* use the `PSNames' module to synthetize the Unicode charmap */ - code = psnames->next_unicode( &face->unicode_map, - (FT_ULong)charcode ); - if ( code < 256 ) - return code; - break; - } - - /*******************************************************************/ - /* */ - /* 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++; - } - } - - - /*******************************************************************/ - /* */ - /* 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; - } - - /* END */ diff --git a/src/libs/freetype2/type42/t42objs.h b/src/libs/freetype2/type42/t42objs.h index c6ce127669a..6fb176917ee 100644 --- a/src/libs/freetype2/type42/t42objs.h +++ b/src/libs/freetype2/type42/t42objs.h @@ -103,21 +103,12 @@ FT_BEGIN_HEADER T42_GlyphSlot_Load( FT_GlyphSlot glyph, FT_Size size, FT_Int glyph_index, - FT_Int load_flags ); + FT_Int32 load_flags ); FT_LOCAL( void ) T42_GlyphSlot_Done( T42_GlyphSlot slot ); - FT_LOCAL( FT_UInt ) - T42_CMap_CharIndex( FT_CharMap charmap, - FT_Long charcode ); - - FT_LOCAL( FT_Long ) - T42_CMap_CharNext( FT_CharMap charmap, - FT_Long charcode ); - - FT_LOCAL( FT_Error ) T42_Driver_Init( T42_Driver driver ); diff --git a/src/libs/freetype2/type42/t42parse.c b/src/libs/freetype2/type42/t42parse.c index e28bcdb7953..8bb2e7ba6c5 100644 --- a/src/libs/freetype2/type42/t42parse.c +++ b/src/libs/freetype2/type42/t42parse.c @@ -964,7 +964,7 @@ { FT_UNUSED( face ); - FT_MEM_SET( loader, 0, sizeof ( *loader ) ); + FT_MEM_ZERO( loader, sizeof ( *loader ) ); loader->num_glyphs = 0; loader->num_chars = 0; diff --git a/src/libs/freetype2/winfonts/winfnt.c b/src/libs/freetype2/winfonts/winfnt.c index 5344c684faf..21ff6dfadee 100644 --- a/src/libs/freetype2/winfonts/winfnt.c +++ b/src/libs/freetype2/winfonts/winfnt.c @@ -310,8 +310,6 @@ } -#ifdef FT_CONFIG_OPTION_USE_CMAPS - typedef struct FNT_CMapRec_ { @@ -393,57 +391,6 @@ static FT_CMap_Class fnt_cmap_class = &fnt_cmap_class_rec; -#else /* !FT_CONFIG_OPTION_USE_CMAPS */ - - - static FT_UInt - FNT_Get_Char_Index( FT_CharMap charmap, - FT_Long char_code ) - { - FT_Long result = char_code; - - - if ( charmap ) - { - FNT_Font font = ((FNT_Face)charmap->face)->fonts; - FT_Long first = font->header.first_char; - FT_Long count = font->header.last_char - first + 1; - - - char_code -= first; - if ( char_code < count ) - result = char_code + 1; - else - result = 0; - } - - return result; - } - - - static FT_Long - FNT_Get_Next_Char( FT_CharMap charmap, - FT_Long char_code ) - { - char_code++; - if ( charmap ) - { - FNT_Font font = ((FNT_Face)charmap->face)->fonts; - FT_Long first = font->header.first_char; - - - if ( char_code < first ) - char_code = first; - if ( char_code <= font->header.last_char ) - return char_code; - } - else - return char_code; - return 0; - } - -#endif /* !FT_CONFIG_OPTION_USE_CMAPS */ - static void FNT_Face_Done( FNT_Face face ) @@ -534,12 +481,10 @@ } } -#ifdef FT_CONFIG_OPTION_USE_CMAPS - { FT_CharMapRec charmap; - charmap.encoding = ft_encoding_unicode; + charmap.encoding = FT_ENCODING_UNICODE; charmap.platform_id = 3; charmap.encoding_id = 1; charmap.face = root; @@ -556,23 +501,6 @@ root->charmap = root->charmaps[0]; } -#else /* !FT_CONFIG_OPTION_USE_CMAPS */ - - /* Setup the `charmaps' array */ - root->charmaps = &face->charmap_handle; - root->num_charmaps = 1; - - 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 */ - /* setup remaining flags */ root->num_glyphs = fonts->header.last_char - fonts->header.first_char + 1; @@ -635,7 +563,7 @@ FNT_Load_Glyph( FT_GlyphSlot slot, FNT_Size size, FT_UInt glyph_index, - FT_Int load_flags ) + FT_Int32 load_flags ) { FNT_Font font = size->font; FT_Error error = 0; @@ -686,7 +614,7 @@ bitmap->pitch = pitch; bitmap->rows = font->header.pixel_height; - bitmap->pixel_mode = ft_pixel_mode_mono; + bitmap->pixel_mode = FT_PIXEL_MODE_MONO; if ( FT_ALLOC( bitmap->buffer, pitch * bitmap->rows ) ) goto Exit; @@ -706,7 +634,7 @@ slot->flags = FT_GLYPH_OWN_BITMAP; slot->bitmap_left = 0; slot->bitmap_top = font->header.ascent; - slot->format = ft_glyph_format_bitmap; + slot->format = FT_GLYPH_FORMAT_BITMAP; /* now set up metrics */ slot->metrics.horiAdvance = bitmap->width << 6; @@ -714,7 +642,7 @@ slot->metrics.horiBearingY = slot->bitmap_top << 6; slot->linearHoriAdvance = (FT_Fixed)bitmap->width << 16; - slot->format = ft_glyph_format_bitmap; + slot->format = FT_GLYPH_FORMAT_BITMAP; Exit: return error; @@ -754,22 +682,9 @@ (FT_Size_ResetPixelsFunc) FNT_Size_Set_Pixels, (FT_Slot_LoadFunc) FNT_Load_Glyph, -#ifdef FT_CONFIG_OPTION_USE_CMAPS - (FT_CharMap_CharIndexFunc)0, -#else - (FT_CharMap_CharIndexFunc)FNT_Get_Char_Index, -#endif - - (FT_Face_GetKerningFunc) 0, (FT_Face_AttachFunc) 0, - (FT_Face_GetAdvancesFunc) 0, - -#ifdef FT_CONFIG_OPTION_USE_CMAPS - (FT_CharMap_CharNextFunc) 0 -#else - (FT_CharMap_CharNextFunc) FNT_Get_Next_Char -#endif + (FT_Face_GetAdvancesFunc) 0 };