[FREETYPE] Update to v2.5.5. CORE-8888
authorAmine Khaldi <amine.khaldi@reactos.org>
Tue, 26 May 2015 12:02:58 +0000 (12:02 +0000)
committerAmine Khaldi <amine.khaldi@reactos.org>
Tue, 26 May 2015 12:02:58 +0000 (12:02 +0000)
svn path=/trunk/; revision=67920

197 files changed:
reactos/lib/3rdparty/freetype/ChangeLog
reactos/lib/3rdparty/freetype/README
reactos/lib/3rdparty/freetype/devel/ftoption.h
reactos/lib/3rdparty/freetype/include/config/ftconfig.h
reactos/lib/3rdparty/freetype/include/config/ftoption.h
reactos/lib/3rdparty/freetype/include/freetype.h
reactos/lib/3rdparty/freetype/include/ftadvanc.h
reactos/lib/3rdparty/freetype/include/ftautoh.h
reactos/lib/3rdparty/freetype/include/ftbbox.h
reactos/lib/3rdparty/freetype/include/ftbdf.h
reactos/lib/3rdparty/freetype/include/ftbitmap.h
reactos/lib/3rdparty/freetype/include/ftbzip2.h
reactos/lib/3rdparty/freetype/include/ftcache.h
reactos/lib/3rdparty/freetype/include/ftcffdrv.h
reactos/lib/3rdparty/freetype/include/ftcid.h
reactos/lib/3rdparty/freetype/include/fterrdef.h
reactos/lib/3rdparty/freetype/include/ftgasp.h
reactos/lib/3rdparty/freetype/include/ftglyph.h
reactos/lib/3rdparty/freetype/include/ftgxval.h
reactos/lib/3rdparty/freetype/include/ftgzip.h
reactos/lib/3rdparty/freetype/include/ftimage.h
reactos/lib/3rdparty/freetype/include/ftincrem.h
reactos/lib/3rdparty/freetype/include/ftlcdfil.h
reactos/lib/3rdparty/freetype/include/ftlist.h
reactos/lib/3rdparty/freetype/include/ftlzw.h
reactos/lib/3rdparty/freetype/include/ftmm.h
reactos/lib/3rdparty/freetype/include/ftmodapi.h
reactos/lib/3rdparty/freetype/include/ftotval.h
reactos/lib/3rdparty/freetype/include/ftoutln.h
reactos/lib/3rdparty/freetype/include/ftpfr.h
reactos/lib/3rdparty/freetype/include/ftrender.h
reactos/lib/3rdparty/freetype/include/ftstroke.h
reactos/lib/3rdparty/freetype/include/ftsynth.h
reactos/lib/3rdparty/freetype/include/ftsystem.h
reactos/lib/3rdparty/freetype/include/fttrigon.h
reactos/lib/3rdparty/freetype/include/ftttdrv.h
reactos/lib/3rdparty/freetype/include/fttypes.h
reactos/lib/3rdparty/freetype/include/ftwinfnt.h
reactos/lib/3rdparty/freetype/include/ftxf86.h
reactos/lib/3rdparty/freetype/include/internal/ftcalc.h
reactos/lib/3rdparty/freetype/include/internal/ftgloadr.h
reactos/lib/3rdparty/freetype/include/internal/ftobjs.h
reactos/lib/3rdparty/freetype/include/internal/ftvalid.h
reactos/lib/3rdparty/freetype/include/internal/pshints.h
reactos/lib/3rdparty/freetype/include/internal/sfnt.h
reactos/lib/3rdparty/freetype/include/t1tables.h
reactos/lib/3rdparty/freetype/include/ttnameid.h
reactos/lib/3rdparty/freetype/include/tttables.h
reactos/lib/3rdparty/freetype/include/ttunpat.h
reactos/lib/3rdparty/freetype/src/autofit/afangles.c
reactos/lib/3rdparty/freetype/src/autofit/afblue.c
reactos/lib/3rdparty/freetype/src/autofit/afblue.dat
reactos/lib/3rdparty/freetype/src/autofit/afblue.h
reactos/lib/3rdparty/freetype/src/autofit/afblue.hin
reactos/lib/3rdparty/freetype/src/autofit/afcjk.c
reactos/lib/3rdparty/freetype/src/autofit/afcjk.h
reactos/lib/3rdparty/freetype/src/autofit/afglobal.c
reactos/lib/3rdparty/freetype/src/autofit/afglobal.h
reactos/lib/3rdparty/freetype/src/autofit/afhints.c
reactos/lib/3rdparty/freetype/src/autofit/afhints.h
reactos/lib/3rdparty/freetype/src/autofit/aflatin.c
reactos/lib/3rdparty/freetype/src/autofit/aflatin.h
reactos/lib/3rdparty/freetype/src/autofit/aflatin2.c
reactos/lib/3rdparty/freetype/src/autofit/afloader.c
reactos/lib/3rdparty/freetype/src/autofit/afmodule.c
reactos/lib/3rdparty/freetype/src/autofit/afranges.c
reactos/lib/3rdparty/freetype/src/autofit/afscript.h
reactos/lib/3rdparty/freetype/src/autofit/afstyles.h
reactos/lib/3rdparty/freetype/src/autofit/hbshim.c
reactos/lib/3rdparty/freetype/src/base/ftadvanc.c
reactos/lib/3rdparty/freetype/src/base/ftbbox.c
reactos/lib/3rdparty/freetype/src/base/ftbdf.c
reactos/lib/3rdparty/freetype/src/base/ftbitmap.c
reactos/lib/3rdparty/freetype/src/base/ftcalc.c
reactos/lib/3rdparty/freetype/src/base/ftfstype.c
reactos/lib/3rdparty/freetype/src/base/ftglyph.c
reactos/lib/3rdparty/freetype/src/base/ftgxval.c
reactos/lib/3rdparty/freetype/src/base/ftinit.c
reactos/lib/3rdparty/freetype/src/base/ftlcdfil.c
reactos/lib/3rdparty/freetype/src/base/ftmac.c
reactos/lib/3rdparty/freetype/src/base/ftmm.c
reactos/lib/3rdparty/freetype/src/base/ftobjs.c
reactos/lib/3rdparty/freetype/src/base/ftoutln.c
reactos/lib/3rdparty/freetype/src/base/ftpfr.c
reactos/lib/3rdparty/freetype/src/base/ftrfork.c
reactos/lib/3rdparty/freetype/src/base/ftstream.c
reactos/lib/3rdparty/freetype/src/base/ftstroke.c
reactos/lib/3rdparty/freetype/src/base/ftsynth.c
reactos/lib/3rdparty/freetype/src/base/fttrigon.c
reactos/lib/3rdparty/freetype/src/base/fttype1.c
reactos/lib/3rdparty/freetype/src/base/ftutil.c
reactos/lib/3rdparty/freetype/src/base/ftwinfnt.c
reactos/lib/3rdparty/freetype/src/bdf/bdfdrivr.c
reactos/lib/3rdparty/freetype/src/bdf/bdflib.c
reactos/lib/3rdparty/freetype/src/bzip2/ftbzip2.c
reactos/lib/3rdparty/freetype/src/cache/ftcbasic.c
reactos/lib/3rdparty/freetype/src/cache/ftccmap.c
reactos/lib/3rdparty/freetype/src/cache/ftcmanag.c
reactos/lib/3rdparty/freetype/src/cache/ftcsbits.c
reactos/lib/3rdparty/freetype/src/cff/cf2font.c
reactos/lib/3rdparty/freetype/src/cff/cf2ft.c
reactos/lib/3rdparty/freetype/src/cff/cf2hints.c
reactos/lib/3rdparty/freetype/src/cff/cf2intrp.c
reactos/lib/3rdparty/freetype/src/cff/cffcmap.c
reactos/lib/3rdparty/freetype/src/cff/cffdrivr.c
reactos/lib/3rdparty/freetype/src/cff/cffgload.c
reactos/lib/3rdparty/freetype/src/cff/cffobjs.c
reactos/lib/3rdparty/freetype/src/cff/cffparse.c
reactos/lib/3rdparty/freetype/src/gxvalid/gxvbsln.c
reactos/lib/3rdparty/freetype/src/gxvalid/gxvcommn.c
reactos/lib/3rdparty/freetype/src/gxvalid/gxvcommn.h
reactos/lib/3rdparty/freetype/src/gxvalid/gxvfeat.c
reactos/lib/3rdparty/freetype/src/gxvalid/gxvjust.c
reactos/lib/3rdparty/freetype/src/gxvalid/gxvkern.c
reactos/lib/3rdparty/freetype/src/gxvalid/gxvlcar.c
reactos/lib/3rdparty/freetype/src/gxvalid/gxvmort.c
reactos/lib/3rdparty/freetype/src/gxvalid/gxvmort.h
reactos/lib/3rdparty/freetype/src/gxvalid/gxvmort0.c
reactos/lib/3rdparty/freetype/src/gxvalid/gxvmort1.c
reactos/lib/3rdparty/freetype/src/gxvalid/gxvmort2.c
reactos/lib/3rdparty/freetype/src/gxvalid/gxvmort4.c
reactos/lib/3rdparty/freetype/src/gxvalid/gxvmort5.c
reactos/lib/3rdparty/freetype/src/gxvalid/gxvmorx.c
reactos/lib/3rdparty/freetype/src/gxvalid/gxvmorx.h
reactos/lib/3rdparty/freetype/src/gxvalid/gxvmorx0.c
reactos/lib/3rdparty/freetype/src/gxvalid/gxvmorx1.c
reactos/lib/3rdparty/freetype/src/gxvalid/gxvmorx2.c
reactos/lib/3rdparty/freetype/src/gxvalid/gxvmorx4.c
reactos/lib/3rdparty/freetype/src/gxvalid/gxvmorx5.c
reactos/lib/3rdparty/freetype/src/gxvalid/gxvopbd.c
reactos/lib/3rdparty/freetype/src/gxvalid/gxvprop.c
reactos/lib/3rdparty/freetype/src/gxvalid/gxvtrak.c
reactos/lib/3rdparty/freetype/src/gzip/ftgzip.c
reactos/lib/3rdparty/freetype/src/gzip/inftrees.c
reactos/lib/3rdparty/freetype/src/lzw/ftlzw.c
reactos/lib/3rdparty/freetype/src/lzw/ftzopen.h
reactos/lib/3rdparty/freetype/src/otvalid/otvbase.c
reactos/lib/3rdparty/freetype/src/otvalid/otvcommn.c
reactos/lib/3rdparty/freetype/src/otvalid/otvcommn.h
reactos/lib/3rdparty/freetype/src/otvalid/otvgdef.c
reactos/lib/3rdparty/freetype/src/otvalid/otvgpos.c
reactos/lib/3rdparty/freetype/src/otvalid/otvgsub.c
reactos/lib/3rdparty/freetype/src/otvalid/otvjstf.c
reactos/lib/3rdparty/freetype/src/otvalid/otvmath.c
reactos/lib/3rdparty/freetype/src/pcf/pcfdrivr.c
reactos/lib/3rdparty/freetype/src/pcf/pcfread.c
reactos/lib/3rdparty/freetype/src/pfr/pfrcmap.c
reactos/lib/3rdparty/freetype/src/pfr/pfrdrivr.c
reactos/lib/3rdparty/freetype/src/pfr/pfrload.c
reactos/lib/3rdparty/freetype/src/pfr/pfrobjs.c
reactos/lib/3rdparty/freetype/src/pfr/pfrsbit.c
reactos/lib/3rdparty/freetype/src/psaux/psconv.c
reactos/lib/3rdparty/freetype/src/psaux/psobjs.c
reactos/lib/3rdparty/freetype/src/psaux/t1cmap.c
reactos/lib/3rdparty/freetype/src/psaux/t1decode.c
reactos/lib/3rdparty/freetype/src/pshinter/pshglob.c
reactos/lib/3rdparty/freetype/src/pshinter/pshglob.h
reactos/lib/3rdparty/freetype/src/pshinter/pshrec.c
reactos/lib/3rdparty/freetype/src/pshinter/pshrec.h
reactos/lib/3rdparty/freetype/src/psnames/psmodule.c
reactos/lib/3rdparty/freetype/src/raster/ftraster.c
reactos/lib/3rdparty/freetype/src/sfnt/pngshim.c
reactos/lib/3rdparty/freetype/src/sfnt/sfdriver.c
reactos/lib/3rdparty/freetype/src/sfnt/sfobjs.c
reactos/lib/3rdparty/freetype/src/sfnt/ttcmap.c
reactos/lib/3rdparty/freetype/src/sfnt/ttkern.c
reactos/lib/3rdparty/freetype/src/sfnt/ttload.c
reactos/lib/3rdparty/freetype/src/sfnt/ttmtx.c
reactos/lib/3rdparty/freetype/src/sfnt/ttmtx.h
reactos/lib/3rdparty/freetype/src/sfnt/ttpost.c
reactos/lib/3rdparty/freetype/src/sfnt/ttsbit.c
reactos/lib/3rdparty/freetype/src/smooth/ftgrays.c
reactos/lib/3rdparty/freetype/src/smooth/ftsmooth.c
reactos/lib/3rdparty/freetype/src/tools/afblue.pl
reactos/lib/3rdparty/freetype/src/tools/docmaker/content.py
reactos/lib/3rdparty/freetype/src/tools/docmaker/docmaker.py
reactos/lib/3rdparty/freetype/src/tools/docmaker/formatter.py
reactos/lib/3rdparty/freetype/src/tools/docmaker/sources.py
reactos/lib/3rdparty/freetype/src/tools/docmaker/tohtml.py
reactos/lib/3rdparty/freetype/src/tools/docmaker/utils.py
reactos/lib/3rdparty/freetype/src/tools/ftrandom/ftrandom.c
reactos/lib/3rdparty/freetype/src/tools/test_trig.c
reactos/lib/3rdparty/freetype/src/truetype/ttdriver.c
reactos/lib/3rdparty/freetype/src/truetype/ttgload.c
reactos/lib/3rdparty/freetype/src/truetype/ttgxvar.c
reactos/lib/3rdparty/freetype/src/truetype/ttinterp.c
reactos/lib/3rdparty/freetype/src/truetype/ttinterp.h
reactos/lib/3rdparty/freetype/src/truetype/ttobjs.c
reactos/lib/3rdparty/freetype/src/truetype/ttobjs.h
reactos/lib/3rdparty/freetype/src/truetype/ttpload.c
reactos/lib/3rdparty/freetype/src/truetype/ttsubpix.c
reactos/lib/3rdparty/freetype/src/type1/t1driver.c
reactos/lib/3rdparty/freetype/src/type1/t1load.c
reactos/lib/3rdparty/freetype/src/type42/t42objs.c
reactos/lib/3rdparty/freetype/src/type42/t42parse.c
reactos/lib/3rdparty/freetype/src/winfonts/winfnt.c
reactos/media/doc/3rd Party Files.txt

index ea1eb4a..809b475 100644 (file)
+2014-12-30  Werner Lemberg  <wl@gnu.org>
+
+       * Version 2.5.5 released.
+       =========================
+
+
+       Tag sources with `VER-2-5-5'.
+
+       * docs/VERSION.DLL: Update documentation and bump version number to
+       2.5.5.
+
+       * README, Jamfile (RefDoc), builds/windows/vc2005/freetype.vcproj,
+       builds/windows/vc2005/index.html,
+       builds/windows/vc2008/freetype.vcproj,
+       builds/windows/vc2008/index.html,
+       builds/windows/vc2010/freetype.vcxproj,
+       builds/windows/vc2010/index.html,
+       builds/windows/visualc/freetype.dsp,
+       builds/windows/visualc/freetype.vcproj,
+       builds/windows/visualc/index.html,
+       builds/windows/visualce/freetype.dsp,
+       builds/windows/visualce/freetype.vcproj,
+       builds/windows/visualce/index.html,
+       builds/wince/vc2005-ce/freetype.vcproj,
+       builds/wince/vc2005-ce/index.html,
+       builds/wince/vc2008-ce/freetype.vcproj,
+       builds/wince/vc2008-ce/index.html: s/2.5.4/2.5.5/, s/254/255/.
+
+       * include/freetype/freetype.h (FREETYPE_PATCH): Set to 5.
+
+       * builds/unix/configure.raw (version_info): Set to 17:4:11.
+       * CMakeLists.txt (VERSION_PATCH): Set to 5.
+       * docs/CHANGES: Updated.
+
+2014-12-24  Alexei Podtelezhnikov <apodtele@gmail.com>
+
+       [base] Formatting and nanooptimizations.
+
+       * src/base/ftcalc.c,
+       * src/base/fttrigon.c: Revise sign restoration.
+
+2014-12-13  Werner Lemberg  <wl@gnu.org>
+
+       * src/pcf/pcfread.c (pcf_read_TOC): Improve fix from 2014-12-08.
+
+2014-12-11  Werner Lemberg  <wl@gnu.org>
+
+       * builds/toplevel.mk (dist): Use older POSIX standard for `tar'.
+
+       Apparently, BSD tar isn't capable yet of handling POSIX-1.2001
+       (contrary to GNU tar), so force the POSIX-1.1988 format.
+
+       Problem reported by Stephen Fisher <sfisher@SDF.ORG>.
+
+2014-12-11  Werner Lemberg  <wl@gnu.org>
+
+       * src/type42/t42parse.c (t42_parse_sfnts): Reject invalid TTF size.
+
+2014-12-11  Werner Lemberg  <wl@gnu.org>
+
+       * src/base/ftobjs.c (FT_Get_Glyph_Name): Fix off-by-one check.
+
+       Problem reported by Dennis Felsing <dennis@felsin9.de>.
+
+2014-12-11  Werner Lemberg  <wl@gnu.org>
+
+       * src/type42/t42parse.c (t42_parse_sfnts): Check `string_size'.
+
+       Problem reported by Dennis Felsing <dennis@felsin9.de>.
+
+2014-12-09  suzuki toshiya  <mpsuzuki@hiroshima-u.ac.jp>
+
+       [gxvalid] Fix a naming convention conflicting with ftvalid.
+
+       See previous changeset for otvalid.
+
+       * src/gxvalid/{gxvcommn.h, gxvmort.h, gxvmorx.h}: Replace
+       `valid' by `gxvalid'.
+       * src/gxvalid/{gxvbsln.c, gxvcommn.c, gxvfeat.c, gxvjust.c,
+       gxvkern.c, gxvlcar.c, gxvmort.c, gxvmort0.c, gxvmort1.c,
+       gxvmort2.c, gxvmort4.c, gxvmort5.c, gxvmorx.c, gxvmorx0.c,
+       gxvmorx1.c, gxvmorx2.c, gxvmorx4.c, gxvmorx5.c, gxvopbd.c,
+       gxvprop.c, gxvtrak.c}: Replace `valid' by `gxvalid' if
+       it is typed as GXV_Validator.
+
+2014-12-09  suzuki toshiya  <mpsuzuki@hiroshima-u.ac.jp>
+
+       [otvalid] Fix a naming convention conflicting with ftvalid.
+
+       Some prototypes in ftvalid.h use `valid' for the variables
+       typed as FT_Validator.  Their implementations in src/base/
+       ftobjs.c and utilizations in src/sfnt/ttcmap.c do similar.
+
+       Some macros in otvcommn.h assume the exist of the variable
+       `valid' typed as OTV_Validator in the caller.
+
+       Mixing these two conventions cause invalid pointer conversion
+       and unexpected SEGV in longjmp.  To prevent it, all variables
+       typed as OTV_Validator are renamed to `otvalid'.
+
+       * src/otvalid/otvcommn.h: Replace `valid' by `otvalid'.
+       * src/otvalid/{otvcommn.c, otvbase.c, otvgdef.c, otvgpos.c,
+       otvgsub.c, otvjstf.c, otvmath.c}: Replace `valid' by `otvalid'
+       if it is typed as OTV_Validator.
+
+2014-12-09  suzuki toshiya  <mpsuzuki@hiroshima-u.ac.jp>
+
+       [ftvalid] Introduce FT_THROW() in FT_INVALID_XXX macros.
+
+       Original patch is designed by Werner Lemberg.  Extra part
+       for otvalid and gxvalid are added by suzuki toshiya, see
+       discussion:
+       http://lists.nongnu.org/archive/html/freetype-devel/2014-12/msg00002.html
+       http://lists.nongnu.org/archive/html/freetype-devel/2014-12/msg00007.html
+
+       * include/internal/ftvalid.h: Introduce FT_THROW() in FT_INVALID_().
+       * src/gxvalid/gxvcommn.h: Ditto.
+       * src/otvalid/otvcommn.h: Ditto.
+
+2014-12-08  Werner Lemberg  <wl@gnu.org>
+
+       [pcf] Fix Savannah bug #43774.
+
+       Work around `features' of X11's `pcfWriteFont' and `pcfReadFont'
+       functions.  Since the PCF format doesn't have an official
+       specification, we have to exactly follow these functions' behaviour.
+
+       The problem was unveiled with a patch from 2014-11-06, fixing issue
+       #43547.
+
+       * src/pcf/pcfread.c (pcf_read_TOC): Don't check table size for last
+       element.  Instead, assign real size.
+
+2014-12-07  Werner Lemberg  <wl@gnu.org>
+
+       Work around a bug in Borland's C++ compiler.
+
+       See
+
+         http://qc.embarcadero.com/wc/qcmain.aspx?d=118998
+
+       for Borland's bug tracker entry.
+
+       Reported by Yuliana Zigangirova <zigangirova@inbox.ru>,
+       http://lists.gnu.org/archive/html/freetype-devel/2014-04/msg00001.html.
+
+       * include/internal/ftvalid.h (FT_ValidatorRec), src/smooth/ftgrays.c
+       (gray_TWorker_): Move `ft_jmp_buf' field to be the first element.
+
+2014-12-07  Werner Lemberg  <wl@gnu.org>
+
+       */*: Decorate hex constants with `U' and `L' where appropriate.
+
+2014-12-07  Werner Lemberg  <wl@gnu.org>
+
+       [truetype] Prevent memory leak for buggy fonts.
+
+       * src/truetype/ttobjs.c (tt_size_done): Unconditionally call
+       `tt_size_done_bytecode'.
+
+2014-12-06  Werner Lemberg  <wl@gnu.org>
+
+       * Version 2.5.4 released.
+       =========================
+
+
+       Tag sources with `VER-2-5-4'.
+
+       * docs/VERSION.DLL: Update documentation and bump version number to
+       2.5.4.
+
+       * README, Jamfile (RefDoc), builds/windows/vc2005/freetype.vcproj,
+       builds/windows/vc2005/index.html,
+       builds/windows/vc2008/freetype.vcproj,
+       builds/windows/vc2008/index.html,
+       builds/windows/vc2010/freetype.vcxproj,
+       builds/windows/vc2010/index.html,
+       builds/windows/visualc/freetype.dsp,
+       builds/windows/visualc/freetype.vcproj,
+       builds/windows/visualc/index.html,
+       builds/windows/visualce/freetype.dsp,
+       builds/windows/visualce/freetype.vcproj,
+       builds/windows/visualce/index.html,
+       builds/wince/vc2005-ce/freetype.vcproj,
+       builds/wince/vc2005-ce/index.html,
+       builds/wince/vc2008-ce/freetype.vcproj,
+       builds/wince/vc2008-ce/index.html: s/2.5.3/2.5.4/, s/253/254/.
+
+       * include/freetype/freetype.h (FREETYPE_PATCH): Set to 4.
+
+       * builds/unix/configure.raw (version_info): Set to 17:3:11.
+       * CMakeLists.txt (VERSION_PATCH): Set to 4.
+       * docs/CHANGES: Updated.
+
+2014-12-04  Werner Lemberg  <wl@gnu.org>
+
+       docs/CHANGES: Updated, formatted.
+
+2014-12-04  Dave Arnold  <darnold@adobe.com>
+
+       [cff] Modify an FT_ASSERT.
+
+       * src/cff/cf2hints.c (cf2_hintmap_map): After the fix for Savannah
+       bug #43661, the test font `...aspartam.otf' still triggers an
+       FT_ASSERT.  Since hintmap still works with count==0, ...
+       (cf2_glyphpath_lineTo, cf2_glyphpath_curveTo): ... add that term to
+       suppress the assert.
+
+2014-12-04  Dave Arnold  <darnold@adobe.com>
+
+       [cff] Fix Savannah bug #43661.
+
+       * src/cff/cf2intrp.c (cf2_interpT2CharString) <cf2_cmdHSTEM,
+       cf2_cmdVSTEM, cf2_cmdHINTMASK>: Don't append to stem arrays after
+       hintmask is constructed.
+
+       * src/cff/cf2hints.c (cf2_hintmap_build): Add defensive code to
+       avoid reading past end of hintmask.
+
+2014-12-03  Werner Lemberg  <wl@gnu.org>
+
+       docs/CHANGES: Updated.
+
+2014-12-03  Werner Lemberg  <wl@gnu.org>
+
+       [autofit] Better fix for conversion specifiers in debug messages.
+
+       Using `%ld' for pointer differences causes warnings on 32bit
+       platforms.  The correct type would be (the relatively new) `%td',
+       however, this is missing on some important platforms.
+
+       This patch improves the change from 2014-11-28.
+
+       * src/autofit/afhints.c (AF_INDEX_NUM): Use `int' typecast.  Our
+       pointer differences are always sufficiently small.
+       (af_glyph_hints_dump_points, af_glyph_hints_dump_segments,
+       af_glyph_hints_dump_edge): Revert to `%d' and use `AF_INDEX_NUM'.
+
+2014-12-03  Werner Lemberg  <wl@gnu.org>
+
+       FT_Sfnt_Tag: s/ft_sfnt_xxx/FT_SFNT_XXX/ for orthogonality.
+
+       All public FreeType enumeration and flag values are uppercase...
+
+       * include/tttables.h (FT_Sfnt_Tag): Implement it.  For backwards
+       compatilibity, retain the old values as macros.
+
+       * src/base/ftfstype.c (FT_Get_FSType_Flags), src/sfnt/sfdriver.c
+       (get_sfnt_table): Updated.
+
+2014-12-02  Werner Lemberg  <wl@gnu.org>
+
+       * include/*: Improve structure of documentation.
+
+       . Add and update many `<Order>' tags.
+       . Apply various documentation fixes.
+       . Remove details to deprecated (or never implemented) data.
+
+2014-12-02  Werner Lemberg  <wl@gnu.org>
+
+       [docmaker] Always handle `<Order>' section elements.
+
+       Previously, those elements were handled only for sections present in
+       a `<Sections>' chapter element.
+
+       * src/tools/docmaker/content.py (ContentProcessor::finish):
+       Implement it.
+
+2014-12-02  Werner Lemberg  <wl@gnu.org>
+
+       [docmaker] Properly handle empty rows in Synopsis.
+
+       * src/tools/docmaker/tohtml.py (HtmlFormatter::section_enter): Emit
+       `&nbsp;' for empty fields.
+
+2014-12-02  Werner Lemberg  <wl@gnu.org>
+
+       [docmaker] Thinko.
+
+       * src/tools/docmaker/content.py (DocBlock::get_markup_words_all):
+       Emit `/empty/' string for first element also.
+
+2014-12-02  Werner Lemberg  <wl@gnu.org>
+
+       [docmaker] Honour empty lines in `<Order>' section element.
+
+       This greatly improves the readability of the `Synopsis' links.
+
+       * src/tools/docmaker/content.py (DocBlock::get_markup_words_all):
+       Insert string `/empty/' between items.
+
+       * src/tools/docmaker/formatter.py (Formatter::section_dump): Make it
+       robust against nonexistent keys.
+
+       * src/tools/docmaker/tohtml.py (HtmlFormatter::section_enter): Emit
+       empty <td> elements for `/empty/'.
+
+2014-12-02  Werner Lemberg  <wl@gnu.org>
+
+       [docmaker] Ensure Python 3 compatibility.
+
+       * src/tools/docmaker/content.py (ContentProcessor::set_section,
+       ContentProcessor::finish): Replace `has_key' function with `in'
+       keyword.
+
+       * src/tools/docmaker/formatter.py (Formatter::__init__): Replace
+       sorting function with a key generator.
+       (Formatter::add_identifier): Replace `has_key' function with `in'
+       keyword.
+
+       * src/tools/docmaker/tohtml.py (HtmlFormatter::html_source_quote):
+       Replace `has_key' function with `in' keyword.
+       (HtmlFormatter::index_exit, HtmlFormatter::section_enter): Use
+       integer division.
+       s/<>/>/.
+
+       * src/tools/docmaker/utils.py: Import `itertools'.
+       (index_sort): Replaced by...
+       (index_key): ... this new key generator (doing exactly the same).
+
+2014-11-29  Werner Lemberg  <wl@gnu.org>
+
+       [docmaker] Don't output a block multiple times.
+
+       This bug was hidden by not processing all lines of `<Order>' blocks.
+
+       * src/tools/docmaker/formatter.py (Formatter::section_dump): Filter
+       out field names.
+
+2014-11-29  Werner Lemberg  <wl@gnu.org>
+
+       [docmaker] Use field values as HTML link targets where possible.
+
+       * src/tools/docmaker/tohtml.py (HtmlFormatter::make_block_url):
+       Accept second, optional argument to specify a name.
+       (HtmlFormatter::html_source_quote): Link to field ID if possible.
+       (HtmlFormatter::print_html_field_list): Emit `id' attribute.
+
+2014-11-29  Werner Lemberg  <wl@gnu.org>
+
+       [docmaker] Allow empty lines in `<Order>' blocks.
+
+       Before this patch, the suggested order of entries stopped at the
+       first empty line.
+
+       Obviously, nobody noticed that this problem caused a much reduced
+       set of links in the `Synopsis' sections; in particular, the
+       `<Order>' blocks contain a lot of entries that wouldn't be listed
+       otherwise...
+
+       * src/tools/docmaker/content.py (DocBlock::get_markup_words_all):
+       New function to iterate over all items.
+       (DocSection::process): Use it.
+
+2014-11-29  Werner Lemberg  <wl@gnu.org>
+
+       * src/tools/docmaker/sources.py (column) [Format 2]: Fix regexp.
+
+       After the single asterisk there must be no other immediately following
+       asterisk.
+
+2014-11-29  Werner Lemberg  <wl@gnu.org>
+
+       * src/tools/docmaker/tohtml.py: Improve CSS for vertical spacing.
+
+2014-11-29  Werner Lemberg  <wl@gnu.org>
+
+       [docmaker] Improve HTML code for table of contents.
+
+       * src/tools/docmaker/tohtml.py: Introduce a new table class `toc',
+       together with proper CSS.
+
+2014-11-29  Werner Lemberg  <wl@gnu.org>
+
+       [docmaker] Provide higher-level markup and simplify HTML.
+
+       * src/tools/docmaker/tohtml.py: Instead of using extraneous `<div>'
+       elements, use CSS descendants (of class `section') to format the
+       data.
+
+       Also remove reduntant <p> and <br> elements, replacing them with
+       proper CSS.
+
+       Globally reduce page width to 75%.
+
+       (block_header): Rename <div> class to `section'.
+
+2014-11-29  Werner Lemberg  <wl@gnu.org>
+
+       [docmaker] Add `top' links after blocks.
+
+       * src/tools/docmaker/tohtml.py (block_footer_middle): Implement it.
+
+2014-11-29  Werner Lemberg  <wl@gnu.org>
+
+       * src/tools/docmaker/tohtml.py: Improve CSS for fields.
+
+       Make fields align horizontally relative to full line width.
+
+2014-11-29  Werner Lemberg  <wl@gnu.org>
+
+       * src/tools/docmaker/tohtml.py: Fix index and TOC templates.
+
+       This thinko was introduced 2014-11-27.
+
+2014-11-28  Werner Lemberg  <wl@gnu.org>
+
+       [docmaker] Format field lists with CSS.
+
+       This also simplifies the inserted HTML code.
+
+       * src/tools/docmaker/tohtml.py
+       (HtmlFormatter::print_html_field_list): Do it.
+
+2014-11-28  suzuki toshiya  <mpsuzuki@hiroshima-u.ac.jp>
+
+       Fix compiler warning to the comparison between signed and
+       unsigned variable.
+
+       * src/pfr/pfrsbit.c (pfr_slot_load_bitmap): Fix the comparison
+       between `ypos + ysize' and FT_INT_{MAX,MIN}.
+
+2014-11-28  Werner Lemberg  <wl@gnu.org>
+
+       [docmaker] Replace empty `<td>' with CSS.
+
+       * src/tools/docmaker/tohtml.py (HtmlFormatter::section_enter): Do
+       it.
+
+2014-11-28  Werner Lemberg  <wl@gnu.org>
+
+       [docmaker] Replace some `<table>' tags with `<h4>' and `<div>'.
+
+       * src/tools/docmaker/tohtml.py (marker_*): Use `<h4>'.
+       (source_*): Use `<div>'.
+       (HtmlFormatter::block_enter): s/<h4>/<h3>/.
+
+2014-11-28  suzuki toshiya  <mpsuzuki@hiroshima-u.ac.jp>
+
+       Fix compiler warning to conversion specifiers in debug messages.
+
+       * src/autofit/afhints.c (af_glyph_hints_dump_points): Add length
+       modifier to dump long integers.
+       (af_glyph_hints_dump_segments, af_glyph_hints_dump_edges): Ditto.
+
+2014-11-27  Werner Lemberg  <wl@gnu.org>
+
+       * src/tools/docmaker/tohtml.py: Use more CSS for index.
+
+2014-11-27  Werner Lemberg  <wl@gnu.org>
+
+       [docmaker] Replace `name' attribute of `<a>' with `id'.
+
+       * src/tools/docmaker/tohtml.py (HtmlFormatter::block_enter): Do it.
+
+2014-11-27  Werner Lemberg  <wl@gnu.org>
+
+       * src/tools/docmaker/tohtml.py: Remove remaining `width' attributes.
+
+       For `Index' and `TOC' links, we now simply use the `text-align' CSS
+       property of `<td>' to enforce flush-left and flush-right,
+       eliminating the hack with an empty, full-width `<td>' element
+       inbetween.
+
+       The change also enforces the same (smaller) size for all index and
+       TOC links.
+
+2014-11-27  suzuki toshiya  <mpsuzuki@hiroshima-u.ac.jp>
+
+       * src/cff/cf2font.c: Include `ftcalc.h' to use FT_MSB(),
+       cf2font.c could not find it under `make multi' build.
+
+2014-11-27  suzuki toshiya  <mpsuzuki@hiroshima-u.ac.jp>
+
+       * src/smooth/ftsmooth.c (ft_smooth_render_generic): Remove
+       unrequired negative value check for `width' and `height'.
+
+2014-11-27  Werner Lemberg  <wl@gnu.org>
+
+       * src/tools/docmaker/tohtml.py: More HTML table refactoring.
+
+       Replace some `<table>' tags with `<div>' to simplify structure.
+
+       Move `bgcolor' attribute to CSS.
+
+       Replace most `width' attributes with CSS.  The remaining instances
+       (providing a similar effect as LaTeX's `\hfill' command) are removed
+       in a later patch.
+
+2014-11-27  Werner Lemberg  <wl@gnu.org>
+
+       * src/tools/docmaker/tohtml.py: Replace <font> with CSS.
+
+2014-11-27  Werner Lemberg  <wl@gnu.org>
+
+       * src/tools/docmaker/tohtml.py: Center <table> with CSS.
+
+2014-11-27  Werner Lemberg  <wl@gnu.org>
+
+       * src/tools/docmaker/tohtml.py: Replace `<center>' with `<div>'.
+
+2014-11-27  Werner Lemberg  <wl@gnu.org>
+
+       * src/tools/docmaker/tohtml.py: Remove redundant `<center>' tags.
+
+       This starts a series of commits into the direction of generating
+       valid HTML 5 code, especially using much more CSS.
+
+2014-11-27  suzuki toshiya  <mpsuzuki@hiroshima-u.ac.jp>
+
+       Prevent too negative values (< FT_INT_MIN) in bitmap metrics,
+       suggested by Alexei.
+
+       * src/pfr/pfrsbit.c (pfr_slot_load_bitmap): Prevent too
+       negative values in `xpos' and `ypos + ysize'.
+       * src/smooth/ftsmooth.c (ft_smooth_render_generic): Prevent
+       too negative values in `x_left' and `y_top'.  Either negative
+       values in `width' and `height' are checked.
+
+2014-11-27  Werner Lemberg  <wl@gnu.org>
+
+       [docmaker] Produce better HTML code.
+
+       * src/tools/docmaker/tohtml.py: Always use double quotes for
+       attribute values.
+       (source_footer): Close `td' and `tr' groups.
+
+2014-11-27  Werner Lemberg  <wl@gnu.org>
+
+       Use better way to disable creation of .pyc files for `make refdoc'.
+
+       Python 2.6 was released in 2008...
+
+       * builds/freetype.mk (refdoc): Use python's `-B' option.
+
+       * builds/detect.mk (std_setup, dos_setup): Mention required python
+       version for `refdoc' target.
+
+2014-11-27  Werner Lemberg  <wl@gnu.org>
+
+       * src/tools/docmaker/sources.py (re_bold, re_italic): Use
+       non-grouping parentheses.
+       * src/tools/docmaker/tohtml.py (HtmlFormatter::make_html_word):
+       Updated.
+
+2014-11-27  Werner Lemberg  <wl@gnu.org>
+
+       * src/base/ftobjs.c (FT_Get_Glyph_Name): Fix compiler warning.
+
+       Introdruced in previous change.  Reported by Alexei.
+
+2014-11-26  Werner Lemberg  <wl@gnu.org>
+
+       * src/*: Add checks for parameters of API functions where missing.
+
+       `API functions' are functions tagged with `FT_EXPORT_DEF'.
+
+       Besides trivial fixes, the following changes are included, too.
+
+       * src/base/ftbdf.c (FT_Get_BDF_Charset_ID, FT_Get_BDF_Property): Set
+       error code if no service is available.
+
+       * src/base/ftinit.c (FT_Done_FreeType): Change return value for
+       invalid `library' parameter to `Invalid_Library_Handle'.
+
+       * src/base/ftobjs.c (FT_New_Size): Change return value for invalid
+       `asize' parameter to `Invalid_Argument'.
+
+       * src/base/ftoutln.c (FT_Outline_Copy): Change return value for
+       invalid `source' and `target' parameters to `Invalid_Outline'.
+       (FT_Outline_Done_Internal): Change return value for invalid
+       `outline' parameter to `Invalid_Outline'.
+
+2014-11-26  Werner Lemberg  <wl@gnu.org>
+
+       * src/cache/ftcbasic.c: Use single calls to `FT_TRACE'.
+
+2014-11-26  suzuki toshiya  <mpsuzuki@hiroshima-u.ac.jp>
+
+       * src/base/ftobj.c (Mac_Read_POST_Resource): Additional
+       overflow check in the summation of POST fragment lengths,
+       suggested by Mateusz Jurczyk <mjurczyk@google.com>.
+
+2014-11-26  suzuki toshiya  <mpsuzuki@hiroshima-u.ac.jp>
+
+       * src/base/ftobjs.c (Mac_Read_POST_Resource): Insert comments
+       and fold too long tracing messages.
+
+2014-11-26  suzuki toshiya  <mpsuzuki@hiroshima-u.ac.jp>
+
+       Fix Savannah bug #43540.
+
+       * src/base/ftmac.c (parse_fond): Prevent a buffer overrun
+       caused by a font including too many (> 63) strings to store
+       names[] table.
+
+2014-11-26  suzuki toshiya  <mpsuzuki@hiroshima-u.ac.jp>
+
+       * src/base/ftobjs.c (Mac_Read_POST_Resource): Use unsigned long
+       variables to read the lengths in POST fragments.  Suggested by
+       Mateusz Jurczyk <mjurczyk@google.com>.
+
+2014-11-26  suzuki toshiya  <mpsuzuki@hiroshima-u.ac.jp>
+
+       Fix Savannah bug #43539.
+
+       * src/base/ftobjs.c (Mac_Read_POST_Resource): Fix integer overflow
+       by a broken POST table in resource-fork.
+
+2014-11-26  suzuki toshiya  <mpsuzuki@hiroshima-u.ac.jp>
+
+       Fix Savannah bug #43538.
+
+       * src/base/ftobjs.c (Mac_Read_POST_Resource): Fix integer overflow
+       by a broken POST table in resource-fork.
+
+2014-11-26  suzuki toshiya  <mpsuzuki@hiroshima-u.ac.jp>
+
+       * src/base/ftobjs.c (Mac_Read_POST_Resource): Avoid memory leak
+       by a broken POST table in resource-fork.  Return after freeing
+       the buffered POST table when it is found to be broken.
+
+2014-11-25  Werner Lemberg  <wl@gnu.org>
+
+       */*: s/Invalid_Argument/Invalid_Size_Handle/ where appropriate.
+
+2014-11-25  Werner Lemberg  <wl@gnu.org>
+
+       */*: s/Invalid_Argument/Invalid_Stream_Handle/ where appropriate.
+
+2014-11-25  Werner Lemberg  <wl@gnu.org>
+
+       */*: s/Invalid_Argument/Invalid_Library_Handle/ where appropriate.
+
+2014-11-25  Werner Lemberg  <wl@gnu.org>
+
+       */*: s/Invalid_Argument/Invalid_Outline/ where appropriate.
+
+2014-11-25  Werner Lemberg  <wl@gnu.org>
+
+       */*: s/Invalid_Argument/Invalid_Face_Handle/ where appropriate.
+
+2014-11-24  Werner Lemberg  <wl@gnu.org>
+
+       [Savannah bug #43682] Adjust some renderer callbacks.
+
+       * src/raster/ftraster.c (ft_black_set_mode): Change return type to
+       `int' to stay in sync with `FT_Renderer_SetModeFunc' prototype.
+
+       * src/smooth/ftgrays.c (gray_raster_set_mode): New dummy function
+       for orthogonality.
+       (ft_grays_raster): Use it.
+
+2014-11-25  Werner Lemberg  <wl@gnu.org>
+
+       [Savannah bug #43682] Properly handle missing return errors.
+
+       The functions in this patch *do* return non-trivial errors that must
+       be taken care of.
+
+       * src/autofit/afloader.c (af_loader_load_g), src/base/ftobjs.c
+       (FT_Render_Glyph_Internal), src/base/ftoutln.c (FT_Outline_Render),
+       src/cff/cffgload.c (cff_decoder_parse_charstrings) <cff_op_endchar>,
+       src/psaux/psobjs.c (ps_parser_load_field_table), src/psaux/t1decode
+       (t1_decoder_parse_charstrings) <op_endchar>, src/truetype/ttgload.c
+       (load_truetype_glyph <subglyph loop>, tt_loader_init,
+       TT_Load_Glyph), src/truetype/ttgxvar.c (TT_Set_MM_Blend),
+       src/truetype/ttobjs.c (tt_size_run_fpgm, tt_size_run_prep): Do it.
+
+2014-11-25  Werner Lemberg  <wl@gnu.org>
+
+       [Savannah bug #43682] Add/remove `void' casts to some functions.
+
+       We use a cast to indicate that we intentionally ignore a function's
+       return value.  However, this doesn't apply to API functions where
+       errors can only happen for trivially invalid input.
+
+       * src/base/ftstroke.c (FT_Glyph_Stroke, FT_Glyph_StrokeBorder),
+       src/base/ftsynth.c (FT_GlyphSlot_Embolden), src/cff/cffgload.c
+       (cff_slot_load), src/pfr/pfrdrivr.c (pfr_get_kerning),
+       src/type1/t1load.c (parse_encoding), src/type42/t42parse.c
+       (t42_parse_encoding): Do it.
+
+2014-11-25  Werner Lemberg  <wl@gnu.org>
+
+       [Savannah bug #43682] Change some signatures to `void' return type.
+
+       * include/internal/pshints.h (PSH_Globals_SetScaleFunc),
+       include/internal/sfnt.h (TT_Get_Metrics_Func),
+       src/pshinter/pshglob.c (psh_globals_set_scale),
+       src/pshinter/pshrec.c (ps_hints_init), src/sfnt/ttmtx.c
+       (tt_face_get_metrics), src/truetype/ttinterp.c (TT_Goto_CodeRange,
+       TT_Set_CodeRange, TT_Clear_CodeRange, TT_Done_Context,
+       TT_Save_Context): Do it.
+
+       * src/pshinter/pshglob.h, src/pshinter/pshrec.h, src/sfnt/ttmtx.h,
+       src/truetype/ttgload.c (TT_Hint_Glyph), src/truetype/ttinterp.c
+       (TT_Run_Context), src/truetype/ttinterp.h, src/truetype/ttobjs.c
+       (tt_size_run_fpgm, tt_size_run_prep): Updated.
+
+2014-11-24  Werner Lemberg  <wl@gnu.org>
+
+       Remove all code related to FT_MAX_CHARMAP_CACHEABLE.
+
+       This is no longer used.
+
+       * src/base/ftobjs.c, src/cache/ftccmap.c, src/cff/cffobjs.c,
+       src/sfnt/ttcmap.c: Do it.
+
+2014-11-24  Werner Lemberg  <wl@gnu.org>
+
+       [sfnt] Fix Savannah bug #43680.
+
+       This adds an additional constraint to make the fix from 2013-01-25
+       really work.
+
+       * src/sfnt/ttsbit.c (tt_sbit_decoder_load_image) <index_format==4>:
+       Check `p' before `num_glyphs'.
+
+2014-11-24  Werner Lemberg  <wl@gnu.org>
+
+       [truetype] Fix Savannah bug #43679.
+
+       * src/truetype/ttpload.c (tt_face_load_hdmx): Check minimum size of
+       `record_size'.
+
+2014-11-24  Jarkko Pöyry  <jarkko.poyry@gmail.com>
+
+       [cff, pfr, psaux, winfonts] Fix Savannah bug #43676.
+
+       Don't cast cmap init function pointers to an incompatible type.
+
+       Without this patch, the number of parameters between declaration and
+       the real signature differs.  Calling such a function results in
+       undefined behavior.
+
+         ISO/IEC 9899:TC3 (Committee Draft September 7, 2007)
+           6.5.2.2 Function calls
+             9 If the function is defined with a type that is not
+               compatible with the type (of the expression) pointed to by
+               the expression that denotes the called function, the
+               behavior is undefined.
+
+       On certain platforms (c -> js with emscripten) this causes
+       termination of execution or invalid calls because in the emscripten
+       implementation, function pointers of different types are stored in
+       different pointer arrays.  Incorrect pointer type here results in
+       indexing of an incorrect array.
+
+       * src/cff/cffcmap.c (cff_cmap_encoding_init, cff_cmap_unicode_init),
+       src/pfr/pfrcmap.c (pfr_cmap_init), src/psaux/t1cmap.c
+       t1_cmap_standard_init, t1_cmap_expert_init, t1_cmap_custom_init,
+       t1_cmap_unicode_init), src/winfonts/winfnt.c (fnt_cmap_init): Fix
+       signature.
+
+2014-11-24  Werner Lemberg  <wl@gnu.org>
+
+       [sfnt] Fix Savannah bug #43672.
+
+       * src/sfnt/ttkern.c (tt_face_load_kern): Use correct value for
+       minimum table length test.
+
+2014-11-24  Werner Lemberg  <wl@gnu.org>
+
+       [type1, type42] Another fix for Savannah bug #43655.
+
+       * src/type1/t1load.c (parse_charstrings), src/type42/t42parse.c
+       (t42_parse_charstrings): Add another boundary testing.
+
+2014-11-24  Werner Lemberg  <wl@gnu.org>
+
+       [docmaker] Formatting, copyright, improved documentation.
+
+       * src/tools/docmaker/*: No code changes besides trivial
+       modifications.
+
+2014-11-22  Werner Lemberg  <wl@gnu.org>
+
+       [bdf] Fix Savannah bug #43660.
+
+       * src/bdf/bdflib.c (_bdf_parse_glyphs) <"ENDFONT">: Check
+       `_BDF_GLYPH_BITS'.
+
+2014-11-22  Werner Lemberg  <wl@gnu.org>
+
+       [type42] Allow only embedded TrueType fonts.
+
+       This is a follow-up to Savannah bug #43659.
+
+       * src/type42/t42objs.c (T42_Face_Init): Exclusively use the
+       `truetype' font driver for loading the font contained in the `sfnts'
+       array.
+
+2014-11-22  Werner Lemberg  <wl@gnu.org>
+
+       [type42] Fix Savannah bug #43659.
+
+       * src/type42/t42objs.c (T42_Open_Face): Initialize `face->ttf_size'.
+
+       * src/type42/t42parse.c (t42_parse_sfnts): Always set
+       `face->ttf_size' directly.  This ensures a correct stream size in
+       the call to `FT_Open_Face', which follows after parsing, even for
+       buggy input data.
+       Fix error messages.
+
+2014-11-22  Werner Lemberg  <wl@gnu.org>
+
+       [cff] Fix Savannah bug #43658.
+
+       * src/cff/cf2ft.c (cf2_builder_lineTo, cf2_builder_cubeTo): Handle
+       return values of point allocation routines.
+
+2014-11-22  Werner Lemberg  <wl@gnu.org>
+
+       [sfnt] Fix Savannah bug #43656.
+
+       * src/sfnt/ttcmap.c (tt_cmap4_validate): Fix order of validity
+       tests.
+
+2014-11-21  Werner Lemberg  <wl@gnu.org>
+
+       [type1, type42] Fix Savannah bug #43655.
+
+       * src/type1/t1load.c (parse_charstrings), src/type42/t42parse.c
+       (t42_parse_charstrings): Fix boundary testing.
+
+2014-11-21  Werner Lemberg  <wl@gnu.org>
+
+       * src/pcf/pcfread.c (pcf_get_metrics): Sanitize invalid metrics.
+
+2014-11-21  Werner Lemberg  <wl@gnu.org>
+
+       [ftlcdfil] Obey flow direction.
+
+       * src/base/ftlcdfil.c (_ft_lcd_filter_fir, _ft_lcd_filter_legacy):
+       Handle `up' flow.
+
+2014-11-21  Werner Lemberg  <wl@gnu.org>
+
+       * src/base/ftbitmap.c (FT_Bitmap_Convert): Improve.
+
+       This commit completes argument checks and adds support for different
+       flow directions.
+
+2014-11-21  Werner Lemberg  <wl@gnu.org>
+
+       * src/base/ftbitmap.c (FT_Bitmap_Copy): Improve.
+
+       This commit adds argument checks and support for different flow
+       directions.
+
+2014-11-20  Werner Lemberg  <wl@gnu.org>
+
+       * src/base/ftbitmap.c (FT_Bitmap_New): Check argument.
+
+2014-11-19  Werner Lemberg  <wl@gnu.org>
+
+       Change some fields in `FT_Bitmap' to unsigned type.
+
+       This doesn't break ABI.
+
+       * include/ftimage.h (FT_Bitmap): Make `rows', `width', `num_grays',
+       `pixel_mode', and `palette_mode' unsigned types.
+
+       * src/base/ftbitmap.c: Updated.
+       (FT_Bitmap_Copy): Fix casts.
+
+       * src/cache/ftcsbits.c, src/raster/ftraster.c, src/sfnt/pngshim.c:
+       Updated.
+
+2014-11-19  Werner Lemberg  <wl@gnu.org>
+
+       Make `FT_Bitmap_Convert' correctly handle negative `pitch' values.
+
+       * src/base/ftbitmap.c (FT_Bitmap_Convert): Always use positive value
+       for the pitch while copying data.
+       Correctly set pitch sign in target bitmap.
+
+2014-11-19  Werner Lemberg  <wl@gnu.org>
+
+       Minor code improvement in `FT_Bitmap_Embolden'.
+
+       * src/base/ftbitmap.c (FT_Bitmap_Embolden) <FT_PIXEL_MODE_GRAY[24]>:
+       Fix thinko.
+
+2014-11-19  Alexei Podtelezhnikov  <apodtele@gmail.com>
+
+       * src/base/fttrigon.c: Use dedicated `FT_Angle' for arctan table.
+
+2014-11-19  Behdad Esfahbod  <behdad@behdad.org>
+
+       Avoid compiler warnings on x86-64 for `FT_MulFix'.
+
+       `FT_MulFix' takes `FT_Long' parameters as defined in `freetype.h',
+       but several inline implementations of it in `ftcalc.h' take
+       `FT_Int32' arguments.  This is causing compiler warnings on x86-64:
+       If parameters of type `FT_Fixed' (= `FT_Long') are passed to the
+       inline implementation of this function, integer values are truncated
+       from 64bit to 32bit.
+
+       * include/internal/ftcalc.h (FT_MulFix) [FT_MULFIX_ASSEMBLER]: Add
+       casts.
+
+2014-11-15  Werner Lemberg  <wl@gnu.org>
+
+       [sfnt] Fix Savannah bug #43597.
+
+       * src/sfnt/pngshim.c (Load_SBit_Png): Protect against too large
+       bitmaps.
+
+2014-11-12  Werner Lemberg  <wl@gnu.org>
+
+       [sfnt] Fix Savannah bug #43591.
+
+       * src/sfnt/ttsbit.c (tt_sbit_decoder_init): Protect against addition
+       and multiplication overflow.
+
+2014-11-12  Werner Lemberg  <wl@gnu.org>
+
+       [sfnt] Fix Savannah bug #43590.
+
+       * src/sfnt/ttload.c (check_table_dir, tt_face_load_font_dir):
+       Protect against addition overflow.
+
+2014-11-12  Werner Lemberg  <wl@gnu.org>
+
+       [sfnt] Fix Savannah bug #43589.
+
+       * src/sfnt/sfobjs.c (woff_open_font): Protect against addition
+       overflow.
+
+2014-11-12  Werner Lemberg  <wl@gnu.org>
+
+       [sfnt] Fix Savannah bug #43588.
+
+       * src/sfnt/ttcmap.c (tt_cmap8_validate, tt_cmap10_validate,
+       tt_cmap12_validate, tt_cmap13_validate, tt_cmap14_validate): Protect
+       against overflow in additions and multiplications.
+
+2014-11-10  Alexei Podtelezhnikov  <apodtele@gmail.com>
+
+       [base] CORDIC improvements.
+
+       The scaling between the hypotenuse and its CORDIC approximation is
+       based on regression analysis. The smaller padding for `theta' is
+       justifed by its maximum error of less than 6.
+
+       * src/base/fttrigon.c (ft_trig_downscale): Borrow code from
+       ./ftcalc.c (ft_multo64), change linear intercept.
+       (ft_trig_pseudo_polarize): Decrease `theta' padding.
+
+2014-11-09  Werner Lemberg  <wl@gnu.org>
+
+       * src/base/ftstroke.c (ft_stroker_inside): Fix border intersections.
+
+       One more place to check whether `radius' is zero.
+
+       Problem reported by Marco Wertz <marco.wertz@gmx.de>.
+
+2014-11-07  Werner Lemberg  <wl@gnu.org>
+
+       [bdf] Fix Savannah bug #43535.
+
+       * src/bdf/bdflib.c (_bdf_strncmp): New macro that checks one
+       character more than `strncmp'.
+       s/ft_strncmp/_bdf_strncmp/ everywhere.
+
+2014-11-06  Werner Lemberg  <wl@gnu.org>
+
+       [pcf] Fix Savannah bug #43548.
+
+       * src/pcf/pcfread.c (pcf_get_encodings): Add sanity checks for row
+       and column values.
+
+2014-11-06  Werner Lemberg  <wl@gnu.org>
+
+       [pcf] Fix Savannah bug #43547.
+
+       * src/pcf/pcfread.c (pcf_read_TOC): Check `size' and `offset'
+       values.
+
+2014-11-06  Werner Lemberg  <wl@gnu.org>
+
+       * src/pcf/pcfread.c (pcf_read_TOC): Avoid memory leak.
+
+2014-11-03  Infinality  <infinality@infinality.net>
+
+       * src/truetype/ttsubpix.c (COMPATIBILITY_MODE_Rules): Updated.
+
+       The previous commit deteriorates rendering of DejaVu and similar
+       fonts; this gets compensated with this rule.
+
+2014-11-03  Werner Lemberg  <wl@gnu.org>
+
+       * src/truetype/ttinterp.c (Ins_DELTAP): Fix subpixel hinting.
+
+       Before this patch, it was impossible to ever call DELTAP[123] in
+       subpixel hinting mode as described in the ClearType whitepaper; it
+       only worked if in `compatibility mode'.  However, compatibility mode
+       essentially disables SHPIX, completely ruining hinting of
+       ttfautohint output, for example.
+
+       We now follow the whitepaper more closely so that DELTAP[123]
+       instructions for touched points in the non-subpixel direction are
+       executed.
+
+2014-10-31  Alexei Podtelezhnikov  <apodtele@gmail.com>
+
+       [smooth] Improve code readability.
+
+       * src/smooth/ftsmooth.c (ft_smooth_render_generic): Rearrange code.
+
+2014-10-31  Alexei Podtelezhnikov  <apodtele@gmail.com>
+
+       [smooth] Reduce outline translations during rendering.
+
+       * src/smooth/ftsmooth.c (ft_smooth_render_generic): Translate origin
+       virtually by modifying cbox, actually translate outline if cumulative
+       shift is not zero.
+
+2014-10-30  Alexei Podtelezhnikov  <apodtele@gmail.com>
+
+       [smooth] Fix Savannah bug #35604 (cont'd).
+
+       * src/smooth/ftsmooth.c (ft_smooth_render_generic): Remove checks and
+       casts that became unnecessary after the variable type upgrades.
+
+2014-10-29  Alexei Podtelezhnikov  <apodtele@gmail.com>
+
+       [smooth] Improve code readability.
+
+       * src/smooth/ftsmooth.c (ft_smooth_render_generic): Rearrange code.
+
+2014-10-29  Alexei Podtelezhnikov  <apodtele@gmail.com>
+
+       Unify hypotenuse approximations.
+
+       * include/internal/ftcalc.h (FT_HYPOT): Move macro from here...
+       * include/internal/ftobjs.h: ... to here, next to required `FT_ABS'.
+       * src/smooth/ftgrays.c (gray_render_cubic): Use it here.
+
+2014-10-25  Werner Lemberg  <wl@gnu.org>
+
+       [cff] Test valid darkening parameter macros in `ftoption.h'.
+
+       We no longer need an otherwise unused typedef that can cause a gcc
+       warning.
+       Problem reported by Alexei.
+
+       * src/cff/cffobjs.c (cff_driver_init): Use
+       `CFF_CONFIG_OPTION_DARKENING_PARAMETER_XXX' macros directly.
+       (SET_DARKENING_PARAMETERS): Removed.
+       Compile time tests are now ...
+
+       * devel/ftoption.h, include/config/ftoption.h: ... here.
+
+2014-10-25  Alexei Podtelezhnikov  <apodtele@gmail.com>
+
+       Improve flat corner definition.
+
+       * include/internal/ftcalc.h (FT_HYPOT): Macro to approximate Euclidean
+       distance with the alpha max plus beta min algorithm.
+       * src/base/ftcalc.c (ft_corner_is_flat): Use it instead of Taxicab
+       metric.
+
+2014-10-23  David Weiß  <David.Weiss@ptvgroup.com>
+
+       [build] Improve property file for vc2010.
+
+       User-defined properties should be empty by default to prevent linker
+       failures.
+
+       * builds/windows/vc2010/freetype.user.props,
+       builds/windows/vc2010/freetype.vcxproj:
+       s/OptionsDirectory/UserOptionDirectory/.
+       Comment out all user options.
+
+2014-10-23  Werner Lemberg  <wl@gnu.org>
+
+       [cff] Work around bug in preprocessor of MSVC 2010.
+
+       We have been hit by
+
+         https://connect.microsoft.com/VisualStudio/feedback/details/718976/msvc-pr
+
+       * devel/ftoption.h, include/config/ftoption.h: Replace
+       `CFF_CONFIG_OPTION_DARKENING_PARAMETERS' with eight macros
+       `CFF_CONFIG_OPTION_DARKENING_PARAMETER_{X,Y}{1,2,3,4}'.
+
+       * src/cff/cffobjs.c (SET_DARKENING_PARAMETERS): Removed.  We no
+       longer need double expansion.
+       (SET_DARKENING_PARAMETERS_0): Renamed to ...
+       (SET_DARKENING_PARAMETERS): ... this.
+       Update call.
+
+2014-10-20  Werner Lemberg  <wl@gnu.org>
+
+       [sbit] Minor fixes.
+
+       * src/sfnt/ttsbit.c (tt_face_load_sbit) [TT_SBIT_TABLE_TYPE_SBIX]:
+       Accept overlay format also, but emit warning message in that case.
+       (tt_sbit_decoder_load_metrics): Add missing newline to error
+       message.
+       (tt_sbit_load_sbix_image): Add `rgbl' graphic type (as used on iOS
+       7.1) to the list of unsupported formats.
+
+2014-10-19  Alexei Podtelezhnikov  <apodtele@gmail.com>
+
+       [truetype] Clean up bytecode rounding.
+
+       Zero distance does not have to be treated specially if you follow
+       specifications and check the sign as the very last step of rounding.
+
+       * src/truetype/ttinterp.c (Round_None, Round_To_Grid,
+       Round_Down_To_Grid, Round_Up_To_Grid, Round_To_Double_Grid): Use
+       macros when available, do not check for non-zero distance.
+       (Round_To_Half_Grid, Round_Super, Round_Super_45): Ditto, return phase
+       if sign changed.
+
+2014-10-18  Alexei Podtelezhnikov  <apodtele@gmail.com>
+
+       [truetype] Unwrap engine compensation settings.
+
+       * src/truetype/ttobjs.c (tt_size_init_bytecode): Updated.
+
+2014-10-18  David Weiß  <David.Weiss@ptvgroup.com>
+
+       [build] Add property file to vc2010 project.
+
+       This simplifies custom build configurations, especially for
+       automated build environments.
+
+       * builds/windows/vc2010/freetype.user.props: New configuration file.
+
+       * builds/windows/vc2010/freetype.vcxproj: Include
+       `freetype.user.props' and use its data fields.
+
+       * builds/windows/vc2010/index.html: Updated.
+
+2014-10-18  Werner Lemberg  <wl@gnu.org>
+
+       [autofit] Add blue-zone support for Telugu.
+
+       This essentially moves the Telugu script from the `Indic' hinter to
+       the `Latin' hinter.
+
+       Note that this is a first shot and quite certainly needs
+       refinements.
+
+       * src/autofit/afblue.dat: Add blue zone data for Telugu.
+
+       * src/autofit/afblue.c, src/autofit/afblue.h: Regenerated.
+
+       * src/autofit/afscript.h: Add Telugu standard characters and move
+       data out of AF_CONFIG_OPTION_INDIC block.
+
+       * src/autofit/afranges.c: Move Telugu data out of
+       AF_CONFIG_OPTION_INDIC block.
+
+       * src/autofit/afstyles.h: Update Telugu data; in particular, use
+       AF_WRITING_SYSTEM_LATIN.
+
+2014-10-18  David Wimsey  <david@wimsey.us>
+
+       [cmake] Add iOS build support.
+       From Savannah patch #8497.
+
+       * builds/cmake/iOS.cmake: New file.  Universal binaries are built
+       with both 32 and 64 bit arm architectures.
+
+       * CMakeLists.txt (IOS_PLATFORM): New variable for running the iOS
+       toolchain.  Possible values are `OS' to build on iOS, or
+       `SIMULATOR' to build on APPLE.
+
+2014-10-16  Behdad Esfahbod  <behdad@behdad.org>
+           Werner Lemberg  <wl@gnu.org>
+
+       [cff] Add `CFF_CONFIG_OPTION_DARKENING_PARAMETERS' config macro.
+
+       * devel/ftoption.h, include/config/ftoption.h
+       (CFF_CONFIG_OPTION_DARKENING_PARAMETERS): New macro.
+
+       * src/cff/cffobjs.c (SET_DARKENING_PARAMETERS,
+       SET_DARKENING_PARAMETERS_0): New macros.
+       (cff_driver_init): Use new macros.
+
+2014-10-14  Alexei Podtelezhnikov  <apodtele@gmail.com>
+
+       [truetype] Limit delta shift range.
+
+       The valid range for delta shift is zero through six.  Negative values
+       are invalid according to
+
+         https://developer.apple.com/fonts/TrueType-Reference-Manual/RM04/Chap4.html#delta%20shift
+
+       * src/truetype/ttobjs.h (delta_shift, delta_base): Make unsigned.
+       * src/truetype/ttinterp.h (DO_SDS): Throw an error if `delta_shift'
+       is out of range.
+       (Ins_DELTAP, Ins_DELTAC): Optimize for valid `delta_shift'.
+
+2014-10-16  Werner Lemberg  <wl@gnu.org>
+
+       A better fix for Savannah bug #43392.
+       Suggested by Doug Felt <dougfelt@gmail.com>.
+
+       * src/sfnt/ttsbit.c (tt_sbit_decoder_load_metrics): Set
+       `vertAdvance' to zero...
+
+       * src/truetype/ttgload.c (TT_Load_Glyph): ... and set here a default
+       value for `vertAdvance' based on `linearVertAdvance' in case
+       `vertAdvance' is zero.  Note that the previous computed ad-hoc value
+       for `linearVertAdvance' was apparently not tested in a real-life
+       situation.
+
+2014-10-14  David Weiß  <David.Weiss@ptvgroup.com>
+
+       [build] Better optimization settings for vc2010 solution file.
+
+       * builds/windows/vc2010/freetype.sln,
+       builds/windows/vc2010/freetype.vcxproj: Updated.
+
+2014-10-14  Werner Lemberg  <wl@gnu.org>
+
+       [autofit] Adjust Devenagari character range.
+
+       * src/autofit/afranges.c (af_deva_uniranges): Omit characters that
+       are common to all other Indic scripts.
+
+2014-10-12  Werner Lemberg  <wl@gnu.org>
+
+       [sfnt] Fix Savannah bug #43392.
+
+       * src/sfnt/ttsbit.c (tt_sbit_decoder_load_metrics): Don't let
+       vertical metrics uninitialized.
+
+2014-10-11  Alexei Podtelezhnikov  <apodtele@gmail.com>
+
+       [base] Small bbox correction.
+
+       * src/base/ftbbox.c (FT_Outline_Get_BBox): Start from nonsense bbox
+       instead of initial point that could be `off' in conic outlines.
+
+2014-10-08  Alexei Podtelezhnikov  <apodtele@gmail.com>
+
+       [base] Fix Savannah bug #43356.
+
+       * src/base/ftbbox.c (BBox_Move_To, BBox_Conic_To): Update bbox in case
+       of implicit `to'.
+       (BBox_Line_To): New emitter that does not update bbox.
+
+2014-10-08  Alexei Podtelezhnikov  <apodtele@gmail.com>
+
+       [base] Introduce and use new macro `FT_UPDATE_BBOX'
+
+       * src/base/ftbbox.c (FT_UPDATE_BBOX): New macro.
+       (FT_Outline_Get_BBox): Use it here.
+
+2014-10-02  Alexei Podtelezhnikov  <apodtele@gmail.com>
+
+       [base] Significant optimization of `ft_div64by32'
+
+       We shift as many bits as we can into the high register, perform
+       32-bit division with modulo there, then work through the remaining
+       bits with long division. This optimization is especially noticeable
+       for smaller dividends that barely use the high register.
+
+       * src/base/ftcalc.c (ft_div64by32): Updated.
+
+2014-10-02  Dave Arnold  <darnold@adobe.com>
+
+       [cff] Fix Savannah bug #43271.
+
+       * src/cff/cf2font.c (cf2_computeDarkening): Change overflow
+       detection to use logarithms and clamp `scaledStem'.
+
+2014-10-01  Alexei Podtelezhnikov  <apodtele@gmail.com>
+
+       * src/base/ftcalc.c: Remove miscellaneous type casts.
+
+2014-10-01  Alexei Podtelezhnikov  <apodtele@gmail.com>
+
+       [base] Use more common `FT_MSB' implementation with masks.
+
+       * src/base/ftcalc.c (FT_MSB): Updated.
+
+2014-09-30  Alexei Podtelezhnikov  <apodtele@gmail.com>
+
+       [base] Clean up.
+
+       * src/base/ftcalc.c (FT_MOVE_SIGN): New macro for frequently used
+       code.
+
+2014-09-25  Alexei Podtelezhnikov  <apodtele@gmail.com>
+
+       [base] Avoid unnecessary long division.
+
+       This applies to `FT_MulDiv' but not to `FT_DivFix', where overflows or
+       lack thereof are predicted accurately.
+
+       * src/base/ftcalc.c (ft_div64by32): Improve readability.
+       (FT_MulDiv, FT_MulDiv_No_Round) [!FT_LONG64]: Use straight division
+       when multiplication stayed within 32 bits.
+
+2014-09-24  Werner Lemberg  <wl@gnu.org>
+
+       [autofit] Minor clean-ups.
+
+       * src/autofit/afhints.c (AF_FLAGS): Remove obsolete values.
+
+       * src/autofit/afhints.c (af_glyph_hints_dump_points,
+       af_glyph_hints_align_strong_points): Updated.
+
+       * src/autofit/aflatin.c (af_latin_hints_link_segments,
+       af_latin_hints_compute_segments), src/autofit/afcjk.c
+       (af_cjk_hints_link_segments), src/autofit/aflatin2.c
+       (af_latin2_hints_link_segments, af_latin2_hints_compute_segments):
+       There are no longer fake segments since more than 10 years...
+
+2014-09-22  Werner Lemberg  <wl@gnu.org>
+
+       [autofit] Minor code streamlining.
+
+       * src/autofit/afhints.c (af_axis_hints_new_edge): Remove redundant
+       initialization.
+
+2014-09-19  Alexei Podtelezhnikov  <apodtele@gmail.com>
+
+       * src/base/ftcalc.c: Harmonize code.
+
+2014-09-15  Alexei Podtelezhnikov  <apodtele@gmail.com>
+
+       [base] Tighten the overflow check in `FT_MulDiv'.
+
+       * src/base/ftcalc.c (FT_MulDiv) [!FT_LONG64]: Updated.
+
+2014-09-08  Alexei Podtelezhnikov  <apodtele@gmail.com>
+
+       Fix Savannah bug #43153.
+
+       * src/psaux/psconv.c (PS_Conv_ToFixed): Add protection against
+       overflow in `divider'.
+
+2014-09-03  Alexei Podtelezhnikov  <apodtele@gmail.com>
+
+       [base] Tighten the overflow check in `FT_DivFix'.
+
+       This fixes a 13-year old bug. The original overflow check should have
+       been updated when rounding was introduced into this function
+       (c2cd00443b).
+
+       * src/base/ftcalc.c (FT_DivFix) [!FT_LONG64]: Updated.
+       * include/freetype.h (FT_DivFix): Updated documentation.
+
+2014-09-03  Alexei Podtelezhnikov  <apodtele@gmail.com>
+
+       [base] Tighten the overflow check in `FT_MulFix'.
+
+       * src/base/ftcalc.c (FT_MulFix) [!FT_LONG64]: Updated.
+
+2014-09-02  Alexei Podtelezhnikov  <apodtele@gmail.com>
+
+       [truetype] Shortcut ppem calculations for square pixels.
+
+       * src/truetype/ttinterp.h (TT_ExecContextRec): New field
+       `cur_ppem_func' with a function pointer.
+       * src/truetype/ttinterp.c (TT_RunIns): Initialize `cur_ppem_func'
+       depending on the pixel geometry to either...
+       (Current_Ppem_Stretched): ... this for stretched pixels.
+       (Current_Ppem): ... or this for square pixels.
+       (DO_MPPEM, DO_MPS, Ins_DELTAP, Ins_DELTAC): Use `cur_ppem_func'.
+
+2014-08-31  Behdad Esfahbod  <behdad@behdad.org>
+
+       Don't use `register' keyword.  Fixes compiler warnings.
+
+       * src/base/ftcalc.c (FT_Add64) [!FT_LONG64]: Do it.
+       * src/gzip/inftrees.c (huft_build): Ditto.
+       * src/truetype/ttinterp.c (TT_MulFix14_arm): Ditto.
+
+2014-08-24  Alexei Podtelezhnikov  <apodtele@gmail.com>
+
+       [truetype] Optimize DELTAP and DELTAC.
+
+       * src/truetype/ttinterp.c (Ins_DELTAP, Ins_DELTAC): Move ppem
+       calculations outside of the loop.
+
+2014-08-21  Alexei Podtelezhnikov  <apodtele@gmail.com>
+
+       Fix Savannah bug #43033.
+
+       * include/config/ftconfig.h, builds/unix/ftconfig.in,
+       builds/vms/ftconfig.h [FT_LONG64]: Do not disable the macro when
+       64-bit type is `long'.
+
+2014-08-20  Alexei Podtelezhnikov  <apodtele@gmail.com>
+
+       [base] Small optimization of `FT_MulFix'.
+
+       * src/base/ftcalc.c (FT_MulFix): Loosen up the condition for direct
+       32-bit calculations.
+
+2014-08-19  Alexei Podtelezhnikov  <apodtele@gmail.com>
+
+       [base] Use unsigned calculation in `FT_MulDiv'.
+
+       * src/base/ftcalc.c (FT_MulDiv): Updated to expand 32-bit range.
+
+2014-08-18  Alexei Podtelezhnikov  <apodtele@gmail.com>
+
+       [base] Remove truncation in `FT_DivFix'.
+
+       * src/base/ftcalc.c (FT_DivFix): Updated.
+
+2014-08-14  Alexei Podtelezhnikov  <apodtele@gmail.com>
+
+       Minor refactoring.
+
+       * src/base/ftcalc.c (FT_MulDiv, FT_MulDiv_No_Round): Updated.
+
+2014-08-14  Alexei Podtelezhnikov  <apodtele@gmail.com>
+
+       Turn FT_MSB into a macro when using gcc builtins.
+
+       * src/base/ftcalc.c, include/internal/ftcalc.h: Updated.
+
+2014-08-12  Alexei Podtelezhnikov  <apodtele@gmail.com>
+
+       [base] Avoid undefined FT_MSB in `BBox_Cubic_Check'.
+
+       * src/base/ftbbox.c (BBox_Cubic_Check): Update.
+       (update_cubic_max): Repalce with...
+       (cubic_peak): ... this, which now handles upscaling.
+
+2014-08-11  Alexei Podtelezhnikov  <apodtele@gmail.com>
+
+       [base] Handle collapsed outlines to avoid undefined FT_MSB.
+
+       * src/base/ftoutln.c (FT_Outline_Get_Orientation): Update.
+
+2014-08-11  Alexei Podtelezhnikov  <apodtele@gmail.com>
+
+       [base] Restore FT_MulFix inlining.
+
+       * include/freetype.h (FT_MulFix): Unconditionally defined.
+
+       * src/base/ftcalc.c [FT_MULFIX_ASSEMBLER]: Move code from here...
+
+       * include/internal/ftcalc.h [FT_MULFIX_ASSEMBLER]: ... to here,
+       which conditionally replaces the function with an inline version
+       through the macro.
+
+2014-08-08  Alexei Podtelezhnikov  <apodtele@gmail.com>
+
+       * src/base/ftbitmap.c (ft_gray_for_premultiplied_srgb_bgra): Refactor.
+
+2014-07-26  Werner Lemberg  <wl@gnu.org>
+
+       [cff] Fix typo.
+
+       * src/cff/cf2hints.c (cf2_glyphpath_computeOffset): Use correct
+       offsets in third quadrant.
+
+       Reported by maks <maksqwe1@ukr.net>.
+
+2014-07-17  Werner Lemberg  <wl@gnu.org>
+
+       Fix Savannah bug #42788.
+
+       * src/pfr/pfrobjs.c: Include `ftcalc.h'.
+
+2014-07-16  Alexei Podtelezhnikov  <apodtele@gmail.com>
+
+       Replace `ft_highpow2' function.
+
+       * src/pfr/pfrobjs.c (pfr_face_get_kerning): Use `FT_MSB' instead of
+       `ft_highpow2'.
+
+       * src/base/ftutil.c, include/internal/ftobjs.h (ft_highpow2): Remove
+       it.
+
+2014-07-15  Alexei Podtelezhnikov  <apodtele@gmail.com>
+
+       * src/base/ftcalc.c (FT_MSB): Utilize gcc builtins.
+
+2014-07-15  Alexei Podtelezhnikov  <apodtele@gmail.com>
+
+       [base] Move assembler code back in the source file.
+
+       FT_MulFix assembler used to reside in ftcalc.c before f47d263f1b.
+
+       * include/config/ftconfig.h, builds/unix/ftconfig.in,
+       builds/vms/ftconfig.h [FT_MULFIX_ASSEMBLER]: Move code from here...
+
+       * src/base/ftcalc.c [FT_MULFIX_ASSEMBLER]: ... to here.
+
+2014-07-14  Alexei Podtelezhnikov  <apodtele@gmail.com>
+
+       [base] Further clean up color bitmap conversion.
+
+       * src/base/ftbitmap.c (ft_gray_for_premultiplied_srgb_bgra): Stop
+       using FT_MulFix and FT_DivFix since all calculations fit into 32 bits.
+
+2014-07-13  Werner Lemberg  <wl@gnu.org>
+
+       [truetype] Improve handling of buggy `prep' tables.
+
+       In case of an error in the `prep' table, no longer try to execute it
+       again and again.  This makes FreeType handle endless loops in buggy
+       fonts much faster.
+
+       * src/truetype/ttobjs.h (TT_SizeRec): The fields `bytecode_ready'
+       and `cvt_ready' are now negative if not initialized yet, otherwise
+       they indicate the error code of the last run.
+
+       * src/truetype/ttobjs.c (tt_size_run_fpgm, tt_size_run_prep,
+       tt_size_done_bytecode, tt_size_init_bytecode,
+       tt_size_ready_bytecode, tt_size_init, tt_size_done, tt_size_reset):
+       Updated.
+
+       * src/truetype/ttgload.c (tt_loader_init): Updated.
+       * src/truetype/ttinterp.c (TT_RunIns): Force reexecution of `fpgm'
+       and `prep' only if we are in the `glyf' table.
+
+2014-07-12  Werner Lemberg  <wl@gnu.org>
+
+       * builds/vms/ftconfig.h: Synchronize.
+       Problem reported by Alexei.
+
+2014-07-11  Alexei Podtelezhnikov  <apodtele@gmail.com>
+
+       [base] Clean up bitmap conversion.
+
+       * src/base/ftbitmap.c (ft_gray_for_premultiplied_srgb_bgra): Use
+       appropriate FT_DivFix and remove superfluous upscaling.
+
+2014-07-04  Alexei Podtelezhnikov  <apodtele@gmail.com>
+
+       [base] Small optimization of the ancient code.
+
+       * src/base/ftcalc.c (FT_MulDiv, FT_MulDiv_No_Round): Loosen up the
+       condition for direct 32-bit calculations.
+
+2014-06-27  Werner Lemberg  <wl@gnu.org>
+
+       Fix Apple standard glyph names.
+
+       * src/sfnt/ttpost.c (tt_post_default_names): Synchronize with
+       `tools/glnames.py'
+
+       Problem reported by Adam Twardoch <adam@fontlab.com>.
+
+2014-06-17  Werner Lemberg  <wl@gnu.org>
+
+       Partially revert commit from 2014-06-13.
+
+       * src/autofit/aflatin.c (af_latin_metrics_init_blues): Move
+       declaration of `p_first' and `p_last' out of the loop.
+
+2014-06-17  Werner Lemberg  <wl@gnu.org>
+
+       * builds/unix/freetype2.m4: s/AC_PATH_PROG/AC_PATH_TOOL/.
+
+       This simplifies cross-compiling.
+
+2014-06-13  Werner Lemberg  <wl@gnu.org>
+
+       Fix more compiler warnings.
+       Reported by Wojciech Mamrak <wmamrak@gmail.com>.
+
+       * src/autofit/afglobal.c (af_face_globals_compute_style_coverage):
+       Make integer constant unsigned.
+
+       * src/sfnt/ttsbit.c (tt_face_load_strike_metrics)
+       <TT_SBIT_TABLE_TYPE_SBIX>: Fix types.
+       (tt_sbit_decoder_load_compound, tt_face_load_sbix_image): Add proper
+       casts.
+
+2014-06-13  Werner Lemberg  <wl@gnu.org>
+
+       Fix compiler warnings.
+       Reported by Wojciech Mamrak <wmamrak@gmail.com>.
+
+       * src/autofit/afglobal.c (af_face_globals_compute_style_coverage),
+       src/autofit/afmodule.c (af_property_set): Fix `signed' vs.
+       `unsigned' issues.
+
+       * src/autofit/aflatin.c (af_latin_metrics_init_blues): Make compiler
+       happy.
+
+       * src/base/ftlcdfil.c (_ft_lcd_filter_fir): Use only four elements
+       for `fir'.
+       Fix `signed' vs. `unsigned' issues.
+
+       * src/sfnt/sfobjs.c (WRITE_BYTE): Removed, unused.
+       (WRITE_USHORT, WRITE_ULONG): Add proper casts.
+
+       * src/truetype/ttgload.c (TT_Get_VMetrics): Add proper casts.
+
+       * src/truetype/ttinterp.c (Ins_DELTAP): Add proper casts for `B1'
+       and `B2'.
+
+2014-05-16  Alexey Petruchik  <alexey.petruchik@gmail.com>
+
+       [cmake] Add option to build OS X framework.
+
+       * CMakeLists.txt: Update accordingly.
+
+       * builds/mac/freetype-Info.plist: New file.
+
+2014-05-13  Pavel Koshevoy  <pkoshevoy@gmail.com>
+
+       * CMakeLists.txt (BASE_SRCS): Add missing `ftbdf.c'.
+
+2014-05-11  Werner Lemberg  <wl@gnu.org>
+
+       [autofit] Fix variable initializations.
+
+       * src/autofit/afhints.c (af_glyph_hints_reload): Assign default
+       values to `in_dir' and `out_dir' for all points.
+
+2014-05-11  Werner Lemberg  <wl@gnu.org>
+
+       [autofit] Fix crash with font `CabinSketch-Bold.ttf'.
+
+       Problem reported by Ralf S. Engelschall <rse@engelschall.com>.
+
+       * src/autofit/afhints.c (af_glyph_hints_reload): Fix threshold for
+       finding first non-near point.
+       Properly initialize non-near point deltas.
+
+2014-05-01  Werner Lemberg  <wl@gnu.org>
+
+       [autofit] Add blue-zone support for Devanagari.
+
+       This essentially moves the Devanagari script from the `Indic' hinter
+       to the `Latin' hinter.  Thanks to Girish Dalvi
+       <girish.dalvi@gmail.com> for guidance with blue zone characters!
+
+       * src/autofit/afblue.dat: Add blue zone data for Devanagari.
+
+       * src/autofit/afblue.c, src/autofit/afblue.h: Regenerated.
+
+       * src/autofit/afscript.h: Add Devanagari standard characters and
+       move data out of AF_CONFIG_OPTION_INDIC block.
+
+       * src/autofit/afranges.c: Move Devanagari data out of
+       AF_CONFIG_OPTION_INDIC block.
+       Move U+20B9, (new) Rupee sign, from Latin to Devanagari.
+
+       * src/autofit/afstyles.h: Update Devanagari data; in particular, use
+       AF_WRITING_SYSTEM_LATIN.
+
+2014-05-01  Werner Lemberg  <wl@gnu.org>
+
+       [autofit] Fix handling of neutral blue zones in stems.
+
+       * src/autofit/afhints.h (AF_Edge_Flags): New value
+       `AF_EDGE_NEUTRAL'.
+
+       * src/autofit/aflatin.c (af_latin_hints_compute_blue_edges): Trace
+       neutral blue zones with AF_EDGE_NEUTRAL.
+       (af_latin_hint_edges): Skip neutral blue zones if necessary.
+
+2014-04-28  Werner Lemberg  <wl@gnu.org>
+
+       [autofit] Introduce neutral blue zones to the latin module.
+
+       Such blue zones match either the top or the bottom of a contour.  We
+       need them for scripts where accent-like elements directly touch the
+       base character (for example, some vowel signs in Devanagari, cf.
+       U+0913 or U+0914).
+
+       * src/autofit/afblue.hin (AF_BLUE_PROPERTY_LATIN_NEUTRAL): New
+       property.
+
+       * src/autofit/afblue.h: Regenerated.
+
+       * src/autofit/aflatin.h (AF_LATIN_IS_NEUTRAL_BLUE): New macro.
+       (AF_LATIN_BLUE_NEUTRAL): New enumeration value.
+
+       * src/autofit/aflatin.c (af_latin_metrics_init_blues,
+       af_latin_hints_compute_blue_edges): Handle neutral blue zones.
+
+2014-04-25  Werner Lemberg  <wl@gnu.org>
+
+       * src/autofit/hbshim.c: Partially revert commit from 2014-04-17.
+
+       Using input glyph coverage data is simply wrong.
+
+       Problem reported by Nikolaus Waxweiler <madigens@gmail.com> and
+       Mantas Mikulėnas <grawity@gmail.com>.
+
+2014-04-23  Werner Lemberg  <wl@gnu.org>
+
+       * src/raster/ftraster.c (Vertical_Sweep_Span): Use drop-out mode.
+
+       This spot has been missed while introducing support for various
+       drop-out modes years ago (including no drop-out mode, which this
+       commit fixes).
+
+       Problem reported by Patrick Thomas <pthomas505@gmail.com>.
+
+2014-04-22  Werner Lemberg  <wl@gnu.org>
+
+       * src/sfnt/pngshim.c (error_callback): s/longjmp/ft_longjmp/.
+
+2014-04-20  Werner Lemberg  <wl@gnu.org>
+
+       [autofit] Fix Savannah bug #42148.
+
+       The adaptation of the cjk auto-hinter module to blue stringsets in
+       2013-08-25 had three severe bugs.  Mea culpa.
+
+       1. Contrary to the latin auto-hinter, characters for reference and
+          overshoot values of a blue zone are specified separately.  Due to
+          the screwed-up change it didn't work at all.
+
+       2. A boolean comparison was erroneously replaced with a cast,
+          causing invalid results with the `^' operator later on.  The
+          visual artifact caused by this problem is the topic of the bug
+          report.
+
+       3. Two flag values were inverted, causing incorrect assignment of
+          reference and overshoot values.
+
+       * src/autofit/afblue.dat: Fix CJK bluestrings, introducing a new
+       syntax to have both reference and overshoot characters in a single
+       string.  This is error #1.
+       Add extensive comments.
+
+       * src/autofit/afblue.hin (AF_BLUE_PROPERTY_CJK_FILL): Removed, no
+       longer used.
+       (AF_BLUE_PROPERTY_CJK_TOP, AF_BLUE_PROPERTY_CJK_HORIZ): Fix values.
+       This is error #3.
+
+       * src/autofit/afblue.c, src/autofit/afblue.h: Regenerated.
+
+       * src/autofit/afcjk.c (af_cjk_metrics_init_blues): Correct error #1.
+       Use character `|' to separate characters for reference and overshoot
+       values.
+       Improve tracing messages, synchronizing them with the latin
+       auto-hinter.
+       (af_cjk_hints_compute_blue_edges): Fix value of `is_top_right_blue'.
+       This is error #2.
+       (af_cjk_align_linked_edge): Add tracing message.
+
+       * src/autofit/afcjk.h (AF_CJK_IS_FILLED_BLUE): Removed, no longer
+       used.
+
+2014-04-17  Werner Lemberg  <wl@gnu.org>
+
+       [autofit] More coverage fixes for complex scripts.
+
+       * src/autofit/hbshim.c (af_get_coverage): Merge input glyph coverage
+       of GSUB lookups into output coverage.  Otherwise, ligatures are not
+       handled properly.
+       Don't check blue zone characters for default coverage.
+
+2014-04-17  Werner Lemberg  <wl@gnu.org>
+
+       Make `FT_Get_SubGlyph_Info' actually work.
+
+       * src/base/ftobjs.c (FT_Get_SubGlyph_Info): Return FT_Err_Ok
+       if there is no error.
+
+2014-04-15  Werner Lemberg  <wl@gnu.org>
+
+       [afblue.pl]: Minor improvements.
+
+       * src/tools/afblue.pl: Allow whitespace before comments.
+       Ignore whitespace in strings.
+
+2014-04-14  Werner Lemberg  <wl@gnu.org>
+
+       [autofit] Improve coverage handling.
+
+       * src/autofit/hbshim.c (af_get_coverage): Don't exclude glyphs
+       appearing in the GPOS table if we are processing the default
+       coverage.
+
+2014-04-13  David Weber <weber.aulendorf@googlemail.com>
+
+       [smooth] Fix stand-alone compilation.
+
+       * src/smooth/ftgrays.c (FT_BEGIN_STMNT, FT_END_STMNT): Define.
+
+2014-04-12  Werner Lemberg  <wl@gnu.org>
+
+       [autofit] Redesign the recognition algorithm of strong points.
+
+       In particular, local extrema without horizontal or vertical segments
+       are better recognized:
+
+         + A                + D
+          \                /
+           \              /
+            \            /
+             \          /
+              \        + C
+               \    /
+              B +/
+
+       If the distances AB and CD are large, point B wasn't previously
+       detected as an extremum since the `ft_corner_is_flat' function
+       `swallowed' BC regardless of its direction, tagging point B as weak.
+       The next iteration started at B and made `ft_corner_is_flat' swallow
+       point C, tagging it as weak also, et voilà.
+
+       To improve that, another pass gets now performed before calling
+       `ft_corner_is_flat' to improve the `topology' of an outline: A
+       sequence of non-horizontal or non-vertical vectors that point into
+       the same quadrant are handled as a single, large vector.
+
+       Additionally, distances of near points are now accumulated, which
+       makes the auto-hinter handle them as if they were prepended to the
+       next non-near vector.
+
+       This generally improves the auto-hinter's rendering results.
+
+       * src/autofit/afhints.c (af_glyph_hints_reload): Implement it.
+
+       * src/autofit/afhints.h (AF_FLAGS): Remove no longer used flag
+       `AF_FLAG_NEAR'.
+
+2014-04-05  Werner Lemberg  <wl@gnu.org>
+
+       [autofit] Improve scoring algorithm for identifying stems.
+
+       Problem reported by Karsten Lücke <karsten.luecke@kltf.de>.
+
+       The new algorithm takes care of the width of stems: If the distance
+       between two segments is larger than the largest stem width, the
+       demerits quickly increase for larger distances.  This improves
+       hinting of slanted fonts (especially if the inner parts of serifs
+       have non-horizontal `shoulders'), avoiding false stem links.
+
+       * src/autofit/aflatin.c (af_latin_hints_link_segments): Use largest
+       stem width (if available) to compute better demerits for distances
+       between stems.
+       (af_latin_hints_detect_features): Pass stem width array and array
+       size.
+       (af_latin_metrics_init_widths): Updated to use original algorithm.
+       (af_latin_hints_apply): Updated to use new algorithm.
+
+       * src/autofit/aflatin.h: Updated.
+       * src/autofit/afcjk.c: Updated.
+
+2014-04-03  Werner Lemberg  <wl@gnu.org>
+
+       Don't require `gzip' module for `sfnt'.
+
+       Reported by Preet <prismatic.project@gmail.com>.
+
+       * src/sfnt/sfobjs.c (woff_open_font): Guard use of
+       FT_Gzip_Uncompress with FT_CONFIG_OPTION_USE_ZLIB.
+
+2014-03-27  Werner Lemberg  <wl@gnu.org>
+
+       Fix Savannah bug #38235.
+
+       Work around a bug in pkg-config version 0.28 and earlier: If a
+       variable value gets surrounded by doublequotes (in particular values
+       for the `prefix' variable), the prefix override mechanism fails.
+
+       * builds/unix/freetype2.in: Don't use doublequotes.
+       * builds/unix/unix-def.in (freetype.pc): Escape spaces in directory
+       names with backslashes.
+
+2014-03-24  Werner Lemberg  <wl@gnu.org>
+
+       Fix Savannah bug #41946.
+
+       Based on a patch from Marek Kašík <mkasik@redhat.com>.
+
+       * builds/unix/configure.raw (LIBS_CONFIG): Remove.
+       * builds/unix/freetype-config.in (libs): Hard-code value.
+       * builds/unix/unix-def.in: Updated.
+
+2014-03-22  Werner Lemberg  <wl@gnu.org>
+
+       Another revert for the change from 2014-03-18.
+
+       Problem reported by Nikolaus Waxweiler <madigens@gmail.com>.
+
+       * src/base/ftcalc.c (FT_MulFix): Ensure that an `FT_MulFix' symbol
+       gets always exported.
+
+2014-03-20  Werner Lemberg  <wl@gnu.org>
+
+       CMakeLists.txt: Another fix for include directories.
+
+       Problem reported by Taylor Holberton <taylorcholberton@gmail.com>.
+
+2014-03-19  Werner Lemberg  <wl@gnu.org>
+
+       CMakeLists.txt: Fix include directories.
+
+       Problem reported by Taylor Holberton <taylorcholberton@gmail.com>.
+
+2014-03-19  Werner Lemberg  <wl@gnu.org>
+
+       Partially revert last commit.
+
+       Found by Alexei.
+
+       * src/autofit/aflatin.c (af_latin_metrics_init_blues): Initializing
+       those variables is plain wrong, since we are in a loop.
+
+2014-03-18  Sean McBride  <sean@rogue-research.com>
+           Werner Lemberg  <wl@gnu.org>
+
+       Fix clang warnings.
+
+       * src/autofit/aflatin.c (af_latin_metrics_init_blues): Initialize
+       some variables.
+
+       * src/base/ftcalc.c (FT_MulFix): Only use code if
+       `FT_MULFIX_INLINED' is not defined.
+
+       * src/bdf/bdfdrivr.c (bdf_cmap_class), src/cache/ftcbasic.c
+       (ftc_basic_image_family_class, ftc_basic_image_cache_class,
+       ftc_basic_sbit_family_class, ftc_basic_sbit_cache_class),
+       src/cache/ftccmap.c (ftc_cmap_cache_class), src/cache/ftcmanag.c
+       (ftc_size_list_class, ftc_face_list_class), src/pcf/pcfdrivr.c
+       (pcf_cmap_class), src/pfr/pfrdrivr.c (pfr_metrics_service_rec): Make
+       function static.
+
+       * src/type1/t1driver.c (t1_ps_get_font_value): Remove redundant
+       code.
+
+2014-03-17  Werner Lemberg  <wl@gnu.org>
+
+       Fix Savannah bug #41869.
+
+       This works around a problem with HarfBuzz (<= 0.9.26), which doesn't
+       validate glyph indices returned by
+       `hb_ot_layout_lookup_collect_glyphs'.
+
+       * src/autofit/hbshim.c (af_get_coverage): Guard `idx'.
+
+       * docs/CHANGES: Updated.
+
+2014-03-14  Werner Lemberg  <wl@gnu.org>
+
+       * builds/unix/configure.raw: Don't show error messages of `which'.
+
+2014-03-09  Alan Coopersmith  <alan.coopersmith@oracle.com>
+
+       Fix cppcheck 1.64 warning.
+
+       * src/autofit/afglobal.c (af_face_globals_new): Catch NULL pointer
+       dereference in case of error.
+
+2014-03-09  Sean McBride  <sean@rogue-research.com>
+
+       * src/sfnt/ttcmap.c (tt_face_build_cmaps): Remove clang warning.
+
 2014-03-06  Werner Lemberg  <wl@gnu.org>
 
        * Version 2.5.3 released.
        option.
        (libs): Updated.
        (staticlibs): New variable, to be used if `--static' is given.
-       * builds/doc/freetype-config.1: Document `--static'.
+       * docs/freetype-config.1: Document `--static'.
 
        * builds/unix/freetype2.in, builds/unix/unix-def.in: Updated.
 
index 9a793cd..f00a1ab 100644 (file)
@@ -1,4 +1,4 @@
-  FreeType 2.5.3
+  FreeType 2.5.5
   ==============
 
   Homepage: http://www.freetype.org
@@ -24,9 +24,9 @@
 
   and download one of the following files.
 
-    freetype-doc-2.5.3.tar.bz2
-    freetype-doc-2.5.3.tar.gz
-    ftdoc253.zip
+    freetype-doc-2.5.5.tar.bz2
+    freetype-doc-2.5.5.tar.gz
+    ftdoc255.zip
 
   To view the documentation online, go to
 
   Bugs
   ====
 
-  Please report bugs  by e-mail to `freetype-devel@nongnu.org'.  Don't
-  forget to  send a  detailed explanation of  the problem --  there is
-  nothing  worse than  receiving a  terse message  that only  says `it
-  doesn't work'.
-
-  Alternatively, you may submit a bug report at
+  Please submit bug reports at
 
     https://savannah.nongnu.org/bugs/?group=freetype
 
+  Alternatively,    you   might    report    bugs    by   e-mail    to
+  `freetype-devel@nongnu.org'.   Don't  forget   to  send  a  detailed
+  explanation of the problem --  there is nothing worse than receiving
+  a terse message that only says `it doesn't work'.
+
 
   Enjoy!
 
index d7b6a63..10027bb 100644 (file)
@@ -4,7 +4,7 @@
 /*                                                                         */
 /*    User-selectable configuration macros (specification only).           */
 /*                                                                         */
-/*  Copyright 1996-2013 by                                                 */
+/*  Copyright 1996-2014 by                                                 */
 /*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
 /*                                                                         */
 /*  This file is part of the FreeType project, and may only be used,       */
@@ -61,7 +61,7 @@ FT_BEGIN_HEADER
   /*    that are statically linked to the library at compile time.  By     */
   /*    default, this file is <config/ftmodule.h>.                         */
   /*                                                                       */
-  /*  We highly recommend using the third method whenever possible.        */
+  /* We highly recommend using the third method whenever possible.         */
   /*                                                                       */
   /*************************************************************************/
 
@@ -205,7 +205,7 @@ FT_BEGIN_HEADER
 
   /*************************************************************************/
   /*                                                                       */
-  /*  PNG bitmap support.                                                  */
+  /* PNG bitmap support.                                                   */
   /*                                                                       */
   /*   FreeType now handles loading color bitmap glyphs in the PNG format. */
   /*   This requires help from the external libpng library.  Uncompressed  */
@@ -219,7 +219,7 @@ FT_BEGIN_HEADER
 
   /*************************************************************************/
   /*                                                                       */
-  /*  HarfBuzz support.                                                    */
+  /* HarfBuzz support.                                                     */
   /*                                                                       */
   /*   FreeType uses the HarfBuzz library to improve auto-hinting of       */
   /*   OpenType fonts.  If available, many glyphs not directly addressable */
@@ -771,6 +771,30 @@ FT_BEGIN_HEADER
   /*************************************************************************/
 
 
+  /*************************************************************************/
+  /*                                                                       */
+  /* Using CFF_CONFIG_OPTION_DARKENING_PARAMETER_{X,Y}{1,2,3,4} it is      */
+  /* possible to set up the default values of the four control points that */
+  /* define the stem darkening behaviour of the (new) CFF engine.  For     */
+  /* more details please read the documentation of the                     */
+  /* `darkening-parameters' property of the cff driver module (file        */
+  /* `ftcffdrv.h'), which allows the control at run-time.                  */
+  /*                                                                       */
+  /* Do *not* undefine these macros!                                       */
+  /*                                                                       */
+#define CFF_CONFIG_OPTION_DARKENING_PARAMETER_X1   500
+#define CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y1   400
+
+#define CFF_CONFIG_OPTION_DARKENING_PARAMETER_X2  1000
+#define CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y2   275
+
+#define CFF_CONFIG_OPTION_DARKENING_PARAMETER_X3  1667
+#define CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y3   275
+
+#define CFF_CONFIG_OPTION_DARKENING_PARAMETER_X4  2333
+#define CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y4     0
+
+
   /*************************************************************************/
   /*                                                                       */
   /* CFF_CONFIG_OPTION_OLD_ENGINE controls whether the pre-Adobe CFF       */
@@ -820,8 +844,8 @@ FT_BEGIN_HEADER
 
 
   /*
-   *  This macro is obsolete.  Support has been removed in FreeType
-   *  version 2.5.
+   * This macro is obsolete.  Support has been removed in FreeType
+   * version 2.5.
    */
 /* #define FT_CONFIG_OPTION_OLD_INTERNALS */
 
@@ -837,6 +861,35 @@ FT_BEGIN_HEADER
 #define  TT_USE_BYTECODE_INTERPRETER
 #endif
 
+
+  /*
+   * Check CFF darkening parameters.  The checks are the same as in function
+   * `cff_property_set' in file `cffdrivr.c'.
+   */
+#if CFF_CONFIG_OPTION_DARKENING_PARAMETER_X1 < 0   || \
+    CFF_CONFIG_OPTION_DARKENING_PARAMETER_X2 < 0   || \
+    CFF_CONFIG_OPTION_DARKENING_PARAMETER_X3 < 0   || \
+    CFF_CONFIG_OPTION_DARKENING_PARAMETER_X4 < 0   || \
+                                                      \
+    CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y1 < 0   || \
+    CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y2 < 0   || \
+    CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y3 < 0   || \
+    CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y4 < 0   || \
+                                                      \
+    CFF_CONFIG_OPTION_DARKENING_PARAMETER_X1 >        \
+      CFF_CONFIG_OPTION_DARKENING_PARAMETER_X2     || \
+    CFF_CONFIG_OPTION_DARKENING_PARAMETER_X2 >        \
+      CFF_CONFIG_OPTION_DARKENING_PARAMETER_X3     || \
+    CFF_CONFIG_OPTION_DARKENING_PARAMETER_X3 >        \
+      CFF_CONFIG_OPTION_DARKENING_PARAMETER_X4     || \
+                                                      \
+    CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y1 > 500 || \
+    CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y2 > 500 || \
+    CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y3 > 500 || \
+    CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y4 > 500
+#error "Invalid CFF darkening parameters!"
+#endif
+
 FT_END_HEADER
 
 
index d98a311..22d70fd 100644 (file)
@@ -266,7 +266,16 @@ FT_BEGIN_HEADER
 #define FT_INT64   long
 #define FT_UINT64  unsigned long
 
-#elif defined( _MSC_VER ) && _MSC_VER >= 900  /* Visual C++ (and Intel C++) */
+  /*************************************************************************/
+  /*                                                                       */
+  /* A 64-bit data type may create compilation problems if you compile     */
+  /* in strict ANSI mode.  To avoid them, we disable other 64-bit data     */
+  /* types if __STDC__ is defined.  You can however ignore this rule       */
+  /* by defining the FT_CONFIG_OPTION_FORCE_INT64 configuration macro.     */
+  /*                                                                       */
+#elif !defined( __STDC__ ) || defined( FT_CONFIG_OPTION_FORCE_INT64 )
+
+#if defined( _MSC_VER ) && _MSC_VER >= 900  /* Visual C++ (and Intel C++) */
 
   /* this compiler provides the __int64 type */
 #define FT_LONG64
@@ -300,27 +309,9 @@ FT_BEGIN_HEADER
 #define FT_INT64   long long int
 #define FT_UINT64  unsigned long long int
 
-#endif /* FT_SIZEOF_LONG == (64 / FT_CHAR_BIT) */
-
-
-  /*************************************************************************/
-  /*                                                                       */
-  /* A 64-bit data type will create compilation problems if you compile    */
-  /* in strict ANSI mode.  To avoid them, we disable its use if __STDC__   */
-  /* is defined.  You can however ignore this rule by defining the         */
-  /* FT_CONFIG_OPTION_FORCE_INT64 configuration macro.                     */
-  /*                                                                       */
-#if defined( FT_LONG64 ) && !defined( FT_CONFIG_OPTION_FORCE_INT64 )
-
-#ifdef __STDC__
-
-  /* undefine the 64-bit macros in strict ANSI compilation mode */
-#undef FT_LONG64
-#undef FT_INT64
-
-#endif /* __STDC__ */
+#endif /* _MSC_VER */
 
-#endif /* FT_LONG64 && !FT_CONFIG_OPTION_FORCE_INT64 */
+#endif /* FT_SIZEOF_LONG == (64 / FT_CHAR_BIT) */
 
 #ifdef FT_LONG64
   typedef FT_INT64   FT_Int64;
@@ -333,219 +324,6 @@ FT_BEGIN_HEADER
 #define FT_DUMMY_STMNT  FT_BEGIN_STMNT FT_END_STMNT
 
 
-#ifndef  FT_CONFIG_OPTION_NO_ASSEMBLER
-  /* Provide assembler fragments for performance-critical functions. */
-  /* These must be defined `static __inline__' with GCC.             */
-
-#if defined( __CC_ARM ) || defined( __ARMCC__ )  /* RVCT */
-
-#define FT_MULFIX_ASSEMBLER  FT_MulFix_arm
-
-  /* documentation is in freetype.h */
-
-  static __inline FT_Int32
-  FT_MulFix_arm( FT_Int32  a,
-                 FT_Int32  b )
-  {
-    register FT_Int32  t, t2;
-
-
-    __asm
-    {
-      smull t2, t,  b,  a           /* (lo=t2,hi=t) = a*b */
-      mov   a,  t,  asr #31         /* a   = (hi >> 31) */
-      add   a,  a,  #0x8000         /* a  += 0x8000 */
-      adds  t2, t2, a               /* t2 += a */
-      adc   t,  t,  #0              /* t  += carry */
-      mov   a,  t2, lsr #16         /* a   = t2 >> 16 */
-      orr   a,  a,  t,  lsl #16     /* a  |= t << 16 */
-    }
-    return a;
-  }
-
-#endif /* __CC_ARM || __ARMCC__ */
-
-
-#ifdef __GNUC__
-
-#if defined( __arm__ )                                 && \
-    ( !defined( __thumb__ ) || defined( __thumb2__ ) ) && \
-    !( defined( __CC_ARM ) || defined( __ARMCC__ ) )
-
-#define FT_MULFIX_ASSEMBLER  FT_MulFix_arm
-
-  /* documentation is in freetype.h */
-
-  static __inline__ FT_Int32
-  FT_MulFix_arm( FT_Int32  a,
-                 FT_Int32  b )
-  {
-    register FT_Int32  t, t2;
-
-
-    __asm__ __volatile__ (
-      "smull  %1, %2, %4, %3\n\t"       /* (lo=%1,hi=%2) = a*b */
-      "mov    %0, %2, asr #31\n\t"      /* %0  = (hi >> 31) */
-#if defined( __clang__ ) && defined( __thumb2__ )
-      "add.w  %0, %0, #0x8000\n\t"      /* %0 += 0x8000 */
-#else
-      "add    %0, %0, #0x8000\n\t"      /* %0 += 0x8000 */
-#endif
-      "adds   %1, %1, %0\n\t"           /* %1 += %0 */
-      "adc    %2, %2, #0\n\t"           /* %2 += carry */
-      "mov    %0, %1, lsr #16\n\t"      /* %0  = %1 >> 16 */
-      "orr    %0, %0, %2, lsl #16\n\t"  /* %0 |= %2 << 16 */
-      : "=r"(a), "=&r"(t2), "=&r"(t)
-      : "r"(a), "r"(b)
-      : "cc" );
-    return a;
-  }
-
-#endif /* __arm__                      && */
-       /* ( __thumb2__ || !__thumb__ ) && */
-       /* !( __CC_ARM || __ARMCC__ )      */
-
-
-#if defined( __i386__ )
-
-#define FT_MULFIX_ASSEMBLER  FT_MulFix_i386
-
-  /* documentation is in freetype.h */
-
-  static __inline__ FT_Int32
-  FT_MulFix_i386( FT_Int32  a,
-                  FT_Int32  b )
-  {
-    register FT_Int32  result;
-
-
-    __asm__ __volatile__ (
-      "imul  %%edx\n"
-      "movl  %%edx, %%ecx\n"
-      "sarl  $31, %%ecx\n"
-      "addl  $0x8000, %%ecx\n"
-      "addl  %%ecx, %%eax\n"
-      "adcl  $0, %%edx\n"
-      "shrl  $16, %%eax\n"
-      "shll  $16, %%edx\n"
-      "addl  %%edx, %%eax\n"
-      : "=a"(result), "=d"(b)
-      : "a"(a), "d"(b)
-      : "%ecx", "cc" );
-    return result;
-  }
-
-#endif /* i386 */
-
-#endif /* __GNUC__ */
-
-
-#ifdef _MSC_VER /* Visual C++ */
-
-#ifdef _M_IX86
-
-#define FT_MULFIX_ASSEMBLER  FT_MulFix_i386
-
-  /* documentation is in freetype.h */
-
-  static __inline FT_Int32
-  FT_MulFix_i386( FT_Int32  a,
-                  FT_Int32  b )
-  {
-    register FT_Int32  result;
-
-    __asm
-    {
-      mov eax, a
-      mov edx, b
-      imul edx
-      mov ecx, edx
-      sar ecx, 31
-      add ecx, 8000h
-      add eax, ecx
-      adc edx, 0
-      shr eax, 16
-      shl edx, 16
-      add eax, edx
-      mov result, eax
-    }
-    return result;
-  }
-
-#endif /* _M_IX86 */
-
-#endif /* _MSC_VER */
-
-
-#if defined( __GNUC__ ) && defined( __x86_64__ )
-
-#define FT_MULFIX_ASSEMBLER  FT_MulFix_x86_64
-
-  static __inline__ FT_Int32
-  FT_MulFix_x86_64( FT_Int32  a,
-                    FT_Int32  b )
-  {
-    /* Temporarily disable the warning that C90 doesn't support */
-    /* `long long'.                                             */
-#if ( __GNUC__ > 4 ) || ( ( __GNUC__ == 4 ) && ( __GNUC_MINOR__ >= 6 ) )
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wlong-long"
-#endif
-
-#if 1
-    /* Technically not an assembly fragment, but GCC does a really good */
-    /* job at inlining it and generating good machine code for it.      */
-    long long  ret, tmp;
-
-
-    ret  = (long long)a * b;
-    tmp  = ret >> 63;
-    ret += 0x8000 + tmp;
-
-    return (FT_Int32)( ret >> 16 );
-#else
-
-    /* For some reason, GCC 4.6 on Ubuntu 12.04 generates invalid machine  */
-    /* code from the lines below.  The main issue is that `wide_a' is not  */
-    /* properly initialized by sign-extending `a'.  Instead, the generated */
-    /* machine code assumes that the register that contains `a' on input   */
-    /* can be used directly as a 64-bit value, which is wrong most of the  */
-    /* time.                                                               */
-    long long  wide_a = (long long)a;
-    long long  wide_b = (long long)b;
-    long long  result;
-
-
-    __asm__ __volatile__ (
-      "imul %2, %1\n"
-      "mov %1, %0\n"
-      "sar $63, %0\n"
-      "lea 0x8000(%1, %0), %0\n"
-      "sar $16, %0\n"
-      : "=&r"(result), "=&r"(wide_a)
-      : "r"(wide_b)
-      : "cc" );
-
-    return (FT_Int32)result;
-#endif
-
-#if ( __GNUC__ > 4 ) || ( ( __GNUC__ == 4 ) && ( __GNUC_MINOR__ >= 6 ) )
-#pragma GCC diagnostic pop
-#endif
-  }
-
-#endif /* __GNUC__ && __x86_64__ */
-
-#endif /* !FT_CONFIG_OPTION_NO_ASSEMBLER */
-
-
-#ifdef FT_CONFIG_OPTION_INLINE_MULFIX
-#ifdef FT_MULFIX_ASSEMBLER
-#define FT_MULFIX_INLINED  FT_MULFIX_ASSEMBLER
-#endif
-#endif
-
-
 #ifdef FT_MAKE_OPTION_SINGLE_OBJECT
 
 #define FT_LOCAL( x )      static  x
index 5b11f0e..2b0b67e 100644 (file)
@@ -4,7 +4,7 @@
 /*                                                                         */
 /*    User-selectable configuration macros (specification only).           */
 /*                                                                         */
-/*  Copyright 1996-2013 by                                                 */
+/*  Copyright 1996-2014 by                                                 */
 /*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
 /*                                                                         */
 /*  This file is part of the FreeType project, and may only be used,       */
@@ -61,7 +61,7 @@ FT_BEGIN_HEADER
   /*    that are statically linked to the library at compile time.  By     */
   /*    default, this file is <config/ftmodule.h>.                         */
   /*                                                                       */
-  /*  We highly recommend using the third method whenever possible.        */
+  /* We highly recommend using the third method whenever possible.         */
   /*                                                                       */
   /*************************************************************************/
 
@@ -216,7 +216,7 @@ FT_BEGIN_HEADER
 
   /*************************************************************************/
   /*                                                                       */
-  /*  PNG bitmap support.                                                  */
+  /* PNG bitmap support.                                                   */
   /*                                                                       */
   /*   FreeType now handles loading color bitmap glyphs in the PNG format. */
   /*   This requires help from the external libpng library.  Uncompressed  */
@@ -230,7 +230,7 @@ FT_BEGIN_HEADER
 
   /*************************************************************************/
   /*                                                                       */
-  /*  HarfBuzz support.                                                    */
+  /* HarfBuzz support.                                                     */
   /*                                                                       */
   /*   FreeType uses the HarfBuzz library to improve auto-hinting of       */
   /*   OpenType fonts.  If available, many glyphs not directly addressable */
@@ -771,6 +771,30 @@ FT_BEGIN_HEADER
   /*************************************************************************/
 
 
+  /*************************************************************************/
+  /*                                                                       */
+  /* Using CFF_CONFIG_OPTION_DARKENING_PARAMETER_{X,Y}{1,2,3,4} it is      */
+  /* possible to set up the default values of the four control points that */
+  /* define the stem darkening behaviour of the (new) CFF engine.  For     */
+  /* more details please read the documentation of the                     */
+  /* `darkening-parameters' property of the cff driver module (file        */
+  /* `ftcffdrv.h'), which allows the control at run-time.                  */
+  /*                                                                       */
+  /* Do *not* undefine these macros!                                       */
+  /*                                                                       */
+#define CFF_CONFIG_OPTION_DARKENING_PARAMETER_X1   500
+#define CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y1   400
+
+#define CFF_CONFIG_OPTION_DARKENING_PARAMETER_X2  1000
+#define CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y2   275
+
+#define CFF_CONFIG_OPTION_DARKENING_PARAMETER_X3  1667
+#define CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y3   275
+
+#define CFF_CONFIG_OPTION_DARKENING_PARAMETER_X4  2333
+#define CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y4     0
+
+
   /*************************************************************************/
   /*                                                                       */
   /* CFF_CONFIG_OPTION_OLD_ENGINE controls whether the pre-Adobe CFF       */
@@ -820,8 +844,8 @@ FT_BEGIN_HEADER
 
 
   /*
-   *  This macro is obsolete.  Support has been removed in FreeType
-   *  version 2.5.
+   * This macro is obsolete.  Support has been removed in FreeType
+   * version 2.5.
    */
 /* #define FT_CONFIG_OPTION_OLD_INTERNALS */
 
@@ -837,6 +861,35 @@ FT_BEGIN_HEADER
 #define  TT_USE_BYTECODE_INTERPRETER
 #endif
 
+
+  /*
+   * Check CFF darkening parameters.  The checks are the same as in function
+   * `cff_property_set' in file `cffdrivr.c'.
+   */
+#if CFF_CONFIG_OPTION_DARKENING_PARAMETER_X1 < 0   || \
+    CFF_CONFIG_OPTION_DARKENING_PARAMETER_X2 < 0   || \
+    CFF_CONFIG_OPTION_DARKENING_PARAMETER_X3 < 0   || \
+    CFF_CONFIG_OPTION_DARKENING_PARAMETER_X4 < 0   || \
+                                                      \
+    CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y1 < 0   || \
+    CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y2 < 0   || \
+    CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y3 < 0   || \
+    CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y4 < 0   || \
+                                                      \
+    CFF_CONFIG_OPTION_DARKENING_PARAMETER_X1 >        \
+      CFF_CONFIG_OPTION_DARKENING_PARAMETER_X2     || \
+    CFF_CONFIG_OPTION_DARKENING_PARAMETER_X2 >        \
+      CFF_CONFIG_OPTION_DARKENING_PARAMETER_X3     || \
+    CFF_CONFIG_OPTION_DARKENING_PARAMETER_X3 >        \
+      CFF_CONFIG_OPTION_DARKENING_PARAMETER_X4     || \
+                                                      \
+    CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y1 > 500 || \
+    CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y2 > 500 || \
+    CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y3 > 500 || \
+    CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y4 > 500
+#error "Invalid CFF darkening parameters!"
+#endif
+
 FT_END_HEADER
 
 
index fb62b62..27fd44b 100644 (file)
@@ -113,7 +113,8 @@ FT_BEGIN_HEADER
   /*    The FreeType~2 base font interface.                                */
   /*                                                                       */
   /* <Description>                                                         */
-  /*    This section describes the public high-level API of FreeType~2.    */
+  /*    This section describes the most important public high-level API    */
+  /*    functions of FreeType~2.                                           */
   /*                                                                       */
   /* <Order>                                                               */
   /*    FT_Library                                                         */
@@ -122,6 +123,7 @@ FT_BEGIN_HEADER
   /*    FT_GlyphSlot                                                       */
   /*    FT_CharMap                                                         */
   /*    FT_Encoding                                                        */
+  /*    FT_ENC_TAG                                                         */
   /*                                                                       */
   /*    FT_FaceRec                                                         */
   /*                                                                       */
@@ -138,8 +140,22 @@ FT_BEGIN_HEADER
   /*    FT_FACE_FLAG_MULTIPLE_MASTERS                                      */
   /*    FT_FACE_FLAG_GLYPH_NAMES                                           */
   /*    FT_FACE_FLAG_EXTERNAL_STREAM                                       */
-  /*    FT_FACE_FLAG_FAST_GLYPHS                                           */
   /*    FT_FACE_FLAG_HINTER                                                */
+  /*    FT_FACE_FLAG_TRICKY                                                */
+  /*                                                                       */
+  /*    FT_HAS_HORIZONTAL                                                  */
+  /*    FT_HAS_VERTICAL                                                    */
+  /*    FT_HAS_KERNING                                                     */
+  /*    FT_HAS_FIXED_SIZES                                                 */
+  /*    FT_HAS_GLYPH_NAMES                                                 */
+  /*    FT_HAS_MULTIPLE_MASTERS                                            */
+  /*    FT_HAS_COLOR                                                       */
+  /*                                                                       */
+  /*    FT_IS_SFNT                                                         */
+  /*    FT_IS_SCALABLE                                                     */
+  /*    FT_IS_FIXED_WIDTH                                                  */
+  /*    FT_IS_CID_KEYED                                                    */
+  /*    FT_IS_TRICKY                                                       */
   /*                                                                       */
   /*    FT_STYLE_FLAG_BOLD                                                 */
   /*    FT_STYLE_FLAG_ITALIC                                               */
@@ -158,6 +174,7 @@ FT_BEGIN_HEADER
   /*                                                                       */
   /*    FT_New_Face                                                        */
   /*    FT_Done_Face                                                       */
+  /*    FT_Reference_Face                                                  */
   /*    FT_New_Memory_Face                                                 */
   /*    FT_Open_Face                                                       */
   /*    FT_Open_Args                                                       */
@@ -170,10 +187,13 @@ FT_BEGIN_HEADER
   /*    FT_Request_Size                                                    */
   /*    FT_Select_Size                                                     */
   /*    FT_Size_Request_Type                                               */
+  /*    FT_Size_RequestRec                                                 */
   /*    FT_Size_Request                                                    */
   /*    FT_Set_Transform                                                   */
   /*    FT_Load_Glyph                                                      */
   /*    FT_Get_Char_Index                                                  */
+  /*    FT_Get_First_Char                                                  */
+  /*    FT_Get_Next_Char                                                   */
   /*    FT_Get_Name_Index                                                  */
   /*    FT_Load_Char                                                       */
   /*                                                                       */
@@ -190,11 +210,11 @@ FT_BEGIN_HEADER
   /*    FT_LOAD_NO_SCALE                                                   */
   /*    FT_LOAD_NO_HINTING                                                 */
   /*    FT_LOAD_NO_BITMAP                                                  */
-  /*    FT_LOAD_CROP_BITMAP                                                */
+  /*    FT_LOAD_NO_AUTOHINT                                                */
+  /*    FT_LOAD_COLOR                                                      */
   /*                                                                       */
   /*    FT_LOAD_VERTICAL_LAYOUT                                            */
   /*    FT_LOAD_IGNORE_TRANSFORM                                           */
-  /*    FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH                                */
   /*    FT_LOAD_FORCE_AUTOHINT                                             */
   /*    FT_LOAD_NO_RECURSE                                                 */
   /*    FT_LOAD_PEDANTIC                                                   */
@@ -205,6 +225,8 @@ FT_BEGIN_HEADER
   /*    FT_LOAD_TARGET_LCD                                                 */
   /*    FT_LOAD_TARGET_LCD_V                                               */
   /*                                                                       */
+  /*    FT_LOAD_TARGET_MODE                                                */
+  /*                                                                       */
   /*    FT_Render_Glyph                                                    */
   /*    FT_Render_Mode                                                     */
   /*    FT_Get_Kerning                                                     */
@@ -218,14 +240,22 @@ FT_BEGIN_HEADER
   /*    FT_Set_Charmap                                                     */
   /*    FT_Get_Charmap_Index                                               */
   /*                                                                       */
-  /*    FT_FSTYPE_INSTALLABLE_EMBEDDING                                    */
-  /*    FT_FSTYPE_RESTRICTED_LICENSE_EMBEDDING                             */
-  /*    FT_FSTYPE_PREVIEW_AND_PRINT_EMBEDDING                              */
-  /*    FT_FSTYPE_EDITABLE_EMBEDDING                                       */
-  /*    FT_FSTYPE_NO_SUBSETTING                                            */
-  /*    FT_FSTYPE_BITMAP_EMBEDDING_ONLY                                    */
-  /*                                                                       */
   /*    FT_Get_FSType_Flags                                                */
+  /*    FT_Get_SubGlyph_Info                                               */
+  /*                                                                       */
+  /*    FT_Face_Internal                                                   */
+  /*    FT_Size_Internal                                                   */
+  /*    FT_Slot_Internal                                                   */
+  /*                                                                       */
+  /*    FT_FACE_FLAG_XXX                                                   */
+  /*    FT_STYLE_FLAG_XXX                                                  */
+  /*    FT_OPEN_XXX                                                        */
+  /*    FT_LOAD_XXX                                                        */
+  /*    FT_LOAD_TARGET_XXX                                                 */
+  /*    FT_SUBGLYPH_FLAG_XXX                                               */
+  /*    FT_FSTYPE_XXX                                                      */
+  /*                                                                       */
+  /*    FT_HAS_FAST_GLYPHS                                                 */
   /*                                                                       */
   /*************************************************************************/
 
@@ -376,6 +406,13 @@ FT_BEGIN_HEADER
   typedef struct FT_LibraryRec_  *FT_Library;
 
 
+  /*************************************************************************/
+  /*                                                                       */
+  /* <Section>                                                             */
+  /*    module_management                                                  */
+  /*                                                                       */
+  /*************************************************************************/
+
   /*************************************************************************/
   /*                                                                       */
   /* <Type>                                                                */
@@ -415,6 +452,13 @@ FT_BEGIN_HEADER
   typedef struct FT_RendererRec_*  FT_Renderer;
 
 
+  /*************************************************************************/
+  /*                                                                       */
+  /* <Section>                                                             */
+  /*    base_interface                                                     */
+  /*                                                                       */
+  /*************************************************************************/
+
   /*************************************************************************/
   /*                                                                       */
   /* <Type>                                                                */
@@ -727,15 +771,8 @@ FT_BEGIN_HEADER
   } FT_Encoding;
 
 
-  /*************************************************************************/
-  /*                                                                       */
-  /* <Enum>                                                                */
-  /*    ft_encoding_xxx                                                    */
-  /*                                                                       */
-  /* <Description>                                                         */
-  /*    These constants are deprecated; use the corresponding @FT_Encoding */
-  /*    values instead.                                                    */
-  /*                                                                       */
+  /* these constants are deprecated; use the corresponding `FT_Encoding' */
+  /* values instead                                                      */
 #define ft_encoding_none            FT_ENCODING_NONE
 #define ft_encoding_unicode         FT_ENCODING_UNICODE
 #define ft_encoding_symbol          FT_ENCODING_MS_SYMBOL
@@ -1570,15 +1607,15 @@ FT_BEGIN_HEADER
   /*                         change between calls of @FT_Load_Glyph and a  */
   /*                         few other functions.                          */
   /*                                                                       */
-  /*    bitmap_left       :: This is the bitmap's left bearing expressed   */
-  /*                         in integer pixels.  Of course, this is only   */
-  /*                         valid if the format is                        */
-  /*                         @FT_GLYPH_FORMAT_BITMAP.                      */
+  /*    bitmap_left       :: The bitmap's left bearing expressed in        */
+  /*                         integer pixels.  Only valid if the format is  */
+  /*                         @FT_GLYPH_FORMAT_BITMAP, this is, if the      */
+  /*                         glyph slot contains a bitmap.                 */
   /*                                                                       */
-  /*    bitmap_top        :: This is the bitmap's top bearing expressed in */
-  /*                         integer pixels.  Remember that this is the    */
-  /*                         distance from the baseline to the top-most    */
-  /*                         glyph scanline, upwards y~coordinates being   */
+  /*    bitmap_top        :: The bitmap's top bearing expressed in integer */
+  /*                         pixels.  Remember that this is the distance   */
+  /*                         from the baseline to the top-most glyph       */
+  /*                         scanline, upwards y~coordinates being         */
   /*                         *positive*.                                   */
   /*                                                                       */
   /*    outline           :: The outline descriptor for the current glyph  */
@@ -1592,7 +1629,6 @@ FT_BEGIN_HEADER
   /*                         This field is only valid for the composite    */
   /*                         glyph format that should normally only be     */
   /*                         loaded with the @FT_LOAD_NO_RECURSE flag.     */
-  /*                         For now this is internal to FreeType.         */
   /*                                                                       */
   /*    subglyphs         :: An array of subglyph descriptors for          */
   /*                         composite glyphs.  There are `num_subglyphs'  */
@@ -1783,16 +1819,6 @@ FT_BEGIN_HEADER
   /*                                                                       */
   /*    FT_OPEN_PARAMS   :: Use the `num_params' and `params' fields.      */
   /*                                                                       */
-  /*    ft_open_memory   :: Deprecated; use @FT_OPEN_MEMORY instead.       */
-  /*                                                                       */
-  /*    ft_open_stream   :: Deprecated; use @FT_OPEN_STREAM instead.       */
-  /*                                                                       */
-  /*    ft_open_pathname :: Deprecated; use @FT_OPEN_PATHNAME instead.     */
-  /*                                                                       */
-  /*    ft_open_driver   :: Deprecated; use @FT_OPEN_DRIVER instead.       */
-  /*                                                                       */
-  /*    ft_open_params   :: Deprecated; use @FT_OPEN_PARAMS instead.       */
-  /*                                                                       */
   /* <Note>                                                                */
   /*    The `FT_OPEN_MEMORY', `FT_OPEN_STREAM', and `FT_OPEN_PATHNAME'     */
   /*    flags are mutually exclusive.                                      */
@@ -1803,11 +1829,14 @@ FT_BEGIN_HEADER
 #define FT_OPEN_DRIVER    0x8
 #define FT_OPEN_PARAMS    0x10
 
-#define ft_open_memory    FT_OPEN_MEMORY     /* deprecated */
-#define ft_open_stream    FT_OPEN_STREAM     /* deprecated */
-#define ft_open_pathname  FT_OPEN_PATHNAME   /* deprecated */
-#define ft_open_driver    FT_OPEN_DRIVER     /* deprecated */
-#define ft_open_params    FT_OPEN_PARAMS     /* deprecated */
+
+  /* these constants are deprecated; use the corresponding `FT_OPEN_XXX' */
+  /* values instead                                                      */
+#define ft_open_memory    FT_OPEN_MEMORY
+#define ft_open_stream    FT_OPEN_STREAM
+#define ft_open_pathname  FT_OPEN_PATHNAME
+#define ft_open_driver    FT_OPEN_DRIVER
+#define ft_open_params    FT_OPEN_PARAMS
 
 
   /*************************************************************************/
@@ -1872,22 +1901,22 @@ FT_BEGIN_HEADER
   /*    The stream type is determined by the contents of `flags' that      */
   /*    are tested in the following order by @FT_Open_Face:                */
   /*                                                                       */
-  /*    If the `FT_OPEN_MEMORY' bit is set, assume that this is a          */
+  /*    If the @FT_OPEN_MEMORY bit is set, assume that this is a           */
   /*    memory file of `memory_size' bytes, located at `memory_address'.   */
   /*    The data are are not copied, and the client is responsible for     */
   /*    releasing and destroying them _after_ the corresponding call to    */
   /*    @FT_Done_Face.                                                     */
   /*                                                                       */
-  /*    Otherwise, if the `FT_OPEN_STREAM' bit is set, assume that a       */
+  /*    Otherwise, if the @FT_OPEN_STREAM bit is set, assume that a        */
   /*    custom input stream `stream' is used.                              */
   /*                                                                       */
-  /*    Otherwise, if the `FT_OPEN_PATHNAME' bit is set, assume that this  */
+  /*    Otherwise, if the @FT_OPEN_PATHNAME bit is set, assume that this   */
   /*    is a normal file and use `pathname' to open it.                    */
   /*                                                                       */
-  /*    If the `FT_OPEN_DRIVER' bit is set, @FT_Open_Face only tries to    */
+  /*    If the @FT_OPEN_DRIVER bit is set, @FT_Open_Face only tries to     */
   /*    open the file with the driver whose handler is in `driver'.        */
   /*                                                                       */
-  /*    If the `FT_OPEN_PARAMS' bit is set, the parameters given by        */
+  /*    If the @FT_OPEN_PARAMS bit is set, the parameters given by         */
   /*    `num_params' and `params' is used.  They are ignored otherwise.    */
   /*                                                                       */
   /*    Ideally, both the `pathname' and `params' fields should be tagged  */
@@ -2541,11 +2570,6 @@ FT_BEGIN_HEADER
    *     Indicates that the auto-hinter is preferred over the font's native
    *     hinter.  See also the note below.
    *
-   *   FT_LOAD_CROP_BITMAP ::
-   *     Indicates that the font driver should crop the loaded bitmap glyph
-   *     (i.e., remove all space around its black bits).  Not all drivers
-   *     implement this.
-   *
    *   FT_LOAD_PEDANTIC ::
    *     Indicates that the font driver should perform pedantic verifications
    *     during glyph loading.  This is mostly used to detect broken glyphs
@@ -2556,18 +2580,12 @@ FT_BEGIN_HEADER
    *     result in partially hinted or distorted glyphs in case a glyph's
    *     bytecode is buggy.
    *
-   *   FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH ::
-   *     Ignored.  Deprecated.
-   *
    *   FT_LOAD_NO_RECURSE ::
-   *     This flag is only used internally.  It merely indicates that the
-   *     font driver should not load composite glyphs recursively.  Instead,
-   *     it should set the `num_subglyph' and `subglyphs' values of the
-   *     glyph slot accordingly, and set `glyph->format' to
-   *     @FT_GLYPH_FORMAT_COMPOSITE.
-   *
-   *     The description of sub-glyphs is not available to client
-   *     applications for now.
+   *     Indicate that the font driver should not load composite glyphs
+   *     recursively.  Instead, it should set the `num_subglyph' and
+   *     `subglyphs' values of the glyph slot accordingly, and set
+   *     `glyph->format' to @FT_GLYPH_FORMAT_COMPOSITE.  The description of
+   *     subglyphs can then be accessed with @FT_Get_SubGlyph_Info.
    *
    *     This flag implies @FT_LOAD_NO_SCALE and @FT_LOAD_IGNORE_TRANSFORM.
    *
@@ -2600,6 +2618,12 @@ FT_BEGIN_HEADER
    *     bitmaps transparently.  Those bitmaps will be in the
    *     @FT_PIXEL_MODE_GRAY format.
    *
+   *   FT_LOAD_CROP_BITMAP ::
+   *     Ignored.  Deprecated.
+   *
+   *   FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH ::
+   *     Ignored.  Deprecated.
+   *
    * @note:
    *   By default, hinting is enabled and the font's native hinter (see
    *   @FT_FACE_FLAG_HINTER) is preferred over the auto-hinter.  You can
@@ -2836,19 +2860,8 @@ FT_BEGIN_HEADER
   } FT_Render_Mode;
 
 
-  /*************************************************************************/
-  /*                                                                       */
-  /* <Enum>                                                                */
-  /*    ft_render_mode_xxx                                                 */
-  /*                                                                       */
-  /* <Description>                                                         */
-  /*    These constants are deprecated.  Use the corresponding             */
-  /*    @FT_Render_Mode values instead.                                    */
-  /*                                                                       */
-  /* <Values>                                                              */
-  /*    ft_render_mode_normal :: see @FT_RENDER_MODE_NORMAL                */
-  /*    ft_render_mode_mono   :: see @FT_RENDER_MODE_MONO                  */
-  /*                                                                       */
+  /* these constants are deprecated; use the corresponding */
+  /* `FT_Render_Mode' values instead                       */
 #define ft_render_mode_normal  FT_RENDER_MODE_NORMAL
 #define ft_render_mode_mono    FT_RENDER_MODE_MONO
 
@@ -2912,39 +2925,10 @@ FT_BEGIN_HEADER
   } FT_Kerning_Mode;
 
 
-  /*************************************************************************/
-  /*                                                                       */
-  /* <Const>                                                               */
-  /*    ft_kerning_default                                                 */
-  /*                                                                       */
-  /* <Description>                                                         */
-  /*    This constant is deprecated.  Please use @FT_KERNING_DEFAULT       */
-  /*    instead.                                                           */
-  /*                                                                       */
+  /* these constants are deprecated; use the corresponding */
+  /* `FT_Kerning_Mode' values instead                      */
 #define ft_kerning_default   FT_KERNING_DEFAULT
-
-
-  /*************************************************************************/
-  /*                                                                       */
-  /* <Const>                                                               */
-  /*    ft_kerning_unfitted                                                */
-  /*                                                                       */
-  /* <Description>                                                         */
-  /*    This constant is deprecated.  Please use @FT_KERNING_UNFITTED      */
-  /*    instead.                                                           */
-  /*                                                                       */
 #define ft_kerning_unfitted  FT_KERNING_UNFITTED
-
-
-  /*************************************************************************/
-  /*                                                                       */
-  /* <Const>                                                               */
-  /*    ft_kerning_unscaled                                                */
-  /*                                                                       */
-  /* <Description>                                                         */
-  /*    This constant is deprecated.  Please use @FT_KERNING_UNSCALED      */
-  /*    instead.                                                           */
-  /*                                                                       */
 #define ft_kerning_unscaled  FT_KERNING_UNSCALED
 
 
@@ -3065,9 +3049,8 @@ FT_BEGIN_HEADER
   /*    glyph index~0 always corresponds to the `missing glyph' (called    */
   /*    `.notdef').                                                        */
   /*                                                                       */
-  /*    This function is not compiled within the library if the config     */
-  /*    macro `FT_CONFIG_OPTION_NO_GLYPH_NAMES' is defined in              */
-  /*    `ftoptions.h'.                                                     */
+  /*    This function always returns an error if the config macro          */
+  /*    `FT_CONFIG_OPTION_NO_GLYPH_NAMES' is not defined in `ftoptions.h'. */
   /*                                                                       */
   FT_EXPORT( FT_Error )
   FT_Get_Glyph_Name( FT_Face     face,
@@ -3515,8 +3498,8 @@ FT_BEGIN_HEADER
   /*                                                                       */
   /*      http://www.unicode.org/reports/tr37/                             */
   /*                                                                       */
-  /*    To date (November 2012), the character with the most variants is   */
-  /*    U+9089, having 31 such IVS.                                        */
+  /*    To date (November 2014), the character with the most variants is   */
+  /*    U+9089, having 32 such IVS.                                        */
   /*                                                                       */
   /*    Adobe and MS decided to support IVS with a new cmap subtable       */
   /*    (format~14).  It is an odd subtable because it is not a mapping of */
@@ -3767,12 +3750,6 @@ FT_BEGIN_HEADER
              FT_Long  c );
 
 
-  /* */
-
-  /* The following #if 0 ... #endif is for the documentation formatter, */
-  /* hiding the internal `FT_MULFIX_INLINED' macro.                     */
-
-#if 0
   /*************************************************************************/
   /*                                                                       */
   /* <Function>                                                            */
@@ -3806,17 +3783,6 @@ FT_BEGIN_HEADER
   FT_MulFix( FT_Long  a,
              FT_Long  b );
 
-  /* */
-#endif
-
-#ifdef FT_MULFIX_INLINED
-#define FT_MulFix( a, b )  FT_MULFIX_INLINED( a, b )
-#else
-  FT_EXPORT( FT_Long )
-  FT_MulFix( FT_Long  a,
-             FT_Long  b );
-#endif
-
 
   /*************************************************************************/
   /*                                                                       */
@@ -3829,18 +3795,12 @@ FT_BEGIN_HEADER
   /*    used to divide a given value by a 16.16 fixed-point factor.        */
   /*                                                                       */
   /* <Input>                                                               */
-  /*    a :: The first multiplier.                                         */
-  /*    b :: The second multiplier.  Use a 16.16 factor here whenever      */
-  /*         possible (see note below).                                    */
+  /*    a :: The numerator.                                                */
+  /*    b :: The denominator.  Use a 16.16 factor here.                    */
   /*                                                                       */
   /* <Return>                                                              */
   /*    The result of `(a*0x10000)/b'.                                     */
   /*                                                                       */
-  /* <Note>                                                                */
-  /*    The optimization for FT_DivFix() is simple: If (a~<<~16) fits in   */
-  /*    32~bits, then the division is computed directly.  Otherwise, we    */
-  /*    use a specialized version of @FT_MulDiv.                           */
-  /*                                                                       */
   FT_EXPORT( FT_Long )
   FT_DivFix( FT_Long  a,
              FT_Long  b );
@@ -3940,6 +3900,18 @@ FT_BEGIN_HEADER
   /*    even a new release of FreeType with only documentation changes     */
   /*    increases the version number.                                      */
   /*                                                                       */
+  /* <Order>                                                               */
+  /*    FT_Library_Version                                                 */
+  /*                                                                       */
+  /*    FREETYPE_MAJOR                                                     */
+  /*    FREETYPE_MINOR                                                     */
+  /*    FREETYPE_PATCH                                                     */
+  /*                                                                       */
+  /*    FT_Face_CheckTrueTypePatents                                       */
+  /*    FT_Face_SetUnpatentedHinting                                       */
+  /*                                                                       */
+  /*    FREETYPE_XXX                                                       */
+  /*                                                                       */
   /*************************************************************************/
 
 
@@ -3965,7 +3937,7 @@ FT_BEGIN_HEADER
    */
 #define FREETYPE_MAJOR  2
 #define FREETYPE_MINOR  5
-#define FREETYPE_PATCH  3
+#define FREETYPE_PATCH  5
 
 
   /*************************************************************************/
index 8f7e2fc..955f93f 100644 (file)
@@ -4,7 +4,7 @@
 /*                                                                         */
 /*    Quick computation of advance widths (specification only).            */
 /*                                                                         */
-/*  Copyright 2008, 2013 by                                                */
+/*  Copyright 2008, 2013, 2014 by                                          */
 /*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
 /*                                                                         */
 /*  This file is part of the FreeType project, and may only be used,       */
@@ -48,6 +48,11 @@ FT_BEGIN_HEADER
    * @description:
    *   This section contains functions to quickly extract advance values
    *   without handling glyph outlines, if possible.
+   *
+   * @order:
+   *   FT_Get_Advance
+   *   FT_Get_Advances
+   *
    */
 
 
@@ -171,7 +176,7 @@ FT_BEGIN_HEADER
                    FT_Int32   load_flags,
                    FT_Fixed  *padvances );
 
-/* */
+  /* */
 
 
 FT_END_HEADER
index 936791e..59191ab 100644 (file)
@@ -245,12 +245,12 @@ FT_BEGIN_HEADER
    *   The data exchange structure for the @glyph-to-script-map property.
    *
    */
-   typedef struct  FT_Prop_GlyphToScriptMap_
-   {
-     FT_Face   face;
-     FT_Byte*  map;
+  typedef struct  FT_Prop_GlyphToScriptMap_
+  {
+    FT_Face   face;
+    FT_Byte*  map;
 
-   } FT_Prop_GlyphToScriptMap;
+  } FT_Prop_GlyphToScriptMap;
 
 
   /**************************************************************************
@@ -384,15 +384,15 @@ FT_BEGIN_HEADER
    *   The data exchange structure for the @increase-x-height property.
    *
    */
-   typedef struct  FT_Prop_IncreaseXHeight_
-   {
-     FT_Face  face;
-     FT_UInt  limit;
+  typedef struct  FT_Prop_IncreaseXHeight_
+  {
+    FT_Face  face;
+    FT_UInt  limit;
 
-   } FT_Prop_IncreaseXHeight;
+  } FT_Prop_IncreaseXHeight;
 
+  /* */
 
- /* */
 
 FT_END_HEADER
 
index 8938841..d6800e2 100644 (file)
@@ -85,7 +85,6 @@ FT_BEGIN_HEADER
   FT_Outline_Get_BBox( FT_Outline*  outline,
                        FT_BBox     *abbox );
 
-
   /* */
 
 
index 8b3c411..6d262e4 100644 (file)
@@ -53,7 +53,7 @@ FT_BEGIN_HEADER
   /**********************************************************************
    *
    * @enum:
-   *    FT_PropertyType
+   *    BDF_PropertyType
    *
    * @description:
    *    A list of BDF property types.
@@ -200,7 +200,7 @@ FT_BEGIN_HEADER
                        const char*       prop_name,
                        BDF_PropertyRec  *aproperty );
 
- /* */
 /* */
 
 FT_END_HEADER
 
index 7dbf5ba..eae7169 100644 (file)
@@ -4,7 +4,7 @@
 /*                                                                         */
 /*    FreeType utility functions for bitmaps (specification).              */
 /*                                                                         */
-/*  Copyright 2004-2006, 2008, 2013 by                                     */
+/*  Copyright 2004-2006, 2008, 2013, 2014 by                               */
 /*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
 /*                                                                         */
 /*  This file is part of the FreeType project, and may only be used,       */
@@ -45,7 +45,9 @@ FT_BEGIN_HEADER
   /*    Handling FT_Bitmap objects.                                        */
   /*                                                                       */
   /* <Description>                                                         */
-  /*    This section contains functions for converting FT_Bitmap objects.  */
+  /*    This section contains functions for handling @FT_Bitmap objects.   */
+  /*    Note that none of the functions changes the bitmap's `flow' (as    */
+  /*    indicated by the sign of the `pitch' field in `FT_Bitmap').        */
   /*                                                                       */
   /*************************************************************************/
 
@@ -122,6 +124,9 @@ FT_BEGIN_HEADER
   /*    If you want to embolden the bitmap owned by a @FT_GlyphSlotRec,    */
   /*    you should call @FT_GlyphSlot_Own_Bitmap on the slot first.        */
   /*                                                                       */
+  /*    Bitmaps in @FT_PIXEL_MODE_GRAY2 and @FT_PIXEL_MODE_GRAY@ format    */
+  /*    are converted to @FT_PIXEL_MODE_GRAY format (i.e., 8bpp).          */
+  /*                                                                       */
   FT_EXPORT( FT_Error )
   FT_Bitmap_Embolden( FT_Library  library,
                       FT_Bitmap*  bitmap,
index 1bf81b1..4dce161 100644 (file)
@@ -91,7 +91,7 @@ FT_BEGIN_HEADER
   FT_Stream_OpenBzip2( FT_Stream  stream,
                        FT_Stream  source );
 
- /* */
 /* */
 
 
 FT_END_HEADER
index a5d7100..a30e925 100644 (file)
@@ -4,7 +4,7 @@
 /*                                                                         */
 /*    FreeType Cache subsystem (specification).                            */
 /*                                                                         */
-/*  Copyright 1996-2008, 2010, 2013 by                                     */
+/*  Copyright 1996-2008, 2010, 2013, 2014 by                               */
 /*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
 /*                                                                         */
 /*  This file is part of the FreeType project, and may only be used,       */
@@ -209,10 +209,10 @@ FT_BEGIN_HEADER
   typedef FT_Error
   (*FTC_Face_Requester)( FTC_FaceID  face_id,
                          FT_Library  library,
-                         FT_Pointer  request_data,
+                         FT_Pointer  req_data,
                          FT_Face*    aface );
 
- /* */
 /* */
 
 
   /*************************************************************************/
@@ -1046,8 +1046,8 @@ FT_BEGIN_HEADER
                               FTC_SBit      *sbit,
                               FTC_Node      *anode );
 
+  /* */
 
- /* */
 
 FT_END_HEADER
 
index e4d039d..f7031bc 100644 (file)
@@ -4,7 +4,7 @@
 /*                                                                         */
 /*    FreeType API for controlling the CFF driver (specification only).    */
 /*                                                                         */
-/*  Copyright 2013 by                                                      */
+/*  Copyright 2013, 2014 by                                                */
 /*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
 /*                                                                         */
 /*  This file is part of the FreeType project, and may only be used,       */
@@ -108,6 +108,12 @@ FT_BEGIN_HEADER
    *   in one of four ways, top edge up or down, bottom edge up or down.
    *   Unless there are conflicting hstems, the smallest movement is taken
    *   to minimize distortion.
+   *
+   * @order:
+   *   hinting-engine
+   *   no-stem-darkening
+   *   darkening-parameters
+   *
    */
 
 
@@ -212,9 +218,11 @@ FT_BEGIN_HEADER
    *     stem width >= 2.333px: darkening amount = 0px
    *   }
    *
-   *   and piecewise linear in-between.  Using the `darkening-parameters'
-   *   property, these four control points can be changed, as the following
-   *   example demonstrates.
+   *   and piecewise linear in-between.  At configuration time, these four
+   *   control points can be set with the macro
+   *   `CFF_CONFIG_OPTION_DARKENING_PARAMETERS'.  At runtime, the control
+   *   points can be changed using the `darkening-parameters' property, as
+   *   the following example demonstrates.
    *
    *   {
    *     FT_Library  library;
@@ -242,8 +250,8 @@ FT_BEGIN_HEADER
    *
    */
 
+  /* */
 
- /* */
 
 FT_END_HEADER
 
index 203a30c..17550d8 100644 (file)
@@ -156,7 +156,8 @@ FT_BEGIN_HEADER
                                FT_UInt   glyph_index,
                                FT_UInt  *cid );
 
- /* */
+  /* */
+
 
 FT_END_HEADER
 
index 76c7b9e..99b2fad 100644 (file)
 
   /* generic errors */
 
-  FT_NOERRORDEF_( Ok,                                        0x00, \
+  FT_NOERRORDEF_( Ok,                                        0x00,
                   "no error" )
 
-  FT_ERRORDEF_( Cannot_Open_Resource,                        0x01, \
+  FT_ERRORDEF_( Cannot_Open_Resource,                        0x01,
                 "cannot open resource" )
-  FT_ERRORDEF_( Unknown_File_Format,                         0x02, \
+  FT_ERRORDEF_( Unknown_File_Format,                         0x02,
                 "unknown file format" )
-  FT_ERRORDEF_( Invalid_File_Format,                         0x03, \
+  FT_ERRORDEF_( Invalid_File_Format,                         0x03,
                 "broken file" )
-  FT_ERRORDEF_( Invalid_Version,                             0x04, \
+  FT_ERRORDEF_( Invalid_Version,                             0x04,
                 "invalid FreeType version" )
-  FT_ERRORDEF_( Lower_Module_Version,                        0x05, \
+  FT_ERRORDEF_( Lower_Module_Version,                        0x05,
                 "module version is too low" )
-  FT_ERRORDEF_( Invalid_Argument,                            0x06, \
+  FT_ERRORDEF_( Invalid_Argument,                            0x06,
                 "invalid argument" )
-  FT_ERRORDEF_( Unimplemented_Feature,                       0x07, \
+  FT_ERRORDEF_( Unimplemented_Feature,                       0x07,
                 "unimplemented feature" )
-  FT_ERRORDEF_( Invalid_Table,                               0x08, \
+  FT_ERRORDEF_( Invalid_Table,                               0x08,
                 "broken table" )
-  FT_ERRORDEF_( Invalid_Offset,                              0x09, \
+  FT_ERRORDEF_( Invalid_Offset,                              0x09,
                 "broken offset within table" )
-  FT_ERRORDEF_( Array_Too_Large,                             0x0A, \
+  FT_ERRORDEF_( Array_Too_Large,                             0x0A,
                 "array allocation size too large" )
-  FT_ERRORDEF_( Missing_Module,                              0x0B, \
+  FT_ERRORDEF_( Missing_Module,                              0x0B,
                 "missing module" )
-  FT_ERRORDEF_( Missing_Property,                            0x0C, \
+  FT_ERRORDEF_( Missing_Property,                            0x0C,
                 "missing property" )
 
   /* glyph/character errors */
 
-  FT_ERRORDEF_( Invalid_Glyph_Index,                         0x10, \
+  FT_ERRORDEF_( Invalid_Glyph_Index,                         0x10,
                 "invalid glyph index" )
-  FT_ERRORDEF_( Invalid_Character_Code,                      0x11, \
+  FT_ERRORDEF_( Invalid_Character_Code,                      0x11,
                 "invalid character code" )
-  FT_ERRORDEF_( Invalid_Glyph_Format,                        0x12, \
+  FT_ERRORDEF_( Invalid_Glyph_Format,                        0x12,
                 "unsupported glyph image format" )
-  FT_ERRORDEF_( Cannot_Render_Glyph,                         0x13, \
+  FT_ERRORDEF_( Cannot_Render_Glyph,                         0x13,
                 "cannot render this glyph format" )
-  FT_ERRORDEF_( Invalid_Outline,                             0x14, \
+  FT_ERRORDEF_( Invalid_Outline,                             0x14,
                 "invalid outline" )
-  FT_ERRORDEF_( Invalid_Composite,                           0x15, \
+  FT_ERRORDEF_( Invalid_Composite,                           0x15,
                 "invalid composite glyph" )
-  FT_ERRORDEF_( Too_Many_Hints,                              0x16, \
+  FT_ERRORDEF_( Too_Many_Hints,                              0x16,
                 "too many hints" )
-  FT_ERRORDEF_( Invalid_Pixel_Size,                          0x17, \
+  FT_ERRORDEF_( Invalid_Pixel_Size,                          0x17,
                 "invalid pixel size" )
 
   /* handle errors */
 
-  FT_ERRORDEF_( Invalid_Handle,                              0x20, \
+  FT_ERRORDEF_( Invalid_Handle,                              0x20,
                 "invalid object handle" )
-  FT_ERRORDEF_( Invalid_Library_Handle,                      0x21, \
+  FT_ERRORDEF_( Invalid_Library_Handle,                      0x21,
                 "invalid library handle" )
-  FT_ERRORDEF_( Invalid_Driver_Handle,                       0x22, \
+  FT_ERRORDEF_( Invalid_Driver_Handle,                       0x22,
                 "invalid module handle" )
-  FT_ERRORDEF_( Invalid_Face_Handle,                         0x23, \
+  FT_ERRORDEF_( Invalid_Face_Handle,                         0x23,
                 "invalid face handle" )
-  FT_ERRORDEF_( Invalid_Size_Handle,                         0x24, \
+  FT_ERRORDEF_( Invalid_Size_Handle,                         0x24,
                 "invalid size handle" )
-  FT_ERRORDEF_( Invalid_Slot_Handle,                         0x25, \
+  FT_ERRORDEF_( Invalid_Slot_Handle,                         0x25,
                 "invalid glyph slot handle" )
-  FT_ERRORDEF_( Invalid_CharMap_Handle,                      0x26, \
+  FT_ERRORDEF_( Invalid_CharMap_Handle,                      0x26,
                 "invalid charmap handle" )
-  FT_ERRORDEF_( Invalid_Cache_Handle,                        0x27, \
+  FT_ERRORDEF_( Invalid_Cache_Handle,                        0x27,
                 "invalid cache manager handle" )
-  FT_ERRORDEF_( Invalid_Stream_Handle,                       0x28, \
+  FT_ERRORDEF_( Invalid_Stream_Handle,                       0x28,
                 "invalid stream handle" )
 
   /* driver errors */
 
-  FT_ERRORDEF_( Too_Many_Drivers,                            0x30, \
+  FT_ERRORDEF_( Too_Many_Drivers,                            0x30,
                 "too many modules" )
-  FT_ERRORDEF_( Too_Many_Extensions,                         0x31, \
+  FT_ERRORDEF_( Too_Many_Extensions,                         0x31,
                 "too many extensions" )
 
   /* memory errors */
 
-  FT_ERRORDEF_( Out_Of_Memory,                               0x40, \
+  FT_ERRORDEF_( Out_Of_Memory,                               0x40,
                 "out of memory" )
-  FT_ERRORDEF_( Unlisted_Object,                             0x41, \
+  FT_ERRORDEF_( Unlisted_Object,                             0x41,
                 "unlisted object" )
 
   /* stream errors */
 
-  FT_ERRORDEF_( Cannot_Open_Stream,                          0x51, \
+  FT_ERRORDEF_( Cannot_Open_Stream,                          0x51,
                 "cannot open stream" )
-  FT_ERRORDEF_( Invalid_Stream_Seek,                         0x52, \
+  FT_ERRORDEF_( Invalid_Stream_Seek,                         0x52,
                 "invalid stream seek" )
-  FT_ERRORDEF_( Invalid_Stream_Skip,                         0x53, \
+  FT_ERRORDEF_( Invalid_Stream_Skip,                         0x53,
                 "invalid stream skip" )
-  FT_ERRORDEF_( Invalid_Stream_Read,                         0x54, \
+  FT_ERRORDEF_( Invalid_Stream_Read,                         0x54,
                 "invalid stream read" )
-  FT_ERRORDEF_( Invalid_Stream_Operation,                    0x55, \
+  FT_ERRORDEF_( Invalid_Stream_Operation,                    0x55,
                 "invalid stream operation" )
-  FT_ERRORDEF_( Invalid_Frame_Operation,                     0x56, \
+  FT_ERRORDEF_( Invalid_Frame_Operation,                     0x56,
                 "invalid frame operation" )
-  FT_ERRORDEF_( Nested_Frame_Access,                         0x57, \
+  FT_ERRORDEF_( Nested_Frame_Access,                         0x57,
                 "nested frame access" )
-  FT_ERRORDEF_( Invalid_Frame_Read,                          0x58, \
+  FT_ERRORDEF_( Invalid_Frame_Read,                          0x58,
                 "invalid frame read" )
 
   /* raster errors */
 
-  FT_ERRORDEF_( Raster_Uninitialized,                        0x60, \
+  FT_ERRORDEF_( Raster_Uninitialized,                        0x60,
                 "raster uninitialized" )
-  FT_ERRORDEF_( Raster_Corrupted,                            0x61, \
+  FT_ERRORDEF_( Raster_Corrupted,                            0x61,
                 "raster corrupted" )
-  FT_ERRORDEF_( Raster_Overflow,                             0x62, \
+  FT_ERRORDEF_( Raster_Overflow,                             0x62,
                 "raster overflow" )
-  FT_ERRORDEF_( Raster_Negative_Height,                      0x63, \
+  FT_ERRORDEF_( Raster_Negative_Height,                      0x63,
                 "negative height while rastering" )
 
   /* cache errors */
 
-  FT_ERRORDEF_( Too_Many_Caches,                             0x70, \
+  FT_ERRORDEF_( Too_Many_Caches,                             0x70,
                 "too many registered caches" )
 
   /* TrueType and SFNT errors */
 
-  FT_ERRORDEF_( Invalid_Opcode,                              0x80, \
+  FT_ERRORDEF_( Invalid_Opcode,                              0x80,
                 "invalid opcode" )
-  FT_ERRORDEF_( Too_Few_Arguments,                           0x81, \
+  FT_ERRORDEF_( Too_Few_Arguments,                           0x81,
                 "too few arguments" )
-  FT_ERRORDEF_( Stack_Overflow,                              0x82, \
+  FT_ERRORDEF_( Stack_Overflow,                              0x82,
                 "stack overflow" )
-  FT_ERRORDEF_( Code_Overflow,                               0x83, \
+  FT_ERRORDEF_( Code_Overflow,                               0x83,
                 "code overflow" )
-  FT_ERRORDEF_( Bad_Argument,                                0x84, \
+  FT_ERRORDEF_( Bad_Argument,                                0x84,
                 "bad argument" )
-  FT_ERRORDEF_( Divide_By_Zero,                              0x85, \
+  FT_ERRORDEF_( Divide_By_Zero,                              0x85,
                 "division by zero" )
-  FT_ERRORDEF_( Invalid_Reference,                           0x86, \
+  FT_ERRORDEF_( Invalid_Reference,                           0x86,
                 "invalid reference" )
-  FT_ERRORDEF_( Debug_OpCode,                                0x87, \
+  FT_ERRORDEF_( Debug_OpCode,                                0x87,
                 "found debug opcode" )
-  FT_ERRORDEF_( ENDF_In_Exec_Stream,                         0x88, \
+  FT_ERRORDEF_( ENDF_In_Exec_Stream,                         0x88,
                 "found ENDF opcode in execution stream" )
-  FT_ERRORDEF_( Nested_DEFS,                                 0x89, \
+  FT_ERRORDEF_( Nested_DEFS,                                 0x89,
                 "nested DEFS" )
-  FT_ERRORDEF_( Invalid_CodeRange,                           0x8A, \
+  FT_ERRORDEF_( Invalid_CodeRange,                           0x8A,
                 "invalid code range" )
-  FT_ERRORDEF_( Execution_Too_Long,                          0x8B, \
+  FT_ERRORDEF_( Execution_Too_Long,                          0x8B,
                 "execution context too long" )
-  FT_ERRORDEF_( Too_Many_Function_Defs,                      0x8C, \
+  FT_ERRORDEF_( Too_Many_Function_Defs,                      0x8C,
                 "too many function definitions" )
-  FT_ERRORDEF_( Too_Many_Instruction_Defs,                   0x8D, \
+  FT_ERRORDEF_( Too_Many_Instruction_Defs,                   0x8D,
                 "too many instruction definitions" )
-  FT_ERRORDEF_( Table_Missing,                               0x8E, \
+  FT_ERRORDEF_( Table_Missing,                               0x8E,
                 "SFNT font table missing" )
-  FT_ERRORDEF_( Horiz_Header_Missing,                        0x8F, \
+  FT_ERRORDEF_( Horiz_Header_Missing,                        0x8F,
                 "horizontal header (hhea) table missing" )
-  FT_ERRORDEF_( Locations_Missing,                           0x90, \
+  FT_ERRORDEF_( Locations_Missing,                           0x90,
                 "locations (loca) table missing" )
-  FT_ERRORDEF_( Name_Table_Missing,                          0x91, \
+  FT_ERRORDEF_( Name_Table_Missing,                          0x91,
                 "name table missing" )
-  FT_ERRORDEF_( CMap_Table_Missing,                          0x92, \
+  FT_ERRORDEF_( CMap_Table_Missing,                          0x92,
                 "character map (cmap) table missing" )
-  FT_ERRORDEF_( Hmtx_Table_Missing,                          0x93, \
+  FT_ERRORDEF_( Hmtx_Table_Missing,                          0x93,
                 "horizontal metrics (hmtx) table missing" )
-  FT_ERRORDEF_( Post_Table_Missing,                          0x94, \
+  FT_ERRORDEF_( Post_Table_Missing,                          0x94,
                 "PostScript (post) table missing" )
-  FT_ERRORDEF_( Invalid_Horiz_Metrics,                       0x95, \
+  FT_ERRORDEF_( Invalid_Horiz_Metrics,                       0x95,
                 "invalid horizontal metrics" )
-  FT_ERRORDEF_( Invalid_CharMap_Format,                      0x96, \
+  FT_ERRORDEF_( Invalid_CharMap_Format,                      0x96,
                 "invalid character map (cmap) format" )
-  FT_ERRORDEF_( Invalid_PPem,                                0x97, \
+  FT_ERRORDEF_( Invalid_PPem,                                0x97,
                 "invalid ppem value" )
-  FT_ERRORDEF_( Invalid_Vert_Metrics,                        0x98, \
+  FT_ERRORDEF_( Invalid_Vert_Metrics,                        0x98,
                 "invalid vertical metrics" )
-  FT_ERRORDEF_( Could_Not_Find_Context,                      0x99, \
+  FT_ERRORDEF_( Could_Not_Find_Context,                      0x99,
                 "could not find context" )
-  FT_ERRORDEF_( Invalid_Post_Table_Format,                   0x9A, \
+  FT_ERRORDEF_( Invalid_Post_Table_Format,                   0x9A,
                 "invalid PostScript (post) table format" )
-  FT_ERRORDEF_( Invalid_Post_Table,                          0x9B, \
+  FT_ERRORDEF_( Invalid_Post_Table,                          0x9B,
                 "invalid PostScript (post) table" )
 
   /* CFF, CID, and Type 1 errors */
 
-  FT_ERRORDEF_( Syntax_Error,                                0xA0, \
+  FT_ERRORDEF_( Syntax_Error,                                0xA0,
                 "opcode syntax error" )
-  FT_ERRORDEF_( Stack_Underflow,                             0xA1, \
+  FT_ERRORDEF_( Stack_Underflow,                             0xA1,
                 "argument stack underflow" )
-  FT_ERRORDEF_( Ignore,                                      0xA2, \
+  FT_ERRORDEF_( Ignore,                                      0xA2,
                 "ignore" )
-  FT_ERRORDEF_( No_Unicode_Glyph_Name,                       0xA3, \
+  FT_ERRORDEF_( No_Unicode_Glyph_Name,                       0xA3,
                 "no Unicode glyph name found" )
-  FT_ERRORDEF_( Glyph_Too_Big,                               0xA4, \
+  FT_ERRORDEF_( Glyph_Too_Big,                               0xA4,
                 "glyph to big for hinting" )
 
   /* BDF errors */
 
-  FT_ERRORDEF_( Missing_Startfont_Field,                     0xB0, \
+  FT_ERRORDEF_( Missing_Startfont_Field,                     0xB0,
                 "`STARTFONT' field missing" )
-  FT_ERRORDEF_( Missing_Font_Field,                          0xB1, \
+  FT_ERRORDEF_( Missing_Font_Field,                          0xB1,
                 "`FONT' field missing" )
-  FT_ERRORDEF_( Missing_Size_Field,                          0xB2, \
+  FT_ERRORDEF_( Missing_Size_Field,                          0xB2,
                 "`SIZE' field missing" )
-  FT_ERRORDEF_( Missing_Fontboundingbox_Field,               0xB3, \
+  FT_ERRORDEF_( Missing_Fontboundingbox_Field,               0xB3,
                 "`FONTBOUNDINGBOX' field missing" )
-  FT_ERRORDEF_( Missing_Chars_Field,                         0xB4, \
+  FT_ERRORDEF_( Missing_Chars_Field,                         0xB4,
                 "`CHARS' field missing" )
-  FT_ERRORDEF_( Missing_Startchar_Field,                     0xB5, \
+  FT_ERRORDEF_( Missing_Startchar_Field,                     0xB5,
                 "`STARTCHAR' field missing" )
-  FT_ERRORDEF_( Missing_Encoding_Field,                      0xB6, \
+  FT_ERRORDEF_( Missing_Encoding_Field,                      0xB6,
                 "`ENCODING' field missing" )
-  FT_ERRORDEF_( Missing_Bbx_Field,                           0xB7, \
+  FT_ERRORDEF_( Missing_Bbx_Field,                           0xB7,
                 "`BBX' field missing" )
-  FT_ERRORDEF_( Bbx_Too_Big,                                 0xB8, \
+  FT_ERRORDEF_( Bbx_Too_Big,                                 0xB8,
                 "`BBX' too big" )
-  FT_ERRORDEF_( Corrupted_Font_Header,                       0xB9, \
+  FT_ERRORDEF_( Corrupted_Font_Header,                       0xB9,
                 "Font header corrupted or missing fields" )
-  FT_ERRORDEF_( Corrupted_Font_Glyphs,                       0xBA, \
+  FT_ERRORDEF_( Corrupted_Font_Glyphs,                       0xBA,
                 "Font glyphs corrupted or missing fields" )
 
 
index 453d4fa..3f3d765 100644 (file)
   FT_Get_Gasp( FT_Face  face,
                FT_UInt  ppem );
 
-/* */
+  /* */
+
 
 #endif /* _FT_GASP_H_ */
 
index 2d30ed9..15fa6a9 100644 (file)
@@ -4,7 +4,7 @@
 /*                                                                         */
 /*    FreeType convenience functions to handle glyphs (specification).     */
 /*                                                                         */
-/*  Copyright 1996-2003, 2006, 2008, 2009, 2011, 2013 by                   */
+/*  Copyright 1996-2003, 2006, 2008, 2009, 2011, 2013, 2014 by             */
 /*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
 /*                                                                         */
 /*  This file is part of the FreeType project, and may only be used,       */
@@ -325,22 +325,8 @@ FT_BEGIN_HEADER
   } FT_Glyph_BBox_Mode;
 
 
-  /*************************************************************************/
-  /*                                                                       */
-  /* <Enum>                                                                */
-  /*    ft_glyph_bbox_xxx                                                  */
-  /*                                                                       */
-  /* <Description>                                                         */
-  /*    These constants are deprecated.  Use the corresponding             */
-  /*    @FT_Glyph_BBox_Mode values instead.                                */
-  /*                                                                       */
-  /* <Values>                                                              */
-  /*   ft_glyph_bbox_unscaled  :: See @FT_GLYPH_BBOX_UNSCALED.             */
-  /*   ft_glyph_bbox_subpixels :: See @FT_GLYPH_BBOX_SUBPIXELS.            */
-  /*   ft_glyph_bbox_gridfit   :: See @FT_GLYPH_BBOX_GRIDFIT.              */
-  /*   ft_glyph_bbox_truncate  :: See @FT_GLYPH_BBOX_TRUNCATE.             */
-  /*   ft_glyph_bbox_pixels    :: See @FT_GLYPH_BBOX_PIXELS.               */
-  /*                                                                       */
+  /* these constants are deprecated; use the corresponding */
+  /* `FT_Glyph_BBox_Mode' values instead                   */
 #define ft_glyph_bbox_unscaled   FT_GLYPH_BBOX_UNSCALED
 #define ft_glyph_bbox_subpixels  FT_GLYPH_BBOX_SUBPIXELS
 #define ft_glyph_bbox_gridfit    FT_GLYPH_BBOX_GRIDFIT
@@ -603,7 +589,6 @@ FT_BEGIN_HEADER
   FT_EXPORT( FT_Error )
   FT_Matrix_Invert( FT_Matrix*  matrix );
 
-
   /* */
 
 
index 6d38e32..88c3d93 100644 (file)
@@ -57,9 +57,19 @@ FT_BEGIN_HEADER
   /*    some TrueTypeGX tables (feat, mort, morx, bsln, just, kern, opbd,  */
   /*    trak, prop, lcar).                                                 */
   /*                                                                       */
+  /* <Order>                                                               */
+  /*    FT_TrueTypeGX_Validate                                             */
+  /*    FT_TrueTypeGX_Free                                                 */
+  /*                                                                       */
+  /*    FT_ClassicKern_Validate                                            */
+  /*    FT_ClassicKern_Free                                                */
+  /*                                                                       */
+  /*    FT_VALIDATE_GX_LENGTH                                              */
+  /*    FT_VALIDATE_GXXXX                                                  */
+  /*    FT_VALIDATE_CKERNXXX                                               */
+  /*                                                                       */
   /*************************************************************************/
 
-
   /*************************************************************************/
   /*                                                                       */
   /*                                                                       */
@@ -171,8 +181,6 @@ FT_BEGIN_HEADER
                           FT_VALIDATE_lcar )
 
 
-  /* */
-
  /**********************************************************************
   *
   * @function:
@@ -221,8 +229,6 @@ FT_BEGIN_HEADER
                           FT_UInt   table_length );
 
 
-  /* */
-
  /**********************************************************************
   *
   * @function:
@@ -248,8 +254,6 @@ FT_BEGIN_HEADER
                       FT_Bytes  table );
 
 
-  /* */
-
  /**********************************************************************
   *
   * @enum:
@@ -277,8 +281,6 @@ FT_BEGIN_HEADER
 #define FT_VALIDATE_CKERN  ( FT_VALIDATE_MS | FT_VALIDATE_APPLE )
 
 
-  /* */
-
  /**********************************************************************
   *
   * @function:
@@ -320,8 +322,6 @@ FT_BEGIN_HEADER
                            FT_Bytes  *ckern_table );
 
 
-  /* */
-
  /**********************************************************************
   *
   * @function:
@@ -346,8 +346,7 @@ FT_BEGIN_HEADER
   FT_ClassicKern_Free( FT_Face   face,
                        FT_Bytes  table );
 
-
- /* */
+  /* */
 
 
 FT_END_HEADER
index 78e7269..eb346c6 100644 (file)
@@ -137,8 +137,7 @@ FT_BEGIN_HEADER
                       const FT_Byte*  input,
                       FT_ULong        input_len );
 
-
- /* */
+  /* */
 
 
 FT_END_HEADER
index ea71a78..2f7ca2a 100644 (file)
@@ -5,7 +5,7 @@
 /*    FreeType glyph image formats and default raster interface            */
 /*    (specification).                                                     */
 /*                                                                         */
-/*  Copyright 1996-2010, 2013 by                                           */
+/*  Copyright 1996-2010, 2013, 2014 by                                     */
 /*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
 /*                                                                         */
 /*  This file is part of the FreeType project, and may only be used,       */
@@ -193,67 +193,14 @@ FT_BEGIN_HEADER
   } FT_Pixel_Mode;
 
 
-  /*************************************************************************/
-  /*                                                                       */
-  /* <Enum>                                                                */
-  /*    ft_pixel_mode_xxx                                                  */
-  /*                                                                       */
-  /* <Description>                                                         */
-  /*    A list of deprecated constants.  Use the corresponding             */
-  /*    @FT_Pixel_Mode values instead.                                     */
-  /*                                                                       */
-  /* <Values>                                                              */
-  /*    ft_pixel_mode_none  :: See @FT_PIXEL_MODE_NONE.                    */
-  /*    ft_pixel_mode_mono  :: See @FT_PIXEL_MODE_MONO.                    */
-  /*    ft_pixel_mode_grays :: See @FT_PIXEL_MODE_GRAY.                    */
-  /*    ft_pixel_mode_pal2  :: See @FT_PIXEL_MODE_GRAY2.                   */
-  /*    ft_pixel_mode_pal4  :: See @FT_PIXEL_MODE_GRAY4.                   */
-  /*                                                                       */
+  /* these constants are deprecated; use the corresponding `FT_Pixel_Mode' */
+  /* values instead.                                                       */
 #define ft_pixel_mode_none   FT_PIXEL_MODE_NONE
 #define ft_pixel_mode_mono   FT_PIXEL_MODE_MONO
 #define ft_pixel_mode_grays  FT_PIXEL_MODE_GRAY
 #define ft_pixel_mode_pal2   FT_PIXEL_MODE_GRAY2
 #define ft_pixel_mode_pal4   FT_PIXEL_MODE_GRAY4
 
- /* */
-
-#if 0
-
-  /*************************************************************************/
-  /*                                                                       */
-  /* <Enum>                                                                */
-  /*    FT_Palette_Mode                                                    */
-  /*                                                                       */
-  /* <Description>                                                         */
-  /*    THIS TYPE IS DEPRECATED.  DO NOT USE IT!                           */
-  /*                                                                       */
-  /*    An enumeration type to describe the format of a bitmap palette,    */
-  /*    used with ft_pixel_mode_pal4 and ft_pixel_mode_pal8.               */
-  /*                                                                       */
-  /* <Values>                                                              */
-  /*    ft_palette_mode_rgb  :: The palette is an array of 3-byte RGB      */
-  /*                            records.                                   */
-  /*                                                                       */
-  /*    ft_palette_mode_rgba :: The palette is an array of 4-byte RGBA     */
-  /*                            records.                                   */
-  /*                                                                       */
-  /* <Note>                                                                */
-  /*    As ft_pixel_mode_pal2, pal4 and pal8 are currently unused by       */
-  /*    FreeType, these types are not handled by the library itself.       */
-  /*                                                                       */
-  typedef enum  FT_Palette_Mode_
-  {
-    ft_palette_mode_rgb = 0,
-    ft_palette_mode_rgba,
-
-    ft_palette_mode_max   /* do not remove */
-
-  } FT_Palette_Mode;
-
-  /* */
-
-#endif
-
 
   /*************************************************************************/
   /*                                                                       */
@@ -318,13 +265,13 @@ FT_BEGIN_HEADER
   /*                                                                       */
   typedef struct  FT_Bitmap_
   {
-    int             rows;
-    int             width;
+    unsigned int    rows;
+    unsigned int    width;
     int             pitch;
     unsigned char*  buffer;
-    short           num_grays;
-    char            pixel_mode;
-    char            palette_mode;
+    unsigned short  num_grays;
+    unsigned char   pixel_mode;
+    unsigned char   palette_mode;
     void*           palette;
 
   } FT_Bitmap;
@@ -381,7 +328,7 @@ FT_BEGIN_HEADER
   /*                                                                       */
   /*    flags      :: A set of bit flags used to characterize the outline  */
   /*                  and give hints to the scan-converter and hinter on   */
-  /*                  how to convert/grid-fit it.  See @FT_OUTLINE_FLAGS.  */
+  /*                  how to convert/grid-fit it.  See @FT_OUTLINE_XXX.    */
   /*                                                                       */
   /* <Note>                                                                */
   /*    The B/W rasterizer only checks bit~2 in the `tags' array for the   */
@@ -402,6 +349,8 @@ FT_BEGIN_HEADER
 
   } FT_Outline;
 
+  /* */
+
   /* Following limits must be consistent with */
   /* FT_Outline.{n_contours,n_points}         */
 #define FT_OUTLINE_CONTOURS_MAX  SHRT_MAX
@@ -411,7 +360,7 @@ FT_BEGIN_HEADER
   /*************************************************************************/
   /*                                                                       */
   /* <Enum>                                                                */
-  /*    FT_OUTLINE_FLAGS                                                   */
+  /*    FT_OUTLINE_XXX                                                     */
   /*                                                                       */
   /* <Description>                                                         */
   /*    A list of bit-field constants use for the flags in an outline's    */
@@ -492,24 +441,8 @@ FT_BEGIN_HEADER
 #define FT_OUTLINE_SINGLE_PASS      0x200
 
 
- /*************************************************************************
-  *
-  * @enum:
-  *   ft_outline_flags
-  *
-  * @description:
-  *   These constants are deprecated.  Please use the corresponding
-  *   @FT_OUTLINE_FLAGS values.
-  *
-  * @values:
-  *   ft_outline_none            :: See @FT_OUTLINE_NONE.
-  *   ft_outline_owner           :: See @FT_OUTLINE_OWNER.
-  *   ft_outline_even_odd_fill   :: See @FT_OUTLINE_EVEN_ODD_FILL.
-  *   ft_outline_reverse_fill    :: See @FT_OUTLINE_REVERSE_FILL.
-  *   ft_outline_ignore_dropouts :: See @FT_OUTLINE_IGNORE_DROPOUTS.
-  *   ft_outline_high_precision  :: See @FT_OUTLINE_HIGH_PRECISION.
-  *   ft_outline_single_pass     :: See @FT_OUTLINE_SINGLE_PASS.
-  */
+  /* these constants are deprecated; use the corresponding */
+  /* `FT_OUTLINE_XXX' values instead                       */
 #define ft_outline_none             FT_OUTLINE_NONE
 #define ft_outline_owner            FT_OUTLINE_OWNER
 #define ft_outline_even_odd_fill    FT_OUTLINE_EVEN_ODD_FILL
@@ -796,22 +729,8 @@ FT_BEGIN_HEADER
   } FT_Glyph_Format;
 
 
-  /*************************************************************************/
-  /*                                                                       */
-  /* <Enum>                                                                */
-  /*    ft_glyph_format_xxx                                                */
-  /*                                                                       */
-  /* <Description>                                                         */
-  /*    A list of deprecated constants.  Use the corresponding             */
-  /*    @FT_Glyph_Format values instead.                                   */
-  /*                                                                       */
-  /* <Values>                                                              */
-  /*    ft_glyph_format_none      :: See @FT_GLYPH_FORMAT_NONE.            */
-  /*    ft_glyph_format_composite :: See @FT_GLYPH_FORMAT_COMPOSITE.       */
-  /*    ft_glyph_format_bitmap    :: See @FT_GLYPH_FORMAT_BITMAP.          */
-  /*    ft_glyph_format_outline   :: See @FT_GLYPH_FORMAT_OUTLINE.         */
-  /*    ft_glyph_format_plotter   :: See @FT_GLYPH_FORMAT_PLOTTER.         */
-  /*                                                                       */
+  /* these constants are deprecated; use the corresponding */
+  /* `FT_Glyph_Format' values instead.                     */
 #define ft_glyph_format_none       FT_GLYPH_FORMAT_NONE
 #define ft_glyph_format_composite  FT_GLYPH_FORMAT_COMPOSITE
 #define ft_glyph_format_bitmap     FT_GLYPH_FORMAT_BITMAP
@@ -856,6 +775,21 @@ FT_BEGIN_HEADER
   /* <Description>                                                         */
   /*    This section contains technical definitions.                       */
   /*                                                                       */
+  /* <Order>                                                               */
+  /*    FT_Raster                                                          */
+  /*    FT_Span                                                            */
+  /*    FT_SpanFunc                                                        */
+  /*                                                                       */
+  /*    FT_Raster_Params                                                   */
+  /*    FT_RASTER_FLAG_XXX                                                 */
+  /*                                                                       */
+  /*    FT_Raster_NewFunc                                                  */
+  /*    FT_Raster_DoneFunc                                                 */
+  /*    FT_Raster_ResetFunc                                                */
+  /*    FT_Raster_SetModeFunc                                              */
+  /*    FT_Raster_RenderFunc                                               */
+  /*    FT_Raster_Funcs                                                    */
+  /*                                                                       */
   /*************************************************************************/
 
 
@@ -865,8 +799,8 @@ FT_BEGIN_HEADER
   /*    FT_Raster                                                          */
   /*                                                                       */
   /* <Description>                                                         */
-  /*    A handle (pointer) to a raster object.  Each object can be used    */
-  /*    independently to convert an outline into a bitmap or pixmap.       */
+  /*    An opaque handle (pointer) to a raster object.  Each object can be */
+  /*    used independently to convert an outline into a bitmap or pixmap.  */
   /*                                                                       */
   typedef struct FT_RasterRec_*  FT_Raster;
 
@@ -877,8 +811,8 @@ FT_BEGIN_HEADER
   /*    FT_Span                                                            */
   /*                                                                       */
   /* <Description>                                                         */
-  /*    A structure used to model a single span of gray (or black) pixels  */
-  /*    when rendering a monochrome or anti-aliased bitmap.                */
+  /*    A structure used to model a single span of gray pixels when        */
+  /*    rendering an anti-aliased bitmap.                                  */
   /*                                                                       */
   /* <Fields>                                                              */
   /*    x        :: The span's horizontal start position.                  */
@@ -886,8 +820,7 @@ FT_BEGIN_HEADER
   /*    len      :: The span's length in pixels.                           */
   /*                                                                       */
   /*    coverage :: The span color/coverage, ranging from 0 (background)   */
-  /*                to 255 (foreground).  Only used for anti-aliased       */
-  /*                rendering.                                             */
+  /*                to 255 (foreground).                                   */
   /*                                                                       */
   /* <Note>                                                                */
   /*    This structure is used by the span drawing callback type named     */
@@ -957,22 +890,7 @@ FT_BEGIN_HEADER
   /*    FT_Raster_BitTest_Func                                             */
   /*                                                                       */
   /* <Description>                                                         */
-  /*    THIS TYPE IS DEPRECATED.  DO NOT USE IT.                           */
-  /*                                                                       */
-  /*    A function used as a call-back by the monochrome scan-converter    */
-  /*    to test whether a given target pixel is already set to the drawing */
-  /*    `color'.  These tests are crucial to implement drop-out control    */
-  /*    per-se the TrueType spec.                                          */
-  /*                                                                       */
-  /* <Input>                                                               */
-  /*    y     :: The pixel's y~coordinate.                                 */
-  /*                                                                       */
-  /*    x     :: The pixel's x~coordinate.                                 */
-  /*                                                                       */
-  /*    user  :: User-supplied data that is passed to the callback.        */
-  /*                                                                       */
-  /* <Return>                                                              */
-  /*   1~if the pixel is `set', 0~otherwise.                               */
+  /*    Deprecated, unimplemented.                                         */
   /*                                                                       */
   typedef int
   (*FT_Raster_BitTest_Func)( int    y,
@@ -986,21 +904,7 @@ FT_BEGIN_HEADER
   /*    FT_Raster_BitSet_Func                                              */
   /*                                                                       */
   /* <Description>                                                         */
-  /*    THIS TYPE IS DEPRECATED.  DO NOT USE IT.                           */
-  /*                                                                       */
-  /*    A function used as a call-back by the monochrome scan-converter    */
-  /*    to set an individual target pixel.  This is crucial to implement   */
-  /*    drop-out control according to the TrueType specification.          */
-  /*                                                                       */
-  /* <Input>                                                               */
-  /*    y     :: The pixel's y~coordinate.                                 */
-  /*                                                                       */
-  /*    x     :: The pixel's x~coordinate.                                 */
-  /*                                                                       */
-  /*    user  :: User-supplied data that is passed to the callback.        */
-  /*                                                                       */
-  /* <Return>                                                              */
-  /*    1~if the pixel is `set', 0~otherwise.                              */
+  /*    Deprecated, unimplemented.                                         */
   /*                                                                       */
   typedef void
   (*FT_Raster_BitSet_Func)( int    y,
@@ -1034,8 +938,8 @@ FT_BEGIN_HEADER
   /*                              pixmap's buffer _must_ be zeroed before  */
   /*                              rendering.                               */
   /*                                                                       */
-  /*                              Note that for now, direct rendering is   */
-  /*                              only possible with anti-aliased glyphs.  */
+  /*                              Direct rendering is only possible with   */
+  /*                              anti-aliased glyphs.                     */
   /*                                                                       */
   /*    FT_RASTER_FLAG_CLIP    :: This flag is only used in direct         */
   /*                              rendering mode.  If set, the output will */
@@ -1053,7 +957,8 @@ FT_BEGIN_HEADER
 #define FT_RASTER_FLAG_DIRECT   0x2
 #define FT_RASTER_FLAG_CLIP     0x4
 
-  /* deprecated */
+  /* these constants are deprecated; use the corresponding */
+  /* `FT_RASTER_FLAG_XXX' values instead                   */
 #define ft_raster_flag_default  FT_RASTER_FLAG_DEFAULT
 #define ft_raster_flag_aa       FT_RASTER_FLAG_AA
 #define ft_raster_flag_direct   FT_RASTER_FLAG_DIRECT
@@ -1079,11 +984,11 @@ FT_BEGIN_HEADER
   /*                                                                       */
   /*    gray_spans  :: The gray span drawing callback.                     */
   /*                                                                       */
-  /*    black_spans :: The black span drawing callback.  UNIMPLEMENTED!    */
+  /*    black_spans :: Unused.                                             */
   /*                                                                       */
-  /*    bit_test    :: The bit test callback.  UNIMPLEMENTED!              */
+  /*    bit_test    :: Unused.                                             */
   /*                                                                       */
-  /*    bit_set     :: The bit set callback.  UNIMPLEMENTED!               */
+  /*    bit_set     :: Unused.                                             */
   /*                                                                       */
   /*    user        :: User-supplied data that is passed to each drawing   */
   /*                   callback.                                           */
@@ -1100,15 +1005,9 @@ FT_BEGIN_HEADER
   /*                                                                       */
   /*    If the @FT_RASTER_FLAG_DIRECT bit flag is set in `flags', the      */
   /*    raster will call the `gray_spans' callback to draw gray pixel      */
-  /*    spans, in the case of an aa glyph bitmap, it will call             */
-  /*    `black_spans', and `bit_test' and `bit_set' in the case of a       */
-  /*    monochrome bitmap.  This allows direct composition over a          */
-  /*    pre-existing bitmap through user-provided callbacks to perform the */
-  /*    span drawing/composition.                                          */
-  /*                                                                       */
-  /*    Note that the `bit_test' and `bit_set' callbacks are required when */
-  /*    rendering a monochrome bitmap, as they are crucial to implement    */
-  /*    correct drop-out control as defined in the TrueType specification. */
+  /*    spans.  This allows direct composition over a pre-existing bitmap  */
+  /*    through user-provided callbacks to perform the span drawing and    */
+  /*    composition.    Not supported by the monochrome rasterizer.        */
   /*                                                                       */
   typedef struct  FT_Raster_Params_
   {
@@ -1116,9 +1015,9 @@ FT_BEGIN_HEADER
     const void*             source;
     int                     flags;
     FT_SpanFunc             gray_spans;
-    FT_SpanFunc             black_spans;  /* doesn't work! */
-    FT_Raster_BitTest_Func  bit_test;     /* doesn't work! */
-    FT_Raster_BitSet_Func   bit_set;      /* doesn't work! */
+    FT_SpanFunc             black_spans;  /* unused */
+    FT_Raster_BitTest_Func  bit_test;     /* unused */
+    FT_Raster_BitSet_Func   bit_set;      /* unused */
     void*                   user;
     FT_BBox                 clip_box;
 
@@ -1305,7 +1204,6 @@ FT_BEGIN_HEADER
 
   } FT_Raster_Funcs;
 
-
   /* */
 
 
index aaf689f..4c0246c 100644 (file)
@@ -4,7 +4,7 @@
 /*                                                                         */
 /*    FreeType incremental loading (specification).                        */
 /*                                                                         */
-/*  Copyright 2002, 2003, 2006, 2007, 2008, 2010 by                        */
+/*  Copyright 2002, 2003, 2006-2008, 2010, 2014 by                         */
 /*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
 /*                                                                         */
 /*  This file is part of the FreeType project, and may only be used,       */
@@ -45,7 +45,7 @@ FT_BEGIN_HEADER
    * @description:
    *   This section contains various functions used to perform so-called
    *   `incremental' glyph loading.  This is a mode where all glyphs loaded
-   *   from a given @FT_Face are provided by the client application,
+   *   from a given @FT_Face are provided by the client application.
    *
    *   Apart from that, all other tables are loaded normally from the font
    *   file.  This mode is useful when FreeType is used within another
@@ -345,6 +345,7 @@ FT_BEGIN_HEADER
 
   /* */
 
+
 FT_END_HEADER
 
 #endif /* __FTINCREM_H__ */
index 39206f0..e8679c1 100644 (file)
@@ -5,7 +5,7 @@
 /*    FreeType API for color filtering of subpixel bitmap glyphs           */
 /*    (specification).                                                     */
 /*                                                                         */
-/*  Copyright 2006-2008, 2010, 2013 by                                     */
+/*  Copyright 2006-2008, 2010, 2013, 2014 by                               */
 /*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
 /*                                                                         */
 /*  This file is part of the FreeType project, and may only be used,       */
@@ -56,7 +56,7 @@ FT_BEGIN_HEADER
    *
    *   FreeType generates alpha coverage maps, which are linear by nature.
    *   For instance, the value 0x80 in bitmap representation means that
-   *   (within numerical precision) 0x80/0xff fraction of that pixel is
+   *   (within numerical precision) 0x80/0xFF fraction of that pixel is
    *   covered by the glyph's outline.  The blending function for placing
    *   text over a background is
    *
index 241e21e..9950a27 100644 (file)
@@ -4,7 +4,7 @@
 /*                                                                         */
 /*    Generic list support for FreeType (specification).                   */
 /*                                                                         */
-/*  Copyright 1996-2001, 2003, 2007, 2010, 2013 by                         */
+/*  Copyright 1996-2001, 2003, 2007, 2010, 2013, 2014 by                   */
 /*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
 /*                                                                         */
 /*  This file is part of the FreeType project, and may only be used,       */
@@ -248,7 +248,7 @@ FT_BEGIN_HEADER
   /*    list    :: A handle to the list.                                   */
   /*                                                                       */
   /*    destroy :: A list destructor that will be applied to each element  */
-  /*               of the list.                                            */
+  /*               of the list.  Set this to NULL if not needed.           */
   /*                                                                       */
   /*    memory  :: The current memory object that handles deallocation.    */
   /*                                                                       */
@@ -265,7 +265,6 @@ FT_BEGIN_HEADER
                     FT_Memory           memory,
                     void*               user );
 
-
   /* */
 
 
index 00d4016..857c0c5 100644 (file)
@@ -88,7 +88,7 @@ FT_BEGIN_HEADER
   FT_Stream_OpenLZW( FT_Stream  stream,
                      FT_Stream  source );
 
- /* */
 /* */
 
 
 FT_END_HEADER
index 837975a..2dcfd67 100644 (file)
@@ -218,9 +218,6 @@ FT_BEGIN_HEADER
   } FT_MM_Var;
 
 
-  /* */
-
-
   /*************************************************************************/
   /*                                                                       */
   /* <Function>                                                            */
@@ -365,7 +362,6 @@ FT_BEGIN_HEADER
                                 FT_UInt    num_coords,
                                 FT_Fixed*  coords );
 
-
   /* */
 
 
index 22878f8..980f15d 100644 (file)
@@ -75,6 +75,33 @@ FT_BEGIN_HEADER
   /*                                                                       */
   /*    Note that the FreeType Cache sub-system is not a FreeType module.  */
   /*                                                                       */
+  /* <Order>                                                               */
+  /*    FT_Module                                                          */
+  /*    FT_Module_Constructor                                              */
+  /*    FT_Module_Destructor                                               */
+  /*    FT_Module_Requester                                                */
+  /*    FT_Module_Class                                                    */
+  /*                                                                       */
+  /*    FT_Add_Module                                                      */
+  /*    FT_Get_Module                                                      */
+  /*    FT_Remove_Module                                                   */
+  /*    FT_Add_Default_Modules                                             */
+  /*                                                                       */
+  /*    FT_Property_Set                                                    */
+  /*    FT_Property_Get                                                    */
+  /*                                                                       */
+  /*    FT_New_Library                                                     */
+  /*    FT_Done_Library                                                    */
+  /*    FT_Reference_Library                                               */
+  /*                                                                       */
+  /*    FT_Renderer                                                        */
+  /*    FT_Renderer_Class                                                  */
+  /*                                                                       */
+  /*    FT_Get_Renderer                                                    */
+  /*    FT_Set_Renderer                                                    */
+  /*                                                                       */
+  /*    FT_Set_Debug_Hook                                                  */
+  /*                                                                       */
   /*************************************************************************/
 
 
@@ -491,7 +518,7 @@ FT_BEGIN_HEADER
   FT_EXPORT( FT_Error )
   FT_Done_Library( FT_Library  library );
 
-/* */
+  /* */
 
   typedef void
   (*FT_DebugHook_Func)( void*  arg );
@@ -629,7 +656,6 @@ FT_BEGIN_HEADER
   FT_EXPORT( FT_TrueTypeEngineType )
   FT_Get_TrueType_Engine_Type( FT_Library  library );
 
-
   /* */
 
 
index bb52dc4..75ba03e 100644 (file)
@@ -4,7 +4,7 @@
 /*                                                                         */
 /*    FreeType API for validating OpenType tables (specification).         */
 /*                                                                         */
-/*  Copyright 2004-2007, 2013 by                                           */
+/*  Copyright 2004-2007, 2013, 2014 by                                     */
 /*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
 /*                                                                         */
 /*  This file is part of the FreeType project, and may only be used,       */
@@ -58,6 +58,12 @@ FT_BEGIN_HEADER
   /*    This section contains the declaration of functions to validate     */
   /*    some OpenType tables (BASE, GDEF, GPOS, GSUB, JSTF, MATH).         */
   /*                                                                       */
+  /* <Order>                                                               */
+  /*    FT_OpenType_Validate                                               */
+  /*    FT_OpenType_Free                                                   */
+  /*                                                                       */
+  /*    FT_VALIDATE_OTXXX                                                  */
+  /*                                                                       */
   /*************************************************************************/
 
 
@@ -107,8 +113,6 @@ FT_BEGIN_HEADER
                         FT_VALIDATE_JSTF | \
                         FT_VALIDATE_MATH
 
-  /* */
-
  /**********************************************************************
   *
   * @function:
@@ -165,8 +169,6 @@ FT_BEGIN_HEADER
                         FT_Bytes  *GSUB_table,
                         FT_Bytes  *JSTF_table );
 
-  /* */
-
  /**********************************************************************
   *
   * @function:
@@ -191,8 +193,7 @@ FT_BEGIN_HEADER
   FT_OpenType_Free( FT_Face   face,
                     FT_Bytes  table );
 
-
- /* */
+  /* */
 
 
 FT_END_HEADER
index 6c6d3f9..d3b8fbd 100644 (file)
@@ -52,7 +52,6 @@ FT_BEGIN_HEADER
   /*                                                                       */
   /* <Order>                                                               */
   /*    FT_Outline                                                         */
-  /*    FT_OUTLINE_FLAGS                                                   */
   /*    FT_Outline_New                                                     */
   /*    FT_Outline_Done                                                    */
   /*    FT_Outline_Copy                                                    */
@@ -68,13 +67,17 @@ FT_BEGIN_HEADER
   /*                                                                       */
   /*    FT_Outline_Get_Bitmap                                              */
   /*    FT_Outline_Render                                                  */
-  /*                                                                       */
   /*    FT_Outline_Decompose                                               */
   /*    FT_Outline_Funcs                                                   */
-  /*    FT_Outline_MoveTo_Func                                             */
-  /*    FT_Outline_LineTo_Func                                             */
-  /*    FT_Outline_ConicTo_Func                                            */
-  /*    FT_Outline_CubicTo_Func                                            */
+  /*    FT_Outline_MoveToFunc                                              */
+  /*    FT_Outline_LineToFunc                                              */
+  /*    FT_Outline_ConicToFunc                                             */
+  /*    FT_Outline_CubicToFunc                                             */
+  /*                                                                       */
+  /*    FT_Orientation                                                     */
+  /*    FT_Outline_Get_Orientation                                         */
+  /*                                                                       */
+  /*    FT_OUTLINE_XXX                                                     */
   /*                                                                       */
   /*************************************************************************/
 
@@ -535,7 +538,7 @@ FT_BEGIN_HEADER
   *
   * @description:
   *   This function analyzes a glyph outline and tries to compute its
-  *   fill orientation (see @FT_Orientation).  This is done by integrating 
+  *   fill orientation (see @FT_Orientation).  This is done by integrating
   *   the total area covered by the outline. The positive integral
   *   corresponds to the clockwise orientation and @FT_ORIENTATION_POSTSCRIPT
   *   is returned. The negative integral corresponds to the counter-clockwise
@@ -555,7 +558,6 @@ FT_BEGIN_HEADER
   FT_EXPORT( FT_Orientation )
   FT_Outline_Get_Orientation( FT_Outline*  outline );
 
-
   /* */
 
 
index 0b7b7d4..7d50353 100644 (file)
@@ -161,7 +161,7 @@ FT_BEGIN_HEADER
                       FT_UInt   gindex,
                       FT_Pos   *aadvance );
 
- /* */
 /* */
 
 
 FT_END_HEADER
index dd0229b..e8d3636 100644 (file)
@@ -226,7 +226,6 @@ FT_BEGIN_HEADER
                    FT_UInt        num_params,
                    FT_Parameter*  parameters );
 
-
   /* */
 
 
index a498e4a..bd31170 100644 (file)
@@ -4,7 +4,7 @@
 /*                                                                         */
 /*    FreeType path stroker (specification).                               */
 /*                                                                         */
-/*  Copyright 2002-2006, 2008, 2009, 2011-2012 by                          */
+/*  Copyright 2002-2006, 2008, 2009, 2011-2012, 2014 by                    */
 /*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
 /*                                                                         */
 /*  This file is part of the FreeType project, and may only be used,       */
@@ -46,6 +46,38 @@ FT_BEGIN_HEADER
   *    This can be useful to generate `bordered' glyph, i.e., glyphs
   *    displayed with a coloured (and anti-aliased) border around their
   *    shape.
+  *
+  * @order:
+  *    FT_Stroker
+  *
+  *    FT_Stroker_LineJoin
+  *    FT_Stroker_LineCap
+  *    FT_StrokerBorder
+  *
+  *    FT_Outline_GetInsideBorder
+  *    FT_Outline_GetOutsideBorder
+  *
+  *    FT_Glyph_Stroke
+  *    FT_Glyph_StrokeBorder
+  *
+  *    FT_Stroker_New
+  *    FT_Stroker_Set
+  *    FT_Stroker_Rewind
+  *    FT_Stroker_ParseOutline
+  *    FT_Stroker_Done
+  *
+  *    FT_Stroker_BeginSubPath
+  *    FT_Stroker_EndSubPath
+  *
+  *    FT_Stroker_LineTo
+  *    FT_Stroker_ConicTo
+  *    FT_Stroker_CubicTo
+  *
+  *    FT_Stroker_GetBorderCounts
+  *    FT_Stroker_ExportBorder
+  *    FT_Stroker_GetCounts
+  *    FT_Stroker_Export
+  *
   */
 
 
@@ -55,7 +87,7 @@ FT_BEGIN_HEADER
   *   FT_Stroker
   *
   * @description:
-  *   Opaque handler to a path stroker object.
+  *   Opaque handle to a path stroker object.
   */
   typedef struct FT_StrokerRec_*  FT_Stroker;
 
@@ -276,6 +308,8 @@ FT_BEGIN_HEADER
    * @note:
    *   The radius is expressed in the same units as the outline
    *   coordinates.
+   *
+   *   This function calls @FT_Stroker_Rewind automatically.
    */
   FT_EXPORT( void )
   FT_Stroker_Set( FT_Stroker           stroker,
@@ -570,10 +604,10 @@ FT_BEGIN_HEADER
    *   receive all new data.
    *
    *   When an outline, or a sub-path, is `closed', the stroker generates
-   *   two independent `border' outlines, named `left' and `right'
+   *   two independent `border' outlines, named `left' and `right'.
    *
    *   When the outline, or a sub-path, is `opened', the stroker merges
-   *   the `border' outlines with caps. The `left' border receives all
+   *   the `border' outlines with caps.  The `left' border receives all
    *   points, while the `right' border becomes empty.
    *
    *   Use the function @FT_Stroker_Export instead if you want to
@@ -736,7 +770,7 @@ FT_BEGIN_HEADER
                          FT_Bool      inside,
                          FT_Bool      destroy );
 
- /* */
 /* */
 
 FT_END_HEADER
 
index 839ab5e..d0ea730 100644 (file)
@@ -73,6 +73,7 @@ FT_BEGIN_HEADER
 
   /* */
 
+
 FT_END_HEADER
 
 #endif /* __FTSYNTH_H__ */
index e07460c..7436ed2 100644 (file)
@@ -4,7 +4,7 @@
 /*                                                                         */
 /*    FreeType low-level system interface definition (specification).      */
 /*                                                                         */
-/*  Copyright 1996-2001, 2002, 2005, 2010 by                               */
+/*  Copyright 1996-2001, 2002, 2005, 2010, 2014 by                         */
 /*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
 /*                                                                         */
 /*  This file is part of the FreeType project, and may only be used,       */
@@ -192,6 +192,10 @@ FT_BEGIN_HEADER
    * @description:
    *   A handle to an input stream.
    *
+   * @also:
+   *   See @FT_StreamRec for the publicly accessible fields of a given
+   *   stream object.
+   *
    */
   typedef struct FT_StreamRec_*  FT_Stream;
 
@@ -285,6 +289,11 @@ FT_BEGIN_HEADER
    *   size ::
    *     The stream size in bytes.
    *
+   *     In case of compressed streams where the size is unknown before
+   *     actually doing the decompression, the value is set to 0x7FFFFFFF. 
+   *     (Note that this size value can occur for normal streams also; it is
+   *     thus just a hint.)
+   *
    *   pos ::
    *     The current position within the stream.
    *
@@ -335,7 +344,6 @@ FT_BEGIN_HEADER
 
   } FT_StreamRec;
 
-
   /* */
 
 
index 65143cb..9c7b543 100644 (file)
@@ -237,7 +237,7 @@ FT_BEGIN_HEADER
    *
    * @input:
    *   angle ::
-   *     The address of angle.
+   *     The input angle.
    *
    */
   FT_EXPORT( void )
@@ -259,7 +259,7 @@ FT_BEGIN_HEADER
    *
    * @input:
    *   angle ::
-   *     The address of angle.
+   *     The input angle.
    *
    */
   FT_EXPORT( void )
index 70ad3d5..3588413 100644 (file)
@@ -158,9 +158,9 @@ FT_BEGIN_HEADER
 #define TT_INTERPRETER_VERSION_35  35
 #define TT_INTERPRETER_VERSION_38  38
 
-
  /* */
 
+
 FT_END_HEADER
 
 
index bd944a4..2c01e87 100644 (file)
@@ -4,7 +4,7 @@
 /*                                                                         */
 /*    FreeType simple types definitions (specification only).              */
 /*                                                                         */
-/*  Copyright 1996-2002, 2004, 2006-2009, 2012, 2013 by                    */
+/*  Copyright 1996-2002, 2004, 2006-2009, 2012-2014 by                     */
 /*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
 /*                                                                         */
 /*  This file is part of the FreeType project, and may only be used,       */
@@ -57,6 +57,8 @@ FT_BEGIN_HEADER
   /*    FT_UInt16                                                          */
   /*    FT_Int32                                                           */
   /*    FT_UInt32                                                          */
+  /*    FT_Int64                                                           */
+  /*    FT_UInt64                                                          */
   /*    FT_Short                                                           */
   /*    FT_UShort                                                          */
   /*    FT_Long                                                            */
@@ -78,7 +80,9 @@ FT_BEGIN_HEADER
   /*    FT_F2Dot14                                                         */
   /*    FT_UnitVector                                                      */
   /*    FT_F26Dot6                                                         */
+  /*    FT_Data                                                            */
   /*                                                                       */
+  /*    FT_MAKE_TAG                                                        */
   /*                                                                       */
   /*    FT_Generic                                                         */
   /*    FT_Generic_Finalizer                                               */
@@ -567,9 +571,9 @@ FT_BEGIN_HEADER
 
   } FT_ListRec;
 
-
   /* */
 
+
 #define FT_IS_EMPTY( list )  ( (list).head == 0 )
 #define FT_BOOL( x )  ( (FT_Bool)( x ) )
 
index 0b67351..5026158 100644 (file)
@@ -259,9 +259,9 @@ FT_BEGIN_HEADER
   FT_Get_WinFNT_Header( FT_Face               face,
                         FT_WinFNT_HeaderRec  *aheader );
 
-
   /* */
 
+
 FT_END_HEADER
 
 #endif /* __FTWINFNT_H__ */
index 493cccd..89d1993 100644 (file)
@@ -76,7 +76,8 @@ FT_BEGIN_HEADER
   FT_EXPORT( const char* )
   FT_Get_X11_Font_Format( FT_Face  face );
 
- /* */
+  /* */
+
 
 FT_END_HEADER
 
index 03bd68e..14ec37b 100644 (file)
@@ -4,7 +4,7 @@
 /*                                                                         */
 /*    Arithmetic computations (specification).                             */
 /*                                                                         */
-/*  Copyright 1996-2006, 2008, 2009, 2012-2013 by                          */
+/*  Copyright 1996-2006, 2008, 2009, 2012-2014 by                          */
 /*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
 /*                                                                         */
 /*  This file is part of the FreeType project, and may only be used,       */
 FT_BEGIN_HEADER
 
 
-#if 0
-
   /*************************************************************************/
   /*                                                                       */
-  /* <Function>                                                            */
-  /*    FT_SqrtFixed                                                       */
-  /*                                                                       */
-  /* <Description>                                                         */
-  /*    Computes the square root of a 16.16 fixed-point value.             */
-  /*                                                                       */
-  /* <Input>                                                               */
-  /*    x :: The value to compute the root for.                            */
-  /*                                                                       */
-  /* <Return>                                                              */
-  /*    The result of `sqrt(x)'.                                           */
-  /*                                                                       */
-  /* <Note>                                                                */
-  /*    This function is not very fast.                                    */
+  /* FT_MulDiv() and FT_MulFix() are declared in freetype.h.               */
   /*                                                                       */
-  FT_BASE( FT_Int32 )
-  FT_SqrtFixed( FT_Int32  x );
+  /*************************************************************************/
 
-#endif /* 0 */
+#ifndef  FT_CONFIG_OPTION_NO_ASSEMBLER
+  /* Provide assembler fragments for performance-critical functions. */
+  /* These must be defined `static __inline__' with GCC.             */
 
+#if defined( __CC_ARM ) || defined( __ARMCC__ )  /* RVCT */
 
-  /*************************************************************************/
-  /*                                                                       */
-  /* FT_MulDiv() and FT_MulFix() are declared in freetype.h.               */
-  /*                                                                       */
-  /*************************************************************************/
+#define FT_MULFIX_ASSEMBLER  FT_MulFix_arm
+
+  /* documentation is in freetype.h */
+
+  static __inline FT_Int32
+  FT_MulFix_arm( FT_Int32  a,
+                 FT_Int32  b )
+  {
+    register FT_Int32  t, t2;
+
+
+    __asm
+    {
+      smull t2, t,  b,  a           /* (lo=t2,hi=t) = a*b */
+      mov   a,  t,  asr #31         /* a   = (hi >> 31) */
+      add   a,  a,  #0x8000         /* a  += 0x8000 */
+      adds  t2, t2, a               /* t2 += a */
+      adc   t,  t,  #0              /* t  += carry */
+      mov   a,  t2, lsr #16         /* a   = t2 >> 16 */
+      orr   a,  a,  t,  lsl #16     /* a  |= t << 16 */
+    }
+    return a;
+  }
+
+#endif /* __CC_ARM || __ARMCC__ */
+
+
+#ifdef __GNUC__
+
+#if defined( __arm__ )                                 && \
+    ( !defined( __thumb__ ) || defined( __thumb2__ ) ) && \
+    !( defined( __CC_ARM ) || defined( __ARMCC__ ) )
+
+#define FT_MULFIX_ASSEMBLER  FT_MulFix_arm
+
+  /* documentation is in freetype.h */
+
+  static __inline__ FT_Int32
+  FT_MulFix_arm( FT_Int32  a,
+                 FT_Int32  b )
+  {
+    register FT_Int32  t, t2;
+
+
+    __asm__ __volatile__ (
+      "smull  %1, %2, %4, %3\n\t"       /* (lo=%1,hi=%2) = a*b */
+      "mov    %0, %2, asr #31\n\t"      /* %0  = (hi >> 31) */
+#if defined( __clang__ ) && defined( __thumb2__ )
+      "add.w  %0, %0, #0x8000\n\t"      /* %0 += 0x8000 */
+#else
+      "add    %0, %0, #0x8000\n\t"      /* %0 += 0x8000 */
+#endif
+      "adds   %1, %1, %0\n\t"           /* %1 += %0 */
+      "adc    %2, %2, #0\n\t"           /* %2 += carry */
+      "mov    %0, %1, lsr #16\n\t"      /* %0  = %1 >> 16 */
+      "orr    %0, %0, %2, lsl #16\n\t"  /* %0 |= %2 << 16 */
+      : "=r"(a), "=&r"(t2), "=&r"(t)
+      : "r"(a), "r"(b)
+      : "cc" );
+    return a;
+  }
+
+#endif /* __arm__                      && */
+       /* ( __thumb2__ || !__thumb__ ) && */
+       /* !( __CC_ARM || __ARMCC__ )      */
+
+
+#if defined( __i386__ )
+
+#define FT_MULFIX_ASSEMBLER  FT_MulFix_i386
+
+  /* documentation is in freetype.h */
+
+  static __inline__ FT_Int32
+  FT_MulFix_i386( FT_Int32  a,
+                  FT_Int32  b )
+  {
+    register FT_Int32  result;
+
+
+    __asm__ __volatile__ (
+      "imul  %%edx\n"
+      "movl  %%edx, %%ecx\n"
+      "sarl  $31, %%ecx\n"
+      "addl  $0x8000, %%ecx\n"
+      "addl  %%ecx, %%eax\n"
+      "adcl  $0, %%edx\n"
+      "shrl  $16, %%eax\n"
+      "shll  $16, %%edx\n"
+      "addl  %%edx, %%eax\n"
+      : "=a"(result), "=d"(b)
+      : "a"(a), "d"(b)
+      : "%ecx", "cc" );
+    return result;
+  }
+
+#endif /* i386 */
+
+#endif /* __GNUC__ */
+
+
+#ifdef _MSC_VER /* Visual C++ */
+
+#ifdef _M_IX86
+
+#define FT_MULFIX_ASSEMBLER  FT_MulFix_i386
+
+  /* documentation is in freetype.h */
+
+  static __inline FT_Int32
+  FT_MulFix_i386( FT_Int32  a,
+                  FT_Int32  b )
+  {
+    register FT_Int32  result;
+
+    __asm
+    {
+      mov eax, a
+      mov edx, b
+      imul edx
+      mov ecx, edx
+      sar ecx, 31
+      add ecx, 8000h
+      add eax, ecx
+      adc edx, 0
+      shr eax, 16
+      shl edx, 16
+      add eax, edx
+      mov result, eax
+    }
+    return result;
+  }
+
+#endif /* _M_IX86 */
+
+#endif /* _MSC_VER */
+
+
+#if defined( __GNUC__ ) && defined( __x86_64__ )
+
+#define FT_MULFIX_ASSEMBLER  FT_MulFix_x86_64
+
+  static __inline__ FT_Int32
+  FT_MulFix_x86_64( FT_Int32  a,
+                    FT_Int32  b )
+  {
+    /* Temporarily disable the warning that C90 doesn't support */
+    /* `long long'.                                             */
+#if __GNUC__ > 4 || ( __GNUC__ == 4 && __GNUC_MINOR__ >= 6 )
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wlong-long"
+#endif
+
+#if 1
+    /* Technically not an assembly fragment, but GCC does a really good */
+    /* job at inlining it and generating good machine code for it.      */
+    long long  ret, tmp;
+
+
+    ret  = (long long)a * b;
+    tmp  = ret >> 63;
+    ret += 0x8000 + tmp;
+
+    return (FT_Int32)( ret >> 16 );
+#else
+
+    /* For some reason, GCC 4.6 on Ubuntu 12.04 generates invalid machine  */
+    /* code from the lines below.  The main issue is that `wide_a' is not  */
+    /* properly initialized by sign-extending `a'.  Instead, the generated */
+    /* machine code assumes that the register that contains `a' on input   */
+    /* can be used directly as a 64-bit value, which is wrong most of the  */
+    /* time.                                                               */
+    long long  wide_a = (long long)a;
+    long long  wide_b = (long long)b;
+    long long  result;
+
+
+    __asm__ __volatile__ (
+      "imul %2, %1\n"
+      "mov %1, %0\n"
+      "sar $63, %0\n"
+      "lea 0x8000(%1, %0), %0\n"
+      "sar $16, %0\n"
+      : "=&r"(result), "=&r"(wide_a)
+      : "r"(wide_b)
+      : "cc" );
+
+    return (FT_Int32)result;
+#endif
+
+#if __GNUC__ > 4 || ( __GNUC__ == 4 && __GNUC_MINOR__ >= 6 )
+#pragma GCC diagnostic pop
+#endif
+  }
+
+#endif /* __GNUC__ && __x86_64__ */
+
+#endif /* !FT_CONFIG_OPTION_NO_ASSEMBLER */
+
+
+#ifdef FT_CONFIG_OPTION_INLINE_MULFIX
+#ifdef FT_MULFIX_ASSEMBLER
+#define FT_MulFix( a, b )  FT_MULFIX_ASSEMBLER( (FT_Int32)(a), (FT_Int32)(b) )
+#endif
+#endif
 
 
   /*************************************************************************/
@@ -124,10 +311,11 @@ FT_BEGIN_HEADER
                          FT_Pos  out_x,
                          FT_Pos  out_y );
 
+
   /*
    *  Return TRUE if a corner is flat or nearly flat.  This is equivalent to
-   *  saying that the angle difference between the `in' and `out' vectors is
-   *  very small.
+   *  saying that the corner point is close to its neighbors, or inside an
+   *  ellipse defined by the neighbor focal points to be more precise.
    */
   FT_BASE( FT_Int )
   ft_corner_is_flat( FT_Pos  in_x,
@@ -139,9 +327,31 @@ FT_BEGIN_HEADER
   /*
    *  Return the most significant bit index.
    */
+
+#ifndef  FT_CONFIG_OPTION_NO_ASSEMBLER
+#if defined( __GNUC__ )                                          && \
+    ( __GNUC__ > 3 || ( __GNUC__ == 3 && __GNUC_MINOR__ >= 4 ) )
+
+#if FT_SIZEOF_INT == 4
+
+#define FT_MSB( x )  ( 31 - __builtin_clz( x ) )
+
+#elif FT_SIZEOF_LONG == 4
+
+#define FT_MSB( x )  ( 31 - __builtin_clzl( x ) )
+
+#endif
+
+#endif /* __GNUC__ */
+#endif /* !FT_CONFIG_OPTION_NO_ASSEMBLER */
+
+#ifndef FT_MSB
+
   FT_BASE( FT_Int )
   FT_MSB( FT_UInt32  z );
 
+#endif
+
 
   /*
    *  Return sqrt(x*x+y*y), which is the same as `FT_Vector_Length' but uses
@@ -152,6 +362,31 @@ FT_BEGIN_HEADER
             FT_Fixed  y );
 
 
+#if 0
+
+  /*************************************************************************/
+  /*                                                                       */
+  /* <Function>                                                            */
+  /*    FT_SqrtFixed                                                       */
+  /*                                                                       */
+  /* <Description>                                                         */
+  /*    Computes the square root of a 16.16 fixed-point value.             */
+  /*                                                                       */
+  /* <Input>                                                               */
+  /*    x :: The value to compute the root for.                            */
+  /*                                                                       */
+  /* <Return>                                                              */
+  /*    The result of `sqrt(x)'.                                           */
+  /*                                                                       */
+  /* <Note>                                                                */
+  /*    This function is not very fast.                                    */
+  /*                                                                       */
+  FT_BASE( FT_Int32 )
+  FT_SqrtFixed( FT_Int32  x );
+
+#endif /* 0 */
+
+
 #define INT_TO_F26DOT6( x )    ( (FT_Long)(x) << 6  )
 #define INT_TO_F2DOT14( x )    ( (FT_Long)(x) << 14 )
 #define INT_TO_FIXED( x )      ( (FT_Long)(x) << 16 )
index ce4dc6c..f70774f 100644 (file)
@@ -121,20 +121,22 @@ FT_BEGIN_HEADER
                               FT_UInt         n_contours );
 
 
-#define FT_GLYPHLOADER_CHECK_P( _loader, _count )                         \
-   ( (_count) == 0 || ((_loader)->base.outline.n_points    +              \
-                       (_loader)->current.outline.n_points +              \
-                       (unsigned long)(_count)) <= (_loader)->max_points )
-
-#define FT_GLYPHLOADER_CHECK_C( _loader, _count )                          \
-  ( (_count) == 0 || ((_loader)->base.outline.n_contours    +              \
-                      (_loader)->current.outline.n_contours +              \
-                      (unsigned long)(_count)) <= (_loader)->max_contours )
-
-#define FT_GLYPHLOADER_CHECK_POINTS( _loader, _points,_contours )      \
-  ( ( FT_GLYPHLOADER_CHECK_P( _loader, _points )   &&                  \
-      FT_GLYPHLOADER_CHECK_C( _loader, _contours ) )                   \
-    ? 0                                                                \
+#define FT_GLYPHLOADER_CHECK_P( _loader, _count )           \
+  ( (_count) == 0                                        || \
+    ( (_loader)->base.outline.n_points    +                 \
+      (_loader)->current.outline.n_points +                 \
+      (unsigned long)(_count) ) <= (_loader)->max_points )
+
+#define FT_GLYPHLOADER_CHECK_C( _loader, _count )            \
+  ( (_count) == 0                                         || \
+    ( (_loader)->base.outline.n_contours    +                \
+      (_loader)->current.outline.n_contours +                \
+      (unsigned long)(_count)) <= (_loader)->max_contours )
+
+#define FT_GLYPHLOADER_CHECK_POINTS( _loader, _points, _contours )      \
+  ( ( FT_GLYPHLOADER_CHECK_P( _loader, _points )   &&                   \
+      FT_GLYPHLOADER_CHECK_C( _loader, _contours ) )                    \
+    ? 0                                                                 \
     : FT_GlyphLoader_CheckPoints( (_loader), (_points), (_contours) ) )
 
 
index 701c850..b45a5ed 100644 (file)
@@ -72,6 +72,16 @@ FT_BEGIN_HEADER
 
 #define FT_ABS( a )     ( (a) < 0 ? -(a) : (a) )
 
+  /*
+   *  Approximate sqrt(x*x+y*y) using the `alpha max plus beta min'
+   *  algorithm.  We use alpha = 1, beta = 3/8, giving us results with a
+   *  largest error less than 7% compared to the exact value.
+   */
+#define FT_HYPOT( x, y )                 \
+          ( x = FT_ABS( x ),             \
+            y = FT_ABS( y ),             \
+            x > y ? x + ( 3 * y >> 3 )   \
+                  : y + ( 3 * x >> 3 ) )
 
 #define FT_PAD_FLOOR( x, n )  ( (x) & ~((n)-1) )
 #define FT_PAD_ROUND( x, n )  FT_PAD_FLOOR( (x) + ((n)/2), n )
@@ -82,14 +92,6 @@ FT_BEGIN_HEADER
 #define FT_PIX_CEIL( x )      FT_PIX_FLOOR( (x) + 63 )
 
 
-  /*
-   *  Return the highest power of 2 that is <= value; this correspond to
-   *  the highest bit in a given 32-bit value.
-   */
-  FT_BASE( FT_UInt32 )
-  ft_highpow2( FT_UInt32  value );
-
-
   /*
    *  character classification functions -- since these are used to parse
    *  font files, we must not use those in <ctypes.h> which are
index 12ad036..c281b14 100644 (file)
@@ -4,7 +4,7 @@
 /*                                                                         */
 /*    FreeType validation support (specification).                         */
 /*                                                                         */
-/*  Copyright 2004, 2013 by                                                */
+/*  Copyright 2004, 2013, 2014 by                                          */
 /*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
 /*                                                                         */
 /*  This file is part of the FreeType project, and may only be used,       */
@@ -87,13 +87,13 @@ FT_BEGIN_HEADER
   /* validator structure */
   typedef struct  FT_ValidatorRec_
   {
+    ft_jmp_buf          jump_buffer; /* used for exception handling      */
+
     const FT_Byte*      base;        /* address of table in memory       */
     const FT_Byte*      limit;       /* `base' + sizeof(table) in memory */
     FT_ValidationLevel  level;       /* validation level                 */
     FT_Error            error;       /* error returned. 0 means success  */
 
-    ft_jmp_buf          jump_buffer; /* used for exception handling      */
-
   } FT_ValidatorRec;
 
 #if defined( _MSC_VER )
@@ -126,31 +126,29 @@ FT_BEGIN_HEADER
   /* Calls ft_validate_error.  Assumes that the `valid' local variable */
   /* holds a pointer to the current validator object.                  */
   /*                                                                   */
-  /* Use preprocessor prescan to pass FT_ERR_PREFIX.                   */
-  /*                                                                   */
-#define FT_INVALID( _prefix, _error )  FT_INVALID_( _prefix, _error )
-#define FT_INVALID_( _prefix, _error ) \
-          ft_validator_error( valid, _prefix ## _error )
+#define FT_INVALID( _error )  FT_INVALID_( _error )
+#define FT_INVALID_( _error ) \
+          ft_validator_error( valid, FT_THROW( _error ) )
 
   /* called when a broken table is detected */
 #define FT_INVALID_TOO_SHORT \
-          FT_INVALID( FT_ERR_PREFIX, Invalid_Table )
+          FT_INVALID( Invalid_Table )
 
   /* called when an invalid offset is detected */
 #define FT_INVALID_OFFSET \
-          FT_INVALID( FT_ERR_PREFIX, Invalid_Offset )
+          FT_INVALID( Invalid_Offset )
 
   /* called when an invalid format/value is detected */
 #define FT_INVALID_FORMAT \
-          FT_INVALID( FT_ERR_PREFIX, Invalid_Table )
+          FT_INVALID( Invalid_Table )
 
   /* called when an invalid glyph index is detected */
 #define FT_INVALID_GLYPH_ID \
-          FT_INVALID( FT_ERR_PREFIX, Invalid_Glyph_Index )
+          FT_INVALID( Invalid_Glyph_Index )
 
   /* called when an invalid field value is detected */
 #define FT_INVALID_DATA \
-          FT_INVALID( FT_ERR_PREFIX, Invalid_Table )
+          FT_INVALID( Invalid_Table )
 
 
 FT_END_HEADER
index 3fb18dc..f05ea68 100644 (file)
@@ -6,7 +6,7 @@
 /*    recorders (specification only).  These are used to support native    */
 /*    T1/T2 hints in the `type1', `cid', and `cff' font drivers.           */
 /*                                                                         */
-/*  Copyright 2001-2003, 2005-2007, 2009, 2012 by                          */
+/*  Copyright 2001-2003, 2005-2007, 2009, 2012, 2014 by                    */
 /*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
 /*                                                                         */
 /*  This file is part of the FreeType project, and may only be used,       */
@@ -45,7 +45,7 @@ FT_BEGIN_HEADER
                           T1_Private*   private_dict,
                           PSH_Globals*  aglobals );
 
-  typedef FT_Error
+  typedef void
   (*PSH_Globals_SetScaleFunc)( PSH_Globals  globals,
                                FT_Fixed     x_scale,
                                FT_Fixed     y_scale,
index 6b5e41f..d558e86 100644 (file)
@@ -4,7 +4,7 @@
 /*                                                                         */
 /*    High-level `sfnt' driver interface (specification).                  */
 /*                                                                         */
-/*  Copyright 1996-2006, 2009, 2012-2013 by                                */
+/*  Copyright 1996-2006, 2009, 2012-2014 by                                */
 /*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
 /*                                                                         */
 /*  This file is part of the FreeType project, and may only be used,       */
@@ -405,14 +405,18 @@ FT_BEGIN_HEADER
   /* <Input>                                                               */
   /*    face     :: A handle to the target face object.                    */
   /*                                                                       */
-  /*    stream   :: The input stream.                                      */
-  /*                                                                       */
   /*    vertical :: A boolean flag.  If set, load vertical metrics.        */
   /*                                                                       */
-  /* <Return>                                                              */
-  /*    FreeType error code.  0 means success.                             */
+  /*    gindex   :: The glyph index.                                       */
   /*                                                                       */
-  typedef FT_Error
+  /* <Output>                                                              */
+  /*    abearing :: The horizontal (or vertical) bearing.  Set to zero in  */
+  /*                case of error.                                         */
+  /*                                                                       */
+  /*    aadvance :: The horizontal (or vertical) advance.  Set to zero in  */
+  /*                case of error.                                         */
+  /*                                                                       */
+  typedef void
   (*TT_Get_Metrics_Func)( TT_Face     face,
                           FT_Bool     vertical,
                           FT_UInt     gindex,
index a14255e..61aefdd 100644 (file)
@@ -5,7 +5,7 @@
 /*    Basic Type 1/Type 2 tables definitions and interface (specification  */
 /*    only).                                                               */
 /*                                                                         */
-/*  Copyright 1996-2004, 2006, 2008, 2009, 2011 by                         */
+/*  Copyright 1996-2004, 2006, 2008, 2009, 2011, 2014 by                   */
 /*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
 /*                                                                         */
 /*  This file is part of the FreeType project, and may only be used,       */
@@ -49,6 +49,26 @@ FT_BEGIN_HEADER
   /*    This section contains the definition of Type 1-specific tables,    */
   /*    including structures related to other PostScript font formats.     */
   /*                                                                       */
+  /* <Order>                                                               */
+  /*    PS_FontInfoRec                                                     */
+  /*    PS_FontInfo                                                        */
+  /*    PS_PrivateRec                                                      */
+  /*    PS_Private                                                         */
+  /*                                                                       */
+  /*    CID_FaceDictRec                                                    */
+  /*    CID_FaceDict                                                       */
+  /*    CID_FaceInfoRec                                                    */
+  /*    CID_FaceInfo                                                       */
+  /*                                                                       */
+  /*    FT_Has_PS_Glyph_Names                                              */
+  /*    FT_Get_PS_Font_Info                                                */
+  /*    FT_Get_PS_Font_Private                                             */
+  /*    FT_Get_PS_Font_Value                                               */
+  /*                                                                       */
+  /*    T1_Blend_Flags                                                     */
+  /*    T1_EncodingType                                                    */
+  /*    PS_Dict_Keys                                                       */
+  /*                                                                       */
   /*************************************************************************/
 
 
@@ -190,14 +210,30 @@ FT_BEGIN_HEADER
   /*    given blend dictionary (font info or private).  Used to support    */
   /*    Multiple Masters fonts.                                            */
   /*                                                                       */
+  /* <Values>                                                              */
+  /*    T1_BLEND_UNDERLINE_POSITION ::                                     */
+  /*    T1_BLEND_UNDERLINE_THICKNESS ::                                    */
+  /*    T1_BLEND_ITALIC_ANGLE ::                                           */
+  /*    T1_BLEND_BLUE_VALUES ::                                            */
+  /*    T1_BLEND_OTHER_BLUES ::                                            */
+  /*    T1_BLEND_STANDARD_WIDTH ::                                         */
+  /*    T1_BLEND_STANDARD_HEIGHT ::                                        */
+  /*    T1_BLEND_STEM_SNAP_WIDTHS ::                                       */
+  /*    T1_BLEND_STEM_SNAP_HEIGHTS ::                                      */
+  /*    T1_BLEND_BLUE_SCALE ::                                             */
+  /*    T1_BLEND_BLUE_SHIFT ::                                             */
+  /*    T1_BLEND_FAMILY_BLUES ::                                           */
+  /*    T1_BLEND_FAMILY_OTHER_BLUES ::                                     */
+  /*    T1_BLEND_FORCE_BOLD ::                                             */
+  /*                                                                       */
   typedef enum  T1_Blend_Flags_
   {
-    /*# required fields in a FontInfo blend dictionary */
+    /* required fields in a FontInfo blend dictionary */
     T1_BLEND_UNDERLINE_POSITION = 0,
     T1_BLEND_UNDERLINE_THICKNESS,
     T1_BLEND_ITALIC_ANGLE,
 
-    /*# required fields in a Private blend dictionary */
+    /* required fields in a Private blend dictionary */
     T1_BLEND_BLUE_VALUES,
     T1_BLEND_OTHER_BLUES,
     T1_BLEND_STANDARD_WIDTH,
@@ -210,15 +246,13 @@ FT_BEGIN_HEADER
     T1_BLEND_FAMILY_OTHER_BLUES,
     T1_BLEND_FORCE_BOLD,
 
-    /*# never remove */
-    T1_BLEND_MAX
+    T1_BLEND_MAX    /* do not remove */
 
   } T1_Blend_Flags;
 
-  /* */
 
-
-  /*# backwards compatible definitions */
+  /* these constants are deprecated; use the corresponding */
+  /* `T1_Blend_Flags' values instead                       */
 #define t1_blend_underline_position   T1_BLEND_UNDERLINE_POSITION
 #define t1_blend_underline_thickness  T1_BLEND_UNDERLINE_THICKNESS
 #define t1_blend_italic_angle         T1_BLEND_ITALIC_ANGLE
@@ -235,6 +269,8 @@ FT_BEGIN_HEADER
 #define t1_blend_force_bold           T1_BLEND_FORCE_BOLD
 #define t1_blend_max                  T1_BLEND_MAX
 
+  /* */
+
 
   /* maximum number of Multiple Masters designs, as defined in the spec */
 #define T1_MAX_MM_DESIGNS     16
@@ -333,10 +369,17 @@ FT_BEGIN_HEADER
   /*                                                                       */
   typedef struct CID_FaceDictRec_*  CID_FaceDict;
 
-  /* */
-
 
-  /* backwards-compatible definition */
+  /*************************************************************************/
+  /*                                                                       */
+  /* <Struct>                                                              */
+  /*    CID_FontDict                                                       */
+  /*                                                                       */
+  /* <Description>                                                         */
+  /*    This type is equivalent to @CID_FaceDictRec.  It is deprecated but */
+  /*    kept to maintain source compatibility between various versions of  */
+  /*    FreeType.                                                          */
+  /*                                                                       */
   typedef CID_FaceDictRec  CID_FontDict;
 
 
@@ -503,6 +546,13 @@ FT_BEGIN_HEADER
   /*    An enumeration describing the `Encoding' entry in a Type 1         */
   /*    dictionary.                                                        */
   /*                                                                       */
+  /* <Values>                                                              */
+  /*    T1_ENCODING_TYPE_NONE ::                                           */
+  /*    T1_ENCODING_TYPE_ARRAY ::                                          */
+  /*    T1_ENCODING_TYPE_STANDARD ::                                       */
+  /*    T1_ENCODING_TYPE_ISOLATIN1 ::                                      */
+  /*    T1_ENCODING_TYPE_EXPERT ::                                         */
+  /*                                                                       */
   typedef enum  T1_EncodingType_
   {
     T1_ENCODING_TYPE_NONE = 0,
@@ -523,6 +573,54 @@ FT_BEGIN_HEADER
   /*    An enumeration used in calls to @FT_Get_PS_Font_Value to identify  */
   /*    the Type~1 dictionary entry to retrieve.                           */
   /*                                                                       */
+  /* <Values>                                                              */
+  /*    PS_DICT_FONT_TYPE ::                                               */
+  /*    PS_DICT_FONT_MATRIX ::                                             */
+  /*    PS_DICT_FONT_BBOX ::                                               */
+  /*    PS_DICT_PAINT_TYPE ::                                              */
+  /*    PS_DICT_FONT_NAME ::                                               */
+  /*    PS_DICT_UNIQUE_ID ::                                               */
+  /*    PS_DICT_NUM_CHAR_STRINGS ::                                        */
+  /*    PS_DICT_CHAR_STRING_KEY ::                                         */
+  /*    PS_DICT_CHAR_STRING ::                                             */
+  /*    PS_DICT_ENCODING_TYPE ::                                           */
+  /*    PS_DICT_ENCODING_ENTRY ::                                          */
+  /*    PS_DICT_NUM_SUBRS ::                                               */
+  /*    PS_DICT_SUBR ::                                                    */
+  /*    PS_DICT_STD_HW ::                                                  */
+  /*    PS_DICT_STD_VW ::                                                  */
+  /*    PS_DICT_NUM_BLUE_VALUES ::                                         */
+  /*    PS_DICT_BLUE_VALUE ::                                              */
+  /*    PS_DICT_BLUE_FUZZ ::                                               */
+  /*    PS_DICT_NUM_OTHER_BLUES ::                                         */
+  /*    PS_DICT_OTHER_BLUE ::                                              */
+  /*    PS_DICT_NUM_FAMILY_BLUES ::                                        */
+  /*    PS_DICT_FAMILY_BLUE ::                                             */
+  /*    PS_DICT_NUM_FAMILY_OTHER_BLUES ::                                  */
+  /*    PS_DICT_FAMILY_OTHER_BLUE ::                                       */
+  /*    PS_DICT_BLUE_SCALE ::                                              */
+  /*    PS_DICT_BLUE_SHIFT ::                                              */
+  /*    PS_DICT_NUM_STEM_SNAP_H ::                                         */
+  /*    PS_DICT_STEM_SNAP_H ::                                             */
+  /*    PS_DICT_NUM_STEM_SNAP_V ::                                         */
+  /*    PS_DICT_STEM_SNAP_V ::                                             */
+  /*    PS_DICT_FORCE_BOLD ::                                              */
+  /*    PS_DICT_RND_STEM_UP ::                                             */
+  /*    PS_DICT_MIN_FEATURE ::                                             */
+  /*    PS_DICT_LEN_IV ::                                                  */
+  /*    PS_DICT_PASSWORD ::                                                */
+  /*    PS_DICT_LANGUAGE_GROUP ::                                          */
+  /*    PS_DICT_VERSION ::                                                 */
+  /*    PS_DICT_NOTICE ::                                                  */
+  /*    PS_DICT_FULL_NAME ::                                               */
+  /*    PS_DICT_FAMILY_NAME ::                                             */
+  /*    PS_DICT_WEIGHT ::                                                  */
+  /*    PS_DICT_IS_FIXED_PITCH ::                                          */
+  /*    PS_DICT_UNDERLINE_POSITION ::                                      */
+  /*    PS_DICT_UNDERLINE_THICKNESS ::                                     */
+  /*    PS_DICT_FS_TYPE ::                                                 */
+  /*    PS_DICT_ITALIC_ANGLE ::                                            */
+  /*                                                                       */
   typedef enum  PS_Dict_Keys_
   {
     /* conventionally in the font dictionary */
index 9711d1d..e65b558 100644 (file)
@@ -4,7 +4,7 @@
 /*                                                                         */
 /*    TrueType name ID definitions (specification only).                   */
 /*                                                                         */
-/*  Copyright 1996-2004, 2006-2008, 2012, 2013 by                          */
+/*  Copyright 1996-2004, 2006-2008, 2012-2014 by                           */
 /*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
 /*                                                                         */
 /*  This file is part of the FreeType project, and may only be used,       */
@@ -470,26 +470,26 @@ FT_BEGIN_HEADER
 #define TT_MS_LANGID_ARABIC_GENERAL                    0x0001
 #define TT_MS_LANGID_ARABIC_SAUDI_ARABIA               0x0401
 #define TT_MS_LANGID_ARABIC_IRAQ                       0x0801
-#define TT_MS_LANGID_ARABIC_EGYPT                      0x0c01
+#define TT_MS_LANGID_ARABIC_EGYPT                      0x0C01
 #define TT_MS_LANGID_ARABIC_LIBYA                      0x1001
 #define TT_MS_LANGID_ARABIC_ALGERIA                    0x1401
 #define TT_MS_LANGID_ARABIC_MOROCCO                    0x1801
-#define TT_MS_LANGID_ARABIC_TUNISIA                    0x1c01
+#define TT_MS_LANGID_ARABIC_TUNISIA                    0x1C01
 #define TT_MS_LANGID_ARABIC_OMAN                       0x2001
 #define TT_MS_LANGID_ARABIC_YEMEN                      0x2401
 #define TT_MS_LANGID_ARABIC_SYRIA                      0x2801
-#define TT_MS_LANGID_ARABIC_JORDAN                     0x2c01
+#define TT_MS_LANGID_ARABIC_JORDAN                     0x2C01
 #define TT_MS_LANGID_ARABIC_LEBANON                    0x3001
 #define TT_MS_LANGID_ARABIC_KUWAIT                     0x3401
 #define TT_MS_LANGID_ARABIC_UAE                        0x3801
-#define TT_MS_LANGID_ARABIC_BAHRAIN                    0x3c01
+#define TT_MS_LANGID_ARABIC_BAHRAIN                    0x3C01
 #define TT_MS_LANGID_ARABIC_QATAR                      0x4001
 #define TT_MS_LANGID_BULGARIAN_BULGARIA                0x0402
 #define TT_MS_LANGID_CATALAN_SPAIN                     0x0403
 #define TT_MS_LANGID_CHINESE_GENERAL                   0x0004
 #define TT_MS_LANGID_CHINESE_TAIWAN                    0x0404
 #define TT_MS_LANGID_CHINESE_PRC                       0x0804
-#define TT_MS_LANGID_CHINESE_HONG_KONG                 0x0c04
+#define TT_MS_LANGID_CHINESE_HONG_KONG                 0x0C04
 #define TT_MS_LANGID_CHINESE_SINGAPORE                 0x1004
 
 #if 1  /* this looks like the correct value */
@@ -507,7 +507,7 @@ FT_BEGIN_HEADER
 #define TT_MS_LANGID_DANISH_DENMARK                    0x0406
 #define TT_MS_LANGID_GERMAN_GERMANY                    0x0407
 #define TT_MS_LANGID_GERMAN_SWITZERLAND                0x0807
-#define TT_MS_LANGID_GERMAN_AUSTRIA                    0x0c07
+#define TT_MS_LANGID_GERMAN_AUSTRIA                    0x0C07
 #define TT_MS_LANGID_GERMAN_LUXEMBOURG                 0x1007
 #define TT_MS_LANGID_GERMAN_LIECHTENSTEI               0x1407
 #define TT_MS_LANGID_GREEK_GREECE                      0x0408
@@ -520,69 +520,69 @@ FT_BEGIN_HEADER
 #define TT_MS_LANGID_ENGLISH_GENERAL                   0x0009
 #define TT_MS_LANGID_ENGLISH_UNITED_STATES             0x0409
 #define TT_MS_LANGID_ENGLISH_UNITED_KINGDOM            0x0809
-#define TT_MS_LANGID_ENGLISH_AUSTRALIA                 0x0c09
+#define TT_MS_LANGID_ENGLISH_AUSTRALIA                 0x0C09
 #define TT_MS_LANGID_ENGLISH_CANADA                    0x1009
 #define TT_MS_LANGID_ENGLISH_NEW_ZEALAND               0x1409
 #define TT_MS_LANGID_ENGLISH_IRELAND                   0x1809
-#define TT_MS_LANGID_ENGLISH_SOUTH_AFRICA              0x1c09
+#define TT_MS_LANGID_ENGLISH_SOUTH_AFRICA              0x1C09
 #define TT_MS_LANGID_ENGLISH_JAMAICA                   0x2009
 #define TT_MS_LANGID_ENGLISH_CARIBBEAN                 0x2409
 #define TT_MS_LANGID_ENGLISH_BELIZE                    0x2809
-#define TT_MS_LANGID_ENGLISH_TRINIDAD                  0x2c09
+#define TT_MS_LANGID_ENGLISH_TRINIDAD                  0x2C09
 #define TT_MS_LANGID_ENGLISH_ZIMBABWE                  0x3009
 #define TT_MS_LANGID_ENGLISH_PHILIPPINES               0x3409
 #define TT_MS_LANGID_ENGLISH_INDONESIA                 0x3809
-#define TT_MS_LANGID_ENGLISH_HONG_KONG                 0x3c09
+#define TT_MS_LANGID_ENGLISH_HONG_KONG                 0x3C09
 #define TT_MS_LANGID_ENGLISH_INDIA                     0x4009
 #define TT_MS_LANGID_ENGLISH_MALAYSIA                  0x4409
 #define TT_MS_LANGID_ENGLISH_SINGAPORE                 0x4809
-#define TT_MS_LANGID_SPANISH_SPAIN_TRADITIONAL_SORT    0x040a
-#define TT_MS_LANGID_SPANISH_MEXICO                    0x080a
-#define TT_MS_LANGID_SPANISH_SPAIN_INTERNATIONAL_SORT  0x0c0a
-#define TT_MS_LANGID_SPANISH_GUATEMALA                 0x100a
-#define TT_MS_LANGID_SPANISH_COSTA_RICA                0x140a
-#define TT_MS_LANGID_SPANISH_PANAMA                    0x180a
-#define TT_MS_LANGID_SPANISH_DOMINICAN_REPUBLIC        0x1c0a
-#define TT_MS_LANGID_SPANISH_VENEZUELA                 0x200a
-#define TT_MS_LANGID_SPANISH_COLOMBIA                  0x240a
-#define TT_MS_LANGID_SPANISH_PERU                      0x280a
-#define TT_MS_LANGID_SPANISH_ARGENTINA                 0x2c0a
-#define TT_MS_LANGID_SPANISH_ECUADOR                   0x300a
-#define TT_MS_LANGID_SPANISH_CHILE                     0x340a
-#define TT_MS_LANGID_SPANISH_URUGUAY                   0x380a
-#define TT_MS_LANGID_SPANISH_PARAGUAY                  0x3c0a
-#define TT_MS_LANGID_SPANISH_BOLIVIA                   0x400a
-#define TT_MS_LANGID_SPANISH_EL_SALVADOR               0x440a
-#define TT_MS_LANGID_SPANISH_HONDURAS                  0x480a
-#define TT_MS_LANGID_SPANISH_NICARAGUA                 0x4c0a
-#define TT_MS_LANGID_SPANISH_PUERTO_RICO               0x500a
-#define TT_MS_LANGID_SPANISH_UNITED_STATES             0x540a
+#define TT_MS_LANGID_SPANISH_SPAIN_TRADITIONAL_SORT    0x040A
+#define TT_MS_LANGID_SPANISH_MEXICO                    0x080A
+#define TT_MS_LANGID_SPANISH_SPAIN_INTERNATIONAL_SORT  0x0C0A
+#define TT_MS_LANGID_SPANISH_GUATEMALA                 0x100A
+#define TT_MS_LANGID_SPANISH_COSTA_RICA                0x140A
+#define TT_MS_LANGID_SPANISH_PANAMA                    0x180A
+#define TT_MS_LANGID_SPANISH_DOMINICAN_REPUBLIC        0x1C0A
+#define TT_MS_LANGID_SPANISH_VENEZUELA                 0x200A
+#define TT_MS_LANGID_SPANISH_COLOMBIA                  0x240A
+#define TT_MS_LANGID_SPANISH_PERU                      0x280A
+#define TT_MS_LANGID_SPANISH_ARGENTINA                 0x2C0A
+#define TT_MS_LANGID_SPANISH_ECUADOR                   0x300A
+#define TT_MS_LANGID_SPANISH_CHILE                     0x340A
+#define TT_MS_LANGID_SPANISH_URUGUAY                   0x380A
+#define TT_MS_LANGID_SPANISH_PARAGUAY                  0x3C0A
+#define TT_MS_LANGID_SPANISH_BOLIVIA                   0x400A
+#define TT_MS_LANGID_SPANISH_EL_SALVADOR               0x440A
+#define TT_MS_LANGID_SPANISH_HONDURAS                  0x480A
+#define TT_MS_LANGID_SPANISH_NICARAGUA                 0x4C0A
+#define TT_MS_LANGID_SPANISH_PUERTO_RICO               0x500A
+#define TT_MS_LANGID_SPANISH_UNITED_STATES             0x540A
   /* The following ID blatantly violate MS specs by using a */
   /* sublanguage > 0x1F.                                    */
-#define TT_MS_LANGID_SPANISH_LATIN_AMERICA             0xE40aU
-#define TT_MS_LANGID_FINNISH_FINLAND                   0x040b
-#define TT_MS_LANGID_FRENCH_FRANCE                     0x040c
-#define TT_MS_LANGID_FRENCH_BELGIUM                    0x080c
-#define TT_MS_LANGID_FRENCH_CANADA                     0x0c0c
-#define TT_MS_LANGID_FRENCH_SWITZERLAND                0x100c
-#define TT_MS_LANGID_FRENCH_LUXEMBOURG                 0x140c
-#define TT_MS_LANGID_FRENCH_MONACO                     0x180c
-#define TT_MS_LANGID_FRENCH_WEST_INDIES                0x1c0c
-#define TT_MS_LANGID_FRENCH_REUNION                    0x200c
-#define TT_MS_LANGID_FRENCH_CONGO                      0x240c
+#define TT_MS_LANGID_SPANISH_LATIN_AMERICA             0xE40AU
+#define TT_MS_LANGID_FINNISH_FINLAND                   0x040B
+#define TT_MS_LANGID_FRENCH_FRANCE                     0x040C
+#define TT_MS_LANGID_FRENCH_BELGIUM                    0x080C
+#define TT_MS_LANGID_FRENCH_CANADA                     0x0C0C
+#define TT_MS_LANGID_FRENCH_SWITZERLAND                0x100C
+#define TT_MS_LANGID_FRENCH_LUXEMBOURG                 0x140C
+#define TT_MS_LANGID_FRENCH_MONACO                     0x180C
+#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
-#define TT_MS_LANGID_FRENCH_SENEGAL                    0x280c
-#define TT_MS_LANGID_FRENCH_CAMEROON                   0x2c0c
-#define TT_MS_LANGID_FRENCH_COTE_D_IVOIRE              0x300c
-#define TT_MS_LANGID_FRENCH_MALI                       0x340c
-#define TT_MS_LANGID_FRENCH_MOROCCO                    0x380c
-#define TT_MS_LANGID_FRENCH_HAITI                      0x3c0c
-  /* and another violation of the spec (see 0xE40aU) */
-#define TT_MS_LANGID_FRENCH_NORTH_AFRICA               0xE40cU
-#define TT_MS_LANGID_HEBREW_ISRAEL                     0x040d
-#define TT_MS_LANGID_HUNGARIAN_HUNGARY                 0x040e
-#define TT_MS_LANGID_ICELANDIC_ICELAND                 0x040f
+#define TT_MS_LANGID_FRENCH_SENEGAL                    0x280C
+#define TT_MS_LANGID_FRENCH_CAMEROON                   0x2C0C
+#define TT_MS_LANGID_FRENCH_COTE_D_IVOIRE              0x300C
+#define TT_MS_LANGID_FRENCH_MALI                       0x340C
+#define TT_MS_LANGID_FRENCH_MOROCCO                    0x380C
+#define TT_MS_LANGID_FRENCH_HAITI                      0x3C0C
+  /* and another violation of the spec (see 0xE40AU) */
+#define TT_MS_LANGID_FRENCH_NORTH_AFRICA               0xE40CU
+#define TT_MS_LANGID_HEBREW_ISRAEL                     0x040D
+#define TT_MS_LANGID_HUNGARIAN_HUNGARY                 0x040E
+#define TT_MS_LANGID_ICELANDIC_ICELAND                 0x040F
 #define TT_MS_LANGID_ITALIAN_ITALY                     0x0410
 #define TT_MS_LANGID_ITALIAN_SWITZERLAND               0x0810
 #define TT_MS_LANGID_JAPANESE_JAPAN                    0x0411
@@ -600,27 +600,27 @@ FT_BEGIN_HEADER
 #define TT_MS_LANGID_MOLDAVIAN_MOLDAVIA                0x0818
 #define TT_MS_LANGID_RUSSIAN_RUSSIA                    0x0419
 #define TT_MS_LANGID_RUSSIAN_MOLDAVIA                  0x0819
-#define TT_MS_LANGID_CROATIAN_CROATIA                  0x041a
-#define TT_MS_LANGID_SERBIAN_SERBIA_LATIN              0x081a
-#define TT_MS_LANGID_SERBIAN_SERBIA_CYRILLIC           0x0c1a
+#define TT_MS_LANGID_CROATIAN_CROATIA                  0x041A
+#define TT_MS_LANGID_SERBIAN_SERBIA_LATIN              0x081A
+#define TT_MS_LANGID_SERBIAN_SERBIA_CYRILLIC           0x0C1A
 
 #if 0  /* this used to be this value, but it looks like we were wrong */
-#define TT_MS_LANGID_BOSNIAN_BOSNIA_HERZEGOVINA        0x101a
+#define TT_MS_LANGID_BOSNIAN_BOSNIA_HERZEGOVINA        0x101A
 #else  /* current sources say */
-#define TT_MS_LANGID_CROATIAN_BOSNIA_HERZEGOVINA       0x101a
-#define TT_MS_LANGID_BOSNIAN_BOSNIA_HERZEGOVINA        0x141a
+#define TT_MS_LANGID_CROATIAN_BOSNIA_HERZEGOVINA       0x101A
+#define TT_MS_LANGID_BOSNIAN_BOSNIA_HERZEGOVINA        0x141A
        /* and XPsp2 Platform SDK added (2004-07-26) */
        /* Names are shortened to be significant within 40 chars. */
-#define TT_MS_LANGID_SERBIAN_BOSNIA_HERZ_LATIN         0x181a
-#define TT_MS_LANGID_SERBIAN_BOSNIA_HERZ_CYRILLIC      0x181a
+#define TT_MS_LANGID_SERBIAN_BOSNIA_HERZ_LATIN         0x181A
+#define TT_MS_LANGID_SERBIAN_BOSNIA_HERZ_CYRILLIC      0x181A
 #endif
 
-#define TT_MS_LANGID_SLOVAK_SLOVAKIA                   0x041b
-#define TT_MS_LANGID_ALBANIAN_ALBANIA                  0x041c
-#define TT_MS_LANGID_SWEDISH_SWEDEN                    0x041d
-#define TT_MS_LANGID_SWEDISH_FINLAND                   0x081d
-#define TT_MS_LANGID_THAI_THAILAND                     0x041e
-#define TT_MS_LANGID_TURKISH_TURKEY                    0x041f
+#define TT_MS_LANGID_SLOVAK_SLOVAKIA                   0x041B
+#define TT_MS_LANGID_ALBANIAN_ALBANIA                  0x041C
+#define TT_MS_LANGID_SWEDISH_SWEDEN                    0x041D
+#define TT_MS_LANGID_SWEDISH_FINLAND                   0x081D
+#define TT_MS_LANGID_THAI_THAILAND                     0x041E
+#define TT_MS_LANGID_TURKISH_TURKEY                    0x041F
 #define TT_MS_LANGID_URDU_PAKISTAN                     0x0420
 #define TT_MS_LANGID_URDU_INDIA                        0x0820
 #define TT_MS_LANGID_INDONESIAN_INDONESIA              0x0421
@@ -633,13 +633,13 @@ FT_BEGIN_HEADER
 #define TT_MS_LANGID_CLASSIC_LITHUANIAN_LITHUANIA      0x0827
 #define TT_MS_LANGID_TAJIK_TAJIKISTAN                  0x0428
 #define TT_MS_LANGID_FARSI_IRAN                        0x0429
-#define TT_MS_LANGID_VIETNAMESE_VIET_NAM               0x042a
-#define TT_MS_LANGID_ARMENIAN_ARMENIA                  0x042b
-#define TT_MS_LANGID_AZERI_AZERBAIJAN_LATIN            0x042c
-#define TT_MS_LANGID_AZERI_AZERBAIJAN_CYRILLIC         0x082c
-#define TT_MS_LANGID_BASQUE_SPAIN                      0x042d
-#define TT_MS_LANGID_SORBIAN_GERMANY                   0x042e
-#define TT_MS_LANGID_MACEDONIAN_MACEDONIA              0x042f
+#define TT_MS_LANGID_VIETNAMESE_VIET_NAM               0x042A
+#define TT_MS_LANGID_ARMENIAN_ARMENIA                  0x042B
+#define TT_MS_LANGID_AZERI_AZERBAIJAN_LATIN            0x042C
+#define TT_MS_LANGID_AZERI_AZERBAIJAN_CYRILLIC         0x082C
+#define TT_MS_LANGID_BASQUE_SPAIN                      0x042D
+#define TT_MS_LANGID_SORBIAN_GERMANY                   0x042E
+#define TT_MS_LANGID_MACEDONIAN_MACEDONIA              0x042F
 #define TT_MS_LANGID_SUTU_SOUTH_AFRICA                 0x0430
 #define TT_MS_LANGID_TSONGA_SOUTH_AFRICA               0x0431
 #define TT_MS_LANGID_TSWANA_SOUTH_AFRICA               0x0432
@@ -650,32 +650,32 @@ FT_BEGIN_HEADER
 #define TT_MS_LANGID_GEORGIAN_GEORGIA                  0x0437
 #define TT_MS_LANGID_FAEROESE_FAEROE_ISLANDS           0x0438
 #define TT_MS_LANGID_HINDI_INDIA                       0x0439
-#define TT_MS_LANGID_MALTESE_MALTA                     0x043a
+#define TT_MS_LANGID_MALTESE_MALTA                     0x043A
   /* Added by XPsp2 Platform SDK (2004-07-26) */
-#define TT_MS_LANGID_SAMI_NORTHERN_NORWAY              0x043b
-#define TT_MS_LANGID_SAMI_NORTHERN_SWEDEN              0x083b
-#define TT_MS_LANGID_SAMI_NORTHERN_FINLAND             0x0C3b
-#define TT_MS_LANGID_SAMI_LULE_NORWAY                  0x103b
-#define TT_MS_LANGID_SAMI_LULE_SWEDEN                  0x143b
-#define TT_MS_LANGID_SAMI_SOUTHERN_NORWAY              0x183b
-#define TT_MS_LANGID_SAMI_SOUTHERN_SWEDEN              0x1C3b
-#define TT_MS_LANGID_SAMI_SKOLT_FINLAND                0x203b
-#define TT_MS_LANGID_SAMI_INARI_FINLAND                0x243b
+#define TT_MS_LANGID_SAMI_NORTHERN_NORWAY              0x043B
+#define TT_MS_LANGID_SAMI_NORTHERN_SWEDEN              0x083B
+#define TT_MS_LANGID_SAMI_NORTHERN_FINLAND             0x0C3B
+#define TT_MS_LANGID_SAMI_LULE_NORWAY                  0x103B
+#define TT_MS_LANGID_SAMI_LULE_SWEDEN                  0x143B
+#define TT_MS_LANGID_SAMI_SOUTHERN_NORWAY              0x183B
+#define TT_MS_LANGID_SAMI_SOUTHERN_SWEDEN              0x1C3B
+#define TT_MS_LANGID_SAMI_SKOLT_FINLAND                0x203B
+#define TT_MS_LANGID_SAMI_INARI_FINLAND                0x243B
   /* ... and we also keep our old identifier... */
-#define TT_MS_LANGID_SAAMI_LAPONIA                     0x043b
+#define TT_MS_LANGID_SAAMI_LAPONIA                     0x043B
 
 #if 0 /* this seems to be a previous inversion */
-#define TT_MS_LANGID_IRISH_GAELIC_IRELAND              0x043c
-#define TT_MS_LANGID_SCOTTISH_GAELIC_UNITED_KINGDOM    0x083c
+#define TT_MS_LANGID_IRISH_GAELIC_IRELAND              0x043C
+#define TT_MS_LANGID_SCOTTISH_GAELIC_UNITED_KINGDOM    0x083C
 #else
-#define TT_MS_LANGID_SCOTTISH_GAELIC_UNITED_KINGDOM    0x083c
-#define TT_MS_LANGID_IRISH_GAELIC_IRELAND              0x043c
+#define TT_MS_LANGID_SCOTTISH_GAELIC_UNITED_KINGDOM    0x083C
+#define TT_MS_LANGID_IRISH_GAELIC_IRELAND              0x043C
 #endif
 
-#define TT_MS_LANGID_YIDDISH_GERMANY                   0x043d
-#define TT_MS_LANGID_MALAY_MALAYSIA                    0x043e
-#define TT_MS_LANGID_MALAY_BRUNEI_DARUSSALAM           0x083e
-#define TT_MS_LANGID_KAZAK_KAZAKSTAN                   0x043f
+#define TT_MS_LANGID_YIDDISH_GERMANY                   0x043D
+#define TT_MS_LANGID_MALAY_MALAYSIA                    0x043E
+#define TT_MS_LANGID_MALAY_BRUNEI_DARUSSALAM           0x083E
+#define TT_MS_LANGID_KAZAK_KAZAKSTAN                   0x043F
 #define TT_MS_LANGID_KIRGHIZ_KIRGHIZSTAN /* Cyrillic*/ 0x0440
   /* alias declared in Windows 2000 */
 #define TT_MS_LANGID_KIRGHIZ_KIRGHIZ_REPUBLIC \
@@ -693,12 +693,12 @@ FT_BEGIN_HEADER
 #define TT_MS_LANGID_GUJARATI_INDIA                    0x0447
 #define TT_MS_LANGID_ORIYA_INDIA                       0x0448
 #define TT_MS_LANGID_TAMIL_INDIA                       0x0449
-#define TT_MS_LANGID_TELUGU_INDIA                      0x044a
-#define TT_MS_LANGID_KANNADA_INDIA                     0x044b
-#define TT_MS_LANGID_MALAYALAM_INDIA                   0x044c
-#define TT_MS_LANGID_ASSAMESE_INDIA                    0x044d
-#define TT_MS_LANGID_MARATHI_INDIA                     0x044e
-#define TT_MS_LANGID_SANSKRIT_INDIA                    0x044f
+#define TT_MS_LANGID_TELUGU_INDIA                      0x044A
+#define TT_MS_LANGID_KANNADA_INDIA                     0x044B
+#define TT_MS_LANGID_MALAYALAM_INDIA                   0x044C
+#define TT_MS_LANGID_ASSAMESE_INDIA                    0x044D
+#define TT_MS_LANGID_MARATHI_INDIA                     0x044E
+#define TT_MS_LANGID_SANSKRIT_INDIA                    0x044F
 #define TT_MS_LANGID_MONGOLIAN_MONGOLIA /* Cyrillic */ 0x0450
 #define TT_MS_LANGID_MONGOLIAN_MONGOLIA_MONGOLIAN      0x0850
 #define TT_MS_LANGID_TIBETAN_CHINA                     0x0451
@@ -732,13 +732,13 @@ FT_BEGIN_HEADER
 #define TT_MS_LANGID_SINDHI_INDIA /* Arabic */         0x0459
 #define TT_MS_LANGID_SINDHI_PAKISTAN                   0x0859
   /* Missing a LCID for Sindhi in Devanagari script */
-#define TT_MS_LANGID_SYRIAC_SYRIA                      0x045a
-#define TT_MS_LANGID_SINHALESE_SRI_LANKA               0x045b
-#define TT_MS_LANGID_CHEROKEE_UNITED_STATES            0x045c
-#define TT_MS_LANGID_INUKTITUT_CANADA                  0x045d
-#define TT_MS_LANGID_AMHARIC_ETHIOPIA                  0x045e
-#define TT_MS_LANGID_TAMAZIGHT_MOROCCO /* Arabic */    0x045f
-#define TT_MS_LANGID_TAMAZIGHT_MOROCCO_LATIN           0x085f
+#define TT_MS_LANGID_SYRIAC_SYRIA                      0x045A
+#define TT_MS_LANGID_SINHALESE_SRI_LANKA               0x045B
+#define TT_MS_LANGID_CHEROKEE_UNITED_STATES            0x045C
+#define TT_MS_LANGID_INUKTITUT_CANADA                  0x045D
+#define TT_MS_LANGID_AMHARIC_ETHIOPIA                  0x045E
+#define TT_MS_LANGID_TAMAZIGHT_MOROCCO /* Arabic */    0x045F
+#define TT_MS_LANGID_TAMAZIGHT_MOROCCO_LATIN           0x085F
   /* Missing a LCID for Tifinagh script */
 #define TT_MS_LANGID_KASHMIRI_PAKISTAN /* Arabic */    0x0460
   /* Spelled this way by XPsp2 Platform SDK (2004-07-26) */
@@ -758,15 +758,15 @@ FT_BEGIN_HEADER
 #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
-#define TT_MS_LANGID_QUECHUA_BOLIVIA                   0x046b
-#define TT_MS_LANGID_QUECHUA_ECUADOR                   0x086b
-#define TT_MS_LANGID_QUECHUA_PERU                      0x0c6b
-#define TT_MS_LANGID_SEPEDI_SOUTH_AFRICA               0x046c
+#define TT_MS_LANGID_YORUBA_NIGERIA                    0x046A
+#define TT_MS_LANGID_QUECHUA_BOLIVIA                   0x046B
+#define TT_MS_LANGID_QUECHUA_ECUADOR                   0x086B
+#define TT_MS_LANGID_QUECHUA_PERU                      0x0C6B
+#define TT_MS_LANGID_SEPEDI_SOUTH_AFRICA               0x046C
   /* Also spelled by XPsp2 Platform SDK (2004-07-26) */
 #define TT_MS_LANGID_SOTHO_SOUTHERN_SOUTH_AFRICA \
           TT_MS_LANGID_SEPEDI_SOUTH_AFRICA
-  /* language codes 0x046d, 0x046e and 0x046f are (still) unknown. */
+  /* language codes 0x046D, 0x046E and 0x046F are (still) unknown. */
 #define TT_MS_LANGID_IGBO_NIGERIA                      0x0470
 #define TT_MS_LANGID_KANURI_NIGERIA                    0x0471
 #define TT_MS_LANGID_OROMO_ETHIOPIA                    0x0472
@@ -783,12 +783,12 @@ FT_BEGIN_HEADER
   /*       studying).                                                     */
 #define TT_MS_LANGID_YI_CHINA                          0x0478
 #define TT_MS_LANGID_PAPIAMENTU_NETHERLANDS_ANTILLES   0x0479
-  /* language codes from 0x047a to 0x047f are (still) unknown. */
+  /* language codes from 0x047A to 0x047F are (still) unknown. */
 #define TT_MS_LANGID_UIGHUR_CHINA                      0x0480
 #define TT_MS_LANGID_MAORI_NEW_ZEALAND                 0x0481
 
 #if 0  /* not deemed useful for fonts */
-#define TT_MS_LANGID_HUMAN_INTERFACE_DEVICE            0x04ff
+#define TT_MS_LANGID_HUMAN_INTERFACE_DEVICE            0x04FF
 #endif
 
 
index bb49dc0..e1d8b05 100644 (file)
@@ -5,7 +5,7 @@
 /*    Basic SFNT/TrueType tables definitions and interface                 */
 /*    (specification only).                                                */
 /*                                                                         */
-/*  Copyright 1996-2005, 2008-2013 by                                      */
+/*  Copyright 1996-2005, 2008-2014 by                                      */
 /*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
 /*                                                                         */
 /*  This file is part of the FreeType project, and may only be used,       */
@@ -48,6 +48,25 @@ FT_BEGIN_HEADER
   /*    This section contains the definition of TrueType-specific tables   */
   /*    as well as some routines used to access and process them.          */
   /*                                                                       */
+  /* <Order>                                                               */
+  /*    TT_Header                                                          */
+  /*    TT_HoriHeader                                                      */
+  /*    TT_VertHeader                                                      */
+  /*    TT_OS2                                                             */
+  /*    TT_Postscript                                                      */
+  /*    TT_PCLT                                                            */
+  /*    TT_MaxProfile                                                      */
+  /*                                                                       */
+  /*    FT_Sfnt_Tag                                                        */
+  /*    FT_Get_Sfnt_Table                                                  */
+  /*    FT_Load_Sfnt_Table                                                 */
+  /*    FT_Sfnt_Table_Info                                                 */
+  /*                                                                       */
+  /*    FT_Get_CMap_Language_ID                                            */
+  /*    FT_Get_CMap_Format                                                 */
+  /*                                                                       */
+  /*    FT_PARAM_TAG_UNPATENTED_HINTING                                    */
+  /*                                                                       */
   /*************************************************************************/
 
 
@@ -559,21 +578,44 @@ FT_BEGIN_HEADER
   /*    An enumeration used to specify the index of an SFNT table.         */
   /*    Used in the @FT_Get_Sfnt_Table API function.                       */
   /*                                                                       */
+  /* <Values>                                                              */
+  /*    FT_SFNT_HEAD :: To access the font's @TT_Header structure.         */
+  /*                                                                       */
+  /*    FT_SFNT_MAXP :: To access the font's @TT_MaxProfile structure.     */
+  /*                                                                       */
+  /*    FT_SFNT_OS2  :: To access the font's @TT_OS2 structure.            */
+  /*                                                                       */
+  /*    FT_SFNT_HHEA :: To access the font's @TT_HoriHeader structure.     */
+  /*                                                                       */
+  /*    FT_SFNT_VHEA :: To access the font's @TT_VertHeader struture.      */
+  /*                                                                       */
+  /*    FT_SFNT_POST :: To access the font's @TT_Postscript structure.     */
+  /*                                                                       */
+  /*    FT_SFNT_PCLT :: To access the font's @TT_PCLT structure.           */
+  /*                                                                       */
   typedef enum  FT_Sfnt_Tag_
   {
-    ft_sfnt_head = 0,    /* TT_Header     */
-    ft_sfnt_maxp = 1,    /* TT_MaxProfile */
-    ft_sfnt_os2  = 2,    /* TT_OS2        */
-    ft_sfnt_hhea = 3,    /* TT_HoriHeader */
-    ft_sfnt_vhea = 4,    /* TT_VertHeader */
-    ft_sfnt_post = 5,    /* TT_Postscript */
-    ft_sfnt_pclt = 6,    /* TT_PCLT       */
+    FT_SFNT_HEAD,
+    FT_SFNT_MAXP,
+    FT_SFNT_OS2,
+    FT_SFNT_HHEA,
+    FT_SFNT_VHEA,
+    FT_SFNT_POST,
+    FT_SFNT_PCLT,
 
-    sfnt_max   /* internal end mark */
+    FT_SFNT_MAX
 
   } FT_Sfnt_Tag;
 
-  /* */
+  /* these constants are deprecated; use the corresponding `FT_Sfnt_Tag' */
+  /* values instead                                                      */
+#define ft_sfnt_head  FT_SFNT_HEAD
+#define ft_sfnt_maxp  FT_SFNT_MAXP
+#define ft_sfnt_os2   FT_SFNT_OS2
+#define ft_sfnt_hhea  FT_SFNT_HHEA
+#define ft_sfnt_vhea  FT_SFNT_VHEA
+#define ft_sfnt_post  FT_SFNT_POST
+#define ft_sfnt_pclt  FT_SFNT_PCLT
 
 
   /*************************************************************************/
@@ -611,7 +653,7 @@ FT_BEGIN_HEADER
   /*                                                                       */
   /*                                                                       */
   /*      vert_header =                                                    */
-  /*        (TT_VertHeader*)FT_Get_Sfnt_Table( face, ft_sfnt_vhea );       */
+  /*        (TT_VertHeader*)FT_Get_Sfnt_Table( face, FT_SFNT_VHEA );       */
   /*    }                                                                  */
   /*                                                                       */
   FT_EXPORT( void* )
index a016275..bf53ddd 100644 (file)
@@ -48,7 +48,8 @@ FT_BEGIN_HEADER
   */
 #define FT_PARAM_TAG_UNPATENTED_HINTING  FT_MAKE_TAG( 'u', 'n', 'p', 'a' )
 
- /* */
+  /* */
+
 
 FT_END_HEADER
 
index b44a5ba..f8b095b 100644 (file)
 #include "aftypes.h"
 
 
-#if 0
-
-  FT_LOCAL_DEF( FT_Int )
-  af_corner_is_flat( FT_Pos  x_in,
-                     FT_Pos  y_in,
-                     FT_Pos  x_out,
-                     FT_Pos  y_out )
-  {
-    FT_Pos  ax = x_in;
-    FT_Pos  ay = y_in;
-
-    FT_Pos  d_in, d_out, d_corner;
-
-
-    if ( ax < 0 )
-      ax = -ax;
-    if ( ay < 0 )
-      ay = -ay;
-    d_in = ax + ay;
-
-    ax = x_out;
-    if ( ax < 0 )
-      ax = -ax;
-    ay = y_out;
-    if ( ay < 0 )
-      ay = -ay;
-    d_out = ax + ay;
-
-    ax = x_out + x_in;
-    if ( ax < 0 )
-      ax = -ax;
-    ay = y_out + y_in;
-    if ( ay < 0 )
-      ay = -ay;
-    d_corner = ax + ay;
-
-    return ( d_in + d_out - d_corner ) < ( d_corner >> 4 );
-  }
-
-
-  FT_LOCAL_DEF( FT_Int )
-  af_corner_orientation( FT_Pos  x_in,
-                         FT_Pos  y_in,
-                         FT_Pos  x_out,
-                         FT_Pos  y_out )
-  {
-    FT_Pos  delta;
-
-
-    delta = x_in * y_out - y_in * x_out;
-
-    if ( delta == 0 )
-      return 0;
-    else
-      return 1 - 2 * ( delta < 0 );
-  }
-
-#endif /* 0 */
-
-
   /*
    *  We are not using `af_angle_atan' anymore, but we keep the source
    *  code below just in case...
index 6e214c8..811226e 100644 (file)
   af_blue_strings[] =
   {
     /* */
-    'T', 'H', 'E', 'Z', 'O', 'C', 'Q', 'S',  /* THEZOCQS */
+    '\xD0', '\x91', '\xD0', '\x92', '\xD0', '\x95', '\xD0', '\x9F', '\xD0', '\x97', '\xD0', '\x9E', '\xD0', '\xA1', '\xD0', '\xAD',  /* БВЕПЗОСЭ */
     '\0',
-    'H', 'E', 'Z', 'L', 'O', 'C', 'U', 'S',  /* HEZLOCUS */
+    '\xD0', '\x91', '\xD0', '\x92', '\xD0', '\x95', '\xD0', '\xA8', '\xD0', '\x97', '\xD0', '\x9E', '\xD0', '\xA1', '\xD0', '\xAD',  /* БВЕШЗОСЭ */
     '\0',
-    'f', 'i', 'j', 'k', 'd', 'b', 'h',  /* fijkdbh */
+    '\xD1', '\x85', '\xD0', '\xBF', '\xD0', '\xBD', '\xD1', '\x88', '\xD0', '\xB5', '\xD0', '\xB7', '\xD0', '\xBE', '\xD1', '\x81',  /* хпншезос */
     '\0',
-    'x', 'z', 'r', 'o', 'e', 's', 'c',  /* xzroesc */
+    '\xD1', '\x80', '\xD1', '\x83', '\xD1', '\x84',  /* руф */
     '\0',
-    'p', 'q', 'g', 'j', 'y',  /* pqgjy */
+    '\xE0', '\xA4', '\x95', '\xE0', '\xA4', '\xAE', '\xE0', '\xA4', '\x85', '\xE0', '\xA4', '\x86', '\xE0', '\xA4', '\xA5', '\xE0', '\xA4', '\xA7', '\xE0', '\xA4', '\xAD', '\xE0', '\xA4', '\xB6',  /* क म अ आ थ ध भ श */
+    '\0',
+    '\xE0', '\xA4', '\x88', '\xE0', '\xA4', '\x90', '\xE0', '\xA4', '\x93', '\xE0', '\xA4', '\x94', '\xE0', '\xA4', '\xBF', '\xE0', '\xA5', '\x80', '\xE0', '\xA5', '\x8B', '\xE0', '\xA5', '\x8C',  /* ई ऐ ओ औ ि ी ो ौ */
+    '\0',
+    '\xE0', '\xA4', '\x95', '\xE0', '\xA4', '\xAE', '\xE0', '\xA4', '\x85', '\xE0', '\xA4', '\x86', '\xE0', '\xA4', '\xA5', '\xE0', '\xA4', '\xA7', '\xE0', '\xA4', '\xAD', '\xE0', '\xA4', '\xB6',  /* क म अ आ थ ध भ श */
+    '\0',
+    '\xE0', '\xA5', '\x81', '\xE0', '\xA5', '\x83',  /* ु ृ */
     '\0',
     '\xCE', '\x93', '\xCE', '\x92', '\xCE', '\x95', '\xCE', '\x96', '\xCE', '\x98', '\xCE', '\x9F', '\xCE', '\xA9',  /* ΓΒΕΖΘΟΩ */
     '\0',
     '\0',
     '\xCE', '\xB2', '\xCE', '\xB3', '\xCE', '\xB7', '\xCE', '\xBC', '\xCF', '\x81', '\xCF', '\x86', '\xCF', '\x87', '\xCF', '\x88',  /* βγημρφχψ */
     '\0',
-    '\xD0', '\x91', '\xD0', '\x92', '\xD0', '\x95', '\xD0', '\x9F', '\xD0', '\x97', '\xD0', '\x9E', '\xD0', '\xA1', '\xD0', '\xAD',  /* БВЕПЗОСЭ */
+    '\xD7', '\x91', '\xD7', '\x93', '\xD7', '\x94', '\xD7', '\x97', '\xD7', '\x9A', '\xD7', '\x9B', '\xD7', '\x9D', '\xD7', '\xA1',  /* בדהחךכםס */
     '\0',
-    '\xD0', '\x91', '\xD0', '\x92', '\xD0', '\x95', '\xD0', '\xA8', '\xD0', '\x97', '\xD0', '\x9E', '\xD0', '\xA1', '\xD0', '\xAD',  /* БВЕШЗОСЭ */
+    '\xD7', '\x91', '\xD7', '\x98', '\xD7', '\x9B', '\xD7', '\x9D', '\xD7', '\xA1', '\xD7', '\xA6',  /* בטכםסצ */
     '\0',
-    '\xD1', '\x85', '\xD0', '\xBF', '\xD0', '\xBD', '\xD1', '\x88', '\xD0', '\xB5', '\xD0', '\xB7', '\xD0', '\xBE', '\xD1', '\x81',  /* хпншезос */
+    '\xD7', '\xA7', '\xD7', '\x9A', '\xD7', '\x9F', '\xD7', '\xA3', '\xD7', '\xA5',  /* קךןףץ */
     '\0',
-    '\xD1', '\x80', '\xD1', '\x83', '\xD1', '\x84',  /* руф */
+    'T', 'H', 'E', 'Z', 'O', 'C', 'Q', 'S',  /* THEZOCQS */
     '\0',
-    '\xD7', '\x91', '\xD7', '\x93', '\xD7', '\x94', '\xD7', '\x97', '\xD7', '\x9A', '\xD7', '\x9B', '\xD7', '\x9D', '\xD7', '\xA1',  /* בדהחךכםס */
+    'H', 'E', 'Z', 'L', 'O', 'C', 'U', 'S',  /* HEZLOCUS */
     '\0',
-    '\xD7', '\x91', '\xD7', '\x98', '\xD7', '\x9B', '\xD7', '\x9D', '\xD7', '\xA1', '\xD7', '\xA6',  /* בטכםסצ */
+    'f', 'i', 'j', 'k', 'd', 'b', 'h',  /* fijkdbh */
     '\0',
-    '\xD7', '\xA7', '\xD7', '\x9A', '\xD7', '\x9F', '\xD7', '\xA3', '\xD7', '\xA5',  /* קךןףץ */
+    'x', 'z', 'r', 'o', 'e', 's', 'c',  /* xzroesc */
+    '\0',
+    'p', 'q', 'g', 'j', 'y',  /* pqgjy */
+    '\0',
+    '\xE0', '\xB0', '\x87', '\xE0', '\xB0', '\x8C', '\xE0', '\xB0', '\x99', '\xE0', '\xB0', '\x9E', '\xE0', '\xB0', '\xA3', '\xE0', '\xB0', '\xB1', '\xE0', '\xB1', '\xAF',  /* ఇ ఌ ఙ ఞ ణ ఱ ౯ */
+    '\0',
+    '\xE0', '\xB0', '\x85', '\xE0', '\xB0', '\x95', '\xE0', '\xB0', '\x9A', '\xE0', '\xB0', '\xB0', '\xE0', '\xB0', '\xBD', '\xE0', '\xB1', '\xA8', '\xE0', '\xB1', '\xAC',  /* అ క చ ర ఽ ౨ ౬ */
 #ifdef AF_CONFIG_OPTION_CJK
     '\0',
     '\xE4', '\xBB', '\x96', '\xE4', '\xBB', '\xAC', '\xE4', '\xBD', '\xA0', '\xE4', '\xBE', '\x86', '\xE5', '\x80', '\x91', '\xE5', '\x88', '\xB0', '\xE5', '\x92', '\x8C', '\xE5', '\x9C', '\xB0',  /* 他们你來們到和地 */
     '\xE5', '\xAF', '\xB9', '\xE5', '\xB0', '\x8D', '\xE5', '\xB0', '\xB1', '\xE5', '\xB8', '\xAD', '\xE6', '\x88', '\x91', '\xE6', '\x97', '\xB6', '\xE6', '\x99', '\x82', '\xE6', '\x9C', '\x83',  /* 对對就席我时時會 */
     '\xE6', '\x9D', '\xA5', '\xE7', '\x82', '\xBA', '\xE8', '\x83', '\xBD', '\xE8', '\x88', '\xB0', '\xE8', '\xAA', '\xAA', '\xE8', '\xAF', '\xB4', '\xE8', '\xBF', '\x99', '\xE9', '\x80', '\x99',  /* 来為能舰說说这這 */
-    '\xE9', '\xBD', '\x8A',  /* 齊 */
-    '\0',
+    '\xE9', '\xBD', '\x8A', '|',  /* 齊 | */
     '\xE5', '\x86', '\x9B', '\xE5', '\x90', '\x8C', '\xE5', '\xB7', '\xB2', '\xE6', '\x84', '\xBF', '\xE6', '\x97', '\xA2', '\xE6', '\x98', '\x9F', '\xE6', '\x98', '\xAF', '\xE6', '\x99', '\xAF',  /* 军同已愿既星是景 */
     '\xE6', '\xB0', '\x91', '\xE7', '\x85', '\xA7', '\xE7', '\x8E', '\xB0', '\xE7', '\x8F', '\xBE', '\xE7', '\x90', '\x86', '\xE7', '\x94', '\xA8', '\xE7', '\xBD', '\xAE', '\xE8', '\xA6', '\x81',  /* 民照现現理用置要 */
     '\xE8', '\xBB', '\x8D', '\xE9', '\x82', '\xA3', '\xE9', '\x85', '\x8D', '\xE9', '\x87', '\x8C', '\xE9', '\x96', '\x8B', '\xE9', '\x9B', '\xB7', '\xE9', '\x9C', '\xB2', '\xE9', '\x9D', '\xA2',  /* 軍那配里開雷露面 */
@@ -74,8 +85,7 @@
     '\xE4', '\xB8', '\xAA', '\xE4', '\xB8', '\xBA', '\xE4', '\xBA', '\xBA', '\xE4', '\xBB', '\x96', '\xE4', '\xBB', '\xA5', '\xE4', '\xBB', '\xAC', '\xE4', '\xBD', '\xA0', '\xE4', '\xBE', '\x86',  /* 个为人他以们你來 */
     '\xE5', '\x80', '\x8B', '\xE5', '\x80', '\x91', '\xE5', '\x88', '\xB0', '\xE5', '\x92', '\x8C', '\xE5', '\xA4', '\xA7', '\xE5', '\xAF', '\xB9', '\xE5', '\xB0', '\x8D', '\xE5', '\xB0', '\xB1',  /* 個們到和大对對就 */
     '\xE6', '\x88', '\x91', '\xE6', '\x97', '\xB6', '\xE6', '\x99', '\x82', '\xE6', '\x9C', '\x89', '\xE6', '\x9D', '\xA5', '\xE7', '\x82', '\xBA', '\xE8', '\xA6', '\x81', '\xE8', '\xAA', '\xAA',  /* 我时時有来為要說 */
-    '\xE8', '\xAF', '\xB4',  /* 说 */
-    '\0',
+    '\xE8', '\xAF', '\xB4', '|',  /* 说 | */
     '\xE4', '\xB8', '\xBB', '\xE4', '\xBA', '\x9B', '\xE5', '\x9B', '\xA0', '\xE5', '\xAE', '\x83', '\xE6', '\x83', '\xB3', '\xE6', '\x84', '\x8F', '\xE7', '\x90', '\x86', '\xE7', '\x94', '\x9F',  /* 主些因它想意理生 */
     '\xE7', '\x95', '\xB6', '\xE7', '\x9C', '\x8B', '\xE7', '\x9D', '\x80', '\xE7', '\xBD', '\xAE', '\xE8', '\x80', '\x85', '\xE8', '\x87', '\xAA', '\xE8', '\x91', '\x97', '\xE8', '\xA3', '\xA1',  /* 當看着置者自著裡 */
     '\xE8', '\xBF', '\x87', '\xE8', '\xBF', '\x98', '\xE8', '\xBF', '\x9B', '\xE9', '\x80', '\xB2', '\xE9', '\x81', '\x8E', '\xE9', '\x81', '\x93', '\xE9', '\x82', '\x84', '\xE9', '\x87', '\x8C',  /* 过还进進過道還里 */
@@ -85,8 +95,7 @@
     '\xE4', '\xBA', '\x9B', '\xE4', '\xBB', '\xAC', '\xE4', '\xBD', '\xA0', '\xE4', '\xBE', '\x86', '\xE5', '\x80', '\x91', '\xE5', '\x88', '\xB0', '\xE5', '\x92', '\x8C', '\xE5', '\x9C', '\xB0',  /* 些们你來們到和地 */
     '\xE5', '\xA5', '\xB9', '\xE5', '\xB0', '\x86', '\xE5', '\xB0', '\x87', '\xE5', '\xB0', '\xB1', '\xE5', '\xB9', '\xB4', '\xE5', '\xBE', '\x97', '\xE6', '\x83', '\x85', '\xE6', '\x9C', '\x80',  /* 她将將就年得情最 */
     '\xE6', '\xA0', '\xB7', '\xE6', '\xA8', '\xA3', '\xE7', '\x90', '\x86', '\xE8', '\x83', '\xBD', '\xE8', '\xAA', '\xAA', '\xE8', '\xAF', '\xB4', '\xE8', '\xBF', '\x99', '\xE9', '\x80', '\x99',  /* 样樣理能說说这這 */
-    '\xE9', '\x80', '\x9A',  /* 通 */
-    '\0',
+    '\xE9', '\x80', '\x9A', '|',  /* 通 | */
     '\xE5', '\x8D', '\xB3', '\xE5', '\x90', '\x97', '\xE5', '\x90', '\xA7', '\xE5', '\x90', '\xAC', '\xE5', '\x91', '\xA2', '\xE5', '\x93', '\x81', '\xE5', '\x93', '\x8D', '\xE5', '\x97', '\x8E',  /* 即吗吧听呢品响嗎 */
     '\xE5', '\xB8', '\x88', '\xE5', '\xB8', '\xAB', '\xE6', '\x94', '\xB6', '\xE6', '\x96', '\xAD', '\xE6', '\x96', '\xB7', '\xE6', '\x98', '\x8E', '\xE7', '\x9C', '\xBC', '\xE9', '\x96', '\x93',  /* 师師收断斷明眼間 */
     '\xE9', '\x97', '\xB4', '\xE9', '\x99', '\x85', '\xE9', '\x99', '\x88', '\xE9', '\x99', '\x90', '\xE9', '\x99', '\xA4', '\xE9', '\x99', '\xB3', '\xE9', '\x9A', '\x8F', '\xE9', '\x9A', '\x9B',  /* 间际陈限除陳随際 */
     '\xE4', '\xBA', '\x8B', '\xE5', '\x89', '\x8D', '\xE5', '\xAD', '\xB8', '\xE5', '\xB0', '\x86', '\xE5', '\xB0', '\x87', '\xE6', '\x83', '\x85', '\xE6', '\x83', '\xB3', '\xE6', '\x88', '\x96',  /* 事前學将將情想或 */
     '\xE6', '\x94', '\xBF', '\xE6', '\x96', '\xAF', '\xE6', '\x96', '\xB0', '\xE6', '\xA0', '\xB7', '\xE6', '\xA8', '\xA3', '\xE6', '\xB0', '\x91', '\xE6', '\xB2', '\x92', '\xE6', '\xB2', '\xA1',  /* 政斯新样樣民沒没 */
     '\xE7', '\x84', '\xB6', '\xE7', '\x89', '\xB9', '\xE7', '\x8E', '\xB0', '\xE7', '\x8F', '\xBE', '\xE7', '\x90', '\x83', '\xE7', '\xAC', '\xAC', '\xE7', '\xB6', '\x93', '\xE8', '\xB0', '\x81',  /* 然特现現球第經谁 */
-    '\xE8', '\xB5', '\xB7',  /* 起 */
-    '\0',
+    '\xE8', '\xB5', '\xB7', '|',  /* 起 | */
     '\xE4', '\xBE', '\x8B', '\xE5', '\x88', '\xA5', '\xE5', '\x88', '\xAB', '\xE5', '\x88', '\xB6', '\xE5', '\x8A', '\xA8', '\xE5', '\x8B', '\x95', '\xE5', '\x90', '\x97', '\xE5', '\x97', '\x8E',  /* 例別别制动動吗嗎 */
     '\xE5', '\xA2', '\x9E', '\xE6', '\x8C', '\x87', '\xE6', '\x98', '\x8E', '\xE6', '\x9C', '\x9D', '\xE6', '\x9C', '\x9F', '\xE6', '\x9E', '\x84', '\xE7', '\x89', '\xA9', '\xE7', '\xA1', '\xAE',  /* 增指明朝期构物确 */
     '\xE7', '\xA7', '\x8D', '\xE8', '\xAA', '\xBF', '\xE8', '\xB0', '\x83', '\xE8', '\xB2', '\xBB', '\xE8', '\xB4', '\xB9', '\xE9', '\x82', '\xA3', '\xE9', '\x83', '\xBD', '\xE9', '\x96', '\x93',  /* 种調调費费那都間 */
   af_blue_stringsets[] =
   {
     /* */
-    { AF_BLUE_STRING_LATIN_CAPITAL_TOP,     AF_BLUE_PROPERTY_LATIN_TOP        },
-    { AF_BLUE_STRING_LATIN_CAPITAL_BOTTOM,  0                                 },
-    { AF_BLUE_STRING_LATIN_SMALL_F_TOP,     AF_BLUE_PROPERTY_LATIN_TOP        },
-    { AF_BLUE_STRING_LATIN_SMALL,           AF_BLUE_PROPERTY_LATIN_TOP      |
-                                            AF_BLUE_PROPERTY_LATIN_X_HEIGHT   },
-    { AF_BLUE_STRING_LATIN_SMALL,           0                                 },
-    { AF_BLUE_STRING_LATIN_SMALL_DESCENDER, 0                                 },
-    { AF_BLUE_STRING_MAX,                   0                                 },
+    { AF_BLUE_STRING_CYRILLIC_CAPITAL_TOP,     AF_BLUE_PROPERTY_LATIN_TOP        },
+    { AF_BLUE_STRING_CYRILLIC_CAPITAL_BOTTOM,  0                                 },
+    { AF_BLUE_STRING_CYRILLIC_SMALL,           AF_BLUE_PROPERTY_LATIN_TOP      |
+                                               AF_BLUE_PROPERTY_LATIN_X_HEIGHT   },
+    { AF_BLUE_STRING_CYRILLIC_SMALL,           0                                 },
+    { AF_BLUE_STRING_CYRILLIC_SMALL_DESCENDER, 0                                 },
+    { AF_BLUE_STRING_MAX,                      0                                 },
+    { AF_BLUE_STRING_DEVANAGARI_TOP,    AF_BLUE_PROPERTY_LATIN_TOP        },
+    { AF_BLUE_STRING_DEVANAGARI_HEAD,   AF_BLUE_PROPERTY_LATIN_TOP        },
+    { AF_BLUE_STRING_DEVANAGARI_BASE,   AF_BLUE_PROPERTY_LATIN_TOP      |
+                                        AF_BLUE_PROPERTY_LATIN_NEUTRAL  |
+                                        AF_BLUE_PROPERTY_LATIN_X_HEIGHT   },
+    { AF_BLUE_STRING_DEVANAGARI_BASE,   0                                 },
+    { AF_BLUE_STRING_DEVANAGARI_BOTTOM, 0                                 },
+    { AF_BLUE_STRING_MAX,               0                                 },
     { AF_BLUE_STRING_GREEK_CAPITAL_TOP,     AF_BLUE_PROPERTY_LATIN_TOP        },
     { AF_BLUE_STRING_GREEK_CAPITAL_BOTTOM,  0                                 },
     { AF_BLUE_STRING_GREEK_SMALL_BETA_TOP,  AF_BLUE_PROPERTY_LATIN_TOP        },
     { AF_BLUE_STRING_GREEK_SMALL,           0                                 },
     { AF_BLUE_STRING_GREEK_SMALL_DESCENDER, 0                                 },
     { AF_BLUE_STRING_MAX,                   0                                 },
-    { AF_BLUE_STRING_CYRILLIC_CAPITAL_TOP,     AF_BLUE_PROPERTY_LATIN_TOP        },
-    { AF_BLUE_STRING_CYRILLIC_CAPITAL_BOTTOM,  0                                 },
-    { AF_BLUE_STRING_CYRILLIC_SMALL,           AF_BLUE_PROPERTY_LATIN_TOP      |
-                                               AF_BLUE_PROPERTY_LATIN_X_HEIGHT   },
-    { AF_BLUE_STRING_CYRILLIC_SMALL,           0                                 },
-    { AF_BLUE_STRING_CYRILLIC_SMALL_DESCENDER, 0                                 },
-    { AF_BLUE_STRING_MAX,                      0                                 },
     { AF_BLUE_STRING_HEBREW_TOP,       AF_BLUE_PROPERTY_LATIN_TOP  |
                                        AF_BLUE_PROPERTY_LATIN_LONG   },
     { AF_BLUE_STRING_HEBREW_BOTTOM,    0                             },
     { AF_BLUE_STRING_HEBREW_DESCENDER, 0                             },
     { AF_BLUE_STRING_MAX,              0                             },
+    { AF_BLUE_STRING_LATIN_CAPITAL_TOP,     AF_BLUE_PROPERTY_LATIN_TOP        },
+    { AF_BLUE_STRING_LATIN_CAPITAL_BOTTOM,  0                                 },
+    { AF_BLUE_STRING_LATIN_SMALL_F_TOP,     AF_BLUE_PROPERTY_LATIN_TOP        },
+    { AF_BLUE_STRING_LATIN_SMALL,           AF_BLUE_PROPERTY_LATIN_TOP      |
+                                            AF_BLUE_PROPERTY_LATIN_X_HEIGHT   },
+    { AF_BLUE_STRING_LATIN_SMALL,           0                                 },
+    { AF_BLUE_STRING_LATIN_SMALL_DESCENDER, 0                                 },
+    { AF_BLUE_STRING_MAX,                   0                                 },
+    { AF_BLUE_STRING_TELUGU_TOP,    AF_BLUE_PROPERTY_LATIN_TOP },
+    { AF_BLUE_STRING_TELUGU_BOTTOM, 0                          },
+    { AF_BLUE_STRING_MAX,           0                          },
 #ifdef AF_CONFIG_OPTION_CJK
-    { AF_BLUE_STRING_CJK_TOP_FILL,      AF_BLUE_PROPERTY_CJK_TOP |
-                                        AF_BLUE_PROPERTY_CJK_FILL    },
-    { AF_BLUE_STRING_CJK_TOP_UNFILL,    AF_BLUE_PROPERTY_CJK_TOP     },
-    { AF_BLUE_STRING_CJK_BOTTOM_FILL,   AF_BLUE_PROPERTY_CJK_FILL    },
-    { AF_BLUE_STRING_CJK_BOTTOM_UNFILL, 0                            },
+    { AF_BLUE_STRING_CJK_TOP,    AF_BLUE_PROPERTY_CJK_TOP     },
+    { AF_BLUE_STRING_CJK_BOTTOM, 0                            },
 #ifdef AF_CONFIG_OPTION_CJK_BLUE_HANI_VERT
-    { AF_BLUE_STRING_CJK_LEFT_FILL,     AF_BLUE_PROPERTY_CJK_HORIZ |
-                                        AF_BLUE_PROPERTY_CJK_FILL    },
-    { AF_BLUE_STRING_CJK_LEFT_UNFILL,   AF_BLUE_PROPERTY_CJK_HORIZ   },
-    { AF_BLUE_STRING_CJK_RIGHT_FILL,    AF_BLUE_PROPERTY_CJK_HORIZ |
-                                        AF_BLUE_PROPERTY_CJK_RIGHT |
-                                        AF_BLUE_PROPERTY_CJK_FILL    },
-    { AF_BLUE_STRING_CJK_RIGHT_UNFILL,  AF_BLUE_PROPERTY_CJK_HORIZ |
-                                        AF_BLUE_PROPERTY_CJK_RIGHT   },
+    { AF_BLUE_STRING_CJK_LEFT,   AF_BLUE_PROPERTY_CJK_HORIZ   },
+    { AF_BLUE_STRING_CJK_RIGHT,  AF_BLUE_PROPERTY_CJK_HORIZ |
+                                 AF_BLUE_PROPERTY_CJK_RIGHT   },
 #endif /* AF_CONFIG_OPTION_CJK_BLUE_HANI_VERT */
-    { AF_BLUE_STRING_MAX,               0                            },
+    { AF_BLUE_STRING_MAX,        0                            },
 #endif /* AF_CONFIG_OPTION_CJK                */
 
   };
index d488f3f..3f98c13 100644 (file)
@@ -2,7 +2,7 @@
 //
 //    Auto-fitter data for blue strings.
 //
-//  Copyright 2013 by
+//  Copyright 2013, 2014 by
 //  David Turner, Robert Wilhelm, and Werner Lemberg.
 //
 //  This file is part of the FreeType project, and may only be used,
 //   using C syntax.  There can be only one string per line, thus the
 //   starting and ending double quote must be the first and last character
 //   in the line, respectively, ignoring whitespace before and after the
-//   string.  If there are multiple strings (in multiple lines), they are
-//   concatenated to a single string.  In the output, a string gets
-//   represented as a series of singles bytes, followed by a zero byte.  The
-//   enumeration values simply hold byte offsets to the start of the
-//   corresponding strings.
+//   string.  Space characters within the string are ignored too.  If there
+//   are multiple strings (in multiple lines), they are concatenated to a
+//   single string.  In the output, a string gets represented as a series of
+//   singles bytes, followed by a zero byte.  The enumeration values simply
+//   hold byte offsets to the start of the corresponding strings.
 //
 // - Data blocks enclosed in balanced braces, which get copied verbatim and
 //   which can span multiple lines.  The opening brace of a block must be
 // characters, not bytes.
 
 
+// The blue zone string data, to be used in the blue stringsets below.
+
 AF_BLUE_STRING_ENUM AF_BLUE_STRINGS_ARRAY AF_BLUE_STRING_MAX_LEN:
 
-  AF_BLUE_STRING_LATIN_CAPITAL_TOP
-    "THEZOCQS"
-  AF_BLUE_STRING_LATIN_CAPITAL_BOTTOM
-    "HEZLOCUS"
-  AF_BLUE_STRING_LATIN_SMALL_F_TOP
-    "fijkdbh"
-  AF_BLUE_STRING_LATIN_SMALL
-    "xzroesc"
-  AF_BLUE_STRING_LATIN_SMALL_DESCENDER
-    "pqgjy"
+  AF_BLUE_STRING_CYRILLIC_CAPITAL_TOP
+    "БВЕПЗОСЭ"
+  AF_BLUE_STRING_CYRILLIC_CAPITAL_BOTTOM
+    "БВЕШЗОСЭ"
+  AF_BLUE_STRING_CYRILLIC_SMALL
+    "хпншезос"
+  AF_BLUE_STRING_CYRILLIC_SMALL_DESCENDER
+    "руф"
+
+  // we separate the letters with spaces to avoid ligatures;
+  // this is just for convenience to simplify reading
+  AF_BLUE_STRING_DEVANAGARI_BASE
+    "क म अ आ थ ध भ श"
+  AF_BLUE_STRING_DEVANAGARI_TOP
+    "ई ऐ ओ औ ि ी ो ौ"
+  // note that some fonts have extreme variation in the height of the
+  // round head elements; for this reason we also define the `base'
+  // blue zone, which must be always present
+  AF_BLUE_STRING_DEVANAGARI_HEAD
+    "क म अ आ थ ध भ श"
+  AF_BLUE_STRING_DEVANAGARI_BOTTOM
+    "ु ृ"
 
   AF_BLUE_STRING_GREEK_CAPITAL_TOP
     "ΓΒΕΖΘΟΩ"
@@ -87,15 +101,6 @@ AF_BLUE_STRING_ENUM AF_BLUE_STRINGS_ARRAY AF_BLUE_STRING_MAX_LEN:
   AF_BLUE_STRING_GREEK_SMALL_DESCENDER
     "βγημρφχψ"
 
-  AF_BLUE_STRING_CYRILLIC_CAPITAL_TOP
-    "БВЕПЗОСЭ"
-  AF_BLUE_STRING_CYRILLIC_CAPITAL_BOTTOM
-    "БВЕШЗОСЭ"
-  AF_BLUE_STRING_CYRILLIC_SMALL
-    "хпншезос"
-  AF_BLUE_STRING_CYRILLIC_SMALL_DESCENDER
-    "руф"
-
   AF_BLUE_STRING_HEBREW_TOP
     "בדהחךכםס"
   AF_BLUE_STRING_HEBREW_BOTTOM
@@ -103,24 +108,41 @@ AF_BLUE_STRING_ENUM AF_BLUE_STRINGS_ARRAY AF_BLUE_STRING_MAX_LEN:
   AF_BLUE_STRING_HEBREW_DESCENDER
     "קךןףץ"
 
+  AF_BLUE_STRING_LATIN_CAPITAL_TOP
+    "THEZOCQS"
+  AF_BLUE_STRING_LATIN_CAPITAL_BOTTOM
+    "HEZLOCUS"
+  AF_BLUE_STRING_LATIN_SMALL_F_TOP
+    "fijkdbh"
+  AF_BLUE_STRING_LATIN_SMALL
+    "xzroesc"
+  AF_BLUE_STRING_LATIN_SMALL_DESCENDER
+    "pqgjy"
+
+  // we separate the letters with spaces to avoid ligatures;
+  // this is just for convenience to simplify reading
+  AF_BLUE_STRING_TELUGU_TOP
+    "ఇ ఌ ఙ ఞ ణ ఱ ౯"
+
+  AF_BLUE_STRING_TELUGU_BOTTOM
+    "అ క చ ర ఽ ౨ ౬"
+
 #ifdef AF_CONFIG_OPTION_CJK
 
-  AF_BLUE_STRING_CJK_TOP_FILL
+  AF_BLUE_STRING_CJK_TOP
     "他们你來們到和地"
     "对對就席我时時會"
     "来為能舰說说这這"
-    "齊"
-  AF_BLUE_STRING_CJK_TOP_UNFILL
+    "齊 |"
     "军同已愿既星是景"
     "民照现現理用置要"
     "軍那配里開雷露面"
     "顾"
-  AF_BLUE_STRING_CJK_BOTTOM_FILL
+  AF_BLUE_STRING_CJK_BOTTOM
     "个为人他以们你來"
     "個們到和大对對就"
     "我时時有来為要說"
-    "说"
-  AF_BLUE_STRING_CJK_BOTTOM_UNFILL
+    "说 |"
     "主些因它想意理生"
     "當看着置者自著裡"
     "过还进進過道還里"
@@ -128,22 +150,20 @@ AF_BLUE_STRING_ENUM AF_BLUE_STRINGS_ARRAY AF_BLUE_STRING_MAX_LEN:
 
 #ifdef AF_CONFIG_OPTION_CJK_BLUE_HANI_VERT
 
-  AF_BLUE_STRING_CJK_LEFT_FILL
+  AF_BLUE_STRING_CJK_LEFT
     "些们你來們到和地"
     "她将將就年得情最"
     "样樣理能說说这這"
-    "通"
-  AF_BLUE_STRING_CJK_LEFT_UNFILL
+    "通 |"
     "即吗吧听呢品响嗎"
     "师師收断斷明眼間"
     "间际陈限除陳随際"
     "隨"
-  AF_BLUE_STRING_CJK_RIGHT_FILL
+  AF_BLUE_STRING_CJK_RIGHT
     "事前學将將情想或"
     "政斯新样樣民沒没"
     "然特现現球第經谁"
-    "起"
-  AF_BLUE_STRING_CJK_RIGHT_UNFILL
+    "起 |"
     "例別别制动動吗嗎"
     "增指明朝期构物确"
     "种調调費费那都間"
@@ -154,17 +174,118 @@ AF_BLUE_STRING_ENUM AF_BLUE_STRINGS_ARRAY AF_BLUE_STRING_MAX_LEN:
 #endif /* AF_CONFIG_OPTION_CJK                */
 
 
+// The blue zone stringsets, as used in the script styles, cf. `afstyles.h'.
+//
+// The AF_BLUE_PROPERTY_XXX flags are defined in `afblue.h'; here some
+// explanations.
+//
+// A blue zone in general is defined by a reference and an overshoot line.
+// During the hinting process, all coordinate values between those two lines
+// are set equal to the reference value, provided that the blue zone is not
+// wider than 0.75 pixels (otherwise the blue zone gets ignored).  All
+// entries must have `AF_BLUE_STRING_MAX' as the final line.
+//
+// During the glyph analysis, edges are sorted from bottom to top, and then
+// sequentially checked, edge by edge, against the blue zones in the order
+// given below.
+//
+//
+// latin auto-hinter
+// -----------------
+//
+// Characters in a blue string are automatically classified as having a flat
+// (reference) or a round (overshoot) extremum.  The blue zone is then set
+// up by the mean values of all flat extrema and all round extrema,
+// respectively.  Only horizontal blue zones (i.e., adjusting vertical
+// coordinate values) are supported.
+//
+// For the latin auto-hinter, the overshoot should be larger than the
+// reference for top zones, and vice versa for bottom zones.
+//
+//   LATIN_TOP
+//     Take the maximum flat and round coordinate values of the blue string
+//     characters for computing the blue zone's reference and overshoot
+//     values.
+//
+//     If not set, take the minimum values.
+//
+//   LATIN_NEUTRAL
+//     Ignore round extrema and define the blue zone with flat values only.
+//     Both top and bottom of contours can match.  This is useful for
+//     scripts like Devanagari where vowel signs attach to the base
+//     character and are implemented as components of composite glyphs.
+//
+//     If not set, both round and flat extrema are taken into account.
+//     Additionally, only the top or the bottom of a contour can match,
+//     depending on the LATIN_TOP flag.
+//
+//     Neutral blue zones should always follow non-neutral blue zones.
+//
+//   LATIN_X_HEIGHT
+//     Scale all glyphs vertically from the corresponding script to make the
+//     reference line of this blue zone align on the grid.  The scaling
+//     takes place before all other blue zones get aligned to the grid.
+//     Only one blue character string of a script style can have this flag.
+//
+//   LATIN_LONG
+//     Apply an additional constraint for blue zone values: Don't
+//     necessarily use the extremum as-is but a segment of the topmost (or
+//     bottommost) contour that is longer than a heuristic threshold, and
+//     which is not too far away vertically from the real extremum.  This
+//     ensures that small bumps in the outline are ignored (for example, the
+//     `vertical serifs' found in many Hebrew glyph designs).
+//
+//     The segment must be at least EM/25 font units long, and the distance
+//     to the extremum must be smaller than EM/4.
+//
+//
+// cjk auto-hinter
+// ---------------
+//
+// Characters in a blue string are *not* automatically classified.  Instead,
+// first come the characters used for the overshoot value, then the
+// character `|', then the characters used for the reference value.  The
+// blue zone is then set up by the mean values of all reference values and
+// all overshoot values, respectively.  Both horizontal and vertical blue
+// zones (i.e., adjusting vertical and horizontal coordinate values,
+// respectively) are supported.
+//
+// For the cjk auto-hinter, the overshoot should be smaller than the
+// reference for top zones, and vice versa for bottom zones.
+//
+//   CJK_TOP
+//     Take the maximum flat and round coordinate values of the blue string
+//     characters.  If not set, take the minimum values.
+//
+//   CJK_RIGHT
+//     A synonym for CJK_TOP.  If CJK_HORIZ is set, this flag indicates the
+//     right blue zone, taking horizontal maximum values.
+//
+//   CJK_HORIZ
+//     Define a blue zone for horizontal hinting (i.e., vertical blue
+//     zones).  If not set, this is a blue zone for vertical hinting.
+
+
 AF_BLUE_STRINGSET_ENUM AF_BLUE_STRINGSETS_ARRAY AF_BLUE_STRINGSET_MAX_LEN:
 
-  AF_BLUE_STRINGSET_LATN
-    { AF_BLUE_STRING_LATIN_CAPITAL_TOP,     AF_BLUE_PROPERTY_LATIN_TOP        }
-    { AF_BLUE_STRING_LATIN_CAPITAL_BOTTOM,  0                                 }
-    { AF_BLUE_STRING_LATIN_SMALL_F_TOP,     AF_BLUE_PROPERTY_LATIN_TOP        }
-    { AF_BLUE_STRING_LATIN_SMALL,           AF_BLUE_PROPERTY_LATIN_TOP      |
-                                            AF_BLUE_PROPERTY_LATIN_X_HEIGHT   }
-    { AF_BLUE_STRING_LATIN_SMALL,           0                                 }
-    { AF_BLUE_STRING_LATIN_SMALL_DESCENDER, 0                                 }
-    { AF_BLUE_STRING_MAX,                   0                                 }
+  AF_BLUE_STRINGSET_CYRL
+    { AF_BLUE_STRING_CYRILLIC_CAPITAL_TOP,     AF_BLUE_PROPERTY_LATIN_TOP        }
+    { AF_BLUE_STRING_CYRILLIC_CAPITAL_BOTTOM,  0                                 }
+    { AF_BLUE_STRING_CYRILLIC_SMALL,           AF_BLUE_PROPERTY_LATIN_TOP      |
+                                               AF_BLUE_PROPERTY_LATIN_X_HEIGHT   }
+    { AF_BLUE_STRING_CYRILLIC_SMALL,           0                                 }
+    { AF_BLUE_STRING_CYRILLIC_SMALL_DESCENDER, 0                                 }
+    { AF_BLUE_STRING_MAX,                      0                                 }
+
+  AF_BLUE_STRINGSET_DEVA
+    { AF_BLUE_STRING_DEVANAGARI_TOP,    AF_BLUE_PROPERTY_LATIN_TOP        }
+    { AF_BLUE_STRING_DEVANAGARI_HEAD,   AF_BLUE_PROPERTY_LATIN_TOP        }
+    { AF_BLUE_STRING_DEVANAGARI_BASE,   AF_BLUE_PROPERTY_LATIN_TOP      |
+                                        AF_BLUE_PROPERTY_LATIN_NEUTRAL  |
+                                        AF_BLUE_PROPERTY_LATIN_X_HEIGHT   }
+    { AF_BLUE_STRING_DEVANAGARI_BASE,   0                                 }
+    { AF_BLUE_STRING_DEVANAGARI_BOTTOM, 0                                 }
+    { AF_BLUE_STRING_MAX,               0                                 }
 
   AF_BLUE_STRINGSET_GREK
     { AF_BLUE_STRING_GREEK_CAPITAL_TOP,     AF_BLUE_PROPERTY_LATIN_TOP        }
@@ -176,15 +297,6 @@ AF_BLUE_STRINGSET_ENUM AF_BLUE_STRINGSETS_ARRAY AF_BLUE_STRINGSET_MAX_LEN:
     { AF_BLUE_STRING_GREEK_SMALL_DESCENDER, 0                                 }
     { AF_BLUE_STRING_MAX,                   0                                 }
 
-  AF_BLUE_STRINGSET_CYRL
-    { AF_BLUE_STRING_CYRILLIC_CAPITAL_TOP,     AF_BLUE_PROPERTY_LATIN_TOP        }
-    { AF_BLUE_STRING_CYRILLIC_CAPITAL_BOTTOM,  0                                 }
-    { AF_BLUE_STRING_CYRILLIC_SMALL,           AF_BLUE_PROPERTY_LATIN_TOP      |
-                                               AF_BLUE_PROPERTY_LATIN_X_HEIGHT   }
-    { AF_BLUE_STRING_CYRILLIC_SMALL,           0                                 }
-    { AF_BLUE_STRING_CYRILLIC_SMALL_DESCENDER, 0                                 }
-    { AF_BLUE_STRING_MAX,                      0                                 }
-
   AF_BLUE_STRINGSET_HEBR
     { AF_BLUE_STRING_HEBREW_TOP,       AF_BLUE_PROPERTY_LATIN_TOP  |
                                        AF_BLUE_PROPERTY_LATIN_LONG   }
@@ -192,25 +304,32 @@ AF_BLUE_STRINGSET_ENUM AF_BLUE_STRINGSETS_ARRAY AF_BLUE_STRINGSET_MAX_LEN:
     { AF_BLUE_STRING_HEBREW_DESCENDER, 0                             }
     { AF_BLUE_STRING_MAX,              0                             }
 
+  AF_BLUE_STRINGSET_LATN
+    { AF_BLUE_STRING_LATIN_CAPITAL_TOP,     AF_BLUE_PROPERTY_LATIN_TOP        }
+    { AF_BLUE_STRING_LATIN_CAPITAL_BOTTOM,  0                                 }
+    { AF_BLUE_STRING_LATIN_SMALL_F_TOP,     AF_BLUE_PROPERTY_LATIN_TOP        }
+    { AF_BLUE_STRING_LATIN_SMALL,           AF_BLUE_PROPERTY_LATIN_TOP      |
+                                            AF_BLUE_PROPERTY_LATIN_X_HEIGHT   }
+    { AF_BLUE_STRING_LATIN_SMALL,           0                                 }
+    { AF_BLUE_STRING_LATIN_SMALL_DESCENDER, 0                                 }
+    { AF_BLUE_STRING_MAX,                   0                                 }
+
+  AF_BLUE_STRINGSET_TELU
+    { AF_BLUE_STRING_TELUGU_TOP,    AF_BLUE_PROPERTY_LATIN_TOP }
+    { AF_BLUE_STRING_TELUGU_BOTTOM, 0                          }
+    { AF_BLUE_STRING_MAX,           0                          }
+
 #ifdef AF_CONFIG_OPTION_CJK
 
   AF_BLUE_STRINGSET_HANI
-    { AF_BLUE_STRING_CJK_TOP_FILL,      AF_BLUE_PROPERTY_CJK_TOP |
-                                        AF_BLUE_PROPERTY_CJK_FILL    }
-    { AF_BLUE_STRING_CJK_TOP_UNFILL,    AF_BLUE_PROPERTY_CJK_TOP     }
-    { AF_BLUE_STRING_CJK_BOTTOM_FILL,   AF_BLUE_PROPERTY_CJK_FILL    }
-    { AF_BLUE_STRING_CJK_BOTTOM_UNFILL, 0                            }
+    { AF_BLUE_STRING_CJK_TOP,    AF_BLUE_PROPERTY_CJK_TOP     }
+    { AF_BLUE_STRING_CJK_BOTTOM, 0                            }
 #ifdef AF_CONFIG_OPTION_CJK_BLUE_HANI_VERT
-    { AF_BLUE_STRING_CJK_LEFT_FILL,     AF_BLUE_PROPERTY_CJK_HORIZ |
-                                        AF_BLUE_PROPERTY_CJK_FILL    }
-    { AF_BLUE_STRING_CJK_LEFT_UNFILL,   AF_BLUE_PROPERTY_CJK_HORIZ   }
-    { AF_BLUE_STRING_CJK_RIGHT_FILL,    AF_BLUE_PROPERTY_CJK_HORIZ |
-                                        AF_BLUE_PROPERTY_CJK_RIGHT |
-                                        AF_BLUE_PROPERTY_CJK_FILL    }
-    { AF_BLUE_STRING_CJK_RIGHT_UNFILL,  AF_BLUE_PROPERTY_CJK_HORIZ |
-                                        AF_BLUE_PROPERTY_CJK_RIGHT   }
+    { AF_BLUE_STRING_CJK_LEFT,   AF_BLUE_PROPERTY_CJK_HORIZ   }
+    { AF_BLUE_STRING_CJK_RIGHT,  AF_BLUE_PROPERTY_CJK_HORIZ |
+                                 AF_BLUE_PROPERTY_CJK_RIGHT   }
 #endif /* AF_CONFIG_OPTION_CJK_BLUE_HANI_VERT */
-    { AF_BLUE_STRING_MAX,               0                            }
+    { AF_BLUE_STRING_MAX,        0                            }
 
 #endif /* AF_CONFIG_OPTION_CJK                */
 
index 6f336ab..a861841 100644 (file)
@@ -7,7 +7,7 @@
 /*                                                                         */
 /*    Auto-fitter data for blue strings (specification).                   */
 /*                                                                         */
-/*  Copyright 2013 by                                                      */
+/*  Copyright 2013, 2014 by                                                */
 /*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
 /*                                                                         */
 /*  This file is part of the FreeType project, and may only be used,       */
@@ -67,42 +67,44 @@ FT_BEGIN_HEADER
   /* At the bottommost level, we define strings for finding blue zones. */
 
 
-#define AF_BLUE_STRING_MAX_LEN  25
+#define AF_BLUE_STRING_MAX_LEN  51
 
   /* The AF_Blue_String enumeration values are offsets into the */
   /* `af_blue_strings' array.                                   */
 
   typedef enum  AF_Blue_String_
   {
-    AF_BLUE_STRING_LATIN_CAPITAL_TOP = 0,
-    AF_BLUE_STRING_LATIN_CAPITAL_BOTTOM = 9,
-    AF_BLUE_STRING_LATIN_SMALL_F_TOP = 18,
-    AF_BLUE_STRING_LATIN_SMALL = 26,
-    AF_BLUE_STRING_LATIN_SMALL_DESCENDER = 34,
-    AF_BLUE_STRING_GREEK_CAPITAL_TOP = 40,
-    AF_BLUE_STRING_GREEK_CAPITAL_BOTTOM = 55,
-    AF_BLUE_STRING_GREEK_SMALL_BETA_TOP = 68,
-    AF_BLUE_STRING_GREEK_SMALL = 81,
-    AF_BLUE_STRING_GREEK_SMALL_DESCENDER = 98,
-    AF_BLUE_STRING_CYRILLIC_CAPITAL_TOP = 115,
-    AF_BLUE_STRING_CYRILLIC_CAPITAL_BOTTOM = 132,
-    AF_BLUE_STRING_CYRILLIC_SMALL = 149,
-    AF_BLUE_STRING_CYRILLIC_SMALL_DESCENDER = 166,
-    AF_BLUE_STRING_HEBREW_TOP = 173,
-    AF_BLUE_STRING_HEBREW_BOTTOM = 190,
-    AF_BLUE_STRING_HEBREW_DESCENDER = 203,
-    af_blue_1_1 = 213,
+    AF_BLUE_STRING_CYRILLIC_CAPITAL_TOP = 0,
+    AF_BLUE_STRING_CYRILLIC_CAPITAL_BOTTOM = 17,
+    AF_BLUE_STRING_CYRILLIC_SMALL = 34,
+    AF_BLUE_STRING_CYRILLIC_SMALL_DESCENDER = 51,
+    AF_BLUE_STRING_DEVANAGARI_BASE = 58,
+    AF_BLUE_STRING_DEVANAGARI_TOP = 83,
+    AF_BLUE_STRING_DEVANAGARI_HEAD = 108,
+    AF_BLUE_STRING_DEVANAGARI_BOTTOM = 133,
+    AF_BLUE_STRING_GREEK_CAPITAL_TOP = 140,
+    AF_BLUE_STRING_GREEK_CAPITAL_BOTTOM = 155,
+    AF_BLUE_STRING_GREEK_SMALL_BETA_TOP = 168,
+    AF_BLUE_STRING_GREEK_SMALL = 181,
+    AF_BLUE_STRING_GREEK_SMALL_DESCENDER = 198,
+    AF_BLUE_STRING_HEBREW_TOP = 215,
+    AF_BLUE_STRING_HEBREW_BOTTOM = 232,
+    AF_BLUE_STRING_HEBREW_DESCENDER = 245,
+    AF_BLUE_STRING_LATIN_CAPITAL_TOP = 256,
+    AF_BLUE_STRING_LATIN_CAPITAL_BOTTOM = 265,
+    AF_BLUE_STRING_LATIN_SMALL_F_TOP = 274,
+    AF_BLUE_STRING_LATIN_SMALL = 282,
+    AF_BLUE_STRING_LATIN_SMALL_DESCENDER = 290,
+    AF_BLUE_STRING_TELUGU_TOP = 296,
+    AF_BLUE_STRING_TELUGU_BOTTOM = 318,
+    af_blue_1_1 = 339,
 #ifdef AF_CONFIG_OPTION_CJK
-    AF_BLUE_STRING_CJK_TOP_FILL = af_blue_1_1 + 1,
-    AF_BLUE_STRING_CJK_TOP_UNFILL = af_blue_1_1 + 77,
-    AF_BLUE_STRING_CJK_BOTTOM_FILL = af_blue_1_1 + 153,
-    AF_BLUE_STRING_CJK_BOTTOM_UNFILL = af_blue_1_1 + 229,
+    AF_BLUE_STRING_CJK_TOP = af_blue_1_1 + 1,
+    AF_BLUE_STRING_CJK_BOTTOM = af_blue_1_1 + 153,
     af_blue_1_1_1 = af_blue_1_1 + 304,
 #ifdef AF_CONFIG_OPTION_CJK_BLUE_HANI_VERT
-    AF_BLUE_STRING_CJK_LEFT_FILL = af_blue_1_1_1 + 1,
-    AF_BLUE_STRING_CJK_LEFT_UNFILL = af_blue_1_1_1 + 77,
-    AF_BLUE_STRING_CJK_RIGHT_FILL = af_blue_1_1_1 + 153,
-    AF_BLUE_STRING_CJK_RIGHT_UNFILL = af_blue_1_1_1 + 229,
+    AF_BLUE_STRING_CJK_LEFT = af_blue_1_1_1 + 1,
+    AF_BLUE_STRING_CJK_RIGHT = af_blue_1_1_1 + 153,
     af_blue_1_1_2 = af_blue_1_1_1 + 304,
 #else
     af_blue_1_1_2 = af_blue_1_1_1 + 0,
@@ -136,33 +138,35 @@ FT_BEGIN_HEADER
   /* Properties are specific to a writing system.  We assume that a given  */
   /* blue string can't be used in more than a single writing system, which */
   /* is a safe bet.                                                        */
-#define AF_BLUE_PROPERTY_LATIN_TOP       ( 1 << 0 )
-#define AF_BLUE_PROPERTY_LATIN_X_HEIGHT  ( 1 << 1 )
-#define AF_BLUE_PROPERTY_LATIN_LONG      ( 1 << 2 )
+#define AF_BLUE_PROPERTY_LATIN_TOP       ( 1 << 0 )   /* must have value 1 */
+#define AF_BLUE_PROPERTY_LATIN_NEUTRAL   ( 1 << 1 )
+#define AF_BLUE_PROPERTY_LATIN_X_HEIGHT  ( 1 << 2 )
+#define AF_BLUE_PROPERTY_LATIN_LONG      ( 1 << 3 )
 
-#define AF_BLUE_PROPERTY_CJK_HORIZ  ( 1 << 0 )
-#define AF_BLUE_PROPERTY_CJK_TOP    ( 1 << 1 )
-#define AF_BLUE_PROPERTY_CJK_FILL   ( 1 << 2 )
+#define AF_BLUE_PROPERTY_CJK_TOP    ( 1 << 0 )        /* must have value 1 */
+#define AF_BLUE_PROPERTY_CJK_HORIZ  ( 1 << 1 )        /* must have value 2 */
 #define AF_BLUE_PROPERTY_CJK_RIGHT  AF_BLUE_PROPERTY_CJK_TOP
 
 
-#define AF_BLUE_STRINGSET_MAX_LEN  9
+#define AF_BLUE_STRINGSET_MAX_LEN  7
 
   /* The AF_Blue_Stringset enumeration values are offsets into the */
   /* `af_blue_stringsets' array.                                   */
 
   typedef enum  AF_Blue_Stringset_
   {
-    AF_BLUE_STRINGSET_LATN = 0,
-    AF_BLUE_STRINGSET_GREK = 7,
-    AF_BLUE_STRINGSET_CYRL = 14,
-    AF_BLUE_STRINGSET_HEBR = 20,
-    af_blue_2_1 = 24,
+    AF_BLUE_STRINGSET_CYRL = 0,
+    AF_BLUE_STRINGSET_DEVA = 6,
+    AF_BLUE_STRINGSET_GREK = 12,
+    AF_BLUE_STRINGSET_HEBR = 19,
+    AF_BLUE_STRINGSET_LATN = 23,
+    AF_BLUE_STRINGSET_TELU = 30,
+    af_blue_2_1 = 33,
 #ifdef AF_CONFIG_OPTION_CJK
     AF_BLUE_STRINGSET_HANI = af_blue_2_1 + 0,
-    af_blue_2_1_1 = af_blue_2_1 + 4,
+    af_blue_2_1_1 = af_blue_2_1 + 2,
 #ifdef AF_CONFIG_OPTION_CJK_BLUE_HANI_VERT
-    af_blue_2_1_2 = af_blue_2_1_1 + 4,
+    af_blue_2_1_2 = af_blue_2_1_1 + 2,
 #else
     af_blue_2_1_2 = af_blue_2_1_1 + 0,
 #endif /* AF_CONFIG_OPTION_CJK_BLUE_HANI_VERT */
index 4fc9917..0b4b48d 100644 (file)
@@ -4,7 +4,7 @@
 /*                                                                         */
 /*    Auto-fitter data for blue strings (specification).                   */
 /*                                                                         */
-/*  Copyright 2013 by                                                      */
+/*  Copyright 2013, 2014 by                                                */
 /*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
 /*                                                                         */
 /*  This file is part of the FreeType project, and may only be used,       */
@@ -96,13 +96,13 @@ FT_BEGIN_HEADER
   /* Properties are specific to a writing system.  We assume that a given  */
   /* blue string can't be used in more than a single writing system, which */
   /* is a safe bet.                                                        */
-#define AF_BLUE_PROPERTY_LATIN_TOP       ( 1 << 0 )
-#define AF_BLUE_PROPERTY_LATIN_X_HEIGHT  ( 1 << 1 )
-#define AF_BLUE_PROPERTY_LATIN_LONG      ( 1 << 2 )
+#define AF_BLUE_PROPERTY_LATIN_TOP       ( 1 << 0 )   /* must have value 1 */
+#define AF_BLUE_PROPERTY_LATIN_NEUTRAL   ( 1 << 1 )
+#define AF_BLUE_PROPERTY_LATIN_X_HEIGHT  ( 1 << 2 )
+#define AF_BLUE_PROPERTY_LATIN_LONG      ( 1 << 3 )
 
-#define AF_BLUE_PROPERTY_CJK_HORIZ  ( 1 << 0 )
-#define AF_BLUE_PROPERTY_CJK_TOP    ( 1 << 1 )
-#define AF_BLUE_PROPERTY_CJK_FILL   ( 1 << 2 )
+#define AF_BLUE_PROPERTY_CJK_TOP    ( 1 << 0 )        /* must have value 1 */
+#define AF_BLUE_PROPERTY_CJK_HORIZ  ( 1 << 1 )        /* must have value 2 */
 #define AF_BLUE_PROPERTY_CJK_RIGHT  AF_BLUE_PROPERTY_CJK_TOP
 
 
index 3a65fc5..048e0e7 100644 (file)
@@ -4,7 +4,7 @@
 /*                                                                         */
 /*    Auto-fitter hinting routines for CJK writing system (body).          */
 /*                                                                         */
-/*  Copyright 2006-2013 by                                                 */
+/*  Copyright 2006-2014 by                                                 */
 /*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
 /*                                                                         */
 /*  This file is part of the FreeType project, and may only be used,       */
           goto Exit;
 
         af_latin_hints_link_segments( hints,
+                                      0,
+                                      NULL,
                                       (AF_Dimension)dim );
 
         seg   = axhints->segments;
     FT_Int      num_fills;
     FT_Int      num_flats;
 
+    FT_Bool     fill;
+
     AF_CJKBlue  blue;
     FT_Error    error;
     AF_CJKAxis  axis;
     AF_Blue_Stringset         bss = sc->blue_stringset;
     const AF_Blue_StringRec*  bs  = &af_blue_stringsets[bss];
 
-#ifdef FT_DEBUG_LEVEL_TRACE
-    FT_String*  cjk_blue_name[4] =
-    {
-      (FT_String*)"bottom",    /* --   , --  */
-      (FT_String*)"top",       /* --   , TOP */
-      (FT_String*)"left",      /* HORIZ, --  */
-      (FT_String*)"right"      /* HORIZ, TOP */
-    };
-
-    FT_String*  cjk_blue_type_name[2] =
-    {
-      (FT_String*)"unfilled",  /* --   */
-      (FT_String*)"filled"     /* FILL */
-    };
-#endif
-
 
     /* we walk over the blue character strings as specified in the   */
     /* style's entry in the `af_blue_stringset' array, computing its */
       else
         axis = &metrics->axis[AF_DIMENSION_VERT];
 
-      FT_TRACE5(( "blue zone %d:\n", axis->blue_count ));
+#ifdef FT_DEBUG_LEVEL_TRACE
+      {
+        FT_String*  cjk_blue_name[4] =
+        {
+          (FT_String*)"bottom",    /* --   , --  */
+          (FT_String*)"top",       /* --   , TOP */
+          (FT_String*)"left",      /* HORIZ, --  */
+          (FT_String*)"right"      /* HORIZ, TOP */
+        };
+
+
+        FT_TRACE5(( "blue zone %d (%s):\n",
+                    axis->blue_count,
+                    cjk_blue_name[AF_CJK_IS_HORIZ_BLUE( bs ) |
+                                  AF_CJK_IS_TOP_BLUE( bs )   ] ));
+      }
+#endif /* FT_DEBUG_LEVEL_TRACE */
 
       num_fills = 0;
       num_flats = 0;
 
-      FT_TRACE5(( "  cjk blue %s/%s\n",
-                  cjk_blue_name[AF_CJK_IS_HORIZ_BLUE( bs ) |
-                                AF_CJK_IS_TOP_BLUE( bs )   ],
-                  cjk_blue_type_name[!!AF_CJK_IS_FILLED_BLUE( bs )] ));
+      fill = 1;  /* start with characters that define fill values */
+      FT_TRACE5(( "  [overshoot values]\n" ));
 
       while ( *p )
       {
 
         GET_UTF8_CHAR( ch, p );
 
+        /* switch to characters that define flat values */
+        if ( ch == '|' )
+        {
+          fill = 0;
+          FT_TRACE5(( "  [reference values]\n" ));
+          continue;
+        }
+
         /* load the character in the face -- skip unknown or empty ones */
         af_get_char_index( &metrics->root, ch, &glyph_index, &y_offset );
         if ( glyph_index == 0 )
           FT_TRACE5(( "  U+%04lX: best_pos = %5ld\n", ch, best_pos ));
         }
 
-        if ( AF_CJK_IS_FILLED_BLUE( bs ) )
+        if ( fill )
           fills[num_fills++] = best_pos;
         else
           flats[num_flats++] = best_pos;
          *  we couldn't find a single glyph to compute this blue zone,
          *  we will simply ignore it then
          */
-        FT_TRACE5(( "    empty\n" ));
+        FT_TRACE5(( "  empty\n" ));
         continue;
       }
 
-      /* we have computed the contents of the `fill' and `flats' tables, */
-      /* now determine the reference position of the blue zone --        */
-      /* we simply take the median value after a simple sort             */
-      af_sort_pos( num_flats, flats );
+      /* we have computed the contents of the `fill' and `flats' tables,   */
+      /* now determine the reference and overshoot position of the blue -- */
+      /* we simply take the median value after a simple sort               */
       af_sort_pos( num_fills, fills );
+      af_sort_pos( num_flats, flats );
 
       blue       = &axis->blues[axis->blue_count];
       blue_ref   = &blue->ref.org;
           *blue_ref   =
           *blue_shoot = ( shoot + ref ) / 2;
 
-          FT_TRACE5(( "  [overshoot smaller than reference,"
+          FT_TRACE5(( "  [reference smaller than overshoot,"
                       " taking mean value]\n" ));
         }
       }
     /* now compare each segment to the others */
     for ( seg1 = segments; seg1 < segment_limit; seg1++ )
     {
-      /* the fake segments are for metrics hinting only */
-      if ( seg1->first == seg1->last )
-        continue;
-
       if ( seg1->dir != major_dir )
         continue;
 
 
         edge->first    = seg;
         edge->last     = seg;
+        edge->dir      = seg->dir;
         edge->fpos     = seg->pos;
-        edge->opos     = edge->pos = FT_MulFix( seg->pos, scale );
+        edge->opos     = FT_MulFix( seg->pos, scale );
+        edge->pos      = edge->opos;
         seg->edge_next = seg;
-        edge->dir      = seg->dir;
       }
       else
       {
         /* zone, check for left edges                                      */
         /*                                                                 */
         /* of course, that's for TrueType                                  */
-        is_top_right_blue = FT_BOOL( blue->flags & AF_CJK_BLUE_TOP );
-        is_major_dir      = FT_BOOL( edge->dir == axis->major_dir );
+        is_top_right_blue =
+          (FT_Byte)( ( blue->flags & AF_CJK_BLUE_TOP ) != 0 );
+        is_major_dir =
+          FT_BOOL( edge->dir == axis->major_dir );
 
         /* if it is a top zone, the edge must be against the major    */
         /* direction; if it is a bottom zone, it must be in the major */
 
 
     stem_edge->pos = base_edge->pos + fitted_width;
+
+    FT_TRACE5(( "  CJKLINK: edge %d @%d (opos=%.2f) linked to %.2f,"
+                " dist was %.2f, now %.2f\n",
+                stem_edge - hints->axis[dim].edges, stem_edge->fpos,
+                stem_edge->opos / 64.0, stem_edge->pos / 64.0,
+                dist / 64.0, fitted_width / 64.0 ));
   }
 
 
index a260b09..4dd4f39 100644 (file)
@@ -4,7 +4,7 @@
 /*                                                                         */
 /*    Auto-fitter hinting routines for CJK writing system (specification). */
 /*                                                                         */
-/*  Copyright 2006, 2007, 2011-2013 by                                     */
+/*  Copyright 2006, 2007, 2011-2014 by                                     */
 /*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
 /*                                                                         */
 /*  This file is part of the FreeType project, and may only be used,       */
@@ -50,8 +50,6 @@ FT_BEGIN_HEADER
           ( (b)->properties & AF_BLUE_PROPERTY_CJK_TOP )
 #define AF_CJK_IS_HORIZ_BLUE( b ) \
           ( (b)->properties & AF_BLUE_PROPERTY_CJK_HORIZ )
-#define AF_CJK_IS_FILLED_BLUE( b ) \
-          ( (b)->properties & AF_BLUE_PROPERTY_CJK_FILL )
 #define AF_CJK_IS_RIGHT_BLUE  AF_CJK_IS_TOP_BLUE
 
 #define AF_CJK_MAX_WIDTHS  16
index 7aa2e11..a54c20c 100644 (file)
     FT_Byte*    gstyles     = globals->glyph_styles;
     FT_UInt     ss;
     FT_UInt     i;
-    FT_UInt     dflt        = -1;
+    FT_UInt     dflt        = ~0U; /* a non-valid value */
 
 
     /* the value AF_STYLE_UNASSIGNED means `uncovered glyph' */
        */
       if ( style_class->coverage == AF_COVERAGE_DEFAULT )
       {
-        if ( style_class->script == globals->module->default_script )
+        if ( (FT_UInt)style_class->script ==
+             globals->module->default_script )
           dflt = ss;
 
         for ( range = script_class->script_uni_ranges;
       af_face_globals_free( globals );
       globals = NULL;
     }
-
-    globals->increase_x_height = AF_PROP_INCREASE_X_HEIGHT_MAX;
+    else
+      globals->increase_x_height = AF_PROP_INCREASE_X_HEIGHT_MAX;
 
   Exit:
     *aglobals = globals;
index d2da40e..38d8d69 100644 (file)
@@ -66,16 +66,16 @@ FT_BEGIN_HEADER
 
   /* index of fallback style in `af_style_classes' */
 #ifdef AF_CONFIG_OPTION_CJK
-#define AF_STYLE_FALLBACK  AF_STYLE_HANI_DFLT
+#define AF_STYLE_FALLBACK    AF_STYLE_HANI_DFLT
 #else
-#define AF_STYLE_FALLBACK  AF_STYLE_NONE_DFLT
+#define AF_STYLE_FALLBACK    AF_STYLE_NONE_DFLT
 #endif
   /* default script for OpenType; ignored if HarfBuzz isn't used */
-#define AF_SCRIPT_DEFAULT  AF_SCRIPT_LATN
+#define AF_SCRIPT_DEFAULT    AF_SCRIPT_LATN
   /* a bit mask indicating an uncovered glyph        */
 #define AF_STYLE_UNASSIGNED  0x7F
   /* if this flag is set, we have an ASCII digit     */
-#define AF_DIGIT              0x80
+#define AF_DIGIT             0x80
 
   /* `increase-x-height' property */
 #define AF_PROP_INCREASE_X_HEIGHT_MIN  6
index 270a06b..f3cc50f 100644 (file)
@@ -74,7 +74,8 @@
   }
 
 
-  /* Get new edge for given axis, direction, and position. */
+  /* Get new edge for given axis, direction, and position, */
+  /* without initializing the edge itself.                 */
 
   FT_LOCAL( FT_Error )
   af_axis_hints_new_edge( AF_AxisHints  axis,
 
     axis->num_edges++;
 
-    FT_ZERO( edge );
-    edge->fpos = (FT_Short)fpos;
-    edge->dir  = (FT_Char)dir;
-
   Exit:
     *anedge = edge;
     return error;
   }
 
 
-#define AF_INDEX_NUM( ptr, base )  ( (ptr) ? ( (ptr) - (base) ) : -1 )
+#define AF_INDEX_NUM( ptr, base )  (int)( (ptr) ? ( (ptr) - (base) ) : -1 )
 
 
 #ifdef __cplusplus
 
     for ( point = points; point < limit; point++ )
       AF_DUMP(( "  [ %5d | %5d | %5d | %6.2f | %6.2f"
-                " | %5.2f | %5.2f | %c%c%c%c%c%c ]\n",
-                point - points,
+                " | %5.2f | %5.2f | %c ]\n",
+                AF_INDEX_NUM( point, points ),
                 point->fx,
                 point->fy,
                 point->ox / 64.0,
                 point->oy / 64.0,
                 point->x / 64.0,
                 point->y / 64.0,
-                ( point->flags & AF_FLAG_WEAK_INTERPOLATION ) ? 'w' : ' ',
-                ( point->flags & AF_FLAG_INFLECTION )         ? 'i' : ' ',
-                ( point->flags & AF_FLAG_EXTREMA_X )          ? '<' : ' ',
-                ( point->flags & AF_FLAG_EXTREMA_Y )          ? 'v' : ' ',
-                ( point->flags & AF_FLAG_ROUND_X )            ? '(' : ' ',
-                ( point->flags & AF_FLAG_ROUND_Y )            ? 'u' : ' '));
+                ( point->flags & AF_FLAG_WEAK_INTERPOLATION ) ? 'w' : ' '));
     AF_DUMP(( "\n" ));
   }
 #ifdef __cplusplus
         AF_DUMP(( "  [ %5d | %5.2g | %5s | %4d"
                   " | %4d | %4d | %5d | %4d"
                   " | %6d | %5d | %11s ]\n",
-                  seg - segments,
+                  AF_INDEX_NUM( seg, segments ),
                   dimension == AF_DIMENSION_HORZ
                                ? (int)seg->first->ox / 64.0
                                : (int)seg->first->oy / 64.0,
       for ( edge = edges; edge < limit; edge++ )
         AF_DUMP(( "  [ %5d | %5.2g | %5s | %4d"
                   " | %5d |   %c  | %5.2f | %5.2f | %11s ]\n",
-                  edge - edges,
+                  AF_INDEX_NUM( edge, edges ),
                   (int)edge->opos / 64.0,
                   af_dir_str( (AF_Direction)edge->dir ),
                   AF_INDEX_NUM( edge->link, edges ),
 
         for ( point = points; point < point_limit; point++, vec++, tag++ )
         {
+          point->in_dir  = (FT_Char)AF_DIR_NONE;
+          point->out_dir = (FT_Char)AF_DIR_NONE;
+
           point->fx = (FT_Short)vec->x;
           point->fy = (FT_Short)vec->y;
           point->ox = point->x = FT_MulFix( vec->x, x_scale ) + x_delta;
         }
       }
 
-      /* compute directions of in & out vectors */
       {
-        AF_Point      first  = points;
-        AF_Point      prev   = NULL;
-        FT_Pos        in_x   = 0;
-        FT_Pos        in_y   = 0;
-        AF_Direction  in_dir = AF_DIR_NONE;
-
-        FT_Pos  last_good_in_x = 0;
-        FT_Pos  last_good_in_y = 0;
-
+        /*
+         *  Compute directions of `in' and `out' vectors.
+         *
+         *  Note that distances between points that are very near to each
+         *  other are accumulated.  In other words, the auto-hinter
+         *  prepends the small vectors between near points to the first
+         *  non-near vector.  All intermediate points are tagged as
+         *  weak; the directions are adjusted also to be equal to the
+         *  accumulated one.
+         */
+
+        /* value 20 in `near_limit' is heuristic */
         FT_UInt  units_per_em = hints->metrics->scaler.face->units_per_EM;
         FT_Int   near_limit   = 20 * units_per_em / 2048;
+        FT_Int   near_limit2  = 2 * near_limit - 1;
 
+        AF_Point*  contour;
+        AF_Point*  contour_limit = hints->contours + hints->num_contours;
 
-        for ( point = points; point < point_limit; point++ )
+
+        for ( contour = hints->contours; contour < contour_limit; contour++ )
         {
-          AF_Point  next;
-          FT_Pos    out_x, out_y;
+          AF_Point  first = *contour;
+          AF_Point  next, prev, curr;
+
+          FT_Pos  out_x, out_y;
 
+          FT_Bool  is_first;
 
-          if ( point == first )
+
+          /* since the first point of a contour could be part of a */
+          /* series of near points, go backwards to find the first */
+          /* non-near point and adjust `first'                     */
+
+          point = first;
+          prev  = first->prev;
+
+          while ( prev != first )
           {
-            prev = first->prev;
+            out_x = point->fx - prev->fx;
+            out_y = point->fy - prev->fy;
+
+            /*
+             *  We use Taxicab metrics to measure the vector length.
+             *
+             *  Note that the accumulated distances so far could have the
+             *  opposite direction of the distance measured here.  For this
+             *  reason we use `near_limit2' for the comparison to get a
+             *  non-near point even in the worst case.
+             */
+            if ( FT_ABS( out_x ) + FT_ABS( out_y ) >= near_limit2 )
+              break;
+
+            point = prev;
+            prev  = prev->prev;
+          }
 
-            in_x = first->fx - prev->fx;
-            in_y = first->fy - prev->fy;
+          /* adjust first point */
+          first = point;
 
-            last_good_in_x = in_x;
-            last_good_in_y = in_y;
+          /* now loop over all points of the contour to get */
+          /* `in' and `out' vector directions               */
 
-            if ( FT_ABS( in_x ) + FT_ABS( in_y ) < near_limit )
-            {
-              /* search first non-near point to get a good `in_dir' value */
+          curr  = first;
 
-              AF_Point  point_ = prev;
+          /*
+           *  We abuse the `u' and `v' fields to store index deltas to the
+           *  next and previous non-near point, respectively.
+           *
+           *  To avoid problems with not having non-near points, we point to
+           *  `first' by default as the next non-near point.
+           *
+           */
+          curr->u  = (FT_Pos)( first - curr );
+          first->v = -curr->u;
 
+          out_x = 0;
+          out_y = 0;
 
-              while ( point_ != first )
-              {
-                AF_Point  prev_ = point_->prev;
+          is_first = 1;
 
-                FT_Pos  in_x_ = point_->fx - prev_->fx;
-                FT_Pos  in_y_ = point_->fy - prev_->fy;
+          for ( point = first;
+                point != first || is_first;
+                point = point->next )
+          {
+            AF_Direction  out_dir;
 
 
-                if ( FT_ABS( in_x_ ) + FT_ABS( in_y_ ) >= near_limit )
-                {
-                  last_good_in_x = in_x_;
-                  last_good_in_y = in_y_;
+            is_first = 0;
 
-                  break;
-                }
+            next = point->next;
 
-                point_ = prev_;
-              }
+            out_x += next->fx - point->fx;
+            out_y += next->fy - point->fy;
+
+            if ( FT_ABS( out_x ) + FT_ABS( out_y ) < near_limit )
+            {
+              next->flags |= AF_FLAG_WEAK_INTERPOLATION;
+              continue;
+            }
+
+            curr->u = (FT_Pos)( next - curr );
+            next->v = -curr->u;
+
+            out_dir = af_direction_compute( out_x, out_y );
+
+            /* adjust directions for all points inbetween; */
+            /* the loop also updates position of `curr'    */
+            curr->out_dir = (FT_Char)out_dir;
+            for ( curr = curr->next; curr != next; curr = curr->next )
+            {
+              curr->in_dir  = (FT_Char)out_dir;
+              curr->out_dir = (FT_Char)out_dir;
             }
+            next->in_dir = (FT_Char)out_dir;
 
-            in_dir = af_direction_compute( in_x, in_y );
-            first  = prev + 1;
+            curr->u  = (FT_Pos)( first - curr );
+            first->v = -curr->u;
+
+            out_x = 0;
+            out_y = 0;
           }
+        }
 
-          point->in_dir = (FT_Char)in_dir;
+        /*
+         *  The next step is to `simplify' an outline's topology so that we
+         *  can identify local extrema more reliably: A series of
+         *  non-horizontal or non-vertical vectors pointing into the same
+         *  quadrant are handled as a single, long vector.  From a
+         *  topological point of the view, the intermediate points are of no
+         *  interest and thus tagged as weak.
+         */
 
-          /* check whether the current point is near to the previous one */
-          /* (value 20 in `near_limit' is heuristic; we use Taxicab      */
-          /* metrics for the test)                                       */
+        for ( point = points; point < point_limit; point++ )
+        {
+          if ( point->flags & AF_FLAG_WEAK_INTERPOLATION )
+            continue;
 
-          if ( FT_ABS( in_x ) + FT_ABS( in_y ) < near_limit )
-            point->flags |= AF_FLAG_NEAR;
-          else
+          if ( point->in_dir  == AF_DIR_NONE &&
+               point->out_dir == AF_DIR_NONE )
           {
-            last_good_in_x = in_x;
-            last_good_in_y = in_y;
-          }
+            /* check whether both vectors point into the same quadrant */
+
+            FT_Pos  in_x, in_y;
+            FT_Pos  out_x, out_y;
+
+            AF_Point  next_u = point + point->u;
+            AF_Point  prev_v = point + point->v;
+
 
-          next  = point->next;
-          out_x = next->fx - point->fx;
-          out_y = next->fy - point->fy;
+            in_x = point->fx - prev_v->fx;
+            in_y = point->fy - prev_v->fy;
+
+            out_x = next_u->fx - point->fx;
+            out_y = next_u->fy - point->fy;
+
+            if ( ( in_x ^ out_x ) >= 0 && ( in_y ^ out_y ) >= 0 )
+            {
+              /* yes, so tag current point as weak */
+              /* and update index deltas           */
+
+              point->flags |= AF_FLAG_WEAK_INTERPOLATION;
+
+              prev_v->u = (FT_Pos)( next_u - prev_v );
+              next_u->v = -prev_v->u;
+            }
+          }
+        }
 
-          in_dir         = af_direction_compute( out_x, out_y );
-          point->out_dir = (FT_Char)in_dir;
+        /*
+         *  Finally, check for remaining weak points.  Everything else not
+         *  collected in edges so far is then implicitly classified as strong
+         *  points.
+         */
 
-          /* Check for weak points.  The remaining points not collected */
-          /* in edges are then implicitly classified as strong points.  */
+        for ( point = points; point < point_limit; point++ )
+        {
+          if ( point->flags & AF_FLAG_WEAK_INTERPOLATION )
+            continue;
 
           if ( point->flags & AF_FLAG_CONTROL )
           {
               goto Is_Weak_Point;
             }
 
-            /* test whether `in' and `out' direction is approximately */
-            /* the same (and use the last good `in' vector in case    */
-            /* the current point is near to the previous one)         */
-            if ( ft_corner_is_flat(
-                   point->flags & AF_FLAG_NEAR ? last_good_in_x : in_x,
-                   point->flags & AF_FLAG_NEAR ? last_good_in_y : in_y,
-                   out_x,
-                   out_y ) )
             {
-              /* current point lies on a straight, diagonal line */
-              /* (more or less)                                  */
-              goto Is_Weak_Point;
+              AF_Point  next_u = point + point->u;
+              AF_Point  prev_v = point + point->v;
+
+
+              if ( ft_corner_is_flat( point->fx  - prev_v->fx,
+                                      point->fy  - prev_v->fy,
+                                      next_u->fx - point->fx,
+                                      next_u->fy - point->fy ) )
+              {
+                /* either the `in' or the `out' vector is much more  */
+                /* dominant than the other one, so tag current point */
+                /* as weak and update index deltas                   */
+
+                prev_v->u = (FT_Pos)( next_u - prev_v );
+                next_u->v = -prev_v->u;
+
+                goto Is_Weak_Point;
+              }
             }
           }
           else if ( point->in_dir == -point->out_dir )
             /* current point forms a spike */
             goto Is_Weak_Point;
           }
-
-          in_x = out_x;
-          in_y = out_y;
         }
       }
     }
         /* if this point is candidate to weak interpolation, we       */
         /* interpolate it after all strong points have been processed */
 
-        if (  ( point->flags & AF_FLAG_WEAK_INTERPOLATION ) &&
-             !( point->flags & AF_FLAG_INFLECTION )         )
+        if ( ( point->flags & AF_FLAG_WEAK_INTERPOLATION ) )
           continue;
 
         if ( dim == AF_DIMENSION_VERT )
index 5f1507f..92101de 100644 (file)
@@ -4,7 +4,7 @@
 /*                                                                         */
 /*    Auto-fitter hinting routines (specification).                        */
 /*                                                                         */
-/*  Copyright 2003-2008, 2010-2012 by                                      */
+/*  Copyright 2003-2008, 2010-2012, 2014 by                                */
 /*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
 /*                                                                         */
 /*  This file is part of the FreeType project, and may only be used,       */
@@ -72,13 +72,9 @@ FT_BEGIN_HEADER
    *    `af_{cjk,latin,...}_hints_compute_segments' are the functions to
    *    find segments in an outline.
    *
-   *    A segment is a series of consecutive points that are approximately
-   *    aligned along a coordinate axis.  The analysis to do so is specific
-   *    to a writing system.
-   *
-   *    A segment must have at least two points, except in the case of
-   *    `fake' segments that are generated to hint metrics appropriately,
-   *    and which consist of a single point.
+   *    A segment is a series of at least two consecutive points that are
+   *    approximately aligned along a coordinate axis.  The analysis to do
+   *    so is specific to a writing system.
    *
    *
    *  Edges
@@ -148,7 +144,7 @@ FT_BEGIN_HEADER
    *    Serifs are detected by `af_{cjk,latin,...}_hint_edges'.
    *
    *    In comparison to a stem, a serif (as handled by the auto-hinter
-   *    module which takes care of the `latin' writing system) has
+   *    module that takes care of the `latin' writing system) has
    *
    *      best segment_1 = segment_2 && best segment_2 != segment_1
    *
@@ -178,19 +174,19 @@ FT_BEGIN_HEADER
    *
    *  Strong Points
    *
-   *    Experience has shown that points which are not part of an edge need
-   *    to be interpolated linearly between their two closest edges, even if
-   *    these are not part of the contour of those particular points.
-   *    Typical candidates for this are
+   *    Experience has shown that points not part of an edge need to be
+   *    interpolated linearly between their two closest edges, even if these
+   *    are not part of the contour of those particular points.  Typical
+   *    candidates for this are
    *
    *    - angle points (i.e., points where the `in' and `out' direction
    *      differ greatly)
    *
    *    - inflection points (i.e., where the `in' and `out' angles are the
    *      same, but the curvature changes sign) [currently, such points
-   *      aren't handled in the auto-hinter]
+   *      aren't handled specially in the auto-hinter]
    *
-   *    `af_glyph_hints_align_strong_points' is the function which takes
+   *    `af_glyph_hints_align_strong_points' is the function that takes
    *    care of such situations; it is equivalent to the TrueType `IP'
    *    hinting instruction.
    *
@@ -220,26 +216,12 @@ FT_BEGIN_HEADER
     AF_FLAG_CUBIC   = 1 << 1,
     AF_FLAG_CONTROL = AF_FLAG_CONIC | AF_FLAG_CUBIC,
 
-    /* point extremum flags */
-    AF_FLAG_EXTREMA_X = 1 << 2,
-    AF_FLAG_EXTREMA_Y = 1 << 3,
-
-    /* point roundness flags */
-    AF_FLAG_ROUND_X = 1 << 4,
-    AF_FLAG_ROUND_Y = 1 << 5,
-
     /* point touch flags */
-    AF_FLAG_TOUCH_X = 1 << 6,
-    AF_FLAG_TOUCH_Y = 1 << 7,
+    AF_FLAG_TOUCH_X = 1 << 2,
+    AF_FLAG_TOUCH_Y = 1 << 3,
 
     /* candidates for weak interpolation have this flag set */
-    AF_FLAG_WEAK_INTERPOLATION = 1 << 8,
-
-    /* all inflection points in the outline have this flag set */
-    AF_FLAG_INFLECTION = 1 << 9,
-
-    /* the current point is very near to another one */
-    AF_FLAG_NEAR = 1 << 10
+    AF_FLAG_WEAK_INTERPOLATION = 1 << 4
 
   } AF_Flags;
 
@@ -247,10 +229,11 @@ FT_BEGIN_HEADER
   /* edge hint flags */
   typedef enum  AF_Edge_Flags_
   {
-    AF_EDGE_NORMAL = 0,
-    AF_EDGE_ROUND  = 1 << 0,
-    AF_EDGE_SERIF  = 1 << 1,
-    AF_EDGE_DONE   = 1 << 2
+    AF_EDGE_NORMAL  = 0,
+    AF_EDGE_ROUND   = 1 << 0,
+    AF_EDGE_SERIF   = 1 << 1,
+    AF_EDGE_DONE    = 1 << 2,
+    AF_EDGE_NEUTRAL = 1 << 3  /* set if edge aligns to a neutral blue zone */
 
   } AF_Edge_Flags;
 
index e3a7742..36a3689 100644 (file)
         if ( error )
           goto Exit;
 
+        /*
+         *  We assume that the glyphs selected for the stem width
+         *  computation are `featureless' enough so that the linking
+         *  algorithm works fine without adjustments of its scoring
+         *  function.
+         */
         af_latin_hints_link_segments( hints,
+                                      0,
+                                      NULL,
                                       (AF_Dimension)dim );
 
         seg   = axhints->segments;
             have_flag = 1;
           }
 
+          if ( AF_LATIN_IS_NEUTRAL_BLUE( bs ) )
+          {
+            if ( have_flag )
+              FT_TRACE5(( ", " ));
+            FT_TRACE5(( "neutral" ));
+            have_flag = 1;
+          }
+
           if ( AF_LATIN_IS_X_HEIGHT_BLUE( bs ) )
           {
             if ( have_flag )
               FT_Int   last;
               FT_Bool  hit;
 
+              /* we intentionally declare these two variables        */
+              /* outside of the loop since various compilers emit    */
+              /* incorrect warning messages otherwise, talking about */
+              /* `possibly uninitialized variables'                  */
+              FT_Int  p_first = 0;            /* make compiler happy */
+              FT_Int  p_last  = 0;
+
               FT_Bool  left2right;
 
 
               {
                 FT_Bool  l2r;
                 FT_Pos   d;
-                FT_Int   p_first, p_last;
 
 
                 if ( !hit )
                       FT_CURVE_TAG( outline.tags[best_segment_last]  ) !=
                         FT_CURVE_TAG_ON                                   );
 
+          if ( round && AF_LATIN_IS_NEUTRAL_BLUE( bs ) )
+          {
+            /* only use flat segments for a neutral blue zone */
+            FT_TRACE5(( " (round, skipped)\n" ));
+            continue;
+          }
+
           FT_TRACE5(( " (%s)\n", round ? "round" : "flat" ));
         }
 
       blue->flags = 0;
       if ( AF_LATIN_IS_TOP_BLUE( bs ) )
         blue->flags |= AF_LATIN_BLUE_TOP;
+      if ( AF_LATIN_IS_NEUTRAL_BLUE( bs ) )
+        blue->flags |= AF_LATIN_BLUE_NEUTRAL;
 
       /*
        * The following flag is used later to adjust the y and x scales
           /* this is the start of a new segment! */
           segment_dir = (AF_Direction)point->out_dir;
 
-          /* clear all segment fields */
           error = af_axis_hints_new_segment( axis, memory, &segment );
           if ( error )
             goto Exit;
 
-          segment[0]        = seg0;
+          /* clear all segment fields */
+          segment[0] = seg0;
+
           segment->dir      = (FT_Char)segment_dir;
           min_pos = max_pos = point->u;
           segment->first    = point;
           segment->last     = point;
-          on_edge           = 1;
+
+          on_edge = 1;
         }
 
         point = point->next;
         FT_Pos    last_v  = last->v;
 
 
-        if ( first == last )
-          continue;
-
         if ( first_v < last_v )
         {
           AF_Point  p;
   }
 
 
-  /* Link segments to form stems and serifs. */
+  /* Link segments to form stems and serifs.  If `width_count' and      */
+  /* `widths' are non-zero, use them to fine-tune the scoring function. */
 
   FT_LOCAL_DEF( void )
   af_latin_hints_link_segments( AF_GlyphHints  hints,
+                                FT_UInt        width_count,
+                                AF_WidthRec*   widths,
                                 AF_Dimension   dim )
   {
     AF_AxisHints  axis          = &hints->axis[dim];
     AF_Segment    segments      = axis->segments;
     AF_Segment    segment_limit = segments + axis->num_segments;
-    FT_Pos        len_threshold, len_score;
+    FT_Pos        len_threshold, len_score, dist_score, max_width;
     AF_Segment    seg1, seg2;
 
 
+    if ( width_count )
+      max_width = widths[width_count - 1].org;
+    else
+      max_width = 0;
+
+    /* a heuristic value to set up a minimum value for overlapping */
     len_threshold = AF_LATIN_CONSTANT( hints->metrics, 8 );
     if ( len_threshold == 0 )
       len_threshold = 1;
 
+    /* a heuristic value to weight lengths */
     len_score = AF_LATIN_CONSTANT( hints->metrics, 6000 );
 
+    /* a heuristic value to weight distances (no call to    */
+    /* AF_LATIN_CONSTANT needed, since we work on multiples */
+    /* of the stem width)                                   */
+    dist_score = 3000;
+
     /* now compare each segment to the others */
     for ( seg1 = segments; seg1 < segment_limit; seg1++ )
     {
-      /* the fake segments are introduced to hint the metrics -- */
-      /* we must never link them to anything                     */
-      if ( seg1->dir != axis->major_dir || seg1->first == seg1->last )
+      if ( seg1->dir != axis->major_dir )
         continue;
 
       /* search for stems having opposite directions, */
         if ( seg1->dir + seg2->dir == 0 && pos2 > pos1 )
         {
           /* compute distance between the two segments */
-          FT_Pos  dist = pos2 - pos1;
-          FT_Pos  min  = seg1->min_coord;
-          FT_Pos  max  = seg1->max_coord;
-          FT_Pos  len, score;
+          FT_Pos  min = seg1->min_coord;
+          FT_Pos  max = seg1->max_coord;
+          FT_Pos  len;
 
 
           if ( min < seg2->min_coord )
             max = seg2->max_coord;
 
           /* compute maximum coordinate difference of the two segments */
+          /* (this is, how much they overlap)                          */
           len = max - min;
           if ( len >= len_threshold )
           {
-            /* small coordinate differences cause a higher score, and     */
-            /* segments with a greater distance cause a higher score also */
-            score = dist + len_score / len;
+            /*
+             *  The score is the sum of two demerits indicating the
+             *  `badness' of a fit, measured along the segments' main axis
+             *  and orthogonal to it, respectively.
+             *
+             *  o The less overlapping along the main axis, the worse it
+             *    is, causing a larger demerit.
+             *
+             *  o The nearer the orthogonal distance to a stem width, the
+             *    better it is, causing a smaller demerit.  For simplicity,
+             *    however, we only increase the demerit for values that
+             *    exceed the largest stem width.
+             */
+
+            FT_Pos  dist = pos2 - pos1;
+
+            FT_Pos  dist_demerit, score;
+
+
+            if ( max_width )
+            {
+              /* distance demerits are based on multiples of `max_width'; */
+              /* we scale by 1024 for getting more precision              */
+              FT_Pos  delta = ( dist << 10 ) / max_width - ( 1 << 10 );
+
+
+              if ( delta > 10000 )
+                dist_demerit = 32000;
+              else if ( delta > 0 )
+                dist_demerit = delta * delta / dist_score;
+              else
+                dist_demerit = 0;
+            }
+            else
+              dist_demerit = dist; /* default if no widths available */
+
+            score = dist_demerit + len_score / len;
 
             /* and we search for the smallest score */
-            /* of the sum of the two values         */
             if ( score < seg1->score )
             {
               seg1->score = score;
 
   FT_LOCAL_DEF( FT_Error )
   af_latin_hints_detect_features( AF_GlyphHints  hints,
+                                  FT_UInt        width_count,
+                                  AF_WidthRec*   widths,
                                   AF_Dimension   dim )
   {
     FT_Error  error;
     error = af_latin_hints_compute_segments( hints, dim );
     if ( !error )
     {
-      af_latin_hints_link_segments( hints, dim );
+      af_latin_hints_link_segments( hints, width_count, widths, dim );
 
       error = af_latin_hints_compute_edges( hints, dim );
     }
     for ( ; edge < edge_limit; edge++ )
     {
       FT_UInt   bb;
-      AF_Width  best_blue = NULL;
-      FT_Pos    best_dist;  /* initial threshold */
+      AF_Width  best_blue            = NULL;
+      FT_Bool   best_blue_is_neutral = 0;
+      FT_Pos    best_dist;                 /* initial threshold */
 
 
       /* compute the initial threshold as a fraction of the EM size */
       for ( bb = 0; bb < latin->blue_count; bb++ )
       {
         AF_LatinBlue  blue = latin->blues + bb;
-        FT_Bool       is_top_blue, is_major_dir;
+        FT_Bool       is_top_blue, is_neutral_blue, is_major_dir;
 
 
         /* skip inactive blue zones (i.e., those that are too large) */
         if ( !( blue->flags & AF_LATIN_BLUE_ACTIVE ) )
           continue;
 
-        /* if it is a top zone, check for right edges -- if it is a bottom */
-        /* zone, check for left edges                                      */
-        /*                                                                 */
-        /* of course, that's for TrueType                                  */
-        is_top_blue  = (FT_Byte)( ( blue->flags & AF_LATIN_BLUE_TOP ) != 0 );
-        is_major_dir = FT_BOOL( edge->dir == axis->major_dir );
-
-        /* if it is a top zone, the edge must be against the major    */
-        /* direction; if it is a bottom zone, it must be in the major */
-        /* direction                                                  */
-        if ( is_top_blue ^ is_major_dir )
+        /* if it is a top zone, check for right edges (against the major */
+        /* direction); if it is a bottom zone, check for left edges (in  */
+        /* the major direction) -- this assumes the TrueType convention  */
+        /* for the orientation of contours                               */
+        is_top_blue =
+          (FT_Byte)( ( blue->flags & AF_LATIN_BLUE_TOP ) != 0 );
+        is_neutral_blue =
+          (FT_Byte)( ( blue->flags & AF_LATIN_BLUE_NEUTRAL ) != 0);
+        is_major_dir =
+          FT_BOOL( edge->dir == axis->major_dir );
+
+        /* neutral blue zones are handled for both directions */
+        if ( is_top_blue ^ is_major_dir || is_neutral_blue )
         {
           FT_Pos  dist;
 
           dist = FT_MulFix( dist, scale );
           if ( dist < best_dist )
           {
-            best_dist = dist;
-            best_blue = &blue->ref;
+            best_dist            = dist;
+            best_blue            = &blue->ref;
+            best_blue_is_neutral = is_neutral_blue;
           }
 
           /* now compare it to the overshoot position and check whether */
           /* the edge is rounded, and whether the edge is over the      */
           /* reference position of a top zone, or under the reference   */
-          /* position of a bottom zone                                  */
-          if ( edge->flags & AF_EDGE_ROUND && dist != 0 )
+          /* position of a bottom zone (provided we don't have a        */
+          /* neutral blue zone)                                         */
+          if ( edge->flags & AF_EDGE_ROUND &&
+               dist != 0                   &&
+               !is_neutral_blue            )
           {
             FT_Bool  is_under_ref = FT_BOOL( edge->fpos < blue->ref.org );
 
               dist = FT_MulFix( dist, scale );
               if ( dist < best_dist )
               {
-                best_dist = dist;
-                best_blue = &blue->shoot;
+                best_dist            = dist;
+                best_blue            = &blue->shoot;
+                best_blue_is_neutral = is_neutral_blue;
               }
             }
           }
       }
 
       if ( best_blue )
+      {
         edge->blue_edge = best_blue;
+        if ( best_blue_is_neutral )
+          edge->flags |= AF_EDGE_NEUTRAL;
+      }
     }
   }
 
 
     FT_TRACE5(( "  LINK: edge %d (opos=%.2f) linked to %.2f,"
                 " dist was %.2f, now %.2f\n",
-                stem_edge-hints->axis[dim].edges, stem_edge->opos / 64.0,
+                stem_edge - hints->axis[dim].edges, stem_edge->opos / 64.0,
                 stem_edge->pos / 64.0, dist / 64.0, fitted_width / 64.0 ));
   }
 
         if ( edge->flags & AF_EDGE_DONE )
           continue;
 
-        blue  = edge->blue_edge;
         edge1 = NULL;
         edge2 = edge->link;
 
+        /*
+         *  If a stem contains both a neutral and a non-neutral blue zone,
+         *  skip the neutral one.  Otherwise, outlines with different
+         *  directions might be incorrectly aligned at the same vertical
+         *  position.
+         *
+         *  If we have two neutral blue zones, skip one of them.
+         *
+         */
+        if ( edge->blue_edge && edge2 && edge2->blue_edge )
+        {
+          FT_Byte  neutral  = edge->flags  & AF_EDGE_NEUTRAL;
+          FT_Byte  neutral2 = edge2->flags & AF_EDGE_NEUTRAL;
+
+
+          if ( ( neutral && neutral2 ) || neutral2 )
+          {
+            edge2->blue_edge = NULL;
+            edge2->flags    &= ~AF_EDGE_NEUTRAL;
+          }
+          else if ( neutral )
+          {
+            edge->blue_edge = NULL;
+            edge->flags    &= ~AF_EDGE_NEUTRAL;
+          }
+        }
+
+        blue = edge->blue_edge;
         if ( blue )
           edge1 = edge;
 
-        /* flip edges if the other stem is aligned to a blue zone */
+        /* flip edges if the other edge is aligned to a blue zone */
         else if ( edge2 && edge2->blue_edge )
         {
           blue  = edge2->blue_edge;
       /* this should not happen, but it's better to be safe */
       if ( edge2->blue_edge )
       {
-        FT_TRACE5(( "  ASSERTION FAILED for edge %d\n", edge2-edges ));
+        FT_TRACE5(( "  ASSERTION FAILED for edge %d\n", edge2 - edges ));
 
         af_latin_align_linked_edge( hints, dim, edge2, edge );
         edge->flags |= AF_EDGE_DONE;
     FT_Error  error;
     int       dim;
 
+    AF_LatinAxis  axis;
+
 
     error = af_glyph_hints_reload( hints, outline );
     if ( error )
     if ( AF_HINTS_DO_HORIZONTAL( hints ) )
 #endif
     {
-      error = af_latin_hints_detect_features( hints, AF_DIMENSION_HORZ );
+      axis  = &metrics->axis[AF_DIMENSION_HORZ];
+      error = af_latin_hints_detect_features( hints,
+                                              axis->width_count,
+                                              axis->widths,
+                                              AF_DIMENSION_HORZ );
       if ( error )
         goto Exit;
     }
 
     if ( AF_HINTS_DO_VERTICAL( hints ) )
     {
-      error = af_latin_hints_detect_features( hints, AF_DIMENSION_VERT );
+      axis  = &metrics->axis[AF_DIMENSION_VERT];
+      error = af_latin_hints_detect_features( hints,
+                                              axis->width_count,
+                                              axis->widths,
+                                              AF_DIMENSION_VERT );
       if ( error )
         goto Exit;
 
index a958af3..2c0bfca 100644 (file)
@@ -5,7 +5,7 @@
 /*    Auto-fitter hinting routines for latin writing system                */
 /*    (specification).                                                     */
 /*                                                                         */
-/*  Copyright 2003-2007, 2009, 2011-2013 by                                */
+/*  Copyright 2003-2007, 2009, 2011-2014 by                                */
 /*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
 /*                                                                         */
 /*  This file is part of the FreeType project, and may only be used,       */
@@ -53,6 +53,8 @@ FT_BEGIN_HEADER
 
 #define AF_LATIN_IS_TOP_BLUE( b ) \
           ( (b)->properties & AF_BLUE_PROPERTY_LATIN_TOP )
+#define AF_LATIN_IS_NEUTRAL_BLUE( b ) \
+          ( (b)->properties & AF_BLUE_PROPERTY_LATIN_NEUTRAL )
 #define AF_LATIN_IS_X_HEIGHT_BLUE( b ) \
           ( (b)->properties & AF_BLUE_PROPERTY_LATIN_X_HEIGHT )
 #define AF_LATIN_IS_LONG_BLUE( b ) \
@@ -63,10 +65,11 @@ FT_BEGIN_HEADER
 
   enum
   {
-    AF_LATIN_BLUE_ACTIVE     = 1 << 0,  /* set if zone height is <= 3/4px */
-    AF_LATIN_BLUE_TOP        = 1 << 1,  /* result of AF_LATIN_IS_TOP_BLUE */
-    AF_LATIN_BLUE_ADJUSTMENT = 1 << 2,  /* used for scale adjustment      */
-                                        /* optimization                   */
+    AF_LATIN_BLUE_ACTIVE     = 1 << 0, /* set if zone height is <= 3/4px   */
+    AF_LATIN_BLUE_TOP        = 1 << 1, /* set if we have a top blue zone   */
+    AF_LATIN_BLUE_NEUTRAL    = 1 << 2, /* set if we have neutral blue zone */
+    AF_LATIN_BLUE_ADJUSTMENT = 1 << 3, /* used for scale adjustment        */
+                                       /* optimization                     */
     AF_LATIN_BLUE_FLAG_MAX
   };
 
@@ -169,6 +172,8 @@ FT_BEGIN_HEADER
 
   FT_LOCAL( void )
   af_latin_hints_link_segments( AF_GlyphHints  hints,
+                                FT_UInt        width_count,
+                                AF_WidthRec*   widths,
                                 AF_Dimension   dim );
 
   FT_LOCAL( FT_Error )
@@ -177,6 +182,8 @@ FT_BEGIN_HEADER
 
   FT_LOCAL( FT_Error )
   af_latin_hints_detect_features( AF_GlyphHints  hints,
+                                  FT_UInt        width_count,
+                                  AF_WidthRec*   widths,
                                   AF_Dimension   dim );
 
 /* */
index 930fa98..07590b3 100644 (file)
@@ -4,7 +4,7 @@
 /*                                                                         */
 /*    Auto-fitter hinting routines for latin writing system (body).        */
 /*                                                                         */
-/*  Copyright 2003-2013 by                                                 */
+/*  Copyright 2003-2014 by                                                 */
 /*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
 /*                                                                         */
 /*  This file is part of the FreeType project, and may only be used,       */
         FT_Pos    last_v  = last->v;
 
 
-        if ( first == last )
-          continue;
-
         if ( first_v < last_v )
         {
           p = first->prev;
 #ifdef AF_SORT_SEGMENTS
     for ( seg1 = segments; seg1 < segment_mid; seg1++ )
     {
-      if ( seg1->dir != axis->major_dir || seg1->first == seg1->last )
+      if ( seg1->dir != axis->major_dir )
         continue;
 
       for ( seg2 = segment_mid; seg2 < segment_limit; seg2++ )
     /* now compare each segment to the others */
     for ( seg1 = segments; seg1 < segment_limit; seg1++ )
     {
-      /* the fake segments are introduced to hint the metrics -- */
-      /* we must never link them to anything                     */
-      if ( seg1->dir != axis->major_dir || seg1->first == seg1->last )
+      if ( seg1->dir != axis->major_dir )
         continue;
 
       for ( seg2 = segments; seg2 < segment_limit; seg2++ )
 
         edge->first    = seg;
         edge->last     = seg;
-        edge->fpos     = seg->pos;
         edge->dir      = seg->dir;
-        edge->opos     = edge->pos = FT_MulFix( seg->pos, scale );
+        edge->fpos     = seg->pos;
+        edge->opos     = FT_MulFix( seg->pos, scale );
+        edge->pos      = edge->opos;
         seg->edge_next = seg;
       }
       else
index 0fa3c12..fb15c87 100644 (file)
       loader->trans_delta  = internal->glyph_delta;
 
       inverse = loader->trans_matrix;
-      FT_Matrix_Invert( &inverse );
-      FT_Vector_Transform( &loader->trans_delta, &inverse );
+      if ( !FT_Matrix_Invert( &inverse ) )
+        FT_Vector_Transform( &loader->trans_delta, &inverse );
     }
 
     switch ( slot->format )
 
 
     if ( !size )
-      return FT_THROW( Invalid_Argument );
+      return FT_THROW( Invalid_Size_Handle );
 
     FT_ZERO( &scaler );
 
index 73bf832..641e03e 100644 (file)
@@ -55,7 +55,7 @@
 
 
     if ( !face )
-      return FT_THROW( Invalid_Argument );
+      return FT_THROW( Invalid_Face_Handle );
 
     globals = (AF_FaceGlobals)face->autohint.data;
     if ( !globals )
         AF_StyleClass  style_class = AF_STYLE_CLASSES_GET[ss];
 
 
-        if ( style_class->script == *fallback_script      &&
-             style_class->coverage == AF_COVERAGE_DEFAULT )
+        if ( (FT_UInt)style_class->script == *fallback_script &&
+             style_class->coverage == AF_COVERAGE_DEFAULT     )
         {
           module->fallback_style = ss;
           break;
   af_get_interface( FT_Module    module,
                     const char*  module_interface )
   {
-    /* AF_SERVICES_GET derefers `library' in PIC mode */
+    /* AF_SERVICES_GET dereferences `library' in PIC mode */
 #ifdef FT_CONFIG_OPTION_PIC
     FT_Library  library;
 
index 3d919b5..b2c504d 100644 (file)
 
   const AF_Script_UniRangeRec  af_cyrl_uniranges[] =
   {
-    AF_UNIRANGE_REC(  0x0400UL,  0x04FFUL ),  /* Cyrillic */
+    AF_UNIRANGE_REC(  0x0400UL,  0x04FFUL ),  /* Cyrillic            */
     AF_UNIRANGE_REC(  0x0500UL,  0x052FUL ),  /* Cyrillic Supplement */
     AF_UNIRANGE_REC(  0x2DE0UL,  0x2DFFUL ),  /* Cyrillic Extended-A */
     AF_UNIRANGE_REC(  0xA640UL,  0xA69FUL ),  /* Cyrillic Extended-B */
     AF_UNIRANGE_REC(       0UL,       0UL )
   };
 
+  /* there are some characters in the Devanagari Unicode block that are    */
+  /* generic to Indic scripts; we omit them so that their presence doesn't */
+  /* trigger Devanagari                                                    */
+
+  const AF_Script_UniRangeRec  af_deva_uniranges[] =
+  {
+    AF_UNIRANGE_REC(  0x0900UL,  0x093BUL ),  /* Devanagari       */
+    /* omitting U+093C nukta */
+    AF_UNIRANGE_REC(  0x093DUL,  0x0950UL ),
+    /* omitting U+0951 udatta, U+0952 anudatta */
+    AF_UNIRANGE_REC(  0x0953UL,  0x0963UL ),
+    /* omitting U+0964 danda, U+0965 double danda */
+    AF_UNIRANGE_REC(  0x0966UL,  0x097FUL ),
+    AF_UNIRANGE_REC(  0x20B9UL,  0x20B9UL ),  /* (new) Rupee sign */
+    AF_UNIRANGE_REC(       0UL,       0UL )
+  };
+
   const AF_Script_UniRangeRec  af_grek_uniranges[] =
   {
     AF_UNIRANGE_REC(  0x0370UL,  0x03FFUL ),  /* Greek and Coptic */
-    AF_UNIRANGE_REC(  0x1F00UL,  0x1FFFUL ),  /* Greek Extended */
+    AF_UNIRANGE_REC(  0x1F00UL,  0x1FFFUL ),  /* Greek Extended   */
     AF_UNIRANGE_REC(       0UL,       0UL )
   };
 
   const AF_Script_UniRangeRec  af_hebr_uniranges[] =
   {
-    AF_UNIRANGE_REC(  0x0590UL,  0x05FFUL ),  /* Hebrew */
+    AF_UNIRANGE_REC(  0x0590UL,  0x05FFUL ),  /* Hebrew                          */
     AF_UNIRANGE_REC(  0xFB1DUL,  0xFB4FUL ),  /* Alphab. Present. Forms (Hebrew) */
     AF_UNIRANGE_REC(       0UL,       0UL )
   };
 
   const AF_Script_UniRangeRec  af_latn_uniranges[] =
   {
-    AF_UNIRANGE_REC(  0x0020UL,  0x007FUL ),  /* Basic Latin (no control chars) */
-    AF_UNIRANGE_REC(  0x00A0UL,  0x00FFUL ),  /* Latin-1 Supplement (no control chars) */
-    AF_UNIRANGE_REC(  0x0100UL,  0x017FUL ),  /* Latin Extended-A */
-    AF_UNIRANGE_REC(  0x0180UL,  0x024FUL ),  /* Latin Extended-B */
-    AF_UNIRANGE_REC(  0x0250UL,  0x02AFUL ),  /* IPA Extensions */
-    AF_UNIRANGE_REC(  0x02B0UL,  0x02FFUL ),  /* Spacing Modifier Letters */
-    AF_UNIRANGE_REC(  0x0300UL,  0x036FUL ),  /* Combining Diacritical Marks */
-    AF_UNIRANGE_REC(  0x1D00UL,  0x1D7FUL ),  /* Phonetic Extensions */
-    AF_UNIRANGE_REC(  0x1D80UL,  0x1DBFUL ),  /* Phonetic Extensions Supplement */
+    AF_UNIRANGE_REC(  0x0020UL,  0x007FUL ),  /* Basic Latin (no control chars)         */
+    AF_UNIRANGE_REC(  0x00A0UL,  0x00FFUL ),  /* Latin-1 Supplement (no control chars)  */
+    AF_UNIRANGE_REC(  0x0100UL,  0x017FUL ),  /* Latin Extended-A                       */
+    AF_UNIRANGE_REC(  0x0180UL,  0x024FUL ),  /* Latin Extended-B                       */
+    AF_UNIRANGE_REC(  0x0250UL,  0x02AFUL ),  /* IPA Extensions                         */
+    AF_UNIRANGE_REC(  0x02B0UL,  0x02FFUL ),  /* Spacing Modifier Letters               */
+    AF_UNIRANGE_REC(  0x0300UL,  0x036FUL ),  /* Combining Diacritical Marks            */
+    AF_UNIRANGE_REC(  0x1D00UL,  0x1D7FUL ),  /* Phonetic Extensions                    */
+    AF_UNIRANGE_REC(  0x1D80UL,  0x1DBFUL ),  /* Phonetic Extensions Supplement         */
     AF_UNIRANGE_REC(  0x1DC0UL,  0x1DFFUL ),  /* Combining Diacritical Marks Supplement */
-    AF_UNIRANGE_REC(  0x1E00UL,  0x1EFFUL ),  /* Latin Extended Additional */
-    AF_UNIRANGE_REC(  0x2000UL,  0x206FUL ),  /* General Punctuation */
-    AF_UNIRANGE_REC(  0x2070UL,  0x209FUL ),  /* Superscripts and Subscripts */
-    AF_UNIRANGE_REC(  0x20A0UL,  0x20CFUL ),  /* Currency Symbols */
-    AF_UNIRANGE_REC(  0x2150UL,  0x218FUL ),  /* Number Forms */
-    AF_UNIRANGE_REC(  0x2460UL,  0x24FFUL ),  /* Enclosed Alphanumerics */
-    AF_UNIRANGE_REC(  0x2C60UL,  0x2C7FUL ),  /* Latin Extended-C */
-    AF_UNIRANGE_REC(  0x2E00UL,  0x2E7FUL ),  /* Supplemental Punctuation */
-    AF_UNIRANGE_REC(  0xA720UL,  0xA7FFUL ),  /* Latin Extended-D */
-    AF_UNIRANGE_REC(  0xFB00UL,  0xFB06UL ),  /* Alphab. Present. Forms (Latin Ligs) */
-    AF_UNIRANGE_REC( 0x1D400UL, 0x1D7FFUL ),  /* Mathematical Alphanumeric Symbols */
-    AF_UNIRANGE_REC( 0x1F100UL, 0x1F1FFUL ),  /* Enclosed Alphanumeric Supplement */
+    AF_UNIRANGE_REC(  0x1E00UL,  0x1EFFUL ),  /* Latin Extended Additional              */
+    AF_UNIRANGE_REC(  0x2000UL,  0x206FUL ),  /* General Punctuation                    */
+    AF_UNIRANGE_REC(  0x2070UL,  0x209FUL ),  /* Superscripts and Subscripts            */
+    AF_UNIRANGE_REC(  0x20A0UL,  0x20B8UL ),  /* Currency Symbols ...                   */
+    AF_UNIRANGE_REC(  0x20BAUL,  0x20CFUL ),  /* ... except new Rupee sign              */
+    AF_UNIRANGE_REC(  0x2150UL,  0x218FUL ),  /* Number Forms                           */
+    AF_UNIRANGE_REC(  0x2460UL,  0x24FFUL ),  /* Enclosed Alphanumerics                 */
+    AF_UNIRANGE_REC(  0x2C60UL,  0x2C7FUL ),  /* Latin Extended-C                       */
+    AF_UNIRANGE_REC(  0x2E00UL,  0x2E7FUL ),  /* Supplemental Punctuation               */
+    AF_UNIRANGE_REC(  0xA720UL,  0xA7FFUL ),  /* Latin Extended-D                       */
+    AF_UNIRANGE_REC(  0xFB00UL,  0xFB06UL ),  /* Alphab. Present. Forms (Latin Ligs)    */
+    AF_UNIRANGE_REC( 0x1D400UL, 0x1D7FFUL ),  /* Mathematical Alphanumeric Symbols      */
+    AF_UNIRANGE_REC( 0x1F100UL, 0x1F1FFUL ),  /* Enclosed Alphanumeric Supplement       */
     AF_UNIRANGE_REC(       0UL,       0UL )
   };
 
     AF_UNIRANGE_REC( 0UL, 0UL )
   };
 
-#ifdef AF_CONFIG_OPTION_INDIC
-
-  const AF_Script_UniRangeRec  af_beng_uniranges[] =
+  const AF_Script_UniRangeRec  af_telu_uniranges[] =
   {
-    AF_UNIRANGE_REC(  0x0980UL,  0x09FFUL ),  /* Bengali */
+    AF_UNIRANGE_REC(  0x0C00UL,  0x0C7FUL ),  /* Telugu */
     AF_UNIRANGE_REC(       0UL,       0UL )
   };
 
-  const AF_Script_UniRangeRec  af_deva_uniranges[] =
+#ifdef AF_CONFIG_OPTION_INDIC
+
+  const AF_Script_UniRangeRec  af_beng_uniranges[] =
   {
-    AF_UNIRANGE_REC(  0x0900UL,  0x097FUL ),  /* Devanagari */
+    AF_UNIRANGE_REC(  0x0980UL,  0x09FFUL ),  /* Bengali */
     AF_UNIRANGE_REC(       0UL,       0UL )
   };
 
     AF_UNIRANGE_REC(       0UL,       0UL )
   };
 
-  const AF_Script_UniRangeRec  af_telu_uniranges[] =
-  {
-    AF_UNIRANGE_REC(  0x0C00UL,  0x0C7FUL ),  /* Telugu */
-    AF_UNIRANGE_REC(       0UL,       0UL )
-  };
-
   const AF_Script_UniRangeRec  af_tibt_uniranges[] =
   {
     AF_UNIRANGE_REC(  0x0F00UL,  0x0FFFUL ),  /* Tibetan */
index ae20932..efe8754 100644 (file)
           HB_SCRIPT_CYRILLIC,
           0x43E, 0x41E, 0x0 ) /* оО */
 
+  SCRIPT( deva, DEVA,
+          "Devanagari",
+          HB_SCRIPT_DEVANAGARI,
+          0x920, 0x935, 0x91F ) /* ठ व ट */
+
   SCRIPT( grek, GREK,
           "Greek",
           HB_SCRIPT_GREEK,
           HB_SCRIPT_INVALID,
           0x0, 0x0, 0x0 )
 
+  /* there are no simple forms for letters; we thus use two digit shapes */
+  SCRIPT( telu, TELU,
+          "Telugu",
+          HB_SCRIPT_TELUGU,
+          0xC66, 0xC67, 0x0 ) /* ౦ ౧ */
+
 #ifdef AF_CONFIG_OPTION_INDIC
 
   SCRIPT( beng, BENG,
           HB_SCRIPT_BENGALI,
           'o', 0x0, 0x0 ) /* XXX */
 
-  SCRIPT( deva, DEVA,
-          "Devanagari",
-          HB_SCRIPT_DEVANAGARI,
-          'o', 0x0, 0x0 ) /* XXX */
-
   SCRIPT( gujr, GUJR,
           "Gujarati",
           HB_SCRIPT_GUJARATI,
           HB_SCRIPT_TAMIL,
           'o', 0x0, 0x0 ) /* XXX */
 
-  SCRIPT( telu, TELU,
-          "Telugu",
-          HB_SCRIPT_TELUGU,
-          'o', 0x0, 0x0 ) /* XXX */
-
   SCRIPT( tibt, TIBT,
           "Tibetan",
           HB_SCRIPT_TIBETAN,
index 429da76..f14d354 100644 (file)
@@ -81,7 +81,9 @@
                        DEFAULT )
 
   META_STYLE_LATIN( cyrl, CYRL, "Cyrillic" )
+
   META_STYLE_LATIN( grek, GREK, "Greek" )
+
   STYLE( hebr_dflt, HEBR_DFLT,
          "Hebrew default style",
          AF_WRITING_SYSTEM_LATIN,
          AF_COVERAGE_DEFAULT )
   META_STYLE_LATIN( latn, LATN, "Latin" )
 
+  STYLE( deva_dflt, DEVA_DFLT,
+         "Devanagari default style",
+         AF_WRITING_SYSTEM_LATIN,
+         AF_SCRIPT_DEVA,
+         AF_BLUE_STRINGSET_DEVA,
+         AF_COVERAGE_DEFAULT )
+
 #ifdef FT_OPTION_AUTOFIT2
   STYLE( ltn2_dflt, LTN2_DFLT,
          "Latin 2 default style",
          (AF_Blue_Stringset)0,
          AF_COVERAGE_DEFAULT )
 
+  STYLE( telu_dflt, TELU_DFLT,
+         "Telugu default style",
+         AF_WRITING_SYSTEM_LATIN,
+         AF_SCRIPT_TELU,
+         AF_BLUE_STRINGSET_TELU,
+         AF_COVERAGE_DEFAULT )
+
 #ifdef AF_CONFIG_OPTION_INDIC
 
   /* no blue stringset support for the Indic writing system yet */
                  AF_COVERAGE_DEFAULT )
 
   STYLE_DEFAULT_INDIC( beng, BENG, "Bengali" )
-  STYLE_DEFAULT_INDIC( deva, DEVA, "Devanagari" )
   STYLE_DEFAULT_INDIC( gujr, GUJR, "Gujarati" )
   STYLE_DEFAULT_INDIC( guru, GURU, "Gurmukhi" )
   STYLE_DEFAULT_INDIC( knda, KNDA, "Kannada" )
   STYLE_DEFAULT_INDIC( sund, SUND, "Sundanese" )
   STYLE_DEFAULT_INDIC( sylo, SYLO, "Syloti Nagri" )
   STYLE_DEFAULT_INDIC( taml, TAML, "Tamil" )
-  STYLE_DEFAULT_INDIC( telu, TELU, "Telugu" )
   STYLE_DEFAULT_INDIC( tibt, TIBT, "Tibetan" )
 
 #endif /* AF_CONFIG_OPTION_INDIC */
index 11fb743..a705cef 100644 (file)
      * (this is, not a single character is covered), we skip this coverage.
      *
      */
+    if ( style_class->coverage != AF_COVERAGE_DEFAULT )
     {
       AF_Blue_Stringset         bss = style_class->blue_stringset;
       const AF_Blue_StringRec*  bs  = &af_blue_stringsets[bss];
      * out whether a glyph gets shifted vertically, but this is something I
      * would like to avoid if not really necessary.
      *
+     * Note that we don't follow this logic for the default coverage.
+     * Complex scripts like Devanagari have mandatory GPOS features to
+     * position many glyph elements, using mark-to-base or mark-to-ligature
+     * tables; the number of glyphs missed due to condition (b) would be far
+     * too large.
+     *
      */
-    hb_set_subtract( gsub_glyphs, gpos_glyphs );
+    if ( style_class->coverage != AF_COVERAGE_DEFAULT )
+      hb_set_subtract( gsub_glyphs, gpos_glyphs );
 
 #ifdef FT_DEBUG_LEVEL_TRACE
     FT_TRACE4(( "  glyphs without GPOS data (`*' means already assigned)" ));
       count++;
 #endif
 
+      /* glyph indices returned by `hb_ot_layout_lookup_collect_glyphs' */
+      /* can be arbitrary: some fonts use fake indices for processing   */
+      /* internal to GSUB or GPOS, which is fully valid                 */
+      if ( idx >= (hb_codepoint_t)globals->glyph_count )
+        continue;
+
       if ( gstyles[idx] == AF_STYLE_UNASSIGNED )
         gstyles[idx] = (FT_Byte)style_class->style;
 #ifdef FT_DEBUG_LEVEL_TRACE
index 5207847..18884ef 100644 (file)
@@ -4,7 +4,7 @@
 /*                                                                         */
 /*    Quick computation of advance widths (body).                          */
 /*                                                                         */
-/*  Copyright 2008, 2009, 2011, 2013 by                                    */
+/*  Copyright 2008, 2009, 2011, 2013, 2014 by                              */
 /*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
 /*                                                                         */
 /*  This file is part of the FreeType project, and may only be used,       */
@@ -80,6 +80,9 @@
     if ( !face )
       return FT_THROW( Invalid_Face_Handle );
 
+    if ( !padvance )
+      return FT_THROW( Invalid_Argument );
+
     if ( gindex >= (FT_UInt)face->num_glyphs )
       return FT_THROW( Invalid_Glyph_Index );
 
     if ( !face )
       return FT_THROW( Invalid_Face_Handle );
 
+    if ( !padvances )
+      return FT_THROW( Invalid_Argument );
+
     num = (FT_UInt)face->num_glyphs;
     end = start + count;
     if ( start >= num || end < start || end > num )
index 8d3f383..f9a1751 100644 (file)
@@ -4,7 +4,7 @@
 /*                                                                         */
 /*    FreeType bbox computation (body).                                    */
 /*                                                                         */
-/*  Copyright 1996-2002, 2004, 2006, 2010, 2013 by                         */
+/*  Copyright 1996-2002, 2004, 2006, 2010, 2013, 2014 by                   */
 /*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
 /*                                                                         */
 /*  This file is part of the FreeType project, and may only be used        */
   } TBBox_Rec;
 
 
+#define FT_UPDATE_BBOX( p, bbox ) \
+  FT_BEGIN_STMNT                  \
+    if ( p->x < bbox.xMin )       \
+      bbox.xMin = p->x;           \
+    if ( p->x > bbox.xMax )       \
+      bbox.xMax = p->x;           \
+    if ( p->y < bbox.yMin )       \
+      bbox.yMin = p->y;           \
+    if ( p->y > bbox.yMax )       \
+      bbox.yMax = p->y;           \
+  FT_END_STMNT
+
+#define CHECK_X( p, bbox )                         \
+          ( p->x < bbox.xMin || p->x > bbox.xMax )
+
+#define CHECK_Y( p, bbox )                         \
+          ( p->y < bbox.yMin || p->y > bbox.yMax )
+
+
   /*************************************************************************/
   /*                                                                       */
   /* <Function>                                                            */
   /*    BBox_Move_To                                                       */
   /*                                                                       */
   /* <Description>                                                         */
-  /*    This function is used as a `move_to' and `line_to' emitter during  */
+  /*    This function is used as a `move_to' emitter during                */
   /*    FT_Outline_Decompose().  It simply records the destination point   */
-  /*    in `user->last'; no further computations are necessary since we    */
-  /*    use the cbox as the starting bbox which must be refined.           */
+  /*    in `user->last'. We also update bbox in case contour starts with   */
+  /*    an implicit `on' point.                                            */
   /*                                                                       */
   /* <Input>                                                               */
   /*    to   :: A pointer to the destination vector.                       */
   BBox_Move_To( FT_Vector*  to,
                 TBBox_Rec*  user )
   {
+    FT_UPDATE_BBOX( to, user->bbox );
+
     user->last = *to;
 
     return 0;
   }
 
 
-#define CHECK_X( p, bbox )  \
-          ( p->x < bbox.xMin || p->x > bbox.xMax )
+  /*************************************************************************/
+  /*                                                                       */
+  /* <Function>                                                            */
+  /*    BBox_Line_To                                                       */
+  /*                                                                       */
+  /* <Description>                                                         */
+  /*    This function is used as a `line_to' emitter during                */
+  /*    FT_Outline_Decompose().  It simply records the destination point   */
+  /*    in `user->last'; no further computations are necessary because     */
+  /*    bbox already contains both explicit ends of the line segment.      */
+  /*                                                                       */
+  /* <Input>                                                               */
+  /*    to   :: A pointer to the destination vector.                       */
+  /*                                                                       */
+  /* <InOut>                                                               */
+  /*    user :: A pointer to the current walk context.                     */
+  /*                                                                       */
+  /* <Return>                                                              */
+  /*    Always 0.  Needed for the interface only.                          */
+  /*                                                                       */
+  static int
+  BBox_Line_To( FT_Vector*  to,
+                TBBox_Rec*  user )
+  {
+    user->last = *to;
 
-#define CHECK_Y( p, bbox )  \
-          ( p->y < bbox.yMin || p->y > bbox.yMax )
+    return 0;
+  }
 
 
   /*************************************************************************/
                  FT_Vector*  to,
                  TBBox_Rec*  user )
   {
-    /* we don't need to check `to' since it is always an `on' point, thus */
-    /* within the bbox                                                    */
+    /* in case `to' is implicit and not included in bbox yet */
+    FT_UPDATE_BBOX( to, user->bbox );
 
     if ( CHECK_X( control, user->bbox ) )
       BBox_Conic_Check( user->last.x,
   /*    max :: The address of the current maximum.                         */
   /*                                                                       */
   static FT_Pos
-  update_cubic_max( FT_Pos  q1,
-                    FT_Pos  q2,
-                    FT_Pos  q3,
-                    FT_Pos  q4,
-                    FT_Pos  max )
+  cubic_peak( FT_Pos  q1,
+              FT_Pos  q2,
+              FT_Pos  q3,
+              FT_Pos  q4 )
   {
-    /* for a cubic segment to possibly reach new maximum, at least */
-    /* one of its off-points must stay above the current value     */
-    while ( q2 > max || q3 > max )
+    FT_Pos  peak = 0;
+    FT_Int  shift;
+
+    /* This function finds a peak of a cubic segment if it is above 0    */
+    /* using iterative bisection of the segment, or returns 0.           */
+    /* The fixed-point arithmetic of bisection is inherently stable      */
+    /* but may loose accuracy in the two lowest bits.  To compensate,    */
+    /* we upscale the segment if there is room.  Large values may need   */
+    /* to be downscaled to avoid overflows during bisection.             */
+    /* It is called with either q2 or q3 positive, which is necessary    */
+    /* for the peak to exist and avoids undefined FT_MSB.                */
+
+    shift = 27 -
+      FT_MSB( FT_ABS( q1 ) | FT_ABS( q2 ) | FT_ABS( q3 ) | FT_ABS( q4 ) );
+
+    if ( shift > 0 )
+    {
+      /* upscaling too much just wastes time */
+      if ( shift > 2 )
+        shift = 2;
+
+      q1 <<=  shift;
+      q2 <<=  shift;
+      q3 <<=  shift;
+      q4 <<=  shift;
+    }
+    else
+    {
+      q1 >>= -shift;
+      q2 >>= -shift;
+      q3 >>= -shift;
+      q4 >>= -shift;
+    }
+
+    /* for a peak to exist above 0, the cubic segment must have */
+    /* at least one of its control off-points above 0.          */
+    while ( q2 > 0 || q3 > 0 )
     {
       /* determine which half contains the maximum and split */
       if ( q1 + q2 > q3 + q4 ) /* first half */
       /* check whether either end reached the maximum */
       if ( q1 == q2 && q1 >= q3 )
       {
-        max = q1;
+        peak = q1;
         break;
       }
       if ( q3 == q4 && q2 <= q4 )
       {
-        max = q4;
+        peak = q4;
         break;
       }
     }
 
-    return max;
+    if ( shift > 0 )
+      peak >>=  shift;
+    else
+      peak <<= -shift;
+
+    return peak;
   }
 
 
                     FT_Pos*  min,
                     FT_Pos*  max )
   {
-    FT_Pos  nmin, nmax;
-    FT_Int  shift;
-
-
     /* This function is only called when a control off-point is outside  */
-    /* the bbox that contains all on-points.  It finds a local extremum  */
-    /* within the segment using iterative bisection of the segment.      */
-    /* The fixed-point arithmetic of bisection is inherently stable      */
-    /* but may loose accuracy in the two lowest bits.  To compensate,    */
-    /* we upscale the segment if there is room.  Large values may need   */
-    /* to be downscaled to avoid overflows during bisection.             */
-    /* The control off-point outside the bbox is likely to have the top  */
-    /* absolute value among arguments.                                   */
-
-    shift = 27 - FT_MSB( FT_ABS( p2 ) | FT_ABS( p3 ) );
-
-    if ( shift > 0 )
-    {
-      /* upscaling too much just wastes time */
-      if ( shift > 2 )
-        shift = 2;
-
-      p1 <<=  shift;
-      p2 <<=  shift;
-      p3 <<=  shift;
-      p4 <<=  shift;
-      nmin = *min << shift;
-      nmax = *max << shift;
-    }
-    else
-    {
-      p1 >>= -shift;
-      p2 >>= -shift;
-      p3 >>= -shift;
-      p4 >>= -shift;
-      nmin = *min >> -shift;
-      nmax = *max >> -shift;
-    }
+    /* the bbox that contains all on-points.  So at least one of the     */
+    /* conditions below holds and cubic_peak is called with at least one */
+    /* non-zero argument.                                                */
 
-    nmax =  update_cubic_max(  p1,  p2,  p3,  p4,  nmax );
+    if ( p2 > *max || p3 > *max )
+      *max += cubic_peak( p1 - *max, p2 - *max, p3 - *max, p4 - *max );
 
     /* now flip the signs to update the minimum */
-    nmin = -update_cubic_max( -p1, -p2, -p3, -p4, -nmin );
-
-    if ( shift > 0 )
-    {
-      nmin >>=  shift;
-      nmax >>=  shift;
-    }
-    else
-    {
-      nmin <<= -shift;
-      nmax <<= -shift;
-    }
-
-    if ( nmin < *min )
-      *min = nmin;
-    if ( nmax > *max )
-      *max = nmax;
+    if ( p2 < *min || p3 < *min )
+      *min -= cubic_peak( *min - p1, *min - p2, *min - p3, *min - p4 );
   }
 
 
     return 0;
   }
 
-FT_DEFINE_OUTLINE_FUNCS(bbox_interface,
+
+  FT_DEFINE_OUTLINE_FUNCS(bbox_interface,
     (FT_Outline_MoveTo_Func) BBox_Move_To,
-    (FT_Outline_LineTo_Func) BBox_Move_To,
+    (FT_Outline_LineTo_Func) BBox_Line_To,
     (FT_Outline_ConicTo_Func)BBox_Conic_To,
     (FT_Outline_CubicTo_Func)BBox_Cubic_To,
     0, 0
   )
 
+
   /* documentation is in ftbbox.h */
 
   FT_EXPORT_DEF( FT_Error )
   FT_Outline_Get_BBox( FT_Outline*  outline,
                        FT_BBox     *abbox )
   {
-    FT_BBox     cbox;
-    FT_BBox     bbox;
+    FT_BBox     cbox = {  0x7FFFFFFFL,  0x7FFFFFFFL,
+                         -0x7FFFFFFFL, -0x7FFFFFFFL };
+    FT_BBox     bbox = {  0x7FFFFFFFL,  0x7FFFFFFFL,
+                         -0x7FFFFFFFL, -0x7FFFFFFFL };
     FT_Vector*  vec;
     FT_UShort   n;
 
@@ -424,32 +462,13 @@ FT_DEFINE_OUTLINE_FUNCS(bbox_interface,
     /* coincide, we exit immediately.                             */
 
     vec = outline->points;
-    bbox.xMin = bbox.xMax = cbox.xMin = cbox.xMax = vec->x;
-    bbox.yMin = bbox.yMax = cbox.yMin = cbox.yMax = vec->y;
-    vec++;
 
-    for ( n = 1; n < outline->n_points; n++ )
+    for ( n = 0; n < outline->n_points; n++ )
     {
-      FT_Pos  x = vec->x;
-      FT_Pos  y = vec->y;
-
-
-      /* update control box */
-      if ( x < cbox.xMin ) cbox.xMin = x;
-      if ( x > cbox.xMax ) cbox.xMax = x;
-
-      if ( y < cbox.yMin ) cbox.yMin = y;
-      if ( y > cbox.yMax ) cbox.yMax = y;
+      FT_UPDATE_BBOX( vec, cbox);
 
       if ( FT_CURVE_TAG( outline->tags[n] ) == FT_CURVE_TAG_ON )
-      {
-        /* update bbox for `on' points only */
-        if ( x < bbox.xMin ) bbox.xMin = x;
-        if ( x > bbox.xMax ) bbox.xMax = x;
-
-        if ( y < bbox.yMin ) bbox.yMin = y;
-        if ( y > bbox.yMax ) bbox.yMax = y;
-      }
+        FT_UPDATE_BBOX( vec, bbox);
 
       vec++;
     }
index 5755f85..d9dcbad 100644 (file)
@@ -4,7 +4,7 @@
 /*                                                                         */
 /*    FreeType API for accessing BDF-specific strings (body).              */
 /*                                                                         */
-/*  Copyright 2002-2004, 2013 by                                           */
+/*  Copyright 2002-2004, 2013, 2014 by                                     */
 /*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
 /*                                                                         */
 /*  This file is part of the FreeType project, and may only be used,       */
@@ -17,6 +17,8 @@
 
 
 #include <ft2build.h>
+#include FT_INTERNAL_DEBUG_H
+
 #include FT_INTERNAL_OBJECTS_H
 #include FT_SERVICE_BDF_H
 
     const char*  encoding = NULL;
     const char*  registry = NULL;
 
+    FT_Service_BDF  service;
 
-    error = FT_ERR( Invalid_Argument );
-
-    if ( face )
-    {
-      FT_Service_BDF  service;
 
+    if ( !face )
+      return FT_THROW( Invalid_Face_Handle );
 
-      FT_FACE_FIND_SERVICE( face, service, BDF );
+    FT_FACE_FIND_SERVICE( face, service, BDF );
 
-      if ( service && service->get_charset_id )
-        error = service->get_charset_id( face, &encoding, &registry );
-    }
+    if ( service && service->get_charset_id )
+      error = service->get_charset_id( face, &encoding, &registry );
+    else
+      error = FT_THROW( Invalid_Argument );
 
     if ( acharset_encoding )
       *acharset_encoding = encoding;
   {
     FT_Error  error;
 
+    FT_Service_BDF  service;
 
-    error = FT_ERR( Invalid_Argument );
 
-    aproperty->type = BDF_PROPERTY_TYPE_NONE;
+    if ( !face )
+      return FT_THROW( Invalid_Face_Handle );
 
-    if ( face )
-    {
-      FT_Service_BDF  service;
+    if ( !aproperty )
+      return FT_THROW( Invalid_Argument );
 
+    aproperty->type = BDF_PROPERTY_TYPE_NONE;
 
-      FT_FACE_FIND_SERVICE( face, service, BDF );
+    FT_FACE_FIND_SERVICE( face, service, BDF );
 
-      if ( service && service->get_property )
-        error = service->get_property( face, prop_name, aproperty );
-    }
+    if ( service && service->get_property )
+      error = service->get_property( face, prop_name, aproperty );
+    else
+      error = FT_THROW( Invalid_Argument );
 
-    return  error;
+    return error;
   }
 
 
index a746043..4bd8498 100644 (file)
@@ -33,7 +33,8 @@
   FT_EXPORT_DEF( void )
   FT_Bitmap_New( FT_Bitmap  *abitmap )
   {
-    *abitmap = null_bitmap;
+    if ( abitmap )
+      *abitmap = null_bitmap;
   }
 
 
                   const FT_Bitmap  *source,
                   FT_Bitmap        *target)
   {
-    FT_Memory  memory = library->memory;
+    FT_Memory  memory;
     FT_Error   error  = FT_Err_Ok;
-    FT_Int     pitch  = source->pitch;
-    FT_ULong   size;
 
+    FT_Int    pitch;
+    FT_ULong  size;
+
+    FT_Int  source_pitch_sign, target_pitch_sign;
+
+
+    if ( !library )
+      return FT_THROW( Invalid_Library_Handle );
+
+    if ( !source || !target )
+      return FT_THROW( Invalid_Argument );
 
     if ( source == target )
       return FT_Err_Ok;
 
+    source_pitch_sign = source->pitch < 0 ? -1 : 1;
+    target_pitch_sign = target->pitch < 0 ? -1 : 1;
+
     if ( source->buffer == NULL )
     {
       *target = *source;
+      if ( source_pitch_sign != target_pitch_sign )
+        target->pitch = -target->pitch;
 
       return FT_Err_Ok;
     }
 
+    memory = library->memory;
+    pitch  = source->pitch;
+
     if ( pitch < 0 )
       pitch = -pitch;
-    size = (FT_ULong)( pitch * source->rows );
+    size = (FT_ULong)pitch * source->rows;
 
     if ( target->buffer )
     {
@@ -70,9 +88,9 @@
       FT_ULong  target_size;
 
 
-      if ( target_pitch < 0  )
+      if ( target_pitch < 0 )
         target_pitch = -target_pitch;
-      target_size = (FT_ULong)( target_pitch * target->rows );
+      target_size = (FT_ULong)target_pitch * target->rows;
 
       if ( target_size != size )
         (void)FT_QREALLOC( target->buffer, target_size, size );
       *target = *source;
       target->buffer = p;
 
-      FT_MEM_COPY( target->buffer, source->buffer, size );
+      if ( source_pitch_sign == target_pitch_sign )
+        FT_MEM_COPY( target->buffer, source->buffer, size );
+      else
+      {
+        /* take care of bitmap flow */
+        FT_UInt   i;
+        FT_Byte*  s = source->buffer;
+        FT_Byte*  t = target->buffer;
+
+
+        t += pitch * ( target->rows - 1 );
+
+        for ( i = target->rows; i > 0; i-- )
+        {
+          FT_ARRAY_COPY( t, s, pitch );
+
+          s += pitch;
+          t -= pitch;
+        }
+      }
     }
 
     return error;
   }
 
 
+  /* Enlarge `bitmap' horizontally and vertically by `xpixels' */
+  /* and `ypixels', respectively.                              */
+
   static FT_Error
   ft_bitmap_assure_buffer( FT_Memory   memory,
                            FT_Bitmap*  bitmap,
     int             pitch;
     int             new_pitch;
     FT_UInt         bpp;
-    FT_Int          i, width, height;
+    FT_UInt         i, width, height;
     unsigned char*  buffer = NULL;
 
 
     if ( ypixels == 0 && new_pitch <= pitch )
     {
       /* zero the padding */
-      FT_Int  bit_width = pitch * 8;
-      FT_Int  bit_last  = ( width + xpixels ) * bpp;
+      FT_UInt  bit_width = pitch * 8;
+      FT_UInt  bit_last  = ( width + xpixels ) * bpp;
 
 
       if ( bit_last < bit_width )
       {
         FT_Byte*  line  = bitmap->buffer + ( bit_last >> 3 );
         FT_Byte*  end   = bitmap->buffer + pitch;
-        FT_Int    shift = bit_last & 7;
+        FT_UInt   shift = bit_last & 7;
         FT_UInt   mask  = 0xFF00U >> shift;
-        FT_Int    count = height;
+        FT_UInt   count = height;
 
 
         for ( ; count > 0; count--, line += pitch, end += pitch )
             write++;
           }
           if ( write < end )
-            FT_MEM_ZERO( write, end-write );
+            FT_MEM_ZERO( write, end - write );
         }
       }
 
       return FT_Err_Ok;
     }
 
+    /* otherwise allocate new buffer */
     if ( FT_QALLOC_MULT( buffer, new_pitch, bitmap->rows + ypixels ) )
       return error;
 
+    /* new rows get added at the top of the bitmap, */
+    /* thus take care of the flow direction         */
     if ( bitmap->pitch > 0 )
     {
-      FT_Int  len = ( width * bpp + 7 ) >> 3;
+      FT_UInt  len = ( width * bpp + 7 ) >> 3;
 
 
       for ( i = 0; i < bitmap->rows; i++ )
     }
     else
     {
-      FT_Int  len = ( width * bpp + 7 ) >> 3;
+      FT_UInt  len = ( width * bpp + 7 ) >> 3;
 
 
       for ( i = 0; i < bitmap->rows; i++ )
   {
     FT_Error        error;
     unsigned char*  p;
-    FT_Int          i, x, y, pitch;
+    FT_Int          i, x, pitch;
+    FT_UInt         y;
     FT_Int          xstr, ystr;
 
 
     case FT_PIXEL_MODE_GRAY4:
       {
         FT_Bitmap  tmp;
-        FT_Int     align;
 
 
-        if ( bitmap->pixel_mode == FT_PIXEL_MODE_GRAY2 )
-          align = ( bitmap->width + xstr + 3 ) / 4;
-        else
-          align = ( bitmap->width + xstr + 1 ) / 2;
-
+        /* convert to 8bpp */
         FT_Bitmap_New( &tmp );
-
-        error = FT_Bitmap_Convert( library, bitmap, &tmp, align );
+        error = FT_Bitmap_Convert( library, bitmap, &tmp, 1 );
         if ( error )
           return error;
 
     if ( error )
       return error;
 
+    /* take care of bitmap flow */
     pitch = bitmap->pitch;
     if ( pitch > 0 )
       p = bitmap->buffer + pitch * ystr;
        */
       for ( x = pitch - 1; x >= 0; x-- )
       {
-        unsigned char tmp;
+        unsigned char  tmp;
 
 
         tmp = p[x];
               p[x] |= p[x - 1] << ( 8 - i );
 
 #if 0
-            if ( p[x] == 0xff )
+            if ( p[x] == 0xFF )
               break;
 #endif
           }
             {
               if ( p[x] + p[x - i] > bitmap->num_grays - 1 )
               {
-                p[x] = (unsigned char)(bitmap->num_grays - 1);
+                p[x] = (unsigned char)( bitmap->num_grays - 1 );
                 break;
               }
               else
               {
-                p[x] = (unsigned char)(p[x] + p[x-i]);
+                p[x] = (unsigned char)( p[x] + p[x - i] );
                 if ( p[x] == bitmap->num_grays - 1 )
                   break;
               }
   static FT_Byte
   ft_gray_for_premultiplied_srgb_bgra( const FT_Byte*  bgra )
   {
-    FT_Long  a = bgra[3];
-    FT_Long  b = bgra[0];
-    FT_Long  g = bgra[1];
-    FT_Long  r = bgra[2];
-    FT_Long  l;
+    FT_UInt  a = bgra[3];
+    FT_UInt  l;
 
 
-    /* Short-circuit transparent color to avoid div-by-zero. */
+    /* Short-circuit transparent color to avoid division by zero. */
     if ( !a )
       return 0;
 
      * A gamma of 2.2 is fair to assume.  And then, we need to
      * undo the premultiplication too.
      *
-     * http://accessibility.kde.org/hsl-adjusted.php
+     *   http://accessibility.kde.org/hsl-adjusted.php
+     *
+     * We do the computation with integers only, applying a gamma of 2.0.
+     * We guarantee 32-bit arithmetic to avoid overflow but the resulting
+     * luminosity fits into 16 bits.
      *
-     * We do the computation with integers only.
      */
 
-    /* Undo premultification, get the number in a 16.16 form. */
-    b = FT_MulDiv( b, 65536, a );
-    g = FT_MulDiv( g, 65536, a );
-    r = FT_MulDiv( r, 65536, a );
-    a = a * 256;
-
-    /* Apply gamma of 2.0 instead of 2.2. */
-    b = FT_MulFix( b, b );
-    g = FT_MulFix( g, g );
-    r = FT_MulFix( r, r );
-
-    /* Apply coefficients. */
-    b = FT_MulFix( b,  4731 /* 0.0722 * 65536 */ );
-    g = FT_MulFix( g, 46871 /* 0.7152 * 65536 */ );
-    r = FT_MulFix( r, 13933 /* 0.2126 * 65536 */ );
-
-    l = r + g + b;
+    l = (  4732UL /* 0.0722 * 65536 */ * bgra[0] * bgra[0] +
+          46871UL /* 0.7152 * 65536 */ * bgra[1] * bgra[1] +
+          13933UL /* 0.2126 * 65536 */ * bgra[2] * bgra[2] ) >> 16;
 
     /*
-     * Final transparency can be determined this way:
+     * Final transparency can be determined as follows.
      *
      * - If alpha is zero, we want 0.
      * - If alpha is zero and luminosity is zero, we want 255.
      * - If alpha is zero and luminosity is one, we want 0.
      *
-     * So the formula is a * (1 - l).
+     * So the formula is a * (1 - l) = a - l * a.
+     *
+     * We still need to undo premultiplication by dividing l by a*a.
+     *
      */
 
-    return (FT_Byte)( FT_MulFix( 65535 - l, a ) >> 8 );
+    return (FT_Byte)( a - l / a );
   }
 
 
     FT_Error   error = FT_Err_Ok;
     FT_Memory  memory;
 
+    FT_Byte*  s;
+    FT_Byte*  t;
+
 
     if ( !library )
       return FT_THROW( Invalid_Library_Handle );
 
+    if ( !source || !target )
+      return FT_THROW( Invalid_Argument );
+
     memory = library->memory;
 
     switch ( source->pixel_mode )
     case FT_PIXEL_MODE_LCD_V:
     case FT_PIXEL_MODE_BGRA:
       {
-        FT_Int   pad;
-        FT_Long  old_size;
+        FT_Int    pad, old_target_pitch, target_pitch;
+        FT_ULong  old_size;
+
 
+        old_target_pitch = target->pitch;
+        if ( old_target_pitch < 0 )
+          old_target_pitch = -old_target_pitch;
 
-        old_size = target->rows * target->pitch;
-        if ( old_size < 0 )
-          old_size = -old_size;
+        old_size = target->rows * old_target_pitch;
 
         target->pixel_mode = FT_PIXEL_MODE_GRAY;
         target->rows       = source->rows;
             pad = alignment - pad;
         }
 
-        target->pitch = source->width + pad;
+        target_pitch = source->width + pad;
 
-        if ( target->pitch > 0                                     &&
-             (FT_ULong)target->rows > FT_ULONG_MAX / target->pitch )
+        if ( target_pitch > 0                                     &&
+             (FT_ULong)target->rows > FT_ULONG_MAX / target_pitch )
           return FT_THROW( Invalid_Argument );
 
-        if ( target->rows * target->pitch > old_size             &&
+        if ( target->rows * target_pitch > old_size               &&
              FT_QREALLOC( target->buffer,
-                          old_size, target->rows * target->pitch ) )
+                          old_size, target->rows * target_pitch ) )
           return error;
+
+        target->pitch = target->pitch < 0 ? -target_pitch : target_pitch;
       }
       break;
 
       error = FT_THROW( Invalid_Argument );
     }
 
+    s = source->buffer;
+    t = target->buffer;
+
+    /* take care of bitmap flow */
+    if ( source->pitch < 0 )
+      s -= source->pitch * ( source->rows - 1 );
+    if ( target->pitch < 0 )
+      t -= target->pitch * ( target->rows - 1 );
+
     switch ( source->pixel_mode )
     {
     case FT_PIXEL_MODE_MONO:
       {
-        FT_Byte*  s = source->buffer;
-        FT_Byte*  t = target->buffer;
-        FT_Int    i;
+        FT_UInt  i;
 
 
         target->num_grays = 2;
         {
           FT_Byte*  ss = s;
           FT_Byte*  tt = t;
-          FT_Int    j;
+          FT_UInt   j;
 
 
           /* get the full bytes */
           {
             FT_Int  val = ss[0]; /* avoid a byte->int cast on each line */
 
+
             tt[0] = (FT_Byte)( ( val & 0x80 ) ? 0xff : 0);
             tt[1] = (FT_Byte)( ( val & 0x40 ) ? 0xff : 0);
             tt[2] = (FT_Byte)( ( val & 0x20 ) ? 0xff : 0);
             tt[6] = (FT_Byte)( ( val & 0x02 ) ? 0xff : 0);
             tt[7] = (FT_Byte)( ( val & 0x01 ) ? 0xff : 0);
 
-
             tt += 8;
             ss += 1;
           }
     case FT_PIXEL_MODE_LCD:
     case FT_PIXEL_MODE_LCD_V:
       {
-        FT_Int    width   = source->width;
-        FT_Byte*  s       = source->buffer;
-        FT_Byte*  t       = target->buffer;
-        FT_Int    s_pitch = source->pitch;
-        FT_Int    t_pitch = target->pitch;
-        FT_Int    i;
+        FT_Int   width = source->width;
+        FT_UInt  i;
 
 
         target->num_grays = 256;
         {
           FT_ARRAY_COPY( t, s, width );
 
-          s += s_pitch;
-          t += t_pitch;
+          s += source->pitch;
+          t += target->pitch;
         }
       }
       break;
 
     case FT_PIXEL_MODE_GRAY2:
       {
-        FT_Byte*  s = source->buffer;
-        FT_Byte*  t = target->buffer;
-        FT_Int    i;
+        FT_UInt  i;
 
 
         target->num_grays = 4;
         {
           FT_Byte*  ss = s;
           FT_Byte*  tt = t;
-          FT_Int    j;
+          FT_UInt   j;
 
 
           /* get the full bytes */
 
     case FT_PIXEL_MODE_GRAY4:
       {
-        FT_Byte*  s = source->buffer;
-        FT_Byte*  t = target->buffer;
-        FT_Int    i;
+        FT_UInt  i;
 
 
         target->num_grays = 16;
         {
           FT_Byte*  ss = s;
           FT_Byte*  tt = t;
-          FT_Int    j;
+          FT_UInt   j;
 
 
           /* get the full bytes */
       }
       break;
 
+
     case FT_PIXEL_MODE_BGRA:
       {
-        FT_Byte*  s       = source->buffer;
-        FT_Byte*  t       = target->buffer;
-        FT_Int    s_pitch = source->pitch;
-        FT_Int    t_pitch = target->pitch;
-        FT_Int    i;
+        FT_UInt  i;
 
 
         target->num_grays = 256;
         {
           FT_Byte*  ss = s;
           FT_Byte*  tt = t;
-          FT_Int    j;
+          FT_UInt   j;
 
 
           for ( j = source->width; j > 0; j-- )
             tt += 1;
           }
 
-          s += s_pitch;
-          t += t_pitch;
+          s += source->pitch;
+          t += target->pitch;
         }
       }
       break;
index 6e65583..57f7968 100644 (file)
@@ -39,7 +39,8 @@
 #include FT_INTERNAL_DEBUG_H
 #include FT_INTERNAL_OBJECTS_H
 
-#ifdef FT_MULFIX_INLINED
+
+#ifdef FT_MULFIX_ASSEMBLER
 #undef FT_MulFix
 #endif
 
 #define FT_COMPONENT  trace_calc
 
 
+  /* transfer sign leaving a positive number */
+#define FT_MOVE_SIGN( x, s ) \
+  FT_BEGIN_STMNT             \
+    if ( x < 0 )             \
+    {                        \
+      x = -x;                \
+      s = -s;                \
+    }                        \
+  FT_END_STMNT
+
   /* The following three functions are available regardless of whether */
   /* FT_LONG64 is defined.                                             */
 
@@ -75,8 +86,8 @@
   FT_EXPORT_DEF( FT_Fixed )
   FT_RoundFix( FT_Fixed  a )
   {
-    return ( a >= 0 ) ?   ( a + 0x8000L ) & ~0xFFFFL
-                      : -((-a + 0x8000L ) & ~0xFFFFL );
+    return a >= 0 ?   ( a + 0x8000L ) & ~0xFFFFL
+                  : -((-a + 0x8000L ) & ~0xFFFFL );
   }
 
 
@@ -85,8 +96,8 @@
   FT_EXPORT_DEF( FT_Fixed )
   FT_CeilFix( FT_Fixed  a )
   {
-    return ( a >= 0 ) ?   ( a + 0xFFFFL ) & ~0xFFFFL
-                      : -((-a + 0xFFFFL ) & ~0xFFFFL );
+    return a >= 0 ?   ( a + 0xFFFFL ) & ~0xFFFFL
+                  : -((-a + 0xFFFFL ) & ~0xFFFFL );
   }
 
 
   FT_EXPORT_DEF( FT_Fixed )
   FT_FloorFix( FT_Fixed  a )
   {
-    return ( a >= 0 ) ?   a & ~0xFFFFL
-                      : -((-a) & ~0xFFFFL );
+    return a >= 0 ?   a & ~0xFFFFL
+                  : -((-a) & ~0xFFFFL );
   }
 
+#ifndef FT_MSB
 
   FT_BASE_DEF ( FT_Int )
   FT_MSB( FT_UInt32 z )
   {
-    FT_Int shift = 0;
+    FT_Int  shift = 0;
+
 
     /* determine msb bit index in `shift' */
-    if ( z >= ( 1L << 16 ) )
+    if ( z & 0xFFFF0000UL )
     {
       z     >>= 16;
       shift  += 16;
     }
-    if ( z >= ( 1L << 8 ) )
+    if ( z & 0x0000FF00UL )
     {
       z     >>= 8;
       shift  += 8;
     }
-    if ( z >= ( 1L << 4 ) )
+    if ( z & 0x000000F0UL )
     {
       z     >>= 4;
       shift  += 4;
     }
-    if ( z >= ( 1L << 2 ) )
+    if ( z & 0x0000000CUL )
     {
       z     >>= 2;
       shift  += 2;
     }
-    if ( z >= ( 1L << 1 ) )
+    if ( z & 0x00000002UL )
     {
    /* z     >>= 1; */
       shift  += 1;
     return shift;
   }
 
+#endif /* !FT_MSB */
+
 
   /* documentation is in ftcalc.h */
 
              FT_Long  b,
              FT_Long  c )
   {
-    FT_Int   s;
+    FT_Int   s = 1;
     FT_Long  d;
 
 
-    s = 1;
-    if ( a < 0 ) { a = -a; s = -1; }
-    if ( b < 0 ) { b = -b; s = -s; }
-    if ( c < 0 ) { c = -c; s = -s; }
+    FT_MOVE_SIGN( a, s );
+    FT_MOVE_SIGN( b, s );
+    FT_MOVE_SIGN( c, s );
 
     d = (FT_Long)( c > 0 ? ( (FT_Int64)a * b + ( c >> 1 ) ) / c
                          : 0x7FFFFFFFL );
 
-    return ( s > 0 ) ? d : -d;
+    return s < 0 ? -d : d;
   }
 
 
                       FT_Long  b,
                       FT_Long  c )
   {
-    FT_Int   s;
+    FT_Int   s = 1;
     FT_Long  d;
 
 
-    s = 1;
-    if ( a < 0 ) { a = -a; s = -1; }
-    if ( b < 0 ) { b = -b; s = -s; }
-    if ( c < 0 ) { c = -c; s = -s; }
+    FT_MOVE_SIGN( a, s );
+    FT_MOVE_SIGN( b, s );
+    FT_MOVE_SIGN( c, s );
 
     d = (FT_Long)( c > 0 ? (FT_Int64)a * b / c
                          : 0x7FFFFFFFL );
 
-    return ( s > 0 ) ? d : -d;
+    return s < 0 ? -d : d;
   }
 
 
     FT_Long  c;
 
 
-    if ( a < 0 )
-    {
-      a = -a;
-      s = -1;
-    }
-
-    if ( b < 0 )
-    {
-      b = -b;
-      s = -s;
-    }
+    FT_MOVE_SIGN( a, s );
+    FT_MOVE_SIGN( b, s );
 
     c = (FT_Long)( ( (FT_Int64)a * b + 0x8000L ) >> 16 );
 
-    return ( s > 0 ) ? c : -c;
+    return s < 0 ? -c : c;
 
 #endif /* FT_MULFIX_ASSEMBLER */
   }
   FT_DivFix( FT_Long  a,
              FT_Long  b )
   {
-    FT_Int32   s;
-    FT_UInt32  q;
+    FT_Int   s = 1;
+    FT_Long  q;
 
 
-    s = 1;
-    if ( a < 0 )
-    {
-      a = -a;
-      s = -1;
-    }
-    if ( b < 0 )
-    {
-      b = -b;
-      s = -s;
-    }
+    FT_MOVE_SIGN( a, s );
+    FT_MOVE_SIGN( b, s );
 
-    if ( b == 0 )
-      /* check for division by 0 */
-      q = 0x7FFFFFFFL;
-    else
-      /* compute result directly */
-      q = (FT_UInt32)( ( ( (FT_UInt64)a << 16 ) + ( b >> 1 ) ) / b );
+    q = (FT_Long)( b > 0 ? ( ( (FT_UInt64)a << 16 ) + ( b >> 1 ) ) / b
+                         : 0x7FFFFFFFL );
 
-    return ( s < 0 ? -(FT_Long)q : (FT_Long)q );
+    return s < 0 ? -q : q;
   }
 
 
     FT_Int     i;
 
 
-    q = 0;
-    r = hi;
-
-    if ( r >= y )
+    if ( hi >= y )
       return (FT_UInt32)0x7FFFFFFFL;
 
-    i = 32;
+    /* We shift as many bits as we can into the high register, perform     */
+    /* 32-bit division with modulo there, then work through the remaining  */
+    /* bits with long division. This optimization is especially noticeable */
+    /* for smaller dividends that barely use the high register.            */
+
+    i = 31 - FT_MSB( hi );
+    r = ( hi << i ) | ( lo >> ( 32 - i ) ); lo <<= i; /* left 64-bit shift */
+    q = r / y;
+    r -= q * y;   /* remainder */
+
+    i = 32 - i;   /* bits remaining in low register */
     do
     {
-      r <<= 1;
       q <<= 1;
-      r  |= lo >> 31;
+      r   = ( r << 1 ) | ( lo >> 31 ); lo <<= 1;
 
       if ( r >= y )
       {
         r -= y;
         q |= 1;
       }
-      lo <<= 1;
     } while ( --i );
 
     return q;
             FT_Int64*  y,
             FT_Int64  *z )
   {
-    register FT_UInt32  lo, hi;
+    FT_UInt32  lo, hi;
 
 
     lo = x->lo + y->lo;
   }
 
 
-  /* documentation is in freetype.h */
-
-  /* The FT_MulDiv function has been optimized thanks to ideas from      */
-  /* Graham Asher.  The trick is to optimize computation when everything */
-  /* fits within 32-bits (a rather common case).                         */
+  /*  The FT_MulDiv function has been optimized thanks to ideas from     */
+  /*  Graham Asher and Alexei Podtelezhnikov.  The trick is to optimize  */
+  /*  a rather common case when everything fits within 32-bits.          */
+  /*                                                                     */
+  /*  We compute 'a*b+c/2', then divide it by 'c' (all positive values). */
+  /*                                                                     */
+  /*  The product of two positive numbers never exceeds the square of    */
+  /*  its mean values.  Therefore, we always avoid the overflow by       */
+  /*  imposing                                                           */
   /*                                                                     */
-  /*  we compute 'a*b+c/2', then divide it by 'c'. (positive values)     */
+  /*    (a + b) / 2 <= sqrt(X - c/2)    ,                                */
   /*                                                                     */
-  /*  46340 is FLOOR(SQRT(2^31-1)).                                      */
+  /*  where X = 2^32 - 1, the maximum unsigned 32-bit value, and using   */
+  /*  unsigned arithmetic.  Now we replace `sqrt' with a linear function */
+  /*  that is smaller or equal for all values of c in the interval       */
+  /*  [0;X/2]; it should be equal to sqrt(X) and sqrt(3X/4) at the       */
+  /*  endpoints.  Substituting the linear solution and explicit numbers  */
+  /*  we get                                                             */
   /*                                                                     */
-  /*  if ( a <= 46340 && b <= 46340 ) then ( a*b <= 0x7FFEA810 )         */
+  /*    a + b <= 131071.99 - c / 122291.84    .                          */
   /*                                                                     */
-  /*  0x7FFFFFFF - 0x7FFEA810 = 0x157F0                                  */
+  /*  In practice, we should use a faster and even stronger inequality   */
   /*                                                                     */
-  /*  if ( c < 0x157F0*2 ) then ( a*b+c/2 <= 0x7FFFFFFF )                */
+  /*    a + b <= 131071 - (c >> 16)                                      */
   /*                                                                     */
-  /*  and 2*0x157F0 = 176096                                             */
+  /*  or, alternatively,                                                 */
   /*                                                                     */
+  /*    a + b <= 129894 - (c >> 17)    .                                 */
+  /*                                                                     */
+  /*  FT_MulFix, on the other hand, is optimized for a small value of    */
+  /*  the first argument, when the second argument can be much larger.   */
+  /*  This can be achieved by scaling the second argument and the limit  */
+  /*  in the above inequalities.  For example,                           */
+  /*                                                                     */
+  /*    a + (b >> 8) <= (131071 >> 4)                                    */
+  /*                                                                     */
+  /*  covers the practical range of use. The actual test below is a bit  */
+  /*  tighter to avoid the border case overflows.                        */
+  /*                                                                     */
+  /*  In the case of FT_DivFix, the exact overflow check                 */
+  /*                                                                     */
+  /*    a << 16 <= X - c/2                                               */
+  /*                                                                     */
+  /*  is scaled down by 2^16 and we use                                  */
+  /*                                                                     */
+  /*    a <= 65535 - (c >> 17)    .                                      */
+
+  /* documentation is in freetype.h */
 
   FT_EXPORT_DEF( FT_Long )
   FT_MulDiv( FT_Long  a,
              FT_Long  b,
              FT_Long  c )
   {
-    long  s;
+    FT_Int  s = 1;
 
 
     /* XXX: this function does not allow 64-bit arguments */
     if ( a == 0 || b == c )
       return a;
 
-    s  = a; a = FT_ABS( a );
-    s ^= b; b = FT_ABS( b );
-    s ^= c; c = FT_ABS( c );
+    FT_MOVE_SIGN( a, s );
+    FT_MOVE_SIGN( b, s );
+    FT_MOVE_SIGN( c, s );
+
+    if ( c == 0 )
+      a = 0x7FFFFFFFL;
 
-    if ( a <= 46340L && b <= 46340L && c <= 176095L && c > 0 )
-      a = ( a * b + ( c >> 1 ) ) / c;
+    else if ( (FT_ULong)a + b <= 129894UL - ( c >> 17 ) )
+      a = ( (FT_ULong)a * b + ( c >> 1 ) ) / c;
 
-    else if ( (FT_Int32)c > 0 )
+    else
     {
       FT_Int64  temp, temp2;
 
 
-      ft_multo64( (FT_Int32)a, (FT_Int32)b, &temp );
+      ft_multo64( a, b, &temp );
 
       temp2.hi = 0;
-      temp2.lo = (FT_UInt32)(c >> 1);
+      temp2.lo = c >> 1;
+
       FT_Add64( &temp, &temp2, &temp );
-      a = ft_div64by32( temp.hi, temp.lo, (FT_Int32)c );
+
+      /* last attempt to ditch long division */
+      a = temp.hi == 0 ? temp.lo / c
+                       : ft_div64by32( temp.hi, temp.lo, c );
     }
-    else
-      a = 0x7FFFFFFFL;
 
-    return ( s < 0 ? -a : a );
+    return s < 0 ? -a : a;
   }
 
 
                       FT_Long  b,
                       FT_Long  c )
   {
-    long  s;
+    FT_Int  s = 1;
 
 
     if ( a == 0 || b == c )
       return a;
 
-    s  = a; a = FT_ABS( a );
-    s ^= b; b = FT_ABS( b );
-    s ^= c; c = FT_ABS( c );
+    FT_MOVE_SIGN( a, s );
+    FT_MOVE_SIGN( b, s );
+    FT_MOVE_SIGN( c, s );
+
+    if ( c == 0 )
+      a = 0x7FFFFFFFL;
 
-    if ( a <= 46340L && b <= 46340L && c > 0 )
-      a = a * b / c;
+    else if ( (FT_ULong)a + b <= 131071UL )
+      a = (FT_ULong)a * b / c;
 
-    else if ( (FT_Int32)c > 0 )
+    else
     {
       FT_Int64  temp;
 
 
-      ft_multo64( (FT_Int32)a, (FT_Int32)b, &temp );
-      a = ft_div64by32( temp.hi, temp.lo, (FT_Int32)c );
+      ft_multo64( a, b, &temp );
+
+      /* last attempt to ditch long division */
+      a = temp.hi == 0 ? temp.lo / c
+                       : ft_div64by32( temp.hi, temp.lo, c );
     }
-    else
-      a = 0x7FFFFFFFL;
 
-    return ( s < 0 ? -a : a );
+    return s < 0 ? -a : a;
   }
 
 
     ua = (FT_ULong)a;
     ub = (FT_ULong)b;
 
-    if ( ua <= 2048 && ub <= 1048576L )
+    if ( ua + ( ub >> 8 ) <= 8190UL )
       ua = ( ua * ub + 0x8000U ) >> 16;
     else
     {
 
 #else /* 0 */
 
-    FT_Long   s;
+    FT_Int    s = 1;
     FT_ULong  ua, ub;
 
 
     if ( a == 0 || b == 0x10000L )
       return a;
 
-    s  = a; a = FT_ABS( a );
-    s ^= b; b = FT_ABS( b );
+    FT_MOVE_SIGN( a, s );
+    FT_MOVE_SIGN( b, s );
 
     ua = (FT_ULong)a;
     ub = (FT_ULong)b;
 
-    if ( ua <= 2048 && ub <= 1048576L )
+    if ( ua + ( ub >> 8 ) <= 8190UL )
       ua = ( ua * ub + 0x8000UL ) >> 16;
     else
     {
            ( ( al * ( ub & 0xFFFFUL ) + 0x8000UL ) >> 16 );
     }
 
-    return ( s < 0 ? -(FT_Long)ua : (FT_Long)ua );
+    return s < 0 ? -(FT_Long)ua : (FT_Long)ua;
 
 #endif /* 0 */
 
   FT_DivFix( FT_Long  a,
              FT_Long  b )
   {
-    FT_Int32   s;
-    FT_UInt32  q;
+    FT_Int   s = 1;
+    FT_Long  q;
 
 
     /* XXX: this function does not allow 64-bit arguments */
-    s  = (FT_Int32)a; a = FT_ABS( a );
-    s ^= (FT_Int32)b; b = FT_ABS( b );
 
-    if ( (FT_UInt32)b == 0 )
+    FT_MOVE_SIGN( a, s );
+    FT_MOVE_SIGN( b, s );
+
+    if ( b == 0 )
     {
       /* check for division by 0 */
-      q = (FT_UInt32)0x7FFFFFFFL;
+      q = 0x7FFFFFFFL;
     }
-    else if ( ( a >> 16 ) == 0 )
+    else if ( a <= 65535L - ( b >> 17 ) )
     {
       /* compute result directly */
-      q = (FT_UInt32)( ( (FT_ULong)a << 16 ) + ( b >> 1 ) ) / (FT_UInt32)b;
+      q = (FT_Long)( ( ( (FT_ULong)a << 16 ) + ( b >> 1 ) ) / b );
     }
     else
     {
       FT_Int64  temp, temp2;
 
 
-      temp.hi  = (FT_Int32)( a >> 16 );
-      temp.lo  = (FT_UInt32)a << 16;
+      temp.hi  = a >> 16;
+      temp.lo  = a << 16;
       temp2.hi = 0;
-      temp2.lo = (FT_UInt32)( b >> 1 );
-      FT_Add64( &temp, &temp2, &temp );
-      q = ft_div64by32( temp.hi, temp.lo, (FT_Int32)b );
-    }
-
-    return ( s < 0 ? -(FT_Int32)q : (FT_Int32)q );
-  }
+      temp2.lo = b >> 1;
 
-
-#if 0
-
-  /* documentation is in ftcalc.h */
-
-  FT_EXPORT_DEF( void )
-  FT_MulTo64( FT_Int32   x,
-              FT_Int32   y,
-              FT_Int64  *z )
-  {
-    FT_Int32  s;
-
-
-    s  = x; x = FT_ABS( x );
-    s ^= y; y = FT_ABS( y );
-
-    ft_multo64( x, y, z );
-
-    if ( s < 0 )
-    {
-      z->lo = (FT_UInt32)-(FT_Int32)z->lo;
-      z->hi = ~z->hi + !( z->lo );
-    }
-  }
-
-
-  /* apparently, the second version of this code is not compiled correctly */
-  /* on Mac machines with the MPW C compiler..  tsk, tsk, tsk...           */
-
-#if 1
-
-  FT_EXPORT_DEF( FT_Int32 )
-  FT_Div64by32( FT_Int64*  x,
-                FT_Int32   y )
-  {
-    FT_Int32   s;
-    FT_UInt32  q, r, i, lo;
-
-
-    s  = x->hi;
-    if ( s < 0 )
-    {
-      x->lo = (FT_UInt32)-(FT_Int32)x->lo;
-      x->hi = ~x->hi + !x->lo;
-    }
-    s ^= y;  y = FT_ABS( y );
-
-    /* Shortcut */
-    if ( x->hi == 0 )
-    {
-      if ( y > 0 )
-        q = x->lo / y;
-      else
-        q = 0x7FFFFFFFL;
-
-      return ( s < 0 ? -(FT_Int32)q : (FT_Int32)q );
-    }
-
-    r  = x->hi;
-    lo = x->lo;
-
-    if ( r >= (FT_UInt32)y ) /* we know y is to be treated as unsigned here */
-      return ( s < 0 ? 0x80000001UL : 0x7FFFFFFFUL );
-                             /* Return Max/Min Int32 if division overflow. */
-                             /* This includes division by zero!            */
-    q = 0;
-    for ( i = 0; i < 32; i++ )
-    {
-      r <<= 1;
-      q <<= 1;
-      r  |= lo >> 31;
-
-      if ( r >= (FT_UInt32)y )
-      {
-        r -= y;
-        q |= 1;
-      }
-      lo <<= 1;
-    }
-
-    return ( s < 0 ? -(FT_Int32)q : (FT_Int32)q );
-  }
-
-#else /* 0 */
-
-  FT_EXPORT_DEF( FT_Int32 )
-  FT_Div64by32( FT_Int64*  x,
-                FT_Int32   y )
-  {
-    FT_Int32   s;
-    FT_UInt32  q;
-
-
-    s  = x->hi;
-    if ( s < 0 )
-    {
-      x->lo = (FT_UInt32)-(FT_Int32)x->lo;
-      x->hi = ~x->hi + !x->lo;
-    }
-    s ^= y;  y = FT_ABS( y );
-
-    /* Shortcut */
-    if ( x->hi == 0 )
-    {
-      if ( y > 0 )
-        q = ( x->lo + ( y >> 1 ) ) / y;
-      else
-        q = 0x7FFFFFFFL;
-
-      return ( s < 0 ? -(FT_Int32)q : (FT_Int32)q );
+      FT_Add64( &temp, &temp2, &temp );
+      q = (FT_Long)ft_div64by32( temp.hi, temp.lo, b );
     }
 
-    q = ft_div64by32( x->hi, x->lo, y );
-
-    return ( s < 0 ? -(FT_Int32)q : (FT_Int32)q );
+    return s < 0 ? -q : q;
   }
 
-#endif /* 0 */
-
-#endif /* 0 */
-
 
 #endif /* FT_LONG64 */
 
                      FT_Pos  out_x,
                      FT_Pos  out_y )
   {
-    FT_Pos  ax = in_x;
-    FT_Pos  ay = in_y;
-
-    FT_Pos  d_in, d_out, d_corner;
-
-
-    /* We approximate the Euclidean metric (sqrt(x^2 + y^2)) with */
-    /* the Taxicab metric (|x| + |y|), which can be computed much */
-    /* faster.  If one of the two vectors is much longer than the */
-    /* other one, the direction of the shorter vector doesn't     */
-    /* influence the result any more.                             */
-    /*                                                            */
-    /*                 corner                                     */
-    /*       x---------------------------x                        */
-    /*        \                      /                            */
-    /*         \                /                                 */
-    /*      in  \          /  out                                 */
-    /*           \    /                                           */
-    /*            o                                               */
-    /*              Point                                         */
-    /*                                                            */
-
-    if ( ax < 0 )
-      ax = -ax;
-    if ( ay < 0 )
-      ay = -ay;
-    d_in = ax + ay;  /* d_in = || in || */
-
-    ax = out_x;
-    if ( ax < 0 )
-      ax = -ax;
-    ay = out_y;
-    if ( ay < 0 )
-      ay = -ay;
-    d_out = ax + ay;  /* d_out = || out || */
-
-    ax = out_x + in_x;
-    if ( ax < 0 )
-      ax = -ax;
-    ay = out_y + in_y;
-    if ( ay < 0 )
-      ay = -ay;
-    d_corner = ax + ay;  /* d_corner = || in + out || */
+    FT_Pos  ax = in_x + out_x;
+    FT_Pos  ay = in_y + out_y;
+
+    FT_Pos  d_in, d_out, d_hypot;
+
+
+    /* The idea of this function is to compare the length of the */
+    /* hypotenuse with the `in' and `out' length.  The `corner'  */
+    /* represented by `in' and `out' is flat if the hypotenuse's */
+    /* length isn't too large.                                   */
+    /*                                                           */
+    /* This approach has the advantage that the angle between    */
+    /* `in' and `out' is not checked.  In case one of the two    */
+    /* vectors is `dominant', this is, much larger than the      */
+    /* other vector, we thus always have a flat corner.          */
+    /*                                                           */
+    /*                hypotenuse                                 */
+    /*       x---------------------------x                       */
+    /*        \                      /                           */
+    /*         \                /                                */
+    /*      in  \          /  out                                */
+    /*           \    /                                          */
+    /*            o                                              */
+    /*              Point                                        */
+
+    d_in    = FT_HYPOT(  in_x,  in_y );
+    d_out   = FT_HYPOT( out_x, out_y );
+    d_hypot = FT_HYPOT(    ax,    ay );
 
     /* now do a simple length comparison: */
     /*                                    */
-    /*   d_in + d_out < 17/16 d_corner    */
+    /*   d_in + d_out < 17/16 d_hypot     */
 
-    return ( d_in + d_out - d_corner ) < ( d_corner >> 4 );
+    return ( d_in + d_out - d_hypot ) < ( d_hypot >> 4 );
   }
 
 
index d0ef7b7..6b49ef8 100644 (file)
@@ -4,7 +4,7 @@
 /*                                                                         */
 /*    FreeType utility file to access FSType data (body).                  */
 /*                                                                         */
-/*  Copyright 2008, 2009 by                                                */
+/*  Copyright 2008, 2009, 2014 by                                          */
 /*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
 /*                                                                         */
 /*  This file is part of the FreeType project, and may only be used,       */
@@ -51,7 +51,7 @@
 
     /* look at FSType before fsType for Type42 */
 
-    if ( ( os2 = (TT_OS2*)FT_Get_Sfnt_Table( face, ft_sfnt_os2 ) ) != NULL &&
+    if ( ( os2 = (TT_OS2*)FT_Get_Sfnt_Table( face, FT_SFNT_OS2 ) ) != NULL &&
          os2->version != 0xFFFFU                                           )
       return os2->fsType;
 
index c62b3db..ac178c4 100644 (file)
@@ -4,7 +4,7 @@
 /*                                                                         */
 /*    FreeType convenience functions to handle glyphs (body).              */
 /*                                                                         */
-/*  Copyright 1996-2005, 2007, 2008, 2010, 2012, 2013 by                   */
+/*  Copyright 1996-2005, 2007, 2008, 2010, 2012-2014 by                    */
 /*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
 /*                                                                         */
 /*  This file is part of the FreeType project, and may only be used,       */
 
 
     /* check arguments */
-    if ( !target )
+    if ( !target || !source || !source->clazz )
     {
       error = FT_THROW( Invalid_Argument );
       goto Exit;
     }
 
-    *target = 0;
+    *target = NULL;
 
     if ( !source || !source->clazz )
     {
     FT_Error    error;
     FT_Glyph    glyph;
 
-    const FT_Glyph_Class*  clazz = 0;
+    const FT_Glyph_Class*  clazz = NULL;
 
 
     if ( !slot )
     FT_BitmapGlyph            bitmap = NULL;
     const FT_Glyph_Class*     clazz;
 
-    /* FT_BITMAP_GLYPH_CLASS_GET derefers `library' in PIC mode */
+    /* FT_BITMAP_GLYPH_CLASS_GET dereferences `library' in PIC mode */
     FT_Library                library;
 
 
index a8ec44a..a65f4c8 100644 (file)
@@ -4,7 +4,7 @@
 /*                                                                         */
 /*    FreeType API for validating TrueTyepGX/AAT tables (body).            */
 /*                                                                         */
-/*  Copyright 2004-2006, 2010, 2013 by                                     */
+/*  Copyright 2004-2006, 2010, 2013, 2014 by                               */
 /*  Masatake YAMATO, Redhat K.K,                                           */
 /*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
 /*                                                                         */
@@ -50,7 +50,7 @@
       goto Exit;
     }
 
-    if ( tables == NULL )
+    if ( !tables )
     {
       error = FT_THROW( Invalid_Argument );
       goto Exit;
       goto Exit;
     }
 
-    if ( ckern_table == NULL )
+    if ( !ckern_table )
     {
       error = FT_THROW( Invalid_Argument );
       goto Exit;
index 6176273..c4c8820 100644 (file)
@@ -4,7 +4,7 @@
 /*                                                                         */
 /*    FreeType initialization layer (body).                                */
 /*                                                                         */
-/*  Copyright 1996-2002, 2005, 2007, 2009, 2012, 2013 by                   */
+/*  Copyright 1996-2002, 2005, 2007, 2009, 2012-2014 by                    */
 /*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
 /*                                                                         */
 /*  This file is part of the FreeType project, and may only be used,       */
     FT_Memory  memory;
 
 
+    /* check of `alibrary' delayed to `FT_New_Library' */
+
     /* First of all, allocate a new system object -- this function is part */
     /* of the system-specific component, i.e. `ftsystem.c'.                */
 
   FT_EXPORT_DEF( FT_Error )
   FT_Done_FreeType( FT_Library  library )
   {
-    if ( library )
-    {
-      FT_Memory  memory = library->memory;
+    FT_Memory  memory;
 
 
-      /* Discard the library object */
-      FT_Done_Library( library );
+    if ( !library )
+      return FT_THROW( Invalid_Library_Handle );
 
-      /* discard memory manager */
-      FT_Done_Memory( memory );
-    }
+    memory = library->memory;
+
+    /* Discard the library object */
+    FT_Done_Library( library );
+
+    /* discard memory manager */
+    FT_Done_Memory( memory );
 
     return FT_Err_Ok;
   }
index 852fb32..d8bcbbf 100644 (file)
@@ -4,7 +4,7 @@
 /*                                                                         */
 /*    FreeType API for color filtering of subpixel bitmap glyphs (body).   */
 /*                                                                         */
-/*  Copyright 2006, 2008-2010, 2013 by                                     */
+/*  Copyright 2006, 2008-2010, 2013, 2014 by                               */
 /*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
 /*                                                                         */
 /*  This file is part of the FreeType project, and may only be used,       */
       FT_Byte*  line = bitmap->buffer;
 
 
+      /* take care of bitmap flow */
+      if ( bitmap->pitch < 0 )
+        line -= bitmap->pitch * ( bitmap->rows - 1 );
+
+      /* `fir' and `pix' must be at least 32 bit wide, since the sum of */
+      /* the values in `weights' can exceed 0xFF                        */
+
       for ( ; height > 0; height--, line += bitmap->pitch )
       {
-        FT_UInt  fir[5];
+        FT_UInt  fir[4];        /* below, `pix' is used as the 5th element */
         FT_UInt  val1, xx;
 
 
@@ -57,7 +64,6 @@
         fir[1] = weights[3] * val1;
         fir[2] = weights[4] * val1;
         fir[3] = 0;
-        fir[4] = 0;
 
         val1    = line[1];
         fir[0] += weights[1] * val1;
@@ -78,7 +84,7 @@
           fir[3] =          weights[4] * val;
 
           pix        >>= 8;
-          pix         |= -( pix >> 8 );
+          pix         |= (FT_UInt)-(FT_Int)( pix >> 8 );
           line[xx - 2] = (FT_Byte)pix;
         }
 
 
 
           pix          = fir[0] >> 8;
-          pix         |= -( pix >> 8 );
+          pix         |= (FT_UInt)-(FT_Int)( pix >> 8 );
           line[xx - 2] = (FT_Byte)pix;
 
           pix          = fir[1] >> 8;
-          pix         |= -( pix >> 8 );
+          pix         |= (FT_UInt)-(FT_Int)( pix >> 8 );
           line[xx - 1] = (FT_Byte)pix;
         }
       }
       FT_Int    pitch  = bitmap->pitch;
 
 
+      /* take care of bitmap flow */
+      if ( bitmap->pitch < 0 )
+        column -= bitmap->pitch * ( bitmap->rows - 1 );
+
       for ( ; width > 0; width--, column++ )
       {
         FT_Byte*  col = column;
-        FT_UInt   fir[5];
+        FT_UInt   fir[4];       /* below, `pix' is used as the 5th element */
         FT_UInt   val1, yy;
 
 
         fir[1] = weights[3] * val1;
         fir[2] = weights[4] * val1;
         fir[3] = 0;
-        fir[4] = 0;
         col   += pitch;
 
         val1    = col[0];
           fir[3] =          weights[4] * val;
 
           pix           >>= 8;
-          pix            |= -( pix >> 8 );
+          pix            |= (FT_UInt)-(FT_Int)( pix >> 8 );
           col[-2 * pitch] = (FT_Byte)pix;
           col            += pitch;
         }
 
 
           pix             = fir[0] >> 8;
-          pix            |= -( pix >> 8 );
+          pix            |= (FT_UInt)-(FT_Int)( pix >> 8 );
           col[-2 * pitch] = (FT_Byte)pix;
 
           pix         = fir[1] >> 8;
-          pix        |= -( pix >> 8 );
+          pix        |= (FT_UInt)-(FT_Int)( pix >> 8 );
           col[-pitch] = (FT_Byte)pix;
         }
       }
       FT_Byte*  line = bitmap->buffer;
 
 
+      /* take care of bitmap flow */
+      if ( bitmap->pitch < 0 )
+        line -= bitmap->pitch * ( bitmap->rows - 1 );
+
       for ( ; height > 0; height--, line += pitch )
       {
         FT_UInt  xx;
       FT_Byte*  column = bitmap->buffer;
 
 
+      /* take care of bitmap flow */
+      if ( bitmap->pitch < 0 )
+        column -= bitmap->pitch * ( bitmap->rows - 1 );
+
       for ( ; width > 0; width--, column++ )
       {
         FT_Byte*  col     = column;
   FT_Library_SetLcdFilterWeights( FT_Library      library,
                                   unsigned char  *weights )
   {
-    if ( !library || !weights )
+    if ( !library )
+      return FT_THROW( Invalid_Library_Handle );
+
+    if ( !weights )
       return FT_THROW( Invalid_Argument );
 
     ft_memcpy( library->lcd_weights, weights, 5 );
 
 
     if ( !library )
-      return FT_THROW( Invalid_Argument );
+      return FT_THROW( Invalid_Library_Handle );
 
     switch ( filter )
     {
index 9b49da8..5301ab4 100644 (file)
@@ -8,7 +8,7 @@
 /*  This file is for Mac OS X only; see builds/mac/ftoldmac.c for          */
 /*  classic platforms built by MPW.                                        */
 /*                                                                         */
-/*  Copyright 1996-2009, 2013 by                                           */
+/*  Copyright 1996-2009, 2013, 2014 by                                     */
 /*  Just van Rossum, David Turner, Robert Wilhelm, and Werner Lemberg.     */
 /*                                                                         */
 /*  This file is part of the FreeType project, and may only be used,       */
     FT_Error  err;
 
 
+    if ( !fontName || !face_index )
+      return FT_THROW( Invalid_Argument) ;
+
     err = FT_GetFileRef_From_Mac_ATS_Name( fontName, &ref, face_index );
     if ( err )
       return err;
     FT_Error  err;
 
 
+    if ( !fontName || !face_index )
+      return FT_THROW( Invalid_Argument );
+
     err = FT_GetFileRef_From_Mac_ATS_Name( fontName, &ref, face_index );
     if ( err )
       return err;
       style = (StyleTable*)p;
       p += sizeof ( StyleTable );
       string_count = EndianS16_BtoN( *(short*)(p) );
+      string_count = FT_MIN( 64, string_count );
       p += sizeof ( short );
 
-      for ( i = 0; i < string_count && i < 64; i++ )
+      for ( i = 0; i < string_count; i++ )
       {
         names[i] = p;
         p       += names[i][0];
           ps_name[ps_name_len] = 0;
         }
         if ( style->indexes[face_index] > 1 &&
-             style->indexes[face_index] <= FT_MIN( string_count, 64 ) )
+             style->indexes[face_index] <= string_count )
         {
           unsigned char*  suffixes = names[style->indexes[face_index] - 1];
 
     FT_Error  error = FT_Err_Ok;
 
 
+    /* check of `library' and `aface' delayed to `FT_New_Face_From_XXX' */
+
     GetResInfo( fond, &fond_id, &fond_type, fond_name );
     if ( ResError() != noErr || fond_type != TTAG_FOND )
       return FT_THROW( Invalid_File_Format );
   {
     FT_Error      error;
     FT_Open_Args  args;
-    OSErr   err;
-    UInt8   pathname[PATH_MAX];
+
+    OSErr  err;
+    UInt8  pathname[PATH_MAX];
 
 
+    /* check of `library' and `aface' delayed to */
+    /* `FT_New_Face_From_Resource'               */
+
     if ( !ref )
       return FT_THROW( Invalid_Argument );
 
     FSRef  ref;
 
 
+    /* check of `library' and `aface' delayed to `FT_New_Face_From_FSRef' */
+
     if ( !spec || FSpMakeFSRef( spec, &ref ) != noErr )
       return FT_THROW( Invalid_Argument );
     else
index 18ff879..056680b 100644 (file)
@@ -4,7 +4,7 @@
 /*                                                                         */
 /*    Multiple Master font support (body).                                 */
 /*                                                                         */
-/*  Copyright 1996-2001, 2003, 2004, 2009, 2013 by                         */
+/*  Copyright 1996-2001, 2003, 2004, 2009, 2013, 2014 by                   */
 /*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
 /*                                                                         */
 /*  This file is part of the FreeType project, and may only be used,       */
     FT_Service_MultiMasters  service;
 
 
+    /* check of `face' delayed to `ft_face_get_mm_service' */
+
+    if ( !amaster )
+      return FT_THROW( Invalid_Argument );
+
     error = ft_face_get_mm_service( face, &service );
     if ( !error )
     {
     FT_Service_MultiMasters  service;
 
 
+    /* check of `face' delayed to `ft_face_get_mm_service' */
+
+    if ( !amaster )
+      return FT_THROW( Invalid_Argument );
+
     error = ft_face_get_mm_service( face, &service );
     if ( !error )
     {
     FT_Service_MultiMasters  service;
 
 
+    /* check of `face' delayed to `ft_face_get_mm_service' */
+
+    if ( !coords )
+      return FT_THROW( Invalid_Argument );
+
     error = ft_face_get_mm_service( face, &service );
     if ( !error )
     {
     FT_Service_MultiMasters  service;
 
 
+    /* check of `face' delayed to `ft_face_get_mm_service' */
+
+    if ( !coords )
+      return FT_THROW( Invalid_Argument );
+
     error = ft_face_get_mm_service( face, &service );
     if ( !error )
     {
     FT_Service_MultiMasters  service;
 
 
+    /* check of `face' delayed to `ft_face_get_mm_service' */
+
+    if ( !coords )
+      return FT_THROW( Invalid_Argument );
+
     error = ft_face_get_mm_service( face, &service );
     if ( !error )
     {
     FT_Service_MultiMasters  service;
 
 
+    /* check of `face' delayed to `ft_face_get_mm_service' */
+
+    if ( !coords )
+      return FT_THROW( Invalid_Argument );
+
     error = ft_face_get_mm_service( face, &service );
     if ( !error )
     {
index 6f32336..ee15a01 100644 (file)
     FT_GlyphSlot     slot = NULL;
 
 
-    if ( !face || !face->driver )
+    if ( !face )
+      return FT_THROW( Invalid_Face_Handle );
+
+    if ( !face->driver )
       return FT_THROW( Invalid_Argument );
 
     driver = face->driver;
       internal->transform_matrix.xy = 0;
       internal->transform_matrix.yx = 0;
       internal->transform_matrix.yy = 0x10000L;
+
       matrix = &internal->transform_matrix;
     }
     else
     {
       internal->transform_delta.x = 0;
       internal->transform_delta.y = 0;
+
       delta = &internal->transform_delta;
     }
     else
              ( cur[0]->platform_id == TT_PLATFORM_APPLE_UNICODE &&
                cur[0]->encoding_id == TT_APPLE_ID_UNICODE_32    ) )
         {
-#ifdef FT_MAX_CHARMAP_CACHEABLE
-          if ( cur - first > FT_MAX_CHARMAP_CACHEABLE )
-          {
-            FT_ERROR(( "find_unicode_charmap: UCS-4 cmap is found "
-                       "at too late position (%d)\n", cur - first ));
-            continue;
-          }
-#endif
           face->charmap = cur[0];
           return FT_Err_Ok;
         }
     {
       if ( cur[0]->encoding == FT_ENCODING_UNICODE )
       {
-#ifdef FT_MAX_CHARMAP_CACHEABLE
-        if ( cur - first > FT_MAX_CHARMAP_CACHEABLE )
-        {
-          FT_ERROR(( "find_unicode_charmap: UCS-2 cmap is found "
-                     "at too late position (%d)\n", cur - first ));
-          continue;
-        }
-#endif
         face->charmap = cur[0];
         return FT_Err_Ok;
       }
       if ( cur[0]->platform_id == TT_PLATFORM_APPLE_UNICODE    &&
            cur[0]->encoding_id == TT_APPLE_ID_VARIANT_SELECTOR &&
            FT_Get_CMap_Format( cur[0] ) == 14                  )
-      {
-#ifdef FT_MAX_CHARMAP_CACHEABLE
-        if ( cur - first > FT_MAX_CHARMAP_CACHEABLE )
-        {
-          FT_ERROR(( "find_unicode_charmap: UVS cmap is found "
-                     "at too late position (%d)\n", cur - first ));
-          continue;
-        }
-#endif
         return cur[0];
-      }
     }
 
     return NULL;
     FT_Open_Args  args;
 
 
-    /* test for valid `library' and `aface' delayed to FT_Open_Face() */
+    /* test for valid `library' and `aface' delayed to `FT_Open_Face' */
     if ( !pathname )
       return FT_THROW( Invalid_Argument );
 
     FT_Open_Args  args;
 
 
-    /* test for valid `library' and `face' delayed to FT_Open_Face() */
+    /* test for valid `library' and `face' delayed to `FT_Open_Face' */
     if ( !file_base )
       return FT_THROW( Invalid_Argument );
 
     FT_Memory  memory = library->memory;
     FT_Byte*   pfb_data = NULL;
     int        i, type, flags;
-    FT_Long    len;
-    FT_Long    pfb_len, pfb_pos, pfb_lenpos;
-    FT_Long    rlen, temp;
+    FT_ULong   len;
+    FT_ULong   pfb_len, pfb_pos, pfb_lenpos;
+    FT_ULong   rlen, temp;
 
 
     if ( face_index == -1 )
       error = FT_Stream_Seek( stream, offsets[i] );
       if ( error )
         goto Exit;
-      if ( FT_READ_LONG( temp ) )
+      if ( FT_READ_ULONG( temp ) )
+        goto Exit;
+
+      /* FT2 allocator takes signed long buffer length,
+       * too large value causing overflow should be checked
+       */
+      FT_TRACE4(( "                 POST fragment #%d: length=0x%08x\n",
+                  i, temp));
+      if ( 0x7FFFFFFFUL < temp || pfb_len + temp + 6 < pfb_len )
+      {
+        FT_TRACE2(( "             too long fragment length makes"
+                    " pfb_len confused: temp=0x%08x\n", temp ));
+        error = FT_THROW( Invalid_Offset );
         goto Exit;
+      }
+
       pfb_len += temp + 6;
     }
 
+    FT_TRACE2(( "             total buffer size to concatenate %d"
+                " POST fragments: 0x%08x\n",
+                 resource_cnt, pfb_len + 2));
+    if ( pfb_len + 2 < 6 ) {
+      FT_TRACE2(( "             too long fragment length makes"
+                  " pfb_len confused: pfb_len=0x%08x\n", pfb_len ));
+      error = FT_THROW( Array_Too_Large );
+      goto Exit;
+    }
     if ( FT_ALLOC( pfb_data, (FT_Long)pfb_len + 2 ) )
       goto Exit;
 
       error = FT_Stream_Seek( stream, offsets[i] );
       if ( error )
         goto Exit2;
-      if ( FT_READ_LONG( rlen ) )
-        goto Exit;
+      if ( FT_READ_ULONG( rlen ) )
+        goto Exit2;
+
+      /* FT2 allocator takes signed long buffer length,
+       * too large fragment length causing overflow should be checked
+       */
+      if ( 0x7FFFFFFFUL < rlen )
+      {
+        error = FT_THROW( Invalid_Offset );
+        goto Exit2;
+      }
+
       if ( FT_READ_USHORT( flags ) )
-        goto Exit;
+        goto Exit2;
       FT_TRACE3(( "POST fragment[%d]: offsets=0x%08x, rlen=0x%08x, flags=0x%04x\n",
                    i, offsets[i], rlen, flags ));
 
+      error = FT_ERR( Array_Too_Large );
       /* postpone the check of rlen longer than buffer until FT_Stream_Read() */
       if ( ( flags >> 8 ) == 0 )        /* Comment, should not be loaded */
+      {
+        FT_TRACE3(( "    Skip POST fragment #%d because it is a comment\n", i ));
         continue;
+      }
 
       /* the flags are part of the resource, so rlen >= 2.  */
       /* but some fonts declare rlen = 0 for empty fragment */
         len += rlen;
       else
       {
+        FT_TRACE3(( "    Write POST fragment #%d header (4-byte) to buffer"
+                    " 0x%p + 0x%08x\n", i, pfb_data, pfb_lenpos ));
         if ( pfb_lenpos + 3 > pfb_len + 2 )
           goto Exit2;
         pfb_data[pfb_lenpos    ] = (FT_Byte)( len );
         if ( ( flags >> 8 ) == 5 )      /* End of font mark */
           break;
 
+        FT_TRACE3(( "    Write POST fragment #%d header (6-byte) to buffer"
+                    " 0x%p + 0x%08x\n", i, pfb_data, pfb_pos ));
         if ( pfb_pos + 6 > pfb_len + 2 )
           goto Exit2;
         pfb_data[pfb_pos++] = 0x80;
         pfb_data[pfb_pos++] = 0;
       }
 
-      error = FT_ERR( Cannot_Open_Resource );
       if ( pfb_pos > pfb_len || pfb_pos + rlen > pfb_len )
         goto Exit2;
 
+      FT_TRACE3(( "    Load POST fragment #%d (%d byte) to buffer"
+                  " 0x%p + 0x%08x\n", i, rlen, pfb_data, pfb_pos ));
       error = FT_Stream_Read( stream, (FT_Byte *)pfb_data + pfb_pos, rlen );
       if ( error )
         goto Exit2;
       pfb_pos += rlen;
     }
 
+    error = FT_ERR( Array_Too_Large );
     if ( pfb_pos + 2 > pfb_len + 2 )
       goto Exit2;
     pfb_data[pfb_pos++] = 0x80;
                                   aface );
 
   Exit2:
+    if ( error == FT_ERR( Array_Too_Large ) )
+      FT_TRACE2(( "  Abort due to too-short buffer to store"
+                  " all POST fragments\n" ));
+    else if ( error == FT_ERR( Invalid_Offset ) )
+      FT_TRACE2(( "  Abort due to invalid offset in a POST fragment\n" ));
+    if ( error )
+      error = FT_ERR( Cannot_Open_Resource );
     FT_FREE( pfb_data );
 
   Exit:
     rlen = ( header[0x57] << 24 ) |
            ( header[0x58] << 16 ) |
            ( header[0x59] <<  8 ) |
-             header[0x5a];
+             header[0x5A];
 #endif /* 0 */
     offset = 128 + ( ( dlen + 127 ) & ~127 );
 
     FT_Module*   limit;
 
 
-    /* test for valid `library' delayed to */
-    /* FT_Stream_New()                     */
+    /* test for valid `library' delayed to `FT_Stream_New' */
 
     if ( ( !aface && face_index >= 0 ) || !args )
       return FT_THROW( Invalid_Argument );
     FT_Open_Args  open;
 
 
-    /* test for valid `face' delayed to FT_Attach_Stream() */
+    /* test for valid `face' delayed to `FT_Attach_Stream' */
 
     if ( !filepathname )
       return FT_THROW( Invalid_Argument );
     FT_Driver_Class  clazz;
 
 
-    /* test for valid `parameters' delayed to FT_Stream_New() */
+    /* test for valid `parameters' delayed to `FT_Stream_New' */
 
     if ( !face )
       return FT_THROW( Invalid_Face_Handle );
   FT_EXPORT_DEF( FT_Error )
   FT_Reference_Face( FT_Face  face )
   {
+    if ( !face )
+      return FT_THROW( Invalid_Face_Handle );
+
     face->internal->refcount++;
 
     return FT_Err_Ok;
       return FT_THROW( Invalid_Face_Handle );
 
     if ( !asize )
-      return FT_THROW( Invalid_Size_Handle );
+      return FT_THROW( Invalid_Argument );
 
     if ( !face->driver )
       return FT_THROW( Invalid_Driver_Handle );
     FT_Size_RequestRec  req;
 
 
+    /* check of `face' delayed to `FT_Request_Size' */
+
     if ( !char_width )
       char_width = char_height;
     else if ( !char_height )
     FT_Size_RequestRec  req;
 
 
+    /* check of `face' delayed to `FT_Request_Size' */
+
     if ( pixel_width == 0 )
       pixel_width = pixel_height;
     else if ( pixel_height == 0 )
     {
       if ( cur[0]->encoding == encoding )
       {
-#ifdef FT_MAX_CHARMAP_CACHEABLE
-        if ( cur - face->charmaps > FT_MAX_CHARMAP_CACHEABLE )
-        {
-          FT_ERROR(( "FT_Select_Charmap: requested charmap is found (%d), "
-                     "but in too late position to cache\n",
-                     cur - face->charmaps ));
-          continue;
-        }
-#endif
         face->charmap = cur[0];
         return 0;
       }
       return FT_THROW( Invalid_Face_Handle );
 
     cur = face->charmaps;
-    if ( !cur )
+    if ( !cur || !charmap )
       return FT_THROW( Invalid_CharMap_Handle );
+
     if ( FT_Get_CMap_Format( charmap ) == 14 )
       return FT_THROW( Invalid_Argument );
 
     {
       if ( cur[0] == charmap )
       {
-#ifdef FT_MAX_CHARMAP_CACHEABLE
-        if ( cur - face->charmaps > FT_MAX_CHARMAP_CACHEABLE )
-        {
-          FT_ERROR(( "FT_Set_Charmap: requested charmap is found (%d), "
-                     "but in too late position to cache\n",
-                     cur - face->charmaps ));
-          continue;
-        }
-#endif
         face->charmap = cur[0];
-        return 0;
+        return FT_Err_Ok;
       }
     }
+
     return FT_THROW( Invalid_Argument );
   }
 
 
     FT_ASSERT( i < charmap->face->num_charmaps );
 
-#ifdef FT_MAX_CHARMAP_CACHEABLE
-    if ( i > FT_MAX_CHARMAP_CACHEABLE )
-    {
-      FT_ERROR(( "FT_Get_Charmap_Index: requested charmap is found (%d), "
-                 "but in too late position to cache\n",
-                 i ));
-      return -i;
-    }
-#endif
     return i;
   }
 
     FT_UInt  result = 0;
 
 
-    if ( face && face->charmap &&
-        face->charmap->encoding == FT_ENCODING_UNICODE )
+    if ( face                                           &&
+         face->charmap                                  &&
+         face->charmap->encoding == FT_ENCODING_UNICODE )
     {
       FT_CharMap  charmap = find_variant_selector_charmap( face );
       FT_CMap     ucmap = FT_CMAP( face->charmap );
     FT_UInt  result = 0;
 
 
-    if ( face && FT_HAS_GLYPH_NAMES( face ) )
+    if ( face                       &&
+         FT_HAS_GLYPH_NAMES( face ) &&
+         glyph_name                 )
     {
       FT_Service_GlyphDict  service;
 
                      FT_Pointer  buffer,
                      FT_UInt     buffer_max )
   {
-    FT_Error  error = FT_ERR( Invalid_Argument );
+    FT_Error              error;
+    FT_Service_GlyphDict  service;
 
 
-    /* clean up buffer */
-    if ( buffer && buffer_max > 0 )
-      ((FT_Byte*)buffer)[0] = 0;
+    if ( !face )
+      return FT_THROW( Invalid_Face_Handle );
 
-    if ( face                                     &&
-         (FT_Long)glyph_index <= face->num_glyphs &&
-         FT_HAS_GLYPH_NAMES( face )               )
-    {
-      FT_Service_GlyphDict  service;
+    if ( !buffer || buffer_max == 0 )
+      return FT_THROW( Invalid_Argument );
 
+    /* clean up buffer */
+    ((FT_Byte*)buffer)[0] = '\0';
 
-      FT_FACE_LOOKUP_SERVICE( face,
-                              service,
-                              GLYPH_DICT );
+    if ( (FT_Long)glyph_index >= face->num_glyphs )
+      return FT_THROW( Invalid_Glyph_Index );
 
-      if ( service && service->get_name )
-        error = service->get_name( face, glyph_index, buffer, buffer_max );
-    }
+    if ( !FT_HAS_GLYPH_NAMES( face ) )
+      return FT_THROW( Invalid_Argument );
+
+    FT_FACE_LOOKUP_SERVICE( face, service, GLYPH_DICT );
+    if ( service && service->get_name )
+      error = service->get_name( face, glyph_index, buffer, buffer_max );
+    else
+      error = FT_THROW( Invalid_Argument );
 
     return error;
   }
   FT_Get_Sfnt_Table( FT_Face      face,
                      FT_Sfnt_Tag  tag )
   {
-    void*                  table = 0;
+    void*                  table = NULL;
     FT_Service_SFNT_Table  service;
 
 
     FT_ULong               offset;
 
 
+    /* test for valid `length' delayed to `service->table_info' */
+
     if ( !face || !FT_IS_SFNT( face ) )
       return FT_THROW( Invalid_Face_Handle );
 
     FT_Face  face;
 
 
-    if ( size == NULL )
-      return FT_THROW( Invalid_Argument );
+    if ( !size )
+      return FT_THROW( Invalid_Size_Handle );
 
     face = size->face;
-    if ( face == NULL || face->driver == NULL )
-      return FT_THROW( Invalid_Argument );
+    if ( !face || !face->driver )
+      return FT_THROW( Invalid_Face_Handle );
 
     /* we don't need anything more complex than that; all size objects */
     /* are already listed by the face                                  */
   FT_Get_Renderer( FT_Library       library,
                    FT_Glyph_Format  format )
   {
-    /* test for valid `library' delayed to FT_Lookup_Renderer() */
+    /* test for valid `library' delayed to `FT_Lookup_Renderer' */
 
     return FT_Lookup_Renderer( library, format, 0 );
   }
     FT_ListNode  node;
     FT_Error     error = FT_Err_Ok;
 
+    FT_Renderer_SetModeFunc  set_mode;
+
 
     if ( !library )
-      return FT_THROW( Invalid_Library_Handle );
+    {
+      error = FT_THROW( Invalid_Library_Handle );
+      goto Exit;
+    }
 
     if ( !renderer )
-      return FT_THROW( Invalid_Argument );
+    {
+      error = FT_THROW( Invalid_Argument );
+      goto Exit;
+    }
+
+    if ( num_params > 0 && !parameters )
+    {
+      error = FT_THROW( Invalid_Argument );
+      goto Exit;
+    }
 
     node = FT_List_Find( &library->renderers, renderer );
     if ( !node )
     if ( renderer->glyph_format == FT_GLYPH_FORMAT_OUTLINE )
       library->cur_renderer = renderer;
 
-    if ( num_params > 0 )
-    {
-      FT_Renderer_SetModeFunc  set_mode = renderer->clazz->set_mode;
-
+    set_mode = renderer->clazz->set_mode;
 
-      for ( ; num_params > 0; num_params-- )
-      {
-        error = set_mode( renderer, parameters->tag, parameters->data );
-        if ( error )
-          break;
-        parameters++;
-      }
+    for ( ; num_params > 0; num_params-- )
+    {
+      error = set_mode( renderer, parameters->tag, parameters->data );
+      if ( error )
+        break;
+      parameters++;
     }
 
   Exit:
         /* if we changed the current renderer for the glyph image format */
         /* we need to select it as the next current one                  */
         if ( !error && update && renderer )
-          FT_Set_Renderer( library, renderer, 0, 0 );
+        {
+          error = FT_Set_Renderer( library, renderer, 0, 0 );
+          if ( error )
+            break;
+        }
       }
     }
 
 #define FT_COMPONENT  trace_bitmap
 
     /* we convert to a single bitmap format for computing the checksum */
+    if ( !error )
     {
       FT_Bitmap  bitmap;
       FT_Error   err;
 
       FT_Bitmap_New( &bitmap );
 
+      /* this also converts the bitmap flow to `down' (i.e., pitch > 0) */
       err = FT_Bitmap_Convert( library, &slot->bitmap, &bitmap, 1 );
       if ( !err )
       {
   FT_Get_Module( FT_Library   library,
                  const char*  module_name )
   {
-    FT_Module   result = 0;
+    FT_Module   result = NULL;
     FT_Module*  cur;
     FT_Module*  limit;
 
   FT_EXPORT_DEF( FT_Error )
   FT_Reference_Library( FT_Library  library )
   {
+    if ( !library )
+      return FT_THROW( Invalid_Library_Handle );
+
     library->refcount++;
 
     return FT_Err_Ok;
     FT_Error    error;
 
 
-    if ( !memory )
+    if ( !memory || !alibrary )
       return FT_THROW( Invalid_Argument );
 
 #ifdef FT_DEBUG_LEVEL_ERROR
       *p_arg1      = subg->arg1;
       *p_arg2      = subg->arg2;
       *p_transform = subg->transform;
+
+      error = FT_Err_Ok;
     }
 
     return error;
index 4a39dcd..8749d64 100644 (file)
     FT_Pos   delta;
 
 
-    if ( !outline || !func_interface )
+    if ( !outline )
+      return FT_THROW( Invalid_Outline );
+
+    if ( !func_interface )
       return FT_THROW( Invalid_Argument );
 
     shift = func_interface->shift;
 
       /* empty glyph? */
       if ( n_points == 0 && n_contours == 0 )
-        return 0;
+        return FT_Err_Ok;
 
       /* check point and contour counts */
       if ( n_points <= 0 || n_contours <= 0 )
         goto Bad;
 
       /* XXX: check the tags array */
-      return 0;
+      return FT_Err_Ok;
     }
 
   Bad:
     FT_Int  is_owner;
 
 
-    if ( !source            || !target            ||
-         source->n_points   != target->n_points   ||
+    if ( !source || !target )
+      return FT_THROW( Invalid_Outline );
+
+    if ( source->n_points   != target->n_points   ||
          source->n_contours != target->n_contours )
       return FT_THROW( Invalid_Argument );
 
   FT_Outline_Done_Internal( FT_Memory    memory,
                             FT_Outline*  outline )
   {
-    if ( memory && outline )
-    {
-      if ( outline->flags & FT_OUTLINE_OWNER )
-      {
-        FT_FREE( outline->points   );
-        FT_FREE( outline->tags     );
-        FT_FREE( outline->contours );
-      }
-      *outline = null_outline;
+    if ( !outline )
+      return FT_THROW( Invalid_Outline );
 
-      return FT_Err_Ok;
-    }
-    else
+    if ( !memory )
       return FT_THROW( Invalid_Argument );
+
+    if ( outline->flags & FT_OUTLINE_OWNER )
+    {
+      FT_FREE( outline->points   );
+      FT_FREE( outline->tags     );
+      FT_FREE( outline->contours );
+    }
+    *outline = null_outline;
+
+    return FT_Err_Ok;
   }
 
 
     if ( !library )
       return FT_THROW( Invalid_Library_Handle );
 
-    if ( !outline || !params )
+    if ( !outline )
+      return FT_THROW( Invalid_Outline );
+
+    if ( !params )
       return FT_THROW( Invalid_Argument );
 
     renderer = library->cur_renderer;
     /* if we changed the current renderer for the glyph image format */
     /* we need to select it as the next current one                  */
     if ( !error && update && renderer )
-      FT_Set_Renderer( library, renderer, 0, 0 );
+      error = FT_Set_Renderer( library, renderer, 0, 0 );
 
     return error;
   }
     if ( !abitmap )
       return FT_THROW( Invalid_Argument );
 
-    /* other checks are delayed to FT_Outline_Render() */
+    /* other checks are delayed to `FT_Outline_Render' */
 
     params.target = abitmap;
     params.flags  = 0;
 
 
     if ( !outline )
-      return FT_THROW( Invalid_Argument );
+      return FT_THROW( Invalid_Outline );
 
     xstrength /= 2;
     ystrength /= 2;
 
     FT_Outline_Get_CBox( outline, &cbox );
 
+    /* Handle collapsed outlines to avoid undefined FT_MSB. */
+    if ( cbox.xMin == cbox.xMax || cbox.yMin == cbox.yMax )
+      return FT_ORIENTATION_NONE;
+
     xshift = FT_MSB( FT_ABS( cbox.xMax ) | FT_ABS( cbox.xMin ) ) - 14;
     xshift = FT_MAX( xshift, 0 );
 
index 0ba955f..7425abe 100644 (file)
@@ -4,7 +4,7 @@
 /*                                                                         */
 /*    FreeType API for accessing PFR-specific data (body).                 */
 /*                                                                         */
-/*  Copyright 2002-2004, 2008, 2010, 2013 by                               */
+/*  Copyright 2002-2004, 2008, 2010, 2013, 2014 by                         */
 /*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
 /*                                                                         */
 /*  This file is part of the FreeType project, and may only be used,       */
@@ -50,7 +50,7 @@
 
 
     if ( !face )
-      return FT_THROW( Invalid_Argument );
+      return FT_THROW( Invalid_Face_Handle );
 
     service = ft_pfr_check( face );
     if ( service )
 
 
     if ( !face )
+      return FT_THROW( Invalid_Face_Handle );
+
+    if ( !avector )
       return FT_THROW( Invalid_Argument );
 
     service = ft_pfr_check( face );
     FT_Service_PfrMetrics  service;
 
 
+    if ( !face )
+      return FT_THROW( Invalid_Face_Handle );
+
+    if ( !aadvance )
+      return FT_THROW( Invalid_Argument );
+
     service = ft_pfr_check( face );
     if ( service )
-    {
       error = service->get_advance( face, gindex, aadvance );
-    }
     else
       /* XXX: TODO: PROVIDE ADVANCE-LOADING METHOD TO ALL FONT DRIVERS */
       error = FT_THROW( Invalid_Argument );
index 5352970..efe24d6 100644 (file)
         return error;
 
       FT_TRACE2(( "Resource tags: %c%c%c%c\n",
-                  (char)( 0xff & ( tag_internal >> 24 ) ),
-                  (char)( 0xff & ( tag_internal >> 16 ) ),
-                  (char)( 0xff & ( tag_internal >>  8 ) ),
-                  (char)( 0xff & ( tag_internal >>  0 ) ) ));
+                  (char)( 0xFF & ( tag_internal >> 24 ) ),
+                  (char)( 0xFF & ( tag_internal >> 16 ) ),
+                  (char)( 0xFF & ( tag_internal >>  8 ) ),
+                  (char)( 0xFF & ( tag_internal >>  0 ) ) ));
       FT_TRACE3(( "             : subcount=%d, suboffset=0x%04x\n",
                   subcnt, rpos ));
 
index d965333..759fd8f 100644 (file)
     FT_Byte*  cursor;
 
 
-    if ( !fields || !stream )
+    if ( !fields )
       return FT_THROW( Invalid_Argument );
 
+    if ( !stream )
+      return FT_THROW( Invalid_Stream_Handle );
+
     cursor = stream->cursor;
 
     error = FT_Err_Ok;
index ee61cec..5fc41fc 100644 (file)
@@ -4,7 +4,7 @@
 /*                                                                         */
 /*    FreeType path stroker (body).                                        */
 /*                                                                         */
-/*  Copyright 2002-2006, 2008-2011, 2013 by                                */
+/*  Copyright 2002-2006, 2008-2011, 2013, 2014 by                          */
 /*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
 /*                                                                         */
 /*  This file is part of the FreeType project, and may only be used,       */
 
 
     if ( !library )
+      return FT_THROW( Invalid_Library_Handle );
+
+    if ( !astroker )
       return FT_THROW( Invalid_Argument );
 
     memory = library->memory;
                   FT_Stroker_LineJoin  line_join,
                   FT_Fixed             miter_limit )
   {
+    if ( !stroker )
+      return;
+
     stroker->radius      = radius;
     stroker->line_cap    = line_cap;
     stroker->line_join   = line_join;
     stroker->miter_limit = miter_limit;
 
     /* ensure miter limit has sensible value */
-    if ( stroker->miter_limit < 0x10000 )
-      stroker->miter_limit = 0x10000;
+    if ( stroker->miter_limit < 0x10000L )
+      stroker->miter_limit = 0x10000L;
 
     /* save line join style:                                           */
     /* line join style can be temporarily changed when stroking curves */
                                                     FT_Tan( theta ) ) );
 
 
-      intersect = FT_BOOL( stroker->line_length >= min_length &&
+      intersect = FT_BOOL( min_length                         &&
+                           stroker->line_length >= min_length &&
                            line_length          >= min_length );
     }
 
     FT_Fixed         line_length;
 
 
+    if ( !stroker || !to )
+      return FT_THROW( Invalid_Argument );
+
     delta.x = to->x - stroker->center.x;
     delta.y = to->y - stroker->center.y;
 
     FT_Bool     first_arc = TRUE;
 
 
+    if ( !stroker || !control || !to )
+    {
+      error = FT_THROW( Invalid_Argument );
+      goto Exit;
+    }
+
     /* if all control points are coincident, this is a no-op; */
     /* avoid creating a spurious corner                       */
     if ( FT_IS_SMALL( stroker->center.x - control->x ) &&
     FT_Bool     first_arc = TRUE;
 
 
+    if ( !stroker || !control1 || !control2 || !to )
+    {
+      error = FT_THROW( Invalid_Argument );
+      goto Exit;
+    }
+
     /* if all control points are coincident, this is a no-op; */
     /* avoid creating a spurious corner */
     if ( FT_IS_SMALL( stroker->center.x - control1->x ) &&
                            FT_Vector*  to,
                            FT_Bool     open )
   {
+    if ( !stroker || !to )
+      return FT_THROW( Invalid_Argument );
+
     /* We cannot process the first point, because there is not enough      */
     /* information regarding its corner/cap.  The latter will be processed */
     /* in the `FT_Stroker_EndSubPath' routine.                             */
     FT_Error  error = FT_Err_Ok;
 
 
+    if ( !stroker )
+    {
+      error = FT_THROW( Invalid_Argument );
+      goto Exit;
+    }
+
     if ( stroker->subpath_open )
     {
       FT_StrokeBorder  right = stroker->borders;
     FT_Error  error;
 
 
+    if ( !stroker )
+    {
+      error = FT_THROW( Invalid_Argument );
+      goto Exit;
+    }
+
     error = ft_stroke_border_get_counts( stroker->borders + 0,
                                          &count1, &count2 );
     if ( error )
     num_contours = count2 + count4;
 
   Exit:
-    *anum_points   = num_points;
-    *anum_contours = num_contours;
+    if ( anum_points )
+      *anum_points   = num_points;
+
+    if ( anum_contours )
+      *anum_contours = num_contours;
+
     return error;
   }
 
                            FT_StrokerBorder  border,
                            FT_Outline*       outline )
   {
+    if ( !stroker || !outline )
+      return;
+
     if ( border == FT_STROKER_BORDER_LEFT  ||
          border == FT_STROKER_BORDER_RIGHT )
     {
     FT_Int      tag;       /* current point's state           */
 
 
-    if ( !outline || !stroker )
+    if ( !outline )
+      return FT_THROW( Invalid_Outline );
+
+    if ( !stroker )
       return FT_THROW( Invalid_Argument );
 
     FT_Stroker_Rewind( stroker );
                    FT_Stroker   stroker,
                    FT_Bool      destroy )
   {
-    FT_Error    error   = FT_ERR( Invalid_Argument );
-    FT_Glyph    glyph   = NULL;
+    FT_Error  error = FT_ERR( Invalid_Argument );
+    FT_Glyph  glyph = NULL;
+
+    /* for FT_OUTLINE_GLYPH_CLASS_GET (in PIC mode) */
     FT_Library  library = stroker->library;
 
     FT_UNUSED( library );
 
 
-    if ( pglyph == NULL )
+    if ( !pglyph )
       goto Exit;
 
     glyph = *pglyph;
-    if ( glyph == NULL || glyph->clazz != FT_OUTLINE_GLYPH_CLASS_GET )
+    if ( !glyph || glyph->clazz != FT_OUTLINE_GLYPH_CLASS_GET )
       goto Exit;
 
     {
       if ( error )
         goto Fail;
 
-      (void)FT_Stroker_GetCounts( stroker, &num_points, &num_contours );
+      FT_Stroker_GetCounts( stroker, &num_points, &num_contours );
 
       FT_Outline_Done( glyph->library, outline );
 
                          FT_Bool      inside,
                          FT_Bool      destroy )
   {
-    FT_Error    error   = FT_ERR( Invalid_Argument );
-    FT_Glyph    glyph   = NULL;
+    FT_Error  error = FT_ERR( Invalid_Argument );
+    FT_Glyph  glyph = NULL;
+
+    /* for FT_OUTLINE_GLYPH_CLASS_GET (in PIC mode) */
     FT_Library  library = stroker->library;
 
     FT_UNUSED( library );
 
 
-    if ( pglyph == NULL )
+    if ( !pglyph )
       goto Exit;
 
     glyph = *pglyph;
-    if ( glyph == NULL || glyph->clazz != FT_OUTLINE_GLYPH_CLASS_GET )
+    if ( !glyph || glyph->clazz != FT_OUTLINE_GLYPH_CLASS_GET )
       goto Exit;
 
     {
       if ( error )
         goto Fail;
 
-      (void)FT_Stroker_GetBorderCounts( stroker, border,
-                                        &num_points, &num_contours );
+      FT_Stroker_GetBorderCounts( stroker, border,
+                                  &num_points, &num_contours );
 
       FT_Outline_Done( glyph->library, outline );
 
index 3098a60..0567bd5 100644 (file)
@@ -4,7 +4,7 @@
 /*                                                                         */
 /*    FreeType synthesizing code for emboldening and slanting (body).      */
 /*                                                                         */
-/*  Copyright 2000-2006, 2010, 2012, 2013 by                               */
+/*  Copyright 2000-2006, 2010, 2012-2014 by                                */
 /*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
 /*                                                                         */
 /*  This file is part of the FreeType project, and may only be used,       */
   FT_GlyphSlot_Oblique( FT_GlyphSlot  slot )
   {
     FT_Matrix    transform;
-    FT_Outline*  outline = &slot->outline;
+    FT_Outline*  outline;
 
 
+    if ( !slot )
+      return;
+
+    outline = &slot->outline;
+
     /* only oblique outline glyphs */
     if ( slot->format != FT_GLYPH_FORMAT_OUTLINE )
       return;
   FT_EXPORT_DEF( void )
   FT_GlyphSlot_Embolden( FT_GlyphSlot  slot )
   {
-    FT_Library  library = slot->library;
-    FT_Face     face    = slot->face;
+    FT_Library  library;
+    FT_Face     face;
     FT_Error    error;
     FT_Pos      xstr, ystr;
 
 
+    if ( !slot )
+      return;
+
+    library = slot->library;
+    face    = slot->face;
+
     if ( slot->format != FT_GLYPH_FORMAT_OUTLINE &&
          slot->format != FT_GLYPH_FORMAT_BITMAP  )
       return;
     ystr = xstr;
 
     if ( slot->format == FT_GLYPH_FORMAT_OUTLINE )
-    {
-      /* ignore error */
-      (void)FT_Outline_EmboldenXY( &slot->outline, xstr, ystr );
-    }
+      FT_Outline_EmboldenXY( &slot->outline, xstr, ystr );
+
     else /* slot->format == FT_GLYPH_FORMAT_BITMAP */
     {
       /* round to full pixels */
index 4ffdcb7..22b7ecf 100644 (file)
@@ -4,7 +4,7 @@
 /*                                                                         */
 /*    FreeType trigonometric functions (body).                             */
 /*                                                                         */
-/*  Copyright 2001-2005, 2012-2013 by                                      */
+/*  Copyright 2001-2005, 2012-2014 by                                      */
 /*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
 /*                                                                         */
 /*  This file is part of the FreeType project, and may only be used,       */
@@ -45,7 +45,7 @@
   /* this table was generated for FT_PI = 180L << 16, i.e. degrees */
 #define FT_TRIG_MAX_ITERS  23
 
-  static const FT_Fixed
+  static const FT_Angle
   ft_trig_arctan_table[] =
   {
     1740967L, 919879L, 466945L, 234379L, 117304L, 58666L, 29335L,
   static FT_Fixed
   ft_trig_downscale( FT_Fixed  val )
   {
-    FT_Fixed  s;
-    FT_Int64  v;
+    FT_Int  s = 1;
 
 
-    s   = val;
-    val = FT_ABS( val );
+    if ( val < 0 )
+    {
+       val = -val;
+       s = -1;
+    }
 
-    v   = ( val * (FT_Int64)FT_TRIG_SCALE ) + 0x100000000UL;
-    val = (FT_Fixed)( v >> 32 );
+    /* 0x40000000 comes from regression analysis between true */
+    /* and CORDIC hypotenuse, so it minimizes the error       */
+    val = (FT_Fixed)( ( (FT_Int64)val * FT_TRIG_SCALE + 0x40000000UL ) >> 32 );
 
-    return ( s >= 0 ) ? val : -val;
+    return s < 0 ? -val : val;
   }
 
 #else /* !FT_LONG64 */
   static FT_Fixed
   ft_trig_downscale( FT_Fixed  val )
   {
-    FT_Fixed   s;
-    FT_UInt32  v1, v2, k1, k2, hi, lo1, lo2, lo3;
+    FT_Int     s = 1;
+    FT_UInt32  lo1, hi1, lo2, hi2, lo, hi, i1, i2;
+
+
+    if ( val < 0 )
+    {
+       val = -val;
+       s = -1;
+    }
 
+    lo1 = val & 0x0000FFFFU;
+    hi1 = val >> 16;
+    lo2 = FT_TRIG_SCALE & 0x0000FFFFU;
+    hi2 = FT_TRIG_SCALE >> 16;
 
-    s   = val;
-    val = FT_ABS( val );
+    lo = lo1 * lo2;
+    i1 = lo1 * hi2;
+    i2 = lo2 * hi1;
+    hi = hi1 * hi2;
 
-    v1 = (FT_UInt32)val >> 16;
-    v2 = (FT_UInt32)( val & 0xFFFFL );
+    /* Check carry overflow of i1 + i2 */
+    i1 += i2;
+    hi += (FT_UInt32)( i1 < i2 ) << 16;
 
-    k1 = (FT_UInt32)FT_TRIG_SCALE >> 16;           /* constant */
-    k2 = (FT_UInt32)( FT_TRIG_SCALE & 0xFFFFL );   /* constant */
+    hi += i1 >> 16;
+    i1  = i1 << 16;
 
-    hi   = k1 * v1;
-    lo1  = k1 * v2 + k2 * v1;       /* can't overflow */
+    /* Check carry overflow of i1 + lo */
+    lo += i1;
+    hi += ( lo < i1 );
 
-    lo2  = ( k2 * v2 ) >> 16;
-    lo3  = FT_MAX( lo1, lo2 );
-    lo1 += lo2;
+    /* 0x40000000 comes from regression analysis between true */
+    /* and CORDIC hypotenuse, so it minimizes the error       */
 
-    hi  += lo1 >> 16;
-    if ( lo1 < lo3 )
-      hi += (FT_UInt32)0x10000UL;
+    /* Check carry overflow of lo + 0x40000000 */
+    lo += 0x40000000UL;
+    hi += ( lo < 0x40000000UL );
 
     val  = (FT_Fixed)hi;
 
-    return ( s >= 0 ) ? val : -val;
+    return s < 0 ? -val : val;
   }
 
 #endif /* !FT_LONG64 */
 
 
+  /* undefined and never called for zero vector */
   static FT_Int
   ft_trig_prenorm( FT_Vector*  vec )
   {
   {
     FT_Int           i;
     FT_Fixed         x, y, xtemp, b;
-    const FT_Fixed  *arctanptr;
+    const FT_Angle  *arctanptr;
 
 
     x = vec->x;
     FT_Angle         theta;
     FT_Int           i;
     FT_Fixed         x, y, xtemp, b;
-    const FT_Fixed  *arctanptr;
+    const FT_Angle  *arctanptr;
 
 
     x = vec->x;
       }
     }
 
-    /* round theta */
+    /* round theta to acknowledge its error that mostly comes */
+    /* from accumulated rounding errors in the arctan table   */
     if ( theta >= 0 )
-      theta = FT_PAD_ROUND( theta, 32 );
+      theta = FT_PAD_ROUND( theta, 16 );
     else
-      theta = -FT_PAD_ROUND( -theta, 32 );
+      theta = -FT_PAD_ROUND( -theta, 16 );
 
     vec->x = x;
     vec->y = theta;
   FT_Vector_Unit( FT_Vector*  vec,
                   FT_Angle    angle )
   {
+    if ( !vec )
+      return;
+
     vec->x = FT_TRIG_SCALE >> 8;
     vec->y = 0;
     ft_trig_pseudo_rotate( vec, angle );
     FT_Vector  v;
 
 
+    if ( !vec )
+      return;
+
     v.x   = vec->x;
     v.y   = vec->y;
 
     FT_Vector  v;
 
 
+    if ( !vec )
+      return 0;
+
     v = *vec;
 
     /* handle trivial cases */
     FT_Vector  v;
 
 
+    if ( !vec || !length || !angle )
+      return;
+
     v = *vec;
 
     if ( v.x == 0 && v.y == 0 )
 
     v.x = ft_trig_downscale( v.x );
 
-    *length = ( shift >= 0 ) ?                      ( v.x >>  shift )
-                             : (FT_Fixed)( (FT_UInt32)v.x << -shift );
+    *length = shift >= 0 ?                      ( v.x >>  shift )
+                         : (FT_Fixed)( (FT_UInt32)v.x << -shift );
     *angle  = v.y;
   }
 
                         FT_Fixed    length,
                         FT_Angle    angle )
   {
+    if ( !vec )
+      return;
+
     vec->x = length;
     vec->y = 0;
 
index c1f9931..47af19a 100644 (file)
@@ -4,7 +4,7 @@
 /*                                                                         */
 /*    FreeType utility file for PS names support (body).                   */
 /*                                                                         */
-/*  Copyright 2002-2004, 2011 by                                           */
+/*  Copyright 2002-2004, 2011, 2014 by                                     */
 /*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
 /*                                                                         */
 /*  This file is part of the FreeType project, and may only be used,       */
@@ -17,6 +17,7 @@
 
 
 #include <ft2build.h>
+#include FT_INTERNAL_DEBUG_H
 #include FT_INTERNAL_OBJECTS_H
 #include FT_INTERNAL_SERVICE_H
 #include FT_SERVICE_POSTSCRIPT_INFO_H
   FT_Get_PS_Font_Info( FT_Face          face,
                        PS_FontInfoRec*  afont_info )
   {
-    FT_Error  error = FT_ERR( Invalid_Argument );
+    FT_Error           error;
+    FT_Service_PsInfo  service;
 
 
-    if ( face )
-    {
-      FT_Service_PsInfo  service = NULL;
+    if ( !face )
+      return FT_THROW( Invalid_Face_Handle );
 
+    if ( !afont_info )
+      return FT_THROW( Invalid_Argument );
 
-      FT_FACE_FIND_SERVICE( face, service, POSTSCRIPT_INFO );
+    FT_FACE_FIND_SERVICE( face, service, POSTSCRIPT_INFO );
 
-      if ( service && service->ps_get_font_info )
-        error = service->ps_get_font_info( face, afont_info );
-    }
+    if ( service && service->ps_get_font_info )
+      error = service->ps_get_font_info( face, afont_info );
+    else
+      error = FT_THROW( Invalid_Argument );
 
     return error;
   }
@@ -51,8 +55,8 @@
   FT_EXPORT_DEF( FT_Int )
   FT_Has_PS_Glyph_Names( FT_Face  face )
   {
-    FT_Int             result  = 0;
-    FT_Service_PsInfo  service = NULL;
+    FT_Int             result = 0;
+    FT_Service_PsInfo  service;
 
 
     if ( face )
   FT_Get_PS_Font_Private( FT_Face         face,
                           PS_PrivateRec*  afont_private )
   {
-    FT_Error  error = FT_ERR( Invalid_Argument );
+    FT_Error           error;
+    FT_Service_PsInfo  service;
 
 
-    if ( face )
-    {
-      FT_Service_PsInfo  service = NULL;
+    if ( !face )
+      return FT_THROW( Invalid_Face_Handle );
 
+    if ( !afont_private )
+      return FT_THROW( Invalid_Argument );
 
-      FT_FACE_FIND_SERVICE( face, service, POSTSCRIPT_INFO );
+    FT_FACE_FIND_SERVICE( face, service, POSTSCRIPT_INFO );
 
-      if ( service && service->ps_get_font_private )
-        error = service->ps_get_font_private( face, afont_private );
-    }
+    if ( service && service->ps_get_font_private )
+      error = service->ps_get_font_private( face, afont_private );
+    else
+      error = FT_THROW( Invalid_Argument );
 
     return error;
   }
index 879d027..56e2800 100644 (file)
     FT_ListNode  cur;
 
 
+    if ( !list )
+      return NULL;
+
     cur = list->head;
     while ( cur )
     {
       cur = cur->next;
     }
 
-    return (FT_ListNode)0;
+    return NULL;
   }
 
 
   FT_List_Add( FT_List      list,
                FT_ListNode  node )
   {
-    FT_ListNode  before = list->tail;
+    FT_ListNode  before;
+
+
+    if ( !list || !node )
+      return;
 
+    before = list->tail;
 
     node->next = 0;
     node->prev = before;
   FT_List_Insert( FT_List      list,
                   FT_ListNode  node )
   {
-    FT_ListNode  after = list->head;
+    FT_ListNode  after;
+
+
+    if ( !list || !node )
+      return;
 
+    after = list->head;
 
     node->next = after;
     node->prev = 0;
     FT_ListNode  before, after;
 
 
+    if ( !list || !node )
+      return;
+
     before = node->prev;
     after  = node->next;
 
     FT_ListNode  before, after;
 
 
+    if ( !list || !node )
+      return;
+
     before = node->prev;
     after  = node->next;
 
   /* documentation is in ftlist.h */
 
   FT_EXPORT_DEF( FT_Error )
-  FT_List_Iterate( FT_List            list,
-                   FT_List_Iterator   iterator,
-                   void*              user )
+  FT_List_Iterate( FT_List           list,
+                   FT_List_Iterator  iterator,
+                   void*             user )
   {
-    FT_ListNode  cur   = list->head;
+    FT_ListNode  cur;
     FT_Error     error = FT_Err_Ok;
 
 
+    if ( !list || !iterator )
+      return FT_THROW( Invalid_Argument );
+
+    cur = list->head;
+
     while ( cur )
     {
       FT_ListNode  next = cur->next;
     FT_ListNode  cur;
 
 
+    if ( !list || !memory )
+      return;
+
     cur = list->head;
     while ( cur )
     {
   }
 
 
-  FT_BASE_DEF( FT_UInt32 )
-  ft_highpow2( FT_UInt32  value )
-  {
-    FT_UInt32  value2;
-
-
-    /*
-     *  We simply clear the lowest bit in each iteration.  When
-     *  we reach 0, we know that the previous value was our result.
-     */
-    for ( ;; )
-    {
-      value2 = value & (value - 1);  /* clear lowest bit */
-      if ( value2 == 0 )
-        break;
-
-      value = value2;
-    }
-    return value;
-  }
-
-
 /* END */
index 463ae76..8e337fb 100644 (file)
@@ -4,7 +4,7 @@
 /*                                                                         */
 /*    FreeType API for accessing Windows FNT specific info (body).         */
 /*                                                                         */
-/*  Copyright 2003, 2004 by                                                */
+/*  Copyright 2003, 2004, 2014 by                                          */
 /*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
 /*                                                                         */
 /*  This file is part of the FreeType project, and may only be used,       */
@@ -17,6 +17,7 @@
 
 
 #include <ft2build.h>
+#include FT_INTERNAL_DEBUG_H
 #include FT_WINFONTS_H
 #include FT_INTERNAL_OBJECTS_H
 #include FT_SERVICE_WINFNT_H
     FT_Error           error;
 
 
-    error = FT_ERR( Invalid_Argument );
+    if ( !face )
+      return FT_THROW( Invalid_Face_Handle );
 
-    if ( face != NULL )
-    {
-      FT_FACE_LOOKUP_SERVICE( face, service, WINFNT );
+    if ( !header )
+      return FT_THROW( Invalid_Argument );
 
-      if ( service != NULL )
-      {
-        error = service->get_header( face, header );
-      }
-    }
+    FT_FACE_LOOKUP_SERVICE( face, service, WINFNT );
+
+    if ( service )
+      error = service->get_header( face, header );
+    else
+      error = FT_THROW( Invalid_Argument );
 
     return error;
   }
index 5a1c296..55a428c 100644 (file)
@@ -182,7 +182,7 @@ THE SOFTWARE.
   }
 
 
-  FT_CALLBACK_TABLE_DEF
+  static
   const FT_CMap_ClassRec  bdf_cmap_class =
   {
     sizeof ( BDF_CMapRec ),
@@ -384,7 +384,7 @@ THE SOFTWARE.
       BDF_Face_Done( bdfface );
       return FT_THROW( Invalid_Argument );
     }
+
     {
       bdf_property_t*  prop = NULL;
 
@@ -679,7 +679,13 @@ THE SOFTWARE.
     FT_UNUSED( load_flags );
 
 
-    if ( !face || glyph_index >= (FT_UInt)face->num_glyphs )
+    if ( !face )
+    {
+      error = FT_THROW( Invalid_Face_Handle );
+      goto Exit;
+    }
+
+    if ( glyph_index >= (FT_UInt)face->num_glyphs )
     {
       error = FT_THROW( Invalid_Argument );
       goto Exit;
index 2eda11c..abcfdee 100644 (file)
                         sizeof ( _bdf_properties[0] );
 
 
+  /* An auxiliary macro to parse properties, to be used in conditionals. */
+  /* It behaves like `strncmp' but also tests the following character    */
+  /* whether it is a whitespace or NULL.                                 */
+  /* `property' is a constant string of length `n' to compare with.      */
+#define _bdf_strncmp( name, property, n )      \
+          ( ft_strncmp( name, property, n ) || \
+            !( name[n] == ' '  ||              \
+               name[n] == '\0' ||              \
+               name[n] == '\n' ||              \
+               name[n] == '\r' ||              \
+               name[n] == '\t' )            )
+
   /* Auto correction messages. */
 #define ACMSG1   "FONT_ASCENT property missing.  " \
                  "Added `FONT_ASCENT %hd'.\n"
       hold     = buf[end];
       buf[end] = 0;
 
-      /* XXX: Use encoding independent value for 0x1a */
-      if ( buf[start] != '#' && buf[start] != 0x1a && end > start )
+      /* XXX: Use encoding independent value for 0x1A */
+      if ( buf[start] != '#' && buf[start] != 0x1A && end > start )
       {
         error = (*cb)( buf + start, (unsigned long)( end - start ), lineno,
                        (void*)&cb, client_data );
     0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
     0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
     0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x00, 0x00,
-    0x00, 0x00, 0x00, 0x00, 0x00, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x00,
+    0x00, 0x00, 0x00, 0x00, 0x00, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x00,
     0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
     0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-    0x00, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00,
+    0x00, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x00,
     0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
     0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
   };
 
   static const unsigned char  odigits[32] =
   {
-    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00,
+    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00,
     0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
     0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
     0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
 
   static const unsigned char  ddigits[32] =
   {
-    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x03,
+    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x03,
     0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
     0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
     0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
 
   static const unsigned char  hdigits[32] =
   {
-    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x03,
-    0x7e, 0x00, 0x00, 0x00, 0x7e, 0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x03,
+    0x7E, 0x00, 0x00, 0x00, 0x7E, 0x00, 0x00, 0x00,
     0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
     0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
   };
 
     /* If the property happens to be a comment, then it doesn't need */
     /* to be added to the internal hash table.                       */
-    if ( ft_strncmp( name, "COMMENT", 7 ) != 0 )
+    if ( _bdf_strncmp( name, "COMMENT", 7 ) != 0 )
     {
       /* Add the property to the font property table. */
       error = hash_insert( fp->name,
     /* FONT_ASCENT and FONT_DESCENT need to be assigned if they are        */
     /* present, and the SPACING property should override the default       */
     /* spacing.                                                            */
-    if ( ft_strncmp( name, "DEFAULT_CHAR", 12 ) == 0 )
+    if ( _bdf_strncmp( name, "DEFAULT_CHAR", 12 ) == 0 )
       font->default_char = fp->value.l;
-    else if ( ft_strncmp( name, "FONT_ASCENT", 11 ) == 0 )
+    else if ( _bdf_strncmp( name, "FONT_ASCENT", 11 ) == 0 )
       font->font_ascent = fp->value.l;
-    else if ( ft_strncmp( name, "FONT_DESCENT", 12 ) == 0 )
+    else if ( _bdf_strncmp( name, "FONT_DESCENT", 12 ) == 0 )
       font->font_descent = fp->value.l;
-    else if ( ft_strncmp( name, "SPACING", 7 ) == 0 )
+    else if ( _bdf_strncmp( name, "SPACING", 7 ) == 0 )
     {
       if ( !fp->value.atom )
       {
     memory = font->memory;
 
     /* Check for a comment. */
-    if ( ft_strncmp( line, "COMMENT", 7 ) == 0 )
+    if ( _bdf_strncmp( line, "COMMENT", 7 ) == 0 )
     {
       linelen -= 7;
 
     /* The very first thing expected is the number of glyphs. */
     if ( !( p->flags & _BDF_GLYPHS ) )
     {
-      if ( ft_strncmp( line, "CHARS", 5 ) != 0 )
+      if ( _bdf_strncmp( line, "CHARS", 5 ) != 0 )
       {
         FT_ERROR(( "_bdf_parse_glyphs: " ERRMSG1, lineno, "CHARS" ));
         error = FT_THROW( Missing_Chars_Field );
     }
 
     /* Check for the ENDFONT field. */
-    if ( ft_strncmp( line, "ENDFONT", 7 ) == 0 )
+    if ( _bdf_strncmp( line, "ENDFONT", 7 ) == 0 )
     {
+      if ( p->flags & _BDF_GLYPH_BITS )
+      {
+        /* Missing ENDCHAR field. */
+        FT_ERROR(( "_bdf_parse_glyphs: " ERRMSG1, lineno, "ENDCHAR" ));
+        error = FT_THROW( Corrupted_Font_Glyphs );
+        goto Exit;
+      }
+
       /* Sort the glyphs by encoding. */
       ft_qsort( (char *)font->glyphs,
                 font->glyphs_used,
     }
 
     /* Check for the ENDCHAR field. */
-    if ( ft_strncmp( line, "ENDCHAR", 7 ) == 0 )
+    if ( _bdf_strncmp( line, "ENDCHAR", 7 ) == 0 )
     {
       p->glyph_enc = 0;
       p->flags    &= ~_BDF_GLYPH_BITS;
       goto Exit;
 
     /* Check for the STARTCHAR field. */
-    if ( ft_strncmp( line, "STARTCHAR", 9 ) == 0 )
+    if ( _bdf_strncmp( line, "STARTCHAR", 9 ) == 0 )
     {
       /* Set the character name in the parse info first until the */
       /* encoding can be checked for an unencoded character.      */
     }
 
     /* Check for the ENCODING field. */
-    if ( ft_strncmp( line, "ENCODING", 8 ) == 0 )
+    if ( _bdf_strncmp( line, "ENCODING", 8 ) == 0 )
     {
       if ( !( p->flags & _BDF_GLYPH ) )
       {
     }
 
     /* Expect the SWIDTH (scalable width) field next. */
-    if ( ft_strncmp( line, "SWIDTH", 6 ) == 0 )
+    if ( _bdf_strncmp( line, "SWIDTH", 6 ) == 0 )
     {
       if ( !( p->flags & _BDF_ENCODING ) )
         goto Missing_Encoding;
     }
 
     /* Expect the DWIDTH (scalable width) field next. */
-    if ( ft_strncmp( line, "DWIDTH", 6 ) == 0 )
+    if ( _bdf_strncmp( line, "DWIDTH", 6 ) == 0 )
     {
       if ( !( p->flags & _BDF_ENCODING ) )
         goto Missing_Encoding;
     }
 
     /* Expect the BBX field next. */
-    if ( ft_strncmp( line, "BBX", 3 ) == 0 )
+    if ( _bdf_strncmp( line, "BBX", 3 ) == 0 )
     {
       if ( !( p->flags & _BDF_ENCODING ) )
         goto Missing_Encoding;
     }
 
     /* And finally, gather up the bitmap. */
-    if ( ft_strncmp( line, "BITMAP", 6 ) == 0 )
+    if ( _bdf_strncmp( line, "BITMAP", 6 ) == 0 )
     {
       unsigned long  bitmap_size;
 
     p    = (_bdf_parse_t *)    client_data;
 
     /* Check for the end of the properties. */
-    if ( ft_strncmp( line, "ENDPROPERTIES", 13 ) == 0 )
+    if ( _bdf_strncmp( line, "ENDPROPERTIES", 13 ) == 0 )
     {
       /* If the FONT_ASCENT or FONT_DESCENT properties have not been      */
       /* encountered yet, then make sure they are added as properties and */
     }
 
     /* Ignore the _XFREE86_GLYPH_RANGES properties. */
-    if ( ft_strncmp( line, "_XFREE86_GLYPH_RANGES", 21 ) == 0 )
+    if ( _bdf_strncmp( line, "_XFREE86_GLYPH_RANGES", 21 ) == 0 )
       goto Exit;
 
     /* Handle COMMENT fields and properties in a special way to preserve */
     /* the spacing.                                                      */
-    if ( ft_strncmp( line, "COMMENT", 7 ) == 0 )
+    if ( _bdf_strncmp( line, "COMMENT", 7 ) == 0 )
     {
       name = value = line;
       value += 7;
 
     /* Check for a comment.  This is done to handle those fonts that have */
     /* comments before the STARTFONT line for some reason.                */
-    if ( ft_strncmp( line, "COMMENT", 7 ) == 0 )
+    if ( _bdf_strncmp( line, "COMMENT", 7 ) == 0 )
     {
       if ( p->opts->keep_comments != 0 && p->font != 0 )
       {
     {
       memory = p->memory;
 
-      if ( ft_strncmp( line, "STARTFONT", 9 ) != 0 )
+      if ( _bdf_strncmp( line, "STARTFONT", 9 ) != 0 )
       {
         /* we don't emit an error message since this code gets */
         /* explicitly caught one level higher                  */
     }
 
     /* Check for the start of the properties. */
-    if ( ft_strncmp( line, "STARTPROPERTIES", 15 ) == 0 )
+    if ( _bdf_strncmp( line, "STARTPROPERTIES", 15 ) == 0 )
     {
       if ( !( p->flags & _BDF_FONT_BBX ) )
       {
     }
 
     /* Check for the FONTBOUNDINGBOX field. */
-    if ( ft_strncmp( line, "FONTBOUNDINGBOX", 15 ) == 0 )
+    if ( _bdf_strncmp( line, "FONTBOUNDINGBOX", 15 ) == 0 )
     {
       if ( !( p->flags & _BDF_SIZE ) )
       {
     }
 
     /* The next thing to check for is the FONT field. */
-    if ( ft_strncmp( line, "FONT", 4 ) == 0 )
+    if ( _bdf_strncmp( line, "FONT", 4 ) == 0 )
     {
       error = _bdf_list_split( &p->list, (char *)" +", line, linelen );
       if ( error )
     }
 
     /* Check for the SIZE field. */
-    if ( ft_strncmp( line, "SIZE", 4 ) == 0 )
+    if ( _bdf_strncmp( line, "SIZE", 4 ) == 0 )
     {
       if ( !( p->flags & _BDF_FONT_NAME ) )
       {
     }
 
     /* Check for the CHARS field -- font properties are optional */
-    if ( ft_strncmp( line, "CHARS", 5 ) == 0 )
+    if ( _bdf_strncmp( line, "CHARS", 5 ) == 0 )
     {
       char  nbuf[128];
 
index 7494130..7e406b1 100644 (file)
@@ -8,7 +8,7 @@
 /*  parse compressed PCF fonts, as found with many X11 server              */
 /*  distributions.                                                         */
 /*                                                                         */
-/*  Copyright 2010, 2012, 2013 by                                          */
+/*  Copyright 2010, 2012-2014 by                                           */
 /*  Joel Klinghed.                                                         */
 /*                                                                         */
 /*  Based on src/gzip/ftgzip.c, Copyright 2002 - 2010 by                   */
     /* head[0] && head[1] are the magic numbers;    */
     /* head[2] is the version, and head[3] the blocksize */
     if ( head[0] != 0x42  ||
-         head[1] != 0x5a  ||
+         head[1] != 0x5A  ||
          head[2] != 0x68  )  /* only support bzip2 (huffman) */
     {
       error = FT_THROW( Invalid_File_Format );
                        FT_Stream  source )
   {
     FT_Error      error;
-    FT_Memory     memory = source->memory;
+    FT_Memory     memory;
     FT_BZip2File  zip = NULL;
 
 
+    if ( !stream || !source )
+    {
+      error = FT_THROW( Invalid_Stream_Handle );
+      goto Exit;
+    }
+
+    memory = source->memory;
+
     /*
      *  check the header right now; this prevents allocating unnecessary
      *  objects when we don't need them
index 84d336d..6bad39d 100644 (file)
@@ -4,7 +4,7 @@
 /*                                                                         */
 /*    The FreeType basic cache interface (body).                           */
 /*                                                                         */
-/*  Copyright 2003-2007, 2009-2011, 2013 by                                */
+/*  Copyright 2003-2007, 2009-2011, 2013, 2014 by                          */
 /*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
 /*                                                                         */
 /*  This file is part of the FreeType project, and may only be used,       */
       return result;
 
     if ( (FT_ULong)face->num_glyphs > FT_UINT_MAX || 0 > face->num_glyphs )
-    {
-      FT_TRACE1(( "ftc_basic_family_get_count: too large number of glyphs " ));
-      FT_TRACE1(( "in this face, truncated\n", face->num_glyphs ));
-    }
+      FT_TRACE1(( "ftc_basic_family_get_count:"
+                  " too large number of glyphs in this face, truncated\n",
+                  face->num_glyphs ));
 
     if ( !error )
       result = (FT_UInt)face->num_glyphs;
   *
   */
 
-  FT_CALLBACK_TABLE_DEF
+  static
   const FTC_IFamilyClassRec  ftc_basic_image_family_class =
   {
     {
   };
 
 
-  FT_CALLBACK_TABLE_DEF
+  static
   const FTC_GCacheClassRec  ftc_basic_image_cache_class =
   {
     {
     FT_PtrDist         hash;
 
 
-    /* some argument checks are delayed to FTC_Cache_Lookup */
+    /* some argument checks are delayed to `FTC_Cache_Lookup' */
     if ( !aglyph )
     {
       error = FT_THROW( Invalid_Argument );
     if ( anode )
       *anode  = NULL;
 
-    {
-      if ( (FT_ULong)(type->flags - FT_INT_MIN) > FT_UINT_MAX )
-      {
-        FT_TRACE1(( "FTC_ImageCache_Lookup: higher bits in load_flags" ));
-        FT_TRACE1(( "0x%x are dropped\n", (type->flags & ~((FT_ULong)FT_UINT_MAX)) ));
-      }
+    if ( (FT_ULong)( type->flags - FT_INT_MIN ) > FT_UINT_MAX )
+      FT_TRACE1(( "FTC_ImageCache_Lookup:"
+                  " higher bits in load_flags 0x%x are dropped\n",
+                  type->flags & ~((FT_ULong)FT_UINT_MAX) ));
 
-      query.attrs.scaler.face_id = type->face_id;
-      query.attrs.scaler.width   = type->width;
-      query.attrs.scaler.height  = type->height;
-      query.attrs.load_flags     = (FT_UInt)type->flags;
-    }
+    query.attrs.scaler.face_id = type->face_id;
+    query.attrs.scaler.width   = type->width;
+    query.attrs.scaler.height  = type->height;
+    query.attrs.load_flags     = (FT_UInt)type->flags;
 
     query.attrs.scaler.pixel = 1;
     query.attrs.scaler.x_res = 0;  /* make compilers happy */
     FT_PtrDist         hash;
 
 
-    /* some argument checks are delayed to FTC_Cache_Lookup */
+    /* some argument checks are delayed to `FTC_Cache_Lookup' */
     if ( !aglyph || !scaler )
     {
       error = FT_THROW( Invalid_Argument );
     if ( anode )
       *anode  = NULL;
 
-    /* FT_Load_Glyph(), FT_Load_Char() take FT_UInt flags */
+    /* `FT_Load_Glyph' and `FT_Load_Char' take FT_UInt flags */
     if ( load_flags > FT_UINT_MAX )
-    {
-      FT_TRACE1(( "FTC_ImageCache_LookupScaler: higher bits in load_flags" ));
-      FT_TRACE1(( "0x%x are dropped\n", (load_flags & ~((FT_ULong)FT_UINT_MAX)) ));
-    }
+      FT_TRACE1(( "FTC_ImageCache_LookupScaler:"
+                  " higher bits in load_flags 0x%x are dropped\n",
+                  load_flags & ~((FT_ULong)FT_UINT_MAX) ));
 
     query.attrs.scaler     = scaler[0];
     query.attrs.load_flags = (FT_UInt)load_flags;
    *
    */
 
-  FT_CALLBACK_TABLE_DEF
+  static
   const FTC_SFamilyClassRec  ftc_basic_sbit_family_class =
   {
     {
   };
 
 
-  FT_CALLBACK_TABLE_DEF
+  static
   const FTC_GCacheClassRec  ftc_basic_sbit_cache_class =
   {
     {
     if ( anode )
       *anode = NULL;
 
-    /* other argument checks delayed to FTC_Cache_Lookup */
+    /* other argument checks delayed to `FTC_Cache_Lookup' */
     if ( !ansbit )
       return FT_THROW( Invalid_Argument );
 
     *ansbit = NULL;
 
-    {
-      if ( (FT_ULong)(type->flags - FT_INT_MIN) > FT_UINT_MAX )
-      {
-        FT_TRACE1(( "FTC_ImageCache_Lookup: higher bits in load_flags" ));
-        FT_TRACE1(( "0x%x are dropped\n", (type->flags & ~((FT_ULong)FT_UINT_MAX)) ));
-      }
+    if ( (FT_ULong)( type->flags - FT_INT_MIN ) > FT_UINT_MAX )
+      FT_TRACE1(( "FTC_ImageCache_Lookup:"
+                  " higher bits in load_flags 0x%x are dropped\n",
+                  type->flags & ~((FT_ULong)FT_UINT_MAX) ));
 
-      query.attrs.scaler.face_id = type->face_id;
-      query.attrs.scaler.width   = type->width;
-      query.attrs.scaler.height  = type->height;
-      query.attrs.load_flags     = (FT_UInt)type->flags;
-    }
+    query.attrs.scaler.face_id = type->face_id;
+    query.attrs.scaler.width   = type->width;
+    query.attrs.scaler.height  = type->height;
+    query.attrs.load_flags     = (FT_UInt)type->flags;
 
     query.attrs.scaler.pixel = 1;
     query.attrs.scaler.x_res = 0;  /* make compilers happy */
     if ( anode )
         *anode = NULL;
 
-    /* other argument checks delayed to FTC_Cache_Lookup */
+    /* other argument checks delayed to `FTC_Cache_Lookup' */
     if ( !ansbit || !scaler )
         return FT_THROW( Invalid_Argument );
 
     *ansbit = NULL;
 
-    /* FT_Load_Glyph(), FT_Load_Char() take FT_UInt flags */
+    /* `FT_Load_Glyph' and `FT_Load_Char' take FT_UInt flags */
     if ( load_flags > FT_UINT_MAX )
-    {
-      FT_TRACE1(( "FTC_ImageCache_LookupScaler: higher bits in load_flags" ));
-      FT_TRACE1(( "0x%x are dropped\n", (load_flags & ~((FT_ULong)FT_UINT_MAX)) ));
-    }
+      FT_TRACE1(( "FTC_ImageCache_LookupScaler:"
+                  " higher bits in load_flags 0x%x are dropped\n",
+                  load_flags & ~((FT_ULong)FT_UINT_MAX) ));
 
     query.attrs.scaler     = scaler[0];
     query.attrs.load_flags = (FT_UInt)load_flags;
index 848349b..ab22366 100644 (file)
@@ -4,7 +4,7 @@
 /*                                                                         */
 /*    FreeType CharMap cache (body)                                        */
 /*                                                                         */
-/*  Copyright 2000-2013 by                                                 */
+/*  Copyright 2000-2014 by                                                 */
 /*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
 /*                                                                         */
 /*  This file is part of the FreeType project, and may only be used,       */
   /*************************************************************************/
 
 
-  FT_CALLBACK_TABLE_DEF
+  static
   const FTC_CacheClassRec  ftc_cmap_cache_class =
   {
     ftc_cmap_node_new,
       return 0;
     }
 
+    if ( !face_id )
+      return 0;
+
     query.face_id    = face_id;
     query.cmap_index = (FT_UInt)cmap_index;
     query.char_code  = char_code;
       if ( error )
         goto Exit;
 
-#ifdef FT_MAX_CHARMAP_CACHEABLE
-      /* something rotten can happen with rogue clients */
-      if ( cmap_index > FT_MAX_CHARMAP_CACHEABLE )
-        return 0; /* XXX: should return appropriate error */
-#endif
-
       if ( (FT_UInt)cmap_index < (FT_UInt)face->num_charmaps )
       {
         FT_CharMap  old, cmap  = NULL;
index 4eb2c5b..fff7a08 100644 (file)
@@ -4,7 +4,7 @@
 /*                                                                         */
 /*    FreeType Cache Manager (body).                                       */
 /*                                                                         */
-/*  Copyright 2000-2006, 2008-2010, 2013 by                                */
+/*  Copyright 2000-2006, 2008-2010, 2013, 2014 by                          */
 /*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
 /*                                                                         */
 /*  This file is part of the FreeType project, and may only be used,       */
   }
 
 
-  FT_CALLBACK_TABLE_DEF
+  static
   const FTC_MruListClassRec  ftc_size_list_class =
   {
     sizeof ( FTC_SizeNodeRec ),
     FTC_MruNode  mrunode;
 
 
-    if ( asize == NULL )
+    if ( !asize || !scaler )
       return FT_THROW( Invalid_Argument );
 
     *asize = NULL;
   }
 
 
-  FT_CALLBACK_TABLE_DEF
+  static
   const FTC_MruListClassRec  ftc_face_list_class =
   {
     sizeof ( FTC_FaceNodeRec),
     FTC_MruNode  mrunode;
 
 
-    if ( aface == NULL )
+    if ( !aface || !face_id )
       return FT_THROW( Invalid_Argument );
 
     *aface = NULL;
     if ( !library )
       return FT_THROW( Invalid_Library_Handle );
 
+    if ( !amanager || !requester )
+      return FT_THROW( Invalid_Argument );
+
     memory = library->memory;
 
     if ( FT_NEW( manager ) )
   FT_EXPORT_DEF( void )
   FTC_Manager_Reset( FTC_Manager  manager )
   {
-    if ( manager )
-    {
-      FTC_MruList_Reset( &manager->sizes );
-      FTC_MruList_Reset( &manager->faces );
-    }
+    if ( !manager )
+      return;
+
+    FTC_MruList_Reset( &manager->sizes );
+    FTC_MruList_Reset( &manager->faces );
 
     FTC_Manager_FlushN( manager, manager->num_nodes );
   }
   {
     FT_UInt  nn;
 
+
+    if ( !manager || !face_id )
+      return;
+
     /* this will remove all FTC_SizeNode that correspond to
      * the face_id as well
      */
   FTC_Node_Unref( FTC_Node     node,
                   FTC_Manager  manager )
   {
-    if ( node && (FT_UInt)node->cache_index < manager->num_caches )
+    if ( node                                             &&
+         manager                                          &&
+         (FT_UInt)node->cache_index < manager->num_caches )
       node->ref_count--;
   }
 
index 6df1c19..59727d1 100644 (file)
@@ -4,7 +4,7 @@
 /*                                                                         */
 /*    FreeType sbits manager (body).                                       */
 /*                                                                         */
-/*  Copyright 2000-2006, 2009-2011, 2013 by                                */
+/*  Copyright 2000-2006, 2009-2011, 2013, 2014 by                          */
 /*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
 /*                                                                         */
 /*  This file is part of the FreeType project, and may only be used,       */
         goto BadGlyph;
       }
 
-      /* Check that our values fit into 8-bit containers!       */
+      /* Check whether our values fit into 8-bit containers!    */
       /* If this is not the case, our bitmap is too large       */
       /* and we will leave it as `missing' with sbit.buffer = 0 */
 
-#define CHECK_CHAR( d )  ( temp = (FT_Char)d, temp == d )
-#define CHECK_BYTE( d )  ( temp = (FT_Byte)d, temp == d )
+#define CHECK_CHAR( d )  ( temp = (FT_Char)d, (FT_Int) temp == (FT_Int) d )
+#define CHECK_BYTE( d )  ( temp = (FT_Byte)d, (FT_UInt)temp == (FT_UInt)d )
 
       /* horizontal advance in pixels */
       xadvance = ( slot->advance.x + 32 ) >> 6;
index 6e99dc2..83fd348 100644 (file)
@@ -36,6 +36,9 @@
 /***************************************************************************/
 
 
+#include <ft2build.h>
+#include FT_INTERNAL_CALC_H
+
 #include "cf2ft.h"
 
 #include "cf2glue.h"
     /* adjusting for emRatio converts darkenAmount to character */
     /* space (font units).                                      */
     CF2_Fixed  stemWidthPer1000, scaledStem;
+    FT_Int     logBase2;
 
 
     *darkenAmount = 0;
       /* convert from true character space to 1000 unit character space; */
       /* add synthetic emboldening effect                                */
 
-      /* we have to assure that the computation of `scaledStem' */
-      /* and `stemWidthPer1000' don't overflow                  */
+      /* `stemWidthPer1000' will not overflow for a legitimate font      */
 
       stemWidthPer1000 = FT_MulFix( stemWidth + boldenAmount, emRatio );
 
-      if ( emRatio > CF2_FIXED_ONE                          &&
-           stemWidthPer1000 <= ( stemWidth + boldenAmount ) )
-      {
-        stemWidthPer1000 = 0;                      /* to pacify compiler */
-        scaledStem       = cf2_intToFixed( x4 );
-      }
+      /* `scaledStem' can easily overflow, so we must clamp its maximum  */
+      /* value; the test doesn't need to be precise, but must be         */
+      /* conservative.  The clamp value (default 2333) where             */
+      /* `darkenAmount' is zero is well below the overflow value of      */
+      /* 32767.                                                          */
+      /*                                                                 */
+      /* FT_MSB computes the integer part of the base 2 logarithm.  The  */
+      /* number of bits for the product is 1 or 2 more than the sum of   */
+      /* logarithms; remembering that the 16 lowest bits of the fraction */
+      /* are dropped this is correct to within a factor of almost 4.     */
+      /* For example, 0x80.0000 * 0x80.0000 = 0x4000.0000 is 23+23 and   */
+      /* is flagged as possible overflow because 0xFF.FFFF * 0xFF.FFFF = */
+      /* 0xFFFF.FE00 is also 23+23.                                      */
+
+      logBase2 = FT_MSB( (FT_UInt32)stemWidthPer1000 ) +
+                   FT_MSB( (FT_UInt32)ppem );
+
+      if ( logBase2 >= 46 )
+        /* possible overflow */
+        scaledStem = cf2_intToFixed( x4 );
       else
-      {
         scaledStem = FT_MulFix( stemWidthPer1000, ppem );
 
-        if ( ppem > CF2_FIXED_ONE           &&
-             scaledStem <= stemWidthPer1000 )
-          scaledStem = cf2_intToFixed( x4 );
-      }
-
       /* now apply the darkening parameters */
 
       if ( scaledStem < cf2_intToFixed( x1 ) )
index cb8d31c..ebba469 100644 (file)
   cf2_builder_lineTo( CF2_OutlineCallbacks      callbacks,
                       const CF2_CallbackParams  params )
   {
+    FT_Error  error;
+
     /* downcast the object pointer */
     CF2_Outline   outline = (CF2_Outline)callbacks;
     CFF_Builder*  builder;
     {
       /* record the move before the line; also check points and set */
       /* `path_begun'                                               */
-      cff_builder_start_point( builder,
-                               params->pt0.x,
-                               params->pt0.y );
+      error = cff_builder_start_point( builder,
+                                       params->pt0.x,
+                                       params->pt0.y );
+      if ( error )
+      {
+        if ( !*callbacks->error )
+          *callbacks->error =  error;
+        return;
+      }
     }
 
     /* `cff_builder_add_point1' includes a check_points call for one point */
-    cff_builder_add_point1( builder,
-                            params->pt1.x,
-                            params->pt1.y );
+    error = cff_builder_add_point1( builder,
+                                    params->pt1.x,
+                                    params->pt1.y );
+    if ( error )
+    {
+      if ( !*callbacks->error )
+        *callbacks->error =  error;
+      return;
+    }
   }
 
 
   cf2_builder_cubeTo( CF2_OutlineCallbacks      callbacks,
                       const CF2_CallbackParams  params )
   {
+    FT_Error  error;
+
     /* downcast the object pointer */
     CF2_Outline   outline = (CF2_Outline)callbacks;
     CFF_Builder*  builder;
     {
       /* record the move before the line; also check points and set */
       /* `path_begun'                                               */
-      cff_builder_start_point( builder,
-                               params->pt0.x,
-                               params->pt0.y );
+      error = cff_builder_start_point( builder,
+                                       params->pt0.x,
+                                       params->pt0.y );
+      if ( error )
+      {
+        if ( !*callbacks->error )
+          *callbacks->error =  error;
+        return;
+      }
     }
 
     /* prepare room for 3 points: 2 off-curve, 1 on-curve */
-    cff_check_points( builder, 3 );
+    error = cff_check_points( builder, 3 );
+    if ( error )
+    {
+      if ( !*callbacks->error )
+        *callbacks->error =  error;
+      return;
+    }
 
     cff_builder_add_point( builder,
                            params->pt1.x,
index 5853d77..040d193 100644 (file)
   cf2_hintmap_map( CF2_HintMap  hintmap,
                    CF2_Fixed    csCoord )
   {
-    FT_ASSERT( hintmap->isValid );  /* must call Build before Map */
-    FT_ASSERT( hintmap->lastIndex < CF2_MAX_HINT_EDGES );
-
     if ( hintmap->count == 0 || ! hintmap->hinted )
     {
       /* there are no hints; use uniform scale and zero offset */
       /* start linear search from last hit */
       CF2_UInt  i = hintmap->lastIndex;
 
+      FT_ASSERT( hintmap->lastIndex < CF2_MAX_HINT_EDGES );
 
       /* search up */
       while ( i < hintmap->count - 1                  &&
     maskPtr      = cf2_hintmask_getMaskPtr( &tempHintMask );
 
     /* use the hStem hints only, which are first in the mask */
-    /* TODO: compare this to cffhintmaskGetBitCount */
     bitCount = cf2_arrstack_size( hStemHintArray );
 
+    /* Defense-in-depth.  Should never return here. */
+    if ( bitCount > hintMask->bitCount )
+        return;
+
     /* synthetic embox hints get highest priority */
     if ( font->blues.doEmBoxHints )
     {
         {
           /* -y */
           *x = -glyphpath->xOffset;
-          *y = glyphpath->xOffset;
+          *y = glyphpath->yOffset;
         }
         else
         {
 
     if ( glyphpath->elemIsQueued )
     {
-      FT_ASSERT( cf2_hintmap_isValid( &glyphpath->hintMap ) );
+      FT_ASSERT( cf2_hintmap_isValid( &glyphpath->hintMap ) ||
+                 glyphpath->hintMap.count == 0              );
 
       cf2_glyphpath_pushPrevElem( glyphpath,
                                   &glyphpath->hintMap,
 
     if ( glyphpath->elemIsQueued )
     {
-      FT_ASSERT( cf2_hintmap_isValid( &glyphpath->hintMap ) );
+      FT_ASSERT( cf2_hintmap_isValid( &glyphpath->hintMap ) ||
+                 glyphpath->hintMap.count == 0              );
 
       cf2_glyphpath_pushPrevElem( glyphpath,
                                   &glyphpath->hintMap,
index 5610917..a269606 100644 (file)
@@ -4,7 +4,7 @@
 /*                                                                         */
 /*    Adobe's CFF Interpreter (body).                                      */
 /*                                                                         */
-/*  Copyright 2007-2013 Adobe Systems Incorporated.                        */
+/*  Copyright 2007-2014 Adobe Systems Incorporated.                        */
 /*                                                                         */
 /*  This software, and all works of authorship, whether in source or       */
 /*  object code form as indicated by the copyright notice(s) included      */
 
         /* never add hints after the mask is computed */
         if ( cf2_hintmask_isValid( &hintMask ) )
+        {
           FT_TRACE4(( "cf2_interpT2CharString:"
                       " invalid horizontal hint mask\n" ));
+          break;
+        }
 
         cf2_doStems( font,
                      opStack,
 
         /* never add hints after the mask is computed */
         if ( cf2_hintmask_isValid( &hintMask ) )
+        {
           FT_TRACE4(( "cf2_interpT2CharString:"
                       " invalid vertical hint mask\n" ));
+          break;
+        }
 
         cf2_doStems( font,
                      opStack,
         /* `cf2_hintmask_read' (which also traces the mask bytes) */
         FT_TRACE4(( op1 == cf2_cmdCNTRMASK ? " cntrmask" : " hintmask" ));
 
-        /* if there are arguments on the stack, there this is an */
-        /* implied cf2_cmdVSTEMHM                                */
-        if ( cf2_stack_count( opStack ) != 0 )
+        /* never add hints after the mask is computed */
+        if ( cf2_stack_count( opStack ) > 1    &&
+             cf2_hintmask_isValid( &hintMask ) )
         {
-          /* never add hints after the mask is computed */
-          if ( cf2_hintmask_isValid( &hintMask ) )
-            FT_TRACE4(( "cf2_interpT2CharString: invalid hint mask\n" ));
+          FT_TRACE4(( "cf2_interpT2CharString: invalid hint mask\n" ));
+          break;
         }
 
+        /* if there are arguments on the stack, there this is an */
+        /* implied cf2_cmdVSTEMHM                                */
         cf2_doStems( font,
                      opStack,
                      &vStemHintArray,
index f6e03c6..52248b2 100644 (file)
   /*************************************************************************/
 
   FT_CALLBACK_DEF( FT_Error )
-  cff_cmap_encoding_init( CFF_CMapStd  cmap )
+  cff_cmap_encoding_init( CFF_CMapStd  cmap,
+                          FT_Pointer   pointer )
   {
     TT_Face       face     = (TT_Face)FT_CMAP_FACE( cmap );
     CFF_Font      cff      = (CFF_Font)face->extra.data;
     CFF_Encoding  encoding = &cff->encoding;
 
+    FT_UNUSED( pointer );
+
 
     cmap->gids  = encoding->codes;
 
 
 
   FT_CALLBACK_DEF( FT_Error )
-  cff_cmap_unicode_init( PS_Unicodes  unicodes )
+  cff_cmap_unicode_init( PS_Unicodes  unicodes,
+                         FT_Pointer   pointer )
   {
     TT_Face             face    = (TT_Face)FT_CMAP_FACE( unicodes );
     FT_Memory           memory  = FT_FACE_MEMORY( face );
     CFF_Charset         charset = &cff->charset;
     FT_Service_PsCMaps  psnames = (FT_Service_PsCMaps)cff->psnames;
 
+    FT_UNUSED( pointer );
+
 
     /* can't build Unicode map for CID-keyed font */
     /* because we don't know glyph names.         */
index dde7d44..3e8898e 100644 (file)
@@ -4,7 +4,7 @@
 /*                                                                         */
 /*    OpenType font driver implementation (body).                          */
 /*                                                                         */
-/*  Copyright 1996-2013 by                                                 */
+/*  Copyright 1996-2014 by                                                 */
 /*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
 /*                                                                         */
 /*  This file is part of the FreeType project, and may only be used,       */
     FT_Module_Interface  result;
 
 
-    /* CFF_SERVICES_GET derefers `library' in PIC mode */
+    /* CFF_SERVICES_GET dereferences `library' in PIC mode */
 #ifdef FT_CONFIG_OPTION_PIC
     if ( !driver )
       return NULL;
index c8e9f91..758a3d3 100644 (file)
@@ -4,7 +4,7 @@
 /*                                                                         */
 /*    OpenType Glyph Loader (body).                                        */
 /*                                                                         */
-/*  Copyright 1996-2013 by                                                 */
+/*  Copyright 1996-2014 by                                                 */
 /*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
 /*                                                                         */
 /*  This file is part of the FreeType project, and may only be used,       */
     /* callback function.                                     */
     if ( face->root.internal->incremental_interface )
     {
-      FT_Data data;
+      FT_Data  data;
 
 
       data.pointer = *pointer;
           }
           else
           {
-            if ( !error )
-              error = FT_Err_Ok;
-
             cff_builder_close_contour( builder );
 
             /* close hints recording session */
                 goto Syntax_Error;
 
               /* apply hints to the loaded glyph outline now */
-              hinter->apply( hinter->hints,
-                             builder->current,
-                             (PSH_Globals)builder->hints_globals,
-                             decoder->hint_mode );
+              error = hinter->apply( hinter->hints,
+                                     builder->current,
+                                     (PSH_Globals)builder->hints_globals,
+                                     decoder->hint_mode );
+              if ( error )
+                goto Fail;
             }
 
             /* add current outline to the glyph slot */
 
           /* compute linear advance widths */
 
-          ( (SFNT_Service)face->sfnt )->get_metrics( face, 0,
-                                                     glyph_index,
-                                                     &dummy,
-                                                     &advance );
+          (void)( (SFNT_Service)face->sfnt )->get_metrics( face, 0,
+                                                           glyph_index,
+                                                           &dummy,
+                                                           &advance );
           glyph->root.linearHoriAdvance = advance;
 
           has_vertical_info = FT_BOOL(
           /* get the vertical metrics from the vtmx table if we have one */
           if ( has_vertical_info )
           {
-            ( (SFNT_Service)face->sfnt )->get_metrics( face, 1,
-                                                       glyph_index,
-                                                       &dummy,
-                                                       &advance );
+            (void)( (SFNT_Service)face->sfnt )->get_metrics( face, 1,
+                                                             glyph_index,
+                                                             &dummy,
+                                                             &advance );
             glyph->root.linearVertAdvance = advance;
           }
           else
           FT_UShort  vertAdvance  = 0;
 
 
-          ( (SFNT_Service)face->sfnt )->get_metrics( face, 1,
-                                                     glyph_index,
-                                                     &vertBearingY,
-                                                     &vertAdvance );
+          (void)( (SFNT_Service)face->sfnt )->get_metrics( face, 1,
+                                                           glyph_index,
+                                                           &vertBearingY,
+                                                           &vertAdvance );
           metrics->vertBearingY = vertBearingY;
           metrics->vertAdvance  = vertAdvance;
         }
index cac4ac2..da3d019 100644 (file)
@@ -4,7 +4,7 @@
 /*                                                                         */
 /*    OpenType objects manager (body).                                     */
 /*                                                                         */
-/*  Copyright 1996-2013 by                                                 */
+/*  Copyright 1996-2014 by                                                 */
 /*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
 /*                                                                         */
 /*  This file is part of the FreeType project, and may only be used,       */
         if ( pure_cff && cff->top_font.font_dict.cid_registry != 0xFFFFU )
           goto Exit;
 
-#ifdef FT_MAX_CHARMAP_CACHEABLE
-        if ( nn + 1 > FT_MAX_CHARMAP_CACHEABLE )
-        {
-          FT_ERROR(( "cff_face_init: no Unicode cmap is found, "
-                     "and too many subtables (%d) to add synthesized cmap\n",
-                     nn ));
-          goto Exit;
-        }
-#endif
-
         /* we didn't find a Unicode charmap -- synthesize one */
         cmaprec.face        = cffface;
         cmaprec.platform_id = TT_PLATFORM_MICROSOFT;
           cffface->charmap = cffface->charmaps[nn];
 
       Skip_Unicode:
-#ifdef FT_MAX_CHARMAP_CACHEABLE
-        if ( nn > FT_MAX_CHARMAP_CACHEABLE )
-        {
-          FT_ERROR(( "cff_face_init: Unicode cmap is found, "
-                     "but too many preceding subtables (%d) to access\n",
-                     nn - 1 ));
-          goto Exit;
-        }
-#endif
         if ( encoding->count > 0 )
         {
           FT_CMap_Class  clazz;
     CFF_Driver  driver = (CFF_Driver)module;
 
 
-    /* set default property values, cf `ftcffdrv.h' */
+    /* set default property values, cf. `ftcffdrv.h' */
 #ifdef CFF_CONFIG_OPTION_OLD_ENGINE
-    driver->hinting_engine    = FT_CFF_HINTING_FREETYPE;
+    driver->hinting_engine = FT_CFF_HINTING_FREETYPE;
 #else
-    driver->hinting_engine    = FT_CFF_HINTING_ADOBE;
+    driver->hinting_engine = FT_CFF_HINTING_ADOBE;
 #endif
+
     driver->no_stem_darkening = FALSE;
 
-    driver->darken_params[0] =  500;
-    driver->darken_params[1] =  400;
-    driver->darken_params[2] = 1000;
-    driver->darken_params[3] =  275;
-    driver->darken_params[4] = 1667;
-    driver->darken_params[5] =  275;
-    driver->darken_params[6] = 2333;
-    driver->darken_params[7] =    0;
+    driver->darken_params[0] = CFF_CONFIG_OPTION_DARKENING_PARAMETER_X1;
+    driver->darken_params[1] = CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y1;
+    driver->darken_params[2] = CFF_CONFIG_OPTION_DARKENING_PARAMETER_X2;
+    driver->darken_params[3] = CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y2;
+    driver->darken_params[4] = CFF_CONFIG_OPTION_DARKENING_PARAMETER_X3;
+    driver->darken_params[5] = CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y3;
+    driver->darken_params[6] = CFF_CONFIG_OPTION_DARKENING_PARAMETER_X4;
+    driver->darken_params[7] = CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y4;
 
     return FT_Err_Ok;
   }
index 91bd532..c79ab62 100644 (file)
     }
 
     /* Read fraction part, if any. */
-    if ( nib == 0xa )
+    if ( nib == 0xA )
       for (;;)
       {
         /* If we entered this iteration with phase == 4, we need */
index 3d10031..d165118 100644 (file)
   static void
   gxv_bsln_LookupValue_validate( FT_UShort            glyph,
                                  GXV_LookupValueCPtr  value_p,
-                                 GXV_Validator        valid )
+                                 GXV_Validator        gxvalid )
   {
-    FT_UShort   v = value_p->u;
-    FT_UShort*  ctlPoints;
+    FT_UShort     v = value_p->u;
+    FT_UShort*    ctlPoints;
 
     FT_UNUSED( glyph );
 
   gxv_bsln_LookupFmt4_transit( FT_UShort            relative_gindex,
                                GXV_LookupValueCPtr  base_value_p,
                                FT_Bytes             lookuptbl_limit,
-                               GXV_Validator        valid )
+                               GXV_Validator        gxvalid )
   {
     FT_Bytes             p;
     FT_Bytes             limit;
     offset = (FT_UShort)( base_value_p->u +
                           ( relative_gindex * sizeof ( FT_UShort ) ) );
 
-    p     = valid->lookuptbl_head + offset;
+    p     = gxvalid->lookuptbl_head + offset;
     limit = lookuptbl_limit;
     GXV_LIMIT_CHECK( 2 );
 
   static void
   gxv_bsln_parts_fmt0_validate( FT_Bytes       tables,
                                 FT_Bytes       limit,
-                                GXV_Validator  valid )
+                                GXV_Validator  gxvalid )
   {
     FT_Bytes  p = tables;
 
     /* deltas */
     GXV_LIMIT_CHECK( 2 * GXV_BSLN_VALUE_COUNT );
 
-    valid->table_data = NULL;      /* No ctlPoints here. */
+    gxvalid->table_data = NULL;      /* No ctlPoints here. */
 
     GXV_EXIT;
   }
   static void
   gxv_bsln_parts_fmt1_validate( FT_Bytes       tables,
                                 FT_Bytes       limit,
-                                GXV_Validator  valid )
+                                GXV_Validator  gxvalid )
   {
     FT_Bytes  p = tables;
 
     GXV_NAME_ENTER( "parts format 1" );
 
     /* deltas */
-    gxv_bsln_parts_fmt0_validate( p, limit, valid );
+    gxv_bsln_parts_fmt0_validate( p, limit, gxvalid );
 
     /* mappingData */
-    valid->lookupval_sign   = GXV_LOOKUPVALUE_UNSIGNED;
-    valid->lookupval_func   = gxv_bsln_LookupValue_validate;
-    valid->lookupfmt4_trans = gxv_bsln_LookupFmt4_transit;
+    gxvalid->lookupval_sign   = GXV_LOOKUPVALUE_UNSIGNED;
+    gxvalid->lookupval_func   = gxv_bsln_LookupValue_validate;
+    gxvalid->lookupfmt4_trans = gxv_bsln_LookupFmt4_transit;
     gxv_LookupTable_validate( p + 2 * GXV_BSLN_VALUE_COUNT,
                               limit,
-                              valid );
+                              gxvalid );
 
     GXV_EXIT;
   }
   static void
   gxv_bsln_parts_fmt2_validate( FT_Bytes       tables,
                                 FT_Bytes       limit,
-                                GXV_Validator  valid )
+                                GXV_Validator  gxvalid )
   {
     FT_Bytes   p = tables;
 
     stdGlyph = FT_NEXT_USHORT( p );
     GXV_TRACE(( " (stdGlyph = %u)\n", stdGlyph ));
 
-    gxv_glyphid_validate( stdGlyph, valid );
+    gxv_glyphid_validate( stdGlyph, gxvalid );
 
     /* Record the position of ctlPoints */
     GXV_BSLN_DATA( ctlPoints_p ) = p;
           FT_INVALID_DATA;
       }
       else
-        gxv_ctlPoint_validate( stdGlyph, (FT_Short)ctlPoint, valid );
+        gxv_ctlPoint_validate( stdGlyph, (FT_Short)ctlPoint, gxvalid );
     }
 
     GXV_EXIT;
   static void
   gxv_bsln_parts_fmt3_validate( FT_Bytes       tables,
                                 FT_Bytes       limit,
-                                GXV_Validator  valid)
+                                GXV_Validator  gxvalid)
   {
     FT_Bytes  p = tables;
 
     GXV_NAME_ENTER( "parts format 3" );
 
     /* stdGlyph + ctlPoints */
-    gxv_bsln_parts_fmt2_validate( p, limit, valid );
+    gxv_bsln_parts_fmt2_validate( p, limit, gxvalid );
 
     /* mappingData */
-    valid->lookupval_sign   = GXV_LOOKUPVALUE_UNSIGNED;
-    valid->lookupval_func   = gxv_bsln_LookupValue_validate;
-    valid->lookupfmt4_trans = gxv_bsln_LookupFmt4_transit;
+    gxvalid->lookupval_sign   = GXV_LOOKUPVALUE_UNSIGNED;
+    gxvalid->lookupval_func   = gxv_bsln_LookupValue_validate;
+    gxvalid->lookupfmt4_trans = gxv_bsln_LookupFmt4_transit;
     gxv_LookupTable_validate( p + ( 2 + 2 * GXV_BSLN_VALUE_COUNT ),
                               limit,
-                              valid );
+                              gxvalid );
 
     GXV_EXIT;
   }
                      FT_Face       face,
                      FT_Validator  ftvalid )
   {
-    GXV_ValidatorRec  validrec;
-    GXV_Validator     valid = &validrec;
+    GXV_ValidatorRec  gxvalidrec;
+    GXV_Validator     gxvalid = &gxvalidrec;
 
     GXV_bsln_DataRec  bslnrec;
     GXV_bsln_Data     bsln = &bslnrec;
     };
 
 
-    valid->root       = ftvalid;
-    valid->table_data = bsln;
-    valid->face       = face;
+    gxvalid->root       = ftvalid;
+    gxvalid->table_data = bsln;
+    gxvalid->face       = face;
 
     FT_TRACE3(( "validating `bsln' table\n" ));
     GXV_INIT;
 
     bsln->defaultBaseline = defaultBaseline;
 
-    fmt_funcs_table[format]( p, limit, valid );
+    fmt_funcs_table[format]( p, limit, gxvalid );
 
     FT_TRACE4(( "\n" ));
   }
index 7af5234..8e72a72 100644 (file)
@@ -65,7 +65,7 @@
                                    FT_UShort*     buff,
                                    FT_UInt        nmemb,
                                    FT_UShort      limit,
-                                   GXV_Validator  valid )
+                                   GXV_Validator  gxvalid )
   {
     FT_UInt  i;
 
                                   FT_ULong*      buff,
                                   FT_UInt        nmemb,
                                   FT_ULong       limit,
-                                  GXV_Validator  valid)
+                                  GXV_Validator  gxvalid)
   {
     FT_UInt  i;
 
                             FT_Bytes       limit,
                             FT_Byte*       min,
                             FT_Byte*       max,
-                            GXV_Validator  valid )
+                            GXV_Validator  gxvalid )
   {
     FT_Bytes  p = table;
 
       *max = (FT_Byte)FT_MAX( *max, val );
     }
 
-    valid->subtable_length = p - table;
+    gxvalid->subtable_length = p - table;
   }
 
 
                               FT_Bytes       limit,
                               FT_UShort*     min,
                               FT_UShort*     max,
-                              GXV_Validator  valid )
+                              GXV_Validator  gxvalid )
   {
     FT_Bytes  p = table;
 
       *max = (FT_Byte)FT_MAX( *max, val );
     }
 
-    valid->subtable_length = p - table;
+    gxvalid->subtable_length = p - table;
   }
 
 
 
   static void
   gxv_BinSrchHeader_check_consistency( GXV_BinSrchHeader*  binSrchHeader,
-                                       GXV_Validator       valid )
+                                       GXV_Validator       gxvalid )
   {
     FT_UShort  searchRange;
     FT_UShort  entrySelector;
                               FT_Bytes       limit,
                               FT_UShort*     unitSize_p,
                               FT_UShort*     nUnits_p,
-                              GXV_Validator  valid )
+                              GXV_Validator  gxvalid )
   {
     FT_Bytes           p = table;
     GXV_BinSrchHeader  binSrchHeader;
     binSrchHeader.rangeShift    = FT_NEXT_USHORT( p );
     GXV_TRACE(( "nUnits %d\n", binSrchHeader.nUnits ));
 
-    gxv_BinSrchHeader_check_consistency( &binSrchHeader, valid );
+    gxv_BinSrchHeader_check_consistency( &binSrchHeader, gxvalid );
 
     if ( *unitSize_p == 0 )
       *unitSize_p = binSrchHeader.unitSize;
     if ( *nUnits_p == 0 )
       *nUnits_p = binSrchHeader.nUnits;
 
-    valid->subtable_length = p - table;
+    gxvalid->subtable_length = p - table;
     GXV_EXIT;
   }
 
   static void
   gxv_LookupTable_fmt0_validate( FT_Bytes       table,
                                  FT_Bytes       limit,
-                                 GXV_Validator  valid )
+                                 GXV_Validator  gxvalid )
   {
     FT_Bytes   p = table;
     FT_UShort  i;
 
     GXV_NAME_ENTER( "LookupTable format 0" );
 
-    GXV_LIMIT_CHECK( 2 * valid->face->num_glyphs );
+    GXV_LIMIT_CHECK( 2 * gxvalid->face->num_glyphs );
 
-    for ( i = 0; i < valid->face->num_glyphs; i++ )
+    for ( i = 0; i < gxvalid->face->num_glyphs; i++ )
     {
       GXV_LIMIT_CHECK( 2 );
       if ( p + 2 >= limit )     /* some fonts have too-short fmt0 array */
       {
         GXV_TRACE(( "too short, glyphs %d - %d are missing\n",
-                    i, valid->face->num_glyphs ));
+                    i, gxvalid->face->num_glyphs ));
         GXV_SET_ERR_IF_PARANOID( FT_INVALID_GLYPH_ID );
         break;
       }
 
-      value = GXV_LOOKUP_VALUE_LOAD( p, valid->lookupval_sign );
-      valid->lookupval_func( i, &value, valid );
+      value = GXV_LOOKUP_VALUE_LOAD( p, gxvalid->lookupval_sign );
+      gxvalid->lookupval_func( i, &value, gxvalid );
     }
 
-    valid->subtable_length = p - table;
+    gxvalid->subtable_length = p - table;
     GXV_EXIT;
   }
 
   static void
   gxv_LookupTable_fmt2_skip_endmarkers( FT_Bytes       table,
                                         FT_UShort      unitSize,
-                                        GXV_Validator  valid )
+                                        GXV_Validator  gxvalid )
   {
     FT_Bytes  p = table;
 
 
-    while ( ( p + 4 ) < valid->root->limit )
+    while ( ( p + 4 ) < gxvalid->root->limit )
     {
       if ( p[0] != 0xFF || p[1] != 0xFF || /* lastGlyph */
            p[2] != 0xFF || p[3] != 0xFF )  /* firstGlyph */
       p += unitSize;
     }
 
-    valid->subtable_length = p - table;
+    gxvalid->subtable_length = p - table;
   }
 
 
   static void
   gxv_LookupTable_fmt2_validate( FT_Bytes       table,
                                  FT_Bytes       limit,
-                                 GXV_Validator  valid )
+                                 GXV_Validator  gxvalid )
   {
     FT_Bytes             p = table;
     FT_UShort            gid;
     GXV_NAME_ENTER( "LookupTable format 2" );
 
     unitSize = nUnits = 0;
-    gxv_BinSrchHeader_validate( p, limit, &unitSize, &nUnits, valid );
-    p += valid->subtable_length;
+    gxv_BinSrchHeader_validate( p, limit, &unitSize, &nUnits, gxvalid );
+    p += gxvalid->subtable_length;
 
     GXV_UNITSIZE_VALIDATE( "format2", unitSize, nUnits, 6 );
 
       GXV_LIMIT_CHECK( 2 + 2 + 2 );
       lastGlyph  = FT_NEXT_USHORT( p );
       firstGlyph = FT_NEXT_USHORT( p );
-      value      = GXV_LOOKUP_VALUE_LOAD( p, valid->lookupval_sign );
+      value      = GXV_LOOKUP_VALUE_LOAD( p, gxvalid->lookupval_sign );
 
-      gxv_glyphid_validate( firstGlyph, valid );
-      gxv_glyphid_validate( lastGlyph, valid );
+      gxv_glyphid_validate( firstGlyph, gxvalid );
+      gxv_glyphid_validate( lastGlyph, gxvalid );
 
       if ( lastGlyph < gid )
       {
                     unit, lastGlyph, firstGlyph ));
         GXV_SET_ERR_IF_PARANOID( FT_INVALID_GLYPH_ID );
 
-        if ( valid->root->level == FT_VALIDATE_TIGHT )
+        if ( gxvalid->root->level == FT_VALIDATE_TIGHT )
           continue;     /* ftxvalidator silently skips such an entry */
 
         FT_TRACE4(( "continuing with exchanged values\n" ));
       }
 
       for ( gid = firstGlyph; gid <= lastGlyph; gid++ )
-        valid->lookupval_func( gid, &value, valid );
+        gxvalid->lookupval_func( gid, &value, gxvalid );
     }
 
-    gxv_LookupTable_fmt2_skip_endmarkers( p, unitSize, valid );
-    p += valid->subtable_length;
+    gxv_LookupTable_fmt2_skip_endmarkers( p, unitSize, gxvalid );
+    p += gxvalid->subtable_length;
 
-    valid->subtable_length = p - table;
+    gxvalid->subtable_length = p - table;
     GXV_EXIT;
   }
 
   static void
   gxv_LookupTable_fmt4_validate( FT_Bytes       table,
                                  FT_Bytes       limit,
-                                 GXV_Validator  valid )
+                                 GXV_Validator  gxvalid )
   {
     FT_Bytes             p = table;
     FT_UShort            unit;
     GXV_NAME_ENTER( "LookupTable format 4" );
 
     unitSize = nUnits = 0;
-    gxv_BinSrchHeader_validate( p, limit, &unitSize, &nUnits, valid );
-    p += valid->subtable_length;
+    gxv_BinSrchHeader_validate( p, limit, &unitSize, &nUnits, gxvalid );
+    p += gxvalid->subtable_length;
 
     GXV_UNITSIZE_VALIDATE( "format4", unitSize, nUnits, 6 );
 
       lastGlyph  = FT_NEXT_USHORT( p );
       firstGlyph = FT_NEXT_USHORT( p );
 
-      gxv_glyphid_validate( firstGlyph, valid );
-      gxv_glyphid_validate( lastGlyph, valid );
+      gxv_glyphid_validate( firstGlyph, gxvalid );
+      gxv_glyphid_validate( lastGlyph, gxvalid );
 
       if ( lastGlyph < gid )
       {
                     unit, lastGlyph, firstGlyph ));
         GXV_SET_ERR_IF_PARANOID( FT_INVALID_GLYPH_ID );
 
-        if ( valid->root->level == FT_VALIDATE_TIGHT )
+        if ( gxvalid->root->level == FT_VALIDATE_TIGHT )
           continue; /* ftxvalidator silently skips such an entry */
 
         FT_TRACE4(( "continuing with exchanged values\n" ));
 
       for ( gid = firstGlyph; gid <= lastGlyph; gid++ )
       {
-        value = valid->lookupfmt4_trans( (FT_UShort)( gid - firstGlyph ),
+        value = gxvalid->lookupfmt4_trans( (FT_UShort)( gid - firstGlyph ),
                                          &base_value,
                                          limit,
-                                         valid );
+                                         gxvalid );
 
-        valid->lookupval_func( gid, &value, valid );
+        gxvalid->lookupval_func( gid, &value, gxvalid );
       }
     }
 
-    gxv_LookupTable_fmt2_skip_endmarkers( p, unitSize, valid );
-    p += valid->subtable_length;
+    gxv_LookupTable_fmt2_skip_endmarkers( p, unitSize, gxvalid );
+    p += gxvalid->subtable_length;
 
-    valid->subtable_length = p - table;
+    gxvalid->subtable_length = p - table;
     GXV_EXIT;
   }
 
   static void
   gxv_LookupTable_fmt6_skip_endmarkers( FT_Bytes       table,
                                         FT_UShort      unitSize,
-                                        GXV_Validator  valid )
+                                        GXV_Validator  gxvalid )
   {
     FT_Bytes  p = table;
 
 
-    while ( p < valid->root->limit )
+    while ( p < gxvalid->root->limit )
     {
       if ( p[0] != 0xFF || p[1] != 0xFF )
         break;
       p += unitSize;
     }
 
-    valid->subtable_length = p - table;
+    gxvalid->subtable_length = p - table;
   }
 
 
   static void
   gxv_LookupTable_fmt6_validate( FT_Bytes       table,
                                  FT_Bytes       limit,
-                                 GXV_Validator  valid )
+                                 GXV_Validator  gxvalid )
   {
     FT_Bytes             p = table;
     FT_UShort            unit;
     GXV_NAME_ENTER( "LookupTable format 6" );
 
     unitSize = nUnits = 0;
-    gxv_BinSrchHeader_validate( p, limit, &unitSize, &nUnits, valid );
-    p += valid->subtable_length;
+    gxv_BinSrchHeader_validate( p, limit, &unitSize, &nUnits, gxvalid );
+    p += gxvalid->subtable_length;
 
     GXV_UNITSIZE_VALIDATE( "format6", unitSize, nUnits, 4 );
 
     {
       GXV_LIMIT_CHECK( 2 + 2 );
       glyph = FT_NEXT_USHORT( p );
-      value = GXV_LOOKUP_VALUE_LOAD( p, valid->lookupval_sign );
+      value = GXV_LOOKUP_VALUE_LOAD( p, gxvalid->lookupval_sign );
 
-      if ( gxv_glyphid_validate( glyph, valid ) )
+      if ( gxv_glyphid_validate( glyph, gxvalid ) )
         GXV_TRACE(( " endmarker found within defined range"
                     " (entry %d < nUnits=%d)\n",
                     unit, nUnits ));
       }
       prev_glyph = glyph;
 
-      valid->lookupval_func( glyph, &value, valid );
+      gxvalid->lookupval_func( glyph, &value, gxvalid );
     }
 
-    gxv_LookupTable_fmt6_skip_endmarkers( p, unitSize, valid );
-    p += valid->subtable_length;
+    gxv_LookupTable_fmt6_skip_endmarkers( p, unitSize, gxvalid );
+    p += gxvalid->subtable_length;
 
-    valid->subtable_length = p - table;
+    gxvalid->subtable_length = p - table;
     GXV_EXIT;
   }
 
   static void
   gxv_LookupTable_fmt8_validate( FT_Bytes       table,
                                  FT_Bytes       limit,
-                                 GXV_Validator  valid )
+                                 GXV_Validator  gxvalid )
   {
     FT_Bytes              p = table;
     FT_UShort             i;
     firstGlyph = FT_NEXT_USHORT( p );
     glyphCount = FT_NEXT_USHORT( p );
 
-    gxv_glyphid_validate( firstGlyph, valid );
-    gxv_glyphid_validate( (FT_UShort)( firstGlyph + glyphCount ), valid );
+    gxv_glyphid_validate( firstGlyph, gxvalid );
+    gxv_glyphid_validate( (FT_UShort)( firstGlyph + glyphCount ), gxvalid );
 
     /* valueArray */
     for ( i = 0; i < glyphCount; i++ )
     {
       GXV_LIMIT_CHECK( 2 );
-      value = GXV_LOOKUP_VALUE_LOAD( p, valid->lookupval_sign );
-      valid->lookupval_func( (FT_UShort)( firstGlyph + i ), &value, valid );
+      value = GXV_LOOKUP_VALUE_LOAD( p, gxvalid->lookupval_sign );
+      gxvalid->lookupval_func( (FT_UShort)( firstGlyph + i ), &value, gxvalid );
     }
 
-    valid->subtable_length = p - table;
+    gxvalid->subtable_length = p - table;
     GXV_EXIT;
   }
 
   FT_LOCAL_DEF( void )
   gxv_LookupTable_validate( FT_Bytes       table,
                             FT_Bytes       limit,
-                            GXV_Validator  valid )
+                            GXV_Validator  gxvalid )
   {
     FT_Bytes   p = table;
     FT_UShort  format;
     GXV_NAME_ENTER( "LookupTable" );
 
     /* lookuptbl_head may be used in fmt4 transit function. */
-    valid->lookuptbl_head = table;
+    gxvalid->lookuptbl_head = table;
 
     /* format */
     GXV_LIMIT_CHECK( 2 );
     if ( func == NULL )
       FT_INVALID_FORMAT;
 
-    func( p, limit, valid );
-    p += valid->subtable_length;
+    func( p, limit, gxvalid );
+    p += gxvalid->subtable_length;
 
-    valid->subtable_length = p - table;
+    gxvalid->subtable_length = p - table;
 
     GXV_EXIT;
   }
 
   FT_LOCAL_DEF( FT_Int )
   gxv_glyphid_validate( FT_UShort      gid,
-                        GXV_Validator  valid )
+                        GXV_Validator  gxvalid )
   {
     FT_Face  face;
 
       return 1;
     }
 
-    face = valid->face;
+    face = gxvalid->face;
     if ( face->num_glyphs < gid )
     {
       GXV_TRACE(( " gxv_glyphid_check() gid overflow: num_glyphs %d < %d\n",
   FT_LOCAL_DEF( void )
   gxv_ctlPoint_validate( FT_UShort      gid,
                          FT_Short       ctl_point,
-                         GXV_Validator  valid )
+                         GXV_Validator  gxvalid )
   {
     FT_Face       face;
     FT_Error      error;
     short         n_points;
 
 
-    face = valid->face;
+    face = gxvalid->face;
 
     error = FT_Load_Glyph( face,
                            gid,
   gxv_sfntName_validate( FT_UShort      name_index,
                          FT_UShort      min_index,
                          FT_UShort      max_index,
-                         GXV_Validator  valid )
+                         GXV_Validator  gxvalid )
   {
     FT_SfntName  name;
     FT_UInt      i;
     if ( name_index < min_index || max_index < name_index )
       FT_INVALID_FORMAT;
 
-    nnames = FT_Get_Sfnt_Name_Count( valid->face );
+    nnames = FT_Get_Sfnt_Name_Count( gxvalid->face );
     for ( i = 0; i < nnames; i++ )
     {
-      if ( FT_Get_Sfnt_Name( valid->face, i, &name ) != FT_Err_Ok )
+      if ( FT_Get_Sfnt_Name( gxvalid->face, i, &name ) != FT_Err_Ok )
         continue ;
 
       if ( name.name_id == name_index )
                            FT_UShort*     length_p,
                            FT_UShort      stateSize,
                            FT_Byte*       maxClassID_p,
-                           GXV_Validator  valid )
+                           GXV_Validator  gxvalid )
   {
     FT_Bytes   p     = table;
     FT_Bytes   limit = table + *length_p;
     if ( !nGlyphs )
       goto Out;
 
-    gxv_glyphid_validate( (FT_UShort)( firstGlyph + nGlyphs ), valid );
+    gxv_glyphid_validate( (FT_UShort)( firstGlyph + nGlyphs ), gxvalid );
 
     {
       FT_Byte    nGlyphInClass[256];
                            FT_UShort      stateSize,
                            FT_Byte*       maxState_p,
                            FT_Byte*       maxEntry_p,
-                           GXV_Validator  valid )
+                           GXV_Validator  gxvalid )
   {
-    FT_Bytes  p = table;
+    FT_Bytes  p     = table;
     FT_Bytes  limit = table + *length_p;
     FT_Byte   clazz;
     FT_Byte   entry;
                            FT_Byte        maxClassID,
                            FT_Bytes       statetable_table,
                            FT_Bytes       statetable_limit,
-                           GXV_Validator  valid )
+                           GXV_Validator  gxvalid )
   {
     FT_Bytes  p     = table;
     FT_Bytes  limit = table + *length_p;
         goto Exit;
       }
 
-      if ( NULL != valid->statetable.entry_validate_func )
-        valid->statetable.entry_validate_func( state,
-                                               flags,
-                                               &glyphOffset,
-                                               statetable_table,
-                                               statetable_limit,
-                                               valid );
+      if ( NULL != gxvalid->statetable.entry_validate_func )
+        gxvalid->statetable.entry_validate_func( state,
+                                                 flags,
+                                                 &glyphOffset,
+                                                 statetable_table,
+                                                 statetable_limit,
+                                                 gxvalid );
     }
 
   Exit:
                                  FT_UShort*     classTable_length_p,
                                  FT_UShort*     stateArray_length_p,
                                  FT_UShort*     entryTable_length_p,
-                                 GXV_Validator  valid )
+                                 GXV_Validator  gxvalid )
   {
     FT_UShort   o[3];
     FT_UShort*  l[3];
     l[1] = stateArray_length_p;
     l[2] = entryTable_length_p;
 
-    gxv_set_length_by_ushort_offset( o, l, buff, 3, table_size, valid );
+    gxv_set_length_by_ushort_offset( o, l, buff, 3, table_size, gxvalid );
   }
 
 
   FT_LOCAL_DEF( void )
   gxv_StateTable_validate( FT_Bytes       table,
                            FT_Bytes       limit,
-                           GXV_Validator  valid )
+                           GXV_Validator  gxvalid )
   {
     FT_UShort   stateSize;
     FT_UShort   classTable;     /* offset to Class(Sub)Table */
     if ( stateSize > 0xFF )
       FT_INVALID_DATA;
 
-    if ( valid->statetable.optdata_load_func != NULL )
-      valid->statetable.optdata_load_func( p, limit, valid );
+    if ( gxvalid->statetable.optdata_load_func != NULL )
+      gxvalid->statetable.optdata_load_func( p, limit, gxvalid );
 
-    if ( valid->statetable.subtable_setup_func != NULL)
-      setup_func = valid->statetable.subtable_setup_func;
+    if ( gxvalid->statetable.subtable_setup_func != NULL)
+      setup_func = gxvalid->statetable.subtable_setup_func;
     else
       setup_func = gxv_StateTable_subtable_setup;
 
                 &classTable_length,
                 &stateArray_length,
                 &entryTable_length,
-                valid );
+                gxvalid );
 
     GXV_TRACE(( "StateTable Subtables\n" ));
 
                                &classTable_length,
                                stateSize,
                                &maxClassID,
-                               valid );
+                               gxvalid );
     else
       maxClassID = (FT_Byte)( stateSize - 1 );
 
                                stateSize,
                                &maxState,
                                &maxEntry,
-                               valid );
+                               gxvalid );
     else
     {
 #if 0
                                maxClassID,
                                table,
                                limit,
-                               valid );
+                               gxvalid );
 
     GXV_EXIT;
   }
                                   FT_ULong*      classTable_length_p,
                                   FT_ULong*      stateArray_length_p,
                                   FT_ULong*      entryTable_length_p,
-                                  GXV_Validator  valid )
+                                  GXV_Validator  gxvalid )
   {
     FT_ULong   o[3];
     FT_ULong*  l[3];
     l[1] = stateArray_length_p;
     l[2] = entryTable_length_p;
 
-    gxv_set_length_by_ulong_offset( o, l, buff, 3, table_size, valid );
+    gxv_set_length_by_ulong_offset( o, l, buff, 3, table_size, gxvalid );
   }
 
 
   static void
   gxv_XClassTable_lookupval_validate( FT_UShort            glyph,
                                       GXV_LookupValueCPtr  value_p,
-                                      GXV_Validator        valid )
+                                      GXV_Validator        gxvalid )
   {
     FT_UNUSED( glyph );
 
-    if ( value_p->u >= valid->xstatetable.nClasses )
+    if ( value_p->u >= gxvalid->xstatetable.nClasses )
       FT_INVALID_DATA;
-    if ( value_p->u > valid->xstatetable.maxClassID )
-      valid->xstatetable.maxClassID = value_p->u;
+    if ( value_p->u > gxvalid->xstatetable.maxClassID )
+      gxvalid->xstatetable.maxClassID = value_p->u;
   }
 
 
   gxv_XClassTable_lookupfmt4_transit( FT_UShort            relative_gindex,
                                       GXV_LookupValueCPtr  base_value_p,
                                       FT_Bytes             lookuptbl_limit,
-                                      GXV_Validator        valid )
+                                      GXV_Validator        gxvalid )
   {
     FT_Bytes             p;
     FT_Bytes             limit;
     offset = (FT_UShort)( base_value_p->u +
                           relative_gindex * sizeof ( FT_UShort ) );
 
-    p     = valid->lookuptbl_head + offset;
+    p     = gxvalid->lookuptbl_head + offset;
     limit = lookuptbl_limit;
 
     GXV_LIMIT_CHECK ( 2 );
                             FT_ULong       stateSize,
                             FT_UShort*     maxState_p,
                             FT_UShort*     maxEntry_p,
-                            GXV_Validator  valid )
+                            GXV_Validator  gxvalid )
   {
     FT_Bytes   p = table;
     FT_Bytes   limit = table + *length_p;
                             FT_UShort      maxClassID,
                             FT_Bytes       xstatetable_table,
                             FT_Bytes       xstatetable_limit,
-                            GXV_Validator  valid )
+                            GXV_Validator  gxvalid )
   {
     FT_Bytes   p = table;
     FT_Bytes   limit = table + *length_p;
         goto Exit;
       }
 
-      if ( NULL != valid->xstatetable.entry_validate_func )
-        valid->xstatetable.entry_validate_func( state,
-                                                flags,
-                                                &glyphOffset,
-                                                xstatetable_table,
-                                                xstatetable_limit,
-                                                valid );
+      if ( NULL != gxvalid->xstatetable.entry_validate_func )
+        gxvalid->xstatetable.entry_validate_func( state,
+                                                  flags,
+                                                  &glyphOffset,
+                                                  xstatetable_table,
+                                                  xstatetable_limit,
+                                                  gxvalid );
     }
 
   Exit:
   FT_LOCAL_DEF( void )
   gxv_XStateTable_validate( FT_Bytes       table,
                             FT_Bytes       limit,
-                            GXV_Validator  valid )
+                            GXV_Validator  gxvalid )
   {
     /* StateHeader members */
     FT_ULong   classTable;      /* offset to Class(Sub)Table */
     GXV_TRACE(( "XStateTable header\n" ));
 
     GXV_LIMIT_CHECK( 4 + 4 + 4 + 4 );
-    valid->xstatetable.nClasses = FT_NEXT_ULONG( p );
+    gxvalid->xstatetable.nClasses = FT_NEXT_ULONG( p );
     classTable = FT_NEXT_ULONG( p );
     stateArray = FT_NEXT_ULONG( p );
     entryTable = FT_NEXT_ULONG( p );
 
-    GXV_TRACE(( "nClasses =0x%08x\n", valid->xstatetable.nClasses ));
+    GXV_TRACE(( "nClasses =0x%08x\n", gxvalid->xstatetable.nClasses ));
     GXV_TRACE(( "offset to classTable=0x%08x\n", classTable ));
     GXV_TRACE(( "offset to stateArray=0x%08x\n", stateArray ));
     GXV_TRACE(( "offset to entryTable=0x%08x\n", entryTable ));
 
-    if ( valid->xstatetable.nClasses > 0xFFFFU )
+    if ( gxvalid->xstatetable.nClasses > 0xFFFFU )
       FT_INVALID_DATA;
 
     GXV_TRACE(( "StateTable Subtables\n" ));
 
-    if ( valid->xstatetable.optdata_load_func != NULL )
-      valid->xstatetable.optdata_load_func( p, limit, valid );
+    if ( gxvalid->xstatetable.optdata_load_func != NULL )
+      gxvalid->xstatetable.optdata_load_func( p, limit, gxvalid );
 
-    if ( valid->xstatetable.subtable_setup_func != NULL )
-      setup_func = valid->xstatetable.subtable_setup_func;
+    if ( gxvalid->xstatetable.subtable_setup_func != NULL )
+      setup_func = gxvalid->xstatetable.subtable_setup_func;
     else
       setup_func = gxv_XStateTable_subtable_setup;
 
                 &classTable_length,
                 &stateArray_length,
                 &entryTable_length,
-                valid );
+                gxvalid );
 
     if ( classTable != 0 )
     {
-      valid->xstatetable.maxClassID = 0;
-      valid->lookupval_sign         = GXV_LOOKUPVALUE_UNSIGNED;
-      valid->lookupval_func         = gxv_XClassTable_lookupval_validate;
-      valid->lookupfmt4_trans       = gxv_XClassTable_lookupfmt4_transit;
+      gxvalid->xstatetable.maxClassID = 0;
+      gxvalid->lookupval_sign         = GXV_LOOKUPVALUE_UNSIGNED;
+      gxvalid->lookupval_func         = gxv_XClassTable_lookupval_validate;
+      gxvalid->lookupfmt4_trans       = gxv_XClassTable_lookupfmt4_transit;
       gxv_LookupTable_validate( table + classTable,
                                 table + classTable + classTable_length,
-                                valid );
+                                gxvalid );
 #if 0
-      if ( valid->subtable_length < classTable_length )
-        classTable_length = valid->subtable_length;
+      if ( gxvalid->subtable_length < classTable_length )
+        classTable_length = gxvalid->subtable_length;
 #endif
     }
     else
     {
       /* XXX: check range? */
-      valid->xstatetable.maxClassID =
-        (FT_UShort)( valid->xstatetable.nClasses - 1 );
+      gxvalid->xstatetable.maxClassID =
+        (FT_UShort)( gxvalid->xstatetable.nClasses - 1 );
     }
 
     if ( stateArray != 0 )
       gxv_XStateArray_validate( table + stateArray,
                                 &stateArray_length,
-                                valid->xstatetable.maxClassID,
-                                valid->xstatetable.nClasses,
+                                gxvalid->xstatetable.maxClassID,
+                                gxvalid->xstatetable.nClasses,
                                 &maxState,
                                 &maxEntry,
-                                valid );
+                                gxvalid );
     else
     {
 #if 0
                                 &entryTable_length,
                                 maxEntry,
                                 stateArray_length,
-                                valid->xstatetable.maxClassID,
+                                gxvalid->xstatetable.maxClassID,
                                 table,
                                 limit,
-                                valid );
+                                gxvalid );
 
     GXV_EXIT;
   }
 
   FT_LOCAL_DEF( void )
   gxv_odtect_validate( GXV_odtect_Range  odtect,
-                       GXV_Validator     valid )
+                       GXV_Validator     gxvalid )
   {
     FT_UInt  i, j;
 
index 2f44a75..f114345 100644 (file)
@@ -4,7 +4,7 @@
 /*                                                                         */
 /*    TrueTypeGX/AAT common tables validation (specification).             */
 /*                                                                         */
-/*  Copyright 2004, 2005, 2012                                             */
+/*  Copyright 2004, 2005, 2012, 2014                                       */
 /*  by suzuki toshiya, Masatake YAMATO, Red Hat K.K.,                      */
 /*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
 /*                                                                         */
@@ -62,7 +62,7 @@ FT_BEGIN_HEADER
 
 #undef GXV_LOAD_UNUSED_VARS /* debug purpose */
 
-#define IS_PARANOID_VALIDATION          ( valid->root->level >= FT_VALIDATE_PARANOID )
+#define IS_PARANOID_VALIDATION          ( gxvalid->root->level >= FT_VALIDATE_PARANOID )
 #define GXV_SET_ERR_IF_PARANOID( err )  { if ( IS_PARANOID_VALIDATION ) ( err ); }
 
   /*************************************************************************/
@@ -81,7 +81,7 @@ FT_BEGIN_HEADER
   typedef void
   (*GXV_Validate_Func)( FT_Bytes       table,
                         FT_Bytes       limit,
-                        GXV_Validator  valid );
+                        GXV_Validator  gxvalid );
 
 
   /* ====================== LookupTable Validator ======================== */
@@ -106,13 +106,13 @@ FT_BEGIN_HEADER
   typedef void
   (*GXV_Lookup_Value_Validate_Func)( FT_UShort            glyph,
                                      GXV_LookupValueCPtr  value_p,
-                                     GXV_Validator        valid );
+                                     GXV_Validator        gxvalid );
 
   typedef GXV_LookupValueDesc
   (*GXV_Lookup_Fmt4_Transit_Func)( FT_UShort            relative_gindex,
                                    GXV_LookupValueCPtr  base_value_p,
                                    FT_Bytes             lookuptbl_limit,
-                                   GXV_Validator        valid );
+                                   GXV_Validator        gxvalid );
 
 
   /* ====================== StateTable Validator ========================= */
@@ -131,10 +131,10 @@ FT_BEGIN_HEADER
 
 
 #define GXV_GLYPHOFFSET_FMT( table )           \
-        ( valid->table.entry_glyphoffset_fmt )
+        ( gxvalid->table.entry_glyphoffset_fmt )
 
 #define GXV_GLYPHOFFSET_SIZE( table )              \
-        ( valid->table.entry_glyphoffset_fmt / 2 )
+        ( gxvalid->table.entry_glyphoffset_fmt / 2 )
 
 
   /* ----------------------- 16bit StateTable ---------------------------- */
@@ -160,7 +160,7 @@ FT_BEGIN_HEADER
                                          FT_UShort*     classTable_length_p,
                                          FT_UShort*     stateArray_length_p,
                                          FT_UShort*     entryTable_length_p,
-                                         GXV_Validator  valid );
+                                         GXV_Validator  gxvalid );
 
   typedef void
   (*GXV_StateTable_Entry_Validate_Func)(
@@ -169,12 +169,12 @@ FT_BEGIN_HEADER
      GXV_StateTable_GlyphOffsetCPtr  glyphOffset_p,
      FT_Bytes                        statetable_table,
      FT_Bytes                        statetable_limit,
-     GXV_Validator                   valid );
+     GXV_Validator                   gxvalid );
 
   typedef void
   (*GXV_StateTable_OptData_Load_Func)( FT_Bytes       table,
                                        FT_Bytes       limit,
-                                       GXV_Validator  valid );
+                                       GXV_Validator  gxvalid );
 
   typedef struct  GXV_StateTable_ValidatorRec_
   {
@@ -202,7 +202,7 @@ FT_BEGIN_HEADER
                                           FT_ULong*      classTable_length_p,
                                           FT_ULong*      stateArray_length_p,
                                           FT_ULong*      entryTable_length_p,
-                                          GXV_Validator  valid );
+                                          GXV_Validator  gxvalid );
 
   typedef void
   (*GXV_XStateTable_Entry_Validate_Func)(
@@ -211,7 +211,7 @@ FT_BEGIN_HEADER
      GXV_StateTable_GlyphOffsetCPtr  glyphOffset_p,
      FT_Bytes                        xstatetable_table,
      FT_Bytes                        xstatetable_limit,
-     GXV_Validator                   valid );
+     GXV_Validator                   gxvalid );
 
 
   typedef GXV_StateTable_OptData_Load_Func  GXV_XStateTable_OptData_Load_Func;
@@ -263,35 +263,35 @@ FT_BEGIN_HEADER
 
 
 #define GXV_TABLE_DATA( tag, field )                           \
-        ( ( (GXV_ ## tag ## _Data)valid->table_data )->field )
+        ( ( (GXV_ ## tag ## _Data)gxvalid->table_data )->field )
 
 #undef  FT_INVALID_
-#define FT_INVALID_( _prefix, _error )                         \
-          ft_validator_error( valid->root, _prefix ## _error )
+#define FT_INVALID_( _error ) \
+          ft_validator_error( gxvalid->root, FT_THROW( _error ) )
 
 #define GXV_LIMIT_CHECK( _count )                                     \
           FT_BEGIN_STMNT                                              \
-            if ( p + _count > ( limit? limit : valid->root->limit ) ) \
+            if ( p + _count > ( limit? limit : gxvalid->root->limit ) ) \
               FT_INVALID_TOO_SHORT;                                   \
           FT_END_STMNT
 
 
 #ifdef FT_DEBUG_LEVEL_TRACE
 
-#define GXV_INIT  valid->debug_indent = 0
+#define GXV_INIT  gxvalid->debug_indent = 0
 
 #define GXV_NAME_ENTER( name )                             \
           FT_BEGIN_STMNT                                   \
-            valid->debug_indent += 2;                      \
-            FT_TRACE4(( "%*.s", valid->debug_indent, 0 )); \
+            gxvalid->debug_indent += 2;                      \
+            FT_TRACE4(( "%*.s", gxvalid->debug_indent, 0 )); \
             FT_TRACE4(( "%s table\n", name ));             \
           FT_END_STMNT
 
-#define GXV_EXIT  valid->debug_indent -= 2
+#define GXV_EXIT  gxvalid->debug_indent -= 2
 
 #define GXV_TRACE( s )                                     \
           FT_BEGIN_STMNT                                   \
-            FT_TRACE4(( "%*.s", valid->debug_indent, 0 )); \
+            FT_TRACE4(( "%*.s", gxvalid->debug_indent, 0 )); \
             FT_TRACE4( s );                                \
           FT_END_STMNT
 
@@ -349,7 +349,7 @@ FT_BEGIN_HEADER
                                                         \
                                                         \
               for ( b = p; b < (FT_Bytes)p + len; b++ ) \
-                if ( 0x40 < *b && *b < 0x7e )           \
+                if ( 0x40 < *b && *b < 0x7E )           \
                   FT_TRACE1(("%c", *b)) ;               \
                 else                                    \
                   FT_TRACE1(("\\x%02x", *b)) ;          \
@@ -373,12 +373,12 @@ FT_BEGIN_HEADER
                               FT_Bytes       limit,
                               FT_UShort*     unitSize_p,
                               FT_UShort*     nUnits_p,
-                              GXV_Validator  valid );
+                              GXV_Validator  gxvalid );
 
   FT_LOCAL( void )
   gxv_LookupTable_validate( FT_Bytes       table,
                             FT_Bytes       limit,
-                            GXV_Validator  valid );
+                            GXV_Validator  gxvalid );
 
 
   /*************************************************************************/
@@ -391,7 +391,7 @@ FT_BEGIN_HEADER
 
   FT_LOCAL( FT_Int )
   gxv_glyphid_validate( FT_UShort      gid,
-                        GXV_Validator  valid );
+                        GXV_Validator  gxvalid );
 
 
   /*************************************************************************/
@@ -405,7 +405,7 @@ FT_BEGIN_HEADER
   FT_LOCAL( void )
   gxv_ctlPoint_validate( FT_UShort      gid,
                          FT_Short       ctl_point,
-                         GXV_Validator  valid );
+                         GXV_Validator  gxvalid );
 
 
   /*************************************************************************/
@@ -420,7 +420,7 @@ FT_BEGIN_HEADER
   gxv_sfntName_validate( FT_UShort      name_index,
                          FT_UShort      min_index,
                          FT_UShort      max_index,
-                         GXV_Validator  valid );
+                         GXV_Validator  gxvalid );
 
 
   /*************************************************************************/
@@ -439,7 +439,7 @@ FT_BEGIN_HEADER
                                  FT_UShort*     classTable_length_p,
                                  FT_UShort*     stateArray_length_p,
                                  FT_UShort*     entryTable_length_p,
-                                 GXV_Validator  valid );
+                                 GXV_Validator  gxvalid );
 
   FT_LOCAL( void )
   gxv_XStateTable_subtable_setup( FT_ULong       table_size,
@@ -449,17 +449,17 @@ FT_BEGIN_HEADER
                                   FT_ULong*      classTable_length_p,
                                   FT_ULong*      stateArray_length_p,
                                   FT_ULong*      entryTable_length_p,
-                                  GXV_Validator  valid );
+                                  GXV_Validator  gxvalid );
 
   FT_LOCAL( void )
   gxv_StateTable_validate( FT_Bytes       table,
                            FT_Bytes       limit,
-                           GXV_Validator  valid );
+                           GXV_Validator  gxvalid );
 
   FT_LOCAL( void )
   gxv_XStateTable_validate( FT_Bytes       table,
                             FT_Bytes       limit,
-                            GXV_Validator  valid );
+                            GXV_Validator  gxvalid );
 
 
   /*************************************************************************/
@@ -475,14 +475,14 @@ FT_BEGIN_HEADER
                             FT_Bytes       limit,
                             FT_Byte*       min,
                             FT_Byte*       max,
-                            GXV_Validator  valid );
+                            GXV_Validator  gxvalid );
 
   FT_LOCAL( void )
   gxv_array_getlimits_ushort( FT_Bytes       table,
                               FT_Bytes       limit,
                               FT_UShort*     min,
                               FT_UShort*     max,
-                              GXV_Validator  valid );
+                              GXV_Validator  gxvalid );
 
   FT_LOCAL( void )
   gxv_set_length_by_ushort_offset( FT_UShort*     offset,
@@ -490,7 +490,7 @@ FT_BEGIN_HEADER
                                    FT_UShort*     buff,
                                    FT_UInt        nmemb,
                                    FT_UShort      limit,
-                                   GXV_Validator  valid );
+                                   GXV_Validator  gxvalid );
 
   FT_LOCAL( void )
   gxv_set_length_by_ulong_offset( FT_ULong*      offset,
@@ -498,19 +498,19 @@ FT_BEGIN_HEADER
                                   FT_ULong*      buff,
                                   FT_UInt        nmemb,
                                   FT_ULong       limit,
-                                  GXV_Validator  valid);
+                                  GXV_Validator  gxvalid);
 
 
 #define GXV_SUBTABLE_OFFSET_CHECK( _offset )          \
           FT_BEGIN_STMNT                              \
-            if ( (_offset) > valid->subtable_length ) \
+            if ( (_offset) > gxvalid->subtable_length ) \
               FT_INVALID_OFFSET;                      \
           FT_END_STMNT
 
 #define GXV_SUBTABLE_LIMIT_CHECK( _count )                  \
           FT_BEGIN_STMNT                                    \
-            if ( ( p + (_count) - valid->subtable_start ) > \
-                   valid->subtable_length )                 \
+            if ( ( p + (_count) - gxvalid->subtable_start ) > \
+                   gxvalid->subtable_length )                 \
               FT_INVALID_TOO_SHORT;                         \
           FT_END_STMNT
 
@@ -556,7 +556,7 @@ FT_BEGIN_HEADER
 
   FT_LOCAL( void )
   gxv_odtect_validate( GXV_odtect_Range  odtect,
-                       GXV_Validator     valid );
+                       GXV_Validator     gxvalid );
 
 
 #define GXV_ODTECT( n, odtect )                              \
index 6f75650..69298b2 100644 (file)
@@ -82,7 +82,7 @@
   gxv_feat_registry_validate( FT_UShort      feature,
                               FT_UShort      nSettings,
                               FT_Bool        exclusive,
-                              GXV_Validator  valid )
+                              GXV_Validator  gxvalid )
   {
     GXV_NAME_ENTER( "feature in registry" );
 
     {
       /* Don't use here. Apple is reserved. */
       GXV_TRACE(( "feature number %d is reserved by Apple\n", feature ));
-      if ( valid->root->level >= FT_VALIDATE_TIGHT )
+      if ( gxvalid->root->level >= FT_VALIDATE_TIGHT )
         FT_INVALID_DATA;
     }
 
       GXV_TRACE(( "feature %d: nSettings %d != defined nSettings %d\n",
                   feature, nSettings,
                   gxv_feat_registry[feature].nSettings ));
-      if ( valid->root->level >= FT_VALIDATE_TIGHT )
+      if ( gxvalid->root->level >= FT_VALIDATE_TIGHT )
         FT_INVALID_DATA;
     }
 
     {
       GXV_TRACE(( "exclusive flag %d differs from predefined value\n",
                   exclusive ));
-      if ( valid->root->level >= FT_VALIDATE_TIGHT )
+      if ( gxvalid->root->level >= FT_VALIDATE_TIGHT )
         FT_INVALID_DATA;
     }
 
   static void
   gxv_feat_name_index_validate( FT_Bytes       table,
                                 FT_Bytes       limit,
-                                GXV_Validator  valid )
+                                GXV_Validator  gxvalid )
   {
     FT_Bytes  p = table;
 
     gxv_sfntName_validate( (FT_UShort)nameIndex,
                            255,
                            32768U,
-                           valid );
+                           gxvalid );
 
     GXV_EXIT;
   }
   gxv_feat_setting_validate( FT_Bytes       table,
                              FT_Bytes       limit,
                              FT_Bool        exclusive,
-                             GXV_Validator  valid )
+                             GXV_Validator  gxvalid )
   {
     FT_Bytes   p = table;
     FT_UShort  setting;
     if ( exclusive && ( setting & 1 ) == 0 )
       FT_INVALID_DATA;
 
-    gxv_feat_name_index_validate( p, limit, valid );
+    gxv_feat_name_index_validate( p, limit, gxvalid );
 
     GXV_FEAT_DATA( setting ) = setting;
 
   static void
   gxv_feat_name_validate( FT_Bytes       table,
                           FT_Bytes       limit,
-                          GXV_Validator  valid )
+                          GXV_Validator  gxvalid )
   {
     FT_Bytes   p             = table;
     FT_UInt    reserved_size = GXV_FEAT_DATA( reserved_size );
         FT_INVALID_FORMAT;
     }
 
-    gxv_feat_registry_validate( feature, nSettings, exclusive, valid );
+    gxv_feat_registry_validate( feature, nSettings, exclusive, gxvalid );
 
-    gxv_feat_name_index_validate( p, limit, valid );
+    gxv_feat_name_index_validate( p, limit, gxvalid );
 
-    p = valid->root->base + settingTable;
+    p = gxvalid->root->base + settingTable;
     for ( last_setting = -1, i = 0; i < nSettings; i++ )
     {
-      gxv_feat_setting_validate( p, limit, exclusive, valid );
+      gxv_feat_setting_validate( p, limit, exclusive, gxvalid );
 
       if ( (FT_Int)GXV_FEAT_DATA( setting ) <= last_setting )
         GXV_SET_ERR_IF_PARANOID( FT_INVALID_FORMAT );
                      FT_Face       face,
                      FT_Validator  ftvalid )
   {
-    GXV_ValidatorRec  validrec;
-    GXV_Validator     valid = &validrec;
+    GXV_ValidatorRec  gxvalidrec;
+    GXV_Validator     gxvalid = &gxvalidrec;
 
     GXV_feat_DataRec  featrec;
     GXV_feat_Data     feat = &featrec;
     FT_Int            last_feature;
 
 
-    valid->root       = ftvalid;
-    valid->table_data = feat;
-    valid->face       = face;
+    gxvalid->root       = ftvalid;
+    gxvalid->table_data = feat;
+    gxvalid->face       = face;
 
     FT_TRACE3(( "validating `feat' table\n" ));
     GXV_INIT;
 
     for ( last_feature = -1, i = 0; i < featureNameCount; i++ )
     {
-      gxv_feat_name_validate( p, limit, valid );
+      gxv_feat_name_validate( p, limit, gxvalid );
 
       if ( (FT_Int)GXV_FEAT_DATA( feature ) <= last_feature )
         GXV_SET_ERR_IF_PARANOID( FT_INVALID_FORMAT );
index 7816e0b..24c26a5 100644 (file)
@@ -4,7 +4,7 @@
 /*                                                                         */
 /*    TrueTypeGX/AAT just table validation (body).                         */
 /*                                                                         */
-/*  Copyright 2005 by suzuki toshiya, Masatake YAMATO, Red Hat K.K.,       */
+/*  Copyright 2005, 2014 by suzuki toshiya, Masatake YAMATO, Red Hat K.K., */
 /*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
 /*                                                                         */
 /*  This file is part of the FreeType project, and may only be used,       */
   static void
   gxv_just_check_max_gid( FT_UShort         gid,
                           const FT_String*  msg_tag,
-                          GXV_Validator     valid )
+                          GXV_Validator     gxvalid )
   {
-    if ( gid < valid->face->num_glyphs )
+    if ( gid < gxvalid->face->num_glyphs )
       return;
 
     GXV_TRACE(( "just table includes too large %s"
                 " GID=%d > %d (in maxp)\n",
-                msg_tag, gid, valid->face->num_glyphs ));
+                msg_tag, gid, gxvalid->face->num_glyphs ));
     GXV_SET_ERR_IF_PARANOID( FT_INVALID_GLYPH_ID );
   }
 
@@ -84,7 +84,7 @@
   static void
   gxv_just_wdp_entry_validate( FT_Bytes       table,
                                FT_Bytes       limit,
-                               GXV_Validator  valid )
+                               GXV_Validator  gxvalid )
   {
     FT_Bytes   p = table;
     FT_ULong   justClass;
 #endif
 
     /* According to Apple spec, only 7bits in justClass is used */
-    if ( ( justClass & 0xFFFFFF80 ) != 0 )
+    if ( ( justClass & 0xFFFFFF80UL ) != 0 )
     {
       GXV_TRACE(( "just table includes non-zero value"
                   " in unused justClass higher bits"
       GXV_SET_ERR_IF_PARANOID( FT_INVALID_DATA );
     }
 
-    valid->subtable_length = p - table;
+    gxvalid->subtable_length = p - table;
   }
 
 
   static void
   gxv_just_wdc_entry_validate( FT_Bytes       table,
                                FT_Bytes       limit,
-                               GXV_Validator  valid )
+                               GXV_Validator  gxvalid )
   {
     FT_Bytes  p = table;
     FT_ULong  count, i;
     for ( i = 0; i < count; i++ )
     {
       GXV_TRACE(( "validating wdc pair %d/%d\n", i + 1, count ));
-      gxv_just_wdp_entry_validate( p, limit, valid );
-      p += valid->subtable_length;
+      gxv_just_wdp_entry_validate( p, limit, gxvalid );
+      p += gxvalid->subtable_length;
     }
 
-    valid->subtable_length = p - table;
+    gxvalid->subtable_length = p - table;
   }
 
 
   static void
   gxv_just_widthDeltaClusters_validate( FT_Bytes       table,
                                         FT_Bytes       limit,
-                                        GXV_Validator  valid )
+                                        GXV_Validator  gxvalid )
   {
     FT_Bytes  p         = table ;
     FT_Bytes  wdc_end   = table + GXV_JUST_DATA( wdc_offset_max );
 
     for ( i = 0; p <= wdc_end; i++ )
     {
-      gxv_just_wdc_entry_validate( p, limit, valid );
-      p += valid->subtable_length;
+      gxv_just_wdc_entry_validate( p, limit, gxvalid );
+      p += gxvalid->subtable_length;
     }
 
-    valid->subtable_length = p - table;
+    gxvalid->subtable_length = p - table;
 
     GXV_EXIT;
   }
   static void
   gxv_just_actSubrecord_type0_validate( FT_Bytes       table,
                                         FT_Bytes       limit,
-                                        GXV_Validator  valid )
+                                        GXV_Validator  gxvalid )
   {
     FT_Bytes   p = table;
 
 
       GXV_LIMIT_CHECK( 2 );
       glyphs = FT_NEXT_USHORT( p );
-      gxv_just_check_max_gid( glyphs, "type0:glyphs", valid );
+      gxv_just_check_max_gid( glyphs, "type0:glyphs", gxvalid );
     }
 
-    valid->subtable_length = p - table;
+    gxvalid->subtable_length = p - table;
   }
 
 
   static void
   gxv_just_actSubrecord_type1_validate( FT_Bytes       table,
                                         FT_Bytes       limit,
-                                        GXV_Validator  valid )
+                                        GXV_Validator  gxvalid )
   {
     FT_Bytes   p = table;
     FT_UShort  addGlyph;
     GXV_LIMIT_CHECK( 2 );
     addGlyph = FT_NEXT_USHORT( p );
 
-    gxv_just_check_max_gid( addGlyph, "type1:addGlyph", valid );
+    gxv_just_check_max_gid( addGlyph, "type1:addGlyph", gxvalid );
 
-    valid->subtable_length = p - table;
+    gxvalid->subtable_length = p - table;
   }
 
 
   static void
   gxv_just_actSubrecord_type2_validate( FT_Bytes       table,
                                         FT_Bytes       limit,
-                                        GXV_Validator  valid )
+                                        GXV_Validator  gxvalid )
   {
     FT_Bytes   p = table;
 #ifdef GXV_LOAD_UNUSED_VARS
-    FT_Fixed   substThreshhold; /* Apple misspelled "Threshhold" */
+    FT_Fixed      substThreshhold; /* Apple misspelled "Threshhold" */
 #endif
     FT_UShort  addGlyph;
     FT_UShort  substGlyph;
     substGlyph      = FT_NEXT_USHORT( p );
 
     if ( addGlyph != 0xFFFF )
-      gxv_just_check_max_gid( addGlyph, "type2:addGlyph", valid );
+      gxv_just_check_max_gid( addGlyph, "type2:addGlyph", gxvalid );
 
-    gxv_just_check_max_gid( substGlyph, "type2:substGlyph", valid );
+    gxv_just_check_max_gid( substGlyph, "type2:substGlyph", gxvalid );
 
-    valid->subtable_length = p - table;
+    gxvalid->subtable_length = p - table;
   }
 
 
   static void
   gxv_just_actSubrecord_type4_validate( FT_Bytes       table,
                                         FT_Bytes       limit,
-                                        GXV_Validator  valid )
+                                        GXV_Validator  gxvalid )
   {
     FT_Bytes  p = table;
     FT_ULong  variantsAxis;
     noStretchValue = FT_NEXT_ULONG( p );
     maximumLimit   = FT_NEXT_ULONG( p );
 
-    valid->subtable_length = p - table;
+    gxvalid->subtable_length = p - table;
 
-    if ( variantsAxis != 0x64756374 ) /* 'duct' */
+    if ( variantsAxis != 0x64756374L ) /* 'duct' */
       GXV_TRACE(( "variantsAxis 0x%08x is non default value",
                    variantsAxis ));
 
   static void
   gxv_just_actSubrecord_type5_validate( FT_Bytes       table,
                                         FT_Bytes       limit,
-                                        GXV_Validator  valid )
+                                        GXV_Validator  gxvalid )
   {
     FT_Bytes   p = table;
     FT_UShort  flags;
     if ( flags )
       GXV_TRACE(( "type5: nonzero value 0x%04x in unused flags\n",
                    flags ));
-    gxv_just_check_max_gid( glyph, "type5:glyph", valid );
+    gxv_just_check_max_gid( glyph, "type5:glyph", gxvalid );
 
-    valid->subtable_length = p - table;
+    gxvalid->subtable_length = p - table;
   }
 
 
   static void
   gxv_just_actSubrecord_validate( FT_Bytes       table,
                                   FT_Bytes       limit,
-                                  GXV_Validator  valid )
+                                  GXV_Validator  gxvalid )
   {
     FT_Bytes   p = table;
     FT_UShort  actionClass;
       GXV_SET_ERR_IF_PARANOID( FT_INVALID_DATA );
 
     if ( actionType == 0 )
-      gxv_just_actSubrecord_type0_validate( p, limit, valid );
+      gxv_just_actSubrecord_type0_validate( p, limit, gxvalid );
     else if ( actionType == 1 )
-      gxv_just_actSubrecord_type1_validate( p, limit, valid );
+      gxv_just_actSubrecord_type1_validate( p, limit, gxvalid );
     else if ( actionType == 2 )
-      gxv_just_actSubrecord_type2_validate( p, limit, valid );
+      gxv_just_actSubrecord_type2_validate( p, limit, gxvalid );
     else if ( actionType == 3 )
       ;                         /* Stretch glyph action: no actionData */
     else if ( actionType == 4 )
-      gxv_just_actSubrecord_type4_validate( p, limit, valid );
+      gxv_just_actSubrecord_type4_validate( p, limit, gxvalid );
     else if ( actionType == 5 )
-      gxv_just_actSubrecord_type5_validate( p, limit, valid );
+      gxv_just_actSubrecord_type5_validate( p, limit, gxvalid );
     else
       FT_INVALID_DATA;
 
-    valid->subtable_length = actionLength;
+    gxvalid->subtable_length = actionLength;
 
     GXV_EXIT;
   }
   static void
   gxv_just_pcActionRecord_validate( FT_Bytes       table,
                                     FT_Bytes       limit,
-                                    GXV_Validator  valid )
+                                    GXV_Validator  gxvalid )
   {
     FT_Bytes  p = table;
     FT_ULong  actionCount;
 
     for ( i = 0; i < actionCount; i++ )
     {
-      gxv_just_actSubrecord_validate( p, limit, valid );
-      p += valid->subtable_length;
+      gxv_just_actSubrecord_validate( p, limit, gxvalid );
+      p += gxvalid->subtable_length;
     }
 
-    valid->subtable_length = p - table;
+    gxvalid->subtable_length = p - table;
 
     GXV_EXIT;
   }
   static void
   gxv_just_pcTable_LookupValue_entry_validate( FT_UShort            glyph,
                                                GXV_LookupValueCPtr  value_p,
-                                               GXV_Validator        valid )
+                                               GXV_Validator        gxvalid )
   {
     FT_UNUSED( glyph );
 
   static void
   gxv_just_pcLookupTable_validate( FT_Bytes       table,
                                    FT_Bytes       limit,
-                                   GXV_Validator  valid )
+                                   GXV_Validator  gxvalid )
   {
-    FT_Bytes p = table;
+    FT_Bytes  p = table;
 
 
     GXV_NAME_ENTER( "just pcLookupTable" );
     GXV_JUST_DATA( pc_offset_max ) = 0x0000;
     GXV_JUST_DATA( pc_offset_min ) = 0xFFFFU;
 
-    valid->lookupval_sign = GXV_LOOKUPVALUE_UNSIGNED;
-    valid->lookupval_func = gxv_just_pcTable_LookupValue_entry_validate;
+    gxvalid->lookupval_sign = GXV_LOOKUPVALUE_UNSIGNED;
+    gxvalid->lookupval_func = gxv_just_pcTable_LookupValue_entry_validate;
 
-    gxv_LookupTable_validate( p, limit, valid );
+    gxv_LookupTable_validate( p, limit, gxvalid );
 
     /* subtable_length is set by gxv_LookupTable_validate() */
 
   static void
   gxv_just_postcompTable_validate( FT_Bytes       table,
                                    FT_Bytes       limit,
-                                   GXV_Validator  valid )
+                                   GXV_Validator  gxvalid )
   {
     FT_Bytes  p = table;
 
 
     GXV_NAME_ENTER( "just postcompTable" );
 
-    gxv_just_pcLookupTable_validate( p, limit, valid );
-    p += valid->subtable_length;
+    gxv_just_pcLookupTable_validate( p, limit, gxvalid );
+    p += gxvalid->subtable_length;
 
-    gxv_just_pcActionRecord_validate( p, limit, valid );
-    p += valid->subtable_length;
+    gxv_just_pcActionRecord_validate( p, limit, gxvalid );
+    p += gxvalid->subtable_length;
 
-    valid->subtable_length = p - table;
+    gxvalid->subtable_length = p - table;
 
     GXV_EXIT;
   }
     GXV_StateTable_GlyphOffsetCPtr  glyphOffset_p,
     FT_Bytes                        table,
     FT_Bytes                        limit,
-    GXV_Validator                   valid )
+    GXV_Validator                   gxvalid )
   {
 #ifdef GXV_LOAD_UNUSED_VARS
     /* TODO: validate markClass & currentClass */
     FT_UNUSED( glyphOffset_p );
     FT_UNUSED( table );
     FT_UNUSED( limit );
-    FT_UNUSED( valid );
+    FT_UNUSED( gxvalid );
 
 #ifndef GXV_LOAD_UNUSED_VARS
     FT_UNUSED( flags );
   static void
   gxv_just_justClassTable_validate ( FT_Bytes       table,
                                      FT_Bytes       limit,
-                                     GXV_Validator  valid )
+                                     GXV_Validator  gxvalid )
   {
     FT_Bytes   p = table;
     FT_UShort  length;
       GXV_TRACE(( "  justClassTable: nonzero value (0x%08x)"
                   " in unused subFeatureFlags\n", subFeatureFlags ));
 
-    valid->statetable.optdata               = NULL;
-    valid->statetable.optdata_load_func     = NULL;
-    valid->statetable.subtable_setup_func   = NULL;
-    valid->statetable.entry_glyphoffset_fmt = GXV_GLYPHOFFSET_NONE;
-    valid->statetable.entry_validate_func   =
+    gxvalid->statetable.optdata               = NULL;
+    gxvalid->statetable.optdata_load_func     = NULL;
+    gxvalid->statetable.subtable_setup_func   = NULL;
+    gxvalid->statetable.entry_glyphoffset_fmt = GXV_GLYPHOFFSET_NONE;
+    gxvalid->statetable.entry_validate_func   =
       gxv_just_classTable_entry_validate;
 
-    gxv_StateTable_validate( p, table + length, valid );
+    gxv_StateTable_validate( p, table + length, gxvalid );
 
     /* subtable_length is set by gxv_LookupTable_validate() */
 
   static void
   gxv_just_wdcTable_LookupValue_validate( FT_UShort            glyph,
                                           GXV_LookupValueCPtr  value_p,
-                                          GXV_Validator        valid )
+                                          GXV_Validator        gxvalid )
   {
     FT_UNUSED( glyph );
 
   static void
   gxv_just_justData_lookuptable_validate( FT_Bytes       table,
                                           FT_Bytes       limit,
-                                          GXV_Validator  valid )
+                                          GXV_Validator  gxvalid )
   {
     FT_Bytes  p = table;
 
     GXV_JUST_DATA( wdc_offset_max ) = 0x0000;
     GXV_JUST_DATA( wdc_offset_min ) = 0xFFFFU;
 
-    valid->lookupval_sign = GXV_LOOKUPVALUE_UNSIGNED;
-    valid->lookupval_func = gxv_just_wdcTable_LookupValue_validate;
+    gxvalid->lookupval_sign = GXV_LOOKUPVALUE_UNSIGNED;
+    gxvalid->lookupval_func = gxv_just_wdcTable_LookupValue_validate;
 
-    gxv_LookupTable_validate( p, limit, valid );
+    gxv_LookupTable_validate( p, limit, gxvalid );
 
     /* subtable_length is set by gxv_LookupTable_validate() */
 
   static void
   gxv_just_justData_validate( FT_Bytes       table,
                               FT_Bytes       limit,
-                              GXV_Validator  valid )
+                              GXV_Validator  gxvalid )
   {
     /*
      * following 3 offsets are measured from the start of `just'
     GXV_TRACE(( " (wdcTableOffset = 0x%04x)\n", wdcTableOffset ));
     GXV_TRACE(( " (pcTableOffset = 0x%04x)\n", pcTableOffset ));
 
-    gxv_just_justData_lookuptable_validate( p, limit, valid );
-    gxv_odtect_add_range( p, valid->subtable_length,
+    gxv_just_justData_lookuptable_validate( p, limit, gxvalid );
+    gxv_odtect_add_range( p, gxvalid->subtable_length,
                           "just_LookupTable", odtect );
 
     if ( wdcTableOffset )
     {
       gxv_just_widthDeltaClusters_validate(
-        valid->root->base + wdcTableOffset, limit, valid );
-      gxv_odtect_add_range( valid->root->base + wdcTableOffset,
-                            valid->subtable_length, "just_wdcTable", odtect );
+        gxvalid->root->base + wdcTableOffset, limit, gxvalid );
+      gxv_odtect_add_range( gxvalid->root->base + wdcTableOffset,
+                            gxvalid->subtable_length, "just_wdcTable", odtect );
     }
 
     if ( pcTableOffset )
     {
-      gxv_just_postcompTable_validate( valid->root->base + pcTableOffset,
-                                       limit, valid );
-      gxv_odtect_add_range( valid->root->base + pcTableOffset,
-                            valid->subtable_length, "just_pcTable", odtect );
+      gxv_just_postcompTable_validate( gxvalid->root->base + pcTableOffset,
+                                       limit, gxvalid );
+      gxv_odtect_add_range( gxvalid->root->base + pcTableOffset,
+                            gxvalid->subtable_length, "just_pcTable", odtect );
     }
 
     if ( justClassTableOffset )
     {
       gxv_just_justClassTable_validate(
-        valid->root->base + justClassTableOffset, limit, valid );
-      gxv_odtect_add_range( valid->root->base + justClassTableOffset,
-                            valid->subtable_length, "just_justClassTable",
+        gxvalid->root->base + justClassTableOffset, limit, gxvalid );
+      gxv_odtect_add_range( gxvalid->root->base + justClassTableOffset,
+                            gxvalid->subtable_length, "just_justClassTable",
                             odtect );
     }
 
-    gxv_odtect_validate( odtect, valid );
+    gxv_odtect_validate( odtect, gxvalid );
 
     GXV_EXIT;
   }
     FT_Bytes           p     = table;
     FT_Bytes           limit = 0;
 
-    GXV_ValidatorRec   validrec;
-    GXV_Validator      valid = &validrec;
+    GXV_ValidatorRec   gxvalidrec;
+    GXV_Validator      gxvalid = &gxvalidrec;
     GXV_just_DataRec   justrec;
     GXV_just_Data      just = &justrec;
 
 
     GXV_ODTECT_INIT( odtect );
 
-    valid->root       = ftvalid;
-    valid->table_data = just;
-    valid->face       = face;
+    gxvalid->root       = ftvalid;
+    gxvalid->table_data = just;
+    gxvalid->face       = face;
 
     FT_TRACE3(( "validating `just' table\n" ));
     GXV_INIT;
 
-    limit      = valid->root->limit;
+    limit      = gxvalid->root->limit;
 
     GXV_LIMIT_CHECK( 4 + 2 + 2 + 2 );
     version     = FT_NEXT_ULONG( p );
     /* validate justData */
     if ( 0 < horizOffset )
     {
-      gxv_just_justData_validate( table + horizOffset, limit, valid );
-      gxv_odtect_add_range( table + horizOffset, valid->subtable_length,
+      gxv_just_justData_validate( table + horizOffset, limit, gxvalid );
+      gxv_odtect_add_range( table + horizOffset, gxvalid->subtable_length,
                             "horizJustData", odtect );
     }
 
     if ( 0 < vertOffset )
     {
-      gxv_just_justData_validate( table + vertOffset, limit, valid );
-      gxv_odtect_add_range( table + vertOffset, valid->subtable_length,
+      gxv_just_justData_validate( table + vertOffset, limit, gxvalid );
+      gxv_odtect_add_range( table + vertOffset, gxvalid->subtable_length,
                             "vertJustData", odtect );
     }
 
-    gxv_odtect_validate( odtect, valid );
+    gxv_odtect_validate( odtect, gxvalid );
 
     FT_TRACE4(( "\n" ));
   }
index 557c5f1..787e3db 100644 (file)
 
 #define GXV_KERN_DATA( field )  GXV_TABLE_DATA( kern, field )
 
-#define KERN_IS_CLASSIC( valid )                               \
+#define KERN_IS_CLASSIC( gxvalid )                               \
           ( KERN_VERSION_CLASSIC == GXV_KERN_DATA( version ) )
-#define KERN_IS_NEW( valid )                                   \
+#define KERN_IS_NEW( gxvalid )                                   \
           ( KERN_VERSION_NEW     == GXV_KERN_DATA( version ) )
 
-#define KERN_DIALECT( valid )              \
+#define KERN_DIALECT( gxvalid )              \
           GXV_KERN_DATA( dialect_request )
-#define KERN_ALLOWS_MS( valid )                       \
-          ( KERN_DIALECT( valid ) & KERN_DIALECT_MS )
-#define KERN_ALLOWS_APPLE( valid )                       \
-          ( KERN_DIALECT( valid ) & KERN_DIALECT_APPLE )
+#define KERN_ALLOWS_MS( gxvalid )                       \
+          ( KERN_DIALECT( gxvalid ) & KERN_DIALECT_MS )
+#define KERN_ALLOWS_APPLE( gxvalid )                       \
+          ( KERN_DIALECT( gxvalid ) & KERN_DIALECT_APPLE )
 
-#define GXV_KERN_HEADER_SIZE           ( KERN_IS_NEW( valid ) ? 8 : 4 )
-#define GXV_KERN_SUBTABLE_HEADER_SIZE  ( KERN_IS_NEW( valid ) ? 8 : 6 )
+#define GXV_KERN_HEADER_SIZE           ( KERN_IS_NEW( gxvalid ) ? 8 : 4 )
+#define GXV_KERN_SUBTABLE_HEADER_SIZE  ( KERN_IS_NEW( gxvalid ) ? 8 : 6 )
 
 
   /*************************************************************************/
   gxv_kern_subtable_fmt0_pairs_validate( FT_Bytes       table,
                                          FT_Bytes       limit,
                                          FT_UShort      nPairs,
-                                         GXV_Validator  valid )
+                                         GXV_Validator  gxvalid )
   {
     FT_Bytes   p = table;
     FT_UShort  i;
 
       /* left */
       gid_left  = FT_NEXT_USHORT( p );
-      gxv_glyphid_validate( gid_left, valid );
+      gxv_glyphid_validate( gid_left, gxvalid );
 
       /* right */
       gid_right = FT_NEXT_USHORT( p );
-      gxv_glyphid_validate( gid_right, valid );
+      gxv_glyphid_validate( gid_right, gxvalid );
 
       /* Pairs of left and right GIDs must be unique and sorted. */
       GXV_TRACE(( "left gid = %u, right gid = %u\n", gid_left, gid_right ));
   static void
   gxv_kern_subtable_fmt0_validate( FT_Bytes       table,
                                    FT_Bytes       limit,
-                                   GXV_Validator  valid )
+                                   GXV_Validator  gxvalid )
   {
     FT_Bytes   p = table + GXV_KERN_SUBTABLE_HEADER_SIZE;
 
 
     /* nPairs, searchRange, entrySelector, rangeShift */
     GXV_LIMIT_CHECK( 2 + 2 + 2 + 2 );
-    gxv_BinSrchHeader_validate( p, limit, &unitSize, &nPairs, valid );
+    gxv_BinSrchHeader_validate( p, limit, &unitSize, &nPairs, gxvalid );
     p += 2 + 2 + 2 + 2;
 
-    gxv_kern_subtable_fmt0_pairs_validate( p, limit, nPairs, valid );
+    gxv_kern_subtable_fmt0_pairs_validate( p, limit, nPairs, gxvalid );
 
     GXV_EXIT;
   }
   static void
   gxv_kern_subtable_fmt1_valueTable_load( FT_Bytes       table,
                                           FT_Bytes       limit,
-                                          GXV_Validator  valid )
+                                          GXV_Validator  gxvalid )
   {
     FT_Bytes                       p = table;
     GXV_kern_fmt1_StateOptRecData  optdata =
-      (GXV_kern_fmt1_StateOptRecData)valid->statetable.optdata;
+      (GXV_kern_fmt1_StateOptRecData)gxvalid->statetable.optdata;
 
 
     GXV_LIMIT_CHECK( 2 );
                                          FT_UShort*     classTable_length_p,
                                          FT_UShort*     stateArray_length_p,
                                          FT_UShort*     entryTable_length_p,
-                                         GXV_Validator  valid )
+                                         GXV_Validator  gxvalid )
   {
     FT_UShort  o[4];
     FT_UShort  *l[4];
     FT_UShort  buff[5];
 
     GXV_kern_fmt1_StateOptRecData  optdata =
-      (GXV_kern_fmt1_StateOptRecData)valid->statetable.optdata;
+      (GXV_kern_fmt1_StateOptRecData)gxvalid->statetable.optdata;
 
 
     o[0] = classTable;
     l[2] = entryTable_length_p;
     l[3] = &(optdata->valueTable_length);
 
-    gxv_set_length_by_ushort_offset( o, l, buff, 4, table_size, valid );
+    gxv_set_length_by_ushort_offset( o, l, buff, 4, table_size, gxvalid );
   }
 
 
     GXV_StateTable_GlyphOffsetCPtr  glyphOffset_p,
     FT_Bytes                        table,
     FT_Bytes                        limit,
-    GXV_Validator                   valid )
+    GXV_Validator                   gxvalid )
   {
 #ifdef GXV_LOAD_UNUSED_VARS
     FT_UShort  push;
 
     {
       GXV_kern_fmt1_StateOptRecData  vt_rec =
-        (GXV_kern_fmt1_StateOptRecData)valid->statetable.optdata;
+        (GXV_kern_fmt1_StateOptRecData)gxvalid->statetable.optdata;
       FT_Bytes  p;
 
 
   static void
   gxv_kern_subtable_fmt1_validate( FT_Bytes       table,
                                    FT_Bytes       limit,
-                                   GXV_Validator  valid )
+                                   GXV_Validator  gxvalid )
   {
     FT_Bytes                   p = table;
     GXV_kern_fmt1_StateOptRec  vt_rec;
 
     GXV_NAME_ENTER( "kern subtable format 1" );
 
-    valid->statetable.optdata =
+    gxvalid->statetable.optdata =
       &vt_rec;
-    valid->statetable.optdata_load_func =
+    gxvalid->statetable.optdata_load_func =
       gxv_kern_subtable_fmt1_valueTable_load;
-    valid->statetable.subtable_setup_func =
+    gxvalid->statetable.subtable_setup_func =
       gxv_kern_subtable_fmt1_subtable_setup;
-    valid->statetable.entry_glyphoffset_fmt =
+    gxvalid->statetable.entry_glyphoffset_fmt =
       GXV_GLYPHOFFSET_NONE;
-    valid->statetable.entry_validate_func =
+    gxvalid->statetable.entry_validate_func =
       gxv_kern_subtable_fmt1_entry_validate;
 
-    gxv_StateTable_validate( p, limit, valid );
+    gxv_StateTable_validate( p, limit, gxvalid );
 
     GXV_EXIT;
   }
   gxv_kern_subtable_fmt2_clstbl_validate( FT_Bytes            table,
                                           FT_Bytes            limit,
                                           GXV_kern_ClassSpec  spec,
-                                          GXV_Validator       valid )
+                                          GXV_Validator       gxvalid )
   {
     const FT_String*  tag    = GXV_KERN_FMT2_DATA( class_tag[spec] );
     GXV_odtect_Range  odtect = GXV_KERN_FMT2_DATA( odtect );
     GXV_TRACE(( " %s firstGlyph=%d, nGlyphs=%d\n",
                 tag, firstGlyph, nGlyphs ));
 
-    gxv_glyphid_validate( firstGlyph, valid );
-    gxv_glyphid_validate( (FT_UShort)( firstGlyph + nGlyphs - 1 ), valid );
+    gxv_glyphid_validate( firstGlyph, gxvalid );
+    gxv_glyphid_validate( (FT_UShort)( firstGlyph + nGlyphs - 1 ), gxvalid );
 
     gxv_array_getlimits_ushort( p, p + ( 2 * nGlyphs ),
                                 &( GXV_KERN_FMT2_DATA( offset_min[spec] ) ),
                                 &( GXV_KERN_FMT2_DATA( offset_max[spec] ) ),
-                                valid );
+                                gxvalid );
 
     gxv_odtect_add_range( table, 2 * nGlyphs, tag, odtect );
 
   static void
   gxv_kern_subtable_fmt2_validate( FT_Bytes       table,
                                    FT_Bytes       limit,
-                                   GXV_Validator  valid )
+                                   GXV_Validator  gxvalid )
   {
     GXV_ODTECT( 3, odtect );
     GXV_kern_subtable_fmt2_DataRec  fmt2_rec =
     GXV_LIMIT_CHECK( GXV_KERN_FMT2_DATA( array ) );
 
     gxv_kern_subtable_fmt2_clstbl_validate( table + leftOffsetTable, limit,
-                                            GXV_KERN_CLS_L, valid );
+                                            GXV_KERN_CLS_L, gxvalid );
 
     gxv_kern_subtable_fmt2_clstbl_validate( table + rightOffsetTable, limit,
-                                            GXV_KERN_CLS_R, valid );
+                                            GXV_KERN_CLS_R, gxvalid );
 
     if ( GXV_KERN_FMT2_DATA( offset_min[GXV_KERN_CLS_L] ) +
            GXV_KERN_FMT2_DATA( offset_min[GXV_KERN_CLS_R] )
                             - GXV_KERN_FMT2_DATA( array ),
                           "array", odtect );
 
-    gxv_odtect_validate( odtect, valid );
+    gxv_odtect_validate( odtect, gxvalid );
 
     GXV_EXIT;
   }
   static void
   gxv_kern_subtable_fmt3_validate( FT_Bytes       table,
                                    FT_Bytes       limit,
-                                   GXV_Validator  valid )
+                                   GXV_Validator  gxvalid )
   {
     FT_Bytes   p = table + GXV_KERN_SUBTABLE_HEADER_SIZE;
     FT_UShort  glyphCount;
     rightClassCount = FT_NEXT_BYTE( p );
     flags           = FT_NEXT_BYTE( p );
 
-    if ( valid->face->num_glyphs != glyphCount )
+    if ( gxvalid->face->num_glyphs != glyphCount )
     {
       GXV_TRACE(( "maxGID=%d, but glyphCount=%d\n",
-                  valid->face->num_glyphs, glyphCount ));
+                  gxvalid->face->num_glyphs, glyphCount ));
       GXV_SET_ERR_IF_PARANOID( FT_INVALID_GLYPH_ID );
     }
 
 
 
       GXV_LIMIT_CHECK( glyphCount );
-      gxv_array_getlimits_byte( p, p + glyphCount, &min, &max, valid );
-      p += valid->subtable_length;
+      gxv_array_getlimits_byte( p, p + glyphCount, &min, &max, gxvalid );
+      p += gxvalid->subtable_length;
 
       if ( leftClassCount < max )
         FT_INVALID_DATA;
 
 
       GXV_LIMIT_CHECK( glyphCount );
-      gxv_array_getlimits_byte( p, p + glyphCount, &min, &max, valid );
-      p += valid->subtable_length;
+      gxv_array_getlimits_byte( p, p + glyphCount, &min, &max, gxvalid );
+      p += gxvalid->subtable_length;
 
       if ( rightClassCount < max )
         FT_INVALID_DATA;
       }
     }
 
-    valid->subtable_length = p - table;
+    gxvalid->subtable_length = p - table;
 
     GXV_EXIT;
   }
   static FT_Bool
   gxv_kern_coverage_new_apple_validate( FT_UShort      coverage,
                                         FT_UShort*     format,
-                                        GXV_Validator  valid )
+                                        GXV_Validator  gxvalid )
   {
     /* new Apple-dialect */
 #ifdef GXV_LOAD_TRACE_VARS
     FT_Bool  kernVariation;
 #endif
 
-    FT_UNUSED( valid );
+    FT_UNUSED( gxvalid );
 
 
     /* reserved bits = 0 */
   static FT_Bool
   gxv_kern_coverage_classic_apple_validate( FT_UShort      coverage,
                                             FT_UShort*     format,
-                                            GXV_Validator  valid )
+                                            GXV_Validator  gxvalid )
   {
     /* classic Apple-dialect */
 #ifdef GXV_LOAD_TRACE_VARS
 
 
     /* check expected flags, but don't check if MS-dialect is impossible */
-    if ( !( coverage & 0xFD00 ) && KERN_ALLOWS_MS( valid ) )
+    if ( !( coverage & 0xFD00 ) && KERN_ALLOWS_MS( gxvalid ) )
       return FALSE;
 
     /* reserved bits = 0 */
   static FT_Bool
   gxv_kern_coverage_classic_microsoft_validate( FT_UShort      coverage,
                                                 FT_UShort*     format,
-                                                GXV_Validator  valid )
+                                                GXV_Validator  gxvalid )
   {
     /* classic Microsoft-dialect */
 #ifdef GXV_LOAD_TRACE_VARS
     FT_Bool  override;
 #endif
 
-    FT_UNUSED( valid );
+    FT_UNUSED( gxvalid );
 
 
     /* reserved bits = 0 */
   static GXV_kern_Dialect
   gxv_kern_coverage_validate( FT_UShort      coverage,
                               FT_UShort*     format,
-                              GXV_Validator  valid )
+                              GXV_Validator  gxvalid )
   {
     GXV_kern_Dialect  result = KERN_DIALECT_UNKNOWN;
 
 
     GXV_TRACE(( "interprete coverage 0x%04x by Apple style\n", coverage ));
 
-    if ( KERN_IS_NEW( valid ) )
+    if ( KERN_IS_NEW( gxvalid ) )
     {
       if ( gxv_kern_coverage_new_apple_validate( coverage,
                                                  format,
-                                                 valid ) )
+                                                 gxvalid ) )
       {
         result = KERN_DIALECT_APPLE;
         goto Exit;
       }
     }
 
-    if ( KERN_IS_CLASSIC( valid ) && KERN_ALLOWS_APPLE( valid ) )
+    if ( KERN_IS_CLASSIC( gxvalid ) && KERN_ALLOWS_APPLE( gxvalid ) )
     {
       if ( gxv_kern_coverage_classic_apple_validate( coverage,
                                                      format,
-                                                     valid ) )
+                                                     gxvalid ) )
       {
         result = KERN_DIALECT_APPLE;
         goto Exit;
       }
     }
 
-    if ( KERN_IS_CLASSIC( valid ) && KERN_ALLOWS_MS( valid ) )
+    if ( KERN_IS_CLASSIC( gxvalid ) && KERN_ALLOWS_MS( gxvalid ) )
     {
       if ( gxv_kern_coverage_classic_microsoft_validate( coverage,
                                                          format,
-                                                         valid ) )
+                                                         gxvalid ) )
       {
         result = KERN_DIALECT_MS;
         goto Exit;
   static void
   gxv_kern_subtable_validate( FT_Bytes       table,
                               FT_Bytes       limit,
-                              GXV_Validator  valid )
+                              GXV_Validator  gxvalid )
   {
     FT_Bytes   p = table;
 #ifdef GXV_LOAD_TRACE_VARS
     u16[1]   = FT_NEXT_USHORT( p ); /* Apple: length_lo MS: length */
     coverage = FT_NEXT_USHORT( p );
 
-    switch ( gxv_kern_coverage_validate( coverage, &format, valid ) )
+    switch ( gxv_kern_coverage_validate( coverage, &format, gxvalid ) )
     {
     case KERN_DIALECT_MS:
 #ifdef GXV_LOAD_TRACE_VARS
 #endif
       GXV_TRACE(( "Subtable length = %d\n", length ));
 
-      if ( KERN_IS_NEW( valid ) )
+      if ( KERN_IS_NEW( gxvalid ) )
       {
         GXV_LIMIT_CHECK( 2 );
 #ifdef GXV_LOAD_TRACE_VARS
 
     /* formats 1, 2, 3 require the position of the start of this subtable */
     if ( format == 0 )
-      gxv_kern_subtable_fmt0_validate( table, table + length, valid );
+      gxv_kern_subtable_fmt0_validate( table, table + length, gxvalid );
     else if ( format == 1 )
-      gxv_kern_subtable_fmt1_validate( table, table + length, valid );
+      gxv_kern_subtable_fmt1_validate( table, table + length, gxvalid );
     else if ( format == 2 )
-      gxv_kern_subtable_fmt2_validate( table, table + length, valid );
+      gxv_kern_subtable_fmt2_validate( table, table + length, gxvalid );
     else if ( format == 3 )
-      gxv_kern_subtable_fmt3_validate( table, table + length, valid );
+      gxv_kern_subtable_fmt3_validate( table, table + length, gxvalid );
     else
       FT_INVALID_DATA;
 
   Exit:
-    valid->subtable_length = length;
+    gxvalid->subtable_length = length;
     GXV_EXIT;
   }
 
                              GXV_kern_Dialect  dialect_request,
                              FT_Validator      ftvalid )
   {
-    GXV_ValidatorRec   validrec;
-    GXV_Validator      valid = &validrec;
+    GXV_ValidatorRec   gxvalidrec;
+    GXV_Validator      gxvalid = &gxvalidrec;
 
     GXV_kern_DataRec   kernrec;
     GXV_kern_Data      kern = &kernrec;
     FT_UInt            i;
 
 
-    valid->root       = ftvalid;
-    valid->table_data = kern;
-    valid->face       = face;
+    gxvalid->root       = ftvalid;
+    gxvalid->table_data = kern;
+    gxvalid->face       = face;
 
     FT_TRACE3(( "validating `kern' table\n" ));
     GXV_INIT;
-    KERN_DIALECT( valid ) = dialect_request;
+    KERN_DIALECT( gxvalid ) = dialect_request;
 
     GXV_LIMIT_CHECK( 2 );
     GXV_KERN_DATA( version ) = (GXV_kern_Version)FT_NEXT_USHORT( p );
 
     if ( 0x0001 < GXV_KERN_DATA( version ) )
       FT_INVALID_FORMAT;
-    else if ( KERN_IS_CLASSIC( valid ) )
+    else if ( KERN_IS_CLASSIC( gxvalid ) )
     {
       GXV_LIMIT_CHECK( 2 );
       nTables = FT_NEXT_USHORT( p );
     }
-    else if ( KERN_IS_NEW( valid ) )
+    else if ( KERN_IS_NEW( gxvalid ) )
     {
       if ( classic_only )
         FT_INVALID_FORMAT;
     {
       GXV_TRACE(( "validating subtable %d/%d\n", i, nTables ));
       /* p should be 32bit-aligned? */
-      gxv_kern_subtable_validate( p, 0, valid );
-      p += valid->subtable_length;
+      gxv_kern_subtable_validate( p, 0, gxvalid );
+      p += gxvalid->subtable_length;
     }
 
     FT_TRACE4(( "\n" ));
index f14fa5b..48308b0 100644 (file)
   static void
   gxv_lcar_partial_validate( FT_UShort      partial,
                              FT_UShort      glyph,
-                             GXV_Validator  valid )
+                             GXV_Validator  gxvalid )
   {
     GXV_NAME_ENTER( "partial" );
 
     if ( GXV_LCAR_DATA( format ) != 1 )
       goto Exit;
 
-    gxv_ctlPoint_validate( glyph, partial, valid );
+    gxv_ctlPoint_validate( glyph, partial, gxvalid );
 
   Exit:
     GXV_EXIT;
   static void
   gxv_lcar_LookupValue_validate( FT_UShort            glyph,
                                  GXV_LookupValueCPtr  value_p,
-                                 GXV_Validator        valid )
+                                 GXV_Validator        gxvalid )
   {
-    FT_Bytes   p     = valid->root->base + value_p->u;
-    FT_Bytes   limit = valid->root->limit;
+    FT_Bytes   p     = gxvalid->root->base + value_p->u;
+    FT_Bytes   limit = gxvalid->root->limit;
     FT_UShort  count;
     FT_Short   partial;
     FT_UShort  i;
     for ( i = 0; i < count; i++ )
     {
       partial = FT_NEXT_SHORT( p );
-      gxv_lcar_partial_validate( partial, glyph, valid );
+      gxv_lcar_partial_validate( partial, glyph, gxvalid );
     }
 
     GXV_EXIT;
   gxv_lcar_LookupFmt4_transit( FT_UShort            relative_gindex,
                                GXV_LookupValueCPtr  base_value_p,
                                FT_Bytes             lookuptbl_limit,
-                               GXV_Validator        valid )
+                               GXV_Validator        gxvalid )
   {
     FT_Bytes             p;
     FT_Bytes             limit;
     /* XXX: check range? */
     offset = (FT_UShort)( base_value_p->u +
                           relative_gindex * sizeof ( FT_UShort ) );
-    p      = valid->root->base + offset;
-    limit  = valid->root->limit;
+    p      = gxvalid->root->base + offset;
+    limit  = gxvalid->root->limit;
 
     GXV_LIMIT_CHECK ( 2 );
     value.u = FT_NEXT_USHORT( p );
   {
     FT_Bytes          p     = table;
     FT_Bytes          limit = 0;
-    GXV_ValidatorRec  validrec;
-    GXV_Validator     valid = &validrec;
+    GXV_ValidatorRec  gxvalidrec;
+    GXV_Validator     gxvalid = &gxvalidrec;
 
     GXV_lcar_DataRec  lcarrec;
     GXV_lcar_Data     lcar = &lcarrec;
     FT_Fixed          version;
 
 
-    valid->root       = ftvalid;
-    valid->table_data = lcar;
-    valid->face       = face;
+    gxvalid->root       = ftvalid;
+    gxvalid->table_data = lcar;
+    gxvalid->face       = face;
 
     FT_TRACE3(( "validating `lcar' table\n" ));
     GXV_INIT;
     if ( GXV_LCAR_DATA( format ) > 1 )
       FT_INVALID_FORMAT;
 
-    valid->lookupval_sign   = GXV_LOOKUPVALUE_UNSIGNED;
-    valid->lookupval_func   = gxv_lcar_LookupValue_validate;
-    valid->lookupfmt4_trans = gxv_lcar_LookupFmt4_transit;
-    gxv_LookupTable_validate( p, limit, valid );
+    gxvalid->lookupval_sign   = GXV_LOOKUPVALUE_UNSIGNED;
+    gxvalid->lookupval_func   = gxv_lcar_LookupValue_validate;
+    gxvalid->lookupfmt4_trans = gxv_lcar_LookupFmt4_transit;
+    gxv_LookupTable_validate( p, limit, gxvalid );
 
     FT_TRACE4(( "\n" ));
   }
index c4d49b3..55ff5a8 100644 (file)
@@ -40,7 +40,7 @@
 
   static void
   gxv_mort_feature_validate( GXV_mort_feature  f,
-                             GXV_Validator     valid )
+                             GXV_Validator     gxvalid )
   {
     if ( f->featureType >= gxv_feat_registry_length )
     {
@@ -89,7 +89,7 @@
   gxv_mort_featurearray_validate( FT_Bytes       table,
                                   FT_Bytes       limit,
                                   FT_ULong       nFeatureFlags,
-                                  GXV_Validator  valid )
+                                  GXV_Validator  gxvalid )
   {
     FT_Bytes  p = table;
     FT_ULong  i;
       f.enableFlags    = FT_NEXT_ULONG( p );
       f.disableFlags   = FT_NEXT_ULONG( p );
 
-      gxv_mort_feature_validate( &f, valid );
+      gxv_mort_feature_validate( &f, gxvalid );
     }
 
     if ( !IS_GXV_MORT_FEATURE_OFF( f ) )
       FT_INVALID_DATA;
 
-    valid->subtable_length = p - table;
+    gxvalid->subtable_length = p - table;
     GXV_EXIT;
   }
 
 
   FT_LOCAL_DEF( void )
   gxv_mort_coverage_validate( FT_UShort      coverage,
-                              GXV_Validator  valid )
+                              GXV_Validator  gxvalid )
   {
-    FT_UNUSED( valid );
+    FT_UNUSED( gxvalid );
 
 #ifdef FT_DEBUG_LEVEL_TRACE
     if ( coverage & 0x8000U )
   gxv_mort_subtables_validate( FT_Bytes       table,
                                FT_Bytes       limit,
                                FT_UShort      nSubtables,
-                               GXV_Validator  valid )
+                               GXV_Validator  gxvalid )
   {
     FT_Bytes  p = table;
 
       rest = length - ( 2 + 2 + 4 );
 
       GXV_LIMIT_CHECK( rest );
-      gxv_mort_coverage_validate( coverage, valid );
+      gxv_mort_coverage_validate( coverage, gxvalid );
 
       if ( type > 5 )
         FT_INVALID_FORMAT;
       if ( func == NULL )
         GXV_TRACE(( "morx type %d is reserved\n", type ));
 
-      func( p, p + rest, valid );
+      func( p, p + rest, gxvalid );
 
       p += rest;
       /* TODO: validate subFeatureFlags */
     }
 
-    valid->subtable_length = p - table;
+    gxvalid->subtable_length = p - table;
 
     GXV_EXIT;
   }
   static void
   gxv_mort_chain_validate( FT_Bytes       table,
                            FT_Bytes       limit,
-                           GXV_Validator  valid )
+                           GXV_Validator  gxvalid )
   {
     FT_Bytes   p = table;
 #ifdef GXV_LOAD_UNUSED_VARS
     nSubtables    = FT_NEXT_USHORT( p );
 
     gxv_mort_featurearray_validate( p, table + chainLength,
-                                    nFeatureFlags, valid );
-    p += valid->subtable_length;
-    gxv_mort_subtables_validate( p, table + chainLength, nSubtables, valid );
-    valid->subtable_length = chainLength;
+                                    nFeatureFlags, gxvalid );
+    p += gxvalid->subtable_length;
+    gxv_mort_subtables_validate( p, table + chainLength, nSubtables, gxvalid );
+    gxvalid->subtable_length = chainLength;
 
     /* TODO: validate defaultFlags */
     GXV_EXIT;
                      FT_Face       face,
                      FT_Validator  ftvalid )
   {
-    GXV_ValidatorRec  validrec;
-    GXV_Validator     valid = &validrec;
+    GXV_ValidatorRec  gxvalidrec;
+    GXV_Validator     gxvalid = &gxvalidrec;
     FT_Bytes          p     = table;
     FT_Bytes          limit = 0;
     FT_ULong          version;
     FT_ULong          i;
 
 
-    valid->root = ftvalid;
-    valid->face = face;
-    limit       valid->root->limit;
+    gxvalid->root = ftvalid;
+    gxvalid->face = face;
+    limit         = gxvalid->root->limit;
 
     FT_TRACE3(( "validating `mort' table\n" ));
     GXV_INIT;
     {
       GXV_TRACE(( "validating chain %d/%d\n", i + 1, nChains ));
       GXV_32BIT_ALIGNMENT_VALIDATE( p - table );
-      gxv_mort_chain_validate( p, limit, valid );
-      p += valid->subtable_length;
+      gxv_mort_chain_validate( p, limit, gxvalid );
+      p += gxvalid->subtable_length;
     }
 
     FT_TRACE4(( "\n" ));
index 1e5a1f5..8e62e52 100644 (file)
   gxv_mort_featurearray_validate( FT_Bytes       table,
                                   FT_Bytes       limit,
                                   FT_ULong       nFeatureFlags,
-                                  GXV_Validator  valid );
+                                  GXV_Validator  gxvalid );
 
   FT_LOCAL( void )
   gxv_mort_coverage_validate( FT_UShort      coverage,
-                              GXV_Validator  valid );
+                              GXV_Validator  gxvalid );
 
   FT_LOCAL( void )
   gxv_mort_subtable_type0_validate( FT_Bytes       table,
                                     FT_Bytes       limit,
-                                    GXV_Validator  valid );
+                                    GXV_Validator  gxvalid );
 
   FT_LOCAL( void )
   gxv_mort_subtable_type1_validate( FT_Bytes       table,
                                     FT_Bytes       limit,
-                                    GXV_Validator  valid );
+                                    GXV_Validator  gxvalid );
 
   FT_LOCAL( void )
   gxv_mort_subtable_type2_validate( FT_Bytes       table,
                                     FT_Bytes       limit,
-                                    GXV_Validator  valid );
+                                    GXV_Validator  gxvalid );
 
   FT_LOCAL( void )
   gxv_mort_subtable_type4_validate( FT_Bytes       table,
                                     FT_Bytes       limit,
-                                    GXV_Validator  valid );
+                                    GXV_Validator  gxvalid );
 
   FT_LOCAL( void )
   gxv_mort_subtable_type5_validate( FT_Bytes       table,
                                     FT_Bytes       limit,
-                                    GXV_Validator  valid );
+                                    GXV_Validator  gxvalid );
 
 
 #endif /* __GXVMORT_H__ */
index b136ced..f19016e 100644 (file)
@@ -67,7 +67,7 @@
     GXV_StateTable_GlyphOffsetCPtr  glyphOffset_p,
     FT_Bytes                        table,
     FT_Bytes                        limit,
-    GXV_Validator                   valid )
+    GXV_Validator                   gxvalid )
   {
     FT_UShort  markFirst;
     FT_UShort  dontAdvance;
   FT_LOCAL_DEF( void )
   gxv_mort_subtable_type0_validate( FT_Bytes       table,
                                     FT_Bytes       limit,
-                                    GXV_Validator  valid )
+                                    GXV_Validator  gxvalid )
   {
     FT_Bytes  p = table;
 
 
     GXV_LIMIT_CHECK( GXV_STATETABLE_HEADER_SIZE );
 
-    valid->statetable.optdata               = NULL;
-    valid->statetable.optdata_load_func     = NULL;
-    valid->statetable.subtable_setup_func   = NULL;
-    valid->statetable.entry_glyphoffset_fmt = GXV_GLYPHOFFSET_NONE;
-    valid->statetable.entry_validate_func =
+    gxvalid->statetable.optdata               = NULL;
+    gxvalid->statetable.optdata_load_func     = NULL;
+    gxvalid->statetable.subtable_setup_func   = NULL;
+    gxvalid->statetable.entry_glyphoffset_fmt = GXV_GLYPHOFFSET_NONE;
+    gxvalid->statetable.entry_validate_func =
       gxv_mort_subtable_type0_entry_validate;
 
-    gxv_StateTable_validate( p, limit, valid );
+    gxv_StateTable_validate( p, limit, gxvalid );
 
     GXV_EXIT;
   }
index 1c17a5d..0189504 100644 (file)
   static void
   gxv_mort_subtable_type1_substitutionTable_load( FT_Bytes       table,
                                                   FT_Bytes       limit,
-                                                  GXV_Validator  valid )
+                                                  GXV_Validator  gxvalid )
   {
     FT_Bytes  p = table;
 
     GXV_mort_subtable_type1_StateOptRecData  optdata =
-      (GXV_mort_subtable_type1_StateOptRecData)valid->statetable.optdata;
+      (GXV_mort_subtable_type1_StateOptRecData)gxvalid->statetable.optdata;
 
 
     GXV_LIMIT_CHECK( 2 );
                                           FT_UShort*     classTable_length_p,
                                           FT_UShort*     stateArray_length_p,
                                           FT_UShort*     entryTable_length_p,
-                                          GXV_Validator  valid )
+                                          GXV_Validator  gxvalid )
   {
     FT_UShort  o[4];
     FT_UShort  *l[4];
     FT_UShort  buff[5];
 
     GXV_mort_subtable_type1_StateOptRecData  optdata =
-      (GXV_mort_subtable_type1_StateOptRecData)valid->statetable.optdata;
+      (GXV_mort_subtable_type1_StateOptRecData)gxvalid->statetable.optdata;
 
 
     o[0] = classTable;
@@ -93,7 +93,7 @@
     l[2] = entryTable_length_p;
     l[3] = &( optdata->substitutionTable_length );
 
-    gxv_set_length_by_ushort_offset( o, l, buff, 4, table_size, valid );
+    gxv_set_length_by_ushort_offset( o, l, buff, 4, table_size, gxvalid );
   }
 
 
     FT_Short          wordOffset,
     const FT_String*  tag,
     FT_Byte           state,
-    GXV_Validator     valid )
+    GXV_Validator     gxvalid )
   {
     FT_UShort  substTable;
     FT_UShort  substTable_limit;
 
     substTable =
       ((GXV_mort_subtable_type1_StateOptRec *)
-       (valid->statetable.optdata))->substitutionTable;
+       (gxvalid->statetable.optdata))->substitutionTable;
     substTable_limit =
       (FT_UShort)( substTable +
                    ((GXV_mort_subtable_type1_StateOptRec *)
-                    (valid->statetable.optdata))->substitutionTable_length );
+                    (gxvalid->statetable.optdata))->substitutionTable_length );
 
-    valid->min_gid = (FT_UShort)( ( substTable       - wordOffset * 2 ) / 2 );
-    valid->max_gid = (FT_UShort)( ( substTable_limit - wordOffset * 2 ) / 2 );
-    valid->max_gid = (FT_UShort)( FT_MAX( valid->max_gid,
-                                          valid->face->num_glyphs ) );
+    gxvalid->min_gid = (FT_UShort)( ( substTable       - wordOffset * 2 ) / 2 );
+    gxvalid->max_gid = (FT_UShort)( ( substTable_limit - wordOffset * 2 ) / 2 );
+    gxvalid->max_gid = (FT_UShort)( FT_MAX( gxvalid->max_gid,
+                                            gxvalid->face->num_glyphs ) );
 
     /* XXX: check range? */
 
     GXV_StateTable_GlyphOffsetCPtr  glyphOffset_p,
     FT_Bytes                        table,
     FT_Bytes                        limit,
-    GXV_Validator                   valid )
+    GXV_Validator                   gxvalid )
   {
 #ifdef GXV_LOAD_UNUSED_VARS
     FT_UShort  setMark;
     gxv_mort_subtable_type1_offset_to_subst_validate( markOffset,
                                                       "markOffset",
                                                       state,
-                                                      valid );
+                                                      gxvalid );
 
     gxv_mort_subtable_type1_offset_to_subst_validate( currentOffset,
                                                       "currentOffset",
                                                       state,
-                                                      valid );
+                                                      gxvalid );
   }
 
 
   static void
   gxv_mort_subtable_type1_substTable_validate( FT_Bytes       table,
                                                FT_Bytes       limit,
-                                               GXV_Validator  valid )
+                                               GXV_Validator  gxvalid )
   {
     FT_Bytes   p = table;
     FT_UShort  num_gids = (FT_UShort)(
                  ((GXV_mort_subtable_type1_StateOptRec *)
-                  (valid->statetable.optdata))->substitutionTable_length / 2 );
+                  (gxvalid->statetable.optdata))->substitutionTable_length / 2 );
     FT_UShort  i;
 
 
       if ( dst_gid >= 0xFFFFU )
         continue;
 
-      if ( dst_gid < valid->min_gid || valid->max_gid < dst_gid )
+      if ( dst_gid < gxvalid->min_gid || gxvalid->max_gid < dst_gid )
       {
         GXV_TRACE(( "substTable include a strange gid[%d]=%d >"
                     " out of define range (%d..%d)\n",
-                    i, dst_gid, valid->min_gid, valid->max_gid ));
+                    i, dst_gid, gxvalid->min_gid, gxvalid->max_gid ));
         GXV_SET_ERR_IF_PARANOID( FT_INVALID_GLYPH_ID );
       }
     }
   FT_LOCAL_DEF( void )
   gxv_mort_subtable_type1_validate( FT_Bytes       table,
                                     FT_Bytes       limit,
-                                    GXV_Validator  valid )
+                                    GXV_Validator  gxvalid )
   {
     FT_Bytes  p = table;
 
 
     GXV_LIMIT_CHECK( GXV_MORT_SUBTABLE_TYPE1_HEADER_SIZE );
 
-    valid->statetable.optdata =
+    gxvalid->statetable.optdata =
       &st_rec;
-    valid->statetable.optdata_load_func =
+    gxvalid->statetable.optdata_load_func =
       gxv_mort_subtable_type1_substitutionTable_load;
-    valid->statetable.subtable_setup_func =
+    gxvalid->statetable.subtable_setup_func =
       gxv_mort_subtable_type1_subtable_setup;
-    valid->statetable.entry_glyphoffset_fmt =
+    gxvalid->statetable.entry_glyphoffset_fmt =
       GXV_GLYPHOFFSET_ULONG;
-    valid->statetable.entry_validate_func =
+    gxvalid->statetable.entry_validate_func =
 
       gxv_mort_subtable_type1_entry_validate;
-    gxv_StateTable_validate( p, limit, valid );
+    gxv_StateTable_validate( p, limit, gxvalid );
 
     gxv_mort_subtable_type1_substTable_validate(
       table + st_rec.substitutionTable,
       table + st_rec.substitutionTable + st_rec.substitutionTable_length,
-      valid );
+      gxvalid );
 
     GXV_EXIT;
   }
index 9e08fb7..099ffd4 100644 (file)
   static void
   gxv_mort_subtable_type2_opttable_load( FT_Bytes       table,
                                          FT_Bytes       limit,
-                                         GXV_Validator  valid )
+                                         GXV_Validator  gxvalid )
   {
-    FT_Bytes p = table;
+    FT_Bytes  p = table;
     GXV_mort_subtable_type2_StateOptRecData  optdata =
-      (GXV_mort_subtable_type2_StateOptRecData)valid->statetable.optdata;
+      (GXV_mort_subtable_type2_StateOptRecData)gxvalid->statetable.optdata;
 
 
     GXV_LIMIT_CHECK( 2 + 2 + 2 );
                                           FT_UShort      *classTable_length_p,
                                           FT_UShort      *stateArray_length_p,
                                           FT_UShort      *entryTable_length_p,
-                                          GXV_Validator  valid )
+                                          GXV_Validator  gxvalid )
   {
     FT_UShort  o[6];
     FT_UShort  *l[6];
     FT_UShort  buff[7];
 
     GXV_mort_subtable_type2_StateOptRecData  optdata =
-      (GXV_mort_subtable_type2_StateOptRecData)valid->statetable.optdata;
+      (GXV_mort_subtable_type2_StateOptRecData)gxvalid->statetable.optdata;
 
 
     GXV_NAME_ENTER( "subtable boundaries setup" );
     l[4] = &(optdata->componentTable_length);
     l[5] = &(optdata->ligatureTable_length);
 
-    gxv_set_length_by_ushort_offset( o, l, buff, 6, table_size, valid );
+    gxv_set_length_by_ushort_offset( o, l, buff, 6, table_size, gxvalid );
 
     GXV_TRACE(( "classTable: offset=0x%04x length=0x%04x\n",
                 classTable, *classTable_length_p ));
   gxv_mort_subtable_type2_ligActionOffset_validate(
     FT_Bytes       table,
     FT_UShort      ligActionOffset,
-    GXV_Validator  valid )
+    GXV_Validator  gxvalid )
   {
     /* access ligActionTable */
     GXV_mort_subtable_type2_StateOptRecData  optdata =
-      (GXV_mort_subtable_type2_StateOptRecData)valid->statetable.optdata;
+      (GXV_mort_subtable_type2_StateOptRecData)gxvalid->statetable.optdata;
 
     FT_Bytes lat_base  = table + optdata->ligActionTable;
     FT_Bytes p         = table + ligActionOffset;
     GXV_StateTable_GlyphOffsetCPtr  glyphOffset_p,
     FT_Bytes                        table,
     FT_Bytes                        limit,
-    GXV_Validator                   valid )
+    GXV_Validator                   gxvalid )
   {
 #ifdef GXV_LOAD_UNUSED_VARS
     FT_UShort setComponent;
 
     if ( 0 < offset )
       gxv_mort_subtable_type2_ligActionOffset_validate( table, offset,
-                                                        valid );
+                                                        gxvalid );
   }
 
 
   static void
   gxv_mort_subtable_type2_ligatureTable_validate( FT_Bytes       table,
-                                                  GXV_Validator  valid )
+                                                  GXV_Validator  gxvalid )
   {
     GXV_mort_subtable_type2_StateOptRecData  optdata =
-      (GXV_mort_subtable_type2_StateOptRecData)valid->statetable.optdata;
+      (GXV_mort_subtable_type2_StateOptRecData)gxvalid->statetable.optdata;
 
     FT_Bytes p     = table + optdata->ligatureTable;
     FT_Bytes limit = table + optdata->ligatureTable
         GXV_LIMIT_CHECK( 2 );
         lig_gid = FT_NEXT_USHORT( p );
 
-        if ( valid->face->num_glyphs < lig_gid )
+        if ( gxvalid->face->num_glyphs < lig_gid )
           GXV_SET_ERR_IF_PARANOID( FT_INVALID_GLYPH_ID );
       }
     }
   FT_LOCAL_DEF( void )
   gxv_mort_subtable_type2_validate( FT_Bytes       table,
                                     FT_Bytes       limit,
-                                    GXV_Validator  valid )
+                                    GXV_Validator  gxvalid )
   {
     FT_Bytes  p = table;
 
 
     GXV_LIMIT_CHECK( GXV_MORT_SUBTABLE_TYPE2_HEADER_SIZE );
 
-    valid->statetable.optdata =
+    gxvalid->statetable.optdata =
       &lig_rec;
-    valid->statetable.optdata_load_func =
+    gxvalid->statetable.optdata_load_func =
       gxv_mort_subtable_type2_opttable_load;
-    valid->statetable.subtable_setup_func =
+    gxvalid->statetable.subtable_setup_func =
       gxv_mort_subtable_type2_subtable_setup;
-    valid->statetable.entry_glyphoffset_fmt =
+    gxvalid->statetable.entry_glyphoffset_fmt =
       GXV_GLYPHOFFSET_NONE;
-    valid->statetable.entry_validate_func =
+    gxvalid->statetable.entry_validate_func =
       gxv_mort_subtable_type2_entry_validate;
 
-    gxv_StateTable_validate( p, limit, valid );
+    gxv_StateTable_validate( p, limit, gxvalid );
 
-    p += valid->subtable_length;
-    gxv_mort_subtable_type2_ligatureTable_validate( table, valid );
+    p += gxvalid->subtable_length;
+    gxv_mort_subtable_type2_ligatureTable_validate( table, gxvalid );
 
-    valid->subtable_length = p - table;
+    gxvalid->subtable_length = p - table;
 
     GXV_EXIT;
   }
index 8347098..9e86af4 100644 (file)
   static void
   gxv_mort_subtable_type4_lookupval_validate( FT_UShort            glyph,
                                               GXV_LookupValueCPtr  value_p,
-                                              GXV_Validator        valid )
+                                              GXV_Validator        gxvalid )
   {
     FT_UNUSED( glyph );
 
-    gxv_glyphid_validate( value_p->u, valid );
+    gxv_glyphid_validate( value_p->u, gxvalid );
   }
 
   /*
@@ -80,7 +80,7 @@
     FT_UShort            relative_gindex,
     GXV_LookupValueCPtr  base_value_p,
     FT_Bytes             lookuptbl_limit,
-    GXV_Validator        valid )
+    GXV_Validator        gxvalid )
   {
     FT_Bytes             p;
     FT_Bytes             limit;
@@ -91,7 +91,7 @@
     offset = (FT_UShort)( base_value_p->u +
                           relative_gindex * sizeof ( FT_UShort ) );
 
-    p     = valid->lookuptbl_head + offset;
+    p     = gxvalid->lookuptbl_head + offset;
     limit = lookuptbl_limit;
 
     GXV_LIMIT_CHECK( 2 );
   FT_LOCAL_DEF( void )
   gxv_mort_subtable_type4_validate( FT_Bytes       table,
                                     FT_Bytes       limit,
-                                    GXV_Validator  valid )
+                                    GXV_Validator  gxvalid )
   {
     FT_Bytes  p = table;
 
     GXV_NAME_ENTER( "mort chain subtable type4 "
                     "(Non-Contextual Glyph Substitution)" );
 
-    valid->lookupval_sign   = GXV_LOOKUPVALUE_UNSIGNED;
-    valid->lookupval_func   = gxv_mort_subtable_type4_lookupval_validate;
-    valid->lookupfmt4_trans = gxv_mort_subtable_type4_lookupfmt4_transit;
+    gxvalid->lookupval_sign   = GXV_LOOKUPVALUE_UNSIGNED;
+    gxvalid->lookupval_func   = gxv_mort_subtable_type4_lookupval_validate;
+    gxvalid->lookupfmt4_trans = gxv_mort_subtable_type4_lookupfmt4_transit;
 
-    gxv_LookupTable_validate( p, limit, valid );
+    gxv_LookupTable_validate( p, limit, gxvalid );
 
     GXV_EXIT;
   }
index 32cfb03..9498b10 100644 (file)
                                           FT_UShort*     classTable_length_p,
                                           FT_UShort*     stateArray_length_p,
                                           FT_UShort*     entryTable_length_p,
-                                          GXV_Validator  valid )
+                                          GXV_Validator  gxvalid )
   {
     GXV_mort_subtable_type5_StateOptRecData  optdata =
-      (GXV_mort_subtable_type5_StateOptRecData)valid->statetable.optdata;
+      (GXV_mort_subtable_type5_StateOptRecData)gxvalid->statetable.optdata;
 
 
     gxv_StateTable_subtable_setup( table_size,
@@ -83,7 +83,7 @@
                                    classTable_length_p,
                                    stateArray_length_p,
                                    entryTable_length_p,
-                                   valid );
+                                   gxvalid );
 
     optdata->classTable = classTable;
     optdata->stateArray = stateArray;
                                                FT_UShort      count,
                                                FT_Bytes       table,
                                                FT_Bytes       limit,
-                                               GXV_Validator  valid )
+                                               GXV_Validator  gxvalid )
   {
     /*
      * We don't know the range of insertion-glyph-list.
     FT_Bytes  p = table + offset;
 
     GXV_mort_subtable_type5_StateOptRecData  optdata =
-      (GXV_mort_subtable_type5_StateOptRecData)valid->statetable.optdata;
+      (GXV_mort_subtable_type5_StateOptRecData)gxvalid->statetable.optdata;
 
     if ( optdata->classTable < offset                                   &&
          offset < optdata->classTable + *(optdata->classTable_length_p) )
     GXV_StateTable_GlyphOffsetCPtr  glyphOffset,
     FT_Bytes                        table,
     FT_Bytes                        limit,
-    GXV_Validator                   valid )
+    GXV_Validator                   gxvalid )
   {
 #ifdef GXV_LOAD_UNUSED_VARS
     FT_Bool    setMark;
                                                    currentInsertCount,
                                                    table,
                                                    limit,
-                                                   valid );
+                                                   gxvalid );
     }
 
     if ( 0 != markedInsertList && 0 != markedInsertCount )
                                                    markedInsertCount,
                                                    table,
                                                    limit,
-                                                   valid );
+                                                   gxvalid );
     }
   }
 
   FT_LOCAL_DEF( void )
   gxv_mort_subtable_type5_validate( FT_Bytes       table,
                                     FT_Bytes       limit,
-                                    GXV_Validator  valid )
+                                    GXV_Validator  gxvalid )
   {
     FT_Bytes  p = table;
 
 
     GXV_LIMIT_CHECK( GXV_MORT_SUBTABLE_TYPE5_HEADER_SIZE );
 
-    valid->statetable.optdata =
+    gxvalid->statetable.optdata =
       et;
-    valid->statetable.optdata_load_func =
+    gxvalid->statetable.optdata_load_func =
       NULL;
-    valid->statetable.subtable_setup_func =
+    gxvalid->statetable.subtable_setup_func =
       gxv_mort_subtable_type5_subtable_setup;
-    valid->statetable.entry_glyphoffset_fmt =
+    gxvalid->statetable.entry_glyphoffset_fmt =
       GXV_GLYPHOFFSET_ULONG;
-    valid->statetable.entry_validate_func =
+    gxvalid->statetable.entry_validate_func =
       gxv_mort_subtable_type5_entry_validate;
 
-    gxv_StateTable_validate( p, limit, valid );
+    gxv_StateTable_validate( p, limit, gxvalid );
 
     GXV_EXIT;
   }
index 5ae04d3..96dba63 100644 (file)
@@ -42,7 +42,7 @@
   gxv_morx_subtables_validate( FT_Bytes       table,
                                FT_Bytes       limit,
                                FT_UShort      nSubtables,
-                               GXV_Validator  valid )
+                               GXV_Validator  gxvalid )
   {
     FT_Bytes  p = table;
 
@@ -93,7 +93,7 @@
 
       /* morx coverage consists of mort_coverage & 16bit padding */
       gxv_mort_coverage_validate( (FT_UShort)( ( coverage >> 16 ) | coverage ),
-                                  valid );
+                                  gxvalid );
       if ( type > 5 )
         FT_INVALID_FORMAT;
 
       if ( func == NULL )
         GXV_TRACE(( "morx type %d is reserved\n", type ));
 
-      func( p, p + rest, valid );
+      func( p, p + rest, gxvalid );
 
       /* TODO: subFeatureFlags should be unique in a table? */
       p += rest;
     }
 
-    valid->subtable_length = p - table;
+    gxvalid->subtable_length = p - table;
 
     GXV_EXIT;
   }
   static void
   gxv_morx_chain_validate( FT_Bytes       table,
                            FT_Bytes       limit,
-                           GXV_Validator  valid )
+                           GXV_Validator  gxvalid )
   {
     FT_Bytes  p = table;
 #ifdef GXV_LOAD_UNUSED_VARS
     nSubtables    = FT_NEXT_ULONG( p );
 
     /* feature-array of morx is same with that of mort */
-    gxv_mort_featurearray_validate( p, limit, nFeatureFlags, valid );
-    p += valid->subtable_length;
+    gxv_mort_featurearray_validate( p, limit, nFeatureFlags, gxvalid );
+    p += gxvalid->subtable_length;
 
     if ( nSubtables >= 0x10000L )
       FT_INVALID_DATA;
 
     gxv_morx_subtables_validate( p, table + chainLength,
-                                 (FT_UShort)nSubtables, valid );
+                                 (FT_UShort)nSubtables, gxvalid );
 
-    valid->subtable_length = chainLength;
+    gxvalid->subtable_length = chainLength;
 
     /* TODO: defaultFlags should be compared with the flags in tables */
 
                      FT_Face       face,
                      FT_Validator  ftvalid )
   {
-    GXV_ValidatorRec  validrec;
-    GXV_Validator     valid = &validrec;
+    GXV_ValidatorRec  gxvalidrec;
+    GXV_Validator     gxvalid = &gxvalidrec;
     FT_Bytes          p     = table;
     FT_Bytes          limit = 0;
     FT_ULong          version;
     FT_ULong          i;
 
 
-    valid->root = ftvalid;
-    valid->face = face;
+    gxvalid->root = ftvalid;
+    gxvalid->face = face;
 
     FT_TRACE3(( "validating `morx' table\n" ));
     GXV_INIT;
     {
       GXV_TRACE(( "validating chain %d/%d\n", i + 1, nChains ));
       GXV_32BIT_ALIGNMENT_VALIDATE( p - table );
-      gxv_morx_chain_validate( p, limit, valid );
-      p += valid->subtable_length;
+      gxv_morx_chain_validate( p, limit, gxvalid );
+      p += gxvalid->subtable_length;
     }
 
     FT_TRACE4(( "\n" ));
index 28c1a44..9ed907a 100644 (file)
   FT_LOCAL( void )
   gxv_morx_subtable_type0_validate( FT_Bytes       table,
                                     FT_Bytes       limit,
-                                    GXV_Validator  valid );
+                                    GXV_Validator  gxvalid );
 
   FT_LOCAL( void )
   gxv_morx_subtable_type1_validate( FT_Bytes       table,
                                     FT_Bytes       limit,
-                                    GXV_Validator  valid );
+                                    GXV_Validator  gxvalid );
 
   FT_LOCAL( void )
   gxv_morx_subtable_type2_validate( FT_Bytes       table,
                                     FT_Bytes       limit,
-                                    GXV_Validator  valid );
+                                    GXV_Validator  gxvalid );
 
   FT_LOCAL( void )
   gxv_morx_subtable_type4_validate( FT_Bytes       table,
                                     FT_Bytes       limit,
-                                    GXV_Validator  valid );
+                                    GXV_Validator  gxvalid );
 
   FT_LOCAL( void )
   gxv_morx_subtable_type5_validate( FT_Bytes       table,
                                     FT_Bytes       limit,
-                                    GXV_Validator  valid );
+                                    GXV_Validator  gxvalid );
 
 
 #endif /* __GXVMORX_H__ */
index 6a736c1..db165f4 100644 (file)
@@ -45,7 +45,7 @@
     GXV_XStateTable_GlyphOffsetCPtr  glyphOffset_p,
     FT_Bytes                         table,
     FT_Bytes                         limit,
-    GXV_Validator                    valid )
+    GXV_Validator                    gxvalid )
   {
 #ifdef GXV_LOAD_UNUSED_VARS
     FT_UShort  markFirst;
@@ -85,7 +85,7 @@
   FT_LOCAL_DEF( void )
   gxv_morx_subtable_type0_validate( FT_Bytes       table,
                                     FT_Bytes       limit,
-                                    GXV_Validator  valid )
+                                    GXV_Validator  gxvalid )
   {
     FT_Bytes  p = table;
 
 
     GXV_LIMIT_CHECK( GXV_STATETABLE_HEADER_SIZE );
 
-    valid->xstatetable.optdata               = NULL;
-    valid->xstatetable.optdata_load_func     = NULL;
-    valid->xstatetable.subtable_setup_func   = NULL;
-    valid->xstatetable.entry_glyphoffset_fmt = GXV_GLYPHOFFSET_NONE;
-    valid->xstatetable.entry_validate_func =
+    gxvalid->xstatetable.optdata               = NULL;
+    gxvalid->xstatetable.optdata_load_func     = NULL;
+    gxvalid->xstatetable.subtable_setup_func   = NULL;
+    gxvalid->xstatetable.entry_glyphoffset_fmt = GXV_GLYPHOFFSET_NONE;
+    gxvalid->xstatetable.entry_validate_func =
       gxv_morx_subtable_type0_entry_validate;
 
-    gxv_XStateTable_validate( p, limit, valid );
+    gxv_XStateTable_validate( p, limit, gxvalid );
 
     GXV_EXIT;
   }
index ce0009a..49f53d1 100644 (file)
   static void
   gxv_morx_subtable_type1_substitutionTable_load( FT_Bytes       table,
                                                   FT_Bytes       limit,
-                                                  GXV_Validator  valid )
+                                                  GXV_Validator  gxvalid )
   {
     FT_Bytes  p = table;
 
     GXV_morx_subtable_type1_StateOptRecData  optdata =
-      (GXV_morx_subtable_type1_StateOptRecData)valid->xstatetable.optdata;
+      (GXV_morx_subtable_type1_StateOptRecData)gxvalid->xstatetable.optdata;
 
 
     GXV_LIMIT_CHECK( 2 );
                                           FT_ULong*      classTable_length_p,
                                           FT_ULong*      stateArray_length_p,
                                           FT_ULong*      entryTable_length_p,
-                                          GXV_Validator  valid )
+                                          GXV_Validator  gxvalid )
   {
     FT_ULong  o[4];
     FT_ULong  *l[4];
     FT_ULong  buff[5];
 
     GXV_morx_subtable_type1_StateOptRecData  optdata =
-      (GXV_morx_subtable_type1_StateOptRecData)valid->xstatetable.optdata;
+      (GXV_morx_subtable_type1_StateOptRecData)gxvalid->xstatetable.optdata;
 
 
     o[0] = classTable;
@@ -95,7 +95,7 @@
     l[2] = entryTable_length_p;
     l[3] = &(optdata->substitutionTable_length);
 
-    gxv_set_length_by_ulong_offset( o, l, buff, 4, table_size, valid );
+    gxv_set_length_by_ulong_offset( o, l, buff, 4, table_size, gxvalid );
   }
 
 
     GXV_StateTable_GlyphOffsetCPtr  glyphOffset_p,
     FT_Bytes                        table,
     FT_Bytes                        limit,
-    GXV_Validator                   valid )
+    GXV_Validator                   gxvalid )
   {
 #ifdef GXV_LOAD_TRACE_VARS
     FT_UShort  setMark;
     FT_Short   currentIndex;
 
     GXV_morx_subtable_type1_StateOptRecData  optdata =
-      (GXV_morx_subtable_type1_StateOptRecData)valid->xstatetable.optdata;
+      (GXV_morx_subtable_type1_StateOptRecData)gxvalid->xstatetable.optdata;
 
     FT_UNUSED( state );
     FT_UNUSED( table );
   static void
   gxv_morx_subtable_type1_LookupValue_validate( FT_UShort            glyph,
                                                 GXV_LookupValueCPtr  value_p,
-                                                GXV_Validator        valid )
+                                                GXV_Validator        gxvalid )
   {
     FT_UNUSED( glyph ); /* for the non-debugging case */
 
     GXV_TRACE(( "morx subtable type1 subst.: %d -> %d\n", glyph, value_p->u ));
 
-    if ( value_p->u > valid->face->num_glyphs )
+    if ( value_p->u > gxvalid->face->num_glyphs )
       FT_INVALID_GLYPH_ID;
   }
 
     FT_UShort            relative_gindex,
     GXV_LookupValueCPtr  base_value_p,
     FT_Bytes             lookuptbl_limit,
-    GXV_Validator        valid )
+    GXV_Validator        gxvalid )
   {
     FT_Bytes             p;
     FT_Bytes             limit;
     offset = (FT_UShort)( base_value_p->u +
                           relative_gindex * sizeof ( FT_UShort ) );
 
-    p     = valid->lookuptbl_head + offset;
+    p     = gxvalid->lookuptbl_head + offset;
     limit = lookuptbl_limit;
 
     GXV_LIMIT_CHECK ( 2 );
   static void
   gxv_morx_subtable_type1_substitutionTable_validate( FT_Bytes       table,
                                                       FT_Bytes       limit,
-                                                      GXV_Validator  valid )
+                                                      GXV_Validator  gxvalid )
   {
     FT_Bytes   p = table;
     FT_UShort  i;
 
     GXV_morx_subtable_type1_StateOptRecData  optdata =
-      (GXV_morx_subtable_type1_StateOptRecData)valid->xstatetable.optdata;
+      (GXV_morx_subtable_type1_StateOptRecData)gxvalid->xstatetable.optdata;
 
 
     /* TODO: calculate offset/length for each lookupTables */
-    valid->lookupval_sign   = GXV_LOOKUPVALUE_UNSIGNED;
-    valid->lookupval_func   = gxv_morx_subtable_type1_LookupValue_validate;
-    valid->lookupfmt4_trans = gxv_morx_subtable_type1_LookupFmt4_transit;
+    gxvalid->lookupval_sign   = GXV_LOOKUPVALUE_UNSIGNED;
+    gxvalid->lookupval_func   = gxv_morx_subtable_type1_LookupValue_validate;
+    gxvalid->lookupfmt4_trans = gxv_morx_subtable_type1_LookupFmt4_transit;
 
     for ( i = 0; i < optdata->substitutionTable_num_lookupTables; i++ )
     {
       GXV_LIMIT_CHECK( 4 );
       offset = FT_NEXT_ULONG( p );
 
-      gxv_LookupTable_validate( table + offset, limit, valid );
+      gxv_LookupTable_validate( table + offset, limit, gxvalid );
     }
 
     /* TODO: overlapping of lookupTables in substitutionTable */
   FT_LOCAL_DEF( void )
   gxv_morx_subtable_type1_validate( FT_Bytes       table,
                                     FT_Bytes       limit,
-                                    GXV_Validator  valid )
+                                    GXV_Validator  gxvalid )
   {
     FT_Bytes  p = table;
 
 
     st_rec.substitutionTable_num_lookupTables = 0;
 
-    valid->xstatetable.optdata =
+    gxvalid->xstatetable.optdata =
       &st_rec;
-    valid->xstatetable.optdata_load_func =
+    gxvalid->xstatetable.optdata_load_func =
       gxv_morx_subtable_type1_substitutionTable_load;
-    valid->xstatetable.subtable_setup_func =
+    gxvalid->xstatetable.subtable_setup_func =
       gxv_morx_subtable_type1_subtable_setup;
-    valid->xstatetable.entry_glyphoffset_fmt =
+    gxvalid->xstatetable.entry_glyphoffset_fmt =
       GXV_GLYPHOFFSET_ULONG;
-    valid->xstatetable.entry_validate_func =
+    gxvalid->xstatetable.entry_validate_func =
       gxv_morx_subtable_type1_entry_validate;
 
-    gxv_XStateTable_validate( p, limit, valid );
+    gxv_XStateTable_validate( p, limit, gxvalid );
 
     gxv_morx_subtable_type1_substitutionTable_validate(
       table + st_rec.substitutionTable,
       table + st_rec.substitutionTable + st_rec.substitutionTable_length,
-      valid );
+      gxvalid );
 
     GXV_EXIT;
   }
index 95b8ea4..e44445d 100644 (file)
   static void
   gxv_morx_subtable_type2_opttable_load( FT_Bytes       table,
                                          FT_Bytes       limit,
-                                         GXV_Validator  valid )
+                                         GXV_Validator  gxvalid )
   {
     FT_Bytes  p = table;
 
     GXV_morx_subtable_type2_StateOptRecData  optdata =
-      (GXV_morx_subtable_type2_StateOptRecData)valid->xstatetable.optdata;
+      (GXV_morx_subtable_type2_StateOptRecData)gxvalid->xstatetable.optdata;
 
 
     GXV_LIMIT_CHECK( 4 + 4 + 4 );
                                           FT_ULong*      classTable_length_p,
                                           FT_ULong*      stateArray_length_p,
                                           FT_ULong*      entryTable_length_p,
-                                          GXV_Validator  valid )
+                                          GXV_Validator  gxvalid )
   {
     FT_ULong   o[6];
     FT_ULong*  l[6];
     FT_ULong   buff[7];
 
     GXV_morx_subtable_type2_StateOptRecData  optdata =
-      (GXV_morx_subtable_type2_StateOptRecData)valid->xstatetable.optdata;
+      (GXV_morx_subtable_type2_StateOptRecData)gxvalid->xstatetable.optdata;
 
 
     GXV_NAME_ENTER( "subtable boundaries setup" );
     l[4] = &(optdata->componentTable_length);
     l[5] = &(optdata->ligatureTable_length);
 
-    gxv_set_length_by_ulong_offset( o, l, buff, 6, table_size, valid );
+    gxv_set_length_by_ulong_offset( o, l, buff, 6, table_size, gxvalid );
 
     GXV_TRACE(( "classTable: offset=0x%08x length=0x%08x\n",
                 classTable, *classTable_length_p ));
   gxv_morx_subtable_type2_ligActionIndex_validate(
     FT_Bytes       table,
     FT_UShort      ligActionIndex,
-    GXV_Validator  valid )
+    GXV_Validator  gxvalid )
   {
     /* access ligActionTable */
     GXV_morx_subtable_type2_StateOptRecData optdata =
-      (GXV_morx_subtable_type2_StateOptRecData)valid->xstatetable.optdata;
+      (GXV_morx_subtable_type2_StateOptRecData)gxvalid->xstatetable.optdata;
 
     FT_Bytes lat_base  = table + optdata->ligActionTable;
     FT_Bytes p         = lat_base +
       /* it is different from the location offset in mort */
       if ( ( offset & 0x3FFF0000UL ) == 0x3FFF0000UL )
       { /* negative offset */
-        gid_limit = valid->face->num_glyphs - ( offset & 0x0000FFFFUL );
+        gid_limit = gxvalid->face->num_glyphs - ( offset & 0x0000FFFFUL );
         if ( gid_limit > 0 )
           return;
 
                     offset & 0xFFFFU ));
         GXV_SET_ERR_IF_PARANOID( FT_INVALID_OFFSET );
       }
-      else if ( ( offset & 0x3FFF0000UL ) == 0x0000000UL )
+      else if ( ( offset & 0x3FFF0000UL ) == 0x00000000UL )
       { /* positive offset */
-        if ( (FT_Long)offset < valid->face->num_glyphs )
+        if ( (FT_Long)offset < gxvalid->face->num_glyphs )
           return;
 
         GXV_TRACE(( "ligature action table includes"
     GXV_StateTable_GlyphOffsetCPtr  glyphOffset_p,
     FT_Bytes                        table,
     FT_Bytes                        limit,
-    GXV_Validator                   valid )
+    GXV_Validator                   gxvalid )
   {
 #ifdef GXV_LOAD_UNUSED_VARS
     FT_UShort  setComponent;
 
     if ( 0 < ligActionIndex )
       gxv_morx_subtable_type2_ligActionIndex_validate(
-        table, ligActionIndex, valid );
+        table, ligActionIndex, gxvalid );
   }
 
 
   static void
   gxv_morx_subtable_type2_ligatureTable_validate( FT_Bytes       table,
-                                                  GXV_Validator  valid )
+                                                  GXV_Validator  gxvalid )
   {
     GXV_morx_subtable_type2_StateOptRecData  optdata =
-      (GXV_morx_subtable_type2_StateOptRecData)valid->xstatetable.optdata;
+      (GXV_morx_subtable_type2_StateOptRecData)gxvalid->xstatetable.optdata;
 
     FT_Bytes p     = table + optdata->ligatureTable;
     FT_Bytes limit = table + optdata->ligatureTable
 
         GXV_LIMIT_CHECK( 2 );
         lig_gid = FT_NEXT_USHORT( p );
-        if ( lig_gid < valid->face->num_glyphs )
+        if ( lig_gid < gxvalid->face->num_glyphs )
           GXV_SET_ERR_IF_PARANOID( FT_INVALID_GLYPH_ID );
       }
     }
   FT_LOCAL_DEF( void )
   gxv_morx_subtable_type2_validate( FT_Bytes       table,
                                     FT_Bytes       limit,
-                                    GXV_Validator  valid )
+                                    GXV_Validator  gxvalid )
   {
     FT_Bytes  p = table;
 
 
     GXV_LIMIT_CHECK( GXV_MORX_SUBTABLE_TYPE2_HEADER_SIZE );
 
-    valid->xstatetable.optdata =
+    gxvalid->xstatetable.optdata =
       &lig_rec;
-    valid->xstatetable.optdata_load_func =
+    gxvalid->xstatetable.optdata_load_func =
       gxv_morx_subtable_type2_opttable_load;
-    valid->xstatetable.subtable_setup_func =
+    gxvalid->xstatetable.subtable_setup_func =
       gxv_morx_subtable_type2_subtable_setup;
-    valid->xstatetable.entry_glyphoffset_fmt =
+    gxvalid->xstatetable.entry_glyphoffset_fmt =
       GXV_GLYPHOFFSET_USHORT;
-    valid->xstatetable.entry_validate_func =
+    gxvalid->xstatetable.entry_validate_func =
       gxv_morx_subtable_type2_entry_validate;
 
-    gxv_XStateTable_validate( p, limit, valid );
+    gxv_XStateTable_validate( p, limit, gxvalid );
 
 #if 0
-    p += valid->subtable_length;
+    p += gxvalid->subtable_length;
 #endif
-    gxv_morx_subtable_type2_ligatureTable_validate( table, valid );
+    gxv_morx_subtable_type2_ligatureTable_validate( table, gxvalid );
 
     GXV_EXIT;
   }
index c0d2f78..68ab678 100644 (file)
   FT_LOCAL_DEF( void )
   gxv_morx_subtable_type4_validate( FT_Bytes       table,
                                     FT_Bytes       limit,
-                                    GXV_Validator  valid )
+                                    GXV_Validator  gxvalid )
   {
     GXV_NAME_ENTER( "morx chain subtable type4 "
                     "(Non-Contextual Glyph Substitution)" );
 
-    gxv_mort_subtable_type4_validate( table, limit, valid );
+    gxv_mort_subtable_type4_validate( table, limit, gxvalid );
 
     GXV_EXIT;
   }
index d8cf700..5e095dd 100644 (file)
   static void
   gxv_morx_subtable_type5_insertionGlyphList_load( FT_Bytes       table,
                                                    FT_Bytes       limit,
-                                                   GXV_Validator  valid )
+                                                   GXV_Validator  gxvalid )
   {
     FT_Bytes  p = table;
 
     GXV_morx_subtable_type5_StateOptRecData  optdata =
-      (GXV_morx_subtable_type5_StateOptRecData)valid->xstatetable.optdata;
+      (GXV_morx_subtable_type5_StateOptRecData)gxvalid->xstatetable.optdata;
 
 
     GXV_LIMIT_CHECK( 4 );
                                           FT_ULong*      classTable_length_p,
                                           FT_ULong*      stateArray_length_p,
                                           FT_ULong*      entryTable_length_p,
-                                          GXV_Validator  valid )
+                                          GXV_Validator  gxvalid )
   {
     FT_ULong   o[4];
     FT_ULong*  l[4];
     FT_ULong   buff[5];
 
     GXV_morx_subtable_type5_StateOptRecData  optdata =
-      (GXV_morx_subtable_type5_StateOptRecData)valid->xstatetable.optdata;
+      (GXV_morx_subtable_type5_StateOptRecData)gxvalid->xstatetable.optdata;
 
 
     o[0] = classTable;
     l[2] = entryTable_length_p;
     l[3] = &(optdata->insertionGlyphList_length);
 
-    gxv_set_length_by_ulong_offset( o, l, buff, 4, table_size, valid );
+    gxv_set_length_by_ulong_offset( o, l, buff, 4, table_size, gxvalid );
   }
 
 
                                                FT_UShort      count,
                                                FT_Bytes       table,
                                                FT_Bytes       limit,
-                                               GXV_Validator  valid )
+                                               GXV_Validator  gxvalid )
   {
-    FT_Bytes p = table + table_index * 2;
+    FT_Bytes  p = table + table_index * 2;
 
 
 #ifndef GXV_LOAD_TRACE_VARS
     GXV_StateTable_GlyphOffsetCPtr  glyphOffset_p,
     FT_Bytes                        table,
     FT_Bytes                        limit,
-    GXV_Validator                   valid )
+    GXV_Validator                   gxvalid )
   {
 #ifdef GXV_LOAD_UNUSED_VARS
     FT_Bool    setMark;
       gxv_morx_subtable_type5_InsertList_validate( currentInsertList,
                                                    currentInsertCount,
                                                    table, limit,
-                                                   valid );
+                                                   gxvalid );
 
     if ( markedInsertList && 0 != markedInsertCount )
       gxv_morx_subtable_type5_InsertList_validate( markedInsertList,
                                                    markedInsertCount,
                                                    table, limit,
-                                                   valid );
+                                                   gxvalid );
   }
 
 
   FT_LOCAL_DEF( void )
   gxv_morx_subtable_type5_validate( FT_Bytes       table,
                                     FT_Bytes       limit,
-                                    GXV_Validator  valid )
+                                    GXV_Validator  gxvalid )
   {
     FT_Bytes  p = table;
 
 
     GXV_LIMIT_CHECK( GXV_MORX_SUBTABLE_TYPE5_HEADER_SIZE );
 
-    valid->xstatetable.optdata =
+    gxvalid->xstatetable.optdata =
       et;
-    valid->xstatetable.optdata_load_func =
+    gxvalid->xstatetable.optdata_load_func =
       gxv_morx_subtable_type5_insertionGlyphList_load;
-    valid->xstatetable.subtable_setup_func =
+    gxvalid->xstatetable.subtable_setup_func =
       gxv_morx_subtable_type5_subtable_setup;
-    valid->xstatetable.entry_glyphoffset_fmt =
+    gxvalid->xstatetable.entry_glyphoffset_fmt =
       GXV_GLYPHOFFSET_ULONG;
-    valid->xstatetable.entry_validate_func =
+    gxvalid->xstatetable.entry_validate_func =
       gxv_morx_subtable_type5_entry_validate;
 
-    gxv_XStateTable_validate( p, limit, valid );
+    gxv_XStateTable_validate( p, limit, gxvalid );
 
     GXV_EXIT;
   }
index e125060..ab0cd72 100644 (file)
   static void
   gxv_opbd_LookupValue_validate( FT_UShort            glyph,
                                  GXV_LookupValueCPtr  value_p,
-                                 GXV_Validator        valid )
+                                 GXV_Validator        gxvalid )
   {
     /* offset in LookupTable is measured from the head of opbd table */
-    FT_Bytes   p     = valid->root->base + value_p->u;
-    FT_Bytes   limit = valid->root->limit;
+    FT_Bytes   p     = gxvalid->root->base + value_p->u;
+    FT_Bytes   limit = gxvalid->root->limit;
     FT_Short   delta_value;
     int        i;
 
@@ -90,7 +90,7 @@
         if ( delta_value == -1 )
           continue;
 
-        gxv_ctlPoint_validate( glyph, delta_value, valid );
+        gxv_ctlPoint_validate( glyph, delta_value, gxvalid );
       }
       else                              /* format 0, value is distance */
         continue;
   gxv_opbd_LookupFmt4_transit( FT_UShort            relative_gindex,
                                GXV_LookupValueCPtr  base_value_p,
                                FT_Bytes             lookuptbl_limit,
-                               GXV_Validator        valid )
+                               GXV_Validator        gxvalid )
   {
     GXV_LookupValueDesc  value;
 
     FT_UNUSED( lookuptbl_limit );
-    FT_UNUSED( valid );
+    FT_UNUSED( gxvalid );
 
     /* XXX: check range? */
     value.u = (FT_UShort)( base_value_p->u +
                      FT_Face       face,
                      FT_Validator  ftvalid )
   {
-    GXV_ValidatorRec  validrec;
-    GXV_Validator     valid = &validrec;
+    GXV_ValidatorRec  gxvalidrec;
+    GXV_Validator     gxvalid = &gxvalidrec;
     GXV_opbd_DataRec  opbdrec;
     GXV_opbd_Data     opbd  = &opbdrec;
     FT_Bytes          p     = table;
     FT_ULong  version;
 
 
-    valid->root       = ftvalid;
-    valid->table_data = opbd;
-    valid->face       = face;
+    gxvalid->root       = ftvalid;
+    gxvalid->table_data = opbd;
+    gxvalid->face       = face;
 
     FT_TRACE3(( "validating `opbd' table\n" ));
     GXV_INIT;
     if ( 0x0001 < GXV_OPBD_DATA( format ) )
       FT_INVALID_FORMAT;
 
-    valid->lookupval_sign   = GXV_LOOKUPVALUE_UNSIGNED;
-    valid->lookupval_func   = gxv_opbd_LookupValue_validate;
-    valid->lookupfmt4_trans = gxv_opbd_LookupFmt4_transit;
+    gxvalid->lookupval_sign   = GXV_LOOKUPVALUE_UNSIGNED;
+    gxvalid->lookupval_func   = gxv_opbd_LookupValue_validate;
+    gxvalid->lookupfmt4_trans = gxv_opbd_LookupFmt4_transit;
 
-    gxv_LookupTable_validate( p, limit, valid );
-    p += valid->subtable_length;
+    gxv_LookupTable_validate( p, limit, gxvalid );
+    p += gxvalid->subtable_length;
 
     if ( p > table + GXV_OPBD_DATA( valueOffset_min ) )
     {
index 0be2133..aa5c8ee 100644 (file)
@@ -75,7 +75,7 @@
 
   static void
   gxv_prop_zero_advance_validate( FT_UShort      gid,
-                                  GXV_Validator  valid )
+                                  GXV_Validator  gxvalid )
   {
     FT_Face       face;
     FT_Error      error;
@@ -84,7 +84,7 @@
 
     GXV_NAME_ENTER( "zero advance" );
 
-    face = valid->face;
+    face = gxvalid->face;
 
     error = FT_Load_Glyph( face,
                            gid,
   static void
   gxv_prop_property_validate( FT_UShort      property,
                               FT_UShort      glyph,
-                              GXV_Validator  valid )
+                              GXV_Validator  gxvalid )
   {
     if ( glyph != 0 && ( property & GXV_PROP_FLOATER ) )
-      gxv_prop_zero_advance_validate( glyph, valid );
+      gxv_prop_zero_advance_validate( glyph, gxvalid );
 
     if ( property & GXV_PROP_USE_COMPLEMENTARY_BRACKET )
     {
       else
       {
         /* The gid for complement must be the face. */
-        gxv_glyphid_validate( (FT_UShort)( glyph + complement ), valid );
+        gxv_glyphid_validate( (FT_UShort)( glyph + complement ), gxvalid );
       }
     }
     else
   static void
   gxv_prop_LookupValue_validate( FT_UShort            glyph,
                                  GXV_LookupValueCPtr  value_p,
-                                 GXV_Validator        valid )
+                                 GXV_Validator        gxvalid )
   {
-    gxv_prop_property_validate( value_p->u, glyph, valid );
+    gxv_prop_property_validate( value_p->u, glyph, gxvalid );
   }
 
 
   gxv_prop_LookupFmt4_transit( FT_UShort            relative_gindex,
                                GXV_LookupValueCPtr  base_value_p,
                                FT_Bytes             lookuptbl_limit,
-                               GXV_Validator        valid )
+                               GXV_Validator        gxvalid )
   {
     FT_Bytes             p;
     FT_Bytes             limit;
     /* XXX: check range? */
     offset = (FT_UShort)( base_value_p->u +
                           relative_gindex * sizeof ( FT_UShort ) );
-    p      = valid->lookuptbl_head + offset;
+    p      = gxvalid->lookuptbl_head + offset;
     limit  = lookuptbl_limit;
 
     GXV_LIMIT_CHECK ( 2 );
   {
     FT_Bytes          p     = table;
     FT_Bytes          limit = 0;
-    GXV_ValidatorRec  validrec;
-    GXV_Validator     valid = &validrec;
+    GXV_ValidatorRec  gxvalidrec;
+    GXV_Validator     gxvalid = &gxvalidrec;
 
     GXV_prop_DataRec  proprec;
     GXV_prop_Data     prop = &proprec;
     FT_UShort         defaultProp;
 
 
-    valid->root       = ftvalid;
-    valid->table_data = prop;
-    valid->face       = face;
+    gxvalid->root       = ftvalid;
+    gxvalid->table_data = prop;
+    gxvalid->face       = face;
 
     FT_TRACE3(( "validating `prop' table\n" ));
     GXV_INIT;
       FT_INVALID_FORMAT;
     }
 
-    gxv_prop_property_validate( defaultProp, 0, valid );
+    gxv_prop_property_validate( defaultProp, 0, gxvalid );
 
     if ( format == 0 )
     {
     /* format == 1 */
     GXV_PROP_DATA( version ) = version;
 
-    valid->lookupval_sign   = GXV_LOOKUPVALUE_UNSIGNED;
-    valid->lookupval_func   = gxv_prop_LookupValue_validate;
-    valid->lookupfmt4_trans = gxv_prop_LookupFmt4_transit;
+    gxvalid->lookupval_sign   = GXV_LOOKUPVALUE_UNSIGNED;
+    gxvalid->lookupval_func   = gxv_prop_LookupValue_validate;
+    gxvalid->lookupfmt4_trans = gxv_prop_LookupFmt4_transit;
 
-    gxv_LookupTable_validate( p, limit, valid );
+    gxv_LookupTable_validate( p, limit, gxvalid );
 
   Exit:
     FT_TRACE4(( "\n" ));
index 11fbd7c..3ec1a56 100644 (file)
@@ -93,9 +93,9 @@
   gxv_trak_trackTable_validate( FT_Bytes       table,
                                 FT_Bytes       limit,
                                 FT_UShort      nTracks,
-                                GXV_Validator  valid )
+                                GXV_Validator  gxvalid )
   {
-    FT_Bytes   p = table;
+    FT_Bytes  p = table;
 
     FT_Fixed   track, t;
     FT_UShort  nameIndex;
       if ( offset > GXV_TRAK_DATA( trackValueOffset_max ) )
         GXV_TRAK_DATA( trackValueOffset_max ) = offset;
 
-      gxv_sfntName_validate( nameIndex, 256, 32767, valid );
+      gxv_sfntName_validate( nameIndex, 256, 32767, gxvalid );
 
       for ( j = i; j < nTracks; j ++ )
       {
       }
     }
 
-    valid->subtable_length = p - table;
+    gxvalid->subtable_length = p - table;
     GXV_EXIT;
   }
 
   static void
   gxv_trak_trackData_validate( FT_Bytes       table,
                                FT_Bytes       limit,
-                               GXV_Validator  valid )
+                               GXV_Validator  gxvalid )
   {
     FT_Bytes   p = table;
     FT_UShort  nTracks;
     gxv_odtect_add_range( table, p - table, "trackData header", odtect );
 
     /* validate trackTable */
-    gxv_trak_trackTable_validate( p, limit, nTracks, valid );
-    gxv_odtect_add_range( p, valid->subtable_length,
+    gxv_trak_trackTable_validate( p, limit, nTracks, gxvalid );
+    gxv_odtect_add_range( p, gxvalid->subtable_length,
                           "trackTable", odtect );
 
     /* sizeTable is array of FT_Fixed, don't check contents */
-    p = valid->root->base + sizeTableOffset;
+    p = gxvalid->root->base + sizeTableOffset;
     GXV_LIMIT_CHECK( nSizes * 4 );
     gxv_odtect_add_range( p, nSizes * 4, "sizeTable", odtect );
 
     /* validate trackValueOffet */
-    p = valid->root->base + GXV_TRAK_DATA( trackValueOffset_min );
+    p = gxvalid->root->base + GXV_TRAK_DATA( trackValueOffset_min );
     if ( limit - p < nTracks * nSizes * 2 )
       GXV_TRACE(( "too short trackValue array\n" ));
 
-    p = valid->root->base + GXV_TRAK_DATA( trackValueOffset_max );
+    p = gxvalid->root->base + GXV_TRAK_DATA( trackValueOffset_max );
     GXV_LIMIT_CHECK( nSizes * 2 );
 
-    gxv_odtect_add_range( valid->root->base
+    gxv_odtect_add_range( gxvalid->root->base
                             + GXV_TRAK_DATA( trackValueOffset_min ),
                           GXV_TRAK_DATA( trackValueOffset_max )
                             - GXV_TRAK_DATA( trackValueOffset_min )
                             + nSizes * 2,
                           "trackValue array", odtect );
 
-    gxv_odtect_validate( odtect, valid );
+    gxv_odtect_validate( odtect, gxvalid );
 
     GXV_EXIT;
   }
     FT_Bytes          p = table;
     FT_Bytes          limit = 0;
 
-    GXV_ValidatorRec  validrec;
-    GXV_Validator     valid = &validrec;
+    GXV_ValidatorRec  gxvalidrec;
+    GXV_Validator     gxvalid = &gxvalidrec;
     GXV_trak_DataRec  trakrec;
     GXV_trak_Data     trak = &trakrec;
 
     GXV_ODTECT( 3, odtect );
 
     GXV_ODTECT_INIT( odtect );
-    valid->root       = ftvalid;
-    valid->table_data = trak;
-    valid->face       = face;
+    gxvalid->root       = ftvalid;
+    gxvalid->table_data = trak;
+    gxvalid->face       = face;
 
-    limit      = valid->root->limit;
+    limit      = gxvalid->root->limit;
 
     FT_TRACE3(( "validating `trak' table\n" ));
     GXV_INIT;
     /* validate trackData */
     if ( 0 < horizOffset )
     {
-      gxv_trak_trackData_validate( table + horizOffset, limit, valid );
-      gxv_odtect_add_range( table + horizOffset, valid->subtable_length,
+      gxv_trak_trackData_validate( table + horizOffset, limit, gxvalid );
+      gxv_odtect_add_range( table + horizOffset, gxvalid->subtable_length,
                             "horizJustData", odtect );
     }
 
     if ( 0 < vertOffset )
     {
-      gxv_trak_trackData_validate( table + vertOffset, limit, valid );
-      gxv_odtect_add_range( table + vertOffset, valid->subtable_length,
+      gxv_trak_trackData_validate( table + vertOffset, limit, gxvalid );
+      gxv_odtect_add_range( table + vertOffset, gxvalid->subtable_length,
                             "vertJustData", odtect );
     }
 
-    gxv_odtect_validate( odtect, valid );
+    gxv_odtect_validate( odtect, gxvalid );
 
     FT_TRACE4(( "\n" ));
   }
index 2c60b6c..2d4200d 100644 (file)
@@ -8,7 +8,7 @@
 /*  parse compressed PCF fonts, as found with many X11 server              */
 /*  distributions.                                                         */
 /*                                                                         */
-/*  Copyright 2002-2006, 2009-2013 by                                      */
+/*  Copyright 2002-2006, 2009-2014 by                                      */
 /*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
 /*                                                                         */
 /*  This file is part of the FreeType project, and may only be used,       */
 
     /* head[0] && head[1] are the magic numbers;    */
     /* head[2] is the method, and head[3] the flags */
-    if ( head[0] != 0x1f              ||
-         head[1] != 0x8b              ||
+    if ( head[0] != 0x1F              ||
+         head[1] != 0x8B              ||
          head[2] != Z_DEFLATED        ||
         (head[3] & FT_GZIP_RESERVED)  )
     {
                       FT_Stream  source )
   {
     FT_Error     error;
-    FT_Memory    memory = source->memory;
+    FT_Memory    memory;
     FT_GZipFile  zip = NULL;
 
 
+    if ( !stream || !source )
+    {
+      error = FT_THROW( Invalid_Stream_Handle );
+      goto Exit;
+    }
+
+    memory = source->memory;
+
     /*
      *  check the header right now; this prevents allocating un-necessary
      *  objects when we don't need them
     int       err;
 
 
+    /* check for `input' delayed to `inflate' */
+
+    if ( !memory || ! output_len || !output )
+      return FT_THROW( Invalid_Argument );
+
     /* this function is modeled after zlib's `uncompress' function */
 
     stream.next_in  = (Bytef*)input;
index ef53652..56f52b1 100644 (file)
@@ -115,16 +115,16 @@ uIntf *v                /* working area: values in order of bit length */
   uInt f;                       /* i repeats in table every f entries */
   int g;                        /* maximum code length */
   int h;                        /* table level */
-  register uInt i;              /* counter, current code */
-  register uInt j;              /* counter */
-  register int k;               /* number of bits in current code */
+  uInt i;                       /* counter, current code */
+  uInt j;                       /* counter */
+  int k;                        /* number of bits in current code */
   int l;                        /* bits per table (returned in m) */
   uInt mask;                    /* (1 << w) - 1, to avoid cc -O bug on HP */
-  register uIntf *p;            /* pointer into c[], b[], or v[] */
+  uIntf *p;                     /* pointer into c[], b[], or v[] */
   inflate_huft *q;              /* points to current table */
   struct inflate_huft_s r;      /* table entry for structure assignment */
   inflate_huft *u[BMAX];        /* table stack */
-  register int w;               /* bits before this table == (l * h) */
+  int w;                        /* bits before this table == (l * h) */
   uInt x[BMAX+1];               /* bit offsets, then code stack */
   uIntf *xp;                    /* pointer into x */
   int y;                        /* number of dummy codes added */
index 82e6c00..e1b3564 100644 (file)
@@ -8,7 +8,7 @@
 /*  be used to parse compressed PCF fonts, as found with many X11 server   */
 /*  distributions.                                                         */
 /*                                                                         */
-/*  Copyright 2004-2006, 2009, 2010, 2012, 2013 by                         */
+/*  Copyright 2004-2006, 2009, 2010, 2012-2014 by                          */
 /*  Albert Chin-A-Young.                                                   */
 /*                                                                         */
 /*  Based on code in src/gzip/ftgzip.c, Copyright 2004 by                  */
@@ -96,8 +96,8 @@
       goto Exit;
 
     /* head[0] && head[1] are the magic numbers */
-    if ( head[0] != 0x1f ||
-         head[1] != 0x9d )
+    if ( head[0] != 0x1F ||
+         head[1] != 0x9D )
       error = FT_THROW( Invalid_File_Format );
 
   Exit:
                      FT_Stream  source )
   {
     FT_Error    error;
-    FT_Memory   memory = source->memory;
+    FT_Memory   memory;
     FT_LZWFile  zip = NULL;
 
 
+    if ( !stream || !source )
+    {
+      error = FT_THROW( Invalid_Stream_Handle );
+      goto Exit;
+    }
+
+    memory = source->memory;
+
     /*
      *  Check the header right now; this prevents allocation of a huge
      *  LZWFile object (400 KByte of heap memory) if not necessary.
index f7d2936..cdc8fd7 100644 (file)
@@ -41,7 +41,7 @@
 #define LZW_CLEAR         256
 #define LZW_FIRST         257
 
-#define LZW_BIT_MASK      0x1f
+#define LZW_BIT_MASK      0x1F
 #define LZW_BLOCK_MASK    0x80
 #define LZW_MASK( n )     ( ( 1U << (n) ) - 1U )
 
index d742d2d..4f9d2fa 100644 (file)
@@ -32,7 +32,7 @@
 
   static void
   otv_BaseCoord_validate( FT_Bytes       table,
-                          OTV_Validator  valid )
+                          OTV_Validator  otvalid )
   {
     FT_Bytes  p = table;
     FT_UInt   BaseCoordFormat;
@@ -58,7 +58,7 @@
     case 3:     /* BaseCoordFormat3 */
       OTV_LIMIT_CHECK( 2 );
       /* DeviceTable */
-      otv_Device_validate( table + FT_NEXT_USHORT( p ), valid );
+      otv_Device_validate( table + FT_NEXT_USHORT( p ), otvalid );
       break;
 
     default:
@@ -71,7 +71,7 @@
 
   static void
   otv_BaseTagList_validate( FT_Bytes       table,
-                            OTV_Validator  valid )
+                            OTV_Validator  otvalid )
   {
     FT_Bytes  p = table;
     FT_UInt   BaseTagCount;
@@ -93,7 +93,7 @@
 
   static void
   otv_BaseValues_validate( FT_Bytes       table,
-                           OTV_Validator  valid )
+                           OTV_Validator  otvalid )
   {
     FT_Bytes  p = table;
     FT_UInt   BaseCoordCount;
 
     /* BaseCoord */
     for ( ; BaseCoordCount > 0; BaseCoordCount-- )
-      otv_BaseCoord_validate( table + FT_NEXT_USHORT( p ), valid );
+      otv_BaseCoord_validate( table + FT_NEXT_USHORT( p ), otvalid );
 
     OTV_EXIT;
   }
 
   static void
   otv_MinMax_validate( FT_Bytes       table,
-                       OTV_Validator  valid )
+                       OTV_Validator  otvalid )
   {
     FT_Bytes  p = table;
     FT_UInt   table_size;
 
     OTV_SIZE_CHECK( MinCoord );
     if ( MinCoord )
-      otv_BaseCoord_validate( table + MinCoord, valid );
+      otv_BaseCoord_validate( table + MinCoord, otvalid );
 
     OTV_SIZE_CHECK( MaxCoord );
     if ( MaxCoord )
-      otv_BaseCoord_validate( table + MaxCoord, valid );
+      otv_BaseCoord_validate( table + MaxCoord, otvalid );
 
     OTV_LIMIT_CHECK( FeatMinMaxCount * 8 );
 
 
       OTV_SIZE_CHECK( MinCoord );
       if ( MinCoord )
-        otv_BaseCoord_validate( table + MinCoord, valid );
+        otv_BaseCoord_validate( table + MinCoord, otvalid );
 
       OTV_SIZE_CHECK( MaxCoord );
       if ( MaxCoord )
-        otv_BaseCoord_validate( table + MaxCoord, valid );
+        otv_BaseCoord_validate( table + MaxCoord, otvalid );
     }
 
     OTV_EXIT;
 
   static void
   otv_BaseScript_validate( FT_Bytes       table,
-                           OTV_Validator  valid )
+                           OTV_Validator  otvalid )
   {
     FT_Bytes  p = table;
     FT_UInt   table_size;
 
     OTV_SIZE_CHECK( BaseValues );
     if ( BaseValues )
-      otv_BaseValues_validate( table + BaseValues, valid );
+      otv_BaseValues_validate( table + BaseValues, otvalid );
 
     OTV_SIZE_CHECK( DefaultMinMax );
     if ( DefaultMinMax )
-      otv_MinMax_validate( table + DefaultMinMax, valid );
+      otv_MinMax_validate( table + DefaultMinMax, otvalid );
 
     OTV_LIMIT_CHECK( BaseLangSysCount * 6 );
 
     {
       p += 4;       /* skip BaseLangSysTag */
 
-      otv_MinMax_validate( table + FT_NEXT_USHORT( p ), valid );
+      otv_MinMax_validate( table + FT_NEXT_USHORT( p ), otvalid );
     }
 
     OTV_EXIT;
 
   static void
   otv_BaseScriptList_validate( FT_Bytes       table,
-                               OTV_Validator  valid )
+                               OTV_Validator  otvalid )
   {
     FT_Bytes  p = table;
     FT_UInt   BaseScriptCount;
       p += 4;       /* skip BaseScriptTag */
 
       /* BaseScript */
-      otv_BaseScript_validate( table + FT_NEXT_USHORT( p ), valid );
+      otv_BaseScript_validate( table + FT_NEXT_USHORT( p ), otvalid );
     }
 
     OTV_EXIT;
 
   static void
   otv_Axis_validate( FT_Bytes       table,
-                     OTV_Validator  valid )
+                     OTV_Validator  otvalid )
   {
     FT_Bytes  p = table;
     FT_UInt   table_size;
 
     OTV_SIZE_CHECK( BaseTagList );
     if ( BaseTagList )
-      otv_BaseTagList_validate( table + BaseTagList, valid );
+      otv_BaseTagList_validate( table + BaseTagList, otvalid );
 
     /* BaseScriptList */
-    otv_BaseScriptList_validate( table + FT_NEXT_USHORT( p ), valid );
+    otv_BaseScriptList_validate( table + FT_NEXT_USHORT( p ), otvalid );
 
     OTV_EXIT;
   }
   otv_BASE_validate( FT_Bytes      table,
                      FT_Validator  ftvalid )
   {
-    OTV_ValidatorRec  validrec;
-    OTV_Validator     valid = &validrec;
-    FT_Bytes          p     = table;
+    OTV_ValidatorRec  otvalidrec;
+    OTV_Validator     otvalid = &otvalidrec;
+    FT_Bytes          p       = table;
     FT_UInt           table_size;
 
     OTV_OPTIONAL_TABLE( HorizAxis );
     OTV_OPTIONAL_TABLE( VertAxis  );
 
 
-    valid->root = ftvalid;
+    otvalid->root = ftvalid;
 
     FT_TRACE3(( "validating BASE table\n" ));
     OTV_INIT;
     OTV_OPTIONAL_OFFSET( HorizAxis );
     OTV_SIZE_CHECK( HorizAxis );
     if ( HorizAxis )
-      otv_Axis_validate( table + HorizAxis, valid );
+      otv_Axis_validate( table + HorizAxis, otvalid );
 
     OTV_OPTIONAL_OFFSET( VertAxis );
     OTV_SIZE_CHECK( VertAxis );
     if ( VertAxis )
-      otv_Axis_validate( table + VertAxis, valid );
+      otv_Axis_validate( table + VertAxis, otvalid );
 
     FT_TRACE4(( "\n" ));
   }
index a4f885b..3c3de63 100644 (file)
@@ -39,7 +39,7 @@
 
   FT_LOCAL_DEF( void )
   otv_Coverage_validate( FT_Bytes       table,
-                         OTV_Validator  valid,
+                         OTV_Validator  otvalid,
                          FT_Int         expected_count )
   {
     FT_Bytes  p = table;
@@ -74,7 +74,7 @@
 
 
           gid = FT_NEXT_USHORT( p );
-          if ( gid >= valid->glyph_count )
+          if ( gid >= otvalid->glyph_count )
             FT_INVALID_GLYPH_ID;
         }
 
           if ( Start > End || StartCoverageIndex != total )
             FT_INVALID_DATA;
 
-          if ( End >= valid->glyph_count )
+          if ( End >= otvalid->glyph_count )
             FT_INVALID_GLYPH_ID;
 
           if ( n > 0 && Start <= last )
 
   FT_LOCAL_DEF( void )
   otv_ClassDef_validate( FT_Bytes       table,
-                         OTV_Validator  valid )
+                         OTV_Validator  otvalid )
   {
     FT_Bytes  p = table;
     FT_UInt   ClassFormat;
 
         OTV_LIMIT_CHECK( GlyphCount * 2 );    /* ClassValueArray */
 
-        if ( StartGlyph + GlyphCount - 1 >= valid->glyph_count )
+        if ( StartGlyph + GlyphCount - 1 >= otvalid->glyph_count )
           FT_INVALID_GLYPH_ID;
       }
       break;
           if ( Start > End || ( n > 0 && Start <= last ) )
             FT_INVALID_DATA;
 
-          if ( End >= valid->glyph_count )
+          if ( End >= otvalid->glyph_count )
             FT_INVALID_GLYPH_ID;
 
           last = End;
 
   FT_LOCAL_DEF( void )
   otv_Device_validate( FT_Bytes       table,
-                       OTV_Validator  valid )
+                       OTV_Validator  otvalid )
   {
     FT_Bytes  p = table;
     FT_UInt   StartSize, EndSize, DeltaFormat, count;
   /*************************************************************************/
   /*************************************************************************/
 
-  /* uses valid->type_count */
-  /* uses valid->type_funcs */
+  /* uses otvalid->type_count */
+  /* uses otvalid->type_funcs */
 
   FT_LOCAL_DEF( void )
   otv_Lookup_validate( FT_Bytes       table,
-                       OTV_Validator  valid )
+                       OTV_Validator  otvalid )
   {
     FT_Bytes           p = table;
     FT_UInt            LookupType, SubTableCount;
 
     OTV_TRACE(( " (type %d)\n", LookupType ));
 
-    if ( LookupType == 0 || LookupType > valid->type_count )
+    if ( LookupType == 0 || LookupType > otvalid->type_count )
       FT_INVALID_DATA;
 
-    validate = valid->type_funcs[LookupType - 1];
+    validate = otvalid->type_funcs[LookupType - 1];
 
     OTV_TRACE(( " (SubTableCount = %d)\n", SubTableCount ));
 
 
     /* SubTable */
     for ( ; SubTableCount > 0; SubTableCount-- )
-      validate( table + FT_NEXT_USHORT( p ), valid );
+      validate( table + FT_NEXT_USHORT( p ), otvalid );
 
     OTV_EXIT;
   }
 
   FT_LOCAL_DEF( void )
   otv_LookupList_validate( FT_Bytes       table,
-                           OTV_Validator  valid )
+                           OTV_Validator  otvalid )
   {
     FT_Bytes  p = table;
     FT_UInt   LookupCount;
 
     OTV_LIMIT_CHECK( LookupCount * 2 );
 
-    valid->lookup_count = LookupCount;
+    otvalid->lookup_count = LookupCount;
 
     /* Lookup */
     for ( ; LookupCount > 0; LookupCount-- )
-      otv_Lookup_validate( table + FT_NEXT_USHORT( p ), valid );
+      otv_Lookup_validate( table + FT_NEXT_USHORT( p ), otvalid );
 
     OTV_EXIT;
   }
   /*************************************************************************/
   /*************************************************************************/
 
-  /* uses valid->lookup_count */
+  /* uses otvalid->lookup_count */
 
   FT_LOCAL_DEF( void )
   otv_Feature_validate( FT_Bytes       table,
-                        OTV_Validator  valid )
+                        OTV_Validator  otvalid )
   {
     FT_Bytes  p = table;
     FT_UInt   LookupCount;
 
     /* LookupListIndex */
     for ( ; LookupCount > 0; LookupCount-- )
-      if ( FT_NEXT_USHORT( p ) >= valid->lookup_count )
+      if ( FT_NEXT_USHORT( p ) >= otvalid->lookup_count )
         FT_INVALID_DATA;
 
     OTV_EXIT;
   }
 
 
-  /* sets valid->lookup_count */
+  /* sets otvalid->lookup_count */
 
   FT_LOCAL_DEF( void )
   otv_FeatureList_validate( FT_Bytes       table,
                             FT_Bytes       lookups,
-                            OTV_Validator  valid )
+                            OTV_Validator  otvalid )
   {
     FT_Bytes  p = table;
     FT_UInt   FeatureCount;
 
     OTV_LIMIT_CHECK( FeatureCount * 2 );
 
-    valid->lookup_count = otv_LookupList_get_count( lookups );
+    otvalid->lookup_count = otv_LookupList_get_count( lookups );
 
     /* FeatureRecord */
     for ( ; FeatureCount > 0; FeatureCount-- )
       p += 4;       /* skip FeatureTag */
 
       /* Feature */
-      otv_Feature_validate( table + FT_NEXT_USHORT( p ), valid );
+      otv_Feature_validate( table + FT_NEXT_USHORT( p ), otvalid );
     }
 
     OTV_EXIT;
   /*************************************************************************/
 
 
-  /* uses valid->extra1 (number of features) */
+  /* uses otvalid->extra1 (number of features) */
 
   FT_LOCAL_DEF( void )
   otv_LangSys_validate( FT_Bytes       table,
-                        OTV_Validator  valid )
+                        OTV_Validator  otvalid )
   {
     FT_Bytes  p = table;
     FT_UInt   ReqFeatureIndex;
     OTV_TRACE(( " (ReqFeatureIndex = %d)\n", ReqFeatureIndex ));
     OTV_TRACE(( " (FeatureCount = %d)\n",    FeatureCount    ));
 
-    if ( ReqFeatureIndex != 0xFFFFU && ReqFeatureIndex >= valid->extra1 )
+    if ( ReqFeatureIndex != 0xFFFFU && ReqFeatureIndex >= otvalid->extra1 )
       FT_INVALID_DATA;
 
     OTV_LIMIT_CHECK( FeatureCount * 2 );
 
     /* FeatureIndex */
     for ( ; FeatureCount > 0; FeatureCount-- )
-      if ( FT_NEXT_USHORT( p ) >= valid->extra1 )
+      if ( FT_NEXT_USHORT( p ) >= otvalid->extra1 )
         FT_INVALID_DATA;
 
     OTV_EXIT;
 
   FT_LOCAL_DEF( void )
   otv_Script_validate( FT_Bytes       table,
-                       OTV_Validator  valid )
+                       OTV_Validator  otvalid )
   {
     FT_UInt   DefaultLangSys, LangSysCount;
     FT_Bytes  p = table;
     OTV_TRACE(( " (LangSysCount = %d)\n", LangSysCount ));
 
     if ( DefaultLangSys != 0 )
-      otv_LangSys_validate( table + DefaultLangSys, valid );
+      otv_LangSys_validate( table + DefaultLangSys, otvalid );
 
     OTV_LIMIT_CHECK( LangSysCount * 6 );
 
       p += 4;       /* skip LangSysTag */
 
       /* LangSys */
-      otv_LangSys_validate( table + FT_NEXT_USHORT( p ), valid );
+      otv_LangSys_validate( table + FT_NEXT_USHORT( p ), otvalid );
     }
 
     OTV_EXIT;
   }
 
 
-  /* sets valid->extra1 (number of features) */
+  /* sets otvalid->extra1 (number of features) */
 
   FT_LOCAL_DEF( void )
   otv_ScriptList_validate( FT_Bytes       table,
                            FT_Bytes       features,
-                           OTV_Validator  valid )
+                           OTV_Validator  otvalid )
   {
     FT_UInt   ScriptCount;
     FT_Bytes  p = table;
 
     OTV_LIMIT_CHECK( ScriptCount * 6 );
 
-    valid->extra1 = otv_Feature_get_count( features );
+    otvalid->extra1 = otv_Feature_get_count( features );
 
     /* ScriptRecord */
     for ( ; ScriptCount > 0; ScriptCount-- )
     {
       p += 4;       /* skip ScriptTag */
 
-      otv_Script_validate( table + FT_NEXT_USHORT( p ), valid ); /* Script */
+      otv_Script_validate( table + FT_NEXT_USHORT( p ), otvalid ); /* Script */
     }
 
     OTV_EXIT;
 
   FT_LOCAL_DEF( void )
   otv_x_Ox( FT_Bytes       table,
-            OTV_Validator  valid )
+            OTV_Validator  otvalid )
   {
     FT_Bytes           p = table;
     FT_UInt            Count;
 
     OTV_LIMIT_CHECK( Count * 2 );
 
-    valid->nesting_level++;
-    func = valid->func[valid->nesting_level];
+    otvalid->nesting_level++;
+    func = otvalid->func[otvalid->nesting_level];
 
     for ( ; Count > 0; Count-- )
-      func( table + FT_NEXT_USHORT( p ), valid );
+      func( table + FT_NEXT_USHORT( p ), otvalid );
 
-    valid->nesting_level--;
+    otvalid->nesting_level--;
 
     OTV_EXIT;
   }
 
   FT_LOCAL_DEF( void )
   otv_u_C_x_Ox( FT_Bytes       table,
-                OTV_Validator  valid )
+                OTV_Validator  otvalid )
   {
     FT_Bytes           p = table;
     FT_UInt            Count, Coverage;
 
     OTV_TRACE(( " (Count = %d)\n", Count ));
 
-    otv_Coverage_validate( table + Coverage, valid, Count );
+    otv_Coverage_validate( table + Coverage, otvalid, Count );
 
     OTV_LIMIT_CHECK( Count * 2 );
 
-    valid->nesting_level++;
-    func = valid->func[valid->nesting_level];
+    otvalid->nesting_level++;
+    func = otvalid->func[otvalid->nesting_level];
 
     for ( ; Count > 0; Count-- )
-      func( table + FT_NEXT_USHORT( p ), valid );
+      func( table + FT_NEXT_USHORT( p ), otvalid );
 
-    valid->nesting_level--;
+    otvalid->nesting_level--;
 
     OTV_EXIT;
   }
 
 
-  /* uses valid->extra1 (if > 0: array value limit) */
+  /* uses otvalid->extra1 (if > 0: array value limit) */
 
   FT_LOCAL_DEF( void )
   otv_x_ux( FT_Bytes       table,
-            OTV_Validator  valid )
+            OTV_Validator  otvalid )
   {
     FT_Bytes  p = table;
     FT_UInt   Count;
 
     OTV_LIMIT_CHECK( Count * 2 );
 
-    if ( valid->extra1 )
+    if ( otvalid->extra1 )
     {
       for ( ; Count > 0; Count-- )
-        if ( FT_NEXT_USHORT( p ) >= valid->extra1 )
+        if ( FT_NEXT_USHORT( p ) >= otvalid->extra1 )
           FT_INVALID_DATA;
     }
 
   /* `ux' in the function's name is not really correct since only x-1 */
   /* elements are tested                                              */
 
-  /* uses valid->extra1 (array value limit) */
+  /* uses otvalid->extra1 (array value limit) */
 
   FT_LOCAL_DEF( void )
   otv_x_y_ux_sy( FT_Bytes       table,
-                 OTV_Validator  valid )
+                 OTV_Validator  otvalid )
   {
     FT_Bytes  p = table;
     FT_UInt   Count1, Count2;
       if ( FT_NEXT_USHORT( p ) >= Count1 )
         FT_INVALID_DATA;
 
-      if ( FT_NEXT_USHORT( p ) >= valid->extra1 )
+      if ( FT_NEXT_USHORT( p ) >= otvalid->extra1 )
         FT_INVALID_DATA;
     }
 
   /* `uy' in the function's name is not really correct since only y-1 */
   /* elements are tested                                              */
 
-  /* uses valid->extra1 (array value limit) */
+  /* uses otvalid->extra1 (array value limit) */
 
   FT_LOCAL_DEF( void )
   otv_x_ux_y_uy_z_uz_p_sp( FT_Bytes       table,
-                           OTV_Validator  valid )
+                           OTV_Validator  otvalid )
   {
     FT_Bytes  p = table;
     FT_UInt   BacktrackCount, InputCount, LookaheadCount;
       if ( FT_NEXT_USHORT( p ) >= InputCount )
         FT_INVALID_DATA;
 
-      if ( FT_NEXT_USHORT( p ) >= valid->extra1 )
+      if ( FT_NEXT_USHORT( p ) >= otvalid->extra1 )
         FT_INVALID_DATA;
     }
 
   }
 
 
-  /* sets valid->extra1 (valid->lookup_count) */
+  /* sets otvalid->extra1 (valid->lookup_count) */
 
   FT_LOCAL_DEF( void )
   otv_u_O_O_x_Onx( FT_Bytes       table,
-                   OTV_Validator  valid )
+                   OTV_Validator  otvalid )
   {
     FT_Bytes           p = table;
     FT_UInt            Coverage, ClassDef, ClassSetCount;
 
     OTV_TRACE(( " (ClassSetCount = %d)\n", ClassSetCount ));
 
-    otv_Coverage_validate( table + Coverage, valid, -1 );
-    otv_ClassDef_validate( table + ClassDef, valid );
+    otv_Coverage_validate( table + Coverage, otvalid, -1 );
+    otv_ClassDef_validate( table + ClassDef, otvalid );
 
     OTV_LIMIT_CHECK( ClassSetCount * 2 );
 
-    valid->nesting_level++;
-    func          = valid->func[valid->nesting_level];
-    valid->extra1 = valid->lookup_count;
+    otvalid->nesting_level++;
+    func          = otvalid->func[otvalid->nesting_level];
+    otvalid->extra1 = otvalid->lookup_count;
 
     for ( ; ClassSetCount > 0; ClassSetCount-- )
     {
 
 
       if ( offset )
-        func( table + offset, valid );
+        func( table + offset, otvalid );
     }
 
-    valid->nesting_level--;
+    otvalid->nesting_level--;
 
     OTV_EXIT;
   }
 
 
-  /* uses valid->lookup_count */
+  /* uses otvalid->lookup_count */
 
   FT_LOCAL_DEF( void )
   otv_u_x_y_Ox_sy( FT_Bytes       table,
-                   OTV_Validator  valid )
+                   OTV_Validator  otvalid )
   {
     FT_Bytes  p = table;
     FT_UInt   GlyphCount, Count, count1;
     OTV_LIMIT_CHECK( GlyphCount * 2 + Count * 4 );
 
     for ( count1 = GlyphCount; count1 > 0; count1-- )
-      otv_Coverage_validate( table + FT_NEXT_USHORT( p ), valid, -1 );
+      otv_Coverage_validate( table + FT_NEXT_USHORT( p ), otvalid, -1 );
 
     for ( ; Count > 0; Count-- )
     {
       if ( FT_NEXT_USHORT( p ) >= GlyphCount )
         FT_INVALID_DATA;
 
-      if ( FT_NEXT_USHORT( p ) >= valid->lookup_count )
+      if ( FT_NEXT_USHORT( p ) >= otvalid->lookup_count )
         FT_INVALID_DATA;
     }
 
   }
 
 
-  /* sets valid->extra1 (valid->lookup_count)    */
+  /* sets otvalid->extra1 (valid->lookup_count)    */
 
   FT_LOCAL_DEF( void )
   otv_u_O_O_O_O_x_Onx( FT_Bytes       table,
-                       OTV_Validator  valid )
+                       OTV_Validator  otvalid )
   {
     FT_Bytes           p = table;
     FT_UInt            Coverage;
 
     OTV_TRACE(( " (ChainClassSetCount = %d)\n", ChainClassSetCount ));
 
-    otv_Coverage_validate( table + Coverage, valid, -1 );
+    otv_Coverage_validate( table + Coverage, otvalid, -1 );
 
-    otv_ClassDef_validate( table + BacktrackClassDef,  valid );
-    otv_ClassDef_validate( table + InputClassDef, valid );
-    otv_ClassDef_validate( table + LookaheadClassDef, valid );
+    otv_ClassDef_validate( table + BacktrackClassDef,  otvalid );
+    otv_ClassDef_validate( table + InputClassDef, otvalid );
+    otv_ClassDef_validate( table + LookaheadClassDef, otvalid );
 
     OTV_LIMIT_CHECK( ChainClassSetCount * 2 );
 
-    valid->nesting_level++;
-    func          = valid->func[valid->nesting_level];
-    valid->extra1 = valid->lookup_count;
+    otvalid->nesting_level++;
+    func          = otvalid->func[otvalid->nesting_level];
+    otvalid->extra1 = otvalid->lookup_count;
 
     for ( ; ChainClassSetCount > 0; ChainClassSetCount-- )
     {
 
 
       if ( offset )
-        func( table + offset, valid );
+        func( table + offset, otvalid );
     }
 
-    valid->nesting_level--;
+    otvalid->nesting_level--;
 
     OTV_EXIT;
   }
 
 
-  /* uses valid->lookup_count */
+  /* uses otvalid->lookup_count */
 
   FT_LOCAL_DEF( void )
   otv_u_x_Ox_y_Oy_z_Oz_p_sp( FT_Bytes       table,
-                             OTV_Validator  valid )
+                             OTV_Validator  otvalid )
   {
     FT_Bytes  p = table;
     FT_UInt   BacktrackGlyphCount, InputGlyphCount, LookaheadGlyphCount;
     OTV_LIMIT_CHECK( BacktrackGlyphCount * 2 + 2 );
 
     for ( ; BacktrackGlyphCount > 0; BacktrackGlyphCount-- )
-      otv_Coverage_validate( table + FT_NEXT_USHORT( p ), valid, -1 );
+      otv_Coverage_validate( table + FT_NEXT_USHORT( p ), otvalid, -1 );
 
     InputGlyphCount = FT_NEXT_USHORT( p );
 
     OTV_LIMIT_CHECK( InputGlyphCount * 2 + 2 );
 
     for ( count1 = InputGlyphCount; count1 > 0; count1-- )
-      otv_Coverage_validate( table + FT_NEXT_USHORT( p ), valid, -1 );
+      otv_Coverage_validate( table + FT_NEXT_USHORT( p ), otvalid, -1 );
 
     LookaheadGlyphCount = FT_NEXT_USHORT( p );
 
     OTV_LIMIT_CHECK( LookaheadGlyphCount * 2 + 2 );
 
     for ( ; LookaheadGlyphCount > 0; LookaheadGlyphCount-- )
-      otv_Coverage_validate( table + FT_NEXT_USHORT( p ), valid, -1 );
+      otv_Coverage_validate( table + FT_NEXT_USHORT( p ), otvalid, -1 );
 
     count2 = FT_NEXT_USHORT( p );
 
       if ( FT_NEXT_USHORT( p ) >= InputGlyphCount )
         FT_INVALID_DATA;
 
-      if ( FT_NEXT_USHORT( p ) >= valid->lookup_count )
+      if ( FT_NEXT_USHORT( p ) >= otvalid->lookup_count )
         FT_INVALID_DATA;
     }
 
index 898887f..5c93ba7 100644 (file)
@@ -4,7 +4,7 @@
 /*                                                                         */
 /*    OpenType common tables validation (specification).                   */
 /*                                                                         */
-/*  Copyright 2004, 2005, 2007, 2009 by                                    */
+/*  Copyright 2004, 2005, 2007, 2009, 2014 by                              */
 /*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
 /*                                                                         */
 /*  This file is part of the FreeType project, and may only be used,       */
@@ -39,7 +39,7 @@ FT_BEGIN_HEADER
   typedef struct OTV_ValidatorRec_*  OTV_Validator;
 
   typedef void  (*OTV_Validate_Func)( FT_Bytes       table,
-                                      OTV_Validator  valid );
+                                      OTV_Validator  otvalid );
 
   typedef struct  OTV_ValidatorRec_
   {
@@ -67,8 +67,8 @@ FT_BEGIN_HEADER
 
 
 #undef  FT_INVALID_
-#define FT_INVALID_( _prefix, _error )                         \
-          ft_validator_error( valid->root, _prefix ## _error )
+#define FT_INVALID_( _error ) \
+          ft_validator_error( otvalid->root, FT_THROW( _error ) )
 
 #define OTV_OPTIONAL_TABLE( _table )  FT_UShort  _table;      \
                                       FT_Bytes   _table ## _p
@@ -81,7 +81,7 @@ FT_BEGIN_HEADER
 
 #define OTV_LIMIT_CHECK( _count )                    \
           FT_BEGIN_STMNT                             \
-            if ( p + (_count) > valid->root->limit ) \
+            if ( p + (_count) > otvalid->root->limit ) \
               FT_INVALID_TOO_SHORT;                  \
           FT_END_STMNT
 
@@ -89,7 +89,7 @@ FT_BEGIN_HEADER
           FT_BEGIN_STMNT                                            \
             if ( _size > 0 && _size < table_size )                  \
             {                                                       \
-              if ( valid->root->level == FT_VALIDATE_PARANOID )     \
+              if ( otvalid->root->level == FT_VALIDATE_PARANOID )     \
                 FT_INVALID_OFFSET;                                  \
               else                                                  \
               {                                                     \
@@ -117,79 +117,79 @@ FT_BEGIN_HEADER
 
 #ifdef FT_DEBUG_LEVEL_TRACE
 
-#define OTV_NEST1( x )                                     \
-          FT_BEGIN_STMNT                                   \
-            valid->nesting_level          = 0;             \
-            valid->func[0]                = OTV_FUNC( x ); \
-            valid->debug_function_name[0] = OTV_NAME( x ); \
+#define OTV_NEST1( x )                                       \
+          FT_BEGIN_STMNT                                     \
+            otvalid->nesting_level          = 0;             \
+            otvalid->func[0]                = OTV_FUNC( x ); \
+            otvalid->debug_function_name[0] = OTV_NAME( x ); \
           FT_END_STMNT
 
-#define OTV_NEST2( x, y )                                  \
-          FT_BEGIN_STMNT                                   \
-            valid->nesting_level          = 0;             \
-            valid->func[0]                = OTV_FUNC( x ); \
-            valid->func[1]                = OTV_FUNC( y ); \
-            valid->debug_function_name[0] = OTV_NAME( x ); \
-            valid->debug_function_name[1] = OTV_NAME( y ); \
+#define OTV_NEST2( x, y )                                    \
+          FT_BEGIN_STMNT                                     \
+            otvalid->nesting_level          = 0;             \
+            otvalid->func[0]                = OTV_FUNC( x ); \
+            otvalid->func[1]                = OTV_FUNC( y ); \
+            otvalid->debug_function_name[0] = OTV_NAME( x ); \
+            otvalid->debug_function_name[1] = OTV_NAME( y ); \
           FT_END_STMNT
 
-#define OTV_NEST3( x, y, z )                               \
-          FT_BEGIN_STMNT                                   \
-            valid->nesting_level          = 0;             \
-            valid->func[0]                = OTV_FUNC( x ); \
-            valid->func[1]                = OTV_FUNC( y ); \
-            valid->func[2]                = OTV_FUNC( z ); \
-            valid->debug_function_name[0] = OTV_NAME( x ); \
-            valid->debug_function_name[1] = OTV_NAME( y ); \
-            valid->debug_function_name[2] = OTV_NAME( z ); \
+#define OTV_NEST3( x, y, z )                                 \
+          FT_BEGIN_STMNT                                     \
+            otvalid->nesting_level          = 0;             \
+            otvalid->func[0]                = OTV_FUNC( x ); \
+            otvalid->func[1]                = OTV_FUNC( y ); \
+            otvalid->func[2]                = OTV_FUNC( z ); \
+            otvalid->debug_function_name[0] = OTV_NAME( x ); \
+            otvalid->debug_function_name[1] = OTV_NAME( y ); \
+            otvalid->debug_function_name[2] = OTV_NAME( z ); \
           FT_END_STMNT
 
-#define OTV_INIT  valid->debug_indent = 0
+#define OTV_INIT  otvalid->debug_indent = 0
 
-#define OTV_ENTER                                                            \
-          FT_BEGIN_STMNT                                                     \
-            valid->debug_indent += 2;                                        \
-            FT_TRACE4(( "%*.s", valid->debug_indent, 0 ));                   \
-            FT_TRACE4(( "%s table\n",                                        \
-                        valid->debug_function_name[valid->nesting_level] )); \
+#define OTV_ENTER                                                              \
+          FT_BEGIN_STMNT                                                       \
+            otvalid->debug_indent += 2;                                        \
+            FT_TRACE4(( "%*.s", otvalid->debug_indent, 0 ));                   \
+            FT_TRACE4(( "%s table\n",                                          \
+                        otvalid->debug_function_name[otvalid->nesting_level] )); \
           FT_END_STMNT
 
-#define OTV_NAME_ENTER( name )                             \
-          FT_BEGIN_STMNT                                   \
-            valid->debug_indent += 2;                      \
-            FT_TRACE4(( "%*.s", valid->debug_indent, 0 )); \
-            FT_TRACE4(( "%s table\n", name ));             \
+#define OTV_NAME_ENTER( name )                               \
+          FT_BEGIN_STMNT                                     \
+            otvalid->debug_indent += 2;                      \
+            FT_TRACE4(( "%*.s", otvalid->debug_indent, 0 )); \
+            FT_TRACE4(( "%s table\n", name ));               \
           FT_END_STMNT
 
-#define OTV_EXIT  valid->debug_indent -= 2
+#define OTV_EXIT  otvalid->debug_indent -= 2
 
-#define OTV_TRACE( s )                                     \
-          FT_BEGIN_STMNT                                   \
-            FT_TRACE4(( "%*.s", valid->debug_indent, 0 )); \
-            FT_TRACE4( s );                                \
+#define OTV_TRACE( s )                                       \
+          FT_BEGIN_STMNT                                     \
+            FT_TRACE4(( "%*.s", otvalid->debug_indent, 0 )); \
+            FT_TRACE4( s );                                  \
           FT_END_STMNT
 
 #else   /* !FT_DEBUG_LEVEL_TRACE */
 
-#define OTV_NEST1( x )                            \
-          FT_BEGIN_STMNT                          \
-            valid->nesting_level = 0;             \
-            valid->func[0]       = OTV_FUNC( x ); \
+#define OTV_NEST1( x )                              \
+          FT_BEGIN_STMNT                            \
+            otvalid->nesting_level = 0;             \
+            otvalid->func[0]       = OTV_FUNC( x ); \
           FT_END_STMNT
 
-#define OTV_NEST2( x, y )                         \
-          FT_BEGIN_STMNT                          \
-            valid->nesting_level = 0;             \
-            valid->func[0]       = OTV_FUNC( x ); \
-            valid->func[1]       = OTV_FUNC( y ); \
+#define OTV_NEST2( x, y )                           \
+          FT_BEGIN_STMNT                            \
+            otvalid->nesting_level = 0;             \
+            otvalid->func[0]       = OTV_FUNC( x ); \
+            otvalid->func[1]       = OTV_FUNC( y ); \
           FT_END_STMNT
 
-#define OTV_NEST3( x, y, z )                      \
-          FT_BEGIN_STMNT                          \
-            valid->nesting_level = 0;             \
-            valid->func[0]       = OTV_FUNC( x ); \
-            valid->func[1]       = OTV_FUNC( y ); \
-            valid->func[2]       = OTV_FUNC( z ); \
+#define OTV_NEST3( x, y, z )                        \
+          FT_BEGIN_STMNT                            \
+            otvalid->nesting_level = 0;             \
+            otvalid->func[0]       = OTV_FUNC( x ); \
+            otvalid->func[1]       = OTV_FUNC( y ); \
+            otvalid->func[2]       = OTV_FUNC( z ); \
           FT_END_STMNT
 
 #define OTV_INIT                do { } while ( 0 )
@@ -202,7 +202,7 @@ FT_BEGIN_HEADER
 #endif  /* !FT_DEBUG_LEVEL_TRACE */
 
 
-#define OTV_RUN  valid->func[0]
+#define OTV_RUN  otvalid->func[0]
 
 
   /*************************************************************************/
@@ -215,7 +215,7 @@ FT_BEGIN_HEADER
 
   FT_LOCAL( void )
   otv_Coverage_validate( FT_Bytes       table,
-                         OTV_Validator  valid,
+                         OTV_Validator  otvalid,
                          FT_Int         expected_count );
 
   /* return first covered glyph */
@@ -241,7 +241,7 @@ FT_BEGIN_HEADER
 
   FT_LOCAL( void )
   otv_ClassDef_validate( FT_Bytes       table,
-                         OTV_Validator  valid );
+                         OTV_Validator  otvalid );
 
 
   /*************************************************************************/
@@ -254,7 +254,7 @@ FT_BEGIN_HEADER
 
   FT_LOCAL( void )
   otv_Device_validate( FT_Bytes       table,
-                       OTV_Validator  valid );
+                       OTV_Validator  otvalid );
 
 
   /*************************************************************************/
@@ -267,11 +267,11 @@ FT_BEGIN_HEADER
 
   FT_LOCAL( void )
   otv_Lookup_validate( FT_Bytes       table,
-                       OTV_Validator  valid );
+                       OTV_Validator  otvalid );
 
   FT_LOCAL( void )
   otv_LookupList_validate( FT_Bytes       table,
-                           OTV_Validator  valid );
+                           OTV_Validator  otvalid );
 
 
   /*************************************************************************/
@@ -284,13 +284,13 @@ FT_BEGIN_HEADER
 
   FT_LOCAL( void )
   otv_Feature_validate( FT_Bytes       table,
-                        OTV_Validator  valid );
+                        OTV_Validator  otvalid );
 
   /* lookups must already be validated */
   FT_LOCAL( void )
   otv_FeatureList_validate( FT_Bytes       table,
                             FT_Bytes       lookups,
-                            OTV_Validator  valid );
+                            OTV_Validator  otvalid );
 
 
   /*************************************************************************/
@@ -303,7 +303,7 @@ FT_BEGIN_HEADER
 
   FT_LOCAL( void )
   otv_LangSys_validate( FT_Bytes       table,
-                        OTV_Validator  valid );
+                        OTV_Validator  otvalid );
 
 
   /*************************************************************************/
@@ -316,13 +316,13 @@ FT_BEGIN_HEADER
 
   FT_LOCAL( void )
   otv_Script_validate( FT_Bytes       table,
-                       OTV_Validator  valid );
+                       OTV_Validator  otvalid );
 
   /* features must already be validated */
   FT_LOCAL( void )
   otv_ScriptList_validate( FT_Bytes       table,
                            FT_Bytes       features,
-                           OTV_Validator  valid );
+                           OTV_Validator  otvalid );
 
 
   /*************************************************************************/
@@ -349,7 +349,7 @@ FT_BEGIN_HEADER
 
   FT_LOCAL( void )
   otv_x_Ox ( FT_Bytes       table,
-             OTV_Validator  valid );
+             OTV_Validator  otvalid );
 
 #define AlternateSubstFormat1Func     otv_u_C_x_Ox
 #define ChainContextPosFormat1Func    otv_u_C_x_Ox
@@ -361,7 +361,7 @@ FT_BEGIN_HEADER
 
   FT_LOCAL( void )
   otv_u_C_x_Ox( FT_Bytes       table,
-                OTV_Validator  valid );
+                OTV_Validator  otvalid );
 
 #define AlternateSetFunc     otv_x_ux
 #define AttachPointFunc      otv_x_ux
@@ -372,7 +372,7 @@ FT_BEGIN_HEADER
 
   FT_LOCAL( void )
   otv_x_ux( FT_Bytes       table,
-            OTV_Validator  valid );
+            OTV_Validator  otvalid );
 
 #define PosClassRuleFunc  otv_x_y_ux_sy
 #define PosRuleFunc       otv_x_y_ux_sy
@@ -381,7 +381,7 @@ FT_BEGIN_HEADER
 
   FT_LOCAL( void )
   otv_x_y_ux_sy( FT_Bytes       table,
-                 OTV_Validator  valid );
+                 OTV_Validator  otvalid );
 
 #define ChainPosClassRuleFunc  otv_x_ux_y_uy_z_uz_p_sp
 #define ChainPosRuleFunc       otv_x_ux_y_uy_z_uz_p_sp
@@ -390,35 +390,35 @@ FT_BEGIN_HEADER
 
   FT_LOCAL( void )
   otv_x_ux_y_uy_z_uz_p_sp( FT_Bytes       table,
-                           OTV_Validator  valid );
+                           OTV_Validator  otvalid );
 
 #define ContextPosFormat2Func    otv_u_O_O_x_Onx
 #define ContextSubstFormat2Func  otv_u_O_O_x_Onx
 
   FT_LOCAL( void )
   otv_u_O_O_x_Onx( FT_Bytes       table,
-                   OTV_Validator  valid );
+                   OTV_Validator  otvalid );
 
 #define ContextPosFormat3Func    otv_u_x_y_Ox_sy
 #define ContextSubstFormat3Func  otv_u_x_y_Ox_sy
 
   FT_LOCAL( void )
   otv_u_x_y_Ox_sy( FT_Bytes       table,
-                   OTV_Validator  valid );
+                   OTV_Validator  otvalid );
 
 #define ChainContextPosFormat2Func    otv_u_O_O_O_O_x_Onx
 #define ChainContextSubstFormat2Func  otv_u_O_O_O_O_x_Onx
 
   FT_LOCAL( void )
   otv_u_O_O_O_O_x_Onx( FT_Bytes       table,
-                       OTV_Validator  valid );
+                       OTV_Validator  otvalid );
 
 #define ChainContextPosFormat3Func    otv_u_x_Ox_y_Oy_z_Oz_p_sp
 #define ChainContextSubstFormat3Func  otv_u_x_Ox_y_Oy_z_Oz_p_sp
 
   FT_LOCAL( void )
   otv_u_x_Ox_y_Oy_z_Oz_p_sp( FT_Bytes       table,
-                             OTV_Validator  valid );
+                             OTV_Validator  otvalid );
 
 
   FT_LOCAL( FT_UInt )
index 3633ad0..e60ef36 100644 (file)
@@ -45,7 +45,7 @@
 
   static void
   otv_O_x_Ox( FT_Bytes       table,
-              OTV_Validator  valid )
+              OTV_Validator  otvalid )
   {
     FT_Bytes           p = table;
     FT_Bytes           Coverage;
 
     OTV_TRACE(( " (GlyphCount = %d)\n", GlyphCount ));
 
-    otv_Coverage_validate( Coverage, valid, GlyphCount );
+    otv_Coverage_validate( Coverage, otvalid, GlyphCount );
     if ( GlyphCount != otv_Coverage_get_count( Coverage ) )
       FT_INVALID_DATA;
 
     OTV_LIMIT_CHECK( GlyphCount * 2 );
 
-    valid->nesting_level++;
-    func          = valid->func[valid->nesting_level];
-    valid->extra1 = 0;
+    otvalid->nesting_level++;
+    func          = otvalid->func[otvalid->nesting_level];
+    otvalid->extra1 = 0;
 
     for ( ; GlyphCount > 0; GlyphCount-- )
-      func( table + FT_NEXT_USHORT( p ), valid );
+      func( table + FT_NEXT_USHORT( p ), otvalid );
 
-    valid->nesting_level--;
+    otvalid->nesting_level--;
 
     OTV_EXIT;
   }
@@ -92,7 +92,7 @@
 
   static void
   otv_CaretValue_validate( FT_Bytes       table,
-                           OTV_Validator  valid )
+                           OTV_Validator  otvalid )
   {
     FT_Bytes  p = table;
     FT_UInt   CaretValueFormat;
       OTV_LIMIT_CHECK( 2 );
 
       /* DeviceTable */
-      otv_Device_validate( table + FT_NEXT_USHORT( p ), valid );
+      otv_Device_validate( table + FT_NEXT_USHORT( p ), otvalid );
       break;
 
     default:
   /*************************************************************************/
   /*************************************************************************/
 
-  /* sets valid->glyph_count */
+  /* sets otvalid->glyph_count */
 
   FT_LOCAL_DEF( void )
   otv_GDEF_validate( FT_Bytes      table,
                      FT_UInt       glyph_count,
                      FT_Validator  ftvalid )
   {
-    OTV_ValidatorRec  validrec;
-    OTV_Validator     valid = &validrec;
+    OTV_ValidatorRec  otvalidrec;
+    OTV_Validator     otvalid = &otvalidrec;
     FT_Bytes          p     = table;
     FT_UInt           table_size;
     FT_Bool           need_MarkAttachClassDef;
     OTV_OPTIONAL_TABLE( MarkAttachClassDef );
 
 
-    valid->root = ftvalid;
+    otvalid->root = ftvalid;
 
     FT_TRACE3(( "validating GDEF table\n" ));
     OTV_INIT;
     else
       table_size = 10;              /* OpenType < 1.2  */
 
-    valid->glyph_count = glyph_count;
+    otvalid->glyph_count = glyph_count;
 
     OTV_OPTIONAL_OFFSET( GlyphClassDef );
     OTV_SIZE_CHECK( GlyphClassDef );
     if ( GlyphClassDef )
-      otv_ClassDef_validate( table + GlyphClassDef, valid );
+      otv_ClassDef_validate( table + GlyphClassDef, otvalid );
 
     OTV_OPTIONAL_OFFSET( AttachListOffset );
     OTV_SIZE_CHECK( AttachListOffset );
     if ( AttachListOffset )
     {
       OTV_NEST2( AttachList, AttachPoint );
-      OTV_RUN( table + AttachListOffset, valid );
+      OTV_RUN( table + AttachListOffset, otvalid );
     }
 
     OTV_OPTIONAL_OFFSET( LigCaretListOffset );
     if ( LigCaretListOffset )
     {
       OTV_NEST3( LigCaretList, LigGlyph, CaretValue );
-      OTV_RUN( table + LigCaretListOffset, valid );
+      OTV_RUN( table + LigCaretListOffset, otvalid );
     }
 
     if ( need_MarkAttachClassDef )
       OTV_OPTIONAL_OFFSET( MarkAttachClassDef );
       OTV_SIZE_CHECK( MarkAttachClassDef );
       if ( MarkAttachClassDef )
-        otv_ClassDef_validate( table + MarkAttachClassDef, valid );
+        otv_ClassDef_validate( table + MarkAttachClassDef, otvalid );
     }
 
     FT_TRACE4(( "\n" ));
index 49b4618..1a9dbaa 100644 (file)
@@ -57,7 +57,7 @@
 
   static void
   otv_x_sxy( FT_Bytes       table,
-             OTV_Validator  valid )
+             OTV_Validator  otvalid )
   {
     FT_Bytes  p = table;
     FT_UInt   Count, count1, table_size;
 
     OTV_TRACE(( " (Count = %d)\n", Count ));
 
-    OTV_LIMIT_CHECK( Count * valid->extra1 * 2 );
+    OTV_LIMIT_CHECK( Count * otvalid->extra1 * 2 );
 
-    table_size = Count * valid->extra1 * 2 + 2;
+    table_size = Count * otvalid->extra1 * 2 + 2;
 
     for ( ; Count > 0; Count-- )
-      for ( count1 = valid->extra1; count1 > 0; count1-- )
+      for ( count1 = otvalid->extra1; count1 > 0; count1-- )
       {
         OTV_OPTIONAL_TABLE( anchor_offset );
 
 
         OTV_OPTIONAL_OFFSET( anchor_offset );
 
-        if ( valid->extra2 )
+        if ( otvalid->extra2 )
         {
           OTV_SIZE_CHECK( anchor_offset );
           if ( anchor_offset )
-            otv_Anchor_validate( table + anchor_offset, valid );
+            otv_Anchor_validate( table + anchor_offset, otvalid );
         }
         else
-          otv_Anchor_validate( table + anchor_offset, valid );
+          otv_Anchor_validate( table + anchor_offset, otvalid );
       }
 
     OTV_EXIT;
 #define MarkLigPosFormat1Func   otv_u_O_O_u_O_O
 #define MarkMarkPosFormat1Func  otv_u_O_O_u_O_O
 
-  /* sets valid->extra1 (class count) */
+  /* sets otvalid->extra1 (class count) */
 
   static void
   otv_u_O_O_u_O_O( FT_Bytes       table,
-                   OTV_Validator  valid )
+                   OTV_Validator  otvalid )
   {
     FT_Bytes           p = table;
     FT_UInt            Coverage1, Coverage2, ClassCount;
     Array1     = FT_NEXT_USHORT( p );
     Array2     = FT_NEXT_USHORT( p );
 
-    otv_Coverage_validate( table + Coverage1, valid, -1 );
-    otv_Coverage_validate( table + Coverage2, valid, -1 );
+    otv_Coverage_validate( table + Coverage1, otvalid, -1 );
+    otv_Coverage_validate( table + Coverage2, otvalid, -1 );
 
-    otv_MarkArray_validate( table + Array1, valid );
+    otv_MarkArray_validate( table + Array1, otvalid );
 
-    valid->nesting_level++;
-    func          = valid->func[valid->nesting_level];
-    valid->extra1 = ClassCount;
+    otvalid->nesting_level++;
+    func          = otvalid->func[otvalid->nesting_level];
+    otvalid->extra1 = ClassCount;
 
-    func( table + Array2, valid );
+    func( table + Array2, otvalid );
 
-    valid->nesting_level--;
+    otvalid->nesting_level--;
 
     OTV_EXIT;
   }
   }
 
 
-  /* uses valid->extra3 (pointer to base table) */
+  /* uses otvalid->extra3 (pointer to base table) */
 
   static void
   otv_ValueRecord_validate( FT_Bytes       table,
                             FT_UInt        format,
-                            OTV_Validator  valid )
+                            OTV_Validator  otvalid )
   {
     FT_Bytes  p = table;
     FT_UInt   count;
         /* ValueRecord is part of an array -- getting the correct table    */
         /* size is probably not worth the trouble                          */
 
-        table_size = p - valid->extra3;
+        table_size = p - otvalid->extra3;
 
         OTV_SIZE_CHECK( device );
         if ( device )
-          otv_Device_validate( valid->extra3 + device, valid );
+          otv_Device_validate( otvalid->extra3 + device, otvalid );
       }
       format >>= 1;
     }
 
   static void
   otv_Anchor_validate( FT_Bytes       table,
-                       OTV_Validator  valid )
+                       OTV_Validator  otvalid )
   {
     FT_Bytes  p = table;
     FT_UInt   AnchorFormat;
 
         OTV_SIZE_CHECK( XDeviceTable );
         if ( XDeviceTable )
-          otv_Device_validate( table + XDeviceTable, valid );
+          otv_Device_validate( table + XDeviceTable, otvalid );
 
         OTV_SIZE_CHECK( YDeviceTable );
         if ( YDeviceTable )
-          otv_Device_validate( table + YDeviceTable, valid );
+          otv_Device_validate( table + YDeviceTable, otvalid );
       }
       break;
 
 
   static void
   otv_MarkArray_validate( FT_Bytes       table,
-                          OTV_Validator  valid )
+                          OTV_Validator  otvalid )
   {
     FT_Bytes  p = table;
     FT_UInt   MarkCount;
     {
       p += 2;   /* skip Class */
       /* MarkAnchor */
-      otv_Anchor_validate( table + FT_NEXT_USHORT( p ), valid );
+      otv_Anchor_validate( table + FT_NEXT_USHORT( p ), otvalid );
     }
 
     OTV_EXIT;
   /*************************************************************************/
   /*************************************************************************/
 
-  /* sets valid->extra3 (pointer to base table) */
+  /* sets otvalid->extra3 (pointer to base table) */
 
   static void
   otv_SinglePos_validate( FT_Bytes       table,
-                          OTV_Validator  valid )
+                          OTV_Validator  otvalid )
   {
     FT_Bytes  p = table;
     FT_UInt   PosFormat;
 
     OTV_TRACE(( " (format %d)\n", PosFormat ));
 
-    valid->extra3 = table;
+    otvalid->extra3 = table;
 
     switch ( PosFormat )
     {
         Coverage    = FT_NEXT_USHORT( p );
         ValueFormat = FT_NEXT_USHORT( p );
 
-        otv_Coverage_validate( table + Coverage, valid, -1 );
-        otv_ValueRecord_validate( p, ValueFormat, valid ); /* Value */
+        otv_Coverage_validate( table + Coverage, otvalid, -1 );
+        otv_ValueRecord_validate( p, ValueFormat, otvalid ); /* Value */
       }
       break;
 
 
         len_value = otv_value_length( ValueFormat );
 
-        otv_Coverage_validate( table + Coverage, valid, ValueCount );
+        otv_Coverage_validate( table + Coverage, otvalid, ValueCount );
 
         OTV_LIMIT_CHECK( ValueCount * len_value );
 
         /* Value */
         for ( ; ValueCount > 0; ValueCount-- )
         {
-          otv_ValueRecord_validate( p, ValueFormat, valid );
+          otv_ValueRecord_validate( p, ValueFormat, otvalid );
           p += len_value;
         }
       }
   otv_PairSet_validate( FT_Bytes       table,
                         FT_UInt        format1,
                         FT_UInt        format2,
-                        OTV_Validator  valid )
+                        OTV_Validator  otvalid )
   {
     FT_Bytes  p = table;
     FT_UInt   value_len1, value_len2, PairValueCount;
       p += 2;       /* skip SecondGlyph */
 
       if ( format1 )
-        otv_ValueRecord_validate( p, format1, valid ); /* Value1 */
+        otv_ValueRecord_validate( p, format1, otvalid ); /* Value1 */
       p += value_len1;
 
       if ( format2 )
-        otv_ValueRecord_validate( p, format2, valid ); /* Value2 */
+        otv_ValueRecord_validate( p, format2, otvalid ); /* Value2 */
       p += value_len2;
     }
 
   }
 
 
-  /* sets valid->extra3 (pointer to base table) */
+  /* sets otvalid->extra3 (pointer to base table) */
 
   static void
   otv_PairPos_validate( FT_Bytes       table,
-                        OTV_Validator  valid )
+                        OTV_Validator  otvalid )
   {
     FT_Bytes  p = table;
     FT_UInt   PosFormat;
 
     OTV_TRACE(( " (format %d)\n", PosFormat ));
 
-    valid->extra3 = table;
+    otvalid->extra3 = table;
 
     switch ( PosFormat )
     {
 
         OTV_TRACE(( " (PairSetCount = %d)\n", PairSetCount ));
 
-        otv_Coverage_validate( table + Coverage, valid, -1 );
+        otv_Coverage_validate( table + Coverage, otvalid, -1 );
 
         OTV_LIMIT_CHECK( PairSetCount * 2 );
 
         /* PairSetOffset */
         for ( ; PairSetCount > 0; PairSetCount-- )
           otv_PairSet_validate( table + FT_NEXT_USHORT( p ),
-                                ValueFormat1, ValueFormat2, valid );
+                                ValueFormat1, ValueFormat2, otvalid );
       }
       break;
 
         len_value1 = otv_value_length( ValueFormat1 );
         len_value2 = otv_value_length( ValueFormat2 );
 
-        otv_Coverage_validate( table + Coverage, valid, -1 );
-        otv_ClassDef_validate( table + ClassDef1, valid );
-        otv_ClassDef_validate( table + ClassDef2, valid );
+        otv_Coverage_validate( table + Coverage, otvalid, -1 );
+        otv_ClassDef_validate( table + ClassDef1, otvalid );
+        otv_ClassDef_validate( table + ClassDef2, otvalid );
 
         OTV_LIMIT_CHECK( ClassCount1 * ClassCount2 *
                      ( len_value1 + len_value2 ) );
           {
             if ( ValueFormat1 )
               /* Value1 */
-              otv_ValueRecord_validate( p, ValueFormat1, valid );
+              otv_ValueRecord_validate( p, ValueFormat1, otvalid );
             p += len_value1;
 
             if ( ValueFormat2 )
               /* Value2 */
-              otv_ValueRecord_validate( p, ValueFormat2, valid );
+              otv_ValueRecord_validate( p, ValueFormat2, otvalid );
             p += len_value2;
           }
         }
 
   static void
   otv_CursivePos_validate( FT_Bytes       table,
-                           OTV_Validator  valid )
+                           OTV_Validator  otvalid )
   {
     FT_Bytes  p = table;
     FT_UInt   PosFormat;
 
         OTV_TRACE(( " (EntryExitCount = %d)\n", EntryExitCount ));
 
-        otv_Coverage_validate( table + Coverage, valid, EntryExitCount );
+        otv_Coverage_validate( table + Coverage, otvalid, EntryExitCount );
 
         OTV_LIMIT_CHECK( EntryExitCount * 4 );
 
 
           OTV_SIZE_CHECK( EntryAnchor );
           if ( EntryAnchor )
-            otv_Anchor_validate( table + EntryAnchor, valid );
+            otv_Anchor_validate( table + EntryAnchor, otvalid );
 
           OTV_SIZE_CHECK( ExitAnchor );
           if ( ExitAnchor )
-            otv_Anchor_validate( table + ExitAnchor, valid );
+            otv_Anchor_validate( table + ExitAnchor, otvalid );
         }
       }
       break;
   /* UNDOCUMENTED (in OpenType 1.5):              */
   /* BaseRecord tables can contain NULL pointers. */
 
-  /* sets valid->extra2 (1) */
+  /* sets otvalid->extra2 (1) */
 
   static void
   otv_MarkBasePos_validate( FT_Bytes       table,
-                            OTV_Validator  valid )
+                            OTV_Validator  otvalid )
   {
     FT_Bytes  p = table;
     FT_UInt   PosFormat;
     switch ( PosFormat )
     {
     case 1:
-      valid->extra2 = 1;
+      otvalid->extra2 = 1;
       OTV_NEST2( MarkBasePosFormat1, BaseArray );
-      OTV_RUN( table, valid );
+      OTV_RUN( table, otvalid );
       break;
 
     default:
   /*************************************************************************/
   /*************************************************************************/
 
-  /* sets valid->extra2 (1) */
+  /* sets otvalid->extra2 (1) */
 
   static void
   otv_MarkLigPos_validate( FT_Bytes       table,
-                           OTV_Validator  valid )
+                           OTV_Validator  otvalid )
   {
     FT_Bytes  p = table;
     FT_UInt   PosFormat;
     switch ( PosFormat )
     {
     case 1:
-      valid->extra2 = 1;
+      otvalid->extra2 = 1;
       OTV_NEST3( MarkLigPosFormat1, LigatureArray, LigatureAttach );
-      OTV_RUN( table, valid );
+      OTV_RUN( table, otvalid );
       break;
 
     default:
   /*************************************************************************/
   /*************************************************************************/
 
-  /* sets valid->extra2 (0) */
+  /* sets otvalid->extra2 (0) */
 
   static void
   otv_MarkMarkPos_validate( FT_Bytes       table,
-                            OTV_Validator  valid )
+                            OTV_Validator  otvalid )
   {
     FT_Bytes  p = table;
     FT_UInt   PosFormat;
     switch ( PosFormat )
     {
     case 1:
-      valid->extra2 = 0;
+      otvalid->extra2 = 0;
       OTV_NEST2( MarkMarkPosFormat1, Mark2Array );
-      OTV_RUN( table, valid );
+      OTV_RUN( table, otvalid );
       break;
 
     default:
   /*************************************************************************/
   /*************************************************************************/
 
-  /* sets valid->extra1 (lookup count) */
+  /* sets otvalid->extra1 (lookup count) */
 
   static void
   otv_ContextPos_validate( FT_Bytes       table,
-                           OTV_Validator  valid )
+                           OTV_Validator  otvalid )
   {
     FT_Bytes  p = table;
     FT_UInt   PosFormat;
       /* context rules since even invalid glyph indices/classes return  */
       /* meaningful results                                             */
 
-      valid->extra1 = valid->lookup_count;
+      otvalid->extra1 = otvalid->lookup_count;
       OTV_NEST3( ContextPosFormat1, PosRuleSet, PosRule );
-      OTV_RUN( table, valid );
+      OTV_RUN( table, otvalid );
       break;
 
     case 2:
       /* meaningful results                                             */
 
       OTV_NEST3( ContextPosFormat2, PosClassSet, PosClassRule );
-      OTV_RUN( table, valid );
+      OTV_RUN( table, otvalid );
       break;
 
     case 3:
       OTV_NEST1( ContextPosFormat3 );
-      OTV_RUN( table, valid );
+      OTV_RUN( table, otvalid );
       break;
 
     default:
   /*************************************************************************/
   /*************************************************************************/
 
-  /* sets valid->extra1 (lookup count) */
+  /* sets otvalid->extra1 (lookup count) */
 
   static void
   otv_ChainContextPos_validate( FT_Bytes       table,
-                                OTV_Validator  valid )
+                                OTV_Validator  otvalid )
   {
     FT_Bytes  p = table;
     FT_UInt   PosFormat;
       /* context rules since even invalid glyph indices/classes return  */
       /* meaningful results                                             */
 
-      valid->extra1 = valid->lookup_count;
+      otvalid->extra1 = otvalid->lookup_count;
       OTV_NEST3( ChainContextPosFormat1,
                  ChainPosRuleSet, ChainPosRule );
-      OTV_RUN( table, valid );
+      OTV_RUN( table, otvalid );
       break;
 
     case 2:
 
       OTV_NEST3( ChainContextPosFormat2,
                  ChainPosClassSet, ChainPosClassRule );
-      OTV_RUN( table, valid );
+      OTV_RUN( table, otvalid );
       break;
 
     case 3:
       OTV_NEST1( ChainContextPosFormat3 );
-      OTV_RUN( table, valid );
+      OTV_RUN( table, otvalid );
       break;
 
     default:
   /*************************************************************************/
   /*************************************************************************/
 
-  /* uses valid->type_funcs */
+  /* uses otvalid->type_funcs */
 
   static void
   otv_ExtensionPos_validate( FT_Bytes       table,
-                             OTV_Validator  valid )
+                             OTV_Validator  otvalid )
   {
     FT_Bytes  p = table;
     FT_UInt   PosFormat;
         if ( ExtensionLookupType == 0 || ExtensionLookupType >= 9 )
           FT_INVALID_DATA;
 
-        validate = valid->type_funcs[ExtensionLookupType - 1];
-        validate( table + ExtensionOffset, valid );
+        validate = otvalid->type_funcs[ExtensionLookupType - 1];
+        validate( table + ExtensionOffset, otvalid );
       }
       break;
 
   };
 
 
-  /* sets valid->type_count */
-  /* sets valid->type_funcs */
+  /* sets otvalid->type_count */
+  /* sets otvalid->type_funcs */
 
   FT_LOCAL_DEF( void )
   otv_GPOS_subtable_validate( FT_Bytes       table,
-                              OTV_Validator  valid )
+                              OTV_Validator  otvalid )
   {
-    valid->type_count = 9;
-    valid->type_funcs = (OTV_Validate_Func*)otv_gpos_validate_funcs;
+    otvalid->type_count = 9;
+    otvalid->type_funcs = (OTV_Validate_Func*)otv_gpos_validate_funcs;
 
-    otv_Lookup_validate( table, valid );
+    otv_Lookup_validate( table, otvalid );
   }
 
 
   /*************************************************************************/
   /*************************************************************************/
 
-  /* sets valid->glyph_count */
+  /* sets otvalid->glyph_count */
 
   FT_LOCAL_DEF( void )
   otv_GPOS_validate( FT_Bytes      table,
                      FT_Validator  ftvalid )
   {
     OTV_ValidatorRec  validrec;
-    OTV_Validator     valid = &validrec;
+    OTV_Validator     otvalid = &validrec;
     FT_Bytes          p     = table;
     FT_UInt           ScriptList, FeatureList, LookupList;
 
 
-    valid->root = ftvalid;
+    otvalid->root = ftvalid;
 
     FT_TRACE3(( "validating GPOS table\n" ));
     OTV_INIT;
     FeatureList = FT_NEXT_USHORT( p );
     LookupList  = FT_NEXT_USHORT( p );
 
-    valid->type_count  = 9;
-    valid->type_funcs  = (OTV_Validate_Func*)otv_gpos_validate_funcs;
-    valid->glyph_count = glyph_count;
+    otvalid->type_count  = 9;
+    otvalid->type_funcs  = (OTV_Validate_Func*)otv_gpos_validate_funcs;
+    otvalid->glyph_count = glyph_count;
 
     otv_LookupList_validate( table + LookupList,
-                             valid );
+                             otvalid );
     otv_FeatureList_validate( table + FeatureList, table + LookupList,
-                              valid );
+                              otvalid );
     otv_ScriptList_validate( table + ScriptList, table + FeatureList,
-                             valid );
+                             otvalid );
 
     FT_TRACE4(( "\n" ));
   }
index ed499d1..024b8ca 100644 (file)
   /*************************************************************************/
   /*************************************************************************/
 
-  /* uses valid->glyph_count */
+  /* uses otvalid->glyph_count */
 
   static void
   otv_SingleSubst_validate( FT_Bytes       table,
-                            OTV_Validator  valid )
+                            OTV_Validator  otvalid )
   {
     FT_Bytes  p = table;
     FT_UInt   SubstFormat;
         Coverage     = table + FT_NEXT_USHORT( p );
         DeltaGlyphID = FT_NEXT_SHORT( p );
 
-        otv_Coverage_validate( Coverage, valid, -1 );
+        otv_Coverage_validate( Coverage, otvalid, -1 );
 
         idx = otv_Coverage_get_first( Coverage ) + DeltaGlyphID;
         if ( idx < 0 )
           FT_INVALID_DATA;
 
         idx = otv_Coverage_get_last( Coverage ) + DeltaGlyphID;
-        if ( (FT_UInt)idx >= valid->glyph_count )
+        if ( (FT_UInt)idx >= otvalid->glyph_count )
           FT_INVALID_DATA;
       }
       break;
 
         OTV_TRACE(( " (GlyphCount = %d)\n", GlyphCount ));
 
-        otv_Coverage_validate( table + Coverage, valid, GlyphCount );
+        otv_Coverage_validate( table + Coverage, otvalid, GlyphCount );
 
         OTV_LIMIT_CHECK( GlyphCount * 2 );
 
         /* Substitute */
         for ( ; GlyphCount > 0; GlyphCount-- )
-          if ( FT_NEXT_USHORT( p ) >= valid->glyph_count )
+          if ( FT_NEXT_USHORT( p ) >= otvalid->glyph_count )
             FT_INVALID_GLYPH_ID;
       }
       break;
   /*************************************************************************/
   /*************************************************************************/
 
-  /* sets valid->extra1 (glyph count) */
+  /* sets otvalid->extra1 (glyph count) */
 
   static void
   otv_MultipleSubst_validate( FT_Bytes       table,
-                              OTV_Validator  valid )
+                              OTV_Validator  otvalid )
   {
     FT_Bytes  p = table;
     FT_UInt   SubstFormat;
     switch ( SubstFormat )
     {
     case 1:
-      valid->extra1 = valid->glyph_count;
+      otvalid->extra1 = otvalid->glyph_count;
       OTV_NEST2( MultipleSubstFormat1, Sequence );
-      OTV_RUN( table, valid );
+      OTV_RUN( table, otvalid );
       break;
 
     default:
   /*************************************************************************/
   /*************************************************************************/
 
-  /* sets valid->extra1 (glyph count) */
+  /* sets otvalid->extra1 (glyph count) */
 
   static void
   otv_AlternateSubst_validate( FT_Bytes       table,
-                               OTV_Validator  valid )
+                               OTV_Validator  otvalid )
   {
     FT_Bytes  p = table;
     FT_UInt   SubstFormat;
     switch ( SubstFormat )
     {
     case 1:
-      valid->extra1 = valid->glyph_count;
+      otvalid->extra1 = otvalid->glyph_count;
       OTV_NEST2( AlternateSubstFormat1, AlternateSet );
-      OTV_RUN( table, valid );
+      OTV_RUN( table, otvalid );
       break;
 
     default:
 
 #define LigatureFunc  otv_Ligature_validate
 
-  /* uses valid->glyph_count */
+  /* uses otvalid->glyph_count */
 
   static void
   otv_Ligature_validate( FT_Bytes       table,
-                         OTV_Validator  valid )
+                         OTV_Validator  otvalid )
   {
     FT_Bytes  p = table;
     FT_UInt   LigatureGlyph, CompCount;
 
     OTV_LIMIT_CHECK( 4 );
     LigatureGlyph = FT_NEXT_USHORT( p );
-    if ( LigatureGlyph >= valid->glyph_count )
+    if ( LigatureGlyph >= otvalid->glyph_count )
       FT_INVALID_DATA;
 
     CompCount = FT_NEXT_USHORT( p );
 
   static void
   otv_LigatureSubst_validate( FT_Bytes       table,
-                              OTV_Validator  valid )
+                              OTV_Validator  otvalid )
   {
     FT_Bytes  p = table;
     FT_UInt   SubstFormat;
     {
     case 1:
       OTV_NEST3( LigatureSubstFormat1, LigatureSet, Ligature );
-      OTV_RUN( table, valid );
+      OTV_RUN( table, otvalid );
       break;
 
     default:
   /*************************************************************************/
   /*************************************************************************/
 
-  /* sets valid->extra1 (lookup count) */
+  /* sets otvalid->extra1 (lookup count) */
 
   static void
   otv_ContextSubst_validate( FT_Bytes       table,
-                             OTV_Validator  valid )
+                             OTV_Validator  otvalid )
   {
     FT_Bytes  p = table;
     FT_UInt   SubstFormat;
       /* context rules since even invalid glyph indices/classes return  */
       /* meaningful results                                             */
 
-      valid->extra1 = valid->lookup_count;
+      otvalid->extra1 = otvalid->lookup_count;
       OTV_NEST3( ContextSubstFormat1, SubRuleSet, SubRule );
-      OTV_RUN( table, valid );
+      OTV_RUN( table, otvalid );
       break;
 
     case 2:
       /* meaningful results                                             */
 
       OTV_NEST3( ContextSubstFormat2, SubClassSet, SubClassRule );
-      OTV_RUN( table, valid );
+      OTV_RUN( table, otvalid );
       break;
 
     case 3:
       OTV_NEST1( ContextSubstFormat3 );
-      OTV_RUN( table, valid );
+      OTV_RUN( table, otvalid );
       break;
 
     default:
   /*************************************************************************/
   /*************************************************************************/
 
-  /* sets valid->extra1 (lookup count)            */
+  /* sets otvalid->extra1 (lookup count)            */
 
   static void
   otv_ChainContextSubst_validate( FT_Bytes       table,
-                                  OTV_Validator  valid )
+                                  OTV_Validator  otvalid )
   {
     FT_Bytes  p = table;
     FT_UInt   SubstFormat;
       /* context rules since even invalid glyph indices/classes return  */
       /* meaningful results                                             */
 
-      valid->extra1 = valid->lookup_count;
+      otvalid->extra1 = otvalid->lookup_count;
       OTV_NEST3( ChainContextSubstFormat1,
                  ChainSubRuleSet, ChainSubRule );
-      OTV_RUN( table, valid );
+      OTV_RUN( table, otvalid );
       break;
 
     case 2:
 
       OTV_NEST3( ChainContextSubstFormat2,
                  ChainSubClassSet, ChainSubClassRule );
-      OTV_RUN( table, valid );
+      OTV_RUN( table, otvalid );
       break;
 
     case 3:
       OTV_NEST1( ChainContextSubstFormat3 );
-      OTV_RUN( table, valid );
+      OTV_RUN( table, otvalid );
       break;
 
     default:
   /*************************************************************************/
   /*************************************************************************/
 
-  /* uses valid->type_funcs */
+  /* uses otvalid->type_funcs */
 
   static void
   otv_ExtensionSubst_validate( FT_Bytes       table,
-                               OTV_Validator  valid )
+                               OTV_Validator  otvalid )
   {
     FT_Bytes  p = table;
     FT_UInt   SubstFormat;
              ExtensionLookupType > 8  )
           FT_INVALID_DATA;
 
-        validate = valid->type_funcs[ExtensionLookupType - 1];
-        validate( table + ExtensionOffset, valid );
+        validate = otvalid->type_funcs[ExtensionLookupType - 1];
+        validate( table + ExtensionOffset, otvalid );
       }
       break;
 
   /*************************************************************************/
   /*************************************************************************/
 
-  /* uses valid->glyph_count */
+  /* uses otvalid->glyph_count */
 
   static void
   otv_ReverseChainSingleSubst_validate( FT_Bytes       table,
-                                        OTV_Validator  valid )
+                                        OTV_Validator  otvalid )
   {
     FT_Bytes  p = table, Coverage;
     FT_UInt   SubstFormat;
 
       OTV_TRACE(( " (BacktrackGlyphCount = %d)\n", BacktrackGlyphCount ));
 
-      otv_Coverage_validate( Coverage, valid, -1 );
+      otv_Coverage_validate( Coverage, otvalid, -1 );
 
       OTV_LIMIT_CHECK( BacktrackGlyphCount * 2 + 2 );
 
       for ( ; BacktrackGlyphCount > 0; BacktrackGlyphCount-- )
-        otv_Coverage_validate( table + FT_NEXT_USHORT( p ), valid, -1 );
+        otv_Coverage_validate( table + FT_NEXT_USHORT( p ), otvalid, -1 );
 
       LookaheadGlyphCount = FT_NEXT_USHORT( p );
 
       OTV_LIMIT_CHECK( LookaheadGlyphCount * 2 + 2 );
 
       for ( ; LookaheadGlyphCount > 0; LookaheadGlyphCount-- )
-        otv_Coverage_validate( table + FT_NEXT_USHORT( p ), valid, -1 );
+        otv_Coverage_validate( table + FT_NEXT_USHORT( p ), otvalid, -1 );
 
       GlyphCount = FT_NEXT_USHORT( p );
 
 
       /* Substitute */
       for ( ; GlyphCount > 0; GlyphCount-- )
-        if ( FT_NEXT_USHORT( p ) >= valid->glyph_count )
+        if ( FT_NEXT_USHORT( p ) >= otvalid->glyph_count )
           FT_INVALID_DATA;
 
       break;
   /*************************************************************************/
   /*************************************************************************/
 
-  /* sets valid->type_count  */
-  /* sets valid->type_funcs  */
-  /* sets valid->glyph_count */
+  /* sets otvalid->type_count  */
+  /* sets otvalid->type_funcs  */
+  /* sets otvalid->glyph_count */
 
   FT_LOCAL_DEF( void )
   otv_GSUB_validate( FT_Bytes      table,
                      FT_UInt       glyph_count,
                      FT_Validator  ftvalid )
   {
-    OTV_ValidatorRec  validrec;
-    OTV_Validator     valid = &validrec;
-    FT_Bytes          p     = table;
+    OTV_ValidatorRec  otvalidrec;
+    OTV_Validator     otvalid = &otvalidrec;
+    FT_Bytes          p       = table;
     FT_UInt           ScriptList, FeatureList, LookupList;
 
 
-    valid->root = ftvalid;
+    otvalid->root = ftvalid;
 
     FT_TRACE3(( "validating GSUB table\n" ));
     OTV_INIT;
     FeatureList = FT_NEXT_USHORT( p );
     LookupList  = FT_NEXT_USHORT( p );
 
-    valid->type_count  = 8;
-    valid->type_funcs  = (OTV_Validate_Func*)otv_gsub_validate_funcs;
-    valid->glyph_count = glyph_count;
+    otvalid->type_count  = 8;
+    otvalid->type_funcs  = (OTV_Validate_Func*)otv_gsub_validate_funcs;
+    otvalid->glyph_count = glyph_count;
 
     otv_LookupList_validate( table + LookupList,
-                             valid );
+                             otvalid );
     otv_FeatureList_validate( table + FeatureList, table + LookupList,
-                              valid );
+                              otvalid );
     otv_ScriptList_validate( table + ScriptList, table + FeatureList,
-                             valid );
+                             otvalid );
 
     FT_TRACE4(( "\n" ));
   }
index a616a23..f273be8 100644 (file)
 #define JstfPriorityFunc  otv_JstfPriority_validate
 #define JstfLookupFunc    otv_GPOS_subtable_validate
 
-  /* uses valid->extra1 (GSUB lookup count) */
-  /* uses valid->extra2 (GPOS lookup count) */
-  /* sets valid->extra1 (counter)           */
+  /* uses otvalid->extra1 (GSUB lookup count) */
+  /* uses otvalid->extra2 (GPOS lookup count) */
+  /* sets otvalid->extra1 (counter)           */
 
   static void
   otv_JstfPriority_validate( FT_Bytes       table,
-                             OTV_Validator  valid )
+                             OTV_Validator  otvalid )
   {
     FT_Bytes  p = table;
     FT_UInt   table_size;
 
     OTV_LIMIT_CHECK( 20 );
 
-    gsub_lookup_count = valid->extra1;
-    gpos_lookup_count = valid->extra2;
+    gsub_lookup_count = otvalid->extra1;
+    gpos_lookup_count = otvalid->extra2;
 
     table_size = 20;
 
-    valid->extra1 = gsub_lookup_count;
+    otvalid->extra1 = gsub_lookup_count;
 
     OTV_OPTIONAL_OFFSET( ShrinkageEnableGSUB );
     OTV_SIZE_CHECK( ShrinkageEnableGSUB );
     if ( ShrinkageEnableGSUB )
-      otv_x_ux( table + ShrinkageEnableGSUB, valid );
+      otv_x_ux( table + ShrinkageEnableGSUB, otvalid );
 
     OTV_OPTIONAL_OFFSET( ShrinkageDisableGSUB );
     OTV_SIZE_CHECK( ShrinkageDisableGSUB );
     if ( ShrinkageDisableGSUB )
-      otv_x_ux( table + ShrinkageDisableGSUB, valid );
+      otv_x_ux( table + ShrinkageDisableGSUB, otvalid );
 
-    valid->extra1 = gpos_lookup_count;
+    otvalid->extra1 = gpos_lookup_count;
 
     OTV_OPTIONAL_OFFSET( ShrinkageEnableGPOS );
     OTV_SIZE_CHECK( ShrinkageEnableGPOS );
     if ( ShrinkageEnableGPOS )
-      otv_x_ux( table + ShrinkageEnableGPOS, valid );
+      otv_x_ux( table + ShrinkageEnableGPOS, otvalid );
 
     OTV_OPTIONAL_OFFSET( ShrinkageDisableGPOS );
     OTV_SIZE_CHECK( ShrinkageDisableGPOS );
     if ( ShrinkageDisableGPOS )
-      otv_x_ux( table + ShrinkageDisableGPOS, valid );
+      otv_x_ux( table + ShrinkageDisableGPOS, otvalid );
 
     OTV_OPTIONAL_OFFSET( ShrinkageJstfMax );
     OTV_SIZE_CHECK( ShrinkageJstfMax );
     {
       /* XXX: check lookup types? */
       OTV_NEST2( JstfMax, JstfLookup );
-      OTV_RUN( table + ShrinkageJstfMax, valid );
+      OTV_RUN( table + ShrinkageJstfMax, otvalid );
     }
 
-    valid->extra1 = gsub_lookup_count;
+    otvalid->extra1 = gsub_lookup_count;
 
     OTV_OPTIONAL_OFFSET( ExtensionEnableGSUB );
     OTV_SIZE_CHECK( ExtensionEnableGSUB );
     if ( ExtensionEnableGSUB )
-      otv_x_ux( table + ExtensionEnableGSUB, valid );
+      otv_x_ux( table + ExtensionEnableGSUB, otvalid );
 
     OTV_OPTIONAL_OFFSET( ExtensionDisableGSUB );
     OTV_SIZE_CHECK( ExtensionDisableGSUB );
     if ( ExtensionDisableGSUB )
-      otv_x_ux( table + ExtensionDisableGSUB, valid );
+      otv_x_ux( table + ExtensionDisableGSUB, otvalid );
 
-    valid->extra1 = gpos_lookup_count;
+    otvalid->extra1 = gpos_lookup_count;
 
     OTV_OPTIONAL_OFFSET( ExtensionEnableGPOS );
     OTV_SIZE_CHECK( ExtensionEnableGPOS );
     if ( ExtensionEnableGPOS )
-      otv_x_ux( table + ExtensionEnableGPOS, valid );
+      otv_x_ux( table + ExtensionEnableGPOS, otvalid );
 
     OTV_OPTIONAL_OFFSET( ExtensionDisableGPOS );
     OTV_SIZE_CHECK( ExtensionDisableGPOS );
     if ( ExtensionDisableGPOS )
-      otv_x_ux( table + ExtensionDisableGPOS, valid );
+      otv_x_ux( table + ExtensionDisableGPOS, otvalid );
 
     OTV_OPTIONAL_OFFSET( ExtensionJstfMax );
     OTV_SIZE_CHECK( ExtensionJstfMax );
     {
       /* XXX: check lookup types? */
       OTV_NEST2( JstfMax, JstfLookup );
-      OTV_RUN( table + ExtensionJstfMax, valid );
+      OTV_RUN( table + ExtensionJstfMax, otvalid );
     }
 
-    valid->extra1 = gsub_lookup_count;
-    valid->extra2 = gpos_lookup_count;
+    otvalid->extra1 = gsub_lookup_count;
+    otvalid->extra2 = gpos_lookup_count;
 
     OTV_EXIT;
   }
 
 
-  /* sets valid->extra (glyph count)               */
-  /* sets valid->func1 (otv_JstfPriority_validate) */
+  /* sets otvalid->extra (glyph count)               */
+  /* sets otvalid->func1 (otv_JstfPriority_validate) */
 
   static void
   otv_JstfScript_validate( FT_Bytes       table,
-                           OTV_Validator  valid )
+                           OTV_Validator  otvalid )
   {
     FT_Bytes  p = table;
     FT_UInt   table_size;
     OTV_SIZE_CHECK( ExtGlyph );
     if ( ExtGlyph )
     {
-      valid->extra1 = valid->glyph_count;
+      otvalid->extra1 = otvalid->glyph_count;
       OTV_NEST1( ExtenderGlyph );
-      OTV_RUN( table + ExtGlyph, valid );
+      OTV_RUN( table + ExtGlyph, otvalid );
     }
 
     OTV_SIZE_CHECK( DefJstfLangSys );
     if ( DefJstfLangSys )
     {
       OTV_NEST2( JstfLangSys, JstfPriority );
-      OTV_RUN( table + DefJstfLangSys, valid );
+      OTV_RUN( table + DefJstfLangSys, otvalid );
     }
 
     OTV_LIMIT_CHECK( 6 * JstfLangSysCount );
     {
       p += 4;       /* skip JstfLangSysTag */
 
-      OTV_RUN( table + FT_NEXT_USHORT( p ), valid );
+      OTV_RUN( table + FT_NEXT_USHORT( p ), otvalid );
     }
 
     OTV_EXIT;
   }
 
 
-  /* sets valid->extra1 (GSUB lookup count) */
-  /* sets valid->extra2 (GPOS lookup count) */
-  /* sets valid->glyph_count                */
+  /* sets otvalid->extra1 (GSUB lookup count) */
+  /* sets otvalid->extra2 (GPOS lookup count) */
+  /* sets otvalid->glyph_count                */
 
   FT_LOCAL_DEF( void )
   otv_JSTF_validate( FT_Bytes      table,
                      FT_UInt       glyph_count,
                      FT_Validator  ftvalid )
   {
-    OTV_ValidatorRec  validrec;
-    OTV_Validator     valid = &validrec;
+    OTV_ValidatorRec  otvalidrec;
+    OTV_Validator     otvalid = &otvalidrec;
     FT_Bytes          p     = table;
     FT_UInt           JstfScriptCount;
 
 
-    valid->root = ftvalid;
+    otvalid->root = ftvalid;
+
 
     FT_TRACE3(( "validating JSTF table\n" ));
     OTV_INIT;
     OTV_LIMIT_CHECK( JstfScriptCount * 6 );
 
     if ( gsub )
-      valid->extra1 = otv_GSUBGPOS_get_Lookup_count( gsub );
+      otvalid->extra1 = otv_GSUBGPOS_get_Lookup_count( gsub );
     else
-      valid->extra1 = 0;
+      otvalid->extra1 = 0;
 
     if ( gpos )
-      valid->extra2 = otv_GSUBGPOS_get_Lookup_count( gpos );
+      otvalid->extra2 = otv_GSUBGPOS_get_Lookup_count( gpos );
     else
-      valid->extra2 = 0;
+      otvalid->extra2 = 0;
 
-    valid->glyph_count = glyph_count;
+    otvalid->glyph_count = glyph_count;
 
     /* JstfScriptRecord */
     for ( ; JstfScriptCount > 0; JstfScriptCount-- )
       p += 4;       /* skip JstfScriptTag */
 
       /* JstfScript */
-      otv_JstfScript_validate( table + FT_NEXT_USHORT( p ), valid );
+      otv_JstfScript_validate( table + FT_NEXT_USHORT( p ), otvalid );
     }
 
     FT_TRACE4(( "\n" ));
index 96f841f..d1791f8 100644 (file)
@@ -44,7 +44,7 @@
 
   static void
   otv_MathConstants_validate( FT_Bytes       table,
-                              OTV_Validator  valid )
+                              OTV_Validator  otvalid )
   {
     FT_Bytes  p = table;
     FT_UInt   i;
@@ -66,7 +66,7 @@
       OTV_OPTIONAL_OFFSET( DeviceTableOffset );
       OTV_SIZE_CHECK( DeviceTableOffset );
       if ( DeviceTableOffset )
-        otv_Device_validate( table + DeviceTableOffset, valid );
+        otv_Device_validate( table + DeviceTableOffset, otvalid );
     }
 
     OTV_EXIT;
@@ -84,7 +84,7 @@
 
   static void
   otv_MathItalicsCorrectionInfo_validate( FT_Bytes       table,
-                                          OTV_Validator  valid,
+                                          OTV_Validator  otvalid,
                                           FT_Int         isItalic )
   {
     FT_Bytes  p = table;
     table_size = 4 + 4 * cnt;
 
     OTV_SIZE_CHECK( Coverage );
-    otv_Coverage_validate( table + Coverage, valid, cnt );
+    otv_Coverage_validate( table + Coverage, otvalid, cnt );
 
     for ( i = 0; i < cnt; ++i )
     {
       OTV_OPTIONAL_OFFSET( DeviceTableOffset );
       OTV_SIZE_CHECK( DeviceTableOffset );
       if ( DeviceTableOffset )
-        otv_Device_validate( table + DeviceTableOffset, valid );
+        otv_Device_validate( table + DeviceTableOffset, otvalid );
     }
 
     OTV_EXIT;
 
   static void
   otv_MathKern_validate( FT_Bytes       table,
-                         OTV_Validator  valid )
+                         OTV_Validator  otvalid )
   {
     FT_Bytes  p = table;
     FT_UInt   i, cnt, table_size;
       OTV_OPTIONAL_OFFSET( DeviceTableOffset );
       OTV_SIZE_CHECK( DeviceTableOffset );
       if ( DeviceTableOffset )
-        otv_Device_validate( table + DeviceTableOffset, valid );
+        otv_Device_validate( table + DeviceTableOffset, otvalid );
     }
 
     /* One more Kerning value */
       OTV_OPTIONAL_OFFSET( DeviceTableOffset );
       OTV_SIZE_CHECK( DeviceTableOffset );
       if ( DeviceTableOffset )
-        otv_Device_validate( table + DeviceTableOffset, valid );
+        otv_Device_validate( table + DeviceTableOffset, otvalid );
     }
 
     OTV_EXIT;
 
   static void
   otv_MathKernInfo_validate( FT_Bytes       table,
-                             OTV_Validator  valid )
+                             OTV_Validator  otvalid )
   {
     FT_Bytes  p = table;
     FT_UInt   i, j, cnt, table_size;
     table_size = 4 + 8 * cnt;
 
     OTV_SIZE_CHECK( Coverage );
-    otv_Coverage_validate( table + Coverage, valid, cnt );
+    otv_Coverage_validate( table + Coverage, otvalid, cnt );
 
     for ( i = 0; i < cnt; ++i )
     {
         OTV_OPTIONAL_OFFSET( MKRecordOffset );
         OTV_SIZE_CHECK( MKRecordOffset );
         if ( MKRecordOffset )
-          otv_MathKern_validate( table + MKRecordOffset, valid );
+          otv_MathKern_validate( table + MKRecordOffset, otvalid );
       }
     }
 
 
   static void
   otv_MathGlyphInfo_validate( FT_Bytes       table,
-                              OTV_Validator  valid )
+                              OTV_Validator  otvalid )
   {
     FT_Bytes  p = table;
     FT_UInt   MathItalicsCorrectionInfo, MathTopAccentAttachment;
 
     if ( MathItalicsCorrectionInfo )
       otv_MathItalicsCorrectionInfo_validate(
-        table + MathItalicsCorrectionInfo, valid, TRUE );
+        table + MathItalicsCorrectionInfo, otvalid, TRUE );
 
     /* Italic correction and Top Accent Attachment have the same format */
     if ( MathTopAccentAttachment )
       otv_MathItalicsCorrectionInfo_validate(
-        table + MathTopAccentAttachment, valid, FALSE );
+        table + MathTopAccentAttachment, otvalid, FALSE );
 
     if ( ExtendedShapeCoverage )
     {
       OTV_NAME_ENTER( "ExtendedShapeCoverage" );
-      otv_Coverage_validate( table + ExtendedShapeCoverage, valid, -1 );
+      otv_Coverage_validate( table + ExtendedShapeCoverage, otvalid, -1 );
       OTV_EXIT;
     }
 
     if ( MathKernInfo )
-      otv_MathKernInfo_validate( table + MathKernInfo, valid );
+      otv_MathKernInfo_validate( table + MathKernInfo, otvalid );
 
     OTV_EXIT;
   }
 
   static void
   otv_GlyphAssembly_validate( FT_Bytes       table,
-                              OTV_Validator  valid )
+                              OTV_Validator  otvalid )
   {
     FT_Bytes  p = table;
     FT_UInt   pcnt, table_size;
 
     OTV_SIZE_CHECK( DeviceTableOffset );
     if ( DeviceTableOffset )
-      otv_Device_validate( table + DeviceTableOffset, valid );
+      otv_Device_validate( table + DeviceTableOffset, otvalid );
 
     for ( i = 0; i < pcnt; ++i )
     {
 
 
       gid = FT_NEXT_USHORT( p );
-      if ( gid >= valid->glyph_count )
+      if ( gid >= otvalid->glyph_count )
         FT_INVALID_GLYPH_ID;
       p += 2*4;             /* skip the Start, End, Full, and Flags fields */
     }
 
   static void
   otv_MathGlyphConstruction_validate( FT_Bytes       table,
-                                      OTV_Validator  valid )
+                                      OTV_Validator  otvalid )
   {
     FT_Bytes  p = table;
     FT_UInt   vcnt, table_size;
 
 
       gid = FT_NEXT_USHORT( p );
-      if ( gid >= valid->glyph_count )
+      if ( gid >= otvalid->glyph_count )
         FT_INVALID_GLYPH_ID;
       p += 2;                          /* skip the size */
     }
 
     OTV_SIZE_CHECK( GlyphAssembly );
     if ( GlyphAssembly )
-      otv_GlyphAssembly_validate( table+GlyphAssembly, valid );
+      otv_GlyphAssembly_validate( table+GlyphAssembly, otvalid );
 
     /* OTV_EXIT; */
   }
 
   static void
   otv_MathVariants_validate( FT_Bytes       table,
-                             OTV_Validator  valid )
+                             OTV_Validator  otvalid )
   {
     FT_Bytes  p = table;
     FT_UInt   vcnt, hcnt, i, table_size;
 
     OTV_SIZE_CHECK( VCoverage );
     if ( VCoverage )
-      otv_Coverage_validate( table + VCoverage, valid, vcnt );
+      otv_Coverage_validate( table + VCoverage, otvalid, vcnt );
 
     OTV_SIZE_CHECK( HCoverage );
     if ( HCoverage )
-      otv_Coverage_validate( table + HCoverage, valid, hcnt );
+      otv_Coverage_validate( table + HCoverage, otvalid, hcnt );
 
     for ( i = 0; i < vcnt; ++i )
     {
       OTV_OPTIONAL_OFFSET( Offset );
       OTV_SIZE_CHECK( Offset );
-      otv_MathGlyphConstruction_validate( table + Offset, valid );
+      otv_MathGlyphConstruction_validate( table + Offset, otvalid );
     }
 
     for ( i = 0; i < hcnt; ++i )
     {
       OTV_OPTIONAL_OFFSET( Offset );
       OTV_SIZE_CHECK( Offset );
-      otv_MathGlyphConstruction_validate( table + Offset, valid );
+      otv_MathGlyphConstruction_validate( table + Offset, otvalid );
     }
 
     OTV_EXIT;
   /*************************************************************************/
   /*************************************************************************/
 
-  /* sets valid->glyph_count */
+  /* sets otvalid->glyph_count */
 
   FT_LOCAL_DEF( void )
   otv_MATH_validate( FT_Bytes      table,
                      FT_UInt       glyph_count,
                      FT_Validator  ftvalid )
   {
-    OTV_ValidatorRec  validrec;
-    OTV_Validator     valid = &validrec;
-    FT_Bytes          p     = table;
+    OTV_ValidatorRec  otvalidrec;
+    OTV_Validator     otvalid = &otvalidrec;
+    FT_Bytes          p       = table;
     FT_UInt           MathConstants, MathGlyphInfo, MathVariants;
 
 
-    valid->root = ftvalid;
+    otvalid->root = ftvalid;
 
     FT_TRACE3(( "validating MATH table\n" ));
     OTV_INIT;
     MathGlyphInfo = FT_NEXT_USHORT( p );
     MathVariants  = FT_NEXT_USHORT( p );
 
-    valid->glyph_count = glyph_count;
+    otvalid->glyph_count = glyph_count;
 
     otv_MathConstants_validate( table + MathConstants,
-                                valid );
+                                otvalid );
     otv_MathGlyphInfo_validate( table + MathGlyphInfo,
-                                valid );
+                                otvalid );
     otv_MathVariants_validate ( table + MathVariants,
-                                valid );
+                                otvalid );
 
     FT_TRACE4(( "\n" ));
   }
index 748cbca..96f6912 100644 (file)
@@ -2,7 +2,7 @@
 
     FreeType font driver for pcf files
 
-    Copyright (C) 2000-2004, 2006-2011, 2013 by
+    Copyright (C) 2000-2004, 2006-2011, 2013, 2014 by
     Francesco Zappa Nardelli
 
 Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -189,7 +189,7 @@ THE SOFTWARE.
   }
 
 
-  FT_CALLBACK_TABLE_DEF
+  static
   const FT_CMap_ClassRec  pcf_cmap_class =
   {
     sizeof ( PCF_CMapRec ),
@@ -494,7 +494,13 @@ THE SOFTWARE.
 
     FT_TRACE1(( "PCF_Glyph_Load: glyph index %d\n", glyph_index ));
 
-    if ( !face || glyph_index >= (FT_UInt)face->root.num_glyphs )
+    if ( !face )
+    {
+      error = FT_THROW( Invalid_Face_Handle );
+      goto Exit;
+    }
+
+    if ( glyph_index >= (FT_UInt)face->root.num_glyphs )
     {
       error = FT_THROW( Invalid_Argument );
       goto Exit;
index d936c58..a29a9e3 100644 (file)
@@ -2,7 +2,7 @@
 
     FreeType font driver for pcf fonts
 
-  Copyright 2000-2010, 2012, 2013 by
+  Copyright 2000-2010, 2012-2014 by
   Francesco Zappa Nardelli
 
 Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -78,7 +78,7 @@ THE SOFTWARE.
     FT_FRAME_START( 16  ),
       FT_FRAME_ULONG_LE( type ),
       FT_FRAME_ULONG_LE( format ),
-      FT_FRAME_ULONG_LE( size ),
+      FT_FRAME_ULONG_LE( size ),   /* rounded up to a multiple of 4 */
       FT_FRAME_ULONG_LE( offset ),
     FT_FRAME_END
   };
@@ -95,9 +95,11 @@ THE SOFTWARE.
     FT_Memory  memory = FT_FACE( face )->memory;
     FT_UInt    n;
 
+    FT_ULong   size;
 
-    if ( FT_STREAM_SEEK ( 0 )                          ||
-         FT_STREAM_READ_FIELDS ( pcf_toc_header, toc ) )
+
+    if ( FT_STREAM_SEEK( 0 )                          ||
+         FT_STREAM_READ_FIELDS( pcf_toc_header, toc ) )
       return FT_THROW( Cannot_Open_Resource );
 
     if ( toc->version != PCF_FILE_VERSION                 ||
@@ -144,13 +146,62 @@ THE SOFTWARE.
 
         if ( ( tables[i].size   > tables[i + 1].offset )                  ||
              ( tables[i].offset > tables[i + 1].offset - tables[i].size ) )
-          return FT_THROW( Invalid_Offset );
+        {
+          error = FT_THROW( Invalid_Offset );
+          goto Exit;
+        }
       }
 
       if ( !have_change )
         break;
     }
 
+    /*
+     *  We now check whether the `size' and `offset' values are reasonable:
+     *  `offset' + `size' must not exceed the stream size.
+     *
+     *  Note, however, that X11's `pcfWriteFont' routine (used by the
+     *  `bdftopcf' program to create PDF font files) has two special
+     *  features.
+     *
+     *  - It always assigns the accelerator table a size of 100 bytes in the
+     *    TOC, regardless of its real size, which can vary between 34 and 72
+     *    bytes.
+     *
+     *  - Due to the way the routine is designed, it ships out the last font
+     *    table with its real size, ignoring the TOC's size value.  Since
+     *    the TOC size values are always rounded up to a multiple of 4, the
+     *    difference can be up to three bytes for all tables except the
+     *    accelerator table, for which the difference can be as large as 66
+     *    bytes.
+     *
+     */
+
+    tables = face->toc.tables;
+    size   = stream->size;
+
+    for ( n = 0; n < toc->count - 1; n++ )
+    {
+      /* we need two checks to avoid overflow */
+      if ( ( tables->size   > size                ) ||
+           ( tables->offset > size - tables->size ) )
+      {
+        error = FT_THROW( Invalid_Table );
+        goto Exit;
+      }
+      tables++;
+    }
+
+    /* only check `tables->offset' for last table element ... */
+    if ( ( tables->offset > size ) )
+    {
+      error = FT_THROW( Invalid_Table );
+      goto Exit;
+    }
+    /* ... and adjust `tables->size' to the real value if necessary */
+    if ( tables->size > size - tables->offset )
+      tables->size = size - tables->offset;
+
 #ifdef FT_DEBUG_LEVEL_TRACE
 
     {
@@ -631,24 +682,40 @@ THE SOFTWARE.
       return FT_THROW( Out_Of_Memory );
 
     metrics = face->metrics;
-    for ( i = 0; i < nmetrics; i++ )
+    for ( i = 0; i < nmetrics; i++, metrics++ )
     {
-      error = pcf_get_metric( stream, format, metrics + i );
+      error = pcf_get_metric( stream, format, metrics );
 
-      metrics[i].bits = 0;
+      metrics->bits = 0;
 
       FT_TRACE5(( "  idx %d: width=%d, "
                   "lsb=%d, rsb=%d, ascent=%d, descent=%d, swidth=%d\n",
                   i,
-                  ( metrics + i )->characterWidth,
-                  ( metrics + i )->leftSideBearing,
-                  ( metrics + i )->rightSideBearing,
-                  ( metrics + i )->ascent,
-                  ( metrics + i )->descent,
-                  ( metrics + i )->attributes ));
+                  metrics->characterWidth,
+                  metrics->leftSideBearing,
+                  metrics->rightSideBearing,
+                  metrics->ascent,
+                  metrics->descent,
+                  metrics->attributes ));
 
       if ( error )
         break;
+
+      /* sanity checks -- those values are used in `PCF_Glyph_Load' to     */
+      /* compute a glyph's bitmap dimensions, thus setting them to zero in */
+      /* case of an error disables this particular glyph only              */
+      if ( metrics->rightSideBearing < metrics->leftSideBearing ||
+           metrics->ascent + metrics->descent < 0               )
+      {
+        metrics->characterWidth   = 0;
+        metrics->leftSideBearing  = 0;
+        metrics->rightSideBearing = 0;
+        metrics->ascent           = 0;
+        metrics->descent          = 0;
+
+        FT_TRACE0(( "pcf_get_metrics:"
+                    " invalid metrics for glyph %d\n", i ));
+      }
     }
 
     if ( error )
@@ -699,8 +766,8 @@ THE SOFTWARE.
 
     FT_TRACE4(( "  number of bitmaps: %d\n", nbitmaps ));
 
-    /* XXX: PCF_Face->nmetrics is singed FT_Long, see pcf.h */
-    if ( face->nmetrics < 0 || nbitmaps != ( FT_ULong )face->nmetrics )
+    /* XXX: PCF_Face->nmetrics is signed FT_Long, see pcf.h */
+    if ( face->nmetrics < 0 || nbitmaps != (FT_ULong)face->nmetrics )
       return FT_THROW( Invalid_File_Format );
 
     if ( FT_NEW_ARRAY( offsets, nbitmaps ) )
@@ -812,6 +879,15 @@ THE SOFTWARE.
     if ( !PCF_FORMAT_MATCH( format, PCF_DEFAULT_FORMAT ) )
       return FT_THROW( Invalid_File_Format );
 
+    /* sanity checks */
+    if ( firstCol < 0       ||
+         firstCol > lastCol ||
+         lastCol  > 0xFF    ||
+         firstRow < 0       ||
+         firstRow > lastRow ||
+         lastRow  > 0xFF    )
+      return FT_THROW( Invalid_Table );
+
     FT_TRACE4(( "pdf_get_encodings:\n" ));
 
     FT_TRACE4(( "  firstCol %d, lastCol %d, firstRow %d, lastRow %d\n",
index 1f05640..90ba010 100644 (file)
 
 
   FT_CALLBACK_DEF( FT_Error )
-  pfr_cmap_init( PFR_CMap  cmap )
+  pfr_cmap_init( PFR_CMap    cmap,
+                 FT_Pointer  pointer )
   {
     FT_Error  error = FT_Err_Ok;
     PFR_Face  face  = (PFR_Face)FT_CMAP_FACE( cmap );
 
+    FT_UNUSED( pointer );
+
 
     cmap->num_chars = face->phy_font.num_chars;
     cmap->chars     = face->phy_font.chars;
index 4c43947..db66281 100644 (file)
@@ -4,7 +4,7 @@
 /*                                                                         */
 /*    FreeType PFR driver interface (body).                                */
 /*                                                                         */
-/*  Copyright 2002-2004, 2006, 2008, 2010, 2011, 2013 by                   */
+/*  Copyright 2002-2004, 2006, 2008, 2010, 2011, 2013, 2014 by             */
 /*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
 /*                                                                         */
 /*  This file is part of the FreeType project, and may only be used,       */
@@ -37,7 +37,7 @@
     PFR_PhyFont  phys = &face->phy_font;
 
 
-    pfr_face_get_kerning( pfrface, left, right, avector );
+    (void)pfr_face_get_kerning( pfrface, left, right, avector );
 
     /* convert from metrics to outline units when necessary */
     if ( phys->outline_resolution != phys->metrics_resolution )
   }
 
 
-  FT_CALLBACK_TABLE_DEF
+  static
   const FT_Service_PfrMetricsRec  pfr_metrics_service_rec =
   {
     pfr_get_metrics,
index 97c130a..f68d016 100644 (file)
     if ( header->signature  != 0x50465230L ||   /* "PFR0" */
          header->version     > 4           ||
          header->header_size < 58          ||
-         header->signature2 != 0x0d0a      )    /* CR/LF  */
+         header->signature2 != 0x0D0A      )    /* CR/LF  */
     {
       result = 0;
     }
index 194d2df..0c89242 100644 (file)
@@ -4,7 +4,7 @@
 /*                                                                         */
 /*    FreeType PFR object methods (body).                                  */
 /*                                                                         */
-/*  Copyright 2002-2008, 2010-2011, 2013 by                                */
+/*  Copyright 2002-2008, 2010-2011, 2013, 2014 by                          */
 /*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
 /*                                                                         */
 /*  This file is part of the FreeType project, and may only be used,       */
@@ -23,6 +23,7 @@
 #include "pfrsbit.h"
 #include FT_OUTLINE_H
 #include FT_INTERNAL_DEBUG_H
+#include FT_INTERNAL_CALC_H
 #include FT_TRUETYPE_IDS_H
 
 #include "pfrerror.h"
       {
         FT_UInt    count       = item->pair_count;
         FT_UInt    size        = item->pair_size;
-        FT_UInt    power       = (FT_UInt)ft_highpow2( (FT_UInt32)count );
+        FT_UInt    power       = 1 << FT_MSB( count );
         FT_UInt    probe       = power * size;
         FT_UInt    extra       = count - power;
         FT_Byte*   base        = stream->cursor;
index 2da1500..979bf78 100644 (file)
@@ -59,7 +59,7 @@
 
     if ( !decreasing )
     {
-      writer->line += writer->pitch * ( target->rows-1 );
+      writer->line += writer->pitch * ( target->rows - 1 );
       writer->pitch = -writer->pitch;
     }
   }
        *      which causes a size truncation, because truncated
        *      size properties makes bitmap glyph broken.
        */
-      if ( xpos > FT_INT_MAX || ( ypos + ysize ) > FT_INT_MAX )
+      if ( xpos > FT_INT_MAX  || xpos < FT_INT_MIN         ||
+           ysize > FT_INT_MAX || ypos + ysize > FT_INT_MAX ||
+           ypos + (FT_Long)ysize < FT_INT_MIN )
       {
         FT_TRACE1(( "pfr_slot_load_bitmap:" ));
         FT_TRACE1(( "huge bitmap glyph %dx%d over FT_GlyphSlot\n",
index d0d8861..22e8cf2 100644 (file)
       if ( IS_PS_SPACE( *p ) || *p OP 0x80 )
         break;
 
-      c = ft_char_table[*p & 0x7f];
+      c = ft_char_table[*p & 0x7F];
 
       if ( c < 0 || c >= base )
         break;
         if ( IS_PS_SPACE( *p ) || *p OP 0x80 )
           break;
 
-        c = ft_char_table[*p & 0x7f];
+        c = ft_char_table[*p & 0x7F];
 
         if ( c < 0 || c >= 10 )
           break;
 
-        if ( decimal < 0xCCCCCCCL )
+        /* only add digit if we don't overflow */
+        if ( divider < 0xCCCCCCCL && decimal < 0xCCCCCCCL )
         {
           decimal = decimal * 10 + c;
 
       if ( *p OP 0x80 )
         break;
 
-      c = ft_char_table[*p & 0x7f];
+      c = ft_char_table[*p & 0x7F];
 
       if ( (unsigned)c >= 16 )
         break;
index b4b7d45..7ec3b4c 100644 (file)
     {
       parser->cursor = token->start;
       parser->limit  = token->limit;
-      ps_parser_load_field( parser, &fieldrec, objects, max_objects, 0 );
+
+      error = ps_parser_load_field( parser,
+                                    &fieldrec,
+                                    objects,
+                                    max_objects,
+                                    0 );
+      if ( error )
+        break;
+
       fieldrec.offset += fieldrec.size;
     }
 
index 9e5bd34..fb1353a 100644 (file)
 
 
   FT_CALLBACK_DEF( FT_Error )
-  t1_cmap_standard_init( T1_CMapStd  cmap )
+  t1_cmap_standard_init( T1_CMapStd  cmap,
+                         FT_Pointer  pointer )
   {
+    FT_UNUSED( pointer );
+
+
     t1_cmap_std_init( cmap, 0 );
     return 0;
   }
 
 
   FT_CALLBACK_DEF( FT_Error )
-  t1_cmap_expert_init( T1_CMapStd  cmap )
+  t1_cmap_expert_init( T1_CMapStd  cmap,
+                       FT_Pointer  pointer )
   {
+    FT_UNUSED( pointer );
+
+
     t1_cmap_std_init( cmap, 1 );
     return 0;
   }
 
 
   FT_CALLBACK_DEF( FT_Error )
-  t1_cmap_custom_init( T1_CMapCustom  cmap )
+  t1_cmap_custom_init( T1_CMapCustom  cmap,
+                       FT_Pointer     pointer )
   {
     T1_Face      face     = (T1_Face)FT_CMAP_FACE( cmap );
     T1_Encoding  encoding = &face->type1.encoding;
 
+    FT_UNUSED( pointer );
+
 
     cmap->first   = encoding->code_first;
     cmap->count   = (FT_UInt)( encoding->code_last - cmap->first );
 
 
   FT_CALLBACK_DEF( FT_Error )
-  t1_cmap_unicode_init( PS_Unicodes  unicodes )
+  t1_cmap_unicode_init( PS_Unicodes  unicodes,
+                        FT_Pointer   pointer )
   {
     T1_Face             face    = (T1_Face)FT_CMAP_FACE( unicodes );
     FT_Memory           memory  = FT_FACE_MEMORY( face );
     FT_Service_PsCMaps  psnames = (FT_Service_PsCMaps)face->psnames;
 
+    FT_UNUSED( pointer );
+
 
     return psnames->unicodes_init( memory,
                                    unicodes,
index 6ce370b..d67a05e 100644 (file)
@@ -4,7 +4,7 @@
 /*                                                                         */
 /*    PostScript Type 1 decoding routines (body).                          */
 /*                                                                         */
-/*  Copyright 2000-2013 by                                                 */
+/*  Copyright 2000-2014 by                                                 */
 /*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
 /*                                                                         */
 /*  This file is part of the FreeType project, and may only be used,       */
               goto Syntax_Error;
 
             /* apply hints to the loaded glyph outline now */
-            hinter->apply( hinter->hints,
-                           builder->current,
-                           (PSH_Globals)builder->hints_globals,
-                           decoder->hint_mode );
+            error = hinter->apply( hinter->hints,
+                                   builder->current,
+                                   (PSH_Globals)builder->hints_globals,
+                                   decoder->hint_mode );
+            if ( error )
+              goto Fail;
           }
 
           /* add current outline to the glyph slot */
index f75bae4..1bcc481 100644 (file)
@@ -5,7 +5,7 @@
 /*    PostScript hinter global hinting management (body).                  */
 /*    Inspired by the new auto-hinter module.                              */
 /*                                                                         */
-/*  Copyright 2001-2004, 2006, 2010, 2012, 2013 by                         */
+/*  Copyright 2001-2004, 2006, 2010, 2012-2014 by                          */
 /*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
 /*                                                                         */
 /*  This file is part of the FreeType project, and may only be used        */
   }
 
 
-  FT_LOCAL_DEF( FT_Error )
+  FT_LOCAL_DEF( void )
   psh_globals_set_scale( PSH_Globals  globals,
                          FT_Fixed     x_scale,
                          FT_Fixed     y_scale,
       psh_globals_scale_widths( globals, 1 );
       psh_blues_scale_zones( &globals->blues, y_scale, y_delta );
     }
-
-    return 0;
   }
 
 
index c511626..94d972a 100644 (file)
@@ -4,7 +4,7 @@
 /*                                                                         */
 /*    PostScript hinter global hinting management.                         */
 /*                                                                         */
-/*  Copyright 2001, 2002, 2003 by                                          */
+/*  Copyright 2001, 2002, 2003, 2014 by                                    */
 /*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
 /*                                                                         */
 /*  This file is part of the FreeType project, and may only be used,       */
@@ -167,7 +167,7 @@ FT_BEGIN_HEADER
                             FT_Int         org_width );
 #endif
 
-  FT_LOCAL( FT_Error )
+  FT_LOCAL( void )
   psh_globals_set_scale( PSH_Globals  globals,
                          FT_Fixed     x_scale,
                          FT_Fixed     y_scale,
index cd66ea8..73a18ff 100644 (file)
@@ -4,7 +4,7 @@
 /*                                                                         */
 /*    FreeType PostScript hints recorder (body).                           */
 /*                                                                         */
-/*  Copyright 2001-2004, 2007, 2009, 2013 by                               */
+/*  Copyright 2001-2004, 2007, 2009, 2013, 2014 by                         */
 /*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
 /*                                                                         */
 /*  This file is part of the FreeType project, and may only be used,       */
   }
 
 
-  FT_LOCAL( FT_Error )
+  FT_LOCAL( void )
   ps_hints_init( PS_Hints   hints,
                  FT_Memory  memory )
   {
     FT_MEM_ZERO( hints, sizeof ( *hints ) );
     hints->memory = memory;
-    return FT_Err_Ok;
   }
 
 
index dcb3197..a88fe6e 100644 (file)
@@ -4,7 +4,7 @@
 /*                                                                         */
 /*    Postscript (Type1/Type2) hints recorder (specification).             */
 /*                                                                         */
-/*  Copyright 2001, 2002, 2003, 2006, 2008 by                              */
+/*  Copyright 2001, 2002, 2003, 2006, 2008, 2014 by                        */
 /*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
 /*                                                                         */
 /*  This file is part of the FreeType project, and may only be used,       */
@@ -141,7 +141,7 @@ FT_BEGIN_HEADER
   /* */
 
   /* initialize hints recorder */
-  FT_LOCAL( FT_Error )
+  FT_LOCAL( void )
   ps_hints_init( PS_Hints   hints,
                  FT_Memory  memory );
 
index 0a5bcb7..42c9aff 100644 (file)
@@ -4,7 +4,7 @@
 /*                                                                         */
 /*    PSNames module implementation (body).                                */
 /*                                                                         */
-/*  Copyright 1996-2003, 2005-2008, 2012, 2013 by                          */
+/*  Copyright 1996-2003, 2005-2008, 2012-2014 by                           */
 /*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
 /*                                                                         */
 /*  This file is part of the FreeType project, and may only be used,       */
   psnames_get_service( FT_Module    module,
                        const char*  service_id )
   {
-    /* PSCMAPS_SERVICES_GET derefers `library' in PIC mode */
+    /* PSCMAPS_SERVICES_GET dereferences `library' in PIC mode */
 #ifdef FT_CONFIG_OPTION_PIC
     FT_Library  library;
 
index ddecc80..b06ac33 100644 (file)
     Long   e1, e2;
     Byte*  target;
 
+    Int  dropOutControl = left->flags & 7;
+
     FT_UNUSED( y );
     FT_UNUSED( left );
     FT_UNUSED( right );
 
     e1 = TRUNC( CEILING( x1 ) );
 
-    if ( x2 - x1 - ras.precision <= ras.precision_jitter )
+    if ( dropOutControl != 2                             &&
+         x2 - x1 - ras.precision <= ras.precision_jitter )
       e2 = e1;
     else
       e2 = TRUNC( FLOOR( x2 ) );
 
         e1 = TRUNC( e1 );
 
-        if ( e1 >= 0 && e1 < ras.target.rows )
+        if ( e1 >= 0 && (ULong)e1 < ras.target.rows )
         {
           PByte  p;
 
         /* bounding box instead                                           */
         if ( pxl < 0 )
           pxl = e1;
-        else if ( TRUNC( pxl ) >= ras.target.rows )
+        else if ( (ULong)( TRUNC( pxl ) ) >= ras.target.rows )
           pxl = e2;
 
         /* check that the other pixel isn't set */
         if ( ras.target.pitch > 0 )
           bits += ( ras.target.rows - 1 ) * ras.target.pitch;
 
-        if ( e1 >= 0              &&
-             e1 < ras.target.rows &&
-             *bits & f1           )
+        if ( e1 >= 0                     &&
+             (ULong)e1 < ras.target.rows &&
+             *bits & f1                  )
           return;
       }
       else
 
     e1 = TRUNC( pxl );
 
-    if ( e1 >= 0 && e1 < ras.target.rows )
+    if ( e1 >= 0 && (ULong)e1 < ras.target.rows )
     {
       bits -= e1 * ras.target.pitch;
       if ( ras.target.pitch > 0 )
   }
 
 
-  static void
+  static int
   ft_black_set_mode( black_PRaster  raster,
                      unsigned long  mode,
                      const char*    palette )
     FT_UNUSED( palette );
 
 #endif
+
+    return 0;
   }
 
 
index 878de1f..9bfcc2a 100644 (file)
@@ -4,7 +4,7 @@
 /*                                                                         */
 /*    PNG Bitmap glyph support.                                            */
 /*                                                                         */
-/*  Copyright 2013 by Google, Inc.                                         */
+/*  Copyright 2013, 2014 by Google, Inc.                                   */
 /*  Written by Stuart Gill and Behdad Esfahbod.                            */
 /*                                                                         */
 /*  This file is part of the FreeType project, and may only be used,       */
 
     *error = FT_THROW( Out_Of_Memory );
 #ifdef PNG_SETJMP_SUPPORTED
-    longjmp( png_jmpbuf( png ), 1 );
+    ft_longjmp( png_jmpbuf( png ), 1 );
 #endif
     /* if we get here, then we have no choice but to abort ... */
   }
       goto Exit;
     }
 
-    if ( !populate_map_and_metrics                   &&
-         ( x_offset + metrics->width  > map->width ||
-           y_offset + metrics->height > map->rows  ||
-           pix_bits != 32                          ||
-           map->pixel_mode != FT_PIXEL_MODE_BGRA   ) )
+    if ( !populate_map_and_metrics                            &&
+         ( (FT_UInt)x_offset + metrics->width  > map->width ||
+           (FT_UInt)y_offset + metrics->height > map->rows  ||
+           pix_bits != 32                                   ||
+           map->pixel_mode != FT_PIXEL_MODE_BGRA            ) )
     {
       error = FT_THROW( Invalid_Argument );
       goto Exit;
       map->pitch      = map->width * 4;
       map->num_grays  = 256;
 
+      /* reject too large bitmaps similarly to the rasterizer */
+      if ( map->rows > 0x7FFF || map->width > 0x7FFF )
+      {
+        error = FT_THROW( Array_Too_Large );
+        goto DestroyExit;
+      }
+
+      /* this doesn't overflow: 0x7FFF * 0x7FFF * 4 < 2^32 */
       size = map->rows * map->pitch;
 
       error = ft_glyphslot_alloc_bitmap( slot, size );
index e4fcda5..badb159 100644 (file)
 
     switch ( tag )
     {
-    case ft_sfnt_head:
+    case FT_SFNT_HEAD:
       table = &face->header;
       break;
 
-    case ft_sfnt_hhea:
+    case FT_SFNT_HHEA:
       table = &face->horizontal;
       break;
 
-    case ft_sfnt_vhea:
-      table = face->vertical_info ? &face->vertical : 0;
+    case FT_SFNT_VHEA:
+      table = face->vertical_info ? &face->vertical : NULL;
       break;
 
-    case ft_sfnt_os2:
-      table = face->os2.version == 0xFFFFU ? 0 : &face->os2;
+    case FT_SFNT_OS2:
+      table = face->os2.version == 0xFFFFU ? NULL : &face->os2;
       break;
 
-    case ft_sfnt_post:
+    case FT_SFNT_POST:
       table = &face->postscript;
       break;
 
-    case ft_sfnt_maxp:
+    case FT_SFNT_MAXP:
       table = &face->max_profile;
       break;
 
-    case ft_sfnt_pclt:
-      table = face->pclt.Version ? &face->pclt : 0;
+    case FT_SFNT_PCLT:
+      table = face->pclt.Version ? &face->pclt : NULL;
       break;
 
     default:
-      table = 0;
+      table = NULL;
     }
 
     return table;
   sfnt_get_interface( FT_Module    module,
                       const char*  module_interface )
   {
-    /* SFNT_SERVICES_GET derefers `library' in PIC mode */
+    /* SFNT_SERVICES_GET dereferences `library' in PIC mode */
 #ifdef FT_CONFIG_OPTION_PIC
     FT_Library  library;
 
index a31c77c..70b988d 100644 (file)
@@ -4,7 +4,7 @@
 /*                                                                         */
 /*    SFNT object management (base).                                       */
 /*                                                                         */
-/*  Copyright 1996-2008, 2010-2013 by                                      */
+/*  Copyright 1996-2008, 2010-2014 by                                      */
 /*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
 /*                                                                         */
 /*  This file is part of the FreeType project, and may only be used,       */
   }
 
 
-#define WRITE_BYTE( p, v )     \
-          do                   \
-          {                    \
-            *(p)++ = (v) >> 0; \
-                               \
+#define WRITE_USHORT( p, v )                \
+          do                                \
+          {                                 \
+            *(p)++ = (FT_Byte)( (v) >> 8 ); \
+            *(p)++ = (FT_Byte)( (v) >> 0 ); \
+                                            \
           } while ( 0 )
 
-#define WRITE_USHORT( p, v )   \
-          do                   \
-          {                    \
-            *(p)++ = (v) >> 8; \
-            *(p)++ = (v) >> 0; \
-                               \
-          } while ( 0 )
-
-#define WRITE_ULONG( p, v )     \
-          do                    \
-          {                     \
-            *(p)++ = (v) >> 24; \
-            *(p)++ = (v) >> 16; \
-            *(p)++ = (v) >>  8; \
-            *(p)++ = (v) >>  0; \
-                                \
+#define WRITE_ULONG( p, v )                  \
+          do                                 \
+          {                                  \
+            *(p)++ = (FT_Byte)( (v) >> 24 ); \
+            *(p)++ = (FT_Byte)( (v) >> 16 ); \
+            *(p)++ = (FT_Byte)( (v) >>  8 ); \
+            *(p)++ = (FT_Byte)( (v) >>  0 ); \
+                                             \
           } while ( 0 )
 
 
 
 
       if ( table->Offset != woff_offset                         ||
-           table->Offset + table->CompLength > woff.length      ||
-           sfnt_offset + table->OrigLength > woff.totalSfntSize ||
+           table->CompLength > woff.length                      ||
+           table->Offset > woff.length - table->CompLength      ||
+           table->OrigLength > woff.totalSfntSize               ||
+           sfnt_offset > woff.totalSfntSize - table->OrigLength ||
            table->CompLength > table->OrigLength                )
       {
         error = FT_THROW( Invalid_Table );
       }
       else
       {
+#ifdef FT_CONFIG_OPTION_USE_ZLIB
+
         /* Uncompress with zlib. */
         FT_ULong  output_len = table->OrigLength;
 
           error = FT_THROW( Invalid_Table );
           goto Exit;
         }
+
+#else /* !FT_CONFIG_OPTION_USE_ZLIB */
+
+        error = FT_THROW( Unimplemented_Feature );
+        goto Exit;
+
+#endif /* !FT_CONFIG_OPTION_USE_ZLIB */
       }
 
       FT_FRAME_EXIT();
   }
 
 
-#undef WRITE_BYTE
 #undef WRITE_USHORT
 #undef WRITE_ULONG
 
     if ( is_apple_sbix )
       has_outline = FALSE;
 
-
     /* if this font doesn't contain outlines, we try to load */
     /* a `bhed' table                                        */
     if ( !has_outline && sfnt->load_bhed )
index c717f5f..f54de70 100644 (file)
     p      = table + 2;           /* skip format */
     length = TT_NEXT_USHORT( p );
 
-    if ( length < 16 )
-      FT_INVALID_TOO_SHORT;
-
     /* in certain fonts, the `length' field is invalid and goes */
     /* out of bound.  We try to correct this here...            */
     if ( table + length > valid->limit )
       length = (FT_UInt)( valid->limit - table );
     }
 
+    if ( length < 16 )
+      FT_INVALID_TOO_SHORT;
+
     p        = table + 6;
     num_segs = TT_NEXT_USHORT( p );   /* read segCountX2 */
 
     p          = is32  + 8192;          /* skip `is32' array */
     num_groups = TT_NEXT_ULONG( p );
 
-    if ( p + num_groups * 12 > valid->limit )
+    /* p + num_groups * 12 > valid->limit ? */
+    if ( num_groups > (FT_UInt32)( valid->limit - p ) / 12 )
       FT_INVALID_TOO_SHORT;
 
     /* check groups, they must be in increasing order */
 
         if ( valid->level >= FT_VALIDATE_TIGHT )
         {
-          if ( start_id + end - start >= TT_VALID_GLYPH_COUNT( valid ) )
+          FT_UInt32  d = end - start;
+
+
+          /* start_id + end - start >= TT_VALID_GLYPH_COUNT( valid ) ? */
+          if ( d > TT_VALID_GLYPH_COUNT( valid )             ||
+               start_id >= TT_VALID_GLYPH_COUNT( valid ) - d )
             FT_INVALID_GLYPH_ID;
 
           count = (FT_UInt32)( end - start + 1 );
     count  = TT_NEXT_ULONG( p );
 
     if ( length > (FT_ULong)( valid->limit - table ) ||
-         length < 20 + count * 2                     )
+         /* length < 20 + count * 2 ? */
+         length < 20                                 ||
+         ( length - 20 ) / 2 < count                 )
       FT_INVALID_TOO_SHORT;
 
     /* check glyph indices */
     num_groups = TT_NEXT_ULONG( p );
 
     if ( length > (FT_ULong)( valid->limit - table ) ||
-         length < 16 + 12 * num_groups               )
+         /* length < 16 + 12 * num_groups ? */
+         length < 16                                 ||
+         ( length - 16 ) / 12 < num_groups           )
       FT_INVALID_TOO_SHORT;
 
     /* check groups, they must be in increasing order */
 
         if ( valid->level >= FT_VALIDATE_TIGHT )
         {
-          if ( start_id + end - start >= TT_VALID_GLYPH_COUNT( valid ) )
+          FT_UInt32  d = end - start;
+
+
+          /* start_id + end - start >= TT_VALID_GLYPH_COUNT( valid ) ? */
+          if ( d > TT_VALID_GLYPH_COUNT( valid )             ||
+               start_id >= TT_VALID_GLYPH_COUNT( valid ) - d )
             FT_INVALID_GLYPH_ID;
         }
 
     num_groups = TT_NEXT_ULONG( p );
 
     if ( length > (FT_ULong)( valid->limit - table ) ||
-         length < 16 + 12 * num_groups               )
+         /* length < 16 + 12 * num_groups ? */
+         length < 16                                 ||
+         ( length - 16 ) / 12 < num_groups           )
       FT_INVALID_TOO_SHORT;
 
     /* check groups, they must be in increasing order */
     num_selectors = TT_NEXT_ULONG( p );
 
     if ( length > (FT_ULong)( valid->limit - table ) ||
-         length < 10 + 11 * num_selectors            )
+         /* length < 10 + 11 * num_selectors ? */
+         length < 10                                 ||
+         ( length - 10 ) / 11 < num_selectors        )
       FT_INVALID_TOO_SHORT;
 
     /* check selectors, they must be in increasing order */
           FT_ULong  lastBase  = 0;
 
 
-          if ( defp + numRanges * 4 > valid->limit )
+          /* defp + numRanges * 4 > valid->limit ? */
+          if ( numRanges > (FT_ULong)( valid->limit - defp ) / 4 )
             FT_INVALID_TOO_SHORT;
 
           for ( i = 0; i < numRanges; ++i )
           FT_ULong  i, lastUni  = 0;
 
 
-          if ( numMappings * 4 > (FT_ULong)( valid->limit - ndp ) )
+          /* numMappings * 4 > (FT_ULong)( valid->limit - ndp ) ? */
+          if ( numMappings > ( (FT_ULong)( valid->limit - ndp ) ) / 4 )
             FT_INVALID_TOO_SHORT;
 
           for ( i = 0; i < numMappings; ++i )
     /* only recognize format 0 */
     if ( TT_NEXT_USHORT( p ) != 0 )
     {
-      p -= 2;
       FT_ERROR(( "tt_face_build_cmaps:"
                  " unsupported `cmap' table format = %d\n",
-                 TT_PEEK_USHORT( p ) ));
+                 TT_PEEK_USHORT( p - 2 ) ));
       return FT_THROW( Invalid_Table );
     }
 
     num_cmaps = TT_NEXT_USHORT( p );
 
-#ifdef FT_MAX_CHARMAP_CACHEABLE
-    if ( num_cmaps > FT_MAX_CHARMAP_CACHEABLE )
-      FT_ERROR(( "tt_face_build_cmaps: too many cmap subtables (%d)\n"
-                 "                     subtable #%d and higher are loaded"
-                 "                     but cannot be searched\n",
-                 num_cmaps, FT_MAX_CHARMAP_CACHEABLE + 1 ));
-#endif
-
     for ( ; num_cmaps > 0 && p + 8 <= limit; num_cmaps-- )
     {
       FT_CharMapRec  charmap;
index 32c4008..455e7b5 100644 (file)
@@ -99,7 +99,7 @@
       length   = FT_NEXT_USHORT( p );
       coverage = FT_NEXT_USHORT( p );
 
-      if ( length <= 6 )
+      if ( length <= 6 + 8 )
         break;
 
       p_next += length;
index 0a3cd29..8338150 100644 (file)
@@ -5,7 +5,7 @@
 /*    Load the basic TrueType tables, i.e., tables that can be either in   */
 /*    TTF or OTF fonts (body).                                             */
 /*                                                                         */
-/*  Copyright 1996-2010, 2012, 2013 by                                     */
+/*  Copyright 1996-2010, 2012-2014 by                                      */
 /*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
 /*                                                                         */
 /*  This file is part of the FreeType project, and may only be used,       */
       }
 
       /* we ignore invalid tables */
-      if ( table.Offset + table.Length > stream->size )
+
+      /* table.Offset + table.Length > stream->size ? */
+      if ( table.Length > stream->size                ||
+           table.Offset > stream->size - table.Length )
       {
         FT_TRACE2(( "check_table_dir: table entry %d invalid\n", nn ));
         continue;
       entry->Length   = FT_GET_ULONG();
 
       /* ignore invalid tables */
-      if ( entry->Offset + entry->Length > stream->size )
+
+      /* entry->Offset + entry->Length > stream->size ? */
+      if ( entry->Length > stream->size                 ||
+           entry->Offset > stream->size - entry->Length )
         continue;
       else
       {
index a8cc63a..bb31957 100644 (file)
@@ -4,7 +4,7 @@
 /*                                                                         */
 /*    Load the metrics tables common to TTF and OTF fonts (body).          */
 /*                                                                         */
-/*  Copyright 2006-2009, 2011-2013 by                                      */
+/*  Copyright 2006-2009, 2011-2014 by                                      */
 /*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
 /*                                                                         */
 /*  This file is part of the FreeType project, and may only be used,       */
   /*    aadvance :: The advance width or advance height, depending on      */
   /*                the `vertical' flag.                                   */
   /*                                                                       */
-  FT_LOCAL_DEF( FT_Error )
+  FT_LOCAL_DEF( void )
   tt_face_get_metrics( TT_Face     face,
                        FT_Bool     vertical,
                        FT_UInt     gindex,
       *abearing = 0;
       *aadvance = 0;
     }
-
-    return FT_Err_Ok;
   }
 
 
index 8b91a11..fb04039 100644 (file)
@@ -4,7 +4,7 @@
 /*                                                                         */
 /*    Load the metrics tables common to TTF and OTF fonts (specification). */
 /*                                                                         */
-/*  Copyright 2006 by                                                      */
+/*  Copyright 2006, 2014 by                                                */
 /*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
 /*                                                                         */
 /*  This file is part of the FreeType project, and may only be used,       */
@@ -40,7 +40,7 @@ FT_BEGIN_HEADER
                      FT_Bool    vertical );
 
 
-  FT_LOCAL( FT_Error )
+  FT_LOCAL( void )
   tt_face_get_metrics( TT_Face     face,
                        FT_Bool     vertical,
                        FT_UInt     gindex,
index 47a85c0..99d8005 100644 (file)
@@ -5,7 +5,7 @@
 /*    Postcript name table processing for TrueType and OpenType fonts      */
 /*    (body).                                                              */
 /*                                                                         */
-/*  Copyright 1996-2003, 2006-2010, 2013 by                                */
+/*  Copyright 1996-2003, 2006-2010, 2013, 2014 by                          */
 /*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
 /*                                                                         */
 /*  This file is part of the FreeType project, and may only be used,       */
 
 #define MAC_NAME( x )  ( (FT_String*)tt_post_default_names[x] )
 
-  /* the 258 default Mac PS glyph names */
+  /* the 258 default Mac PS glyph names; see file `tools/glnames.py' */
 
   static const FT_String* const  tt_post_default_names[258] =
   {
     /*   0 */
-    ".notdef", ".null", "CR", "space", "exclam",
+    ".notdef", ".null", "nonmarkingreturn", "space", "exclam",
     "quotedbl", "numbersign", "dollar", "percent", "ampersand",
     /*  10 */
     "quotesingle", "parenleft", "parenright", "asterisk", "plus",
     "ae", "oslash", "questiondown", "exclamdown", "logicalnot",
     "radical", "florin", "approxequal", "Delta", "guillemotleft",
     /* 170 */
-    "guillemotright", "ellipsis", "nbspace", "Agrave", "Atilde",
+    "guillemotright", "ellipsis", "nonbreakingspace", "Agrave", "Atilde",
     "Otilde", "OE", "oe", "endash", "emdash",
     /* 180 */
     "quotedblleft", "quotedblright", "quoteleft", "quoteright", "divide",
     "multiply", "onesuperior", "twosuperior", "threesuperior", "onehalf",
     "onequarter", "threequarters", "franc", "Gbreve", "gbreve",
     /* 250 */
-    "Idot", "Scedilla", "scedilla", "Cacute", "cacute",
-    "Ccaron", "ccaron", "dmacron",
+    "Idotaccent", "Scedilla", "scedilla", "Cacute", "cacute",
+    "Ccaron", "ccaron", "dcroat",
   };
 
 
index 8ff7b9d..c2db96c 100644 (file)
           error = FT_THROW( Unknown_File_Format );
           goto Exit;
         }
-        if ( flags != 0x0001 || num_strikes >= 0x10000UL )
+
+        /* Bit 0 must always be `1'.                            */
+        /* Bit 1 controls the overlay of bitmaps with outlines. */
+        /* All other bits should be zero.                       */
+        if ( !( flags == 1 || flags == 3 ) ||
+             num_strikes >= 0x10000UL      )
         {
           error = FT_THROW( Invalid_File_Format );
           goto Exit;
         }
 
+        /* we currently don't support bit 1; however, it is better to */
+        /* draw at least something...                                 */
+        if ( flags == 3 )
+          FT_TRACE1(( "tt_face_load_sbit_strikes:"
+                      " sbix overlay not supported yet\n"
+                      "                          "
+                      " expect bad rendering results\n" ));
+
         /*
          *  Count the number of strikes available in the table.  We are a bit
          *  paranoid there and don't trust the data.
     case TT_SBIT_TABLE_TYPE_SBIX:
       {
         FT_Stream       stream = face->root.stream;
-        FT_UInt         offset, ppem, resolution, upem;
+        FT_UInt         offset, upem;
+        FT_UShort       ppem, resolution;
         TT_HoriHeader  *hori;
         FT_ULong        table_size;
 
       p                          += 34;
       decoder->bit_depth          = *p;
 
-      if ( decoder->strike_index_array > face->sbit_table_size             ||
-           decoder->strike_index_array + 8 * decoder->strike_index_count >
-             face->sbit_table_size                                         )
+      /* decoder->strike_index_array +                               */
+      /*   8 * decoder->strike_index_count > face->sbit_table_size ? */
+      if ( decoder->strike_index_array > face->sbit_table_size           ||
+           decoder->strike_index_count >
+             ( face->sbit_table_size - decoder->strike_index_array ) / 8 )
         error = FT_THROW( Invalid_File_Format );
     }
 
 
       p += 3;
     }
+    else
+    {
+      /* avoid uninitialized data in case there is no vertical info -- */
+      metrics->vertBearingX = 0;
+      metrics->vertBearingY = 0;
+      metrics->vertAdvance  = 0;
+    }
 
     decoder->metrics_loaded = 1;
     *pp = p;
     return FT_Err_Ok;
 
   Fail:
-    FT_TRACE1(( "tt_sbit_decoder_load_metrics: broken table" ));
+    FT_TRACE1(( "tt_sbit_decoder_load_metrics: broken table\n" ));
     return FT_THROW( Invalid_Argument );
   }
 
     FT_Error  error = FT_Err_Ok;
     FT_UInt   num_components, nn;
 
-    FT_Char  horiBearingX = decoder->metrics->horiBearingX;
-    FT_Char  horiBearingY = decoder->metrics->horiBearingY;
-    FT_Byte  horiAdvance  = decoder->metrics->horiAdvance;
-    FT_Char  vertBearingX = decoder->metrics->vertBearingX;
-    FT_Char  vertBearingY = decoder->metrics->vertBearingY;
-    FT_Byte  vertAdvance  = decoder->metrics->vertAdvance;
+    FT_Char  horiBearingX = (FT_Char)decoder->metrics->horiBearingX;
+    FT_Char  horiBearingY = (FT_Char)decoder->metrics->horiBearingY;
+    FT_Byte  horiAdvance  = (FT_Byte)decoder->metrics->horiAdvance;
+    FT_Char  vertBearingX = (FT_Char)decoder->metrics->vertBearingX;
+    FT_Char  vertBearingY = (FT_Char)decoder->metrics->vertBearingY;
+    FT_Byte  vertAdvance  = (FT_Byte)decoder->metrics->vertAdvance;
 
 
     if ( p + 2 > limit )
         num_glyphs = FT_NEXT_ULONG( p );
 
         /* overflow check for p + ( num_glyphs + 1 ) * 4 */
-        if ( num_glyphs > (FT_ULong)( ( ( p_limit - p ) >> 2 ) - 1 ) )
+        if ( p + 4 > p_limit                                         ||
+             num_glyphs > (FT_ULong)( ( ( p_limit - p ) >> 2 ) - 1 ) )
           goto NoBitmap;
 
         for ( mm = 0; mm < num_glyphs; mm++ )
 
     case FT_MAKE_TAG( 'j', 'p', 'g', ' ' ):
     case FT_MAKE_TAG( 't', 'i', 'f', 'f' ):
+    case FT_MAKE_TAG( 'r', 'g', 'b', 'l' ): /* used on iOS 7.1 */
       error = FT_THROW( Unknown_File_Format );
       break;
 
 
       tt_face_get_metrics( face, FALSE, glyph_index, &abearing, &aadvance );
 
-      metrics->horiBearingX = originOffsetX;
-      metrics->horiBearingY = -originOffsetY + metrics->height;
-      metrics->horiAdvance  = aadvance * face->root.size->metrics.x_ppem /
-                                face->header.Units_Per_EM;
+      metrics->horiBearingX = (FT_Short)originOffsetX;
+      metrics->horiBearingY = (FT_Short)( -originOffsetY + metrics->height );
+      metrics->horiAdvance  = (FT_Short)( aadvance *
+                                          face->root.size->metrics.x_ppem /
+                                          face->header.Units_Per_EM );
     }
 
     return error;
index 425911a..131ad27 100644 (file)
@@ -98,6 +98,9 @@
 #define FT_ERR_XCAT( x, y )  x ## y
 #define FT_ERR_CAT( x, y )   FT_ERR_XCAT( x, y )
 
+#define FT_BEGIN_STMNT  do {
+#define FT_END_STMNT    } while ( 0 )
+
 
   /* define this to dump debugging information */
 /* #define FT_DEBUG_LEVEL_TRACE */
@@ -402,6 +405,8 @@ typedef ptrdiff_t  FT_PtrDist;
 
   typedef struct  gray_TWorker_
   {
+    ft_jmp_buf  jump_buffer;
+
     TCoord  ex, ey;
     TPos    min_ex, max_ex;
     TPos    min_ey, max_ey;
@@ -437,8 +442,6 @@ typedef ptrdiff_t  FT_PtrDist;
     int  band_size;
     int  band_shoot;
 
-    ft_jmp_buf  jump_buffer;
-
     void*       buffer;
     long        buffer_size;
 
@@ -1088,37 +1091,10 @@ typedef ptrdiff_t  FT_PtrDist;
 
 
         /* dx and dy are x and y components of the P0-P3 chord vector. */
-        dx = arc[3].x - arc[0].x;
-        dy = arc[3].y - arc[0].y;
-
-        /* L is an (under)estimate of the Euclidean distance P0-P3.       */
-        /*                                                                */
-        /* If dx >= dy, then r = sqrt(dx^2 + dy^2) can be overestimated   */
-        /* with least maximum error by                                    */
-        /*                                                                */
-        /*   r_upperbound = dx + (sqrt(2) - 1) * dy  ,                    */
-        /*                                                                */
-        /* where sqrt(2) - 1 can be (over)estimated by 107/256, giving an */
-        /* error of no more than 8.4%.                                    */
-        /*                                                                */
-        /* Similarly, some elementary calculus shows that r can be        */
-        /* underestimated with least maximum error by                     */
-        /*                                                                */
-        /*   r_lowerbound = sqrt(2 + sqrt(2)) / 2 * dx                    */
-        /*                  + sqrt(2 - sqrt(2)) / 2 * dy  .               */
-        /*                                                                */
-        /* 236/256 and 97/256 are (under)estimates of the two algebraic   */
-        /* numbers, giving an error of no more than 8.1%.                 */
-
-        dx_ = FT_ABS( dx );
-        dy_ = FT_ABS( dy );
-
-        /* This is the same as                     */
-        /*                                         */
-        /*   L = ( 236 * FT_MAX( dx_, dy_ )        */
-        /*       + 97 * FT_MIN( dx_, dy_ ) ) >> 8; */
-        L = ( dx_ > dy_ ? 236 * dx_ +  97 * dy_
-                        :  97 * dx_ + 236 * dy_ ) >> 8;
+        dx = dx_ = arc[3].x - arc[0].x;
+        dy = dy_ = arc[3].y - arc[0].y;
+
+        L = FT_HYPOT( dx_, dy_ );
 
         /* Avoid possible arithmetic overflow below by splitting. */
         if ( L > 32767 )
@@ -1539,7 +1515,10 @@ typedef ptrdiff_t  FT_PtrDist;
     TPos  delta;
 
 
-    if ( !outline || !func_interface )
+    if ( !outline )
+      return FT_THROW( Invalid_Outline );
+
+    if ( !func_interface )
       return FT_THROW( Invalid_Argument );
 
     shift = func_interface->shift;
@@ -2121,12 +2100,26 @@ typedef ptrdiff_t  FT_PtrDist;
   }
 
 
+  static int
+  gray_raster_set_mode( FT_Raster      raster,
+                        unsigned long  mode,
+                        void*          args )
+  {
+    FT_UNUSED( raster );
+    FT_UNUSED( mode );
+    FT_UNUSED( args );
+
+
+    return 0; /* nothing to do */
+  }
+
+
   FT_DEFINE_RASTER_FUNCS(ft_grays_raster,
     FT_GLYPH_FORMAT_OUTLINE,
 
     (FT_Raster_New_Func)     gray_raster_new,
     (FT_Raster_Reset_Func)   gray_raster_reset,
-    (FT_Raster_Set_Mode_Func)0,
+    (FT_Raster_Set_Mode_Func)gray_raster_set_mode,
     (FT_Raster_Render_Func)  gray_raster_render,
     (FT_Raster_Done_Func)    gray_raster_done
   )
index 89088cd..4e2dee5 100644 (file)
                             FT_Render_Mode    required_mode )
   {
     FT_Error     error;
-    FT_Outline*  outline = NULL;
+    FT_Outline*  outline = &slot->outline;
+    FT_Bitmap*   bitmap  = &slot->bitmap;
+    FT_Memory    memory  = render->root.memory;
     FT_BBox      cbox;
+    FT_Pos       x_shift = 0;
+    FT_Pos       y_shift = 0;
+    FT_Pos       x_left, y_top;
     FT_Pos       width, height, pitch;
 #ifndef FT_CONFIG_OPTION_SUBPIXEL_RENDERING
     FT_Pos       height_org, width_org;
 #endif
-    FT_Bitmap*   bitmap  = &slot->bitmap;
-    FT_Memory    memory  = render->root.memory;
     FT_Int       hmul    = mode == FT_RENDER_MODE_LCD;
     FT_Int       vmul    = mode == FT_RENDER_MODE_LCD_V;
-    FT_Pos       x_shift = 0;
-    FT_Pos       y_shift = 0;
-    FT_Pos       x_left, y_top;
 
     FT_Raster_Params  params;
 
-    FT_Bool  have_translated_origin = FALSE;
-    FT_Bool  have_outline_shifted   = FALSE;
-    FT_Bool  have_buffer            = FALSE;
+    FT_Bool  have_outline_shifted = FALSE;
+    FT_Bool  have_buffer          = FALSE;
 
 
     /* check glyph image format */
       goto Exit;
     }
 
-    outline = &slot->outline;
-
-    /* translate the outline to the new origin if needed */
     if ( origin )
     {
-      FT_Outline_Translate( outline, origin->x, origin->y );
-      have_translated_origin = TRUE;
+      x_shift = origin->x;
+      y_shift = origin->y;
     }
 
     /* compute the control box, and grid fit it */
+    /* taking into account the origin shift     */
     FT_Outline_Get_CBox( outline, &cbox );
 
-    cbox.xMin = FT_PIX_FLOOR( cbox.xMin );
-    cbox.yMin = FT_PIX_FLOOR( cbox.yMin );
-    cbox.xMax = FT_PIX_CEIL( cbox.xMax );
-    cbox.yMax = FT_PIX_CEIL( cbox.yMax );
+    cbox.xMin = FT_PIX_FLOOR( cbox.xMin + x_shift );
+    cbox.yMin = FT_PIX_FLOOR( cbox.yMin + y_shift );
+    cbox.xMax = FT_PIX_CEIL( cbox.xMax + x_shift );
+    cbox.yMax = FT_PIX_CEIL( cbox.yMax + y_shift );
 
-    if ( cbox.xMin < 0 && cbox.xMax > FT_INT_MAX + cbox.xMin )
-    {
-      FT_ERROR(( "ft_smooth_render_generic: glyph too large:"
-                 " xMin = %d, xMax = %d\n",
-                 cbox.xMin >> 6, cbox.xMax >> 6 ));
-      error = FT_THROW( Raster_Overflow );
-      goto Exit;
-    }
-    else
-      width = ( cbox.xMax - cbox.xMin ) >> 6;
+    x_shift -= cbox.xMin;
+    y_shift -= cbox.yMin;
 
-    if ( cbox.yMin < 0 && cbox.yMax > FT_INT_MAX + cbox.yMin )
-    {
-      FT_ERROR(( "ft_smooth_render_generic: glyph too large:"
-                 " yMin = %d, yMax = %d\n",
-                 cbox.yMin >> 6, cbox.yMax >> 6 ));
-      error = FT_THROW( Raster_Overflow );
-      goto Exit;
-    }
-    else
-      height = ( cbox.yMax - cbox.yMin ) >> 6;
+    x_left  = cbox.xMin >> 6;
+    y_top   = cbox.yMax >> 6;
+
+    width  = (FT_ULong)( cbox.xMax - cbox.xMin ) >> 6;
+    height = (FT_ULong)( cbox.yMax - cbox.yMin ) >> 6;
 
 #ifndef FT_CONFIG_OPTION_SUBPIXEL_RENDERING
     width_org  = width;
     height_org = height;
 #endif
 
-    /* release old bitmap buffer */
-    if ( slot->internal->flags & FT_GLYPH_OWN_BITMAP )
-    {
-      FT_FREE( bitmap->buffer );
-      slot->internal->flags &= ~FT_GLYPH_OWN_BITMAP;
-    }
-
-    /* allocate new one */
     pitch = width;
     if ( hmul )
     {
-      width = width * 3;
-      pitch = FT_PAD_CEIL( width, 4 );
+      width *= 3;
+      pitch  = FT_PAD_CEIL( width, 4 );
     }
 
     if ( vmul )
       height *= 3;
 
-    x_shift = (FT_Int) cbox.xMin;
-    y_shift = (FT_Int) cbox.yMin;
-    x_left  = (FT_Int)( cbox.xMin >> 6 );
-    y_top   = (FT_Int)( cbox.yMax >> 6 );
-
 #ifdef FT_CONFIG_OPTION_SUBPIXEL_RENDERING
 
     if ( slot->library->lcd_filter_func )
 
       if ( hmul )
       {
-        x_shift -= 64 * ( extra >> 1 );
+        x_shift += 64 * ( extra >> 1 );
+        x_left  -= extra >> 1;
         width   += 3 * extra;
         pitch    = FT_PAD_CEIL( width, 4 );
-        x_left  -= extra >> 1;
       }
 
       if ( vmul )
       {
-        y_shift -= 64 * ( extra >> 1 );
-        height  += 3 * extra;
+        y_shift += 64 * ( extra >> 1 );
         y_top   += extra >> 1;
+        height  += 3 * extra;
       }
     }
 
 #endif
 
-#if FT_UINT_MAX > 0xFFFFU
+    /*
+     * XXX: on 16bit system, we return an error for huge bitmap
+     * to prevent an overflow.
+     */
+    if ( x_left > FT_INT_MAX || y_top > FT_INT_MAX ||
+         x_left < FT_INT_MIN || y_top < FT_INT_MIN )
+    {
+      error = FT_THROW( Invalid_Pixel_Size );
+      goto Exit;
+    }
 
     /* Required check is (pitch * height < FT_ULONG_MAX),        */
     /* but we care realistic cases only.  Always pitch <= width. */
       goto Exit;
     }
 
-#endif
+    /* release old bitmap buffer */
+    if ( slot->internal->flags & FT_GLYPH_OWN_BITMAP )
+    {
+      FT_FREE( bitmap->buffer );
+      slot->internal->flags &= ~FT_GLYPH_OWN_BITMAP;
+    }
+
+    /* allocate new one */
+    if ( FT_ALLOC( bitmap->buffer, (FT_ULong)pitch * height ) )
+      goto Exit;
+    else
+      have_buffer = TRUE;
+
+    slot->internal->flags |= FT_GLYPH_OWN_BITMAP;
+
+    slot->format      = FT_GLYPH_FORMAT_BITMAP;
+    slot->bitmap_left = (FT_Int)x_left;
+    slot->bitmap_top  = (FT_Int)y_top;
 
     bitmap->pixel_mode = FT_PIXEL_MODE_GRAY;
     bitmap->num_grays  = 256;
     bitmap->pitch      = pitch;
 
     /* translate outline to render it into the bitmap */
-    FT_Outline_Translate( outline, -x_shift, -y_shift );
-    have_outline_shifted = TRUE;
-
-    if ( FT_ALLOC( bitmap->buffer, (FT_ULong)pitch * height ) )
-      goto Exit;
-    else
-      have_buffer = TRUE;
-
-    slot->internal->flags |= FT_GLYPH_OWN_BITMAP;
+    if ( x_shift || y_shift )
+    {
+      FT_Outline_Translate( outline, x_shift, y_shift );
+      have_outline_shifted = TRUE;
+    }
 
     /* set up parameters */
     params.target = bitmap;
 
 #endif /* !FT_CONFIG_OPTION_SUBPIXEL_RENDERING */
 
-    /*
-     * XXX: on 16bit system, we return an error for huge bitmap
-     * to prevent an overflow.
-     */
-    if ( x_left > FT_INT_MAX || y_top > FT_INT_MAX )
-    {
-      error = FT_THROW( Invalid_Pixel_Size );
-      goto Exit;
-    }
-
-    slot->format      = FT_GLYPH_FORMAT_BITMAP;
-    slot->bitmap_left = (FT_Int)x_left;
-    slot->bitmap_top  = (FT_Int)y_top;
-
     /* everything is fine; don't deallocate buffer */
     have_buffer = FALSE;
 
 
   Exit:
     if ( have_outline_shifted )
-      FT_Outline_Translate( outline, x_shift, y_shift );
-    if ( have_translated_origin )
-      FT_Outline_Translate( outline, -origin->x, -origin->y );
+      FT_Outline_Translate( outline, -x_shift, -y_shift );
     if ( have_buffer )
     {
       FT_FREE( bitmap->buffer );
index 58aa2a0..60fe696 100644 (file)
@@ -63,8 +63,8 @@ my $enum_element_re = qr/ ^ \s* ( [A-Za-z0-9_]+ ) \s* $ /x;
 # '#' <preprocessor directive> '\n'
 my $preprocessor_re = qr/ ^ \# /x;
 
-# '/' '/' <comment> '\n'
-my $comment_re = qr| ^ // |x;
+# [<ws>] '/' '/' <comment> '\n'
+my $comment_re = qr| ^ \s* // |x;
 
 # empty line
 my $whitespace_only_re = qr/ ^ \s* $ /x;
@@ -159,6 +159,9 @@ sub convert_ascii_chars
   # A series of ASCII characters in the printable range.
   my $s = shift;
 
+  # We ignore spaces.
+  $s =~ s/ //g;
+
   my $count = $s =~ s/\G(.)/'$1', /g;
   $curr_offset += $count;
   $curr_elem_size += $count;
index 98025e6..adea6f1 100644 (file)
@@ -1,57 +1,81 @@
-#  Content (c) 2002, 2004, 2006-2009, 2012, 2013
-#    David Turner <david@freetype.org>
 #
-#  This file contains routines used to parse the content of documentation
-#  comment blocks and build more structured objects out of them.
+#  content.py
+#
+#    Parse comment blocks to build content blocks (library file).
+#
+#  Copyright 2002, 2004, 2006-2009, 2012-2014 by
+#  David Turner.
+#
+#  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.
+
+#
+# This file contains routines to parse documentation comment blocks,
+# building more structured objects out of them.
 #
 
+
 from sources import *
-from utils import *
+from utils   import *
+
 import string, re
 
 
-# this regular expression is used to detect code sequences. these
-# are simply code fragments embedded in '{' and '}' like in:
 #
-#  {
-#    x = y + z;
-#    if ( zookoo == 2 )
-#    {
-#      foobar();
-#    }
-#  }
+# Regular expressions to detect code sequences.  `Code sequences' are simply
+# code fragments embedded in '{' and '}', as demonstrated in the following
+# example.
+#
+#   {
+#     x = y + z;
+#     if ( zookoo == 2 )
+#     {
+#       foobar();
+#     }
+#   }
 #
-# note that indentation of the starting and ending accolades must be
-# exactly the same. the code sequence can contain accolades at greater
-# indentation
+# Note that the indentation of the first opening brace and the last closing
+# brace must be exactly the same.  The code sequence itself should have a
+# larger indentation than the surrounding braces.
 #
 re_code_start = re.compile( r"(\s*){\s*$" )
 re_code_end   = re.compile( r"(\s*)}\s*$" )
 
 
-# this regular expression is used to isolate identifiers from
-# other text
 #
-re_identifier = re.compile( r'((?:\w|-)*)' )
-
-
-# we collect macros ending in `_H'; while outputting the object data, we use
-# this info together with the object's file location to emit the appropriate
-# header file macro and name before the object itself
+# A regular expression to isolate identifiers from other text.
 #
-re_header_macro = re.compile( r'^#define\s{1,}(\w{1,}_H)\s{1,}<(.*)>' )
+re_identifier = re.compile( r'((?:\w|-)*)' )
 
 
-#############################################################################
 #
-# The DocCode class is used to store source code lines.
+# We collect macro names ending in `_H' (group 1), as defined in
+# `config/ftheader.h'.  While outputting the object data, we use this info
+# together with the object's file location (group 2) to emit the appropriate
+# header file macro and its associated file name before the object itself.
 #
-#   'self.lines' contains a set of source code lines that will be dumped as
-#   HTML in a <PRE> tag.
+# Example:
 #
-#   The object is filled line by line by the parser; it strips the leading
-#   "margin" space from each input line before storing it in 'self.lines'.
+#   #define FT_FREETYPE_H <freetype.h>
 #
+re_header_macro = re.compile( r'^#define\s{1,}(\w{1,}_H)\s{1,}<(.*)>' )
+
+
+################################################################
+##
+##  DOC CODE CLASS
+##
+##  The `DocCode' class is used to store source code lines.
+##
+##  `self.lines' contains a set of source code lines that will be dumped as
+##  HTML in a <PRE> tag.
+##
+##  The object is filled line by line by the parser; it strips the leading
+##  `margin' space from each input line before storing it in `self.lines'.
+##
 class  DocCode:
 
     def  __init__( self, margin, lines ):
@@ -77,12 +101,14 @@ class  DocCode:
 
 
 
-#############################################################################
-#
-# The DocPara class is used to store "normal" text paragraph.
-#
-#   'self.words' contains the list of words that make up the paragraph
-#
+################################################################
+##
+##  DOC PARA CLASS
+##
+##  `Normal' text paragraphs are stored in the `DocPara' class.
+##
+##  `self.words' contains the list of words that make up the paragraph.
+##
 class  DocPara:
 
     def  __init__( self, lines ):
@@ -123,17 +149,18 @@ class  DocPara:
         return result
 
 
-
-#############################################################################
-#
-#  The DocField class is used to store a list containing either DocPara or
-#  DocCode objects. Each DocField also has an optional "name" which is used
-#  when the object corresponds to a field or value definition
-#
+################################################################
+##
+##  DOC FIELD CLASS
+##
+##  The `DocField' class stores a list containing either `DocPara' or
+##  `DocCode' objects.  Each DocField object also has an optional `name'
+##  that is used when the object corresponds to a field or value definition.
+##
 class  DocField:
 
     def  __init__( self, name, lines ):
-        self.name  = name  # can be None for normal paragraphs/sources
+        self.name  = name  # can be `None' for normal paragraphs/sources
         self.items = []    # list of items
 
         mode_none  = 0     # start parsing mode
@@ -143,14 +170,14 @@ class  DocField:
         margin     = -1    # current code sequence indentation
         cur_lines  = []
 
-        # now analyze the markup lines to see if they contain paragraphs,
-        # code sequences or fields definitions
+        # analyze the markup lines to check whether they contain paragraphs,
+        # code sequences, or fields definitions
         #
         start = 0
         mode  = mode_none
 
         for l in lines:
-            # are we parsing a code sequence ?
+            # are we parsing a code sequence?
             if mode == mode_code:
                 m = re_code_end.match( l )
                 if m and len( m.group( 1 ) ) <= margin:
@@ -161,10 +188,10 @@ class  DocField:
                     cur_lines = []
                     mode      = mode_none
                 else:
-                    # nope, continue the code sequence
+                    # otherwise continue the code sequence
                     cur_lines.append( l[margin:] )
             else:
-                # start of code sequence ?
+                # start of code sequence?
                 m = re_code_start.match( l )
                 if m:
                     # save current lines
@@ -222,13 +249,29 @@ class  DocField:
         return result
 
 
-
-# this regular expression is used to detect field definitions
 #
-re_field = re.compile( r"\s*(\w*|\w(\w|\.)*\w)\s*::" )
-
-
-
+# A regular expression to detect field definitions.
+#
+# Examples:
+#
+#   foo     ::
+#   foo.bar ::
+#
+re_field = re.compile( r"""
+                         \s*
+                           (
+                             \w*
+                           |
+                             \w (\w | \.)* \w
+                           )
+                         \s* ::
+                       """, re.VERBOSE )
+
+
+################################################################
+##
+##  DOC MARKUP CLASS
+##
 class  DocMarkup:
 
     def  __init__( self, tag, lines ):
@@ -242,7 +285,7 @@ class  DocMarkup:
         for l in lines:
             m = re_field.match( l )
             if m:
-                # we detected the start of a new field definition
+                # We detected the start of a new field definition.
 
                 # first, save the current one
                 if cur_lines:
@@ -275,7 +318,10 @@ class  DocMarkup:
         print " " * margin + "</" + self.tag + ">"
 
 
-
+################################################################
+##
+##  DOC CHAPTER CLASS
+##
 class  DocChapter:
 
     def  __init__( self, block ):
@@ -291,7 +337,10 @@ class  DocChapter:
             self.order = []
 
 
-
+################################################################
+##
+##  DOC SECTION CLASS
+##
 class  DocSection:
 
     def  __init__( self, name = "Other" ):
@@ -320,18 +369,21 @@ class  DocSection:
                 self.title       = title
                 self.abstract    = block.get_markup_words( "abstract" )
                 self.description = block.get_markup_items( "description" )
-                self.order       = block.get_markup_words( "order" )
+                self.order       = block.get_markup_words_all( "order" )
                 return
 
     def  reorder( self ):
         self.block_names = sort_order_list( self.block_names, self.order )
 
 
-
+################################################################
+##
+##  CONTENT PROCESSOR CLASS
+##
 class  ContentProcessor:
 
     def  __init__( self ):
-        """initialize a block content processor"""
+        """Initialize a block content processor."""
         self.reset()
 
         self.sections = {}    # dictionary of documentation sections
@@ -342,8 +394,8 @@ class  ContentProcessor:
         self.headers  = {}    # dictionary of header macros
 
     def  set_section( self, section_name ):
-        """set current section during parsing"""
-        if not self.sections.has_key( section_name ):
+        """Set current section during parsing."""
+        if not section_name in self.sections:
             section = DocSection( section_name )
             self.sections[section_name] = section
             self.section                = section
@@ -354,15 +406,14 @@ class  ContentProcessor:
         chapter = DocChapter( block )
         self.chapters.append( chapter )
 
-
     def  reset( self ):
-        """reset the content processor for a new block"""
+        """Reset the content processor for a new block."""
         self.markups      = []
         self.markup       = None
         self.markup_lines = []
 
     def  add_markup( self ):
-        """add a new markup section"""
+        """Add a new markup section."""
         if self.markup and self.markup_lines:
 
             # get rid of last line of markup if it's empty
@@ -378,8 +429,8 @@ class  ContentProcessor:
             self.markup_lines = []
 
     def  process_content( self, content ):
-        """process a block content and return a list of DocMarkup objects
-           corresponding to it"""
+        """Process a block content and return a list of DocMarkup objects
+           corresponding to it."""
         markup       = None
         markup_lines = []
         first        = 1
@@ -437,7 +488,7 @@ class  ContentProcessor:
         # listed there
         for chap in self.chapters:
             for sec in chap.order:
-                if self.sections.has_key( sec ):
+                if sec in self.sections:
                     section = self.sections[sec]
                     section.chapter = chap
                     section.reorder()
@@ -452,6 +503,7 @@ class  ContentProcessor:
         others = []
         for sec in self.sections.values():
             if not sec.chapter:
+                sec.reorder()
                 others.append( sec )
 
         # create a new special chapter for all remaining sections
@@ -463,7 +515,10 @@ class  ContentProcessor:
             self.chapters.append( chap )
 
 
-
+################################################################
+##
+##  DOC BLOCK CLASS
+##
 class  DocBlock:
 
     def  __init__( self, source, follow, processor ):
@@ -540,7 +595,7 @@ class  DocBlock:
         return self.source.location()
 
     def  get_markup( self, tag_name ):
-        """return the DocMarkup corresponding to a given tag in a block"""
+        """Return the DocMarkup corresponding to a given tag in a block."""
         for m in self.markups:
             if m.tag == string.lower( tag_name ):
                 return m
@@ -553,6 +608,21 @@ class  DocBlock:
         except:
             return []
 
+    def  get_markup_words_all( self, tag_name ):
+        try:
+            m = self.get_markup( tag_name )
+            words = []
+            for item in m.fields[0].items:
+                # We honour empty lines in an `<Order>' section element by
+                # adding the sentinel `/empty/'.  The formatter should then
+                # convert it to an appropriate representation in the
+                # `section_enter' function.
+                words += item.words
+                words.append( "/empty/" )
+            return words
+        except:
+            return []
+
     def  get_markup_text( self, tag_name ):
         result = self.get_markup_words( tag_name )
         return string.join( result )
index bf75c5d..4fb1abf 100644 (file)
@@ -1,16 +1,26 @@
 #!/usr/bin/env python
 #
-#  DocMaker (c) 2002, 2004, 2008, 2013 David Turner <david@freetype.org>
+#  docmaker.py
 #
-# This program is a re-write of the original DocMaker tool used
-# to generate the API Reference of the FreeType font engine
-# by converting in-source comments into structured HTML.
+#    Convert source code markup to HTML documentation.
 #
-# This new version is capable of outputting XML data, as well
-# as accepts more liberal formatting options.
+#  Copyright 2002, 2004, 2008, 2013, 2014 by
+#  David Turner.
 #
-# It also uses regular expression matching and substitution
-# to speed things significantly.
+#  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.
+
+#
+# This program is a re-write of the original DocMaker tool used to generate
+# the API Reference of the FreeType font rendering engine by converting
+# in-source comments into structured HTML.
+#
+# This new version is capable of outputting XML data as well as accepting
+# more liberal formatting options.  It also uses regular expression matching
+# and substitution to speed up operation significantly.
 #
 
 from sources   import *
@@ -39,13 +49,13 @@ def  usage():
 
 
 def  main( argv ):
-    """main program loop"""
+    """Main program loop."""
 
     global output_dir
 
     try:
-        opts, args = getopt.getopt( sys.argv[1:], \
-                                    "ht:o:p:",    \
+        opts, args = getopt.getopt( sys.argv[1:],
+                                    "ht:o:p:",
                                     ["help", "title=", "output=", "prefix="] )
     except getopt.GetoptError:
         usage()
@@ -56,7 +66,6 @@ def  main( argv ):
         sys.exit( 1 )
 
     # process options
-    #
     project_title  = "Project"
     project_prefix = None
     output_dir     = None
@@ -90,7 +99,9 @@ def  main( argv ):
     # process sections
     content_processor.finish()
 
-    formatter = HtmlFormatter( content_processor, project_title, project_prefix )
+    formatter = HtmlFormatter( content_processor,
+                               project_title,
+                               project_prefix )
 
     formatter.toc_dump()
     formatter.index_dump()
@@ -98,9 +109,7 @@ def  main( argv ):
 
 
 # if called from the command line
-#
 if __name__ == '__main__':
     main( sys.argv )
 
-
 # eof
index f62ce67..7152c01 100644 (file)
@@ -1,19 +1,37 @@
-#  Formatter (c) 2002, 2004, 2007, 2008 David Turner <david@freetype.org>
 #
+#  formatter.py
+#
+#    Convert parsed content blocks to a structured document (library file).
+#
+#  Copyright 2002, 2004, 2007, 2008, 2014 by
+#  David Turner.
+#
+#  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.
+
+#
+# This is the base Formatter class.  Its purpose is to convert a content
+# processor's data into specific documents (i.e., table of contents, global
+# index, and individual API reference indices).
+#
+# You need to sub-class it to output anything sensible.  For example, the
+# file `tohtml.py' contains the definition of the `HtmlFormatter' sub-class
+# to output HTML.
+#
+
 
 from sources import *
 from content import *
 from utils   import *
 
-# This is the base Formatter class.  Its purpose is to convert
-# a content processor's data into specific documents (i.e., table of
-# contents, global index, and individual API reference indices).
-#
-# You need to sub-class it to output anything sensible.  For example,
-# the file tohtml.py contains the definition of the HtmlFormatter sub-class
-# used to output -- you guessed it -- HTML.
-#
 
+################################################################
+##
+##  FORMATTER CLASS
+##
 class  Formatter:
 
     def  __init__( self, processor ):
@@ -36,20 +54,22 @@ class  Formatter:
                             self.add_identifier( field.name, block )
 
         self.block_index = self.identifiers.keys()
-        self.block_index.sort( index_sort )
+        self.block_index.sort( key = index_key )
 
     def  add_identifier( self, name, block ):
-        if self.identifiers.has_key( name ):
+        if name in self.identifiers:
             # duplicate name!
-            sys.stderr.write(                                           \
-               "WARNING: duplicate definition for '" + name + "' in " + \
-               block.location() + ", previous definition in " +         \
-               self.identifiers[name].location() + "\n" )
+            sys.stderr.write( "WARNING: duplicate definition for"
+                              + " '" + name + "' "
+                              + "in " + block.location() + ", "
+                              + "previous definition in "
+                              + self.identifiers[name].location()
+                              + "\n" )
         else:
             self.identifiers[name] = block
 
     #
-    #  Formatting the table of contents
+    # formatting the table of contents
     #
     def  toc_enter( self ):
         pass
@@ -97,7 +117,7 @@ class  Formatter:
             close_output( output )
 
     #
-    #  Formatting the index
+    # formatting the index
     #
     def  index_enter( self ):
         pass
@@ -128,7 +148,7 @@ class  Formatter:
             close_output( output )
 
     #
-    #  Formatting a section
+    # formatting a section
     #
     def  section_enter( self, section ):
         pass
@@ -162,7 +182,22 @@ class  Formatter:
         self.section_enter( section )
 
         for name in section.block_names:
-            block = self.identifiers[name]
+            skip_entry = 0
+            try:
+                block = self.identifiers[name]
+                # `block_names' can contain field names also,
+                # which we filter out
+                for markup in block.markups:
+                    if markup.tag == 'values':
+                        for field in markup.fields:
+                            if field.name == name:
+                                skip_entry = 1
+            except:
+                skip_entry = 1   # this happens e.g. for `/empty/' entries
+
+            if skip_entry:
+              continue
+
             self.block_enter( block )
 
             for markup in block.markups[1:]:   # always ignore first markup!
index dab8349..61ecc22 100644 (file)
@@ -1,62 +1,70 @@
-#  Sources (c) 2002-2004, 2006-2009, 2012, 2013
-#    David Turner <david@freetype.org>
 #
+#  sources.py
 #
-# this file contains definitions of classes needed to decompose
-# C sources files into a series of multi-line "blocks". There are
-# two kinds of blocks:
+#    Convert source code comments to multi-line blocks (library file).
 #
-#   - normal blocks, which contain source code or ordinary comments
+#  Copyright 2002-2004, 2006-2009, 2012-2014 by
+#  David Turner.
 #
-#   - documentation blocks, which have restricted formatting, and
-#     whose text always start with a documentation markup tag like
-#     "<Function>", "<Type>", etc..
+#  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.
+
+#
+# This library file contains definitions of classes needed to decompose C
+# source code files into a series of multi-line `blocks'.  There are two
+# kinds of blocks.
+#
+#   - Normal blocks, which contain source code or ordinary comments.
 #
-# the routines used to process the content of documentation blocks
-# are not contained here, but in "content.py"
+#   - Documentation blocks, which have restricted formatting, and whose text
+#     always start with a documentation markup tag like `<Function>',
+#     `<Type>', etc.
 #
-# the classes and methods found here only deal with text parsing
-# and basic documentation block extraction
+# The routines to process the content of documentation blocks are contained
+# in file `content.py'; the classes and methods found here only deal with
+# text parsing and basic documentation block extraction.
 #
 
-import fileinput, re, sys, os, string
 
+import fileinput, re, sys, os, string
 
 
 ################################################################
 ##
-##  BLOCK FORMAT PATTERN
+##  SOURCE BLOCK FORMAT CLASS
+##
+##  A simple class containing compiled regular expressions to detect
+##  potential documentation format block comments within C source code.
 ##
-##   A simple class containing compiled regular expressions used
-##   to detect potential documentation format block comments within
-##   C source code
+##  The `column' pattern must contain a group to `unbox' the content of
+##  documentation comment blocks.
 ##
-##   note that the 'column' pattern must contain a group that will
-##   be used to "unbox" the content of documentation comment blocks
+##  Later on, paragraphs are converted to long lines, which simplifies the
+##  regular expressions that act upon the text.
 ##
 class  SourceBlockFormat:
 
     def  __init__( self, id, start, column, end ):
-        """create a block pattern, used to recognize special documentation blocks"""
+        """Create a block pattern, used to recognize special documentation
+           blocks."""
         self.id     = id
         self.start  = re.compile( start, re.VERBOSE )
         self.column = re.compile( column, re.VERBOSE )
         self.end    = re.compile( end, re.VERBOSE )
 
 
-
 #
-# format 1 documentation comment blocks look like the following:
+# Format 1 documentation comment blocks.
 #
-#    /************************************/
+#    /************************************/ (at least 2 asterisks)
 #    /*                                  */
 #    /*                                  */
 #    /*                                  */
-#    /************************************/
-#
-# we define a few regular expressions here to detect them
+#    /************************************/ (at least 2 asterisks)
 #
-
 start = r'''
   \s*      # any number of whitespace
   /\*{2,}/ # followed by '/' and at least two asterisks then '/'
@@ -75,16 +83,13 @@ re_source_block_format1 = SourceBlockFormat( 1, start, column, start )
 
 
 #
-# format 2 documentation comment blocks look like the following:
+# Format 2 documentation comment blocks.
 #
 #    /************************************ (at least 2 asterisks)
 #     *
+#     *                                    (1 asterisk)
 #     *
-#     *
-#     *
-#     **/       (1 or more asterisks at the end)
-#
-# we define a few regular expressions here to detect them
+#     */                                   (1 or more asterisks)
 #
 start = r'''
   \s*     # any number of whitespace
@@ -93,9 +98,9 @@ start = r'''
 '''
 
 column = r'''
-  \s*        # any number of whitespace
-  \*{1}(?!/) # followed by precisely one asterisk not followed by `/'
-  (.*)       # then anything (group1)
+  \s*           # any number of whitespace
+  \*{1}(?![*/]) # followed by precisely one asterisk not followed by `/'
+  (.*)          # then anything (group1)
 '''
 
 end = r'''
@@ -107,47 +112,56 @@ re_source_block_format2 = SourceBlockFormat( 2, start, column, end )
 
 
 #
-# the list of supported documentation block formats, we could add new ones
-# relatively easily
+# The list of supported documentation block formats.  We could add new ones
+# quite easily.
 #
 re_source_block_formats = [re_source_block_format1, re_source_block_format2]
 
 
 #
-# the following regular expressions corresponds to markup tags
-# within the documentation comment blocks. they're equivalent
-# despite their different syntax
+# The following regular expressions correspond to markup tags within the
+# documentation comment blocks.  They are equivalent despite their different
+# syntax.
+#
+# A markup tag consists of letters or character `-', to be found in group 1.
 #
-# notice how each markup tag _must_ begin a new line
+# Notice that a markup tag _must_ begin a new paragraph.
 #
 re_markup_tag1 = re.compile( r'''\s*<((?:\w|-)*)>''' )  # <xxxx> format
 re_markup_tag2 = re.compile( r'''\s*@((?:\w|-)*):''' )  # @xxxx: format
 
 #
-# the list of supported markup tags, we could add new ones relatively
-# easily
+# The list of supported markup tags.  We could add new ones quite easily.
 #
 re_markup_tags = [re_markup_tag1, re_markup_tag2]
 
+
 #
-# used to detect a cross-reference, after markup tags have been stripped
+# A regular expression to detect a cross reference, after markup tags have
+# been stripped off.  Group 1 is the reference, group 2 the rest of the
+# line.
+#
+# A cross reference consists of letters, digits, or characters `-' and `_'.
 #
 re_crossref = re.compile( r'@((?:\w|-)*)(.*)' )    #  @foo
 
 #
-# used to detect italic and bold styles in paragraph text
+# Two regular expressions to detect italic and bold markup, respectively.
+# Group 1 is the markup, group 2 the rest of the line.
+#
+# Note that the markup is limited to words consisting of letters, digits,
+# the character `_', or an apostrophe (but not as the first character).
 #
-re_italic = re.compile( r"_(\w(\w|')*)_(.*)" )     #  _italic_
-re_bold   = re.compile( r"\*(\w(\w|')*)\*(.*)" )   #  *bold*
+re_italic = re.compile( r"_(\w(?:\w|')*)_(.*)" )     #  _italic_
+re_bold   = re.compile( r"\*(\w(?:\w|')*)\*(.*)" )   #  *bold*
 
 #
-# this regular expression code to identify an URL has been taken from
+# This regular expression code to identify an URL has been taken from
 #
 #   http://mail.python.org/pipermail/tutor/2002-September/017228.html
 #
-# (with slight modifications)
+# (with slight modifications).
 #
-
 urls = r'(?:https?|telnet|gopher|file|wais|ftp)'
 ltrs = r'\w'
 gunk = r'/#~:.?+=&%@!\-'
@@ -177,17 +191,22 @@ url  = r"""
 re_url = re.compile( url, re.VERBOSE | re.MULTILINE )
 
 #
-# used to detect the end of commented source lines
+# A regular expression that stops collection of comments for the current
+# block.
 #
-re_source_sep = re.compile( r'\s*/\*\s*\*/' )
+re_source_sep = re.compile( r'\s*/\*\s*\*/' )   #  /* */
 
 #
-# used to perform cross-reference within source output
+# A regular expression to find possible C identifiers while outputting
+# source code verbatim, covering things like `*foo' or `(bar'.  Group 1 is
+# the prefix, group 2 the identifier -- since we scan lines from left to
+# right, sequentially splitting the source code into prefix and identifier
+# is fully sufficient for our purposes.
 #
 re_source_crossref = re.compile( r'(\W*)(\w*)' )
 
 #
-# a list of reserved source keywords
+# A regular expression that matches a list of reserved C source keywords.
 #
 re_source_keywords = re.compile( '''\\b ( typedef   |
                                           struct    |
@@ -215,24 +234,16 @@ re_source_keywords = re.compile( '''\\b ( typedef   |
 ##
 ##  SOURCE BLOCK CLASS
 ##
-##   A SourceProcessor is in charge of reading a C source file
-##   and decomposing it into a series of different "SourceBlocks".
-##   each one of these blocks can be made of the following data:
-##
-##   - A documentation comment block that starts with "/**" and
-##     whose exact format will be discussed later
-##
-##   - normal sources lines, including comments
+##  There are two important fields in a `SourceBlock' object.
 ##
-##   the important fields in a text block are the following ones:
+##    self.lines
+##      A list of text lines for the corresponding block.
 ##
-##     self.lines   : a list of text lines for the corresponding block
-##
-##     self.content : for documentation comment blocks only, this is the
-##                    block content that has been "unboxed" from its
-##                    decoration. This is None for all other blocks
-##                    (i.e. sources or ordinary comments with no starting
-##                     markup tag)
+##    self.content
+##      For documentation comment blocks only, this is the block content
+##      that has been `unboxed' from its decoration.  This is `None' for all
+##      other blocks (i.e., sources or ordinary comments with no starting
+##      markup tag)
 ##
 class  SourceBlock:
 
@@ -269,7 +280,7 @@ class  SourceBlock:
     def  location( self ):
         return "(" + self.filename + ":" + repr( self.lineno ) + ")"
 
-    # debugging only - not used in normal operations
+    # debugging only -- not used in normal operations
     def  dump( self ):
         if self.content:
             print "{{{content start---"
@@ -286,39 +297,38 @@ class  SourceBlock:
             print line
 
 
-
 ################################################################
 ##
 ##  SOURCE PROCESSOR CLASS
 ##
-##   The SourceProcessor is in charge of reading a C source file
-##   and decomposing it into a series of different "SourceBlock"
-##   objects.
+##  The `SourceProcessor' is in charge of reading a C source file and
+##  decomposing it into a series of different `SourceBlock' objects.
 ##
-##   each one of these blocks can be made of the following data:
+##  A SourceBlock object consists of the following data.
 ##
-##   - A documentation comment block that starts with "/**" and
-##     whose exact format will be discussed later
+##    - A documentation comment block using one of the layouts above.  Its
+##      exact format will be discussed later.
 ##
-##   - normal sources lines, include comments
+##    - Normal sources lines, including comments.
 ##
 ##
 class  SourceProcessor:
 
     def  __init__( self ):
-        """initialize a source processor"""
+        """Initialize a source processor."""
         self.blocks   = []
         self.filename = None
         self.format   = None
         self.lines    = []
 
     def  reset( self ):
-        """reset a block processor, clean all its blocks"""
+        """Reset a block processor and clean up all its blocks."""
         self.blocks = []
         self.format = None
 
     def  parse_file( self, filename ):
-        """parse a C source file, and add its blocks to the processor's list"""
+        """Parse a C source file and add its blocks to the processor's
+           list."""
         self.reset()
 
         self.filename = filename
@@ -337,16 +347,16 @@ class  SourceProcessor:
                 self.process_normal_line( line )
             else:
                 if self.format.end.match( line ):
-                    # that's a normal block end, add it to 'lines' and
-                    # create a new block
+                    # A normal block end.  Add it to `lines' and create a
+                    # new block
                     self.lines.append( line )
                     self.add_block_lines()
                 elif self.format.column.match( line ):
-                    # that's a normal column line, add it to 'lines'
+                    # A normal column line.  Add it to `lines'.
                     self.lines.append( line )
                 else:
-                    # humm.. this is an unexpected block end,
-                    # create a new block, but don't process the line
+                    # An unexpected block end.  Create a new block, but
+                    # don't process the line.
                     self.add_block_lines()
 
                     # we need to process the line again
@@ -356,7 +366,8 @@ class  SourceProcessor:
         self.add_block_lines()
 
     def  process_normal_line( self, line ):
-        """process a normal line and check whether it is the start of a new block"""
+        """Process a normal line and check whether it is the start of a new
+           block."""
         for f in re_source_block_formats:
             if f.start.match( line ):
                 self.add_block_lines()
@@ -366,9 +377,12 @@ class  SourceProcessor:
         self.lines.append( line )
 
     def  add_block_lines( self ):
-        """add the current accumulated lines and create a new block"""
+        """Add the current accumulated lines and create a new block."""
         if self.lines != []:
-            block = SourceBlock( self, self.filename, self.lineno, self.lines )
+            block = SourceBlock( self,
+                                 self.filename,
+                                 self.lineno,
+                                 self.lines )
 
             self.blocks.append( block )
             self.format = None
@@ -376,7 +390,7 @@ class  SourceProcessor:
 
     # debugging only, not used in normal operations
     def  dump( self ):
-        """print all blocks in a processor"""
+        """Print all blocks in a processor."""
         for b in self.blocks:
             b.dump()
 
index 7944f1c..05fc08a 100644 (file)
@@ -1,5 +1,19 @@
-#  ToHTML (c) 2002, 2003, 2005-2008, 2013
-#    David Turner <david@freetype.org>
+#
+#  tohtml.py
+#
+#    A sub-class container of the `Formatter' class to produce HTML.
+#
+#  Copyright 2002, 2003, 2005-2008, 2013, 2014 by
+#  David Turner.
+#
+#  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.
+
+# The parent class is contained in file `formatter.py'.
+
 
 from sources import *
 from content import *
@@ -8,7 +22,7 @@ from formatter import *
 import time
 
 
-# The following defines the HTML header used by all generated pages.
+# The following strings define the HTML header used by all generated pages.
 html_header_1 = """\
 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
 "http://www.w3.org/TR/html4/loose.dtd">
@@ -21,62 +35,125 @@ html_header_1 = """\
 html_header_2 = """\
  API Reference</title>
 <style type="text/css">
+  a:link { color: #0000EF; }
+  a:visited { color: #51188E; }
+  a:hover { color: #FF0000; }
+
   body { font-family: Verdana, Geneva, Arial, Helvetica, serif;
          color: #000000;
-         background: #FFFFFF; }
+         background: #FFFFFF;
+         width: 87%;
+         margin: auto; }
+
+  div.section { width: 75%;
+                margin: auto; }
+  div.section hr { margin: 4ex 0 1ex 0; }
+  div.section h4 { background-color: #EEEEFF;
+                   font-size: medium;
+                   font-style: oblique;
+                   font-weight: bold;
+                   margin: 3ex 0 1.5ex 9%;
+                   padding: 0.3ex 0 0.3ex 1%; }
+  div.section p { margin: 1.5ex 0 1.5ex 10%; }
+  div.section pre { margin: 3ex 0 3ex 9%;
+                    background-color: #D6E8FF;
+                    padding: 2ex 0 2ex 1%; }
+  div.section table.fields { width: 90%;
+                             margin: 1.5ex 0 1.5ex 10%; }
+  div.section table.toc { width: 95%;
+                          margin: 1.5ex 0 1.5ex 5%; }
+  div.timestamp { text-align: center;
+                  font-size: 69%;
+                  margin: 1.5ex 0 1.5ex 0; }
 
-  p { text-align: justify; }
   h1 { text-align: center; }
-  li { text-align: justify; }
-  td { padding: 0 0.5em 0 0.5em; }
-  td.left { padding: 0 0.5em 0 0.5em;
-            text-align: left; }
+  h3 { font-size: medium;
+       margin: 4ex 0 1.5ex 0; }
 
-  a:link { color: #0000EF; }
-  a:visited { color: #51188E; }
-  a:hover { color: #FF0000; }
+  p { text-align: justify; }
+
+  pre.colored { color: blue; }
 
   span.keyword { font-family: monospace;
                  text-align: left;
                  white-space: pre;
                  color: darkblue; }
 
-  pre.colored { color: blue; }
+  table.fields td.val { font-weight: bold;
+                        text-align: right;
+                        width: 30%;
+                        vertical-align: baseline;
+                        padding: 1ex 1em 1ex 0; }
+  table.fields td.desc { vertical-align: baseline;
+                         padding: 1ex 0 1ex 1em; }
+  table.fields td.desc p:first-child { margin: 0; }
+  table.fields td.desc p { margin: 1.5ex 0 0 0; }
+  table.index { margin: 6ex auto 6ex auto;
+                border: 0;
+                border-collapse: separate;
+                border-spacing: 1em 0.3ex; }
+  table.index tr { padding: 0; }
+  table.index td { padding: 0; }
+  table.index-toc-link { width: 100%;
+                         border: 0;
+                         border-spacing: 0;
+                         margin: 1ex 0 1ex 0; }
+  table.index-toc-link td.left { padding: 0 0.5em 0 0.5em;
+                                 font-size: 83%;
+                                 text-align: left; }
+  table.index-toc-link td.middle { padding: 0 0.5em 0 0.5em;
+                                   font-size: 83%;
+                                   text-align: center; }
+  table.index-toc-link td.right { padding: 0 0.5em 0 0.5em;
+                                  font-size: 83%;
+                                  text-align: right; }
+  table.synopsis { margin: 6ex auto 6ex auto;
+                   border: 0;
+                   border-collapse: separate;
+                   border-spacing: 2em 0.6ex; }
+  table.synopsis tr { padding: 0; }
+  table.synopsis td { padding: 0; }
+  table.toc td.link { width: 30%;
+                      text-align: right;
+                      vertical-align: baseline;
+                      padding: 1ex 1em 1ex 0; }
+  table.toc td.desc { vertical-align: baseline;
+                      padding: 1ex 0 1ex 1em;
+                      text-align: left; }
+  table.toc td.desc p:first-child { margin: 0;
+                                    text-align: left; }
+  table.toc td.desc p { margin: 1.5ex 0 0 0;
+                        text-align: left; }
 
-  ul.empty { list-style-type: none; }
 </style>
 </head>
 <body>
 """
 
-html_header_3 = """
-<table align=center><tr><td><font size=-1>[<a href="\
+html_header_3l = """
+<table class="index-toc-link"><tr><td class="left">[<a href="\
 """
 
-html_header_3i = """
-<table align=center><tr><td width="100%"></td>
-<td><font size=-1>[<a href="\
+html_header_3r = """
+<table class="index-toc-link"><tr><td class="right">[<a href="\
 """
 
 html_header_4 = """\
-">Index</a>]</font></td>
-<td width="100%"></td>
-<td><font size=-1>[<a href="\
+">Index</a>]</td><td class="right">[<a href="\
 """
 
-html_header_5 = """\
-">TOC</a>]</font></td></tr></table>
-<center><h1>\
+html_header_5t = """\
+">TOC</a>]</td></tr></table>
+<h1>\
 """
 
-html_header_5t = """\
-">Index</a>]</font></td>
-<td width="100%"></td></tr></table>
-<center><h1>\
+html_header_5i = """\
+">Index</a>]</td></tr></table>
+<h1>\
 """
 
 html_header_6 = """\
- API Reference</h1></center>
+ API Reference</h1>
 """
 
 
@@ -87,8 +164,8 @@ html_footer = """\
 """
 
 # The header and footer used for each section.
-section_title_header = "<center><h1>"
-section_title_footer = "</h1></center>"
+section_title_header = "<h1>"
+section_title_footer = "</h1>"
 
 # The header and footer used for code segments.
 code_header = '<pre class="colored">'
@@ -99,66 +176,65 @@ para_header = "<p>"
 para_footer = "</p>"
 
 # Block header and footer.
-block_header        = '<table align=center width="75%"><tr><td>'
+block_header        = '<div class="section">'
 block_footer_start  = """\
-</td></tr></table>
-<hr width="75%">
-<table align=center width="75%"><tr><td><font size=-2>[<a href="\
+<hr>
+<table class="index-toc-link"><tr><td class="left">[<a href="\
 """
 block_footer_middle = """\
-">Index</a>]</font></td>
-<td width="100%"></td>
-<td><font size=-2>[<a href="\
+">Index</a>]</td>\
+<td class="middle">[<a href="#">Top</a>]</td>\
+<td class="right">[<a href="\
 """
 block_footer_end    = """\
-">TOC</a>]</font></td></tr></table>
+">TOC</a>]</td></tr></table></div>
 """
 
 # Description header/footer.
-description_header = '<table align=center width="87%"><tr><td>'
-description_footer = "</td></tr></table><br>"
+description_header = ""
+description_footer = ""
 
 # Marker header/inter/footer combination.
-marker_header = '<table align=center width="87%" cellpadding=5><tr bgcolor="#EEEEFF"><td><em><b>'
-marker_inter  = "</b></em></td></tr><tr><td>"
-marker_footer = "</td></tr></table>"
+marker_header = "<h4>"
+marker_inter  = "</h4>"
+marker_footer = ""
 
 # Header location header/footer.
-header_location_header = '<table align=center width="87%"><tr><td>'
-header_location_footer = "</td></tr></table><br>"
+header_location_header = "<p>"
+header_location_footer = "</p>"
 
 # Source code extracts header/footer.
-source_header = '<table align=center width="87%"><tr bgcolor="#D6E8FF"><td><pre>\n'
-source_footer = "\n</pre></table><br>"
+source_header = "<pre>"
+source_footer = "</pre>"
 
 # Chapter header/inter/footer.
-chapter_header = '<br><table align=center width="75%"><tr><td><h2>'
-chapter_inter  = '</h2><ul class="empty"><li>'
-chapter_footer = '</li></ul></td></tr></table>'
+chapter_header = """\
+<div class="section">
+<h2>\
+"""
+chapter_inter  = '</h2>'
+chapter_footer = '</div>'
 
 # Index footer.
 index_footer_start = """\
 <hr>
-<table><tr><td width="100%"></td>
-<td><font size=-2>[<a href="\
+<table class="index-toc-link"><tr><td class="right">[<a href="\
 """
 index_footer_end = """\
-">TOC</a>]</font></td></tr></table>
+">TOC</a>]</td></tr></table>
 """
 
 # TOC footer.
 toc_footer_start = """\
 <hr>
-<table><tr><td><font size=-2>[<a href="\
+<table class="index-toc-link"><tr><td class="left">[<a href="\
 """
 toc_footer_end = """\
-">Index</a>]</font></td>
-<td width="100%"></td>
-</tr></table>
+">Index</a>]</td></tr></table>
 """
 
 
-# source language keyword coloration/styling
+# Source language keyword coloration and styling.
 keyword_prefix = '<span class="keyword">'
 keyword_suffix = '</span>'
 
@@ -166,66 +242,78 @@ section_synopsis_header = '<h2>Synopsis</h2>'
 section_synopsis_footer = ''
 
 
-# Translate a single line of source to HTML.  This will convert
-# a "<" into "&lt.", ">" into "&gt.", etc.
+# Translate a single line of source to HTML.  This converts `<', `>', and
+# `&' into `&lt;',`&gt;', and `&amp;'.
+#
 def  html_quote( line ):
-    result = string.replace( line, "&", "&amp;" )
-    result = string.replace( result, "<", "&lt;" )
-    result = string.replace( result, ">", "&gt;" )
+    result = string.replace( line,   "&", "&amp;" )
+    result = string.replace( result, "<", "&lt;"  )
+    result = string.replace( result, ">", "&gt;"  )
     return result
 
 
-
+################################################################
+##
+##  HTML FORMATTER CLASS
+##
 class  HtmlFormatter( Formatter ):
 
     def  __init__( self, processor, project_title, file_prefix ):
         Formatter.__init__( self, processor )
 
-        global html_header_1, html_header_2, html_header_3
-        global html_header_4, html_header_5, html_footer
+        global html_header_1
+        global html_header_2
+        global html_header_3l, html_header_3r
+        global html_header_4
+        global html_header_5t, html_header_5i
+        global html_header_6
+        global html_footer
 
         if file_prefix:
             file_prefix = file_prefix + "-"
         else:
             file_prefix = ""
 
-        self.headers           = processor.headers
-        self.project_title     = project_title
-        self.file_prefix       = file_prefix
-        self.html_header       = html_header_1 + project_title +              \
-                                 html_header_2 +                              \
-                                 html_header_3 + file_prefix + "index.html" + \
-                                 html_header_4 + file_prefix + "toc.html" +   \
-                                 html_header_5 + project_title +              \
-                                 html_header_6
-
-        self.html_index_header = html_header_1 + project_title +             \
-                                 html_header_2 +                             \
-                                 html_header_3i + file_prefix + "toc.html" + \
-                                 html_header_5 + project_title +             \
-                                 html_header_6
-
-        self.html_toc_header   = html_header_1 + project_title +              \
-                                 html_header_2 +                              \
-                                 html_header_3 + file_prefix + "index.html" + \
-                                 html_header_5t + project_title +             \
-                                 html_header_6
-
-        self.html_footer       = "<center><font size=""-2"">generated on " +     \
-                                 time.asctime( time.localtime( time.time() ) ) + \
-                                 "</font></center>" + html_footer
+        self.headers       = processor.headers
+        self.project_title = project_title
+        self.file_prefix   = file_prefix
+        self.html_header   = (
+          html_header_1 + project_title
+          + html_header_2
+          + html_header_3l + file_prefix + "index.html"
+          + html_header_4 + file_prefix + "toc.html"
+          + html_header_5t + project_title
+          + html_header_6 )
+        self.html_index_header = (
+          html_header_1 + project_title
+          + html_header_2
+          + html_header_3r + file_prefix + "toc.html"
+          + html_header_5t + project_title
+          + html_header_6 )
+        self.html_toc_header = (
+          html_header_1 + project_title
+          + html_header_2
+          + html_header_3l + file_prefix + "index.html"
+          + html_header_5i + project_title
+          + html_header_6 )
+        self.html_footer = (
+          '<div class="timestamp">generated on '
+          + time.asctime( time.localtime( time.time() ) )
+          + "</div>" + html_footer )
 
         self.columns = 3
 
     def  make_section_url( self, section ):
         return self.file_prefix + section.name + ".html"
 
-    def  make_block_url( self, block ):
-        return self.make_section_url( block.section ) + "#" + block.name
+    def  make_block_url( self, block, name = None ):
+        if name == None:
+            name = block.name
+        return self.make_section_url( block.section ) + "#" + name
 
     def  make_html_word( self, word ):
-        """analyze a simple word to detect cross-references and styling"""
-        # look for cross-references
+        """Analyze a simple word to detect cross-references and markup."""
+        # handle cross-references
         m = re_crossref.match( word )
         if m:
             try:
@@ -236,27 +324,28 @@ class  HtmlFormatter( Formatter ):
                 return '<a href="' + url + '">' + name + '</a>' + rest
             except:
                 # we detected a cross-reference to an unknown item
-                sys.stderr.write( \
-                   "WARNING: undefined cross reference '" + name + "'.\n" )
+                sys.stderr.write( "WARNING: undefined cross reference"
+                                  + " '" + name + "'.\n" )
                 return '?' + name + '?' + rest
 
-        # look for italics and bolds
+        # handle markup for italic and bold
         m = re_italic.match( word )
         if m:
             name = m.group( 1 )
-            rest = m.group( 3 )
+            rest = m.group( 2 )
             return '<i>' + name + '</i>' + rest
 
         m = re_bold.match( word )
         if m:
             name = m.group( 1 )
-            rest = m.group( 3 )
+            rest = m.group( 2 )
             return '<b>' + name + '</b>' + rest
 
         return html_quote( word )
 
     def  make_html_para( self, words ):
-        """ convert words of a paragraph into tagged HTML text, handle xrefs """
+        """Convert words of a paragraph into tagged HTML text.  Also handle
+           cross references."""
         line = ""
         if words:
             line = self.make_html_word( words[0] )
@@ -265,8 +354,8 @@ class  HtmlFormatter( Formatter ):
             # handle hyperlinks
             line = re_url.sub( r'<a href="\1">\1</a>', line )
             # convert `...' quotations into real left and right single quotes
-            line = re.sub( r"(^|\W)`(.*?)'(\W|$)",  \
-                           r'\1&lsquo;\2&rsquo;\3', \
+            line = re.sub( r"(^|\W)`(.*?)'(\W|$)",
+                           r'\1&lsquo;\2&rsquo;\3',
                            line )
             # convert tilde into non-breakable space
             line = string.replace( line, "~", "&nbsp;" )
@@ -274,7 +363,7 @@ class  HtmlFormatter( Formatter ):
         return para_header + line + para_footer
 
     def  make_html_code( self, lines ):
-        """ convert a code sequence to HTML """
+        """Convert a code sequence to HTML."""
         line = code_header + '\n'
         for l in lines:
             line = line + html_quote( l ) + '\n'
@@ -282,7 +371,7 @@ class  HtmlFormatter( Formatter ):
         return line + code_footer
 
     def  make_html_items( self, items ):
-        """ convert a field's content into some valid HTML """
+        """Convert a field's content into HTML."""
         lines = []
         for item in items:
             if item.lines:
@@ -297,7 +386,9 @@ class  HtmlFormatter( Formatter ):
 
     def  print_html_field( self, field ):
         if field.name:
-            print "<table><tr valign=top><td><b>" + field.name + "</b></td><td>"
+            print( '<table><tr valign="top"><td><b>'
+                   + field.name
+                   + "</b></td><td>" )
 
         print self.make_html_items( field.items )
 
@@ -318,12 +409,24 @@ class  HtmlFormatter( Formatter ):
                     result = result + prefix + '<b>' + name + '</b>'
                 elif re_source_keywords.match( name ):
                     # this is a C keyword
-                    result = result + prefix + keyword_prefix + name + keyword_suffix
-                elif self.identifiers.has_key( name ):
+                    result = ( result + prefix
+                               + keyword_prefix + name + keyword_suffix )
+                elif name in self.identifiers:
                     # this is a known identifier
                     block = self.identifiers[name]
-                    result = result + prefix + '<a href="' + \
-                             self.make_block_url( block ) + '">' + name + '</a>'
+                    id = block.name
+
+                    # link to a field ID if possible
+                    for markup in block.markups:
+                        if markup.tag == 'values':
+                            for field in markup.fields:
+                                if field.name:
+                                    id = name
+
+                    result = ( result + prefix
+                               + '<a href="'
+                               + self.make_block_url( block, id )
+                               + '">' + name + '</a>' )
                 else:
                     result = result + html_quote( line[:length] )
 
@@ -335,15 +438,11 @@ class  HtmlFormatter( Formatter ):
         return result
 
     def  print_html_field_list( self, fields ):
-        print "<p></p>"
-        print "<table cellpadding=3 border=0>"
+        print '<table class="fields">'
         for field in fields:
-            if len( field.name ) > 22:
-              print "<tr valign=top><td colspan=0><b>" + field.name + "</b></td></tr>"
-              print "<tr valign=top><td></td><td>"
-            else:
-              print "<tr valign=top><td><b>" + field.name + "</b></td><td>"
-
+            print ( '<tr><td class="val" id="' + field.name + '">'
+                    + field.name
+                    + '</td><td class="desc">' )
             self.print_html_items( field.items )
             print "</td></tr>"
         print "</table>"
@@ -352,10 +451,9 @@ class  HtmlFormatter( Formatter ):
         table_fields = []
         for field in markup.fields:
             if field.name:
-                # we begin a new series of field or value definitions, we
-                # will record them in the 'table_fields' list before outputting
-                # all of them as a single table
-                #
+                # We begin a new series of field or value definitions.  We
+                # record them in the `table_fields' list before outputting
+                # all of them as a single table.
                 table_fields.append( field )
             else:
                 if table_fields:
@@ -368,7 +466,7 @@ class  HtmlFormatter( Formatter ):
             self.print_html_field_list( table_fields )
 
     #
-    #  Formatting the index
+    # formatting the index
     #
     def  index_enter( self ):
         print self.html_index_header
@@ -380,11 +478,11 @@ class  HtmlFormatter( Formatter ):
         self.index_items[name] = url
 
     def  index_exit( self ):
-        # block_index already contains the sorted list of index names
+        # `block_index' already contains the sorted list of index names
         count = len( self.block_index )
-        rows  = ( count + self.columns - 1 ) / self.columns
+        rows  = ( count + self.columns - 1 ) // self.columns
 
-        print "<table align=center border=0 cellpadding=0 cellspacing=0>"
+        print '<table class="index">'
         for r in range( rows ):
             line = "<tr>"
             for c in range( self.columns ):
@@ -392,7 +490,8 @@ class  HtmlFormatter( Formatter ):
                 if i < count:
                     bname = self.block_index[r + c * rows]
                     url   = self.index_items[bname]
-                    line = line + '<td><a href="' + url + '">' + bname + '</a></td>'
+                    line  = ( line + '<td><a href="' + url + '">'
+                              + bname + '</a></td>' )
                 else:
                     line = line + '<td></td>'
             line = line + "</tr>"
@@ -400,9 +499,9 @@ class  HtmlFormatter( Formatter ):
 
         print "</table>"
 
-        print index_footer_start +            \
-              self.file_prefix + "toc.html" + \
-              index_footer_end
+        print( index_footer_start
+               + self.file_prefix + "toc.html"
+               + index_footer_end )
 
         print self.html_footer
 
@@ -415,21 +514,20 @@ class  HtmlFormatter( Formatter ):
         Formatter.index_dump( self, index_filename )
 
     #
-    #  Formatting the table of content
+    # formatting the table of contents
     #
     def  toc_enter( self ):
         print self.html_toc_header
-        print "<center><h1>Table of Contents</h1></center>"
+        print "<h1>Table of Contents</h1>"
 
     def  toc_chapter_enter( self, chapter ):
-        print  chapter_header + string.join( chapter.title ) + chapter_inter
-        print "<table cellpadding=5>"
+        print chapter_header + string.join( chapter.title ) + chapter_inter
+        print '<table class="toc">'
 
     def  toc_section_enter( self, section ):
-        print '<tr valign=top><td class="left">'
-        print '<a href="' + self.make_section_url( section ) + '">' + \
-               section.title + '</a></td><td>'
-
+        print ( '<tr><td class="link">'
+                + '<a href="' + self.make_section_url( section ) + '">'
+                + section.title + '</a></td><td class="desc">' )
         print self.make_html_para( section.abstract )
 
     def  toc_section_exit( self, section ):
@@ -440,14 +538,14 @@ class  HtmlFormatter( Formatter ):
         print chapter_footer
 
     def  toc_index( self, index_filename ):
-        print chapter_header +                                      \
-              '<a href="' + index_filename + '">Global Index</a>' + \
-              chapter_inter + chapter_footer
+        print( chapter_header
+               + '<a href="' + index_filename + '">Global Index</a>'
+               + chapter_inter + chapter_footer )
 
     def  toc_exit( self ):
-        print toc_footer_start +                \
-              self.file_prefix + "index.html" + \
-              toc_footer_end
+        print( toc_footer_start
+               + self.file_prefix + "index.html"
+               + toc_footer_end )
 
         print self.html_footer
 
@@ -461,14 +559,12 @@ class  HtmlFormatter( Formatter ):
         Formatter.toc_dump( self, toc_filename, index_filename )
 
     #
-    #  Formatting sections
+    # formatting sections
     #
     def  section_enter( self, section ):
         print self.html_header
 
-        print section_title_header
-        print section.title
-        print section_title_footer
+        print section_title_header + section.title + section_title_footer
 
         maxwidth = 0
         for b in section.blocks.values():
@@ -476,32 +572,43 @@ class  HtmlFormatter( Formatter ):
                 maxwidth = len( b.name )
 
         width = 70  # XXX magic number
-        if maxwidth <> 0:
+        if maxwidth > 0:
             # print section synopsis
             print section_synopsis_header
-            print "<table align=center cellspacing=5 cellpadding=0 border=0>"
+            print '<table class="synopsis">'
 
-            columns = width / maxwidth
+            columns = width // maxwidth
             if columns < 1:
                 columns = 1
 
             count = len( section.block_names )
-            rows  = ( count + columns - 1 ) / columns
+            # don't handle last entry if it is empty
+            if section.block_names[-1] == "/empty/":
+                count -= 1
+            rows  = ( count + columns - 1 ) // columns
 
             for r in range( rows ):
                 line = "<tr>"
                 for c in range( columns ):
                     i = r + c * rows
-                    line = line + '<td></td><td>'
+                    line = line + '<td>'
                     if i < count:
                         name = section.block_names[i]
-                        line = line + '<a href="#' + name + '">' + name + '</a>'
+                        if name == "/empty/":
+                            # it can happen that a complete row is empty, and
+                            # without a proper `filler' the browser might
+                            # collapse the row to a much smaller height (or
+                            # even omit it completely)
+                            line = line + "&nbsp;"
+                        else:
+                            line = ( line + '<a href="#' + name + '">'
+                                     + name + '</a>' )
 
                     line = line + '</td>'
                 line = line + "</tr>"
                 print line
 
-            print "</table><br><br>"
+            print "</table>"
             print section_synopsis_footer
 
         print description_header
@@ -513,7 +620,7 @@ class  HtmlFormatter( Formatter ):
 
         # place html anchor if needed
         if block.name:
-            print '<h4><a name="' + block.name + '">' + block.name + '</a></h4>'
+            print( '<h3 id="' + block.name + '">' + block.name + '</h3>' )
 
         # dump the block C source lines now
         if block.code:
@@ -521,16 +628,17 @@ class  HtmlFormatter( Formatter ):
             for f in self.headers.keys():
                 if block.source.filename.find( f ) >= 0:
                     header = self.headers[f] + ' (' + f + ')'
-                    break;
+                    break
 
 #           if not header:
-#               sys.stderr.write( \
-#                 'WARNING: No header macro for ' + block.source.filename + '.\n' )
+#               sys.stderr.write(
+#                 "WARNING: No header macro for"
+#                 + " '" + block.source.filename + "'.\n" )
 
             if header:
-                print header_location_header
-                print 'Defined in ' + header + '.'
-                print header_location_footer
+                print header_location_header
+                        + 'Defined in ' + header + '.'
+                        + header_location_footer )
 
             print source_header
             for l in block.code:
@@ -552,15 +660,16 @@ class  HtmlFormatter( Formatter ):
             print marker_footer
 
     def  block_exit( self, block ):
-        print block_footer_start + self.file_prefix + "index.html" + \
-              block_footer_middle + self.file_prefix + "toc.html" +  \
-              block_footer_end
+        print( block_footer_start + self.file_prefix + "index.html"
+               + block_footer_middle + self.file_prefix + "toc.html"
+               + block_footer_end )
 
     def  section_exit( self, section ):
         print html_footer
 
     def  section_dump_all( self ):
         for section in self.sections:
-            self.section_dump( section, self.file_prefix + section.name + '.html' )
+            self.section_dump( section,
+                               self.file_prefix + section.name + '.html' )
 
 # eof
index 1d96658..b35823a 100644 (file)
@@ -1,48 +1,42 @@
-#  Utils (c) 2002, 2004, 2007, 2008  David Turner <david@freetype.org>
 #
-
-import string, sys, os, glob
-
-# current output directory
+#  utils.py
 #
-output_dir = None
-
-
-# This function is used to sort the index.  It is a simple lexicographical
-# sort, except that it places capital letters before lowercase ones.
+#    Auxiliary functions for the `docmaker' tool (library file).
 #
-def  index_sort( s1, s2 ):
-    if not s1:
-        return -1
-
-    if not s2:
-        return 1
-
-    l1 = len( s1 )
-    l2 = len( s2 )
-    m1 = string.lower( s1 )
-    m2 = string.lower( s2 )
+#  Copyright 2002, 2004, 2007, 2008, 2014 by
+#  David Turner.
+#
+#  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.
 
-    for i in range( l1 ):
-        if i >= l2 or m1[i] > m2[i]:
-            return 1
 
-        if m1[i] < m2[i]:
-            return -1
+import string, sys, os, glob, itertools
 
-        if s1[i] < s2[i]:
-            return -1
 
-        if s1[i] > s2[i]:
-            return 1
+# current output directory
+#
+output_dir = None
 
-    if l2 > l1:
-        return -1
 
-    return 0
+# A function that generates a sorting key.  We want lexicographical order
+# (primary key) except that capital letters are sorted before lowercase
+# ones (secondary key).
+#
+# The primary key is implemented by lowercasing the input.  The secondary
+# key is simply the original data appended, character by character.  For
+# example, the sort key for `FT_x' is `fFtT__xx', while the sort key for
+# `ft_X' is `fftt__xX'.  Since ASCII codes of uppercase letters are
+# numerically smaller than the codes of lowercase letters, `fFtT__xx' gets
+# sorted before `fftt__xX'.
+#
+def  index_key( s ):
+    return string.join( itertools.chain( *zip( s.lower(), s ) ) )
 
 
-# Sort input_list, placing the elements of order_list in front.
+# Sort `input_list', placing the elements of `order_list' in front.
 #
 def  sort_order_list( input_list, order_list ):
     new_list = order_list[:]
@@ -52,9 +46,9 @@ def  sort_order_list( input_list, order_list ):
     return new_list
 
 
-# Open the standard output to a given project documentation file.  Use
-# "output_dir" to determine the filename location if necessary and save the
-# old stdout in a tuple that is returned by this function.
+# Divert standard output to a given project documentation file.  Use
+# `output_dir' to determine the filename location if necessary and save the
+# old stdout handle in a tuple that is returned by this function.
 #
 def  open_output( filename ):
     global output_dir
@@ -69,7 +63,7 @@ def  open_output( filename ):
     return ( new_file, old_stdout )
 
 
-# Close the output that was returned by "close_output".
+# Close the output that was returned by `open_output'.
 #
 def  close_output( output ):
     output[0].close()
@@ -83,15 +77,16 @@ def  check_output():
     if output_dir:
         if output_dir != "":
             if not os.path.isdir( output_dir ):
-                sys.stderr.write( "argument" + " '" + output_dir + "' " + \
-                                  "is not a valid directory" )
+                sys.stderr.write( "argument"
+                                  + " '" + output_dir + "' "
+                                  + "is not a valid directory" )
                 sys.exit( 2 )
         else:
             output_dir = None
 
 
 def  file_exists( pathname ):
-    """checks that a given file exists"""
+    """Check that a given file exists."""
     result = 1
     try:
         file = open( pathname, "r" )
@@ -104,12 +99,12 @@ def  file_exists( pathname ):
 
 
 def  make_file_list( args = None ):
-    """builds a list of input files from command-line arguments"""
+    """Build a list of input files from command-line arguments."""
     file_list = []
     # sys.stderr.write( repr( sys.argv[1 :] ) + '\n' )
 
     if not args:
-        args = sys.argv[1 :]
+        args = sys.argv[1:]
 
     for pathname in args:
         if string.find( pathname, '*' ) >= 0:
index 7c97957..9a5b632 100644 (file)
       fseek( new, getRandom( 0, item->len - 1 ), SEEK_SET );
 
       if ( item->isbinary )
-        putc( getRandom( 0, 0xff ), new );
+        putc( getRandom( 0, 0xFF ), new );
       else if ( item->isascii )
-        putc( getRandom( 0x20, 0x7e ), new );
+        putc( getRandom( 0x20, 0x7E ), new );
       else
       {
         int  hex = getRandom( 0, 15 );
index 49d927e..99ac1cf 100644 (file)
@@ -20,7 +20,7 @@
     int  i;
 
 
-    for ( i = 0; i < FT_ANGLE_2PI; i += 0x10000 )
+    for ( i = 0; i < FT_ANGLE_2PI; i += 0x10000L )
     {
       FT_Fixed  f1, f2;
       double    d2;
@@ -46,7 +46,7 @@
     int  i;
 
 
-    for ( i = 0; i < FT_ANGLE_2PI; i += 0x10000 )
+    for ( i = 0; i < FT_ANGLE_2PI; i += 0x10000L )
     {
       FT_Fixed  f1, f2;
       double    d2;
@@ -72,7 +72,7 @@
     int  i;
 
 
-    for ( i = 0; i < FT_ANGLE_PI2-0x2000000; i += 0x10000 )
+    for ( i = 0; i < FT_ANGLE_PI2 - 0x2000000L; i += 0x10000L )
     {
       FT_Fixed  f1, f2;
       double    d2;
@@ -98,7 +98,7 @@
     int  i;
 
 
-    for ( i = 0; i < FT_ANGLE_2PI; i += 0x10000 )
+    for ( i = 0; i < FT_ANGLE_2PI; i += 0x10000L )
     {
       FT_Fixed  c2, s2;
       double    l, a, c1, s1;
     int  i;
 
 
-    for ( i = 0; i < FT_ANGLE_2PI; i += 0x10000 )
+    for ( i = 0; i < FT_ANGLE_2PI; i += 0x10000L )
     {
       FT_Vector  v;
       double     a, c1, s1;
     int  i;
 
 
-    for ( i = 0; i < FT_ANGLE_2PI; i += 0x10000 )
+    for ( i = 0; i < FT_ANGLE_2PI; i += 0x10000L )
     {
       FT_Vector  v;
       FT_Fixed   l, l2;
     int  rotate;
 
 
-    for ( rotate = 0; rotate < FT_ANGLE_2PI; rotate += 0x10000 )
+    for ( rotate = 0; rotate < FT_ANGLE_2PI; rotate += 0x10000L )
     {
       double  ra, cra, sra;
       int     i;
       cra = cos( ra );
       sra = sin( ra );
 
-      for ( i = 0; i < FT_ANGLE_2PI; i += 0x10000 )
+      for ( i = 0; i < FT_ANGLE_2PI; i += 0x10000L )
       {
         FT_Fixed   c2, s2, c4, s4;
         FT_Vector  v;
index 36d23a2..ecf4cdc 100644 (file)
@@ -4,7 +4,7 @@
 /*                                                                         */
 /*    TrueType font driver implementation (body).                          */
 /*                                                                         */
-/*  Copyright 1996-2013 by                                                 */
+/*  Copyright 1996-2014 by                                                 */
 /*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
 /*                                                                         */
 /*  This file is part of the FreeType project, and may only be used,       */
       /* use the scaled metrics, even when tt_size_reset fails */
       FT_Select_Metrics( size->face, strike_index );
 
-      tt_size_reset( ttsize );
+      tt_size_reset( ttsize ); /* ignore return value */
     }
     else
     {
       return FT_THROW( Invalid_Size_Handle );
 
     if ( !face )
-      return FT_THROW( Invalid_Argument );
+      return FT_THROW( Invalid_Face_Handle );
 
 #ifdef FT_CONFIG_OPTION_INCREMENTAL
     if ( glyph_index >= (FT_UInt)face->num_glyphs &&
     SFNT_Service         sfnt;
 
 
-    /* TT_SERVICES_GET derefers `library' in PIC mode */
+    /* TT_SERVICES_GET dereferences `library' in PIC mode */
 #ifdef FT_CONFIG_OPTION_PIC
     if ( !driver )
       return NULL;
index 5f676a2..c5841c3 100644 (file)
@@ -4,7 +4,7 @@
 /*                                                                         */
 /*    TrueType Glyph Loader (body).                                        */
 /*                                                                         */
-/*  Copyright 1996-2013                                                    */
+/*  Copyright 1996-2014                                                    */
 /*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
 /*                                                                         */
 /*  This file is part of the FreeType project, and may only be used,       */
 
     else if ( face->os2.version != 0xFFFFU )
     {
-      *tsb = face->os2.sTypoAscender - yMax;
+      *tsb = (FT_Short)( face->os2.sTypoAscender - yMax );
       *ah  = face->os2.sTypoAscender - face->os2.sTypoDescender;
     }
 
     else
     {
-      *tsb = face->horizontal.Ascender - yMax;
+      *tsb = (FT_Short)( face->horizontal.Ascender - yMax );
       *ah  = face->horizontal.Ascender - face->horizontal.Descender;
     }
 
       FT_Outline      current_outline = gloader->current.outline;
 
 
-      error = TT_Set_CodeRange( loader->exec, tt_coderange_glyph,
-                                loader->exec->glyphIns, n_ins );
-      if ( error )
-        return error;
+      TT_Set_CodeRange( loader->exec, tt_coderange_glyph,
+                        loader->exec->glyphIns, n_ins );
 
       loader->exec->is_composite = is_composite;
       loader->exec->pts          = *zone;
           /* (1): exists from the beginning                               */
           /* (2): components that have been loaded so far                 */
           /* (3): the newly loaded component                              */
-          TT_Process_Composite_Component( loader, subglyph, start_point,
-                                          num_base_points );
+          error = TT_Process_Composite_Component( loader,
+                                                  subglyph,
+                                                  start_point,
+                                                  num_base_points );
+          if ( error )
+            goto Exit;
         }
 
         loader->stream   = old_stream;
         /* process the glyph */
         loader->ins_pos = ins_pos;
         if ( IS_HINTED( loader->load_flags ) &&
-
 #ifdef TT_USE_BYTECODE_INTERPRETER
-
              subglyph->flags & WE_HAVE_INSTR &&
-
 #endif
-
              num_points > start_point )
-          TT_Process_Composite_Glyph( loader, start_point, start_contour );
-
+        {
+          error = TT_Process_Composite_Glyph( loader,
+                                              start_point,
+                                              start_contour );
+          if ( error )
+            goto Exit;
+        }
       }
     }
     else
                   FT_Int32      load_flags,
                   FT_Bool       glyf_table_only )
   {
+    FT_Error  error;
+
     TT_Face    face;
     FT_Stream  stream;
 #ifdef TT_USE_BYTECODE_INTERPRETER
       FT_Bool  reexecute = FALSE;
 
 
-      if ( !size->cvt_ready )
+      if ( size->bytecode_ready < 0 || size->cvt_ready < 0 )
       {
-        FT_Error  error = tt_size_ready_bytecode( size, pedantic );
-
-
+        error = tt_size_ready_bytecode( size, pedantic );
         if ( error )
           return error;
       }
+      else if ( size->bytecode_ready )
+        return size->bytecode_ready;
+      else if ( size->cvt_ready )
+        return size->cvt_ready;
 
       /* query new execution context */
       exec = size->debug ? size->context
                              FT_RENDER_MODE_MONO );
       }
 
-      TT_Load_Context( exec, face, size );
+      error = TT_Load_Context( exec, face, size );
+      if ( error )
+        return error;
 
 #ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
 
 
         for ( i = 0; i < size->cvt_size; i++ )
           size->cvt[i] = FT_MulFix( face->cvt[i], size->ttmetrics.scale );
-        tt_size_run_prep( size, pedantic );
+        error = tt_size_run_prep( size, pedantic );
+        if ( error )
+          return error;
       }
 
       /* see whether the cvt program has disabled hinting */
 #endif
 
     {
-      FT_Error  error = face->goto_table( face, TTAG_glyf, stream, 0 );
-
+      error = face->goto_table( face, TTAG_glyf, stream, 0 );
 
       if ( FT_ERR_EQ( error, Table_Missing ) )
         loader->glyf_offset = 0;
           (void)tt_loader_init( &loader, size, glyph, load_flags, TRUE );
           (void)load_truetype_glyph( &loader, glyph_index, 0, TRUE );
           glyph->linearHoriAdvance = loader.linear;
-          glyph->linearVertAdvance = loader.top_bearing + loader.bbox.yMax -
-                                       loader.vadvance;
+          glyph->linearVertAdvance = loader.vadvance;
 
-          /* sanity check: if `horiAdvance' in the sbit metric */
-          /* structure isn't set, use `linearHoriAdvance'      */
+          /* sanity checks: if `xxxAdvance' in the sbit metric */
+          /* structure isn't set, use `linearXXXAdvance'      */
           if ( !glyph->metrics.horiAdvance && glyph->linearHoriAdvance )
             glyph->metrics.horiAdvance =
               FT_MulFix( glyph->linearHoriAdvance,
                          size->root.metrics.x_scale );
+          if ( !glyph->metrics.vertAdvance && glyph->linearVertAdvance )
+            glyph->metrics.vertAdvance =
+              FT_MulFix( glyph->linearVertAdvance,
+                         size->root.metrics.y_scale );
         }
 
         return FT_Err_Ok;
 
 #endif /* TT_USE_BYTECODE_INTERPRETER */
 
-      compute_glyph_metrics( &loader, glyph_index );
+      error = compute_glyph_metrics( &loader, glyph_index );
     }
 
     /* Set the `high precision' bit flag.                           */
index 7899d36..1b35539 100644 (file)
@@ -4,7 +4,7 @@
 /*                                                                         */
 /*    TrueType GX Font Variation loader                                    */
 /*                                                                         */
-/*  Copyright 2004-2013 by                                                 */
+/*  Copyright 2004-2014 by                                                 */
 /*  David Turner, Robert Wilhelm, Werner Lemberg, and George Williams.     */
 /*                                                                         */
 /*  This file is part of the FreeType project, and may only be used,       */
         FT_FREE( face->cvt );
         face->cvt = NULL;
 
-        tt_face_load_cvt( face, face->root.stream );
+        error = tt_face_load_cvt( face, face->root.stream );
         break;
 
       case mcvt_modify:
         /* The original cvt table is in memory.  All we need to do is */
         /* apply the `cvar' table (if any).                           */
-        tt_face_vary_cvt( face, face->root.stream );
+        error = tt_face_vary_cvt( face, face->root.stream );
         break;
 
       case mcvt_retain:
index 56e8fa7..eccd4aa 100644 (file)
 #define CUR_Func_round( d, c ) \
           CUR.func_round( EXEC_ARG_ d, c )
 
+#define CUR_Func_cur_ppem() \
+          CUR.func_cur_ppem( EXEC_ARG )
+
 #define CUR_Func_read_cvt( index ) \
           CUR.func_read_cvt( EXEC_ARG_ index )
 
 #define CURRENT_Ratio() \
           Current_Ratio( EXEC_ARG )
 
-#define CURRENT_Ppem() \
-          Current_Ppem( EXEC_ARG )
-
-#define CUR_Ppem() \
-          Cur_PPEM( EXEC_ARG )
-
 #define INS_SxVTL( a, b, c, d ) \
           Ins_SxVTL( EXEC_ARG_ a, b, c, d )
 
   /* <InOut>                                                               */
   /*    exec  :: The target execution context.                             */
   /*                                                                       */
-  /* <Return>                                                              */
-  /*    FreeType error code.  0 means success.                             */
-  /*                                                                       */
-  FT_LOCAL_DEF( FT_Error )
+  FT_LOCAL_DEF( void )
   TT_Goto_CodeRange( TT_ExecContext  exec,
                      FT_Int          range,
                      FT_Long         IP )
     exec->codeSize = coderange->size;
     exec->IP       = IP;
     exec->curRange = range;
-
-    return FT_Err_Ok;
   }
 
 
   /* <InOut>                                                               */
   /*    exec   :: The target execution context.                            */
   /*                                                                       */
-  /* <Return>                                                              */
-  /*    FreeType error code.  0 means success.                             */
-  /*                                                                       */
-  FT_LOCAL_DEF( FT_Error )
+  FT_LOCAL_DEF( void )
   TT_Set_CodeRange( TT_ExecContext  exec,
                     FT_Int          range,
                     void*           base,
 
     exec->codeRangeTable[range - 1].base = (FT_Byte*)base;
     exec->codeRangeTable[range - 1].size = length;
-
-    return FT_Err_Ok;
   }
 
 
   /* <InOut>                                                               */
   /*    exec  :: The target execution context.                             */
   /*                                                                       */
-  /* <Return>                                                              */
-  /*    FreeType error code.  0 means success.                             */
-  /*                                                                       */
-  /* <Note>                                                                */
-  /*    Does not set the Error variable.                                   */
-  /*                                                                       */
-  FT_LOCAL_DEF( FT_Error )
+  FT_LOCAL_DEF( void )
   TT_Clear_CodeRange( TT_ExecContext  exec,
                       FT_Int          range )
   {
 
     exec->codeRangeTable[range - 1].base = NULL;
     exec->codeRangeTable[range - 1].size = 0;
-
-    return FT_Err_Ok;
   }
 
 
   /*                                                                       */
   /*    memory :: A handle to the parent memory object.                    */
   /*                                                                       */
-  /* <Return>                                                              */
-  /*    FreeType error code.  0 means success.                             */
-  /*                                                                       */
   /* <Note>                                                                */
   /*    Only the glyph loader and debugger should call this function.      */
   /*                                                                       */
-  FT_LOCAL_DEF( FT_Error )
+  FT_LOCAL_DEF( void )
   TT_Done_Context( TT_ExecContext  exec )
   {
     FT_Memory  memory = exec->memory;
     exec->face = NULL;
 
     FT_FREE( exec );
-
-    return FT_Err_Ok;
   }
 
 
   /* <InOut>                                                               */
   /*    size :: A handle to the target size object.                        */
   /*                                                                       */
-  /* <Return>                                                              */
-  /*    FreeType error code.  0 means success.                             */
-  /*                                                                       */
   /* <Note>                                                                */
   /*    Only the glyph loader and debugger should call this function.      */
   /*                                                                       */
-  FT_LOCAL_DEF( FT_Error )
+  FT_LOCAL_DEF( void )
   TT_Save_Context( TT_ExecContext  exec,
                    TT_Size         size )
   {
 
     for ( i = 0; i < TT_MAX_CODE_RANGES; i++ )
       size->codeRangeTable[i] = exec->codeRangeTable[i];
-
-    return FT_Err_Ok;
   }
 
 
   TT_Run_Context( TT_ExecContext  exec,
                   FT_Bool         debug )
   {
-    FT_Error  error;
-
-
-    if ( ( error = TT_Goto_CodeRange( exec, tt_coderange_glyph, 0 ) )
-           != FT_Err_Ok )
-      return error;
+    TT_Goto_CodeRange( exec, tt_coderange_glyph, 0 );
 
     exec->zp0 = exec->pts;
     exec->zp1 = exec->pts;
   FT_EXPORT_DEF( TT_ExecContext )
   TT_New_Context( TT_Driver  driver )
   {
-    FT_Memory  memory = driver->root.root.memory;
+    FT_Memory  memory;
+
+
+    if ( !driver )
+      goto Fail;
 
+    memory = driver->root.root.memory;
 
     if ( !driver->context )
     {
   TT_MulFix14_arm( FT_Int32  a,
                    FT_Int    b )
   {
-    register FT_Int32  t, t2;
+    FT_Int32  t, t2;
 
 
 #if defined( __CC_ARM ) || defined( __ARMCC__ )
   }
 
 
-  static FT_Long
+  FT_CALLBACK_DEF( FT_Long )
   Current_Ppem( EXEC_OP )
+  {
+    return CUR.tt_metrics.ppem;
+  }
+
+
+  FT_CALLBACK_DEF( FT_Long )
+  Current_Ppem_Stretched( EXEC_OP )
   {
     return FT_MulFix( CUR.tt_metrics.ppem, CURRENT_Ratio() );
   }
     if ( distance >= 0 )
     {
       val = distance + compensation;
-      if ( distance && val < 0 )
+      if ( val < 0 )
         val = 0;
     }
     else
 
     if ( distance >= 0 )
     {
-      val = distance + compensation + 32;
-      if ( distance && val > 0 )
-        val &= ~63;
-      else
+      val = FT_PIX_ROUND( distance + compensation );
+      if ( val < 0 )
         val = 0;
     }
     else
     if ( distance >= 0 )
     {
       val = FT_PIX_FLOOR( distance + compensation ) + 32;
-      if ( distance && val < 0 )
-        val = 0;
+      if ( val < 0 )
+        val = 32;
     }
     else
     {
       val = -( FT_PIX_FLOOR( compensation - distance ) + 32 );
       if ( val > 0 )
-        val = 0;
+        val = -32;
     }
 
     return val;
 
     if ( distance >= 0 )
     {
-      val = distance + compensation;
-      if ( distance && val > 0 )
-        val &= ~63;
-      else
+      val = FT_PIX_FLOOR( distance + compensation );
+      if ( val < 0 )
         val = 0;
     }
     else
     {
-      val = -( ( compensation - distance ) & -64 );
+      val = -FT_PIX_FLOOR( compensation - distance );
       if ( val > 0 )
         val = 0;
     }
 
     if ( distance >= 0 )
     {
-      val = distance + compensation + 63;
-      if ( distance && val > 0 )
-        val &= ~63;
-      else
+      val = FT_PIX_CEIL( distance + compensation );
+      if ( val < 0 )
         val = 0;
     }
     else
 
     if ( distance >= 0 )
     {
-      val = distance + compensation + 16;
-      if ( distance && val > 0 )
-        val &= ~31;
-      else
+      val = FT_PAD_ROUND( distance + compensation, 32 );
+      if ( val < 0 )
         val = 0;
     }
     else
     {
       val = ( distance - CUR.phase + CUR.threshold + compensation ) &
               -CUR.period;
-      if ( distance && val < 0 )
-        val = 0;
       val += CUR.phase;
+      if ( val < 0 )
+        val = CUR.phase;
     }
     else
     {
       val = -( ( CUR.threshold - CUR.phase - distance + compensation ) &
                -CUR.period );
-      if ( val > 0 )
-        val = 0;
       val -= CUR.phase;
+      if ( val > 0 )
+        val = -CUR.phase;
     }
 
     return val;
     {
       val = ( ( distance - CUR.phase + CUR.threshold + compensation ) /
                 CUR.period ) * CUR.period;
-      if ( distance && val < 0 )
-        val = 0;
       val += CUR.phase;
+      if ( val < 0 )
+        val = CUR.phase;
     }
     else
     {
       val = -( ( ( CUR.threshold - CUR.phase - distance + compensation ) /
                    CUR.period ) * CUR.period );
-      if ( val > 0 )
-        val = 0;
       val -= CUR.phase;
+      if ( val > 0 )
+        val = -CUR.phase;
     }
 
     return val;
     CUR.GS.auto_flip = FALSE;
 
 
-#define DO_SDB                             \
-    CUR.GS.delta_base = (FT_Short)args[0];
+#define DO_SDB                              \
+    CUR.GS.delta_base = (FT_UShort)args[0];
 
 
-#define DO_SDS                              \
-    CUR.GS.delta_shift = (FT_Short)args[0];
+#define DO_SDS                                 \
+    if ( (FT_ULong)args[0] > 6UL )             \
+      CUR.error = FT_THROW( Bad_Argument );    \
+    else                                       \
+      CUR.GS.delta_shift = (FT_UShort)args[0];
 
 
 #define DO_MD  /* nothing */
 
 
-#define DO_MPPEM              \
-    args[0] = CURRENT_Ppem();
+#define DO_MPPEM                   \
+    args[0] = CUR_Func_cur_ppem();
 
 
   /* Note: The pointSize should be irrelevant in a given font program; */
 
 #else
 
-#define DO_MPS                \
-    args[0] = CURRENT_Ppem();
+#define DO_MPS                     \
+    args[0] = CUR_Func_cur_ppem();
 
 #endif /* 0 */
 
   /*************************************************************************/
   /*                                                                       */
   /* INSTCTRL[]:   INSTruction ConTRoL                                     */
-  /* Opcode range: 0x8e                                                    */
+  /* Opcode range: 0x8E                                                    */
   /* Stack:        int32 int32 -->                                         */
   /*                                                                       */
   static void
   static void
   Ins_DELTAP( INS_ARG )
   {
-    FT_ULong   k, nump;
+    FT_ULong   nump, k;
     FT_UShort  A;
-    FT_ULong   C;
+    FT_ULong   C, P;
     FT_Long    B;
 #ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
     FT_UShort  B1, B2;
     }
 #endif
 
+    P = (FT_ULong)CUR_Func_cur_ppem();
     nump = (FT_ULong)args[0];   /* some points theoretically may occur more
                                    than once, thus UShort isn't enough */
 
 
         C += CUR.GS.delta_base;
 
-        if ( CURRENT_Ppem() == (FT_Long)C )
+        if ( P == C )
         {
           B = ( (FT_ULong)B & 0xF ) - 8;
           if ( B >= 0 )
             B++;
-          B = B * 64 / ( 1L << CUR.GS.delta_shift );
+          B *= 1L << ( 6 - CUR.GS.delta_shift );
 
 #ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
 
             /*
              *  Allow delta move if
              *
-             *  - not using ignore_x_mode rendering
-             *  - glyph is specifically set to allow it
-             *  - glyph is composite and freedom vector is not subpixel
-             *    vector
+             *  - not using ignore_x_mode rendering,
+             *  - glyph is specifically set to allow it, or
+             *  - glyph is composite and freedom vector is not in subpixel
+             *    direction.
              */
             if ( !CUR.ignore_x_mode                                   ||
                  ( CUR.sph_tweak_flags & SPH_TWEAK_ALWAYS_DO_DELTAP ) ||
                  ( CUR.is_composite && CUR.GS.freeVector.y != 0 )     )
               CUR_Func_move( &CUR.zp0, A, B );
 
-            /* Otherwise apply subpixel hinting and */
-            /* compatibility mode rules             */
-            else if ( CUR.ignore_x_mode )
+            /* Otherwise, apply subpixel hinting and compatibility mode */
+            /* rules, always skipping deltas in subpixel direction.     */
+            else if ( CUR.ignore_x_mode && CUR.GS.freeVector.y != 0 )
             {
-              if ( CUR.GS.freeVector.y != 0 )
-                B1 = CUR.zp0.cur[A].y;
-              else
-                B1 = CUR.zp0.cur[A].x;
+              /* save the y value of the point now; compare after move */
+              B1 = (FT_UShort)CUR.zp0.cur[A].y;
 
-#if 0
-              /* Standard Subpixel Hinting: Allow y move.       */
-              /* This messes up dejavu and may not be needed... */
-              if ( !CUR.face->sph_compatibility_mode &&
-                   CUR.GS.freeVector.y != 0          )
+              /* Standard subpixel hinting: Allow y move for y-touched */
+              /* points.  This messes up DejaVu ...                    */
+              if ( !CUR.face->sph_compatibility_mode          &&
+                   ( CUR.zp0.tags[A] & FT_CURVE_TAG_TOUCH_Y ) )
                 CUR_Func_move( &CUR.zp0, A, B );
-              else
-#endif /* 0 */
 
-              /* Compatibility Mode: Allow x or y move if point touched in */
-              /* Y direction.                                              */
-              if ( CUR.face->sph_compatibility_mode                      &&
-                   !( CUR.sph_tweak_flags & SPH_TWEAK_ALWAYS_SKIP_DELTAP ) )
+              /* compatibility mode */
+              else if ( CUR.face->sph_compatibility_mode                      &&
+                        !( CUR.sph_tweak_flags & SPH_TWEAK_ALWAYS_SKIP_DELTAP ) )
               {
-                /* save the y value of the point now; compare after move */
-                B1 = CUR.zp0.cur[A].y;
-
                 if ( CUR.sph_tweak_flags & SPH_TWEAK_ROUND_NONPIXEL_Y_MOVES )
                   B = FT_PIX_ROUND( B1 + B ) - B1;
 
                   CUR_Func_move( &CUR.zp0, A, B );
               }
 
-              B2 = CUR.zp0.cur[A].y;
+              B2 = (FT_UShort)CUR.zp0.cur[A].y;
 
               /* Reverse this move if it results in a disallowed move */
               if ( CUR.GS.freeVector.y != 0                           &&
   Ins_DELTAC( INS_ARG )
   {
     FT_ULong  nump, k;
-    FT_ULong  A, C;
+    FT_ULong  A, C, P;
     FT_Long   B;
 
 
     }
 #endif
 
+    P    = (FT_ULong)CUR_Func_cur_ppem();
     nump = (FT_ULong)args[0];
 
     for ( k = 1; k <= nump; k++ )
 
         C += CUR.GS.delta_base;
 
-        if ( CURRENT_Ppem() == (FT_Long)C )
+        if ( P == C )
         {
           B = ( (FT_ULong)B & 0xF ) - 8;
           if ( B >= 0 )
             B++;
-          B = B * 64 / ( 1L << CUR.GS.delta_shift );
+          B *= 1L << ( 6 - CUR.GS.delta_shift );
 
           CUR_Func_move_cvt( A, B );
         }
 
 
 #ifdef TT_CONFIG_OPTION_STATIC_RASTER
+    if ( !exc )
+      return FT_THROW( Invalid_Argument );
+
     cur = *exc;
 #endif
 
     CUR.iup_called = FALSE;
 #endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */
 
-    /* set CVT functions */
+    /* set PPEM and CVT functions */
     CUR.tt_metrics.ratio = 0;
     if ( CUR.metrics.x_ppem != CUR.metrics.y_ppem )
     {
       /* non-square pixels, use the stretched routines */
+      CUR.func_cur_ppem  = Current_Ppem_Stretched;
       CUR.func_read_cvt  = Read_CVT_Stretched;
       CUR.func_write_cvt = Write_CVT_Stretched;
       CUR.func_move_cvt  = Move_CVT_Stretched;
     else
     {
       /* square pixels, use normal routines */
+      CUR.func_cur_ppem  = Current_Ppem;
       CUR.func_read_cvt  = Read_CVT;
       CUR.func_write_cvt = Write_CVT;
       CUR.func_move_cvt  = Move_CVT;
     /* If any errors have occurred, function tables may be broken. */
     /* Force a re-execution of `prep' and `fpgm' tables if no      */
     /* bytecode debugger is run.                                   */
-    if ( CUR.error && !CUR.instruction_trap )
+    if ( CUR.error                          &&
+         !CUR.instruction_trap              &&
+         CUR.curRange == tt_coderange_glyph )
     {
       FT_TRACE1(( "  The interpreter returned error 0x%x\n", CUR.error ));
-      exc->size->cvt_ready      = FALSE;
+      exc->size->bytecode_ready = -1;
+      exc->size->cvt_ready      = -1;
     }
 
     return CUR.error;
index 1d8825d..333decc 100644 (file)
@@ -4,7 +4,7 @@
 /*                                                                         */
 /*    TrueType bytecode interpreter (specification).                       */
 /*                                                                         */
-/*  Copyright 1996-2007, 2010, 2012-2013 by                                */
+/*  Copyright 1996-2007, 2010, 2012-2014 by                                */
 /*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
 /*                                                                         */
 /*  This file is part of the FreeType project, and may only be used,       */
@@ -81,6 +81,10 @@ FT_BEGIN_HEADER
   (*TT_Project_Func)( EXEC_OP_ FT_Pos   dx,
                                FT_Pos   dy );
 
+  /* getting current ppem.  Take care of non-square pixels if necessary */
+  typedef FT_Long
+  (*TT_Cur_Ppem_Func)( EXEC_OP );
+
   /* reading a cvt value.  Take care of non-square pixels if necessary */
   typedef FT_F26Dot6
   (*TT_Get_CVT_Func)( EXEC_OP_ FT_ULong  idx );
@@ -228,11 +232,6 @@ FT_BEGIN_HEADER
     FT_F26Dot6         phase;      /* `SuperRounding'     */
     FT_F26Dot6         threshold;
 
-#if 0
-    /* this seems to be unused */
-    FT_Int             cur_ppem;   /* ppem along the current proj vector */
-#endif
-
     FT_Bool            instruction_trap; /* If `True', the interpreter will */
                                          /* exit after each instruction     */
 
@@ -254,6 +253,8 @@ FT_BEGIN_HEADER
     TT_Move_Func       func_move;      /* current point move function */
     TT_Move_Func       func_move_orig; /* move original position function */
 
+    TT_Cur_Ppem_Func   func_cur_ppem;  /* get current proj. ppem value  */
+
     TT_Get_CVT_Func    func_read_cvt;  /* read a cvt entry              */
     TT_Set_CVT_Func    func_write_cvt; /* write a cvt entry (in pixels) */
     TT_Set_CVT_Func    func_move_cvt;  /* incr a cvt entry (in pixels)  */
@@ -295,18 +296,18 @@ FT_BEGIN_HEADER
 
 
 #ifdef TT_USE_BYTECODE_INTERPRETER
-  FT_LOCAL( FT_Error )
+  FT_LOCAL( void )
   TT_Goto_CodeRange( TT_ExecContext  exec,
                      FT_Int          range,
                      FT_Long         IP );
 
-  FT_LOCAL( FT_Error )
+  FT_LOCAL( void )
   TT_Set_CodeRange( TT_ExecContext  exec,
                     FT_Int          range,
                     void*           base,
                     FT_Long         length );
 
-  FT_LOCAL( FT_Error )
+  FT_LOCAL( void )
   TT_Clear_CodeRange( TT_ExecContext  exec,
                       FT_Int          range );
 
@@ -344,7 +345,7 @@ FT_BEGIN_HEADER
 
 
 #ifdef TT_USE_BYTECODE_INTERPRETER
-  FT_LOCAL( FT_Error )
+  FT_LOCAL( void )
   TT_Done_Context( TT_ExecContext  exec );
 
   FT_LOCAL( FT_Error )
@@ -352,7 +353,7 @@ FT_BEGIN_HEADER
                    TT_Face         face,
                    TT_Size         size );
 
-  FT_LOCAL( FT_Error )
+  FT_LOCAL( void )
   TT_Save_Context( TT_ExecContext  exec,
                    TT_Size         ins );
 
index 4adba58..4707dfe 100644 (file)
 #define TRICK_SFNT_ID_prep  2
 
       { /* MingLiU 1995 */
-        { 0x05bcf058, 0x000002e4 }, /* cvt  */
-        { 0x28233bf1, 0x000087c4 }, /* fpgm */
-        { 0xa344a1ea, 0x000001e1 }  /* prep */
+        { 0x05BCF058UL, 0x000002E4UL }, /* cvt  */
+        { 0x28233BF1UL, 0x000087C4UL }, /* fpgm */
+        { 0xA344A1EAUL, 0x000001E1UL }  /* prep */
       },
       { /* MingLiU 1996- */
-        { 0x05bcf058, 0x000002e4 }, /* cvt  */
-        { 0x28233bf1, 0x000087c4 }, /* fpgm */
-        { 0xa344a1eb, 0x000001e1 }  /* prep */
+        { 0x05BCF058UL, 0x000002E4UL }, /* cvt  */
+        { 0x28233BF1UL, 0x000087C4UL }, /* fpgm */
+        { 0xA344A1EBUL, 0x000001E1UL }  /* prep */
       },
       { /* DFKaiShu */
-        { 0x11e5ead4, 0x00000350 }, /* cvt  */
-        { 0x5a30ca3b, 0x00009063 }, /* fpgm */
-        { 0x13a42602, 0x0000007e }  /* prep */
+        { 0x11E5EAD4UL, 0x00000350UL }, /* cvt  */
+        { 0x5A30CA3BUL, 0x00009063UL }, /* fpgm */
+        { 0x13A42602UL, 0x0000007EUL }  /* prep */
       },
       { /* HuaTianKaiTi */
-        { 0xfffbfffc, 0x00000008 }, /* cvt  */
-        { 0x9c9e48b8, 0x0000bea2 }, /* fpgm */
-        { 0x70020112, 0x00000008 }  /* prep */
+        { 0xFFFBFFFCUL, 0x00000008UL }, /* cvt  */
+        { 0x9C9E48B8UL, 0x0000BEA2UL }, /* fpgm */
+        { 0x70020112UL, 0x00000008UL }  /* prep */
       },
       { /* HuaTianSongTi */
-        { 0xfffbfffc, 0x00000008 }, /* cvt  */
-        { 0x0a5a0483, 0x00017c39 }, /* fpgm */
-        { 0x70020112, 0x00000008 }  /* prep */
+        { 0xFFFBFFFCUL, 0x00000008UL }, /* cvt  */
+        { 0x0A5A0483UL, 0x00017C39UL }, /* fpgm */
+        { 0x70020112UL, 0x00000008UL }  /* prep */
       },
       { /* NEC fadpop7.ttf */
-        { 0x00000000, 0x00000000 }, /* cvt  */
-        { 0x40c92555, 0x000000e5 }, /* fpgm */
-        { 0xa39b58e3, 0x0000117c }  /* prep */
+        { 0x00000000UL, 0x00000000UL }, /* cvt  */
+        { 0x40C92555UL, 0x000000E5UL }, /* fpgm */
+        { 0xA39B58E3UL, 0x0000117CUL }  /* prep */
       },
       { /* NEC fadrei5.ttf */
-        { 0x00000000, 0x00000000 }, /* cvt  */
-        { 0x33c41652, 0x000000e5 }, /* fpgm */
-        { 0x26d6c52a, 0x00000f6a }  /* prep */
+        { 0x00000000UL, 0x00000000UL }, /* cvt  */
+        { 0x33C41652UL, 0x000000E5UL }, /* fpgm */
+        { 0x26D6C52AUL, 0x00000F6AUL }  /* prep */
       },
       { /* NEC fangot7.ttf */
-        { 0x00000000, 0x00000000 }, /* cvt  */
-        { 0x6db1651d, 0x0000019d }, /* fpgm */
-        { 0x6c6e4b03, 0x00002492 }  /* prep */
+        { 0x00000000UL, 0x00000000UL }, /* cvt  */
+        { 0x6DB1651DUL, 0x0000019DUL }, /* fpgm */
+        { 0x6C6E4B03UL, 0x00002492UL }  /* prep */
       },
       { /* NEC fangyo5.ttf */
-        { 0x00000000, 0x00000000 }, /* cvt  */
-        { 0x40c92555, 0x000000e5 }, /* fpgm */
-        { 0xde51fad0, 0x0000117c }  /* prep */
+        { 0x00000000UL, 0x00000000UL }, /* cvt  */
+        { 0x40C92555UL, 0x000000E5UL }, /* fpgm */
+        { 0xDE51FAD0UL, 0x0000117CUL }  /* prep */
       },
       { /* NEC fankyo5.ttf */
-        { 0x00000000, 0x00000000 }, /* cvt  */
-        { 0x85e47664, 0x000000e5 }, /* fpgm */
-        { 0xa6c62831, 0x00001caa }  /* prep */
+        { 0x00000000UL, 0x00000000UL }, /* cvt  */
+        { 0x85E47664UL, 0x000000E5UL }, /* fpgm */
+        { 0xA6C62831UL, 0x00001CAAUL }  /* prep */
       },
       { /* NEC fanrgo5.ttf */
-        { 0x00000000, 0x00000000 }, /* cvt  */
-        { 0x2d891cfd, 0x0000019d }, /* fpgm */
-        { 0xa0604633, 0x00001de8 }  /* prep */
+        { 0x00000000UL, 0x00000000UL }, /* cvt  */
+        { 0x2D891CFDUL, 0x0000019DUL }, /* fpgm */
+        { 0xA0604633UL, 0x00001DE8UL }  /* prep */
       },
       { /* NEC fangot5.ttc */
-        { 0x00000000, 0x00000000 }, /* cvt  */
-        { 0x40aa774c, 0x000001cb }, /* fpgm */
-        { 0x9b5caa96, 0x00001f9a }  /* prep */
+        { 0x00000000UL, 0x00000000UL }, /* cvt  */
+        { 0x40AA774CUL, 0x000001CBUL }, /* fpgm */
+        { 0x9B5CAA96UL, 0x00001F9AUL }  /* prep */
       },
       { /* NEC fanmin3.ttc */
-        { 0x00000000, 0x00000000 }, /* cvt  */
-        { 0x0d3de9cb, 0x00000141 }, /* fpgm */
-        { 0xd4127766, 0x00002280 }  /* prep */
+        { 0x00000000UL, 0x00000000UL }, /* cvt  */
+        { 0x0D3DE9CBUL, 0x00000141UL }, /* fpgm */
+        { 0xD4127766UL, 0x00002280UL }  /* prep */
       },
       { /* NEC FA-Gothic, 1996 */
-        { 0x00000000, 0x00000000 }, /* cvt  */
-        { 0x4a692698, 0x000001f0 }, /* fpgm */
-        { 0x340d4346, 0x00001fca }  /* prep */
+        { 0x00000000UL, 0x00000000UL }, /* cvt  */
+        { 0x4A692698UL, 0x000001F0UL }, /* fpgm */
+        { 0x340D4346UL, 0x00001FCAUL }  /* prep */
       },
       { /* NEC FA-Minchou, 1996 */
-        { 0x00000000, 0x00000000 }, /* cvt  */
-        { 0xcd34c604, 0x00000166 }, /* fpgm */
-        { 0x6cf31046, 0x000022b0 }  /* prep */
+        { 0x00000000UL, 0x00000000UL }, /* cvt  */
+        { 0xCD34C604UL, 0x00000166UL }, /* fpgm */
+        { 0x6CF31046UL, 0x000022B0UL }  /* prep */
       },
       { /* NEC FA-RoundGothicB, 1996 */
-        { 0x00000000, 0x00000000 }, /* cvt  */
-        { 0x5da75315, 0x0000019d }, /* fpgm */
-        { 0x40745a5f, 0x000022e0 }  /* prep */
+        { 0x00000000UL, 0x00000000UL }, /* cvt  */
+        { 0x5DA75315UL, 0x0000019DUL }, /* fpgm */
+        { 0x40745A5FUL, 0x000022E0UL }  /* prep */
       },
       { /* NEC FA-RoundGothicM, 1996 */
-        { 0x00000000, 0x00000000 }, /* cvt  */
-        { 0xf055fc48, 0x000001c2 }, /* fpgm */
-        { 0x3900ded3, 0x00001e18 }  /* prep */
+        { 0x00000000UL, 0x00000000UL }, /* cvt  */
+        { 0xF055FC48UL, 0x000001C2UL }, /* fpgm */
+        { 0x3900DED3UL, 0x00001E18UL }  /* prep */
       }
     };
 
     if ( !exec )
       return FT_THROW( Could_Not_Find_Context );
 
-    TT_Load_Context( exec, face, size );
+    error = TT_Load_Context( exec, face, size );
+    if ( error )
+      return error;
 
     exec->callTop = 0;
     exec->top     = 0;
 
     if ( face->font_program_size > 0 )
     {
-      error = TT_Goto_CodeRange( exec, tt_coderange_font, 0 );
+      TT_Goto_CodeRange( exec, tt_coderange_font, 0 );
 
-      if ( !error )
-      {
-        FT_TRACE4(( "Executing `fpgm' table.\n" ));
-
-        error = face->interpreter( exec );
-      }
+      FT_TRACE4(( "Executing `fpgm' table.\n" ));
+      error = face->interpreter( exec );
     }
     else
       error = FT_Err_Ok;
 
+    size->bytecode_ready = error;
+
     if ( !error )
       TT_Save_Context( exec, size );
 
     if ( !exec )
       return FT_THROW( Could_Not_Find_Context );
 
-    TT_Load_Context( exec, face, size );
+    error = TT_Load_Context( exec, face, size );
+    if ( error )
+      return error;
 
     exec->callTop = 0;
     exec->top     = 0;
 
     if ( face->cvt_program_size > 0 )
     {
-      error = TT_Goto_CodeRange( exec, tt_coderange_cvt, 0 );
+      TT_Goto_CodeRange( exec, tt_coderange_cvt, 0 );
 
-      if ( !error && !size->debug )
+      if ( !size->debug )
       {
         FT_TRACE4(( "Executing `prep' table.\n" ));
 
     else
       error = FT_Err_Ok;
 
+    size->cvt_ready = error;
+
     /* UNDOCUMENTED!  The MS rasterizer doesn't allow the following */
     /* graphics state variables to be modified by the CVT program.  */
 
     return error;
   }
 
-#endif /* TT_USE_BYTECODE_INTERPRETER */
-
-
-#ifdef TT_USE_BYTECODE_INTERPRETER
 
   static void
   tt_size_done_bytecode( FT_Size  ftsize )
     size->max_func = 0;
     size->max_ins  = 0;
 
-    size->bytecode_ready = 0;
-    size->cvt_ready      = 0;
+    size->bytecode_ready = -1;
+    size->cvt_ready      = -1;
   }
 
 
     TT_Size    size = (TT_Size)ftsize;
     TT_Face    face = (TT_Face)ftsize->face;
     FT_Memory  memory = face->root.memory;
-    FT_Int     i;
 
     FT_UShort       n_twilight;
     TT_MaxProfile*  maxp = &face->max_profile;
 
 
-    size->bytecode_ready = 1;
-    size->cvt_ready      = 0;
+    size->bytecode_ready = -1;
+    size->cvt_ready      = -1;
 
     size->max_function_defs    = maxp->maxFunctionDefs;
     size->max_instruction_defs = maxp->maxInstructionDefs;
       metrics->rotated   = FALSE;
       metrics->stretched = FALSE;
 
-      /* set default compensation (all 0) */
-      for ( i = 0; i < 4; i++ )
-        metrics->compensations[i] = 0;
+      /* set default engine compensation */
+      metrics->compensations[0] = 0;   /* gray     */
+      metrics->compensations[1] = 0;   /* black    */
+      metrics->compensations[2] = 0;   /* white    */
+      metrics->compensations[3] = 0;   /* reserved */
     }
 
     /* allocate function defs, instruction defs, cvt, and storage area */
     FT_Error  error = FT_Err_Ok;
 
 
-    if ( !size->bytecode_ready )
-    {
+    if ( size->bytecode_ready < 0 )
       error = tt_size_init_bytecode( (FT_Size)size, pedantic );
-      if ( error )
-        goto Exit;
-    }
+
+    if ( error || size->bytecode_ready )
+      goto Exit;
 
     /* rescale CVT when needed */
-    if ( !size->cvt_ready )
+    if ( size->cvt_ready < 0 )
     {
       FT_UInt  i;
       TT_Face  face = (TT_Face)size->root.face;
       size->GS = tt_default_graphics_state;
 
       error = tt_size_run_prep( size, pedantic );
-      if ( !error )
-        size->cvt_ready = 1;
     }
 
   Exit:
     TT_Size   size  = (TT_Size)ttsize;
     FT_Error  error = FT_Err_Ok;
 
+
 #ifdef TT_USE_BYTECODE_INTERPRETER
-    size->bytecode_ready = 0;
-    size->cvt_ready      = 0;
+    size->bytecode_ready = -1;
+    size->cvt_ready      = -1;
 #endif
 
     size->ttmetrics.valid = FALSE;
 
 
 #ifdef TT_USE_BYTECODE_INTERPRETER
-    if ( size->bytecode_ready )
-      tt_size_done_bytecode( ttsize );
+    tt_size_done_bytecode( ttsize );
 #endif
 
     size->ttmetrics.valid = FALSE;
     }
 
 #ifdef TT_USE_BYTECODE_INTERPRETER
-    size->cvt_ready = 0;
+    size->cvt_ready = -1;
 #endif /* TT_USE_BYTECODE_INTERPRETER */
 
     if ( !error )
index a11dd37..859164f 100644 (file)
@@ -4,7 +4,7 @@
 /*                                                                         */
 /*    Objects manager (specification).                                     */
 /*                                                                         */
-/*  Copyright 1996-2009, 2011-2013 by                                      */
+/*  Copyright 1996-2009, 2011-2014 by                                      */
 /*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
 /*                                                                         */
 /*  This file is part of the FreeType project, and may only be used,       */
@@ -95,8 +95,8 @@ FT_BEGIN_HEADER
     FT_F26Dot6     control_value_cutin;
     FT_F26Dot6     single_width_cutin;
     FT_F26Dot6     single_width_value;
-    FT_Short       delta_base;
-    FT_Short       delta_shift;
+    FT_UShort      delta_base;
+    FT_UShort      delta_shift;
 
     FT_Byte        instruct_control;
     /* According to Greg Hitchcock from Microsoft, the `scan_control'     */
@@ -333,8 +333,10 @@ FT_BEGIN_HEADER
     FT_Bool            debug;
     TT_ExecContext     context;
 
-    FT_Bool            bytecode_ready;
-    FT_Bool            cvt_ready;
+    /* if negative, `fpgm' (resp. `prep'), wasn't executed yet; */
+    /* otherwise it is the returned error code                  */
+    FT_Error           bytecode_ready;
+    FT_Error           cvt_ready;
 
 #endif /* TT_USE_BYTECODE_INTERPRETER */
 
index 9723a51..9991925 100644 (file)
     record_size = FT_NEXT_ULONG( p );
 
     /* The maximum number of bytes in an hdmx device record is the */
-    /* maximum number of glyphs + 2; this is 0xFFFF + 2; this is   */
-    /* the reason why `record_size' is a long (which we read as    */
-    /* unsigned long for convenience).  In practice, two bytes     */
+    /* maximum number of glyphs + 2; this is 0xFFFF + 2, thus      */
+    /* explaining why `record_size' is a long (which we read as    */
+    /* unsigned long for convenience).  In practice, two bytes are */
     /* sufficient to hold the size value.                          */
     /*                                                             */
     /* There are at least two fonts, HANNOM-A and HANNOM-B version */
       record_size &= 0xFFFFU;
 
     /* The limit for `num_records' is a heuristic value. */
-
-    if ( version != 0 || num_records > 255 || record_size > 0x10001L )
+    if ( version != 0           ||
+         num_records > 255      ||
+         record_size > 0x10001L ||
+         record_size < 4        )
     {
       error = FT_THROW( Invalid_File_Format );
       goto Fail;
index 28470ad..ca60451 100644 (file)
   const SPH_TweakRule  COMPATIBILITY_MODE_Rules
                        [COMPATIBILITY_MODE_RULES_SIZE] =
   {
-    { "-", 0, "", 0 },
+    { "Verdana Clones", 0, "", 0 },
   };
 
 
       if ( loader->exec->rasterizer_version != TT_INTERPRETER_VERSION_35 )
       {
         loader->exec->rasterizer_version = TT_INTERPRETER_VERSION_35;
-        loader->exec->size->cvt_ready    = FALSE;
+        loader->exec->size->cvt_ready    = -1;
 
         tt_size_ready_bytecode(
           loader->exec->size,
            SPH_OPTION_SET_RASTERIZER_VERSION )
       {
         loader->exec->rasterizer_version = SPH_OPTION_SET_RASTERIZER_VERSION;
-        loader->exec->size->cvt_ready    = FALSE;
+        loader->exec->size->cvt_ready    = -1;
 
         tt_size_ready_bytecode(
           loader->exec->size,
index 697288d..2602bdb 100644 (file)
@@ -4,7 +4,7 @@
 /*                                                                         */
 /*    Type 1 driver interface (body).                                      */
 /*                                                                         */
-/*  Copyright 1996-2004, 2006, 2007, 2009, 2011, 2013 by                   */
+/*  Copyright 1996-2004, 2006, 2007, 2009, 2011, 2013, 2014 by             */
 /*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
 /*                                                                         */
 /*  This file is part of the FreeType project, and may only be used,       */
       if ( value && value_len >= retval )
         *((FT_Long *)value) = type1->font_info.italic_angle;
       break;
-
-    default:
-      break;
     }
 
     return retval;
index fd06432..22b3f6b 100644 (file)
         char*  notdef = (char *)".notdef";
 
 
-        T1_Add_Table( char_table, n, notdef, 8 );
+        (void)T1_Add_Table( char_table, n, notdef, 8 );
       }
 
       /* Now we need to read records of the form                */
       }
 
       T1_Skip_PS_Token( parser );
+      if ( parser->root.cursor >= limit )
+      {
+        error = FT_THROW( Invalid_File_Format );
+        goto Fail;
+      }
       if ( parser->root.error )
         return;
 
         FT_PtrDist  len;
 
 
-        if ( cur + 1 >= limit )
+        if ( cur + 2 >= limit )
         {
           error = FT_THROW( Invalid_File_Format );
           goto Fail;
index 798ebdb..915e81f 100644 (file)
     if ( FT_ALLOC( face->ttf_data, 12 ) )
       goto Exit;
 
+    /* while parsing the font we always update `face->ttf_size' so that */
+    /* even in case of buggy data (which might lead to premature end of */
+    /* scanning without causing an error) the call to `FT_Open_Face' in */
+    /* `T42_Face_Init' passes the correct size                          */
+    face->ttf_size = 12;
+
     error = t42_parser_init( parser,
                              face->root.stream,
                              memory,
       FT_Open_Args  args;
 
 
-      args.flags       = FT_OPEN_MEMORY;
+      args.flags       = FT_OPEN_MEMORY | FT_OPEN_DRIVER;
+      args.driver      = FT_Get_Module( FT_FACE_LIBRARY( face ),
+                                        "truetype" );
       args.memory_base = face->ttf_data;
       args.memory_size = face->ttf_size;
 
index 9b66888..5070853 100644 (file)
         char*  notdef = (char *)".notdef";
 
 
-        T1_Add_Table( char_table, n, notdef, 8 );
+        (void)T1_Add_Table( char_table, n, notdef, 8 );
       }
 
       /* Now we need to read records of the form                */
     FT_Byte*    limit  = parser->root.limit;
     FT_Error    error;
     FT_Int      num_tables = 0;
-    FT_ULong    count, ttf_size = 0;
+    FT_ULong    count;
 
     FT_Long     n, string_size, old_string_size, real_size;
     FT_Byte*    string_buf = NULL;
 
         /* don't include delimiters */
         string_size = (FT_Long)( ( parser->root.cursor - cur - 2 + 1 ) / 2 );
+        if ( !string_size )
+        {
+          FT_ERROR(( "t42_parse_sfnts: invalid data in sfnts array\n" ));
+          error = FT_THROW( Invalid_File_Format );
+          goto Fail;
+        }
         if ( FT_REALLOC( string_buf, old_string_size, string_size ) )
           goto Fail;
 
 
         if ( limit - parser->root.cursor < string_size )
         {
-          FT_ERROR(( "t42_parse_sfnts: too many binary data\n" ));
+          FT_ERROR(( "t42_parse_sfnts: too much binary data\n" ));
           error = FT_THROW( Invalid_File_Format );
           goto Fail;
         }
           }
           else
           {
-            num_tables = 16 * face->ttf_data[4] + face->ttf_data[5];
-            status     = BEFORE_TABLE_DIR;
-            ttf_size   = 12 + 16 * num_tables;
+            num_tables     = 16 * face->ttf_data[4] + face->ttf_data[5];
+            status         = BEFORE_TABLE_DIR;
+            face->ttf_size = 12 + 16 * num_tables;
 
-            if ( FT_REALLOC( face->ttf_data, 12, ttf_size ) )
+            if ( (FT_ULong)( limit - parser->root.cursor ) < face->ttf_size )
+            {
+              FT_ERROR(( "t42_parse_sfnts: invalid data in sfnts array\n" ));
+              error = FT_THROW( Invalid_File_Format );
+              goto Fail;
+            }
+
+            if ( FT_REALLOC( face->ttf_data, 12, face->ttf_size ) )
               goto Fail;
           }
           /* fall through */
 
         case BEFORE_TABLE_DIR:
           /* the offset table is read; read the table directory */
-          if ( count < ttf_size )
+          if ( count < face->ttf_size )
           {
             face->ttf_data[count++] = string_buf[n];
             continue;
               len = FT_PEEK_ULONG( p );
 
               /* Pad to a 4-byte boundary length */
-              ttf_size += ( len + 3 ) & ~3;
+              face->ttf_size += ( len + 3 ) & ~3;
             }
 
-            status         = OTHER_TABLES;
-            face->ttf_size = ttf_size;
+            status = OTHER_TABLES;
 
             /* there are no more than 256 tables, so no size check here */
             if ( FT_REALLOC( face->ttf_data, 12 + 16 * num_tables,
-                             ttf_size + 1 ) )
+                             face->ttf_size + 1 ) )
               goto Fail;
           }
           /* fall through */
 
         case OTHER_TABLES:
           /* all other tables are just copied */
-          if ( count >= ttf_size )
+          if ( count >= face->ttf_size )
           {
-            FT_ERROR(( "t42_parse_sfnts: too many binary data\n" ));
+            FT_ERROR(( "t42_parse_sfnts: too much binary data\n" ));
             error = FT_THROW( Invalid_File_Format );
             goto Fail;
           }
         break;
 
       T1_Skip_PS_Token( parser );
+      if ( parser->root.cursor >= limit )
+      {
+        FT_ERROR(( "t42_parse_charstrings: out of bounds\n" ));
+        error = FT_THROW( Invalid_File_Format );
+        goto Fail;
+      }
       if ( parser->root.error )
         return;
 
         FT_PtrDist  len;
 
 
-        if ( cur + 1 >= limit )
+        if ( cur + 2 >= limit )
         {
           FT_ERROR(( "t42_parse_charstrings: out of bounds\n" ));
           error = FT_THROW( Invalid_File_Format );
index e9c1a9b..4705c53 100644 (file)
 
     FT_FRAME_START( 248 ),
       FT_FRAME_ULONG_LE  ( magic ),   /* PE00 */
-      FT_FRAME_USHORT_LE ( machine ), /* 0x014c - i386 */
+      FT_FRAME_USHORT_LE ( machine ), /* 0x014C - i386 */
       FT_FRAME_USHORT_LE ( number_of_sections ),
       FT_FRAME_SKIP_BYTES( 12 ),
       FT_FRAME_USHORT_LE ( size_of_optional_header ),
       FT_FRAME_SKIP_BYTES( 2 ),
-      FT_FRAME_USHORT_LE ( magic32 ), /* 0x10b */
+      FT_FRAME_USHORT_LE ( magic32 ), /* 0x10B */
       FT_FRAME_SKIP_BYTES( 110 ),
       FT_FRAME_ULONG_LE  ( rsrc_virtual_address ),
       FT_FRAME_ULONG_LE  ( rsrc_size ),
                     pe32_header.rsrc_size ));
 
         if ( pe32_header.magic != WINFNT_PE_MAGIC /* check full signature */ ||
-             pe32_header.machine != 0x014c /* i386 */                        ||
-             pe32_header.size_of_optional_header != 0xe0 /* FIXME */         ||
-             pe32_header.magic32 != 0x10b                                    )
+             pe32_header.machine != 0x014C /* i386 */                        ||
+             pe32_header.size_of_optional_header != 0xE0 /* FIXME */         ||
+             pe32_header.magic32 != 0x10B                                    )
         {
           FT_TRACE2(( "this file has an invalid PE header\n" ));
           error = FT_THROW( Invalid_File_Format );
 
 
   static FT_Error
-  fnt_cmap_init( FNT_CMap  cmap )
+  fnt_cmap_init( FNT_CMap    cmap,
+                 FT_Pointer  pointer )
   {
     FNT_Face  face = (FNT_Face)FT_CMAP_FACE( cmap );
     FNT_Font  font = face->font;
 
+    FT_UNUSED( pointer );
+
 
     cmap->first = (FT_UInt32)  font->header.first_char;
     cmap->count = (FT_UInt32)( font->header.last_char - cmap->first + 1 );
 
     if ( !face )
     {
-      error = FT_THROW( Invalid_Argument );
+      error = FT_THROW( Invalid_Face_Handle );
       goto Exit;
     }
 
index 2e7cff5..5d85912 100644 (file)
@@ -23,7 +23,7 @@ Used Version: 1.1
 Website: http://www.geocities.com/dborca/opengl/tc.html
 
 Title: FreeType
-Used Version: 2.5.3
+Used Version: 2.5.5
 Website: http://www.freetype.org
 
 Title: Mesa3D