summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWerner Lemberg <wl@gnu.org>2001-12-05 01:22:05 +0000
committerWerner Lemberg <wl@gnu.org>2001-12-05 01:22:05 +0000
commit05f271b5d452e11636c3c166e9c40ccd6055d52f (patch)
tree176bbf187508cfeefc85bc63797886a9607f26cd
parent58c48a4324352007b060158b0cac26089248408a (diff)
downloadfreetype2-05f271b5d452e11636c3c166e9c40ccd6055d52f.tar.gz
Formatting.
Cleaning up of ChangeLog. * docs/license.txt: s/X Windows/X Window System/. * src/raster/ftraster.c: Fix definition condition of MEM_Set(). * src/smooth/ftgrays.c (M_Y): Change value to 192. * src/base/ftdbgmem.c (ft_mem_table_destroy): Fix printf() parameter. Remove unused variable. * src/cache/ftcimage.c (ftc_image_node_init, ftc_image_node_compare): Remove unused variables. * src/cache/ftcsbits.c (ftc_sbit_node_weight): Remove unused variable. * src/raster/ftraster.c (MEM_Set): Move definition down to avoid compiler warning. * src/autohint/ahhint.c (ah_hinter_hint_edges): Use UNUSED() to avoid compiler warnings. * src/pcf/pcfread.c (tableNames): Use `const'. (pcf_read_TOC): Change counter name to avoid compiler warning. Use `const'. * src/pshinter/pshrec.c (ps_hints_close): Remove redundant declaration. * src/pshinter/pshalgo1.c (psh1_hint_table_init): Rename variables to avoid shadowing. * src/pshinter/pshalgo2.c (psh2_hint_table_activate_mask): Ditto. * src/type1/t1objs.h: Remove double declarations of `T1_Size_Init()' and `T1_Size_Done()'.
-rw-r--r--ChangeLog362
-rw-r--r--Jamfile1
-rw-r--r--builds/amiga/src/base/ftsystem.c49
-rw-r--r--builds/mac/README2
-rw-r--r--docs/BUGS81
-rw-r--r--docs/CHANGES14
-rw-r--r--docs/license.txt5
-rw-r--r--include/freetype/cache/ftcchunk.h46
-rw-r--r--include/freetype/cache/ftcglyph.h97
-rw-r--r--include/freetype/cache/ftcimage.h14
-rw-r--r--include/freetype/cache/ftcmanag.h109
-rw-r--r--include/freetype/cache/ftlru.h47
-rw-r--r--include/freetype/config/ftoption.h66
-rw-r--r--include/freetype/freetype.h10
-rw-r--r--include/freetype/ftcache.h20
-rw-r--r--include/freetype/internal/ftmemory.h66
-rw-r--r--include/freetype/internal/ftobjs.h16
-rw-r--r--include/freetype/internal/internal.h44
-rw-r--r--include/freetype/internal/psaux.h42
-rw-r--r--include/freetype/internal/psglobal.h293
-rw-r--r--include/freetype/internal/pshints.h1025
-rw-r--r--include/freetype/internal/t1types.h3
-rw-r--r--include/freetype/ttnameid.h112
-rw-r--r--src/autohint/ahglyph.c6
-rw-r--r--src/autohint/ahhint.c5
-rw-r--r--src/autohint/ahtypes.h2
-rw-r--r--src/base/ftcalc.c4
-rw-r--r--src/base/ftdbgmem.c348
-rw-r--r--src/base/ftmac.c17
-rw-r--r--src/base/ftobjs.c7
-rw-r--r--src/cache/ftcchunk.c53
-rw-r--r--src/cache/ftcglyph.c33
-rw-r--r--src/cache/ftcimage.c138
-rw-r--r--src/cache/ftcmanag.c232
-rw-r--r--src/cache/ftcsbits.c107
-rw-r--r--src/cache/ftlru.c16
-rw-r--r--src/cff/cffload.c5
-rw-r--r--src/cid/cidgload.c2
-rw-r--r--src/cid/cidriver.c1
-rw-r--r--src/pcf/pcfread.c12
-rw-r--r--src/psaux/psobjs.c8
-rw-r--r--src/psaux/psobjs.h1
-rw-r--r--src/psaux/t1decode.c13
-rw-r--r--src/pshinter/Jamfile2
-rw-r--r--src/pshinter/pshalgo.h41
-rw-r--r--src/pshinter/pshalgo1.c353
-rw-r--r--src/pshinter/pshalgo1.h73
-rw-r--r--src/pshinter/pshalgo2.c555
-rw-r--r--src/pshinter/pshalgo2.h93
-rw-r--r--src/pshinter/pshglob.c332
-rw-r--r--src/pshinter/pshglob.h154
-rw-r--r--src/pshinter/pshinter.c8
-rw-r--r--src/pshinter/pshmod.c60
-rw-r--r--src/pshinter/pshmod.h12
-rw-r--r--src/pshinter/pshrec.c570
-rw-r--r--src/pshinter/pshrec.h163
-rw-r--r--src/pshinter/rules.mk7
-rw-r--r--src/psnames/psmodule.c6
-rw-r--r--src/raster/ftraster.c9
-rw-r--r--src/sfnt/sfdriver.c25
-rw-r--r--src/smooth/ftgrays.c28
-rw-r--r--src/tools/glnames.py18
-rw-r--r--src/type1/t1gload.c8
-rw-r--r--src/type1/t1load.c3
-rw-r--r--src/type1/t1objs.c54
-rw-r--r--src/type1/t1objs.h19
-rw-r--r--tests/Jamfile9
67 files changed, 3389 insertions, 2747 deletions
diff --git a/ChangeLog b/ChangeLog
index 3524083e1..8721293c0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,121 +1,178 @@
-2001-11-20 Antoine Leca <antoineleca@multimania.com>
+2001-12-05 David Krause <freetype@davidkrause.com>
- * include/freetype/ttnameid.h: Added some new Microsoft language
- codes and LCIDs as found in MSDN (Passport SDK). Also added
- comments about the meaning of bit 57 of OS/2 (TT_UCR_SURROGATES)
- which with OpenType v.1.3 now means "there is a character beyond
- FFFF in this font". Thanks to Detlef Wuerkner <TetiSoft@apg.lahn.de>
- for noticing this.
-
-2001-11-20 David Turner <david@freetype.org>
-
- * src/pshinter/{pshalgo2.c, pshalgo1.c}: fixed stupid bug in sorting
- routine that created nasty alignment artefacts.
-
- * src/pshinter/pshrec.c, tests/gview.c: debugging updates..
-
- * src/smooth/ftgrays.c: de-activated experimental gamme support,
- apparently, "optimal" gamma tables depend on the monitor type,
- resolution and general karma, so it's better to compute them outside
- of the rasterizer itself..
-
-
-2001-10-29 David Turner <david@freetype.org>
-
- * src/smooth/ftgrays.c: adding experimental "gamma" support. This
- produces smoother glyphs at small sizes for very little cost
-
- * src/autohint/ahglyph.c, src/autohint/ahhint.c: various fixes to
- the auto-hinter. They merely improve the output of sans-serif fonts.
- Note that there are still problems with serifed fonts and composites
- (accented characters)
+ * docs/license.txt: s/X Windows/X Window System/.
- * tests/gview.c: updated the debugging glyph viewer to show the
- hints generated by the "autohint" module
+2001-12-04 Werner Lemberg <wl@gnu.org>
+ * src/raster/ftraster.c: Fix definition condition of MEM_Set().
+ * src/smooth/ftgrays.c (M_Y): Change value to 192.
+ * src/base/ftdbgmem.c (ft_mem_table_destroy): Fix printf() parameter.
+ Remove unused variable.
+ * src/cache/ftcimage.c (ftc_image_node_init,
+ ftc_image_node_compare): Remove unused variables.
+ * src/cache/ftcsbits.c (ftc_sbit_node_weight): Remove unused
+ variable.
+ * src/raster/ftraster.c (MEM_Set): Move definition down to avoid
+ compiler warning.
+ * src/autohint/ahhint.c (ah_hinter_hint_edges): Use UNUSED() to
+ avoid compiler warnings.
+ * src/pcf/pcfread.c (tableNames): Use `const'.
+ (pcf_read_TOC): Change counter name to avoid compiler warning.
+ Use `const'.
+ * src/pshinter/pshrec.c (ps_hints_close): Remove redundant
+ declaration.
+ * src/pshinter/pshalgo1.c (psh1_hint_table_init): Rename variables
+ to avoid shadowing.
+ * src/pshinter/pshalgo2.c (psh2_hint_table_activate_mask): Ditto.
+ * src/type1/t1objs.h: Remove double declarations of `T1_Size_Init()'
+ and `T1_Size_Done()'.
+
+2001-11-20 Antoine Leca <antoineleca@multimania.com>
-2001-10-27 David Turner <david@freetype.org>
-
- * src/cache/ftchunk.c (ftc_chunk_cache_lookup): fixed a bug that
+ * include/freetype/ttnameid.h: Added some new Microsoft language
+ codes and LCIDs as found in MSDN (Passport SDK). Also added
+ comments about the meaning of bit 57 of the `OS/2' table
+ (TT_UCR_SURROGATES) which (with OpenType v.1.3) now means "there is
+ a character beyond 0xFFFF in this font". Thanks to Detlef Würkner
+ <TetiSoft@apg.lahn.de> for noticing this.
+
+2001-11-20 David Turner <david@freetype.org>
+
+ * src/pshinter/{pshalgo2.c, pshalgo1.c}: Fixed stupid bug in sorting
+ routine that created nasty alignment artefacts.
+
+ * src/pshinter/pshrec.c, tests/gview.c: Debugging updates.
+
+ * src/smooth/ftgrays.c: De-activated experimental gamma support.
+ Apparently, `optimal' gamma tables depend on the monitor type,
+ resolution and general karma, so it's better to compute them outside
+ of the rasterizer itself.
+ (gray_convert_glyph): Use `volatile' keyword.
+
+2001-10-29 David Turner <david@freetype.org>
+
+ Adding experimental `gamma' support. This produces smoother glyphs
+ at small sizes for very little cost.
+
+ * src/smooth/ftgrays.c (grays_init_gamma): New function.
+ (gray_raster_new): Use it.
+
+ Various fixes to the auto-hinter. They merely improve the output of
+ sans-serif fonts. Note that there are still problems with serifed
+ fonts and composites (accented characters).
+
+ * src/autohint/ahglyph.c (ah_outline_load,
+ ah_outline_link_segments): Implement it.
+ Fix typos.
+ (ah_outline_save, ah_outline_compute_segments): Fix typos.
+ * src/autohint/ahhint.c (ah_align_serif_edge): New argument
+ `vertical'. Implement improvement.
+ (ah_hint_edges_3, ah_hinter_hint_edges): Implement it.
+ Fix typos.
+ (ah_hinter_align_strong_points, ah_hinter_align_weak_points): Fix
+ typos.
+ (ah_hinter_load): Set `ah_debug_hinter' if DEBUG_HINTER is defined.
+ * src/autohint/ahmodule.c: Implement support for DEBUG_HINTER macro.
+ * src/autohint/ahtypes.h: Ditto.
+ (AH_Hinter): Remove `disable_horz_edges' and `disable_vert_edges'
+ (making them global as `ah_debug_disable_horz' and
+ `ah_debug_disable_vert').
+ Fix typos.
+
+ * tests/gview.c: Updated the debugging glyph viewer to show the
+ hints generated by the "autohint" module.
+
+2001-10-27 David Turner <david@freetype.org>
+
+ * src/cache/ftcchunk.c (ftc_chunk_cache_lookup): Fixed a bug that
considerably lowered the performance of the abstract chunk cache.
-2001-10-26 David Turner <david@freetype.org>
-
- * include/freetype/ftcache.h, include/freetype/cache/*.h,
- src/cache/*.c: Major re-design of the cache sub-system to provide
- better performance as well as an "Acquire"/"Release" API..
-
- seems to work well here.. but probably needs a bit more testing..
+2001-10-26 David Turner <david@freetype.org>
+ * include/freetype/ftcache.h, include/freetype/cache/*.h,
+ src/cache/*.c: Major re-design of the cache sub-system to provide
+ better performance as well as an "Acquire"/"Release" API. Seems to
+ work well here, but probably needs a bit more testing.
2001-10-26 Leonard Rosenthol <leonardr@lazerware.com>
- * updated Mac OS README (builds/mac/) to reflect my taking over
- the project and that is now being actively maintained.
+ * builds/mac/README: Updated to reflect my taking over the project
+ and that is now being actively maintained.
- * Applied patches from Paul Miller (<paulm@profoundeffects.com>)
- to /src/base/ftmac.c to support loading a face other than the
+ * src/base/ftmac.c (parse_fond): Applied patches from Paul Miller
+ <paulm@profoundeffects.com> to support loading a face other than the
first from a FOND resource.
-
+ (FT_New_Face_From_FOND): Updated.
2001-10-25 Leonard Rosenthol <leonardr@lazerware.com>
- * update CodeWarrior project for Mac OS (builds/mac/ftlib.prj)
- for latest version (7) of CWPro and for recent changes to the
- FT source tree.
-
+ * builds/mac/ftlib.prj: Update of CodeWarrior project file for Mac
+ OS for latest version (7) of CWPro and for recent changes to the FT
+ source tree.
2001-10-25 David Turner <david@freetype.org>
- * include/freetype/config/ftoption.h: updated comment to explain
+ * include/freetype/config/ftoption.h: Updated comments to explain
precisely how to use project-specific macro definitions without
- modifying this file manually..
+ modifying this file manually.
+ (FT_CONFIG_FORCE_INT64): Define.
-2001-10-24 Tom Kacvinsky <tkacvins@freetype.org>
+ (FT_DEBUG_MEMORY): New macro.
- * builds/unix/ftsystem.c (FT_New_Memory): Added a missing `{'.
+2001-10-24 Tom Kacvinsky <tkacvins@freetype.org>
+ * builds/unix/ftsystem.c (FT_New_Memory): Added a missing `{'.
2001-10-23 David Turner <david@freetype.org>
* include/freetype/internal/ftmemory.h, src/base/ftdbgmem.c:
- improvements to the memory debugger to report more information in
- case of errors. Also, some allocations that occured through
- REALLOC couldn't be previously catched correctly..
+ Improvements to the memory debugger to report more information in
+ case of errors. Also, some allocations that occured through REALLOC
+ couldn't be previously catched correctly.
+ * src/autohint/ahglyph.c (ah_outline_compute_segments,
+ ah_outline_compute_edges), src/raster/ftraster.c (ft_black_new),
+ src/smooth/ftgrays.c (gray_render_span, gray_raster_new): Replaced
+ liberal uses of memset() by the MEM_Set() macro.
- * src/autohint/ahglyph.c, src/raster/ftraster.c,
- src/smooth/ftgrays.c: replaced liberal uses of "memset" by the
- MEM_Set macro instead..
+2001-10-23 David Turner <david@freetype.org>
+ * src/raster/ftraster.c (Update): Removed to be inlined in ...
+ (Sort): Updated.
2001-10-22 David Turner <david@freetype.org>
- * builds/unix/ftsystem.c, builds/vms/ftsystem.c,
- builds/amiga/ftsystem.c, src/base/ftdbgmem.c: updated the memory
- debugger and platform-specific implementations of 'ftsystem' in order
- to be able to debug memory allocations on Unix, VMS and Amiga too !!
+ * builds/unix/ftsystem.c (FT_New_Memory, FT_Done_Memory),
+ builds/vms/ftsystem.c (FT_New_Memory, FT_Done_Memory),
+ builds/amiga/ftsystem.c (FT_New_Memory, FT_Done_Memory),
+ src/base/ftdbgmem.c: Updated the memory debugger and
+ platform-specific implementations of `ftsystem' in order to be able
+ to debug memory allocations on Unix, VMS and Amiga too!
- * src/pshinter/pshalgo2.c (psh2_hint_table_record_mask): removed some
- bogus warnings..
+ * src/pshinter/pshalgo2.c (psh2_hint_table_record_mask): Removed
+ some bogus warnings.
+
+ * include/freetype/internal/ftmemory.h, src/base/ftdbgmem.c:
+ Modified the debugging memory manager to report the location (source
+ file name + line number) where leaked memory blocks are allocated in
+ the source file.
- * include/freetype/internal/ftmemory.h, src/base/ftdbgmem.c: modified
- the debugging memory manager to report the location (source file name
- + line number) where leaked memory blocks are allocated in the source
- file.. funny, isn't it ??
+ * src/base/ftdbgmem.c: New debugging memory manager. You must
+ define the FT_DEBUG_MEMORY macro in "ftoption.h" to enable it. It
+ will record every memory block allocated and report simple errors
+ like memory leaks and double deletes.
- * src/base/ftdbgmem.c: new debugging memory manager. You must define
- the FT_DEBUG_MEMORY macro in "ftoption.h" to enable it. It will record
- every memory block allocated and report simple errors like memory
- leaks and double deletes.
+ * src/base/Jamfile: Include ftdbgmem.
+ * src/base/rules.mk: Ditto.
+ * src/base/ftbase.c: Include ftdbgmem.c.
- * include/freetype/config/ftoption.h: added the FT_DEBUG_MEMORY macro
- definition
+ * include/freetype/config/ftoption.h: Added the FT_DEBUG_MEMORY
+ macro definition.
- * src/base/ftsystem.c (FT_New_Memory, FT_Done_Memory): modified the
+ * src/base/ftsystem.c (FT_New_Memory, FT_Done_Memory): Modified the
base component to use the debugging memory manager when the macro
- FT_DEBUG_MEMORY is defined..
+ FT_DEBUG_MEMORY is defined.
2001-10-21 Tom Kacvinsky <tkacvins@freetype.org>
@@ -129,12 +186,11 @@
* src/cff/cffload.c (CFF_Done_Font): Free the subfonts array to
avoid a memory leak.
-2001-10-21 David Turner <david@freetype.org>
+2001-10-21 David Turner <david@freetype.org>
* src/pshinter/pshalgo2.c, src/pshinter/pshalgo1.c,
- src/pshinter/pshglob.c: removing compiler warnings in pedantic modes
- (in multi-object compilation mode, mainly)
-
+ src/pshinter/pshglob.c: Removing compiler warnings in pedantic modes
+ (in multi-object compilation mode, mainly).
2001-10-20 Tom Kacvinsky <tkacvins@freetype.org>
@@ -150,91 +206,90 @@
objects were not deallocated when the objects were parsed the
second time.
+2001-10-19 David Turner <david@freetype.org>
-2001-10-19 David Turner <david@freetype.org>
-
- * src/smooth/ftgrays.c, src/pshinter/pshglob.h, src/pshinter/pshrec.c,
- src/pshinter/pshalgo2.c: getting rid of compiler warnings
+ * src/smooth/ftgrays.c, src/pshinter/pshglob.h,
+ src/pshinter/pshrec.c, src/pshinter/pshalgo2.c: Getting rid of
+ compiler warnings.
- * src/pshinter/module.mk, src/pshinter/rules.mk: adding control files
- to build the postscript hinter with the "old" build system
+ * src/pshinter/module.mk, src/pshinter/rules.mk: Adding control
+ files to build the PostScript hinter with the "old" build system.
-2001-10-19 Jacob Jansen <joukj@hrem.stm.tudelft.nl>
+2001-10-19 Jacob Jansen <joukj@hrem.stm.tudelft.nl>
- * descrip.mms, src/pshinter/descrip.mms: updates to the VMS build
+ * descrip.mms, src/pshinter/descrip.mms: Updates to the VMS build
files.
2001-10-18 David Turner <david@freetype.org>
- * src/psnames/pstables.h, src/tools/glnames.py: rewrote the "glnames.py"
- script used to generate the "pstables.h" header file. The old one
- contained a bug (yes !!) that made FreeType return incorrect glyph
- names for certain glyphs..
-
- * src/truetype/ttdriver.c: changing computation of pixel size from
- character size to use rounding. This is an experiment to see if this
- gives values similar to Windows for scaled ascent/descent/etc..
-
- * src/base/ftcalc.c (FT_Div64by32): changed the implementation
- slightly since the original code was mis-compiled on Mac machines
- using the MPW C compiler..
-
- * src/base/ftobjs.c (FT_Realloc): when a memory block was grown
- through FT_Realloc, the new bytes were not set to 0, which created
- some strange bugs in the Postscript hinter
-
- * src/cid/cidgload.c: adding support to new postscript hinter
-
- * include/freetype/internal/psglobal.h,
- include/freetype/internal/pshints.h,
- include/freetype/config/ftmodule.h,
- src/pshinter/Jamfile,
- src/pshinter/pshalgo.h,
- src/pshinter/pshalgo1.h,
- src/pshinter/pshalgo1.c,
- src/pshinter/pshalgo2.h,
- src/pshinter/pshalgo2.c,
- src/pshinter/pshglob.h,
- src/pshinter/pshglob.c,
- src/pshinter/pshinter.c,
- src/pshinter/pshmod.c,
- src/pshinter/pshmod.h,
- src/pshinter/pshrec.c,
- src/pshinter/pshrec.h : Adding new postscript hinter module
-
- * include/freetype/internal/ftobjs.h,
- include/freetype/internal/internal.h,
- include/freetype/internal/psaux.h,
- include/freetype/internal/t1types.h,
- src/psaux/psobjs.c,
- src/psaux/psobjs.h,
- src/psaux/t1decode.h,
- src/psaux/t1decode.c,
- src/type1/t1driver.c,
- src/type1/t1gload.c,
- src/type1/t1objs.c,
- src/type1/t1objs.h : updates to use the new postscript hinter
-
- * tests/Jamfile, tests/gview.c: Adding a new glyph hinting
- viewer/debugger to the source tree. Note that you will _not_ be
- able to compile it since it depends on an unavailable graphics
- library named "Nirvana" to render vector images..
-
-
+ * src/psnames/pstables.h, src/tools/glnames.py: Rewrote the
+ "glnames.py" script used to generate the "pstables.h" header file.
+ The old one contained a serious bug that made FreeType return
+ incorrect glyph names for certain glyphs.
+
+ * src/truetype/ttdriver.c (Set_Char_Sizes): Changing computation of
+ pixel size from character size to use rounding. This is an
+ experiment to see whether this gives values similar to Windows for
+ scaled ascent/descent/etc.
+
+ * src/base/ftcalc.c (FT_Div64by32): Changed the implementation
+ slightly since the original code was mis-compiled on Mac machines
+ using the MPW C compiler.
+
+ * src/base/ftobjs.c (FT_Realloc): When a memory block was grown
+ through FT_Realloc(), the new bytes were not set to 0, which created
+ some strange bugs in the PostScript hinter.
+ (destroy_face): Don't deallocate unconditionally.
+
+ * src/cid/cidgload.c (CID_Compute_Max_Advance, CID_Load_Glyph):
+ Adding support to new PostScript hinter.
+
+ * include/freetype/internal/psglobal.h,
+ include/freetype/internal/pshints.h,
+ include/freetype/config/ftmodule.h, src/pshinter/Jamfile,
+ src/pshinter/pshalgo.h, src/pshinter/pshalgo1.h,
+ src/pshinter/pshalgo1.c, src/pshinter/pshalgo2.h,
+ src/pshinter/pshalgo2.c, src/pshinter/pshglob.h,
+ src/pshinter/pshglob.c, src/pshinter/pshinter.c,
+ src/pshinter/pshmod.c, src/pshinter/pshmod.h, src/pshinter/pshrec.c,
+ src/pshinter/pshrec.h: Adding new PostScript hinter module.
+
+ * include/freetype/internal/ftobjs.h,
+ include/freetype/internal/internal.h,
+ include/freetype/internal/psaux.h,
+ include/freetype/internal/t1types.h, src/psaux/psobjs.c,
+ src/psaux/psobjs.h, src/psaux/t1decode.h, src/psaux/t1decode.c,
+ src/type1/t1driver.c, src/type1/t1gload.c, src/type1/t1objs.c,
+ src/type1/t1objs.h: Updates to use the new PostScript hinter.
+
+ * tests/Jamfile, tests/gview.c: Adding a new glyph hinting
+ viewer/debugger to the source tree. Note that you will _not_ be
+ able to compile it since it depends on an unavailable graphics
+ library named "Nirvana" to render vector images.
2001-10-17 David Turner <david@freetype.org>
+
* Version 2.0.5 released.
=========================
+
* include/freetype/freetype.h, include/internal/ftobjs.h,
- src/base/ftobjs.c, src/sfnt/sfdriver.c, type1/t1driver.c,
- cid/cidriver.c: Adding a new function named 'FT_Get_Postscript_Name' to
- retrieve the Postscript name of a given font. Should work with all
- formats except pure CFF/CEF fonts (this will be added soon).
+ src/base/ftobjs.c, src/type1/t1driver.c: Adding a new function named
+ 'FT_Get_Postscript_Name' to retrieve the PostScript name of a given
+ font. Should work with all formats except pure CFF/CEF fonts (this
+ will be added soon).
+
+ * src/cid/cidriver (cid_get_postscript_name): New function.
+ (CID_Get_Interface): Handle `postscript_name' interface.
- * README, docs/CHANGES: updated for 2.0.5 release
+ * src/sfnt/sfdriver.c (get_sfnt_postscript_name): New function.
+ (SFNT_Get_Interface): Handle `postscript_name' interface.
+ * src/type1/t1driver.c (t1_get_ps_name): New function.
+ (Get_Interface): Handle `postscript_name' interface.
+
+ * README, docs/CHANGES: Updated for 2.0.5 release.
2001-10-08 David Turner <david@freetype.org>
@@ -1418,7 +1473,7 @@
2001-01-01 Francesco Zappa Nardelli <francesco.zappa.nardelli@ens.fr>
* src/pcf/*: New driver module for PCF font format (used in
- X Windows).
+ X Window System).
* include/freetype/internal/ftdebug.h (FT_Trace): Added values for
PCF driver.
* include/freetype/internal/pcftypes.h: New file.
@@ -1665,9 +1720,11 @@
2000-12-01 David Turner <david.turner@freetype.org>
+
* Version 2.0.1 released.
=========================
+
* builds/unix/configure.in, builds/unix/configure,
builds/cygwin/configure.in, builds/cygwin/configure: Setting
"version_info" to 6:1:0 for the 2.0.1 release.
@@ -1873,6 +1930,7 @@
2000-11-09 David Turner <david@freetype.org>
+
* Version 2.0 released.
=======================
diff --git a/Jamfile b/Jamfile
index 8fc419bc0..724b71265 100644
--- a/Jamfile
+++ b/Jamfile
@@ -21,7 +21,6 @@ if $(DEBUG_HINTER)
}
-
# We need "freetype2/include" in the current include path in order to
# compile any part of FreeType 2.
#
diff --git a/builds/amiga/src/base/ftsystem.c b/builds/amiga/src/base/ftsystem.c
index c9433fc8a..023216a3d 100644
--- a/builds/amiga/src/base/ftsystem.c
+++ b/builds/amiga/src/base/ftsystem.c
@@ -9,41 +9,41 @@
* (These amiga.lib functions work under AmigaOS V33 and up)
*/
extern APTR __asm AsmCreatePool(register __d0 ULONG memFlags,
- register __d1 ULONG puddleSize,
- register __d2 ULONG threshSize,
- register __a6 struct ExecBase *SysBase);
+ register __d1 ULONG puddleSize,
+ register __d2 ULONG threshSize,
+ register __a6 struct ExecBase *SysBase);
extern VOID __asm AsmDeletePool(register __a0 APTR poolHeader,
- register __a6 struct ExecBase *SysBase);
+ register __a6 struct ExecBase *SysBase);
extern APTR __asm AsmAllocPooled(register __a0 APTR poolHeader,
- register __d0 ULONG memSize,
- register __a6 struct ExecBase *SysBase);
+ register __d0 ULONG memSize,
+ register __a6 struct ExecBase *SysBase);
extern VOID __asm AsmFreePooled(register __a0 APTR poolHeader,
- register __a1 APTR memory,
- register __d0 ULONG memSize,
- register __a6 struct ExecBase *SysBase);
+ register __a1 APTR memory,
+ register __d0 ULONG memSize,
+ register __a6 struct ExecBase *SysBase);
// TetiSoft: C implementation of AllocVecPooled (see autodoc exec/AllocPooled)
APTR AllocVecPooled(APTR poolHeader, ULONG memSize)
{
- ULONG newSize = memSize + 4;
- ULONG *mem = AsmAllocPooled(poolHeader, newSize, SysBase);
+ ULONG newSize = memSize + 4;
+ ULONG *mem = AsmAllocPooled(poolHeader, newSize, SysBase);
- if (!mem)
- return NULL;
- *mem = newSize;
- return mem + 1;
+ if (!mem)
+ return NULL;
+ *mem = newSize;
+ return mem + 1;
}
// TetiSoft: C implementation of FreeVecPooled (see autodoc exec/AllocPooled)
void FreeVecPooled(APTR poolHeader, APTR memory)
{
- ULONG *realmem = (ULONG *)memory - 1;
+ ULONG *realmem = (ULONG *)memory - 1;
- AsmFreePooled(poolHeader, realmem, *realmem, SysBase);
+ AsmFreePooled(poolHeader, realmem, *realmem, SysBase);
}
/***************************************************************************/
@@ -215,7 +215,7 @@ void FreeVecPooled(APTR poolHeader, APTR memory)
/* We use the macro STREAM_FILE for convenience to extract the */
/* system-specific stream handle from a given FreeType stream object */
//#define STREAM_FILE( stream ) ( (FILE*)stream->descriptor.pointer )
-#define STREAM_FILE( stream ) ( (BPTR)stream->descriptor.pointer ) // TetiSoft
+#define STREAM_FILE( stream ) ( (BPTR)stream->descriptor.pointer ) // TetiSoft
/*************************************************************************/
@@ -233,7 +233,7 @@ void FreeVecPooled(APTR poolHeader, APTR memory)
ft_close_stream( FT_Stream stream )
{
// fclose( STREAM_FILE( stream ) );
- Close( STREAM_FILE( stream ) ); // TetiSoft
+ Close( STREAM_FILE( stream ) ); // TetiSoft
stream->descriptor.pointer = NULL;
stream->size = 0;
@@ -268,13 +268,13 @@ void FreeVecPooled(APTR poolHeader, APTR memory)
unsigned long count )
{
// FILE* file;
- BPTR file; // TetiSoft
+ BPTR file; // TetiSoft
file = STREAM_FILE( stream );
// fseek( file, offset, SEEK_SET );
- Seek( file, offset, OFFSET_BEGINNING ); // TetiSoft
+ Seek( file, offset, OFFSET_BEGINNING ); // TetiSoft
// return (unsigned long)fread( buffer, 1, count, file );
return (unsigned long)FRead( file, buffer, 1, count);
@@ -288,15 +288,15 @@ void FreeVecPooled(APTR poolHeader, APTR memory)
FT_Stream astream )
{
// FILE* file;
- BPTR file; // TetiSoft
- struct FileInfoBlock *fib; // TetiSoft
+ BPTR file; // TetiSoft
+ struct FileInfoBlock *fib; // TetiSoft
if ( !astream )
return FT_Err_Invalid_Stream_Handle;
// file = fopen( filepathname, "rb" );
- file = Open( filepathname, MODE_OLDFILE ); // TetiSoft
+ file = Open( filepathname, MODE_OLDFILE ); // TetiSoft
if ( !file )
{
FT_ERROR(( "FT_New_Stream:" ));
@@ -346,7 +346,6 @@ void FreeVecPooled(APTR poolHeader, APTR memory)
}
-
#ifdef FT_DEBUG_MEMORY
extern FT_Int
diff --git a/builds/mac/README b/builds/mac/README
index e339f2b9f..937fb4693 100644
--- a/builds/mac/README
+++ b/builds/mac/README
@@ -7,4 +7,4 @@ The library will be built as a static lib in the obj/ folder.
Current maintainer: Leonard Rosenthol, <leonardr@lazerware.com>
Originally prepared by Just van Rossum, <just@letterror.com>
-This directory is now actively maintained as part of the FreeType Project
+This directory is now actively maintained as part of the FreeType Project.
diff --git a/docs/BUGS b/docs/BUGS
index ba051706a..6d87e0ffb 100644
--- a/docs/BUGS
+++ b/docs/BUGS
@@ -12,7 +12,7 @@ we can use abbreviations here, like:
"David" for David Turner
"Werner" for Werner Lemberg
- etc.
+ etc.
"Reproduceable" indicates whether the bug could be reproduced by the
development team or not (it can be specific to a given platform), whether it
@@ -108,7 +108,6 @@ BAD-TT-RENDERING
bytecode-hinted glyphs! Something seems to be really broken here!
-
BAD-THIN-LINES
It seems that the anti-aliased renderer in FreeType has problems rendering
@@ -116,7 +115,6 @@ BAD-THIN-LINES
FT_Outline_Render() function.
-
NOT-WINDOWS-METRICS
FreeType doesn't always return the same metrics as Windows for ascender,
@@ -128,68 +126,61 @@ NOT-WINDOWS-METRICS
BAD-T1-CHARMAP
Type1 driver doesn't read "cacute" and "lslash" characters from iso8859-2
- charset. Those characters are mapped as MAC-one in glnames.py, so they
+ charset. Those characters are mapped as MAC-one in glnames.py, so they
cannot be shown in Adobe Type1 fonts.
- (this was due to a bug in the "glnames.py" script used to generate the
- table of glyph names in 'src/psaux/pstables.h')
+ (This was due to a bug in the "glnames.py" script used to generate the
+ table of glyph names in 'src/psaux/pstables.h'.)
BAD-UNIXXX-NAMES
- Glyph names like uniXXXX are not recognized as they should be.
- It seems that code in psmodule.c for uniXXXX glyph names was
- never tested. The patch is very simple.
+ Glyph names like uniXXXX are not recognized as they should be. It seems
+ that code in psmodule.c for uniXXXX glyph names was never tested. The
+ patch is very simple.
- (a simple bug that was left un-noticed due to the fact that I don't have
- any Postscript font that use this convention, unfortunately..)
+ (A simple bug that was left un-noticed due to the fact that I don't have
+ any Postscript font that use this convention, unfortunately.)
ADVANCED-COMPOSITES
Provided by George Williams <pfaedit@users.sourceforge.net>:
- I notice that truetype/ttgload.c only supports Apple's
- definition of offsets for composit glyphs. Apple and
- Microsoft behave differently if there is a scale
- factor. OpenType defines some bits to disambiguate.
+ I notice that truetype/ttgload.c only supports Apple's definition of
+ offsets for composite glyphs. Apple and Microsoft behave differently if
+ there is a scale factor. OpenType defines some bits to disambiguate.
- (a problem in both 2.0.4 and 2.0.5)
+ (A problem in both 2.0.4 and 2.0.5.)
- Apple says
- (http://fonts.apple.com/TTRefMan/RM06/Chap6glyf.html)
- that if flags&ARGS_ARE_XY is set then the offsets
- should be scaled by the scale factors (as you have
- done), but they also say something very cryptic about
- what happens when the component is rotated at 45°
- (which you do not support)-- See the "Important" note
- at the bottom.
+ Apple says (http://fonts.apple.com/TTRefMan/RM06/Chap6glyf.html) that if
+ flags&ARGS_ARE_XY is set then the offsets should be scaled by the scale
+ factors (as you have done), but they also say something very cryptic
+ about what happens when the component is rotated at 45° (which you do
+ not support) -- See the "Important" note at the bottom.
- The old truetype spec from Microsoft did not mention
- this. The OpenType spec
- (http://www.microsoft.com/typography/otspec/glyf.htm,
- http://partners.adobe.com/asn/developer/opentype/glyf.html)
- efines two new bits to disambiguate:
- SCALED_COMPONENT_OFFSET 11
- Composite designed to have the component offset scaled
- (designed for Apple rasterizer)
- UNSCALED_COMPONENT_OFFSET 12
- Composite designed not to have the component offset
- scaled (designed for the Microsoft TrueType rasterizer)
+ The old truetype spec from Microsoft did not mention this. The OpenType
+ spec (http://www.microsoft.com/typography/otspec/glyf.htm,
+ http://partners.adobe.com/asn/developer/opentype/glyf.html) defines two
+ new bits to disambiguate:
+
+ SCALED_COMPONENT_OFFSET 11
+ Composite designed to have the component offset scaled (designed for
+ Apple rasterizer)
+
+ UNSCALED_COMPONENT_OFFSET 12
+ Composite designed not to have the component offset scaled (designed
+ for the Microsoft TrueType rasterizer)
- Perhaps you could add a load_flag to allow the user to
- define the default setting?
+ Perhaps you could add a load_flag to allow the user to define the
+ default setting?
David says:
- Wow, I was not even aware of this, it will probably take a little
- time to implement since I don't have any font that implement these
- "features", and also because I believe that we're running out of
- bits for "load_flag", some other way to set preferences is probably
- needed..
+ Wow, I was not even aware of this, it will probably take a little time
+ to implement since I don't have any font that implement these
+ "features", and also because I believe that we're running out of bits
+ for "load_flag", some other way to set preferences is probably needed.
-
-
-
=== end of file ===
diff --git a/docs/CHANGES b/docs/CHANGES
index bfde26c87..5f542e7cc 100644
--- a/docs/CHANGES
+++ b/docs/CHANGES
@@ -1,13 +1,13 @@
LATEST CHANGES BETWEEN 2.0.6 and 2.0.5
- - a new Postscript hinter module has been added to support native hints
- in the following formats: Postscript Type 1, Postscript CID and CFF/CEF
+ - A new Postscript hinter module has been added to support native hints in
+ the following formats: Postscript Type 1, Postscript CID and CFF/CEF.
- (for now, only the Type 1 driver uses it, the "cid" and "cff" drivers
- will be updated shortly)
+ (For now, only the Type 1 driver uses it; the "cid" and "cff" drivers
+ will be updated shortly.)
- - "glnames.py" still contained a bug !! that made FreeType return invalid
- names for certain glyphs..
+ - "glnames.py" still contained a bug that made FreeType return invalid
+ names for certain glyphs.
============================================================================
@@ -44,7 +44,7 @@ LATEST CHANGES BETWEEN 2.0.5 and 2.0.4
index of a given glyph name, when found in a face.
- Added a new function named "FT_Get_Postscript_Name" to retrieve the
- "unique" Postscript font name of a given face
+ "unique" Postscript font name of a given face.
- Added a new public header size named FT_SIZES_H (or <freetype/ftsizes.h>)
providing new FT_Size-management functions: FT_New_Size, FT_Activate_Size,
diff --git a/docs/license.txt b/docs/license.txt
index 741bc9f45..c95318d1b 100644
--- a/docs/license.txt
+++ b/docs/license.txt
@@ -6,5 +6,6 @@ fits your needs best:
. The GNU General Public License, in file `docs/GPL.txt'.
-The contributed PCF driver comes with a license similar to that of X Windows
-which is compatible to the above two licenses (see file src/pcf/readme).
+The contributed PCF driver comes with a license similar to that of X Window
+System which is compatible to the above two licenses (see file
+src/pcf/readme).
diff --git a/include/freetype/cache/ftcchunk.h b/include/freetype/cache/ftcchunk.h
index e799123de..8bc02a4ae 100644
--- a/include/freetype/cache/ftcchunk.h
+++ b/include/freetype/cache/ftcchunk.h
@@ -58,9 +58,9 @@ FT_BEGIN_HEADER
#define FTC_MAX_CHUNK_SETS 16
- typedef struct FTC_ChunkNodeRec_* FTC_ChunkNode;
- typedef struct FTC_ChunkSetRec_* FTC_ChunkSet;
- typedef struct FTC_ChunkCacheRec_* FTC_ChunkCache;
+ typedef struct FTC_ChunkNodeRec_* FTC_ChunkNode;
+ typedef struct FTC_ChunkSetRec_* FTC_ChunkSet;
+ typedef struct FTC_ChunkCacheRec_* FTC_ChunkCache;
typedef struct FTC_ChunkNodeRec_
{
@@ -72,42 +72,42 @@ FT_BEGIN_HEADER
} FTC_ChunkNodeRec;
-#define FTC_CHUNK_NODE(x) ((FTC_ChunkNode)(x))
+#define FTC_CHUNK_NODE( x ) ((FTC_ChunkNode)( x ))
- /* a chunk set is used to categorize chunks of a given type */
- typedef struct FTC_ChunkSetRec_
+ /* a chunk set is used to categorize chunks of a given type */
+ typedef struct FTC_ChunkSetRec_
{
- FT_LruNodeRec lru;
- FT_UFast hash;
- FTC_ChunkCache ccache;
- FT_Fast num_chunks;
- FT_UInt item_total; /* total number of glyphs in set */
- FT_UInt item_size; /* size of each glyph item in set */
- FT_UInt item_count; /* number of glyph items per chunk */
+ FT_LruNodeRec lru;
+ FT_UFast hash;
+ FTC_ChunkCache ccache;
+ FT_Fast num_chunks;
+ FT_UInt item_total; /* total number of glyphs in set */
+ FT_UInt item_size; /* size of each glyph item in set */
+ FT_UInt item_count; /* number of glyph items per chunk */
} FTC_ChunkSetRec;
-#define FTC_CHUNK_SET(x) ((FTC_ChunkSet)(x))
+#define FTC_CHUNK_SET( x ) ((FTC_ChunkSet)( x ))
-#define FTC_CHUNK_SET_MEMORY(x) ((x)->ccache->cache.memory)
+#define FTC_CHUNK_SET_MEMORY( x ) (( x )->ccache->cache.memory)
- /* the abstract chunk cache class */
- typedef struct FTC_ChunkCacheRec_
+ /* the abstract chunk cache class */
+ typedef struct FTC_ChunkCacheRec_
{
- FTC_CacheRec cache;
- FT_LruList cset_lru; /* LRU list of chunk sets */
+ FTC_CacheRec cache;
+ FT_LruList cset_lru; /* LRU list of chunk sets */
} FTC_ChunkCacheRec;
-#define FTC_CHUNK_CACHE(x) ((FTC_ChunkCache)(x))
+#define FTC_CHUNK_CACHE( x ) ((FTC_ChunkCache)( x ))
- typedef struct FTC_ChunkQueryRec_
+ typedef struct FTC_ChunkQueryRec_
{
- /* input */
+ /* input */
FT_UInt gindex; /* glyph index */
- /* output */
+ /* output */
FTC_ChunkSet cset;
} FTC_ChunkQueryRec, *FTC_ChunkQuery;
diff --git a/include/freetype/cache/ftcglyph.h b/include/freetype/cache/ftcglyph.h
index c92e4fa29..bc11c7cac 100644
--- a/include/freetype/cache/ftcglyph.h
+++ b/include/freetype/cache/ftcglyph.h
@@ -64,61 +64,62 @@
FT_BEGIN_HEADER
- /* each glyph set is caracterized by a "glyph set type" which must be */
- /* defined by sub-classes.. */
- typedef struct FTC_GlyphSetRec_* FTC_GlyphSet;
+ /* each glyph set is caracterized by a "glyph set type" which must be */
+ /* defined by sub-classes */
+ typedef struct FTC_GlyphSetRec_* FTC_GlyphSet;
- /* handle to a glyph cache node */
- typedef struct FTC_GlyphNodeRec_* FTC_GlyphNode;
+ /* handle to a glyph cache node */
+ typedef struct FTC_GlyphNodeRec_* FTC_GlyphNode;
- /* a glyph cache, its nodes are all glyph-specific */
- typedef struct FTC_GlyphCacheRec_* FTC_GlyphCache;
+ /* a glyph cache; its nodes are all glyph-specific */
+ typedef struct FTC_GlyphCacheRec_* FTC_GlyphCache;
- /* glyph sets class handle */
- typedef const struct FTC_GlyphSet_ClassRec_* FTC_GlyphSet_Class;
+ /* glyph sets class handle */
+ typedef const struct FTC_GlyphSet_ClassRec_* FTC_GlyphSet_Class;
- /* size should be 24 bytes on 32-bit machines */
- /* note that the node's hash is ((gset->hash << 16) | glyph_index) */
- /* this _must_ be set properly by the glyph node initializer */
- /* */
- typedef struct FTC_GlyphNodeRec_
+ /* Size should be 24 bytes on 32-bit machines. */
+ /* Note that the node's hash is ((gset->hash << 16) | glyph_index); */
+ /* this _must_ be set properly by the glyph node initializer. */
+ /* */
+ typedef struct FTC_GlyphNodeRec_
{
- FTC_NodeRec node;
- FTC_GlyphSet gset;
+ FTC_NodeRec node;
+ FTC_GlyphSet gset;
} FTC_GlyphNodeRec;
-#define FTC_GLYPH_NODE(x) ((FTC_GlyphNode)(x))
-#define FTC_GLYPH_NODE_P(x) ((FTC_GlyphNode*)(x))
+#define FTC_GLYPH_NODE( x ) ((FTC_GlyphNode)( x ))
+#define FTC_GLYPH_NODE_P( x ) ((FTC_GlyphNode*)( x ))
- /* the glyph set structure. each glyph set is used to model a set of */
- /* glyphs of the same "type". The type itself is defined in sub-classes */
- /* */
- /* for example, the "image cache" uses face_id + character_pixel_sizes + */
- /* image_format to characterize glyph sets.. */
- /* */
- /* a pure "master outlines" cache would only use face_id, etc.. */
- /* */
+ /* The glyph set structure. Each glyph set is used to model a set of */
+ /* glyphs of the same "type". The type itself is defined in */
+ /* sub-classes. */
+ /* */
+ /* For example, the "image cache" uses face_id + character_pixel_sizes + */
+ /* image_format to characterize glyph sets. */
+ /* */
+ /* A pure "master outlines" cache would only use face_id, etc. */
+ /* */
typedef struct FTC_GlyphSetRec_
{
FT_LruNodeRec lru; /* glyph sets are LRU nodes within */
- FTC_GlyphCache gcache; /* parent cache.. */
- FT_UFast hash; /* must be set by initializer !! */
- FT_Fast num_glyphs; /* destroyed when 0.. */
+ FTC_GlyphCache gcache; /* parent cache */
+ FT_UFast hash; /* must be set by initializer! */
+ FT_Fast num_glyphs; /* destroyed when 0 */
} FTC_GlyphSetRec;
-#define FTC_GLYPH_SET(x) ((FTC_GlyphSet)(x))
-#define FTC_GLYPH_SET_P(x) ((FTC_GlyphSet*)(x))
+#define FTC_GLYPH_SET( x ) ((FTC_GlyphSet)( x ))
+#define FTC_GLYPH_SET_P( x ) ((FTC_GlyphSet*)( x ))
-#define FTC_GLYPH_SET_MEMORY(x) ((x)->gcache->cache.memory)
+#define FTC_GLYPH_SET_MEMORY( x ) (( x )->gcache->cache.memory)
-/* retrieve glyph index of glyph node */
-#define FTC_GLYPH_NODE_GINDEX(x) \
- ((FT_UInt)(FTC_GLYPH_NODE(x)->node.hash & 0xFFFF))
+ /* retrieve glyph index of glyph node */
+#define FTC_GLYPH_NODE_GINDEX( x ) \
+ ((FT_UInt)(FTC_GLYPH_NODE( x )->node.hash & 0xFFFF))
/* the abstract glyph cache object */
typedef struct FTC_GlyphCacheRec_
@@ -128,16 +129,16 @@ FT_BEGIN_HEADER
} FTC_GlyphCacheRec;
-#define FTC_GLYPH_CACHE(x) ((FTC_GlyphCache)(x))
-#define FTC_GLYPH_CACHE_P(x) ((FTC_GlyphCache*)(x))
+#define FTC_GLYPH_CACHE( x ) ((FTC_GlyphCache)( x ))
+#define FTC_GLYPH_CACHE_P( x ) ((FTC_GlyphCache*)( x ))
- typedef struct FTC_GlyphQueryRec_
+ typedef struct FTC_GlyphQueryRec_
{
- /* input */
+ /* input */
FT_UInt gindex;
- /* output */
+ /* output */
FTC_GlyphSet gset;
} FTC_GlyphQueryRec, *FTC_GlyphQuery;
@@ -150,37 +151,37 @@ FT_BEGIN_HEADER
/* cache sub-system internals. */
/* */
- /* must be called by derived FTC_Node_InitFunc routines */
+ /* must be called by derived FTC_Node_InitFunc routines */
FT_EXPORT( void )
ftc_glyph_node_init( FTC_GlyphNode node,
FT_UInt gindex, /* glyph index for node */
FTC_GlyphSet gset );
- /* must be called by derived FTC_Node_DoneFunc routines */
+ /* must be called by derived FTC_Node_DoneFunc routines */
FT_EXPORT( void )
ftc_glyph_node_done( FTC_GlyphNode node );
- /* can be used as a FTC_LruNode_InitFunc or called by sub-classes */
+ /* can be used as an FTC_LruNode_InitFunc or called by sub-classes */
FT_EXPORT( FT_Error )
ftc_glyph_set_init( FTC_GlyphSet gset,
FT_LruList list );
- /* can be used as a FTC_LruNode_DoneFunc or called by sub-classes */
+ /* can be used as an FTC_LruNode_DoneFunc or called by sub-classes */
FT_EXPORT( void )
ftc_glyph_set_done( FTC_GlyphSet gset );
- /* can be used as a FTC_Cache_DoneFunc or called by sub-classes */
+ /* can be used as an FTC_Cache_DoneFunc or called by sub-classes */
FT_EXPORT( void )
- ftc_glyph_cache_done( FTC_GlyphCache cache );
+ ftc_glyph_cache_done( FTC_GlyphCache cache );
- /* must be called in a FTC_Cache_InitFunc !! */
+ /* must be called in an FTC_Cache_InitFunc! */
FT_EXPORT( FT_Error )
ftc_glyph_cache_init( FTC_GlyphCache cache,
FT_LruList_Class gset_class );
- /* can be called directly or from sub-classes */
+ /* can be called directly or from sub-classes */
FT_EXPORT( FT_Error )
ftc_glyph_cache_lookup( FTC_GlyphCache cache,
FTC_GlyphQuery query,
diff --git a/include/freetype/cache/ftcimage.h b/include/freetype/cache/ftcimage.h
index a82cf8aa8..55e3e6c43 100644
--- a/include/freetype/cache/ftcimage.h
+++ b/include/freetype/cache/ftcimage.h
@@ -95,14 +95,16 @@ FT_BEGIN_HEADER
} FTC_Image_Desc;
+
/* */
-#define FTC_IMAGE_DESC_COMPARE( d1, d2 ) \
- ( FTC_FONT_COMPARE( &(d1)->font, &(d2)->font ) && \
- (d1)->image_type == (d2)->image_type )
+#define FTC_IMAGE_DESC_COMPARE( d1, d2 ) \
+ ( FTC_FONT_COMPARE( &(d1)->font, &(d2)->font ) && \
+ (d1)->image_type == (d2)->image_type )
+
+#define FTC_IMAGE_DESC_HASH( d ) \
+ (FT_UFast)( FTC_FONT_HASH(&(d)->font) ^ \
+ ((d)->image_type << 4) )
-#define FTC_IMAGE_DESC_HASH(d) \
- (FT_UFast)( FTC_FONT_HASH(&(d)->font) ^ \
- ((d)->image_type << 4) )
/*************************************************************************/
/* */
diff --git a/include/freetype/cache/ftcmanag.h b/include/freetype/cache/ftcmanag.h
index 6355a5d32..edc092db9 100644
--- a/include/freetype/cache/ftcmanag.h
+++ b/include/freetype/cache/ftcmanag.h
@@ -81,20 +81,20 @@ FT_BEGIN_HEADER
#define FTC_MAX_FACES_DEFAULT 2
#define FTC_MAX_SIZES_DEFAULT 4
-#define FTC_MAX_BYTES_DEFAULT 100000L /* 200kByte by default! */
+#define FTC_MAX_BYTES_DEFAULT 100000L /* 100kByte by default! */
/* maximum number of caches registered in a single manager */
#define FTC_MAX_CACHES 16
- /* handle to cache object */
+ /* handle to cache object */
typedef struct FTC_CacheRec_* FTC_Cache;
- /* handle to cache class */
+ /* handle to cache class */
typedef const struct FTC_Cache_ClassRec_* FTC_Cache_Class;
- /* handle to cache node */
- typedef struct FTC_NodeRec_* FTC_Node;
+ /* handle to cache node */
+ typedef struct FTC_NodeRec_* FTC_Node;
@@ -113,7 +113,7 @@ FT_BEGIN_HEADER
/* */
/* sizes_list :: The lru list of FT_Size objects in the cache. */
/* */
- /* max_weight :: The maximum cache pool weight.. */
+ /* max_weight :: The maximum cache pool weight. */
/* */
/* cur_weight :: The current cache pool weight. */
/* */
@@ -195,23 +195,23 @@ FT_BEGIN_HEADER
/* */
- /* structure size should be 20 bytes on 32-bits machines */
- typedef struct FTC_NodeRec_
+ /* structure size should be 20 bytes on 32-bits machines */
+ typedef struct FTC_NodeRec_
{
- FTC_Node mru_next; /* circular mru list pointer */
- FTC_Node mru_prev; /* circular mru list pointer */
- FTC_Node link; /* used for hashing.. */
- FT_UInt32 hash; /* used for hashing too.. */
- FT_UShort cache_index; /* index of cache the node belongs to */
- FT_Short ref_count; /* reference count for this node.. */
+ FTC_Node mru_next; /* circular mru list pointer */
+ FTC_Node mru_prev; /* circular mru list pointer */
+ FTC_Node link; /* used for hashing */
+ FT_UInt32 hash; /* used for hashing too */
+ FT_UShort cache_index; /* index of cache the node belongs to */
+ FT_Short ref_count; /* reference count for this node */
} FTC_NodeRec;
-#define FTC_NODE(x) ((FTC_Node)(x))
-#define FTC_NODE_P(x) ((FTC_Node*)(x))
+#define FTC_NODE( x ) ((FTC_Node)( x ))
+#define FTC_NODE_P( x ) ((FTC_Node*)( x ))
- /* each cache really implements a dynamic hash table to manage its nodes */
+ /* each cache really implements a dynamic hash table to manage its nodes */
typedef struct FTC_CacheRec_
{
FTC_Manager manager;
@@ -228,41 +228,42 @@ FT_BEGIN_HEADER
} FTC_CacheRec;
-#define FTC_CACHE(x) ((FTC_Cache)(x))
-#define FTC_CACHE_P(x) ((FTC_Cache*)(x))
+#define FTC_CACHE( x ) ((FTC_Cache)( x ))
+#define FTC_CACHE_P( x ) ((FTC_Cache*)( x ))
- /* initialize a given cache */
+ /* initialize a given cache */
typedef FT_Error
- (*FTC_Cache_InitFunc)( FTC_Cache cache );
+ (*FTC_Cache_InitFunc)( FTC_Cache cache );
- /* finalize a given cache */
+ /* finalize a given cache */
typedef void
- (*FTC_Cache_DoneFunc)( FTC_Cache cache );
+ (*FTC_Cache_DoneFunc)( FTC_Cache cache );
- /* initialize a new cache node */
+ /* initialize a new cache node */
typedef FT_Error
(*FTC_Node_InitFunc)( FTC_Node node,
FT_Pointer type,
FTC_Cache cache );
- /* compute the weight of a given cache node */
+ /* compute the weight of a given cache node */
typedef FT_ULong
- (*FTC_Node_WeightFunc)( FTC_Node node,
- FTC_Cache cache );
+ (*FTC_Node_WeightFunc)( FTC_Node node,
+ FTC_Cache cache );
- /* compare a node to a given key pair */
+ /* compare a node to a given key pair */
typedef FT_Bool
- (*FTC_Node_CompareFunc)( FTC_Node node,
- FT_Pointer key,
- FTC_Cache cache );
+ (*FTC_Node_CompareFunc)( FTC_Node node,
+ FT_Pointer key,
+ FTC_Cache cache );
- /* finalize a given cache node */
+ /* finalize a given cache node */
typedef void
- (*FTC_Node_DoneFunc)( FTC_Node node,
- FTC_Cache cache );
+ (*FTC_Node_DoneFunc)( FTC_Node node,
+ FTC_Cache cache );
+
- typedef struct FTC_Cache_ClassRec_
+ typedef struct FTC_Cache_ClassRec_
{
FT_UInt cache_size;
FTC_Cache_InitFunc cache_init;
@@ -278,9 +279,9 @@ FT_BEGIN_HEADER
/* */
-#define FTC_CACHE_RESIZE_TEST(c) \
- ( (c)->nodes*3 < (c)->size || \
- (c)->size*3 < (c)->nodes )
+#define FTC_CACHE_RESIZE_TEST( c ) \
+ ( (c)->nodes*3 < (c)->size || \
+ (c)->size*3 < (c)->nodes )
/* this must be used internally for the moment */
@@ -290,35 +291,35 @@ FT_BEGIN_HEADER
FTC_Cache *acache );
- /* can be used directory as FTC_Cache_DoneFunc, or called by custom */
- /* cache finalizers.. */
+ /* can be used directly as FTC_Cache_DoneFunc(), or called by custom */
+ /* cache finalizers */
FT_EXPORT( void )
ftc_cache_done( FTC_Cache cache );
- /* initalize the hash table within the cache */
+ /* initalize the hash table within the cache */
FT_EXPORT( FT_Error )
ftc_cache_init( FTC_Cache cache );
- /* can be used when FTC_CACHE_RESIZE_TEST returns TRUE after a node */
- /* insertion.. */
- FT_EXPORT(void)
+ /* can be used when FTC_CACHE_RESIZE_TEST returns TRUE after a node */
+ /* insertion */
+ FT_EXPORT( void )
ftc_cache_resize( FTC_Cache cache );
- /* can be called when the key's hash value has been computed */
- FT_EXPORT(FT_Error)
- ftc_cache_lookup_node( FTC_Cache cache,
- FT_UFast key_hash,
- FT_Pointer key,
- FTC_Node *anode );
+ /* can be called when the key's hash value has been computed */
+ FT_EXPORT( FT_Error )
+ ftc_cache_lookup_node( FTC_Cache cache,
+ FT_UFast key_hash,
+ FT_Pointer key,
+ FTC_Node *anode );
- /* can be called to increment a node's reference count */
- FT_EXPORT(void)
+ /* can be called to increment a node's reference count */
+ FT_EXPORT( void )
ftc_node_ref( FTC_Node node,
FTC_Cache cache );
- /* can be called to decrement a node's reference count */
- FT_EXPORT(void)
+ /* can be called to decrement a node's reference count */
+ FT_EXPORT( void )
ftc_node_unref( FTC_Node node,
FTC_Cache cache );
diff --git a/include/freetype/cache/ftlru.h b/include/freetype/cache/ftlru.h
index 27fdcf186..d39081418 100644
--- a/include/freetype/cache/ftlru.h
+++ b/include/freetype/cache/ftlru.h
@@ -73,11 +73,12 @@ FT_BEGIN_HEADER
typedef struct FT_LruListRec_* FT_LruList;
/* list class handle */
- typedef const struct FT_LruList_ClassRec_* FT_LruList_Class;
+ typedef const struct FT_LruList_ClassRec_* FT_LruList_Class;
- /* an list node handle */
- typedef struct FT_LruNodeRec_* FT_LruNode;
+ /* a list node handle */
+ typedef struct FT_LruNodeRec_* FT_LruNode;
+
/* the list node structure */
typedef struct FT_LruNodeRec_
{
@@ -100,40 +101,40 @@ FT_BEGIN_HEADER
} FT_LruListRec;
- /* initialize a list list */
+ /* initialize a list list */
typedef FT_Error (*FT_LruList_InitFunc)( FT_LruList list );
- /* finalize a list list */
+ /* finalize a list list */
typedef void (*FT_LruList_DoneFunc)( FT_LruList list );
- /* this method is used to initialize a new list element node */
+ /* this method is used to initialize a new list element node */
typedef FT_Error (*FT_LruNode_InitFunc)( FT_LruNode node,
FT_LruKey key,
FT_LruList list );
- /* this method is used to finalize a given list element node */
+ /* this method is used to finalize a given list element node */
typedef void (*FT_LruNode_DoneFunc)( FT_LruNode node,
FT_LruList list );
- /* If defined, this method is called when the list if full */
- /* during the lookup process -- it is used to change the contents */
- /* of a list element node, instead of calling `done_element()', */
- /* then `init_element'. Set it to 0 for default behaviour. */
+ /* If defined, this method is called when the list if full */
+ /* during the lookup process -- it is used to change the contents */
+ /* of a list element node, instead of calling `done_element()', */
+ /* then `init_element()'. Set it to 0 for default behaviour. */
typedef FT_Error (*FT_LruNode_FlushFunc)( FT_LruNode node,
FT_LruKey new_key,
FT_LruList list );
- /* If defined, this method is used to compare a list element node */
- /* with a given key during a lookup. If set to 0, the `key' */
- /* fields will be directly compared instead. */
+ /* If defined, this method is used to compare a list element node */
+ /* with a given key during a lookup. If set to 0, the `key' */
+ /* fields will be directly compared instead. */
typedef FT_Bool (*FT_LruNode_CompareFunc)( FT_LruNode node,
FT_LruKey key,
FT_LruList list );
- /* A selector is used to indicate whether a given list element node */
- /* is part of a selection for FT_LruList_Remove_Selection(). The function */
- /* must return true (i.e., non-null) to indicate that the node is part */
- /* of it. */
+ /* A selector is used to indicate whether a given list element node */
+ /* is part of a selection for FT_LruList_Remove_Selection(). The */
+ /* functrion must return true (i.e., non-null) to indicate that the */
+ /* node is part of it. */
typedef FT_Bool (*FT_LruNode_SelectFunc)( FT_LruNode node,
FT_Pointer data,
FT_LruList list );
@@ -154,8 +155,8 @@ FT_BEGIN_HEADER
} FT_LruList_ClassRec;
- /* the following functions must be exported in the case where applications */
- /* would want to write their own cache classes.. */
+ /* The following functions must be exported in the case where */
+ /* applications would want to write their own cache classes. */
FT_EXPORT( FT_Error )
FT_LruList_New( FT_LruList_Class clazz,
@@ -173,9 +174,9 @@ FT_BEGIN_HEADER
FT_EXPORT( FT_Error )
- FT_LruList_Lookup( FT_LruList list,
- FT_LruKey key,
- FT_LruNode *anode );
+ FT_LruList_Lookup( FT_LruList list,
+ FT_LruKey key,
+ FT_LruNode *anode );
FT_EXPORT( void )
diff --git a/include/freetype/config/ftoption.h b/include/freetype/config/ftoption.h
index 2f1e5e48e..7a57a6108 100644
--- a/include/freetype/config/ftoption.h
+++ b/include/freetype/config/ftoption.h
@@ -30,41 +30,39 @@ FT_BEGIN_HEADER
/* */
/* USER-SELECTABLE CONFIGURATION MACROS */
/* */
- /* this file contains the default configuration macro definitions for */
- /* a standard build of the FreeType library. There are three ways to */
+ /* This file contains the default configuration macro definitions for */
+ /* a standard build of the FreeType library. There are three ways to */
/* use this file to build project-specific versions of the library: */
/* */
- /* - you can modify this file by hand, but this is not recommended */
- /* in cases where you'd like to build several versions of the */
- /* library from a single source directory */
+ /* - You can modify this file by hand, but this is not recommended in */
+ /* cases where you would like to build several versions of the */
+ /* library from a single source directory. */
/* */
- /* */
- /* - you can put a copy of this file in your build directory, more */
+ /* - You can put a copy of this file in your build directory, more */
/* precisely in "$BUILD/freetype/config/ftoption.h", where "$BUILD" */
- /* is the name of a directory that is included _before_ the */
- /* FreeType include path during compilation. */
+ /* is the name of a directory that is included _before_ the FreeType */
+ /* include path during compilation. */
/* */
- /* the default FreeType Makefiles and Jamfiles use the build */
+ /* The default FreeType Makefiles and Jamfiles use the build */
/* directory "builds/<system>" by default, but you can easily change */
- /* that for your own projects */
- /* */
+ /* that for your own projects. */
/* */
- /* - copy the file <ft2build.h> to "$BUILD/ft2build.h" and modify */
- /* it slightly to pre-define the macro FT_CONFIG_OPTIONS_H used */
- /* to locate this file during the build. For example: */
+ /* - Copy the file <ft2build.h> to "$BUILD/ft2build.h" and modify it */
+ /* slightly to pre-define the macro FT_CONFIG_OPTIONS_H used to */
+ /* locate this file during the build. For example, */
/* */
- /* #define FT_CONFIG_OPTIONS_H <myftoptions.h> */
- /* #include <freetype/config/ftheader.h> */
+ /* #define FT_CONFIG_OPTIONS_H <myftoptions.h> */
+ /* #include <freetype/config/ftheader.h> */
/* */
/* will use "$BUILD/myftoptions.h" instead of this file for macro */
/* definitions. */
/* */
- /* note also that you can similarly pre-define the macro */
- /* FT_CONFIG_MODULES_H used to locate the file listing the modules */
- /* that are statically linked to the library at compile time. */
- /* by default, this file is <freetype/config/ftmodule.h> */
+ /* Note also that you can similarly pre-define the macro */
+ /* FT_CONFIG_MODULES_H used to locate the file listing of the modules */
+ /* that are statically linked to the library at compile time. By */
+ /* default, this file is <freetype/config/ftmodule.h>. */
/* */
- /* we highly recommend using the third method whenever possible */
+ /* We highly recommend using the third method whenever possible. */
/* */
/*************************************************************************/
@@ -111,7 +109,7 @@ FT_BEGIN_HEADER
/* */
/* More details can be found in the files ftmoderr.h and fterrors.h. */
/* */
-#undef FT_CONFIG_OPTION_USE_MODULE_ERRORS
+#undef FT_CONFIG_OPTION_USE_MODULE_ERRORS
/*************************************************************************/
@@ -195,7 +193,7 @@ FT_BEGIN_HEADER
/* file "ftconfig.h" either statically, or through Autoconf */
/* on platforms that support it. */
/* */
-#undef FT_CONFIG_OPTION_FORCE_INT64
+#undef FT_CONFIG_OPTION_FORCE_INT64
/*************************************************************************/
@@ -251,8 +249,9 @@ FT_BEGIN_HEADER
/* */
/* Don't define any of these macros to compile in `release' mode! */
/* */
-#define FT_DEBUG_LEVEL_ERROR
-#define FT_DEBUG_LEVEL_TRACE
+#define FT_DEBUG_LEVEL_ERROR
+#define FT_DEBUG_LEVEL_TRACE
+
/*************************************************************************/
/* */
@@ -260,13 +259,14 @@ FT_BEGIN_HEADER
/* */
/* FreeType now comes with an integrated memory debugger that is */
/* capable of detecting simple errors like memory leaks or double */
- /* deletes. To compile it within your build of the library, you should */
- /* define FT_DEBUG_MEMORY here. */
+ /* deletes. To compile it within your build of the library, you */
+ /* should define FT_DEBUG_MEMORY here. */
/* */
- /* note that the memory debugger is only activated at runtime when */
- /* when the _environment_ variable "FT_DEBUG_MEMORY" is also defined ! */
+ /* Note that the memory debugger is only activated at runtime when */
+ /* when the _environment_ variable "FT_DEBUG_MEMORY" is also defined! */
/* */
-#define FT_DEBUG_MEMORY
+#define FT_DEBUG_MEMORY
+
/*************************************************************************/
/* */
@@ -275,7 +275,7 @@ FT_BEGIN_HEADER
/* Used for debugging, this configuration macro should disappear */
/* soon. */
/* */
-#undef FT_CONFIG_OPTION_OLD_CALCS
+#undef FT_CONFIG_OPTION_OLD_CALCS
/*************************************************************************/
@@ -375,7 +375,7 @@ 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
+#undef TT_CONFIG_OPTION_BYTECODE_INTERPRETER
/*************************************************************************/
diff --git a/include/freetype/freetype.h b/include/freetype/freetype.h
index 41d6f609e..c9a5c2808 100644
--- a/include/freetype/freetype.h
+++ b/include/freetype/freetype.h
@@ -145,6 +145,7 @@ FT_BEGIN_HEADER
/* FT_Get_Kerning */
/* FT_Kerning_Mode */
/* FT_Get_Glyph_Name */
+ /* FT_Get_Postscript_Name */
/* */
/* FT_CharMapRec */
/* FT_Select_Charmap */
@@ -2292,15 +2293,14 @@ FT_BEGIN_HEADER
/* FT_Get_Postscript_Name */
/* */
/* <Description> */
- /* Retrieves the ASCII Postscript name of a given face, when */
- /* available. This should only work with Postscript and TrueType */
- /* fonts.. */
+ /* Retrieves the ASCII Postscript name of a given face, if available. */
+ /* This should only work with Postscript and TrueType fonts. */
/* */
/* <Input> */
- /* face :: handle to source face object. */
+ /* face :: A handle to the source face object. */
/* */
/* <Return> */
- /* pointer to face's Postscript name. NULL when un-available */
+ /* A pointer to the face's Postscript name. NULL if un-available. */
/* */
/* <Note> */
/* The returned pointer is owned by the face and will be destroyed */
diff --git a/include/freetype/ftcache.h b/include/freetype/ftcache.h
index 8fcbd1998..d28b21da1 100644
--- a/include/freetype/ftcache.h
+++ b/include/freetype/ftcache.h
@@ -142,19 +142,21 @@ FT_BEGIN_HEADER
} FTC_FontRec;
+
/* */
-#define FTC_FONT_COMPARE(f1,f2) \
- ( (f1)->face_id == (f2)->face_id && \
- (f1)->pix_width == (f2)->pix_width && \
- (f1)->pix_height == (f2)->pix_height )
+#define FTC_FONT_COMPARE( f1, f2 ) \
+ ( (f1)->face_id == (f2)->face_id && \
+ (f1)->pix_width == (f2)->pix_width && \
+ (f1)->pix_height == (f2)->pix_height )
+
+#define FTC_FACE_ID_HASH( i ) ((FT_UInt32)(FT_Pointer)( i ))
-#define FTC_FACE_ID_HASH(i) ((FT_UInt32)(FT_Pointer)(i))
+#define FTC_FONT_HASH( f ) \
+ (FT_UInt32)( FTC_FACE_ID_HASH((f)->face_id) ^ \
+ ((f)->pix_width << 8) ^ \
+ ((f)->pix_height) )
-#define FTC_FONT_HASH(f) \
- (FT_UInt32)( FTC_FACE_ID_HASH((f)->face_id) ^ \
- ((f)->pix_width << 8) ^ \
- ((f)->pix_height) )
/*************************************************************************/
/* */
diff --git a/include/freetype/internal/ftmemory.h b/include/freetype/internal/ftmemory.h
index ecd23067c..a08a955a3 100644
--- a/include/freetype/internal/ftmemory.h
+++ b/include/freetype/internal/ftmemory.h
@@ -108,6 +108,7 @@ FT_BEGIN_HEADER
FT_Long size,
void* *P );
+
/*************************************************************************/
/* */
/* <Function> */
@@ -171,7 +172,6 @@ FT_BEGIN_HEADER
void** P );
-
/* This `#include' is needed by the MEM_xxx() macros; it should be */
/* available on all platforms we know of. */
#include <string.h>
@@ -183,7 +183,6 @@ FT_BEGIN_HEADER
#define MEM_Move( dest, source, count ) memmove( dest, source, count )
-
/*************************************************************************/
/* */
/* We now support closures to produce completely reentrant code. This */
@@ -200,41 +199,44 @@ FT_BEGIN_HEADER
#ifdef FT_DEBUG_MEMORY
-# define MEM_Alloc( _pointer_, _size_ ) \
- FT_Alloc_Debug( memory, _size_, (void**)&(_pointer_), __FILE__, __LINE__ )
+#define MEM_Alloc( _pointer_, _size_ ) \
+ FT_Alloc_Debug( memory, _size_, \
+ (void**)&(_pointer_), __FILE__, __LINE__ )
-# define MEM_Alloc_Array( _pointer_, _count_, _type_ ) \
- FT_Alloc_Debug( memory, (_count_)*sizeof ( _type_ ), \
- (void**)&(_pointer_), __FILE__, __LINE__ )
+#define MEM_Alloc_Array( _pointer_, _count_, _type_ ) \
+ FT_Alloc_Debug( memory, (_count_)*sizeof ( _type_ ), \
+ (void**)&(_pointer_), __FILE__, __LINE__ )
-# define MEM_Realloc( _pointer_, _current_, _size_ ) \
- FT_Realloc_Debug( memory, _current_, _size_, (void**)&(_pointer_), __FILE__, __LINE__ )
+#define MEM_Realloc( _pointer_, _current_, _size_ ) \
+ FT_Realloc_Debug( memory, _current_, _size_, \
+ (void**)&(_pointer_), __FILE__, __LINE__ )
-# define MEM_Realloc_Array( _pointer_, _current_, _new_, _type_ ) \
- FT_Realloc_Debug( memory, (_current_)*sizeof ( _type_ ), \
- (_new_)*sizeof ( _type_ ), (void**)&(_pointer_), __FILE__, __LINE__ )
+#define MEM_Realloc_Array( _pointer_, _current_, _new_, _type_ ) \
+ FT_Realloc_Debug( memory, (_current_)*sizeof ( _type_ ), \
+ (_new_)*sizeof ( _type_ ), \
+ (void**)&(_pointer_), __FILE__, __LINE__ )
-# define MEM_Free( _pointer_ ) \
+#define MEM_Free( _pointer_ ) \
FT_Free_Debug( memory, (void**)&(_pointer_), __FILE__, __LINE__ )
#else /* !FT_DEBUG_MEMORY */
-# define MEM_Alloc( _pointer_, _size_ ) \
- FT_Alloc( memory, _size_, (void**)&(_pointer_) )
+#define MEM_Alloc( _pointer_, _size_ ) \
+ FT_Alloc( memory, _size_, (void**)&(_pointer_) )
-# define MEM_Alloc_Array( _pointer_, _count_, _type_ ) \
- FT_Alloc( memory, (_count_)*sizeof ( _type_ ), \
- (void**)&(_pointer_) )
+#define MEM_Alloc_Array( _pointer_, _count_, _type_ ) \
+ FT_Alloc( memory, (_count_)*sizeof ( _type_ ), \
+ (void**)&(_pointer_) )
-# define MEM_Realloc( _pointer_, _current_, _size_ ) \
- FT_Realloc( memory, _current_, _size_, (void**)&(_pointer_) )
+#define MEM_Realloc( _pointer_, _current_, _size_ ) \
+ FT_Realloc( memory, _current_, _size_, (void**)&(_pointer_) )
-# define MEM_Realloc_Array( _pointer_, _current_, _new_, _type_ ) \
- FT_Realloc( memory, (_current_)*sizeof ( _type_ ), \
+#define MEM_Realloc_Array( _pointer_, _current_, _new_, _type_ ) \
+ FT_Realloc( memory, (_current_)*sizeof ( _type_ ), \
(_new_)*sizeof ( _type_ ), (void**)&(_pointer_) )
-# define MEM_Free( _pointer_ ) \
- FT_Free( memory, (void**)&(_pointer_) )
+#define MEM_Free( _pointer_ ) \
+ FT_Free( memory, (void**)&(_pointer_) )
#endif /* !FT_DEBUG_MEMORY */
@@ -245,16 +247,16 @@ FT_BEGIN_HEADER
#define REALLOC( _pointer_, _current_, _size_ ) \
FT_SET_ERROR( MEM_Realloc( _pointer_, _current_, _size_ ) )
-#define ALLOC_ARRAY( _pointer_, _count_, _type_ ) \
- FT_SET_ERROR( MEM_Alloc( _pointer_, \
- (_count_)*sizeof ( _type_ ) ) )
+#define ALLOC_ARRAY( _pointer_, _count_, _type_ ) \
+ FT_SET_ERROR( MEM_Alloc( _pointer_, \
+ (_count_)*sizeof ( _type_ ) ) )
-#define REALLOC_ARRAY( _pointer_, _current_, _count_, _type_ ) \
- FT_SET_ERROR( MEM_Realloc( _pointer_, \
- (_current_)*sizeof ( _type_ ), \
- (_count_)*sizeof ( _type_ ) ) )
+#define REALLOC_ARRAY( _pointer_, _current_, _count_, _type_ ) \
+ FT_SET_ERROR( MEM_Realloc( _pointer_, \
+ (_current_)*sizeof ( _type_ ), \
+ (_count_)*sizeof ( _type_ ) ) )
-#define FREE( _pointer_ ) \
+#define FREE( _pointer_ ) \
MEM_Free( _pointer_ )
diff --git a/include/freetype/internal/ftobjs.h b/include/freetype/internal/ftobjs.h
index 96bf3c0cd..31b79c0d1 100644
--- a/include/freetype/internal/ftobjs.h
+++ b/include/freetype/internal/ftobjs.h
@@ -171,15 +171,15 @@ FT_BEGIN_HEADER
/* glyph_delta :: The 2d translation vector corresponding to */
/* the glyph transformation, if necessary. */
/* */
- /* glyph_hints :: format-specific glyph hints management */
+ /* glyph_hints :: Format-specific glyph hints management. */
/* */
- typedef struct FT_Slot_InternalRec_
+ typedef struct FT_Slot_InternalRec_
{
- FT_GlyphLoader* loader;
- FT_Bool glyph_transformed;
- FT_Matrix glyph_matrix;
- FT_Vector glyph_delta;
- void* glyph_hints;
+ FT_GlyphLoader* loader;
+ FT_Bool glyph_transformed;
+ FT_Matrix glyph_matrix;
+ FT_Vector glyph_delta;
+ void* glyph_hints;
} FT_GlyphSlot_InternalRec;
@@ -636,7 +636,7 @@ FT_BEGIN_HEADER
FT_UInt render_mode );
typedef const char*
- (*FT_PSName_Requester)( FT_Face face );
+ (*FT_PSName_Requester)( FT_Face face );
typedef FT_Error
(*FT_Glyph_Name_Requester)( FT_Face face,
diff --git a/include/freetype/internal/internal.h b/include/freetype/internal/internal.h
index 62f369c22..cad39bbf8 100644
--- a/include/freetype/internal/internal.h
+++ b/include/freetype/internal/internal.h
@@ -24,28 +24,28 @@
/*************************************************************************/
-#define FT_INTERNAL_OBJECTS_H <freetype/internal/ftobjs.h>
-#define FT_INTERNAL_STREAM_H <freetype/internal/ftstream.h>
-#define FT_INTERNAL_MEMORY_H <freetype/internal/ftmemory.h>
-#define FT_INTERNAL_EXTENSION_H <freetype/internal/ftextend.h>
-#define FT_INTERNAL_DEBUG_H <freetype/internal/ftdebug.h>
-#define FT_INTERNAL_CALC_H <freetype/internal/ftcalc.h>
-#define FT_INTERNAL_DRIVER_H <freetype/internal/ftdriver.h>
-#define FT_INTERNAL_EXTEND_H <freetype/internal/ftextend.h>
-
-#define FT_INTERNAL_SFNT_H <freetype/internal/sfnt.h>
-
-#define FT_INTERNAL_TRUETYPE_TYPES_H <freetype/internal/tttypes.h>
-#define FT_INTERNAL_TYPE1_TYPES_H <freetype/internal/t1types.h>
-#define FT_INTERNAL_CFF_TYPES_H <freetype/internal/cfftypes.h>
-#define FT_INTERNAL_FNT_TYPES_H <freetype/internal/fnttypes.h>
-
-#define FT_INTERNAL_POSTSCRIPT_NAMES_H <freetype/internal/psnames.h>
-#define FT_INTERNAL_POSTSCRIPT_AUX_H <freetype/internal/psaux.h>
-#define FT_INTERNAL_POSTSCRIPT_HINTS_H <freetype/internal/pshints.h>
-#define FT_INTERNAL_POSTSCRIPT_GLOBALS_H <freetype/internal/psglobal.h>
-
-#define FT_INTERNAL_AUTOHINT_H <freetype/internal/autohint.h>
+#define FT_INTERNAL_OBJECTS_H <freetype/internal/ftobjs.h>
+#define FT_INTERNAL_STREAM_H <freetype/internal/ftstream.h>
+#define FT_INTERNAL_MEMORY_H <freetype/internal/ftmemory.h>
+#define FT_INTERNAL_EXTENSION_H <freetype/internal/ftextend.h>
+#define FT_INTERNAL_DEBUG_H <freetype/internal/ftdebug.h>
+#define FT_INTERNAL_CALC_H <freetype/internal/ftcalc.h>
+#define FT_INTERNAL_DRIVER_H <freetype/internal/ftdriver.h>
+#define FT_INTERNAL_EXTEND_H <freetype/internal/ftextend.h>
+
+#define FT_INTERNAL_SFNT_H <freetype/internal/sfnt.h>
+
+#define FT_INTERNAL_TRUETYPE_TYPES_H <freetype/internal/tttypes.h>
+#define FT_INTERNAL_TYPE1_TYPES_H <freetype/internal/t1types.h>
+#define FT_INTERNAL_CFF_TYPES_H <freetype/internal/cfftypes.h>
+#define FT_INTERNAL_FNT_TYPES_H <freetype/internal/fnttypes.h>
+
+#define FT_INTERNAL_POSTSCRIPT_NAMES_H <freetype/internal/psnames.h>
+#define FT_INTERNAL_POSTSCRIPT_AUX_H <freetype/internal/psaux.h>
+#define FT_INTERNAL_POSTSCRIPT_HINTS_H <freetype/internal/pshints.h>
+#define FT_INTERNAL_POSTSCRIPT_GLOBALS_H <freetype/internal/psglobal.h>
+
+#define FT_INTERNAL_AUTOHINT_H <freetype/internal/autohint.h>
/* END */
diff --git a/include/freetype/internal/psaux.h b/include/freetype/internal/psaux.h
index f74c2d9dd..38816090f 100644
--- a/include/freetype/internal/psaux.h
+++ b/include/freetype/internal/psaux.h
@@ -426,11 +426,12 @@ FT_BEGIN_HEADER
typedef struct T1_Builder_Funcs_
{
- void (*init)( T1_Builder* builder,
- FT_Face face,
- FT_Size size,
- FT_GlyphSlot slot,
- FT_Bool hinting );
+ void
+ (*init)( T1_Builder* builder,
+ FT_Face face,
+ FT_Size size,
+ FT_GlyphSlot slot,
+ FT_Bool hinting );
void
(*done)( T1_Builder* builder );
@@ -586,20 +587,23 @@ FT_BEGIN_HEADER
struct T1_Decoder_Funcs_
{
- FT_Error (*init) ( T1_Decoder* decoder,
- FT_Face face,
- FT_Size size,
- FT_GlyphSlot slot,
- FT_Byte** glyph_names,
- T1_Blend* blend,
- FT_Bool hinting,
- T1_Decoder_Callback callback );
-
- void (*done) ( T1_Decoder* decoder );
-
- FT_Error (*parse_charstrings)( T1_Decoder* decoder,
- FT_Byte* base,
- FT_UInt len );
+ FT_Error
+ (*init) ( T1_Decoder* decoder,
+ FT_Face face,
+ FT_Size size,
+ FT_GlyphSlot slot,
+ FT_Byte** glyph_names,
+ T1_Blend* blend,
+ FT_Bool hinting,
+ T1_Decoder_Callback callback );
+
+ void
+ (*done) ( T1_Decoder* decoder );
+
+ FT_Error
+ (*parse_charstrings)( T1_Decoder* decoder,
+ FT_Byte* base,
+ FT_UInt len );
};
diff --git a/include/freetype/internal/psglobal.h b/include/freetype/internal/psglobal.h
index 9c961f598..5ddafff8b 100644
--- a/include/freetype/internal/psglobal.h
+++ b/include/freetype/internal/psglobal.h
@@ -1,141 +1,186 @@
-#ifndef __PSGLOBALS_H__
-#define __PSGLOBALS_H__
+/***************************************************************************/
+/* */
+/* psglobal.h */
+/* */
+/* Global PostScript hinting structures (specification only). */
+/* */
+/* Copyright 2001 by */
+/* David Turner, Robert Wilhelm, and Werner Lemberg. */
+/* */
+/* This file is part of the FreeType project, and may only be used, */
+/* modified, and distributed under the terms of the FreeType project */
+/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
+/* this file you indicate that you have read the license and */
+/* understand and accept it fully. */
+/* */
+/***************************************************************************/
- /**********************************************************************/
- /**********************************************************************/
- /***** *****/
- /***** PUBLIC STRUCTURES & API *****/
- /***** *****/
- /**********************************************************************/
- /**********************************************************************/
+
+#ifndef __PSGLOBAL_H__
+#define __PSGLOBAL_H__
+
+
+FT_BEGIN_HEADER
+
+
+ /**********************************************************************/
+ /**********************************************************************/
+ /***** *****/
+ /***** PUBLIC STRUCTURES & API *****/
+ /***** *****/
+ /**********************************************************************/
+ /**********************************************************************/
#if 0
- /****************************************************************
- *
- * @constant: PS_GLOBALS_MAX_BLUE_ZONES
- *
- * @description:
- * the maximum number of blue zones in a font global hints
- * structure. See @PS_Globals_BluesRec
- */
-#define PS_GLOBALS_MAX_BLUE_ZONES 16
-
- /****************************************************************
- *
- * @constant: PS_GLOBALS_MAX_STD_WIDTHS
- *
- * @description:
- * the maximum number of standard and snap widths in either the
- * horizontal or vertical direction. See @PS_Globals_WidthsRec
- */
-#define PS_GLOBALS_MAX_STD_WIDTHS 16
-
- /****************************************************************
- *
- * @type: PS_Globals
- *
- * @description:
- * a handle to a @PS_GlobalsRec structure used to
- * describe the global hints of a given font
- */
- typedef struct PS_GlobalsRec_* PS_Globals;
-
- /****************************************************************
- *
- * @struct: PS_Globals_BluesRec
- *
- * @description:
- * a structure used to model the global blue zones of a given
- * font
- *
- * @fields:
- * count :: number of blue zones
- * zones :: an array of (count*2) coordinates describing the zones
- *
- * count_family :: number of family blue zones
- * zones_family :: an array of (count_family*2) coordinates describing
- * the family blue zones
- *
- * scale :: the blue scale to be used (fixed float)
- * shift :: the blue shift to be used
- * fuzz :: the blue fuzz to be used
- *
- * @note:
- * each blue zone is modeled by a (reference,overshoot) coordinate pair
- * in the table. zones can be placed in any order..
- */
- typedef struct PS_Globals_BluesRec
- {
- FT_UInt count;
- FT_Int16 zones[ 2*PS_GLOBALS_MAX_BLUE_ZONES ];
-
- FT_UInt count_family;
- FT_Int16 zones_family[ 2*PS_GLOBALS_MAX_BLUE_ZONES ];
-
- FT_Fixed scale;
- FT_Int16 shift;
- FT_Int16 fuzz;
-
+
+ /*************************************************************************/
+ /* */
+ /* @constant: */
+ /* PS_GLOBALS_MAX_BLUE_ZONES */
+ /* */
+ /* @description: */
+ /* The maximum number of blue zones in a font global hints structure. */
+ /* See @PS_Globals_BluesRec. */
+ /* */
+#define PS_GLOBALS_MAX_BLUE_ZONES 16
+
+
+ /*************************************************************************/
+ /* */
+ /* @constant: */
+ /* PS_GLOBALS_MAX_STD_WIDTHS */
+ /* */
+ /* @description: */
+ /* The maximum number of standard and snap widths in either the */
+ /* horizontal or vertical direction. See @PS_Globals_WidthsRec. */
+ /* */
+#define PS_GLOBALS_MAX_STD_WIDTHS 16
+
+
+ /*************************************************************************/
+ /* */
+ /* @type: */
+ /* PS_Globals */
+ /* */
+ /* @description: */
+ /* A handle to a @PS_GlobalsRec structure used to describe the global */
+ /* hints of a given font. */
+ /* */
+ typedef struct PS_GlobalsRec_* PS_Globals;
+
+
+ /*************************************************************************/
+ /* */
+ /* @struct: */
+ /* PS_Globals_BluesRec */
+ /* */
+ /* @description: */
+ /* A structure used to model the global blue zones of a given font. */
+ /* */
+ /* @fields: */
+ /* count :: The number of blue zones. */
+ /* */
+ /* zones :: An array of (count*2) coordinates describing the */
+ /* zones. */
+ /* */
+ /* count_family :: The number of family blue zones. */
+ /* */
+ /* zones_family :: An array of (count_family*2) coordinates describing */
+ /* the family blue zones. */
+ /* */
+ /* scale :: The blue scale to be used (fixed float). */
+ /* */
+ /* shift :: The blue shift to be used. */
+ /* */
+ /* fuzz :: Te blue fuzz to be used. */
+ /* */
+ /* @note: */
+ /* Each blue zone is modeled by a (reference,overshoot) coordinate */
+ /* pair in the table. Zones can be placed in any order. */
+ /* */
+ typedef struct PS_Globals_BluesRec_
+ {
+ FT_UInt count;
+ FT_Int16 zones[2 * PS_GLOBALS_MAX_BLUE_ZONES];
+
+ FT_UInt count_family;
+ FT_Int16 zones_family[2 * PS_GLOBALS_MAX_BLUE_ZONES];
+
+ FT_Fixed scale;
+ FT_Int16 shift;
+ FT_Int16 fuzz;
+
} PS_Globals_BluesRec, *PS_Globals_Blues;
- /****************************************************************
- *
- * @type: PS_Global_Widths;
- *
- * @description:
- * a handle to a @PS_Globals_WidthsRec structure used to model
- * the global standard and snap widths in a given direction
- */
+ /*************************************************************************/
+ /* */
+ /* @type: */
+ /* PS_Global_Widths */
+ /* */
+ /* @description: */
+ /* A handle to a @PS_Globals_WidthsRec structure used to model the */
+ /* global standard and snap widths in a given direction. */
+ /* */
typedef struct PS_Globals_WidthsRec_* PS_Globals_Widths;
-
-
- /****************************************************************
- *
- * @struct: PS_Globals_WidthsRec
- *
- * @description:
- * a structure used to model the global standard and snap widths
- * in a given font
- *
- * @fields:
- * count :: number of widths
- * widths :: an array of 'count' widths in font units.
- *
- * @note:
- * 'widths[0]' must be the standard width or height, while
- * remaining elements of the array are snap widths or heights
- */
- typedef struct PS_Globals_WidthsRec_
- {
- FT_UInt count;
- FT_Int16 widths[ PS_GLOBALS_MAX_STD_WIDTHS ];
-
+
+
+ /*************************************************************************/
+ /* */
+ /* @struct: */
+ /* PS_Globals_WidthsRec */
+ /* */
+ /* @description: */
+ /* A structure used to model the global standard and snap widths in a */
+ /* given font. */
+ /* */
+ /* @fields: */
+ /* count :: The number of widths. */
+ /* */
+ /* widths :: An array of `count' widths in font units. */
+ /* */
+ /* @note: */
+ /* `widths[0]' must be the standard width or height, while remaining */
+ /* elements of the array are snap widths or heights. */
+ /* */
+ typedef struct PS_Globals_WidthsRec_
+ {
+ FT_UInt count;
+ FT_Int16 widths[PS_GLOBALS_MAX_STD_WIDTHS];
+
} PS_Globals_WidthsRec;
-
- /****************************************************************
- *
- * @struct: PS_Globals_GlobalsRec
- *
- * @description:
- * a structure used to model the global hints for a given font
- *
- * @fields:
- * horizontal :: horizontal widths
- * vertical :: vertical heights
- * blues :: blue zones
- */
- typedef struct PS_GlobalsRec_
+
+ /*************************************************************************/
+ /* */
+ /* @struct: */
+ /* PS_GlobalsRec */
+ /* */
+ /* @description: */
+ /* A structure used to model the global hints for a given font. */
+ /* */
+ /* @fields: */
+ /* horizontal :: The horizontal widths. */
+ /* */
+ /* vertical :: The vertical heights. */
+ /* */
+ /* blues :: The blue zones. */
+ /* */
+ typedef struct PS_GlobalsRec_
{
PS_Globals_WidthsRec horizontal;
PS_Globals_WidthsRec vertical;
PS_Globals_BluesRec blues;
-
+
} PS_GlobalsRec;
-
-#endif
+#endif
+
/* */
-#endif /* __PS_GLOBALS_H__ */
+FT_END_HEADER
+
+#endif /* __PS_GLOBAL_H__ */
+
+
+/* END */
diff --git a/include/freetype/internal/pshints.h b/include/freetype/internal/pshints.h
index 4384ad791..87a4d806d 100644
--- a/include/freetype/internal/pshints.h
+++ b/include/freetype/internal/pshints.h
@@ -3,8 +3,8 @@
/* pshints.h */
/* */
/* Interface to Postscript-specific (Type 1 and Type 2) hints */
-/* recorders. These are used to support native T1/T2 hints */
-/* in the "type1", "cid" and "cff" font drivers */
+/* recorders (specification only). These are used to support native */
+/* T1/T2 hints in the "type1", "cid" and "cff" font drivers. */
/* */
/* Copyright 2001 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
@@ -17,491 +17,575 @@
/* */
/***************************************************************************/
+
#ifndef __PSHINTS_H__
#define __PSHINTS_H__
+
#include <ft2build.h>
#include FT_FREETYPE_H
#include FT_TYPE1_TABLES_H
#include FT_INTERNAL_POSTSCRIPT_GLOBALS_H
+
FT_BEGIN_HEADER
- /**********************************************************************/
- /**********************************************************************/
- /***** *****/
- /***** INTERNAL REPRESENTATION OF GLOBALS *****/
- /***** *****/
- /**********************************************************************/
- /**********************************************************************/
-
- typedef struct PSH_GlobalsRec_* PSH_Globals;
-
- typedef FT_Error (*PSH_Globals_NewFunc)( FT_Memory memory,
- T1_Private* private_dict,
- PSH_Globals* aglobals );
-
- typedef FT_Error (*PSH_Globals_SetScaleFunc)( PSH_Globals globals,
- FT_Fixed x_scale,
- FT_Fixed y_scale,
- FT_Fixed x_delta,
- FT_Fixed y_delta );
-
- typedef void (*PSH_Globals_DestroyFunc)( PSH_Globals globals );
-
- typedef struct
+
+ /*************************************************************************/
+ /*************************************************************************/
+ /***** *****/
+ /***** INTERNAL REPRESENTATION OF GLOBALS *****/
+ /***** *****/
+ /*************************************************************************/
+ /*************************************************************************/
+
+ typedef struct PSH_GlobalsRec_* PSH_Globals;
+
+ typedef FT_Error
+ (*PSH_Globals_NewFunc)( FT_Memory memory,
+ T1_Private* private_dict,
+ PSH_Globals* aglobals );
+
+ typedef FT_Error
+ (*PSH_Globals_SetScaleFunc)( PSH_Globals globals,
+ FT_Fixed x_scale,
+ FT_Fixed y_scale,
+ FT_Fixed x_delta,
+ FT_Fixed y_delta );
+
+ typedef void
+ (*PSH_Globals_DestroyFunc)( PSH_Globals globals );
+
+
+ typedef struct PSH_Globals_FuncsRec_
{
PSH_Globals_NewFunc create;
PSH_Globals_SetScaleFunc set_scale;
PSH_Globals_DestroyFunc destroy;
-
+
} PSH_Globals_FuncsRec, *PSH_Globals_Funcs;
- /**********************************************************************/
- /**********************************************************************/
- /***** *****/
- /***** PUBLIC TYPE 1 HINTS RECORDER *****/
- /***** *****/
- /**********************************************************************/
- /**********************************************************************/
-
- /************************************************************************
- *
- * @type: T1_Hints
- *
- * @description:
- * this is a handle to an opaque structure used to record glyph
- * hints from a Type 1 character glyph character string.
- *
- * the methods used to operate on this object are defined by the
- * @T1_Hints_FuncsRec structure. Recording glyph hints is normally
- * achieved through the following scheme:
- *
- * - open a new hint recording session by calling the "open"
- * method. This will rewind the recorder and prepare it for
- * new input
- *
- * - for each hint found in the glyph charstring, call the
- * corresponding method ("stem", "stem3" or "reset").
- * note that these functions do not return an error code
- *
- * - close the recording session by calling the "close" method
- * it will return an error code if the hints were invalid or
- * something strange happened (e.g. memory shortage)
- *
- * the hints accumulated in the object can later be used by the
- * Postscript hinter
- */
- typedef struct T1_HintsRec_* T1_Hints;
-
- /************************************************************************
- *
- * @type: T1_Hints_Funcs
- *
- * @description:
- * a pointer to the @T1_Hints_FuncsRec structure that defines the
- * API of a given @T1_Hints object
- */
+
+ /*************************************************************************/
+ /*************************************************************************/
+ /***** *****/
+ /***** PUBLIC TYPE 1 HINTS RECORDER *****/
+ /***** *****/
+ /*************************************************************************/
+ /*************************************************************************/
+
+ /*************************************************************************/
+ /* */
+ /* @type: */
+ /* T1_Hints */
+ /* */
+ /* @description: */
+ /* This is a handle to an opaque structure used to record glyph hints */
+ /* from a Type 1 character glyph character string. */
+ /* */
+ /* The methods used to operate on this object are defined by the */
+ /* @T1_Hints_FuncsRec structure. Recording glyph hints is normally */
+ /* achieved through the following scheme: */
+ /* */
+ /* - Open a new hint recording session by calling the "open" method. */
+ /* This will rewind the recorder and prepare it for new input. */
+ /* */
+ /* - For each hint found in the glyph charstring, call the */
+ /* corresponding method ("stem", "stem3", or "reset"). Note that */
+ /* these functions do not return an error code. */
+ /* */
+ /* - Close the recording session by calling the "close" method. It */
+ /* will return an error code if the hints were invalid or something */
+ /* strange happened (e.g. memory shortage). */
+ /* */
+ /* The hints accumulated in the object can later be used by the */
+ /* Postscript hinter. */
+ /* */
+ typedef struct T1_HintsRec_* T1_Hints;
+
+
+ /*************************************************************************/
+ /* */
+ /* @type: */
+ /* T1_Hints_Funcs */
+ /* */
+ /* @description: */
+ /* A pointer to the @T1_Hints_FuncsRec structure that defines the */
+ /* API of a given @T1_Hints object. */
+ /* */
typedef const struct T1_Hints_FuncsRec_* T1_Hints_Funcs;
-
-
- /************************************************************************
- *
- * @functype: T1_Hints_OpenFunc
- *
- * @description:
- * a method of the @T1_Hints class used to prepare it for a new
- * Type 1 hints recording session
- *
- * @input:
- * hints :: handle to Type 1 hints recorder
- *
- * @note:
- * You should always call the @T1_Hints_CloseFunc method in order
- * to close an opened recording session
- */
- typedef void (*T1_Hints_OpenFunc) ( T1_Hints hints );
-
- /************************************************************************
- *
- * @functype: T1_Hints_SetStemFunc
- *
- * @description:
- * a method of the @T1_Hints class used to record a new horizontal or
- * vertical stem. This corresponds to the Type 1 "hstem" and "vstem"
- * operators
- *
- * @input:
- * hints :: handle to Type 1 hints recorder
- * dimension :: 0 for horizontal stems (hstem), 1 for vertical ones (vstem)
- * coords :: array of 2 integers, used as (position,length) stem descriptor
- *
- * @note:
- * use vertical coordinates (y) for horizontal stems (dim=0)
- * use horizontal coordinates (x) for vertical stems (dim=1)
- *
- * "coords[0]" is the absolute stem position (lowest coordinate)
- * "coords[1]" is the length.
- *
- * the length can be negative, in which case it must be either
- * -20 or -21 in order and will be interpreted as a "ghost" stem,
- * according to the Type 1 specification.
- *
- * if the length is -21 (corresponding to a bottom ghost stem), then
- * the real stem position is "coords[0]+coords[1]"
- */
- typedef void (*T1_Hints_SetStemFunc) ( T1_Hints hints,
- FT_UInt dimension,
- FT_Long* coords );
-
- /************************************************************************
- *
- * @functype: T1_Hints_SetStem3Func
- *
- * @description:
- * a method of the @T1_Hints class used to record three counter-controlled
- * horizontal or vertical stems at once
- *
- * @input:
- * hints :: handle to Type 1 hints recorder
- * dimension :: 0 for horizontal stems, 1 for vertical ones
- * coords :: array of 6 integers, i.e. 3 (position,length) pairs
- * for the counter-controlled stems
- *
- * @note:
- * use vertical coordinates (y) for horizontal stems (dim=0)
- * use horizontal coordinates (x) for vertical stems (dim=1)
- *
- * the lengths cannot be negative (ghost stems are never counter-controlled)
- */
- typedef void (*T1_Hints_SetStem3Func) ( T1_Hints hints,
- FT_UInt dimension,
- FT_Long* coords );
-
- /************************************************************************
- *
- * @functype: T1_Hints_ResetFunc
- *
- * @description:
- * a method of the @T1_Hints class used to reset the stems hints
- * in a recording session. This is equivalent to the Type 1 ...
- *
- * @input:
- * hints :: handle to Type 1 hints recorder
- * end_point :: index of last point in the input glyph in which
- * the previously defined hints apply
- */
- typedef void (*T1_Hints_ResetFunc)( T1_Hints hints,
- FT_UInt end_point );
-
- /************************************************************************
- *
- * @functype: T1_Hints_CloseFunc
- *
- * @description:
- * a method of the @T1_Hints class used to close a hint recording
- * session.
- *
- * @input:
- * hints :: handle to Type 1 hints recorder
- * end_point :: index of last point in the input glyph
- *
- * @return:
- * error code. 0 means success
- *
- * @note:
- * the error code will be set to indicate that an error occured
- * during the recording session
- */
- typedef FT_Error (*T1_Hints_CloseFunc)( T1_Hints hints,
- FT_UInt end_point );
-
-
- /************************************************************************
- *
- * @functype: T1_Hints_ApplyFunc
- *
- * @description:
- * a method of the @T1_Hints class used to apply hints to the
- * corresponding glyph outline. Must be called once all hints
- * have been recorded.
- *
- * @input:
- * hints :: handle to Type 1 hints recorder
- * outline :: pointer to target outline descriptor
- * globals :: the hinter globals for this font
- *
- * @return:
- * error code. 0 means success
- *
- * @note:
- * on input, all points within the outline are in font coordinates.
- * on output, they're in 1/64th of pixels.
- *
- * the scaling transform is taken from the "globals" object, which
- * must correspond to the same font than the glyph
- */
- typedef FT_Error (*T1_Hints_ApplyFunc)( T1_Hints hints,
- FT_Outline* outline,
- PSH_Globals globals );
-
-
- /************************************************************************
- *
- * @struct: T1_Hints_FuncsRec
- *
- * @description:
- * the structure used to provide the API to @T1_Hints objects
- *
- * @fields:
- * hints :: handle to T1 Hints recorder
- * open :: open recording session
- * close :: close recording session
- * stem :: set simple stem
- * stem3 :: set counter-controlled stems
- * reset :: reset stem hints
- * apply :: apply the hints to the corresponding glyph outline
- */
- typedef struct T1_Hints_FuncsRec_
+
+
+ /*************************************************************************/
+ /* */
+ /* @functype: */
+ /* T1_Hints_OpenFunc */
+ /* */
+ /* @description: */
+ /* A method of the @T1_Hints class used to prepare it for a new */
+ /* Type 1 hints recording session. */
+ /* */
+ /* @input: */
+ /* hints :: A handle to the Type 1 hints recorder. */
+ /* */
+ /* @note: */
+ /* You should always call the @T1_Hints_CloseFunc method in order to */
+ /* close an opened recording session. */
+ /* */
+ typedef void
+ (*T1_Hints_OpenFunc)( T1_Hints hints );
+
+
+ /*************************************************************************/
+ /* */
+ /* @functype: */
+ /* T1_Hints_SetStemFunc */
+ /* */
+ /* @description: */
+ /* A method of the @T1_Hints class used to record a new horizontal or */
+ /* vertical stem. This corresponds to the Type 1 "hstem" and "vstem" */
+ /* operators. */
+ /* */
+ /* @input: */
+ /* hints :: A handle to the Type 1 hints recorder. */
+ /* */
+ /* dimension :: 0 for horizontal stems (hstem), 1 for vertical ones */
+ /* (vstem). */
+ /* */
+ /* coords :: Array of 2 integers, used as (position,length) stem */
+ /* descriptor. */
+ /* */
+ /* @note: */
+ /* Use vertical coordinates (y) for horizontal stems (dim=0). Use */
+ /* horizontal coordinates (x) for vertical stems (dim=1). */
+ /* */
+ /* "coords[0]" is the absolute stem position (lowest coordinate); */
+ /* "coords[1]" is the length. */
+ /* */
+ /* The length can be negative, in which case it must be either -20 or */
+ /* -21. It will be interpreted as a "ghost" stem, according to */
+ /* Type 1 specification. */
+ /* */
+ /* If the length is -21 (corresponding to a bottom ghost stem), then */
+ /* the real stem position is "coords[0]+coords[1]". */
+ /* */
+ typedef void
+ (*T1_Hints_SetStemFunc)( T1_Hints hints,
+ FT_UInt dimension,
+ FT_Long* coords );
+
+
+ /*************************************************************************/
+ /* */
+ /* @functype: */
+ /* T1_Hints_SetStem3Func */
+ /* */
+ /* @description: */
+ /* A method of the @T1_Hints class used to record three */
+ /* counter-controlled horizontal or vertical stems at once. */
+ /* */
+ /* @input: */
+ /* hints :: A handle to the Type 1 hints recorder. */
+ /* */
+ /* dimension :: 0 for horizontal stems, 1 for vertical ones. */
+ /* */
+ /* coords :: An array of 6 integers, holding 3 (position,length) */
+ /* pairs for the counter-controlled stems. */
+ /* */
+ /* @note: */
+ /* Use vertical coordinates (y) for horizontal stems (dim=0). Use */
+ /* horizontal coordinates (x) for vertical stems (dim=1). */
+ /* */
+ /* The lengths cannot be negative (ghost stems are never */
+ /* counter-controlled). */
+ /* */
+ typedef void
+ (*T1_Hints_SetStem3Func)( T1_Hints hints,
+ FT_UInt dimension,
+ FT_Long* coords );
+
+
+ /*************************************************************************/
+ /* */
+ /* @functype: */
+ /* T1_Hints_ResetFunc */
+ /* */
+ /* @description: */
+ /* A method of the @T1_Hints class used to reset the stems hints in a */
+ /* recording session. */
+ /* */
+ /* @input: */
+ /* hints :: A handle to the Type 1 hints recorder. */
+ /* end_point :: The index of the last point in the input glyph in */
+ /* which the previously defined hints apply. */
+ /* */
+ typedef void
+ (*T1_Hints_ResetFunc)( T1_Hints hints,
+ FT_UInt end_point );
+
+
+ /*************************************************************************/
+ /* */
+ /* @functype: */
+ /* T1_Hints_CloseFunc */
+ /* */
+ /* @description: */
+ /* A method of the @T1_Hints class used to close a hint recording */
+ /* session. */
+ /* */
+ /* @input: */
+ /* hints :: A handle to the Type 1 hints recorder. */
+ /* */
+ /* end_point :: The index of the last point in the input glyph. */
+ /* */
+ /* @return: */
+ /* FreeType error code. 0 means success. */
+ /* */
+ /* @note: */
+ /* The error code will be set to indicate that an error occured */
+ /* during the recording session. */
+ /* */
+ typedef FT_Error
+ (*T1_Hints_CloseFunc)( T1_Hints hints,
+ FT_UInt end_point );
+
+
+ /*************************************************************************/
+ /* */
+ /* @functype: */
+ /* T1_Hints_ApplyFunc */
+ /* */
+ /* @description: */
+ /* A method of the @T1_Hints class used to apply hints to the */
+ /* corresponding glyph outline. Must be called once all hints have */
+ /* been recorded. */
+ /* */
+ /* @input: */
+ /* hints :: A handle to the Type 1 hints recorder. */
+ /* */
+ /* outline :: A pointer to the target outline descriptor. */
+ /* */
+ /* globals :: The hinter globals for this font. */
+ /* */
+ /* @return: */
+ /* FreeType error code. 0 means success. */
+ /* */
+ /* @note: */
+ /* On input, all points within the outline are in font coordinates. */
+ /* On output, they are in 1/64th of pixels. */
+ /* */
+ /* The scaling transformation is taken from the "globals" object */
+ /* 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 );
+
+
+ /*************************************************************************/
+ /* */
+ /* @struct: */
+ /* T1_Hints_FuncsRec */
+ /* */
+ /* @description: */
+ /* The structure used to provide the API to @T1_Hints objects. */
+ /* */
+ /* @fields: */
+ /* hints :: A handle to the T1 Hints recorder. */
+ /* */
+ /* open :: The function to open a recording session. */
+ /* */
+ /* close :: The function to close a recording session. */
+ /* */
+ /* stem :: The function to set a simple stem. */
+ /* */
+ /* stem3 :: The function to set counter-controlled stems. */
+ /* */
+ /* reset :: The function to reset stem hints. */
+ /* */
+ /* apply :: The function to apply the hints to the corresponding */
+ /* glyph outline. */
+ /* */
+ typedef struct T1_Hints_FuncsRec_
{
- T1_Hints hints;
- T1_Hints_OpenFunc open;
- T1_Hints_CloseFunc close;
- T1_Hints_SetStemFunc stem;
- T1_Hints_SetStem3Func stem3;
- T1_Hints_ResetFunc reset;
- T1_Hints_ApplyFunc apply;
-
+ T1_Hints hints;
+ T1_Hints_OpenFunc open;
+ T1_Hints_CloseFunc close;
+ T1_Hints_SetStemFunc stem;
+ T1_Hints_SetStem3Func stem3;
+ T1_Hints_ResetFunc reset;
+ T1_Hints_ApplyFunc apply;
+
} T1_Hints_FuncsRec;
- /**********************************************************************/
- /**********************************************************************/
- /***** *****/
- /***** PUBLIC TYPE 2 HINTS RECORDER *****/
- /***** *****/
- /**********************************************************************/
- /**********************************************************************/
-
-
- /************************************************************************
- *
- * @type: T2_Hints
- *
- * @description:
- * this is a handle to an opaque structure used to record glyph
- * hints from a Type 2 character glyph character string.
- *
- * the methods used to operate on this object are defined by the
- * @T2_Hints_FuncsRec structure. Recording glyph hints is normally
- * achieved through the following scheme:
- *
- * - open a new hint recording session by calling the "open"
- * method. This will rewind the recorder and prepare it for
- * new input
- *
- * - for each hint found in the glyph charstring, call the
- * corresponding method ("stems", "hintmask", "counters").
- * note that these functions do not return an error code
- *
- * - close the recording session by calling the "close" method
- * it will return an error code if the hints were invalid or
- * something strange happened (e.g. memory shortage)
- *
- * the hints accumulated in the object can later be used by the
- * Postscript hinter
- */
- typedef struct T2_HintsRec_* T2_Hints;
-
- /************************************************************************
- *
- * @type: T2_Hints_Funcs
- *
- * @description:
- * a pointer to the @T1_Hints_FuncsRec structure that defines the
- * API of a given @T2_Hints object
- */
+ /*************************************************************************/
+ /*************************************************************************/
+ /***** *****/
+ /***** PUBLIC TYPE 2 HINTS RECORDER *****/
+ /***** *****/
+ /*************************************************************************/
+ /*************************************************************************/
+
+ /*************************************************************************/
+ /* */
+ /* @type: */
+ /* T2_Hints */
+ /* */
+ /* @description: */
+ /* This is a handle to an opaque structure used to record glyph hints */
+ /* from a Type 2 character glyph character string. */
+ /* */
+ /* The methods used to operate on this object are defined by the */
+ /* @T2_Hints_FuncsRec structure. Recording glyph hints is normally */
+ /* achieved through the following scheme: */
+ /* */
+ /* - Open a new hint recording session by calling the "open" method. */
+ /* This will rewind the recorder and prepare it for new input. */
+ /* */
+ /* - For each hint found in the glyph charstring, call the */
+ /* corresponding method ("stems", "hintmask", "counters"). Note */
+ /* that these functions do not return an error code. */
+ /* */
+ /* - Close the recording session by calling the "close" method. It */
+ /* will return an error code if the hints were invalid or something */
+ /* strange happened (e.g. memory shortage). */
+ /* */
+ /* The hints accumulated in the object can later be used by the */
+ /* Postscript hinter. */
+ /* */
+ typedef struct T2_HintsRec_* T2_Hints;
+
+
+ /*************************************************************************/
+ /* */
+ /* @type: */
+ /* T2_Hints_Funcs */
+ /* */
+ /* @description: */
+ /* A pointer to the @T2_Hints_FuncsRec structure that defines the API */
+ /* of a given @T2_Hints object. */
+ /* */
typedef const struct T2_Hints_FuncsRec_* T2_Hints_Funcs;
- /************************************************************************
- *
- * @functype: T2_Hints_OpenFunc
- *
- * @description:
- * a method of the @T2_Hints class used to prepare it for a new
- * Type 2 hints recording session
- *
- * @input:
- * hints :: handle to Type 2 hints recorder
- *
- * @note:
- * You should always call the @T2_Hints_CloseFunc method in order
- * to close an opened recording session
- */
- typedef void (*T2_Hints_OpenFunc) ( T2_Hints hints );
-
-
- /************************************************************************
- *
- * @functype: T2_Hints_StemsFunc
- *
- * @description:
- * a method of the @T2_Hints class used to set the table of stems
- * in either the vertical or horizontal dimension. Equivalent to the
- * "hstem", "vstem", "hstemhm" and "vstemhm" Type 2 operators
- *
- * @input:
- * hints :: handle to Type 2 hints recorder
- * dimension :: 0 for horizontal stems (hstem), 1 for vertical ones (vstem)
- * count :: number of stems
- * coordinates :: an array of "count" (position,length) pairs
- *
- * @note:
- * use vertical coordinates (y) for horizontal stems (dim=0)
- * use horizontal coordinates (x) for vertical stems (dim=1)
- *
- * there are "2*count" elements in the "coordinates" array. Each
- * even element is an absolute position in font units, each odd
- * element is a length in font units
- *
- * a length can be negative, in which case it must be either
- * -20 or -21 in order and will be interpreted as a "ghost" stem,
- * according to the Type 1 specification.
- */
- typedef void (*T2_Hints_StemsFunc) ( T2_Hints hints,
- FT_UInt dimension,
- FT_UInt count,
- FT_Fixed* coordinates );
-
- /************************************************************************
- *
- * @functype: T2_Hints_MaskFunc
- *
- * @description:
- * a method of the @T2_Hints class used to set a given hintmask
- * (correspond to the "hintmask" Type 2 operator)
- *
- * @input:
- * hints :: handle to Type 2 hints recorder
- * end_point :: glyph index of the last point to which the previously
- * defined/active hints apply.
- * bit_count :: number of bits in the hint mask.
- * bytes :: an array of bytes modelling the hint mask
- *
- * @note:
- * if the hintmask starts the charstring (before any glyph point
- * definition), the value of "end_point" should be 0
- *
- * "bit_count" is the number of meaningful bits in the "bytes" array,
- * and must be equal to the total number of hints defined so far
- * (i.e. horizontal+verticals)
- *
- * the "bytes" array can come directly from the Type 2 charstring
- * and respect the same format.
- */
- typedef void (*T2_Hints_MaskFunc) ( T2_Hints hints,
- FT_UInt end_point,
- FT_UInt bit_count,
- const FT_Byte* bytes );
-
- /************************************************************************
- *
- * @functype: T2_Hints_CounterFunc
- *
- * @description:
- * a method of the @T2_Hints class used to set a given counter
- * mask (correspond to the "hintmask" Type 2 operator)
- *
- * @input:
- * hints :: handle to Type 2 hints recorder
- * end_point :: glyph index of the last point to which the previously
- * defined/active hints apply.
- * bit_count :: number of bits in the hint mask.
- * bytes :: an array of bytes modelling the hint mask
- *
- * @note:
- * if the hintmask starts the charstring (before any glyph point
- * definition), the value of "end_point" should be 0
- *
- * "bit_count" is the number of meaningful bits in the "bytes" array,
- * and must be equal to the total number of hints defined so far
- * (i.e. horizontal+verticals)
- *
- * the "bytes" array can come directly from the Type 2 charstring
- * and respect the same format.
- */
- typedef void (*T2_Hints_CounterFunc)( T2_Hints hints,
- FT_UInt bit_count,
- const FT_Byte* bytes );
-
- /************************************************************************
- *
- * @functype: T2_Hints_CloseFunc
- *
- * @description:
- * a method of the @T2_Hints class used to close a hint recording
- * session.
- *
- * @input:
- * hints :: handle to Type 2 hints recorder
- * end_point :: index of last point in the input glyph
- *
- * @return:
- * error code. 0 means success
- *
- * @note:
- * the error code will be set to indicate that an error occured
- * during the recording session
- */
- typedef FT_Error (*T2_Hints_CloseFunc) ( T2_Hints hints,
- FT_UInt end_point );
-
-
- /************************************************************************
- *
- * @functype: T2_Hints_ApplyFunc
- *
- * @description:
- * a method of the @T2_Hints class used to apply hints to the
- * corresponding glyph outline. Must be called after the "close" method
- *
- * @input:
- * hints :: handle to Type 2 hints recorder
- * outline :: pointer to target outline descriptor
- * globals :: the hinter globals for this font
- *
- * @return:
- * error code. 0 means success
- *
- * @note:
- * on input, all points within the outline are in font coordinates.
- * on output, they're in 1/64th of pixels.
- *
- * the scaling transform is taken from the "globals" object, 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 );
-
-
- /************************************************************************
- *
- * @struct: T2_Hints_FuncsRec
- *
- * @description:
- * the structure used to provide the API to @T2_Hints objects
- *
- * @fields:
- * hints :: handle to T2 hints recorder object
- * open :: open recording session
- * close :: close recording session
- * stems :: set dimension's stems table
- * hintmask :: set hint masks
- * counter :: set counter masks
- * apply :: apply the hints on the corresponding glyph outline
- */
- typedef struct T2_Hints_FuncsRec_
+
+ /*************************************************************************/
+ /* */
+ /* @functype: */
+ /* T2_Hints_OpenFunc */
+ /* */
+ /* @description: */
+ /* A method of the @T2_Hints class used to prepare it for a new */
+ /* Type 2 hints recording session. */
+ /* */
+ /* @input: */
+ /* hints :: A handle to the Type 2 hints recorder. */
+ /* */
+ /* @note: */
+ /* You should always call the @T2_Hints_CloseFunc method in order to */
+ /* close an opened recording session. */
+ /* */
+ typedef void
+ (*T2_Hints_OpenFunc)( T2_Hints hints );
+
+
+ /*************************************************************************/
+ /* */
+ /* @functype: */
+ /* T2_Hints_StemsFunc */
+ /* */
+ /* @description: */
+ /* A method of the @T2_Hints class used to set the table of stems in */
+ /* either the vertical or horizontal dimension. Equivalent to the */
+ /* "hstem", "vstem", "hstemhm", and "vstemhm" Type 2 operators. */
+ /* */
+ /* @input: */
+ /* hints :: A handle to the Type 2 hints recorder. */
+ /* */
+ /* dimension :: 0 for horizontal stems (hstem), 1 for vertical ones */
+ /* (vstem). */
+ /* */
+ /* count :: The number of stems. */
+ /* */
+ /* coords :: An array of "count" (position,length) pairs. */
+ /* */
+ /* @note: */
+ /* Use vertical coordinates (y) for horizontal stems (dim=0). Use */
+ /* horizontal coordinates (x) for vertical stems (dim=1). */
+ /* */
+ /* There are "2*count" elements in the "coords" aray. Each even */
+ /* element is an absolute position in font units, each odd element is */
+ /* a length in font units. */
+ /* */
+ /* A length can be negative, in which case it must be either -20 or */
+ /* -21. It will be interpreted as a "ghost" stem, according to the */
+ /* Type 1 specification. */
+ /* */
+ typedef void
+ (*T2_Hints_StemsFunc)( T2_Hints hints,
+ FT_UInt dimension,
+ FT_UInt count,
+ FT_Fixed* coordinates );
+
+
+ /*************************************************************************/
+ /* */
+ /* @functype: */
+ /* T2_Hints_MaskFunc */
+ /* */
+ /* @description: */
+ /* A method of the @T2_Hints class used to set a given hintmask */
+ /* (this corresponds to the "hintmask" Type 2 operator). */
+ /* */
+ /* @input: */
+ /* hints :: A handle to the Type 2 hints recorder. */
+ /* */
+ /* end_point :: The glyph index of the last point to which the */
+ /* previously defined/activated hints apply. */
+ /* */
+ /* bit_count :: The number of bits in the hint mask. */
+ /* */
+ /* bytes :: An array of bytes modelling the hint mask. */
+ /* */
+ /* @note: */
+ /* If the hintmask starts the charstring (before any glyph point */
+ /* definition), the value of "end_point" should be 0. */
+ /* */
+ /* "bit_count" is the number of meaningful bits in the "bytes" array; */
+ /* it must be equal to the total number of hints defined so far */
+ /* (i.e. horizontal+verticals). */
+ /* */
+ /* The "bytes" array can come directly from the Type 2 charstring and */
+ /* respects the same format. */
+ /* */
+ typedef void
+ (*T2_Hints_MaskFunc)( T2_Hints hints,
+ FT_UInt end_point,
+ FT_UInt bit_count,
+ const FT_Byte* bytes );
+
+
+ /*************************************************************************/
+ /* */
+ /* @functype: */
+ /* T2_Hints_CounterFunc */
+ /* */
+ /* @description: */
+ /* A method of the @T2_Hints class used to set a given counter mask */
+ /* (this corresponds to the "hintmask" Type 2 operator). */
+ /* */
+ /* @input: */
+ /* hints :: A handle to the Type 2 hints recorder. */
+ /* */
+ /* end_point :: A glyph index of the last point to which the */
+ /* previously defined/active hints apply. */
+ /* */
+ /* bit_count :: The number of bits in the hint mask. */
+ /* */
+ /* bytes :: An array of bytes modelling the hint mask. */
+ /* */
+ /* @note: */
+ /* If the hintmask starts the charstring (before any glyph point */
+ /* definition), the value of "end_point" should be 0. */
+ /* */
+ /* "bit_count" is the number of meaningful bits in the "bytes" array; */
+ /* it must be equal to the total number of hints defined so far */
+ /* (i.e. horizontal+verticals). */
+ /* */
+ /* The "bytes" array can come directly from the Type 2 charstring and */
+ /* respects the same format. */
+ /* */
+ typedef void
+ (*T2_Hints_CounterFunc)( T2_Hints hints,
+ FT_UInt bit_count,
+ const FT_Byte* bytes );
+
+
+ /*************************************************************************/
+ /* */
+ /* @functype: */
+ /* T2_Hints_CloseFunc */
+ /* */
+ /* @description: */
+ /* A method of the @T2_Hints class used to close a hint recording */
+ /* session. */
+ /* */
+ /* @input: */
+ /* hints :: A handle to the Type 2 hints recorder. */
+ /* */
+ /* end_point :: The index of the last point in the input glyph. */
+ /* */
+ /* @return: */
+ /* FreeType error code. 0 means success. */
+ /* */
+ /* @note: */
+ /* The error code will be set to indicate that an error occured */
+ /* during the recording session. */
+ /* */
+ typedef FT_Error
+ (*T2_Hints_CloseFunc)( T2_Hints hints,
+ FT_UInt end_point );
+
+
+ /*************************************************************************/
+ /* */
+ /* @functype: */
+ /* T2_Hints_ApplyFunc */
+ /* */
+ /* @description: */
+ /* A method of the @T2_Hints class used to apply hints to the */
+ /* corresponding glyph outline. Must be called after the "close" */
+ /* method. */
+ /* */
+ /* @input: */
+ /* hints :: A handle to the Type 2 hints recorder. */
+ /* */
+ /* outline :: A pointer to the target outline descriptor. */
+ /* */
+ /* globals :: The hinter globals for this font. */
+ /* */
+ /* @return: */
+ /* FreeType error code. 0 means success. */
+ /* */
+ /* @note: */
+ /* On input, all points within the outline are in font coordinates. */
+ /* On output, they are in 1/64th of pixels. */
+ /* */
+ /* The scaling transformation is taken from the "globals" object */
+ /* 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 );
+
+
+ /*************************************************************************/
+ /* */
+ /* @struct: */
+ /* T2_Hints_FuncsRec */
+ /* */
+ /* @description: */
+ /* The structure used to provide the API to @T2_Hints objects. */
+ /* */
+ /* @fields: */
+ /* hints :: A handle to the T2 hints recorder object. */
+ /* */
+ /* open :: The function to open a recording session. */
+ /* */
+ /* close :: The function to close a recording session. */
+ /* */
+ /* stems :: The function to set the dimension's stems table. */
+ /* */
+ /* hintmask :: The function to set hint masks. */
+ /* */
+ /* counter :: The function to set counter masks. */
+ /* */
+ /* apply :: The function to apply the hints on the corresponding */
+ /* glyph outline. */
+ /* */
+ typedef struct T2_Hints_FuncsRec_
{
T2_Hints hints;
T2_Hints_OpenFunc open;
@@ -510,20 +594,25 @@ FT_BEGIN_HEADER
T2_Hints_MaskFunc hintmask;
T2_Hints_CounterFunc counter;
T2_Hints_ApplyFunc apply;
-
+
} T2_Hints_FuncsRec;
/* */
-
- typedef struct PSHinter_Interface_
+
+
+ typedef struct PSHinter_Interface_
{
PSH_Globals_Funcs (*get_globals_funcs)( FT_Module module );
T1_Hints_Funcs (*get_t1_funcs) ( FT_Module module );
T2_Hints_Funcs (*get_t2_funcs) ( FT_Module module );
-
+
} PSHinter_Interface, *PSHinter_InterfacePtr;
+
FT_END_HEADER
#endif /* __PSHINTS_H__ */
+
+
+/* END */
diff --git a/include/freetype/internal/t1types.h b/include/freetype/internal/t1types.h
index 40612a80a..f3cb0832f 100644
--- a/include/freetype/internal/t1types.h
+++ b/include/freetype/internal/t1types.h
@@ -26,6 +26,7 @@
#include FT_INTERNAL_POSTSCRIPT_NAMES_H
#include FT_INTERNAL_POSTSCRIPT_HINTS_H
+
FT_BEGIN_HEADER
@@ -173,7 +174,7 @@ FT_BEGIN_HEADER
/* support for Multiple Masters fonts */
T1_Blend* blend;
- /* since FT 2.1 - interface to Postscript hinter */
+ /* since FT 2.1 - interface to PostScript hinter */
void* pshinter;
} T1_FaceRec;
diff --git a/include/freetype/ttnameid.h b/include/freetype/ttnameid.h
index 0f1c56883..e0f56b840 100644
--- a/include/freetype/ttnameid.h
+++ b/include/freetype/ttnameid.h
@@ -316,8 +316,8 @@ FT_BEGIN_HEADER
#if 1 /* this used to be this value (and it still is in many places) */
#define TT_MS_LANGID_CHINESE_MACAU 0x1404
#else /* but beware, Microsoft may change its mind...
- the most recent Word reference has the following: :-( */
-#define TT_MS_LANGID_CHINESE_MACAU TT_MS_LANGID_CHINESE_HONG_KONG
+ the most recent Word reference has the following: */
+#define TT_MS_LANGID_CHINESE_MACAU TT_MS_LANGID_CHINESE_HONG_KONG
#endif
#define TT_MS_LANGID_CZECH_CZECH_REPUBLIC 0x0405
@@ -432,7 +432,7 @@ FT_BEGIN_HEADER
#define TT_MS_LANGID_MALTESE_MALTA 0x043a
#define TT_MS_LANGID_SAAMI_LAPONIA 0x043b
-#if 0 /* this seems to be a previous invertion */
+#if 0 /* this seems to be a previous invertion */
#define TT_MS_LANGID_IRISH_GAELIC_IRELAND 0x043c
#define TT_MS_LANGID_SCOTTISH_GAELIC_UNITED_KINGDOM 0x083c
#else
@@ -460,15 +460,15 @@ FT_BEGIN_HEADER
#define TT_MS_LANGID_SANSKRIT_INDIA 0x044f
#define TT_MS_LANGID_KONKANI_INDIA 0x0457
-/* new as of 2001-01-01 */
+ /* new as of 2001-01-01 */
#define TT_MS_LANGID_ARABIC_GENERAL 0x0001
#define TT_MS_LANGID_CHINESE_GENERAL 0x0004
#define TT_MS_LANGID_ENGLISH_GENERAL 0x0009
#define TT_MS_LANGID_FRENCH_WEST_INDIES 0x1c0c
#define TT_MS_LANGID_FRENCH_REUNION 0x200c
#define TT_MS_LANGID_FRENCH_CONGO 0x240c
- /* which was formerly: */
-#define TT_MS_LANGID_FRENCH_ZAIRE TT_MS_LANGID_FRENCH_CONGO
+ /* which was formerly: */
+#define TT_MS_LANGID_FRENCH_ZAIRE TT_MS_LANGID_FRENCH_CONGO
#define TT_MS_LANGID_FRENCH_SENEGAL 0x280c
#define TT_MS_LANGID_FRENCH_CAMEROON 0x2c0c
@@ -479,20 +479,20 @@ FT_BEGIN_HEADER
#define TT_MS_LANGID_TAJIK_TAJIKISTAN 0x0428
#define TT_MS_LANGID_YIDDISH_GERMANY 0x043d
#define TT_MS_LANGID_KIRGHIZ_KIRGHIZSTAN 0x0440
- /* alias declared in Windows 2000 */
+ /* alias declared in Windows 2000 */
#define TT_MS_LANGID_KIRGHIZ_KIRGHIZ_REPUBLIC \
- TT_MS_LANGID_KIRGHIZ_KIRGHIZSTAN
+ TT_MS_LANGID_KIRGHIZ_KIRGHIZSTAN
#define TT_MS_LANGID_TURKMEN_TURKMENISTAN 0x0442
#define TT_MS_LANGID_MONGOLIAN_MONGOLIA /* Cyrillic */ 0x0450
- /* this seems to be inconsistant... :-(
- * here is the current "official" way: */
+ /* the following seems to be inconsistent;
+ here is the current "official" way: */
#define TT_MS_LANGID_TIBETAN_BHUTAN 0x0451
- /* and now here is what is used by Passport SDK */
+ /* and here is what is used by Passport SDK */
#define TT_MS_LANGID_TIBETAN_CHINA 0x0451
#define TT_MS_LANGID_DZONGHKA_BHUTAN 0x0851
- /* end of inconsistency */
+ /* end of inconsistency */
#define TT_MS_LANGID_WELSH_WALES 0x0452
#define TT_MS_LANGID_KHMER_CAMBODIA 0x0453
@@ -501,15 +501,15 @@ FT_BEGIN_HEADER
#define TT_MS_LANGID_GALICIAN_SPAIN 0x0456
#define TT_MS_LANGID_MANIPURI_INDIA 0x0458
#define TT_MS_LANGID_SINDHI_INDIA 0x0459
- /* the following one is only encountered in Microsoft RTF specification */
+ /* the following one is only encountered in Microsoft RTF specification */
#define TT_MS_LANGID_KASHMIRI_PAKISTAN 0x0460
- /* the following one is not in the Passport list, looks like an omission */
+ /* the following one is not in the Passport list, looks like an omission */
#define TT_MS_LANGID_KASHMIRI_INDIA 0x0860
#define TT_MS_LANGID_NEPALI_NEPAL 0x0461
#define TT_MS_LANGID_NEPALI_INDIA 0x0861
#define TT_MS_LANGID_FRISIAN_NETHERLANDS 0x0462
-/* new as of 2001-03-01 (from Office Xp) */
+ /* new as of 2001-03-01 (from Office Xp) */
#define TT_MS_LANGID_ENGLISH_HONG_KONG 0x3c09
#define TT_MS_LANGID_ENGLISH_INDIA 0x4009
#define TT_MS_LANGID_ENGLISH_MALAYSIA 0x4409
@@ -524,48 +524,50 @@ FT_BEGIN_HEADER
#define TT_MS_LANGID_PASHTO_AFGHANISTAN 0x0463
#define TT_MS_LANGID_FILIPINO_PHILIPPINES 0x0464
#define TT_MS_LANGID_DHIVEHI_MALDIVES 0x0465
- /* alias declared in Windows 2000 */
-#define TT_MS_LANGID_DIVEHI_MALDIVES TT_MS_LANGID_DHIVEHI_MALDIVES
- /* for language codes from 0x0466 to 0x0471, see below */
+ /* alias declared in Windows 2000 */
+#define TT_MS_LANGID_DIVEHI_MALDIVES TT_MS_LANGID_DHIVEHI_MALDIVES
+ /* for language codes from 0x0466 to 0x0471 see below */
#define TT_MS_LANGID_OROMO_ETHIOPIA 0x0472
#define TT_MS_LANGID_TIGRIGNA_ETHIOPIA 0x0473
#define TT_MS_LANGID_TIGRIGNA_ERYTHREA 0x0873
- /* also spelled in the `Passport SDK' list as: */
-#define TT_MS_LANGID_TIGRIGNA_ERYTREA TT_MS_LANGID_TIGRIGNA_ERYTHREA
+ /* also spelled in the `Passport SDK' list as: */
+#define TT_MS_LANGID_TIGRIGNA_ERYTREA TT_MS_LANGID_TIGRIGNA_ERYTHREA
- /* New additions from Windows Xp/Passport SDK. AL 2001-11-10. */
+ /* New additions from Windows Xp/Passport SDK 2001-11-10. */
- /* don't ask me what this one means... :-(
- * note it is currently commented out
-#define TT_MS_LANGID_GREEK_GREECE2 0x2008
- * end of comment to avoid strange code */
+ /* don't ask what this one means... It is commented out currently. */
+#if 0
+#define TT_MS_LANGID_GREEK_GREECE2 0x2008
+#endif
-#define TT_MS_LANGID_SPANISH_UNITED_STATES 0x540a
- /* these following two blatently violate MS specs, by using a sublang>0x1F */
-#define TT_MS_LANGID_SPANISH_LATIN_AMERICA 0xE40a
-#define TT_MS_LANGID_FRENCH_NORTH_AFRICA 0xE40c
+#define TT_MS_LANGID_SPANISH_UNITED_STATES 0x540a
+ /* The following two IDs blatantly violate MS specs by using a */
+ /* 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
-#define TT_MS_LANGID_PUNJABI_ARABIC_PAKISTAN 0x0846
-#define TT_MS_LANGID_MONGOLIAN_MONGOLIA_MONGOLIAN 0x0850
-#define TT_MS_LANGID_EDO_NIGERIA 0x0466
-#define TT_MS_LANGID_FULFULDE_NIGERIA 0x0467
-#define TT_MS_LANGID_HAUSA_NIGERIA 0x0468
-#define TT_MS_LANGID_IBIBIO_NIGERIA 0x0469
-#define TT_MS_LANGID_YORUBA_NIGERIA 0x046a
- /* language codes from 0x046b to 0x046f are (still) unknown. */
-#define TT_MS_LANGID_IGBO_NIGERIA 0x0470
-#define TT_MS_LANGID_KANURI_NIGERIA 0x0471
-#define TT_MS_LANGID_GUARANI_PARAGUAY 0x0474
-#define TT_MS_LANGID_HAWAIIAN_UNITED_STATES 0x0475
-#define TT_MS_LANGID_LATIN 0x0476
-#define TT_MS_LANGID_SOMALI_SOMALIA 0x0477
- /* Note Yi does not have a (proper) ISO639-2 code, since it is mostly not
- * written (but OTOH the peculiar writing system is worth studying). */
-#define TT_MS_LANGID_YI_CHINA 0x0478
-#define TT_MS_LANGID_PAPIAMENTU_NETHERLANDS_ANTILLES 0x0479
+#define TT_MS_LANGID_FRENCH_MOROCCO 0x380c
+#define TT_MS_LANGID_FRENCH_HAITI 0x3c0c
+#define TT_MS_LANGID_BENGALI_BANGLADESH 0x0845
+#define TT_MS_LANGID_PUNJABI_ARABIC_PAKISTAN 0x0846
+#define TT_MS_LANGID_MONGOLIAN_MONGOLIA_MONGOLIAN 0x0850
+#define TT_MS_LANGID_EDO_NIGERIA 0x0466
+#define TT_MS_LANGID_FULFULDE_NIGERIA 0x0467
+#define TT_MS_LANGID_HAUSA_NIGERIA 0x0468
+#define TT_MS_LANGID_IBIBIO_NIGERIA 0x0469
+#define TT_MS_LANGID_YORUBA_NIGERIA 0x046a
+ /* language codes from 0x046b to 0x046f are (still) unknown. */
+#define TT_MS_LANGID_IGBO_NIGERIA 0x0470
+#define TT_MS_LANGID_KANURI_NIGERIA 0x0471
+#define TT_MS_LANGID_GUARANI_PARAGUAY 0x0474
+#define TT_MS_LANGID_HAWAIIAN_UNITED_STATES 0x0475
+#define TT_MS_LANGID_LATIN 0x0476
+#define TT_MS_LANGID_SOMALI_SOMALIA 0x0477
+ /* Note: Yi does not have a (proper) ISO 639-2 code, since it is mostly */
+ /* not written (but OTOH the peculiar writing system is worth */
+ /* studying). */
+#define TT_MS_LANGID_YI_CHINA 0x0478
+#define TT_MS_LANGID_PAPIAMENTU_NETHERLANDS_ANTILLES 0x0479
/*************************************************************************/
@@ -582,7 +584,7 @@ FT_BEGIN_HEADER
#define TT_NAME_ID_PS_NAME 6
#define TT_NAME_ID_TRADEMARK 7
-/* the following values are from the OpenType spec */
+ /* the following values are from the OpenType spec */
#define TT_NAME_ID_MANUFACTURER 8
#define TT_NAME_ID_DESIGNER 9
#define TT_NAME_ID_DESCRIPTION 10
@@ -590,15 +592,15 @@ FT_BEGIN_HEADER
#define TT_NAME_ID_DESIGNER_URL 12
#define TT_NAME_ID_LICENSE 13
#define TT_NAME_ID_LICENSE_URL 14
-/* number 15 is reserved */
+ /* number 15 is reserved */
#define TT_NAME_ID_PREFERRED_FAMILY 16
#define TT_NAME_ID_PREFERRED_SUBFAMILY 17
#define TT_NAME_ID_MAC_FULL_NAME 18
-/* The following code is new as of 2000-01-21 */
+ /* The following code is new as of 2000-01-21 */
#define TT_NAME_ID_SAMPLE_TEXT 19
-/* This is new in OpenType 1.3 */
+ /* This is new in OpenType 1.3 */
#define TT_NAME_ID_CID_FINDFONT_NAME 20
@@ -744,7 +746,7 @@ FT_BEGIN_HEADER
/* U+DC00-U+DFFF */
/* According to OpenType specs v.1.3+, setting bit 57 implies that there */
/* is at least one codepoint beyond the Basic Multilingual Plane that is */
- /* supported by this font. So really means: U+10000-U+10FFFD */
+ /* supported by this font. So it really means: >= U+10000 */
/* Bit 58 is reserved for Unicode SubRanges */
diff --git a/src/autohint/ahglyph.c b/src/autohint/ahglyph.c
index 5c2f4f750..756db6577 100644
--- a/src/autohint/ahglyph.c
+++ b/src/autohint/ahglyph.c
@@ -596,11 +596,11 @@
if ( point->out_dir != ah_dir_none )
goto Is_Weak_Point;
-
+
angle_in = ah_angle( &ivec );
angle_out = ah_angle( &ovec );
delta = angle_in - angle_out;
-
+
if ( delta > AH_PI )
delta = AH_2PI - delta;
@@ -952,7 +952,7 @@
best_score = seg1->score;
else
best_score = 32000;
-
+
for ( seg2 = segments; seg2 < segment_limit; seg2++ )
if ( seg1 != seg2 && seg1->dir + seg2->dir == 0 )
{
diff --git a/src/autohint/ahhint.c b/src/autohint/ahhint.c
index 1dd003c60..b6b2c7870 100644
--- a/src/autohint/ahhint.c
+++ b/src/autohint/ahhint.c
@@ -380,9 +380,12 @@
FT_Bool no_horz_edges,
FT_Bool no_vert_edges )
{
-#if 0
+#if 0
ah_debug_disable_horz = no_horz_edges;
ah_debug_disable_vert = no_vert_edges;
+#else
+ UNUSED( no_horz_edges );
+ 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... */
diff --git a/src/autohint/ahtypes.h b/src/autohint/ahtypes.h
index 6593060ff..83b499582 100644
--- a/src/autohint/ahtypes.h
+++ b/src/autohint/ahtypes.h
@@ -83,7 +83,7 @@ FT_BEGIN_HEADER
/* detected and later hinted through strong interpolation to correct */
/* some unpleasant artefacts. */
/* */
-#undef AH_OPTION_NO_STRONG_INTERPOLATION
+#undef AH_OPTION_NO_STRONG_INTERPOLATION
/*************************************************************************/
diff --git a/src/base/ftcalc.c b/src/base/ftcalc.c
index 1201e3b56..8f024673b 100644
--- a/src/base/ftcalc.c
+++ b/src/base/ftcalc.c
@@ -511,7 +511,7 @@
if ( s < 0 )
{
x->lo = (FT_UInt32)-(FT_Int32)x->lo;
- x->hi = ~x->hi + !( x->lo );
+ x->hi = ~x->hi + !x->lo;
}
s ^= y; y = ABS( y );
@@ -563,7 +563,7 @@
if ( s < 0 )
{
x->lo = (FT_UInt32)-(FT_Int32)x->lo;
- x->hi = ~x->hi + !( x->lo );
+ x->hi = ~x->hi + !x->lo;
}
s ^= y; y = ABS( y );
diff --git a/src/base/ftdbgmem.c b/src/base/ftdbgmem.c
index 42ccc9726..7f50bd621 100644
--- a/src/base/ftdbgmem.c
+++ b/src/base/ftdbgmem.c
@@ -1,3 +1,21 @@
+/***************************************************************************/
+/* */
+/* ftdbgmem.c */
+/* */
+/* Memory debugger (body). */
+/* */
+/* Copyright 2001 by */
+/* David Turner, Robert Wilhelm, and Werner Lemberg. */
+/* */
+/* This file is part of the FreeType project, and may only be used, */
+/* modified, and distributed under the terms of the FreeType project */
+/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
+/* this file you indicate that you have read the license and */
+/* understand and accept it fully. */
+/* */
+/***************************************************************************/
+
+
#include <ft2build.h>
#include FT_CONFIG_CONFIG_H
#include FT_INTERNAL_DEBUG_H
@@ -6,6 +24,7 @@
#include FT_ERRORS_H
#include FT_TYPES_H
+
#ifdef FT_DEBUG_MEMORY
@@ -17,48 +36,51 @@
typedef struct FT_MemNodeRec_* FT_MemNode;
typedef struct FT_MemTableRec_* FT_MemTable;
-#define FT_MEM_VAL(addr) ((FT_ULong)(FT_Pointer)(addr))
+#define FT_MEM_VAL( addr ) ((FT_ULong)(FT_Pointer)( addr ))
- typedef struct FT_MemNodeRec_
+ typedef struct FT_MemNodeRec_
{
FT_Byte* address;
FT_Long size; /* < 0 if the block was freed */
-
- const char* alloc_file_name;
+
+ const char* alloc_file_name;
FT_Long alloc_line_no;
-
- const char* free_file_name;
+
+ const char* free_file_name;
FT_Long free_line_no;
FT_MemNode link;
-
- } FT_MemNodeRec;
- typedef struct FT_MemTableRec_
+ } FT_MemNodeRec;
+
+
+ typedef struct FT_MemTableRec_
{
- FT_ULong size;
- FT_ULong nodes;
- FT_MemNode* buckets;
+ FT_ULong size;
+ FT_ULong nodes;
+ FT_MemNode* buckets;
- FT_ULong alloc_total;
- FT_ULong alloc_current;
- FT_ULong alloc_max;
-
- const char* file_name;
- FT_Long line_no;
+ FT_ULong alloc_total;
+ FT_ULong alloc_current;
+ FT_ULong alloc_max;
- FT_Memory memory;
- FT_Pointer memory_user;
+ const char* file_name;
+ FT_Long line_no;
+
+ FT_Memory memory;
+ FT_Pointer memory_user;
FT_Alloc_Func alloc;
FT_Free_Func free;
FT_Realloc_Func realloc;
-
- } FT_MemTableRec;
-#define FT_MEM_SIZE_MIN 7
-#define FT_MEM_SIZE_MAX 13845163
+ } FT_MemTableRec;
+
+
+#define FT_MEM_SIZE_MIN 7
+#define FT_MEM_SIZE_MAX 13845163
+
+#define FT_FILENAME( x ) ((x) ? (x) : "unknown file")
-#define FT_FILENAME(x) ((x) ? (x) : "unknown file")
static const FT_UInt ft_mem_primes[] =
{
@@ -125,7 +147,9 @@
{
FT_UInt i;
- for ( i = 0; i < sizeof(ft_mem_primes)/sizeof(ft_mem_primes[0]); i++ )
+
+ for ( i = 0;
+ i < sizeof ( ft_mem_primes ) / sizeof ( ft_mem_primes[0] ); i++ )
if ( ft_mem_primes[i] > num )
return ft_mem_primes[i];
@@ -140,19 +164,22 @@
FT_Memory memory = table->memory;
FT_Pointer block;
+
memory->user = table->memory_user;
block = table->alloc( memory, size );
memory->user = table;
-
- return block;
+
+ return block;
}
+
static void
ft_mem_table_free( FT_MemTable table,
FT_Pointer block )
{
FT_Memory memory = table->memory;
+
memory->user = table->memory_user;
table->free( memory, block );
memory->user = table;
@@ -164,40 +191,44 @@
{
FT_ULong new_size;
+
new_size = ft_mem_closest_prime( table->nodes );
- if (new_size != table->size)
+ if ( new_size != table->size )
{
FT_MemNode* new_buckets ;
FT_ULong i;
- new_buckets = ft_mem_table_alloc( table, new_size * sizeof(FT_MemNode) );
+
+ new_buckets = ft_mem_table_alloc( table,
+ new_size * sizeof ( FT_MemNode ) );
if ( new_buckets == NULL )
return;
-
- MEM_Set( new_buckets, 0, sizeof(FT_MemNode)*new_size );
-
+
+ MEM_Set( new_buckets, 0, sizeof ( FT_MemNode ) * new_size );
+
for ( i = 0; i < table->size; i++ )
{
FT_MemNode node, next, *pnode;
FT_ULong hash;
+
node = table->buckets[i];
- while (node)
+ while ( node )
{
next = node->link;
- hash = FT_MEM_VAL(node->address) % new_size;
+ hash = FT_MEM_VAL( node->address ) % new_size;
pnode = new_buckets + hash;
node->link = pnode[0];
pnode[0] = node;
- node = next;
+ node = next;
}
}
if ( table->buckets )
ft_mem_table_free( table, table->buckets );
-
+
table->buckets = new_buckets;
table->size = new_size;
}
@@ -209,73 +240,78 @@
{
FT_MemTable table;
- table = memory->alloc( memory, sizeof(*table) );
- if ( table == NULL ) goto Exit;
-
- MEM_Set( table, 0, sizeof(*table) );
+
+ table = memory->alloc( memory, sizeof ( *table ) );
+ if ( table == NULL )
+ goto Exit;
+
+ MEM_Set( table, 0, sizeof ( *table ) );
table->size = FT_MEM_SIZE_MIN;
table->nodes = 0;
-
- table->memory = memory;
+
+ table->memory = memory;
table->memory_user = memory->user;
-
+
table->alloc = memory->alloc;
table->realloc = memory->realloc;
table->free = memory->free;
- table->buckets = memory->alloc( memory, table->size * sizeof(FT_MemNode) );
+ table->buckets = memory->alloc( memory,
+ table->size * sizeof ( FT_MemNode ) );
if ( table->buckets )
- MEM_Set( table->buckets, 0, sizeof(FT_MemNode)*table->size );
+ MEM_Set( table->buckets, 0, sizeof ( FT_MemNode ) * table->size );
else
{
memory->free( memory, table );
table = NULL;
}
-
- Exit:
+
+ Exit:
return table;
}
-
static void
ft_mem_table_destroy( FT_MemTable table )
{
- FT_ULong i;
+ FT_ULong i;
+
if ( table )
{
- FT_Memory memory = table->memory;
FT_Long leak_count = 0;
FT_ULong leaks = 0;
-
+
+
for ( i = 0; i < table->size; i++ )
{
FT_MemNode *pnode = table->buckets + i, next, node = *pnode;
- while (node)
+
+ while ( node )
{
- next = node->link;
- node->link = 0;
-
+ next = node->link;
+ node->link = 0;
+
if ( node->size > 0 )
{
- printf( "leaked memory block at address %p, size %8ld in (%s:%d)\n",
- node->address, node->size,
- FT_FILENAME( node->alloc_file_name ),
- node->alloc_line_no );
-
+ printf(
+ "leaked memory block at address %p, size %8ld in (%s:%ld)\n",
+ node->address, node->size,
+ FT_FILENAME( node->alloc_file_name ),
+ node->alloc_line_no );
+
leak_count++;
leaks += node->size;
-
+
ft_mem_table_free( table, node->address );
}
-
+
node->address = NULL;
node->size = 0;
-
+
free( node );
node = next;
}
@@ -288,32 +324,35 @@
table->nodes = 0;
free( table );
- printf( "FreeType: total memory allocations = %ld\n", table->alloc_total );
- printf( "FreeType: maximum memory footprint = %ld\n", table->alloc_max );
-
+ printf(
+ "FreeType: total memory allocations = %ld\n", table->alloc_total );
+ printf(
+ "FreeType: maximum memory footprint = %ld\n", table->alloc_max );
+
if ( leak_count > 0 )
- ft_mem_debug_panic( "FreeType: %ld bytes of memory leaked in %ld blocks\n",
- leaks, leak_count );
- printf( "FreeType: no memory leaks detected !!\n" );
+ ft_mem_debug_panic(
+ "FreeType: %ld bytes of memory leaked in %ld blocks\n",
+ leaks, leak_count );
+ printf( "FreeType: No memory leaks detected!\n" );
}
}
-
static FT_MemNode*
ft_mem_table_get_nodep( FT_MemTable table,
- FT_Byte* address )
+ FT_Byte* address )
{
- FT_ULong hash;
- FT_MemNode *pnode, node;
+ FT_ULong hash;
+ FT_MemNode *pnode, node;
- hash = FT_MEM_VAL(address);
- pnode = table->buckets + (hash % table->size);
+
+ hash = FT_MEM_VAL( address );
+ pnode = table->buckets + ( hash % table->size );
for (;;)
{
node = pnode[0];
- if (!node)
+ if ( !node )
break;
if ( node->address == address )
@@ -325,7 +364,6 @@
}
-
static void
ft_mem_table_set( FT_MemTable table,
FT_Byte* address,
@@ -333,41 +371,44 @@
{
FT_MemNode *pnode, node;
- if (table)
+
+ if ( table )
{
pnode = ft_mem_table_get_nodep( table, address );
node = *pnode;
- if (node)
+ if ( node )
{
if ( node->size < 0 )
{
- /* this block was already freed. this means that our memory is */
- /* now completely corrupted !! */
- ft_mem_debug_panic( "memory heap corrupted (allocating freed block)" );
+ /* this block was already freed. This means that our memory is */
+ /* now completely corrupted! */
+ ft_mem_debug_panic(
+ "memory heap corrupted (allocating freed block)" );
}
else
{
- /* this block was already allocated. this means that our memory */
- /* is also corrupted !! */
- ft_mem_debug_panic( "memory heap corrupted (re-allocating allocated block)" );
+ /* this block was already allocated. This means that our memory */
+ /* is also corrupted! */
+ ft_mem_debug_panic(
+ "memory heap corrupted (re-allocating allocated block)" );
}
}
-
+
/* we need to create a new node in this table */
- node = ft_mem_table_alloc( table, sizeof(*node) );
+ node = ft_mem_table_alloc( table, sizeof ( *node ) );
if ( node == NULL )
ft_mem_debug_panic( "not enough memory to run memory tests" );
- node->address = address;
- node->size = size;
+ node->address = address;
+ node->size = size;
node->alloc_file_name = table->file_name;
node->alloc_line_no = table->line_no;
- node->free_file_name = NULL;
- node->free_line_no = 0;
+ node->free_file_name = NULL;
+ node->free_line_no = 0;
- node->link = pnode[0];
+ node->link = pnode[0];
pnode[0] = node;
table->nodes++;
@@ -377,8 +418,8 @@
if ( table->alloc_current > table->alloc_max )
table->alloc_max = table->alloc_current;
- if ( table->nodes*3 < table->size ||
- table->size *3 < table->nodes )
+ if ( table->nodes * 3 < table->size ||
+ table->size * 3 < table->nodes )
ft_mem_table_resize( table );
}
}
@@ -388,27 +429,26 @@
ft_mem_table_remove( FT_MemTable table,
FT_Byte* address )
{
- if (table)
+ if ( table )
{
FT_MemNode *pnode, node;
+
pnode = ft_mem_table_get_nodep( table, address );
node = *pnode;
- if (node)
+ if ( node )
{
if ( node->size < 0 )
- ft_mem_debug_panic( "freeing memory block at %p more than once at (%s:%ld)\n"
- "block allocated at (%s:%ld) and released at (%s:%ld)",
- address,
- FT_FILENAME(table->file_name),
- table->line_no,
- FT_FILENAME(node->alloc_file_name),
- node->alloc_line_no,
- FT_FILENAME(node->free_file_name),
- node->free_line_no );
-
+ ft_mem_debug_panic(
+ "freeing memory block at %p more than once at (%s:%ld)\n"
+ "block allocated at (%s:%ld) and released at (%s:%ld)",
+ address,
+ FT_FILENAME( table->file_name ), table->line_no,
+ FT_FILENAME( node->alloc_file_name ), node->alloc_line_no,
+ FT_FILENAME( node->free_file_name ), node->free_line_no );
+
/* we simply invert the node's size to indicate that the node */
- /* was freed. We also change its content.. */
+ /* was freed. We also change its contents. */
MEM_Set( address, 0xF3, node->size );
table->alloc_current -= node->size;
@@ -417,10 +457,10 @@
node->free_line_no = table->line_no;
}
else
- ft_mem_debug_panic( "trying to free unknown block at %p in (%s:%ld)\n",
- address,
- FT_FILENAME( table->file_name ),
- table->line_no );
+ ft_mem_debug_panic(
+ "trying to free unknown block at %p in (%s:%ld)\n",
+ address,
+ FT_FILENAME( table->file_name ), table->line_no );
}
}
@@ -432,16 +472,17 @@
FT_MemTable table = memory->user;
FT_Byte* block;
+
if ( size <= 0 )
ft_mem_debug_panic( "negative block size allocation (%ld)", size );
-
+
block = ft_mem_table_alloc( table, size );
if ( block )
ft_mem_table_set( table, block, (FT_ULong)size );
table->file_name = NULL;
table->line_no = 0;
-
+
return (FT_Pointer) block;
}
@@ -451,21 +492,21 @@
FT_Pointer block )
{
FT_MemTable table = memory->user;
-
+
+
if ( block == NULL )
ft_mem_debug_panic( "trying to free NULL in (%s:%ld)",
FT_FILENAME( table->file_name ),
table->line_no );
-
+
ft_mem_table_remove( table, (FT_Byte*)block );
-
+
/* we never really free the block */
table->file_name = NULL;
table->line_no = 0;
}
-
extern FT_Pointer
ft_mem_debug_realloc( FT_Memory memory,
FT_Long cur_size,
@@ -476,34 +517,37 @@
FT_MemNode node, *pnode;
FT_Pointer new_block;
- const char* file_name = FT_FILENAME(table->file_name);
+ const char* file_name = FT_FILENAME( table->file_name );
FT_Long line_no = table->line_no;
+
if ( block == NULL || cur_size == 0 )
ft_mem_debug_panic( "trying to reallocate NULL in (%s:%ld)",
file_name, line_no );
-
+
if ( new_size <= 0 )
- ft_mem_debug_panic( "trying to reallocate %p to size 0 (current is %ld)"
- " in (%s:%ld)",
- block, cur_size, file_name, line_no );
-
- /* check 'cur_size' value */
+ ft_mem_debug_panic(
+ "trying to reallocate %p to size 0 (current is %ld) in (%s:%ld)",
+ block, cur_size, file_name, line_no );
+
+ /* check 'cur_size' value */
pnode = ft_mem_table_get_nodep( table, (FT_Byte*)block );
node = *pnode;
- if (!node)
- ft_mem_debug_panic( "trying to reallocate unknown block at %p in (%s:%ld)",
- block, file_name, line_no );
-
+ if ( !node )
+ ft_mem_debug_panic(
+ "trying to reallocate unknown block at %p in (%s:%ld)",
+ block, file_name, line_no );
+
if ( node->size <= 0 )
- ft_mem_debug_panic( "trying to reallocate freed block at %p in (%s:%ld)",
- block, file_name, line_no );
-
+ ft_mem_debug_panic(
+ "trying to reallocate freed block at %p in (%s:%ld)",
+ block, file_name, line_no );
+
if ( node->size != cur_size )
ft_mem_debug_panic( "invalid realloc request for %p. cur_size is "
"%ld instead of %ld in (%s:%ld)",
block, cur_size, node->size, file_name, line_no );
-
+
new_block = ft_mem_debug_alloc( memory, new_size );
if ( new_block == NULL )
return NULL;
@@ -514,19 +558,20 @@
table->line_no = line_no;
ft_mem_debug_free( memory, (FT_Byte*)block );
-
+
return new_block;
}
-
-
+
+
extern FT_Int
ft_mem_debug_init( FT_Memory memory )
{
FT_MemTable table;
FT_Int result = 0;
- if ( getenv( "FT_DEBUG_MEMORY") )
- {
+
+ if ( getenv( "FT_DEBUG_MEMORY" ) )
+ {
table = ft_mem_table_new( memory );
if ( table )
{
@@ -538,20 +583,21 @@
}
}
return result;
- }
-
-
+ }
+
+
extern void
ft_mem_debug_done( FT_Memory memory )
{
FT_MemTable table = memory->user;
-
+
+
if ( table )
{
memory->free = table->free;
memory->realloc = table->realloc;
memory->alloc = table->alloc;
-
+
ft_mem_table_destroy( table );
memory->user = NULL;
}
@@ -566,7 +612,8 @@
FT_Long line_no )
{
FT_MemTable table = memory->user;
-
+
+
if ( table )
{
table->file_name = file_name;
@@ -585,7 +632,8 @@
FT_Long line_no )
{
FT_MemTable table = memory->user;
-
+
+
if ( table )
{
table->file_name = file_name;
@@ -602,7 +650,8 @@
FT_Long line_no )
{
FT_MemTable table = memory->user;
-
+
+
if ( table )
{
table->file_name = file_name;
@@ -613,8 +662,11 @@
#else /* !FT_DEBUG_MEMORY */
-
- /* ansi C doesn't like empty source files */
+
+ /* ANSI C doesn't like empty source files */
extern const FT_Byte _debug_mem_dummy = 0;
#endif /* !FT_DEBUG_MEMORY */
+
+
+/* END */
diff --git a/src/base/ftmac.c b/src/base/ftmac.c
index 6657617d3..a2395fe10 100644
--- a/src/base/ftmac.c
+++ b/src/base/ftmac.c
@@ -239,21 +239,22 @@
*have_sfnt = 0;
lwfn_file_name[0] = 0;
- fond = (FamRec*)fond_data;
- assoc = (AsscEntry*)( fond_data + sizeof ( FamRec ) + 2 );
+ fond = (FamRec*)fond_data;
+ assoc = (AsscEntry*)( fond_data + sizeof ( FamRec ) + 2 );
base_assoc = assoc;
- assoc += face_index; /* add on the face_index! */
+ assoc += face_index; /* add on the face_index! */
- /* if the face at this index is not scalable, fall back to the first one (old behavior) */
+ /* if the face at this index is not scalable,
+ fall back to the first one (old behavior) */
if ( assoc->fontSize == 0 )
{
*have_sfnt = 1;
- *sfnt_id = assoc->fontID;
+ *sfnt_id = assoc->fontID;
}
- else if (base_assoc->fontSize == 0)
+ else if ( base_assoc->fontSize == 0 )
{
*have_sfnt = 1;
- *sfnt_id = base_assoc->fontID;
+ *sfnt_id = base_assoc->fontID;
}
if ( fond->ffStylOff )
@@ -647,7 +648,7 @@
FT_Error error = FT_Err_Unknown_File_Format;
- GetResInfo(fond, &fond_id, &fond_type, fond_name);
+ GetResInfo( fond, &fond_id, &fond_type, fond_name );
if ( ResError() != noErr || fond_type != 'FOND' )
return FT_Err_Invalid_File_Format;
diff --git a/src/base/ftobjs.c b/src/base/ftobjs.c
index 370730825..e8d58b8c8 100644
--- a/src/base/ftobjs.c
+++ b/src/base/ftobjs.c
@@ -1920,6 +1920,7 @@
{
const char* result = NULL;
+
if ( !face )
goto Exit;
@@ -1927,13 +1928,15 @@
if ( !result )
{
/* now, lookup for glyph name */
- FT_Driver driver = face->driver;
- FT_Module_Class* clazz = FT_MODULE_CLASS( driver );
+ FT_Driver driver = face->driver;
+ FT_Module_Class* clazz = FT_MODULE_CLASS( driver );
+
if ( clazz->get_interface )
{
FT_PSName_Requester requester;
+
requester = (FT_PSName_Requester)clazz->get_interface(
FT_MODULE( driver ), "postscript_name" );
if ( requester )
diff --git a/src/cache/ftcchunk.c b/src/cache/ftcchunk.c
index e6288bc6c..78040c31b 100644
--- a/src/cache/ftcchunk.c
+++ b/src/cache/ftcchunk.c
@@ -34,15 +34,17 @@
/*************************************************************************/
/*************************************************************************/
-#define FTC_CSET_CHUNK_INDEX(cset,gindex) \
- ( (gindex) / (cset)->item_count )
+
+#define FTC_CSET_CHUNK_INDEX( cset, gindex ) \
+ ( (gindex) / (cset)->item_count )
-#define FTC_CSET_START(cset,gindex) \
- ( FTC_CSET_CHUNK_INDEX(cset,gindex) * (cset)->item_count )
+#define FTC_CSET_START( cset, gindex ) \
+ ( FTC_CSET_CHUNK_INDEX( cset, gindex ) * (cset)->item_count )
+
+#define FTC_CSET_HASH( cset, gindex ) \
+ ( (FT_UFast)( ( (cset)->hash << 16 ) | \
+ ( FTC_CSET_CHUNK_INDEX( cset, gindex ) & 0xFFFF ) ) )
-#define FTC_CSET_HASH(cset,gindex) \
- ((FT_UFast)( ((cset)->hash << 16) | \
- (FTC_CSET_CHUNK_INDEX(cset,gindex) & 0xFFFF) ))
/* create a new chunk node, setting its cache index and ref count */
FT_EXPORT_DEF( FT_Error )
@@ -54,10 +56,11 @@
FTC_ChunkCache ccache = cset->ccache;
FT_Error error = 0;
FT_UInt len;
- FT_UInt start = FTC_CSET_START(cset,gindex);
+ FT_UInt start = FTC_CSET_START( cset, gindex );
+
cnode->cset = cset;
- cnode->node.hash = FTC_CSET_HASH(cset,gindex);
+ cnode->node.hash = FTC_CSET_HASH( cset, gindex );
cnode->item_start = start;
len = cset->item_total - start;
@@ -70,10 +73,11 @@
{
FT_Memory memory = ccache->cache.memory;
+
error = MEM_Alloc( cnode->items, cset->item_size * cnode->item_count );
}
- if (!error )
+ if ( !error )
cset->num_chunks++;
return error;
@@ -83,21 +87,21 @@
FT_EXPORT_DEF( void )
ftc_chunk_node_done( FTC_ChunkNode cnode )
{
- FTC_ChunkSet cset = cnode->cset;
+ FTC_ChunkSet cset = cnode->cset;
FT_Memory memory = cset->ccache->cache.memory;
+
/* destroy the node */
FREE( cnode->items );
cnode->item_count = 0;
cnode->item_start = 0;
- /* remove from parent set table - eventually destroy the set */
+ /* remove from parent set table -- eventually destroy the set */
if ( --cset->num_chunks <= 0 )
- FT_LruList_Remove( cset->ccache->cset_lru, (FT_LruNode) cset );
+ FT_LruList_Remove( cset->ccache->cset_lru, (FT_LruNode)cset );
}
-
/*************************************************************************/
/*************************************************************************/
/***** *****/
@@ -143,9 +147,9 @@
FT_EXPORT_DEF( void )
- ftc_chunk_cache_done( FTC_ChunkCache ccache )
+ ftc_chunk_cache_done( FTC_ChunkCache ccache )
{
- ftc_cache_done( FTC_CACHE(ccache) );
+ ftc_cache_done( FTC_CACHE( ccache ) );
/* simply delete all remaining glyph sets */
if ( ccache->cset_lru )
@@ -156,15 +160,16 @@
}
-
FT_EXPORT_DEF( FT_Error )
ftc_chunk_cache_init( FTC_ChunkCache ccache,
FT_LruList_Class cset_class )
{
FT_Error error;
- error = ftc_cache_init( FTC_CACHE(ccache) );
- if (error) goto Exit;
+
+ error = ftc_cache_init( FTC_CACHE( ccache ) );
+ if ( error )
+ goto Exit;
error = FT_LruList_New( cset_class, 0, ccache,
ccache->cache.memory,
@@ -174,7 +179,6 @@
}
-
FT_EXPORT_DEF( FT_Error )
ftc_chunk_cache_lookup( FTC_ChunkCache ccache,
FTC_ChunkQuery query,
@@ -183,14 +187,15 @@
FT_LruNode node;
FT_Error error;
+
error = FT_LruList_Lookup( ccache->cset_lru, query, &node );
if ( !error )
{
- FTC_ChunkSet cset = FTC_CHUNK_SET(node);
- FT_UFast hash = FTC_CSET_HASH( cset, query->gindex );
+ FTC_ChunkSet cset = FTC_CHUNK_SET( node );
+ FT_UFast hash = FTC_CSET_HASH( cset, query->gindex );
- error = ftc_cache_lookup_node( FTC_CACHE(ccache), hash, query,
- FTC_NODE_P(anode) );
+ error = ftc_cache_lookup_node( FTC_CACHE( ccache ), hash, query,
+ FTC_NODE_P( anode ) );
}
return error;
}
diff --git a/src/cache/ftcglyph.c b/src/cache/ftcglyph.c
index 6519fd26b..c2effddfd 100644
--- a/src/cache/ftcglyph.c
+++ b/src/cache/ftcglyph.c
@@ -35,8 +35,9 @@
/*************************************************************************/
/*************************************************************************/
-#define FTC_GSET_HASH(gset,gindex) \
- ((FT_UFast)(((gset)->hash << 16) | ((gindex) & 0xFFFF)))
+
+#define FTC_GSET_HASH( gset, gindex ) \
+ ( (FT_UFast)( ( (gset)->hash << 16 ) | ( (gindex) & 0xFFFF ) ) )
/* create a new glyph node, setting its cache index and ref count */
@@ -59,16 +60,16 @@
/* will happen! */
FT_EXPORT_DEF( void )
- ftc_glyph_node_done( FTC_GlyphNode gnode )
+ ftc_glyph_node_done( FTC_GlyphNode gnode )
{
FTC_GlyphSet gset = gnode->gset;
+
if ( --gset->num_glyphs <= 0 )
- FT_LruList_Remove( gset->gcache->gset_lru, (FT_LruNode) gset );
+ FT_LruList_Remove( gset->gcache->gset_lru, (FT_LruNode)gset );
}
-
/*************************************************************************/
/*************************************************************************/
/***** *****/
@@ -77,12 +78,14 @@
/*************************************************************************/
/*************************************************************************/
+
FT_EXPORT_DEF( FT_Error )
ftc_glyph_set_init( FTC_GlyphSet gset,
- FT_LruList lru )
+ FT_LruList lru )
{
FTC_GlyphCache gcache = lru->user_data;
+
gset->gcache = gcache;
gset->num_glyphs = 0;
@@ -94,7 +97,7 @@
ftc_glyph_set_done( FTC_GlyphSet gset )
{
/* for now, nothing to be done here */
- FT_UNUSED(gset);
+ FT_UNUSED( gset );
}
@@ -108,7 +111,7 @@
FT_EXPORT_DEF( void )
- ftc_glyph_cache_done( FTC_GlyphCache gcache )
+ ftc_glyph_cache_done( FTC_GlyphCache gcache )
{
/* remove all nodes in the cache */
ftc_cache_done( &gcache->cache );
@@ -128,8 +131,10 @@
{
FT_Error error;
- error = ftc_cache_init( FTC_CACHE(gcache) );
- if (error) goto Exit;
+
+ error = ftc_cache_init( FTC_CACHE( gcache ) );
+ if ( error )
+ goto Exit;
error = FT_LruList_New( gset_class, 0, gcache,
gcache->cache.memory,
@@ -147,18 +152,18 @@
FT_LruNode node;
FT_Error error;
+
error = FT_LruList_Lookup( gcache->gset_lru, query, &node );
if ( !error )
{
- FTC_GlyphSet gset = (FTC_GlyphSet) node;
+ FTC_GlyphSet gset = (FTC_GlyphSet)node;
FT_UFast hash = FTC_GSET_HASH( gset, query->gindex );
- error = ftc_cache_lookup_node( FTC_CACHE(gcache), hash, query,
- FTC_NODE_P(anode) );
+ error = ftc_cache_lookup_node( FTC_CACHE( gcache ), hash, query,
+ FTC_NODE_P( anode ) );
}
return error;
}
-
/* END */
diff --git a/src/cache/ftcimage.c b/src/cache/ftcimage.c
index c635ae9bf..6a2b4d1b7 100644
--- a/src/cache/ftcimage.c
+++ b/src/cache/ftcimage.c
@@ -36,8 +36,10 @@
} FTC_ImageNodeRec, *FTC_ImageNode;
-#define FTC_IMAGE_NODE(x) ((FTC_ImageNode)(x))
-#define FTC_IMAGE_NODE_GINDEX(x) FTC_GLYPH_NODE_GINDEX(x)
+
+#define FTC_IMAGE_NODE( x ) ((FTC_ImageNode)( x ))
+#define FTC_IMAGE_NODE_GINDEX( x ) FTC_GLYPH_NODE_GINDEX( x )
+
/* the glyph image set type */
typedef struct FTC_ImageSetRec_
@@ -47,16 +49,16 @@
} FTC_ImageSetRec, *FTC_ImageSet;
-#define FTC_IMAGE_SET(x) ((FTC_ImageSet)(x))
-#define FTC_IMAGE_SET_MEMORY(x) FTC_GLYPH_SET_MEMORY(&(x)->gset)
+#define FTC_IMAGE_SET( x ) ((FTC_ImageSet)( x ))
+#define FTC_IMAGE_SET_MEMORY( x ) FTC_GLYPH_SET_MEMORY( &(x)->gset )
- typedef struct FTC_ImageQueryRec_
+ typedef struct FTC_ImageQueryRec_
{
FTC_GlyphQueryRec glyph;
FTC_Image_Desc desc;
-
+
} FTC_ImageQueryRec, *FTC_ImageQuery;
@@ -69,11 +71,11 @@
/*************************************************************************/
- /* finalize a given glyph image node */
+ /* finalize a given glyph image node */
FT_CALLBACK_DEF( void )
ftc_image_node_done( FTC_ImageNode inode )
{
- if (inode->glyph)
+ if ( inode->glyph )
{
FT_Done_Glyph( inode->glyph );
inode->glyph = NULL;
@@ -81,19 +83,20 @@
}
- /* initialize a new glyph image node */
+ /* initialize a new glyph image node */
FT_CALLBACK_DEF( FT_Error )
ftc_image_node_init( FTC_ImageNode inode,
FTC_GlyphQuery query )
{
- FTC_ImageSet iset = FTC_IMAGE_SET( query->gset );
- FT_Memory memory = FTC_IMAGE_SET_MEMORY( iset );
- FT_Error error;
- FT_Face face;
- FT_Size size;
+ FTC_ImageSet iset = FTC_IMAGE_SET( query->gset );
+ FT_Error error;
+ FT_Face face;
+ FT_Size size;
+
/* initialize its inner fields */
- ftc_glyph_node_init( FTC_GLYPH_NODE(inode), query->gindex, query->gset );
+ ftc_glyph_node_init( FTC_GLYPH_NODE( inode ),
+ query->gindex, query->gset );
/* we will now load the glyph image */
error = FTC_Manager_Lookup_Size( iset->gset.gcache->cache.manager,
@@ -152,9 +155,9 @@
error = FTC_Err_Invalid_Argument;
}
}
-
+
/* in case of error */
- ftc_glyph_node_done( FTC_GLYPH_NODE(inode) );
+ ftc_glyph_node_done( FTC_GLYPH_NODE( inode ) );
Exit:
return error;
@@ -167,6 +170,7 @@
FT_ULong size = 0;
FT_Glyph glyph = inode->glyph;
+
switch ( glyph->format )
{
case ft_glyph_format_bitmap:
@@ -187,7 +191,7 @@
outg = (FT_OutlineGlyph)glyph;
size = outg->outline.n_points *
- ( sizeof( FT_Vector ) + sizeof ( FT_Byte ) ) +
+ ( sizeof ( FT_Vector ) + sizeof ( FT_Byte ) ) +
outg->outline.n_contours * sizeof ( FT_Short ) +
sizeof ( *outg );
}
@@ -202,22 +206,19 @@
}
- /* this function assumes that the desired node's glyph set has been */
- /* set by a previous call to ftc_image_set_compare.. */
- /* */
+ /* this function assumes that the desired node's glyph set has been */
+ /* set by a previous call to ftc_image_set_compare() */
+ /* */
FT_CALLBACK_DEF( FT_Bool )
ftc_image_node_compare( FTC_ImageNode inode,
FTC_ImageQuery iquery )
{
- FTC_ImageSet iset = FTC_IMAGE_SET(inode->gnode.gset);
-
- /* only if same glyph index and image set description */
- return FT_BOOL( iquery->glyph.gindex == FTC_IMAGE_NODE_GINDEX(inode) &&
+ /* only if same glyph index and image set description */
+ return FT_BOOL( iquery->glyph.gindex == FTC_IMAGE_NODE_GINDEX( inode ) &&
iquery->glyph.gset == inode->gnode.gset );
}
-
/*************************************************************************/
/*************************************************************************/
/***** *****/
@@ -234,10 +235,10 @@
{
ftc_glyph_set_init( &iset->gset, lru );
iset->description = query->desc;
-
- /* now compute hash from description - this is _very_ important */
- iset->gset.hash = FTC_IMAGE_DESC_HASH(&query->desc);
- query->glyph.gset = FTC_GLYPH_SET(iset);
+
+ /* now compute hash from description -- this is _very_ important */
+ iset->gset.hash = FTC_IMAGE_DESC_HASH( &query->desc );
+ query->glyph.gset = FTC_GLYPH_SET( iset );
return 0;
}
@@ -249,11 +250,13 @@
{
FT_Bool result;
+
/* we must set iquery.glyph.gset for faster glyph node comparisons */
- result = FT_BOOL( FTC_IMAGE_DESC_COMPARE( &iset->description, &iquery->desc ) );
+ result = FT_BOOL( FTC_IMAGE_DESC_COMPARE( &iset->description,
+ &iquery->desc ) );
if ( result )
iquery->glyph.gset = &iset->gset;
-
+
return result;
}
@@ -261,15 +264,15 @@
FT_CALLBACK_TABLE_DEF
const FT_LruList_ClassRec ftc_image_set_class =
{
- sizeof( FT_LruListRec ),
- (FT_LruList_InitFunc) NULL,
- (FT_LruList_DoneFunc) NULL,
-
- sizeof( FTC_ImageSetRec ),
- (FT_LruNode_InitFunc) ftc_image_set_init,
- (FT_LruNode_DoneFunc) ftc_glyph_set_init,
- (FT_LruNode_FlushFunc) NULL,
- (FT_LruNode_CompareFunc) ftc_image_set_compare
+ sizeof ( FT_LruListRec ),
+ (FT_LruList_InitFunc) NULL,
+ (FT_LruList_DoneFunc) NULL,
+
+ sizeof ( FTC_ImageSetRec ),
+ (FT_LruNode_InitFunc) ftc_image_set_init,
+ (FT_LruNode_DoneFunc) ftc_glyph_set_init,
+ (FT_LruNode_FlushFunc) NULL,
+ (FT_LruNode_CompareFunc)ftc_image_set_compare
};
@@ -285,22 +288,23 @@
FT_CALLBACK_DEF( FT_Error )
ftc_image_cache_init( FTC_Image_Cache cache )
{
- return ftc_glyph_cache_init( (FTC_GlyphCache) cache, &ftc_image_set_class );
+ return ftc_glyph_cache_init( (FTC_GlyphCache)cache,
+ &ftc_image_set_class );
}
-
+
FT_CALLBACK_TABLE_DEF
const FTC_Cache_ClassRec ftc_image_cache_class =
{
- sizeof( FTC_GlyphCacheRec ),
- (FTC_Cache_InitFunc) ftc_image_cache_init,
- (FTC_Cache_DoneFunc) ftc_glyph_cache_done,
-
- sizeof( FTC_ImageNodeRec ),
- (FTC_Node_InitFunc) ftc_image_node_init,
- (FTC_Node_WeightFunc) ftc_image_node_weight,
- (FTC_Node_CompareFunc) ftc_image_node_compare,
- (FTC_Node_DoneFunc) ftc_image_node_done
+ sizeof ( FTC_GlyphCacheRec ),
+ (FTC_Cache_InitFunc) ftc_image_cache_init,
+ (FTC_Cache_DoneFunc) ftc_glyph_cache_done,
+
+ sizeof ( FTC_ImageNodeRec ),
+ (FTC_Node_InitFunc) ftc_image_node_init,
+ (FTC_Node_WeightFunc) ftc_image_node_weight,
+ (FTC_Node_CompareFunc)ftc_image_node_compare,
+ (FTC_Node_DoneFunc) ftc_image_node_done
};
@@ -312,8 +316,8 @@
{
return FTC_Manager_Register_Cache(
manager,
- (FTC_Cache_Class) &ftc_image_cache_class,
- FTC_CACHE_P(acache) );
+ (FTC_Cache_Class)&ftc_image_cache_class,
+ FTC_CACHE_P( acache ) );
}
@@ -329,47 +333,46 @@
FTC_ImageQueryRec query;
FTC_ImageNode node;
FT_Error error;
-
- /* some argument checks are delayed to ftc_glyph_cache_lookup */
+
+
+ /* some argument checks are delayed to ftc_glyph_cache_lookup() */
if ( !cache || !desc || !aglyph )
return FTC_Err_Invalid_Argument;
*aglyph = NULL;
-
+
if ( anode )
*anode = NULL;
query.glyph.gindex = gindex;
query.glyph.gset = NULL;
query.desc = *desc;
- error = ftc_glyph_cache_lookup( FTC_GLYPH_CACHE(cache),
+ error = ftc_glyph_cache_lookup( FTC_GLYPH_CACHE( cache ),
&query.glyph,
- (FTC_GlyphNode*) &node );
- if (!error)
+ (FTC_GlyphNode*)&node );
+ if ( !error )
{
*aglyph = node->glyph;
-
- if (anode)
+
+ if ( anode )
{
- *anode = (FTC_Node) node;
+ *anode = (FTC_Node)node;
FTC_NODE(node)->ref_count++;
}
}
return error;
- }
+ }
FT_EXPORT_DEF( void )
FTC_Image_Cache_Release( FTC_Image_Cache icache,
FTC_Node node )
{
- ftc_node_unref( node, FTC_CACHE(icache) );
+ ftc_node_unref( node, FTC_CACHE( icache ) );
}
-
-
FT_EXPORT_DEF( FT_Error )
FTC_Image_Cache_Lookup( FTC_Image_Cache icache,
FTC_Image_Desc* desc,
@@ -380,5 +383,4 @@
}
-
/* END */
diff --git a/src/cache/ftcmanag.c b/src/cache/ftcmanag.c
index 4dffd246f..03f2303f1 100644
--- a/src/cache/ftcmanag.c
+++ b/src/cache/ftcmanag.c
@@ -31,7 +31,7 @@
#undef FT_COMPONENT
#define FT_COMPONENT trace_cache
-#define FTC_LRU_GET_MANAGER( lru ) ((FTC_Manager)(lru)->user_data)
+#define FTC_LRU_GET_MANAGER( lru ) ( (FTC_Manager)(lru)->user_data )
/*************************************************************************/
@@ -42,11 +42,11 @@
/*************************************************************************/
/*************************************************************************/
- typedef struct FTC_FaceNodeRec_* FTC_FaceNode;
+ typedef struct FTC_FaceNodeRec_* FTC_FaceNode;
+ typedef struct FTC_SizeNodeRec_* FTC_SizeNode;
- typedef struct FTC_SizeNodeRec_* FTC_SizeNode;
- typedef struct FTC_FaceNodeRec_
+ typedef struct FTC_FaceNodeRec_
{
FT_LruNodeRec lru;
FT_Face face;
@@ -54,7 +54,7 @@
} FTC_FaceNodeRec;
- typedef struct FTC_SizeNodeRec_
+ typedef struct FTC_SizeNodeRec_
{
FT_LruNodeRec lru;
FT_Size size;
@@ -62,13 +62,12 @@
} FTC_SizeNodeRec;
-
FT_CALLBACK_DEF( FT_Error )
- ftc_face_node_init( FTC_FaceNode node,
- FTC_FaceID face_id,
- FT_LruList list )
+ ftc_face_node_init( FTC_FaceNode node,
+ FTC_FaceID face_id,
+ FT_LruList list )
{
- FTC_Manager manager = FTC_LRU_GET_MANAGER(list);
+ FTC_Manager manager = FTC_LRU_GET_MANAGER( list );
FT_Error error;
@@ -87,27 +86,27 @@
}
- /* helper function for ftc_manager_done_face() */
- FT_CALLBACK_DEF( FT_Bool )
- ftc_size_node_select( FTC_SizeNode node,
- FT_Face face )
- {
- return FT_BOOL( node->size->face == face );
- }
+ /* helper function for ftc_manager_done_face() */
+ FT_CALLBACK_DEF( FT_Bool )
+ ftc_size_node_select( FTC_SizeNode node,
+ FT_Face face )
+ {
+ return FT_BOOL( node->size->face == face );
+ }
FT_CALLBACK_DEF( void )
ftc_face_node_done( FTC_FaceNode node,
FT_LruList list )
{
- FTC_Manager manager = FTC_LRU_GET_MANAGER(list);
+ FTC_Manager manager = FTC_LRU_GET_MANAGER( list );
FT_Face face = node->face;
/* we must begin by removing all sizes for the target face */
/* from the manager's list */
FT_LruList_Remove_Selection( manager->sizes_list,
- (FT_LruNode_SelectFunc) ftc_size_node_select,
+ (FT_LruNode_SelectFunc)ftc_size_node_select,
face );
/* all right, we can discard the face now */
@@ -117,17 +116,17 @@
FT_CALLBACK_TABLE_DEF
- const FT_LruList_ClassRec ftc_face_list_class =
+ const FT_LruList_ClassRec ftc_face_list_class =
{
- sizeof( FT_LruListRec ),
- (FT_LruList_InitFunc) 0,
- (FT_LruList_DoneFunc) 0,
-
- sizeof( FTC_FaceNodeRec ),
- (FT_LruNode_InitFunc) ftc_face_node_init,
- (FT_LruNode_DoneFunc) ftc_face_node_done,
- (FT_LruNode_FlushFunc) 0, /* no flushing needed.. */
- (FT_LruNode_CompareFunc) 0, /* direct comparison of FTC_FaceID handles */
+ sizeof ( FT_LruListRec ),
+ (FT_LruList_InitFunc) 0,
+ (FT_LruList_DoneFunc) 0,
+
+ sizeof ( FTC_FaceNodeRec ),
+ (FT_LruNode_InitFunc) ftc_face_node_init,
+ (FT_LruNode_DoneFunc) ftc_face_node_done,
+ (FT_LruNode_FlushFunc) 0, /* no flushing needed */
+ (FT_LruNode_CompareFunc)0, /* direct comparison of FTC_FaceID handles */
};
@@ -149,7 +148,6 @@
} FTC_SizeQueryRec, *FTC_SizeQuery;
-
FT_CALLBACK_DEF( FT_Error )
ftc_size_node_init( FTC_SizeNode node,
FTC_SizeQuery query )
@@ -179,7 +177,7 @@
FT_CALLBACK_DEF( void )
ftc_size_node_done( FTC_SizeNode node )
{
- if (node->size)
+ if ( node->size )
{
FT_Done_Size( node->size );
node->size = NULL;
@@ -222,9 +220,10 @@
{
FT_Size size = node->size;
- return FT_BOOL( size->face == query->face &&
- (FT_UInt) size->metrics.x_ppem == query->width &&
- (FT_UInt) size->metrics.y_ppem == query->height );
+
+ return FT_BOOL( size->face == query->face &&
+ (FT_UInt)size->metrics.x_ppem == query->width &&
+ (FT_UInt)size->metrics.y_ppem == query->height );
}
@@ -232,14 +231,14 @@
const FT_LruList_ClassRec ftc_size_list_class =
{
sizeof ( FT_LruListRec ),
- (FT_LruList_InitFunc) 0,
- (FT_LruList_DoneFunc) 0,
-
- sizeof( FTC_SizeNodeRec ),
- (FT_LruNode_InitFunc) ftc_size_node_init,
- (FT_LruNode_DoneFunc) ftc_size_node_done,
- (FT_LruNode_FlushFunc) ftc_size_node_flush,
- (FT_LruNode_CompareFunc) ftc_size_node_compare
+ (FT_LruList_InitFunc) 0,
+ (FT_LruList_DoneFunc) 0,
+
+ sizeof ( FTC_SizeNodeRec ),
+ (FT_LruNode_InitFunc) ftc_size_node_init,
+ (FT_LruNode_DoneFunc) ftc_size_node_done,
+ (FT_LruNode_FlushFunc) ftc_size_node_flush,
+ (FT_LruNode_CompareFunc)ftc_size_node_compare
};
@@ -308,8 +307,6 @@
manager->request_face = requester;
manager->request_data = req_data;
-
-
*amanager = manager;
Exit:
@@ -368,7 +365,7 @@
FT_EXPORT_DEF( void )
FTC_Manager_Reset( FTC_Manager manager )
{
- if (manager )
+ if ( manager )
{
FT_LruList_Reset( manager->sizes_list );
FT_LruList_Reset( manager->faces_list );
@@ -387,6 +384,7 @@
FT_Error error;
FTC_FaceNode node;
+
if ( aface == NULL )
return FTC_Err_Bad_Argument;
@@ -395,10 +393,10 @@
if ( !manager )
return FTC_Err_Invalid_Cache_Handle;
- error = FT_LruList_Lookup( manager->faces_list,
- (FT_LruKey) face_id,
- (FT_LruNode*) &node );
- if (!error)
+ error = FT_LruList_Lookup( manager->faces_list,
+ (FT_LruKey)face_id,
+ (FT_LruNode*)&node );
+ if ( !error )
*aface = node->face;
return error;
@@ -435,8 +433,8 @@
query.height = font->pix_height;
error = FT_LruList_Lookup( manager->sizes_list,
- (FT_LruKey) &query,
- (FT_LruNode*) &node );
+ (FT_LruKey)&query,
+ (FT_LruNode*)&node );
if ( !error )
{
/* select the size as the current one for this face */
@@ -451,18 +449,18 @@
}
-
- /* add a new node to the head of the manager's circular MRU list */
+ /* add a new node to the head of the manager's circular MRU list */
static void
ftc_node_mru_link( FTC_Node node,
FTC_Manager manager )
{
FTC_Node first = manager->nodes_list;
- if (first)
+
+ if ( first )
{
- node->mru_prev = first->mru_prev;
- node->mru_next = first;
+ node->mru_prev = first->mru_prev;
+ node->mru_next = first;
first->mru_prev->mru_next = node;
first->mru_prev = node;
@@ -472,12 +470,13 @@
node->mru_next = node;
node->mru_prev = node;
}
+
manager->nodes_list = node;
manager->num_nodes++;
}
- /* remove a node from the manager's MRU list */
+ /* remove a node from the manager's MRU list */
static void
ftc_node_mru_unlink( FTC_Node node,
FTC_Manager manager )
@@ -486,12 +485,13 @@
FTC_Node next = node->mru_next;
FTC_Node first = manager->nodes_list;
+
prev->mru_next = next;
next->mru_prev = prev;
if ( node->mru_next == first )
{
- /* this is the last node in the list, update its head pointer */
+ /* this is the last node in the list; update its head pointer */
if ( node == first )
manager->nodes_list = NULL;
else
@@ -504,13 +504,14 @@
}
- /* move a node to the head of the manager's MRU list */
+ /* move a node to the head of the manager's MRU list */
static void
ftc_node_mru_up( FTC_Node node,
FTC_Manager manager )
{
FTC_Node first = manager->nodes_list;
+
if ( node != first )
{
ftc_node_mru_unlink( node, manager );
@@ -519,18 +520,19 @@
}
- /* remove a node from its cache's hash table */
+ /* 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);
+ FTC_Node *pnode = cache->buckets + ( node->hash % cache->size );
+
for (;;)
{
if ( *pnode == NULL )
{
- FT_ERROR(( "FreeType.cache.hash_unlink: unknown node !!\n" ));
+ FT_ERROR(( "FreeType.cache.hash_unlink: unknown node!\n" ));
return;
}
@@ -548,12 +550,13 @@
}
- /* add a node to the "top" of its cache's hash table */
+ /* add a node to the "top" of its cache's hash table */
static void
ftc_node_hash_link( FTC_Node node,
FTC_Cache cache )
{
- FTC_Node *pnode = cache->buckets + (node->hash % cache->size);
+ FTC_Node *pnode = cache->buckets + ( node->hash % cache->size );
+
node->link = *pnode;
*pnode = node;
@@ -562,9 +565,7 @@
}
-
-
- /* remove a node from the cache manager */
+ /* remove a node from the cache manager */
static void
ftc_node_destroy( FTC_Node node,
FTC_Manager manager )
@@ -573,6 +574,7 @@
FTC_Cache cache;
FTC_Cache_Class clazz;
+
#ifdef FT_DEBUG_ERROR
/* find node's cache */
if ( node->cache_index >= FTC_MAX_CACHES )
@@ -582,7 +584,7 @@
}
#endif
- cache = manager->caches[ node->cache_index ];
+ cache = manager->caches[node->cache_index];
#ifdef FT_DEBUG_ERROR
if ( cache == NULL )
@@ -616,50 +618,56 @@
}
-
- FT_EXPORT_DEF(void)
+ FT_EXPORT_DEF( void )
FTC_Manager_Check( FTC_Manager manager )
{
FTC_Node node, first;
+
first = manager->nodes_list;
/* check node weights */
- if (first)
+ if ( first )
{
FT_ULong weight = 0;
+
node = first;
+
do
{
FTC_Cache cache = manager->caches[node->cache_index];
+
weight += cache->clazz->node_weight( node, cache );
- node = node->mru_next;
- }
- while (node != first);
+ node = node->mru_next;
+
+ } while ( node != first );
if ( weight != manager->cur_weight )
- FT_ERROR(( "FTC_Manager_Compress: invalid weight %ld instead of %ld\n",
- manager->cur_weight, weight ));
+ FT_ERROR((
+ "FTC_Manager_Compress: invalid weight %ld instead of %ld\n",
+ manager->cur_weight, weight ));
}
/* check circular list */
- if (first)
+ if ( first )
{
FT_UFast count = 0;
+
node = first;
do
{
count++;
node = node->mru_next;
- }
- while (node != first);
+
+ } while ( node != first );
if ( count != manager->num_nodes )
- FT_ERROR(( "FTC_Manager_Compress: invalid cache node count %d instead of %d\n",
- manager->num_nodes, count ));
+ FT_ERROR((
+ "FTC_Manager_Compress: invalid cache node count %d instead of %d\n",
+ manager->num_nodes, count ));
}
}
@@ -675,19 +683,20 @@
{
FTC_Node node, first;
+
if ( !manager )
return;
- first = manager->nodes_list;
+ first = manager->nodes_list;
#if 0
FTC_Manager_Check( manager );
FT_ERROR(( "compressing, weight = %ld, max = %ld, nodes = %d\n",
- manager->cur_weight, manager->max_weight, manager->num_nodes ));
+ manager->cur_weight, manager->max_weight,
+ manager->num_nodes ));
#endif
-
if ( manager->cur_weight < manager->max_weight || first == NULL )
return;
@@ -697,16 +706,16 @@
{
FTC_Node prev = node->mru_prev;
+
prev = ( node == first ) ? NULL : node->mru_prev;
if ( node->ref_count <= 0 )
ftc_node_destroy( node, manager );
node = prev;
- }
- while ( node && manager->cur_weight > manager->max_weight );
- }
+ } while ( node && manager->cur_weight > manager->max_weight );
+ }
FT_EXPORT_DEF( FT_Error )
@@ -746,8 +755,8 @@
cache->memory = memory;
cache->clazz = clazz;
- /* THIS IS VERY IMPORTANT! IT WILL WRETCH THE MANAGER */
- /* IF IT IS NOT SET CORRECTLY */
+ /* THIS IS VERY IMPORTANT! IT WILL WRETCH THE MANAGER */
+ /* IF IT IS NOT SET CORRECTLY */
cache->cache_index = index;
if ( clazz->cache_init )
@@ -781,8 +790,8 @@
/*************************************************************************/
/*************************************************************************/
-#define FTC_PRIMES_MIN 7
-#define FTC_PRIMES_MAX 13845163
+#define FTC_PRIMES_MIN 7
+#define FTC_PRIMES_MAX 13845163
static const FT_UInt ftc_primes[] =
{
@@ -829,7 +838,8 @@
{
FT_UInt i;
- for ( i = 0; i < sizeof(ftc_primes)/sizeof(ftc_primes[0]); i++ )
+
+ for ( i = 0; i < sizeof ( ftc_primes ) / sizeof ( ftc_primes[0] ); i++ )
if ( ftc_primes[i] > num )
return ftc_primes[i];
@@ -842,6 +852,7 @@
{
FT_UFast new_size;
+
new_size = ftc_prime_closest( cache->nodes );
if ( new_size != cache->size )
{
@@ -850,6 +861,7 @@
FTC_Node* new_buckets ;
FT_ULong i;
+
if ( ALLOC_ARRAY( new_buckets, new_size, FTC_Node ) )
return;
@@ -858,8 +870,9 @@
FTC_Node node, next, *pnode;
FT_UFast hash;
+
node = cache->buckets[i];
- while (node)
+ while ( node )
{
next = node->link;
hash = node->hash % new_size;
@@ -868,7 +881,7 @@
node->link = pnode[0];
pnode[0] = node;
- node = next;
+ node = next;
}
}
@@ -887,6 +900,7 @@
FT_Memory memory = cache->memory;
FT_Error error;
+
cache->nodes = 0;
cache->size = FTC_PRIMES_MIN;
@@ -898,7 +912,6 @@
}
-
FT_EXPORT_DEF( void )
ftc_cache_done( FTC_Cache cache )
{
@@ -909,11 +922,12 @@
FTC_Manager manager = cache->manager;
FT_UFast i;
+
for ( i = 0; i < cache->size; i++ )
{
FTC_Node *pnode = cache->buckets + i, next, node = *pnode;
- while (node)
+ while ( node )
{
next = node->link;
node->link = NULL;
@@ -941,11 +955,10 @@
}
-
- /* lookup a node in "top" of its cache's hash table */
- /* if not found, create a new node.. */
- /* */
- FT_EXPORT_DEF(FT_Error)
+ /* Look up a node in "top" of its cache's hash table. */
+ /* If not found, create a new node. */
+ /* */
+ FT_EXPORT_DEF( FT_Error )
ftc_cache_lookup_node( FTC_Cache cache,
FT_UFast key_hash,
FT_Pointer key,
@@ -953,17 +966,20 @@
{
FT_Error error = 0;
FTC_Node result = NULL;
- FTC_Node* bucket = cache->buckets + (key_hash % cache->size);
+ FTC_Node* bucket = cache->buckets + ( key_hash % cache->size );
+
if ( *bucket )
{
FTC_Node* pnode = bucket;
FTC_Node_CompareFunc compare = cache->clazz->node_compare;
- for ( ;; )
+
+ for (;;)
{
FTC_Node node;
+
node = *pnode;
if ( node == NULL )
break;
@@ -997,6 +1013,7 @@
FT_Memory memory = cache->memory;
FTC_Node node;
+
if ( ALLOC( node, clazz->node_size ) )
goto Exit;
@@ -1026,7 +1043,7 @@
}
/* try to resize the hash table when appropriate */
- if ( FTC_CACHE_RESIZE_TEST(cache) )
+ if ( FTC_CACHE_RESIZE_TEST( cache ) )
ftc_cache_resize( cache );
result = node;
@@ -1038,9 +1055,9 @@
}
- /* maybe these functions will disappear later */
+ /* maybe the next two functions will disappear eventually */
- FT_EXPORT_DEF(void)
+ FT_EXPORT_DEF( void )
ftc_node_ref( FTC_Node node,
FTC_Cache cache )
{
@@ -1049,8 +1066,7 @@
}
-
- FT_EXPORT_DEF(void)
+ FT_EXPORT_DEF( void )
ftc_node_unref( FTC_Node node,
FTC_Cache cache )
{
diff --git a/src/cache/ftcsbits.c b/src/cache/ftcsbits.c
index 95b5a1335..12548d129 100644
--- a/src/cache/ftcsbits.c
+++ b/src/cache/ftcsbits.c
@@ -33,7 +33,7 @@
/* handle to sbit set */
- typedef struct FTC_SBitSetRec_* FTC_SBitSet;
+ typedef struct FTC_SBitSetRec_* FTC_SBitSet;
/* sbit set structure */
typedef struct FTC_SBitSetRec_
@@ -43,12 +43,12 @@
} FTC_SBitSetRec;
-#define FTC_SBIT_SET(x) ((FTC_SBitSet)(x))
-#define FTC_SBIT_SET_MEMORY(x) FTC_CHUNK_SET_MEMORY(&(x)->cset)
+#define FTC_SBIT_SET( x ) ( (FTC_SBitSet)(x) )
+#define FTC_SBIT_SET_MEMORY( x ) FTC_CHUNK_SET_MEMORY( &(x)->cset )
- typedef struct FTC_SBitQueryRec_
+ typedef struct FTC_SBitQueryRec_
{
FTC_ChunkQueryRec chunk;
FTC_Image_Desc desc;
@@ -73,6 +73,7 @@
FT_UInt count = cnode->item_count;
FTC_SBit sbit = (FTC_SBit) cnode->items;
+
if ( sbit )
{
for ( ; count > 0; sbit++, count-- )
@@ -107,7 +108,6 @@
}
-
static FT_Error
ftc_sbit_node_load( FTC_ChunkNode cnode,
FT_UInt gindex,
@@ -122,6 +122,7 @@
FTC_SBit sbit;
+
if ( gindex < (FT_UInt)cnode->item_start ||
gindex >= (FT_UInt)cnode->item_start + cnode->item_count )
{
@@ -129,7 +130,7 @@
return FTC_Err_Invalid_Argument;
}
- sbit = (FTC_SBit)cnode->items + (gindex - cnode->item_start);
+ sbit = (FTC_SBit)cnode->items + ( gindex - cnode->item_start );
error = FTC_Manager_Lookup_Size( cset->ccache->cache.manager,
&sbitset->desc.font,
@@ -154,8 +155,9 @@
}
else
{
- FT_ERROR(( "FreeType.cache.sbit_load: cannot load scalable glyphs in an"
- " sbit cache, please check your arguments!\n" ));
+ FT_ERROR((
+ "FreeType.cache.sbit_load: cannot load scalable glyphs in an"
+ " sbit cache, please check your arguments!\n" ));
error = FTC_Err_Invalid_Argument;
goto Exit;
}
@@ -225,7 +227,7 @@
/* now, compute size */
if ( asize )
- *asize = ABS(sbit->pitch) * sbit->height;
+ *asize = ABS( sbit->pitch ) * sbit->height;
} /* glyph dimensions ok */
@@ -237,9 +239,9 @@
/* */
if ( error )
{
- sbit->width = 255;
- error = 0;
- /* sbit->buffer == NULL too !! */
+ sbit->width = 255;
+ error = 0;
+ /* sbit->buffer == NULL too! */
}
}
@@ -252,7 +254,8 @@
ftc_sbit_node_init( FTC_ChunkNode cnode,
FTC_ChunkQuery query )
{
- FT_Error error;
+ FT_Error error;
+
error = ftc_chunk_node_init( cnode,
query->cset,
@@ -270,22 +273,20 @@
}
-
/* this function is important because it is both part of */
/* an FTC_ChunkSet_Class and an FTC_CacheNode_Class */
/* */
FT_CALLBACK_DEF( FT_ULong )
ftc_sbit_node_weight( FTC_ChunkNode cnode )
{
- FT_ULong size;
- FTC_ChunkSet cset = cnode->cset;
- FT_UInt count = cnode->item_count;
- FT_Int pitch;
- FTC_SBit sbit = (FTC_SBit) cnode->items;
+ FT_ULong size;
+ FT_UInt count = cnode->item_count;
+ FT_Int pitch;
+ FTC_SBit sbit = (FTC_SBit) cnode->items;
/* the node itself */
- size = sizeof ( *cnode );
+ size = sizeof ( *cnode );
/* the sbit records */
size += cnode->item_count * sizeof ( FTC_SBitRec );
@@ -317,6 +318,7 @@
FT_UInt offset = (FT_UInt)(gindex - cnode->item_start);
FT_Bool result;
+
result = FT_BOOL( offset < (FT_UInt)cnode->item_count &&
creq->cset == cnode->cset );
if ( result )
@@ -324,13 +326,17 @@
/* check if we need to load the glyph bitmap now */
FTC_SBit sbit = (FTC_SBit)cnode->items + offset;
+
if ( sbit->buffer == NULL && sbit->width != 255 )
{
FT_ULong size;
+
+
ftc_sbit_node_load( cnode, gindex, &size );
cache->manager->cur_weight += size;
}
}
+
return result;
}
@@ -354,6 +360,7 @@
FT_Error error;
FT_Face face;
+
sset->desc = query->desc;
/* we need to compute "cquery.item_total" now */
@@ -362,14 +369,14 @@
&face );
if ( !error )
{
- ftc_chunk_set_init( FTC_CHUNK_SET(sset),
- sizeof( FTC_SBitRec ),
+ ftc_chunk_set_init( FTC_CHUNK_SET( sset ),
+ sizeof ( FTC_SBitRec ),
FTC_SBIT_ITEMS_PER_NODE,
face->num_glyphs,
- FTC_CHUNK_CACHE(lru->user_data) );
+ FTC_CHUNK_CACHE( lru->user_data ) );
- /* now compute hash from description - this is _very_ important */
- /* for good performance.. */
+ /* now compute hash from description -- this is _very_ important */
+ /* for good performance */
sset->cset.hash = FTC_IMAGE_DESC_HASH( &sset->desc );
query->chunk.cset = &sset->cset;
}
@@ -378,16 +385,16 @@
}
-
FT_CALLBACK_DEF( FT_Bool )
ftc_sbit_set_compare( FTC_SBitSet sset,
FTC_SBitQuery query )
{
FT_Bool result;
+
/* we need to set the "cquery.cset" field or our query for */
- /* faster glyph comparisons in ftc_sbit_node_compare.. */
- /* */
+ /* faster glyph comparisons in ftc_sbit_node_compare() */
+ /* */
result = FT_BOOL( FTC_IMAGE_DESC_COMPARE( &sset->desc, &query->desc ) );
if ( result )
query->chunk.cset = &sset->cset;
@@ -396,23 +403,21 @@
}
-
FT_CALLBACK_TABLE_DEF
const FT_LruList_ClassRec ftc_sbit_set_class =
{
- sizeof( FT_LruListRec ),
- (FT_LruList_InitFunc) NULL,
- (FT_LruList_DoneFunc) NULL,
-
- sizeof( FTC_SBitSetRec ),
- (FT_LruNode_InitFunc) ftc_sbit_set_init,
- (FT_LruNode_DoneFunc) ftc_chunk_set_done,
- (FT_LruNode_FlushFunc) NULL,
- (FT_LruNode_CompareFunc) ftc_sbit_set_compare,
+ sizeof ( FT_LruListRec ),
+ (FT_LruList_InitFunc) NULL,
+ (FT_LruList_DoneFunc) NULL,
+
+ sizeof ( FTC_SBitSetRec ),
+ (FT_LruNode_InitFunc) ftc_sbit_set_init,
+ (FT_LruNode_DoneFunc) ftc_chunk_set_done,
+ (FT_LruNode_FlushFunc) NULL,
+ (FT_LruNode_CompareFunc)ftc_sbit_set_compare,
};
-
/*************************************************************************/
/*************************************************************************/
/***** *****/
@@ -425,22 +430,23 @@
FT_CALLBACK_DEF( FT_Error )
ftc_sbit_cache_init( FTC_SBit_Cache scache )
{
- return ftc_chunk_cache_init( FTC_CHUNK_CACHE(scache),
+ return ftc_chunk_cache_init( FTC_CHUNK_CACHE( scache ),
&ftc_sbit_set_class );
}
+
FT_CALLBACK_TABLE_DEF
const FTC_Cache_ClassRec ftc_sbit_cache_class =
{
- sizeof( FTC_ChunkCacheRec ),
+ sizeof ( FTC_ChunkCacheRec ),
(FTC_Cache_InitFunc) ftc_sbit_cache_init,
(FTC_Cache_DoneFunc) ftc_chunk_cache_done,
- sizeof( FTC_ChunkNodeRec ),
- (FTC_Node_InitFunc) ftc_sbit_node_init,
- (FTC_Node_WeightFunc) ftc_sbit_node_weight,
- (FTC_Node_CompareFunc) ftc_sbit_node_compare,
- (FTC_Node_DoneFunc) ftc_sbit_node_done
+ sizeof ( FTC_ChunkNodeRec ),
+ (FTC_Node_InitFunc) ftc_sbit_node_init,
+ (FTC_Node_WeightFunc) ftc_sbit_node_weight,
+ (FTC_Node_CompareFunc)ftc_sbit_node_compare,
+ (FTC_Node_DoneFunc) ftc_sbit_node_done
};
@@ -450,10 +456,9 @@
FTC_SBit_Cache_New( FTC_Manager manager,
FTC_SBit_Cache *acache )
{
- return FTC_Manager_Register_Cache(
- manager,
- &ftc_sbit_cache_class,
- (FTC_Cache*) acache );
+ return FTC_Manager_Register_Cache( manager,
+ &ftc_sbit_cache_class,
+ (FTC_Cache*)acache );
}
@@ -484,7 +489,7 @@
error = ftc_chunk_cache_lookup( ccache, &query.chunk, &node );
if ( !error )
{
- *ansbit = (FTC_SBit) node->items + (gindex - node->item_start);
+ *ansbit = (FTC_SBit)node->items + ( gindex - node->item_start );
}
return error;
}
diff --git a/src/cache/ftlru.c b/src/cache/ftlru.c
index eed41f5ce..5c4183b7c 100644
--- a/src/cache/ftlru.c
+++ b/src/cache/ftlru.c
@@ -35,6 +35,7 @@
FT_Error error;
FT_LruList list;
+
if ( !alist || !clazz )
return FTC_Err_Invalid_Argument;
@@ -72,6 +73,7 @@
FT_Memory memory;
FT_LruList_Class clazz;
+
if ( !list )
return;
@@ -87,7 +89,6 @@
}
-
FT_EXPORT_DEF( void )
FT_LruList_Reset( FT_LruList list )
{
@@ -107,6 +108,7 @@
{
FT_LruNode next = node->next;
+
if ( clazz->node_done )
clazz->node_done( node, list );
@@ -179,7 +181,7 @@
{
*pnode = node->next;
node->next = list->nodes;
- list->nodes = node;
+ list->nodes = node;
}
result = node;
goto Exit;
@@ -193,9 +195,10 @@
if ( list->max_nodes > 0 && list->num_nodes >= list->max_nodes )
{
/* this list list is full; we will now flush */
- /* the oldest node, if there's one !! */
+ /* the oldest node, if there's one! */
FT_LruNode last = *plast;
+
if ( last )
{
if ( clazz->node_flush )
@@ -223,7 +226,7 @@
}
/* in case of error during the flush or done/init cycle, */
- /* we need to discard the node.. */
+ /* we need to discard the node */
if ( clazz->node_done )
clazz->node_done( last, list );
@@ -258,13 +261,13 @@
}
-
FT_EXPORT_DEF( void )
FT_LruList_Remove( FT_LruList list,
FT_LruNode node )
{
FT_LruNode *pnode;
+
if ( !list || !node )
return;
@@ -276,6 +279,7 @@
FT_Memory memory = list->memory;
FT_LruList_Class clazz = list->clazz;
+
*pnode = node->next;
node->next = NULL;
@@ -292,7 +296,6 @@
}
-
FT_EXPORT_DEF( void )
FT_LruList_Remove_Selection( FT_LruList list,
FT_LruNode_SelectFunc select_func,
@@ -302,6 +305,7 @@
FT_LruList_Class clazz;
FT_Memory memory;
+
if ( !list || !select_func )
return;
diff --git a/src/cff/cffload.c b/src/cff/cffload.c
index 075351fc6..ce41358fb 100644
--- a/src/cff/cffload.c
+++ b/src/cff/cffload.c
@@ -2,7 +2,7 @@
/* */
/* cffload.c */
/* */
-/* OpenType and CFF data/program tables loader (body) */
+/* OpenType and CFF data/program tables loader (body). */
/* */
/* Copyright 1996-2001 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
@@ -2242,7 +2242,8 @@
cff_done_index( &font->name_index );
cff_done_index( &font->charstrings_index );
- /* release font dictionaries, but only if working with a CID keyed CFF font */
+ /* release font dictionaries, but only if working with */
+ /* a CID keyed CFF font */
if ( font->num_subfonts > 0 )
{
for ( index = 0; index < font->num_subfonts; index++ )
diff --git a/src/cid/cidgload.c b/src/cid/cidgload.c
index 34a341453..e07c702bd 100644
--- a/src/cid/cidgload.c
+++ b/src/cid/cidgload.c
@@ -158,7 +158,7 @@
0, /* glyph slot */
0, /* glyph names! XXX */
0, /* blend == 0 */
- 0, /* hinting == FALSE */
+ 0, /* hinting == 0 */
cid_load_glyph );
if ( error )
return error;
diff --git a/src/cid/cidriver.c b/src/cid/cidriver.c
index 8de7852b1..dead1c4ad 100644
--- a/src/cid/cidriver.c
+++ b/src/cid/cidriver.c
@@ -185,7 +185,6 @@
}
-
FT_CALLBACK_TABLE_DEF
const FT_Driver_Class t1cid_driver_class =
{
diff --git a/src/pcf/pcfread.c b/src/pcf/pcfread.c
index eac265e86..984df7150 100644
--- a/src/pcf/pcfread.c
+++ b/src/pcf/pcfread.c
@@ -50,7 +50,7 @@ THE SOFTWARE.
#if defined( FT_DEBUG_LEVEL_TRACE )
- static char* tableNames[] =
+ static const char* tableNames[] =
{
"prop", "accl", "mtrcs", "bmps", "imtrcs",
"enc", "swidth", "names", "accel"
@@ -95,7 +95,7 @@ THE SOFTWARE.
PCF_Table tables;
FT_Memory memory = FT_FACE(face)->memory;
- unsigned int i;
+ unsigned int n;
if ( FILE_Seek ( 0 ) ||
@@ -109,7 +109,7 @@ THE SOFTWARE.
return PCF_Err_Out_Of_Memory;
tables = face->toc.tables;
- for ( i = 0; i < toc->count; i++ )
+ for ( n = 0; n < toc->count; n++ )
{
if ( READ_Fields( pcf_table_header, tables ) )
goto Exit;
@@ -119,8 +119,8 @@ THE SOFTWARE.
#if defined( FT_DEBUG_LEVEL_TRACE )
{
- unsigned int i,j;
- char* name = "?";
+ unsigned int i, j;
+ const char *name = "?";
FT_TRACE4(( "Tables count: %ld\n", face->toc.count ));
@@ -129,7 +129,7 @@ THE SOFTWARE.
{
for( j = 0; j < sizeof ( tableNames ) / sizeof ( tableNames[0] ); j++ )
if ( tables[i].type == (unsigned int)( 1 << j ) )
- name=tableNames[j];
+ name = tableNames[j];
FT_TRACE4(( "Table %d: type=%-6s format=0x%04lX "
"size=0x%06lX (%8ld) offset=0x%04lX\n",
i, name,
diff --git a/src/psaux/psobjs.c b/src/psaux/psobjs.c
index e5d9124d7..5c5fbe0b0 100644
--- a/src/psaux/psobjs.c
+++ b/src/psaux/psobjs.c
@@ -1086,15 +1086,15 @@
FT_GlyphLoader* loader = glyph->internal->loader;
- builder->loader = loader;
- builder->base = &loader->base.outline;
- builder->current = &loader->current.outline;
+ builder->loader = loader;
+ builder->base = &loader->base.outline;
+ builder->current = &loader->current.outline;
FT_GlyphLoader_Rewind( loader );
builder->hints_globals = size->internal;
builder->hints_funcs = 0;
- if (hinting)
+ if ( hinting )
builder->hints_funcs = glyph->internal->glyph_hints;
}
diff --git a/src/psaux/psobjs.h b/src/psaux/psobjs.h
index 34f7f059f..16dfe5c89 100644
--- a/src/psaux/psobjs.h
+++ b/src/psaux/psobjs.h
@@ -177,6 +177,7 @@ FT_BEGIN_HEADER
FT_Pos x,
FT_Pos y );
+
FT_LOCAL void
T1_Builder_Close_Contour( T1_Builder* builder );
diff --git a/src/psaux/t1decode.c b/src/psaux/t1decode.c
index fc5b6823f..36c60549c 100644
--- a/src/psaux/t1decode.c
+++ b/src/psaux/t1decode.c
@@ -141,7 +141,8 @@
FT_String* name = (FT_String*)decoder->glyph_names[n];
- if ( name && name[0] == glyph_name[0] && strcmp( name,glyph_name ) == 0 )
+ if ( name && name[0] == glyph_name[0] &&
+ strcmp( name,glyph_name ) == 0 )
return n;
}
@@ -290,6 +291,7 @@
{
FT_Outline dummy;
+
dummy.n_points = (short)( base->n_points - n_base_points );
dummy.points = base->points + n_base_points;
@@ -337,6 +339,7 @@
T1_Hints_Funcs hinter;
+
/* 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
@@ -738,7 +741,7 @@
/* apply hints to the loaded glyph outline now */
hinter->apply( hinter->hints,
builder->current,
- (PSH_Globals) builder->hints_globals );
+ (PSH_Globals)builder->hints_globals );
}
/* add current outline to the glyph slot */
@@ -1086,7 +1089,7 @@
}
- /* parse a single Type 1 glyph */
+ /* parse a single Type 1 glyph */
FT_LOCAL_DEF FT_Error
T1_Decoder_Parse_Glyph( T1_Decoder* decoder,
FT_UInt glyph )
@@ -1095,7 +1098,7 @@
}
- /* initialise T1 decoder */
+ /* initialise T1 decoder */
FT_LOCAL_DEF FT_Error
T1_Decoder_Init( T1_Decoder* decoder,
FT_Face face,
@@ -1137,7 +1140,7 @@
}
- /* finalize T1 decoder */
+ /* finalize T1 decoder */
FT_LOCAL_DEF void
T1_Decoder_Done( T1_Decoder* decoder )
{
diff --git a/src/pshinter/Jamfile b/src/pshinter/Jamfile
index 3b749f171..6eea3be0f 100644
--- a/src/pshinter/Jamfile
+++ b/src/pshinter/Jamfile
@@ -20,4 +20,4 @@ SubDirHdrs [ FT2_SubDir src pshinter ] ;
Library $(FT2_LIB) : $(_sources).c ;
}
-# end of src/psaux Jamfile
+# end of src/pshinter Jamfile
diff --git a/src/pshinter/pshalgo.h b/src/pshinter/pshalgo.h
index 641931124..6097671b6 100644
--- a/src/pshinter/pshalgo.h
+++ b/src/pshinter/pshalgo.h
@@ -1,19 +1,44 @@
-#ifndef __PS_HINTER_ALGO_H__
-#define __PS_HINTER_ALGO_H__
+/***************************************************************************/
+/* */
+/* pshalgo.h */
+/* */
+/* This header file defines the used hinting algorithm. */
+/* */
+/* Copyright 2001 by */
+/* David Turner, Robert Wilhelm, and Werner Lemberg. */
+/* */
+/* This file is part of the FreeType project, and may only be used */
+/* modified and distributed under the terms of the FreeType project */
+/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
+/* this file you indicate that you have read the license and */
+/* understand and accept it fully. */
+/* */
+/***************************************************************************/
+
+
+#ifndef __PSHALGO_H__
+#define __PSHALGO_H__
FT_BEGIN_HEADER
/* define to choose hinting algorithm */
-#define PSH_ALGORITHM_2
+#define PSH_ALGORITHM_2
#ifdef 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
+
#else
-# include "pshalgo2.h"
-# define PS_HINTS_APPLY_FUNC ps2_hints_apply
+
+#include "pshalgo2.h"
+#define PS_HINTS_APPLY_FUNC ps2_hints_apply
+
#endif
FT_END_HEADER
-#endif /* __PS_HINTER_ALGO_H__ */
+#endif /* __PSHALGO_H__ */
+
+
+/* END */
diff --git a/src/pshinter/pshalgo1.c b/src/pshinter/pshalgo1.c
index 9d61bcaad..d8b3022a8 100644
--- a/src/pshinter/pshalgo1.c
+++ b/src/pshinter/pshalgo1.c
@@ -1,13 +1,33 @@
+/***************************************************************************/
+/* */
+/* pshalgo1.c */
+/* */
+/* PostScript hinting algorithm 1 (body). */
+/* */
+/* Copyright 2001 by */
+/* David Turner, Robert Wilhelm, and Werner Lemberg. */
+/* */
+/* This file is part of the FreeType project, and may only be used */
+/* modified and distributed under the terms of the FreeType project */
+/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
+/* this file you indicate that you have read the license and */
+/* understand and accept it fully. */
+/* */
+/***************************************************************************/
+
+
#include <ft2build.h>
#include FT_INTERNAL_OBJECTS_H
#include FT_INTERNAL_DEBUG_H
#include "pshalgo1.h"
+
#ifdef DEBUG_HINTER
- extern PSH1_Hint_Table ps1_debug_hint_table = 0;
- extern PSH1_HintFunc ps1_debug_hint_func = 0;
+ extern PSH1_Hint_Table ps1_debug_hint_table = 0;
+ extern PSH1_HintFunc ps1_debug_hint_func = 0;
#endif
+
/************************************************************************/
/************************************************************************/
/***** *****/
@@ -16,7 +36,7 @@
/************************************************************************/
/************************************************************************/
- /* return true iff two stem hints overlap */
+ /* return true iff two stem hints overlap */
static FT_Int
psh1_hint_overlap( PSH1_Hint hint1,
PSH1_Hint hint2 )
@@ -26,7 +46,7 @@
}
- /* destroy hints table */
+ /* destroy hints table */
static void
psh1_hint_table_done( PSH1_Hint_Table table,
FT_Memory memory )
@@ -43,28 +63,30 @@
}
- /* deactivate all hints in a table */
+ /* deactivate all hints in a table */
static void
psh1_hint_table_deactivate( PSH1_Hint_Table table )
{
- FT_UInt count = table->max_hints;
+ FT_UInt count = table->max_hints;
PSH1_Hint hint = table->hints;
+
for ( ; count > 0; count--, hint++ )
{
- psh1_hint_deactivate(hint);
+ psh1_hint_deactivate( hint );
hint->order = -1;
}
}
- /* internal function used to record a new hint */
+ /* internal function used to record a new hint */
static void
psh1_hint_table_record( PSH1_Hint_Table table,
FT_UInt index )
{
PSH1_Hint hint = table->hints + index;
+
if ( index >= table->max_hints )
{
FT_ERROR(( "%s.activate: invalid hint index %d\n", index ));
@@ -72,18 +94,19 @@
}
/* ignore active hints */
- if ( psh1_hint_is_active(hint) )
+ if ( psh1_hint_is_active( hint ) )
return;
- psh1_hint_activate(hint);
+ psh1_hint_activate( hint );
/* now scan the current active hint set in order to determine */
- /* if we're overlapping with another segment.. */
+ /* if we are overlapping with another segment */
{
PSH1_Hint* sorted = table->sort_global;
FT_UInt count = table->num_hints;
PSH1_Hint hint2;
+
hint->parent = 0;
for ( ; count > 0; count--, sorted++ )
{
@@ -98,12 +121,10 @@
}
if ( table->num_hints < table->max_hints )
- table->sort_global[ table->num_hints++ ] = hint;
+ table->sort_global[table->num_hints++] = hint;
else
- {
- FT_ERROR(( "%s.activate: too many sorted hints !! BUG !!\n",
+ FT_ERROR(( "%s.activate: too many sorted hints! BUG!\n",
"ps.fitter" ));
- }
}
@@ -115,13 +136,12 @@
FT_Byte* cursor = hint_mask->bytes;
FT_UInt index, limit;
+
limit = hint_mask->num_bits;
if ( limit != table->max_hints )
- {
FT_ERROR(( "%s.activate_mask: invalid bit count (%d instead of %d)\n",
"ps.fitter", hint_mask->num_bits, table->max_hints ));
- }
for ( index = 0; index < limit; index++ )
{
@@ -139,7 +159,7 @@
}
- /* create hints table */
+ /* create hints table */
static FT_Error
psh1_hint_table_init( PSH1_Hint_Table table,
PS_Hint_Table hints,
@@ -150,12 +170,13 @@
FT_UInt count = hints->num_hints;
FT_Error error;
- FT_UNUSED(counter_masks);
+ FT_UNUSED( counter_masks );
+
/* allocate our tables */
- if ( ALLOC_ARRAY( table->sort, 2*count, PSH1_Hint ) ||
- ALLOC_ARRAY( table->hints, count, PSH1_HintRec ) ||
- ALLOC_ARRAY( table->zones, 2*count+1, PSH1_ZoneRec ) )
+ if ( ALLOC_ARRAY( table->sort, 2 * count, PSH1_Hint ) ||
+ ALLOC_ARRAY( table->hints, count, PSH1_HintRec ) ||
+ ALLOC_ARRAY( table->zones, 2 * count + 1, PSH1_ZoneRec ) )
goto Exit;
table->max_hints = count;
@@ -164,10 +185,11 @@
table->num_zones = 0;
table->zone = 0;
- /* now, initialise the "hints" array */
+ /* now, initialize the "hints" array */
{
PSH1_Hint write = table->hints;
- PS_Hint read = hints->hints;
+ PS_Hint read = hints->hints;
+
for ( ; count > 0; count--, write++, read++ )
{
@@ -177,28 +199,30 @@
}
}
- /* we now need to determine the initial "parent" stems, first */
+ /* we now need to determine the initial "parent" stems; first */
/* activate the hints that are given by the initial hint masks */
if ( hint_masks )
{
- FT_UInt count = hint_masks->num_masks;
- PS_Mask mask = hint_masks->masks;
+ FT_UInt Count = hint_masks->num_masks;
+ PS_Mask Mask = hint_masks->masks;
+
table->hint_masks = hint_masks;
- for ( ; count > 0; count--, mask++ )
- psh1_hint_table_record_mask( table, mask );
+ for ( ; Count > 0; Count--, Mask++ )
+ psh1_hint_table_record_mask( table, Mask );
}
/* now, do a linear parse in case some hints were left alone */
if ( table->num_hints != table->max_hints )
{
- FT_UInt index, count;
+ FT_UInt Index, Count;
+
- FT_ERROR(( "%s.init: missing/incorrect hint masks !!\n" ));
+ FT_ERROR(( "%s.init: missing/incorrect hint masks!\n" ));
count = table->max_hints;
- for ( index = 0; index < count; index++ )
- psh1_hint_table_record( table, index );
+ for ( Index = 0; Index < Count; Index++ )
+ psh1_hint_table_record( table, Index );
}
Exit:
@@ -206,7 +230,6 @@
}
-
static void
psh1_hint_table_activate_mask( PSH1_Hint_Table table,
PS_Mask hint_mask )
@@ -215,6 +238,7 @@
FT_Byte* cursor = hint_mask->bytes;
FT_UInt index, limit, count;
+
limit = hint_mask->num_bits;
count = 0;
@@ -232,12 +256,14 @@
{
PSH1_Hint hint = &table->hints[index];
- if ( !psh1_hint_is_active(hint) )
+
+ if ( !psh1_hint_is_active( hint ) )
{
- PSH1_Hint* sort = table->sort;
- FT_UInt count2;
+ PSH1_Hint* sort = table->sort;
+ FT_UInt count2;
PSH1_Hint hint2;
+
for ( count2 = count; count2 > 0; count2--, sort++ )
{
hint2 = sort[0];
@@ -255,10 +281,8 @@
if ( count < table->max_hints )
table->sort[count++] = hint;
else
- {
FT_ERROR(( "%s.activate_mask: too many active hints\n",
"psf.hint" ));
- }
}
}
}
@@ -267,44 +291,41 @@
}
table->num_hints = count;
- /* now, sort the hints, they're guaranteed to not overlap */
- /* so we can compare their "org_pos" field directly.. */
+ /* now, sort the hints; they are guaranteed to not overlap */
+ /* so we can compare their "org_pos" field directly */
{
- FT_Int i1, i2;
+ FT_Int i1, i2;
PSH1_Hint hint1, hint2;
PSH1_Hint* sort = table->sort;
+
/* a simple bubble sort will do, since in 99% of cases, the hints */
- /* will be already sorted.. and the sort will be linear */
+ /* will be already sorted; and the sort will be linear */
for ( i1 = 1; i1 < (FT_Int)count; i1++ )
{
hint1 = sort[i1];
- for ( i2 = i1-1; i2 >= 0; i2-- )
+
+ for ( i2 = i1 - 1; i2 >= 0; i2-- )
{
hint2 = sort[i2];
if ( hint2->org_pos < hint1->org_pos )
break;
- sort[i2+1] = hint2;
- sort[i2] = hint1;
+ sort[i2 + 1] = hint2;
+ sort[i2] = hint1;
}
}
}
}
-
-
-
-
-
- /************************************************************************/
- /************************************************************************/
- /***** *****/
- /***** HINTS GRID-FITTING AND OPTIMISATION *****/
- /***** *****/
- /************************************************************************/
- /************************************************************************/
+ /*************************************************************************/
+ /*************************************************************************/
+ /***** *****/
+ /***** HINTS GRID-FITTING AND OPTIMIZATION *****/
+ /***** *****/
+ /*************************************************************************/
+ /*************************************************************************/
#ifdef DEBUG_HINTER
void
@@ -316,21 +337,23 @@
PSH1_Hint hint;
FT_UInt count;
+
for ( count = 0; count < table->num_hints; count++ )
{
hint = table->sort[count];
- if ( psh1_hint_is_active(hint) )
+ if ( psh1_hint_is_active( hint ) )
{
hint->cur_pos = FT_MulFix( hint->org_pos, scale ) + delta;
hint->cur_len = FT_MulFix( hint->org_len, scale );
- if (ps1_debug_hint_func)
+ if ( ps1_debug_hint_func )
ps1_debug_hint_func( hint, vertical );
}
}
}
#endif
+
FT_LOCAL_DEF FT_Error
psh1_hint_table_optimize( PSH1_Hint_Table table,
PSH_Globals globals,
@@ -341,7 +364,8 @@
FT_Fixed scale = dim->scale_mult;
FT_Fixed delta = dim->scale_delta;
- FT_UNUSED(outline);
+ FT_UNUSED( outline );
+
#ifdef DEBUG_HINTER
if ( ps_debug_no_vert_hints && vertical )
@@ -358,91 +382,91 @@
#endif
/* XXXX: for now, we only scale the hints to test all other aspects */
- /* of the Postscript Hinter.. */
+ /* of the PostScript hinter */
{
PSH1_Hint hint;
FT_UInt count;
+
for ( count = 0; count < table->num_hints; count++ )
{
hint = table->sort[count];
- if ( psh1_hint_is_active(hint) )
+ if ( psh1_hint_is_active( hint ) )
{
-# if 1
- FT_Pos pos = FT_MulFix( hint->org_pos, scale ) + delta;
- FT_Pos len = FT_MulFix( hint->org_len, scale );
+#if 1
+ FT_Pos pos = FT_MulFix( hint->org_pos, scale ) + delta;
+ FT_Pos len = FT_MulFix( hint->org_len, scale );
- FT_Pos fit_center;
- FT_Pos fit_len;
+ FT_Pos fit_center;
+ FT_Pos fit_len;
PSH_AlignmentRec align;
+
/* compute fitted width/height */
fit_len = psh_dimension_snap_width( dim, hint->org_len );
if ( fit_len < 64 )
fit_len = 64;
else
- fit_len = (fit_len + 32 ) & -64;
+ fit_len = ( fit_len + 32 ) & -64;
hint->cur_len = fit_len;
/* check blue zones for horizontal stems */
align.align = 0;
align.align_bot = align.align_top = 0;
- if (!vertical)
+ if ( !vertical )
{
psh_blues_snap_stem( &globals->blues,
- hint->org_pos + hint->org_len,
- hint->org_pos,
- &align );
+ hint->org_pos + hint->org_len,
+ hint->org_pos,
+ &align );
}
- switch (align.align)
+ switch ( align.align )
{
- case PSH_BLUE_ALIGN_TOP:
- {
- /* the top of the stem is aligned against a blue zone */
- hint->cur_pos = align.align_top - fit_len;
- break;
- }
-
- case PSH_BLUE_ALIGN_BOT:
- {
- /* the bottom of the stem is aligned against a blue zone */
- hint->cur_pos = align.align_bot;
- break;
- }
-
- case PSH_BLUE_ALIGN_TOP | PSH_BLUE_ALIGN_BOT:
- {
- /* both edges of the stem are aligned against blue zones */
- hint->cur_pos = align.align_bot;
- hint->cur_len = align.align_top - align.align_bot;
- }
- break;
+ case PSH_BLUE_ALIGN_TOP:
+ /* the top of the stem is aligned against a blue zone */
+ hint->cur_pos = align.align_top - fit_len;
+ break;
- default:
- /* normal processing */
- if ( (fit_len/64) & 1 )
- {
- /* odd number of pixels */
- fit_center = ((pos + (len >> 1)) & -64) + 32;
- }
- else
- {
- /* even number of pixels */
- fit_center = (pos + (len >> 1) + 32) & -64;
- }
-
- hint->cur_pos = fit_center - (fit_len >> 1);
+ case PSH_BLUE_ALIGN_BOT:
+ /* the bottom of the stem is aligned against a blue zone */
+ hint->cur_pos = align.align_bot;
+ break;
+
+ case PSH_BLUE_ALIGN_TOP | PSH_BLUE_ALIGN_BOT:
+ /* both edges of the stem are aligned against blue zones */
+ hint->cur_pos = align.align_bot;
+ hint->cur_len = align.align_top - align.align_bot;
+ break;
+
+ default:
+ /* normal processing */
+ if ( ( fit_len / 64 ) & 1 )
+ {
+ /* odd number of pixels */
+ fit_center = ( ( pos + ( len >> 1 ) ) & -64 ) + 32;
+ }
+ else
+ {
+ /* even number of pixels */
+ fit_center = ( pos + ( len >> 1 ) + 32 ) & -64;
+ }
+
+ hint->cur_pos = fit_center - ( fit_len >> 1 );
}
+
# else
- hint->cur_pos = (FT_MulFix( hint->org_pos, scale ) + delta + 32) & -64;
- hint->cur_len = FT_MulFix( hint->org_len, scale );
+
+ hint->cur_pos = ( FT_MulFix( hint->org_pos, scale ) + delta + 32 )
+ & -64;
+ hint->cur_len = FT_MulFix( hint->org_len, scale );
+
# endif
#ifdef DEBUG_HINTER
- if (ps1_debug_hint_func)
+ if ( ps1_debug_hint_func )
ps1_debug_hint_func( hint, vertical );
#endif
}
@@ -453,22 +477,20 @@
}
+ /*************************************************************************/
+ /*************************************************************************/
+ /***** *****/
+ /***** POINTS INTERPOLATION ROUTINES *****/
+ /***** *****/
+ /*************************************************************************/
+ /*************************************************************************/
-
- /************************************************************************/
- /************************************************************************/
- /***** *****/
- /***** POINTS INTERPOLATION ROUTINES *****/
- /***** *****/
- /************************************************************************/
- /************************************************************************/
-
-#define PSH1_ZONE_MIN -3200000
-#define PSH1_ZONE_MAX +3200000
-
+#define PSH1_ZONE_MIN -3200000
+#define PSH1_ZONE_MAX +3200000
#define xxDEBUG_ZONES
+
#ifdef DEBUG_ZONES
#include <stdio.h>
@@ -477,26 +499,27 @@
print_zone( PSH1_Zone zone )
{
printf( "zone [scale,delta,min,max] = [%.3f,%.3f,%d,%d]\n",
- zone->scale/65536.0,
- zone->delta/64.0,
+ zone->scale / 65536.0,
+ zone->delta / 64.0,
zone->min,
zone->max );
}
#else
-# define print_zone(x) do { } while (0)
+#define print_zone( x ) do { } while ( 0 )
#endif
- /* setup interpolation zones once the hints have been grid-fitted */
- /* by the optimizer.. */
+ /* setup interpolation zones once the hints have been grid-fitted */
+ /* by the optimizer */
static void
psh1_hint_table_setup_zones( PSH1_Hint_Table table,
FT_Fixed scale,
FT_Fixed delta )
{
- FT_UInt count;
- PSH1_Zone zone;
- PSH1_Hint *sort, hint, hint2;
+ FT_UInt count;
+ PSH1_Zone zone;
+ PSH1_Hint *sort, hint, hint2;
+
zone = table->zones;
@@ -513,10 +536,11 @@
return;
}
- /* the first zone is before the first hint */
+ /* the first zone is before the first hint */
/* x' = (x-x0)*s + x0' = x*s + ( x0' - x0*s ) */
- sort = table->sort;
- hint = sort[0];
+
+ sort = table->sort;
+ hint = sort[0];
zone->scale = scale;
zone->delta = hint->cur_pos - FT_MulFix( hint->org_pos, scale );
@@ -531,6 +555,7 @@
{
FT_Fixed scale2;
+
if ( hint->org_len > 0 )
{
/* setup a zone for inner-stem interpolation */
@@ -557,25 +582,28 @@
/* setup zone for inter-stem interpolation */
/* (x'-x1') = (x-x1)*(x2'-x1')/(x2-x1) */
/* x' = x*s3 + x1' - x1*s3 */
+
scale2 = FT_DivFix( hint2->cur_pos - (hint->cur_pos + hint->cur_len),
hint2->org_pos - (hint->org_pos + hint->org_len) );
zone->scale = scale2;
zone->min = hint->org_pos + hint->org_len;
zone->max = hint2->org_pos;
- zone->delta = hint->cur_pos + hint->cur_len - FT_MulFix( zone->min, scale2 );
+ zone->delta = hint->cur_pos + hint->cur_len -
+ FT_MulFix( zone->min, scale2 );
print_zone( zone );
zone++;
- hint = hint2;
+ hint = hint2;
}
/* the last zone */
zone->scale = scale;
zone->min = hint->org_pos + hint->org_len;
zone->max = PSH1_ZONE_MAX;
- zone->delta = hint->cur_pos + hint->cur_len - FT_MulFix( zone->min, scale );
+ zone->delta = hint->cur_pos + hint->cur_len -
+ FT_MulFix( zone->min, scale );
print_zone( zone );
@@ -586,13 +614,14 @@
}
- /* tune a single coordinate with the current interpolation zones */
+ /* tune a single coordinate with the current interpolation zones */
static FT_Pos
psh1_hint_table_tune_coord( PSH1_Hint_Table table,
FT_Int coord )
{
PSH1_Zone zone;
+
zone = table->zone;
if ( coord < zone->min )
@@ -603,8 +632,8 @@
break;
zone--;
- }
- while ( coord < zone->min );
+
+ } while ( coord < zone->min );
table->zone = zone;
}
else if ( coord > zone->max )
@@ -615,8 +644,8 @@
break;
zone++;
- }
- while ( coord > zone->max );
+
+ } while ( coord > zone->max );
table->zone = zone;
}
@@ -624,8 +653,8 @@
}
- /* tune a given outline with current interpolation zones */
- /* the function only works in a single dimension.. */
+ /* tune a given outline with current interpolation zones. */
+ /* The function only works in a single dimension. */
static void
psh1_hint_table_tune_outline( PSH1_Hint_Table table,
FT_Outline* outline,
@@ -636,15 +665,17 @@
FT_UInt count, first, last;
PS_Mask_Table hint_masks = table->hint_masks;
PS_Mask mask;
- PSH_Dimension dim = &globals->dimension[vertical];
+ PSH_Dimension dim = &globals->dimension[vertical];
FT_Fixed scale = dim->scale_mult;
FT_Fixed delta = dim->scale_delta;
+
if ( hint_masks && hint_masks->num_masks > 0 )
{
first = 0;
mask = hint_masks->masks;
count = hint_masks->num_masks;
+
for ( ; count > 0; count--, mask++ )
{
last = mask->end_point;
@@ -654,6 +685,7 @@
FT_Vector* vec;
FT_Int count2;
+
psh1_hint_table_activate_mask( table, mask );
psh1_hint_table_optimize( table, globals, outline, vertical );
psh1_hint_table_setup_zones( table, scale, delta );
@@ -661,10 +693,12 @@
vec = outline->points + first;
count2 = last - first;
+
for ( ; count2 > 0; count2--, vec++ )
{
FT_Pos x, *px;
+
px = vertical ? &vec->x : &vec->y;
x = *px;
@@ -679,6 +713,7 @@
{
FT_Vector* vec;
+
vec = outline->points;
count = outline->n_points;
@@ -696,13 +731,13 @@
}
- /************************************************************************/
- /************************************************************************/
- /***** *****/
- /***** HIGH-LEVEL INTERFACE *****/
- /***** *****/
- /************************************************************************/
- /************************************************************************/
+ /*************************************************************************/
+ /*************************************************************************/
+ /***** *****/
+ /***** HIGH-LEVEL INTERFACE *****/
+ /***** *****/
+ /*************************************************************************/
+ /*************************************************************************/
FT_Error
ps1_hints_apply( PS_Hints ps_hints,
@@ -713,18 +748,21 @@
FT_Error error = 0;
FT_Int dimension;
+
for ( dimension = 1; dimension >= 0; dimension-- )
{
PS_Dimension dim = &ps_hints->dimension[dimension];
- /* initialise hints table */
- memset( &hints, 0, sizeof(hints) );
+
+ /* initialize hints table */
+ memset( &hints, 0, sizeof ( hints ) );
error = psh1_hint_table_init( &hints,
&dim->hints,
&dim->masks,
&dim->counters,
ps_hints->memory );
- if (error) goto Exit;
+ if ( error )
+ goto Exit;
psh1_hint_table_tune_outline( &hints,
outline,
@@ -737,3 +775,6 @@
Exit:
return error;
}
+
+
+/* END */
diff --git a/src/pshinter/pshalgo1.h b/src/pshinter/pshalgo1.h
index 1b0dd5dc2..ed1031fd6 100644
--- a/src/pshinter/pshalgo1.h
+++ b/src/pshinter/pshalgo1.h
@@ -2,7 +2,7 @@
/* */
/* pshalgo1.h */
/* */
-/* First (basic) Postscript hinting routines */
+/* PostScript hinting algorithm 1 (specification). */
/* */
/* Copyright 2001 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
@@ -15,58 +15,61 @@
/* */
/***************************************************************************/
-#ifndef __PS_HINTER_ALGO1_H__
-#define __PS_HINTER_ALGO1_H__
+
+#ifndef __PSHALGO1_H__
+#define __PSHALGO1_H__
#include "pshrec.h"
FT_BEGIN_HEADER
- typedef struct PSH1_HintRec_* PSH1_Hint;
+ typedef struct PSH1_HintRec_* PSH1_Hint;
typedef enum
{
PSH1_HINT_FLAG_GHOST = PS_HINT_FLAG_GHOST,
PSH1_HINT_FLAG_BOTTOM = PS_HINT_FLAG_BOTTOM,
PSH1_HINT_FLAG_ACTIVE = 4
-
+
} PSH1_Hint_Flags;
-#define psh1_hint_is_active(x) (((x)->flags & PSH1_HINT_FLAG_ACTIVE) != 0)
-#define psh1_hint_is_ghost(x) (((x)->flags & PSH1_HINT_FLAG_GHOST ) != 0)
+#define psh1_hint_is_active( x ) \
+ ( ( (x)->flags & PSH1_HINT_FLAG_ACTIVE ) != 0 )
+#define psh1_hint_is_ghost( x ) \
+ ( ( (x)->flags & PSH1_HINT_FLAG_GHOST ) != 0 )
-#define psh1_hint_activate(x) (x)->flags |= PSH1_HINT_FLAG_ACTIVE
-#define psh1_hint_deactivate(x) (x)->flags &= ~PSH1_HINT_FLAG_ACTIVE
+#define psh1_hint_activate( x ) (x)->flags |= PSH1_HINT_FLAG_ACTIVE
+#define psh1_hint_deactivate( x ) (x)->flags &= ~PSH1_HINT_FLAG_ACTIVE
- typedef struct PSH1_HintRec_
+ typedef struct PSH1_HintRec_
{
- FT_Int org_pos;
- FT_Int org_len;
- FT_Pos cur_pos;
- FT_Pos cur_len;
-
- FT_UInt flags;
-
+ FT_Int org_pos;
+ FT_Int org_len;
+ FT_Pos cur_pos;
+ FT_Pos cur_len;
+
+ FT_UInt flags;
+
PSH1_Hint parent;
- FT_Int order;
-
+ FT_Int order;
+
} PSH1_HintRec;
- /* this is an interpolation zone used for strong points */
- /* weak points are interpolated according to their strong */
- /* neighbours.. */
- typedef struct PSH1_ZoneRec_
+ /* this is an interpolation zone used for strong points; */
+ /* weak points are interpolated according to their strong */
+ /* neighbours */
+ typedef struct PSH1_ZoneRec_
{
FT_Fixed scale;
FT_Fixed delta;
FT_Pos min;
FT_Pos max;
-
+
} PSH1_ZoneRec, *PSH1_Zone;
- typedef struct PSH1_Hint_TableRec_
+ typedef struct PSH1_Hint_TableRec_
{
FT_UInt max_hints;
FT_UInt num_hints;
@@ -78,23 +81,29 @@ FT_BEGIN_HEADER
PSH1_Zone zone;
PS_Mask_Table hint_masks;
PS_Mask_Table counter_masks;
-
+
} PSH1_Hint_TableRec, *PSH1_Hint_Table;
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 );
#ifdef DEBUG_HINTER
extern PSH1_Hint_Table ps1_debug_hint_table;
- typedef void (*PSH1_HintFunc)( PSH1_Hint hint, FT_Bool vertical );
- extern PSH1_HintFunc ps1_debug_hint_func;
+ typedef void
+ (*PSH1_HintFunc)( PSH1_Hint hint,
+ FT_Bool vertical );
+
+ extern PSH1_HintFunc ps1_debug_hint_func;
#endif
FT_END_HEADER
-#endif /* __PS_HINTER_FITTER_H__ */
+#endif /* __PSHALGO1_H__ */
+
+
+/* END */
diff --git a/src/pshinter/pshalgo2.c b/src/pshinter/pshalgo2.c
index 86ede1d3c..4bfd3553c 100644
--- a/src/pshinter/pshalgo2.c
+++ b/src/pshinter/pshalgo2.c
@@ -1,3 +1,21 @@
+/***************************************************************************/
+/* */
+/* pshalgo2.c */
+/* */
+/* PostScript hinting algorithm 2 (body). */
+/* */
+/* Copyright 2001 by */
+/* David Turner, Robert Wilhelm, and Werner Lemberg. */
+/* */
+/* This file is part of the FreeType project, and may only be used */
+/* modified and distributed under the terms of the FreeType project */
+/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
+/* this file you indicate that you have read the license and */
+/* understand and accept it fully. */
+/* */
+/***************************************************************************/
+
+
#include <ft2build.h>
#include FT_INTERNAL_OBJECTS_H
#include FT_INTERNAL_DEBUG_H
@@ -5,20 +23,21 @@
#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;
+ extern PSH2_Hint_Table ps2_debug_hint_table = 0;
+ extern PSH2_HintFunc ps2_debug_hint_func = 0;
+ extern PSH2_Glyph ps2_debug_glyph = 0;
#endif
- /************************************************************************/
- /************************************************************************/
- /***** *****/
- /***** BASIC HINTS RECORDINGS *****/
- /***** *****/
- /************************************************************************/
- /************************************************************************/
- /* return true iff two stem hints overlap */
+ /*************************************************************************/
+ /*************************************************************************/
+ /***** *****/
+ /***** BASIC HINTS RECORDINGS *****/
+ /***** *****/
+ /*************************************************************************/
+ /*************************************************************************/
+
+ /* return true iff two stem hints overlap */
static FT_Int
psh2_hint_overlap( PSH2_Hint hint1,
PSH2_Hint hint2 )
@@ -28,7 +47,7 @@
}
- /* destroy hints table */
+ /* destroy hints table */
static void
psh2_hint_table_done( PSH2_Hint_Table table,
FT_Memory memory )
@@ -45,28 +64,30 @@
}
- /* deactivate all hints in a table */
+ /* deactivate all hints in a table */
static void
psh2_hint_table_deactivate( PSH2_Hint_Table table )
{
FT_UInt count = table->max_hints;
PSH2_Hint hint = table->hints;
+
for ( ; count > 0; count--, hint++ )
{
- psh2_hint_deactivate(hint);
+ psh2_hint_deactivate( hint );
hint->order = -1;
}
}
- /* internal function used to record a new hint */
+ /* internal function used to record a new hint */
static void
psh2_hint_table_record( PSH2_Hint_Table table,
FT_UInt index )
{
PSH2_Hint hint = table->hints + index;
+
if ( index >= table->max_hints )
{
FT_ERROR(( "%s.activate: invalid hint index %d\n", index ));
@@ -74,18 +95,19 @@
}
/* ignore active hints */
- if ( psh2_hint_is_active(hint) )
+ if ( psh2_hint_is_active( hint ) )
return;
- psh2_hint_activate(hint);
+ psh2_hint_activate( hint );
/* now scan the current active hint set in order to determine */
- /* if we're overlapping with another segment.. */
+ /* if we are overlapping with another segment */
{
PSH2_Hint* sorted = table->sort_global;
FT_UInt count = table->num_hints;
PSH2_Hint hint2;
+
hint->parent = 0;
for ( ; count > 0; count--, sorted++ )
{
@@ -100,12 +122,10 @@
}
if ( table->num_hints < table->max_hints )
- table->sort_global[ table->num_hints++ ] = hint;
+ table->sort_global[table->num_hints++] = hint;
else
- {
- FT_ERROR(( "%s.activate: too many sorted hints !! BUG !!\n",
+ FT_ERROR(( "%s.activate: too many sorted hints! BUG!\n",
"ps.fitter" ));
- }
}
@@ -117,6 +137,7 @@
FT_Byte* cursor = hint_mask->bytes;
FT_UInt index, limit;
+
limit = hint_mask->num_bits;
for ( index = 0; index < limit; index++ )
@@ -135,7 +156,7 @@
}
- /* create hints table */
+ /* create hints table */
static FT_Error
psh2_hint_table_init( PSH2_Hint_Table table,
PS_Hint_Table hints,
@@ -146,12 +167,13 @@
FT_UInt count = hints->num_hints;
FT_Error error;
- FT_UNUSED(counter_masks);
+ FT_UNUSED( counter_masks );
+
/* allocate our tables */
- if ( ALLOC_ARRAY( table->sort, 2*count, PSH2_Hint ) ||
- ALLOC_ARRAY( table->hints, count, PSH2_HintRec ) ||
- ALLOC_ARRAY( table->zones, 2*count+1, PSH2_ZoneRec ) )
+ if ( ALLOC_ARRAY( table->sort, 2 * count, PSH2_Hint ) ||
+ ALLOC_ARRAY( table->hints, count, PSH2_HintRec ) ||
+ ALLOC_ARRAY( table->zones, 2 * count + 1, PSH2_ZoneRec ) )
goto Exit;
table->max_hints = count;
@@ -160,10 +182,11 @@
table->num_zones = 0;
table->zone = 0;
- /* now, initialise the "hints" array */
+ /* now, initialize the "hints" array */
{
PSH2_Hint write = table->hints;
- PS_Hint read = hints->hints;
+ PS_Hint read = hints->hints;
+
for ( ; count > 0; count--, write++, read++ )
{
@@ -173,28 +196,30 @@
}
}
- /* we now need to determine the initial "parent" stems, first */
+ /* we now need to determine the initial "parent" stems; first */
/* activate the hints that are given by the initial hint masks */
if ( hint_masks )
{
- FT_UInt count = hint_masks->num_masks;
- PS_Mask mask = hint_masks->masks;
+ FT_UInt Count = hint_masks->num_masks;
+ PS_Mask Mask = hint_masks->masks;
+
table->hint_masks = hint_masks;
- for ( ; count > 0; count--, mask++ )
- psh2_hint_table_record_mask( table, mask );
+ for ( ; Count > 0; Count--, Mask++ )
+ psh2_hint_table_record_mask( table, Mask );
}
/* now, do a linear parse in case some hints were left alone */
if ( table->num_hints != table->max_hints )
{
- FT_UInt index, count;
+ FT_UInt Index, Count;
- FT_ERROR(( "%s.init: missing/incorrect hint masks !!\n" ));
+
+ FT_ERROR(( "%s.init: missing/incorrect hint masks!\n" ));
count = table->max_hints;
- for ( index = 0; index < count; index++ )
- psh2_hint_table_record( table, index );
+ for ( Index = 0; Index < Count; Index++ )
+ psh2_hint_table_record( table, Index );
}
Exit:
@@ -202,7 +227,6 @@
}
-
static void
psh2_hint_table_activate_mask( PSH2_Hint_Table table,
PS_Mask hint_mask )
@@ -211,6 +235,7 @@
FT_Byte* cursor = hint_mask->bytes;
FT_UInt index, limit, count;
+
limit = hint_mask->num_bits;
count = 0;
@@ -228,7 +253,8 @@
{
PSH2_Hint hint = &table->hints[index];
- if ( !psh2_hint_is_active(hint) )
+
+ if ( !psh2_hint_is_active( hint ) )
{
FT_UInt count2;
@@ -240,10 +266,8 @@
{
hint2 = sort[0];
if ( psh2_hint_overlap( hint, hint2 ) )
- {
FT_ERROR(( "%s.activate_mask: found overlapping hints\n",
"psf.hint" ));
- }
}
#else
count2 = 0;
@@ -255,10 +279,8 @@
if ( count < table->max_hints )
table->sort[count++] = hint;
else
- {
FT_ERROR(( "%s.activate_mask: too many active hints\n",
"psf.hint" ));
- }
}
}
}
@@ -267,56 +289,53 @@
}
table->num_hints = count;
- /* now, sort the hints, they're guaranteed to not overlap */
- /* so we can compare their "org_pos" field directly.. */
+ /* now, sort the hints; they are guaranteed to not overlap */
+ /* so we can compare their "org_pos" field directly */
{
- FT_Int i1, i2;
+ FT_Int i1, i2;
PSH2_Hint hint1, hint2;
PSH2_Hint* sort = table->sort;
+
/* a simple bubble sort will do, since in 99% of cases, the hints */
- /* will be already sorted.. and the sort will be linear */
+ /* will be already sorted -- and the sort will be linear */
for ( i1 = 1; i1 < (FT_Int)count; i1++ )
{
hint1 = sort[i1];
- for ( i2 = i1-1; i2 >= 0; i2-- )
+ for ( i2 = i1 - 1; i2 >= 0; i2-- )
{
hint2 = sort[i2];
if ( hint2->org_pos < hint1->org_pos )
break;
- sort[i2+1] = hint2;
- sort[i2] = hint1;
+ sort[i2 + 1] = hint2;
+ sort[i2] = hint1;
}
}
}
}
-
-
-
-
-
- /************************************************************************/
- /************************************************************************/
- /***** *****/
- /***** HINTS GRID-FITTING AND OPTIMISATION *****/
- /***** *****/
- /************************************************************************/
- /************************************************************************/
+ /*************************************************************************/
+ /*************************************************************************/
+ /***** *****/
+ /***** HINTS GRID-FITTING AND OPTIMIZATION *****/
+ /***** *****/
+ /*************************************************************************/
+ /*************************************************************************/
#ifdef DEBUG_HINTER
static void
ps2_simple_scale( PSH2_Hint_Table table,
- FT_Fixed scale,
- FT_Fixed delta,
- FT_Int vertical )
+ FT_Fixed scale,
+ FT_Fixed delta,
+ FT_Int vertical )
{
PSH2_Hint hint;
FT_UInt count;
+
for ( count = 0; count < table->max_hints; count++ )
{
hint = table->hints + count;
@@ -324,7 +343,7 @@
hint->cur_pos = FT_MulFix( hint->org_pos, scale ) + delta;
hint->cur_len = FT_MulFix( hint->org_len, scale );
- if (ps2_debug_hint_func)
+ if ( ps2_debug_hint_func )
ps2_debug_hint_func( hint, vertical );
}
}
@@ -340,16 +359,18 @@
FT_Fixed scale = dim->scale_mult;
FT_Fixed delta = dim->scale_delta;
+
if ( !psh2_hint_is_fitted(hint) )
{
- FT_Pos pos = FT_MulFix( hint->org_pos, scale ) + delta;
- FT_Pos len = FT_MulFix( hint->org_len, scale );
+ FT_Pos pos = FT_MulFix( hint->org_pos, scale ) + delta;
+ FT_Pos len = FT_MulFix( hint->org_len, scale );
- FT_Pos fit_center;
- FT_Pos fit_len;
+ FT_Pos fit_center;
+ FT_Pos fit_len;
PSH_AlignmentRec align;
+
/* compute fitted width/height */
fit_len = 0;
if ( hint->org_len )
@@ -358,7 +379,7 @@
if ( fit_len < 64 )
fit_len = 64;
else
- fit_len = (fit_len + 32 ) & -64;
+ fit_len = ( fit_len + 32 ) & -64;
}
hint->cur_len = fit_len;
@@ -367,85 +388,79 @@
align.align = 0;
align.align_bot = align.align_top = 0;
- if (!vertical)
- {
+ if ( !vertical )
psh_blues_snap_stem( &globals->blues,
- hint->org_pos + hint->org_len,
- hint->org_pos,
- &align );
- }
+ hint->org_pos + hint->org_len,
+ hint->org_pos,
+ &align );
- switch (align.align)
+ switch ( align.align )
{
- case PSH_BLUE_ALIGN_TOP:
- {
- /* the top of the stem is aligned against a blue zone */
- hint->cur_pos = align.align_top - fit_len;
- break;
- }
+ case PSH_BLUE_ALIGN_TOP:
+ /* the top of the stem is aligned against a blue zone */
+ hint->cur_pos = align.align_top - fit_len;
+ break;
- case PSH_BLUE_ALIGN_BOT:
- {
- /* the bottom of the stem is aligned against a blue zone */
- hint->cur_pos = align.align_bot;
- break;
- }
+ case PSH_BLUE_ALIGN_BOT:
+ /* the bottom of the stem is aligned against a blue zone */
+ hint->cur_pos = align.align_bot;
+ break;
+
+ case PSH_BLUE_ALIGN_TOP | PSH_BLUE_ALIGN_BOT:
+ /* both edges of the stem are aligned against blue zones */
+ hint->cur_pos = align.align_bot;
+ hint->cur_len = align.align_top - align.align_bot;
+ break;
+
+ default:
+ {
+ PSH2_Hint parent = hint->parent;
- case PSH_BLUE_ALIGN_TOP | PSH_BLUE_ALIGN_BOT:
- {
- /* both edges of the stem are aligned against blue zones */
- hint->cur_pos = align.align_bot;
- hint->cur_len = align.align_top - align.align_bot;
- break;
- }
- default:
+ if ( parent )
{
- PSH2_Hint parent = hint->parent;
+ FT_Pos par_org_center, par_cur_center;
+ FT_Pos cur_org_center, cur_delta;
- if ( parent )
- {
- FT_Pos par_org_center, par_cur_center;
- FT_Pos cur_org_center, cur_delta;
- /* ensure that parent is already fitted */
- if ( !psh2_hint_is_fitted(parent) )
- psh2_hint_align( parent, globals, vertical );
+ /* ensure that parent is already fitted */
+ if ( !psh2_hint_is_fitted( parent ) )
+ psh2_hint_align( parent, globals, vertical );
- par_org_center = parent->org_pos + (parent->org_len/2);
- par_cur_center = parent->cur_pos + (parent->cur_len/2);
- cur_org_center = hint->org_pos + (hint->org_len/2);
+ par_org_center = parent->org_pos + ( parent->org_len / 2);
+ par_cur_center = parent->cur_pos + ( parent->cur_len / 2);
+ cur_org_center = hint->org_pos + ( hint->org_len / 2);
- cur_delta = FT_MulFix( cur_org_center - par_org_center, scale );
+ cur_delta = FT_MulFix( cur_org_center - par_org_center, scale );
#if 0
- if ( cur_delta >= 0 )
- cur_delta = (cur_delta+16) & -64;
- else
- cur_delta = -((-cur_delta+16) & -64);
-#endif
- pos = par_cur_center + cur_delta - (len >> 1);
- }
-
- /* normal processing */
- if ( (fit_len/64) & 1 )
- {
- /* odd number of pixels */
- fit_center = ((pos + (len >> 1)) & -64) + 32;
- }
+ if ( cur_delta >= 0 )
+ cur_delta = ( cur_delta + 16 ) & -64;
else
- {
- /* even number of pixels */
- fit_center = (pos + (len >> 1) + 32) & -64;
- }
+ cur_delta = -( (-cur_delta + 16 ) & -64 );
+#endif
+ pos = par_cur_center + cur_delta - ( len >> 1 );
+ }
- hint->cur_pos = fit_center - (fit_len >> 1);
+ /* normal processing */
+ if ( ( fit_len / 64 ) & 1 )
+ {
+ /* odd number of pixels */
+ fit_center = ( ( pos + ( len >> 1 ) ) & -64 ) + 32;
}
+ else
+ {
+ /* even number of pixels */
+ fit_center = ( pos + ( len >> 1 ) + 32 ) & -64;
+ }
+
+ hint->cur_pos = fit_center - ( fit_len >> 1 );
+ }
}
- psh2_hint_set_fitted(hint);
+ psh2_hint_set_fitted( hint );
#ifdef DEBUG_HINTER
- if (ps2_debug_hint_func)
+ if ( ps2_debug_hint_func )
ps2_debug_hint_func( hint, vertical );
#endif
}
@@ -465,6 +480,7 @@
FT_Fixed scale = dim->scale_mult;
FT_Fixed delta = dim->scale_delta;
+
if ( ps_debug_no_vert_hints && vertical )
{
ps2_simple_scale( table, scale, delta, vertical );
@@ -480,25 +496,26 @@
hint = table->hints;
count = table->max_hints;
+
for ( ; count > 0; count--, hint++ )
psh2_hint_align( hint, globals, vertical );
}
- /************************************************************************/
- /************************************************************************/
- /***** *****/
- /***** POINTS INTERPOLATION ROUTINES *****/
- /***** *****/
- /************************************************************************/
- /************************************************************************/
-
-#define PSH2_ZONE_MIN -3200000
-#define PSH2_ZONE_MAX +3200000
+ /*************************************************************************/
+ /*************************************************************************/
+ /***** *****/
+ /***** POINTS INTERPOLATION ROUTINES *****/
+ /***** *****/
+ /*************************************************************************/
+ /*************************************************************************/
+#define PSH2_ZONE_MIN -3200000
+#define PSH2_ZONE_MAX +3200000
#define xxDEBUG_ZONES
+
#ifdef DEBUG_ZONES
#include <stdio.h>
@@ -514,22 +531,25 @@
}
#else
-# define print_zone(x) do { } while (0)
+
+#define print_zone( x ) do { } while ( 0 )
+
#endif
#if 0
- /* setup interpolation zones once the hints have been grid-fitted */
- /* by the optimizer.. */
+ /* setup interpolation zones once the hints have been grid-fitted */
+ /* by the optimizer */
static void
psh2_hint_table_setup_zones( PSH2_Hint_Table table,
FT_Fixed scale,
FT_Fixed delta )
{
- FT_UInt count;
- PSH2_Zone zone;
- PSH2_Hint *sort, hint, hint2;
+ FT_UInt count;
+ PSH2_Zone zone;
+ PSH2_Hint *sort, hint, hint2;
- zone = table->zones;
+
+ zone = table->zones;
/* special case, no hints defined */
if ( table->num_hints == 0 )
@@ -546,8 +566,8 @@
/* the first zone is before the first hint */
/* x' = (x-x0)*s + x0' = x*s + ( x0' - x0*s ) */
- sort = table->sort;
- hint = sort[0];
+ sort = table->sort;
+ hint = sort[0];
zone->scale = scale;
zone->delta = hint->cur_pos - FT_MulFix( hint->org_pos, scale );
@@ -562,6 +582,7 @@
{
FT_Fixed scale2;
+
if ( hint->org_len > 0 )
{
/* setup a zone for inner-stem interpolation */
@@ -588,25 +609,28 @@
/* setup zone for inter-stem interpolation */
/* (x'-x1') = (x-x1)*(x2'-x1')/(x2-x1) */
/* x' = x*s3 + x1' - x1*s3 */
+
scale2 = FT_DivFix( hint2->cur_pos - (hint->cur_pos + hint->cur_len),
hint2->org_pos - (hint->org_pos + hint->org_len) );
zone->scale = scale2;
zone->min = hint->org_pos + hint->org_len;
zone->max = hint2->org_pos;
- zone->delta = hint->cur_pos + hint->cur_len - FT_MulFix( zone->min, scale2 );
+ zone->delta = hint->cur_pos + hint->cur_len -
+ FT_MulFix( zone->min, scale2 );
print_zone( zone );
zone++;
- hint = hint2;
+ hint = hint2;
}
/* the last zone */
zone->scale = scale;
zone->min = hint->org_pos + hint->org_len;
zone->max = PSH2_ZONE_MAX;
- zone->delta = hint->cur_pos + hint->cur_len - FT_MulFix( zone->min, scale );
+ zone->delta = hint->cur_pos + hint->cur_len -
+ FT_MulFix( zone->min, scale );
print_zone( zone );
@@ -618,13 +642,14 @@
#endif
#if 0
- /* tune a single coordinate with the current interpolation zones */
+ /* tune a single coordinate with the current interpolation zones */
static FT_Pos
psh2_hint_table_tune_coord( PSH2_Hint_Table table,
FT_Int coord )
{
PSH2_Zone zone;
+
zone = table->zone;
if ( coord < zone->min )
@@ -635,8 +660,8 @@
break;
zone--;
- }
- while ( coord < zone->min );
+
+ } while ( coord < zone->min );
table->zone = zone;
}
else if ( coord > zone->max )
@@ -647,8 +672,8 @@
break;
zone++;
- }
- while ( coord > zone->max );
+
+ } while ( coord > zone->max );
table->zone = zone;
}
@@ -673,11 +698,13 @@
FT_Fixed scale = dim->scale_mult;
FT_Fixed delta = dim->scale_delta;
+
if ( hint_masks && hint_masks->num_masks > 0 )
{
first = 0;
mask = hint_masks->masks;
count = hint_masks->num_masks;
+
for ( ; count > 0; count--, mask++ )
{
last = mask->end_point;
@@ -687,6 +714,7 @@
FT_Vector* vec;
FT_Int count2;
+
psh2_hint_table_activate_mask( table, mask );
psh2_hint_table_optimize( table, globals, outline, vertical );
psh2_hint_table_setup_zones( table, scale, delta );
@@ -694,10 +722,12 @@
vec = outline->points + first;
count2 = last - first;
+
for ( ; count2 > 0; count2--, vec++ )
{
FT_Pos x, *px;
+
px = vertical ? &vec->x : &vec->y;
x = *px;
@@ -712,6 +742,7 @@
{
FT_Vector* vec;
+
vec = outline->points;
count = outline->n_points;
@@ -729,13 +760,14 @@
}
#endif
- /************************************************************************/
- /************************************************************************/
- /***** *****/
- /***** HINTER GLYPH MANAGEMENT *****/
- /***** *****/
- /************************************************************************/
- /************************************************************************/
+
+ /*************************************************************************/
+ /*************************************************************************/
+ /***** *****/
+ /***** HINTER GLYPH MANAGEMENT *****/
+ /***** *****/
+ /*************************************************************************/
+ /*************************************************************************/
static int
psh2_point_is_extremum( PSH2_Point point )
@@ -745,6 +777,7 @@
FT_Pos d_before;
FT_Pos d_after;
+
do
{
before = before->prev;
@@ -752,8 +785,8 @@
return 0;
d_before = before->org_u - point->org_u;
- }
- while ( d_before == 0 );
+
+ } while ( d_before == 0 );
do
{
@@ -762,20 +795,20 @@
return 0;
d_after = after->org_u - point->org_u;
- }
- while ( d_after == 0 );
+
+ } while ( d_after == 0 );
return ( ( d_before > 0 && d_after > 0 ) ||
( d_before < 0 && d_after < 0 ) );
}
-
static void
psh2_glyph_done( PSH2_Glyph glyph )
{
FT_Memory memory = glyph->memory;
+
psh2_hint_table_done( &glyph->hint_tables[1], memory );
psh2_hint_table_done( &glyph->hint_tables[0], memory );
@@ -790,24 +823,27 @@
static int
- psh2_compute_dir( FT_Pos dx, FT_Pos dy )
+ psh2_compute_dir( FT_Pos dx,
+ FT_Pos dy )
{
FT_Pos ax, ay;
int result = PSH2_DIR_NONE;
+
ax = ( dx >= 0 ) ? dx : -dx;
ay = ( dy >= 0 ) ? dy : -dy;
- if ( ay*12 < ax )
+ if ( ay * 12 < ax )
{
/* |dy| <<< |dx| means a near-horizontal segment */
result = ( dx >= 0 ) ? PSH2_DIR_RIGHT : PSH2_DIR_LEFT;
}
- else if ( ax*12 < ay )
+ else if ( ax * 12 < ay )
{
/* |dx| <<< |dy| means a near-vertical segment */
result = ( dy >= 0 ) ? PSH2_DIR_UP : PSH2_DIR_DOWN;
}
+
return result;
}
@@ -821,14 +857,17 @@
FT_Error error;
FT_Memory memory;
+
/* clear all fields */
- memset( glyph, 0, sizeof(*glyph) );
+ memset( glyph, 0, sizeof ( *glyph ) );
memory = globals->memory;
/* allocate and setup points + contours arrays */
- if ( ALLOC_ARRAY( glyph->points, outline->n_points, PSH2_PointRec ) ||
- ALLOC_ARRAY( glyph->contours, outline->n_contours, PSH2_ContourRec ) )
+ if ( ALLOC_ARRAY( glyph->points, outline->n_points,
+ PSH2_PointRec ) ||
+ ALLOC_ARRAY( glyph->contours, outline->n_contours,
+ PSH2_ContourRec ) )
goto Exit;
glyph->num_points = outline->n_points;
@@ -839,11 +878,13 @@
PSH2_Point points = glyph->points;
PSH2_Contour contour = glyph->contours;
+
for ( n = 0; n < glyph->num_contours; n++ )
{
FT_Int count;
PSH2_Point point;
+
next = outline->contours[n] + 1;
count = next - first;
@@ -856,6 +897,7 @@
point->prev = points + next - 1;
point->contour = contour;
+
for ( ; count > 1; count-- )
{
point[0].next = point + 1;
@@ -877,30 +919,30 @@
FT_Vector* vec = outline->points;
FT_UInt n;
+
for ( n = 0; n < glyph->num_points; n++, point++ )
{
- FT_Int n_prev = point->prev - points;
- FT_Int n_next = point->next - points;
- FT_Pos dxi, dyi, dxo, dyo;
+ FT_Int n_prev = point->prev - points;
+ FT_Int n_next = point->next - points;
+ 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;
dyi = vec[n].y - vec[n_prev].y;
- point->dir_in = (FT_Char) psh2_compute_dir( dxi, dyi );
+ point->dir_in = (FT_Char)psh2_compute_dir( dxi, dyi );
dxo = vec[n_next].x - vec[n].x;
dyo = vec[n_next].y - vec[n].y;
- point->dir_out = (FT_Char) psh2_compute_dir( dxo, dyo );
+ point->dir_out = (FT_Char)psh2_compute_dir( dxo, dyo );
/* detect smooth points */
if ( point->flags & PSH2_POINT_OFF )
- {
point->flags |= PSH2_POINT_SMOOTH;
- }
else if ( point->dir_in != PSH2_DIR_NONE ||
point->dir_out != PSH2_DIR_NONE )
{
@@ -911,6 +953,7 @@
{
FT_Angle angle_in, angle_out, diff;
+
angle_in = FT_Atan2( dxi, dyi );
angle_out = FT_Atan2( dxo, dyo );
@@ -921,7 +964,7 @@
if ( diff > FT_ANGLE_PI )
diff = FT_ANGLE_2PI - diff;
- if ( (diff < FT_ANGLE_PI/16) )
+ if ( diff < FT_ANGLE_PI / 16 )
point->flags |= PSH2_POINT_SMOOTH;
}
}
@@ -937,21 +980,23 @@
&ps_hints->dimension[0].masks,
&ps_hints->dimension[0].counters,
memory );
- if (error) goto Exit;
+ if ( error )
+ goto Exit;
error = psh2_hint_table_init( &glyph->hint_tables [1],
&ps_hints->dimension[1].hints,
&ps_hints->dimension[1].masks,
&ps_hints->dimension[1].counters,
memory );
- if (error) goto Exit;
+ if ( error )
+ goto Exit;
Exit:
return error;
}
- /* load outline point coordinates into hinter glyph */
+ /* load outline point coordinates into hinter glyph */
static void
psh2_glyph_load_points( PSH2_Glyph glyph,
FT_Int vertical )
@@ -960,24 +1005,25 @@
PSH2_Point point = glyph->points;
FT_UInt count = glyph->num_points;
+
for ( ; count > 0; count--, point++, vec++ )
{
point->flags &= PSH2_POINT_OFF | PSH2_POINT_SMOOTH;
point->hint = 0;
- if (vertical)
+ if ( vertical )
point->org_u = vec->x;
else
point->org_u = vec->y;
#ifdef DEBUG_HINTER
- point->org_x = vec->x;
- point->org_y = vec->y;
+ point->org_x = vec->x;
+ point->org_y = vec->y;
#endif
}
}
- /* save hinted point coordinates back to outline */
+ /* save hinted point coordinates back to outline */
static void
psh2_glyph_save_points( PSH2_Glyph glyph,
FT_Int vertical )
@@ -987,18 +1033,19 @@
FT_Vector* vec = glyph->outline->points;
char* tags = glyph->outline->tags;
+
for ( n = 0; n < glyph->num_points; n++ )
{
- if (vertical)
+ if ( vertical )
vec[n].x = point->cur_u;
else
vec[n].y = point->cur_u;
- if ( psh2_point_is_strong(point) )
+ if ( psh2_point_is_strong( point ) )
tags[n] |= vertical ? 32 : 64;
#ifdef DEBUG_HINTER
- if (vertical)
+ if ( vertical )
{
point->cur_x = point->cur_u;
point->flags_x = point->flags;
@@ -1014,7 +1061,8 @@
}
-#define PSH2_STRONG_THRESHOLD 10
+#define PSH2_STRONG_THRESHOLD 10
+
static void
psh2_hint_table_find_strong_point( PSH2_Hint_Table table,
@@ -1024,26 +1072,29 @@
PSH2_Hint* sort = table->sort;
FT_UInt num_hints = table->num_hints;
+
for ( ; num_hints > 0; num_hints--, sort++ )
{
PSH2_Hint hint = sort[0];
- if ( ABS(point->dir_in) == major_dir ||
- ABS(point->dir_out) == major_dir )
+
+ if ( ABS( point->dir_in ) == major_dir ||
+ ABS( point->dir_out ) == major_dir )
{
FT_Pos d;
+
d = point->org_u - hint->org_pos;
- if ( ABS(d) < PSH2_STRONG_THRESHOLD )
+ if ( ABS( d ) < PSH2_STRONG_THRESHOLD )
{
Is_Strong:
- psh2_point_set_strong(point);
+ psh2_point_set_strong( point );
point->hint = hint;
break;
}
d -= hint->org_len;
- if ( ABS(d) < PSH2_STRONG_THRESHOLD )
+ if ( ABS( d ) < PSH2_STRONG_THRESHOLD )
goto Is_Strong;
}
@@ -1061,8 +1112,7 @@
}
-
- /* find strong points in a glyph */
+ /* find strong points in a glyph */
static void
psh2_glyph_find_strong_points( PSH2_Glyph glyph,
FT_Int vertical )
@@ -1076,6 +1126,7 @@
FT_UInt first = 0;
FT_Int major_dir = vertical ? PSH2_DIR_UP : PSH2_DIR_RIGHT;
+
/* process secondary hints to "selected" points */
if ( num_masks > 1 )
{
@@ -1085,12 +1136,14 @@
FT_UInt next;
FT_Int count;
+
next = mask->end_point;
count = next - first;
if ( count > 0 )
{
PSH2_Point point = glyph->points + first;
+
psh2_hint_table_activate_mask( table, mask );
for ( ; count > 0; count--, point++ )
@@ -1106,30 +1159,31 @@
FT_UInt count = glyph->num_points;
PSH2_Point point = glyph->points;
+
psh2_hint_table_activate_mask( table, table->hint_masks->masks );
for ( ; count > 0; count--, point++ )
{
- if ( !psh2_point_is_strong(point) )
+ if ( !psh2_point_is_strong( point ) )
psh2_hint_table_find_strong_point( table, point, major_dir );
}
}
/* now, certain points may have been attached to hint and */
- /* not marked as strong, update their flags then.. */
+ /* not marked as strong; update their flags then */
{
FT_UInt count = glyph->num_points;
PSH2_Point point = glyph->points;
+
for ( ; count > 0; count--, point++ )
- if ( point->hint && !psh2_point_is_strong(point) )
- psh2_point_set_strong(point);
+ if ( point->hint && !psh2_point_is_strong( point ) )
+ psh2_point_set_strong( point );
}
}
}
-
- /* interpolate strong points with the help of hinted coordinates */
+ /* interpolate strong points with the help of hinted coordinates */
static void
psh2_glyph_interpolate_strong_points( PSH2_Glyph glyph,
FT_Int vertical )
@@ -1137,18 +1191,22 @@
PSH_Dimension dim = &glyph->globals->dimension[vertical];
FT_Fixed scale = dim->scale_mult;
+
{
FT_UInt count = glyph->num_points;
PSH2_Point point = glyph->points;
+
for ( ; count > 0; count--, point++ )
{
PSH2_Hint hint = point->hint;
+
if ( hint )
{
FT_Pos delta;
+
delta = point->org_u - hint->org_pos;
if ( delta <= 0 )
@@ -1164,7 +1222,7 @@
else
point->cur_u = hint->cur_pos;
- psh2_point_set_fitted(point);
+ psh2_point_set_fitted( point );
}
}
}
@@ -1179,18 +1237,20 @@
PSH_Dimension dim = &glyph->globals->dimension[vertical];
FT_Fixed scale = dim->scale_mult;
+
/* first technique: a point is strong if it is a local extrema */
{
FT_UInt count = glyph->num_points;
PSH2_Point point = glyph->points;
+
for ( ; count > 0; count--, point++ )
{
- if ( psh2_point_is_strong(point) )
+ if ( psh2_point_is_strong( point ) )
continue;
/* sometimes, some local extremas are smooth points */
- if ( psh2_point_is_smooth(point) )
+ if ( psh2_point_is_smooth( point ) )
{
if ( point->dir_in == PSH2_DIR_NONE ||
point->dir_in != point->dir_out )
@@ -1214,12 +1274,14 @@
FT_Int count2 = glyph->num_points;
PSH2_Point cur = glyph->points;
+
for ( ; count2 > 0; count2--, cur++ )
{
- if ( psh2_point_is_strong(cur) )
+ if ( psh2_point_is_strong( cur ) )
{
FT_Pos diff = cur->org_u - u;;
+
if ( diff <= 0 )
{
if ( diff > diff_before )
@@ -1244,15 +1306,15 @@
if ( !after )
continue;
- /* we're before the first strong point coordinate */
- /* simply translate the point.. */
+ /* we are before the first strong point coordinate; */
+ /* simply translate the point */
point->cur_u = after->cur_u +
FT_MulFix( point->org_u - after->org_u, scale );
}
else if ( !after )
{
- /* we're after the last strong point coordinate */
- /* simply translate the point.. */
+ /* we are after the last strong point coordinate; */
+ /* simply translate the point */
point->cur_u = before->cur_u +
FT_MulFix( point->org_u - before->org_u, scale );
}
@@ -1271,7 +1333,7 @@
after->org_u - before->org_u );
}
- psh2_point_set_fitted(point);
+ psh2_point_set_fitted( point );
}
}
}
@@ -1279,8 +1341,7 @@
}
-
- /* interpolate other points */
+ /* interpolate other points */
static void
psh2_glyph_interpolate_other_points( PSH2_Glyph glyph,
FT_Int vertical )
@@ -1291,19 +1352,21 @@
PSH2_Contour contour = glyph->contours;
FT_UInt num_contours = glyph->num_contours;
+
for ( ; num_contours > 0; num_contours--, contour++ )
{
PSH2_Point start = contour->start;
PSH2_Point first, next, point;
FT_UInt fit_count;
+
/* count the number of strong points in this contour */
next = start + contour->count;
fit_count = 0;
first = 0;
for ( point = start; point < next; point++ )
- if ( psh2_point_is_fitted(point) )
+ if ( psh2_point_is_fitted( point ) )
{
if ( !first )
first = point;
@@ -1311,8 +1374,8 @@
fit_count++;
}
- /* if there is less than 2 fitted points in the contour, we'll */
- /* simply scale and eventually translate the contour points */
+ /* if there are less than 2 fitted points in the contour, we */
+ /* simply scale and eventually translate the contour points */
if ( fit_count < 2 )
{
if ( fit_count == 1 )
@@ -1325,8 +1388,8 @@
goto Next_Contour;
}
- /* there are more than 2 strong points in this contour, we'll */
- /* need to interpolate weak points between them.. */
+ /* there are more than 2 strong points in this contour; we */
+ /* need to interpolate weak points between them */
start = first;
do
{
@@ -1339,7 +1402,7 @@
if ( next == start )
goto Next_Contour;
- if ( !psh2_point_is_fitted(next) )
+ if ( !psh2_point_is_fitted( next ) )
break;
first = next;
@@ -1349,7 +1412,7 @@
for (;;)
{
next = next->next;
- if ( psh2_point_is_fitted(next) )
+ if ( psh2_point_is_fitted( next ) )
break;
}
@@ -1359,6 +1422,7 @@
FT_Pos org_c, org_ac, cur_c;
FT_Fixed scale_ab;
+
if ( first->org_u <= next->org_u )
{
org_a = first->org_u;
@@ -1403,27 +1467,28 @@
point->cur_u = cur_c;
point = point->next;
- }
- while ( point != next );
+
+ } while ( point != next );
}
/* keep going until all points in the contours have been processed */
first = next;
- }
- while ( first != start );
+
+ } while ( first != start );
Next_Contour:
;
}
}
- /************************************************************************/
- /************************************************************************/
- /***** *****/
- /***** HIGH-LEVEL INTERFACE *****/
- /***** *****/
- /************************************************************************/
- /************************************************************************/
+
+ /*************************************************************************/
+ /*************************************************************************/
+ /***** *****/
+ /***** HIGH-LEVEL INTERFACE *****/
+ /***** *****/
+ /*************************************************************************/
+ /*************************************************************************/
FT_Error
ps2_hints_apply( PS_Hints ps_hints,
@@ -1436,11 +1501,11 @@
FT_Memory memory;
FT_Int dimension;
- memory = globals->memory;
-
FT_UNUSED(glyphrec);
+ memory = globals->memory;
+
#ifdef DEBUG_HINTER
if ( ps2_debug_glyph )
{
@@ -1448,7 +1513,7 @@
FREE( ps2_debug_glyph );
}
- if ( ALLOC( glyph, sizeof(*glyph) ) )
+ if ( ALLOC( glyph, sizeof ( *glyph ) ) )
return error;
ps2_debug_glyph = glyph;
@@ -1457,7 +1522,8 @@
#endif
error = psh2_glyph_init( glyph, outline, ps_hints, globals );
- if (error) goto Exit;
+ if ( error )
+ goto Exit;
for ( dimension = 1; dimension >= 0; dimension-- )
{
@@ -1485,3 +1551,6 @@
#endif
return error;
}
+
+
+/* END */
diff --git a/src/pshinter/pshalgo2.h b/src/pshinter/pshalgo2.h
index d043a650f..5d6a61ee7 100644
--- a/src/pshinter/pshalgo2.h
+++ b/src/pshinter/pshalgo2.h
@@ -2,7 +2,7 @@
/* */
/* pshalgo2.h */
/* */
-/* First (basic) Postscript hinting routines */
+/* PostScript hinting algorithm 2 (specification). */
/* */
/* Copyright 2001 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
@@ -15,16 +15,20 @@
/* */
/***************************************************************************/
-#ifndef __PS_HINTER_ALGO2_H__
-#define __PS_HINTER_ALGO2_H__
+
+#ifndef __PSHALGO2_H__
+#define __PSHALGO2_H__
+
#include "pshrec.h"
#include "pshglob.h"
#include FT_TRIGONOMETRY_H
+
FT_BEGIN_HEADER
- typedef struct PSH2_HintRec_* PSH2_Hint;
+
+ typedef struct PSH2_HintRec_* PSH2_Hint;
typedef enum
{
@@ -32,17 +36,20 @@ FT_BEGIN_HEADER
PSH2_HINT_BOTTOM = PS_HINT_FLAG_BOTTOM,
PSH2_HINT_ACTIVE = 4,
PSH2_HINT_FITTED = 8
+
} PSH2_Hint_Flags;
-#define psh2_hint_is_active(x) (((x)->flags & PSH2_HINT_ACTIVE) != 0)
-#define psh2_hint_is_ghost(x) (((x)->flags & PSH2_HINT_GHOST) != 0)
-#define psh2_hint_is_fitted(x) (((x)->flags & PSH2_HINT_FITTED) != 0)
-#define psh2_hint_activate(x) (x)->flags |= PSH2_HINT_ACTIVE
-#define psh2_hint_deactivate(x) (x)->flags &= ~PSH2_HINT_ACTIVE
-#define psh2_hint_set_fitted(x) (x)->flags |= PSH2_HINT_FITTED
+#define psh2_hint_is_active( x ) ( ( (x)->flags & PSH2_HINT_ACTIVE ) != 0 )
+#define psh2_hint_is_ghost( x ) ( ( (x)->flags & PSH2_HINT_GHOST ) != 0 )
+#define psh2_hint_is_fitted( x ) ( ( (x)->flags & PSH2_HINT_FITTED ) != 0 )
+
+#define psh2_hint_activate( x ) (x)->flags |= PSH2_HINT_ACTIVE
+#define psh2_hint_deactivate( x ) (x)->flags &= ~PSH2_HINT_ACTIVE
+#define psh2_hint_set_fitted( x ) (x)->flags |= PSH2_HINT_FITTED
+
- typedef struct PSH2_HintRec_
+ typedef struct PSH2_HintRec_
{
FT_Int org_pos;
FT_Int org_len;
@@ -55,10 +62,10 @@ FT_BEGIN_HEADER
} PSH2_HintRec;
- /* this is an interpolation zone used for strong points */
- /* weak points are interpolated according to their strong */
- /* neighbours.. */
- typedef struct PSH2_ZoneRec_
+ /* this is an interpolation zone used for strong points; */
+ /* weak points are interpolated according to their strong */
+ /* neighbours */
+ typedef struct PSH2_ZoneRec_
{
FT_Fixed scale;
FT_Fixed delta;
@@ -68,7 +75,7 @@ FT_BEGIN_HEADER
} PSH2_ZoneRec, *PSH2_Zone;
- typedef struct PSH2_Hint_TableRec_
+ typedef struct PSH2_Hint_TableRec_
{
FT_UInt max_hints;
FT_UInt num_hints;
@@ -89,11 +96,11 @@ FT_BEGIN_HEADER
enum
{
- PSH2_DIR_NONE = 4,
- PSH2_DIR_UP = 1,
- PSH2_DIR_DOWN = -1,
- PSH2_DIR_LEFT = -2,
- PSH2_DIR_RIGHT = 2
+ PSH2_DIR_NONE = 4,
+ PSH2_DIR_UP = 1,
+ PSH2_DIR_DOWN = -1,
+ PSH2_DIR_LEFT = -2,
+ PSH2_DIR_RIGHT = 2
};
enum
@@ -105,7 +112,7 @@ FT_BEGIN_HEADER
};
- typedef struct PSH2_PointRec_
+ typedef struct PSH2_PointRec_
{
PSH2_Point prev;
PSH2_Point next;
@@ -130,15 +137,16 @@ FT_BEGIN_HEADER
} PSH2_PointRec;
-#define psh2_point_is_strong(p) ((p)->flags & PSH2_POINT_STRONG)
-#define psh2_point_is_fitted(p) ((p)->flags & PSH2_POINT_FITTED)
-#define psh2_point_is_smooth(p) ((p)->flags & PSH2_POINT_SMOOTH)
+#define psh2_point_is_strong( p ) ( (p)->flags & PSH2_POINT_STRONG )
+#define psh2_point_is_fitted( p ) ( (p)->flags & PSH2_POINT_FITTED )
+#define psh2_point_is_smooth( p ) ( (p)->flags & PSH2_POINT_SMOOTH )
-#define psh2_point_set_strong(p) (p)->flags |= PSH2_POINT_STRONG
-#define psh2_point_set_fitted(p) (p)->flags |= PSH2_POINT_FITTED
-#define psh2_point_set_smooth(p) (p)->flags |= PSH2_POINT_SMOOTH
+#define psh2_point_set_strong( p ) (p)->flags |= PSH2_POINT_STRONG
+#define psh2_point_set_fitted( p ) (p)->flags |= PSH2_POINT_FITTED
+#define psh2_point_set_smooth( p ) (p)->flags |= PSH2_POINT_SMOOTH
- typedef struct PSH2_ContourRec_
+
+ typedef struct PSH2_ContourRec_
{
PSH2_Point start;
FT_UInt count;
@@ -146,8 +154,7 @@ FT_BEGIN_HEADER
} PSH2_ContourRec;
-
- typedef struct PSH2_GlyphRec_
+ typedef struct PSH2_GlyphRec_
{
FT_UInt num_points;
FT_UInt num_contours;
@@ -168,20 +175,28 @@ FT_BEGIN_HEADER
#ifdef DEBUG_HINTER
- extern PSH2_Hint_Table ps2_debug_hint_table;
+ extern PSH2_Hint_Table ps2_debug_hint_table;
- typedef void (*PSH2_HintFunc)( PSH2_Hint hint, FT_Bool vertical );
- extern PSH2_HintFunc ps2_debug_hint_func;
+ typedef void
+ (*PSH2_HintFunc)( PSH2_Hint hint,
+ FT_Bool vertical );
- extern PSH2_Glyph ps2_debug_glyph;
+ extern PSH2_HintFunc ps2_debug_hint_func;
+
+ extern PSH2_Glyph ps2_debug_glyph;
#endif
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_END_HEADER
-#endif /* __PS_HINTS_ALGO_2_H__ */
+
+#endif /* __PSHALGO2_H__ */
+
+
+/* END */
diff --git a/src/pshinter/pshglob.c b/src/pshinter/pshglob.c
index 7557f34db..7162d0aec 100644
--- a/src/pshinter/pshglob.c
+++ b/src/pshinter/pshglob.c
@@ -1,27 +1,45 @@
+/***************************************************************************/
+/* */
+/* pshglob.c */
+/* */
+/* PostScript hinter global hinting management (body). */
+/* Inspired by the new auto-hinter module. */
+/* */
+/* Copyright 2001 by */
+/* David Turner, Robert Wilhelm, and Werner Lemberg. */
+/* */
+/* This file is part of the FreeType project, and may only be used */
+/* modified and distributed under the terms of the FreeType project */
+/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
+/* this file you indicate that you have read the license and */
+/* understand and accept it fully. */
+/* */
+/***************************************************************************/
+
+
#include <ft2build.h>
#include FT_FREETYPE_H
#include FT_INTERNAL_OBJECTS_H
#include "pshglob.h"
#ifdef DEBUG_HINTER
- extern PSH_Globals ps_debug_globals = 0;
-#endif
+ extern PSH_Globals ps_debug_globals = 0;
+#endif
+
-/* "simple" ps hinter globals management, inspired from the new auto-hinter */
+ /*************************************************************************/
+ /*************************************************************************/
+ /***** *****/
+ /***** STANDARD WIDTHS *****/
+ /***** *****/
+ /*************************************************************************/
+ /*************************************************************************/
- /*************************************************************************/
- /*************************************************************************/
- /***** *****/
- /***** STANDARD WIDTHS *****/
- /***** *****/
- /*************************************************************************/
- /*************************************************************************/
-
- /* scale the widths/heights table */
+ /* scale the widths/heights table */
static void
- psh_globals_scale_widths( PSH_Globals globals,
- FT_UInt direction )
+ psh_globals_scale_widths( PSH_Globals globals,
+ FT_UInt direction )
{
PSH_Dimension dim = &globals->dimension[direction];
PSH_Widths std = &dim->std;
@@ -29,6 +47,7 @@
PSH_Width width = std->widths;
FT_Fixed scale = dim->scale_mult;
+
for ( ; count > 0; count--, width++ )
{
width->cur = FT_MulFix( width->org, scale );
@@ -37,8 +56,7 @@
}
-
- /* org_width is is font units, result in device pixels, 26.6 format */
+ /* org_width is is font units, result in device pixels, 26.6 format */
FT_LOCAL_DEF FT_Pos
psh_dimension_snap_width( PSH_Dimension dimension,
FT_Int org_width )
@@ -48,11 +66,13 @@
FT_Pos best = 64 + 32 + 2;
FT_Pos reference = width;
+
for ( n = 0; n < dimension->std.count; n++ )
{
FT_Pos w;
FT_Pos dist;
+
w = dimension->std.widths[n].cur;
dist = width - w;
if ( dist < 0 )
@@ -81,13 +101,13 @@
}
- /*************************************************************************/
- /*************************************************************************/
- /***** *****/
- /***** BLUE ZONES *****/
- /***** *****/
- /*************************************************************************/
- /*************************************************************************/
+ /*************************************************************************/
+ /*************************************************************************/
+ /***** *****/
+ /***** BLUE ZONES *****/
+ /***** *****/
+ /*************************************************************************/
+ /*************************************************************************/
static void
psh_blues_set_zones_0( PSH_Blues target,
@@ -97,19 +117,21 @@
PSH_Blue_Table top_table,
PSH_Blue_Table bot_table )
{
- FT_UInt count_top = top_table->count;
- FT_UInt count_bot = bot_table->count;
- FT_Bool first = 1;
+ FT_UInt count_top = top_table->count;
+ FT_UInt count_bot = bot_table->count;
+ FT_Bool first = 1;
+
+ FT_UNUSED( target );
+
- FT_UNUSED(target);
-
for ( ; read_count > 0; read_count -= 2 )
{
FT_Int reference, delta;
FT_UInt count;
PSH_Blue_Zone zones, zone;
FT_Bool top;
-
+
+
/* read blue zone entry, and select target top/bottom zone */
top = 0;
if ( first || is_others )
@@ -125,25 +147,26 @@
{
reference = read[0];
delta = read[1] - reference;
-
+
zones = top_table->zones;
count = count_top;
top = 1;
}
-
+
/* insert into sorted table */
- zone = zones;
+ zone = zones;
for ( ; count > 0; count--, zone++ )
{
if ( reference < zone->org_ref )
break;
-
+
if ( reference == zone->org_ref )
{
FT_Int delta0 = zone->org_delta;
- /* we have two zones on the same reference position */
- /* only keep the largest one.. */
+
+ /* we have two zones on the same reference position -- */
+ /* only keep the largest one */
if ( delta < 0 )
{
if ( delta < delta0 )
@@ -157,102 +180,109 @@
goto Skip;
}
}
-
+
for ( ; count > 0; count-- )
zone[count] = zone[count-1];
-
+
zone->org_ref = reference;
zone->org_delta = delta;
-
+
if ( top )
- count_top ++;
+ count_top++;
else
- count_bot ++;
-
+ count_bot++;
+
Skip:
read += 2;
- }
+ }
top_table->count = count_top;
bot_table->count = count_bot;
- }
+ }
- /* re-read blue zones from the original fonts, and store them into out */
- /* private structure. This function re-orders, sanitizes and fuzz-expands */
- /* the zones as well.. */
+ /* Re-read blue zones from the original fonts and store them into out */
+ /* private structure. This function re-orders, sanitizes and */
+ /* fuzz-expands the zones as well. */
static void
- psh_blues_set_zones( PSH_Blues target,
- FT_UInt count,
- FT_Short* blues,
- FT_UInt count_others,
- FT_Short* other_blues,
- FT_Int fuzz,
- FT_Int family )
+ psh_blues_set_zones( PSH_Blues target,
+ FT_UInt count,
+ FT_Short* blues,
+ FT_UInt count_others,
+ FT_Short* other_blues,
+ FT_Int fuzz,
+ FT_Int family )
{
PSH_Blue_Table top_table, bot_table;
FT_Int count_top, count_bot;
-
+
+
if ( family )
{
- top_table = &target->family_top;
- bot_table = &target->family_bottom;
+ top_table = &target->family_top;
+ bot_table = &target->family_bottom;
}
else
{
- top_table = &target->normal_top;
- bot_table = &target->normal_bottom;
+ top_table = &target->normal_top;
+ bot_table = &target->normal_bottom;
}
-
- /* read the input blue zones, and build two sorted tables */
- /* (one for the top zones, the other for the bottom zones */
+
+ /* read the input blue zones, and build two sorted tables */
+ /* (one for the top zones, the other for the bottom zones) */
top_table->count = 0;
bot_table->count = 0;
-
+
/* first, the blues */
- psh_blues_set_zones_0( target, 0, count, blues, top_table, bot_table );
- psh_blues_set_zones_0( target, 1, count_others, other_blues, top_table, bot_table );
-
+ psh_blues_set_zones_0( target, 0,
+ count, blues, top_table, bot_table );
+ psh_blues_set_zones_0( target, 1,
+ count_others, other_blues, top_table, bot_table );
+
count_top = top_table->count;
count_bot = bot_table->count;
-
+
/* sanitize top table */
if ( count_top > 0 )
{
PSH_Blue_Zone zone = top_table->zones;
-
+
+
for ( count = count_top; count > 0; count--, zone++ )
{
FT_Int delta;
-
+
+
if ( count > 1 )
{
delta = zone[1].org_ref - zone[0].org_ref;
if ( zone->org_delta > delta )
zone->org_delta = delta;
}
-
+
zone->org_bottom = zone->org_ref;
zone->org_top = zone->org_delta + zone->org_ref;
}
}
-
+
/* sanitize bottom table */
if ( count_bot > 0 )
{
PSH_Blue_Zone zone = bot_table->zones;
+
for ( count = count_bot; count > 0; count--, zone++ )
{
FT_Int delta;
-
+
+
if ( count > 1 )
{
delta = zone[0].org_ref - zone[1].org_ref;
if ( zone->org_delta < delta )
zone->org_delta = delta;
}
-
+
zone->org_top = zone->org_ref;
zone->org_bottom = zone->org_delta + zone->org_ref;
}
@@ -263,38 +293,38 @@
FT_Int dim, top, bot, delta;
PSH_Blue_Zone zone;
+
zone = top_table->zones;
count = count_top;
-
+
for ( dim = 1; dim >= 0; dim-- )
{
if ( count > 0 )
{
/* expand the bottom of the lowest zone normally */
zone->org_bottom -= fuzz;
-
- /* expand the top and bottom of intermediate zones */
+
+ /* expand the top and bottom of intermediate zones; */
/* checking that the interval is smaller than the fuzz */
top = zone->org_top;
-
+
for ( count--; count > 0; count-- )
{
bot = zone[1].org_bottom;
delta = bot - top;
- if ( delta < 2*fuzz )
- {
- zone[0].org_top = zone[1].org_bottom = top + delta/2;
- }
+
+ if ( delta < 2 * fuzz )
+ zone[0].org_top = zone[1].org_bottom = top + delta / 2;
else
{
zone[0].org_top = top + fuzz;
zone[1].org_bottom = bot - fuzz;
}
-
+
zone++;
top = zone->org_top;
}
-
+
/* expand the top of the highest zone normally */
zone->org_top = top + fuzz;
}
@@ -305,8 +335,7 @@
}
-
- /* reset the blues table when the device transform changes */
+ /* reset the blues table when the device transform changes */
static void
psh_blues_scale_zones( PSH_Blues blues,
FT_Fixed scale,
@@ -315,41 +344,51 @@
FT_UInt count;
FT_UInt num;
PSH_Blue_Table table = 0;
-
+
+
for ( num = 0; num < 4; num++ )
{
PSH_Blue_Zone zone;
-
- switch (num)
+
+
+ switch ( num )
{
- case 0: table = &blues->normal_top; break;
- case 1: table = &blues->normal_bottom; break;
- case 2: table = &blues->family_top; break;
- default: table = &blues->family_bottom;
+ case 0:
+ table = &blues->normal_top;
+ break;
+ case 1:
+ table = &blues->normal_bottom;
+ break;
+ case 2:
+ table = &blues->family_top;
+ break;
+ default:
+ table = &blues->family_bottom;
+ break;
}
-
+
zone = table->zones;
count = table->count;
for ( ; count > 0; count--, zone++ )
{
- zone->cur_top = FT_MulFix( zone->org_top, scale ) + delta;
+ zone->cur_top = FT_MulFix( zone->org_top, scale ) + delta;
zone->cur_bottom = FT_MulFix( zone->org_bottom, scale ) + delta;
- zone->cur_ref = FT_MulFix( zone->org_ref, scale ) + delta;
- zone->cur_delta = FT_MulFix( zone->org_delta, scale );
-
+ zone->cur_ref = FT_MulFix( zone->org_ref, scale ) + delta;
+ zone->cur_delta = FT_MulFix( zone->org_delta, scale );
+
/* round scaled reference position */
zone->cur_ref = ( zone->cur_ref + 32 ) & -64;
-#if 0
+#if 0
if ( zone->cur_ref > zone->cur_top )
zone->cur_ref -= 64;
else if ( zone->cur_ref < zone->cur_bottom )
zone->cur_ref += 64;
-#endif
+#endif
}
}
-
- /* XXX: we should process the family / normal tables here !! */
+
+ /* XXX: we should process the family / normal tables here! */
}
@@ -362,18 +401,20 @@
PSH_Blue_Table table;
FT_UInt count;
PSH_Blue_Zone zone;
-
+
+
alignment->align = 0;
-
+
/* lookup stem top in top zones table */
table = &blues->normal_top;
count = table->count;
zone = table->zones;
+
for ( ; count > 0; count--, zone++ )
{
if ( stem_top < zone->org_bottom )
break;
-
+
if ( stem_top <= zone->org_top )
{
alignment->align |= PSH_BLUE_ALIGN_TOP;
@@ -382,10 +423,11 @@
}
}
- /* lookup stem bottom in bottom zones table */
+ /* look up stem bottom in bottom zones table */
table = &blues->normal_bottom;
count = table->count;
zone = table->zones;
+
for ( ; count > 0; count--, zone++ )
{
if ( stem_bot < zone->org_bottom )
@@ -401,39 +443,40 @@
}
- /*************************************************************************/
- /*************************************************************************/
- /***** *****/
- /***** GLOBAL HINTS *****/
- /***** *****/
- /*************************************************************************/
- /*************************************************************************/
+ /*************************************************************************/
+ /*************************************************************************/
+ /***** *****/
+ /***** GLOBAL HINTS *****/
+ /***** *****/
+ /*************************************************************************/
+ /*************************************************************************/
static void
psh_globals_destroy( PSH_Globals globals )
{
- if (globals)
+ if ( globals )
{
FT_Memory memory;
-
+
+
memory = globals->memory;
globals->dimension[0].std.count = 0;
- globals->dimension[1].std.count = 0;
-
+ globals->dimension[1].std.count = 0;
+
globals->blues.normal_top.count = 0;
globals->blues.normal_bottom.count = 0;
globals->blues.family_top.count = 0;
globals->blues.family_bottom.count = 0;
-
+
FREE( globals );
#ifdef DEBUG_HINTER
ps_debug_globals = 0;
-#endif
+#endif
}
}
-
+
static FT_Error
psh_globals_new( FT_Memory memory,
T1_Private* priv,
@@ -441,22 +484,25 @@
{
PSH_Globals globals;
FT_Error error;
-
- if ( !ALLOC( globals, sizeof(*globals) ) )
+
+
+ if ( !ALLOC( globals, sizeof ( *globals ) ) )
{
FT_UInt count;
FT_Short* read;
-
+
+
globals->memory = memory;
- /* copy standard widths */
+ /* copy standard widths */
{
PSH_Dimension dim = &globals->dimension[1];
PSH_Width write = dim->std.widths;
-
+
+
write->org = priv->standard_width[1];
write++;
-
+
read = priv->snap_widths;
for ( count = priv->num_snap_widths; count > 0; count-- )
{
@@ -464,7 +510,7 @@
write++;
read++;
}
-
+
dim->std.count = write - dim->std.widths;
}
@@ -472,10 +518,11 @@
{
PSH_Dimension dim = &globals->dimension[0];
PSH_Width write = dim->std.widths;
-
+
+
write->org = priv->standard_height[1];
write++;
-
+
read = priv->snap_heights;
for ( count = priv->num_snap_heights; count > 0; count-- )
{
@@ -486,12 +533,12 @@
dim->std.count = write - dim->std.widths;
}
-
- /* copy blue zones */
+
+ /* copy blue zones */
psh_blues_set_zones( &globals->blues, priv->num_blue_values,
priv->blue_values, priv->num_other_blues,
priv->other_blues, priv->blue_fuzz, 0 );
-
+
psh_blues_set_zones( &globals->blues, priv->num_family_blues,
priv->family_blues, priv->num_family_other_blues,
priv->family_other_blues, priv->blue_fuzz, 1 );
@@ -503,31 +550,31 @@
#ifdef DEBUG_HINTER
ps_debug_globals = globals;
-#endif
+#endif
}
-
+
*aglobals = globals;
return error;
}
-
static FT_Error
- psh_globals_set_scale( PSH_Globals globals,
- FT_Fixed x_scale,
- FT_Fixed y_scale,
- FT_Fixed x_delta,
- FT_Fixed y_delta )
+ psh_globals_set_scale( PSH_Globals globals,
+ FT_Fixed x_scale,
+ FT_Fixed y_scale,
+ FT_Fixed x_delta,
+ FT_Fixed y_delta )
{
- PSH_Dimension dim = &globals->dimension[0];
-
+ PSH_Dimension dim = &globals->dimension[0];
+
+
dim = &globals->dimension[0];
if ( x_scale != dim->scale_mult ||
x_delta != dim->scale_delta )
{
dim->scale_mult = x_scale;
dim->scale_delta = x_delta;
-
+
psh_globals_scale_widths( globals, 0 );
}
@@ -553,3 +600,6 @@
funcs->set_scale = psh_globals_set_scale;
funcs->destroy = psh_globals_destroy;
}
+
+
+/* END */
diff --git a/src/pshinter/pshglob.h b/src/pshinter/pshglob.h
index 1ded0cb4c..b34f32f79 100644
--- a/src/pshinter/pshglob.h
+++ b/src/pshinter/pshglob.h
@@ -2,7 +2,7 @@
/* */
/* pshglob.h */
/* */
-/* Postscript hinter globals hints management. */
+/* PostScript hinter global hinting management. */
/* */
/* Copyright 2001 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
@@ -15,46 +15,54 @@
/* */
/***************************************************************************/
-#ifndef __PS_HINTER_GLOBALS_H__
-#define __PS_HINTER_GLOBALS_H__
+
+#ifndef __PSHGLOB_H__
+#define __PSHGLOB_H__
+
#include FT_FREETYPE_H
#include FT_INTERNAL_POSTSCRIPT_GLOBALS_H
#include FT_INTERNAL_POSTSCRIPT_HINTS_H
+
FT_BEGIN_HEADER
- /**********************************************************************/
- /**********************************************************************/
- /***** *****/
- /***** GLOBAL HINTS INTERNALS *****/
- /***** *****/
- /**********************************************************************/
- /**********************************************************************/
-
- /****************************************************************
- *
- * @constant: PS_GLOBALS_MAX_BLUE_ZONES
- *
- * @description:
- * the maximum number of blue zones in a font global hints
- * structure. See @PS_Globals_BluesRec
- */
-#define PS_GLOBALS_MAX_BLUE_ZONES 16
-
- /****************************************************************
- *
- * @constant: PS_GLOBALS_MAX_STD_WIDTHS
- *
- * @description:
- * the maximum number of standard and snap widths in either the
- * horizontal or vertical direction. See @PS_Globals_WidthsRec
- */
-#define PS_GLOBALS_MAX_STD_WIDTHS 16
-
-
- /* standard and snap width */
- typedef struct PSH_WidthRec_
+
+ /*************************************************************************/
+ /*************************************************************************/
+ /***** *****/
+ /***** GLOBAL HINTS INTERNALS *****/
+ /***** *****/
+ /*************************************************************************/
+ /*************************************************************************/
+
+
+ /*************************************************************************/
+ /* */
+ /* @constant: */
+ /* PS_GLOBALS_MAX_BLUE_ZONES */
+ /* */
+ /* @description: */
+ /* The maximum number of blue zones in a font global hints structure. */
+ /* See @PS_Globals_BluesRec. */
+ /* */
+#define PS_GLOBALS_MAX_BLUE_ZONES 16
+
+
+ /*************************************************************************/
+ /* */
+ /* @constant: */
+ /* PS_GLOBALS_MAX_STD_WIDTHS */
+ /* */
+ /* @description: */
+ /* The maximum number of standard and snap widths in either the */
+ /* horizontal or vertical direction. See @PS_Globals_WidthsRec. */
+ /* */
+#define PS_GLOBALS_MAX_STD_WIDTHS 16
+
+
+ /* standard and snap width */
+ typedef struct PSH_WidthRec_
{
FT_Int org;
FT_Pos cur;
@@ -63,51 +71,50 @@ FT_BEGIN_HEADER
} PSH_WidthRec, *PSH_Width;
- /* standard and snap widths table */
- typedef struct PSH_WidthsRec_
+ /* standard and snap widths table */
+ typedef struct PSH_WidthsRec_
{
FT_UInt count;
- PSH_WidthRec widths[ PS_GLOBALS_MAX_STD_WIDTHS ];
+ PSH_WidthRec widths[PS_GLOBALS_MAX_STD_WIDTHS];
} PSH_WidthsRec, *PSH_Widths;
- typedef struct PSH_DimensionRec_
+ typedef struct PSH_DimensionRec_
{
PSH_WidthsRec std;
FT_Fixed scale_mult;
FT_Fixed scale_delta;
-
- } PSH_DimensionRec, *PSH_Dimension;
+ } PSH_DimensionRec, *PSH_Dimension;
- /* blue zone descriptor */
- typedef struct PSH_Blue_ZoneRec_
+ /* blue zone descriptor */
+ typedef struct PSH_Blue_ZoneRec_
{
- FT_Int org_ref;
- FT_Int org_delta;
- FT_Int org_top;
- FT_Int org_bottom;
-
- FT_Pos cur_ref;
- FT_Pos cur_delta;
- FT_Pos cur_bottom;
- FT_Pos cur_top;
+ FT_Int org_ref;
+ FT_Int org_delta;
+ FT_Int org_top;
+ FT_Int org_bottom;
+
+ FT_Pos cur_ref;
+ FT_Pos cur_delta;
+ FT_Pos cur_bottom;
+ FT_Pos cur_top;
} PSH_Blue_ZoneRec, *PSH_Blue_Zone;
- typedef struct PSH_Blue_TableRec_
+ typedef struct PSH_Blue_TableRec_
{
FT_UInt count;
- PSH_Blue_ZoneRec zones[ PS_GLOBALS_MAX_BLUE_ZONES ];
-
+ PSH_Blue_ZoneRec zones[PS_GLOBALS_MAX_BLUE_ZONES];
+
} PSH_Blue_TableRec, *PSH_Blue_Table;
- /* blue zones table */
- typedef struct PSH_BluesRec_
+ /* blue zones table */
+ typedef struct PSH_BluesRec_
{
PSH_Blue_TableRec normal_top;
PSH_Blue_TableRec normal_bottom;
@@ -118,8 +125,8 @@ FT_BEGIN_HEADER
} PSH_BluesRec, *PSH_Blues;
- /* font globals */
- typedef struct PSH_GlobalsRec_
+ /* font globals */
+ typedef struct PSH_GlobalsRec_
{
FT_Memory memory;
PSH_DimensionRec dimension[2];
@@ -127,21 +134,21 @@ FT_BEGIN_HEADER
} PSH_GlobalsRec;
-
+
typedef enum
{
PSH_BLUE_ALIGN_TOP = 1,
PSH_BLUE_ALIGN_BOT = 2
-
+
} PSH_Blue_Align;
- typedef struct
+ typedef struct PSH_AlignmentRec_
{
- PSH_Blue_Align align;
- FT_Pos align_top;
- FT_Pos align_bot;
-
+ PSH_Blue_Align align;
+ FT_Pos align_top;
+ FT_Pos align_bot;
+
} PSH_AlignmentRec, *PSH_Alignment;
@@ -149,13 +156,13 @@ FT_BEGIN_HEADER
psh_globals_funcs_init( PSH_Globals_FuncsRec* funcs );
- /* snap a stem width to fitter coordinates. org_width is in font units */
- /* result is in device pixels (26.6 format).. */
+ /* snap a stem width to fitter coordinates. `org_width' is in font */
+ /* units. The result is in device pixels (26.6 format). */
FT_LOCAL FT_Pos
psh_dimension_snap_width( PSH_Dimension dimension,
FT_Int org_width );
- /* snap a stem to one or two blue zones */
+ /* snap a stem to one or two blue zones */
FT_LOCAL void
psh_blues_snap_stem( PSH_Blues blues,
FT_Int stem_top,
@@ -164,9 +171,14 @@ FT_BEGIN_HEADER
/* */
#ifdef DEBUG_HINTER
- extern PSH_Globals ps_debug_globals;
-#endif
+ extern PSH_Globals ps_debug_globals;
+#endif
+
FT_END_HEADER
-#endif /* __T1_FITTER_GLOBALS_H__ */
+
+#endif /* __PSHGLOB_H__ */
+
+
+/* END */
diff --git a/src/pshinter/pshinter.c b/src/pshinter/pshinter.c
index 07c63303c..6b991821b 100644
--- a/src/pshinter/pshinter.c
+++ b/src/pshinter/pshinter.c
@@ -2,9 +2,9 @@
/* */
/* pshinter.c */
/* */
-/* FreeType Postscript Hinting module */
+/* FreeType PostScript Hinting module */
/* */
-/* Copyright 1996-2000 by */
+/* Copyright 2001 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -19,9 +19,9 @@
#define FT_MAKE_OPTION_SINGLE_OBJECT
#include <ft2build.h>
-#include "pshrec.c"
+#include "pshrec.c"
#include "pshglob.c"
-#include "pshalgo1.c"
+#include "pshalgo1.c"
#include "pshalgo2.c"
#include "pshmod.c"
diff --git a/src/pshinter/pshmod.c b/src/pshinter/pshmod.c
index 30fa440ff..47d38baf7 100644
--- a/src/pshinter/pshmod.c
+++ b/src/pshinter/pshmod.c
@@ -2,9 +2,9 @@
/* */
/* pshmod.c */
/* */
-/* FreeType Postscript hinter module implementation (body). */
+/* FreeType PostScript hinter module implementation (body). */
/* */
-/* Copyright 2000 by */
+/* Copyright 2001 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -15,26 +15,28 @@
/* */
/***************************************************************************/
+
#include <ft2build.h>
#include FT_INTERNAL_OBJECTS_H
#include "pshrec.h"
#include "pshalgo.h"
- /* the Postscript Hinter module structure */
- typedef struct
+
+ /* the Postscript Hinter module structure */
+ typedef struct PS_Hinter_Module_Rec_
{
- FT_ModuleRec root;
- PS_HintsRec ps_hints;
+ FT_ModuleRec root;
+ PS_HintsRec ps_hints;
- PSH_Globals_FuncsRec globals_funcs;
- T1_Hints_FuncsRec t1_funcs;
- T2_Hints_FuncsRec t2_funcs;
+ PSH_Globals_FuncsRec globals_funcs;
+ T1_Hints_FuncsRec t1_funcs;
+ T2_Hints_FuncsRec t2_funcs;
} PS_Hinter_ModuleRec, *PS_Hinter_Module;
- /* finalize module */
- FT_CALLBACK_DEF(void)
+ /* finalize module */
+ FT_CALLBACK_DEF( void )
ps_hinter_done( PS_Hinter_Module module )
{
module->t1_funcs.hints = NULL;
@@ -44,51 +46,52 @@
}
- /* initialise module, create hints recorder and the interface */
- FT_CALLBACK_DEF(FT_Error)
+ /* initialize module, create hints recorder and the interface */
+ FT_CALLBACK_DEF( FT_Error )
ps_hinter_init( PS_Hinter_Module module )
{
FT_Memory memory = module->root.memory;
+
ps_hints_init( &module->ps_hints, memory );
psh_globals_funcs_init( &module->globals_funcs );
t1_hints_funcs_init( &module->t1_funcs );
- module->t1_funcs.hints = (T1_Hints) & module->ps_hints;
+ module->t1_funcs.hints = (T1_Hints)&module->ps_hints;
t2_hints_funcs_init( &module->t2_funcs );
- module->t2_funcs.hints = (T2_Hints) & module->ps_hints;
+ module->t2_funcs.hints = (T2_Hints)&module->ps_hints;
return 0;
}
- /* returns global hints interface */
- FT_CALLBACK_DEF(PSH_Globals_Funcs)
+ /* returns global hints interface */
+ FT_CALLBACK_DEF( PSH_Globals_Funcs )
pshinter_get_globals_funcs( FT_Module module )
{
return &((PS_Hinter_Module)module)->globals_funcs;
}
- /* return Type 1 hints interface */
- FT_CALLBACK_DEF(T1_Hints_Funcs)
+ /* return Type 1 hints interface */
+ FT_CALLBACK_DEF( T1_Hints_Funcs )
pshinter_get_t1_funcs( FT_Module module )
{
return &((PS_Hinter_Module)module)->t1_funcs;
}
- /* return Type 2 hints interface */
- FT_CALLBACK_DEF(T2_Hints_Funcs)
+ /* return Type 2 hints interface */
+ FT_CALLBACK_DEF( T2_Hints_Funcs )
pshinter_get_t2_funcs( FT_Module module )
{
return &((PS_Hinter_Module)module)->t2_funcs;
}
- FT_CALLBACK_DEF(PSHinter_Interface)
+ FT_CALLBACK_DEF( PSHinter_Interface )
pshinter_interface =
{
pshinter_get_globals_funcs,
@@ -101,14 +104,17 @@
const FT_Module_Class pshinter_module_class =
{
0,
- sizeof( PS_Hinter_ModuleRec ),
+ sizeof ( PS_Hinter_ModuleRec ),
"pshinter",
0x10000L,
0x20000L,
- &pshinter_interface, /* module-specific interface */
+ &pshinter_interface, /* module-specific interface */
- (FT_Module_Constructor) ps_hinter_init,
- (FT_Module_Destructor) ps_hinter_done,
- (FT_Module_Requester) 0 /* no additional interface for now */
+ (FT_Module_Constructor)ps_hinter_init,
+ (FT_Module_Destructor) ps_hinter_done,
+ (FT_Module_Requester) 0 /* no additional interface for now */
};
+
+
+/* END */
diff --git a/src/pshinter/pshmod.h b/src/pshinter/pshmod.h
index 6bda325cc..1a91025b2 100644
--- a/src/pshinter/pshmod.h
+++ b/src/pshinter/pshmod.h
@@ -2,9 +2,9 @@
/* */
/* pshmod.h */
/* */
-/* Postscript hinter module interface */
+/* PostScript hinter module interface (specification). */
/* */
-/* Copyright 1996-2000 by */
+/* Copyright 2001 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -15,8 +15,9 @@
/* */
/***************************************************************************/
-#ifndef __PS_HINTER_MODULE_H__
-#define __PS_HINTER_MODULE_H__
+
+#ifndef __PSHMOD_H__
+#define __PSHMOD_H__
#include <ft2build.h>
@@ -31,7 +32,8 @@ FT_BEGIN_HEADER
FT_END_HEADER
-#endif /* __PS_HINTER_MODULE_H__ */
+
+#endif /* __PSHMOD_H__ */
/* END */
diff --git a/src/pshinter/pshrec.c b/src/pshinter/pshrec.c
index 250d9c46c..c78d55258 100644
--- a/src/pshinter/pshrec.c
+++ b/src/pshinter/pshrec.c
@@ -1,3 +1,21 @@
+/***************************************************************************/
+/* */
+/* pshrec.c */
+/* */
+/* FreeType PostScript hints recorder (body). */
+/* */
+/* Copyright 2001 by */
+/* David Turner, Robert Wilhelm, and Werner Lemberg. */
+/* */
+/* This file is part of the FreeType project, and may only be used, */
+/* modified, and distributed under the terms of the FreeType project */
+/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
+/* this file you indicate that you have read the license and */
+/* understand and accept it fully. */
+/* */
+/***************************************************************************/
+
+
#include <ft2build.h>
#include FT_FREETYPE_H
#include FT_INTERNAL_OBJECTS_H
@@ -7,21 +25,21 @@
#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;
+ extern PS_Hints ps_debug_hints = 0;
+ extern int ps_debug_no_horz_hints = 0;
+ extern int ps_debug_no_vert_hints = 0;
#endif
- /***********************************************************************/
- /***********************************************************************/
- /***** *****/
- /***** PS_HINT MANAGEMENT *****/
- /***** *****/
- /***********************************************************************/
- /***********************************************************************/
+ /*************************************************************************/
+ /*************************************************************************/
+ /***** *****/
+ /***** PS_HINT MANAGEMENT *****/
+ /***** *****/
+ /*************************************************************************/
+ /*************************************************************************/
- /* destroy hints table */
+ /* destroy hints table */
static void
ps_hint_table_done( PS_Hint_Table table,
FT_Memory memory )
@@ -32,7 +50,7 @@
}
- /* ensure that a table can contain "count" elements */
+ /* ensure that a table can contain "count" elements */
static FT_Error
ps_hint_table_ensure( PS_Hint_Table table,
FT_UInt count,
@@ -42,6 +60,7 @@
FT_UInt new_max = count;
FT_Error error = 0;
+
if ( new_max > old_max )
{
/* try to grow the table */
@@ -62,16 +81,18 @@
FT_UInt count;
PS_Hint hint = 0;
+
count = table->num_hints;
count++;
if ( count >= table->max_hints )
{
error = ps_hint_table_ensure( table, count, memory );
- if (error) goto Exit;
+ if ( error )
+ goto Exit;
}
- hint = table->hints + count-1;
+ hint = table->hints + count - 1;
hint->pos = 0;
hint->len = 0;
hint->flags = 0;
@@ -84,15 +105,15 @@
}
- /***********************************************************************/
- /***********************************************************************/
- /***** *****/
- /***** PS_MASK MANAGEMENT *****/
- /***** *****/
- /***********************************************************************/
- /***********************************************************************/
+ /*************************************************************************/
+ /*************************************************************************/
+ /***** *****/
+ /***** PS_MASK MANAGEMENT *****/
+ /***** *****/
+ /*************************************************************************/
+ /*************************************************************************/
- /* destroy mask */
+ /* destroy mask */
static void
ps_mask_done( PS_Mask mask,
FT_Memory memory )
@@ -104,28 +125,28 @@
}
- /* ensure that a mask can contain "count" bits */
+ /* ensure that a mask can contain "count" bits */
static FT_Error
ps_mask_ensure( PS_Mask mask,
FT_UInt count,
FT_Memory memory )
{
- FT_UInt old_max = (mask->max_bits + 7) >> 3;
- FT_UInt new_max = (count + 7) >> 3;
+ FT_UInt old_max = ( mask->max_bits + 7 ) >> 3;
+ FT_UInt new_max = ( count + 7 ) >> 3;
FT_Error error = 0;
+
if ( new_max > old_max )
{
new_max = ( new_max + 7 ) & -8;
if ( !REALLOC_ARRAY( mask->bytes, old_max, new_max, FT_Byte ) )
- mask->max_bits = new_max*8;
+ mask->max_bits = new_max * 8;
}
return error;
}
-
- /* test a bit value in a given mask */
+ /* test a bit value in a given mask */
static FT_Int
ps_mask_test_bit( PS_Mask mask,
FT_Int index )
@@ -133,26 +154,27 @@
if ( (FT_UInt)index >= mask->num_bits )
return 0;
- return mask->bytes[index >> 3] & (0x80 >> (index & 7));
+ return mask->bytes[index >> 3] & ( 0x80 >> ( index & 7 ) );
}
- /* clear a given bit */
+ /* clear a given bit */
static void
ps_mask_clear_bit( PS_Mask mask,
FT_Int index )
{
FT_Byte* p;
+
if ( (FT_UInt)index >= mask->num_bits )
return;
- p = mask->bytes + (index >> 3);
- p[0] = (FT_Byte)( p[0] & ~(0x80 >> (index & 7)) );
+ p = mask->bytes + ( index >> 3 );
+ p[0] = (FT_Byte)( p[0] & ~( 0x80 >> ( index & 7 ) ) );
}
- /* set a given bit, eventually grow the mask */
+ /* set a given bit, possibly grow the mask */
static FT_Error
ps_mask_set_bit( PS_Mask mask,
FT_Int index,
@@ -161,26 +183,28 @@
FT_Error error = 0;
FT_Byte* p;
+
if ( index < 0 )
goto Exit;
if ( (FT_UInt)index >= mask->num_bits )
{
- error = ps_mask_ensure( mask, index+1, memory );
- if (error) goto Exit;
+ error = ps_mask_ensure( mask, index + 1, memory );
+ if ( error )
+ goto Exit;
- mask->num_bits = index+1;
+ mask->num_bits = index + 1;
}
- p = mask->bytes + (index >> 3);
- p[0] = (FT_Byte)( p[0] | (0x80 >> (index & 7)) );
+ p = mask->bytes + ( index >> 3 );
+ p[0] = (FT_Byte)( p[0] | ( 0x80 >> ( index & 7 ) ) );
Exit:
return error;
}
- /* destroy mask table */
+ /* destroy mask table */
static void
ps_mask_table_done( PS_Mask_Table table,
FT_Memory memory )
@@ -188,6 +212,7 @@
FT_UInt count = table->max_masks;
PS_Mask mask = table->masks;
+
for ( ; count > 0; count--, mask++ )
ps_mask_done( mask, memory );
@@ -197,7 +222,7 @@
}
- /* ensure that a mask table can contain "count" masks */
+ /* ensure that a mask table can contain "count" masks */
static FT_Error
ps_mask_table_ensure( PS_Mask_Table table,
FT_UInt count,
@@ -207,9 +232,10 @@
FT_UInt new_max = count;
FT_Error error = 0;
+
if ( new_max > old_max )
{
- new_max = (new_max+7) & -8;
+ new_max = ( new_max + 7 ) & -8;
if ( !REALLOC_ARRAY( table->masks, old_max, new_max, PS_MaskRec ) )
table->max_masks = new_max;
}
@@ -217,7 +243,7 @@
}
- /* allocate a new mask in a table */
+ /* allocate a new mask in a table */
static FT_Error
ps_mask_table_alloc( PS_Mask_Table table,
FT_Memory memory,
@@ -225,7 +251,8 @@
{
FT_UInt count;
FT_Error error = 0;
- PS_Mask mask = 0;
+ PS_Mask mask = 0;
+
count = table->num_masks;
count++;
@@ -233,7 +260,8 @@
if ( count > table->max_masks )
{
error = ps_mask_table_ensure( table, count, memory );
- if (error) goto Exit;
+ if ( error )
+ goto Exit;
}
mask = table->masks + count - 1;
@@ -247,7 +275,7 @@
}
- /* return last hint mask in a table, create one if the table is empty */
+ /* return last hint mask in a table, create one if the table is empty */
static FT_Error
ps_mask_table_last( PS_Mask_Table table,
FT_Memory memory,
@@ -257,14 +285,16 @@
FT_UInt count;
PS_Mask mask;
+
count = table->num_masks;
if ( count == 0 )
{
error = ps_mask_table_alloc( table, memory, &mask );
- if (error) goto Exit;
+ if ( error )
+ goto Exit;
}
else
- mask = table->masks + count-1;
+ mask = table->masks + count - 1;
Exit:
*amask = mask;
@@ -272,7 +302,7 @@
}
- /* set a new mask to a given bit range */
+ /* set a new mask to a given bit range */
static FT_Error
ps_mask_table_set_bits( PS_Mask_Table table,
FT_Byte* source,
@@ -283,23 +313,27 @@
FT_Error error = 0;
PS_Mask mask;
+
/* allocate new mask, and grow it to "bit_count" bits */
error = ps_mask_table_alloc( table, memory, &mask );
- if (error) goto Exit;
+ if ( error )
+ goto Exit;
error = ps_mask_ensure( mask, bit_count, memory );
- if (error) goto Exit;
+ if ( error )
+ goto Exit;
mask->num_bits = bit_count;
/* now, copy bits */
{
- FT_Byte* read = source + (bit_pos >> 3);
- FT_Int rmask = 0x80 >> (bit_pos & 7);
+ FT_Byte* read = source + ( bit_pos >> 3 );
+ FT_Int rmask = 0x80 >> ( bit_pos & 7 );
FT_Byte* write = mask->bytes;
FT_Int wmask = 0x80;
FT_Int val;
+
for ( ; bit_count > 0; bit_count-- )
{
val = write[0] & ~wmask;
@@ -307,7 +341,7 @@
if ( read[0] & rmask )
val |= wmask;
- write[0] = (FT_Byte) val;
+ write[0] = (FT_Byte)val;
rmask >>= 1;
if ( rmask == 0 )
@@ -330,20 +364,21 @@
}
- /* test wether two masks in a table intersect */
+ /* test whether two masks in a table intersect */
static FT_Int
ps_mask_table_test_intersect( PS_Mask_Table table,
FT_Int index1,
FT_Int index2 )
{
- PS_Mask mask1 = table->masks + index1;
- PS_Mask mask2 = table->masks + index2;
+ PS_Mask mask1 = table->masks + index1;
+ PS_Mask mask2 = table->masks + index2;
FT_Byte* p1 = mask1->bytes;
FT_Byte* p2 = mask2->bytes;
FT_UInt count1 = mask1->num_bits;
FT_UInt count2 = mask2->num_bits;
FT_UInt count;
+
count = ( count1 <= count2 ) ? count1 : count2;
for ( ; count >= 8; count -= 8 )
{
@@ -357,11 +392,11 @@
if ( count == 0 )
return 0;
- return ( p1[0] & p2[0] ) & ~(0xFF >> count);
+ return ( p1[0] & p2[0] ) & ~( 0xFF >> count );
}
- /* merge two masks, used by ps_mask_table_merge_all */
+ /* merge two masks, used by ps_mask_table_merge_all */
static FT_Error
ps_mask_table_merge( PS_Mask_Table table,
FT_Int index1,
@@ -371,6 +406,7 @@
FT_UInt temp;
FT_Error error = 0;
+
/* swap index1 and index2 so that index1 < index2 */
if ( index1 > index2 )
{
@@ -382,12 +418,13 @@
if ( index1 < index2 && index1 >= 0 && index2 < (FT_Int)table->num_masks )
{
/* we need to merge the bitsets of index1 and index2 with a */
- /* simple union.. */
- PS_Mask mask1 = table->masks + index1;
- PS_Mask mask2 = table->masks + index2;
- FT_UInt count1 = mask1->num_bits;
- FT_UInt count2 = mask2->num_bits;
- FT_Int delta;
+ /* simple union */
+ PS_Mask mask1 = table->masks + index1;
+ PS_Mask mask2 = table->masks + index2;
+ FT_UInt count1 = mask1->num_bits;
+ FT_UInt count2 = mask2->num_bits;
+ FT_Int delta;
+
if ( count2 > 0 )
{
@@ -395,21 +432,24 @@
FT_Byte* read;
FT_Byte* write;
+
/* if "count2" is greater than "count1", we need to grow the */
- /* first bitset, and clear the highest bits.. */
+ /* first bitset, and clear the highest bits */
if ( count2 > count1 )
{
error = ps_mask_ensure( mask1, count2, memory );
- if (error) goto Exit;
+ if ( error )
+ goto Exit;
for ( pos = count1; pos < count2; pos++ )
ps_mask_clear_bit( mask1, pos );
}
- /* merge (union) the bitsets */
+ /* merge (unite) the bitsets */
read = mask2->bytes;
write = mask1->bytes;
- pos = (FT_UInt)((count2+7) >> 3);
+ pos = (FT_UInt)( ( count2 + 7 ) >> 3 );
+
for ( ; pos > 0; pos-- )
{
write[0] = (FT_Byte)( write[0] | read[0] );
@@ -418,18 +458,19 @@
}
}
- /* now, remove "mask2" from the list, we need to keep the masks */
- /* sorted in order of importance, so move table elements.. */
+ /* Now, remove "mask2" from the list. We need to keep the masks */
+ /* sorted in order of importance, so move table elements. */
mask2->num_bits = 0;
mask2->end_point = 0;
- delta = table->num_masks-1 - index2; /* number of masks to move */
+ delta = table->num_masks - 1 - index2; /* number of masks to move */
if ( delta > 0 )
{
/* move to end of table for reuse */
PS_MaskRec dummy = *mask2;
- memmove( mask2, mask2+1, delta*sizeof(PS_MaskRec) );
+
+ memmove( mask2, mask2 + 1, delta * sizeof ( PS_MaskRec ) );
mask2[delta] = dummy;
}
@@ -439,13 +480,15 @@
else
FT_ERROR(( "%s: ignoring invalid indices (%d,%d)\n",
index1, index2 ));
+
Exit:
return error;
}
- /* try to merge all masks in a given table, this is used to merge */
- /* all counter masks into independent counter "paths" */
- /* */
+
+ /* Try to merge all masks in a given table. This is used to merge */
+ /* all counter masks into independent counter "paths". */
+ /* */
static FT_Error
ps_mask_table_merge_all( PS_Mask_Table table,
FT_Memory memory )
@@ -453,34 +496,37 @@
FT_Int index1, index2;
FT_Error error = 0;
- for ( index1 = table->num_masks-1; index1 > 0; index1-- )
+
+ for ( index1 = table->num_masks - 1; index1 > 0; index1-- )
{
- for ( index2 = index1-1; index2 >= 0; index2-- )
+ for ( index2 = index1 - 1; index2 >= 0; index2-- )
{
if ( ps_mask_table_test_intersect( table, index1, index2 ) )
{
error = ps_mask_table_merge( table, index2, index1, memory );
- if (error) goto Exit;
+ if ( error )
+ goto Exit;
break;
}
}
}
+
Exit:
return error;
}
- /***********************************************************************/
- /***********************************************************************/
- /***** *****/
- /***** PS_DIMENSION MANAGEMENT *****/
- /***** *****/
- /***********************************************************************/
- /***********************************************************************/
+ /*************************************************************************/
+ /*************************************************************************/
+ /***** *****/
+ /***** PS_DIMENSION MANAGEMENT *****/
+ /***** *****/
+ /*************************************************************************/
+ /*************************************************************************/
- /* finalize a given dimension */
+ /* finalize a given dimension */
static void
ps_dimension_done( PS_Dimension dimension,
FT_Memory memory )
@@ -491,7 +537,7 @@
}
- /* initialise a given dimension */
+ /* initialize a given dimension */
static void
ps_dimension_init( PS_Dimension dimension )
{
@@ -502,7 +548,8 @@
#if 0
- /* set a bit at a given index in the current hint mask */
+
+ /* set a bit at a given index in the current hint mask */
static FT_Error
ps_dimension_set_mask_bit( PS_Dimension dim,
FT_UInt index,
@@ -511,35 +558,39 @@
PS_Mask mask;
FT_Error error = 0;
+
/* get last hint mask */
error = ps_mask_table_last( &dim->masks, memory, &mask );
- if (error) goto Exit;
+ if ( error )
+ goto Exit;
error = ps_mask_set_bit( mask, index, memory );
Exit:
return error;
}
+
#endif
- /* set the end point in a mask, called from "End" & "Reset" methods */
+ /* set the end point in a mask, called from "End" & "Reset" methods */
static void
ps_dimension_end_mask( PS_Dimension dim,
FT_UInt end_point )
{
- FT_UInt count = dim->masks.num_masks;
- PS_Mask mask;
+ FT_UInt count = dim->masks.num_masks;
+ PS_Mask mask;
+
if ( count > 0 )
{
- mask = dim->masks.masks + count-1;
+ mask = dim->masks.masks + count - 1;
mask->end_point = end_point;
}
}
- /* set the end point in the current mask, then create a new empty one */
- /* (called by "Reset" method) */
+ /* set the end point in the current mask, then create a new empty one */
+ /* (called by "Reset" method) */
static FT_Error
ps_dimension_reset_mask( PS_Dimension dim,
FT_UInt end_point,
@@ -547,6 +598,7 @@
{
PS_Mask mask;
+
/* end current mask */
ps_dimension_end_mask( dim, end_point );
@@ -555,7 +607,7 @@
}
- /* set a new mask, called from the "T2Stem" method */
+ /* set a new mask, called from the "T2Stem" method */
static FT_Error
ps_dimension_set_mask_bits( PS_Dimension dim,
const FT_Byte* source,
@@ -566,20 +618,22 @@
{
FT_Error error = 0;
+
/* reset current mask, if any */
error = ps_dimension_reset_mask( dim, end_point, memory );
- if (error) goto Exit;
+ if ( error )
+ goto Exit;
/* set bits in new mask */
error = ps_mask_table_set_bits( &dim->masks, (FT_Byte*)source,
- source_pos, source_bits, memory );
+ source_pos, source_bits, memory );
+
Exit:
return error;
}
-
- /* add a new single stem (called from "T1Stem" method) */
+ /* add a new single stem (called from "T1Stem" method) */
static FT_Error
ps_dimension_add_t1stem( PS_Dimension dim,
FT_Int pos,
@@ -590,6 +644,7 @@
FT_Error error = 0;
FT_UInt flags = 0;
+
/* detect ghost stem */
if ( len < 0 )
{
@@ -602,15 +657,16 @@
len = 0;
}
- if (aindex)
+ if ( aindex )
*aindex = -1;
/* now, lookup stem in the current hints table */
{
- PS_Mask mask;
- FT_UInt index;
- FT_UInt max = dim->hints.num_hints;
- PS_Hint hint = dim->hints.hints;
+ PS_Mask mask;
+ FT_UInt index;
+ FT_UInt max = dim->hints.num_hints;
+ PS_Hint hint = dim->hints.hints;
+
for ( index = 0; index < max; index++, hint++ )
{
@@ -622,7 +678,8 @@
if ( index >= max )
{
error = ps_hint_table_alloc( &dim->hints, memory, &hint );
- if (error) goto Exit;
+ if ( error )
+ goto Exit;
hint->pos = pos;
hint->len = len;
@@ -631,20 +688,23 @@
/* now, store the hint in the current mask */
error = ps_mask_table_last( &dim->masks, memory, &mask );
- if (error) goto Exit;
+ if ( error )
+ goto Exit;
error = ps_mask_set_bit( mask, index, memory );
- if (error) goto Exit;
+ if ( error )
+ goto Exit;
if ( aindex )
*aindex = (FT_Int)index;
}
+
Exit:
return error;
}
- /* add a "hstem3/vstem3" counter to our dimension table */
+ /* add a "hstem3/vstem3" counter to our dimension table */
static FT_Error
ps_dimension_add_counter( PS_Dimension dim,
FT_Int hint1,
@@ -656,39 +716,44 @@
FT_UInt count = dim->counters.num_masks;
PS_Mask counter = dim->counters.masks;
+
/* try to find an existing counter mask that already uses */
- /* one of these stems here.. */
+ /* one of these stems here */
for ( ; count > 0; count--, counter++ )
{
if ( ps_mask_test_bit( counter, hint1 ) ||
ps_mask_test_bit( counter, hint2 ) ||
ps_mask_test_bit( counter, hint3 ) )
- break;
+ break;
}
/* creat a new counter when needed */
if ( count == 0 )
{
error = ps_mask_table_alloc( &dim->counters, memory, &counter );
- if (error) goto Exit;
+ if ( error )
+ goto Exit;
}
/* now, set the bits for our hints in the counter mask */
error = ps_mask_set_bit( counter, hint1, memory );
- if (error) goto Exit;
+ if ( error )
+ goto Exit;
error = ps_mask_set_bit( counter, hint2, memory );
- if (error) goto Exit;
+ if ( error )
+ goto Exit;
error = ps_mask_set_bit( counter, hint3, memory );
- if (error) goto Exit;
+ if ( error )
+ goto Exit;
Exit:
return error;
}
- /* end of recording session for a given dimension */
+ /* end of recording session for a given dimension */
static FT_Error
ps_dimension_end( PS_Dimension dim,
FT_UInt end_point,
@@ -701,22 +766,23 @@
return ps_mask_table_merge_all( &dim->counters, memory );
}
- /***********************************************************************/
- /***********************************************************************/
- /***** *****/
- /***** PS_RECORDER MANAGEMENT *****/
- /***** *****/
- /***********************************************************************/
- /***********************************************************************/
+ /*************************************************************************/
+ /*************************************************************************/
+ /***** *****/
+ /***** PS_RECORDER MANAGEMENT *****/
+ /***** *****/
+ /*************************************************************************/
+ /*************************************************************************/
- /* destroy hints */
+ /* destroy hints */
FT_LOCAL void
- ps_hints_done( PS_Hints hints )
+ ps_hints_done( PS_Hints hints )
{
FT_Memory memory = hints->memory;
+
ps_dimension_done( &hints->dimension[0], memory );
ps_dimension_done( &hints->dimension[1], memory );
@@ -724,44 +790,44 @@
hints->memory = 0;
}
+
FT_LOCAL FT_Error
- ps_hints_init( PS_Hints hints,
+ ps_hints_init( PS_Hints hints,
FT_Memory memory )
{
- memset( hints, 0, sizeof(*hints) );
+ memset( hints, 0, sizeof ( *hints ) );
hints->memory = memory;
return 0;
}
- /* initialise a hints for a new session */
+
+ /* initialize a hints for a new session */
static void
ps_hints_open( PS_Hints hints,
PS_Hint_Type hint_type )
{
- switch (hint_type)
+ switch ( hint_type )
{
- case PS_HINT_TYPE_1:
- case PS_HINT_TYPE_2:
- {
- hints->error = 0;
- hints->hint_type = hint_type;
+ case PS_HINT_TYPE_1:
+ case PS_HINT_TYPE_2:
+ hints->error = 0;
+ hints->hint_type = hint_type;
- ps_dimension_init( &hints->dimension[0] );
- ps_dimension_init( &hints->dimension[1] );
- }
- break;
+ ps_dimension_init( &hints->dimension[0] );
+ ps_dimension_init( &hints->dimension[1] );
+ break;
- default:
- hints->error = FT_Err_Invalid_Argument;
- hints->hint_type = hint_type;
+ default:
+ hints->error = FT_Err_Invalid_Argument;
+ hints->hint_type = hint_type;
- FT_ERROR(( "%s.init: invalid charstring type !!\n", "t1fitter.hints" ));
+ FT_ERROR(( "%s.init: invalid charstring type!\n", "pshrec.hints" ));
+ break;
}
}
-
- /* add one or more stems to the current hints table */
+ /* add one or more stems to the current hints table */
static void
ps_hints_stem( PS_Hints hints,
FT_Int dimension,
@@ -775,66 +841,70 @@
{
FT_ERROR(( "ps.hints.stem: invalid dimension (%d) used\n",
dimension ));
- dimension = (dimension != 0);
+ dimension = ( dimension != 0 );
}
/* record the stems in the current hints/masks table */
switch ( hints->hint_type )
{
- case PS_HINT_TYPE_1: /* Type 1 "hstem" or "vstem" operator */
- case PS_HINT_TYPE_2: /* Type 2 "hstem" or "vstem" operator */
+ case PS_HINT_TYPE_1: /* Type 1 "hstem" or "vstem" operator */
+ case PS_HINT_TYPE_2: /* Type 2 "hstem" or "vstem" operator */
+ {
+ PS_Dimension dim = &hints->dimension[dimension];
+
+
+ for ( ; count > 0; count--, stems += 2 )
{
- PS_Dimension dim = &hints->dimension[dimension];
+ FT_Error error;
+ FT_Memory memory = hints->memory;
+
- for ( ; count > 0; count--, stems += 2 )
+ error = ps_dimension_add_t1stem( dim, stems[0], stems[1],
+ memory, NULL );
+ if ( error )
{
- FT_Error error;
- FT_Memory memory = hints->memory;
-
- error = ps_dimension_add_t1stem( dim, stems[0], stems[1],
- memory, NULL );
- if (error)
- {
- FT_ERROR(( "t1f.hints.stem: could not add stem"
- " (%d,%d) to hints table\n", stems[0], stems[1] ));
-
- hints->error = error;
- return;
- };
+ FT_ERROR(( "ps.hints.stem: could not add stem"
+ " (%d,%d) to hints table\n", stems[0], stems[1] ));
+
+ hints->error = error;
+ return;
}
}
break;
+ }
default:
- FT_ERROR(( "t1f.hints.stem: called with invalid hint type (%d)\n",
+ FT_ERROR(( "ps.hints.stem: called with invalid hint type (%d)\n",
hints->hint_type ));
- ;
+ break;
}
}
}
- /* add one Type1 counter stem to the current hints table */
+ /* add one Type1 counter stem to the current hints table */
static void
ps_hints_t1stem3( PS_Hints hints,
FT_Int dimension,
FT_Long* stems )
{
- FT_Error error = 0;
+ FT_Error error = 0;
- if (!hints->error)
+
+ if ( !hints->error )
{
PS_Dimension dim;
FT_Memory memory = hints->memory;
FT_Int count;
FT_Int index[3];
+
/* limit "dimension" to 0..1 */
if ( dimension < 0 || dimension > 1 )
{
- FT_ERROR(( "t1f.hints.stem: invalid dimension (%d) used\n",
+ FT_ERROR(( "ps.hints.stem: invalid dimension (%d) used\n",
dimension ));
- dimension = (dimension != 0);
+ dimension = ( dimension != 0 );
}
dim = &hints->dimension[dimension];
@@ -846,18 +916,20 @@
for ( count = 0; count < 3; count++, stems += 2 )
{
error = ps_dimension_add_t1stem( dim, stems[0], stems[1],
- memory, &index[count] );
- if (error) goto Fail;
+ memory, &index[count] );
+ if ( error )
+ goto Fail;
}
/* now, add the hints to the counters table */
error = ps_dimension_add_counter( dim, index[0], index[1],
- index[2], memory );
- if (error) goto Fail;
+ index[2], memory );
+ if ( error )
+ goto Fail;
}
else
{
- FT_ERROR(( "t1f.hints.stem3: called with invalid hint type !!\n" ));
+ FT_ERROR(( "ps.hints.stem3: called with invalid hint type!\n" ));
error = FT_Err_Invalid_Argument;
goto Fail;
}
@@ -866,32 +938,35 @@
return;
Fail:
- FT_ERROR(( "t1f.hints.stem3: could not add counter stems to table\n" ));
+ FT_ERROR(( "ps.hints.stem3: could not add counter stems to table\n" ));
hints->error = error;
}
-
- /* reset hints (only with Type 1 hints) */
+ /* reset hints (only with Type 1 hints) */
static void
ps_hints_t1reset( PS_Hints hints,
FT_UInt end_point )
{
FT_Error error = 0;
+
if ( !hints->error )
{
FT_Memory memory = hints->memory;
+
if ( hints->hint_type == PS_HINT_TYPE_1 )
{
error = ps_dimension_reset_mask( &hints->dimension[0],
- end_point, memory );
- if (error) goto Fail;
+ end_point, memory );
+ if ( error )
+ goto Fail;
error = ps_dimension_reset_mask( &hints->dimension[1],
- end_point, memory );
- if (error) goto Fail;
+ end_point, memory );
+ if ( error )
+ goto Fail;
}
else
{
@@ -907,7 +982,7 @@
}
- /* Type2 "hintmask" operator, add a new hintmask to each direction */
+ /* Type2 "hintmask" operator, add a new hintmask to each direction */
static void
ps_hints_t2mask( PS_Hints hints,
FT_UInt end_point,
@@ -916,6 +991,7 @@
{
FT_Error error;
+
if ( !hints->error )
{
PS_Dimension dim = hints->dimension;
@@ -923,23 +999,26 @@
FT_UInt count1 = dim[0].hints.num_hints;
FT_UInt count2 = dim[1].hints.num_hints;
- /* check bit count, must be equal to current total hint count */
+
+ /* check bit count; must be equal to current total hint count */
if ( bit_count != count1 + count2 )
{
error = FT_Err_Invalid_Argument;
FT_ERROR(( "%s: called with invalid bitcount %d (instead of %d)\n",
- bit_count, count1+count2 ));
+ bit_count, count1 + count2 ));
goto Fail;
}
/* set-up new horizontal and vertical hint mask now */
error = ps_dimension_set_mask_bits( &dim[0], bytes, 0, count1,
end_point, memory );
- if (error) goto Fail;
+ if ( error )
+ goto Fail;
error = ps_dimension_set_mask_bits( &dim[1], bytes, count1, count2,
end_point, memory );
- if (error) goto Fail;
+ if ( error )
+ goto Fail;
}
return;
@@ -955,6 +1034,7 @@
{
FT_Error error;
+
if ( !hints->error )
{
PS_Dimension dim = hints->dimension;
@@ -962,23 +1042,26 @@
FT_UInt count1 = dim[0].hints.num_hints;
FT_UInt count2 = dim[1].hints.num_hints;
+
/* check bit count, must be equal to current total hint count */
if ( bit_count != count1 + count2 )
{
error = FT_Err_Invalid_Argument;
FT_ERROR(( "%s: called with invalid bitcount %d (instead of %d)\n",
- bit_count, count1+count2 ));
+ bit_count, count1 + count2 ));
goto Fail;
}
/* set-up new horizontal and vertical hint mask now */
error = ps_dimension_set_mask_bits( &dim[0], bytes, 0, count1,
- 0, memory );
- if (error) goto Fail;
+ 0, memory );
+ if ( error )
+ goto Fail;
error = ps_dimension_set_mask_bits( &dim[1], bytes, count1, count2,
- 0, memory );
- if (error) goto Fail;
+ 0, memory );
+ if ( error )
+ goto Fail;
}
return;
@@ -987,42 +1070,43 @@
}
-
- /* end recording session */
+ /* end recording session */
static FT_Error
ps_hints_close( PS_Hints hints,
FT_UInt end_point )
{
FT_Error error;
+
error = hints->error;
- if (!error)
+ if ( !error )
{
- FT_Error error;
- FT_Memory memory = hints->memory;
+ FT_Memory memory = hints->memory;
PS_Dimension dim = hints->dimension;
+
error = ps_dimension_end( &dim[0], end_point, memory );
- if (!error)
+ if ( !error )
{
error = ps_dimension_end( &dim[1], end_point, memory );
}
}
#ifdef DEBUG_HINTER
- if (!error)
+ if ( !error )
ps_debug_hints = hints;
#endif
return error;
}
- /***********************************************************************/
- /***********************************************************************/
- /***** *****/
- /***** TYPE 1 HINTS RECORDING INTERFACE *****/
- /***** *****/
- /***********************************************************************/
- /***********************************************************************/
+
+ /*************************************************************************/
+ /*************************************************************************/
+ /***** *****/
+ /***** TYPE 1 HINTS RECORDING INTERFACE *****/
+ /***** *****/
+ /*************************************************************************/
+ /*************************************************************************/
static void
t1_hints_open( T1_Hints hints )
@@ -1031,9 +1115,9 @@
}
static void
- t1_hints_stem( T1_Hints hints,
- FT_Int dimension,
- FT_Long* coords )
+ t1_hints_stem( T1_Hints hints,
+ FT_Int dimension,
+ FT_Long* coords )
{
ps_hints_stem( (PS_Hints)hints, dimension, 1, coords );
}
@@ -1042,25 +1126,24 @@
FT_LOCAL_DEF void
t1_hints_funcs_init( T1_Hints_FuncsRec* funcs )
{
- memset( (char*)funcs, 0, sizeof(*funcs) );
-
- funcs->open = (T1_Hints_OpenFunc) t1_hints_open;
- funcs->close = (T1_Hints_CloseFunc) ps_hints_close;
- funcs->stem = (T1_Hints_SetStemFunc) t1_hints_stem;
- funcs->stem3 = (T1_Hints_SetStem3Func) ps_hints_t1stem3;
- funcs->reset = (T1_Hints_ResetFunc) ps_hints_t1reset;
- funcs->apply = (T1_Hints_ApplyFunc) PS_HINTS_APPLY_FUNC;
+ memset( (char*)funcs, 0, sizeof ( *funcs ) );
+
+ funcs->open = (T1_Hints_OpenFunc) t1_hints_open;
+ funcs->close = (T1_Hints_CloseFunc) ps_hints_close;
+ funcs->stem = (T1_Hints_SetStemFunc) t1_hints_stem;
+ funcs->stem3 = (T1_Hints_SetStem3Func)ps_hints_t1stem3;
+ funcs->reset = (T1_Hints_ResetFunc) ps_hints_t1reset;
+ funcs->apply = (T1_Hints_ApplyFunc) PS_HINTS_APPLY_FUNC;
}
-
- /***********************************************************************/
- /***********************************************************************/
- /***** *****/
- /***** TYPE 2 HINTS RECORDING INTERFACE *****/
- /***** *****/
- /***********************************************************************/
- /***********************************************************************/
+ /*************************************************************************/
+ /*************************************************************************/
+ /***** *****/
+ /***** TYPE 2 HINTS RECORDING INTERFACE *****/
+ /***** *****/
+ /*************************************************************************/
+ /*************************************************************************/
static void
t2_hints_open( T2_Hints hints )
@@ -1068,15 +1151,17 @@
ps_hints_open( (PS_Hints)hints, PS_HINT_TYPE_2 );
}
+
static void
- t2_hints_stems( T2_Hints hints,
- FT_Int dimension,
- FT_Int count,
- FT_Fixed* coords )
+ t2_hints_stems( T2_Hints hints,
+ FT_Int dimension,
+ FT_Int count,
+ FT_Fixed* coords )
{
- FT_Long stems[32], n, total = count;
+ FT_Long stems[32], n, total = count;
+
- while (total > 0)
+ while ( total > 0 )
{
/* determine number of stems to write */
count = total;
@@ -1084,13 +1169,13 @@
count = 32;
/* compute integer stem position in font units */
- for ( n = 0; n < count*2; n++ )
- stems[n] = (coords[n] + 0x8000) >> 16;
+ for ( n = 0; n < count * 2; n++ )
+ stems[n] = ( coords[n] + 0x8000 ) >> 16;
/* add them to the current dimension */
ps_hints_stem( (PS_Hints)hints, dimension, count, stems );
- total -= (count >> 1);
+ total -= count >> 1;
}
}
@@ -1098,12 +1183,15 @@
FT_LOCAL_DEF void
t2_hints_funcs_init( T2_Hints_FuncsRec* funcs )
{
- memset( funcs, 0, sizeof(*funcs) );
-
- funcs->open = (T2_Hints_OpenFunc) t2_hints_open;
- funcs->close = (T2_Hints_CloseFunc) ps_hints_close;
- funcs->stems = (T2_Hints_StemsFunc) t2_hints_stems;
- funcs->hintmask = (T2_Hints_MaskFunc) ps_hints_t2mask;
- funcs->counter = (T2_Hints_CounterFunc) ps_hints_t2counter;
- funcs->apply = (T2_Hints_ApplyFunc) PS_HINTS_APPLY_FUNC;
+ memset( funcs, 0, sizeof ( *funcs ) );
+
+ funcs->open = (T2_Hints_OpenFunc) t2_hints_open;
+ funcs->close = (T2_Hints_CloseFunc) ps_hints_close;
+ funcs->stems = (T2_Hints_StemsFunc) t2_hints_stems;
+ funcs->hintmask= (T2_Hints_MaskFunc) ps_hints_t2mask;
+ funcs->counter = (T2_Hints_CounterFunc)ps_hints_t2counter;
+ funcs->apply = (T2_Hints_ApplyFunc) PS_HINTS_APPLY_FUNC;
}
+
+
+/* END */
diff --git a/src/pshinter/pshrec.h b/src/pshinter/pshrec.h
index cdcf05777..fb5309f65 100644
--- a/src/pshinter/pshrec.h
+++ b/src/pshinter/pshrec.h
@@ -2,7 +2,7 @@
/* */
/* pshrec.h */
/* */
-/* Postscript (Type1/Type2) hints recorder. */
+/* Postscript (Type1/Type2) hints recorder (specification). */
/* */
/* Copyright 2001 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
@@ -13,46 +13,54 @@
/* this file you indicate that you have read the license and */
/* understand and accept it fully. */
/* */
-/* */
-/* The functions defined here are called from the Type 1, CID and CFF */
-/* font drivers to record the hints of a given character/glyph. */
-/* */
-/* The hints are recorded in a unified format, and are later processed */
-/* by the "optimiser" and "fitter" to adjust the outlines to the pixel */
-/* grid. */
-/* */
/***************************************************************************/
-#ifndef __PS_HINTER_RECORD_H__
-#define __PS_HINTER_RECORD_H__
+
+ /**************************************************************************/
+ /* */
+ /* The functions defined here are called from the Type 1, CID and CFF */
+ /* font drivers to record the hints of a given character/glyph. */
+ /* */
+ /* The hints are recorded in a unified format, and are later processed */
+ /* by the "optimizer" and "fitter" to adjust the outlines to the pixel */
+ /* grid. */
+ /* */
+ /**************************************************************************/
+
+
+#ifndef __PSHREC_H__
+#define __PSHREC_H__
+
#include <ft2build.h>
#include FT_INTERNAL_POSTSCRIPT_HINTS_H
#include "pshglob.h"
+
FT_BEGIN_HEADER
- /**********************************************************************/
- /**********************************************************************/
- /***** *****/
- /***** GLYPH HINTS RECORDER INTERNALS *****/
- /***** *****/
- /**********************************************************************/
- /**********************************************************************/
-
- /* handle to hint record */
- typedef struct PS_HintRec_* PS_Hint;
-
- /* hint types */
- typedef enum
- {
- PS_HINT_TYPE_1 = 1,
- PS_HINT_TYPE_2 = 2
-
- } PS_Hint_Type;
-
-
- /* hint flags */
+
+ /*************************************************************************/
+ /*************************************************************************/
+ /***** *****/
+ /***** GLYPH HINTS RECORDER INTERNALS *****/
+ /***** *****/
+ /*************************************************************************/
+ /*************************************************************************/
+
+ /* handle to hint record */
+ typedef struct PS_HintRec_* PS_Hint;
+
+ /* hint types */
+ typedef enum
+ {
+ PS_HINT_TYPE_1 = 1,
+ PS_HINT_TYPE_2 = 2
+
+ } PS_Hint_Type;
+
+
+ /* hint flags */
typedef enum
{
PS_HINT_FLAG_GHOST = 1,
@@ -61,54 +69,54 @@ FT_BEGIN_HEADER
} PS_Hint_Flags;
- /* hint descriptor */
- typedef struct PS_HintRec_
+ /* hint descriptor */
+ typedef struct PS_HintRec_
{
- FT_Int pos;
- FT_Int len;
- FT_UInt flags;
+ FT_Int pos;
+ FT_Int len;
+ FT_UInt flags;
} PS_HintRec;
-#define ps_hint_is_active(x) ((x)->flags & PS_HINT_FLAG_ACTIVE)
-#define ps_hint_is_ghost(x) ((x)->flags & PS_HINT_FLAG_GHOST)
-#define ps_hint_is_bottom(x) ((x)->flags & PS_HINT_FLAG_BOTTOM)
+#define ps_hint_is_active( x ) ( (x)->flags & PS_HINT_FLAG_ACTIVE )
+#define ps_hint_is_ghost( x ) ( (x)->flags & PS_HINT_FLAG_GHOST )
+#define ps_hint_is_bottom( x ) ( (x)->flags & PS_HINT_FLAG_BOTTOM )
- /* hints table descriptor */
- typedef struct PS_Hint_TableRec_
+ /* hints table descriptor */
+ typedef struct PS_Hint_TableRec_
{
- FT_UInt num_hints;
- FT_UInt max_hints;
- PS_Hint hints;
+ FT_UInt num_hints;
+ FT_UInt max_hints;
+ PS_Hint hints;
} PS_Hint_TableRec, *PS_Hint_Table;
- /* hint and counter mask descriptor */
- typedef struct PS_MaskRec_
+ /* hint and counter mask descriptor */
+ typedef struct PS_MaskRec_
{
- FT_UInt num_bits;
- FT_UInt max_bits;
- FT_Byte* bytes;
- FT_UInt end_point;
+ FT_UInt num_bits;
+ FT_UInt max_bits;
+ FT_Byte* bytes;
+ FT_UInt end_point;
} PS_MaskRec, *PS_Mask;
- /* masks and counters table descriptor */
- typedef struct PS_Mask_TableRec_
+ /* masks and counters table descriptor */
+ typedef struct PS_Mask_TableRec_
{
- FT_UInt num_masks;
- FT_UInt max_masks;
- PS_Mask masks;
+ FT_UInt num_masks;
+ FT_UInt max_masks;
+ PS_Mask masks;
} PS_Mask_TableRec, *PS_Mask_Table;
/* dimension-specific hints descriptor */
- typedef struct PS_DimensionRec_
+ typedef struct PS_DimensionRec_
{
PS_Hint_TableRec hints;
PS_Mask_TableRec masks;
@@ -117,49 +125,54 @@ FT_BEGIN_HEADER
} PS_DimensionRec, *PS_Dimension;
- /* magic value used within PS_HintsRec */
+ /* magic value used within PS_HintsRec */
#define PS_HINTS_MAGIC 0x68696e74 /* "hint" */
- /* glyph hints descriptor */
- typedef struct PS_HintsRec_
+ /* glyph hints descriptor */
+ typedef struct PS_HintsRec_
{
- FT_Memory memory;
- FT_Error error;
- FT_UInt32 magic;
- PS_Hint_Type hint_type;
- PS_DimensionRec dimension[2];
+ FT_Memory memory;
+ FT_Error error;
+ FT_UInt32 magic;
+ PS_Hint_Type hint_type;
+ PS_DimensionRec dimension[2];
} PS_HintsRec, *PS_Hints;
- /* */
+ /* */
- /* initialise hints recorder */
+ /* initialize hints recorder */
FT_LOCAL FT_Error
ps_hints_init( PS_Hints hints,
FT_Memory memory );
- /* finalize hints recorder */
+ /* finalize hints recorder */
FT_LOCAL void
ps_hints_done( PS_Hints hints );
- /* initialise Type1 hints recorder interface */
+ /* initialize Type1 hints recorder interface */
FT_LOCAL void
t1_hints_funcs_init( T1_Hints_FuncsRec* funcs );
-
- /* initialise Type2 hints recorder interface */
+
+ /* initialize Type2 hints recorder interface */
FT_LOCAL void
t2_hints_funcs_init( T2_Hints_FuncsRec* funcs );
#ifdef DEBUG_HINTER
- extern PS_Hints ps_debug_hints;
- extern int ps_debug_no_horz_hints;
- extern int ps_debug_no_vert_hints;
+ extern PS_Hints ps_debug_hints;
+ extern int ps_debug_no_horz_hints;
+ extern int ps_debug_no_vert_hints;
#endif
/* */
-
+
+
FT_END_HEADER
+
#endif /* __PS_HINTER_RECORD_H__ */
+
+
+/* END */
diff --git a/src/pshinter/rules.mk b/src/pshinter/rules.mk
index a145f62f1..409a7900a 100644
--- a/src/pshinter/rules.mk
+++ b/src/pshinter/rules.mk
@@ -3,7 +3,7 @@
#
-# Copyright 1996-2001 by
+# Copyright 2001 by
# David Turner, Robert Wilhelm, and Werner Lemberg.
#
# This file is part of the FreeType project, and may only be used, modified,
@@ -31,14 +31,13 @@ PSHINTER_DRV_SRC := $(PSHINTER_DIR_)pshrec.c \
$(PSHINTER_DIR_)pshmod.c \
$(PSHINTER_DIR_)pshalgo1.c \
$(PSHINTER_DIR_)pshalgo2.c
-
+
# PSHINTER driver headers
#
PSHINTER_DRV_H := $(PSHINTER_DRV_SRC:%c=%h)
-
# PSHINTER driver object(s)
#
# PSHINTER_DRV_OBJ_M is used during `multi' builds.
@@ -55,7 +54,7 @@ PSHINTER_DRV_SRC_S := $(PSHINTER_DIR_)pshinter.c
# PSHINTER driver - single object
#
$(PSHINTER_DRV_OBJ_S): $(PSHINTER_DRV_SRC_S) $(PSHINTER_DRV_SRC) \
- $(FREETYPE_H) $(PSHINTER_DRV_H)
+ $(FREETYPE_H) $(PSHINTER_DRV_H)
$(PSHINTER_COMPILE) $T$@ $(PSHINTER_DRV_SRC_S)
diff --git a/src/psnames/psmodule.c b/src/psnames/psmodule.c
index 8ed27689d..9f6ccf599 100644
--- a/src/psnames/psmodule.c
+++ b/src/psnames/psmodule.c
@@ -66,8 +66,8 @@
for ( count = 4; count > 0; count--, p++ )
{
- char c = *p;
- unsigned int d;
+ char c = *p;
+ unsigned int d;
d = (unsigned char)c - '0';
@@ -290,7 +290,7 @@
const FT_Module_Class psnames_module_class =
{
0, /* this is not a font driver, nor a renderer */
- sizeof( FT_ModuleRec ),
+ sizeof ( FT_ModuleRec ),
"psnames", /* driver name */
0x10000L, /* driver version */
diff --git a/src/raster/ftraster.c b/src/raster/ftraster.c
index 2a635525b..6c32a17ae 100644
--- a/src/raster/ftraster.c
+++ b/src/raster/ftraster.c
@@ -105,10 +105,6 @@
/*************************************************************************/
/*************************************************************************/
-#ifdef MEM_Set
-# define MEM_Set(d,s,c) memset(d,s,c)
-#endif
-
/* define DEBUG_RASTER if you want to compile a debugging version */
#define xxxDEBUG_RASTER
@@ -190,6 +186,11 @@
#endif /* _STANDALONE_ */
+#ifndef MEM_Set
+#define MEM_Set( d, s, c ) memset( d, s, c )
+#endif
+
+
/* FMulDiv means `Fast MulDiv'; it is used in case where `b' is */
/* typically a small value and the result of a*b is known to fit into */
/* 32 bits. */
diff --git a/src/sfnt/sfdriver.c b/src/sfnt/sfdriver.c
index 31045640f..d1f0ba4af 100644
--- a/src/sfnt/sfdriver.c
+++ b/src/sfnt/sfdriver.c
@@ -116,7 +116,8 @@
{
FT_Int n;
- /* shouldn't happen, but just in case to avoid memory leaks */
+
+ /* shouldn't happen, but just in case to avoid memory leaks */
if ( face->root.internal->postscript_name )
return face->root.internal->postscript_name;
@@ -125,34 +126,36 @@
for ( n = 0; n < face->num_names; n++ )
{
TT_NameRec* name = face->name_table.names + n;
-
+
+
if ( name->nameID == 6 )
{
if ( ( name->platformID == 3 &&
name->encodingID == 1 &&
name->languageID == 0x409 ) ||
-
+
( name->platformID == 1 &&
name->encodingID == 0 &&
name->languageID == 0 ) )
{
- FT_UInt len = name->stringLength;
- FT_Error error;
- FT_Memory memory = face->root.memory;
- FT_String* result;
-
- if ( !ALLOC( result, len+1 ) )
+ FT_UInt len = name->stringLength;
+ FT_Error error;
+ FT_Memory memory = face->root.memory;
+ FT_String* result;
+
+
+ if ( !ALLOC( result, len + 1 ) )
{
memcpy( result, name->string, len );
result[len] = '\0';
-
+
face->root.internal->postscript_name = result;
}
return result;
}
}
}
-
+
return NULL;
}
diff --git a/src/smooth/ftgrays.c b/src/smooth/ftgrays.c
index 155c35273..d93533824 100644
--- a/src/smooth/ftgrays.c
+++ b/src/smooth/ftgrays.c
@@ -86,7 +86,8 @@
/* experimental support for gamma correction within the rasterizer */
-#define xxxGRAYS_USE_GAMMA
+#define xxxGRAYS_USE_GAMMA
+
/*************************************************************************/
/* */
@@ -144,8 +145,8 @@
#endif /* _STANDALONE_ */
-#ifndef MEM_Set
-# define MEM_Set(d,s,c) memset(d,s,c)
+#ifndef MEM_Set
+#define MEM_Set( d, s, c ) memset( d, s, c )
#endif
/* define this to dump debugging information */
@@ -309,8 +310,8 @@
void* memory;
jmp_buf jump_buffer;
-#ifdef GRAYS_USE_GAMMA
- FT_Byte gamma[257];
+#ifdef GRAYS_USE_GAMMA
+ FT_Byte gamma[257];
#endif
} TRaster, *PRaster;
@@ -1240,6 +1241,7 @@
{
FT_UInt coverage = spans->coverage;
+
#ifdef GRAYS_USE_GAMMA
coverage = raster->gamma[(FT_Byte)coverage];
#endif
@@ -1974,26 +1976,28 @@
/**** RASTER OBJECT CREATION: In standalone mode, we simply use *****/
/**** a static object. *****/
-#ifdef GRAYS_USE_GAMMA
+#ifdef GRAYS_USE_GAMMA
/* initialize the "gamma" table. Yes, this is really a crummy function */
- /* but the results look pretty good for something that simple.. */
+ /* but the results look pretty good for something that simple. */
/* */
-#define M_MAX 255
-#define M_X 128
-#define M_Y 96
+#define M_MAX 255
+#define M_X 128
+#define M_Y 192
static void
grays_init_gamma( PRaster raster )
{
FT_UInt x, a;
+
for ( x = 0; x < 256; x++ )
{
if ( x <= M_X )
- a = (x * M_Y + (M_X/2)) / M_X;
+ a = ( x * M_Y + M_X / 2) / M_X;
else
- a = M_Y + ((x-M_X)*(M_MAX-M_Y) + (M_MAX-M_X)/2)/(M_MAX-M_X);
+ 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;
}
diff --git a/src/tools/glnames.py b/src/tools/glnames.py
index 561774d82..e377cd0d3 100644
--- a/src/tools/glnames.py
+++ b/src/tools/glnames.py
@@ -1527,7 +1527,7 @@ def dump_mac_indices( file, all_glyphs ):
write( " {\n" )
for name in mac_standard_names:
- write( " " + repr( all_glyphs.index(name) ) + ",\n" )
+ write( " " + repr( all_glyphs.index( name ) ) + ",\n" )
write( " 0\n" )
write( " };\n" )
@@ -1634,22 +1634,24 @@ def main():
count_sid = len( sid_standard_names )
- # mac_extras contains the list of glyph names in the Macintosh standard
- # encoding which are not in either the Adobe Glyph List or the SID Standard Names
+ # 'mac_extras' contains the list of glyph names in the Macintosh standard
+ # encoding which are not in either the Adobe Glyph List or the SID
+ # Standard Names.
#
mac_extras = filter_glyph_names( mac_standard_names, adobe_glyph_names() )
mac_extras = filter_glyph_names( mac_extras, sid_standard_names )
- # base_list contains the first names of our final glyph names table. It consists
- # of the "mac_extras" glyph names, followed by the SID Standard names
+ # 'base_list' contains the first names of our final glyph names table.
+ # It consists of the 'mac_extras' glyph names, followed by the SID
+ # Standard names.
#
mac_extras_count = len( mac_extras )
t1_bias = mac_extras_count
base_list = mac_extras + sid_standard_names
- # adobe_list contains the glyph names that are in the AGL, but no in
- # the base_list, they will be placed after base_list glyph names in
- # our final table..
+ # 'adobe_list' contains the glyph names that are in the AGL, but not in
+ # the base_list; they will be placed after base_list glyph names in
+ # our final table.
#
adobe_list = filter_glyph_names( adobe_glyph_names(), base_list )
adobe_count = len( adobe_list )
diff --git a/src/type1/t1gload.c b/src/type1/t1gload.c
index 6dafb6e02..a801032a0 100644
--- a/src/type1/t1gload.c
+++ b/src/type1/t1gload.c
@@ -173,7 +173,7 @@
(FT_GlyphSlot)glyph,
(FT_Byte**)type1->glyph_names,
face->blend,
- FT_BOOL(hinting),
+ FT_BOOL( hinting ),
T1_Parse_Glyph );
if ( error )
goto Exit;
@@ -241,9 +241,9 @@
if ( size && size->root.metrics.y_ppem < 24 )
glyph->root.outline.flags |= ft_outline_high_precision;
-/* XXXX: the following needs serious work to work properly with hinting !! */
+ /* XXX: the following needs serious work to work properly with hinting! */
#if 0
- /* apply the font matrix, if any.. */
+ /* apply the font matrix, if any */
FT_Outline_Transform( &glyph->root.outline, &font_matrix );
FT_Outline_Translate( &glyph->root.outline,
@@ -261,7 +261,7 @@
FT_Fixed y_scale = glyph->y_scale;
- /* First of all, scale the points, fi we're not hinting */
+ /* First of all, scale the points, if we are not hinting */
if ( !hinting )
for ( n = cur->n_points; n > 0; n--, vec++ )
{
diff --git a/src/type1/t1load.c b/src/type1/t1load.c
index 2b097999b..817c940c1 100644
--- a/src/type1/t1load.c
+++ b/src/type1/t1load.c
@@ -827,6 +827,7 @@
FT_Byte* cur2;
FT_Byte* limit;
+
if ( face->type1.font_name )
/* with synthetic fonts, it's possible we get here twice */
return;
@@ -959,6 +960,7 @@
FT_Memory memory = parser->root.memory;
FT_Error error;
+
if ( encode->char_index )
/* with synthetic fonts, it's possible we get here twice */
return;
@@ -1101,6 +1103,7 @@
PSAux_Interface* psaux = (PSAux_Interface*)face->psaux;
+
if ( loader->num_subrs )
/* with synthetic fonts, it's possible we get here twice */
return;
diff --git a/src/type1/t1objs.c b/src/type1/t1objs.c
index 8c9bbd37a..34f29fe58 100644
--- a/src/type1/t1objs.c
+++ b/src/type1/t1objs.c
@@ -47,13 +47,14 @@
/*************************************************************************/
/* */
- /* SIZE FUNCTIONS */
+ /* SIZE FUNCTIONS */
/* */
/* note that we store the global hints in the size's "internal" root */
- /* field.. */
+ /* field */
/* */
/*************************************************************************/
+
static PSH_Globals_Funcs
T1_Size_Get_Globals_Funcs( T1_Size size )
{
@@ -61,60 +62,64 @@
PSHinter_Interface* pshinter = face->pshinter;
FT_Module module;
- module = FT_Get_Module( size->root.face->driver->root.library, "pshinter" );
+
+ module = FT_Get_Module( size->root.face->driver->root.library,
+ "pshinter" );
return ( module && pshinter && pshinter->get_globals_funcs )
? pshinter->get_globals_funcs( module )
: 0 ;
}
- FT_LOCAL_DEF
- void T1_Size_Done( T1_Size size )
+ FT_LOCAL_DEF void
+ T1_Size_Done( T1_Size size )
{
if ( size->root.internal )
{
- PSH_Globals_Funcs funcs;
+ PSH_Globals_Funcs funcs;
- funcs = T1_Size_Get_Globals_Funcs(size);
- if (funcs)
- funcs->destroy( (PSH_Globals) size->root.internal );
+
+ funcs = T1_Size_Get_Globals_Funcs( size );
+ if ( funcs )
+ funcs->destroy( (PSH_Globals)size->root.internal );
size->root.internal = 0;
}
}
-
- FT_LOCAL_DEF
- FT_Error T1_Size_Init( T1_Size size )
+ FT_LOCAL_DEF FT_Error
+ T1_Size_Init( T1_Size size )
{
FT_Error error = 0;
PSH_Globals_Funcs funcs = T1_Size_Get_Globals_Funcs( size );
+
if ( funcs )
{
- PSH_Globals globals;
- T1_Face face = (T1_Face) size->root.face;
+ PSH_Globals globals;
+ T1_Face face = (T1_Face)size->root.face;
+
error = funcs->create( size->root.face->memory,
&face->type1.private_dict, &globals );
- if (!error)
- size->root.internal = (FT_Size_Internal)(void*) globals;
+ if ( !error )
+ size->root.internal = (FT_Size_Internal)(void*)globals;
}
return error;
}
-
- FT_LOCAL_DEF
- FT_Error T1_Size_Reset( T1_Size size )
+ FT_LOCAL_DEF FT_Error
+ T1_Size_Reset( T1_Size size )
{
- PSH_Globals_Funcs funcs = T1_Size_Get_Globals_Funcs(size);
+ PSH_Globals_Funcs funcs = T1_Size_Get_Globals_Funcs( size );
FT_Error error = 0;
+
- if (funcs)
- error = funcs->set_scale( (PSH_Globals) size->root.internal,
+ if ( funcs )
+ error = funcs->set_scale( (PSH_Globals)size->root.internal,
size->root.metrics.x_scale,
size->root.metrics.y_scale,
0, 0 );
@@ -178,8 +183,8 @@
/* <Input> */
/* face :: A typeless pointer to the face object to destroy. */
/* */
- FT_LOCAL_DEF
- void T1_Face_Done( T1_Face face )
+ FT_LOCAL_DEF void
+ T1_Face_Done( T1_Face face )
{
FT_Memory memory;
T1_Font* type1 = &face->type1;
@@ -239,7 +244,6 @@
}
-
/*************************************************************************/
/* */
/* <Function> */
diff --git a/src/type1/t1objs.h b/src/type1/t1objs.h
index c7ff8034d..25ed6b57f 100644
--- a/src/type1/t1objs.h
+++ b/src/type1/t1objs.h
@@ -105,14 +105,15 @@ FT_BEGIN_HEADER
} T1_SizeRec;
- FT_LOCAL
- void T1_Size_Done( T1_Size size );
+ FT_LOCAL void
+ T1_Size_Done( T1_Size size );
+
+ FT_LOCAL FT_Error
+ T1_Size_Reset( T1_Size size );
- FT_LOCAL
- FT_Error T1_Size_Reset( T1_Size size );
+ FT_LOCAL FT_Error
+ T1_Size_Init( T1_Size size );
- FT_LOCAL
- FT_Error T1_Size_Init( T1_Size size );
/*************************************************************************/
/* */
@@ -149,12 +150,6 @@ FT_BEGIN_HEADER
T1_Face_Done( T1_Face face );
FT_LOCAL FT_Error
- T1_Size_Init( T1_Size size );
-
- FT_LOCAL void
- T1_Size_Done( T1_Size size );
-
- FT_LOCAL FT_Error
T1_GlyphSlot_Init( T1_GlyphSlot slot );
FT_LOCAL void
diff --git a/tests/Jamfile b/tests/Jamfile
index 23f4b40ea..2635cbdac 100644
--- a/tests/Jamfile
+++ b/tests/Jamfile
@@ -1,10 +1,13 @@
-SubDir FT2_TOP tests ;
+# FreeType 2 src Jamfile (c) 2001 David Turner
+#
+
+SubDir FT2_TOP tests ;
test_programs = gview ;
-SubDirHdrs [ FT2_SubDir .. nirvana include ] ;
+SubDirHdrs [ FT2_SubDir .. nirvana include ] ;
-NV_TOP = [ FT2_SubDir .. .. nirvana ] ;
+NV_TOP = [ FT2_SubDir .. .. nirvana ] ;
NIRVANA_LINKLIBS = $(NV_TOP)\\objs\\nirvana$(SUFLIB) ;