From 0f8cc0fa5b6bc53b81fbf3fe52c15be987dfd7c2 Mon Sep 17 00:00:00 2001 From: volzhs Date: Sat, 24 Jun 2017 23:42:22 +0900 Subject: Update freetype to 2.8 --- modules/freetype/SCsub | 6 + thirdparty/README.md | 2 +- .../freetype/include/freetype/config/ftconfig.h | 28 +- .../freetype/include/freetype/config/ftheader.h | 15 +- .../freetype/include/freetype/config/ftoption.h | 128 +- .../freetype/include/freetype/config/ftstdlib.h | 5 +- thirdparty/freetype/include/freetype/freetype.h | 1064 +++++---- thirdparty/freetype/include/freetype/ftadvanc.h | 2 +- thirdparty/freetype/include/freetype/ftautoh.h | 34 +- thirdparty/freetype/include/freetype/ftbbox.h | 2 +- thirdparty/freetype/include/freetype/ftbdf.h | 2 +- thirdparty/freetype/include/freetype/ftbitmap.h | 2 +- thirdparty/freetype/include/freetype/ftbzip2.h | 2 +- thirdparty/freetype/include/freetype/ftcache.h | 2 +- thirdparty/freetype/include/freetype/ftcffdrv.h | 61 +- thirdparty/freetype/include/freetype/ftchapters.h | 1 + thirdparty/freetype/include/freetype/ftcid.h | 2 +- thirdparty/freetype/include/freetype/fterrdef.h | 4 +- thirdparty/freetype/include/freetype/fterrors.h | 4 +- thirdparty/freetype/include/freetype/ftfntfmt.h | 2 +- thirdparty/freetype/include/freetype/ftgasp.h | 16 +- thirdparty/freetype/include/freetype/ftglyph.h | 4 +- thirdparty/freetype/include/freetype/ftgxval.h | 2 +- thirdparty/freetype/include/freetype/ftgzip.h | 2 +- thirdparty/freetype/include/freetype/ftimage.h | 15 +- thirdparty/freetype/include/freetype/ftincrem.h | 2 +- thirdparty/freetype/include/freetype/ftlcdfil.h | 37 +- thirdparty/freetype/include/freetype/ftlist.h | 2 +- thirdparty/freetype/include/freetype/ftlzw.h | 2 +- thirdparty/freetype/include/freetype/ftmac.h | 2 +- thirdparty/freetype/include/freetype/ftmm.h | 210 +- thirdparty/freetype/include/freetype/ftmodapi.h | 49 +- thirdparty/freetype/include/freetype/ftmoderr.h | 2 +- thirdparty/freetype/include/freetype/ftotval.h | 2 +- thirdparty/freetype/include/freetype/ftoutln.h | 10 +- thirdparty/freetype/include/freetype/ftpcfdrv.h | 105 + thirdparty/freetype/include/freetype/ftpfr.h | 2 +- thirdparty/freetype/include/freetype/ftrender.h | 3 +- thirdparty/freetype/include/freetype/ftsizes.h | 2 +- thirdparty/freetype/include/freetype/ftsnames.h | 147 +- thirdparty/freetype/include/freetype/ftstroke.h | 4 +- thirdparty/freetype/include/freetype/ftsynth.h | 2 +- thirdparty/freetype/include/freetype/ftsystem.h | 2 +- thirdparty/freetype/include/freetype/fttrigon.h | 2 +- thirdparty/freetype/include/freetype/ftttdrv.h | 13 +- thirdparty/freetype/include/freetype/fttypes.h | 2 +- thirdparty/freetype/include/freetype/ftwinfnt.h | 2 +- .../freetype/include/freetype/internal/autohint.h | 2 +- .../freetype/include/freetype/internal/ftcalc.h | 2 +- .../freetype/include/freetype/internal/ftdebug.h | 2 +- .../freetype/include/freetype/internal/ftdriver.h | 11 +- .../freetype/include/freetype/internal/ftgloadr.h | 2 +- .../freetype/include/freetype/internal/ftmemory.h | 11 +- .../freetype/include/freetype/internal/ftobjs.h | 80 +- .../freetype/include/freetype/internal/ftpic.h | 2 +- .../freetype/include/freetype/internal/ftrfork.h | 7 +- .../freetype/include/freetype/internal/ftserv.h | 202 +- .../freetype/include/freetype/internal/ftstream.h | 4 +- .../freetype/include/freetype/internal/fttrace.h | 2 +- .../freetype/include/freetype/internal/ftvalid.h | 2 +- .../freetype/include/freetype/internal/internal.h | 2 +- .../freetype/include/freetype/internal/psaux.h | 4 +- .../freetype/include/freetype/internal/pshints.h | 2 +- .../include/freetype/internal/services/svbdf.h | 2 +- .../include/freetype/internal/services/svcid.h | 2 +- .../include/freetype/internal/services/svfntfmt.h | 2 +- .../include/freetype/internal/services/svgldict.h | 2 +- .../include/freetype/internal/services/svgxval.h | 2 +- .../include/freetype/internal/services/svkern.h | 2 +- .../include/freetype/internal/services/svmetric.h | 153 ++ .../include/freetype/internal/services/svmm.h | 94 +- .../include/freetype/internal/services/svotval.h | 2 +- .../include/freetype/internal/services/svpfr.h | 2 +- .../include/freetype/internal/services/svpostnm.h | 2 +- .../include/freetype/internal/services/svprop.h | 5 +- .../include/freetype/internal/services/svpscmap.h | 2 +- .../include/freetype/internal/services/svpsinfo.h | 2 +- .../include/freetype/internal/services/svsfnt.h | 2 +- .../include/freetype/internal/services/svttcmap.h | 2 +- .../include/freetype/internal/services/svtteng.h | 2 +- .../include/freetype/internal/services/svttglyf.h | 2 +- .../include/freetype/internal/services/svwinfnt.h | 2 +- .../freetype/include/freetype/internal/sfnt.h | 42 +- .../freetype/include/freetype/internal/t1types.h | 2 +- .../freetype/include/freetype/internal/tttypes.h | 263 +- thirdparty/freetype/include/freetype/t1tables.h | 6 +- thirdparty/freetype/include/freetype/ttnameid.h | 627 +++-- thirdparty/freetype/include/freetype/tttables.h | 363 +-- thirdparty/freetype/include/freetype/tttags.h | 6 +- thirdparty/freetype/include/freetype/ttunpat.h | 4 +- thirdparty/freetype/include/ft2build.h | 3 +- thirdparty/freetype/src/autofit/afangles.c | 2 +- thirdparty/freetype/src/autofit/afblue.c | 290 ++- thirdparty/freetype/src/autofit/afblue.cin | 2 +- thirdparty/freetype/src/autofit/afblue.dat | 366 ++- thirdparty/freetype/src/autofit/afblue.h | 370 +-- thirdparty/freetype/src/autofit/afblue.hin | 2 +- thirdparty/freetype/src/autofit/afcjk.c | 34 +- thirdparty/freetype/src/autofit/afcjk.h | 2 +- thirdparty/freetype/src/autofit/afcover.h | 2 +- thirdparty/freetype/src/autofit/afdummy.c | 14 +- thirdparty/freetype/src/autofit/afdummy.h | 2 +- thirdparty/freetype/src/autofit/aferrors.h | 2 +- thirdparty/freetype/src/autofit/afglobal.c | 22 +- thirdparty/freetype/src/autofit/afglobal.h | 2 +- thirdparty/freetype/src/autofit/afhints.c | 47 +- thirdparty/freetype/src/autofit/afhints.h | 3 +- thirdparty/freetype/src/autofit/afindic.c | 28 +- thirdparty/freetype/src/autofit/afindic.h | 2 +- thirdparty/freetype/src/autofit/aflatin.c | 160 +- thirdparty/freetype/src/autofit/aflatin.h | 2 +- thirdparty/freetype/src/autofit/aflatin2.c | 36 +- thirdparty/freetype/src/autofit/aflatin2.h | 2 +- thirdparty/freetype/src/autofit/afloader.c | 559 +++-- thirdparty/freetype/src/autofit/afloader.h | 2 +- thirdparty/freetype/src/autofit/afmodule.c | 164 +- thirdparty/freetype/src/autofit/afmodule.h | 2 +- thirdparty/freetype/src/autofit/afpic.c | 2 +- thirdparty/freetype/src/autofit/afpic.h | 4 +- thirdparty/freetype/src/autofit/afranges.c | 382 ++- thirdparty/freetype/src/autofit/afranges.h | 2 +- thirdparty/freetype/src/autofit/afscript.h | 161 +- thirdparty/freetype/src/autofit/afshaper.c | 2 +- thirdparty/freetype/src/autofit/afshaper.h | 2 +- thirdparty/freetype/src/autofit/afstyles.h | 178 +- thirdparty/freetype/src/autofit/aftypes.h | 5 +- thirdparty/freetype/src/autofit/afwarp.c | 3 +- thirdparty/freetype/src/autofit/afwarp.h | 2 +- thirdparty/freetype/src/autofit/afwrtsys.h | 2 +- thirdparty/freetype/src/autofit/autofit.c | 25 +- thirdparty/freetype/src/autofit/module.mk | 2 +- thirdparty/freetype/src/autofit/rules.mk | 2 +- thirdparty/freetype/src/base/basepic.c | 2 +- thirdparty/freetype/src/base/basepic.h | 2 +- thirdparty/freetype/src/base/ftadvanc.c | 15 +- thirdparty/freetype/src/base/ftapi.c | 4 +- thirdparty/freetype/src/base/ftbase.c | 9 +- thirdparty/freetype/src/base/ftbase.h | 2 +- thirdparty/freetype/src/base/ftbbox.c | 28 +- thirdparty/freetype/src/base/ftbdf.c | 2 +- thirdparty/freetype/src/base/ftbitmap.c | 4 +- thirdparty/freetype/src/base/ftcalc.c | 10 +- thirdparty/freetype/src/base/ftcid.c | 2 +- thirdparty/freetype/src/base/ftdbgmem.c | 30 +- thirdparty/freetype/src/base/ftdebug.c | 2 +- thirdparty/freetype/src/base/ftfntfmt.c | 2 +- thirdparty/freetype/src/base/ftfstype.c | 2 +- thirdparty/freetype/src/base/ftgasp.c | 2 +- thirdparty/freetype/src/base/ftgloadr.c | 2 +- thirdparty/freetype/src/base/ftglyph.c | 38 +- thirdparty/freetype/src/base/ftgxval.c | 4 +- thirdparty/freetype/src/base/ftinit.c | 92 +- thirdparty/freetype/src/base/ftlcdfil.c | 54 +- thirdparty/freetype/src/base/ftmac.c | 42 +- thirdparty/freetype/src/base/ftmm.c | 187 +- thirdparty/freetype/src/base/ftobjs.c | 413 +++- thirdparty/freetype/src/base/ftotval.c | 2 +- thirdparty/freetype/src/base/ftoutln.c | 4 +- thirdparty/freetype/src/base/ftpatent.c | 4 +- thirdparty/freetype/src/base/ftpfr.c | 2 +- thirdparty/freetype/src/base/ftpic.c | 2 +- thirdparty/freetype/src/base/ftrfork.c | 117 +- thirdparty/freetype/src/base/ftsnames.c | 60 +- thirdparty/freetype/src/base/ftstream.c | 2 +- thirdparty/freetype/src/base/ftstroke.c | 2 +- thirdparty/freetype/src/base/ftsynth.c | 4 +- thirdparty/freetype/src/base/ftsystem.c | 2 +- thirdparty/freetype/src/base/fttrigon.c | 2 +- thirdparty/freetype/src/base/fttype1.c | 2 +- thirdparty/freetype/src/base/ftutil.c | 8 +- thirdparty/freetype/src/base/ftwinfnt.c | 2 +- thirdparty/freetype/src/base/rules.mk | 2 +- thirdparty/freetype/src/bdf/bdf.c | 3 +- thirdparty/freetype/src/bdf/bdfdrivr.c | 26 +- thirdparty/freetype/src/bdf/bdflib.c | 6 +- thirdparty/freetype/src/bzip2/ftbzip2.c | 525 ++++ thirdparty/freetype/src/bzip2/rules.mk | 64 + thirdparty/freetype/src/cache/ftcache.c | 11 +- thirdparty/freetype/src/cache/ftcbasic.c | 53 +- thirdparty/freetype/src/cache/ftccache.c | 16 +- thirdparty/freetype/src/cache/ftccache.h | 8 +- thirdparty/freetype/src/cache/ftccback.h | 2 +- thirdparty/freetype/src/cache/ftccmap.c | 16 +- thirdparty/freetype/src/cache/ftcerror.h | 2 +- thirdparty/freetype/src/cache/ftcglyph.c | 2 +- thirdparty/freetype/src/cache/ftcglyph.h | 2 +- thirdparty/freetype/src/cache/ftcimage.c | 2 +- thirdparty/freetype/src/cache/ftcimage.h | 2 +- thirdparty/freetype/src/cache/ftcmanag.c | 23 +- thirdparty/freetype/src/cache/ftcmanag.h | 2 +- thirdparty/freetype/src/cache/ftcmru.c | 12 +- thirdparty/freetype/src/cache/ftcmru.h | 4 +- thirdparty/freetype/src/cache/ftcsbits.c | 4 +- thirdparty/freetype/src/cache/ftcsbits.h | 2 +- thirdparty/freetype/src/cache/rules.mk | 2 +- thirdparty/freetype/src/cff/cf2arrst.c | 20 +- thirdparty/freetype/src/cff/cf2error.c | 2 +- thirdparty/freetype/src/cff/cf2error.h | 2 +- thirdparty/freetype/src/cff/cf2fixed.h | 4 +- thirdparty/freetype/src/cff/cf2font.c | 54 +- thirdparty/freetype/src/cff/cf2font.h | 8 + thirdparty/freetype/src/cff/cf2ft.c | 57 +- thirdparty/freetype/src/cff/cf2ft.h | 12 + thirdparty/freetype/src/cff/cf2hints.c | 4 +- thirdparty/freetype/src/cff/cf2intrp.c | 987 ++++---- thirdparty/freetype/src/cff/cf2stack.c | 77 +- thirdparty/freetype/src/cff/cf2stack.h | 14 +- thirdparty/freetype/src/cff/cff.c | 10 +- thirdparty/freetype/src/cff/cffcmap.c | 39 +- thirdparty/freetype/src/cff/cffcmap.h | 2 +- thirdparty/freetype/src/cff/cffdrivr.c | 399 +++- thirdparty/freetype/src/cff/cffdrivr.h | 2 +- thirdparty/freetype/src/cff/cfferrs.h | 2 +- thirdparty/freetype/src/cff/cffgload.c | 60 +- thirdparty/freetype/src/cff/cffgload.h | 2 +- thirdparty/freetype/src/cff/cffload.c | 1042 +++++++- thirdparty/freetype/src/cff/cffload.h | 57 +- thirdparty/freetype/src/cff/cffobjs.c | 124 +- thirdparty/freetype/src/cff/cffobjs.h | 10 +- thirdparty/freetype/src/cff/cffparse.c | 327 ++- thirdparty/freetype/src/cff/cffparse.h | 35 +- thirdparty/freetype/src/cff/cffpic.c | 2 +- thirdparty/freetype/src/cff/cffpic.h | 32 +- thirdparty/freetype/src/cff/cfftoken.h | 51 +- thirdparty/freetype/src/cff/cfftypes.h | 128 +- thirdparty/freetype/src/cff/module.mk | 2 +- thirdparty/freetype/src/cff/rules.mk | 2 +- thirdparty/freetype/src/cid/ciderrs.h | 2 +- thirdparty/freetype/src/cid/cidgload.c | 2 +- thirdparty/freetype/src/cid/cidgload.h | 2 +- thirdparty/freetype/src/cid/cidload.c | 18 +- thirdparty/freetype/src/cid/cidload.h | 2 +- thirdparty/freetype/src/cid/cidobjs.c | 12 +- thirdparty/freetype/src/cid/cidobjs.h | 2 +- thirdparty/freetype/src/cid/cidparse.c | 14 +- thirdparty/freetype/src/cid/cidparse.h | 2 +- thirdparty/freetype/src/cid/cidriver.c | 12 +- thirdparty/freetype/src/cid/cidriver.h | 2 +- thirdparty/freetype/src/cid/cidtoken.h | 2 +- thirdparty/freetype/src/cid/module.mk | 2 +- thirdparty/freetype/src/cid/rules.mk | 2 +- thirdparty/freetype/src/cid/type1cid.c | 8 +- thirdparty/freetype/src/gxvalid/README | 4 +- thirdparty/freetype/src/gxvalid/gxvalid.c | 16 +- thirdparty/freetype/src/gxvalid/gxvalid.h | 4 +- thirdparty/freetype/src/gxvalid/gxvbsln.c | 2 +- thirdparty/freetype/src/gxvalid/gxvcommn.c | 20 +- thirdparty/freetype/src/gxvalid/gxvcommn.h | 2 +- thirdparty/freetype/src/gxvalid/gxverror.h | 2 +- thirdparty/freetype/src/gxvalid/gxvfeat.c | 2 +- thirdparty/freetype/src/gxvalid/gxvfeat.h | 2 +- thirdparty/freetype/src/gxvalid/gxvfgen.c | 2 +- thirdparty/freetype/src/gxvalid/gxvjust.c | 2 +- thirdparty/freetype/src/gxvalid/gxvkern.c | 2 +- thirdparty/freetype/src/gxvalid/gxvlcar.c | 2 +- thirdparty/freetype/src/gxvalid/gxvmod.c | 10 +- thirdparty/freetype/src/gxvalid/gxvmod.h | 2 +- thirdparty/freetype/src/gxvalid/gxvmort.c | 4 +- thirdparty/freetype/src/gxvalid/gxvmort.h | 2 +- thirdparty/freetype/src/gxvalid/gxvmort0.c | 2 +- thirdparty/freetype/src/gxvalid/gxvmort1.c | 2 +- thirdparty/freetype/src/gxvalid/gxvmort2.c | 2 +- thirdparty/freetype/src/gxvalid/gxvmort4.c | 2 +- thirdparty/freetype/src/gxvalid/gxvmort5.c | 2 +- thirdparty/freetype/src/gxvalid/gxvmorx.c | 4 +- thirdparty/freetype/src/gxvalid/gxvmorx.h | 2 +- thirdparty/freetype/src/gxvalid/gxvmorx0.c | 2 +- thirdparty/freetype/src/gxvalid/gxvmorx1.c | 2 +- thirdparty/freetype/src/gxvalid/gxvmorx2.c | 2 +- thirdparty/freetype/src/gxvalid/gxvmorx4.c | 2 +- thirdparty/freetype/src/gxvalid/gxvmorx5.c | 2 +- thirdparty/freetype/src/gxvalid/gxvopbd.c | 2 +- thirdparty/freetype/src/gxvalid/gxvprop.c | 2 +- thirdparty/freetype/src/gxvalid/gxvtrak.c | 2 +- thirdparty/freetype/src/gxvalid/module.mk | 2 +- thirdparty/freetype/src/gxvalid/rules.mk | 2 +- thirdparty/freetype/src/gzip/adler32.c | 48 + thirdparty/freetype/src/gzip/ftgzip.c | 816 +++++++ thirdparty/freetype/src/gzip/ftzconf.h | 284 +++ thirdparty/freetype/src/gzip/infblock.c | 387 +++ thirdparty/freetype/src/gzip/infblock.h | 36 + thirdparty/freetype/src/gzip/infcodes.c | 250 ++ thirdparty/freetype/src/gzip/infcodes.h | 31 + thirdparty/freetype/src/gzip/inffixed.h | 151 ++ thirdparty/freetype/src/gzip/inflate.c | 273 +++ thirdparty/freetype/src/gzip/inftrees.c | 468 ++++ thirdparty/freetype/src/gzip/inftrees.h | 63 + thirdparty/freetype/src/gzip/infutil.c | 86 + thirdparty/freetype/src/gzip/infutil.h | 98 + thirdparty/freetype/src/gzip/rules.mk | 83 + thirdparty/freetype/src/gzip/zlib.h | 830 +++++++ thirdparty/freetype/src/gzip/zutil.c | 181 ++ thirdparty/freetype/src/gzip/zutil.h | 215 ++ thirdparty/freetype/src/lzw/ftlzw.c | 420 ++++ thirdparty/freetype/src/lzw/ftzopen.c | 424 ++++ thirdparty/freetype/src/lzw/ftzopen.h | 172 ++ thirdparty/freetype/src/lzw/rules.mk | 72 + thirdparty/freetype/src/otvalid/module.mk | 2 +- thirdparty/freetype/src/otvalid/otvalid.c | 5 +- thirdparty/freetype/src/otvalid/otvalid.h | 2 +- thirdparty/freetype/src/otvalid/otvbase.c | 2 +- thirdparty/freetype/src/otvalid/otvcommn.c | 4 +- thirdparty/freetype/src/otvalid/otvcommn.h | 2 +- thirdparty/freetype/src/otvalid/otverror.h | 2 +- thirdparty/freetype/src/otvalid/otvgdef.c | 2 +- thirdparty/freetype/src/otvalid/otvgpos.c | 2 +- thirdparty/freetype/src/otvalid/otvgpos.h | 2 +- thirdparty/freetype/src/otvalid/otvgsub.c | 2 +- thirdparty/freetype/src/otvalid/otvjstf.c | 2 +- thirdparty/freetype/src/otvalid/otvmath.c | 22 +- thirdparty/freetype/src/otvalid/otvmod.c | 10 +- thirdparty/freetype/src/otvalid/otvmod.h | 2 +- thirdparty/freetype/src/otvalid/rules.mk | 2 +- thirdparty/freetype/src/pcf/pcf.c | 8 +- thirdparty/freetype/src/pcf/pcf.h | 9 + thirdparty/freetype/src/pcf/pcfdrivr.c | 223 +- thirdparty/freetype/src/pcf/pcfread.c | 350 ++- thirdparty/freetype/src/pfr/module.mk | 2 +- thirdparty/freetype/src/pfr/pfr.c | 11 +- thirdparty/freetype/src/pfr/pfrcmap.c | 16 +- thirdparty/freetype/src/pfr/pfrcmap.h | 2 +- thirdparty/freetype/src/pfr/pfrdrivr.c | 20 +- thirdparty/freetype/src/pfr/pfrdrivr.h | 2 +- thirdparty/freetype/src/pfr/pfrerror.h | 2 +- thirdparty/freetype/src/pfr/pfrgload.c | 2 +- thirdparty/freetype/src/pfr/pfrgload.h | 2 +- thirdparty/freetype/src/pfr/pfrload.c | 6 +- thirdparty/freetype/src/pfr/pfrload.h | 2 +- thirdparty/freetype/src/pfr/pfrobjs.c | 12 +- thirdparty/freetype/src/pfr/pfrobjs.h | 2 +- thirdparty/freetype/src/pfr/pfrsbit.c | 8 +- thirdparty/freetype/src/pfr/pfrsbit.h | 5 +- thirdparty/freetype/src/pfr/pfrtypes.h | 2 +- thirdparty/freetype/src/pfr/rules.mk | 2 +- thirdparty/freetype/src/psaux/afmparse.c | 11 +- thirdparty/freetype/src/psaux/afmparse.h | 2 +- thirdparty/freetype/src/psaux/module.mk | 2 +- thirdparty/freetype/src/psaux/psaux.c | 14 +- thirdparty/freetype/src/psaux/psauxerr.h | 2 +- thirdparty/freetype/src/psaux/psauxmod.c | 74 +- thirdparty/freetype/src/psaux/psauxmod.h | 2 +- thirdparty/freetype/src/psaux/psconv.c | 2 +- thirdparty/freetype/src/psaux/psconv.h | 2 +- thirdparty/freetype/src/psaux/psobjs.c | 42 +- thirdparty/freetype/src/psaux/psobjs.h | 2 +- thirdparty/freetype/src/psaux/rules.mk | 2 +- thirdparty/freetype/src/psaux/t1cmap.c | 64 +- thirdparty/freetype/src/psaux/t1cmap.h | 2 +- thirdparty/freetype/src/psaux/t1decode.c | 74 +- thirdparty/freetype/src/psaux/t1decode.h | 2 +- thirdparty/freetype/src/pshinter/module.mk | 2 +- thirdparty/freetype/src/pshinter/pshalgo.c | 12 +- thirdparty/freetype/src/pshinter/pshalgo.h | 2 +- thirdparty/freetype/src/pshinter/pshglob.c | 2 +- thirdparty/freetype/src/pshinter/pshglob.h | 2 +- thirdparty/freetype/src/pshinter/pshinter.c | 10 +- thirdparty/freetype/src/pshinter/pshmod.c | 14 +- thirdparty/freetype/src/pshinter/pshmod.h | 2 +- thirdparty/freetype/src/pshinter/pshnterr.h | 2 +- thirdparty/freetype/src/pshinter/pshpic.c | 2 +- thirdparty/freetype/src/pshinter/pshpic.h | 2 +- thirdparty/freetype/src/pshinter/pshrec.c | 8 +- thirdparty/freetype/src/pshinter/pshrec.h | 2 +- thirdparty/freetype/src/pshinter/rules.mk | 2 +- thirdparty/freetype/src/psnames/module.mk | 2 +- thirdparty/freetype/src/psnames/psmodule.c | 22 +- thirdparty/freetype/src/psnames/psmodule.h | 2 +- thirdparty/freetype/src/psnames/psnamerr.h | 2 +- thirdparty/freetype/src/psnames/psnames.c | 6 +- thirdparty/freetype/src/psnames/pspic.c | 2 +- thirdparty/freetype/src/psnames/pspic.h | 2 +- thirdparty/freetype/src/psnames/pstables.h | 94 +- thirdparty/freetype/src/psnames/rules.mk | 2 +- thirdparty/freetype/src/raster/ftmisc.h | 2 +- thirdparty/freetype/src/raster/ftraster.c | 33 +- thirdparty/freetype/src/raster/ftraster.h | 2 +- thirdparty/freetype/src/raster/ftrend1.c | 26 +- thirdparty/freetype/src/raster/ftrend1.h | 2 +- thirdparty/freetype/src/raster/module.mk | 2 +- thirdparty/freetype/src/raster/raster.c | 6 +- thirdparty/freetype/src/raster/rasterrs.h | 2 +- thirdparty/freetype/src/raster/rastpic.c | 2 +- thirdparty/freetype/src/raster/rastpic.h | 2 +- thirdparty/freetype/src/raster/rules.mk | 2 +- thirdparty/freetype/src/sfnt/module.mk | 2 +- thirdparty/freetype/src/sfnt/pngshim.c | 41 +- thirdparty/freetype/src/sfnt/pngshim.h | 5 +- thirdparty/freetype/src/sfnt/rules.mk | 2 +- thirdparty/freetype/src/sfnt/sfdriver.c | 968 +++++++- thirdparty/freetype/src/sfnt/sfdriver.h | 2 +- thirdparty/freetype/src/sfnt/sferrors.h | 2 +- thirdparty/freetype/src/sfnt/sfnt.c | 26 +- thirdparty/freetype/src/sfnt/sfntpic.c | 2 +- thirdparty/freetype/src/sfnt/sfntpic.h | 2 +- thirdparty/freetype/src/sfnt/sfobjs.c | 321 ++- thirdparty/freetype/src/sfnt/sfobjs.h | 2 +- thirdparty/freetype/src/sfnt/ttbdf.c | 15 +- thirdparty/freetype/src/sfnt/ttbdf.h | 2 +- thirdparty/freetype/src/sfnt/ttcmap.c | 340 +-- thirdparty/freetype/src/sfnt/ttcmap.h | 2 +- thirdparty/freetype/src/sfnt/ttcmapc.h | 2 +- thirdparty/freetype/src/sfnt/ttkern.c | 9 +- thirdparty/freetype/src/sfnt/ttkern.h | 2 +- thirdparty/freetype/src/sfnt/ttload.c | 160 +- thirdparty/freetype/src/sfnt/ttload.h | 2 +- thirdparty/freetype/src/sfnt/ttmtx.c | 48 +- thirdparty/freetype/src/sfnt/ttmtx.h | 2 +- thirdparty/freetype/src/sfnt/ttpost.c | 17 +- thirdparty/freetype/src/sfnt/ttpost.h | 2 +- thirdparty/freetype/src/sfnt/ttsbit.c | 228 +- thirdparty/freetype/src/sfnt/ttsbit.h | 2 +- thirdparty/freetype/src/smooth/ftgrays.c | 576 ++--- thirdparty/freetype/src/smooth/ftgrays.h | 2 +- thirdparty/freetype/src/smooth/ftsmerrs.h | 2 +- thirdparty/freetype/src/smooth/ftsmooth.c | 152 +- thirdparty/freetype/src/smooth/ftsmooth.h | 11 +- thirdparty/freetype/src/smooth/ftspic.c | 2 +- thirdparty/freetype/src/smooth/ftspic.h | 2 +- thirdparty/freetype/src/smooth/module.mk | 2 +- thirdparty/freetype/src/smooth/rules.mk | 2 +- thirdparty/freetype/src/smooth/smooth.c | 6 +- thirdparty/freetype/src/truetype/module.mk | 2 +- thirdparty/freetype/src/truetype/rules.mk | 2 +- thirdparty/freetype/src/truetype/truetype.c | 18 +- thirdparty/freetype/src/truetype/ttdriver.c | 153 +- thirdparty/freetype/src/truetype/ttdriver.h | 2 +- thirdparty/freetype/src/truetype/tterrors.h | 2 +- thirdparty/freetype/src/truetype/ttgload.c | 309 +-- thirdparty/freetype/src/truetype/ttgload.h | 2 +- thirdparty/freetype/src/truetype/ttgxvar.c | 2514 ++++++++++++++++---- thirdparty/freetype/src/truetype/ttgxvar.h | 289 ++- thirdparty/freetype/src/truetype/ttinterp.c | 399 +++- thirdparty/freetype/src/truetype/ttinterp.h | 23 +- thirdparty/freetype/src/truetype/ttobjs.c | 260 +- thirdparty/freetype/src/truetype/ttobjs.h | 10 +- thirdparty/freetype/src/truetype/ttpic.c | 2 +- thirdparty/freetype/src/truetype/ttpic.h | 23 +- thirdparty/freetype/src/truetype/ttpload.c | 69 +- thirdparty/freetype/src/truetype/ttpload.h | 2 +- thirdparty/freetype/src/truetype/ttsubpix.c | 13 +- thirdparty/freetype/src/truetype/ttsubpix.h | 2 +- thirdparty/freetype/src/type1/module.mk | 2 +- thirdparty/freetype/src/type1/rules.mk | 2 +- thirdparty/freetype/src/type1/t1afm.c | 17 +- thirdparty/freetype/src/type1/t1afm.h | 2 +- thirdparty/freetype/src/type1/t1driver.c | 17 +- thirdparty/freetype/src/type1/t1driver.h | 2 +- thirdparty/freetype/src/type1/t1errors.h | 2 +- thirdparty/freetype/src/type1/t1gload.c | 2 +- thirdparty/freetype/src/type1/t1gload.h | 2 +- thirdparty/freetype/src/type1/t1load.c | 108 +- thirdparty/freetype/src/type1/t1load.h | 16 +- thirdparty/freetype/src/type1/t1objs.c | 15 +- thirdparty/freetype/src/type1/t1objs.h | 2 +- thirdparty/freetype/src/type1/t1parse.c | 4 +- thirdparty/freetype/src/type1/t1parse.h | 2 +- thirdparty/freetype/src/type1/t1tokens.h | 2 +- thirdparty/freetype/src/type1/type1.c | 15 +- thirdparty/freetype/src/type42/module.mk | 2 +- thirdparty/freetype/src/type42/rules.mk | 2 +- thirdparty/freetype/src/type42/t42drivr.c | 13 +- thirdparty/freetype/src/type42/t42drivr.h | 2 +- thirdparty/freetype/src/type42/t42error.h | 2 +- thirdparty/freetype/src/type42/t42objs.c | 9 +- thirdparty/freetype/src/type42/t42objs.h | 2 +- thirdparty/freetype/src/type42/t42parse.c | 6 +- thirdparty/freetype/src/type42/t42parse.h | 2 +- thirdparty/freetype/src/type42/t42types.h | 2 +- thirdparty/freetype/src/type42/type42.c | 8 +- thirdparty/freetype/src/winfonts/fnterrs.h | 2 +- thirdparty/freetype/src/winfonts/module.mk | 2 +- thirdparty/freetype/src/winfonts/rules.mk | 2 +- thirdparty/freetype/src/winfonts/winfnt.c | 79 +- thirdparty/freetype/src/winfonts/winfnt.h | 2 +- 474 files changed, 21186 insertions(+), 5509 deletions(-) create mode 100644 thirdparty/freetype/include/freetype/ftpcfdrv.h create mode 100644 thirdparty/freetype/include/freetype/internal/services/svmetric.h create mode 100644 thirdparty/freetype/src/bzip2/ftbzip2.c create mode 100644 thirdparty/freetype/src/bzip2/rules.mk create mode 100644 thirdparty/freetype/src/gzip/adler32.c create mode 100644 thirdparty/freetype/src/gzip/ftgzip.c create mode 100644 thirdparty/freetype/src/gzip/ftzconf.h create mode 100644 thirdparty/freetype/src/gzip/infblock.c create mode 100644 thirdparty/freetype/src/gzip/infblock.h create mode 100644 thirdparty/freetype/src/gzip/infcodes.c create mode 100644 thirdparty/freetype/src/gzip/infcodes.h create mode 100644 thirdparty/freetype/src/gzip/inffixed.h create mode 100644 thirdparty/freetype/src/gzip/inflate.c create mode 100644 thirdparty/freetype/src/gzip/inftrees.c create mode 100644 thirdparty/freetype/src/gzip/inftrees.h create mode 100644 thirdparty/freetype/src/gzip/infutil.c create mode 100644 thirdparty/freetype/src/gzip/infutil.h create mode 100644 thirdparty/freetype/src/gzip/rules.mk create mode 100644 thirdparty/freetype/src/gzip/zlib.h create mode 100644 thirdparty/freetype/src/gzip/zutil.c create mode 100644 thirdparty/freetype/src/gzip/zutil.h create mode 100644 thirdparty/freetype/src/lzw/ftlzw.c create mode 100644 thirdparty/freetype/src/lzw/ftzopen.c create mode 100644 thirdparty/freetype/src/lzw/ftzopen.h create mode 100644 thirdparty/freetype/src/lzw/rules.mk diff --git a/modules/freetype/SCsub b/modules/freetype/SCsub index 8401c36b54..6a89e8e087 100644 --- a/modules/freetype/SCsub +++ b/modules/freetype/SCsub @@ -34,10 +34,13 @@ if (env['builtin_freetype'] != 'no'): "src/base/fttype1.c", "src/base/ftwinfnt.c", "src/bdf/bdf.c", + "src/bzip2/ftbzip2.c", "src/cache/ftcache.c", "src/cff/cff.c", "src/cid/type1cid.c", "src/gxvalid/gxvalid.c", + "src/gzip/ftgzip.c", + "src/lzw/ftlzw.c", "src/otvalid/otvalid.c", "src/pcf/pcf.c", "src/pfr/pfr.c", @@ -77,6 +80,9 @@ if (env['builtin_freetype'] != 'no'): break if not inserted: env.Append(LIBS=[lib]) + env.Append(CCFLAGS=['-DFT2_BUILD_LIBRARY']) + if (env['target'] != 'release'): + env.Append(CCFLAGS=['-DZLIB_DEBUG']) # Godot source files env.add_source_files(env.modules_sources, "*.cpp") diff --git a/thirdparty/README.md b/thirdparty/README.md index c846094a6a..ef4f83d4ad 100644 --- a/thirdparty/README.md +++ b/thirdparty/README.md @@ -59,7 +59,7 @@ TODO. ## freetype - Upstream: https://www.freetype.org -- Version: 2.6.5 +- Version: 2.8 - License: FreeType License (BSD-like) Files extracted from upstream source: diff --git a/thirdparty/freetype/include/freetype/config/ftconfig.h b/thirdparty/freetype/include/freetype/config/ftconfig.h index 157a704fa8..889aebf5ab 100644 --- a/thirdparty/freetype/include/freetype/config/ftconfig.h +++ b/thirdparty/freetype/include/freetype/config/ftconfig.h @@ -4,7 +4,7 @@ /* */ /* ANSI-specific configuration file (specification only). */ /* */ -/* Copyright 1996-2016 by */ +/* Copyright 1996-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -143,6 +143,14 @@ FT_BEGIN_HEADER #endif + /* Fix compiler warning with sgi compiler */ +#if defined( __sgi ) && !defined( __GNUC__ ) +#if defined( _COMPILER_VERSION ) && ( _COMPILER_VERSION >= 730 ) +#pragma set woff 3505 +#endif +#endif + + /*************************************************************************/ /* */ /*
*/ @@ -325,6 +333,15 @@ FT_BEGIN_HEADER #endif +#ifdef _WIN64 + /* only 64bit Windows uses the LLP64 data model, i.e., */ + /* 32bit integers, 64bit pointers */ +#define FT_UINT_TO_POINTER( x ) (void*)(unsigned __int64)(x) +#else +#define FT_UINT_TO_POINTER( x ) (void*)(unsigned long)(x) +#endif + + /*************************************************************************/ /* */ /* miscellaneous */ @@ -338,10 +355,11 @@ FT_BEGIN_HEADER /* typeof condition taken from gnulib's `intprops.h' header file */ -#if ( __GNUC__ >= 2 || \ - defined( __IBM__TYPEOF__ ) || \ - ( __SUNPRO_C >= 0x5110 && !__STDC__ ) ) -#define FT_TYPEOF( type ) (__typeof__ (type)) +#if ( ( defined( __GNUC__ ) && __GNUC__ >= 2 ) || \ + ( defined( __IBMC__ ) && __IBMC__ >= 1210 && \ + defined( __IBM__TYPEOF__ ) ) || \ + ( defined( __SUNPRO_C ) && __SUNPRO_C >= 0x5110 && !__STDC__ ) ) +#define FT_TYPEOF( type ) ( __typeof__ ( type ) ) #else #define FT_TYPEOF( type ) /* empty */ #endif diff --git a/thirdparty/freetype/include/freetype/config/ftheader.h b/thirdparty/freetype/include/freetype/config/ftheader.h index 68e14834d4..d491af57c3 100644 --- a/thirdparty/freetype/include/freetype/config/ftheader.h +++ b/thirdparty/freetype/include/freetype/config/ftheader.h @@ -4,7 +4,7 @@ /* */ /* Build macros of the FreeType 2 library. */ /* */ -/* Copyright 1996-2016 by */ +/* Copyright 1996-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -354,6 +354,19 @@ #define FT_TRUETYPE_DRIVER_H + /************************************************************************* + * + * @macro: + * FT_PCF_DRIVER_H + * + * @description: + * A macro used in #include statements to name the file containing + * structures and macros related to the PCF driver module. + * + */ +#define FT_PCF_DRIVER_H + + /************************************************************************* * * @macro: diff --git a/thirdparty/freetype/include/freetype/config/ftoption.h b/thirdparty/freetype/include/freetype/config/ftoption.h index afd32f1cda..1bf6e8f534 100644 --- a/thirdparty/freetype/include/freetype/config/ftoption.h +++ b/thirdparty/freetype/include/freetype/config/ftoption.h @@ -4,7 +4,7 @@ /* */ /* User-selectable configuration macros (specification only). */ /* */ -/* Copyright 1996-2016 by */ +/* Copyright 1996-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -75,6 +75,36 @@ FT_BEGIN_HEADER /*************************************************************************/ + /*************************************************************************/ + /* */ + /* If you enable this configuration option, FreeType recognizes an */ + /* environment variable called `FREETYPE_PROPERTIES', which can be used */ + /* to control the various font drivers and modules. The controllable */ + /* properties are listed in the section `Controlling FreeType Modules' */ + /* in the reference's table of contents; currently there are properties */ + /* for the auto-hinter (file `ftautoh.h'), CFF (file `ftcffdrv.h'), */ + /* TrueType (file `ftttdrv.h'), and PCF (file `ftpcfdrv.h'). */ + /* */ + /* `FREETYPE_PROPERTIES' has the following syntax form (broken here into */ + /* multiple lines for better readability). */ + /* */ + /* */ + /* ':' */ + /* '=' */ + /* */ + /* ':' */ + /* '=' */ + /* ... */ + /* */ + /* Example: */ + /* */ + /* FREETYPE_PROPERTIES=truetype:interpreter-version=35 \ */ + /* cff:no-stem-darkening=1 \ */ + /* autofitter:warping=1 */ + /* */ +#define FT_CONFIG_OPTION_ENVIRONMENT_PROPERTIES + + /*************************************************************************/ /* */ /* Uncomment the line below if you want to activate sub-pixel rendering */ @@ -148,7 +178,7 @@ FT_BEGIN_HEADER /* */ /* Define this macro if you want to enable this `feature'. */ /* */ -/* #define FT_CONFIG_OPTION_USE_LZW */ // -GODOT- +#define FT_CONFIG_OPTION_USE_LZW /*************************************************************************/ @@ -163,7 +193,7 @@ FT_BEGIN_HEADER /* Define this macro if you want to enable this `feature'. See also */ /* the macro FT_CONFIG_OPTION_SYSTEM_ZLIB below. */ /* */ -/* #define FT_CONFIG_OPTION_USE_ZLIB */ // -GODOT- +#define FT_CONFIG_OPTION_USE_ZLIB /*************************************************************************/ @@ -492,7 +522,21 @@ FT_BEGIN_HEADER /* code will be used. */ /* */ /* Setting this macro is needed for systems that prohibit address */ - /* fixups, such as BREW. */ + /* fixups, such as BREW. [Note that standard compilers like gcc or */ + /* clang handle PIC generation automatically; you don't have to set */ + /* FT_CONFIG_OPTION_PIC, which is only necessary for very special */ + /* compilers.] */ + /* */ + /* Note that FT_CONFIG_OPTION_PIC support is not available for all */ + /* modules (see `modules.cfg' for a complete list). For building with */ + /* FT_CONFIG_OPTION_PIC support, do the following. */ + /* */ + /* 0. Clone the repository. */ + /* 1. Define FT_CONFIG_OPTION_PIC. */ + /* 2. Remove all subdirectories in `src' that don't have */ + /* FT_CONFIG_OPTION_PIC support. */ + /* 3. Comment out the corresponding modules in `modules.cfg'. */ + /* 4. Compile. */ /* */ /* #define FT_CONFIG_OPTION_PIC */ @@ -596,17 +640,21 @@ FT_BEGIN_HEADER /* [1] for a technical overview on what this means. See `ttinterp.h' */ /* for more details on the LEAN option. */ /* */ - /* There are three options. */ + /* There are three possible values. */ /* */ - /* 1. This option is associated with the `Infinality' moniker. */ - /* Contributed by an individual nicknamed Infinality with the goal of */ + /* Value 1: */ + /* This value is associated with the `Infinality' moniker, */ + /* contributed by an individual nicknamed Infinality with the goal of */ /* making TrueType fonts render better than on Windows. A high */ /* amount of configurability and flexibility, down to rules for */ /* single glyphs in fonts, but also very slow. Its experimental and */ /* slow nature and the original developer losing interest meant that */ /* this option was never enabled in default builds. */ /* */ - /* 2. The new default mode for the TrueType driver. The Infinality code */ + /* The corresponding interpreter version is v38. */ + /* */ + /* Value 2: */ + /* The new default mode for the TrueType driver. The Infinality code */ /* base was stripped to the bare minimum and all configurability */ /* removed in the name of speed and simplicity. The configurability */ /* was mainly aimed at legacy fonts like Arial, Times New Roman, or */ @@ -616,14 +664,19 @@ FT_BEGIN_HEADER /* that modern and web fonts render well while legacy fonts render */ /* okay. */ /* */ - /* 3. Compile both. */ + /* The corresponding interpreter version is v40. */ + /* */ + /* Value 3: */ + /* Compile both, making both v38 and v40 available (the latter is the */ + /* default). */ /* */ /* By undefining these, you get rendering behavior like on Windows */ /* without ClearType, i.e., Windows XP without ClearType enabled and */ /* Win9x (interpreter version v35). Or not, depending on how much */ /* hinting blood and testing tears the font designer put into a given */ /* font. If you define one or both subpixel hinting options, you can */ - /* switch between between v35 and the ones you define. */ + /* switch between between v35 and the ones you define (using */ + /* `FT_Property_Set'). */ /* */ /* This option requires TT_CONFIG_OPTION_BYTECODE_INTERPRETER to be */ /* defined. */ @@ -631,7 +684,7 @@ FT_BEGIN_HEADER /* [1] http://www.microsoft.com/typography/cleartype/truetypecleartype.aspx */ /* */ /* #define TT_CONFIG_OPTION_SUBPIXEL_HINTING 1 */ -/* #define TT_CONFIG_OPTION_SUBPIXEL_HINTING 2 */ +#define TT_CONFIG_OPTION_SUBPIXEL_HINTING 2 /* #define TT_CONFIG_OPTION_SUBPIXEL_HINTING ( 1 | 2 ) */ @@ -788,6 +841,33 @@ FT_BEGIN_HEADER /* #define CFF_CONFIG_OPTION_OLD_ENGINE */ + /*************************************************************************/ + /*************************************************************************/ + /**** ****/ + /**** P C F D R I V E R C O N F I G U R A T I O N ****/ + /**** ****/ + /*************************************************************************/ + /*************************************************************************/ + + + /*************************************************************************/ + /* */ + /* There are many PCF fonts just called `Fixed' which look completely */ + /* different, and which have nothing to do with each other. When */ + /* selecting `Fixed' in KDE or Gnome one gets results that appear rather */ + /* random, the style changes often if one changes the size and one */ + /* cannot select some fonts at all. This option makes the PCF module */ + /* prepend the foundry name (plus a space) to the family name. */ + /* */ + /* We also check whether we have `wide' characters; all put together, we */ + /* get family names like `Sony Fixed' or `Misc Fixed Wide'. */ + /* */ + /* If this option is activated, it can be controlled with the */ + /* `no-long-family-names' property of the pcf driver module. */ + /* */ +/* #define PCF_CONFIG_OPTION_LONG_FAMILY_NAMES */ + + /*************************************************************************/ /*************************************************************************/ /**** ****/ @@ -806,7 +886,9 @@ FT_BEGIN_HEADER /*************************************************************************/ /* */ - /* Compile autofit module with Indic script support. */ + /* Compile autofit module with fallback Indic script support, covering */ + /* some scripts that the `latin' submodule of the autofit module doesn't */ + /* (yet) handle. */ /* */ #define AF_CONFIG_OPTION_INDIC @@ -825,6 +907,26 @@ FT_BEGIN_HEADER /* */ #define AF_CONFIG_OPTION_USE_WARPER + /*************************************************************************/ + /* */ + /* Use TrueType-like size metrics for `light' auto-hinting. */ + /* */ + /* It is strongly recommended to avoid this option, which exists only to */ + /* help some legacy applications retain its appearance and behaviour */ + /* with respect to auto-hinted TrueType fonts. */ + /* */ + /* The very reason this option exists at all are GNU/Linux distributions */ + /* like Fedora that did not un-patch the following change (which was */ + /* present in FreeType between versions 2.4.6 and 2.7.1, inclusive). */ + /* */ + /* 2011-07-16 Steven Chu */ + /* */ + /* [truetype] Fix metrics on size request for scalable fonts. */ + /* */ + /* This problematic commit is now reverted (more or less). */ + /* */ +/* #define AF_CONFIG_OPTION_TT_SIZE_METRICS */ + /* */ @@ -842,6 +944,7 @@ FT_BEGIN_HEADER #ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER #define TT_USE_BYTECODE_INTERPRETER +#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING #if TT_CONFIG_OPTION_SUBPIXEL_HINTING & 1 #define TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY #endif @@ -849,6 +952,7 @@ FT_BEGIN_HEADER #if TT_CONFIG_OPTION_SUBPIXEL_HINTING & 2 #define TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL #endif +#endif #endif diff --git a/thirdparty/freetype/include/freetype/config/ftstdlib.h b/thirdparty/freetype/include/freetype/config/ftstdlib.h index 562e255810..05a4845fd5 100644 --- a/thirdparty/freetype/include/freetype/config/ftstdlib.h +++ b/thirdparty/freetype/include/freetype/config/ftstdlib.h @@ -5,7 +5,7 @@ /* ANSI-specific library and header configuration file (specification */ /* only). */ /* */ -/* Copyright 2002-2016 by */ +/* Copyright 2002-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -142,7 +142,8 @@ /**********************************************************************/ -#define ft_atol atol +#define ft_strtol strtol +#define ft_getenv getenv /**********************************************************************/ diff --git a/thirdparty/freetype/include/freetype/freetype.h b/thirdparty/freetype/include/freetype/freetype.h index 45e10c48a2..2989fbb5e1 100644 --- a/thirdparty/freetype/include/freetype/freetype.h +++ b/thirdparty/freetype/include/freetype/freetype.h @@ -4,7 +4,7 @@ /* */ /* FreeType high-level API and common types (specification only). */ /* */ -/* Copyright 1996-2016 by */ +/* Copyright 1996-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -175,6 +175,7 @@ FT_BEGIN_HEADER /* FT_Done_Face */ /* FT_Reference_Face */ /* FT_New_Memory_Face */ + /* FT_Face_Properties */ /* FT_Open_Face */ /* FT_Open_Args */ /* FT_Parameter */ @@ -265,8 +266,8 @@ FT_BEGIN_HEADER /* FT_Glyph_Metrics */ /* */ /* */ - /* A structure used to model the metrics of a single glyph. The */ - /* values are expressed in 26.6 fractional pixel format; if the flag */ + /* A structure to model the metrics of a single glyph. The values */ + /* are expressed in 26.6 fractional pixel format; if the flag */ /* @FT_LOAD_NO_SCALE has been used while loading the glyph, values */ /* are expressed in font units instead. */ /* */ @@ -305,6 +306,11 @@ FT_BEGIN_HEADER /* `horiAdvance' or `vertAdvance'; you have to manually adjust these */ /* values to account for the added width and height. */ /* */ + /* FreeType doesn't use the `VORG' table data for CFF fonts because */ + /* it doesn't have an interface to quickly retrieve the glyph height. */ + /* The y~coordinate of the vertical origin can be simply computed as */ + /* `vertBearingY + height' after loading a glyph. */ + /* */ typedef struct FT_Glyph_Metrics_ { FT_Pos width; @@ -349,10 +355,10 @@ FT_BEGIN_HEADER /* */ /* */ /* Windows FNT: */ - /* The nominal size given in a FNT font is not reliable. Thus when */ - /* the driver finds it incorrect, it sets `size' to some calculated */ - /* values and sets `x_ppem' and `y_ppem' to the pixel width and */ - /* height given in the font, respectively. */ + /* The nominal size given in a FNT font is not reliable. If the */ + /* driver finds it incorrect, it sets `size' to some calculated */ + /* values, and `x_ppem' and `y_ppem' to the pixel width and height */ + /* given in the font, respectively. */ /* */ /* TrueType embedded bitmaps: */ /* `size', `width', and `height' values are not contained in the */ @@ -421,9 +427,9 @@ FT_BEGIN_HEADER /* FT_Module */ /* */ /* */ - /* A handle to a given FreeType module object. Each module can be a */ + /* A handle to a given FreeType module object. A module can be a */ /* font driver, a renderer, or anything else that provides services */ - /* to the formers. */ + /* to the former. */ /* */ typedef struct FT_ModuleRec_* FT_Module; @@ -434,8 +440,8 @@ FT_BEGIN_HEADER /* FT_Driver */ /* */ /* */ - /* A handle to a given FreeType font driver object. Each font driver */ - /* is a special module capable of creating faces from font files. */ + /* A handle to a given FreeType font driver object. A font driver */ + /* is a module capable of creating faces from font files. */ /* */ typedef struct FT_DriverRec_* FT_Driver; @@ -446,10 +452,10 @@ FT_BEGIN_HEADER /* FT_Renderer */ /* */ /* */ - /* A handle to a given FreeType renderer. A renderer is a special */ - /* module in charge of converting a glyph image to a bitmap, when */ - /* necessary. Each renderer supports a given glyph image format, and */ - /* one or more target surface depths. */ + /* A handle to a given FreeType renderer. A renderer is a module in */ + /* charge of converting a glyph's outline image to a bitmap. It */ + /* supports a single glyph image format, and one or more target */ + /* surface depths. */ /* */ typedef struct FT_RendererRec_* FT_Renderer; @@ -467,15 +473,15 @@ FT_BEGIN_HEADER /* FT_Face */ /* */ /* */ - /* A handle to a given typographic face object. A face object models */ - /* a given typeface, in a given style. */ + /* A handle to a typographic face object. A face object models a */ + /* given typeface, in a given style. */ /* */ /* */ - /* Each face object also owns a single @FT_GlyphSlot object, as well */ + /* A face object also owns a single @FT_GlyphSlot object, as well */ /* as one or more @FT_Size objects. */ /* */ /* Use @FT_New_Face or @FT_Open_Face to create a new face object from */ - /* a given filepathname or a custom input stream. */ + /* a given filepath or a custom input stream. */ /* */ /* Use @FT_Done_Face to destroy it (along with its slot and sizes). */ /* */ @@ -500,11 +506,11 @@ FT_BEGIN_HEADER /* FT_Size */ /* */ /* */ - /* A handle to an object used to model a face scaled to a given */ + /* A handle to an object that models a face scaled to a given */ /* character size. */ /* */ /* */ - /* Each @FT_Face has an _active_ @FT_Size object that is used by */ + /* An @FT_Face has one _active_ @FT_Size object that is used by */ /* functions like @FT_Load_Glyph to determine the scaling */ /* transformation that in turn is used to load and hint glyphs and */ /* metrics. */ @@ -531,9 +537,8 @@ FT_BEGIN_HEADER /* FT_GlyphSlot */ /* */ /* */ - /* A handle to a given `glyph slot'. A slot is a container where it */ - /* is possible to load any of the glyphs contained in its parent */ - /* face. */ + /* A handle to a given `glyph slot'. A slot is a container that can */ + /* hold any of the glyphs contained in its parent face. */ /* */ /* In other words, each time you call @FT_Load_Glyph or */ /* @FT_Load_Char, the slot's content is erased by the new glyph data, */ @@ -552,13 +557,14 @@ FT_BEGIN_HEADER /* FT_CharMap */ /* */ /* */ - /* A handle to a given character map. A charmap is used to translate */ - /* character codes in a given encoding into glyph indexes for its */ - /* parent's face. Some font formats may provide several charmaps per */ - /* font. */ + /* A handle to a character map (usually abbreviated to `charmap'). A */ + /* charmap is used to translate character codes in a given encoding */ + /* into glyph indexes for its parent's face. Some font formats may */ + /* provide several charmaps per font. */ /* */ /* Each face object owns zero or more charmaps, but only one of them */ - /* can be `active' and used by @FT_Get_Char_Index or @FT_Load_Char. */ + /* can be `active', providing the data used by @FT_Get_Char_Index or */ + /* @FT_Load_Char. */ /* */ /* The list of available charmaps in a face is available through the */ /* `face->num_charmaps' and `face->charmaps' fields of @FT_FaceRec. */ @@ -615,8 +621,8 @@ FT_BEGIN_HEADER /* FT_Encoding */ /* */ /* */ - /* An enumeration used to specify character sets supported by */ - /* charmaps. Used in the @FT_Select_Charmap API function. */ + /* An enumeration to specify character sets supported by charmaps. */ + /* Used in the @FT_Select_Charmap API function. */ /* */ /* */ /* Despite the name, this enumeration lists specific character */ @@ -630,18 +636,17 @@ FT_BEGIN_HEADER /* The encoding value~0 is reserved. */ /* */ /* FT_ENCODING_UNICODE :: */ - /* Corresponds to the Unicode character set. This value covers */ - /* all versions of the Unicode repertoire, including ASCII and */ - /* Latin-1. Most fonts include a Unicode charmap, but not all */ - /* of them. */ + /* The Unicode character set. This value covers all versions of */ + /* the Unicode repertoire, including ASCII and Latin-1. Most fonts */ + /* include a Unicode charmap, but not all of them. */ /* */ /* For example, if you want to access Unicode value U+1F028 (and */ /* the font contains it), use value 0x1F028 as the input value for */ /* @FT_Get_Char_Index. */ /* */ /* FT_ENCODING_MS_SYMBOL :: */ - /* Corresponds to the Microsoft Symbol encoding, used to encode */ - /* mathematical symbols and wingdings. For more information, see */ + /* Microsoft Symbol encoding, used to encode mathematical symbols */ + /* and wingdings. For more information, see */ /* `http://www.microsoft.com/typography/otspec/recom.htm', */ /* `http://www.kostis.net/charsets/symbol.htm', and */ /* `http://www.kostis.net/charsets/wingding.htm'. */ @@ -650,60 +655,60 @@ FT_BEGIN_HEADER /* Area) in the range U+F020-U+F0FF. */ /* */ /* FT_ENCODING_SJIS :: */ - /* Corresponds to Japanese SJIS encoding. More info at */ - /* `http://en.wikipedia.org/wiki/Shift_JIS'. */ - /* See note on multi-byte encodings below. */ + /* Shift JIS encoding for Japanese. More info at */ + /* `http://en.wikipedia.org/wiki/Shift_JIS'. See note on */ + /* multi-byte encodings below. */ /* */ - /* FT_ENCODING_GB2312 :: */ - /* Corresponds to an encoding system for Simplified Chinese as */ - /* used in mainland China. */ + /* FT_ENCODING_PRC :: */ + /* Corresponds to encoding systems mainly for Simplified Chinese as */ + /* used in People's Republic of China (PRC). The encoding layout */ + /* is based on GB~2312 and its supersets GBK and GB~18030. */ /* */ /* FT_ENCODING_BIG5 :: */ /* Corresponds to an encoding system for Traditional Chinese as */ /* used in Taiwan and Hong Kong. */ /* */ /* FT_ENCODING_WANSUNG :: */ - /* Corresponds to the Korean encoding system known as Wansung. */ + /* Corresponds to the Korean encoding system known as Extended */ + /* Wansung (MS Windows code page 949). */ /* For more information see */ - /* `https://msdn.microsoft.com/en-US/goglobal/cc305154'. */ + /* `http://www.unicode.org/Public/MAPPINGS/VENDORS/MICSFT/WindowsBestFit/bestfit949.txt'. */ /* */ /* FT_ENCODING_JOHAB :: */ /* The Korean standard character set (KS~C 5601-1992), which */ /* corresponds to MS Windows code page 1361. This character set */ - /* includes all possible Hangeul character combinations. */ + /* includes all possible Hangul character combinations. */ /* */ /* FT_ENCODING_ADOBE_LATIN_1 :: */ /* Corresponds to a Latin-1 encoding as defined in a Type~1 */ /* PostScript font. It is limited to 256 character codes. */ /* */ /* FT_ENCODING_ADOBE_STANDARD :: */ - /* Corresponds to the Adobe Standard encoding, as found in Type~1, */ - /* CFF, and OpenType/CFF fonts. It is limited to 256 character */ - /* codes. */ + /* Adobe Standard encoding, as found in Type~1, CFF, and */ + /* OpenType/CFF fonts. It is limited to 256 character codes. */ /* */ /* FT_ENCODING_ADOBE_EXPERT :: */ - /* Corresponds to the Adobe Expert encoding, as found in Type~1, */ - /* CFF, and OpenType/CFF fonts. It is limited to 256 character */ - /* codes. */ + /* Adobe Expert encoding, as found in Type~1, CFF, and OpenType/CFF */ + /* fonts. It is limited to 256 character codes. */ /* */ /* FT_ENCODING_ADOBE_CUSTOM :: */ /* Corresponds to a custom encoding, as found in Type~1, CFF, and */ /* OpenType/CFF fonts. It is limited to 256 character codes. */ /* */ /* FT_ENCODING_APPLE_ROMAN :: */ - /* Corresponds to the 8-bit Apple roman encoding. Many TrueType */ - /* and OpenType fonts contain a charmap for this encoding, since */ - /* older versions of Mac OS are able to use it. */ + /* Apple roman encoding. Many TrueType and OpenType fonts contain */ + /* a charmap for this 8-bit encoding, since older versions of Mac */ + /* OS are able to use it. */ /* */ /* FT_ENCODING_OLD_LATIN_2 :: */ - /* This value is deprecated and was never used nor reported by */ + /* This value is deprecated and was neither used nor reported by */ /* FreeType. Don't use or test for it. */ /* */ /* FT_ENCODING_MS_SJIS :: */ /* Same as FT_ENCODING_SJIS. Deprecated. */ /* */ /* FT_ENCODING_MS_GB2312 :: */ - /* Same as FT_ENCODING_GB2312. Deprecated. */ + /* Same as FT_ENCODING_PRC. Deprecated. */ /* */ /* FT_ENCODING_MS_BIG5 :: */ /* Same as FT_ENCODING_BIG5. Deprecated. */ @@ -716,7 +721,7 @@ FT_BEGIN_HEADER /* */ /* */ /* By default, FreeType automatically synthesizes a Unicode charmap */ - /* for PostScript fonts, using their glyph names dictionaries. */ + /* for PostScript fonts, using their glyph name dictionaries. */ /* However, it also reports the encodings defined explicitly in the */ /* font file, for the cases when they are needed, with the Adobe */ /* values as well. */ @@ -736,7 +741,7 @@ FT_BEGIN_HEADER /* Russian). */ /* */ /* FT_ENCODING_NONE is set if `platform_id' is @TT_PLATFORM_MACINTOSH */ - /* and `encoding_id' is not @TT_MAC_ID_ROMAN (otherwise it is set to */ + /* and `encoding_id' is not `TT_MAC_ID_ROMAN' (otherwise it is set to */ /* FT_ENCODING_APPLE_ROMAN). */ /* */ /* If `platform_id' is @TT_PLATFORM_MACINTOSH, use the function */ @@ -748,9 +753,9 @@ FT_BEGIN_HEADER /* to get an idea how to do that. Basically, if the language ID */ /* is~0, don't use it, otherwise subtract 1 from the language ID. */ /* Then examine `encoding_id'. If, for example, `encoding_id' is */ - /* @TT_MAC_ID_ROMAN and the language ID (minus~1) is */ + /* `TT_MAC_ID_ROMAN' and the language ID (minus~1) is */ /* `TT_MAC_LANGID_GREEK', it is the Greek encoding, not Roman. */ - /* @TT_MAC_ID_ARABIC with `TT_MAC_LANGID_FARSI' means the Farsi */ + /* `TT_MAC_ID_ARABIC' with `TT_MAC_LANGID_FARSI' means the Farsi */ /* variant the Arabic encoding. */ /* */ typedef enum FT_Encoding_ @@ -761,14 +766,15 @@ FT_BEGIN_HEADER FT_ENC_TAG( FT_ENCODING_UNICODE, 'u', 'n', 'i', 'c' ), FT_ENC_TAG( FT_ENCODING_SJIS, 's', 'j', 'i', 's' ), - FT_ENC_TAG( FT_ENCODING_GB2312, 'g', 'b', ' ', ' ' ), + FT_ENC_TAG( FT_ENCODING_PRC, 'g', 'b', ' ', ' ' ), FT_ENC_TAG( FT_ENCODING_BIG5, 'b', 'i', 'g', '5' ), FT_ENC_TAG( FT_ENCODING_WANSUNG, 'w', 'a', 'n', 's' ), FT_ENC_TAG( FT_ENCODING_JOHAB, 'j', 'o', 'h', 'a' ), - /* for backwards compatibility */ + /* for backward compatibility */ + FT_ENCODING_GB2312 = FT_ENCODING_PRC, FT_ENCODING_MS_SJIS = FT_ENCODING_SJIS, - FT_ENCODING_MS_GB2312 = FT_ENCODING_GB2312, + FT_ENCODING_MS_GB2312 = FT_ENCODING_PRC, FT_ENCODING_MS_BIG5 = FT_ENCODING_BIG5, FT_ENCODING_MS_WANSUNG = FT_ENCODING_WANSUNG, FT_ENCODING_MS_JOHAB = FT_ENCODING_JOHAB, @@ -793,7 +799,7 @@ FT_BEGIN_HEADER #define ft_encoding_latin_1 FT_ENCODING_ADOBE_LATIN_1 #define ft_encoding_latin_2 FT_ENCODING_OLD_LATIN_2 #define ft_encoding_sjis FT_ENCODING_SJIS -#define ft_encoding_gb2312 FT_ENCODING_GB2312 +#define ft_encoding_gb2312 FT_ENCODING_PRC #define ft_encoding_big5 FT_ENCODING_BIG5 #define ft_encoding_wansung FT_ENCODING_WANSUNG #define ft_encoding_johab FT_ENCODING_JOHAB @@ -820,11 +826,11 @@ FT_BEGIN_HEADER /* */ /* platform_id :: An ID number describing the platform for the */ /* following encoding ID. This comes directly from */ - /* the TrueType specification and should be emulated */ - /* for other formats. */ + /* the TrueType specification and gets emulated for */ + /* other formats. */ /* */ /* encoding_id :: A platform specific encoding number. This also */ - /* comes from the TrueType specification and should be */ + /* comes from the TrueType specification and gets */ /* emulated similarly. */ /* */ typedef struct FT_CharMapRec_ @@ -852,8 +858,8 @@ FT_BEGIN_HEADER /* FT_Face_Internal */ /* */ /* */ - /* An opaque handle to an `FT_Face_InternalRec' structure, used to */ - /* model private data of a given @FT_Face object. */ + /* An opaque handle to an `FT_Face_InternalRec' structure that models */ + /* the private data of a given @FT_Face object. */ /* */ /* This structure might change between releases of FreeType~2 and is */ /* not generally available to client applications. */ @@ -873,7 +879,7 @@ FT_BEGIN_HEADER /* */ /* num_faces :: The number of faces in the font file. Some */ /* font formats can have multiple faces in */ - /* a font file. */ + /* a single font file. */ /* */ /* face_index :: This field holds two different values. */ /* Bits 0-15 are the index of the face in the */ @@ -881,14 +887,15 @@ FT_BEGIN_HEADER /* are set to~0 if there is only one face in */ /* the font file. */ /* */ - /* Bits 16-30 are relevant to GX variation */ - /* fonts only, holding the named instance */ - /* index for the current face index (starting */ - /* with value~1; value~0 indicates font access */ - /* without GX variation data). For non-GX */ - /* fonts, bits 16-30 are ignored. If we have */ - /* the third named instance of face~4, say, */ - /* `face_index' is set to 0x00030004. */ + /* Bits 16-30 are relevant to GX and OpenType */ + /* variation fonts only, holding the named */ + /* instance index for the current face index */ + /* (starting with value~1; value~0 indicates */ + /* font access without a named instance). For */ + /* non-variation fonts, bits 16-30 are */ + /* ignored. If we have the third named */ + /* instance of face~4, say, `face_index' is */ + /* set to 0x00030004. */ /* */ /* Bit 31 is always zero (this is, */ /* `face_index' is always a positive value). */ @@ -902,17 +909,21 @@ FT_BEGIN_HEADER /* @FT_STYLE_FLAG_XXX for the details. Bits */ /* 16-30 hold the number of named instances */ /* available for the current face if we have a */ - /* GX variation (sub)font. Bit 31 is always */ - /* zero (this is, `style_flags' is always a */ - /* positive value). */ + /* GX or OpenType variation (sub)font. Bit 31 */ + /* is always zero (this is, `style_flags' is */ + /* always a positive value). Note that a */ + /* variation font has always at least one */ + /* named instance, namely the default */ + /* instance. */ /* */ /* num_glyphs :: The number of glyphs in the face. If the */ /* face is scalable and has sbits (see */ /* `num_fixed_sizes'), it is set to the number */ /* of outline glyphs. */ /* */ - /* For CID-keyed fonts, this value gives the */ - /* highest CID used in the font. */ + /* For CID-keyed fonts (not in an SFNT */ + /* wrapper) this value gives the highest CID */ + /* used in the font. */ /* */ /* family_name :: The face's family name. This is an ASCII */ /* string, usually in English, that describes */ @@ -951,6 +962,10 @@ FT_BEGIN_HEADER /* strikes in the face. It is set to NULL if */ /* there is no bitmap strike. */ /* */ + /* Note that FreeType tries to sanitize the */ + /* strike data since they are sometimes sloppy */ + /* or incorrect, but this can easily fail. */ + /* */ /* num_charmaps :: The number of charmaps in the face. */ /* */ /* charmaps :: An array of the charmaps of the face. */ @@ -986,8 +1001,8 @@ FT_BEGIN_HEADER /* expressed in font units. For font formats */ /* not having this information, it is set to */ /* `bbox.yMin'. Note that this field is */ - /* usually negative. Only relevant for */ - /* scalable formats. */ + /* negative for values below the baseline. */ + /* Only relevant for scalable formats. */ /* */ /* height :: This value is the vertical distance */ /* between two consecutive baselines, */ @@ -1030,6 +1045,12 @@ FT_BEGIN_HEADER /* Fields may be changed after a call to @FT_Attach_File or */ /* @FT_Attach_Stream. */ /* */ + /* For an OpenType variation font, the values of the following fields */ + /* can change after a call to @FT_Set_Var_Design_Coordinates (and */ + /* friends) if the font contains an `MVAR' table: `ascender', */ + /* `descender', `height', `underline_position', and */ + /* `underline_thickness'. */ + /* */ typedef struct FT_FaceRec_ { FT_Long num_faces; @@ -1101,49 +1122,51 @@ FT_BEGIN_HEADER /* */ /* */ /* FT_FACE_FLAG_SCALABLE :: */ - /* Indicates that the face contains outline glyphs. This doesn't */ - /* prevent bitmap strikes, i.e., a face can have both this and */ + /* The face contains outline glyphs. Note that a face can contain */ + /* bitmap strikes also, i.e., a face can have both this flag and */ /* @FT_FACE_FLAG_FIXED_SIZES set. */ /* */ /* FT_FACE_FLAG_FIXED_SIZES :: */ - /* Indicates that the face contains bitmap strikes. See also the */ + /* The face contains bitmap strikes. See also the */ /* `num_fixed_sizes' and `available_sizes' fields of @FT_FaceRec. */ /* */ /* FT_FACE_FLAG_FIXED_WIDTH :: */ - /* Indicates that the face contains fixed-width characters (like */ - /* Courier, Lucido, MonoType, etc.). */ + /* The face contains fixed-width characters (like Courier, Lucida, */ + /* MonoType, etc.). */ /* */ /* FT_FACE_FLAG_SFNT :: */ - /* Indicates that the face uses the `sfnt' storage scheme. For */ - /* now, this means TrueType and OpenType. */ + /* The face uses the SFNT storage scheme. For now, this means */ + /* TrueType and OpenType. */ /* */ /* FT_FACE_FLAG_HORIZONTAL :: */ - /* Indicates that the face contains horizontal glyph metrics. This */ - /* should be set for all common formats. */ + /* The face contains horizontal glyph metrics. This should be set */ + /* for all common formats. */ /* */ /* FT_FACE_FLAG_VERTICAL :: */ - /* Indicates that the face contains vertical glyph metrics. This */ - /* is only available in some formats, not all of them. */ + /* The face contains vertical glyph metrics. This is only */ + /* available in some formats, not all of them. */ /* */ /* FT_FACE_FLAG_KERNING :: */ - /* Indicates that the face contains kerning information. If set, */ - /* the kerning distance can be retrieved through the function */ - /* @FT_Get_Kerning. Otherwise the function always return the */ - /* vector (0,0). Note that FreeType doesn't handle kerning data */ - /* from the `GPOS' table (as present in some OpenType fonts). */ + /* The face contains kerning information. If set, the kerning */ + /* distance can be retrieved using the function @FT_Get_Kerning. */ + /* Otherwise the function always return the vector (0,0). Note */ + /* that FreeType doesn't handle kerning data from the SFNT `GPOS' */ + /* table (as present in many OpenType fonts). */ /* */ /* FT_FACE_FLAG_FAST_GLYPHS :: */ /* THIS FLAG IS DEPRECATED. DO NOT USE OR TEST IT. */ /* */ /* FT_FACE_FLAG_MULTIPLE_MASTERS :: */ - /* Indicates that the font contains multiple masters and is capable */ - /* of interpolating between them. See the multiple-masters */ - /* specific API for details. */ + /* The face contains multiple masters and is capable of */ + /* interpolating between them. Supported formats are Adobe MM, */ + /* TrueType GX, and OpenType variation fonts. */ + /* */ + /* See the multiple-masters specific API for details. */ /* */ /* FT_FACE_FLAG_GLYPH_NAMES :: */ - /* Indicates that the font contains glyph names that can be */ - /* retrieved through @FT_Get_Glyph_Name. Note that some TrueType */ - /* fonts contain broken glyph name tables. Use the function */ + /* The face contains glyph names, which can be retrieved using */ + /* @FT_Get_Glyph_Name. Note that some TrueType fonts contain */ + /* broken glyph name tables. Use the function */ /* @FT_Has_PS_Glyph_Names when needed. */ /* */ /* FT_FACE_FLAG_EXTERNAL_STREAM :: */ @@ -1152,31 +1175,31 @@ FT_BEGIN_HEADER /* when @FT_Done_Face is called. Don't read or test this flag. */ /* */ /* FT_FACE_FLAG_HINTER :: */ - /* Set if the font driver has a hinting machine of its own. For */ - /* example, with TrueType fonts, it makes sense to use data from */ - /* the SFNT `gasp' table only if the native TrueType hinting engine */ - /* (with the bytecode interpreter) is available and active. */ + /* The font driver has a hinting machine of its own. For example, */ + /* with TrueType fonts, it makes sense to use data from the SFNT */ + /* `gasp' table only if the native TrueType hinting engine (with */ + /* the bytecode interpreter) is available and active. */ /* */ /* FT_FACE_FLAG_CID_KEYED :: */ - /* Set if the font is CID-keyed. In that case, the font is not */ - /* accessed by glyph indices but by CID values. For subsetted */ - /* CID-keyed fonts this has the consequence that not all index */ - /* values are a valid argument to FT_Load_Glyph. Only the CID */ - /* values for which corresponding glyphs in the subsetted font */ - /* exist make FT_Load_Glyph return successfully; in all other cases */ - /* you get an `FT_Err_Invalid_Argument' error. */ - /* */ - /* Note that CID-keyed fonts that are in an SFNT wrapper don't */ - /* have this flag set since the glyphs are accessed in the normal */ - /* way (using contiguous indices); the `CID-ness' isn't visible to */ - /* the application. */ + /* The face is CID-keyed. In that case, the face is not accessed */ + /* by glyph indices but by CID values. For subsetted CID-keyed */ + /* fonts this has the consequence that not all index values are a */ + /* valid argument to @FT_Load_Glyph. Only the CID values for which */ + /* corresponding glyphs in the subsetted font exist make */ + /* `FT_Load_Glyph' return successfully; in all other cases you get */ + /* an `FT_Err_Invalid_Argument' error. */ + /* */ + /* Note that CID-keyed fonts that are in an SFNT wrapper (this is, */ + /* all OpenType/CFF fonts) don't have this flag set since the */ + /* glyphs are accessed in the normal way (using contiguous */ + /* indices); the `CID-ness' isn't visible to the application. */ /* */ /* FT_FACE_FLAG_TRICKY :: */ - /* Set if the font is `tricky', this is, it always needs the */ - /* font format's native hinting engine to get a reasonable result. */ - /* A typical example is the Chinese font `mingli.ttf' that uses */ - /* TrueType bytecode instructions to move and scale all of its */ - /* subglyphs. */ + /* The face is `tricky', this is, it always needs the font format's */ + /* native hinting engine to get a reasonable result. A typical */ + /* example is the old Chinese font `mingli.ttf' (but not */ + /* `mingliu.ttc') that uses TrueType bytecode instructions to move */ + /* and scale all of its subglyphs. */ /* */ /* It is not possible to auto-hint such fonts using */ /* @FT_LOAD_FORCE_AUTOHINT; it will also ignore */ @@ -1188,8 +1211,8 @@ FT_BEGIN_HEADER /* tricky fonts; they are hard-coded in file `ttobjs.c'. */ /* */ /* FT_FACE_FLAG_COLOR :: */ - /* Set if the font has color glyph tables. To access color glyphs */ - /* use @FT_LOAD_COLOR. */ + /* The face has color glyph tables. To access color glyphs use */ + /* @FT_LOAD_COLOR. */ /* */ #define FT_FACE_FLAG_SCALABLE ( 1L << 0 ) #define FT_FACE_FLAG_FIXED_SIZES ( 1L << 1 ) @@ -1261,7 +1284,7 @@ FT_BEGIN_HEADER * @description: * A macro that returns true whenever a face object contains a scalable * font face (true for TrueType, Type~1, Type~42, CID, OpenType/CFF, - * and PFR font formats. + * and PFR font formats). * */ #define FT_IS_SCALABLE( face ) \ @@ -1358,6 +1381,20 @@ FT_BEGIN_HEADER ( (face)->face_flags & FT_FACE_FLAG_MULTIPLE_MASTERS ) + /************************************************************************* + * + * @macro: + * FT_IS_NAMED_INSTANCE( face ) + * + * @description: + * A macro that returns true whenever a face object is a named instance + * of a GX or OpenType variation font. + * + */ +#define FT_IS_NAMED_INSTANCE( face ) \ + ( (face)->face_index & 0x7FFF0000L ) + + /************************************************************************* * * @macro: @@ -1410,15 +1447,15 @@ FT_BEGIN_HEADER /* FT_STYLE_FLAG_XXX */ /* */ /* */ - /* A list of bit flags used to indicate the style of a given face. */ - /* These are used in the `style_flags' field of @FT_FaceRec. */ + /* A list of bit flags to indicate the style of a given face. These */ + /* are used in the `style_flags' field of @FT_FaceRec. */ /* */ /* */ /* FT_STYLE_FLAG_ITALIC :: */ - /* Indicates that a given face style is italic or oblique. */ + /* The face style is italic or oblique. */ /* */ /* FT_STYLE_FLAG_BOLD :: */ - /* Indicates that a given face is bold. */ + /* The face is bold. */ /* */ /* */ /* The style information as provided by FreeType is very basic. More */ @@ -1459,43 +1496,50 @@ FT_BEGIN_HEADER /* hence the term `ppem' (pixels per EM). It is also */ /* referred to as `nominal height'. */ /* */ - /* x_scale :: A 16.16 fractional scaling value used to convert */ + /* x_scale :: A 16.16 fractional scaling value to convert */ /* horizontal metrics from font units to 26.6 */ /* fractional pixels. Only relevant for scalable */ /* font formats. */ /* */ - /* y_scale :: A 16.16 fractional scaling value used to convert */ + /* y_scale :: A 16.16 fractional scaling value to convert */ /* vertical metrics from font units to 26.6 */ /* fractional pixels. Only relevant for scalable */ /* font formats. */ /* */ - /* ascender :: The ascender in 26.6 fractional pixels. See */ - /* @FT_FaceRec for the details. */ + /* ascender :: The ascender in 26.6 fractional pixels, rounded up */ + /* to an integer value. See @FT_FaceRec for the */ + /* details. */ /* */ - /* descender :: The descender in 26.6 fractional pixels. See */ - /* @FT_FaceRec for the details. */ + /* descender :: The descender in 26.6 fractional pixels, rounded */ + /* down to an integer value. See @FT_FaceRec for the */ + /* details. */ /* */ - /* height :: The height in 26.6 fractional pixels. See */ - /* @FT_FaceRec for the details. */ + /* height :: The height in 26.6 fractional pixels, rounded to */ + /* an integer value. See @FT_FaceRec for the */ + /* details. */ /* */ /* max_advance :: The maximum advance width in 26.6 fractional */ - /* pixels. See @FT_FaceRec for the details. */ + /* pixels, rounded to an integer value. See */ + /* @FT_FaceRec for the details. */ /* */ /* */ /* The scaling values, if relevant, are determined first during a */ /* size changing operation. The remaining fields are then set by the */ /* driver. For scalable formats, they are usually set to scaled */ - /* values of the corresponding fields in @FT_FaceRec. */ + /* values of the corresponding fields in @FT_FaceRec. Some values */ + /* like ascender or descender are rounded for historical reasons; */ + /* more precise values (for outline fonts) can be derived by scaling */ + /* the corresponding @FT_FaceRec values manually. */ /* */ - /* Note that due to glyph hinting, these values might not be exact */ - /* for certain fonts. Thus they must be treated as unreliable */ - /* with an error margin of at least one pixel! */ + /* Note that due to glyph hinting and the selected rendering mode */ + /* these values are usually not exact; consequently, they must be */ + /* treated as unreliable with an error margin of at least one pixel! */ /* */ /* Indeed, the only way to get the exact metrics is to render _all_ */ /* glyphs. As this would be a definite performance hit, it is up to */ /* client applications to perform such computations. */ /* */ - /* The FT_Size_Metrics structure is valid for bitmap fonts also. */ + /* The `FT_Size_Metrics' structure is valid for bitmap fonts also. */ /* */ typedef struct FT_Size_Metrics_ { @@ -1635,8 +1679,8 @@ FT_BEGIN_HEADER /* contained in the glyph slot. Typically */ /* @FT_GLYPH_FORMAT_BITMAP, */ /* @FT_GLYPH_FORMAT_OUTLINE, or */ - /* @FT_GLYPH_FORMAT_COMPOSITE, but others are */ - /* possible. */ + /* @FT_GLYPH_FORMAT_COMPOSITE, but other values */ + /* are possible. */ /* */ /* bitmap :: This field is used as a bitmap descriptor */ /* when the slot format is */ @@ -1651,16 +1695,15 @@ FT_BEGIN_HEADER /* glyph slot contains a bitmap. */ /* */ /* 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*. */ + /* pixels. 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 */ /* image if its format is */ /* @FT_GLYPH_FORMAT_OUTLINE. Once a glyph is */ /* loaded, `outline' can be transformed, */ - /* distorted, embolded, etc. However, it must */ + /* distorted, emboldened, etc. However, it must */ /* not be freed. */ /* */ /* num_subglyphs :: The number of subglyphs in a composite glyph. */ @@ -1676,15 +1719,13 @@ FT_BEGIN_HEADER /* control_data :: Certain font drivers can also return the */ /* control data for a given glyph image (e.g. */ /* TrueType bytecode, Type~1 charstrings, etc.). */ - /* This field is a pointer to such data. */ + /* This field is a pointer to such data; it is */ + /* currently internal to FreeType. */ /* */ /* control_len :: This is the length in bytes of the control */ - /* data. */ + /* data. Currently internal to FreeType. */ /* */ - /* other :: Really wicked formats can use this pointer to */ - /* present their own glyph image to client */ - /* applications. Note that the application */ - /* needs to know about the image format. */ + /* other :: Reserved. */ /* */ /* lsb_delta :: The difference between hinted and unhinted */ /* left side bearing while auto-hinting is */ @@ -1701,7 +1742,7 @@ FT_BEGIN_HEADER /* formats). */ /* */ /* This image can later be converted into a bitmap by calling */ - /* @FT_Render_Glyph. This function finds the current renderer for */ + /* @FT_Render_Glyph. This function searches the current renderer for */ /* the native image's format, then invokes it. */ /* */ /* The renderer is in charge of transforming the native image through */ @@ -1713,34 +1754,65 @@ FT_BEGIN_HEADER /* position (e.g., coordinates (0,0) on the baseline). Of course, */ /* `slot->format' is also changed to @FT_GLYPH_FORMAT_BITMAP. */ /* */ - /* */ /* Here is a small pseudo code fragment that shows how to use */ - /* `lsb_delta' and `rsb_delta': */ + /* `lsb_delta' and `rsb_delta' to do fractional positioning of */ + /* glyphs: */ + /* */ + /* { */ + /* FT_GlyphSlot slot = face->glyph; */ + /* FT_Pos origin_x = 0; */ + /* */ + /* */ + /* for all glyphs do */ + /* */ + /* */ + /* FT_Outline_Translate( slot->outline, origin_x & 63, 0 ); */ + /* */ + /* */ + /* */ + /* */ + /* */ + /* origin_x += slot->advance.x; */ + /* origin_x += slot->rsb_delta - slot->lsb_relta; */ + /* endfor */ + /* } */ + /* */ + /* Here is another small pseudo code fragment that shows how to use */ + /* `lsb_delta' and `rsb_delta' to improve integer positioning of */ + /* glyphs: */ /* */ /* { */ - /* FT_Pos origin_x = 0; */ - /* FT_Pos prev_rsb_delta = 0; */ + /* FT_GlyphSlot slot = face->glyph; */ + /* FT_Pos origin_x = 0; */ + /* FT_Pos prev_rsb_delta = 0; */ /* */ /* */ /* for all glyphs do */ - /* */ + /* */ /* */ /* */ /* */ - /* if ( prev_rsb_delta - face->glyph->lsb_delta >= 32 ) */ + /* if ( prev_rsb_delta - slot->lsb_delta >= 32 ) */ /* origin_x -= 64; */ - /* else if ( prev_rsb_delta - face->glyph->lsb_delta < -32 ) */ + /* else if ( prev_rsb_delta - slot->lsb_delta < -32 ) */ /* origin_x += 64; */ /* */ - /* prev_rsb_delta = face->glyph->rsb_delta; */ + /* prev_rsb_delta = slot->rsb_delta; */ /* */ /* */ /* */ - /* origin_x += face->glyph->advance.x; */ + /* origin_x += slot->advance.x; */ /* endfor */ /* } */ /* */ + /* If you use strong auto-hinting, you *must* apply these delta */ + /* values! Otherwise you will experience far too large inter-glyph */ + /* spacing at small rendering sizes in most cases. Note that it */ + /* doesn't harm to use the above code for other hinting modes also, */ + /* since the delta values are zero then. */ + /* */ typedef struct FT_GlyphSlotRec_ { FT_Library library; @@ -1805,7 +1877,8 @@ FT_BEGIN_HEADER /* */ /* In case you want to provide your own memory allocating routines, */ /* use @FT_New_Library instead, followed by a call to */ - /* @FT_Add_Default_Modules (or a series of calls to @FT_Add_Module). */ + /* @FT_Add_Default_Modules (or a series of calls to @FT_Add_Module) */ + /* and @FT_Set_Default_Properties. */ /* */ /* See the documentation of @FT_Library and @FT_Face for */ /* multi-threading issues. */ @@ -1813,6 +1886,11 @@ FT_BEGIN_HEADER /* If you need reference-counting (cf. @FT_Reference_Library), use */ /* @FT_New_Library and @FT_Done_Library. */ /* */ + /* If compilation option FT_CONFIG_OPTION_ENVIRONMENT_PROPERTIES is */ + /* set, this function reads the `FREETYPE_PROPERTIES' environment */ + /* variable to control driver properties. See sections @auto_hinter, */ + /* @cff_driver, @pcf_driver, and @tt_driver for more. */ + /* */ FT_EXPORT( FT_Error ) FT_Init_FreeType( FT_Library *alibrary ); @@ -1883,8 +1961,8 @@ FT_BEGIN_HEADER /* FT_Parameter */ /* */ /* */ - /* A simple structure used to pass more or less generic parameters to */ - /* @FT_Open_Face. */ + /* A simple structure to pass more or less generic parameters to */ + /* @FT_Open_Face and @FT_Face_Properties. */ /* */ /* */ /* tag :: A four-byte identification tag. */ @@ -1909,9 +1987,9 @@ FT_BEGIN_HEADER /* FT_Open_Args */ /* */ /* */ - /* A structure used to indicate how to open a new font file or */ - /* stream. A pointer to such a structure can be used as a parameter */ - /* for the functions @FT_Open_Face and @FT_Attach_Stream. */ + /* A structure to indicate how to open a new font file or stream. A */ + /* pointer to such a structure can be used as a parameter for the */ + /* functions @FT_Open_Face and @FT_Attach_Stream. */ /* */ /* */ /* flags :: A set of bit flags indicating how to use the */ @@ -1926,9 +2004,10 @@ FT_BEGIN_HEADER /* stream :: A handle to a source stream object. */ /* */ /* driver :: This field is exclusively used by @FT_Open_Face; */ - /* it simply specifies the font driver to use to open */ - /* the face. If set to~0, FreeType tries to load the */ - /* face with each one of the drivers in its list. */ + /* it simply specifies the font driver to use for */ + /* opening the face. If set to NULL, FreeType tries */ + /* to load the face with each one of the drivers in */ + /* its list. */ /* */ /* num_params :: The number of extra parameters. */ /* */ @@ -1958,7 +2037,7 @@ FT_BEGIN_HEADER /* `num_params' and `params' is used. They are ignored otherwise. */ /* */ /* Ideally, both the `pathname' and `params' fields should be tagged */ - /* as `const'; this is missing for API backwards compatibility. In */ + /* as `const'; this is missing for API backward compatibility. In */ /* other words, applications should treat them as read-only. */ /* */ typedef struct FT_Open_Args_ @@ -1981,7 +2060,7 @@ FT_BEGIN_HEADER /* FT_New_Face */ /* */ /* */ - /* This function calls @FT_Open_Face to open a font by its pathname. */ + /* Call @FT_Open_Face to open a font by its pathname. */ /* */ /* */ /* library :: A handle to the library resource. */ @@ -2016,8 +2095,8 @@ FT_BEGIN_HEADER /* FT_New_Memory_Face */ /* */ /* */ - /* This function calls @FT_Open_Face to open a font that has been */ - /* loaded into memory. */ + /* Call @FT_Open_Face to open a font that has been loaded into */ + /* memory. */ /* */ /* */ /* library :: A handle to the library resource. */ @@ -2069,20 +2148,21 @@ FT_BEGIN_HEADER /* with value~0). Set it to~0 if there is only one */ /* face in the font file. */ /* */ - /* Bits 16-30 are relevant to GX variation fonts only, */ - /* specifying the named instance index for the current */ - /* face index (starting with value~1; value~0 makes */ - /* FreeType ignore named instances). For non-GX fonts, */ - /* bits 16-30 are ignored. Assuming that you want to */ - /* access the third named instance in face~4, */ - /* `face_index' should be set to 0x00030004. If you */ - /* want to access face~4 without GX variation handling, */ - /* simply set `face_index' to value~4. */ - /* */ - /* FT_Open_Face and its siblings can be used to quickly */ - /* check whether the font format of a given font */ - /* resource is supported by FreeType. In general, if */ - /* the `face_index' argument is negative, the */ + /* Bits 16-30 are relevant to GX and OpenType variation */ + /* fonts only, specifying the named instance index for */ + /* the current face index (starting with value~1; */ + /* value~0 makes FreeType ignore named instances). For */ + /* non-variation fonts, bits 16-30 are ignored. */ + /* Assuming that you want to access the third named */ + /* instance in face~4, `face_index' should be set to */ + /* 0x00030004. If you want to access face~4 without */ + /* variation handling, simply set `face_index' to */ + /* value~4. */ + /* */ + /* `FT_Open_Face' and its siblings can be used to */ + /* quickly check whether the font format of a given */ + /* font resource is supported by FreeType. In general, */ + /* if the `face_index' argument is negative, the */ /* function's return value is~0 if the font format is */ /* recognized, or non-zero otherwise. The function */ /* allocates a more or less empty face handle in */ @@ -2091,10 +2171,10 @@ FT_BEGIN_HEADER /* `face->num_faces' and `face->style_flags'. For any */ /* negative value of `face_index', `face->num_faces' */ /* gives the number of faces within the font file. For */ - /* the negative value `-(N+1)' (with `N' a 16-bit */ - /* value), bits 16-30 in `face->style_flags' give the */ - /* number of named instances in face `N' if we have a */ - /* GX variation font (or zero otherwise). After */ + /* the negative value `-(N+1)' (with `N' a non-negative */ + /* 16-bit value), bits 16-30 in `face->style_flags' */ + /* give the number of named instances in face `N' if we */ + /* have a variation font (or zero otherwise). After */ /* examination, the returned @FT_Face structure should */ /* be deallocated with a call to @FT_Done_Face. */ /* */ @@ -2201,7 +2281,7 @@ FT_BEGIN_HEADER /* FT_Attach_File */ /* */ /* */ - /* This function calls @FT_Attach_Stream to attach a file. */ + /* Call @FT_Attach_Stream to attach a file. */ /* */ /* */ /* face :: The target face object. */ @@ -2245,7 +2325,7 @@ FT_BEGIN_HEADER /* */ /* Client applications are expected to know what they are doing */ /* when invoking this function. Most drivers simply do not implement */ - /* file attachments. */ + /* file or stream attachments. */ /* */ FT_EXPORT( FT_Error ) FT_Attach_Stream( FT_Face face, @@ -2308,7 +2388,10 @@ FT_BEGIN_HEADER /* FT_Select_Size */ /* */ /* */ - /* Select a bitmap strike. */ + /* Select a bitmap strike. To be more precise, this function sets */ + /* the scaling factors of the active @FT_Size object in a face so */ + /* that bitmaps from this particular strike are taken by */ + /* @FT_Load_Glyph and friends. */ /* */ /* */ /* face :: A handle to a target face object. */ @@ -2320,6 +2403,20 @@ FT_BEGIN_HEADER /* */ /* FreeType error code. 0~means success. */ /* */ + /* */ + /* For bitmaps embedded in outline fonts it is common that only a */ + /* subset of the available glyphs at a given ppem value is available. */ + /* FreeType silently uses outlines if there is no bitmap for a given */ + /* glyph index. */ + /* */ + /* For GX and OpenType variation fonts, a bitmap strike makes sense */ + /* only if the default instance is active (this is, no glyph */ + /* variation takes place); otherwise, FreeType simply ignores bitmap */ + /* strikes. The same is true for all named instances that are */ + /* different from the default instance. */ + /* */ + /* Don't use this function if you are using the FreeType cache API. */ + /* */ FT_EXPORT( FT_Error ) FT_Select_Size( FT_Face face, FT_Int strike_index ); @@ -2331,16 +2428,25 @@ FT_BEGIN_HEADER /* FT_Size_Request_Type */ /* */ /* */ - /* An enumeration type that lists the supported size request types. */ + /* An enumeration type that lists the supported size request types, */ + /* i.e., what input size (in font units) maps to the requested output */ + /* size (in pixels, as computed from the arguments of */ + /* @FT_Size_Request). */ /* */ /* */ /* FT_SIZE_REQUEST_TYPE_NOMINAL :: */ /* The nominal size. The `units_per_EM' field of @FT_FaceRec is */ /* used to determine both scaling values. */ /* */ + /* This is the standard scaling found in most applications. In */ + /* particular, use this size request type for TrueType fonts if */ + /* they provide optical scaling or something similar. Note, */ + /* however, that `units_per_EM' is a rather abstract value which */ + /* bears no relation to the actual size of the glyphs in a font. */ + /* */ /* FT_SIZE_REQUEST_TYPE_REAL_DIM :: */ /* The real dimension. The sum of the `ascender' and (minus of) */ - /* the `descender' fields of @FT_FaceRec are used to determine both */ + /* the `descender' fields of @FT_FaceRec is used to determine both */ /* scaling values. */ /* */ /* FT_SIZE_REQUEST_TYPE_BBOX :: */ @@ -2386,27 +2492,36 @@ FT_BEGIN_HEADER /* FT_Size_RequestRec */ /* */ /* */ - /* A structure used to model a size request. */ + /* A structure to model a size request. */ /* */ /* */ /* type :: See @FT_Size_Request_Type. */ /* */ - /* width :: The desired width. */ + /* width :: The desired width, given as a 26.6 fractional */ + /* point value (with 72pt = 1in). */ /* */ - /* height :: The desired height. */ + /* height :: The desired height, given as a 26.6 fractional */ + /* point value (with 72pt = 1in). */ /* */ - /* horiResolution :: The horizontal resolution. If set to zero, */ - /* `width' is treated as a 26.6 fractional pixel */ - /* value. */ + /* horiResolution :: The horizontal resolution (dpi, i.e., pixels per */ + /* inch). If set to zero, `width' is treated as a */ + /* 26.6 fractional *pixel* value, which gets */ + /* internally rounded to an integer. */ /* */ - /* vertResolution :: The vertical resolution. If set to zero, */ - /* `height' is treated as a 26.6 fractional pixel */ - /* value. */ + /* vertResolution :: The vertical resolution (dpi, i.e., pixels per */ + /* inch). If set to zero, `height' is treated as a */ + /* 26.6 fractional *pixel* value, which gets */ + /* internally rounded to an integer. */ /* */ /* */ - /* If `width' is zero, then the horizontal scaling value is set equal */ + /* If `width' is zero, the horizontal scaling value is set equal */ /* to the vertical scaling value, and vice versa. */ /* */ + /* If `type' is FT_SIZE_REQUEST_TYPE_SCALES, `width' and `height' are */ + /* interpreted directly as 16.16 fractional scaling values, without */ + /* any further modification, and both `horiResolution' and */ + /* `vertResolution' are ignored. */ + /* */ typedef struct FT_Size_RequestRec_ { FT_Size_Request_Type type; @@ -2456,7 +2571,11 @@ FT_BEGIN_HEADER /* size is dependent entirely on how the size is defined in the */ /* source face. The font designer chooses the final size of each */ /* glyph relative to this size. For more information refer to */ - /* `http://www.freetype.org/freetype2/docs/glyphs/glyphs-2.html' */ + /* `https://www.freetype.org/freetype2/docs/glyphs/glyphs-2.html'. */ + /* */ + /* Contrary to @FT_Set_Char_Size, this function doesn't have special */ + /* code to normalize zero-valued widths, heights, or resolutions */ + /* (which lead to errors in most cases). */ /* */ /* Don't use this function if you are using the FreeType cache API. */ /* */ @@ -2471,8 +2590,7 @@ FT_BEGIN_HEADER /* FT_Set_Char_Size */ /* */ /* */ - /* This function calls @FT_Request_Size to request the nominal size */ - /* (in points). */ + /* Call @FT_Request_Size to request the nominal size (in points). */ /* */ /* */ /* face :: A handle to a target face object. */ @@ -2490,6 +2608,10 @@ FT_BEGIN_HEADER /* FreeType error code. 0~means success. */ /* */ /* */ + /* While this function allows fractional points as input values, the */ + /* resulting ppem value for the given resolution is always rounded to */ + /* the nearest integer. */ + /* */ /* If either the character width or height is zero, it is set equal */ /* to the other value. */ /* */ @@ -2515,8 +2637,7 @@ FT_BEGIN_HEADER /* FT_Set_Pixel_Sizes */ /* */ /* */ - /* This function calls @FT_Request_Size to request the nominal size */ - /* (in pixels). */ + /* Call @FT_Request_Size to request the nominal size (in pixels). */ /* */ /* */ /* face :: A handle to the target face object. */ @@ -2530,8 +2651,8 @@ FT_BEGIN_HEADER /* FreeType error code. 0~means success. */ /* */ /* */ - /* You should not rely on the resulting glyphs matching, or being */ - /* constrained, to this pixel size. Refer to @FT_Request_Size to */ + /* You should not rely on the resulting glyphs matching or being */ + /* constrained to this pixel size. Refer to @FT_Request_Size to */ /* understand how requested sizes relate to actual sizes. */ /* */ /* Don't use this function if you are using the FreeType cache API. */ @@ -2548,8 +2669,7 @@ FT_BEGIN_HEADER /* FT_Load_Glyph */ /* */ /* */ - /* A function used to load a single glyph into the glyph slot of a */ - /* face object. */ + /* Load a glyph into the glyph slot of a face object. */ /* */ /* */ /* face :: A handle to the target face object where the glyph */ @@ -2594,8 +2714,8 @@ FT_BEGIN_HEADER /* FT_Load_Char */ /* */ /* */ - /* A function used to load a single glyph into the glyph slot of a */ - /* face object, according to its character code. */ + /* Load a glyph into the glyph slot of a face object, accessed by its */ + /* character code. */ /* */ /* */ /* face :: A handle to a target face object where the glyph */ @@ -2617,6 +2737,10 @@ FT_BEGIN_HEADER /* */ /* This function simply calls @FT_Get_Char_Index and @FT_Load_Glyph. */ /* */ + /* Many fonts contain glyphs that can't be loaded by this function */ + /* since its glyph indices are not listed in any of the font's */ + /* charmaps. */ + /* */ FT_EXPORT( FT_Error ) FT_Load_Char( FT_Face face, FT_ULong char_code, @@ -2629,8 +2753,8 @@ FT_BEGIN_HEADER * FT_LOAD_XXX * * @description: - * A list of bit field constants used with @FT_Load_Glyph to indicate - * what kind of operations to perform during glyph loading. + * A list of bit field constants for @FT_Load_Glyph to indicate what + * kind of operations to perform during glyph loading. * * @values: * FT_LOAD_DEFAULT :: @@ -2642,13 +2766,13 @@ FT_BEGIN_HEADER * The bitmap data can be accessed from the glyph slot (see note * below). * - * 2. If no embedded bitmap is searched or found, FreeType looks for a - * scalable outline. If one is found, it is loaded from the font - * file, scaled to device pixels, then `hinted' to the pixel grid - * in order to optimize it. The outline data can be accessed from - * the glyph slot (see note below). + * 2. If no embedded bitmap is searched for or found, FreeType looks + * for a scalable outline. If one is found, it is loaded from + * the font file, scaled to device pixels, then `hinted' to the + * pixel grid in order to optimize it. The outline data can be + * accessed from the glyph slot (see note below). * - * Note that by default, the glyph loader doesn't render outlines into + * Note that by default the glyph loader doesn't render outlines into * bitmaps. The following flags are used to modify this default * behaviour to more specific and useful cases. * @@ -2695,13 +2819,13 @@ FT_BEGIN_HEADER * various font formats. * * FT_LOAD_FORCE_AUTOHINT :: - * Indicates that the auto-hinter is preferred over the font's native - * hinter. See also the note below. + * Prefer the auto-hinter over the font's native hinter. See also + * the note below. * * FT_LOAD_PEDANTIC :: - * Indicates that the font driver should perform pedantic verifications - * during glyph loading. This is mostly used to detect broken glyphs - * in fonts. By default, FreeType tries to handle broken fonts also. + * Make the font driver perform pedantic verifications during glyph + * loading. This is mostly used to detect broken glyphs in fonts. + * By default, FreeType tries to handle broken fonts also. * * In particular, errors from the TrueType bytecode engine are not * passed to the application if this flag is not set; this might @@ -2709,17 +2833,16 @@ FT_BEGIN_HEADER * bytecode is buggy. * * FT_LOAD_NO_RECURSE :: - * 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. + * Don't load composite glyphs recursively. Instead, the font + * driver 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. * * FT_LOAD_IGNORE_TRANSFORM :: - * Indicates that the transform matrix set by @FT_Set_Transform should - * be ignored. + * Ignore the transform matrix set by @FT_Set_Transform. * * FT_LOAD_MONOCHROME :: * This flag is used with @FT_LOAD_RENDER to indicate that you want to @@ -2731,31 +2854,37 @@ FT_BEGIN_HEADER * monochrome-optimized hinting algorithm is used. * * FT_LOAD_LINEAR_DESIGN :: - * Indicates that the `linearHoriAdvance' and `linearVertAdvance' - * fields of @FT_GlyphSlotRec should be kept in font units. See - * @FT_GlyphSlotRec for details. + * Keep `linearHoriAdvance' and `linearVertAdvance' fields of + * @FT_GlyphSlotRec in font units. See @FT_GlyphSlotRec for + * details. * * FT_LOAD_NO_AUTOHINT :: - * Disable auto-hinter. See also the note below. + * Disable the auto-hinter. See also the note below. * * FT_LOAD_COLOR :: - * This flag is used to request loading of color embedded-bitmap - * images. The resulting color bitmaps, if available, will have the - * @FT_PIXEL_MODE_BGRA format. When the flag is not used and color - * bitmaps are found, they will be converted to 256-level gray - * bitmaps transparently. Those bitmaps will be in the + * Load embedded color bitmap images. The resulting color bitmaps, + * if available, will have the @FT_PIXEL_MODE_BGRA format. If the + * flag is not set and color bitmaps are found, they are converted + * to 256-level gray bitmaps transparently, using the * @FT_PIXEL_MODE_GRAY format. * * FT_LOAD_COMPUTE_METRICS :: - * This flag sets computing glyph metrics without the use of bundled - * metrics tables (for example, the `hdmx' table in TrueType fonts). - * Well-behaving fonts have optimized bundled metrics and these should - * be used. This flag is mainly used by font validating or font + * Compute glyph metrics from the glyph data, without the use of + * bundled metrics tables (for example, the `hdmx' table in TrueType + * fonts). This flag is mainly used by font validating or font * editing applications, which need to ignore, verify, or edit those * tables. * * Currently, this flag is only implemented for TrueType fonts. * + * FT_LOAD_BITMAP_METRICS_ONLY :: + * Request loading of the metrics and bitmap image information of a + * (possibly embedded) bitmap glyph without allocating or copying + * the bitmap image data itself. No effect if the target glyph is + * not a bitmap image. + * + * This flag unsets @FT_LOAD_RENDER. + * * FT_LOAD_CROP_BITMAP :: * Ignored. Deprecated. * @@ -2799,13 +2928,14 @@ FT_BEGIN_HEADER #define FT_LOAD_MONOCHROME ( 1L << 12 ) #define FT_LOAD_LINEAR_DESIGN ( 1L << 13 ) #define FT_LOAD_NO_AUTOHINT ( 1L << 15 ) - /* Bits 16..19 are used by `FT_LOAD_TARGET_' */ + /* Bits 16-19 are used by `FT_LOAD_TARGET_' */ #define FT_LOAD_COLOR ( 1L << 20 ) #define FT_LOAD_COMPUTE_METRICS ( 1L << 21 ) +#define FT_LOAD_BITMAP_METRICS_ONLY ( 1L << 22 ) /* */ - /* used internally only by certain font drivers! */ + /* used internally only by certain font drivers */ #define FT_LOAD_ADVANCE_ONLY ( 1L << 8 ) #define FT_LOAD_SBITS_ONLY ( 1L << 14 ) @@ -2816,37 +2946,48 @@ FT_BEGIN_HEADER * FT_LOAD_TARGET_XXX * * @description: - * A list of values that are used to select a specific hinting algorithm - * to use by the hinter. You should OR one of these values to your - * `load_flags' when calling @FT_Load_Glyph. + * A list of values to select a specific hinting algorithm for the + * hinter. You should OR one of these values to your `load_flags' + * when calling @FT_Load_Glyph. * - * Note that font's native hinters may ignore the hinting algorithm you - * have specified (e.g., the TrueType bytecode interpreter). You can set - * @FT_LOAD_FORCE_AUTOHINT to ensure that the auto-hinter is used. + * Note that a font's native hinters may ignore the hinting algorithm + * you have specified (e.g., the TrueType bytecode interpreter). You + * can set @FT_LOAD_FORCE_AUTOHINT to ensure that the auto-hinter is + * used. * * @values: * FT_LOAD_TARGET_NORMAL :: - * This corresponds to the default hinting algorithm, optimized for - * standard gray-level rendering. For monochrome output, use - * @FT_LOAD_TARGET_MONO instead. + * The default hinting algorithm, optimized for standard gray-level + * rendering. For monochrome output, use @FT_LOAD_TARGET_MONO + * instead. * * FT_LOAD_TARGET_LIGHT :: * A lighter hinting algorithm for gray-level modes. Many generated * glyphs are fuzzier but better resemble their original shape. This * is achieved by snapping glyphs to the pixel grid only vertically - * (Y-axis), as is done by Microsoft's ClearType and Adobe's - * proprietary font renderer. This preserves inter-glyph spacing in + * (Y-axis), as is done by FreeType's new CFF engine or Microsoft's + * ClearType font renderer. This preserves inter-glyph spacing in * horizontal text. The snapping is done either by the native font - * driver if the driver itself and the font support it or by the + * driver, if the driver itself and the font support it, or by the * auto-hinter. * + * Advance widths are rounded to integer values; however, using the + * `lsb_delta' and `rsb_delta' fields of @FT_GlyphSlotRec, it is + * possible to get fractional advance widths for sub-pixel positioning + * (which is recommended to use). + * + * If configuration option AF_CONFIG_OPTION_TT_SIZE_METRICS is active, + * TrueType-like metrics are used to make this mode behave similarly + * as in unpatched FreeType versions between 2.4.6 and 2.7.1 + * (inclusive). + * * FT_LOAD_TARGET_MONO :: * Strong hinting algorithm that should only be used for monochrome * output. The result is probably unpleasant if the glyph is rendered * in non-monochrome modes. * * FT_LOAD_TARGET_LCD :: - * A variant of @FT_LOAD_TARGET_NORMAL optimized for horizontally + * A variant of @FT_LOAD_TARGET_LIGHT optimized for horizontally * decimated LCD displays. * * FT_LOAD_TARGET_LCD_V :: @@ -2874,6 +3015,13 @@ FT_BEGIN_HEADER * FT_Render_Glyph( face->glyph, FT_RENDER_MODE_LCD ); * } * + * In general, you should stick with one rendering mode. For example, + * switching between @FT_LOAD_TARGET_NORMAL and @FT_LOAD_TARGET_MONO + * enforces a lot of recomputation for TrueType fonts, which is slow. + * Another reason is caching: Selecting a different mode usually causes + * changes in both the outlines and the rasterized bitmaps; it is thus + * necessary to empty the cache after a mode switch to avoid false hits. + * */ #define FT_LOAD_TARGET_( x ) ( (FT_Int32)( (x) & 15 ) << 16 ) @@ -2903,18 +3051,17 @@ FT_BEGIN_HEADER /* FT_Set_Transform */ /* */ /* */ - /* A function used to set the transformation that is applied to glyph */ - /* images when they are loaded into a glyph slot through */ - /* @FT_Load_Glyph. */ + /* Set the transformation that is applied to glyph images when they */ + /* are loaded into a glyph slot through @FT_Load_Glyph. */ /* */ /* */ /* face :: A handle to the source face object. */ /* */ /* */ - /* matrix :: A pointer to the transformation's 2x2 matrix. Use~0 for */ - /* the identity matrix. */ - /* delta :: A pointer to the translation vector. Use~0 for the null */ - /* vector. */ + /* matrix :: A pointer to the transformation's 2x2 matrix. Use NULL */ + /* for the identity matrix. */ + /* delta :: A pointer to the translation vector. Use NULL for the */ + /* null vector. */ /* */ /* */ /* The transformation is only applied to scalable image formats after */ @@ -2937,9 +3084,8 @@ FT_BEGIN_HEADER /* FT_Render_Mode */ /* */ /* */ - /* An enumeration type that lists the render modes supported by */ - /* FreeType~2. Each mode corresponds to a specific type of scanline */ - /* conversion performed on the outline. */ + /* Render modes supported by FreeType~2. Each mode corresponds to a */ + /* specific type of scanline conversion performed on the outline. */ /* */ /* For bitmap fonts and embedded bitmaps the `bitmap->pixel_mode' */ /* field in the @FT_GlyphSlotRec structure gives the format of the */ @@ -2952,8 +3098,8 @@ FT_BEGIN_HEADER /* */ /* */ /* FT_RENDER_MODE_NORMAL :: */ - /* This is the default render mode; it corresponds to 8-bit */ - /* anti-aliased bitmaps. */ + /* Default render mode; it corresponds to 8-bit anti-aliased */ + /* bitmaps. */ /* */ /* FT_RENDER_MODE_LIGHT :: */ /* This is equivalent to @FT_RENDER_MODE_NORMAL. It is only */ @@ -2978,11 +3124,11 @@ FT_BEGIN_HEADER /* glyph outline in pixels and use the @FT_PIXEL_MODE_LCD_V mode. */ /* */ /* */ - /* The LCD-optimized glyph bitmaps produced by FT_Render_Glyph can be */ - /* filtered to reduce color-fringes by using @FT_Library_SetLcdFilter */ - /* (not active in the default builds). It is up to the caller to */ - /* either call @FT_Library_SetLcdFilter (if available) or do the */ - /* filtering itself. */ + /* The LCD-optimized glyph bitmaps produced by `FT_Render_Glyph' can */ + /* be filtered to reduce color-fringes by using */ + /* @FT_Library_SetLcdFilter (not active in the default builds). It */ + /* is up to the caller to either call `FT_Library_SetLcdFilter' (if */ + /* available) or do the filtering itself. */ /* */ /* The selected render mode only affects vector glyphs of a font. */ /* Embedded bitmaps often have a different pixel mode like */ @@ -3023,16 +3169,16 @@ FT_BEGIN_HEADER /* convert. */ /* */ /* */ - /* render_mode :: This is the render mode used to render the glyph */ - /* image into a bitmap. See @FT_Render_Mode for a */ - /* list of possible values. */ + /* render_mode :: The render mode used to render the glyph image into */ + /* a bitmap. See @FT_Render_Mode for a list of */ + /* possible values. */ /* */ /* */ /* FreeType error code. 0~means success. */ /* */ /* */ /* To get meaningful results, font scaling values must be set with */ - /* functions like @FT_Set_Char_Size before calling FT_Render_Glyph. */ + /* functions like @FT_Set_Char_Size before calling `FT_Render_Glyph'. */ /* */ /* When FreeType outputs a bitmap of a glyph, it really outputs an */ /* alpha coverage map. If a pixel is completely covered by a */ @@ -3058,7 +3204,7 @@ FT_BEGIN_HEADER /* this does not translate to 50% brightness for that pixel on our */ /* sRGB and gamma~2.2 screens. Due to their non-linearity, they */ /* dwell longer in the darks and only a pixel value of about 186 */ - /* results in 50% brightness – 128 ends up too dark on both bright */ + /* results in 50% brightness -- 128 ends up too dark on both bright */ /* and dark backgrounds. The net result is that dark text looks */ /* burnt-out, pixely and blotchy on bright background, bright text */ /* too frail on dark backgrounds, and colored text on colored */ @@ -3122,17 +3268,15 @@ FT_BEGIN_HEADER /* FT_Kerning_Mode */ /* */ /* */ - /* An enumeration used to specify which kerning values to return in */ + /* An enumeration to specify the format of kerning values returned by */ /* @FT_Get_Kerning. */ /* */ /* */ /* FT_KERNING_DEFAULT :: Return grid-fitted kerning distances in */ - /* pixels (value is~0). Whether they are */ - /* scaled depends on @FT_LOAD_NO_SCALE. */ + /* 26.6 fractional pixels. */ /* */ /* FT_KERNING_UNFITTED :: Return un-grid-fitted kerning distances in */ - /* 26.6 fractional pixels. Whether they are */ - /* scaled depends on @FT_LOAD_NO_SCALE. */ + /* 26.6 fractional pixels. */ /* */ /* FT_KERNING_UNSCALED :: Return the kerning vector in original font */ /* units. */ @@ -3142,9 +3286,13 @@ FT_BEGIN_HEADER /* FreeType heuristically scale down kerning distances at small ppem */ /* values so that they don't become too big. */ /* */ + /* Both FT_KERNING_DEFAULT and FT_KERNING_UNFITTED use the current */ + /* horizontal scaling factor (as set e.g. with @FT_Set_Char_Size) to */ + /* convert font units to pixels. */ + /* */ typedef enum FT_Kerning_Mode_ { - FT_KERNING_DEFAULT = 0, + FT_KERNING_DEFAULT = 0, FT_KERNING_UNFITTED, FT_KERNING_UNSCALED @@ -3164,7 +3312,7 @@ FT_BEGIN_HEADER /* FT_Get_Kerning */ /* */ /* */ - /* Return the kerning vector between two glyphs of a same face. */ + /* Return the kerning vector between two glyphs of the same face. */ /* */ /* */ /* face :: A handle to a source face object. */ @@ -3192,6 +3340,10 @@ FT_BEGIN_HEADER /* kernings, are out of the scope of this API function -- they can be */ /* implemented through format-specific interfaces. */ /* */ + /* Kerning for OpenType fonts implemented in a `GPOS' table is not */ + /* supported; use @FT_HAS_KERNING to find out whether a font has data */ + /* that can be extracted with `FT_Get_Kerning'. */ + /* */ FT_EXPORT( FT_Error ) FT_Get_Kerning( FT_Face face, FT_UInt left_glyph, @@ -3231,7 +3383,7 @@ FT_BEGIN_HEADER /* @FT_Attach_Stream). */ /* */ /* Only very few AFM files come with track kerning data; please refer */ - /* to the Adobe's AFM specification for more details. */ + /* to Adobe's AFM specification for more details. */ /* */ FT_EXPORT( FT_Error ) FT_Get_Track_Kerning( FT_Face face, @@ -3293,7 +3445,7 @@ FT_BEGIN_HEADER /* */ /* */ /* Retrieve the ASCII PostScript name of a given face, if available. */ - /* This only works with PostScript and TrueType fonts. */ + /* This only works with PostScript, TrueType, and OpenType fonts. */ /* */ /* */ /* face :: A handle to the source face object. */ @@ -3305,6 +3457,13 @@ FT_BEGIN_HEADER /* The returned pointer is owned by the face and is destroyed with */ /* it. */ /* */ + /* For variation fonts, this string changes if you select a different */ + /* instance, and you have to call `FT_Get_PostScript_Name' again to */ + /* retrieve it. FreeType follows Adobe TechNote #5902, `Generating */ + /* PostScript Names for Fonts Using OpenType Font Variations'. */ + /* */ + /* http://wwwimages.adobe.com/content/dam/Adobe/en/devnet/font/pdfs/5902.AdobePSNameGeneration.html */ + /* */ FT_EXPORT( const char* ) FT_Get_Postscript_Name( FT_Face face ); @@ -3364,7 +3523,8 @@ FT_BEGIN_HEADER /* the face (i.e., if it is not listed in the `face->charmaps' */ /* table). */ /* */ - /* It also fails if a type~14 charmap is selected. */ + /* It also fails if an OpenType type~14 charmap is selected (which */ + /* doesn't map character codes to glyph indices at all). */ /* */ FT_EXPORT( FT_Error ) FT_Set_Charmap( FT_Face face, @@ -3399,7 +3559,7 @@ FT_BEGIN_HEADER /* */ /* */ /* Return the glyph index of a given character code. This function */ - /* uses a charmap object to do the mapping. */ + /* uses the currently selected charmap to do the mapping. */ /* */ /* */ /* face :: A handle to the source face object. */ @@ -3433,9 +3593,8 @@ FT_BEGIN_HEADER /* FT_Get_First_Char */ /* */ /* */ - /* This function is used to return the first character code in the */ - /* current charmap of a given face. It also returns the */ - /* corresponding glyph index. */ + /* Return the first character code in the current charmap of a given */ + /* face, together with its corresponding glyph index. */ /* */ /* */ /* face :: A handle to the source face object. */ @@ -3448,7 +3607,7 @@ FT_BEGIN_HEADER /* The charmap's first character code. */ /* */ /* */ - /* You should use this function with @FT_Get_Next_Char to be able to */ + /* You should use this function together with @FT_Get_Next_Char to */ /* parse all character codes available in a given charmap. The code */ /* should look like this: */ /* */ @@ -3488,12 +3647,13 @@ FT_BEGIN_HEADER /* FT_Get_Next_Char */ /* */ /* */ - /* This function is used to return the next character code in the */ - /* current charmap of a given face following the value `char_code', */ - /* as well as the corresponding glyph index. */ + /* Return the next character code in the current charmap of a given */ + /* face following the value `char_code', as well as the corresponding */ + /* glyph index. */ /* */ /* */ /* face :: A handle to the source face object. */ + /* */ /* char_code :: The starting character code. */ /* */ /* */ @@ -3506,7 +3666,7 @@ FT_BEGIN_HEADER /* */ /* You should use this function with @FT_Get_First_Char to walk */ /* over all character codes available in a given charmap. See the */ - /* note for this function for a simple code example. */ + /* note for that function for a simple code example. */ /* */ /* Note that `*agindex' is set to~0 when there are no more codes in */ /* the charmap. */ @@ -3517,14 +3677,109 @@ FT_BEGIN_HEADER FT_UInt *agindex ); + /************************************************************************* + * + * @function: + * FT_Face_Properties + * + * @description: + * Set or override certain (library or module-wide) properties on a + * face-by-face basis. Useful for finer-grained control and avoiding + * locks on shared structures (threads can modify their own faces as + * they see fit). + * + * Contrary to @FT_Property_Set, this function uses @FT_Parameter so + * that you can pass multiple properties to the target face in one call. + * Note that only a subset of the available properties can be + * controlled. + * + * * Stem darkening (@FT_PARAM_TAG_STEM_DARKENING, corresponding to the + * property `no-stem-darkening' provided by the `autofit' and `cff' + * modules; see @no-stem-darkening[autofit] and + * @no-stem-darkening[cff]). + * + * * LCD filter weights (@FT_PARAM_TAG_LCD_FILTER_WEIGHTS, corresponding + * to function @FT_Library_SetLcdFilterWeights). + * + * * Seed value for the CFF `random' operator + * (@FT_PARAM_TAG_RANDOM_SEED, corresponding to the `random-seed' + * property provided by the `cff' module; see @random-seed). + * + * Pass NULL as `data' in @FT_Parameter for a given tag to reset the + * option and use the library or module default again. + * + * @input: + * face :: + * A handle to the source face object. + * + * num_properties :: + * The number of properties that follow. + * + * properties :: + * A handle to an @FT_Parameter array with `num_properties' elements. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * Here an example that sets three properties. You must define + * FT_CONFIG_OPTION_SUBPIXEL_RENDERING to make the LCD filter examples + * work. + * + * { + * FT_Parameter property1; + * FT_Bool darken_stems = 1; + * + * FT_Parameter property2; + * FT_LcdFiveTapFilter custom_weight = + * { 0x11, 0x44, 0x56, 0x44, 0x11 }; + * + * FT_Parameter property3; + * FT_Int32 random_seed = 314159265; + * + * FT_Parameter properties[3] = { property1, + * property2, + * property3 }; + * + * + * property1.tag = FT_PARAM_TAG_STEM_DARKENING; + * property1.data = &darken_stems; + * + * property2.tag = FT_PARAM_TAG_LCD_FILTER_WEIGHTS; + * property2.data = custom_weight; + * + * property3.tag = FT_PARAM_TAG_RANDOM_SEED; + * property3.data = &random_seed; + * + * FT_Face_Properties( face, 3, properties ); + * } + * + * The next example resets a single property to its default value. + * + * { + * FT_Parameter property; + * + * + * property.tag = FT_PARAM_TAG_LCD_FILTER_WEIGHTS; + * property.data = NULL; + * + * FT_Face_Properties( face, 1, &property ); + * } + * + */ + FT_EXPORT( FT_Error ) + FT_Face_Properties( FT_Face face, + FT_UInt num_properties, + FT_Parameter* properties ); + + /*************************************************************************/ /* */ /* */ /* FT_Get_Name_Index */ /* */ /* */ - /* Return the glyph index of a given glyph name. This function uses */ - /* driver specific objects to do the translation. */ + /* Return the glyph index of a given glyph name. */ /* */ /* */ /* face :: A handle to the source face object. */ @@ -3545,8 +3800,10 @@ FT_BEGIN_HEADER * FT_SUBGLYPH_FLAG_XXX * * @description: - * A list of constants used to describe subglyphs. Please refer to the - * TrueType specification for the meaning of the various flags. + * A list of constants describing subglyphs. Please refer to the + * `glyf' table description in the OpenType specification for the + * meaning of the various flags (which get synthesized for + * non-OpenType subglyphs). * * @values: * FT_SUBGLYPH_FLAG_ARGS_ARE_WORDS :: @@ -3607,7 +3864,7 @@ FT_BEGIN_HEADER * @note: * The values of `*p_arg1', `*p_arg2', and `*p_transform' must be * interpreted depending on the flags returned in `*p_flags'. See the - * TrueType specification for details. + * OpenType specification for details. * */ FT_EXPORT( FT_Error ) @@ -3647,33 +3904,31 @@ FT_BEGIN_HEADER /* the font software copyright owner. */ /* */ /* FT_FSTYPE_PREVIEW_AND_PRINT_EMBEDDING :: */ - /* If this bit is set, the font may be embedded and temporarily */ - /* loaded on the remote system. Documents containing Preview & */ - /* Print fonts must be opened `read-only'; no edits can be applied */ - /* to the document. */ + /* The font may be embedded and temporarily loaded on the remote */ + /* system. Documents containing Preview & Print fonts must be */ + /* opened `read-only'; no edits can be applied to the document. */ /* */ /* FT_FSTYPE_EDITABLE_EMBEDDING :: */ - /* If this bit is set, the font may be embedded but must only be */ - /* installed temporarily on other systems. In contrast to Preview */ - /* & Print fonts, documents containing editable fonts may be opened */ - /* for reading, editing is permitted, and changes may be saved. */ + /* The font may be embedded but must only be installed temporarily */ + /* on other systems. In contrast to Preview & Print fonts, */ + /* documents containing editable fonts may be opened for reading, */ + /* editing is permitted, and changes may be saved. */ /* */ /* FT_FSTYPE_NO_SUBSETTING :: */ - /* If this bit is set, the font may not be subsetted prior to */ - /* embedding. */ + /* The font may not be subsetted prior to embedding. */ /* */ /* FT_FSTYPE_BITMAP_EMBEDDING_ONLY :: */ - /* If this bit is set, only bitmaps contained in the font may be */ - /* embedded; no outline data may be embedded. If there are no */ - /* bitmaps available in the font, then the font is unembeddable. */ + /* Only bitmaps contained in the font may be embedded; no outline */ + /* data may be embedded. If there are no bitmaps available in the */ + /* font, then the font is unembeddable. */ /* */ /* */ /* The flags are ORed together, thus more than a single value can be */ /* returned. */ /* */ - /* While the fsType flags can indicate that a font may be embedded, a */ - /* license with the font vendor may be separately required to use the */ - /* font in this way. */ + /* While the `fsType' flags can indicate that a font may be embedded, */ + /* a license with the font vendor may be separately required to use */ + /* the font in this way. */ /* */ #define FT_FSTYPE_INSTALLABLE_EMBEDDING 0x0000 #define FT_FSTYPE_RESTRICTED_LICENSE_EMBEDDING 0x0002 @@ -3689,13 +3944,13 @@ FT_BEGIN_HEADER /* FT_Get_FSType_Flags */ /* */ /* */ - /* Return the fsType flags for a font. */ + /* Return the `fsType' flags for a font. */ /* */ /* */ /* face :: A handle to the source face object. */ /* */ /* */ - /* The fsType flags, @FT_FSTYPE_XXX. */ + /* The `fsType' flags, see @FT_FSTYPE_XXX. */ /* */ /* */ /* Use this function rather than directly reading the `fs_type' field */ @@ -3715,39 +3970,51 @@ FT_BEGIN_HEADER /* glyph_variants */ /* */ /* */ - /* Glyph Variants */ + /* Unicode Variation Sequences */ /* */ /* <Abstract> */ - /* The FreeType~2 interface to Unicode Ideographic Variation */ - /* Sequences (IVS), using the SFNT cmap format~14. */ + /* The FreeType~2 interface to Unicode Variation Sequences (UVS), */ + /* using the SFNT cmap format~14. */ /* */ /* <Description> */ - /* Many CJK characters have variant forms. They are a sort of grey */ - /* area somewhere between being totally irrelevant and semantically */ - /* distinct; for this reason, the Unicode consortium decided to */ - /* introduce Ideographic Variation Sequences (IVS), consisting of a */ - /* Unicode base character and one of 240 variant selectors */ - /* (U+E0100-U+E01EF), instead of further extending the already huge */ - /* code range for CJK characters. */ - /* */ - /* An IVS is registered and unique; for further details please refer */ - /* to Unicode Technical Standard #37, the Ideographic Variation */ - /* Database: */ - /* */ - /* http://www.unicode.org/reports/tr37/ */ - /* */ - /* 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 */ - /* input code points to glyphs, but contains lists of all variants */ - /* supported by the font. */ - /* */ - /* A variant may be either `default' or `non-default'. A default */ - /* variant is the one you will get for that code point if you look it */ - /* up in the standard Unicode cmap. A non-default variant is a */ - /* different glyph. */ + /* Many characters, especially for CJK scripts, have variant forms. */ + /* They are a sort of grey area somewhere between being totally */ + /* irrelevant and semantically distinct; for this reason, the Unicode */ + /* consortium decided to introduce Variation Sequences (VS), */ + /* consisting of a Unicode base character and a variation selector */ + /* instead of further extending the already huge number of */ + /* characters. */ + /* */ + /* Unicode maintains two different sets, namely `Standardized */ + /* Variation Sequences' and registered `Ideographic Variation */ + /* Sequences' (IVS), collected in the `Ideographic Variation */ + /* Database' (IVD). */ + /* */ + /* http://unicode.org/Public/UCD/latest/ucd/StandardizedVariants.txt */ + /* http://unicode.org/reports/tr37/ */ + /* http://unicode.org/ivd/ */ + /* */ + /* To date (January 2017), the character with the most ideographic */ + /* variations is U+9089, having 32 such IVS. */ + /* */ + /* Three Mongolian Variation Selectors have the values U+180B-U+180D; */ + /* 256 generic Variation Selectors are encoded in the ranges */ + /* U+FE00-U+FE0F and U+E0100-U+E01EF. IVS currently use Variation */ + /* Selectors from the range U+E0100-U+E01EF only. */ + /* */ + /* A VS consists of the base character value followed by a single */ + /* Variation Selector. For example, to get the first variation of */ + /* U+9089, you have to write the character sequence `U+9089 U+E0100'. */ + /* */ + /* Adobe and MS decided to support both standardized and ideographic */ + /* VS with a new cmap subtable (format~14). It is an odd subtable */ + /* because it is not a mapping of input code points to glyphs, but */ + /* contains lists of all variations supported by the font. */ + /* */ + /* A variation may be either `default' or `non-default' for a given */ + /* font. A default variation is the one you will get for that code */ + /* point if you look it up in the standard Unicode cmap. A */ + /* non-default variation is a different glyph. */ /* */ /*************************************************************************/ @@ -3803,8 +4070,8 @@ FT_BEGIN_HEADER /* FT_Face_GetCharVariantIsDefault */ /* */ /* <Description> */ - /* Check whether this variant of this Unicode character is the one to */ - /* be found in the `cmap'. */ + /* Check whether this variation of this Unicode character is the one */ + /* to be found in the `cmap'. */ /* */ /* <Input> */ /* face :: */ @@ -3818,7 +4085,7 @@ FT_BEGIN_HEADER /* */ /* <Return> */ /* 1~if found in the standard (Unicode) cmap, 0~if found in the */ - /* variation selector cmap, or -1 if it is not a variant. */ + /* variation selector cmap, or -1 if it is not a variation. */ /* */ /* <Note> */ /* This function is only meaningful if the font has a variation */ @@ -3839,7 +4106,7 @@ FT_BEGIN_HEADER /* FT_Face_GetVariantSelectors */ /* */ /* <Description> */ - /* Return a zero-terminated list of Unicode variant selectors found */ + /* Return a zero-terminated list of Unicode variation selectors found */ /* in the font. */ /* */ /* <Input> */ @@ -3848,7 +4115,7 @@ FT_BEGIN_HEADER /* */ /* <Return> */ /* A pointer to an array of selector code points, or NULL if there is */ - /* no valid variant selector cmap subtable. */ + /* no valid variation selector cmap subtable. */ /* */ /* <Note> */ /* The last item in the array is~0; the array is owned by the */ @@ -3868,7 +4135,7 @@ FT_BEGIN_HEADER /* FT_Face_GetVariantsOfChar */ /* */ /* <Description> */ - /* Return a zero-terminated list of Unicode variant selectors found */ + /* Return a zero-terminated list of Unicode variation selectors found */ /* for the specified character code. */ /* */ /* <Input> */ @@ -3879,7 +4146,7 @@ FT_BEGIN_HEADER /* The character codepoint in Unicode. */ /* */ /* <Return> */ - /* A pointer to an array of variant selector code points that are */ + /* A pointer to an array of variation selector code points that are */ /* active for the given character, or NULL if the corresponding list */ /* is empty. */ /* */ @@ -3903,19 +4170,19 @@ FT_BEGIN_HEADER /* */ /* <Description> */ /* Return a zero-terminated list of Unicode character codes found for */ - /* the specified variant selector. */ + /* the specified variation selector. */ /* */ /* <Input> */ /* face :: */ /* A handle to the source face object. */ /* */ /* variantSelector :: */ - /* The variant selector code point in Unicode. */ + /* The variation selector code point in Unicode. */ /* */ /* <Return> */ /* A list of all the code points that are specified by this selector */ /* (both default and non-default codes are returned) or NULL if there */ - /* is no valid cmap or the variant selector is invalid. */ + /* is no valid cmap or the variation selector is invalid. */ /* */ /* <Note> */ /* The last item in the array is~0; the array is owned by the */ @@ -3965,16 +4232,17 @@ FT_BEGIN_HEADER /* FT_MulDiv */ /* */ /* <Description> */ - /* A very simple function used to perform the computation `(a*b)/c' */ - /* with maximum accuracy (it uses a 64-bit intermediate integer */ - /* whenever necessary). */ + /* Compute `(a*b)/c' with maximum accuracy, using a 64-bit */ + /* intermediate integer whenever necessary. */ /* */ /* This function isn't necessarily as fast as some processor specific */ /* operations, but is at least completely portable. */ /* */ /* <Input> */ /* a :: The first multiplier. */ + /* */ /* b :: The second multiplier. */ + /* */ /* c :: The divisor. */ /* */ /* <Return> */ @@ -3994,12 +4262,12 @@ FT_BEGIN_HEADER /* FT_MulFix */ /* */ /* <Description> */ - /* A very simple function used to perform the computation */ - /* `(a*b)/0x10000' with maximum accuracy. Most of the time this is */ - /* used to multiply a given value by a 16.16 fixed-point factor. */ + /* Compute `(a*b)/0x10000' with maximum accuracy. Its main use is to */ + /* multiply 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). */ /* */ @@ -4028,12 +4296,12 @@ FT_BEGIN_HEADER /* FT_DivFix */ /* */ /* <Description> */ - /* A very simple function used to perform the computation */ - /* `(a*0x10000)/b' with maximum accuracy. Most of the time, this is */ - /* used to divide a given value by a 16.16 fixed-point factor. */ + /* Compute `(a*0x10000)/b' with maximum accuracy. Its main use is to */ + /* divide a given value by a 16.16 fixed-point factor. */ /* */ /* <Input> */ /* a :: The numerator. */ + /* */ /* b :: The denominator. Use a 16.16 factor here. */ /* */ /* <Return> */ @@ -4050,13 +4318,13 @@ FT_BEGIN_HEADER /* FT_RoundFix */ /* */ /* <Description> */ - /* A very simple function used to round a 16.16 fixed number. */ + /* Round a 16.16 fixed number. */ /* */ /* <Input> */ /* a :: The number to be rounded. */ /* */ /* <Return> */ - /* `a' rounded to nearest 16.16 fixed integer, halfway cases away */ + /* `a' rounded to the nearest 16.16 fixed integer, halfway cases away */ /* from zero. */ /* */ FT_EXPORT( FT_Fixed ) @@ -4069,8 +4337,7 @@ FT_BEGIN_HEADER /* FT_CeilFix */ /* */ /* <Description> */ - /* A very simple function used to compute the ceiling function of a */ - /* 16.16 fixed number. */ + /* Compute the smallest following integer of a 16.16 fixed number. */ /* */ /* <Input> */ /* a :: The number for which the ceiling function is to be computed. */ @@ -4088,8 +4355,7 @@ FT_BEGIN_HEADER /* FT_FloorFix */ /* */ /* <Description> */ - /* A very simple function used to compute the floor function of a */ - /* 16.16 fixed number. */ + /* Compute the largest previous integer of a 16.16 fixed number. */ /* */ /* <Input> */ /* a :: The number for which the floor function is to be computed. */ @@ -4175,8 +4441,8 @@ FT_BEGIN_HEADER * */ #define FREETYPE_MAJOR 2 -#define FREETYPE_MINOR 6 -#define FREETYPE_PATCH 5 +#define FREETYPE_MINOR 8 +#define FREETYPE_PATCH 0 /*************************************************************************/ diff --git a/thirdparty/freetype/include/freetype/ftadvanc.h b/thirdparty/freetype/include/freetype/ftadvanc.h index 023dd84b7a..dea96e0db4 100644 --- a/thirdparty/freetype/include/freetype/ftadvanc.h +++ b/thirdparty/freetype/include/freetype/ftadvanc.h @@ -4,7 +4,7 @@ /* */ /* Quick computation of advance widths (specification only). */ /* */ -/* Copyright 2008-2016 by */ +/* Copyright 2008-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/thirdparty/freetype/include/freetype/ftautoh.h b/thirdparty/freetype/include/freetype/ftautoh.h index 40c8003c4a..abd540f0b5 100644 --- a/thirdparty/freetype/include/freetype/ftautoh.h +++ b/thirdparty/freetype/include/freetype/ftautoh.h @@ -4,7 +4,7 @@ /* */ /* FreeType API for controlling the auto-hinter (specification only). */ /* */ -/* Copyright 2012-2016 by */ +/* Copyright 2012-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -428,6 +428,9 @@ FT_BEGIN_HEADER * @note: * This property can be used with @FT_Property_Get also. * + * This property can be set via the `FREETYPE_PROPERTIES' environment + * variable (using values 1 and 0 for `on' and `off', respectively). + * * The warping code can also change advance widths. Have a look at the * `lsb_delta' and `rsb_delta' fields in the @FT_GlyphSlotRec structure * for details on improving inter-glyph distances while rendering. @@ -445,7 +448,7 @@ FT_BEGIN_HEADER * no-stem-darkening[autofit] * * @description: - * *Experimental* *only,* *requires* *linear* *alpha* *blending* *and* + * *Experimental* *only*, *requires* *linear* *alpha* *blending* *and* * *gamma* *correction* * * Stem darkening emboldens glyphs at smaller sizes to make them more @@ -473,7 +476,32 @@ FT_BEGIN_HEADER * The smaller the size (especially 9ppem and down), the higher the loss * of emboldening versus the CFF driver. * + * This property can be set via the `FREETYPE_PROPERTIES' environment + * variable similar to the CFF driver. It can also be set per face + * using @FT_Face_Properties with @FT_PARAM_TAG_STEM_DARKENING. + * + */ + + + /************************************************************************** + * + * @constant: + * FT_PARAM_TAG_STEM_DARKENING + * + * @description: + * An @FT_Parameter tag to be used with @FT_Face_Properties. The + * corresponding Boolean argument specifies whether to apply stem + * darkening, overriding the global default values or the values set up + * with @FT_Property_Set (see @no-stem-darkening[autofit] and + * @no-stem-darkening[cff]). + * + * This is a passive setting that only takes effect if the font driver + * or autohinter honors it, which the CFF driver always does, but the + * autohinter only in `light' hinting mode (as of version 2.7.0). + * */ +#define FT_PARAM_TAG_STEM_DARKENING \ + FT_MAKE_TAG( 'd', 'a', 'r', 'k' ) /************************************************************************** @@ -489,6 +517,8 @@ FT_BEGIN_HEADER * CFF_CONFIG_OPTION_DARKENING_PARAMETER_* #defines for consistency. * Note the differences described in @no-stem-darkening[autofit]. * + * This property can be set via the `FREETYPE_PROPERTIES' environment + * variable similar to the CFF driver. */ diff --git a/thirdparty/freetype/include/freetype/ftbbox.h b/thirdparty/freetype/include/freetype/ftbbox.h index 2a4d214416..f03bdc1e1e 100644 --- a/thirdparty/freetype/include/freetype/ftbbox.h +++ b/thirdparty/freetype/include/freetype/ftbbox.h @@ -4,7 +4,7 @@ /* */ /* FreeType exact bbox computation (specification). */ /* */ -/* Copyright 1996-2016 by */ +/* Copyright 1996-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/thirdparty/freetype/include/freetype/ftbdf.h b/thirdparty/freetype/include/freetype/ftbdf.h index 016dba086d..3d3106bad0 100644 --- a/thirdparty/freetype/include/freetype/ftbdf.h +++ b/thirdparty/freetype/include/freetype/ftbdf.h @@ -4,7 +4,7 @@ /* */ /* FreeType API for accessing BDF-specific strings (specification). */ /* */ -/* Copyright 2002-2016 by */ +/* Copyright 2002-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/thirdparty/freetype/include/freetype/ftbitmap.h b/thirdparty/freetype/include/freetype/ftbitmap.h index 0eac7b9d7d..04b2402ad0 100644 --- a/thirdparty/freetype/include/freetype/ftbitmap.h +++ b/thirdparty/freetype/include/freetype/ftbitmap.h @@ -4,7 +4,7 @@ /* */ /* FreeType utility functions for bitmaps (specification). */ /* */ -/* Copyright 2004-2016 by */ +/* Copyright 2004-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/thirdparty/freetype/include/freetype/ftbzip2.h b/thirdparty/freetype/include/freetype/ftbzip2.h index b7f2eee87d..9147a790a4 100644 --- a/thirdparty/freetype/include/freetype/ftbzip2.h +++ b/thirdparty/freetype/include/freetype/ftbzip2.h @@ -4,7 +4,7 @@ /* */ /* Bzip2-compressed stream support. */ /* */ -/* Copyright 2010-2016 by */ +/* Copyright 2010-2017 by */ /* Joel Klinghed. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/thirdparty/freetype/include/freetype/ftcache.h b/thirdparty/freetype/include/freetype/ftcache.h index 883c88d5d2..5ff3ccf404 100644 --- a/thirdparty/freetype/include/freetype/ftcache.h +++ b/thirdparty/freetype/include/freetype/ftcache.h @@ -4,7 +4,7 @@ /* */ /* FreeType Cache subsystem (specification). */ /* */ -/* Copyright 1996-2016 by */ +/* Copyright 1996-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/thirdparty/freetype/include/freetype/ftcffdrv.h b/thirdparty/freetype/include/freetype/ftcffdrv.h index ad34541fdb..477b6ddb18 100644 --- a/thirdparty/freetype/include/freetype/ftcffdrv.h +++ b/thirdparty/freetype/include/freetype/ftcffdrv.h @@ -4,7 +4,7 @@ /* */ /* FreeType API for controlling the CFF driver (specification only). */ /* */ -/* Copyright 2013-2016 by */ +/* Copyright 2013-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -113,6 +113,7 @@ FT_BEGIN_HEADER * hinting-engine[cff] * no-stem-darkening[cff] * darkening-parameters[cff] + * random-seed * */ @@ -148,6 +149,8 @@ FT_BEGIN_HEADER * @note: * This property can be used with @FT_Property_Get also. * + * This property can be set via the `FREETYPE_PROPERTIES' environment + * variable (using values `adobe' or `freetype'). */ @@ -199,6 +202,11 @@ FT_BEGIN_HEADER * @note: * This property can be used with @FT_Property_Get also. * + * This property can be set via the `FREETYPE_PROPERTIES' environment + * variable (using values 1 and 0 for `on' and `off', respectively). + * It can also be set per face using @FT_Face_Properties with + * @FT_PARAM_TAG_STEM_DARKENING. + * */ @@ -248,7 +256,58 @@ FT_BEGIN_HEADER * @note: * This property can be used with @FT_Property_Get also. * + * This property can be set via the `FREETYPE_PROPERTIES' environment + * variable, using eight comma-separated integers without spaces. Here + * the above example, using `\' to break the line for readability. + * + * { + * FREETYPE_PROPERTIES=\ + * cff:darkening-parameters=500,300,1000,200,1500,100,2000,0 + * } + */ + + + /************************************************************************** + * + * @property: + * random-seed + * + * @description: + * By default, the seed value for the CFF `random' operator is set to a + * random value. However, mainly for debugging purposes, it is often + * necessary to use a known value as a seed so that the pseudo-random + * number sequences generated by `random' are repeatable. + * + * The `random-seed' property does that. Its argument is a signed 32bit + * integer; if the value is zero or negative, the seed given by the + * `intitialRandomSeed' private DICT operator in a CFF file gets used + * (or a default value if there is no such operator). If the value is + * positive, use it instead of `initialRandomSeed', which is + * consequently ignored. + * + * @note: + * This property can be set via the `FREETYPE_PROPERTIES' environment + * variable. It can also be set per face using @FT_Face_Properties with + * @FT_PARAM_TAG_RANDOM_SEED. + * + */ + + + /************************************************************************** + * + * @constant: + * FT_PARAM_TAG_RANDOM_SEED + * + * @description: + * An @FT_Parameter tag to be used with @FT_Face_Properties. The + * corresponding 32bit signed integer argument overrides the CFF + * module's random seed value with a face-specific one; see + * @random-seed. + * */ +#define FT_PARAM_TAG_RANDOM_SEED \ + FT_MAKE_TAG( 's', 'e', 'e', 'd' ) + /* */ diff --git a/thirdparty/freetype/include/freetype/ftchapters.h b/thirdparty/freetype/include/freetype/ftchapters.h index ab4389530e..a0a121b0a1 100644 --- a/thirdparty/freetype/include/freetype/ftchapters.h +++ b/thirdparty/freetype/include/freetype/ftchapters.h @@ -77,6 +77,7 @@ /* auto_hinter */ /* cff_driver */ /* tt_driver */ +/* pcf_driver */ /* */ /***************************************************************************/ diff --git a/thirdparty/freetype/include/freetype/ftcid.h b/thirdparty/freetype/include/freetype/ftcid.h index e1bc9fe015..4adcbeeda9 100644 --- a/thirdparty/freetype/include/freetype/ftcid.h +++ b/thirdparty/freetype/include/freetype/ftcid.h @@ -4,7 +4,7 @@ /* */ /* FreeType API for accessing CID font information (specification). */ /* */ -/* Copyright 2007-2016 by */ +/* Copyright 2007-2017 by */ /* Dereg Clegg and Michael Toftdal. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/thirdparty/freetype/include/freetype/fterrdef.h b/thirdparty/freetype/include/freetype/fterrdef.h index 3f53dd5820..cabbac8273 100644 --- a/thirdparty/freetype/include/freetype/fterrdef.h +++ b/thirdparty/freetype/include/freetype/fterrdef.h @@ -4,7 +4,7 @@ /* */ /* FreeType error codes (specification). */ /* */ -/* Copyright 2002-2016 by */ +/* Copyright 2002-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -231,6 +231,8 @@ "invalid PostScript (post) table format" ) FT_ERRORDEF_( Invalid_Post_Table, 0x9B, "invalid PostScript (post) table" ) + FT_ERRORDEF_( DEF_In_Glyf_Bytecode, 0x9C, + "found FDEF or IDEF opcode in glyf bytecode" ) /* CFF, CID, and Type 1 errors */ diff --git a/thirdparty/freetype/include/freetype/fterrors.h b/thirdparty/freetype/include/freetype/fterrors.h index e15bfb001e..42769fa7bf 100644 --- a/thirdparty/freetype/include/freetype/fterrors.h +++ b/thirdparty/freetype/include/freetype/fterrors.h @@ -4,7 +4,7 @@ /* */ /* FreeType error code handling (specification). */ /* */ -/* Copyright 1996-2016 by */ +/* Copyright 1996-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -106,7 +106,7 @@ /* */ /* #undefine __FTERRORS_H__ */ /* */ - /* work for backwards compatibility. */ + /* work for backward compatibility. */ /* */ #if !( defined( FTERRORS_H_ ) && defined ( __FTERRORS_H__ ) ) #define FTERRORS_H_ diff --git a/thirdparty/freetype/include/freetype/ftfntfmt.h b/thirdparty/freetype/include/freetype/ftfntfmt.h index bd423247bb..337758328a 100644 --- a/thirdparty/freetype/include/freetype/ftfntfmt.h +++ b/thirdparty/freetype/include/freetype/ftfntfmt.h @@ -4,7 +4,7 @@ /* */ /* Support functions for font formats. */ /* */ -/* Copyright 2002-2016 by */ +/* Copyright 2002-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/thirdparty/freetype/include/freetype/ftgasp.h b/thirdparty/freetype/include/freetype/ftgasp.h index 3f5b3bc695..ce18d64784 100644 --- a/thirdparty/freetype/include/freetype/ftgasp.h +++ b/thirdparty/freetype/include/freetype/ftgasp.h @@ -4,7 +4,7 @@ /* */ /* Access of TrueType's `gasp' table (specification). */ /* */ -/* Copyright 2007-2016 by */ +/* Copyright 2007-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -92,8 +92,8 @@ #define FT_GASP_NO_TABLE -1 #define FT_GASP_DO_GRIDFIT 0x01 #define FT_GASP_DO_GRAY 0x02 +#define FT_GASP_SYMMETRIC_GRIDFIT 0x04 #define FT_GASP_SYMMETRIC_SMOOTHING 0x08 -#define FT_GASP_SYMMETRIC_GRIDFIT 0x10 /************************************************************************* @@ -102,17 +102,25 @@ * FT_Get_Gasp * * @description: - * Read the `gasp' table from a TrueType or OpenType font file and - * return the entry corresponding to a given character pixel size. + * For a TrueType or OpenType font file, return the rasterizer behaviour + * flags from the font's `gasp' table corresponding to a given + * character pixel size. * * @input: * face :: The source face handle. + * * ppem :: The vertical character pixel size. * * @return: * Bit flags (see @FT_GASP_XXX), or @FT_GASP_NO_TABLE if there is no * `gasp' table in the face. * + * @note: + * If you want to use the MM functionality of OpenType variation fonts + * (i.e., using @FT_Set_Var_Design_Coordinates and friends), call this + * function *after* setting an instance since the return values can + * change. + * * @since: * 2.3.0 */ diff --git a/thirdparty/freetype/include/freetype/ftglyph.h b/thirdparty/freetype/include/freetype/ftglyph.h index d9840a81fc..79879a7ac7 100644 --- a/thirdparty/freetype/include/freetype/ftglyph.h +++ b/thirdparty/freetype/include/freetype/ftglyph.h @@ -4,7 +4,7 @@ /* */ /* FreeType convenience functions to handle glyphs (specification). */ /* */ -/* Copyright 1996-2016 by */ +/* Copyright 1996-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -453,7 +453,7 @@ FT_BEGIN_HEADER /* */ /* */ /* // load glyph */ - /* error = FT_Load_Char( face, glyph_index, FT_LOAD_DEFAUT ); */ + /* error = FT_Load_Char( face, glyph_index, FT_LOAD_DEFAULT ); */ /* */ /* // extract glyph image */ /* error = FT_Get_Glyph( face->glyph, &glyph ); */ diff --git a/thirdparty/freetype/include/freetype/ftgxval.h b/thirdparty/freetype/include/freetype/ftgxval.h index a58e86a040..f239c71eb1 100644 --- a/thirdparty/freetype/include/freetype/ftgxval.h +++ b/thirdparty/freetype/include/freetype/ftgxval.h @@ -4,7 +4,7 @@ /* */ /* FreeType API for validating TrueTypeGX/AAT tables (specification). */ /* */ -/* Copyright 2004-2016 by */ +/* Copyright 2004-2017 by */ /* Masatake YAMATO, Redhat K.K, */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ diff --git a/thirdparty/freetype/include/freetype/ftgzip.h b/thirdparty/freetype/include/freetype/ftgzip.h index 3932ce6887..bd5ceaab9f 100644 --- a/thirdparty/freetype/include/freetype/ftgzip.h +++ b/thirdparty/freetype/include/freetype/ftgzip.h @@ -4,7 +4,7 @@ /* */ /* Gzip-compressed stream support. */ /* */ -/* Copyright 2002-2016 by */ +/* Copyright 2002-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/thirdparty/freetype/include/freetype/ftimage.h b/thirdparty/freetype/include/freetype/ftimage.h index 28b2704e80..1a049ef16d 100644 --- a/thirdparty/freetype/include/freetype/ftimage.h +++ b/thirdparty/freetype/include/freetype/ftimage.h @@ -5,7 +5,7 @@ /* FreeType glyph image formats and default raster interface */ /* (specification). */ /* */ -/* Copyright 1996-2016 by */ +/* Copyright 1996-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -619,7 +619,7 @@ FT_BEGIN_HEADER /* */ /* { */ /* x' = (x << shift) - delta */ - /* y' = (x << shift) - delta */ + /* y' = (y << shift) - delta */ /* } */ /* */ /* Set the values of `shift' and `delta' to~0 to get the original */ @@ -860,16 +860,6 @@ FT_BEGIN_HEADER /* This can be used to write anti-aliased outlines directly to a */ /* given background bitmap, and even perform translucency. */ /* */ - /* Note that the `count' field cannot be greater than a fixed value */ - /* defined by the `FT_MAX_GRAY_SPANS' configuration macro in */ - /* `ftoption.h'. By default, this value is set to~32, which means */ - /* that if there are more than 32~spans on a given scanline, the */ - /* callback is called several times with the same `y' parameter in */ - /* order to draw all callbacks. */ - /* */ - /* Otherwise, the callback is only called once per scan-line, and */ - /* only for those scanlines that do have `gray' pixels on them. */ - /* */ typedef void (*FT_SpanFunc)( int y, int count, @@ -1190,6 +1180,7 @@ FT_BEGIN_HEADER typedef struct FT_Raster_Funcs_ { FT_Glyph_Format glyph_format; + FT_Raster_NewFunc raster_new; FT_Raster_ResetFunc raster_reset; FT_Raster_SetModeFunc raster_set_mode; diff --git a/thirdparty/freetype/include/freetype/ftincrem.h b/thirdparty/freetype/include/freetype/ftincrem.h index 46b58b7917..f6ae2baed6 100644 --- a/thirdparty/freetype/include/freetype/ftincrem.h +++ b/thirdparty/freetype/include/freetype/ftincrem.h @@ -4,7 +4,7 @@ /* */ /* FreeType incremental loading (specification). */ /* */ -/* Copyright 2002-2016 by */ +/* Copyright 2002-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/thirdparty/freetype/include/freetype/ftlcdfil.h b/thirdparty/freetype/include/freetype/ftlcdfil.h index e06a8957f5..680bd90c89 100644 --- a/thirdparty/freetype/include/freetype/ftlcdfil.h +++ b/thirdparty/freetype/include/freetype/ftlcdfil.h @@ -5,7 +5,7 @@ /* FreeType API for color filtering of subpixel bitmap glyphs */ /* (specification). */ /* */ -/* Copyright 2006-2016 by */ +/* Copyright 2006-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -268,6 +268,9 @@ FT_BEGIN_HEADER * defined in your build of the library, which should correspond to all * default builds of FreeType. * + * LCD filter weights can also be set per face using @FT_Face_Properties + * with @FT_PARAM_TAG_LCD_FILTER_WEIGHTS. + * * @since: * 2.4.0 */ @@ -275,6 +278,38 @@ FT_BEGIN_HEADER FT_Library_SetLcdFilterWeights( FT_Library library, unsigned char *weights ); + + /************************************************************************** + * + * @constant: + * FT_PARAM_TAG_LCD_FILTER_WEIGHTS + * + * @description: + * An @FT_Parameter tag to be used with @FT_Face_Properties. The + * corresponding argument specifies the five LCD filter weights for a + * given face (if using @FT_LOAD_TARGET_LCD, for example), overriding + * the global default values or the values set up with + * @FT_Library_SetLcdFilterWeights. + * + */ +#define FT_PARAM_TAG_LCD_FILTER_WEIGHTS \ + FT_MAKE_TAG( 'l', 'c', 'd', 'f' ) + + + /* + * @type: + * FT_LcdFiveTapFilter + * + * @description: + * A typedef for passing the five LCD filter weights to + * @FT_Face_Properties within an @FT_Parameter structure. + * + */ +#define FT_LCD_FILTER_FIVE_TAPS 5 + + typedef FT_Byte FT_LcdFiveTapFilter[FT_LCD_FILTER_FIVE_TAPS]; + + /* */ diff --git a/thirdparty/freetype/include/freetype/ftlist.h b/thirdparty/freetype/include/freetype/ftlist.h index 82f437ac61..5309cb18ba 100644 --- a/thirdparty/freetype/include/freetype/ftlist.h +++ b/thirdparty/freetype/include/freetype/ftlist.h @@ -4,7 +4,7 @@ /* */ /* Generic list support for FreeType (specification). */ /* */ -/* Copyright 1996-2016 by */ +/* Copyright 1996-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/thirdparty/freetype/include/freetype/ftlzw.h b/thirdparty/freetype/include/freetype/ftlzw.h index 582e2c1465..a82c95e7c9 100644 --- a/thirdparty/freetype/include/freetype/ftlzw.h +++ b/thirdparty/freetype/include/freetype/ftlzw.h @@ -4,7 +4,7 @@ /* */ /* LZW-compressed stream support. */ /* */ -/* Copyright 2004-2016 by */ +/* Copyright 2004-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/thirdparty/freetype/include/freetype/ftmac.h b/thirdparty/freetype/include/freetype/ftmac.h index adb15cadf3..ad97c6e4c3 100644 --- a/thirdparty/freetype/include/freetype/ftmac.h +++ b/thirdparty/freetype/include/freetype/ftmac.h @@ -4,7 +4,7 @@ /* */ /* Additional Mac-specific API. */ /* */ -/* Copyright 1996-2016 by */ +/* Copyright 1996-2017 by */ /* Just van Rossum, David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/thirdparty/freetype/include/freetype/ftmm.h b/thirdparty/freetype/include/freetype/ftmm.h index 6c05f0c390..c41b80ea67 100644 --- a/thirdparty/freetype/include/freetype/ftmm.h +++ b/thirdparty/freetype/include/freetype/ftmm.h @@ -4,7 +4,7 @@ /* */ /* FreeType Multiple Master font interface (specification). */ /* */ -/* Copyright 1996-2016 by */ +/* Copyright 1996-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -43,11 +43,10 @@ FT_BEGIN_HEADER /* Master fonts, i.e., the selection of specific design instances by */ /* setting design axis coordinates. */ /* */ - /* George Williams has extended this interface to make it work with */ - /* both Type~1 Multiple Masters fonts and GX distortable (var) */ - /* fonts. Some of these routines only work with MM fonts, others */ - /* will work with both types. They are similar enough that a */ - /* consistent interface makes sense. */ + /* Besides Adobe MM fonts, the interface supports Apple's TrueType GX */ + /* and OpenType variation fonts. Some of the routines only work with */ + /* Adobe MM fonts, others will work with all three types. They are */ + /* similar enough that a consistent interface makes sense. */ /* */ /*************************************************************************/ @@ -58,10 +57,11 @@ FT_BEGIN_HEADER /* FT_MM_Axis */ /* */ /* <Description> */ - /* A simple structure used to model a given axis in design space for */ - /* Multiple Masters fonts. */ + /* A structure to model a given axis in design space for Multiple */ + /* Masters fonts. */ /* */ - /* This structure can't be used for GX var fonts. */ + /* This structure can't be used for TrueType GX or OpenType variation */ + /* fonts. */ /* */ /* <Fields> */ /* name :: The axis's name. */ @@ -85,10 +85,11 @@ FT_BEGIN_HEADER /* FT_Multi_Master */ /* */ /* <Description> */ - /* A structure used to model the axes and space of a Multiple Masters */ + /* A structure to model the axes and space of a Multiple Masters */ /* font. */ /* */ - /* This structure can't be used for GX var fonts. */ + /* This structure can't be used for TrueType GX or OpenType variation */ + /* fonts. */ /* */ /* <Fields> */ /* num_axis :: Number of axes. Cannot exceed~4. */ @@ -115,27 +116,35 @@ FT_BEGIN_HEADER /* FT_Var_Axis */ /* */ /* <Description> */ - /* A simple structure used to model a given axis in design space for */ - /* Multiple Masters and GX var fonts. */ + /* A structure to model a given axis in design space for Multiple */ + /* Masters, TrueType GX, and OpenType variation fonts. */ /* */ /* <Fields> */ /* name :: The axis's name. */ - /* Not always meaningful for GX. */ + /* Not always meaningful for TrueType GX or OpenType */ + /* variation fonts. */ /* */ /* minimum :: The axis's minimum design coordinate. */ /* */ /* def :: The axis's default design coordinate. */ - /* FreeType computes meaningful default values for MM; it */ - /* is then an integer value, not in 16.16 format. */ + /* FreeType computes meaningful default values for Adobe */ + /* MM fonts. */ /* */ /* maximum :: The axis's maximum design coordinate. */ /* */ - /* tag :: The axis's tag (the GX equivalent to `name'). */ - /* FreeType provides default values for MM if possible. */ + /* tag :: The axis's tag (the equivalent to `name' for TrueType */ + /* GX and OpenType variation fonts). FreeType provides */ + /* default values for Adobe MM fonts if possible. */ /* */ - /* strid :: The entry in `name' table (another GX version of */ - /* `name'). */ - /* Not meaningful for MM. */ + /* strid :: The axis name entry in the font's `name' table. This */ + /* is another (and often better) version of the `name' */ + /* field for TrueType GX or OpenType variation fonts. Not */ + /* meaningful for Adobe MM fonts. */ + /* */ + /* <Note> */ + /* The fields `minimum', `def', and `maximum' are 16.16 fractional */ + /* values for TrueType GX and OpenType variation fonts. For Adobe MM */ + /* fonts, the values are integers. */ /* */ typedef struct FT_Var_Axis_ { @@ -157,20 +166,25 @@ FT_BEGIN_HEADER /* FT_Var_Named_Style */ /* */ /* <Description> */ - /* A simple structure used to model a named style in a GX var font. */ + /* A structure to model a named instance in a TrueType GX or OpenType */ + /* variation font. */ /* */ - /* This structure can't be used for MM fonts. */ + /* This structure can't be used for Adobe MM fonts. */ /* */ /* <Fields> */ - /* coords :: The design coordinates for this style. */ + /* coords :: The design coordinates for this instance. */ /* This is an array with one entry for each axis. */ /* */ - /* strid :: The entry in `name' table identifying this style. */ + /* strid :: The entry in `name' table identifying this instance. */ + /* */ + /* psid :: The entry in `name' table identifying a PostScript name */ + /* for this instance. */ /* */ typedef struct FT_Var_Named_Style_ { FT_Fixed* coords; FT_UInt strid; + FT_UInt psid; /* since 2.7.1 */ } FT_Var_Named_Style; @@ -181,35 +195,43 @@ FT_BEGIN_HEADER /* FT_MM_Var */ /* */ /* <Description> */ - /* A structure used to model the axes and space of a Multiple Masters */ - /* or GX var distortable font. */ + /* A structure to model the axes and space of a Adobe MM, TrueType */ + /* GX, or OpenType variation font. */ /* */ - /* Some fields are specific to one format and not to the other. */ + /* Some fields are specific to one format and not to the others. */ /* */ /* <Fields> */ /* num_axis :: The number of axes. The maximum value is~4 for */ - /* MM; no limit in GX. */ + /* Adobe MM fonts; no limit in TrueType GX or */ + /* OpenType variation fonts. */ /* */ /* num_designs :: The number of designs; should be normally */ - /* 2^num_axis for MM fonts. Not meaningful for GX */ + /* 2^num_axis for Adobe MM fonts. Not meaningful */ + /* for TrueType GX or OpenType variation fonts */ /* (where every glyph could have a different */ /* number of designs). */ /* */ - /* num_namedstyles :: The number of named styles; only meaningful for */ - /* GX that allows certain design coordinates to */ - /* have a string ID (in the `name' table) */ - /* associated with them. The font can tell the */ - /* user that, for example, Weight=1.5 is `Bold'. */ + /* num_namedstyles :: The number of named styles; a `named style' is */ + /* a tuple of design coordinates that has a string */ + /* ID (in the `name' table) associated with it. */ + /* The font can tell the user that, for example, */ + /* [Weight=1.5,Width=1.1] is `Bold'. Another name */ + /* for `named style' is `named instance'. */ + /* */ + /* For Adobe Multiple Masters fonts, this value is */ + /* always zero because the format does not support */ + /* named styles. */ /* */ /* axis :: An axis descriptor table. */ - /* GX fonts contain slightly more data than MM. */ + /* TrueType GX and OpenType variation fonts */ + /* contain slightly more data than Adobe MM fonts. */ /* Memory management of this pointer is done */ /* internally by FreeType. */ /* */ - /* namedstyle :: A named style table. */ - /* Only meaningful with GX. */ - /* Memory management of this pointer is done */ - /* internally by FreeType. */ + /* namedstyle :: A named style (instance) table. */ + /* Only meaningful for TrueType GX and OpenType */ + /* variation fonts. Memory management of this */ + /* pointer is done internally by FreeType. */ /* */ typedef struct FT_MM_Var_ { @@ -228,9 +250,10 @@ FT_BEGIN_HEADER /* FT_Get_Multi_Master */ /* */ /* <Description> */ - /* Retrieve the Multiple Master descriptor of a given font. */ + /* Retrieve a variation descriptor of a given Adobe MM font. */ /* */ - /* This function can't be used with GX fonts. */ + /* This function can't be used with TrueType GX or OpenType variation */ + /* fonts. */ /* */ /* <Input> */ /* face :: A handle to the source face. */ @@ -252,13 +275,15 @@ FT_BEGIN_HEADER /* FT_Get_MM_Var */ /* */ /* <Description> */ - /* Retrieve the Multiple Master/GX var descriptor of a given font. */ + /* Retrieve a variation descriptor for a given font. */ + /* */ + /* This function works with all supported variation formats. */ /* */ /* <Input> */ /* face :: A handle to the source face. */ /* */ /* <Output> */ - /* amaster :: The Multiple Masters/GX var descriptor. */ + /* amaster :: The variation descriptor. */ /* Allocates a data structure, which the user must */ /* deallocate with `free' after use. */ /* */ @@ -276,10 +301,11 @@ FT_BEGIN_HEADER /* FT_Set_MM_Design_Coordinates */ /* */ /* <Description> */ - /* For Multiple Masters fonts, choose an interpolated font design */ - /* through design coordinates. */ + /* For Adobe MM fonts, choose an interpolated font design through */ + /* design coordinates. */ /* */ - /* This function can't be used with GX fonts. */ + /* This function can't be used with TrueType GX or OpenType variation */ + /* fonts. */ /* */ /* <InOut> */ /* face :: A handle to the source face. */ @@ -307,8 +333,9 @@ FT_BEGIN_HEADER /* FT_Set_Var_Design_Coordinates */ /* */ /* <Description> */ - /* For Multiple Master or GX Var fonts, choose an interpolated font */ - /* design through design coordinates. */ + /* Choose an interpolated font design through design coordinates. */ + /* */ + /* This function works with all supported variation formats. */ /* */ /* <InOut> */ /* face :: A handle to the source face. */ @@ -330,14 +357,46 @@ FT_BEGIN_HEADER FT_Fixed* coords ); + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_Get_Var_Design_Coordinates */ + /* */ + /* <Description> */ + /* Get the design coordinates of the currently selected interpolated */ + /* font. */ + /* */ + /* This function works with all supported variation formats. */ + /* */ + /* <Input> */ + /* face :: A handle to the source face. */ + /* */ + /* num_coords :: The number of design coordinates to retrieve. If it */ + /* is larger than the number of axes, set the excess */ + /* values to~0. */ + /* */ + /* <Output> */ + /* coords :: The design coordinates array. */ + /* */ + /* <Return> */ + /* FreeType error code. 0~means success. */ + /* */ + FT_EXPORT( FT_Error ) + FT_Get_Var_Design_Coordinates( FT_Face face, + FT_UInt num_coords, + FT_Fixed* coords ); + + /*************************************************************************/ /* */ /* <Function> */ /* FT_Set_MM_Blend_Coordinates */ /* */ /* <Description> */ - /* For Multiple Masters and GX var fonts, choose an interpolated font */ - /* design through normalized blend coordinates. */ + /* Choose an interpolated font design through normalized blend */ + /* coordinates. */ + /* */ + /* This function works with all supported variation formats. */ /* */ /* <InOut> */ /* face :: A handle to the source face. */ @@ -349,7 +408,9 @@ FT_BEGIN_HEADER /* use default values for the remaining axes. */ /* */ /* coords :: The design coordinates array (each element must be */ - /* between 0 and 1.0). */ + /* between 0 and 1.0 for Adobe MM fonts, and between */ + /* -1.0 and 1.0 for TrueType GX and OpenType variation */ + /* fonts). */ /* */ /* <Return> */ /* FreeType error code. 0~means success. */ @@ -360,6 +421,37 @@ FT_BEGIN_HEADER FT_Fixed* coords ); + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_Get_MM_Blend_Coordinates */ + /* */ + /* <Description> */ + /* Get the normalized blend coordinates of the currently selected */ + /* interpolated font. */ + /* */ + /* This function works with all supported variation formats. */ + /* */ + /* <Input> */ + /* face :: A handle to the source face. */ + /* */ + /* num_coords :: The number of normalized blend coordinates to */ + /* retrieve. If it is larger than the number of axes, */ + /* set the excess values to~0.5 for Adobe MM fonts, and */ + /* to~0 for TrueType GX and OpenType variation fonts. */ + /* */ + /* <Output> */ + /* coords :: The normalized blend coordinates array. */ + /* */ + /* <Return> */ + /* FreeType error code. 0~means success. */ + /* */ + FT_EXPORT( FT_Error ) + FT_Get_MM_Blend_Coordinates( FT_Face face, + FT_UInt num_coords, + FT_Fixed* coords ); + + /*************************************************************************/ /* */ /* <Function> */ @@ -373,6 +465,20 @@ FT_BEGIN_HEADER FT_UInt num_coords, FT_Fixed* coords ); + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_Get_Var_Blend_Coordinates */ + /* */ + /* <Description> */ + /* This is another name of @FT_Get_MM_Blend_Coordinates. */ + /* */ + FT_EXPORT( FT_Error ) + FT_Get_Var_Blend_Coordinates( FT_Face face, + FT_UInt num_coords, + FT_Fixed* coords ); + /* */ diff --git a/thirdparty/freetype/include/freetype/ftmodapi.h b/thirdparty/freetype/include/freetype/ftmodapi.h index b4d2758efa..4147aadf8b 100644 --- a/thirdparty/freetype/include/freetype/ftmodapi.h +++ b/thirdparty/freetype/include/freetype/ftmodapi.h @@ -4,7 +4,7 @@ /* */ /* FreeType modules public interface (specification). */ /* */ -/* Copyright 1996-2016 by */ +/* Copyright 1996-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -89,6 +89,7 @@ FT_BEGIN_HEADER /* */ /* FT_Property_Set */ /* FT_Property_Get */ + /* FT_Set_Default_Properties */ /* */ /* FT_New_Library */ /* FT_Done_Library */ @@ -437,6 +438,47 @@ FT_BEGIN_HEADER void* value ); + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_Set_Default_Properties */ + /* */ + /* <Description> */ + /* If compilation option FT_CONFIG_OPTION_ENVIRONMENT_PROPERTIES is */ + /* set, this function reads the `FREETYPE_PROPERTIES' environment */ + /* variable to control driver properties. See sections @auto_hinter, */ + /* @cff_driver, @pcf_driver, and @tt_driver for more. */ + /* */ + /* If the compilation option is not set, this function does nothing. */ + /* */ + /* `FREETYPE_PROPERTIES' has the following syntax form (broken here */ + /* into multiple lines for better readability). */ + /* */ + /* { */ + /* <optional whitespace> */ + /* <module-name1> ':' */ + /* <property-name1> '=' <property-value1> */ + /* <whitespace> */ + /* <module-name2> ':' */ + /* <property-name2> '=' <property-value2> */ + /* ... */ + /* } */ + /* */ + /* Example: */ + /* */ + /* { */ + /* FREETYPE_PROPERTIES=truetype:interpreter-version=35 \ */ + /* cff:no-stem-darkening=1 \ */ + /* autofitter:warping=1 */ + /* } */ + /* */ + /* <InOut> */ + /* library :: A handle to a new library object. */ + /* */ + FT_EXPORT( void ) + FT_Set_Default_Properties( FT_Library library ); + + /*************************************************************************/ /* */ /* <Function> */ @@ -477,8 +519,9 @@ FT_BEGIN_HEADER /* valid for the life of the @FT_Library object. */ /* */ /* Normally, you would call this function (followed by a call to */ - /* @FT_Add_Default_Modules or a series of calls to @FT_Add_Module) */ - /* instead of @FT_Init_FreeType to initialize the FreeType library. */ + /* @FT_Add_Default_Modules or a series of calls to @FT_Add_Module, */ + /* and a call to @FT_Set_Default_Properties) instead of */ + /* @FT_Init_FreeType to initialize the FreeType library. */ /* */ /* Don't use @FT_Done_FreeType but @FT_Done_Library to destroy a */ /* library instance. */ diff --git a/thirdparty/freetype/include/freetype/ftmoderr.h b/thirdparty/freetype/include/freetype/ftmoderr.h index 2a7671c816..7f608375e8 100644 --- a/thirdparty/freetype/include/freetype/ftmoderr.h +++ b/thirdparty/freetype/include/freetype/ftmoderr.h @@ -4,7 +4,7 @@ /* */ /* FreeType module error offsets (specification). */ /* */ -/* Copyright 2001-2016 by */ +/* Copyright 2001-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/thirdparty/freetype/include/freetype/ftotval.h b/thirdparty/freetype/include/freetype/ftotval.h index 3e6e18d8a6..b5d27cfe74 100644 --- a/thirdparty/freetype/include/freetype/ftotval.h +++ b/thirdparty/freetype/include/freetype/ftotval.h @@ -4,7 +4,7 @@ /* */ /* FreeType API for validating OpenType tables (specification). */ /* */ -/* Copyright 2004-2016 by */ +/* Copyright 2004-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/thirdparty/freetype/include/freetype/ftoutln.h b/thirdparty/freetype/include/freetype/ftoutln.h index 6a6451207c..07f73ebb1b 100644 --- a/thirdparty/freetype/include/freetype/ftoutln.h +++ b/thirdparty/freetype/include/freetype/ftoutln.h @@ -5,7 +5,7 @@ /* Support for the FT_Outline type used to store glyph shapes of */ /* most scalable font formats (specification). */ /* */ -/* Copyright 1996-2016 by */ +/* Copyright 1996-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -115,6 +115,10 @@ FT_BEGIN_HEADER /* outline for stroking purposes (otherwise it would result in a */ /* visible dot when round caps are used). */ /* */ + /* Similarly, the function returns success for an empty outline also */ + /* (doing nothing, this is, not calling any emitter); if necessary, */ + /* you should filter this out, too. */ + /* */ FT_EXPORT( FT_Error ) FT_Outline_Decompose( FT_Outline* outline, const FT_Outline_Funcs* func_interface, @@ -213,6 +217,10 @@ FT_BEGIN_HEADER /* <Return> */ /* FreeType error code. 0~means success. */ /* */ + /* <Note> */ + /* An empty outline, or an outline with a single point only is also */ + /* valid. */ + /* */ FT_EXPORT( FT_Error ) FT_Outline_Check( FT_Outline* outline ); diff --git a/thirdparty/freetype/include/freetype/ftpcfdrv.h b/thirdparty/freetype/include/freetype/ftpcfdrv.h new file mode 100644 index 0000000000..6622c936fb --- /dev/null +++ b/thirdparty/freetype/include/freetype/ftpcfdrv.h @@ -0,0 +1,105 @@ +/***************************************************************************/ +/* */ +/* ftpcfdrv.h */ +/* */ +/* FreeType API for controlling the PCF driver (specification only). */ +/* */ +/* Copyright 2017 by */ +/* David Turner, Robert Wilhelm, and Werner Lemberg. */ +/* */ +/* This file is part of the FreeType project, and may only be used, */ +/* modified, and distributed under the terms of the FreeType project */ +/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ +/* this file you indicate that you have read the license and */ +/* understand and accept it fully. */ +/* */ +/***************************************************************************/ + + +#ifndef FTPCFDRV_H_ +#define FTPCFDRV_H_ + +#include <ft2build.h> +#include FT_FREETYPE_H + +#ifdef FREETYPE_H +#error "freetype.h of FreeType 1 has been loaded!" +#error "Please fix the directory search order for header files" +#error "so that freetype.h of FreeType 2 is found first." +#endif + + +FT_BEGIN_HEADER + + + /************************************************************************** + * + * @section: + * pcf_driver + * + * @title: + * The PCF driver + * + * @abstract: + * Controlling the PCF driver module. + * + * @description: + * While FreeType's PCF driver doesn't expose API functions by itself, + * it is possible to control its behaviour with @FT_Property_Set and + * @FT_Property_Get. Right now, there is a single property + * `no-long-family-names' available if FreeType is compiled with + * PCF_CONFIG_OPTION_LONG_FAMILY_NAMES. + * + * The PCF driver's module name is `pcf'. + * + */ + + + /************************************************************************** + * + * @property: + * no-long-family-names + * + * @description: + * If PCF_CONFIG_OPTION_LONG_FAMILY_NAMES is active while compiling + * FreeType, the PCF driver constructs long family names. + * + * There are many PCF fonts just called `Fixed' which look completely + * different, and which have nothing to do with each other. When + * selecting `Fixed' in KDE or Gnome one gets results that appear rather + * random, the style changes often if one changes the size and one + * cannot select some fonts at all. The improve this situation, the PCF + * module prepends the foundry name (plus a space) to the family name. + * It also checks whether there are `wide' characters; all put together, + * family names like `Sony Fixed' or `Misc Fixed Wide' are constructed. + * + * If `no-long-family-names' is set, this feature gets switched off. + * + * { + * FT_Library library; + * FT_Bool no_long_family_names = TRUE; + * + * + * FT_Init_FreeType( &library ); + * + * FT_Property_Set( library, "pcf", + * "no-long-family-names", + * &no_long_family_names ); + * } + * + * @note: + * This property can be used with @FT_Property_Get also. + * + * This property can be set via the `FREETYPE_PROPERTIES' environment + * variable (using values 1 and 0 for `on' and `off', respectively). + * + */ + + +FT_END_HEADER + + +#endif /* FTPCFDRV_H_ */ + + +/* END */ diff --git a/thirdparty/freetype/include/freetype/ftpfr.h b/thirdparty/freetype/include/freetype/ftpfr.h index 2e1bff2f67..f2a6ae9349 100644 --- a/thirdparty/freetype/include/freetype/ftpfr.h +++ b/thirdparty/freetype/include/freetype/ftpfr.h @@ -4,7 +4,7 @@ /* */ /* FreeType API for accessing PFR-specific data (specification only). */ /* */ -/* Copyright 2002-2016 by */ +/* Copyright 2002-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/thirdparty/freetype/include/freetype/ftrender.h b/thirdparty/freetype/include/freetype/ftrender.h index 9f7ed9e9d9..960837580a 100644 --- a/thirdparty/freetype/include/freetype/ftrender.h +++ b/thirdparty/freetype/include/freetype/ftrender.h @@ -4,7 +4,7 @@ /* */ /* FreeType renderer modules public interface (specification). */ /* */ -/* Copyright 1996-2016 by */ +/* Copyright 1996-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -75,6 +75,7 @@ FT_BEGIN_HEADER { FT_Long glyph_size; FT_Glyph_Format glyph_format; + FT_Glyph_InitFunc glyph_init; FT_Glyph_DoneFunc glyph_done; FT_Glyph_CopyFunc glyph_copy; diff --git a/thirdparty/freetype/include/freetype/ftsizes.h b/thirdparty/freetype/include/freetype/ftsizes.h index 55e0d5ccfd..2f3958a857 100644 --- a/thirdparty/freetype/include/freetype/ftsizes.h +++ b/thirdparty/freetype/include/freetype/ftsizes.h @@ -4,7 +4,7 @@ /* */ /* FreeType size objects management (specification). */ /* */ -/* Copyright 1996-2016 by */ +/* Copyright 1996-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/thirdparty/freetype/include/freetype/ftsnames.h b/thirdparty/freetype/include/freetype/ftsnames.h index a7b51c2cba..a316540576 100644 --- a/thirdparty/freetype/include/freetype/ftsnames.h +++ b/thirdparty/freetype/include/freetype/ftsnames.h @@ -2,12 +2,12 @@ /* */ /* ftsnames.h */ /* */ -/* Simple interface to access SFNT name tables (which are used */ +/* Simple interface to access SFNT `name' tables (which are used */ /* to hold font names, copyright info, notices, etc.) (specification). */ /* */ /* This is _not_ used to retrieve glyph names! */ /* */ -/* Copyright 1996-2016 by */ +/* Copyright 1996-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -49,7 +49,7 @@ FT_BEGIN_HEADER /* */ /* <Description> */ /* The TrueType and OpenType specifications allow the inclusion of */ - /* a special `names table' in font files. This table contains */ + /* a special names table (`name') in font files. This table contains */ /* textual (and internationalized) information regarding the font, */ /* like family name, copyright, version, etc. */ /* */ @@ -70,30 +70,37 @@ FT_BEGIN_HEADER /* */ /* <Fields> */ /* platform_id :: The platform ID for `string'. */ + /* See @TT_PLATFORM_XXX for possible values. */ /* */ /* encoding_id :: The encoding ID for `string'. */ + /* See @TT_APPLE_ID_XXX, @TT_MAC_ID_XXX, */ + /* @TT_ISO_ID_XXX, @TT_MS_ID_XXX, and @TT_ADOBE_ID_XXX */ + /* for possible values. */ /* */ /* language_id :: The language ID for `string'. */ + /* See @TT_MAC_LANGID_XXX and @TT_MS_LANGID_XXX for */ + /* possible values. */ + /* */ + /* Registered OpenType values for `language_id' are */ + /* always smaller than 0x8000; values equal or larger */ + /* than 0x8000 usually indicate a language tag string */ + /* (introduced in OpenType version 1.6). Use function */ + /* @FT_Get_Sfnt_LangTag with `language_id' as its */ + /* argument to retrieve the associated language tag. */ /* */ /* name_id :: An identifier for `string'. */ + /* See @TT_NAME_ID_XXX for possible values. */ /* */ /* string :: The `name' string. Note that its format differs */ - /* depending on the (platform,encoding) pair. It can */ - /* be a Pascal String, a UTF-16 one, etc. */ - /* */ - /* Generally speaking, the string is not */ - /* zero-terminated. Please refer to the TrueType */ - /* specification for details. */ + /* depending on the (platform,encoding) pair, being */ + /* either a string of bytes (without a terminating */ + /* NULL byte) or containing UTF-16BE entities. */ /* */ /* string_len :: The length of `string' in bytes. */ /* */ /* <Note> */ - /* Possible values for `platform_id', `encoding_id', `language_id', */ - /* and `name_id' are given in the file `ttnameid.h'. For details */ - /* please refer to the TrueType or OpenType specification. */ - /* */ - /* See also @TT_PLATFORM_XXX, @TT_APPLE_ID_XXX, @TT_MAC_ID_XXX, */ - /* @TT_ISO_ID_XXX, and @TT_MS_ID_XXX. */ + /* Please refer to the TrueType or OpenType specification for more */ + /* details. */ /* */ typedef struct FT_SfntName_ { @@ -103,7 +110,7 @@ FT_BEGIN_HEADER FT_UShort name_id; FT_Byte* string; /* this string is *not* null-terminated! */ - FT_UInt string_len; /* in bytes */ + FT_UInt string_len; /* in bytes */ } FT_SfntName; @@ -147,47 +154,127 @@ FT_BEGIN_HEADER /* */ /* <Note> */ /* The `string' array returned in the `aname' structure is not */ - /* null-terminated. The application should deallocate it if it is no */ - /* longer in use. */ + /* null-terminated. Note that you don't have to deallocate `string' */ + /* by yourself; FreeType takes care of it if you call @FT_Done_Face. */ /* */ /* Use @FT_Get_Sfnt_Name_Count to get the total number of available */ /* `name' table entries, then do a loop until you get the right */ /* platform, encoding, and name ID. */ /* */ + /* `name' table format~1 entries can use language tags also, see */ + /* @FT_Get_Sfnt_LangTag. */ + /* */ FT_EXPORT( FT_Error ) FT_Get_Sfnt_Name( FT_Face face, FT_UInt idx, FT_SfntName *aname ); + /*************************************************************************/ + /* */ + /* <Struct> */ + /* FT_SfntLangTag */ + /* */ + /* <Description> */ + /* A structure to model a language tag entry from an SFNT `name' */ + /* table. */ + /* */ + /* <Fields> */ + /* string :: The language tag string, encoded in UTF-16BE */ + /* (without trailing NULL bytes). */ + /* */ + /* string_len :: The length of `string' in *bytes*. */ + /* */ + /* <Note> */ + /* Please refer to the TrueType or OpenType specification for more */ + /* details. */ + /* */ + typedef struct FT_SfntLangTag_ + { + FT_Byte* string; /* this string is *not* null-terminated! */ + FT_UInt string_len; /* in bytes */ + + } FT_SfntLangTag; + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_Get_Sfnt_LangTag */ + /* */ + /* <Description> */ + /* Retrieve the language tag associated with a language ID of an SFNT */ + /* `name' table entry. */ + /* */ + /* <Input> */ + /* face :: A handle to the source face. */ + /* */ + /* langID :: The language ID, as returned by @FT_Get_Sfnt_Name. */ + /* This is always a value larger than 0x8000. */ + /* */ + /* <Output> */ + /* alangTag :: The language tag associated with the `name' table */ + /* entry's language ID. */ + /* */ + /* <Return> */ + /* FreeType error code. 0~means success. */ + /* */ + /* <Note> */ + /* The `string' array returned in the `alangTag' structure is not */ + /* null-terminated. Note that you don't have to deallocate `string' */ + /* by yourself; FreeType takes care of it if you call @FT_Done_Face. */ + /* */ + /* Only `name' table format~1 supports language tags. For format~0 */ + /* tables, this function always returns FT_Err_Invalid_Table. For */ + /* invalid format~1 language ID values, FT_Err_Invalid_Argument is */ + /* returned. */ + /* */ + FT_EXPORT( FT_Error ) + FT_Get_Sfnt_LangTag( FT_Face face, + FT_UInt langID, + FT_SfntLangTag *alangTag ); + + /*************************************************************************** * * @constant: - * FT_PARAM_TAG_IGNORE_PREFERRED_FAMILY + * FT_PARAM_TAG_IGNORE_TYPOGRAPHIC_FAMILY * * @description: - * A constant used as the tag of @FT_Parameter structures to make - * FT_Open_Face() ignore preferred family subfamily names in `name' - * table since OpenType version 1.4. For backwards compatibility with - * legacy systems that have a 4-face-per-family restriction. + * A tag for @FT_Parameter to make @FT_Open_Face ignore typographic + * family names in the `name' table (introduced in OpenType version + * 1.4). Use this for backward compatibility with legacy systems that + * have a four-faces-per-family restriction. * */ -#define FT_PARAM_TAG_IGNORE_PREFERRED_FAMILY FT_MAKE_TAG( 'i', 'g', 'p', 'f' ) +#define FT_PARAM_TAG_IGNORE_TYPOGRAPHIC_FAMILY \ + FT_MAKE_TAG( 'i', 'g', 'p', 'f' ) + + + /* this constant is deprecated */ +#define FT_PARAM_TAG_IGNORE_PREFERRED_FAMILY \ + FT_PARAM_TAG_IGNORE_TYPOGRAPHIC_FAMILY /*************************************************************************** * * @constant: - * FT_PARAM_TAG_IGNORE_PREFERRED_SUBFAMILY + * FT_PARAM_TAG_IGNORE_TYPOGRAPHIC_SUBFAMILY * * @description: - * A constant used as the tag of @FT_Parameter structures to make - * FT_Open_Face() ignore preferred subfamily names in `name' table since - * OpenType version 1.4. For backwards compatibility with legacy - * systems that have a 4-face-per-family restriction. + * A tag for @FT_Parameter to make @FT_Open_Face ignore typographic + * subfamily names in the `name' table (introduced in OpenType version + * 1.4). Use this for backward compatibility with legacy systems that + * have a four-faces-per-family restriction. * */ -#define FT_PARAM_TAG_IGNORE_PREFERRED_SUBFAMILY FT_MAKE_TAG( 'i', 'g', 'p', 's' ) +#define FT_PARAM_TAG_IGNORE_TYPOGRAPHIC_SUBFAMILY \ + FT_MAKE_TAG( 'i', 'g', 'p', 's' ) + + + /* this constant is deprecated */ +#define FT_PARAM_TAG_IGNORE_PREFERRED_SUBFAMILY \ + FT_PARAM_TAG_IGNORE_TYPOGRAPHIC_SUBFAMILY /* */ diff --git a/thirdparty/freetype/include/freetype/ftstroke.h b/thirdparty/freetype/include/freetype/ftstroke.h index b3b9922dad..4a20667c5e 100644 --- a/thirdparty/freetype/include/freetype/ftstroke.h +++ b/thirdparty/freetype/include/freetype/ftstroke.h @@ -4,7 +4,7 @@ /* */ /* FreeType path stroker (specification). */ /* */ -/* Copyright 2002-2016 by */ +/* Copyright 2002-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -136,7 +136,7 @@ FT_BEGIN_HEADER * FT_STROKER_LINEJOIN_MITER_VARIABLE generates a mitered line * join as used in XPS. FT_STROKER_LINEJOIN_MITER is an alias * for FT_STROKER_LINEJOIN_MITER_VARIABLE, retained for - * backwards compatibility. + * backward compatibility. */ typedef enum FT_Stroker_LineJoin_ { diff --git a/thirdparty/freetype/include/freetype/ftsynth.h b/thirdparty/freetype/include/freetype/ftsynth.h index fdfcb6912b..1863fa2383 100644 --- a/thirdparty/freetype/include/freetype/ftsynth.h +++ b/thirdparty/freetype/include/freetype/ftsynth.h @@ -5,7 +5,7 @@ /* FreeType synthesizing code for emboldening and slanting */ /* (specification). */ /* */ -/* Copyright 2000-2016 by */ +/* Copyright 2000-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/thirdparty/freetype/include/freetype/ftsystem.h b/thirdparty/freetype/include/freetype/ftsystem.h index a75f958022..1aa4762ad6 100644 --- a/thirdparty/freetype/include/freetype/ftsystem.h +++ b/thirdparty/freetype/include/freetype/ftsystem.h @@ -4,7 +4,7 @@ /* */ /* FreeType low-level system interface definition (specification). */ /* */ -/* Copyright 1996-2016 by */ +/* Copyright 1996-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/thirdparty/freetype/include/freetype/fttrigon.h b/thirdparty/freetype/include/freetype/fttrigon.h index f789b524cb..89f0350675 100644 --- a/thirdparty/freetype/include/freetype/fttrigon.h +++ b/thirdparty/freetype/include/freetype/fttrigon.h @@ -4,7 +4,7 @@ /* */ /* FreeType trigonometric functions (specification). */ /* */ -/* Copyright 2001-2016 by */ +/* Copyright 2001-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/thirdparty/freetype/include/freetype/ftttdrv.h b/thirdparty/freetype/include/freetype/ftttdrv.h index 0d868bc259..26bc5e966a 100644 --- a/thirdparty/freetype/include/freetype/ftttdrv.h +++ b/thirdparty/freetype/include/freetype/ftttdrv.h @@ -5,7 +5,7 @@ /* FreeType API for controlling the TrueType driver */ /* (specification only). */ /* */ -/* Copyright 2013-2016 by */ +/* Copyright 2013-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -110,7 +110,7 @@ FT_BEGIN_HEADER * TrueType interpreter fully allows the advance width to be adjusted in * this mode, just the DWrite client will ignore those changes. * - * _ClearType_ _Backwards_ _Compatibility_ + * _ClearType_ _Backward_ _Compatibility_ * * This is a set of exceptions made in the TrueType interpreter to * minimize hinting techniques that were problematic with the extra @@ -118,9 +118,9 @@ FT_BEGIN_HEADER * http://www.beatstamm.com/typography/RTRCh4.htm#Sec1 and * http://www.microsoft.com/typography/cleartype/truetypecleartype.aspx. * This technique is not to be confused with ClearType compatible - * widths. ClearType backwards compatibility has no direct impact on + * widths. ClearType backward compatibility has no direct impact on * changing advance widths, but there might be an indirect impact on - * disabling some deltas. This could be worked around in backwards + * disabling some deltas. This could be worked around in backward * compatibility mode. * * _Native_ _ClearType_ _Mode_ @@ -138,7 +138,6 @@ FT_BEGIN_HEADER * interpreter-version * * @description: - * Currently, three versions are available, two representing the * bytecode interpreter with subpixel hinting support (old `Infinality' * code and new stripped-down and higher performance `minimal' code) and @@ -181,6 +180,8 @@ FT_BEGIN_HEADER * @note: * This property can be used with @FT_Property_Get also. * + * This property can be set via the `FREETYPE_PROPERTIES' environment + * variable (using values `35', `38', or `40'). */ @@ -224,7 +225,7 @@ FT_BEGIN_HEADER * filtering. * * If FreeType has not been compiled with the configuration option - * FT_CONFIG_OPTION_SUBPIXEL_HINTING, selecting version~38 or~40 causes + * TT_CONFIG_OPTION_SUBPIXEL_HINTING, selecting version~38 or~40 causes * an `FT_Err_Unimplemented_Feature' error. * * Depending on the graphics framework, Microsoft uses different diff --git a/thirdparty/freetype/include/freetype/fttypes.h b/thirdparty/freetype/include/freetype/fttypes.h index 2673e79c3c..eab8adaad4 100644 --- a/thirdparty/freetype/include/freetype/fttypes.h +++ b/thirdparty/freetype/include/freetype/fttypes.h @@ -4,7 +4,7 @@ /* */ /* FreeType simple types definitions (specification only). */ /* */ -/* Copyright 1996-2016 by */ +/* Copyright 1996-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/thirdparty/freetype/include/freetype/ftwinfnt.h b/thirdparty/freetype/include/freetype/ftwinfnt.h index a1a715baa1..1eeef6c8ba 100644 --- a/thirdparty/freetype/include/freetype/ftwinfnt.h +++ b/thirdparty/freetype/include/freetype/ftwinfnt.h @@ -4,7 +4,7 @@ /* */ /* FreeType API for accessing Windows fnt-specific data. */ /* */ -/* Copyright 2003-2016 by */ +/* Copyright 2003-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/thirdparty/freetype/include/freetype/internal/autohint.h b/thirdparty/freetype/include/freetype/internal/autohint.h index 7ef82b8f3c..bae83e7384 100644 --- a/thirdparty/freetype/include/freetype/internal/autohint.h +++ b/thirdparty/freetype/include/freetype/internal/autohint.h @@ -4,7 +4,7 @@ /* */ /* High-level `autohint' module-specific interface (specification). */ /* */ -/* Copyright 1996-2016 by */ +/* Copyright 1996-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/thirdparty/freetype/include/freetype/internal/ftcalc.h b/thirdparty/freetype/include/freetype/internal/ftcalc.h index 8a884f680a..c9ac9d8246 100644 --- a/thirdparty/freetype/include/freetype/internal/ftcalc.h +++ b/thirdparty/freetype/include/freetype/internal/ftcalc.h @@ -4,7 +4,7 @@ /* */ /* Arithmetic computations (specification). */ /* */ -/* Copyright 1996-2016 by */ +/* Copyright 1996-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/thirdparty/freetype/include/freetype/internal/ftdebug.h b/thirdparty/freetype/include/freetype/internal/ftdebug.h index d110457157..5dcd2b1740 100644 --- a/thirdparty/freetype/include/freetype/internal/ftdebug.h +++ b/thirdparty/freetype/include/freetype/internal/ftdebug.h @@ -4,7 +4,7 @@ /* */ /* Debugging and logging component (specification). */ /* */ -/* Copyright 1996-2016 by */ +/* Copyright 1996-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/thirdparty/freetype/include/freetype/internal/ftdriver.h b/thirdparty/freetype/include/freetype/internal/ftdriver.h index 3e1e66e979..e82fa8d41f 100644 --- a/thirdparty/freetype/include/freetype/internal/ftdriver.h +++ b/thirdparty/freetype/include/freetype/internal/ftdriver.h @@ -4,7 +4,7 @@ /* */ /* FreeType font driver interface (specification). */ /* */ -/* Copyright 1996-2016 by */ +/* Copyright 1996-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -67,15 +67,6 @@ FT_BEGIN_HEADER FT_Int32 load_flags ); - typedef FT_UInt - (*FT_CharMap_CharIndexFunc)( FT_CharMap charmap, - FT_Long charcode ); - - typedef FT_Long - (*FT_CharMap_CharNextFunc)( FT_CharMap charmap, - FT_Long charcode ); - - typedef FT_Error (*FT_Face_GetKerningFunc)( FT_Face face, FT_UInt left_glyph, diff --git a/thirdparty/freetype/include/freetype/internal/ftgloadr.h b/thirdparty/freetype/include/freetype/internal/ftgloadr.h index bebf5dbba2..f41c3df554 100644 --- a/thirdparty/freetype/include/freetype/internal/ftgloadr.h +++ b/thirdparty/freetype/include/freetype/internal/ftgloadr.h @@ -4,7 +4,7 @@ /* */ /* The FreeType glyph loader (specification). */ /* */ -/* Copyright 2002-2016 by */ +/* Copyright 2002-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/thirdparty/freetype/include/freetype/internal/ftmemory.h b/thirdparty/freetype/include/freetype/internal/ftmemory.h index 8c06fc21a5..59e5b58a57 100644 --- a/thirdparty/freetype/include/freetype/internal/ftmemory.h +++ b/thirdparty/freetype/include/freetype/internal/ftmemory.h @@ -4,7 +4,7 @@ /* */ /* The FreeType memory management macros (specification). */ /* */ -/* Copyright 1996-2016 by */ +/* Copyright 1996-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -108,10 +108,12 @@ extern "C++" /* * The allocation functions return a pointer, and the error code - * is written to through the `p_error' parameter. See below for - * for documentation. + * is written to through the `p_error' parameter. */ + /* The `q' variants of the functions below (`q' for `quick') don't fill */ + /* the allocated or reallocated memory with zero bytes. */ + FT_BASE( FT_Pointer ) ft_mem_alloc( FT_Memory memory, FT_Long size, @@ -143,6 +145,9 @@ extern "C++" const void* P ); + /* The `Q' variants of the macros below (`Q' for `quick') don't fill */ + /* the allocated or reallocated memory with zero bytes. */ + #define FT_MEM_ALLOC( ptr, size ) \ FT_ASSIGNP_INNER( ptr, ft_mem_alloc( memory, \ (FT_Long)(size), \ diff --git a/thirdparty/freetype/include/freetype/internal/ftobjs.h b/thirdparty/freetype/include/freetype/internal/ftobjs.h index e3fa32083b..558409166d 100644 --- a/thirdparty/freetype/include/freetype/internal/ftobjs.h +++ b/thirdparty/freetype/include/freetype/internal/ftobjs.h @@ -4,7 +4,7 @@ /* */ /* The FreeType private base classes (specification). */ /* */ -/* Copyright 1996-2016 by */ +/* Copyright 1996-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -193,6 +193,7 @@ FT_BEGIN_HEADER typedef struct FT_CMap_ClassRec_ { FT_ULong size; + FT_CMap_InitFunc init; FT_CMap_DoneFunc done; FT_CMap_CharIndexFunc char_index; @@ -341,6 +342,20 @@ FT_BEGIN_HEADER /* this data when first opened. This field exists only if */ /* @FT_CONFIG_OPTION_INCREMENTAL is defined. */ /* */ + /* no_stem_darkening :: */ + /* Overrides the module-level default, see @stem-darkening[cff], */ + /* for example. FALSE and TRUE toggle stem darkening on and off, */ + /* respectively, value~-1 means to use the module/driver default. */ + /* */ + /* random_seed :: */ + /* If positive, override the seed value for the CFF `random' */ + /* operator. Value~0 means to use the font's value. Value~-1 */ + /* means to use the CFF driver's default. */ + /* */ + /* lcd_weights :: */ + /* Overrides the library default with custom weights for the 5-tap */ + /* FIR filter. `{0, 0, 0, 0, 0}' means to use the library default. */ + /* */ /* refcount :: */ /* A counter initialized to~1 at the time an @FT_Face structure is */ /* created. @FT_Reference_Face increments this counter, and */ @@ -349,9 +364,9 @@ FT_BEGIN_HEADER /* */ typedef struct FT_Face_InternalRec_ { - FT_Matrix transform_matrix; - FT_Vector transform_delta; - FT_Int transform_flags; + FT_Matrix transform_matrix; + FT_Vector transform_delta; + FT_Int transform_flags; FT_ServiceCacheRec services; @@ -359,7 +374,13 @@ FT_BEGIN_HEADER FT_Incremental_InterfaceRec* incremental_interface; #endif - FT_Int refcount; + FT_Char no_stem_darkening; + FT_Int32 random_seed; +#ifdef FT_CONFIG_OPTION_SUBPIXEL_RENDERING + FT_LcdFiveTapFilter lcd_weights; /* preset or custom filter weights */ +#endif + + FT_Int refcount; } FT_Face_InternalRec; @@ -412,8 +433,6 @@ FT_BEGIN_HEADER } FT_GlyphSlot_InternalRec; -#if 0 - /*************************************************************************/ /* */ /* <Struct> */ @@ -421,17 +440,25 @@ FT_BEGIN_HEADER /* */ /* <Description> */ /* This structure contains the internal fields of each FT_Size */ - /* object. Currently, it's empty. */ + /* object. */ + /* */ + /* <Fields> */ + /* module_data :: Data specific to a driver module. */ + /* */ + /* autohint_mode :: The used auto-hinting mode. */ + /* */ + /* autohint_metrics :: Metrics used by the auto-hinter. */ /* */ /*************************************************************************/ typedef struct FT_Size_InternalRec_ { - /* empty */ + void* module_data; - } FT_Size_InternalRec; + FT_Render_Mode autohint_mode; + FT_Size_Metrics autohint_metrics; -#endif + } FT_Size_InternalRec; /*************************************************************************/ @@ -530,7 +557,16 @@ FT_BEGIN_HEADER FT_BASE( FT_Pointer ) ft_module_get_service( FT_Module module, - const char* service_id ); + const char* service_id, + FT_Bool global ); + +#ifdef FT_CONFIG_OPTION_ENVIRONMENT_PROPERTIES + FT_BASE( FT_Error ) + ft_property_string_set( FT_Library library, + const FT_String* module_name, + const FT_String* property_name, + FT_String* value ); +#endif /* */ @@ -765,12 +801,19 @@ FT_BEGIN_HEADER /* This hook is used by the TrueType debugger. It must be set to an */ /* alternate truetype bytecode interpreter function. */ -#define FT_DEBUG_HOOK_TRUETYPE 0 +#define FT_DEBUG_HOOK_TRUETYPE 0 typedef void (*FT_Bitmap_LcdFilterFunc)( FT_Bitmap* bitmap, FT_Render_Mode render_mode, - FT_Library library ); + FT_Byte* weights ); + + + /* This is the default LCD filter, an in-place, 5-tap FIR filter. */ + FT_BASE( void ) + ft_lcd_filter_fir( FT_Bitmap* bitmap, + FT_Render_Mode mode, + FT_LcdFiveTapFilter weights ); /*************************************************************************/ @@ -811,14 +854,17 @@ FT_BEGIN_HEADER /* handle to the current renderer for the */ /* FT_GLYPH_FORMAT_OUTLINE format. */ /* */ - /* auto_hinter :: XXX */ + /* auto_hinter :: The auto-hinter module interface. */ /* */ /* raster_pool :: The raster object's render pool. This can */ /* ideally be changed dynamically at run-time. */ /* */ /* raster_pool_size :: The size of the render pool in bytes. */ /* */ - /* debug_hooks :: XXX */ + /* debug_hooks :: An array of four function pointers that allow */ + /* debuggers to hook into a font format's */ + /* interpreter. Currently, only the TrueType */ + /* bytecode debugger uses this. */ /* */ /* lcd_filter :: If subpixel rendering is activated, the */ /* selected LCD filter mode. */ @@ -866,7 +912,7 @@ FT_BEGIN_HEADER #ifdef FT_CONFIG_OPTION_SUBPIXEL_RENDERING FT_LcdFilter lcd_filter; FT_Int lcd_extra; /* number of extra pixels */ - FT_Byte lcd_weights[7]; /* filter weights, if any */ + FT_LcdFiveTapFilter lcd_weights; /* filter weights, if any */ FT_Bitmap_LcdFilterFunc lcd_filter_func; /* filtering callback */ #endif diff --git a/thirdparty/freetype/include/freetype/internal/ftpic.h b/thirdparty/freetype/include/freetype/internal/ftpic.h index 6d800a08a1..0d43ed20f7 100644 --- a/thirdparty/freetype/include/freetype/internal/ftpic.h +++ b/thirdparty/freetype/include/freetype/internal/ftpic.h @@ -4,7 +4,7 @@ /* */ /* The FreeType position independent code services (declaration). */ /* */ -/* Copyright 2009-2016 by */ +/* Copyright 2009-2017 by */ /* Oran Agra and Mickey Gabel. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/thirdparty/freetype/include/freetype/internal/ftrfork.h b/thirdparty/freetype/include/freetype/internal/ftrfork.h index b923401e68..25a44a4487 100644 --- a/thirdparty/freetype/include/freetype/internal/ftrfork.h +++ b/thirdparty/freetype/include/freetype/internal/ftrfork.h @@ -4,7 +4,7 @@ /* */ /* Embedded resource forks accessor (specification). */ /* */ -/* Copyright 2004-2016 by */ +/* Copyright 2004-2017 by */ /* Masatake YAMATO and Redhat K.K. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -43,11 +43,12 @@ FT_BEGIN_HEADER typedef struct FT_RFork_Ref_ { - FT_UShort res_id; - FT_Long offset; + FT_Short res_id; + FT_Long offset; } FT_RFork_Ref; + #ifdef FT_CONFIG_OPTION_GUESSING_EMBEDDED_RFORK typedef FT_Error (*ft_raccess_guess_func)( FT_Library library, diff --git a/thirdparty/freetype/include/freetype/internal/ftserv.h b/thirdparty/freetype/include/freetype/internal/ftserv.h index 91897177ba..71ef9cac3a 100644 --- a/thirdparty/freetype/include/freetype/internal/ftserv.h +++ b/thirdparty/freetype/include/freetype/internal/ftserv.h @@ -4,7 +4,7 @@ /* */ /* The FreeType services (specification only). */ /* */ -/* Copyright 2003-2016 by */ +/* Copyright 2003-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -109,27 +109,27 @@ FT_BEGIN_HEADER */ #ifdef __cplusplus -#define FT_FACE_FIND_GLOBAL_SERVICE( face, ptr, id ) \ - FT_BEGIN_STMNT \ - FT_Module module = FT_MODULE( FT_FACE( face )->driver ); \ - FT_Pointer _tmp_; \ - FT_Pointer* _pptr_ = (FT_Pointer*)&(ptr); \ - \ - \ - _tmp_ = ft_module_get_service( module, FT_SERVICE_ID_ ## id ); \ - *_pptr_ = _tmp_; \ +#define FT_FACE_FIND_GLOBAL_SERVICE( face, ptr, id ) \ + FT_BEGIN_STMNT \ + FT_Module module = FT_MODULE( FT_FACE( face )->driver ); \ + FT_Pointer _tmp_; \ + FT_Pointer* _pptr_ = (FT_Pointer*)&(ptr); \ + \ + \ + _tmp_ = ft_module_get_service( module, FT_SERVICE_ID_ ## id, 1 ); \ + *_pptr_ = _tmp_; \ FT_END_STMNT #else /* !C++ */ -#define FT_FACE_FIND_GLOBAL_SERVICE( face, ptr, id ) \ - FT_BEGIN_STMNT \ - FT_Module module = FT_MODULE( FT_FACE( face )->driver ); \ - FT_Pointer _tmp_; \ - \ - \ - _tmp_ = ft_module_get_service( module, FT_SERVICE_ID_ ## id ); \ - ptr = _tmp_; \ +#define FT_FACE_FIND_GLOBAL_SERVICE( face, ptr, id ) \ + FT_BEGIN_STMNT \ + FT_Module module = FT_MODULE( FT_FACE( face )->driver ); \ + FT_Pointer _tmp_; \ + \ + \ + _tmp_ = ft_module_get_service( module, FT_SERVICE_ID_ ## id, 1 ); \ + ptr = _tmp_; \ FT_END_STMNT #endif /* !C++ */ @@ -167,6 +167,7 @@ FT_BEGIN_HEADER /* FT_DEFINE_SERVICEDESCREC5 */ /* FT_DEFINE_SERVICEDESCREC6 */ /* FT_DEFINE_SERVICEDESCREC7 */ + /* FT_DEFINE_SERVICEDESCREC8 */ /* */ /* <Description> */ /* Used to initialize an array of FT_ServiceDescRec structures. */ @@ -283,6 +284,52 @@ FT_BEGIN_HEADER { NULL, NULL } \ }; +#define FT_DEFINE_SERVICEDESCREC8( class_, \ + serv_id_1, serv_data_1, \ + serv_id_2, serv_data_2, \ + serv_id_3, serv_data_3, \ + serv_id_4, serv_data_4, \ + serv_id_5, serv_data_5, \ + serv_id_6, serv_data_6, \ + serv_id_7, serv_data_7, \ + serv_id_8, serv_data_8 ) \ + static const FT_ServiceDescRec class_[] = \ + { \ + { serv_id_1, serv_data_1 }, \ + { serv_id_2, serv_data_2 }, \ + { serv_id_3, serv_data_3 }, \ + { serv_id_4, serv_data_4 }, \ + { serv_id_5, serv_data_5 }, \ + { serv_id_6, serv_data_6 }, \ + { serv_id_7, serv_data_7 }, \ + { serv_id_8, serv_data_8 }, \ + { NULL, NULL } \ + }; + +#define FT_DEFINE_SERVICEDESCREC9( class_, \ + serv_id_1, serv_data_1, \ + serv_id_2, serv_data_2, \ + serv_id_3, serv_data_3, \ + serv_id_4, serv_data_4, \ + serv_id_5, serv_data_5, \ + serv_id_6, serv_data_6, \ + serv_id_7, serv_data_7, \ + serv_id_8, serv_data_8, \ + serv_id_9, serv_data_9 ) \ + static const FT_ServiceDescRec class_[] = \ + { \ + { serv_id_1, serv_data_1 }, \ + { serv_id_2, serv_data_2 }, \ + { serv_id_3, serv_data_3 }, \ + { serv_id_4, serv_data_4 }, \ + { serv_id_5, serv_data_5 }, \ + { serv_id_6, serv_data_6 }, \ + { serv_id_7, serv_data_7 }, \ + { serv_id_8, serv_data_8 }, \ + { serv_id_9, serv_data_9 }, \ + { NULL, NULL } \ + }; + #else /* FT_CONFIG_OPTION_PIC */ #define FT_DEFINE_SERVICEDESCREC1( class_, \ @@ -593,6 +640,121 @@ FT_BEGIN_HEADER return FT_Err_Ok; \ } +#define FT_DEFINE_SERVICEDESCREC8( class_, \ + serv_id_1, serv_data_1, \ + serv_id_2, serv_data_2, \ + serv_id_3, serv_data_3, \ + serv_id_4, serv_data_4, \ + serv_id_5, serv_data_5, \ + serv_id_6, serv_data_6, \ + serv_id_7, serv_data_7, \ + serv_id_8, serv_data_8 ) \ + void \ + FT_Destroy_Class_ ## class_( FT_Library library, \ + FT_ServiceDescRec* clazz ) \ + { \ + FT_Memory memory = library->memory; \ + \ + \ + if ( clazz ) \ + FT_FREE( clazz ); \ + } \ + \ + FT_Error \ + FT_Create_Class_ ## class_( FT_Library library, \ + FT_ServiceDescRec** output_class) \ + { \ + FT_ServiceDescRec* clazz = NULL; \ + FT_Error error; \ + FT_Memory memory = library->memory; \ + \ + \ + if ( FT_ALLOC( clazz, sizeof ( *clazz ) * 9 ) ) \ + return error; \ + \ + clazz[0].serv_id = serv_id_1; \ + clazz[0].serv_data = serv_data_1; \ + clazz[1].serv_id = serv_id_2; \ + clazz[1].serv_data = serv_data_2; \ + clazz[2].serv_id = serv_id_3; \ + clazz[2].serv_data = serv_data_3; \ + clazz[3].serv_id = serv_id_4; \ + clazz[3].serv_data = serv_data_4; \ + clazz[4].serv_id = serv_id_5; \ + clazz[4].serv_data = serv_data_5; \ + clazz[5].serv_id = serv_id_6; \ + clazz[5].serv_data = serv_data_6; \ + clazz[6].serv_id = serv_id_7; \ + clazz[6].serv_data = serv_data_7; \ + clazz[7].serv_id = serv_id_8; \ + clazz[7].serv_data = serv_data_8; \ + clazz[8].serv_id = NULL; \ + clazz[8].serv_data = NULL; \ + \ + *output_class = clazz; \ + \ + return FT_Err_Ok; \ + } + +#define FT_DEFINE_SERVICEDESCREC9( class_, \ + serv_id_1, serv_data_1, \ + serv_id_2, serv_data_2, \ + serv_id_3, serv_data_3, \ + serv_id_4, serv_data_4, \ + serv_id_5, serv_data_5, \ + serv_id_6, serv_data_6, \ + serv_id_7, serv_data_7, \ + serv_id_8, serv_data_8, \ + serv_id_9, serv_data_9 ) \ + void \ + FT_Destroy_Class_ ## class_( FT_Library library, \ + FT_ServiceDescRec* clazz ) \ + { \ + FT_Memory memory = library->memory; \ + \ + \ + if ( clazz ) \ + FT_FREE( clazz ); \ + } \ + \ + FT_Error \ + FT_Create_Class_ ## class_( FT_Library library, \ + FT_ServiceDescRec** output_class) \ + { \ + FT_ServiceDescRec* clazz = NULL; \ + FT_Error error; \ + FT_Memory memory = library->memory; \ + \ + \ + if ( FT_ALLOC( clazz, sizeof ( *clazz ) * 10 ) ) \ + return error; \ + \ + clazz[0].serv_id = serv_id_1; \ + clazz[0].serv_data = serv_data_1; \ + clazz[1].serv_id = serv_id_2; \ + clazz[1].serv_data = serv_data_2; \ + clazz[2].serv_id = serv_id_3; \ + clazz[2].serv_data = serv_data_3; \ + clazz[3].serv_id = serv_id_4; \ + clazz[3].serv_data = serv_data_4; \ + clazz[4].serv_id = serv_id_5; \ + clazz[4].serv_data = serv_data_5; \ + clazz[5].serv_id = serv_id_6; \ + clazz[5].serv_data = serv_data_6; \ + clazz[6].serv_id = serv_id_7; \ + clazz[6].serv_data = serv_data_7; \ + clazz[7].serv_id = serv_id_8; \ + clazz[7].serv_data = serv_data_8; \ + clazz[8].serv_id = serv_id_9; \ + clazz[8].serv_data = serv_data_9; \ + clazz[9].serv_id = NULL; \ + clazz[9].serv_data = NULL; \ + \ + *output_class = clazz; \ + \ + return FT_Err_Ok; \ + } + #endif /* FT_CONFIG_OPTION_PIC */ @@ -635,6 +797,7 @@ FT_BEGIN_HEADER { FT_Pointer service_POSTSCRIPT_FONT_NAME; FT_Pointer service_MULTI_MASTERS; + FT_Pointer service_METRICS_VARIATIONS; FT_Pointer service_GLYPH_DICT; FT_Pointer service_PFR_METRICS; FT_Pointer service_WINFNT; @@ -655,7 +818,7 @@ FT_BEGIN_HEADER * FT_FACE_LOOKUP_SERVICE * * @description: - * This macro is used to lookup a service from a face's driver module + * This macro is used to look up a service from a face's driver module * using its cache. * * @input: @@ -739,6 +902,7 @@ FT_BEGIN_HEADER #define FT_SERVICE_GLYPH_DICT_H <freetype/internal/services/svgldict.h> #define FT_SERVICE_GX_VALIDATE_H <freetype/internal/services/svgxval.h> #define FT_SERVICE_KERNING_H <freetype/internal/services/svkern.h> +#define FT_SERVICE_METRICS_VARIATIONS_H <freetype/internal/services/svmetric.h> #define FT_SERVICE_MULTIPLE_MASTERS_H <freetype/internal/services/svmm.h> #define FT_SERVICE_OPENTYPE_VALIDATE_H <freetype/internal/services/svotval.h> #define FT_SERVICE_PFR_H <freetype/internal/services/svpfr.h> diff --git a/thirdparty/freetype/include/freetype/internal/ftstream.h b/thirdparty/freetype/include/freetype/internal/ftstream.h index 6d04875657..3e2c07b269 100644 --- a/thirdparty/freetype/include/freetype/internal/ftstream.h +++ b/thirdparty/freetype/include/freetype/internal/ftstream.h @@ -4,7 +4,7 @@ /* */ /* Stream handling (specification). */ /* */ -/* Copyright 1996-2016 by */ +/* Copyright 1996-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -502,7 +502,7 @@ FT_BEGIN_HEADER #define FT_STREAM_READ_AT( position, buffer, count ) \ FT_SET_ERROR( FT_Stream_ReadAt( stream, \ (FT_ULong)(position), \ - (FT_Byte*)buffer, \ + (FT_Byte*)(buffer), \ (FT_ULong)(count) ) ) #define FT_STREAM_READ_FIELDS( fields, object ) \ diff --git a/thirdparty/freetype/include/freetype/internal/fttrace.h b/thirdparty/freetype/include/freetype/internal/fttrace.h index efb3355954..caf5fc9460 100644 --- a/thirdparty/freetype/include/freetype/internal/fttrace.h +++ b/thirdparty/freetype/include/freetype/internal/fttrace.h @@ -4,7 +4,7 @@ /* */ /* Tracing handling (specification only). */ /* */ -/* Copyright 2002-2016 by */ +/* Copyright 2002-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/thirdparty/freetype/include/freetype/internal/ftvalid.h b/thirdparty/freetype/include/freetype/internal/ftvalid.h index aac92c9af8..df6f7c5778 100644 --- a/thirdparty/freetype/include/freetype/internal/ftvalid.h +++ b/thirdparty/freetype/include/freetype/internal/ftvalid.h @@ -4,7 +4,7 @@ /* */ /* FreeType validation support (specification). */ /* */ -/* Copyright 2004-2016 by */ +/* Copyright 2004-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/thirdparty/freetype/include/freetype/internal/internal.h b/thirdparty/freetype/include/freetype/internal/internal.h index 8c3c14c12a..02046813a3 100644 --- a/thirdparty/freetype/include/freetype/internal/internal.h +++ b/thirdparty/freetype/include/freetype/internal/internal.h @@ -4,7 +4,7 @@ /* */ /* Internal header files (specification only). */ /* */ -/* Copyright 1996-2016 by */ +/* Copyright 1996-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/thirdparty/freetype/include/freetype/internal/psaux.h b/thirdparty/freetype/include/freetype/internal/psaux.h index 15dedfd28e..935eb1a9c7 100644 --- a/thirdparty/freetype/include/freetype/internal/psaux.h +++ b/thirdparty/freetype/include/freetype/internal/psaux.h @@ -5,7 +5,7 @@ /* Auxiliary functions and data structures related to PostScript fonts */ /* (specification). */ /* */ -/* Copyright 1996-2016 by */ +/* Copyright 1996-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -817,7 +817,7 @@ FT_BEGIN_HEADER } PSAux_ServiceRec, *PSAux_Service; - /* backwards-compatible type definition */ + /* backward compatible type definition */ typedef PSAux_ServiceRec PSAux_Interface; diff --git a/thirdparty/freetype/include/freetype/internal/pshints.h b/thirdparty/freetype/include/freetype/internal/pshints.h index e60dc9cd55..49116eb443 100644 --- a/thirdparty/freetype/include/freetype/internal/pshints.h +++ b/thirdparty/freetype/include/freetype/internal/pshints.h @@ -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-2016 by */ +/* Copyright 2001-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/thirdparty/freetype/include/freetype/internal/services/svbdf.h b/thirdparty/freetype/include/freetype/internal/services/svbdf.h index c24475fc20..eeebf67da1 100644 --- a/thirdparty/freetype/include/freetype/internal/services/svbdf.h +++ b/thirdparty/freetype/include/freetype/internal/services/svbdf.h @@ -4,7 +4,7 @@ /* */ /* The FreeType BDF services (specification). */ /* */ -/* Copyright 2003-2016 by */ +/* Copyright 2003-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/thirdparty/freetype/include/freetype/internal/services/svcid.h b/thirdparty/freetype/include/freetype/internal/services/svcid.h index dbbe6044a4..cce94d8df6 100644 --- a/thirdparty/freetype/include/freetype/internal/services/svcid.h +++ b/thirdparty/freetype/include/freetype/internal/services/svcid.h @@ -4,7 +4,7 @@ /* */ /* The FreeType CID font services (specification). */ /* */ -/* Copyright 2007-2016 by */ +/* Copyright 2007-2017 by */ /* Derek Clegg and Michael Toftdal. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/thirdparty/freetype/include/freetype/internal/services/svfntfmt.h b/thirdparty/freetype/include/freetype/internal/services/svfntfmt.h index bd295c9c6b..376d9255bb 100644 --- a/thirdparty/freetype/include/freetype/internal/services/svfntfmt.h +++ b/thirdparty/freetype/include/freetype/internal/services/svfntfmt.h @@ -4,7 +4,7 @@ /* */ /* The FreeType font format service (specification only). */ /* */ -/* Copyright 2003-2016 by */ +/* Copyright 2003-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/thirdparty/freetype/include/freetype/internal/services/svgldict.h b/thirdparty/freetype/include/freetype/internal/services/svgldict.h index fff29bc40c..0cd13618d8 100644 --- a/thirdparty/freetype/include/freetype/internal/services/svgldict.h +++ b/thirdparty/freetype/include/freetype/internal/services/svgldict.h @@ -4,7 +4,7 @@ /* */ /* The FreeType glyph dictionary services (specification). */ /* */ -/* Copyright 2003-2016 by */ +/* Copyright 2003-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/thirdparty/freetype/include/freetype/internal/services/svgxval.h b/thirdparty/freetype/include/freetype/internal/services/svgxval.h index fb8ffba83c..71bfa97af8 100644 --- a/thirdparty/freetype/include/freetype/internal/services/svgxval.h +++ b/thirdparty/freetype/include/freetype/internal/services/svgxval.h @@ -4,7 +4,7 @@ /* */ /* FreeType API for validating TrueTypeGX/AAT tables (specification). */ /* */ -/* Copyright 2004-2016 by */ +/* Copyright 2004-2017 by */ /* Masatake YAMATO, Red Hat K.K., */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ diff --git a/thirdparty/freetype/include/freetype/internal/services/svkern.h b/thirdparty/freetype/include/freetype/internal/services/svkern.h index a636f1af1c..b8344e96e9 100644 --- a/thirdparty/freetype/include/freetype/internal/services/svkern.h +++ b/thirdparty/freetype/include/freetype/internal/services/svkern.h @@ -4,7 +4,7 @@ /* */ /* The FreeType Kerning service (specification). */ /* */ -/* Copyright 2006-2016 by */ +/* Copyright 2006-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/thirdparty/freetype/include/freetype/internal/services/svmetric.h b/thirdparty/freetype/include/freetype/internal/services/svmetric.h new file mode 100644 index 0000000000..1f7d5ddd0c --- /dev/null +++ b/thirdparty/freetype/include/freetype/internal/services/svmetric.h @@ -0,0 +1,153 @@ +/***************************************************************************/ +/* */ +/* svmetric.h */ +/* */ +/* The FreeType services for metrics variations (specification). */ +/* */ +/* Copyright 2016-2017 by */ +/* David Turner, Robert Wilhelm, and Werner Lemberg. */ +/* */ +/* This file is part of the FreeType project, and may only be used, */ +/* modified, and distributed under the terms of the FreeType project */ +/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ +/* this file you indicate that you have read the license and */ +/* understand and accept it fully. */ +/* */ +/***************************************************************************/ + + +#ifndef SVMETRIC_H_ +#define SVMETRIC_H_ + +#include FT_INTERNAL_SERVICE_H + + +FT_BEGIN_HEADER + + + /* + * A service to manage the `HVAR, `MVAR', and `VVAR' OpenType tables. + * + */ + +#define FT_SERVICE_ID_METRICS_VARIATIONS "metrics-variations" + + + /* HVAR */ + + typedef FT_Error + (*FT_HAdvance_Adjust_Func)( FT_Face face, + FT_UInt gindex, + FT_Int *avalue ); + + typedef FT_Error + (*FT_LSB_Adjust_Func)( FT_Face face, + FT_UInt gindex, + FT_Int *avalue ); + + typedef FT_Error + (*FT_RSB_Adjust_Func)( FT_Face face, + FT_UInt gindex, + FT_Int *avalue ); + + /* VVAR */ + + typedef FT_Error + (*FT_VAdvance_Adjust_Func)( FT_Face face, + FT_UInt gindex, + FT_Int *avalue ); + + typedef FT_Error + (*FT_TSB_Adjust_Func)( FT_Face face, + FT_UInt gindex, + FT_Int *avalue ); + + typedef FT_Error + (*FT_BSB_Adjust_Func)( FT_Face face, + FT_UInt gindex, + FT_Int *avalue ); + + typedef FT_Error + (*FT_VOrg_Adjust_Func)( FT_Face face, + FT_UInt gindex, + FT_Int *avalue ); + + /* MVAR */ + + typedef void + (*FT_Metrics_Adjust_Func)( FT_Face face ); + + + FT_DEFINE_SERVICE( MetricsVariations ) + { + FT_HAdvance_Adjust_Func hadvance_adjust; + FT_LSB_Adjust_Func lsb_adjust; + FT_RSB_Adjust_Func rsb_adjust; + + FT_VAdvance_Adjust_Func vadvance_adjust; + FT_TSB_Adjust_Func tsb_adjust; + FT_BSB_Adjust_Func bsb_adjust; + FT_VOrg_Adjust_Func vorg_adjust; + + FT_Metrics_Adjust_Func metrics_adjust; + }; + + +#ifndef FT_CONFIG_OPTION_PIC + +#define FT_DEFINE_SERVICE_METRICSVARIATIONSREC( class_, \ + hadvance_adjust_, \ + lsb_adjust_, \ + rsb_adjust_, \ + vadvance_adjust_, \ + tsb_adjust_, \ + bsb_adjust_, \ + vorg_adjust_, \ + metrics_adjust_ ) \ + static const FT_Service_MetricsVariationsRec class_ = \ + { \ + hadvance_adjust_, \ + lsb_adjust_, \ + rsb_adjust_, \ + vadvance_adjust_, \ + tsb_adjust_, \ + bsb_adjust_, \ + vorg_adjust_, \ + metrics_adjust_ \ + }; + +#else /* FT_CONFIG_OPTION_PIC */ + +#define FT_DEFINE_SERVICE_METRICSVARIATIONSREC( class_, \ + hadvance_adjust_, \ + lsb_adjust_, \ + rsb_adjust_, \ + vadvance_adjust_, \ + tsb_adjust_, \ + bsb_adjust_, \ + vorg_adjust_, \ + metrics_adjust_ ) \ + void \ + FT_Init_Class_ ## class_( FT_Service_MetricsVariationsRec* clazz ) \ + { \ + clazz->hadvance_adjust = hadvance_adjust_; \ + clazz->lsb_adjust = lsb_adjust_; \ + clazz->rsb_adjust = rsb_adjust_; \ + clazz->vadvance_adjust = vadvance_adjust_; \ + clazz->tsb_adjust = tsb_adjust_; \ + clazz->bsb_adjust = bsb_adjust_; \ + clazz->vorg_adjust = vorg_adjust_; \ + clazz->metrics_adjust = metrics_adjust_; \ + } + +#endif /* FT_CONFIG_OPTION_PIC */ + + /* */ + + +FT_END_HEADER + +#endif /* SVMETRIC_H_ */ + + +/* END */ diff --git a/thirdparty/freetype/include/freetype/internal/services/svmm.h b/thirdparty/freetype/include/freetype/internal/services/svmm.h index b78a19f8e0..1d51cd9090 100644 --- a/thirdparty/freetype/include/freetype/internal/services/svmm.h +++ b/thirdparty/freetype/include/freetype/internal/services/svmm.h @@ -4,7 +4,7 @@ /* */ /* The FreeType Multiple Masters and GX var services (specification). */ /* */ -/* Copyright 2003-2016 by */ +/* Copyright 2003-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -58,46 +58,92 @@ FT_BEGIN_HEADER FT_UInt num_coords, FT_Long* coords ); + typedef FT_Error + (*FT_Get_Var_Design_Func)( FT_Face face, + FT_UInt num_coords, + FT_Fixed* coords ); + + typedef FT_Error + (*FT_Get_MM_Blend_Func)( FT_Face face, + FT_UInt num_coords, + FT_Long* coords ); + + typedef FT_Error + (*FT_Get_Var_Blend_Func)( FT_Face face, + FT_UInt *num_coords, + FT_Fixed* *coords, + FT_Fixed* *normalizedcoords, + FT_MM_Var* *mm_var ); + + typedef void + (*FT_Done_Blend_Func)( FT_Face ); + FT_DEFINE_SERVICE( MultiMasters ) { FT_Get_MM_Func get_mm; FT_Set_MM_Design_Func set_mm_design; FT_Set_MM_Blend_Func set_mm_blend; + FT_Get_MM_Blend_Func get_mm_blend; FT_Get_MM_Var_Func get_mm_var; FT_Set_Var_Design_Func set_var_design; + FT_Get_Var_Design_Func get_var_design; + + /* for internal use; only needed for code sharing between modules */ + FT_Get_Var_Blend_Func get_var_blend; + FT_Done_Blend_Func done_blend; }; #ifndef FT_CONFIG_OPTION_PIC -#define FT_DEFINE_SERVICE_MULTIMASTERSREC( class_, \ - get_mm_, \ - set_mm_design_, \ - set_mm_blend_, \ - get_mm_var_, \ - set_var_design_ ) \ - static const FT_Service_MultiMastersRec class_ = \ - { \ - get_mm_, set_mm_design_, set_mm_blend_, get_mm_var_, set_var_design_ \ +#define FT_DEFINE_SERVICE_MULTIMASTERSREC( class_, \ + get_mm_, \ + set_mm_design_, \ + set_mm_blend_, \ + get_mm_blend_, \ + get_mm_var_, \ + set_var_design_, \ + get_var_design_, \ + get_var_blend_, \ + done_blend_ ) \ + static const FT_Service_MultiMastersRec class_ = \ + { \ + get_mm_, \ + set_mm_design_, \ + set_mm_blend_, \ + get_mm_blend_, \ + get_mm_var_, \ + set_var_design_, \ + get_var_design_, \ + get_var_blend_, \ + done_blend_ \ }; #else /* FT_CONFIG_OPTION_PIC */ -#define FT_DEFINE_SERVICE_MULTIMASTERSREC( class_, \ - get_mm_, \ - set_mm_design_, \ - set_mm_blend_, \ - get_mm_var_, \ - set_var_design_ ) \ - void \ - FT_Init_Class_ ## class_( FT_Service_MultiMastersRec* clazz ) \ - { \ - clazz->get_mm = get_mm_; \ - clazz->set_mm_design = set_mm_design_; \ - clazz->set_mm_blend = set_mm_blend_; \ - clazz->get_mm_var = get_mm_var_; \ - clazz->set_var_design = set_var_design_; \ +#define FT_DEFINE_SERVICE_MULTIMASTERSREC( class_, \ + get_mm_, \ + set_mm_design_, \ + set_mm_blend_, \ + get_mm_blend_, \ + get_mm_var_, \ + set_var_design_, \ + get_var_design_, \ + get_var_blend_, \ + done_blend_ ) \ + void \ + FT_Init_Class_ ## class_( FT_Service_MultiMastersRec* clazz ) \ + { \ + clazz->get_mm = get_mm_; \ + clazz->set_mm_design = set_mm_design_; \ + clazz->set_mm_blend = set_mm_blend_; \ + clazz->get_mm_blend = get_mm_blend_; \ + clazz->get_mm_var = get_mm_var_; \ + clazz->set_var_design = set_var_design_; \ + clazz->get_var_design = get_var_design_; \ + clazz->get_var_blend = get_var_blend_; \ + clazz->done_blend = done_blend_; \ } #endif /* FT_CONFIG_OPTION_PIC */ diff --git a/thirdparty/freetype/include/freetype/internal/services/svotval.h b/thirdparty/freetype/include/freetype/internal/services/svotval.h index bc929d4bd9..ac84abee46 100644 --- a/thirdparty/freetype/include/freetype/internal/services/svotval.h +++ b/thirdparty/freetype/include/freetype/internal/services/svotval.h @@ -4,7 +4,7 @@ /* */ /* The FreeType OpenType validation service (specification). */ /* */ -/* Copyright 2004-2016 by */ +/* Copyright 2004-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/thirdparty/freetype/include/freetype/internal/services/svpfr.h b/thirdparty/freetype/include/freetype/internal/services/svpfr.h index d0f7c4df95..c9a182fe39 100644 --- a/thirdparty/freetype/include/freetype/internal/services/svpfr.h +++ b/thirdparty/freetype/include/freetype/internal/services/svpfr.h @@ -4,7 +4,7 @@ /* */ /* Internal PFR service functions (specification). */ /* */ -/* Copyright 2003-2016 by */ +/* Copyright 2003-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/thirdparty/freetype/include/freetype/internal/services/svpostnm.h b/thirdparty/freetype/include/freetype/internal/services/svpostnm.h index f124380050..022cdec195 100644 --- a/thirdparty/freetype/include/freetype/internal/services/svpostnm.h +++ b/thirdparty/freetype/include/freetype/internal/services/svpostnm.h @@ -4,7 +4,7 @@ /* */ /* The FreeType PostScript name services (specification). */ /* */ -/* Copyright 2003-2016 by */ +/* Copyright 2003-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/thirdparty/freetype/include/freetype/internal/services/svprop.h b/thirdparty/freetype/include/freetype/internal/services/svprop.h index 870e90ed7c..eb2d4eed15 100644 --- a/thirdparty/freetype/include/freetype/internal/services/svprop.h +++ b/thirdparty/freetype/include/freetype/internal/services/svprop.h @@ -4,7 +4,7 @@ /* */ /* The FreeType property service (specification). */ /* */ -/* Copyright 2012-2016 by */ +/* Copyright 2012-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -29,7 +29,8 @@ FT_BEGIN_HEADER typedef FT_Error (*FT_Properties_SetFunc)( FT_Module module, const char* property_name, - const void* value ); + const void* value, + FT_Bool value_is_string ); typedef FT_Error (*FT_Properties_GetFunc)( FT_Module module, diff --git a/thirdparty/freetype/include/freetype/internal/services/svpscmap.h b/thirdparty/freetype/include/freetype/internal/services/svpscmap.h index 9acc21690f..b32122e5d6 100644 --- a/thirdparty/freetype/include/freetype/internal/services/svpscmap.h +++ b/thirdparty/freetype/include/freetype/internal/services/svpscmap.h @@ -4,7 +4,7 @@ /* */ /* The FreeType PostScript charmap service (specification). */ /* */ -/* Copyright 2003-2016 by */ +/* Copyright 2003-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/thirdparty/freetype/include/freetype/internal/services/svpsinfo.h b/thirdparty/freetype/include/freetype/internal/services/svpsinfo.h index f2c8060440..0220ce529c 100644 --- a/thirdparty/freetype/include/freetype/internal/services/svpsinfo.h +++ b/thirdparty/freetype/include/freetype/internal/services/svpsinfo.h @@ -4,7 +4,7 @@ /* */ /* The FreeType PostScript info service (specification). */ /* */ -/* Copyright 2003-2016 by */ +/* Copyright 2003-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/thirdparty/freetype/include/freetype/internal/services/svsfnt.h b/thirdparty/freetype/include/freetype/internal/services/svsfnt.h index 0f38cf195f..49d18e43e0 100644 --- a/thirdparty/freetype/include/freetype/internal/services/svsfnt.h +++ b/thirdparty/freetype/include/freetype/internal/services/svsfnt.h @@ -4,7 +4,7 @@ /* */ /* The FreeType SFNT table loading service (specification). */ /* */ -/* Copyright 2003-2016 by */ +/* Copyright 2003-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/thirdparty/freetype/include/freetype/internal/services/svttcmap.h b/thirdparty/freetype/include/freetype/internal/services/svttcmap.h index 772c72189e..30f7feec71 100644 --- a/thirdparty/freetype/include/freetype/internal/services/svttcmap.h +++ b/thirdparty/freetype/include/freetype/internal/services/svttcmap.h @@ -4,7 +4,7 @@ /* */ /* The FreeType TrueType/sfnt cmap extra information service. */ /* */ -/* Copyright 2003-2016 by */ +/* Copyright 2003-2017 by */ /* Masatake YAMATO, Redhat K.K., */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ diff --git a/thirdparty/freetype/include/freetype/internal/services/svtteng.h b/thirdparty/freetype/include/freetype/internal/services/svtteng.h index c55061a034..e4b368ad40 100644 --- a/thirdparty/freetype/include/freetype/internal/services/svtteng.h +++ b/thirdparty/freetype/include/freetype/internal/services/svtteng.h @@ -4,7 +4,7 @@ /* */ /* The FreeType TrueType engine query service (specification). */ /* */ -/* Copyright 2006-2016 by */ +/* Copyright 2006-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/thirdparty/freetype/include/freetype/internal/services/svttglyf.h b/thirdparty/freetype/include/freetype/internal/services/svttglyf.h index c33edd46de..b7793059fd 100644 --- a/thirdparty/freetype/include/freetype/internal/services/svttglyf.h +++ b/thirdparty/freetype/include/freetype/internal/services/svttglyf.h @@ -4,7 +4,7 @@ /* */ /* The FreeType TrueType glyph service. */ /* */ -/* Copyright 2007-2016 by */ +/* Copyright 2007-2017 by */ /* David Turner. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/thirdparty/freetype/include/freetype/internal/services/svwinfnt.h b/thirdparty/freetype/include/freetype/internal/services/svwinfnt.h index c2f6d4c6d3..c94b7e1073 100644 --- a/thirdparty/freetype/include/freetype/internal/services/svwinfnt.h +++ b/thirdparty/freetype/include/freetype/internal/services/svwinfnt.h @@ -4,7 +4,7 @@ /* */ /* The FreeType Windows FNT/FONT service (specification). */ /* */ -/* Copyright 2003-2016 by */ +/* Copyright 2003-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/thirdparty/freetype/include/freetype/internal/sfnt.h b/thirdparty/freetype/include/freetype/internal/sfnt.h index e139315a1f..b8667a003a 100644 --- a/thirdparty/freetype/include/freetype/internal/sfnt.h +++ b/thirdparty/freetype/include/freetype/internal/sfnt.h @@ -4,7 +4,7 @@ /* */ /* High-level `sfnt' driver interface (specification). */ /* */ -/* Copyright 1996-2016 by */ +/* Copyright 1996-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -455,6 +455,37 @@ FT_BEGIN_HEADER FT_String** name ); + /*************************************************************************/ + /* */ + /* <FuncType> */ + /* TT_Get_Name_ID_Func */ + /* */ + /* <Description> */ + /* Search whether an ENGLISH version for a given name ID is in the */ + /* `name' table. */ + /* */ + /* <Input> */ + /* face :: A handle to the source face object. */ + /* */ + /* nameid :: The name id of the name record to return. */ + /* */ + /* <Out> */ + /* win :: If non-negative, an index into the `name' table with */ + /* the corresponding (3,1) or (3,0) Windows entry. */ + /* */ + /* apple :: If non-negative, an index into the `name' table with */ + /* the corresponding (1,0) Apple entry. */ + /* */ + /* <Return> */ + /* 1 if there is either a win or apple entry (or both), 0 otheriwse. */ + /* */ + typedef FT_Bool + (*TT_Get_Name_ID_Func)( TT_Face face, + FT_UShort nameid, + FT_Int *win, + FT_Int *apple ); + + /*************************************************************************/ /* */ /* <FuncType> */ @@ -588,6 +619,7 @@ FT_BEGIN_HEADER TT_Get_Metrics_Func get_metrics; TT_Get_Name_Func get_name; + TT_Get_Name_ID_Func get_name_id; } SFNT_Interface; @@ -628,7 +660,8 @@ FT_BEGIN_HEADER set_sbit_strike_, \ load_strike_metrics_, \ get_metrics_, \ - get_name_ ) \ + get_name_, \ + get_name_id_ ) \ static const SFNT_Interface class_ = \ { \ goto_table_, \ @@ -661,6 +694,7 @@ FT_BEGIN_HEADER load_strike_metrics_, \ get_metrics_, \ get_name_, \ + get_name_id_ \ }; #else /* FT_CONFIG_OPTION_PIC */ @@ -699,7 +733,8 @@ FT_BEGIN_HEADER set_sbit_strike_, \ load_strike_metrics_, \ get_metrics_, \ - get_name_ ) \ + get_name_, \ + get_name_id_ ) \ void \ FT_Init_Class_ ## class_( FT_Library library, \ SFNT_Interface* clazz ) \ @@ -736,6 +771,7 @@ FT_BEGIN_HEADER clazz->load_strike_metrics = load_strike_metrics_; \ clazz->get_metrics = get_metrics_; \ clazz->get_name = get_name_; \ + clazz->get_name_id = get_name_id_; \ } #endif /* FT_CONFIG_OPTION_PIC */ diff --git a/thirdparty/freetype/include/freetype/internal/t1types.h b/thirdparty/freetype/include/freetype/internal/t1types.h index 494c011fc7..b2e35d42d1 100644 --- a/thirdparty/freetype/include/freetype/internal/t1types.h +++ b/thirdparty/freetype/include/freetype/internal/t1types.h @@ -5,7 +5,7 @@ /* Basic Type1/Type2 type definitions and interface (specification */ /* only). */ /* */ -/* Copyright 1996-2016 by */ +/* Copyright 1996-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/thirdparty/freetype/include/freetype/internal/tttypes.h b/thirdparty/freetype/include/freetype/internal/tttypes.h index 4110d50285..c0758e25fc 100644 --- a/thirdparty/freetype/include/freetype/internal/tttypes.h +++ b/thirdparty/freetype/include/freetype/internal/tttypes.h @@ -5,7 +5,7 @@ /* Basic SFNT/TrueType type definitions and interface (specification */ /* only). */ /* */ -/* Copyright 1996-2016 by */ +/* Copyright 1996-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -243,7 +243,7 @@ FT_BEGIN_HEADER /*************************************************************************/ /* */ /* <Struct> */ - /* TT_NameEntryRec */ + /* TT_NameRec */ /* */ /* <Description> */ /* A structure modeling TrueType name records. Name records are used */ @@ -267,7 +267,7 @@ FT_BEGIN_HEADER /* string :: A pointer to the string's bytes. Note that these */ /* are usually UTF-16 encoded characters. */ /* */ - typedef struct TT_NameEntryRec_ + typedef struct TT_NameRec_ { FT_UShort platformID; FT_UShort encodingID; @@ -279,9 +279,39 @@ FT_BEGIN_HEADER /* this last field is not defined in the spec */ /* but used by the FreeType engine */ - FT_Byte* string; + FT_Byte* string; - } TT_NameEntryRec, *TT_NameEntry; + } TT_NameRec, *TT_Name; + + + /*************************************************************************/ + /* */ + /* <Struct> */ + /* TT_LangTagRec */ + /* */ + /* <Description> */ + /* A structure modeling language tag records in SFNT `name' tables, */ + /* introduced in OpenType version 1.6. */ + /* */ + /* <Fields> */ + /* stringLength :: The length of the string in bytes. */ + /* */ + /* stringOffset :: The offset to the string in the `name' table. */ + /* */ + /* string :: A pointer to the string's bytes. Note that these */ + /* are UTF-16BE encoded characters. */ + /* */ + typedef struct TT_LangTagRec_ + { + FT_UShort stringLength; + FT_ULong stringOffset; + + /* this last field is not defined in the spec */ + /* but used by the FreeType engine */ + + FT_Byte* string; + + } TT_LangTagRec, *TT_LangTag; /*************************************************************************/ @@ -293,24 +323,30 @@ FT_BEGIN_HEADER /* A structure modeling the TrueType name table. */ /* */ /* <Fields> */ - /* format :: The format of the name table. */ + /* format :: The format of the name table. */ + /* */ + /* numNameRecords :: The number of names in table. */ /* */ - /* numNameRecords :: The number of names in table. */ + /* storageOffset :: The offset of the name table in the `name' */ + /* TrueType table. */ /* */ - /* storageOffset :: The offset of the name table in the `name' */ - /* TrueType table. */ + /* names :: An array of name records. */ /* */ - /* names :: An array of name records. */ + /* numLangTagRecords :: The number of language tags in table. */ /* */ - /* stream :: the file's input stream. */ + /* langTags :: An array of language tag records. */ + /* */ + /* stream :: The file's input stream. */ /* */ typedef struct TT_NameTableRec_ { - FT_UShort format; - FT_UInt numNameRecords; - FT_UInt storageOffset; - TT_NameEntryRec* names; - FT_Stream stream; + FT_UShort format; + FT_UInt numNameRecords; + FT_UInt storageOffset; + TT_NameRec* names; + FT_UInt numLangTagRecords; + TT_LangTagRec* langTags; + FT_Stream stream; } TT_NameTableRec, *TT_NameTable; @@ -1060,6 +1096,34 @@ FT_BEGIN_HEADER } TT_SbitTableType; + /* OpenType 1.8 brings new tables for variation font support; */ + /* to make the old MM and GX fonts still work we need to check */ + /* the presence (and validity) of the functionality provided */ + /* by those tables. The following flag macros are for the */ + /* field `variation_support'. */ + /* */ + /* Note that `fvar' gets checked immediately at font loading, */ + /* while the other features are only loaded if MM support is */ + /* actually requested. */ + + /* FVAR */ +#define TT_FACE_FLAG_VAR_FVAR ( 1 << 0 ) + + /* HVAR */ +#define TT_FACE_FLAG_VAR_HADVANCE ( 1 << 1 ) +#define TT_FACE_FLAG_VAR_LSB ( 1 << 2 ) +#define TT_FACE_FLAG_VAR_RSB ( 1 << 3 ) + + /* VVAR */ +#define TT_FACE_FLAG_VAR_VADVANCE ( 1 << 4 ) +#define TT_FACE_FLAG_VAR_TSB ( 1 << 5 ) +#define TT_FACE_FLAG_VAR_BSB ( 1 << 6 ) +#define TT_FACE_FLAG_VAR_VORG ( 1 << 7 ) + + /* MVAR */ +#define TT_FACE_FLAG_VAR_MVAR ( 1 << 8 ) + + /*************************************************************************/ /* */ /* TrueType Face Type */ @@ -1161,6 +1225,11 @@ FT_BEGIN_HEADER /* */ /* psnames :: A pointer to the PostScript names service. */ /* */ + /* mm :: A pointer to the Multiple Masters service. */ + /* */ + /* var :: A pointer to the Metrics Variations */ + /* service. */ + /* */ /* hdmx :: The face's horizontal device metrics */ /* (`hdmx' table). This table is optional in */ /* TrueType/OpenType fonts. */ @@ -1182,18 +1251,6 @@ FT_BEGIN_HEADER /* file `ttconfig.h' for comments on the */ /* TT_CONFIG_OPTION_POSTSCRIPT_NAMES option. */ /* */ - /* num_locations :: The number of glyph locations in this */ - /* TrueType file. This should be */ - /* identical to the number of glyphs. */ - /* Ignored for Type 2 fonts. */ - /* */ - /* glyph_locations :: An array of longs. These are offsets to */ - /* glyph data within the `glyf' table. */ - /* Ignored for Type 2 font faces. */ - /* */ - /* glyf_len :: The length of the `glyf' table. Needed */ - /* for malformed `loca' tables. */ - /* */ /* font_program_size :: Size in bytecodes of the face's font */ /* program. 0 if none defined. Ignored for */ /* Type 2 fonts. */ @@ -1219,20 +1276,22 @@ FT_BEGIN_HEADER /* units. Comes from the `cvt ' table. */ /* Ignored for Type 2 fonts. */ /* */ - /* num_kern_pairs :: The number of kerning pairs present in the */ - /* font file. The engine only loads the */ - /* first horizontal format 0 kern table it */ - /* finds in the font file. Ignored for */ - /* Type 2 fonts. */ - /* */ - /* kern_table_index :: The index of the kerning table in the font */ - /* kerning directory. Ignored for Type 2 */ - /* fonts. */ - /* */ /* interpreter :: A pointer to the TrueType bytecode */ /* interpreters field is also used to hook */ /* the debugger in `ttdebug'. */ /* */ + /* extra :: Reserved for third-party font drivers. */ + /* */ + /* postscript_name :: The PS name of the font. Used by the */ + /* postscript name service. */ + /* */ + /* glyf_len :: The length of the `glyf' table. Needed */ + /* for malformed `loca' tables. */ + /* */ + /* glyf_offset :: The file offset of the `glyf' table. */ + /* */ + /* is_cff2 :: Set if the font format is CFF2. */ + /* */ /* doblend :: A boolean which is set if the font should */ /* be blended (this is for GX var). */ /* */ @@ -1240,10 +1299,98 @@ FT_BEGIN_HEADER /* variation tables (rather like Multiple */ /* Master data). */ /* */ - /* extra :: Reserved for third-party font drivers. */ + /* is_default_instance :: Set if the glyph outlines can be used */ + /* unmodified (i.e., without applying glyph */ + /* variation deltas). */ /* */ - /* postscript_name :: The PS name of the font. Used by the */ - /* postscript name service. */ + /* variation_support :: Flags that indicate which OpenType */ + /* functionality related to font variation */ + /* support is present, valid, and usable. */ + /* For example, TT_FACE_FLAG_VAR_FVAR is only */ + /* set if we have at least one design axis. */ + /* */ + /* var_postscript_prefix :: */ + /* The PostScript name prefix needed for */ + /* constructing a variation font instance's */ + /* PS name . */ + /* */ + /* var_postscript_prefix_len :: */ + /* The length of the `var_postscript_prefix' */ + /* string. */ + /* */ + /* horz_metrics_size :: The size of the `hmtx' table. */ + /* */ + /* vert_metrics_size :: The size of the `vmtx' table. */ + /* */ + /* num_locations :: The number of glyph locations in this */ + /* TrueType file. This should be */ + /* identical to the number of glyphs. */ + /* Ignored for Type 2 fonts. */ + /* */ + /* glyph_locations :: An array of longs. These are offsets to */ + /* glyph data within the `glyf' table. */ + /* Ignored for Type 2 font faces. */ + /* */ + /* hdmx_table :: A pointer to the `hdmx' table. */ + /* */ + /* hdmx_table_size :: The size of the `hdmx' table. */ + /* */ + /* hdmx_record_count :: The number of hdmx records. */ + /* */ + /* hdmx_record_size :: The size of a single hdmx record. */ + /* */ + /* hdmx_record_sizes :: An array holding the ppem sizes available */ + /* in the `hdmx' table. */ + /* */ + /* sbit_table :: A pointer to the font's embedded bitmap */ + /* location table. */ + /* */ + /* sbit_table_size :: The size of `sbit_table'. */ + /* */ + /* sbit_table_type :: The sbit table type (CBLC, sbix, etc.). */ + /* */ + /* sbit_num_strikes :: The number of sbit strikes exposed by */ + /* FreeType's API, omitting invalid strikes. */ + /* */ + /* sbit_strike_map :: A mapping between the strike indices */ + /* exposed by the API and the indices used in */ + /* the font's sbit table. */ + /* */ + /* kern_table :: A pointer to the `kern' table. */ + /* */ + /* kern_table_size :: The size of the `kern' table. */ + /* */ + /* num_kern_tables :: The number of supported kern subtables */ + /* (up to 32; FreeType recognizes only */ + /* horizontal ones with format 0). */ + /* */ + /* kern_avail_bits :: The availability status of kern subtables; */ + /* if bit n is set, table n is available. */ + /* */ + /* kern_order_bits :: The sortedness status of kern subtables; */ + /* if bit n is set, table n is sorted. */ + /* */ + /* bdf :: Data related to an SFNT font's `bdf' */ + /* table; see `tttypes.h'. */ + /* */ + /* horz_metrics_offset :: The file offset of the `hmtx' table. */ + /* */ + /* vert_metrics_offset :: The file offset of the `vmtx' table. */ + /* */ + /* sph_found_func_flags :: Flags identifying special bytecode */ + /* functions (used by the v38 implementation */ + /* of the bytecode interpreter). */ + /* */ + /* sph_compatibility_mode :: */ + /* This flag is set if we are in ClearType */ + /* backward compatibility mode (used by the */ + /* v38 implementation of the bytecode */ + /* interpreter). */ + /* */ + /* ebdt_start :: The file offset of the sbit data table */ + /* (CBDT, bdat, etc.). */ + /* */ + /* ebdt_size :: The size of the sbit data table. */ /* */ typedef struct TT_FaceRec_ { @@ -1288,6 +1435,16 @@ FT_BEGIN_HEADER /* handle glyph names <-> unicode & Mac values */ void* psnames; +#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT + /* a typeless pointer to the FT_Service_MultiMasters table used to */ + /* handle variation fonts */ + void* mm; + + /* a typeless pointer to the FT_Service_MetricsVariationsRec table */ + /* used to handle the HVAR, VVAR, and MVAR OpenType tables */ + void* var; +#endif + /***********************************************************************/ /* */ @@ -1311,7 +1468,7 @@ FT_BEGIN_HEADER /***********************************************************************/ /* */ - /* TrueType-specific fields (ignored by the OTF-Type2 driver) */ + /* TrueType-specific fields (ignored by the CFF driver) */ /* */ /***********************************************************************/ @@ -1344,18 +1501,25 @@ FT_BEGIN_HEADER const char* postscript_name; FT_ULong glyf_len; + FT_ULong glyf_offset; /* since 2.7.1 */ + + FT_Bool is_cff2; /* since 2.7.1 */ #ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT FT_Bool doblend; GX_Blend blend; + + FT_Bool is_default_instance; /* since 2.7.1 */ + FT_UInt32 variation_support; /* since 2.7.1 */ + + const char* var_postscript_prefix; /* since 2.7.2 */ + FT_UInt var_postscript_prefix_len; /* since 2.7.2 */ + #endif /* since version 2.2 */ - FT_Byte* horz_metrics; FT_ULong horz_metrics_size; - - FT_Byte* vert_metrics; FT_ULong vert_metrics_size; FT_ULong num_locations; /* in broken TTF, gid > 0xFFFF */ @@ -1371,6 +1535,7 @@ FT_BEGIN_HEADER FT_ULong sbit_table_size; TT_SbitTableType sbit_table_type; FT_UInt sbit_num_strikes; + FT_UInt* sbit_strike_map; FT_Byte* kern_table; FT_ULong kern_table_size; @@ -1393,6 +1558,12 @@ FT_BEGIN_HEADER FT_Bool sph_compatibility_mode; #endif /* TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY */ +#ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS + /* since 2.7 */ + FT_ULong ebdt_start; /* either `CBDT', `EBDT', or `bdat' */ + FT_ULong ebdt_size; +#endif + } TT_FaceRec; @@ -1485,8 +1656,6 @@ FT_BEGIN_HEADER FT_Vector pp1; FT_Vector pp2; - FT_ULong glyf_offset; - /* the zone where we load our glyphs */ TT_GlyphZoneRec base; TT_GlyphZoneRec zone; diff --git a/thirdparty/freetype/include/freetype/t1tables.h b/thirdparty/freetype/include/freetype/t1tables.h index e272324ba2..3f6b36e108 100644 --- a/thirdparty/freetype/include/freetype/t1tables.h +++ b/thirdparty/freetype/include/freetype/t1tables.h @@ -5,7 +5,7 @@ /* Basic Type 1/Type 2 tables definitions and interface (specification */ /* only). */ /* */ -/* Copyright 1996-2016 by */ +/* Copyright 1996-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -291,7 +291,7 @@ FT_BEGIN_HEADER } PS_DesignMapRec, *PS_DesignMap; - /* backwards-compatible definition */ + /* backward compatible definition */ typedef PS_DesignMapRec T1_DesignMap; @@ -326,7 +326,7 @@ FT_BEGIN_HEADER } PS_BlendRec, *PS_Blend; - /* backwards-compatible definition */ + /* backward compatible definition */ typedef PS_BlendRec T1_Blend; diff --git a/thirdparty/freetype/include/freetype/ttnameid.h b/thirdparty/freetype/include/freetype/ttnameid.h index ce707f1645..494d677186 100644 --- a/thirdparty/freetype/include/freetype/ttnameid.h +++ b/thirdparty/freetype/include/freetype/ttnameid.h @@ -4,7 +4,7 @@ /* */ /* TrueType name ID definitions (specification only). */ /* */ -/* Copyright 1996-2016 by */ +/* Copyright 1996-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -36,7 +36,7 @@ FT_BEGIN_HEADER /*************************************************************************/ /* */ /* Possible values for the `platform' identifier code in the name */ - /* records of the TTF `name' table. */ + /* records of an SFNT `name' table. */ /* */ /*************************************************************************/ @@ -119,14 +119,19 @@ FT_BEGIN_HEADER * TT_APPLE_ID_VARIANT_SELECTOR :: * From Adobe, not Apple. Not a normal cmap. Specifies variations * on a real cmap. + * + * TT_APPLE_ID_FULL_UNICODE :: + * Used for fallback fonts that provide complete Unicode coverage with + * a type~13 cmap. */ -#define TT_APPLE_ID_DEFAULT 0 /* Unicode 1.0 */ -#define TT_APPLE_ID_UNICODE_1_1 1 /* specify Hangul at U+34xx */ -#define TT_APPLE_ID_ISO_10646 2 /* deprecated */ -#define TT_APPLE_ID_UNICODE_2_0 3 /* or later */ +#define TT_APPLE_ID_DEFAULT 0 /* Unicode 1.0 */ +#define TT_APPLE_ID_UNICODE_1_1 1 /* specify Hangul at U+34xx */ +#define TT_APPLE_ID_ISO_10646 2 /* deprecated */ +#define TT_APPLE_ID_UNICODE_2_0 3 /* or later */ #define TT_APPLE_ID_UNICODE_32 4 /* 2.0 or later, full repertoire */ -#define TT_APPLE_ID_VARIANT_SELECTOR 5 /* variation selector data */ +#define TT_APPLE_ID_VARIANT_SELECTOR 5 /* variation selector data */ +#define TT_APPLE_ID_FULL_UNICODE 6 /* used with type 13 cmaps */ /*********************************************************************** @@ -137,42 +142,6 @@ FT_BEGIN_HEADER * @description: * A list of valid values for the `encoding_id' for * @TT_PLATFORM_MACINTOSH charmaps and name entries. - * - * @values: - * TT_MAC_ID_ROMAN :: - * TT_MAC_ID_JAPANESE :: - * TT_MAC_ID_TRADITIONAL_CHINESE :: - * TT_MAC_ID_KOREAN :: - * TT_MAC_ID_ARABIC :: - * TT_MAC_ID_HEBREW :: - * TT_MAC_ID_GREEK :: - * TT_MAC_ID_RUSSIAN :: - * TT_MAC_ID_RSYMBOL :: - * TT_MAC_ID_DEVANAGARI :: - * TT_MAC_ID_GURMUKHI :: - * TT_MAC_ID_GUJARATI :: - * TT_MAC_ID_ORIYA :: - * TT_MAC_ID_BENGALI :: - * TT_MAC_ID_TAMIL :: - * TT_MAC_ID_TELUGU :: - * TT_MAC_ID_KANNADA :: - * TT_MAC_ID_MALAYALAM :: - * TT_MAC_ID_SINHALESE :: - * TT_MAC_ID_BURMESE :: - * TT_MAC_ID_KHMER :: - * TT_MAC_ID_THAI :: - * TT_MAC_ID_LAOTIAN :: - * TT_MAC_ID_GEORGIAN :: - * TT_MAC_ID_ARMENIAN :: - * TT_MAC_ID_MALDIVIAN :: - * TT_MAC_ID_SIMPLIFIED_CHINESE :: - * TT_MAC_ID_TIBETAN :: - * TT_MAC_ID_MONGOLIAN :: - * TT_MAC_ID_GEEZ :: - * TT_MAC_ID_SLAVIC :: - * TT_MAC_ID_VIETNAMESE :: - * TT_MAC_ID_SINDHI :: - * TT_MAC_ID_UNINTERP :: */ #define TT_MAC_ID_ROMAN 0 @@ -247,44 +216,47 @@ FT_BEGIN_HEADER * * @values: * TT_MS_ID_SYMBOL_CS :: - * Corresponds to Microsoft symbol encoding. See - * @FT_ENCODING_MS_SYMBOL. + * Microsoft symbol encoding. See @FT_ENCODING_MS_SYMBOL. * * TT_MS_ID_UNICODE_CS :: - * Corresponds to a Microsoft WGL4 charmap, matching Unicode. See + * Microsoft WGL4 charmap, matching Unicode. See * @FT_ENCODING_UNICODE. * * TT_MS_ID_SJIS :: - * Corresponds to SJIS Japanese encoding. See @FT_ENCODING_SJIS. + * Shift JIS Japanese encoding. See @FT_ENCODING_SJIS. * - * TT_MS_ID_GB2312 :: - * Corresponds to Simplified Chinese as used in Mainland China. See - * @FT_ENCODING_GB2312. + * TT_MS_ID_PRC :: + * Chinese encodings as used in the People's Republic of China (PRC). + * This means the encodings GB~2312 and its supersets GBK and + * GB~18030. See @FT_ENCODING_PRC. * * TT_MS_ID_BIG_5 :: - * Corresponds to Traditional Chinese as used in Taiwan and Hong Kong. - * See @FT_ENCODING_BIG5. + * Traditional Chinese as used in Taiwan and Hong Kong. See + * @FT_ENCODING_BIG5. * * TT_MS_ID_WANSUNG :: - * Corresponds to Korean Wansung encoding. See @FT_ENCODING_WANSUNG. + * Korean Extended Wansung encoding. See @FT_ENCODING_WANSUNG. * * TT_MS_ID_JOHAB :: - * Corresponds to Johab encoding. See @FT_ENCODING_JOHAB. + * Korean Johab encoding. See @FT_ENCODING_JOHAB. * * TT_MS_ID_UCS_4 :: - * Corresponds to UCS-4 or UTF-32 charmaps. This has been added to - * the OpenType specification version 1.4 (mid-2001.) + * UCS-4 or UTF-32 charmaps. This has been added to the OpenType + * specification version 1.4 (mid-2001). */ #define TT_MS_ID_SYMBOL_CS 0 #define TT_MS_ID_UNICODE_CS 1 #define TT_MS_ID_SJIS 2 -#define TT_MS_ID_GB2312 3 +#define TT_MS_ID_PRC 3 #define TT_MS_ID_BIG_5 4 #define TT_MS_ID_WANSUNG 5 #define TT_MS_ID_JOHAB 6 #define TT_MS_ID_UCS_4 10 + /* this value is deprecated */ +#define TT_MS_ID_GB2312 TT_MS_ID_PRC + /*********************************************************************** * @@ -312,17 +284,22 @@ FT_BEGIN_HEADER #define TT_ADOBE_ID_LATIN_1 3 - /*************************************************************************/ - /* */ - /* Possible values of the language identifier field in the name records */ - /* of the TTF `name' table if the `platform' identifier code is */ - /* TT_PLATFORM_MACINTOSH. These values are also used as return values */ - /* for function @FT_Get_CMap_Language_ID. */ - /* */ - /* The canonical source for the Apple assigned Language ID's is at */ - /* */ - /* https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6name.html */ - /* */ + /*********************************************************************** + * + * @enum: + * TT_MAC_LANGID_XXX + * + * @description: + * Possible values of the language identifier field in the name records + * of the SFNT `name' table if the `platform' identifier code is + * @TT_PLATFORM_MACINTOSH. These values are also used as return values + * for function @FT_Get_CMap_Language_ID. + * + * The canonical source for Apple's IDs is + * + * https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6name.html + */ + #define TT_MAC_LANGID_ENGLISH 0 #define TT_MAC_LANGID_FRENCH 1 #define TT_MAC_LANGID_GERMAN 2 @@ -433,15 +410,6 @@ FT_BEGIN_HEADER #define TT_MAC_LANGID_JAVANESE 138 #define TT_MAC_LANGID_SUNDANESE 139 - -#if 0 /* these seem to be errors that have been dropped */ - -#define TT_MAC_LANGID_SCOTTISH_GAELIC 140 -#define TT_MAC_LANGID_IRISH_GAELIC 141 - -#endif - - /* The following codes are new as of 2000-03-10 */ #define TT_MAC_LANGID_GALICIAN 140 #define TT_MAC_LANGID_AFRIKAANS 141 @@ -456,18 +424,30 @@ FT_BEGIN_HEADER #define TT_MAC_LANGID_AZERBAIJANI_ROMAN_SCRIPT 150 - /*************************************************************************/ - /* */ - /* Possible values of the language identifier field in the name records */ - /* of the TTF `name' table if the `platform' identifier code is */ - /* TT_PLATFORM_MICROSOFT. */ - /* */ - /* The canonical source for the MS assigned LCIDs is */ - /* */ - /* http://www.microsoft.com/globaldev/reference/lcid-all.mspx */ - /* */ + /*********************************************************************** + * + * @enum: + * TT_MS_LANGID_XXX + * + * @description: + * Possible values of the language identifier field in the name records + * of the SFNT `name' table if the `platform' identifier code is + * @TT_PLATFORM_MICROSOFT. These values are also used as return values + * for function @FT_Get_CMap_Language_ID. + * + * The canonical source for Microsoft's IDs is + * + * http://www.microsoft.com/globaldev/reference/lcid-all.mspx , + * + * however, we only provide macros for language identifiers present in + * the OpenType specification: Microsoft has abandoned the concept of + * LCIDs (language code identifiers), and format~1 of the `name' table + * provides a better mechanism for languages not covered here. + * + * More legacy values not listed in the reference can be found in the + * @FT_TRUETYPE_IDS_H header file. + */ -#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 @@ -485,39 +465,20 @@ FT_BEGIN_HEADER #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_CATALAN_CATALAN 0x0403 #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_SINGAPORE 0x1004 - -#if 1 /* this looks like the correct value */ -#define TT_MS_LANGID_CHINESE_MACAU 0x1404 -#else /* but beware, Microsoft may change its mind... - the most recent Word reference has the following: */ -#define TT_MS_LANGID_CHINESE_MACAU TT_MS_LANGID_CHINESE_HONG_KONG -#endif - -#if 0 /* used only with .NET `cultures'; commented out */ -#define TT_MS_LANGID_CHINESE_TRADITIONAL 0x7C04 -#endif - +#define TT_MS_LANGID_CHINESE_MACAO 0x1404 #define TT_MS_LANGID_CZECH_CZECH_REPUBLIC 0x0405 #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_LUXEMBOURG 0x1007 -#define TT_MS_LANGID_GERMAN_LIECHTENSTEI 0x1407 +#define TT_MS_LANGID_GERMAN_LIECHTENSTEIN 0x1407 #define TT_MS_LANGID_GREEK_GREECE 0x0408 - - /* don't ask what this one means... It is commented out currently. */ -#if 0 -#define TT_MS_LANGID_GREEK_GREECE2 0x2008 -#endif - -#define TT_MS_LANGID_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 @@ -531,14 +492,12 @@ FT_BEGIN_HEADER #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_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_SPAIN_MODERN_SORT 0x0C0A #define TT_MS_LANGID_SPANISH_GUATEMALA 0x100A #define TT_MS_LANGID_SPANISH_COSTA_RICA 0x140A #define TT_MS_LANGID_SPANISH_PANAMA 0x180A @@ -557,9 +516,6 @@ FT_BEGIN_HEADER #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 @@ -567,27 +523,13 @@ FT_BEGIN_HEADER #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_ITALIAN_ITALY 0x0410 #define TT_MS_LANGID_ITALIAN_SWITZERLAND 0x0810 #define TT_MS_LANGID_JAPANESE_JAPAN 0x0411 -#define TT_MS_LANGID_KOREAN_EXTENDED_WANSUNG_KOREA 0x0412 -#define TT_MS_LANGID_KOREAN_JOHAB_KOREA 0x0812 +#define TT_MS_LANGID_KOREAN_KOREA 0x0412 #define TT_MS_LANGID_DUTCH_NETHERLANDS 0x0413 #define TT_MS_LANGID_DUTCH_BELGIUM 0x0813 #define TT_MS_LANGID_NORWEGIAN_NORWAY_BOKMAL 0x0414 @@ -595,26 +537,17 @@ FT_BEGIN_HEADER #define TT_MS_LANGID_POLISH_POLAND 0x0415 #define TT_MS_LANGID_PORTUGUESE_BRAZIL 0x0416 #define TT_MS_LANGID_PORTUGUESE_PORTUGAL 0x0816 -#define TT_MS_LANGID_RHAETO_ROMANIC_SWITZERLAND 0x0417 +#define TT_MS_LANGID_ROMANSH_SWITZERLAND 0x0417 #define TT_MS_LANGID_ROMANIAN_ROMANIA 0x0418 -#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 - -#if 0 /* this used to be this value, but it looks like we were wrong */ -#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 - /* 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 -#endif - +#define TT_MS_LANGID_SERBIAN_BOSNIA_HERZ_CYRILLIC 0x1C1A +#define TT_MS_LANGID_BOSNIAN_BOSNIA_HERZ_CYRILLIC 0x201A #define TT_MS_LANGID_SLOVAK_SLOVAKIA 0x041B #define TT_MS_LANGID_ALBANIAN_ALBANIA 0x041C #define TT_MS_LANGID_SWEDISH_SWEDEN 0x041D @@ -622,36 +555,30 @@ FT_BEGIN_HEADER #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 #define TT_MS_LANGID_UKRAINIAN_UKRAINE 0x0422 #define TT_MS_LANGID_BELARUSIAN_BELARUS 0x0423 -#define TT_MS_LANGID_SLOVENE_SLOVENIA 0x0424 +#define TT_MS_LANGID_SLOVENIAN_SLOVENIA 0x0424 #define TT_MS_LANGID_ESTONIAN_ESTONIA 0x0425 #define TT_MS_LANGID_LATVIAN_LATVIA 0x0426 #define TT_MS_LANGID_LITHUANIAN_LITHUANIA 0x0427 -#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_BASQUE_BASQUE 0x042D +#define TT_MS_LANGID_UPPER_SORBIAN_GERMANY 0x042E +#define TT_MS_LANGID_LOWER_SORBIAN_GERMANY 0x082E #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 -#define TT_MS_LANGID_VENDA_SOUTH_AFRICA 0x0433 -#define TT_MS_LANGID_XHOSA_SOUTH_AFRICA 0x0434 -#define TT_MS_LANGID_ZULU_SOUTH_AFRICA 0x0435 +#define TT_MS_LANGID_SETSWANA_SOUTH_AFRICA 0x0432 +#define TT_MS_LANGID_ISIXHOSA_SOUTH_AFRICA 0x0434 +#define TT_MS_LANGID_ISIZULU_SOUTH_AFRICA 0x0435 #define TT_MS_LANGID_AFRIKAANS_SOUTH_AFRICA 0x0436 #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 - /* 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 @@ -661,37 +588,21 @@ FT_BEGIN_HEADER #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 - -#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 -#else -#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_IRISH_IRELAND 0x083C #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 \ - TT_MS_LANGID_KIRGHIZ_KIRGHIZSTAN - -#define TT_MS_LANGID_SWAHILI_KENYA 0x0441 +#define TT_MS_LANGID_KAZAKH_KAZAKHSTAN 0x043F +#define TT_MS_LANGID_KYRGYZ_KYRGYZSTAN /* Cyrillic*/ 0x0440 +#define TT_MS_LANGID_KISWAHILI_KENYA 0x0441 #define TT_MS_LANGID_TURKMEN_TURKMENISTAN 0x0442 #define TT_MS_LANGID_UZBEK_UZBEKISTAN_LATIN 0x0443 #define TT_MS_LANGID_UZBEK_UZBEKISTAN_CYRILLIC 0x0843 -#define TT_MS_LANGID_TATAR_TATARSTAN 0x0444 +#define TT_MS_LANGID_TATAR_RUSSIA 0x0444 #define TT_MS_LANGID_BENGALI_INDIA 0x0445 #define TT_MS_LANGID_BENGALI_BANGLADESH 0x0845 #define TT_MS_LANGID_PUNJABI_INDIA 0x0446 -#define TT_MS_LANGID_PUNJABI_ARABIC_PAKISTAN 0x0846 #define TT_MS_LANGID_GUJARATI_INDIA 0x0447 -#define TT_MS_LANGID_ORIYA_INDIA 0x0448 +#define TT_MS_LANGID_ODIA_INDIA 0x0448 #define TT_MS_LANGID_TAMIL_INDIA 0x0449 #define TT_MS_LANGID_TELUGU_INDIA 0x044A #define TT_MS_LANGID_KANNADA_INDIA 0x044B @@ -700,142 +611,241 @@ FT_BEGIN_HEADER #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 - /* Don't use the next constant! It has */ - /* (1) the wrong spelling (Dzonghka) */ - /* (2) Microsoft doesn't officially define it -- */ - /* at least it is not in the List of Local */ - /* ID Values. */ - /* (3) Dzongkha is not the same language as */ - /* Tibetan, so merging it is wrong anyway. */ - /* */ - /* TT_MS_LANGID_TIBETAN_BHUTAN is correct, BTW. */ -#define TT_MS_LANGID_DZONGHKA_BHUTAN 0x0851 - -#if 0 - /* the following used to be defined */ -#define TT_MS_LANGID_TIBETAN_BHUTAN 0x0451 - /* ... but it was changed; */ -#else - /* So we will continue to #define it, but with the correct value */ -#define TT_MS_LANGID_TIBETAN_BHUTAN TT_MS_LANGID_DZONGHKA_BHUTAN -#endif - -#define TT_MS_LANGID_WELSH_WALES 0x0452 +#define TT_MS_LANGID_MONGOLIAN_PRC 0x0850 +#define TT_MS_LANGID_TIBETAN_PRC 0x0451 +#define TT_MS_LANGID_WELSH_UNITED_KINGDOM 0x0452 #define TT_MS_LANGID_KHMER_CAMBODIA 0x0453 #define TT_MS_LANGID_LAO_LAOS 0x0454 -#define TT_MS_LANGID_BURMESE_MYANMAR 0x0455 -#define TT_MS_LANGID_GALICIAN_SPAIN 0x0456 +#define TT_MS_LANGID_GALICIAN_GALICIAN 0x0456 #define TT_MS_LANGID_KONKANI_INDIA 0x0457 -#define TT_MS_LANGID_MANIPURI_INDIA /* Bengali */ 0x0458 -#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_SINHALA_SRI_LANKA 0x045B #define TT_MS_LANGID_INUKTITUT_CANADA 0x045D +#define TT_MS_LANGID_INUKTITUT_CANADA_LATIN 0x085D #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) */ - /* script is yet unclear... might be Arabic, Nagari or Sharada */ -#define TT_MS_LANGID_KASHMIRI_SASIA 0x0860 - /* ... and aliased (by MS) for compatibility reasons. */ -#define TT_MS_LANGID_KASHMIRI_INDIA TT_MS_LANGID_KASHMIRI_SASIA +#define TT_MS_LANGID_TAMAZIGHT_ALGERIA 0x085F #define TT_MS_LANGID_NEPALI_NEPAL 0x0461 -#define TT_MS_LANGID_NEPALI_INDIA 0x0861 #define TT_MS_LANGID_FRISIAN_NETHERLANDS 0x0462 #define TT_MS_LANGID_PASHTO_AFGHANISTAN 0x0463 #define TT_MS_LANGID_FILIPINO_PHILIPPINES 0x0464 #define TT_MS_LANGID_DHIVEHI_MALDIVES 0x0465 - /* alias declared in Windows 2000 */ -#define TT_MS_LANGID_DIVEHI_MALDIVES TT_MS_LANGID_DHIVEHI_MALDIVES -#define TT_MS_LANGID_EDO_NIGERIA 0x0466 -#define TT_MS_LANGID_FULFULDE_NIGERIA 0x0467 #define TT_MS_LANGID_HAUSA_NIGERIA 0x0468 -#define TT_MS_LANGID_IBIBIO_NIGERIA 0x0469 #define TT_MS_LANGID_YORUBA_NIGERIA 0x046A #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. */ +#define TT_MS_LANGID_SESOTHO_SA_LEBOA_SOUTH_AFRICA 0x046C +#define TT_MS_LANGID_BASHKIR_RUSSIA 0x046D +#define TT_MS_LANGID_LUXEMBOURGISH_LUXEMBOURG 0x046E +#define TT_MS_LANGID_GREENLANDIC_GREENLAND 0x046F #define TT_MS_LANGID_IGBO_NIGERIA 0x0470 +#define TT_MS_LANGID_YI_PRC 0x0478 +#define TT_MS_LANGID_MAPUDUNGUN_CHILE 0x047A +#define TT_MS_LANGID_MOHAWK_MOHAWK 0x047C +#define TT_MS_LANGID_BRETON_FRANCE 0x047E +#define TT_MS_LANGID_UIGHUR_PRC 0x0480 +#define TT_MS_LANGID_MAORI_NEW_ZEALAND 0x0481 +#define TT_MS_LANGID_OCCITAN_FRANCE 0x0482 +#define TT_MS_LANGID_CORSICAN_FRANCE 0x0483 +#define TT_MS_LANGID_ALSATIAN_FRANCE 0x0484 +#define TT_MS_LANGID_YAKUT_RUSSIA 0x0485 +#define TT_MS_LANGID_KICHE_GUATEMALA 0x0486 +#define TT_MS_LANGID_KINYARWANDA_RWANDA 0x0487 +#define TT_MS_LANGID_WOLOF_SENEGAL 0x0488 +#define TT_MS_LANGID_DARI_AFGHANISTAN 0x048C + + /* */ + + + /* legacy macro definitions not present in OpenType 1.8.1 */ +#define TT_MS_LANGID_ARABIC_GENERAL 0x0001 +#define TT_MS_LANGID_CATALAN_SPAIN \ + TT_MS_LANGID_CATALAN_CATALAN +#define TT_MS_LANGID_CHINESE_GENERAL 0x0004 +#define TT_MS_LANGID_CHINESE_MACAU \ + TT_MS_LANGID_CHINESE_MACAO +#define TT_MS_LANGID_GERMAN_LIECHTENSTEI \ + TT_MS_LANGID_GERMAN_LIECHTENSTEIN +#define TT_MS_LANGID_ENGLISH_GENERAL 0x0009 +#define TT_MS_LANGID_ENGLISH_INDONESIA 0x3809 +#define TT_MS_LANGID_ENGLISH_HONG_KONG 0x3C09 +#define TT_MS_LANGID_SPANISH_SPAIN_INTERNATIONAL_SORT \ + TT_MS_LANGID_SPANISH_SPAIN_MODERN_SORT +#define TT_MS_LANGID_SPANISH_LATIN_AMERICA 0xE40AU +#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 +#define TT_MS_LANGID_FRENCH_NORTH_AFRICA 0xE40CU +#define TT_MS_LANGID_KOREAN_EXTENDED_WANSUNG_KOREA \ + TT_MS_LANGID_KOREAN_KOREA +#define TT_MS_LANGID_KOREAN_JOHAB_KOREA 0x0812 +#define TT_MS_LANGID_RHAETO_ROMANIC_SWITZERLAND \ + TT_MS_LANGID_ROMANSH_SWITZERLAND +#define TT_MS_LANGID_MOLDAVIAN_MOLDAVIA 0x0818 +#define TT_MS_LANGID_RUSSIAN_MOLDAVIA 0x0819 +#define TT_MS_LANGID_URDU_INDIA 0x0820 +#define TT_MS_LANGID_CLASSIC_LITHUANIAN_LITHUANIA 0x0827 +#define TT_MS_LANGID_SLOVENE_SLOVENIA \ + TT_MS_LANGID_SLOVENIAN_SLOVENIA +#define TT_MS_LANGID_FARSI_IRAN 0x0429 +#define TT_MS_LANGID_BASQUE_SPAIN \ + TT_MS_LANGID_BASQUE_BASQUE +#define TT_MS_LANGID_SORBIAN_GERMANY \ + TT_MS_LANGID_UPPER_SORBIAN_GERMANY +#define TT_MS_LANGID_SUTU_SOUTH_AFRICA 0x0430 +#define TT_MS_LANGID_TSONGA_SOUTH_AFRICA 0x0431 +#define TT_MS_LANGID_TSWANA_SOUTH_AFRICA \ + TT_MS_LANGID_SETSWANA_SOUTH_AFRICA +#define TT_MS_LANGID_VENDA_SOUTH_AFRICA 0x0433 +#define TT_MS_LANGID_XHOSA_SOUTH_AFRICA \ + TT_MS_LANGID_ISIXHOSA_SOUTH_AFRICA +#define TT_MS_LANGID_ZULU_SOUTH_AFRICA \ + TT_MS_LANGID_ISIZULU_SOUTH_AFRICA +#define TT_MS_LANGID_SAAMI_LAPONIA 0x043B + /* the next two values are incorrectly inverted */ +#define TT_MS_LANGID_IRISH_GAELIC_IRELAND 0x043C +#define TT_MS_LANGID_SCOTTISH_GAELIC_UNITED_KINGDOM 0x083C +#define TT_MS_LANGID_YIDDISH_GERMANY 0x043D +#define TT_MS_LANGID_KAZAK_KAZAKSTAN \ + TT_MS_LANGID_KAZAKH_KAZAKHSTAN +#define TT_MS_LANGID_KIRGHIZ_KIRGHIZ_REPUBLIC \ + TT_MS_LANGID_KYRGYZ_KYRGYZSTAN +#define TT_MS_LANGID_KIRGHIZ_KIRGHIZSTAN \ + TT_MS_LANGID_KYRGYZ_KYRGYZSTAN +#define TT_MS_LANGID_SWAHILI_KENYA \ + TT_MS_LANGID_KISWAHILI_KENYA +#define TT_MS_LANGID_TATAR_TATARSTAN \ + TT_MS_LANGID_TATAR_RUSSIA +#define TT_MS_LANGID_PUNJABI_ARABIC_PAKISTAN 0x0846 +#define TT_MS_LANGID_ORIYA_INDIA \ + TT_MS_LANGID_ODIA_INDIA +#define TT_MS_LANGID_MONGOLIAN_MONGOLIA_MONGOLIAN \ + TT_MS_LANGID_MONGOLIAN_PRC +#define TT_MS_LANGID_TIBETAN_CHINA \ + TT_MS_LANGID_TIBETAN_PRC +#define TT_MS_LANGID_DZONGHKA_BHUTAN 0x0851 +#define TT_MS_LANGID_TIBETAN_BHUTAN \ + TT_MS_LANGID_DZONGHKA_BHUTAN +#define TT_MS_LANGID_WELSH_WALES \ + TT_MS_LANGID_WELSH_UNITED_KINGDOM +#define TT_MS_LANGID_BURMESE_MYANMAR 0x0455 +#define TT_MS_LANGID_GALICIAN_SPAIN \ + TT_MS_LANGID_GALICIAN_GALICIAN +#define TT_MS_LANGID_MANIPURI_INDIA /* Bengali */ 0x0458 +#define TT_MS_LANGID_SINDHI_INDIA /* Arabic */ 0x0459 +#define TT_MS_LANGID_SINDHI_PAKISTAN 0x0859 +#define TT_MS_LANGID_SINHALESE_SRI_LANKA \ + TT_MS_LANGID_SINHALA_SRI_LANKA +#define TT_MS_LANGID_CHEROKEE_UNITED_STATES 0x045C +#define TT_MS_LANGID_TAMAZIGHT_MOROCCO /* Arabic */ 0x045F +#define TT_MS_LANGID_TAMAZIGHT_MOROCCO_LATIN \ + TT_MS_LANGID_TAMAZIGHT_ALGERIA +#define TT_MS_LANGID_KASHMIRI_PAKISTAN /* Arabic */ 0x0460 +#define TT_MS_LANGID_KASHMIRI_SASIA 0x0860 +#define TT_MS_LANGID_KASHMIRI_INDIA \ + TT_MS_LANGID_KASHMIRI_SASIA +#define TT_MS_LANGID_NEPALI_INDIA 0x0861 +#define TT_MS_LANGID_DIVEHI_MALDIVES \ + TT_MS_LANGID_DHIVEHI_MALDIVES +#define TT_MS_LANGID_EDO_NIGERIA 0x0466 +#define TT_MS_LANGID_FULFULDE_NIGERIA 0x0467 +#define TT_MS_LANGID_IBIBIO_NIGERIA 0x0469 +#define TT_MS_LANGID_SEPEDI_SOUTH_AFRICA \ + TT_MS_LANGID_SESOTHO_SA_LEBOA_SOUTH_AFRICA +#define TT_MS_LANGID_SOTHO_SOUTHERN_SOUTH_AFRICA \ + TT_MS_LANGID_SESOTHO_SA_LEBOA_SOUTH_AFRICA #define TT_MS_LANGID_KANURI_NIGERIA 0x0471 #define TT_MS_LANGID_OROMO_ETHIOPIA 0x0472 #define TT_MS_LANGID_TIGRIGNA_ETHIOPIA 0x0473 #define TT_MS_LANGID_TIGRIGNA_ERYTHREA 0x0873 - /* also spelled in the `Passport SDK' list as: */ -#define TT_MS_LANGID_TIGRIGNA_ERYTREA TT_MS_LANGID_TIGRIGNA_ERYTHREA +#define TT_MS_LANGID_TIGRIGNA_ERYTREA \ + TT_MS_LANGID_TIGRIGNA_ERYTHREA #define TT_MS_LANGID_GUARANI_PARAGUAY 0x0474 #define TT_MS_LANGID_HAWAIIAN_UNITED_STATES 0x0475 #define TT_MS_LANGID_LATIN 0x0476 #define TT_MS_LANGID_SOMALI_SOMALIA 0x0477 - /* Note: Yi does not have a (proper) ISO 639-2 code, since it is mostly */ - /* not written (but OTOH the peculiar writing system is worth */ - /* studying). */ -#define TT_MS_LANGID_YI_CHINA 0x0478 +#define TT_MS_LANGID_YI_CHINA \ + TT_MS_LANGID_YI_PRC #define TT_MS_LANGID_PAPIAMENTU_NETHERLANDS_ANTILLES 0x0479 - /* language codes from 0x047A to 0x047F are (still) unknown. */ -#define TT_MS_LANGID_UIGHUR_CHINA 0x0480 -#define TT_MS_LANGID_MAORI_NEW_ZEALAND 0x0481 +#define TT_MS_LANGID_UIGHUR_CHINA \ + TT_MS_LANGID_UIGHUR_PRC -#if 0 /* not deemed useful for fonts */ -#define TT_MS_LANGID_HUMAN_INTERFACE_DEVICE 0x04FF -#endif + /*********************************************************************** + * + * @enum: + * TT_NAME_ID_XXX + * + * @description: + * Possible values of the `name' identifier field in the name records of + * an SFNT `name' table. These values are platform independent. + */ - /*************************************************************************/ - /* */ - /* Possible values of the `name' identifier field in the name records of */ - /* the TTF `name' table. These values are platform independent. */ - /* */ -#define TT_NAME_ID_COPYRIGHT 0 -#define TT_NAME_ID_FONT_FAMILY 1 -#define TT_NAME_ID_FONT_SUBFAMILY 2 -#define TT_NAME_ID_UNIQUE_ID 3 -#define TT_NAME_ID_FULL_NAME 4 -#define TT_NAME_ID_VERSION_STRING 5 -#define TT_NAME_ID_PS_NAME 6 -#define TT_NAME_ID_TRADEMARK 7 +#define TT_NAME_ID_COPYRIGHT 0 +#define TT_NAME_ID_FONT_FAMILY 1 +#define TT_NAME_ID_FONT_SUBFAMILY 2 +#define TT_NAME_ID_UNIQUE_ID 3 +#define TT_NAME_ID_FULL_NAME 4 +#define TT_NAME_ID_VERSION_STRING 5 +#define TT_NAME_ID_PS_NAME 6 +#define TT_NAME_ID_TRADEMARK 7 /* the following values are from the OpenType spec */ -#define TT_NAME_ID_MANUFACTURER 8 -#define TT_NAME_ID_DESIGNER 9 -#define TT_NAME_ID_DESCRIPTION 10 -#define TT_NAME_ID_VENDOR_URL 11 -#define TT_NAME_ID_DESIGNER_URL 12 -#define TT_NAME_ID_LICENSE 13 -#define TT_NAME_ID_LICENSE_URL 14 +#define TT_NAME_ID_MANUFACTURER 8 +#define TT_NAME_ID_DESIGNER 9 +#define TT_NAME_ID_DESCRIPTION 10 +#define TT_NAME_ID_VENDOR_URL 11 +#define TT_NAME_ID_DESIGNER_URL 12 +#define TT_NAME_ID_LICENSE 13 +#define TT_NAME_ID_LICENSE_URL 14 /* number 15 is reserved */ -#define TT_NAME_ID_PREFERRED_FAMILY 16 -#define TT_NAME_ID_PREFERRED_SUBFAMILY 17 -#define TT_NAME_ID_MAC_FULL_NAME 18 +#define TT_NAME_ID_TYPOGRAPHIC_FAMILY 16 +#define TT_NAME_ID_TYPOGRAPHIC_SUBFAMILY 17 +#define TT_NAME_ID_MAC_FULL_NAME 18 /* The following code is new as of 2000-01-21 */ -#define TT_NAME_ID_SAMPLE_TEXT 19 +#define TT_NAME_ID_SAMPLE_TEXT 19 /* This is new in OpenType 1.3 */ -#define TT_NAME_ID_CID_FINDFONT_NAME 20 +#define TT_NAME_ID_CID_FINDFONT_NAME 20 /* This is new in OpenType 1.5 */ -#define TT_NAME_ID_WWS_FAMILY 21 -#define TT_NAME_ID_WWS_SUBFAMILY 22 +#define TT_NAME_ID_WWS_FAMILY 21 +#define TT_NAME_ID_WWS_SUBFAMILY 22 + /* This is new in OpenType 1.7 */ +#define TT_NAME_ID_LIGHT_BACKGROUND 23 +#define TT_NAME_ID_DARK_BACKGROUND 24 - /*************************************************************************/ - /* */ - /* Bit mask values for the Unicode Ranges from the TTF `OS2 ' table. */ - /* */ - /* Updated 08-Nov-2008. */ - /* */ + /* This is new in OpenType 1.8 */ +#define TT_NAME_ID_VARIATIONS_PREFIX 25 + + /* these two values are deprecated */ +#define TT_NAME_ID_PREFERRED_FAMILY TT_NAME_ID_TYPOGRAPHIC_FAMILY +#define TT_NAME_ID_PREFERRED_SUBFAMILY TT_NAME_ID_TYPOGRAPHIC_SUBFAMILY + + + /*********************************************************************** + * + * @enum: + * TT_UCR_XXX + * + * @description: + * Possible bit mask values for the `ulUnicodeRangeX' fields in an SFNT + * `OS/2' table. + */ + + /* ulUnicodeRange1 */ + /* --------------- */ /* Bit 0 Basic Latin */ #define TT_UCR_BASIC_LATIN (1L << 0) /* U+0020-U+007E */ @@ -857,7 +867,7 @@ FT_BEGIN_HEADER /* U+A700-U+A71F */ /* Bit 6 Combining Diacritical Marks */ /* Combining Diacritical Marks Supplement */ -#define TT_UCR_COMBINING_DIACRITICS (1L << 6) /* U+0300-U+036F */ +#define TT_UCR_COMBINING_DIACRITICAL_MARKS (1L << 6) /* U+0300-U+036F */ /* U+1DC0-U+1DFF */ /* Bit 7 Greek and Coptic */ #define TT_UCR_GREEK (1L << 7) /* U+0370-U+03FF */ @@ -925,12 +935,17 @@ FT_BEGIN_HEADER /* Supplemental Punctuation */ #define TT_UCR_GENERAL_PUNCTUATION (1L << 31) /* U+2000-U+206F */ /* U+2E00-U+2E7F */ + + /* ulUnicodeRange2 */ + /* --------------- */ + /* Bit 32 Superscripts And Subscripts */ #define TT_UCR_SUPERSCRIPTS_SUBSCRIPTS (1L << 0) /* U+2070-U+209F */ /* Bit 33 Currency Symbols */ #define TT_UCR_CURRENCY_SYMBOLS (1L << 1) /* U+20A0-U+20CF */ /* Bit 34 Combining Diacritical Marks For Symbols */ -#define TT_UCR_COMBINING_DIACRITICS_SYMB (1L << 2) /* U+20D0-U+20FF */ +#define TT_UCR_COMBINING_DIACRITICAL_MARKS_SYMB \ + (1L << 2) /* U+20D0-U+20FF */ /* Bit 35 Letterlike Symbols */ #define TT_UCR_LETTERLIKE_SYMBOLS (1L << 3) /* U+2100-U+214F */ /* Bit 36 Number Forms */ @@ -996,13 +1011,13 @@ FT_BEGIN_HEADER /* Bit 57 High Surrogates */ /* High Private Use Surrogates */ /* Low Surrogates */ - /* */ + /* According to OpenType specs v.1.3+, */ /* setting bit 57 implies that there is */ /* at least one codepoint beyond the */ /* Basic Multilingual Plane that is */ /* supported by this font. So it really */ - /* means >= U+10000 */ + /* means >= U+10000. */ #define TT_UCR_SURROGATES (1L << 25) /* U+D800-U+DB7F */ /* U+DB80-U+DBFF */ /* U+DC00-U+DFFF */ @@ -1034,7 +1049,11 @@ FT_BEGIN_HEADER /* Bit 62 Alphabetic Presentation Forms */ #define TT_UCR_ALPHABETIC_PRESENTATION_FORMS (1L << 30) /* U+FB00-U+FB4F */ /* Bit 63 Arabic Presentation Forms-A */ -#define TT_UCR_ARABIC_PRESENTATIONS_A (1L << 31) /* U+FB50-U+FDFF */ +#define TT_UCR_ARABIC_PRESENTATION_FORMS_A (1L << 31) /* U+FB50-U+FDFF */ + + /* ulUnicodeRange3 */ + /* --------------- */ + /* Bit 64 Combining Half Marks */ #define TT_UCR_COMBINING_HALF_MARKS (1L << 0) /* U+FE20-U+FE2F */ /* Bit 65 Vertical forms */ @@ -1044,7 +1063,7 @@ FT_BEGIN_HEADER /* Bit 66 Small Form Variants */ #define TT_UCR_SMALL_FORM_VARIANTS (1L << 2) /* U+FE50-U+FE6F */ /* Bit 67 Arabic Presentation Forms-B */ -#define TT_UCR_ARABIC_PRESENTATIONS_B (1L << 3) /* U+FE70-U+FEFE */ +#define TT_UCR_ARABIC_PRESENTATION_FORMS_B (1L << 3) /* U+FE70-U+FEFE */ /* Bit 68 Halfwidth and Fullwidth Forms */ #define TT_UCR_HALFWIDTH_FULLWIDTH_FORMS (1L << 4) /* U+FF00-U+FFEF */ /* Bit 69 Specials */ @@ -1123,6 +1142,10 @@ FT_BEGIN_HEADER #define TT_UCR_TAI_LE (1L << 30) /* U+1950-U+197F */ /* Bit 95 New Tai Lue */ #define TT_UCR_NEW_TAI_LUE (1L << 31) /* U+1980-U+19DF */ + + /* ulUnicodeRange4 */ + /* --------------- */ + /* Bit 96 Buginese */ #define TT_UCR_BUGINESE (1L << 0) /* U+1A00-U+1A1F */ /* Bit 97 Glagolitic */ @@ -1191,42 +1214,18 @@ FT_BEGIN_HEADER /*U+1F000-U+1F02F*/ /* Bit 123-127 Reserved for process-internal usage */ + /* */ - /*************************************************************************/ - /* */ - /* Some compilers have a very limited length of identifiers. */ - /* */ -#if defined( __TURBOC__ ) && __TURBOC__ < 0x0410 || defined( __PACIFIC__ ) -#define HAVE_LIMIT_ON_IDENTS -#endif - - -#ifndef HAVE_LIMIT_ON_IDENTS - - - /*************************************************************************/ - /* */ - /* Here some alias #defines in order to be clearer. */ - /* */ - /* These are not always #defined to stay within the 31~character limit, */ - /* which some compilers have. */ - /* */ - /* Credits go to Dave Hoo <dhoo@flash.net> for pointing out that modern */ - /* Borland compilers (read: from BC++ 3.1 on) can increase this limit. */ - /* If you get a warning with such a compiler, use the -i40 switch. */ - /* */ -#define TT_UCR_ARABIC_PRESENTATION_FORMS_A \ - TT_UCR_ARABIC_PRESENTATIONS_A -#define TT_UCR_ARABIC_PRESENTATION_FORMS_B \ - TT_UCR_ARABIC_PRESENTATIONS_B - -#define TT_UCR_COMBINING_DIACRITICAL_MARKS \ - TT_UCR_COMBINING_DIACRITICS -#define TT_UCR_COMBINING_DIACRITICAL_MARKS_SYMB \ - TT_UCR_COMBINING_DIACRITICS_SYMB - + /* for backward compatibility with older FreeType versions */ +#define TT_UCR_ARABIC_PRESENTATION_A \ + TT_UCR_ARABIC_PRESENTATION_FORMS_A +#define TT_UCR_ARABIC_PRESENTATION_B \ + TT_UCR_ARABIC_PRESENTATION_FORMS_B -#endif /* !HAVE_LIMIT_ON_IDENTS */ +#define TT_UCR_COMBINING_DIACRITICS \ + TT_UCR_COMBINING_DIACRITICAL_MARKS +#define TT_UCR_COMBINING_DIACRITICS_SYMB \ + TT_UCR_COMBINING_DIACRITICAL_MARKS_SYMB FT_END_HEADER diff --git a/thirdparty/freetype/include/freetype/tttables.h b/thirdparty/freetype/include/freetype/tttables.h index 1c075dcf66..58312044ca 100644 --- a/thirdparty/freetype/include/freetype/tttables.h +++ b/thirdparty/freetype/include/freetype/tttables.h @@ -5,7 +5,7 @@ /* Basic SFNT/TrueType tables definitions and interface */ /* (specification only). */ /* */ -/* Copyright 1996-2016 by */ +/* Copyright 1996-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -45,8 +45,9 @@ FT_BEGIN_HEADER /* TrueType specific table types and functions. */ /* */ /* <Description> */ - /* This section contains the definition of TrueType-specific tables */ - /* as well as some routines used to access and process them. */ + /* This section contains definitions of some basic tables specific to */ + /* TrueType and OpenType as well as some routines used to access and */ + /* process them. */ /* */ /* <Order> */ /* TT_Header */ @@ -76,8 +77,8 @@ FT_BEGIN_HEADER /* TT_Header */ /* */ /* <Description> */ - /* A structure used to model a TrueType font header table. All */ - /* fields follow the TrueType specification. */ + /* A structure to model a TrueType font header table. All fields */ + /* follow the OpenType specification. */ /* */ typedef struct TT_Header_ { @@ -114,9 +115,9 @@ FT_BEGIN_HEADER /* TT_HoriHeader */ /* */ /* <Description> */ - /* A structure used to model a TrueType horizontal header, the `hhea' */ + /* A structure to model a TrueType horizontal header, the `hhea' */ /* table, as well as the corresponding horizontal metrics table, */ - /* i.e., the `hmtx' table. */ + /* `hmtx'. */ /* */ /* <Fields> */ /* Version :: The table version. */ @@ -131,7 +132,7 @@ FT_BEGIN_HEADER /* glyphs found in the font (maybe ASCII). */ /* */ /* You should use the `sTypoAscender' field */ - /* of the OS/2 table instead if you want */ + /* of the `OS/2' table instead if you want */ /* the correct one. */ /* */ /* Descender :: The font's descender, i.e., the distance */ @@ -145,7 +146,7 @@ FT_BEGIN_HEADER /* glyphs found in the font (maybe ASCII). */ /* */ /* You should use the `sTypoDescender' */ - /* field of the OS/2 table instead if you */ + /* field of the `OS/2' table instead if you */ /* want the correct one. */ /* */ /* Line_Gap :: The font's line gap, i.e., the distance */ @@ -175,6 +176,8 @@ FT_BEGIN_HEADER /* caret_Slope_Run :: The run coefficient of the cursor's */ /* slope. */ /* */ + /* caret_Offset :: The cursor's offset for slanted fonts. */ + /* */ /* Reserved :: 8~reserved bytes. */ /* */ /* metric_Data_Format :: Always~0. */ @@ -188,13 +191,10 @@ FT_BEGIN_HEADER /* short_metrics :: A pointer into the `hmtx' table. */ /* */ /* <Note> */ - /* IMPORTANT: The TT_HoriHeader and TT_VertHeader structures should */ - /* be identical except for the names of their fields, */ - /* which are different. */ - /* */ - /* This ensures that a single function in the `ttload' */ - /* module is able to read both the horizontal and vertical */ - /* headers. */ + /* For an OpenType variation font, the values of the following fields */ + /* can change after a call to @FT_Set_Var_Design_Coordinates (and */ + /* friends) if the font contains an `MVAR' table: `caret_Slope_Rise', */ + /* `caret_Slope_Run', and `caret_Offset'. */ /* */ typedef struct TT_HoriHeader_ { @@ -217,9 +217,9 @@ FT_BEGIN_HEADER FT_Short metric_Data_Format; FT_UShort number_Of_HMetrics; - /* The following fields are not defined by the TrueType specification */ + /* The following fields are not defined by the OpenType specification */ /* but they are used to connect the metrics header to the relevant */ - /* `HMTX' table. */ + /* `hmtx' table. */ void* long_metrics; void* short_metrics; @@ -234,8 +234,8 @@ FT_BEGIN_HEADER /* */ /* <Description> */ /* A structure used to model a TrueType vertical header, the `vhea' */ - /* table, as well as the corresponding vertical metrics table, i.e., */ - /* the `vmtx' table. */ + /* table, as well as the corresponding vertical metrics table, */ + /* `vmtx'. */ /* */ /* <Fields> */ /* Version :: The table version. */ @@ -251,8 +251,8 @@ FT_BEGIN_HEADER /* ASCII). */ /* */ /* You should use the `sTypoAscender' */ - /* field of the OS/2 table instead if you */ - /* want the correct one. */ + /* field of the `OS/2' table instead if */ + /* you want the correct one. */ /* */ /* Descender :: The font's descender, i.e., the */ /* distance from the baseline to the */ @@ -266,8 +266,8 @@ FT_BEGIN_HEADER /* ASCII). */ /* */ /* You should use the `sTypoDescender' */ - /* field of the OS/2 table instead if you */ - /* want the correct one. */ + /* field of the `OS/2' table instead if */ + /* you want the correct one. */ /* */ /* Line_Gap :: The font's line gap, i.e., the distance */ /* to add to the ascender and descender to */ @@ -297,30 +297,26 @@ FT_BEGIN_HEADER /* slope. */ /* */ /* caret_Offset :: The cursor's offset for slanted fonts. */ - /* This value is `reserved' in vmtx */ - /* version 1.0. */ /* */ /* Reserved :: 8~reserved bytes. */ /* */ /* metric_Data_Format :: Always~0. */ /* */ - /* number_Of_HMetrics :: Number of VMetrics entries in the */ + /* number_Of_VMetrics :: Number of VMetrics entries in the */ /* `vmtx' table -- this value can be */ /* smaller than the total number of glyphs */ /* in the font. */ /* */ - /* long_metrics :: A pointer into the `vmtx' table. */ + /* long_metrics :: A pointer into the `vmtx' table. */ /* */ - /* short_metrics :: A pointer into the `vmtx' table. */ + /* short_metrics :: A pointer into the `vmtx' table. */ /* */ /* <Note> */ - /* IMPORTANT: The TT_HoriHeader and TT_VertHeader structures should */ - /* be identical except for the names of their fields, */ - /* which are different. */ - /* */ - /* This ensures that a single function in the `ttload' */ - /* module is able to read both the horizontal and vertical */ - /* headers. */ + /* For an OpenType variation font, the values of the following fields */ + /* can change after a call to @FT_Set_Var_Design_Coordinates (and */ + /* friends) if the font contains an `MVAR' table: `Ascender', */ + /* `Descender', `Line_Gap', `caret_Slope_Rise', `caret_Slope_Run', */ + /* and `caret_Offset'. */ /* */ typedef struct TT_VertHeader_ { @@ -331,9 +327,9 @@ FT_BEGIN_HEADER FT_UShort advance_Height_Max; /* advance height maximum */ - FT_Short min_Top_Side_Bearing; /* minimum left-sb or top-sb */ - FT_Short min_Bottom_Side_Bearing; /* minimum right-sb or bottom-sb */ - FT_Short yMax_Extent; /* xmax or ymax extents */ + FT_Short min_Top_Side_Bearing; /* minimum top-sb */ + FT_Short min_Bottom_Side_Bearing; /* minimum bottom-sb */ + FT_Short yMax_Extent; /* ymax extents */ FT_Short caret_Slope_Rise; FT_Short caret_Slope_Run; FT_Short caret_Offset; @@ -343,9 +339,9 @@ FT_BEGIN_HEADER FT_Short metric_Data_Format; FT_UShort number_Of_VMetrics; - /* The following fields are not defined by the TrueType specification */ - /* but they're used to connect the metrics header to the relevant */ - /* `HMTX' or `VMTX' table. */ + /* The following fields are not defined by the OpenType specification */ + /* but they are used to connect the metrics header to the relevant */ + /* `vmtx' table. */ void* long_metrics; void* short_metrics; @@ -359,12 +355,28 @@ FT_BEGIN_HEADER /* TT_OS2 */ /* */ /* <Description> */ - /* A structure used to model a TrueType OS/2 table. All fields */ - /* comply to the OpenType specification. */ + /* A structure to model a TrueType `OS/2' table. All fields comply */ + /* to the OpenType specification. */ + /* */ + /* Note that we now support old Mac fonts that do not include an */ + /* `OS/2' table. In this case, the `version' field is always set to */ + /* 0xFFFF. */ /* */ - /* Note that we now support old Mac fonts that do not include an OS/2 */ - /* table. In this case, the `version' field is always set to 0xFFFF. */ + /* <Note> */ + /* For an OpenType variation font, the values of the following fields */ + /* can change after a call to @FT_Set_Var_Design_Coordinates (and */ + /* friends) if the font contains an `MVAR' table: `sCapHeight', */ + /* `sTypoAscender', `sTypoDescender', `sTypoLineGap', `sxHeight', */ + /* `usWinAscent', `usWinDescent', `yStrikeoutPosition', */ + /* `yStrikeoutSize', `ySubscriptXOffset', `ySubScriptXSize', */ + /* `ySubscriptYOffset', `ySubscriptYSize', `ySuperscriptXOffset', */ + /* `ySuperscriptXSize', `ySuperscriptYOffset', and */ + /* `ySuperscriptYSize'. */ + /* */ + /* Possible values for bits in the `ulUnicodeRangeX' fields are given */ + /* by the @TT_UCR_XXX macros. */ /* */ + typedef struct TT_OS2_ { FT_UShort version; /* 0x0001 - more or 0xFFFF */ @@ -429,10 +441,16 @@ FT_BEGIN_HEADER /* TT_Postscript */ /* */ /* <Description> */ - /* A structure used to model a TrueType PostScript table. All fields */ - /* comply to the TrueType specification. This structure does not */ - /* reference the PostScript glyph names, which can be nevertheless */ - /* accessed with the `ttpost' module. */ + /* A structure to model a TrueType `post' table. All fields comply */ + /* to the OpenType specification. This structure does not reference */ + /* a font's PostScript glyph names; use @FT_Get_Glyph_Name to */ + /* retrieve them. */ + /* */ + /* <Note> */ + /* For an OpenType variation font, the values of the following fields */ + /* can change after a call to @FT_Set_Var_Design_Coordinates (and */ + /* friends) if the font contains an `MVAR' table: `underlinePosition' */ + /* and `underlineThickness'. */ /* */ typedef struct TT_Postscript_ { @@ -446,8 +464,8 @@ FT_BEGIN_HEADER FT_ULong minMemType1; FT_ULong maxMemType1; - /* Glyph names follow in the file, but we don't */ - /* load them by default. See the ttpost.c file. */ + /* Glyph names follow in the `post' table, but we don't */ + /* load them by default. */ } TT_Postscript; @@ -458,8 +476,8 @@ FT_BEGIN_HEADER /* TT_PCLT */ /* */ /* <Description> */ - /* A structure used to model a TrueType PCLT table. All fields */ - /* comply to the TrueType specification. */ + /* A structure to model a TrueType `PCLT' table. All fields comply */ + /* to the OpenType specification. */ /* */ typedef struct TT_PCLT_ { @@ -488,9 +506,9 @@ FT_BEGIN_HEADER /* TT_MaxProfile */ /* */ /* <Description> */ - /* The maximum profile is a table containing many max values, which */ - /* can be used to pre-allocate arrays. This ensures that no memory */ - /* allocation occurs during a glyph load. */ + /* The maximum profile (`maxp') table contains many max values, which */ + /* can be used to pre-allocate arrays for speeding up glyph loading */ + /* and hinting. */ /* */ /* <Fields> */ /* version :: The version number. */ @@ -500,21 +518,19 @@ FT_BEGIN_HEADER /* */ /* maxPoints :: The maximum number of points in a */ /* non-composite TrueType glyph. See also */ - /* the structure element */ /* `maxCompositePoints'. */ /* */ /* maxContours :: The maximum number of contours in a */ /* non-composite TrueType glyph. See also */ - /* the structure element */ /* `maxCompositeContours'. */ /* */ /* maxCompositePoints :: The maximum number of points in a */ - /* composite TrueType glyph. See also the */ - /* structure element `maxPoints'. */ + /* composite TrueType glyph. See also */ + /* `maxPoints'. */ /* */ /* maxCompositeContours :: The maximum number of contours in a */ - /* composite TrueType glyph. See also the */ - /* structure element `maxContours'. */ + /* composite TrueType glyph. See also */ + /* `maxContours'. */ /* */ /* maxZones :: The maximum number of zones used for */ /* glyph hinting. */ @@ -575,8 +591,9 @@ FT_BEGIN_HEADER /* FT_Sfnt_Tag */ /* */ /* <Description> */ - /* An enumeration used to specify the index of an SFNT table. */ - /* Used in the @FT_Get_Sfnt_Table API function. */ + /* An enumeration to specify indices of SFNT tables loaded and parsed */ + /* by FreeType during initialization of an SFNT font. Used in the */ + /* @FT_Get_Sfnt_Table API function. */ /* */ /* <Values> */ /* FT_SFNT_HEAD :: To access the font's @TT_Header structure. */ @@ -624,7 +641,7 @@ FT_BEGIN_HEADER /* FT_Get_Sfnt_Table */ /* */ /* <Description> */ - /* Return a pointer to a given SFNT table within a face. */ + /* Return a pointer to a given SFNT table stored within a face. */ /* */ /* <Input> */ /* face :: A handle to the source. */ @@ -632,7 +649,7 @@ FT_BEGIN_HEADER /* tag :: The index of the SFNT table. */ /* */ /* <Return> */ - /* A type-less pointer to the table. This will be~0 in case of */ + /* A type-less pointer to the table. This will be NULL in case of */ /* error, or if the corresponding table was not found *OR* loaded */ /* from the file. */ /* */ @@ -661,70 +678,70 @@ FT_BEGIN_HEADER FT_Sfnt_Tag tag ); - /************************************************************************** - * - * @function: - * FT_Load_Sfnt_Table - * - * @description: - * Load any font table into client memory. - * - * @input: - * face :: - * A handle to the source face. - * - * tag :: - * The four-byte tag of the table to load. Use the value~0 if you want - * to access the whole font file. Otherwise, you can use one of the - * definitions found in the @FT_TRUETYPE_TAGS_H file, or forge a new - * one with @FT_MAKE_TAG. - * - * offset :: - * The starting offset in the table (or file if tag == 0). - * - * @output: - * buffer :: - * The target buffer address. The client must ensure that the memory - * array is big enough to hold the data. - * - * @inout: - * length :: - * If the `length' parameter is NULL, then try to load the whole table. - * Return an error code if it fails. - * - * Else, if `*length' is~0, exit immediately while returning the - * table's (or file) full size in it. - * - * Else the number of bytes to read from the table or file, from the - * starting offset. - * - * @return: - * FreeType error code. 0~means success. - * - * @note: - * If you need to determine the table's length you should first call this - * function with `*length' set to~0, as in the following example: - * - * { - * FT_ULong length = 0; - * - * - * error = FT_Load_Sfnt_Table( face, tag, 0, NULL, &length ); - * if ( error ) { ... table does not exist ... } - * - * buffer = malloc( length ); - * if ( buffer == NULL ) { ... not enough memory ... } - * - * error = FT_Load_Sfnt_Table( face, tag, 0, buffer, &length ); - * if ( error ) { ... could not load table ... } - * } - * - * Note that structures like @TT_Header or @TT_OS2 can't be used with - * this function; they are limited to @FT_Get_Sfnt_Table. Reason is that - * those structures depend on the processor architecture, with varying - * size (e.g. 32bit vs. 64bit) or order (big endian vs. little endian). - * - */ + /************************************************************************** + * + * @function: + * FT_Load_Sfnt_Table + * + * @description: + * Load any SFNT font table into client memory. + * + * @input: + * face :: + * A handle to the source face. + * + * tag :: + * The four-byte tag of the table to load. Use value~0 if you want + * to access the whole font file. Otherwise, you can use one of the + * definitions found in the @FT_TRUETYPE_TAGS_H file, or forge a new + * one with @FT_MAKE_TAG. + * + * offset :: + * The starting offset in the table (or file if tag~==~0). + * + * @output: + * buffer :: + * The target buffer address. The client must ensure that the memory + * array is big enough to hold the data. + * + * @inout: + * length :: + * If the `length' parameter is NULL, try to load the whole table. + * Return an error code if it fails. + * + * Else, if `*length' is~0, exit immediately while returning the + * table's (or file) full size in it. + * + * Else the number of bytes to read from the table or file, from the + * starting offset. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * If you need to determine the table's length you should first call this + * function with `*length' set to~0, as in the following example: + * + * { + * FT_ULong length = 0; + * + * + * error = FT_Load_Sfnt_Table( face, tag, 0, NULL, &length ); + * if ( error ) { ... table does not exist ... } + * + * buffer = malloc( length ); + * if ( buffer == NULL ) { ... not enough memory ... } + * + * error = FT_Load_Sfnt_Table( face, tag, 0, buffer, &length ); + * if ( error ) { ... could not load table ... } + * } + * + * Note that structures like @TT_Header or @TT_OS2 can't be used with + * this function; they are limited to @FT_Get_Sfnt_Table. Reason is that + * those structures depend on the processor architecture, with varying + * size (e.g. 32bit vs. 64bit) or order (big endian vs. little endian). + * + */ FT_EXPORT( FT_Error ) FT_Load_Sfnt_Table( FT_Face face, FT_ULong tag, @@ -733,41 +750,41 @@ FT_BEGIN_HEADER FT_ULong* length ); - /************************************************************************** - * - * @function: - * FT_Sfnt_Table_Info - * - * @description: - * Return information on an SFNT table. - * - * @input: - * face :: - * A handle to the source face. - * - * table_index :: - * The index of an SFNT table. The function returns - * FT_Err_Table_Missing for an invalid value. - * - * @inout: - * tag :: - * The name tag of the SFNT table. If the value is NULL, `table_index' - * is ignored, and `length' returns the number of SFNT tables in the - * font. - * - * @output: - * length :: - * The length of the SFNT table (or the number of SFNT tables, depending - * on `tag'). - * - * @return: - * FreeType error code. 0~means success. - * - * @note: - * While parsing fonts, FreeType handles SFNT tables with length zero as - * missing. - * - */ + /************************************************************************** + * + * @function: + * FT_Sfnt_Table_Info + * + * @description: + * Return information on an SFNT table. + * + * @input: + * face :: + * A handle to the source face. + * + * table_index :: + * The index of an SFNT table. The function returns + * FT_Err_Table_Missing for an invalid value. + * + * @inout: + * tag :: + * The name tag of the SFNT table. If the value is NULL, `table_index' + * is ignored, and `length' returns the number of SFNT tables in the + * font. + * + * @output: + * length :: + * The length of the SFNT table (or the number of SFNT tables, depending + * on `tag'). + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * While parsing fonts, FreeType handles SFNT tables with length zero as + * missing. + * + */ FT_EXPORT( FT_Error ) FT_Sfnt_Table_Info( FT_Face face, FT_UInt table_index, @@ -781,16 +798,16 @@ FT_BEGIN_HEADER /* FT_Get_CMap_Language_ID */ /* */ /* <Description> */ - /* Return TrueType/sfnt specific cmap language ID. Definitions of */ - /* language ID values are in `ttnameid.h'. */ + /* Return cmap language ID as specified in the OpenType standard. */ + /* Definitions of language ID values are in file @FT_TRUETYPE_IDS_H. */ /* */ /* <Input> */ /* charmap :: */ /* The target charmap. */ /* */ /* <Return> */ - /* The language ID of `charmap'. If `charmap' doesn't belong to a */ - /* TrueType/sfnt face, just return~0 as the default value. */ + /* The language ID of `charmap'. If `charmap' doesn't belong to an */ + /* SFNT face, just return~0 as the default value. */ /* */ /* For a format~14 cmap (to access Unicode IVS), the return value is */ /* 0xFFFFFFFF. */ @@ -805,15 +822,15 @@ FT_BEGIN_HEADER /* FT_Get_CMap_Format */ /* */ /* <Description> */ - /* Return TrueType/sfnt specific cmap format. */ + /* Return the format of an SFNT `cmap' table. */ /* */ /* <Input> */ /* charmap :: */ /* The target charmap. */ /* */ /* <Return> */ - /* The format of `charmap'. If `charmap' doesn't belong to a */ - /* TrueType/sfnt face, return -1. */ + /* The format of `charmap'. If `charmap' doesn't belong to an SFNT */ + /* face, return -1. */ /* */ FT_EXPORT( FT_Long ) FT_Get_CMap_Format( FT_CharMap charmap ); diff --git a/thirdparty/freetype/include/freetype/tttags.h b/thirdparty/freetype/include/freetype/tttags.h index f3c9aa5fc7..32eb2fdc26 100644 --- a/thirdparty/freetype/include/freetype/tttags.h +++ b/thirdparty/freetype/include/freetype/tttags.h @@ -4,7 +4,7 @@ /* */ /* Tags for TrueType and OpenType tables (specification only). */ /* */ -/* Copyright 1996-2016 by */ +/* Copyright 1996-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -43,6 +43,7 @@ FT_BEGIN_HEADER #define TTAG_CBDT FT_MAKE_TAG( 'C', 'B', 'D', 'T' ) #define TTAG_CBLC FT_MAKE_TAG( 'C', 'B', 'L', 'C' ) #define TTAG_CFF FT_MAKE_TAG( 'C', 'F', 'F', ' ' ) +#define TTAG_CFF2 FT_MAKE_TAG( 'C', 'F', 'F', '2' ) #define TTAG_CID FT_MAKE_TAG( 'C', 'I', 'D', ' ' ) #define TTAG_cmap FT_MAKE_TAG( 'c', 'm', 'a', 'p' ) #define TTAG_cvar FT_MAKE_TAG( 'c', 'v', 'a', 'r' ) @@ -61,6 +62,7 @@ FT_BEGIN_HEADER #define TTAG_GPOS FT_MAKE_TAG( 'G', 'P', 'O', 'S' ) #define TTAG_GSUB FT_MAKE_TAG( 'G', 'S', 'U', 'B' ) #define TTAG_gvar FT_MAKE_TAG( 'g', 'v', 'a', 'r' ) +#define TTAG_HVAR FT_MAKE_TAG( 'H', 'V', 'A', 'R' ) #define TTAG_hdmx FT_MAKE_TAG( 'h', 'd', 'm', 'x' ) #define TTAG_head FT_MAKE_TAG( 'h', 'e', 'a', 'd' ) #define TTAG_hhea FT_MAKE_TAG( 'h', 'h', 'e', 'a' ) @@ -79,6 +81,7 @@ FT_BEGIN_HEADER #define TTAG_MMSD FT_MAKE_TAG( 'M', 'M', 'S', 'D' ) #define TTAG_mort FT_MAKE_TAG( 'm', 'o', 'r', 't' ) #define TTAG_morx FT_MAKE_TAG( 'm', 'o', 'r', 'x' ) +#define TTAG_MVAR FT_MAKE_TAG( 'M', 'V', 'A', 'R' ) #define TTAG_name FT_MAKE_TAG( 'n', 'a', 'm', 'e' ) #define TTAG_opbd FT_MAKE_TAG( 'o', 'p', 'b', 'd' ) #define TTAG_OS2 FT_MAKE_TAG( 'O', 'S', '/', '2' ) @@ -100,6 +103,7 @@ FT_BEGIN_HEADER #define TTAG_VDMX FT_MAKE_TAG( 'V', 'D', 'M', 'X' ) #define TTAG_vhea FT_MAKE_TAG( 'v', 'h', 'e', 'a' ) #define TTAG_vmtx FT_MAKE_TAG( 'v', 'm', 't', 'x' ) +#define TTAG_VVAR FT_MAKE_TAG( 'V', 'V', 'A', 'R' ) #define TTAG_wOFF FT_MAKE_TAG( 'w', 'O', 'F', 'F' ) diff --git a/thirdparty/freetype/include/freetype/ttunpat.h b/thirdparty/freetype/include/freetype/ttunpat.h index ca4676baf8..f5e417089e 100644 --- a/thirdparty/freetype/include/freetype/ttunpat.h +++ b/thirdparty/freetype/include/freetype/ttunpat.h @@ -3,9 +3,9 @@ /* ttunpat.h */ /* */ /* Definitions for the unpatented TrueType hinting system. */ -/* Obsolete, retained for backwards compatibility. */ +/* Obsolete, retained for backward compatibility. */ /* */ -/* Copyright 2003-2016 by */ +/* Copyright 2003-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* Written by Graham Asher <graham.asher@btinternet.com> */ diff --git a/thirdparty/freetype/include/ft2build.h b/thirdparty/freetype/include/ft2build.h index 1e8a9b4994..e7d808f3f4 100644 --- a/thirdparty/freetype/include/ft2build.h +++ b/thirdparty/freetype/include/ft2build.h @@ -4,7 +4,7 @@ /* */ /* FreeType 2 build and setup macros. */ /* */ -/* Copyright 1996-2016 by */ +/* Copyright 1996-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -34,7 +34,6 @@ #ifndef FT2BUILD_H_ #define FT2BUILD_H_ -#define FT2_BUILD_LIBRARY #include <freetype/config/ftheader.h> #endif /* FT2BUILD_H_ */ diff --git a/thirdparty/freetype/src/autofit/afangles.c b/thirdparty/freetype/src/autofit/afangles.c index b856e57a8b..ccdae84136 100644 --- a/thirdparty/freetype/src/autofit/afangles.c +++ b/thirdparty/freetype/src/autofit/afangles.c @@ -5,7 +5,7 @@ /* Routines used to compute vector angles with limited accuracy */ /* and very high speed. It also contains sorting routines (body). */ /* */ -/* Copyright 2003-2016 by */ +/* Copyright 2003-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/thirdparty/freetype/src/autofit/afblue.c b/thirdparty/freetype/src/autofit/afblue.c index 95786ed6f2..a00c3a0765 100644 --- a/thirdparty/freetype/src/autofit/afblue.c +++ b/thirdparty/freetype/src/autofit/afblue.c @@ -7,7 +7,7 @@ /* */ /* Auto-fitter data for blue strings (body). */ /* */ -/* Copyright 2013-2016 by */ +/* Copyright 2013-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -26,30 +26,76 @@ af_blue_strings[] = { /* */ + '\xF0', '\x9E', '\xA4', '\x8C', ' ', '\xF0', '\x9E', '\xA4', '\x85', ' ', '\xF0', '\x9E', '\xA4', '\x88', ' ', '\xF0', '\x9E', '\xA4', '\x8F', ' ', '\xF0', '\x9E', '\xA4', '\x94', ' ', '\xF0', '\x9E', '\xA4', '\x9A', /* 𞤌 𞤅 𞤈 𞤏 𞤔 𞤚 */ + '\0', + '\xF0', '\x9E', '\xA4', '\x82', ' ', '\xF0', '\x9E', '\xA4', '\x96', /* 𞤂 𞤖 */ + '\0', + '\xF0', '\x9E', '\xA4', '\xAC', ' ', '\xF0', '\x9E', '\xA4', '\xAE', ' ', '\xF0', '\x9E', '\xA4', '\xBB', ' ', '\xF0', '\x9E', '\xA4', '\xBC', ' ', '\xF0', '\x9E', '\xA4', '\xBE', /* 𞤬 𞤮 𞤻 𞤼 𞤾 */ + '\0', + '\xF0', '\x9E', '\xA4', '\xA4', ' ', '\xF0', '\x9E', '\xA4', '\xA8', ' ', '\xF0', '\x9E', '\xA4', '\xA9', ' ', '\xF0', '\x9E', '\xA4', '\xAD', ' ', '\xF0', '\x9E', '\xA4', '\xB4', ' ', '\xF0', '\x9E', '\xA4', '\xB8', ' ', '\xF0', '\x9E', '\xA4', '\xBA', ' ', '\xF0', '\x9E', '\xA5', '\x80', /* 𞤤 𞤨 𞤩 𞤭 𞤴 𞤸 𞤺 𞥀 */ + '\0', '\xD8', '\xA7', ' ', '\xD8', '\xA5', ' ', '\xD9', '\x84', ' ', '\xD9', '\x83', ' ', '\xD8', '\xB7', ' ', '\xD8', '\xB8', /* ا إ ل ك ط ظ */ '\0', '\xD8', '\xAA', ' ', '\xD8', '\xAB', ' ', '\xD8', '\xB7', ' ', '\xD8', '\xB8', ' ', '\xD9', '\x83', /* ت ث ط ظ ك */ '\0', '\xD9', '\x80', /* ـ */ '\0', - '\xD4', '\xB1', ' ', '\xD5', '\x84', ' ', '\xD5', '\x92', ' ', '\xD5', '\x93', ' ', '\xD4', '\xB2', ' ', '\xD4', '\xB3', ' ', '\xD4', '\xB4', ' ', '\xD5', '\x95', /* Ա Մ Ւ Փ Բ Գ Դ Օ */ + '\xD4', '\xB1', ' ', '\xD5', '\x84', ' ', '\xD5', '\x92', ' ', '\xD5', '\x8D', ' ', '\xD4', '\xB2', ' ', '\xD4', '\xB3', ' ', '\xD4', '\xB4', ' ', '\xD5', '\x95', /* Ա Մ Ւ Ս Բ Գ Դ Օ */ '\0', - '\xD5', '\x92', ' ', '\xD5', '\x88', ' ', '\xD5', '\x93', ' ', '\xD5', '\x83', ' ', '\xD5', '\x87', ' ', '\xD5', '\x8D', ' ', '\xD5', '\x8F', ' ', '\xD5', '\x95', /* Ւ Ո Փ Ճ Շ Ս Տ Օ */ + '\xD5', '\x92', ' ', '\xD5', '\x88', ' ', '\xD4', '\xB4', ' ', '\xD5', '\x83', ' ', '\xD5', '\x87', ' ', '\xD5', '\x8D', ' ', '\xD5', '\x8F', ' ', '\xD5', '\x95', /* Ւ Ո Դ Ճ Շ Ս Տ Օ */ '\0', - '\xD5', '\xA5', ' ', '\xD5', '\xA7', ' ', '\xD5', '\xAB', ' ', '\xD5', '\xB4', ' ', '\xD5', '\xBE', ' ', '\xD6', '\x83', ' ', '\xD6', '\x86', ' ', '\xD6', '\x83', /* ե է ի մ վ փ ֆ փ */ + '\xD5', '\xA5', ' ', '\xD5', '\xA7', ' ', '\xD5', '\xAB', ' ', '\xD5', '\xB4', ' ', '\xD5', '\xBE', ' ', '\xD6', '\x86', ' ', '\xD5', '\xB3', /* ե է ի մ վ ֆ ճ */ '\0', - '\xD5', '\xA1', ' ', '\xD5', '\xB5', ' ', '\xD6', '\x82', ' ', '\xD5', '\xBD', ' ', '\xD5', '\xA3', ' ', '\xD5', '\xBB', ' ', '\xD6', '\x80', ' ', '\xD6', '\x85', /* ա յ ւ ս գ ջ ր օ */ + '\xD5', '\xA1', ' ', '\xD5', '\xB5', ' ', '\xD6', '\x82', ' ', '\xD5', '\xBD', ' ', '\xD5', '\xA3', ' ', '\xD5', '\xB7', ' ', '\xD6', '\x80', ' ', '\xD6', '\x85', /* ա յ ւ ս գ շ ր օ */ '\0', '\xD5', '\xB0', ' ', '\xD5', '\xB8', ' ', '\xD5', '\xB3', ' ', '\xD5', '\xA1', ' ', '\xD5', '\xA5', ' ', '\xD5', '\xAE', ' ', '\xD5', '\xBD', ' ', '\xD6', '\x85', /* հ ո ճ ա ե ծ ս օ */ '\0', '\xD5', '\xA2', ' ', '\xD5', '\xA8', ' ', '\xD5', '\xAB', ' ', '\xD5', '\xAC', ' ', '\xD5', '\xB2', ' ', '\xD5', '\xBA', ' ', '\xD6', '\x83', ' ', '\xD6', '\x81', /* բ ը ի լ ղ պ փ ց */ '\0', + '\xF0', '\x90', '\xAC', '\x80', ' ', '\xF0', '\x90', '\xAC', '\x81', ' ', '\xF0', '\x90', '\xAC', '\x90', ' ', '\xF0', '\x90', '\xAC', '\x9B', /* 𐬀 𐬁 𐬐 𐬛 */ + '\0', + '\xF0', '\x90', '\xAC', '\x80', ' ', '\xF0', '\x90', '\xAC', '\x81', /* 𐬀 𐬁 */ + '\0', + '\xEA', '\x9A', '\xA7', ' ', '\xEA', '\x9A', '\xA8', ' ', '\xEA', '\x9B', '\x9B', ' ', '\xEA', '\x9B', '\x89', ' ', '\xEA', '\x9B', '\x81', ' ', '\xEA', '\x9B', '\x88', ' ', '\xEA', '\x9B', '\xAB', ' ', '\xEA', '\x9B', '\xAF', /* ꚧ ꚨ ꛛ ꛉ ꛁ ꛈ ꛫ ꛯ */ + '\0', + '\xEA', '\x9A', '\xAD', ' ', '\xEA', '\x9A', '\xB3', ' ', '\xEA', '\x9A', '\xB6', ' ', '\xEA', '\x9B', '\xAC', ' ', '\xEA', '\x9A', '\xA2', ' ', '\xEA', '\x9A', '\xBD', ' ', '\xEA', '\x9B', '\xAF', ' ', '\xEA', '\x9B', '\xB2', /* ꚭ ꚳ ꚶ ꛬ ꚢ ꚽ ꛯ ꛲ */ + '\0', '\xE0', '\xA6', '\x85', ' ', '\xE0', '\xA6', '\xA1', ' ', '\xE0', '\xA6', '\xA4', ' ', '\xE0', '\xA6', '\xA8', ' ', '\xE0', '\xA6', '\xAC', ' ', '\xE0', '\xA6', '\xAD', ' ', '\xE0', '\xA6', '\xB2', ' ', '\xE0', '\xA6', '\x95', /* অ ড ত ন ব ভ ল ক */ '\0', '\xE0', '\xA6', '\x87', ' ', '\xE0', '\xA6', '\x9F', ' ', '\xE0', '\xA6', '\xA0', ' ', '\xE0', '\xA6', '\xBF', ' ', '\xE0', '\xA7', '\x80', ' ', '\xE0', '\xA7', '\x88', ' ', '\xE0', '\xA7', '\x97', /* ই ট ঠ ি ী ৈ ৗ */ '\0', '\xE0', '\xA6', '\x93', ' ', '\xE0', '\xA6', '\x8F', ' ', '\xE0', '\xA6', '\xA1', ' ', '\xE0', '\xA6', '\xA4', ' ', '\xE0', '\xA6', '\xA8', ' ', '\xE0', '\xA6', '\xAC', ' ', '\xE0', '\xA6', '\xB2', ' ', '\xE0', '\xA6', '\x95', /* ও এ ড ত ন ব ল ক */ '\0', + '\xE1', '\x9D', '\x90', ' ', '\xE1', '\x9D', '\x88', /* ᝐ ᝈ */ + '\0', + '\xE1', '\x9D', '\x85', ' ', '\xE1', '\x9D', '\x8A', ' ', '\xE1', '\x9D', '\x8E', /* ᝅ ᝊ ᝎ */ + '\0', + '\xE1', '\x9D', '\x82', ' ', '\xE1', '\x9D', '\x83', ' ', '\xE1', '\x9D', '\x89', ' ', '\xE1', '\x9D', '\x8C', /* ᝂ ᝃ ᝉ ᝌ */ + '\0', + '\xE1', '\x9D', '\x80', ' ', '\xE1', '\x9D', '\x83', ' ', '\xE1', '\x9D', '\x86', ' ', '\xE1', '\x9D', '\x89', ' ', '\xE1', '\x9D', '\x8B', ' ', '\xE1', '\x9D', '\x8F', ' ', '\xE1', '\x9D', '\x91', /* ᝀ ᝃ ᝆ ᝉ ᝋ ᝏ ᝑ */ + '\0', + '\xE1', '\x97', '\x9C', ' ', '\xE1', '\x96', '\xB4', ' ', '\xE1', '\x90', '\x81', ' ', '\xE1', '\x92', '\xA3', ' ', '\xE1', '\x91', '\xAB', ' ', '\xE1', '\x91', '\x8E', ' ', '\xE1', '\x94', '\x91', ' ', '\xE1', '\x97', '\xB0', /* ᗜ ᖴ ᐁ ᒣ ᑫ ᑎ ᔑ ᗰ */ + '\0', + '\xE1', '\x97', '\xB6', ' ', '\xE1', '\x96', '\xB5', ' ', '\xE1', '\x92', '\xA7', ' ', '\xE1', '\x90', '\x83', ' ', '\xE1', '\x91', '\x8C', ' ', '\xE1', '\x92', '\x8D', ' ', '\xE1', '\x94', '\x91', ' ', '\xE1', '\x97', '\xA2', /* ᗶ ᖵ ᒧ ᐃ ᑌ ᒍ ᔑ ᗢ */ + '\0', + '\xE1', '\x93', '\x93', ' ', '\xE1', '\x93', '\x95', ' ', '\xE1', '\x93', '\x80', ' ', '\xE1', '\x93', '\x82', ' ', '\xE1', '\x93', '\x84', ' ', '\xE1', '\x95', '\x84', ' ', '\xE1', '\x95', '\x86', ' ', '\xE1', '\x98', '\xA3', /* ᓓ ᓕ ᓀ ᓂ ᓄ ᕄ ᕆ ᘣ */ + '\0', + '\xE1', '\x95', '\x83', ' ', '\xE1', '\x93', '\x82', ' ', '\xE1', '\x93', '\x80', ' ', '\xE1', '\x95', '\x82', ' ', '\xE1', '\x93', '\x97', ' ', '\xE1', '\x93', '\x9A', ' ', '\xE1', '\x95', '\x86', ' ', '\xE1', '\x98', '\xA3', /* ᕃ ᓂ ᓀ ᕂ ᓗ ᓚ ᕆ ᘣ */ + '\0', + '\xE1', '\x90', '\xAA', ' ', '\xE1', '\x99', '\x86', ' ', '\xE1', '\xA3', '\x98', ' ', '\xE1', '\x90', '\xA2', ' ', '\xE1', '\x92', '\xBE', ' ', '\xE1', '\xA3', '\x97', ' ', '\xE1', '\x94', '\x86', /* ᐪ ᙆ ᣘ ᐢ ᒾ ᣗ ᔆ */ + '\0', + '\xE1', '\x99', '\x86', ' ', '\xE1', '\x97', '\xAE', ' ', '\xE1', '\x92', '\xBB', ' ', '\xE1', '\x90', '\x9E', ' ', '\xE1', '\x94', '\x86', ' ', '\xE1', '\x92', '\xA1', ' ', '\xE1', '\x92', '\xA2', ' ', '\xE1', '\x93', '\x91', /* ᙆ ᗮ ᒻ ᐞ ᔆ ᒡ ᒢ ᓑ */ + '\0', + '\xF0', '\x90', '\x8A', '\xA7', ' ', '\xF0', '\x90', '\x8A', '\xAB', ' ', '\xF0', '\x90', '\x8A', '\xAC', ' ', '\xF0', '\x90', '\x8A', '\xAD', ' ', '\xF0', '\x90', '\x8A', '\xB1', ' ', '\xF0', '\x90', '\x8A', '\xBA', ' ', '\xF0', '\x90', '\x8A', '\xBC', ' ', '\xF0', '\x90', '\x8A', '\xBF', /* 𐊧 𐊫 𐊬 𐊭 𐊱 𐊺 𐊼 𐊿 */ + '\0', + '\xF0', '\x90', '\x8A', '\xA3', ' ', '\xF0', '\x90', '\x8A', '\xA7', ' ', '\xF0', '\x90', '\x8A', '\xB7', ' ', '\xF0', '\x90', '\x8B', '\x80', ' ', '\xF0', '\x90', '\x8A', '\xAB', ' ', '\xF0', '\x90', '\x8A', '\xB8', ' ', '\xF0', '\x90', '\x8B', '\x89', /* 𐊣 𐊧 𐊷 𐋀 𐊫 𐊸 𐋉 */ + '\0', + '\xF0', '\x91', '\x84', '\x83', ' ', '\xF0', '\x91', '\x84', '\x85', ' ', '\xF0', '\x91', '\x84', '\x89', ' ', '\xF0', '\x91', '\x84', '\x99', ' ', '\xF0', '\x91', '\x84', '\x97', /* 𑄃 𑄅 𑄉 𑄙 𑄗 */ + '\0', + '\xF0', '\x91', '\x84', '\x85', ' ', '\xF0', '\x91', '\x84', '\x9B', ' ', '\xF0', '\x91', '\x84', '\x9D', ' ', '\xF0', '\x91', '\x84', '\x97', ' ', '\xF0', '\x91', '\x84', '\x93', /* 𑄅 𑄛 𑄝 𑄗 𑄓 */ + '\0', + '\xF0', '\x91', '\x84', '\x96', '\xF0', '\x91', '\x84', '\xB3', '\xF0', '\x91', '\x84', '\xA2', ' ', '\xF0', '\x91', '\x84', '\x98', '\xF0', '\x91', '\x84', '\xB3', '\xF0', '\x91', '\x84', '\xA2', ' ', '\xF0', '\x91', '\x84', '\x99', '\xF0', '\x91', '\x84', '\xB3', '\xF0', '\x91', '\x84', '\xA2', ' ', '\xF0', '\x91', '\x84', '\xA4', '\xF0', '\x91', '\x84', '\xB3', '\xF0', '\x91', '\x84', '\xA2', ' ', '\xF0', '\x91', '\x84', '\xA5', '\xF0', '\x91', '\x84', '\xB3', '\xF0', '\x91', '\x84', '\xA2', /* 𑄖𑄳𑄢 𑄘𑄳𑄢 𑄙𑄳𑄢 𑄤𑄳𑄢 𑄥𑄳𑄢 */ + '\0', '\xE1', '\x8F', '\x86', ' ', '\xE1', '\x8E', '\xBB', ' ', '\xE1', '\x8E', '\xAC', ' ', '\xE1', '\x8F', '\x83', ' ', '\xE1', '\x8E', '\xA4', ' ', '\xE1', '\x8F', '\xA3', ' ', '\xE1', '\x8E', '\xA6', ' ', '\xE1', '\x8F', '\x95', /* Ꮖ Ꮋ Ꭼ Ꮓ Ꭴ Ꮳ Ꭶ Ꮥ */ '\0', '\xEA', '\xAE', '\x92', ' ', '\xEA', '\xAE', '\xA4', ' ', '\xEA', '\xAE', '\xB6', ' ', '\xEA', '\xAD', '\xB4', ' ', '\xEA', '\xAD', '\xBE', ' ', '\xEA', '\xAE', '\x97', ' ', '\xEA', '\xAE', '\x9D', ' ', '\xEA', '\xAE', '\xBF', /* ꮒ ꮤ ꮶ ꭴ ꭾ ꮗ ꮝ ꮿ */ @@ -58,6 +104,20 @@ '\0', '\xE1', '\x8F', '\xB8', ' ', '\xEA', '\xAE', '\x90', ' ', '\xEA', '\xAD', '\xB9', ' ', '\xEA', '\xAD', '\xBB', /* ᏸ ꮐ ꭹ ꭻ */ '\0', + '\xE2', '\xB2', '\x8C', ' ', '\xE2', '\xB2', '\x8E', ' ', '\xE2', '\xB2', '\xA0', ' ', '\xE2', '\xB3', '\x9E', ' ', '\xE2', '\xB2', '\x9E', ' ', '\xE2', '\xB2', '\x90', ' ', '\xE2', '\xB2', '\xA4', ' ', '\xE2', '\xB3', '\x8A', /* Ⲍ Ⲏ Ⲡ Ⳟ Ⲟ Ⲑ Ⲥ Ⳋ */ + '\0', + '\xE2', '\xB3', '\x90', ' ', '\xE2', '\xB3', '\x98', ' ', '\xE2', '\xB3', '\x9E', ' ', '\xE2', '\xB2', '\x8E', ' ', '\xE2', '\xB2', '\x9E', ' ', '\xE2', '\xB2', '\x90', ' ', '\xE2', '\xB3', '\x9C', ' ', '\xE2', '\xB2', '\xB0', /* Ⳑ Ⳙ Ⳟ Ⲏ Ⲟ Ⲑ Ⳝ Ⲱ */ + '\0', + '\xE2', '\xB2', '\x8D', ' ', '\xE2', '\xB2', '\x8F', ' ', '\xE2', '\xB2', '\xA1', ' ', '\xE2', '\xB3', '\x9F', ' ', '\xE2', '\xB2', '\x9F', ' ', '\xE2', '\xB2', '\x91', ' ', '\xE2', '\xB2', '\xA5', ' ', '\xE2', '\xB3', '\x8B', /* ⲍ ⲏ ⲡ ⳟ ⲟ ⲑ ⲥ ⳋ */ + '\0', + '\xE2', '\xB3', '\x91', ' ', '\xE2', '\xB3', '\x99', ' ', '\xE2', '\xB3', '\x9F', ' ', '\xE2', '\xB2', '\x8F', ' ', '\xE2', '\xB2', '\x9F', ' ', '\xE2', '\xB2', '\x91', ' ', '\xE2', '\xB3', '\x9D', ' ', '\xE2', '\xB3', '\x92', /* ⳑ ⳙ ⳟ ⲏ ⲟ ⲑ ⳝ Ⳓ */ + '\0', + '\xF0', '\x90', '\xA0', '\x8D', ' ', '\xF0', '\x90', '\xA0', '\x99', ' ', '\xF0', '\x90', '\xA0', '\xB3', ' ', '\xF0', '\x90', '\xA0', '\xB1', ' ', '\xF0', '\x90', '\xA0', '\x85', ' ', '\xF0', '\x90', '\xA0', '\x93', ' ', '\xF0', '\x90', '\xA0', '\xA3', ' ', '\xF0', '\x90', '\xA0', '\xA6', /* 𐠍 𐠙 𐠳 𐠱 𐠅 𐠓 𐠣 𐠦 */ + '\0', + '\xF0', '\x90', '\xA0', '\x83', ' ', '\xF0', '\x90', '\xA0', '\x8A', ' ', '\xF0', '\x90', '\xA0', '\x9B', ' ', '\xF0', '\x90', '\xA0', '\xA3', ' ', '\xF0', '\x90', '\xA0', '\xB3', ' ', '\xF0', '\x90', '\xA0', '\xB5', ' ', '\xF0', '\x90', '\xA0', '\x90', /* 𐠃 𐠊 𐠛 𐠣 𐠳 𐠵 𐠐 */ + '\0', + '\xF0', '\x90', '\xA0', '\x88', ' ', '\xF0', '\x90', '\xA0', '\x8F', ' ', '\xF0', '\x90', '\xA0', '\x96', /* 𐠈 𐠏 𐠖 */ + '\0', '\xD0', '\x91', ' ', '\xD0', '\x92', ' ', '\xD0', '\x95', ' ', '\xD0', '\x9F', ' ', '\xD0', '\x97', ' ', '\xD0', '\x9E', ' ', '\xD0', '\xA1', ' ', '\xD0', '\xAD', /* Б В Е П З О С Э */ '\0', '\xD0', '\x91', ' ', '\xD0', '\x92', ' ', '\xD0', '\x95', ' ', '\xD0', '\xA8', ' ', '\xD0', '\x97', ' ', '\xD0', '\x9E', ' ', '\xD0', '\xA1', ' ', '\xD0', '\xAD', /* Б В Е Ш З О С Э */ @@ -66,6 +126,14 @@ '\0', '\xD1', '\x80', ' ', '\xD1', '\x83', ' ', '\xD1', '\x84', /* р у ф */ '\0', + '\xF0', '\x90', '\x90', '\x82', ' ', '\xF0', '\x90', '\x90', '\x84', ' ', '\xF0', '\x90', '\x90', '\x8B', ' ', '\xF0', '\x90', '\x90', '\x97', ' ', '\xF0', '\x90', '\x90', '\x91', /* 𐐂 𐐄 𐐋 𐐗 𐐑 */ + '\0', + '\xF0', '\x90', '\x90', '\x80', ' ', '\xF0', '\x90', '\x90', '\x82', ' ', '\xF0', '\x90', '\x90', '\x84', ' ', '\xF0', '\x90', '\x90', '\x97', ' ', '\xF0', '\x90', '\x90', '\x9B', /* 𐐀 𐐂 𐐄 𐐗 𐐛 */ + '\0', + '\xF0', '\x90', '\x90', '\xAA', ' ', '\xF0', '\x90', '\x90', '\xAC', ' ', '\xF0', '\x90', '\x90', '\xB3', ' ', '\xF0', '\x90', '\x90', '\xBF', ' ', '\xF0', '\x90', '\x90', '\xB9', /* 𐐪 𐐬 𐐳 𐐿 𐐹 */ + '\0', + '\xF0', '\x90', '\x90', '\xA8', ' ', '\xF0', '\x90', '\x90', '\xAA', ' ', '\xF0', '\x90', '\x90', '\xAC', ' ', '\xF0', '\x90', '\x90', '\xBF', ' ', '\xF0', '\x90', '\x91', '\x83', /* 𐐨 𐐪 𐐬 𐐿 𐑃 */ + '\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', '\xA4', '\x88', ' ', '\xE0', '\xA4', '\x90', ' ', '\xE0', '\xA4', '\x93', ' ', '\xE0', '\xA4', '\x94', ' ', '\xE0', '\xA4', '\xBF', ' ', '\xE0', '\xA5', '\x80', ' ', '\xE0', '\xA5', '\x8B', ' ', '\xE0', '\xA5', '\x8C', /* ई ऐ ओ औ ि ी ो ौ */ @@ -98,6 +166,18 @@ '\0', '\xE2', '\xB4', '\x84', ' ', '\xE2', '\xB4', '\x85', ' ', '\xE2', '\xB4', '\x94', ' ', '\xE2', '\xB4', '\x95', ' ', '\xE2', '\xB4', '\x81', ' ', '\xE2', '\xB4', '\x82', ' ', '\xE2', '\xB4', '\x98', ' ', '\xE2', '\xB4', '\x9D', /* ⴄ ⴅ ⴔ ⴕ ⴁ ⴂ ⴘ ⴝ */ '\0', + '\xE2', '\xB0', '\x85', ' ', '\xE2', '\xB0', '\x94', ' ', '\xE2', '\xB0', '\xAA', ' ', '\xE2', '\xB0', '\x84', ' ', '\xE2', '\xB0', '\x82', ' ', '\xE2', '\xB0', '\x8A', ' ', '\xE2', '\xB0', '\xAB', ' ', '\xE2', '\xB0', '\x8B', /* Ⰵ Ⱄ Ⱚ Ⰴ Ⰲ Ⰺ Ⱛ Ⰻ */ + '\0', + '\xE2', '\xB0', '\x85', ' ', '\xE2', '\xB0', '\x84', ' ', '\xE2', '\xB0', '\x82', ' ', '\xE2', '\xB0', '\xAA', ' ', '\xE2', '\xB0', '\x9E', ' ', '\xE2', '\xB0', '\xA1', ' ', '\xE2', '\xB0', '\x8A', ' ', '\xE2', '\xB0', '\x94', /* Ⰵ Ⰴ Ⰲ Ⱚ Ⱎ Ⱑ Ⰺ Ⱄ */ + '\0', + '\xE2', '\xB0', '\xB5', ' ', '\xE2', '\xB1', '\x84', ' ', '\xE2', '\xB1', '\x9A', ' ', '\xE2', '\xB0', '\xB4', ' ', '\xE2', '\xB0', '\xB2', ' ', '\xE2', '\xB0', '\xBA', ' ', '\xE2', '\xB1', '\x9B', ' ', '\xE2', '\xB0', '\xBB', /* ⰵ ⱄ ⱚ ⰴ ⰲ ⰺ ⱛ ⰻ */ + '\0', + '\xE2', '\xB0', '\xB5', ' ', '\xE2', '\xB0', '\xB4', ' ', '\xE2', '\xB0', '\xB2', ' ', '\xE2', '\xB1', '\x9A', ' ', '\xE2', '\xB1', '\x8E', ' ', '\xE2', '\xB1', '\x91', ' ', '\xE2', '\xB0', '\xBA', ' ', '\xE2', '\xB1', '\x84', /* ⰵ ⰴ ⰲ ⱚ ⱎ ⱑ ⰺ ⱄ */ + '\0', + '\xF0', '\x90', '\x8C', '\xB2', ' ', '\xF0', '\x90', '\x8C', '\xB6', ' ', '\xF0', '\x90', '\x8D', '\x80', ' ', '\xF0', '\x90', '\x8D', '\x84', ' ', '\xF0', '\x90', '\x8C', '\xB4', ' ', '\xF0', '\x90', '\x8D', '\x83', ' ', '\xF0', '\x90', '\x8D', '\x88', ' ', '\xF0', '\x90', '\x8C', '\xBE', /* 𐌲 𐌶 𐍀 𐍄 𐌴 𐍃 𐍈 𐌾 */ + '\0', + '\xF0', '\x90', '\x8C', '\xB6', ' ', '\xF0', '\x90', '\x8C', '\xB4', ' ', '\xF0', '\x90', '\x8D', '\x83', ' ', '\xF0', '\x90', '\x8D', '\x88', /* 𐌶 𐌴 𐍃 𐍈 */ + '\0', '\xCE', '\x93', ' ', '\xCE', '\x92', ' ', '\xCE', '\x95', ' ', '\xCE', '\x96', ' ', '\xCE', '\x98', ' ', '\xCE', '\x9F', ' ', '\xCE', '\xA9', /* Γ Β Ε Ζ Θ Ο Ω */ '\0', '\xCE', '\x92', ' ', '\xCE', '\x94', ' ', '\xCE', '\x96', ' ', '\xCE', '\x9E', ' ', '\xCE', '\x98', ' ', '\xCE', '\x9F', /* Β Δ Ζ Ξ Θ Ο */ @@ -138,6 +218,16 @@ '\0', '\xE0', '\xB2', '\x85', ' ', '\xE0', '\xB2', '\x89', ' ', '\xE0', '\xB2', '\x8E', ' ', '\xE0', '\xB2', '\xB2', ' ', '\xE0', '\xB3', '\xA6', ' ', '\xE0', '\xB3', '\xA8', ' ', '\xE0', '\xB3', '\xAC', ' ', '\xE0', '\xB3', '\xAD', /* ಅ ಉ ಎ ಲ ೦ ೨ ೬ ೭ */ '\0', + '\xEA', '\xA4', '\x85', ' ', '\xEA', '\xA4', '\x8F', ' ', '\xEA', '\xA4', '\x81', ' ', '\xEA', '\xA4', '\x8B', ' ', '\xEA', '\xA4', '\x80', ' ', '\xEA', '\xA4', '\x8D', /* ꤅ ꤏ ꤁ ꤋ ꤀ ꤍ */ + '\0', + '\xEA', '\xA4', '\x88', ' ', '\xEA', '\xA4', '\x98', ' ', '\xEA', '\xA4', '\x80', ' ', '\xEA', '\xA4', '\x8D', ' ', '\xEA', '\xA4', '\xA2', /* ꤈ ꤘ ꤀ ꤍ ꤢ */ + '\0', + '\xEA', '\xA4', '\x96', ' ', '\xEA', '\xA4', '\xA1', /* ꤖ ꤡ */ + '\0', + '\xEA', '\xA4', '\x91', ' ', '\xEA', '\xA4', '\x9C', ' ', '\xEA', '\xA4', '\x9E', /* ꤑ ꤜ ꤞ */ + '\0', + '\xEA', '\xA4', '\x91', '\xEA', '\xA4', '\xAC', ' ', '\xEA', '\xA4', '\x9C', '\xEA', '\xA4', '\xAD', ' ', '\xEA', '\xA4', '\x94', '\xEA', '\xA4', '\xAC', /* ꤑ꤬ ꤜ꤭ ꤔ꤬ */ + '\0', '\xE1', '\x9E', '\x81', ' ', '\xE1', '\x9E', '\x91', ' ', '\xE1', '\x9E', '\x93', ' ', '\xE1', '\x9E', '\xA7', ' ', '\xE1', '\x9E', '\xA9', ' ', '\xE1', '\x9E', '\xB6', /* ខ ទ ន ឧ ឩ ា */ '\0', '\xE1', '\x9E', '\x80', '\xE1', '\x9F', '\x92', '\xE1', '\x9E', '\x80', ' ', '\xE1', '\x9E', '\x80', '\xE1', '\x9F', '\x92', '\xE1', '\x9E', '\x81', ' ', '\xE1', '\x9E', '\x80', '\xE1', '\x9F', '\x92', '\xE1', '\x9E', '\x82', ' ', '\xE1', '\x9E', '\x80', '\xE1', '\x9F', '\x92', '\xE1', '\x9E', '\x90', /* ក្ក ក្ខ ក្គ ក្ថ */ @@ -168,7 +258,9 @@ '\0', 'f', ' ', 'i', ' ', 'j', ' ', 'k', ' ', 'd', ' ', 'b', ' ', 'h', /* f i j k d b h */ '\0', - 'x', ' ', 'z', ' ', 'r', ' ', 'o', ' ', 'e', ' ', 's', ' ', 'c', /* x z r o e s c */ + 'u', ' ', 'v', ' ', 'x', ' ', 'z', ' ', 'o', ' ', 'e', ' ', 's', ' ', 'c', /* u v x z o e s c */ + '\0', + 'n', ' ', 'r', ' ', 'x', ' ', 'z', ' ', 'o', ' ', 'e', ' ', 's', ' ', 'c', /* n r x z o e s c */ '\0', 'p', ' ', 'q', ' ', 'g', ' ', 'j', ' ', 'y', /* p q g j y */ '\0', @@ -192,6 +284,10 @@ '\0', '\xE1', '\xB5', '\x96', ' ', '\xCA', '\xB8', ' ', '\xE1', '\xB5', '\x8D', /* ᵖ ʸ ᵍ */ '\0', + '\xEA', '\x93', '\xA1', ' ', '\xEA', '\x93', '\xA7', ' ', '\xEA', '\x93', '\xB1', ' ', '\xEA', '\x93', '\xB6', ' ', '\xEA', '\x93', '\xA9', ' ', '\xEA', '\x93', '\x9A', ' ', '\xEA', '\x93', '\xB5', ' ', '\xEA', '\x93', '\xB3', /* ꓡ ꓧ ꓱ ꓶ ꓩ ꓚ ꓵ ꓳ */ + '\0', + '\xEA', '\x93', '\x95', ' ', '\xEA', '\x93', '\x9C', ' ', '\xEA', '\x93', '\x9E', ' ', '\xEA', '\x93', '\xA1', ' ', '\xEA', '\x93', '\x9B', ' ', '\xEA', '\x93', '\xA2', ' ', '\xEA', '\x93', '\xB3', ' ', '\xEA', '\x93', '\xB4', /* ꓕ ꓜ ꓞ ꓡ ꓛ ꓢ ꓳ ꓴ */ + '\0', '\xE0', '\xB4', '\x92', ' ', '\xE0', '\xB4', '\x9F', ' ', '\xE0', '\xB4', '\xA0', ' ', '\xE0', '\xB4', '\xB1', ' ', '\xE0', '\xB4', '\x9A', ' ', '\xE0', '\xB4', '\xAA', ' ', '\xE0', '\xB4', '\x9A', '\xE0', '\xB5', '\x8D', '\xE0', '\xB4', '\x9A', ' ', '\xE0', '\xB4', '\xAA', '\xE0', '\xB5', '\x8D', '\xE0', '\xB4', '\xAA', /* ഒ ട ഠ റ ച പ ച്ച പ്പ */ '\0', '\xE0', '\xB4', '\x9F', ' ', '\xE0', '\xB4', '\xA0', ' ', '\xE0', '\xB4', '\xA7', ' ', '\xE0', '\xB4', '\xB6', ' ', '\xE0', '\xB4', '\x98', ' ', '\xE0', '\xB4', '\x9A', ' ', '\xE0', '\xB4', '\xA5', ' ', '\xE0', '\xB4', '\xB2', /* ട ഠ ധ ശ ഘ ച ഥ ല */ @@ -204,12 +300,68 @@ '\0', '\xE1', '\x80', '\x89', ' ', '\xE1', '\x80', '\x8A', ' ', '\xE1', '\x80', '\xA5', ' ', '\xE1', '\x80', '\xA9', ' ', '\xE1', '\x80', '\xA8', ' ', '\xE1', '\x81', '\x82', ' ', '\xE1', '\x81', '\x85', ' ', '\xE1', '\x81', '\x89', /* ဉ ည ဥ ဩ ဨ ၂ ၅ ၉ */ '\0', + '\xDF', '\x90', ' ', '\xDF', '\x89', ' ', '\xDF', '\x92', ' ', '\xDF', '\x9F', ' ', '\xDF', '\x96', ' ', '\xDF', '\x9C', ' ', '\xDF', '\xA0', ' ', '\xDF', '\xA5', /* ߐ ߉ ߒ ߟ ߖ ߜ ߠ ߥ */ + '\0', + '\xDF', '\x80', ' ', '\xDF', '\x98', ' ', '\xDF', '\xA1', ' ', '\xDF', '\xA0', ' ', '\xDF', '\xA5', /* ߀ ߘ ߡ ߠ ߥ */ + '\0', + '\xDF', '\x8F', ' ', '\xDF', '\x9B', ' ', '\xDF', '\x8B', /* ߏ ߛ ߋ */ + '\0', + '\xDF', '\x8E', ' ', '\xDF', '\x8F', ' ', '\xDF', '\x9B', ' ', '\xDF', '\x8B', /* ߎ ߏ ߛ ߋ */ + '\0', + '\xE1', '\xB1', '\x9B', ' ', '\xE1', '\xB1', '\x9C', ' ', '\xE1', '\xB1', '\x9D', ' ', '\xE1', '\xB1', '\xA1', ' ', '\xE1', '\xB1', '\xA2', ' ', '\xE1', '\xB1', '\xA5', /* ᱛ ᱜ ᱝ ᱡ ᱢ ᱥ */ + '\0', + '\xF0', '\x90', '\xB0', '\x97', ' ', '\xF0', '\x90', '\xB0', '\x98', ' ', '\xF0', '\x90', '\xB0', '\xA7', /* 𐰗 𐰘 𐰧 */ + '\0', + '\xF0', '\x90', '\xB0', '\x89', ' ', '\xF0', '\x90', '\xB0', '\x97', ' ', '\xF0', '\x90', '\xB0', '\xA6', ' ', '\xF0', '\x90', '\xB0', '\xA7', /* 𐰉 𐰗 𐰦 𐰧 */ + '\0', + '\xF0', '\x90', '\x92', '\xBE', ' ', '\xF0', '\x90', '\x93', '\x8D', ' ', '\xF0', '\x90', '\x93', '\x92', ' ', '\xF0', '\x90', '\x93', '\x93', ' ', '\xF0', '\x90', '\x92', '\xBB', ' ', '\xF0', '\x90', '\x93', '\x82', ' ', '\xF0', '\x90', '\x92', '\xB5', ' ', '\xF0', '\x90', '\x93', '\x86', /* 𐒾 𐓍 𐓒 𐓓 𐒻 𐓂 𐒵 𐓆 */ + '\0', + '\xF0', '\x90', '\x92', '\xB0', ' ', '\xF0', '\x90', '\x93', '\x8D', ' ', '\xF0', '\x90', '\x93', '\x82', ' ', '\xF0', '\x90', '\x92', '\xBF', ' ', '\xF0', '\x90', '\x93', '\x8E', ' ', '\xF0', '\x90', '\x92', '\xB9', /* 𐒰 𐓍 𐓂 𐒿 𐓎 𐒹 */ + '\0', + '\xF0', '\x90', '\x92', '\xBC', ' ', '\xF0', '\x90', '\x92', '\xBD', ' ', '\xF0', '\x90', '\x92', '\xBE', /* 𐒼 𐒽 𐒾 */ + '\0', + '\xF0', '\x90', '\x93', '\xB5', ' ', '\xF0', '\x90', '\x93', '\xB6', ' ', '\xF0', '\x90', '\x93', '\xBA', ' ', '\xF0', '\x90', '\x93', '\xBB', ' ', '\xF0', '\x90', '\x93', '\x9D', ' ', '\xF0', '\x90', '\x93', '\xA3', ' ', '\xF0', '\x90', '\x93', '\xAA', ' ', '\xF0', '\x90', '\x93', '\xAE', /* 𐓵 𐓶 𐓺 𐓻 𐓝 𐓣 𐓪 𐓮 */ + '\0', + '\xF0', '\x90', '\x93', '\x98', ' ', '\xF0', '\x90', '\x93', '\x9A', ' ', '\xF0', '\x90', '\x93', '\xA3', ' ', '\xF0', '\x90', '\x93', '\xB5', ' ', '\xF0', '\x90', '\x93', '\xA1', ' ', '\xF0', '\x90', '\x93', '\xA7', ' ', '\xF0', '\x90', '\x93', '\xAA', ' ', '\xF0', '\x90', '\x93', '\xB6', /* 𐓘 𐓚 𐓣 𐓵 𐓡 𐓧 𐓪 𐓶 */ + '\0', + '\xF0', '\x90', '\x93', '\xA4', ' ', '\xF0', '\x90', '\x93', '\xA6', ' ', '\xF0', '\x90', '\x93', '\xB8', ' ', '\xF0', '\x90', '\x93', '\xB9', ' ', '\xF0', '\x90', '\x93', '\x9B', /* 𐓤 𐓦 𐓸 𐓹 𐓛 */ + '\0', + '\xF0', '\x90', '\x93', '\xA4', ' ', '\xF0', '\x90', '\x93', '\xA5', ' ', '\xF0', '\x90', '\x93', '\xA6', /* 𐓤 𐓥 𐓦 */ + '\0', + '\xF0', '\x90', '\x92', '\x86', ' ', '\xF0', '\x90', '\x92', '\x89', ' ', '\xF0', '\x90', '\x92', '\x90', ' ', '\xF0', '\x90', '\x92', '\x92', ' ', '\xF0', '\x90', '\x92', '\x98', ' ', '\xF0', '\x90', '\x92', '\x9B', ' ', '\xF0', '\x90', '\x92', '\xA0', ' ', '\xF0', '\x90', '\x92', '\xA3', /* 𐒆 𐒉 𐒐 𐒒 𐒘 𐒛 𐒠 𐒣 */ + '\0', + '\xF0', '\x90', '\x92', '\x80', ' ', '\xF0', '\x90', '\x92', '\x82', ' ', '\xF0', '\x90', '\x92', '\x86', ' ', '\xF0', '\x90', '\x92', '\x88', ' ', '\xF0', '\x90', '\x92', '\x8A', ' ', '\xF0', '\x90', '\x92', '\x92', ' ', '\xF0', '\x90', '\x92', '\xA0', ' ', '\xF0', '\x90', '\x92', '\xA9', /* 𐒀 𐒂 𐒆 𐒈 𐒊 𐒒 𐒠 𐒩 */ + '\0', + '\xEA', '\xA2', '\x9C', ' ', '\xEA', '\xA2', '\x9E', ' ', '\xEA', '\xA2', '\xB3', ' ', '\xEA', '\xA2', '\x82', ' ', '\xEA', '\xA2', '\x96', ' ', '\xEA', '\xA2', '\x92', ' ', '\xEA', '\xA2', '\x9D', ' ', '\xEA', '\xA2', '\x9B', /* ꢜ ꢞ ꢳ ꢂ ꢖ ꢒ ꢝ ꢛ */ + '\0', + '\xEA', '\xA2', '\x82', ' ', '\xEA', '\xA2', '\xA8', ' ', '\xEA', '\xA2', '\xBA', ' ', '\xEA', '\xA2', '\xA4', ' ', '\xEA', '\xA2', '\x8E', /* ꢂ ꢨ ꢺ ꢤ ꢎ */ + '\0', + '\xF0', '\x90', '\x91', '\x95', ' ', '\xF0', '\x90', '\x91', '\x99', /* 𐑕 𐑙 */ + '\0', + '\xF0', '\x90', '\x91', '\x94', ' ', '\xF0', '\x90', '\x91', '\x96', ' ', '\xF0', '\x90', '\x91', '\x97', ' ', '\xF0', '\x90', '\x91', '\xB9', ' ', '\xF0', '\x90', '\x91', '\xBB', /* 𐑔 𐑖 𐑗 𐑹 𐑻 */ + '\0', + '\xF0', '\x90', '\x91', '\x9F', ' ', '\xF0', '\x90', '\x91', '\xA3', /* 𐑟 𐑣 */ + '\0', + '\xF0', '\x90', '\x91', '\xB1', ' ', '\xF0', '\x90', '\x91', '\xB2', ' ', '\xF0', '\x90', '\x91', '\xB3', ' ', '\xF0', '\x90', '\x91', '\xB4', ' ', '\xF0', '\x90', '\x91', '\xB8', ' ', '\xF0', '\x90', '\x91', '\xBA', ' ', '\xF0', '\x90', '\x91', '\xBC', /* 𐑱 𐑲 𐑳 𐑴 𐑸 𐑺 𐑼 */ + '\0', + '\xF0', '\x90', '\x91', '\xB4', ' ', '\xF0', '\x90', '\x91', '\xBB', ' ', '\xF0', '\x90', '\x91', '\xB9', /* 𐑴 𐑻 𐑹 */ + '\0', '\xE0', '\xB6', '\x89', ' ', '\xE0', '\xB6', '\x9A', ' ', '\xE0', '\xB6', '\x9D', ' ', '\xE0', '\xB6', '\xB3', ' ', '\xE0', '\xB6', '\xB4', ' ', '\xE0', '\xB6', '\xBA', ' ', '\xE0', '\xB6', '\xBD', ' ', '\xE0', '\xB7', '\x86', /* ඉ ක ඝ ඳ ප ය ල ෆ */ '\0', '\xE0', '\xB6', '\x91', ' ', '\xE0', '\xB6', '\x94', ' ', '\xE0', '\xB6', '\x9D', ' ', '\xE0', '\xB6', '\xA2', ' ', '\xE0', '\xB6', '\xA7', ' ', '\xE0', '\xB6', '\xAE', ' ', '\xE0', '\xB6', '\xB0', ' ', '\xE0', '\xB6', '\xBB', /* එ ඔ ඝ ජ ට ථ ධ ර */ '\0', '\xE0', '\xB6', '\xAF', ' ', '\xE0', '\xB6', '\xB3', ' ', '\xE0', '\xB6', '\x8B', ' ', '\xE0', '\xB6', '\xBD', ' ', '\xE0', '\xB6', '\xAD', '\xE0', '\xB7', '\x96', ' ', '\xE0', '\xB6', '\xAD', '\xE0', '\xB7', '\x94', ' ', '\xE0', '\xB6', '\xB6', '\xE0', '\xB7', '\x94', ' ', '\xE0', '\xB6', '\xAF', '\xE0', '\xB7', '\x94', /* ද ඳ උ ල තූ තු බු දු */ '\0', + '\xE1', '\xAE', '\x8B', ' ', '\xE1', '\xAE', '\x9E', ' ', '\xE1', '\xAE', '\xAE', ' ', '\xE1', '\xAE', '\xBD', ' ', '\xE1', '\xAE', '\xB0', ' ', '\xE1', '\xAE', '\x88', /* ᮋ ᮞ ᮮ ᮽ ᮰ ᮈ */ + '\0', + '\xE1', '\xAE', '\x84', ' ', '\xE1', '\xAE', '\x94', ' ', '\xE1', '\xAE', '\x95', ' ', '\xE1', '\xAE', '\x97', ' ', '\xE1', '\xAE', '\xB0', ' ', '\xE1', '\xAE', '\x86', ' ', '\xE1', '\xAE', '\x88', ' ', '\xE1', '\xAE', '\x89', /* ᮄ ᮔ ᮕ ᮗ ᮰ ᮆ ᮈ ᮉ */ + '\0', + '\xE1', '\xAE', '\xBC', ' ', '\xE1', '\xB3', '\x84', /* ᮼ ᳄ */ + '\0', + '\xEA', '\xAA', '\x86', ' ', '\xEA', '\xAA', '\x94', ' ', '\xEA', '\xAA', '\x92', ' ', '\xEA', '\xAA', '\x96', ' ', '\xEA', '\xAA', '\xAB', /* ꪆ ꪔ ꪒ ꪖ ꪫ */ + '\0', + '\xEA', '\xAA', '\x89', ' ', '\xEA', '\xAA', '\xAB', ' ', '\xEA', '\xAA', '\xAE', /* ꪉ ꪫ ꪮ */ + '\0', '\xE0', '\xAE', '\x89', ' ', '\xE0', '\xAE', '\x92', ' ', '\xE0', '\xAE', '\x93', ' ', '\xE0', '\xAE', '\xB1', ' ', '\xE0', '\xAE', '\x88', ' ', '\xE0', '\xAE', '\x95', ' ', '\xE0', '\xAE', '\x99', ' ', '\xE0', '\xAE', '\x9A', /* உ ஒ ஓ ற ஈ க ங ச */ '\0', '\xE0', '\xAE', '\x95', ' ', '\xE0', '\xAE', '\x9A', ' ', '\xE0', '\xAE', '\xB2', ' ', '\xE0', '\xAE', '\xB6', ' ', '\xE0', '\xAE', '\x89', ' ', '\xE0', '\xAE', '\x99', ' ', '\xE0', '\xAE', '\x9F', ' ', '\xE0', '\xAE', '\xAA', /* க ச ல ஶ உ ங ட ப */ @@ -231,6 +383,12 @@ '\xE0', '\xB8', '\x8D', ' ', '\xE0', '\xB8', '\x90', /* ญ ฐ */ '\0', '\xE0', '\xB9', '\x90', ' ', '\xE0', '\xB9', '\x91', ' ', '\xE0', '\xB9', '\x93', /* ๐ ๑ ๓ */ + '\0', + '\xE2', '\xB5', '\x94', ' ', '\xE2', '\xB5', '\x99', ' ', '\xE2', '\xB5', '\x9B', ' ', '\xE2', '\xB5', '\x9E', ' ', '\xE2', '\xB4', '\xB5', ' ', '\xE2', '\xB4', '\xBC', ' ', '\xE2', '\xB4', '\xB9', ' ', '\xE2', '\xB5', '\x8E', /* ⵔ ⵙ ⵛ ⵞ ⴵ ⴼ ⴹ ⵎ */ + '\0', + '\xEA', '\x97', '\x8D', ' ', '\xEA', '\x98', '\x96', ' ', '\xEA', '\x98', '\x99', ' ', '\xEA', '\x98', '\x9C', ' ', '\xEA', '\x96', '\x9C', ' ', '\xEA', '\x96', '\x9D', ' ', '\xEA', '\x94', '\x85', ' ', '\xEA', '\x95', '\xA2', /* ꗍ ꘖ ꘙ ꘜ ꖜ ꖝ ꔅ ꕢ */ + '\0', + '\xEA', '\x97', '\x8D', ' ', '\xEA', '\x98', '\x96', ' ', '\xEA', '\x98', '\x99', ' ', '\xEA', '\x97', '\x9E', ' ', '\xEA', '\x94', '\x85', ' ', '\xEA', '\x95', '\xA2', ' ', '\xEA', '\x96', '\x9C', ' ', '\xEA', '\x94', '\x86', /* ꗍ ꘖ ꘙ ꗞ ꔅ ꕢ ꖜ ꔆ */ #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', /* 他 们 你 來 們 到 和 地 */ @@ -281,6 +439,12 @@ af_blue_stringsets[] = { /* */ + { AF_BLUE_STRING_ADLAM_CAPITAL_TOP, AF_BLUE_PROPERTY_LATIN_TOP }, + { AF_BLUE_STRING_ADLAM_CAPITAL_BOTTOM, 0 }, + { AF_BLUE_STRING_ADLAM_SMALL_TOP, AF_BLUE_PROPERTY_LATIN_TOP | + AF_BLUE_PROPERTY_LATIN_X_HEIGHT }, + { AF_BLUE_STRING_ADLAM_SMALL_BOTTOM, 0 }, + { AF_BLUE_STRING_MAX, 0 }, { AF_BLUE_STRING_ARABIC_TOP, AF_BLUE_PROPERTY_LATIN_TOP }, { AF_BLUE_STRING_ARABIC_BOTTOM, 0 }, { AF_BLUE_STRING_ARABIC_JOIN, AF_BLUE_PROPERTY_LATIN_NEUTRAL }, @@ -293,6 +457,12 @@ { AF_BLUE_STRING_ARMENIAN_SMALL_BOTTOM, 0 }, { AF_BLUE_STRING_ARMENIAN_SMALL_DESCENDER, 0 }, { AF_BLUE_STRING_MAX, 0 }, + { AF_BLUE_STRING_AVESTAN_TOP, AF_BLUE_PROPERTY_LATIN_TOP }, + { AF_BLUE_STRING_AVESTAN_BOTTOM, 0 }, + { AF_BLUE_STRING_MAX, 0 }, + { AF_BLUE_STRING_BAMUM_TOP, AF_BLUE_PROPERTY_LATIN_TOP }, + { AF_BLUE_STRING_BAMUM_BOTTOM, 0 }, + { AF_BLUE_STRING_MAX, 0 }, { AF_BLUE_STRING_BENGALI_TOP, AF_BLUE_PROPERTY_LATIN_TOP }, { AF_BLUE_STRING_BENGALI_HEAD, AF_BLUE_PROPERTY_LATIN_TOP }, { AF_BLUE_STRING_BENGALI_BASE, AF_BLUE_PROPERTY_LATIN_TOP | @@ -300,6 +470,27 @@ AF_BLUE_PROPERTY_LATIN_X_HEIGHT }, { AF_BLUE_STRING_BENGALI_BASE, 0 }, { AF_BLUE_STRING_MAX, 0 }, + { AF_BLUE_STRING_BUHID_TOP, AF_BLUE_PROPERTY_LATIN_TOP }, + { AF_BLUE_STRING_BUHID_LARGE, AF_BLUE_PROPERTY_LATIN_TOP }, + { AF_BLUE_STRING_BUHID_SMALL, AF_BLUE_PROPERTY_LATIN_TOP | + AF_BLUE_PROPERTY_LATIN_X_HEIGHT }, + { AF_BLUE_STRING_BUHID_BOTTOM, 0 }, + { AF_BLUE_STRING_MAX, 0 }, + { AF_BLUE_STRING_CHAKMA_TOP, AF_BLUE_PROPERTY_LATIN_TOP }, + { AF_BLUE_STRING_CHAKMA_BOTTOM, 0 }, + { AF_BLUE_STRING_CHAKMA_DESCENDER, 0 }, + { AF_BLUE_STRING_MAX, 0 }, + { AF_BLUE_STRING_CANADIAN_SYLLABICS_TOP, AF_BLUE_PROPERTY_LATIN_TOP }, + { AF_BLUE_STRING_CANADIAN_SYLLABICS_BOTTOM, 0 }, + { AF_BLUE_STRING_CANADIAN_SYLLABICS_SMALL_TOP, AF_BLUE_PROPERTY_LATIN_TOP | + AF_BLUE_PROPERTY_LATIN_X_HEIGHT }, + { AF_BLUE_STRING_CANADIAN_SYLLABICS_SMALL_BOTTOM, 0 }, + { AF_BLUE_STRING_CANADIAN_SYLLABICS_SUPS_TOP, AF_BLUE_PROPERTY_LATIN_TOP }, + { AF_BLUE_STRING_CANADIAN_SYLLABICS_SUPS_BOTTOM, 0 }, + { AF_BLUE_STRING_MAX, 0 }, + { AF_BLUE_STRING_CARIAN_TOP, AF_BLUE_PROPERTY_LATIN_TOP }, + { AF_BLUE_STRING_CARIAN_BOTTOM, 0 }, + { AF_BLUE_STRING_MAX, 0 }, { AF_BLUE_STRING_CHEROKEE_CAPITAL, AF_BLUE_PROPERTY_LATIN_TOP }, { AF_BLUE_STRING_CHEROKEE_CAPITAL, 0 }, { AF_BLUE_STRING_CHEROKEE_SMALL_ASCENDER, AF_BLUE_PROPERTY_LATIN_TOP }, @@ -308,6 +499,17 @@ { AF_BLUE_STRING_CHEROKEE_SMALL, 0 }, { AF_BLUE_STRING_CHEROKEE_SMALL_DESCENDER, 0 }, { AF_BLUE_STRING_MAX, 0 }, + { AF_BLUE_STRING_COPTIC_CAPITAL_TOP, AF_BLUE_PROPERTY_LATIN_TOP }, + { AF_BLUE_STRING_COPTIC_CAPITAL_BOTTOM, 0 }, + { AF_BLUE_STRING_COPTIC_SMALL_TOP, AF_BLUE_PROPERTY_LATIN_TOP | + AF_BLUE_PROPERTY_LATIN_X_HEIGHT }, + { AF_BLUE_STRING_COPTIC_SMALL_BOTTOM, 0 }, + { AF_BLUE_STRING_MAX, 0 }, + { AF_BLUE_STRING_CYPRIOT_TOP, AF_BLUE_PROPERTY_LATIN_TOP }, + { AF_BLUE_STRING_CYPRIOT_BOTTOM, 0 }, + { AF_BLUE_STRING_CYPRIOT_SMALL, AF_BLUE_PROPERTY_LATIN_TOP }, + { AF_BLUE_STRING_CYPRIOT_SMALL, 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 | @@ -323,6 +525,12 @@ { AF_BLUE_STRING_DEVANAGARI_BASE, 0 }, { AF_BLUE_STRING_DEVANAGARI_BOTTOM, 0 }, { AF_BLUE_STRING_MAX, 0 }, + { AF_BLUE_STRING_DESERET_CAPITAL_TOP, AF_BLUE_PROPERTY_LATIN_TOP }, + { AF_BLUE_STRING_DESERET_CAPITAL_BOTTOM, 0 }, + { AF_BLUE_STRING_DESERET_SMALL_TOP, AF_BLUE_PROPERTY_LATIN_TOP | + AF_BLUE_PROPERTY_LATIN_X_HEIGHT }, + { AF_BLUE_STRING_DESERET_SMALL_BOTTOM, 0 }, + { AF_BLUE_STRING_MAX, 0 }, { AF_BLUE_STRING_ETHIOPIC_TOP, AF_BLUE_PROPERTY_LATIN_TOP }, { AF_BLUE_STRING_ETHIOPIC_BOTTOM, 0 }, { AF_BLUE_STRING_MAX, 0 }, @@ -340,6 +548,15 @@ { AF_BLUE_STRING_GEORGIAN_NUSKHURI_ASCENDER, AF_BLUE_PROPERTY_LATIN_TOP }, { AF_BLUE_STRING_GEORGIAN_NUSKHURI_DESCENDER, 0 }, { AF_BLUE_STRING_MAX, 0 }, + { AF_BLUE_STRING_GLAGOLITIC_CAPITAL_TOP, AF_BLUE_PROPERTY_LATIN_TOP }, + { AF_BLUE_STRING_GLAGOLITIC_CAPITAL_BOTTOM, 0 }, + { AF_BLUE_STRING_GLAGOLITIC_SMALL_TOP, AF_BLUE_PROPERTY_LATIN_TOP | + AF_BLUE_PROPERTY_LATIN_X_HEIGHT }, + { AF_BLUE_STRING_GLAGOLITIC_SMALL_BOTTOM, 0 }, + { AF_BLUE_STRING_MAX, 0 }, + { AF_BLUE_STRING_GOTHIC_TOP, AF_BLUE_PROPERTY_LATIN_TOP }, + { AF_BLUE_STRING_GOTHIC_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 }, @@ -368,6 +585,13 @@ { AF_BLUE_STRING_HEBREW_BOTTOM, 0 }, { AF_BLUE_STRING_HEBREW_DESCENDER, 0 }, { AF_BLUE_STRING_MAX, 0 }, + { AF_BLUE_STRING_KAYAH_LI_TOP, AF_BLUE_PROPERTY_LATIN_TOP | + AF_BLUE_PROPERTY_LATIN_X_HEIGHT }, + { AF_BLUE_STRING_KAYAH_LI_BOTTOM, 0 }, + { AF_BLUE_STRING_KAYAH_LI_ASCENDER, AF_BLUE_PROPERTY_LATIN_TOP }, + { AF_BLUE_STRING_KAYAH_LI_DESCENDER, 0 }, + { AF_BLUE_STRING_KAYAH_LI_LARGE_DESCENDER, 0 }, + { AF_BLUE_STRING_MAX, 0 }, { AF_BLUE_STRING_KANNADA_TOP, AF_BLUE_PROPERTY_LATIN_TOP }, { AF_BLUE_STRING_KANNADA_BOTTOM, 0 }, { AF_BLUE_STRING_MAX, 0 }, @@ -392,9 +616,9 @@ { 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_STRING_LATIN_SMALL_TOP, AF_BLUE_PROPERTY_LATIN_TOP | AF_BLUE_PROPERTY_LATIN_X_HEIGHT }, - { AF_BLUE_STRING_LATIN_SMALL, 0 }, + { AF_BLUE_STRING_LATIN_SMALL_BOTTOM, 0 }, { AF_BLUE_STRING_LATIN_SMALL_DESCENDER, 0 }, { AF_BLUE_STRING_MAX, 0 }, { AF_BLUE_STRING_LATIN_SUBS_CAPITAL_TOP, AF_BLUE_PROPERTY_LATIN_TOP }, @@ -413,6 +637,9 @@ { AF_BLUE_STRING_LATIN_SUPS_SMALL, 0 }, { AF_BLUE_STRING_LATIN_SUPS_SMALL_DESCENDER, 0 }, { AF_BLUE_STRING_MAX, 0 }, + { AF_BLUE_STRING_LISU_TOP, AF_BLUE_PROPERTY_LATIN_TOP }, + { AF_BLUE_STRING_LISU_BOTTOM, 0 }, + { AF_BLUE_STRING_MAX, 0 }, { AF_BLUE_STRING_MALAYALAM_TOP, AF_BLUE_PROPERTY_LATIN_TOP }, { AF_BLUE_STRING_MALAYALAM_BOTTOM, 0 }, { AF_BLUE_STRING_MAX, 0 }, @@ -422,14 +649,55 @@ { AF_BLUE_STRING_MYANMAR_ASCENDER, AF_BLUE_PROPERTY_LATIN_TOP }, { AF_BLUE_STRING_MYANMAR_DESCENDER, 0 }, { AF_BLUE_STRING_MAX, 0 }, + { AF_BLUE_STRING_NKO_TOP, AF_BLUE_PROPERTY_LATIN_TOP }, + { AF_BLUE_STRING_NKO_BOTTOM, 0 }, + { AF_BLUE_STRING_NKO_SMALL_TOP, AF_BLUE_PROPERTY_LATIN_TOP | + AF_BLUE_PROPERTY_LATIN_X_HEIGHT }, + { AF_BLUE_STRING_NKO_SMALL_BOTTOM, 0 }, + { AF_BLUE_STRING_MAX, 0 }, { AF_BLUE_STRING_MAX, 0 }, + { AF_BLUE_STRING_OL_CHIKI, AF_BLUE_PROPERTY_LATIN_TOP }, + { AF_BLUE_STRING_OL_CHIKI, 0 }, + { AF_BLUE_STRING_MAX, 0 }, + { AF_BLUE_STRING_OLD_TURKIC_TOP, AF_BLUE_PROPERTY_LATIN_TOP }, + { AF_BLUE_STRING_OLD_TURKIC_BOTTOM, 0 }, + { AF_BLUE_STRING_MAX, 0 }, + { AF_BLUE_STRING_OSAGE_CAPITAL_TOP, AF_BLUE_PROPERTY_LATIN_TOP }, + { AF_BLUE_STRING_OSAGE_CAPITAL_BOTTOM, 0 }, + { AF_BLUE_STRING_OSAGE_CAPITAL_DESCENDER, 0 }, + { AF_BLUE_STRING_OSAGE_SMALL_TOP, AF_BLUE_PROPERTY_LATIN_TOP | + AF_BLUE_PROPERTY_LATIN_X_HEIGHT }, + { AF_BLUE_STRING_OSAGE_SMALL_BOTTOM, 0 }, + { AF_BLUE_STRING_OSAGE_SMALL_ASCENDER, AF_BLUE_PROPERTY_LATIN_TOP }, + { AF_BLUE_STRING_OSAGE_SMALL_DESCENDER, 0 }, + { AF_BLUE_STRING_MAX, 0 }, + { AF_BLUE_STRING_OSMANYA_TOP, AF_BLUE_PROPERTY_LATIN_TOP }, + { AF_BLUE_STRING_OSMANYA_BOTTOM, 0 }, + { AF_BLUE_STRING_MAX, 0 }, + { AF_BLUE_STRING_SAURASHTRA_TOP, AF_BLUE_PROPERTY_LATIN_TOP }, + { AF_BLUE_STRING_SAURASHTRA_BOTTOM, 0 }, + { AF_BLUE_STRING_MAX, 0 }, + { AF_BLUE_STRING_SHAVIAN_TOP, AF_BLUE_PROPERTY_LATIN_TOP }, + { AF_BLUE_STRING_SHAVIAN_BOTTOM, 0 }, + { AF_BLUE_STRING_SHAVIAN_DESCENDER, 0 }, + { AF_BLUE_STRING_SHAVIAN_SMALL_TOP, AF_BLUE_PROPERTY_LATIN_TOP | + AF_BLUE_PROPERTY_LATIN_X_HEIGHT }, + { AF_BLUE_STRING_SHAVIAN_SMALL_BOTTOM, 0 }, + { AF_BLUE_STRING_MAX, 0 }, { AF_BLUE_STRING_SINHALA_TOP, AF_BLUE_PROPERTY_LATIN_TOP }, { AF_BLUE_STRING_SINHALA_BOTTOM, 0 }, { AF_BLUE_STRING_SINHALA_DESCENDER, 0 }, { AF_BLUE_STRING_MAX, 0 }, + { AF_BLUE_STRING_SUNDANESE_TOP, AF_BLUE_PROPERTY_LATIN_TOP }, + { AF_BLUE_STRING_SUNDANESE_BOTTOM, 0 }, + { AF_BLUE_STRING_SUNDANESE_DESCENDER, 0 }, + { AF_BLUE_STRING_MAX, 0 }, { AF_BLUE_STRING_TAMIL_TOP, AF_BLUE_PROPERTY_LATIN_TOP }, { AF_BLUE_STRING_TAMIL_BOTTOM, 0 }, { AF_BLUE_STRING_MAX, 0 }, + { AF_BLUE_STRING_TAI_VIET_TOP, AF_BLUE_PROPERTY_LATIN_TOP }, + { AF_BLUE_STRING_TAI_VIET_BOTTOM, 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 }, @@ -442,6 +710,12 @@ { AF_BLUE_STRING_THAI_LARGE_DESCENDER, 0 }, { AF_BLUE_STRING_THAI_DIGIT_TOP, 0 }, { AF_BLUE_STRING_MAX, 0 }, + { AF_BLUE_STRING_TIFINAGH, AF_BLUE_PROPERTY_LATIN_TOP }, + { AF_BLUE_STRING_TIFINAGH, 0 }, + { AF_BLUE_STRING_MAX, 0 }, + { AF_BLUE_STRING_VAI_TOP, AF_BLUE_PROPERTY_LATIN_TOP }, + { AF_BLUE_STRING_VAI_BOTTOM, 0 }, + { AF_BLUE_STRING_MAX, 0 }, #ifdef AF_CONFIG_OPTION_CJK { AF_BLUE_STRING_CJK_TOP, AF_BLUE_PROPERTY_CJK_TOP }, { AF_BLUE_STRING_CJK_BOTTOM, 0 }, diff --git a/thirdparty/freetype/src/autofit/afblue.cin b/thirdparty/freetype/src/autofit/afblue.cin index 0c3cae818f..f9080c54d4 100644 --- a/thirdparty/freetype/src/autofit/afblue.cin +++ b/thirdparty/freetype/src/autofit/afblue.cin @@ -4,7 +4,7 @@ /* */ /* Auto-fitter data for blue strings (body). */ /* */ -/* Copyright 2013-2016 by */ +/* Copyright 2013-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/thirdparty/freetype/src/autofit/afblue.dat b/thirdparty/freetype/src/autofit/afblue.dat index 0734ec71f0..454923e9ca 100644 --- a/thirdparty/freetype/src/autofit/afblue.dat +++ b/thirdparty/freetype/src/autofit/afblue.dat @@ -2,7 +2,7 @@ // // Auto-fitter data for blue strings. // -// Copyright 2013-2016 by +// Copyright 2013-2017 by // David Turner, Robert Wilhelm, and Werner Lemberg. // // This file is part of the FreeType project, and may only be used, @@ -74,6 +74,15 @@ AF_BLUE_STRING_ENUM AF_BLUE_STRINGS_ARRAY AF_BLUE_STRING_MAX_LEN: + AF_BLUE_STRING_ADLAM_CAPITAL_TOP + "𞤌 𞤅 𞤈 𞤏 𞤔 𞤚" + AF_BLUE_STRING_ADLAM_CAPITAL_BOTTOM + "𞤂 𞤖" + AF_BLUE_STRING_ADLAM_SMALL_TOP + "𞤬 𞤮 𞤻 𞤼 𞤾" + AF_BLUE_STRING_ADLAM_SMALL_BOTTOM + "𞤤 𞤨 𞤩 𞤭 𞤴 𞤸 𞤺 𞥀" + AF_BLUE_STRING_ARABIC_TOP "ا إ ل ك ط ظ" AF_BLUE_STRING_ARABIC_BOTTOM @@ -87,18 +96,28 @@ AF_BLUE_STRING_ENUM AF_BLUE_STRINGS_ARRAY AF_BLUE_STRING_MAX_LEN: "ـ" AF_BLUE_STRING_ARMENIAN_CAPITAL_TOP - "Ա Մ Ւ Փ Բ Գ Դ Օ" + "Ա Մ Ւ Ս Բ Գ Դ Օ" AF_BLUE_STRING_ARMENIAN_CAPITAL_BOTTOM - "Ւ Ո Փ Ճ Շ Ս Տ Օ" + "Ւ Ո Դ Ճ Շ Ս Տ Օ" AF_BLUE_STRING_ARMENIAN_SMALL_ASCENDER - "ե է ի մ վ փ ֆ փ" + "ե է ի մ վ ֆ ճ" AF_BLUE_STRING_ARMENIAN_SMALL_TOP - "ա յ ւ ս գ ջ ր օ" + "ա յ ւ ս գ շ ր օ" AF_BLUE_STRING_ARMENIAN_SMALL_BOTTOM "հ ո ճ ա ե ծ ս օ" AF_BLUE_STRING_ARMENIAN_SMALL_DESCENDER "բ ը ի լ ղ պ փ ց" + AF_BLUE_STRING_AVESTAN_TOP + "𐬀 𐬁 𐬐 𐬛" + AF_BLUE_STRING_AVESTAN_BOTTOM + "𐬀 𐬁" + + AF_BLUE_STRING_BAMUM_TOP + "ꚧ ꚨ ꛛ ꛉ ꛁ ꛈ ꛫ ꛯ" + AF_BLUE_STRING_BAMUM_BOTTOM + "ꚭ ꚳ ꚶ ꛬ ꚢ ꚽ ꛯ ꛲" + AF_BLUE_STRING_BENGALI_BASE "অ ড ত ন ব ভ ল ক" AF_BLUE_STRING_BENGALI_TOP @@ -106,6 +125,40 @@ AF_BLUE_STRING_ENUM AF_BLUE_STRINGS_ARRAY AF_BLUE_STRING_MAX_LEN: AF_BLUE_STRING_BENGALI_HEAD "ও এ ড ত ন ব ল ক" + AF_BLUE_STRING_BUHID_TOP + "ᝐ ᝈ" + AF_BLUE_STRING_BUHID_LARGE + "ᝅ ᝊ ᝎ" + AF_BLUE_STRING_BUHID_SMALL + "ᝂ ᝃ ᝉ ᝌ" + AF_BLUE_STRING_BUHID_BOTTOM + "ᝀ ᝃ ᝆ ᝉ ᝋ ᝏ ᝑ" + + AF_BLUE_STRING_CANADIAN_SYLLABICS_TOP + "ᗜ ᖴ ᐁ ᒣ ᑫ ᑎ ᔑ ᗰ" + AF_BLUE_STRING_CANADIAN_SYLLABICS_BOTTOM + "ᗶ ᖵ ᒧ ᐃ ᑌ ᒍ ᔑ ᗢ" + AF_BLUE_STRING_CANADIAN_SYLLABICS_SMALL_TOP + "ᓓ ᓕ ᓀ ᓂ ᓄ ᕄ ᕆ ᘣ" + AF_BLUE_STRING_CANADIAN_SYLLABICS_SMALL_BOTTOM + "ᕃ ᓂ ᓀ ᕂ ᓗ ᓚ ᕆ ᘣ" + AF_BLUE_STRING_CANADIAN_SYLLABICS_SUPS_TOP + "ᐪ ᙆ ᣘ ᐢ ᒾ ᣗ ᔆ" + AF_BLUE_STRING_CANADIAN_SYLLABICS_SUPS_BOTTOM + "ᙆ ᗮ ᒻ ᐞ ᔆ ᒡ ᒢ ᓑ" + + AF_BLUE_STRING_CARIAN_TOP + "𐊧 𐊫 𐊬 𐊭 𐊱 𐊺 𐊼 𐊿" + AF_BLUE_STRING_CARIAN_BOTTOM + "𐊣 𐊧 𐊷 𐋀 𐊫 𐊸 𐋉" + + AF_BLUE_STRING_CHAKMA_TOP + "𑄃 𑄅 𑄉 𑄙 𑄗" + AF_BLUE_STRING_CHAKMA_BOTTOM + "𑄅 𑄛 𑄝 𑄗 𑄓" + AF_BLUE_STRING_CHAKMA_DESCENDER + "𑄖𑄳𑄢 𑄘𑄳𑄢 𑄙𑄳𑄢 𑄤𑄳𑄢 𑄥𑄳𑄢" + AF_BLUE_STRING_CHEROKEE_CAPITAL "Ꮖ Ꮋ Ꭼ Ꮓ Ꭴ Ꮳ Ꭶ Ꮥ" AF_BLUE_STRING_CHEROKEE_SMALL_ASCENDER @@ -115,6 +168,22 @@ AF_BLUE_STRING_ENUM AF_BLUE_STRINGS_ARRAY AF_BLUE_STRING_MAX_LEN: AF_BLUE_STRING_CHEROKEE_SMALL_DESCENDER "ᏸ ꮐ ꭹ ꭻ" + AF_BLUE_STRING_COPTIC_CAPITAL_TOP + "Ⲍ Ⲏ Ⲡ Ⳟ Ⲟ Ⲑ Ⲥ Ⳋ" + AF_BLUE_STRING_COPTIC_CAPITAL_BOTTOM + "Ⳑ Ⳙ Ⳟ Ⲏ Ⲟ Ⲑ Ⳝ Ⲱ" + AF_BLUE_STRING_COPTIC_SMALL_TOP + "ⲍ ⲏ ⲡ ⳟ ⲟ ⲑ ⲥ ⳋ" + AF_BLUE_STRING_COPTIC_SMALL_BOTTOM + "ⳑ ⳙ ⳟ ⲏ ⲟ ⲑ ⳝ Ⳓ" + + AF_BLUE_STRING_CYPRIOT_TOP + "𐠍 𐠙 𐠳 𐠱 𐠅 𐠓 𐠣 𐠦" + AF_BLUE_STRING_CYPRIOT_BOTTOM + "𐠃 𐠊 𐠛 𐠣 𐠳 𐠵 𐠐" + AF_BLUE_STRING_CYPRIOT_SMALL + "𐠈 𐠏 𐠖" + AF_BLUE_STRING_CYRILLIC_CAPITAL_TOP "Б В Е П З О С Э" AF_BLUE_STRING_CYRILLIC_CAPITAL_BOTTOM @@ -124,6 +193,15 @@ AF_BLUE_STRING_ENUM AF_BLUE_STRINGS_ARRAY AF_BLUE_STRING_MAX_LEN: AF_BLUE_STRING_CYRILLIC_SMALL_DESCENDER "р у ф" + AF_BLUE_STRING_DESERET_CAPITAL_TOP + "𐐂 𐐄 𐐋 𐐗 𐐑" + AF_BLUE_STRING_DESERET_CAPITAL_BOTTOM + "𐐀 𐐂 𐐄 𐐗 𐐛" + AF_BLUE_STRING_DESERET_SMALL_TOP + "𐐪 𐐬 𐐳 𐐿 𐐹" + AF_BLUE_STRING_DESERET_SMALL_BOTTOM + "𐐨 𐐪 𐐬 𐐿 𐑃" + AF_BLUE_STRING_DEVANAGARI_BASE "क म अ आ थ ध भ श" AF_BLUE_STRING_DEVANAGARI_TOP @@ -164,6 +242,20 @@ AF_BLUE_STRING_ENUM AF_BLUE_STRINGS_ARRAY AF_BLUE_STRING_MAX_LEN: AF_BLUE_STRING_GEORGIAN_NUSKHURI_DESCENDER "ⴄ ⴅ ⴔ ⴕ ⴁ ⴂ ⴘ ⴝ" + AF_BLUE_STRING_GLAGOLITIC_CAPITAL_TOP + "Ⰵ Ⱄ Ⱚ Ⰴ Ⰲ Ⰺ Ⱛ Ⰻ" + AF_BLUE_STRING_GLAGOLITIC_CAPITAL_BOTTOM + "Ⰵ Ⰴ Ⰲ Ⱚ Ⱎ Ⱑ Ⰺ Ⱄ" + AF_BLUE_STRING_GLAGOLITIC_SMALL_TOP + "ⰵ ⱄ ⱚ ⰴ ⰲ ⰺ ⱛ ⰻ" + AF_BLUE_STRING_GLAGOLITIC_SMALL_BOTTOM + "ⰵ ⰴ ⰲ ⱚ ⱎ ⱑ ⰺ ⱄ" + + AF_BLUE_STRING_GOTHIC_TOP + "𐌲 𐌶 𐍀 𐍄 𐌴 𐍃 𐍈 𐌾" + AF_BLUE_STRING_GOTHIC_BOTTOM + "𐌶 𐌴 𐍃 𐍈" + AF_BLUE_STRING_GREEK_CAPITAL_TOP "Γ Β Ε Ζ Θ Ο Ω" AF_BLUE_STRING_GREEK_CAPITAL_BOTTOM @@ -209,6 +301,17 @@ AF_BLUE_STRING_ENUM AF_BLUE_STRINGS_ARRAY AF_BLUE_STRING_MAX_LEN: AF_BLUE_STRING_KANNADA_BOTTOM "ಅ ಉ ಎ ಲ ೦ ೨ ೬ ೭" + AF_BLUE_STRING_KAYAH_LI_TOP + "꤅ ꤏ ꤁ ꤋ ꤀ ꤍ" + AF_BLUE_STRING_KAYAH_LI_BOTTOM + "꤈ ꤘ ꤀ ꤍ ꤢ" + AF_BLUE_STRING_KAYAH_LI_ASCENDER + "ꤖ ꤡ" + AF_BLUE_STRING_KAYAH_LI_DESCENDER + "ꤑ ꤜ ꤞ" + AF_BLUE_STRING_KAYAH_LI_LARGE_DESCENDER + "ꤑ꤬ ꤜ꤭ ꤔ꤬" + AF_BLUE_STRING_KHMER_TOP "ខ ទ ន ឧ ឩ ា" AF_BLUE_STRING_KHMER_SUBSCRIPT_TOP @@ -242,8 +345,10 @@ AF_BLUE_STRING_ENUM AF_BLUE_STRINGS_ARRAY AF_BLUE_STRING_MAX_LEN: "H E Z L O C U S" AF_BLUE_STRING_LATIN_SMALL_F_TOP "f i j k d b h" - AF_BLUE_STRING_LATIN_SMALL - "x z r o e s c" + AF_BLUE_STRING_LATIN_SMALL_TOP + "u v x z o e s c" + AF_BLUE_STRING_LATIN_SMALL_BOTTOM + "n r x z o e s c" AF_BLUE_STRING_LATIN_SMALL_DESCENDER "p q g j y" @@ -272,6 +377,11 @@ AF_BLUE_STRING_ENUM AF_BLUE_STRINGS_ARRAY AF_BLUE_STRING_MAX_LEN: AF_BLUE_STRING_LATIN_SUPS_SMALL_DESCENDER "ᵖ ʸ ᵍ" + AF_BLUE_STRING_LISU_TOP + "ꓡ ꓧ ꓱ ꓶ ꓩ ꓚ ꓵ ꓳ" + AF_BLUE_STRING_LISU_BOTTOM + "ꓕ ꓜ ꓞ ꓡ ꓛ ꓢ ꓳ ꓴ" + AF_BLUE_STRING_MALAYALAM_TOP "ഒ ട ഠ റ ച പ ച്ച പ്പ" AF_BLUE_STRING_MALAYALAM_BOTTOM @@ -286,6 +396,59 @@ AF_BLUE_STRING_ENUM AF_BLUE_STRINGS_ARRAY AF_BLUE_STRING_MAX_LEN: AF_BLUE_STRING_MYANMAR_DESCENDER "ဉ ည ဥ ဩ ဨ ၂ ၅ ၉" + AF_BLUE_STRING_NKO_TOP + "ߐ ߉ ߒ ߟ ߖ ߜ ߠ ߥ" + AF_BLUE_STRING_NKO_BOTTOM + "߀ ߘ ߡ ߠ ߥ" + AF_BLUE_STRING_NKO_SMALL_TOP + "ߏ ߛ ߋ" + AF_BLUE_STRING_NKO_SMALL_BOTTOM + "ߎ ߏ ߛ ߋ" + + AF_BLUE_STRING_OL_CHIKI + "ᱛ ᱜ ᱝ ᱡ ᱢ ᱥ" + + AF_BLUE_STRING_OLD_TURKIC_TOP + "𐰗 𐰘 𐰧" + AF_BLUE_STRING_OLD_TURKIC_BOTTOM + "𐰉 𐰗 𐰦 𐰧" + + AF_BLUE_STRING_OSAGE_CAPITAL_TOP + "𐒾 𐓍 𐓒 𐓓 𐒻 𐓂 𐒵 𐓆" + AF_BLUE_STRING_OSAGE_CAPITAL_BOTTOM + "𐒰 𐓍 𐓂 𐒿 𐓎 𐒹" + AF_BLUE_STRING_OSAGE_CAPITAL_DESCENDER + "𐒼 𐒽 𐒾" + AF_BLUE_STRING_OSAGE_SMALL_TOP + "𐓵 𐓶 𐓺 𐓻 𐓝 𐓣 𐓪 𐓮" + AF_BLUE_STRING_OSAGE_SMALL_BOTTOM + "𐓘 𐓚 𐓣 𐓵 𐓡 𐓧 𐓪 𐓶" + AF_BLUE_STRING_OSAGE_SMALL_ASCENDER + "𐓤 𐓦 𐓸 𐓹 𐓛" + AF_BLUE_STRING_OSAGE_SMALL_DESCENDER + "𐓤 𐓥 𐓦" + + AF_BLUE_STRING_OSMANYA_TOP + "𐒆 𐒉 𐒐 𐒒 𐒘 𐒛 𐒠 𐒣" + AF_BLUE_STRING_OSMANYA_BOTTOM + "𐒀 𐒂 𐒆 𐒈 𐒊 𐒒 𐒠 𐒩" + + AF_BLUE_STRING_SAURASHTRA_TOP + "ꢜ ꢞ ꢳ ꢂ ꢖ ꢒ ꢝ ꢛ" + AF_BLUE_STRING_SAURASHTRA_BOTTOM + "ꢂ ꢨ ꢺ ꢤ ꢎ" + + AF_BLUE_STRING_SHAVIAN_TOP + "𐑕 𐑙" + AF_BLUE_STRING_SHAVIAN_BOTTOM + "𐑔 𐑖 𐑗 𐑹 𐑻" + AF_BLUE_STRING_SHAVIAN_DESCENDER + "𐑟 𐑣" + AF_BLUE_STRING_SHAVIAN_SMALL_TOP + "𐑱 𐑲 𐑳 𐑴 𐑸 𐑺 𐑼" + AF_BLUE_STRING_SHAVIAN_SMALL_BOTTOM + "𐑴 𐑻 𐑹" + AF_BLUE_STRING_SINHALA_TOP "ඉ ක ඝ ඳ ප ය ල ෆ" AF_BLUE_STRING_SINHALA_BOTTOM @@ -293,6 +456,18 @@ AF_BLUE_STRING_ENUM AF_BLUE_STRINGS_ARRAY AF_BLUE_STRING_MAX_LEN: AF_BLUE_STRING_SINHALA_DESCENDER "ද ඳ උ ල තූ තු බු දු" + AF_BLUE_STRING_SUNDANESE_TOP + "ᮋ ᮞ ᮮ ᮽ ᮰ ᮈ" + AF_BLUE_STRING_SUNDANESE_BOTTOM + "ᮄ ᮔ ᮕ ᮗ ᮰ ᮆ ᮈ ᮉ" + AF_BLUE_STRING_SUNDANESE_DESCENDER + "ᮼ ᳄" + + AF_BLUE_STRING_TAI_VIET_TOP + "ꪆ ꪔ ꪒ ꪖ ꪫ" + AF_BLUE_STRING_TAI_VIET_BOTTOM + "ꪉ ꪫ ꪮ" + AF_BLUE_STRING_TAMIL_TOP "உ ஒ ஓ ற ஈ க ங ச" AF_BLUE_STRING_TAMIL_BOTTOM @@ -318,6 +493,14 @@ AF_BLUE_STRING_ENUM AF_BLUE_STRINGS_ARRAY AF_BLUE_STRING_MAX_LEN: AF_BLUE_STRING_THAI_DIGIT_TOP "๐ ๑ ๓" + AF_BLUE_STRING_TIFINAGH + "ⵔ ⵙ ⵛ ⵞ ⴵ ⴼ ⴹ ⵎ" + + AF_BLUE_STRING_VAI_TOP + "ꗍ ꘖ ꘙ ꘜ ꖜ ꖝ ꔅ ꕢ" + AF_BLUE_STRING_VAI_BOTTOM + "ꗍ ꘖ ꘙ ꗞ ꔅ ꕢ ꖜ ꔆ" + #ifdef AF_CONFIG_OPTION_CJK @@ -483,6 +666,14 @@ AF_BLUE_STRING_ENUM AF_BLUE_STRINGS_ARRAY AF_BLUE_STRING_MAX_LEN: AF_BLUE_STRINGSET_ENUM AF_BLUE_STRINGSETS_ARRAY AF_BLUE_STRINGSET_MAX_LEN: + AF_BLUE_STRINGSET_ADLM + { AF_BLUE_STRING_ADLAM_CAPITAL_TOP, AF_BLUE_PROPERTY_LATIN_TOP } + { AF_BLUE_STRING_ADLAM_CAPITAL_BOTTOM, 0 } + { AF_BLUE_STRING_ADLAM_SMALL_TOP, AF_BLUE_PROPERTY_LATIN_TOP | + AF_BLUE_PROPERTY_LATIN_X_HEIGHT } + { AF_BLUE_STRING_ADLAM_SMALL_BOTTOM, 0 } + { AF_BLUE_STRING_MAX, 0 } + AF_BLUE_STRINGSET_ARAB { AF_BLUE_STRING_ARABIC_TOP, AF_BLUE_PROPERTY_LATIN_TOP } { AF_BLUE_STRING_ARABIC_BOTTOM, 0 } @@ -499,6 +690,16 @@ AF_BLUE_STRINGSET_ENUM AF_BLUE_STRINGSETS_ARRAY AF_BLUE_STRINGSET_MAX_LEN: { AF_BLUE_STRING_ARMENIAN_SMALL_DESCENDER, 0 } { AF_BLUE_STRING_MAX, 0 } + AF_BLUE_STRINGSET_AVST + { AF_BLUE_STRING_AVESTAN_TOP, AF_BLUE_PROPERTY_LATIN_TOP } + { AF_BLUE_STRING_AVESTAN_BOTTOM, 0 } + { AF_BLUE_STRING_MAX, 0 } + + AF_BLUE_STRINGSET_BAMU + { AF_BLUE_STRING_BAMUM_TOP, AF_BLUE_PROPERTY_LATIN_TOP } + { AF_BLUE_STRING_BAMUM_BOTTOM, 0 } + { AF_BLUE_STRING_MAX, 0 } + AF_BLUE_STRINGSET_BENG { AF_BLUE_STRING_BENGALI_TOP, AF_BLUE_PROPERTY_LATIN_TOP } { AF_BLUE_STRING_BENGALI_HEAD, AF_BLUE_PROPERTY_LATIN_TOP } @@ -508,6 +709,35 @@ AF_BLUE_STRINGSET_ENUM AF_BLUE_STRINGSETS_ARRAY AF_BLUE_STRINGSET_MAX_LEN: { AF_BLUE_STRING_BENGALI_BASE, 0 } { AF_BLUE_STRING_MAX, 0 } + AF_BLUE_STRINGSET_BUHD + { AF_BLUE_STRING_BUHID_TOP, AF_BLUE_PROPERTY_LATIN_TOP } + { AF_BLUE_STRING_BUHID_LARGE, AF_BLUE_PROPERTY_LATIN_TOP } + { AF_BLUE_STRING_BUHID_SMALL, AF_BLUE_PROPERTY_LATIN_TOP | + AF_BLUE_PROPERTY_LATIN_X_HEIGHT } + { AF_BLUE_STRING_BUHID_BOTTOM, 0 } + { AF_BLUE_STRING_MAX, 0 } + + AF_BLUE_STRINGSET_CAKM + { AF_BLUE_STRING_CHAKMA_TOP, AF_BLUE_PROPERTY_LATIN_TOP } + { AF_BLUE_STRING_CHAKMA_BOTTOM, 0 } + { AF_BLUE_STRING_CHAKMA_DESCENDER, 0 } + { AF_BLUE_STRING_MAX, 0 } + + AF_BLUE_STRINGSET_CANS + { AF_BLUE_STRING_CANADIAN_SYLLABICS_TOP, AF_BLUE_PROPERTY_LATIN_TOP } + { AF_BLUE_STRING_CANADIAN_SYLLABICS_BOTTOM, 0 } + { AF_BLUE_STRING_CANADIAN_SYLLABICS_SMALL_TOP, AF_BLUE_PROPERTY_LATIN_TOP | + AF_BLUE_PROPERTY_LATIN_X_HEIGHT } + { AF_BLUE_STRING_CANADIAN_SYLLABICS_SMALL_BOTTOM, 0 } + { AF_BLUE_STRING_CANADIAN_SYLLABICS_SUPS_TOP, AF_BLUE_PROPERTY_LATIN_TOP } + { AF_BLUE_STRING_CANADIAN_SYLLABICS_SUPS_BOTTOM, 0 } + { AF_BLUE_STRING_MAX, 0 } + + AF_BLUE_STRINGSET_CARI + { AF_BLUE_STRING_CARIAN_TOP, AF_BLUE_PROPERTY_LATIN_TOP } + { AF_BLUE_STRING_CARIAN_BOTTOM, 0 } + { AF_BLUE_STRING_MAX, 0 } + AF_BLUE_STRINGSET_CHER { AF_BLUE_STRING_CHEROKEE_CAPITAL, AF_BLUE_PROPERTY_LATIN_TOP } { AF_BLUE_STRING_CHEROKEE_CAPITAL, 0 } @@ -518,6 +748,21 @@ AF_BLUE_STRINGSET_ENUM AF_BLUE_STRINGSETS_ARRAY AF_BLUE_STRINGSET_MAX_LEN: { AF_BLUE_STRING_CHEROKEE_SMALL_DESCENDER, 0 } { AF_BLUE_STRING_MAX, 0 } + AF_BLUE_STRINGSET_COPT + { AF_BLUE_STRING_COPTIC_CAPITAL_TOP, AF_BLUE_PROPERTY_LATIN_TOP } + { AF_BLUE_STRING_COPTIC_CAPITAL_BOTTOM, 0 } + { AF_BLUE_STRING_COPTIC_SMALL_TOP, AF_BLUE_PROPERTY_LATIN_TOP | + AF_BLUE_PROPERTY_LATIN_X_HEIGHT } + { AF_BLUE_STRING_COPTIC_SMALL_BOTTOM, 0 } + { AF_BLUE_STRING_MAX, 0 } + + AF_BLUE_STRINGSET_CPRT + { AF_BLUE_STRING_CYPRIOT_TOP, AF_BLUE_PROPERTY_LATIN_TOP } + { AF_BLUE_STRING_CYPRIOT_BOTTOM, 0 } + { AF_BLUE_STRING_CYPRIOT_SMALL, AF_BLUE_PROPERTY_LATIN_TOP } + { AF_BLUE_STRING_CYPRIOT_SMALL, 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 } @@ -537,6 +782,14 @@ AF_BLUE_STRINGSET_ENUM AF_BLUE_STRINGSETS_ARRAY AF_BLUE_STRINGSET_MAX_LEN: { AF_BLUE_STRING_DEVANAGARI_BOTTOM, 0 } { AF_BLUE_STRING_MAX, 0 } + AF_BLUE_STRINGSET_DSRT + { AF_BLUE_STRING_DESERET_CAPITAL_TOP, AF_BLUE_PROPERTY_LATIN_TOP } + { AF_BLUE_STRING_DESERET_CAPITAL_BOTTOM, 0 } + { AF_BLUE_STRING_DESERET_SMALL_TOP, AF_BLUE_PROPERTY_LATIN_TOP | + AF_BLUE_PROPERTY_LATIN_X_HEIGHT } + { AF_BLUE_STRING_DESERET_SMALL_BOTTOM, 0 } + { AF_BLUE_STRING_MAX, 0 } + AF_BLUE_STRINGSET_ETHI { AF_BLUE_STRING_ETHIOPIC_TOP, AF_BLUE_PROPERTY_LATIN_TOP } { AF_BLUE_STRING_ETHIOPIC_BOTTOM, 0 } @@ -561,6 +814,19 @@ AF_BLUE_STRINGSET_ENUM AF_BLUE_STRINGSETS_ARRAY AF_BLUE_STRINGSET_MAX_LEN: { AF_BLUE_STRING_GEORGIAN_NUSKHURI_DESCENDER, 0 } { AF_BLUE_STRING_MAX, 0 } + AF_BLUE_STRINGSET_GLAG + { AF_BLUE_STRING_GLAGOLITIC_CAPITAL_TOP, AF_BLUE_PROPERTY_LATIN_TOP } + { AF_BLUE_STRING_GLAGOLITIC_CAPITAL_BOTTOM, 0 } + { AF_BLUE_STRING_GLAGOLITIC_SMALL_TOP, AF_BLUE_PROPERTY_LATIN_TOP | + AF_BLUE_PROPERTY_LATIN_X_HEIGHT } + { AF_BLUE_STRING_GLAGOLITIC_SMALL_BOTTOM, 0 } + { AF_BLUE_STRING_MAX, 0 } + + AF_BLUE_STRINGSET_GOTH + { AF_BLUE_STRING_GOTHIC_TOP, AF_BLUE_PROPERTY_LATIN_TOP } + { AF_BLUE_STRING_GOTHIC_BOTTOM, 0 } + { AF_BLUE_STRING_MAX, 0 } + AF_BLUE_STRINGSET_GREK { AF_BLUE_STRING_GREEK_CAPITAL_TOP, AF_BLUE_PROPERTY_LATIN_TOP } { AF_BLUE_STRING_GREEK_CAPITAL_BOTTOM, 0 } @@ -597,6 +863,15 @@ 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_KALI + { AF_BLUE_STRING_KAYAH_LI_TOP, AF_BLUE_PROPERTY_LATIN_TOP | + AF_BLUE_PROPERTY_LATIN_X_HEIGHT } + { AF_BLUE_STRING_KAYAH_LI_BOTTOM, 0 } + { AF_BLUE_STRING_KAYAH_LI_ASCENDER, AF_BLUE_PROPERTY_LATIN_TOP } + { AF_BLUE_STRING_KAYAH_LI_DESCENDER, 0 } + { AF_BLUE_STRING_KAYAH_LI_LARGE_DESCENDER, 0 } + { AF_BLUE_STRING_MAX, 0 } + AF_BLUE_STRINGSET_KNDA { AF_BLUE_STRING_KANNADA_TOP, AF_BLUE_PROPERTY_LATIN_TOP } { AF_BLUE_STRING_KANNADA_BOTTOM, 0 } @@ -630,9 +905,9 @@ AF_BLUE_STRINGSET_ENUM AF_BLUE_STRINGSETS_ARRAY AF_BLUE_STRINGSET_MAX_LEN: { 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_STRING_LATIN_SMALL_TOP, AF_BLUE_PROPERTY_LATIN_TOP | AF_BLUE_PROPERTY_LATIN_X_HEIGHT } - { AF_BLUE_STRING_LATIN_SMALL, 0 } + { AF_BLUE_STRING_LATIN_SMALL_BOTTOM, 0 } { AF_BLUE_STRING_LATIN_SMALL_DESCENDER, 0 } { AF_BLUE_STRING_MAX, 0 } @@ -656,6 +931,11 @@ AF_BLUE_STRINGSET_ENUM AF_BLUE_STRINGSETS_ARRAY AF_BLUE_STRINGSET_MAX_LEN: { AF_BLUE_STRING_LATIN_SUPS_SMALL_DESCENDER, 0 } { AF_BLUE_STRING_MAX, 0 } + AF_BLUE_STRINGSET_LISU + { AF_BLUE_STRING_LISU_TOP, AF_BLUE_PROPERTY_LATIN_TOP } + { AF_BLUE_STRING_LISU_BOTTOM, 0 } + { AF_BLUE_STRING_MAX, 0 } + AF_BLUE_STRINGSET_MLYM { AF_BLUE_STRING_MALAYALAM_TOP, AF_BLUE_PROPERTY_LATIN_TOP } { AF_BLUE_STRING_MALAYALAM_BOTTOM, 0 } @@ -669,20 +949,79 @@ AF_BLUE_STRINGSET_ENUM AF_BLUE_STRINGSETS_ARRAY AF_BLUE_STRINGSET_MAX_LEN: { AF_BLUE_STRING_MYANMAR_DESCENDER, 0 } { AF_BLUE_STRING_MAX, 0 } + AF_BLUE_STRINGSET_NKOO + { AF_BLUE_STRING_NKO_TOP, AF_BLUE_PROPERTY_LATIN_TOP } + { AF_BLUE_STRING_NKO_BOTTOM, 0 } + { AF_BLUE_STRING_NKO_SMALL_TOP, AF_BLUE_PROPERTY_LATIN_TOP | + AF_BLUE_PROPERTY_LATIN_X_HEIGHT } + { AF_BLUE_STRING_NKO_SMALL_BOTTOM, 0 } + { AF_BLUE_STRING_MAX, 0 } + AF_BLUE_STRINGSET_NONE { AF_BLUE_STRING_MAX, 0 } + AF_BLUE_STRINGSET_OLCK + { AF_BLUE_STRING_OL_CHIKI, AF_BLUE_PROPERTY_LATIN_TOP } + { AF_BLUE_STRING_OL_CHIKI, 0 } + { AF_BLUE_STRING_MAX, 0 } + + AF_BLUE_STRINGSET_ORKH + { AF_BLUE_STRING_OLD_TURKIC_TOP, AF_BLUE_PROPERTY_LATIN_TOP } + { AF_BLUE_STRING_OLD_TURKIC_BOTTOM, 0 } + { AF_BLUE_STRING_MAX, 0 } + + AF_BLUE_STRINGSET_OSGE + { AF_BLUE_STRING_OSAGE_CAPITAL_TOP, AF_BLUE_PROPERTY_LATIN_TOP } + { AF_BLUE_STRING_OSAGE_CAPITAL_BOTTOM, 0 } + { AF_BLUE_STRING_OSAGE_CAPITAL_DESCENDER, 0 } + { AF_BLUE_STRING_OSAGE_SMALL_TOP, AF_BLUE_PROPERTY_LATIN_TOP | + AF_BLUE_PROPERTY_LATIN_X_HEIGHT } + { AF_BLUE_STRING_OSAGE_SMALL_BOTTOM, 0 } + { AF_BLUE_STRING_OSAGE_SMALL_ASCENDER, AF_BLUE_PROPERTY_LATIN_TOP } + { AF_BLUE_STRING_OSAGE_SMALL_DESCENDER, 0 } + { AF_BLUE_STRING_MAX, 0 } + + AF_BLUE_STRINGSET_OSMA + { AF_BLUE_STRING_OSMANYA_TOP, AF_BLUE_PROPERTY_LATIN_TOP } + { AF_BLUE_STRING_OSMANYA_BOTTOM, 0 } + { AF_BLUE_STRING_MAX, 0 } + + AF_BLUE_STRINGSET_SAUR + { AF_BLUE_STRING_SAURASHTRA_TOP, AF_BLUE_PROPERTY_LATIN_TOP } + { AF_BLUE_STRING_SAURASHTRA_BOTTOM, 0 } + { AF_BLUE_STRING_MAX, 0 } + + AF_BLUE_STRINGSET_SHAW + { AF_BLUE_STRING_SHAVIAN_TOP, AF_BLUE_PROPERTY_LATIN_TOP } + { AF_BLUE_STRING_SHAVIAN_BOTTOM, 0 } + { AF_BLUE_STRING_SHAVIAN_DESCENDER, 0 } + { AF_BLUE_STRING_SHAVIAN_SMALL_TOP, AF_BLUE_PROPERTY_LATIN_TOP | + AF_BLUE_PROPERTY_LATIN_X_HEIGHT } + { AF_BLUE_STRING_SHAVIAN_SMALL_BOTTOM, 0 } + { AF_BLUE_STRING_MAX, 0 } + AF_BLUE_STRINGSET_SINH { AF_BLUE_STRING_SINHALA_TOP, AF_BLUE_PROPERTY_LATIN_TOP } { AF_BLUE_STRING_SINHALA_BOTTOM, 0 } { AF_BLUE_STRING_SINHALA_DESCENDER, 0 } { AF_BLUE_STRING_MAX, 0 } + AF_BLUE_STRINGSET_SUND + { AF_BLUE_STRING_SUNDANESE_TOP, AF_BLUE_PROPERTY_LATIN_TOP } + { AF_BLUE_STRING_SUNDANESE_BOTTOM, 0 } + { AF_BLUE_STRING_SUNDANESE_DESCENDER, 0 } + { AF_BLUE_STRING_MAX, 0 } + AF_BLUE_STRINGSET_TAML { AF_BLUE_STRING_TAMIL_TOP, AF_BLUE_PROPERTY_LATIN_TOP } { AF_BLUE_STRING_TAMIL_BOTTOM, 0 } { AF_BLUE_STRING_MAX, 0 } + AF_BLUE_STRINGSET_TAVT + { AF_BLUE_STRING_TAI_VIET_TOP, AF_BLUE_PROPERTY_LATIN_TOP } + { AF_BLUE_STRING_TAI_VIET_BOTTOM, 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 } @@ -699,6 +1038,15 @@ AF_BLUE_STRINGSET_ENUM AF_BLUE_STRINGSETS_ARRAY AF_BLUE_STRINGSET_MAX_LEN: { AF_BLUE_STRING_THAI_DIGIT_TOP, 0 } { AF_BLUE_STRING_MAX, 0 } + AF_BLUE_STRINGSET_TFNG + { AF_BLUE_STRING_TIFINAGH, AF_BLUE_PROPERTY_LATIN_TOP } + { AF_BLUE_STRING_TIFINAGH, 0 } + { AF_BLUE_STRING_MAX, 0 } + + AF_BLUE_STRINGSET_VAII + { AF_BLUE_STRING_VAI_TOP, AF_BLUE_PROPERTY_LATIN_TOP } + { AF_BLUE_STRING_VAI_BOTTOM, 0 } + { AF_BLUE_STRING_MAX, 0 } #ifdef AF_CONFIG_OPTION_CJK diff --git a/thirdparty/freetype/src/autofit/afblue.h b/thirdparty/freetype/src/autofit/afblue.h index 41f838e457..e227dbf50b 100644 --- a/thirdparty/freetype/src/autofit/afblue.h +++ b/thirdparty/freetype/src/autofit/afblue.h @@ -7,7 +7,7 @@ /* */ /* Auto-fitter data for blue strings (specification). */ /* */ -/* Copyright 2013-2016 by */ +/* Copyright 2013-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -77,110 +77,189 @@ FT_BEGIN_HEADER typedef enum AF_Blue_String_ { - AF_BLUE_STRING_ARABIC_TOP = 0, - AF_BLUE_STRING_ARABIC_BOTTOM = 18, - AF_BLUE_STRING_ARABIC_JOIN = 33, - AF_BLUE_STRING_ARMENIAN_CAPITAL_TOP = 36, - AF_BLUE_STRING_ARMENIAN_CAPITAL_BOTTOM = 60, - AF_BLUE_STRING_ARMENIAN_SMALL_ASCENDER = 84, - AF_BLUE_STRING_ARMENIAN_SMALL_TOP = 108, - AF_BLUE_STRING_ARMENIAN_SMALL_BOTTOM = 132, - AF_BLUE_STRING_ARMENIAN_SMALL_DESCENDER = 156, - AF_BLUE_STRING_BENGALI_BASE = 180, - AF_BLUE_STRING_BENGALI_TOP = 212, - AF_BLUE_STRING_BENGALI_HEAD = 240, - AF_BLUE_STRING_CHEROKEE_CAPITAL = 272, - AF_BLUE_STRING_CHEROKEE_SMALL_ASCENDER = 304, - AF_BLUE_STRING_CHEROKEE_SMALL = 336, - AF_BLUE_STRING_CHEROKEE_SMALL_DESCENDER = 368, - AF_BLUE_STRING_CYRILLIC_CAPITAL_TOP = 384, - AF_BLUE_STRING_CYRILLIC_CAPITAL_BOTTOM = 408, - AF_BLUE_STRING_CYRILLIC_SMALL = 432, - AF_BLUE_STRING_CYRILLIC_SMALL_DESCENDER = 456, - AF_BLUE_STRING_DEVANAGARI_BASE = 465, - AF_BLUE_STRING_DEVANAGARI_TOP = 497, - AF_BLUE_STRING_DEVANAGARI_HEAD = 529, - AF_BLUE_STRING_DEVANAGARI_BOTTOM = 561, - AF_BLUE_STRING_ETHIOPIC_TOP = 569, - AF_BLUE_STRING_ETHIOPIC_BOTTOM = 601, - AF_BLUE_STRING_GEORGIAN_MKHEDRULI_TOP = 633, - AF_BLUE_STRING_GEORGIAN_MKHEDRULI_BOTTOM = 665, - AF_BLUE_STRING_GEORGIAN_MKHEDRULI_ASCENDER = 697, - AF_BLUE_STRING_GEORGIAN_MKHEDRULI_DESCENDER = 729, - AF_BLUE_STRING_GEORGIAN_ASOMTAVRULI_TOP = 761, - AF_BLUE_STRING_GEORGIAN_ASOMTAVRULI_BOTTOM = 793, - AF_BLUE_STRING_GEORGIAN_NUSKHURI_TOP = 825, - AF_BLUE_STRING_GEORGIAN_NUSKHURI_BOTTOM = 857, - AF_BLUE_STRING_GEORGIAN_NUSKHURI_ASCENDER = 889, - AF_BLUE_STRING_GEORGIAN_NUSKHURI_DESCENDER = 921, - AF_BLUE_STRING_GREEK_CAPITAL_TOP = 953, - AF_BLUE_STRING_GREEK_CAPITAL_BOTTOM = 974, - AF_BLUE_STRING_GREEK_SMALL_BETA_TOP = 992, - AF_BLUE_STRING_GREEK_SMALL = 1010, - AF_BLUE_STRING_GREEK_SMALL_DESCENDER = 1034, - AF_BLUE_STRING_GUJARATI_TOP = 1058, - AF_BLUE_STRING_GUJARATI_BOTTOM = 1090, - AF_BLUE_STRING_GUJARATI_ASCENDER = 1122, - AF_BLUE_STRING_GUJARATI_DESCENDER = 1172, - AF_BLUE_STRING_GUJARATI_DIGIT_TOP = 1205, - AF_BLUE_STRING_GURMUKHI_BASE = 1225, - AF_BLUE_STRING_GURMUKHI_HEAD = 1257, - AF_BLUE_STRING_GURMUKHI_TOP = 1289, - AF_BLUE_STRING_GURMUKHI_BOTTOM = 1321, - AF_BLUE_STRING_GURMUKHI_DIGIT_TOP = 1353, - AF_BLUE_STRING_HEBREW_TOP = 1373, - AF_BLUE_STRING_HEBREW_BOTTOM = 1397, - AF_BLUE_STRING_HEBREW_DESCENDER = 1415, - AF_BLUE_STRING_KANNADA_TOP = 1430, - AF_BLUE_STRING_KANNADA_BOTTOM = 1474, - AF_BLUE_STRING_KHMER_TOP = 1506, - AF_BLUE_STRING_KHMER_SUBSCRIPT_TOP = 1530, - AF_BLUE_STRING_KHMER_BOTTOM = 1570, - AF_BLUE_STRING_KHMER_DESCENDER = 1602, - AF_BLUE_STRING_KHMER_LARGE_DESCENDER = 1636, - AF_BLUE_STRING_KHMER_SYMBOLS_WAXING_TOP = 1723, - AF_BLUE_STRING_KHMER_SYMBOLS_WANING_BOTTOM = 1731, - AF_BLUE_STRING_LAO_TOP = 1739, - AF_BLUE_STRING_LAO_BOTTOM = 1771, - AF_BLUE_STRING_LAO_ASCENDER = 1803, - AF_BLUE_STRING_LAO_LARGE_ASCENDER = 1819, - AF_BLUE_STRING_LAO_DESCENDER = 1831, - AF_BLUE_STRING_LATIN_CAPITAL_TOP = 1855, - AF_BLUE_STRING_LATIN_CAPITAL_BOTTOM = 1871, - AF_BLUE_STRING_LATIN_SMALL_F_TOP = 1887, - AF_BLUE_STRING_LATIN_SMALL = 1901, - AF_BLUE_STRING_LATIN_SMALL_DESCENDER = 1915, - AF_BLUE_STRING_LATIN_SUBS_CAPITAL_TOP = 1925, - AF_BLUE_STRING_LATIN_SUBS_CAPITAL_BOTTOM = 1945, - AF_BLUE_STRING_LATIN_SUBS_SMALL_F_TOP = 1965, - AF_BLUE_STRING_LATIN_SUBS_SMALL = 1985, - AF_BLUE_STRING_LATIN_SUBS_SMALL_DESCENDER = 2021, - AF_BLUE_STRING_LATIN_SUPS_CAPITAL_TOP = 2041, - AF_BLUE_STRING_LATIN_SUPS_CAPITAL_BOTTOM = 2072, - AF_BLUE_STRING_LATIN_SUPS_SMALL_F_TOP = 2101, - AF_BLUE_STRING_LATIN_SUPS_SMALL = 2127, - AF_BLUE_STRING_LATIN_SUPS_SMALL_DESCENDER = 2152, - AF_BLUE_STRING_MALAYALAM_TOP = 2163, - AF_BLUE_STRING_MALAYALAM_BOTTOM = 2207, - AF_BLUE_STRING_MYANMAR_TOP = 2239, - AF_BLUE_STRING_MYANMAR_BOTTOM = 2271, - AF_BLUE_STRING_MYANMAR_ASCENDER = 2303, - AF_BLUE_STRING_MYANMAR_DESCENDER = 2331, - AF_BLUE_STRING_SINHALA_TOP = 2363, - AF_BLUE_STRING_SINHALA_BOTTOM = 2395, - AF_BLUE_STRING_SINHALA_DESCENDER = 2427, - AF_BLUE_STRING_TAMIL_TOP = 2471, - AF_BLUE_STRING_TAMIL_BOTTOM = 2503, - AF_BLUE_STRING_TELUGU_TOP = 2535, - AF_BLUE_STRING_TELUGU_BOTTOM = 2563, - AF_BLUE_STRING_THAI_TOP = 2591, - AF_BLUE_STRING_THAI_BOTTOM = 2615, - AF_BLUE_STRING_THAI_ASCENDER = 2643, - AF_BLUE_STRING_THAI_LARGE_ASCENDER = 2655, - AF_BLUE_STRING_THAI_DESCENDER = 2667, - AF_BLUE_STRING_THAI_LARGE_DESCENDER = 2683, - AF_BLUE_STRING_THAI_DIGIT_TOP = 2691, - af_blue_1_1 = 2702, + AF_BLUE_STRING_ADLAM_CAPITAL_TOP = 0, + AF_BLUE_STRING_ADLAM_CAPITAL_BOTTOM = 30, + AF_BLUE_STRING_ADLAM_SMALL_TOP = 40, + AF_BLUE_STRING_ADLAM_SMALL_BOTTOM = 65, + AF_BLUE_STRING_ARABIC_TOP = 105, + AF_BLUE_STRING_ARABIC_BOTTOM = 123, + AF_BLUE_STRING_ARABIC_JOIN = 138, + AF_BLUE_STRING_ARMENIAN_CAPITAL_TOP = 141, + AF_BLUE_STRING_ARMENIAN_CAPITAL_BOTTOM = 165, + AF_BLUE_STRING_ARMENIAN_SMALL_ASCENDER = 189, + AF_BLUE_STRING_ARMENIAN_SMALL_TOP = 210, + AF_BLUE_STRING_ARMENIAN_SMALL_BOTTOM = 234, + AF_BLUE_STRING_ARMENIAN_SMALL_DESCENDER = 258, + AF_BLUE_STRING_AVESTAN_TOP = 282, + AF_BLUE_STRING_AVESTAN_BOTTOM = 302, + AF_BLUE_STRING_BAMUM_TOP = 312, + AF_BLUE_STRING_BAMUM_BOTTOM = 344, + AF_BLUE_STRING_BENGALI_BASE = 376, + AF_BLUE_STRING_BENGALI_TOP = 408, + AF_BLUE_STRING_BENGALI_HEAD = 436, + AF_BLUE_STRING_BUHID_TOP = 468, + AF_BLUE_STRING_BUHID_LARGE = 476, + AF_BLUE_STRING_BUHID_SMALL = 488, + AF_BLUE_STRING_BUHID_BOTTOM = 504, + AF_BLUE_STRING_CANADIAN_SYLLABICS_TOP = 532, + AF_BLUE_STRING_CANADIAN_SYLLABICS_BOTTOM = 564, + AF_BLUE_STRING_CANADIAN_SYLLABICS_SMALL_TOP = 596, + AF_BLUE_STRING_CANADIAN_SYLLABICS_SMALL_BOTTOM = 628, + AF_BLUE_STRING_CANADIAN_SYLLABICS_SUPS_TOP = 660, + AF_BLUE_STRING_CANADIAN_SYLLABICS_SUPS_BOTTOM = 688, + AF_BLUE_STRING_CARIAN_TOP = 720, + AF_BLUE_STRING_CARIAN_BOTTOM = 760, + AF_BLUE_STRING_CHAKMA_TOP = 795, + AF_BLUE_STRING_CHAKMA_BOTTOM = 820, + AF_BLUE_STRING_CHAKMA_DESCENDER = 845, + AF_BLUE_STRING_CHEROKEE_CAPITAL = 910, + AF_BLUE_STRING_CHEROKEE_SMALL_ASCENDER = 942, + AF_BLUE_STRING_CHEROKEE_SMALL = 974, + AF_BLUE_STRING_CHEROKEE_SMALL_DESCENDER = 1006, + AF_BLUE_STRING_COPTIC_CAPITAL_TOP = 1022, + AF_BLUE_STRING_COPTIC_CAPITAL_BOTTOM = 1054, + AF_BLUE_STRING_COPTIC_SMALL_TOP = 1086, + AF_BLUE_STRING_COPTIC_SMALL_BOTTOM = 1118, + AF_BLUE_STRING_CYPRIOT_TOP = 1150, + AF_BLUE_STRING_CYPRIOT_BOTTOM = 1190, + AF_BLUE_STRING_CYPRIOT_SMALL = 1225, + AF_BLUE_STRING_CYRILLIC_CAPITAL_TOP = 1240, + AF_BLUE_STRING_CYRILLIC_CAPITAL_BOTTOM = 1264, + AF_BLUE_STRING_CYRILLIC_SMALL = 1288, + AF_BLUE_STRING_CYRILLIC_SMALL_DESCENDER = 1312, + AF_BLUE_STRING_DESERET_CAPITAL_TOP = 1321, + AF_BLUE_STRING_DESERET_CAPITAL_BOTTOM = 1346, + AF_BLUE_STRING_DESERET_SMALL_TOP = 1371, + AF_BLUE_STRING_DESERET_SMALL_BOTTOM = 1396, + AF_BLUE_STRING_DEVANAGARI_BASE = 1421, + AF_BLUE_STRING_DEVANAGARI_TOP = 1453, + AF_BLUE_STRING_DEVANAGARI_HEAD = 1485, + AF_BLUE_STRING_DEVANAGARI_BOTTOM = 1517, + AF_BLUE_STRING_ETHIOPIC_TOP = 1525, + AF_BLUE_STRING_ETHIOPIC_BOTTOM = 1557, + AF_BLUE_STRING_GEORGIAN_MKHEDRULI_TOP = 1589, + AF_BLUE_STRING_GEORGIAN_MKHEDRULI_BOTTOM = 1621, + AF_BLUE_STRING_GEORGIAN_MKHEDRULI_ASCENDER = 1653, + AF_BLUE_STRING_GEORGIAN_MKHEDRULI_DESCENDER = 1685, + AF_BLUE_STRING_GEORGIAN_ASOMTAVRULI_TOP = 1717, + AF_BLUE_STRING_GEORGIAN_ASOMTAVRULI_BOTTOM = 1749, + AF_BLUE_STRING_GEORGIAN_NUSKHURI_TOP = 1781, + AF_BLUE_STRING_GEORGIAN_NUSKHURI_BOTTOM = 1813, + AF_BLUE_STRING_GEORGIAN_NUSKHURI_ASCENDER = 1845, + AF_BLUE_STRING_GEORGIAN_NUSKHURI_DESCENDER = 1877, + AF_BLUE_STRING_GLAGOLITIC_CAPITAL_TOP = 1909, + AF_BLUE_STRING_GLAGOLITIC_CAPITAL_BOTTOM = 1941, + AF_BLUE_STRING_GLAGOLITIC_SMALL_TOP = 1973, + AF_BLUE_STRING_GLAGOLITIC_SMALL_BOTTOM = 2005, + AF_BLUE_STRING_GOTHIC_TOP = 2037, + AF_BLUE_STRING_GOTHIC_BOTTOM = 2077, + AF_BLUE_STRING_GREEK_CAPITAL_TOP = 2097, + AF_BLUE_STRING_GREEK_CAPITAL_BOTTOM = 2118, + AF_BLUE_STRING_GREEK_SMALL_BETA_TOP = 2136, + AF_BLUE_STRING_GREEK_SMALL = 2154, + AF_BLUE_STRING_GREEK_SMALL_DESCENDER = 2178, + AF_BLUE_STRING_GUJARATI_TOP = 2202, + AF_BLUE_STRING_GUJARATI_BOTTOM = 2234, + AF_BLUE_STRING_GUJARATI_ASCENDER = 2266, + AF_BLUE_STRING_GUJARATI_DESCENDER = 2316, + AF_BLUE_STRING_GUJARATI_DIGIT_TOP = 2349, + AF_BLUE_STRING_GURMUKHI_BASE = 2369, + AF_BLUE_STRING_GURMUKHI_HEAD = 2401, + AF_BLUE_STRING_GURMUKHI_TOP = 2433, + AF_BLUE_STRING_GURMUKHI_BOTTOM = 2465, + AF_BLUE_STRING_GURMUKHI_DIGIT_TOP = 2497, + AF_BLUE_STRING_HEBREW_TOP = 2517, + AF_BLUE_STRING_HEBREW_BOTTOM = 2541, + AF_BLUE_STRING_HEBREW_DESCENDER = 2559, + AF_BLUE_STRING_KANNADA_TOP = 2574, + AF_BLUE_STRING_KANNADA_BOTTOM = 2618, + AF_BLUE_STRING_KAYAH_LI_TOP = 2650, + AF_BLUE_STRING_KAYAH_LI_BOTTOM = 2674, + AF_BLUE_STRING_KAYAH_LI_ASCENDER = 2694, + AF_BLUE_STRING_KAYAH_LI_DESCENDER = 2702, + AF_BLUE_STRING_KAYAH_LI_LARGE_DESCENDER = 2714, + AF_BLUE_STRING_KHMER_TOP = 2735, + AF_BLUE_STRING_KHMER_SUBSCRIPT_TOP = 2759, + AF_BLUE_STRING_KHMER_BOTTOM = 2799, + AF_BLUE_STRING_KHMER_DESCENDER = 2831, + AF_BLUE_STRING_KHMER_LARGE_DESCENDER = 2865, + AF_BLUE_STRING_KHMER_SYMBOLS_WAXING_TOP = 2952, + AF_BLUE_STRING_KHMER_SYMBOLS_WANING_BOTTOM = 2960, + AF_BLUE_STRING_LAO_TOP = 2968, + AF_BLUE_STRING_LAO_BOTTOM = 3000, + AF_BLUE_STRING_LAO_ASCENDER = 3032, + AF_BLUE_STRING_LAO_LARGE_ASCENDER = 3048, + AF_BLUE_STRING_LAO_DESCENDER = 3060, + AF_BLUE_STRING_LATIN_CAPITAL_TOP = 3084, + AF_BLUE_STRING_LATIN_CAPITAL_BOTTOM = 3100, + AF_BLUE_STRING_LATIN_SMALL_F_TOP = 3116, + AF_BLUE_STRING_LATIN_SMALL_TOP = 3130, + AF_BLUE_STRING_LATIN_SMALL_BOTTOM = 3146, + AF_BLUE_STRING_LATIN_SMALL_DESCENDER = 3162, + AF_BLUE_STRING_LATIN_SUBS_CAPITAL_TOP = 3172, + AF_BLUE_STRING_LATIN_SUBS_CAPITAL_BOTTOM = 3192, + AF_BLUE_STRING_LATIN_SUBS_SMALL_F_TOP = 3212, + AF_BLUE_STRING_LATIN_SUBS_SMALL = 3232, + AF_BLUE_STRING_LATIN_SUBS_SMALL_DESCENDER = 3268, + AF_BLUE_STRING_LATIN_SUPS_CAPITAL_TOP = 3288, + AF_BLUE_STRING_LATIN_SUPS_CAPITAL_BOTTOM = 3319, + AF_BLUE_STRING_LATIN_SUPS_SMALL_F_TOP = 3348, + AF_BLUE_STRING_LATIN_SUPS_SMALL = 3374, + AF_BLUE_STRING_LATIN_SUPS_SMALL_DESCENDER = 3399, + AF_BLUE_STRING_LISU_TOP = 3410, + AF_BLUE_STRING_LISU_BOTTOM = 3442, + AF_BLUE_STRING_MALAYALAM_TOP = 3474, + AF_BLUE_STRING_MALAYALAM_BOTTOM = 3518, + AF_BLUE_STRING_MYANMAR_TOP = 3550, + AF_BLUE_STRING_MYANMAR_BOTTOM = 3582, + AF_BLUE_STRING_MYANMAR_ASCENDER = 3614, + AF_BLUE_STRING_MYANMAR_DESCENDER = 3642, + AF_BLUE_STRING_NKO_TOP = 3674, + AF_BLUE_STRING_NKO_BOTTOM = 3698, + AF_BLUE_STRING_NKO_SMALL_TOP = 3713, + AF_BLUE_STRING_NKO_SMALL_BOTTOM = 3722, + AF_BLUE_STRING_OL_CHIKI = 3734, + AF_BLUE_STRING_OLD_TURKIC_TOP = 3758, + AF_BLUE_STRING_OLD_TURKIC_BOTTOM = 3773, + AF_BLUE_STRING_OSAGE_CAPITAL_TOP = 3793, + AF_BLUE_STRING_OSAGE_CAPITAL_BOTTOM = 3833, + AF_BLUE_STRING_OSAGE_CAPITAL_DESCENDER = 3863, + AF_BLUE_STRING_OSAGE_SMALL_TOP = 3878, + AF_BLUE_STRING_OSAGE_SMALL_BOTTOM = 3918, + AF_BLUE_STRING_OSAGE_SMALL_ASCENDER = 3958, + AF_BLUE_STRING_OSAGE_SMALL_DESCENDER = 3983, + AF_BLUE_STRING_OSMANYA_TOP = 3998, + AF_BLUE_STRING_OSMANYA_BOTTOM = 4038, + AF_BLUE_STRING_SAURASHTRA_TOP = 4078, + AF_BLUE_STRING_SAURASHTRA_BOTTOM = 4110, + AF_BLUE_STRING_SHAVIAN_TOP = 4130, + AF_BLUE_STRING_SHAVIAN_BOTTOM = 4140, + AF_BLUE_STRING_SHAVIAN_DESCENDER = 4165, + AF_BLUE_STRING_SHAVIAN_SMALL_TOP = 4175, + AF_BLUE_STRING_SHAVIAN_SMALL_BOTTOM = 4210, + AF_BLUE_STRING_SINHALA_TOP = 4225, + AF_BLUE_STRING_SINHALA_BOTTOM = 4257, + AF_BLUE_STRING_SINHALA_DESCENDER = 4289, + AF_BLUE_STRING_SUNDANESE_TOP = 4333, + AF_BLUE_STRING_SUNDANESE_BOTTOM = 4357, + AF_BLUE_STRING_SUNDANESE_DESCENDER = 4389, + AF_BLUE_STRING_TAI_VIET_TOP = 4397, + AF_BLUE_STRING_TAI_VIET_BOTTOM = 4417, + AF_BLUE_STRING_TAMIL_TOP = 4429, + AF_BLUE_STRING_TAMIL_BOTTOM = 4461, + AF_BLUE_STRING_TELUGU_TOP = 4493, + AF_BLUE_STRING_TELUGU_BOTTOM = 4521, + AF_BLUE_STRING_THAI_TOP = 4549, + AF_BLUE_STRING_THAI_BOTTOM = 4573, + AF_BLUE_STRING_THAI_ASCENDER = 4601, + AF_BLUE_STRING_THAI_LARGE_ASCENDER = 4613, + AF_BLUE_STRING_THAI_DESCENDER = 4625, + AF_BLUE_STRING_THAI_LARGE_DESCENDER = 4641, + AF_BLUE_STRING_THAI_DIGIT_TOP = 4649, + AF_BLUE_STRING_TIFINAGH = 4661, + AF_BLUE_STRING_VAI_TOP = 4693, + AF_BLUE_STRING_VAI_BOTTOM = 4725, + af_blue_1_1 = 4756, #ifdef AF_CONFIG_OPTION_CJK AF_BLUE_STRING_CJK_TOP = af_blue_1_1 + 1, AF_BLUE_STRING_CJK_BOTTOM = af_blue_1_1 + 203, @@ -239,34 +318,59 @@ FT_BEGIN_HEADER typedef enum AF_Blue_Stringset_ { - AF_BLUE_STRINGSET_ARAB = 0, - AF_BLUE_STRINGSET_ARMN = 4, - AF_BLUE_STRINGSET_BENG = 11, - AF_BLUE_STRINGSET_CHER = 16, - AF_BLUE_STRINGSET_CYRL = 23, - AF_BLUE_STRINGSET_DEVA = 29, - AF_BLUE_STRINGSET_ETHI = 35, - AF_BLUE_STRINGSET_GEOR = 38, - AF_BLUE_STRINGSET_GEOK = 43, - AF_BLUE_STRINGSET_GREK = 50, - AF_BLUE_STRINGSET_GUJR = 57, - AF_BLUE_STRINGSET_GURU = 63, - AF_BLUE_STRINGSET_HEBR = 69, - AF_BLUE_STRINGSET_KNDA = 73, - AF_BLUE_STRINGSET_KHMR = 76, - AF_BLUE_STRINGSET_KHMS = 82, - AF_BLUE_STRINGSET_LAO = 85, - AF_BLUE_STRINGSET_LATN = 91, - AF_BLUE_STRINGSET_LATB = 98, - AF_BLUE_STRINGSET_LATP = 105, - AF_BLUE_STRINGSET_MLYM = 112, - AF_BLUE_STRINGSET_MYMR = 115, - AF_BLUE_STRINGSET_NONE = 120, - AF_BLUE_STRINGSET_SINH = 121, - AF_BLUE_STRINGSET_TAML = 125, - AF_BLUE_STRINGSET_TELU = 128, - AF_BLUE_STRINGSET_THAI = 131, - af_blue_2_1 = 139, + AF_BLUE_STRINGSET_ADLM = 0, + AF_BLUE_STRINGSET_ARAB = 5, + AF_BLUE_STRINGSET_ARMN = 9, + AF_BLUE_STRINGSET_AVST = 16, + AF_BLUE_STRINGSET_BAMU = 19, + AF_BLUE_STRINGSET_BENG = 22, + AF_BLUE_STRINGSET_BUHD = 27, + AF_BLUE_STRINGSET_CAKM = 32, + AF_BLUE_STRINGSET_CANS = 36, + AF_BLUE_STRINGSET_CARI = 43, + AF_BLUE_STRINGSET_CHER = 46, + AF_BLUE_STRINGSET_COPT = 53, + AF_BLUE_STRINGSET_CPRT = 58, + AF_BLUE_STRINGSET_CYRL = 63, + AF_BLUE_STRINGSET_DEVA = 69, + AF_BLUE_STRINGSET_DSRT = 75, + AF_BLUE_STRINGSET_ETHI = 80, + AF_BLUE_STRINGSET_GEOR = 83, + AF_BLUE_STRINGSET_GEOK = 88, + AF_BLUE_STRINGSET_GLAG = 95, + AF_BLUE_STRINGSET_GOTH = 100, + AF_BLUE_STRINGSET_GREK = 103, + AF_BLUE_STRINGSET_GUJR = 110, + AF_BLUE_STRINGSET_GURU = 116, + AF_BLUE_STRINGSET_HEBR = 122, + AF_BLUE_STRINGSET_KALI = 126, + AF_BLUE_STRINGSET_KNDA = 132, + AF_BLUE_STRINGSET_KHMR = 135, + AF_BLUE_STRINGSET_KHMS = 141, + AF_BLUE_STRINGSET_LAO = 144, + AF_BLUE_STRINGSET_LATN = 150, + AF_BLUE_STRINGSET_LATB = 157, + AF_BLUE_STRINGSET_LATP = 164, + AF_BLUE_STRINGSET_LISU = 171, + AF_BLUE_STRINGSET_MLYM = 174, + AF_BLUE_STRINGSET_MYMR = 177, + AF_BLUE_STRINGSET_NKOO = 182, + AF_BLUE_STRINGSET_NONE = 187, + AF_BLUE_STRINGSET_OLCK = 188, + AF_BLUE_STRINGSET_ORKH = 191, + AF_BLUE_STRINGSET_OSGE = 194, + AF_BLUE_STRINGSET_OSMA = 202, + AF_BLUE_STRINGSET_SAUR = 205, + AF_BLUE_STRINGSET_SHAW = 208, + AF_BLUE_STRINGSET_SINH = 214, + AF_BLUE_STRINGSET_SUND = 218, + AF_BLUE_STRINGSET_TAML = 222, + AF_BLUE_STRINGSET_TAVT = 225, + AF_BLUE_STRINGSET_TELU = 228, + AF_BLUE_STRINGSET_THAI = 231, + AF_BLUE_STRINGSET_TFNG = 239, + AF_BLUE_STRINGSET_VAII = 242, + af_blue_2_1 = 245, #ifdef AF_CONFIG_OPTION_CJK AF_BLUE_STRINGSET_HANI = af_blue_2_1 + 0, af_blue_2_1_1 = af_blue_2_1 + 2, diff --git a/thirdparty/freetype/src/autofit/afblue.hin b/thirdparty/freetype/src/autofit/afblue.hin index dd44e77254..268bcbc531 100644 --- a/thirdparty/freetype/src/autofit/afblue.hin +++ b/thirdparty/freetype/src/autofit/afblue.hin @@ -4,7 +4,7 @@ /* */ /* Auto-fitter data for blue strings (specification). */ /* */ -/* Copyright 2013-2016 by */ +/* Copyright 2013-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/thirdparty/freetype/src/autofit/afcjk.c b/thirdparty/freetype/src/autofit/afcjk.c index 4823c1d7f8..61e29cdeda 100644 --- a/thirdparty/freetype/src/autofit/afcjk.c +++ b/thirdparty/freetype/src/autofit/afcjk.c @@ -4,7 +4,7 @@ /* */ /* Auto-fitter hinting routines for CJK writing system (body). */ /* */ -/* Copyright 2006-2016 by */ +/* Copyright 2006-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -29,13 +29,13 @@ #include "afglobal.h" #include "afpic.h" #include "aflatin.h" +#include "afcjk.h" #ifdef AF_CONFIG_OPTION_CJK #undef AF_CONFIG_OPTION_CJK_BLUE_HANI_VERT -#include "afcjk.h" #include "aferrors.h" @@ -563,7 +563,7 @@ FT_Face face ) { FT_Bool started = 0, same_width = 1; - FT_Fixed advance, old_advance = 0; + FT_Fixed advance = 0, old_advance = 0; void* shaper_buf; @@ -1398,9 +1398,9 @@ other_flags |= AF_LATIN_HINTS_VERT_SNAP; /* - * We adjust stems to full pixels only if we don't use the `light' mode. + * We adjust stems to full pixels unless in `light' or `lcd' mode. */ - if ( mode != FT_RENDER_MODE_LIGHT ) + if ( mode != FT_RENDER_MODE_LIGHT && mode != FT_RENDER_MODE_LCD ) other_flags |= AF_LATIN_HINTS_STEM_ADJUST; if ( mode == FT_RENDER_MODE_MONO ) @@ -2351,13 +2351,13 @@ sizeof ( AF_CJKMetricsRec ), - (AF_WritingSystem_InitMetricsFunc) af_cjk_metrics_init, - (AF_WritingSystem_ScaleMetricsFunc)af_cjk_metrics_scale, - (AF_WritingSystem_DoneMetricsFunc) NULL, - (AF_WritingSystem_GetStdWidthsFunc)af_cjk_get_standard_widths, + (AF_WritingSystem_InitMetricsFunc) af_cjk_metrics_init, /* style_metrics_init */ + (AF_WritingSystem_ScaleMetricsFunc)af_cjk_metrics_scale, /* style_metrics_scale */ + (AF_WritingSystem_DoneMetricsFunc) NULL, /* style_metrics_done */ + (AF_WritingSystem_GetStdWidthsFunc)af_cjk_get_standard_widths, /* style_metrics_getstdw */ - (AF_WritingSystem_InitHintsFunc) af_cjk_hints_init, - (AF_WritingSystem_ApplyHintsFunc) af_cjk_hints_apply + (AF_WritingSystem_InitHintsFunc) af_cjk_hints_init, /* style_hints_init */ + (AF_WritingSystem_ApplyHintsFunc) af_cjk_hints_apply /* style_hints_apply */ ) @@ -2371,13 +2371,13 @@ sizeof ( AF_CJKMetricsRec ), - (AF_WritingSystem_InitMetricsFunc) NULL, - (AF_WritingSystem_ScaleMetricsFunc)NULL, - (AF_WritingSystem_DoneMetricsFunc) NULL, - (AF_WritingSystem_GetStdWidthsFunc)NULL, + (AF_WritingSystem_InitMetricsFunc) NULL, /* style_metrics_init */ + (AF_WritingSystem_ScaleMetricsFunc)NULL, /* style_metrics_scale */ + (AF_WritingSystem_DoneMetricsFunc) NULL, /* style_metrics_done */ + (AF_WritingSystem_GetStdWidthsFunc)NULL, /* style_metrics_getstdw */ - (AF_WritingSystem_InitHintsFunc) NULL, - (AF_WritingSystem_ApplyHintsFunc) NULL + (AF_WritingSystem_InitHintsFunc) NULL, /* style_hints_init */ + (AF_WritingSystem_ApplyHintsFunc) NULL /* style_hints_apply */ ) diff --git a/thirdparty/freetype/src/autofit/afcjk.h b/thirdparty/freetype/src/autofit/afcjk.h index 40d1184386..84f892f909 100644 --- a/thirdparty/freetype/src/autofit/afcjk.h +++ b/thirdparty/freetype/src/autofit/afcjk.h @@ -4,7 +4,7 @@ /* */ /* Auto-fitter hinting routines for CJK writing system (specification). */ /* */ -/* Copyright 2006-2016 by */ +/* Copyright 2006-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/thirdparty/freetype/src/autofit/afcover.h b/thirdparty/freetype/src/autofit/afcover.h index 1c39a707ef..1b18c666ab 100644 --- a/thirdparty/freetype/src/autofit/afcover.h +++ b/thirdparty/freetype/src/autofit/afcover.h @@ -4,7 +4,7 @@ /* */ /* Auto-fitter coverages (specification only). */ /* */ -/* Copyright 2013-2016 by */ +/* Copyright 2013-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/thirdparty/freetype/src/autofit/afdummy.c b/thirdparty/freetype/src/autofit/afdummy.c index f3960c85fd..61c32db5bf 100644 --- a/thirdparty/freetype/src/autofit/afdummy.c +++ b/thirdparty/freetype/src/autofit/afdummy.c @@ -5,7 +5,7 @@ /* Auto-fitter dummy routines to be used if no hinting should be */ /* performed (body). */ /* */ -/* Copyright 2003-2016 by */ +/* Copyright 2003-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -62,13 +62,13 @@ sizeof ( AF_StyleMetricsRec ), - (AF_WritingSystem_InitMetricsFunc) NULL, - (AF_WritingSystem_ScaleMetricsFunc)NULL, - (AF_WritingSystem_DoneMetricsFunc) NULL, - (AF_WritingSystem_GetStdWidthsFunc)NULL, + (AF_WritingSystem_InitMetricsFunc) NULL, /* style_metrics_init */ + (AF_WritingSystem_ScaleMetricsFunc)NULL, /* style_metrics_scale */ + (AF_WritingSystem_DoneMetricsFunc) NULL, /* style_metrics_done */ + (AF_WritingSystem_GetStdWidthsFunc)NULL, /* style_metrics_getstdw */ - (AF_WritingSystem_InitHintsFunc) af_dummy_hints_init, - (AF_WritingSystem_ApplyHintsFunc) af_dummy_hints_apply + (AF_WritingSystem_InitHintsFunc) af_dummy_hints_init, /* style_hints_init */ + (AF_WritingSystem_ApplyHintsFunc) af_dummy_hints_apply /* style_hints_apply */ ) diff --git a/thirdparty/freetype/src/autofit/afdummy.h b/thirdparty/freetype/src/autofit/afdummy.h index 7e58d1a9a5..ebaa7d76ea 100644 --- a/thirdparty/freetype/src/autofit/afdummy.h +++ b/thirdparty/freetype/src/autofit/afdummy.h @@ -5,7 +5,7 @@ /* Auto-fitter dummy routines to be used if no hinting should be */ /* performed (specification). */ /* */ -/* Copyright 2003-2016 by */ +/* Copyright 2003-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/thirdparty/freetype/src/autofit/aferrors.h b/thirdparty/freetype/src/autofit/aferrors.h index 53c01f64dd..dde182f3c8 100644 --- a/thirdparty/freetype/src/autofit/aferrors.h +++ b/thirdparty/freetype/src/autofit/aferrors.h @@ -4,7 +4,7 @@ /* */ /* Autofitter error codes (specification only). */ /* */ -/* Copyright 2005-2016 by */ +/* Copyright 2005-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/thirdparty/freetype/src/autofit/afglobal.c b/thirdparty/freetype/src/autofit/afglobal.c index ac6dcafc0f..85bef001f7 100644 --- a/thirdparty/freetype/src/autofit/afglobal.c +++ b/thirdparty/freetype/src/autofit/afglobal.c @@ -4,7 +4,7 @@ /* */ /* Auto-fitter routines to compute global hinting values (body). */ /* */ -/* Copyright 2003-2016 by */ +/* Copyright 2003-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -168,7 +168,7 @@ AF_Script_UniRange range; - if ( script_class->script_uni_ranges == NULL ) + if ( !script_class->script_uni_ranges ) continue; /* @@ -411,23 +411,11 @@ #ifdef FT_CONFIG_OPTION_USE_HARFBUZZ hb_font_destroy( globals->hb_font ); - globals->hb_font = NULL; - hb_buffer_destroy( globals->hb_buf ); - globals->hb_buf = NULL; #endif - globals->glyph_count = 0; - globals->stem_darkening_for_ppem = 0; - globals->darken_x = 0; - globals->darken_y = 0; - globals->standard_vertical_width = 0; - globals->standard_horizontal_width = 0; - globals->scale_down_factor = 0; - /* no need to free this one! */ - globals->glyph_styles = NULL; - globals->face = NULL; - + /* no need to free `globals->glyph_styles'; */ + /* it is part of the `globals' array */ FT_FREE( globals ); } } @@ -465,7 +453,7 @@ [style_class->writing_system]; metrics = globals->metrics[style]; - if ( metrics == NULL ) + if ( !metrics ) { /* create the global metrics object if necessary */ FT_Memory memory = globals->face->memory; diff --git a/thirdparty/freetype/src/autofit/afglobal.h b/thirdparty/freetype/src/autofit/afglobal.h index ce6b9e8f26..de6142ea26 100644 --- a/thirdparty/freetype/src/autofit/afglobal.h +++ b/thirdparty/freetype/src/autofit/afglobal.h @@ -5,7 +5,7 @@ /* Auto-fitter routines to compute global hinting values */ /* (specification). */ /* */ -/* Copyright 2003-2016 by */ +/* Copyright 2003-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/thirdparty/freetype/src/autofit/afhints.c b/thirdparty/freetype/src/autofit/afhints.c index 6c3d032d1c..f1ff0baef8 100644 --- a/thirdparty/freetype/src/autofit/afhints.c +++ b/thirdparty/freetype/src/autofit/afhints.c @@ -4,7 +4,7 @@ /* */ /* Auto-fitter hinting routines (body). */ /* */ -/* Copyright 2003-2016 by */ +/* Copyright 2003-2017 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 @@ if ( axis->num_segments < AF_SEGMENTS_EMBEDDED ) { - if ( axis->segments == NULL ) + if ( !axis->segments ) { axis->segments = axis->embedded.segments; axis->max_segments = AF_SEGMENTS_EMBEDDED; @@ -110,7 +110,7 @@ if ( axis->num_edges < AF_EDGES_EMBEDDED ) { - if ( axis->edges == NULL ) + if ( !axis->edges ) { axis->edges = axis->embedded.edges; axis->max_edges = AF_EDGES_EMBEDDED; @@ -420,20 +420,19 @@ dimension == AF_DIMENSION_HORZ ? "vertical" : "horizontal" )); if ( axis->num_segments ) - AF_DUMP(( " index pos dir from to" - " link serif edge" + AF_DUMP(( " index pos delta dir from to " + " link serif edge" " height extra flags\n" )); else AF_DUMP(( " (none)\n" )); for ( seg = segments; seg < limit; seg++ ) - AF_DUMP(( " %5d %5.2g %5s %4d %4d" + AF_DUMP(( " %5d %5d %5d %5s %4d %4d" " %4s %5s %4s" " %6d %5d %11s\n", AF_INDEX_NUM( seg, segments ), - dimension == AF_DIMENSION_HORZ - ? (int)seg->first->ox / 64.0 - : (int)seg->first->oy / 64.0, + seg->pos, + seg->delta, af_dir_str( (AF_Direction)seg->dir ), AF_INDEX_NUM( seg->first, points ), AF_INDEX_NUM( seg->last, points ), @@ -553,18 +552,26 @@ * note: AF_DIMENSION_HORZ corresponds to _vertical_ edges * since they have a constant X coordinate. */ - AF_DUMP(( "Table of %s edges:\n", - dimension == AF_DIMENSION_HORZ ? "vertical" - : "horizontal" )); + if ( dimension == AF_DIMENSION_HORZ ) + AF_DUMP(( "Table of %s edges (1px=%.2fu, 10u=%.2fpx):\n", + "vertical", + 65536.0 * 64.0 / hints->x_scale, + 10.0 * hints->x_scale / 65536.0 / 64.0 )); + else + AF_DUMP(( "Table of %s edges (1px=%.2fu, 10u=%.2fpx):\n", + "horizontal", + 65536.0 * 64.0 / hints->y_scale, + 10.0 * hints->y_scale / 65536.0 / 64.0 )); + if ( axis->num_edges ) - AF_DUMP(( " index pos dir link serif" - " blue opos pos flags\n" )); + AF_DUMP(( " index pos dir link serif" + " blue opos pos flags\n" )); else AF_DUMP(( " (none)\n" )); for ( edge = edges; edge < limit; edge++ ) - AF_DUMP(( " %5d %5.2g %5s %4s %5s" - " %c %5.2f %5.2f %11s\n", + AF_DUMP(( " %5d %7.2f %5s %4s %5s" + " %c %7.2f %7.2f %11s\n", AF_INDEX_NUM( edge, edges ), (int)edge->opos / 64.0, af_dir_str( (AF_Direction)edge->dir ), @@ -736,7 +743,7 @@ if ( new_max <= AF_CONTOURS_EMBEDDED ) { - if ( hints->contours == NULL ) + if ( !hints->contours ) { hints->contours = hints->embedded.contours; hints->max_contours = AF_CONTOURS_EMBEDDED; @@ -765,7 +772,7 @@ if ( new_max <= AF_POINTS_EMBEDDED ) { - if ( hints->points == NULL ) + if ( !hints->points ) { hints->points = hints->embedded.points; hints->max_points = AF_POINTS_EMBEDDED; @@ -1175,7 +1182,7 @@ AF_Point point, first, last; - if ( edge == NULL ) + if ( !edge ) continue; first = seg->first; @@ -1201,7 +1208,7 @@ AF_Point point, first, last; - if ( edge == NULL ) + if ( !edge ) continue; first = seg->first; diff --git a/thirdparty/freetype/src/autofit/afhints.h b/thirdparty/freetype/src/autofit/afhints.h index 5142e6ed21..16638b1030 100644 --- a/thirdparty/freetype/src/autofit/afhints.h +++ b/thirdparty/freetype/src/autofit/afhints.h @@ -4,7 +4,7 @@ /* */ /* Auto-fitter hinting routines (specification). */ /* */ -/* Copyright 2003-2016 by */ +/* Copyright 2003-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -260,6 +260,7 @@ FT_BEGIN_HEADER FT_Byte flags; /* edge/segment flags for this segment */ FT_Char dir; /* segment direction */ FT_Short pos; /* position of segment */ + FT_Short delta; /* deviation from segment position */ FT_Short min_coord; /* minimum coordinate of segment */ FT_Short max_coord; /* maximum coordinate of segment */ FT_Short height; /* the hinted segment height */ diff --git a/thirdparty/freetype/src/autofit/afindic.c b/thirdparty/freetype/src/autofit/afindic.c index 097a2b2995..23be46ed51 100644 --- a/thirdparty/freetype/src/autofit/afindic.c +++ b/thirdparty/freetype/src/autofit/afindic.c @@ -4,7 +4,7 @@ /* */ /* Auto-fitter hinting routines for Indic writing system (body). */ /* */ -/* Copyright 2007-2016 by */ +/* Copyright 2007-2017 by */ /* Rahul Bhalerao <rahul.bhalerao@redhat.com>, <b.rahul.pm@gmail.com>. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -18,13 +18,13 @@ #include "aftypes.h" #include "aflatin.h" +#include "afcjk.h" #ifdef AF_CONFIG_OPTION_INDIC #include "afindic.h" #include "aferrors.h" -#include "afcjk.h" #ifdef AF_CONFIG_OPTION_USE_WARPER @@ -121,13 +121,13 @@ sizeof ( AF_CJKMetricsRec ), - (AF_WritingSystem_InitMetricsFunc) af_indic_metrics_init, - (AF_WritingSystem_ScaleMetricsFunc)af_indic_metrics_scale, - (AF_WritingSystem_DoneMetricsFunc) NULL, - (AF_WritingSystem_GetStdWidthsFunc)af_indic_get_standard_widths, + (AF_WritingSystem_InitMetricsFunc) af_indic_metrics_init, /* style_metrics_init */ + (AF_WritingSystem_ScaleMetricsFunc)af_indic_metrics_scale, /* style_metrics_scale */ + (AF_WritingSystem_DoneMetricsFunc) NULL, /* style_metrics_done */ + (AF_WritingSystem_GetStdWidthsFunc)af_indic_get_standard_widths, /* style_metrics_getstdw */ - (AF_WritingSystem_InitHintsFunc) af_indic_hints_init, - (AF_WritingSystem_ApplyHintsFunc) af_indic_hints_apply + (AF_WritingSystem_InitHintsFunc) af_indic_hints_init, /* style_hints_init */ + (AF_WritingSystem_ApplyHintsFunc) af_indic_hints_apply /* style_hints_apply */ ) @@ -141,13 +141,13 @@ sizeof ( AF_CJKMetricsRec ), - (AF_WritingSystem_InitMetricsFunc) NULL, - (AF_WritingSystem_ScaleMetricsFunc)NULL, - (AF_WritingSystem_DoneMetricsFunc) NULL, - (AF_WritingSystem_GetStdWidthsFunc)NULL, + (AF_WritingSystem_InitMetricsFunc) NULL, /* style_metrics_init */ + (AF_WritingSystem_ScaleMetricsFunc)NULL, /* style_metrics_scale */ + (AF_WritingSystem_DoneMetricsFunc) NULL, /* style_metrics_done */ + (AF_WritingSystem_GetStdWidthsFunc)NULL, /* style_metrics_getstdw */ - (AF_WritingSystem_InitHintsFunc) NULL, - (AF_WritingSystem_ApplyHintsFunc) NULL + (AF_WritingSystem_InitHintsFunc) NULL, /* style_hints_init */ + (AF_WritingSystem_ApplyHintsFunc) NULL /* style_hints_apply */ ) diff --git a/thirdparty/freetype/src/autofit/afindic.h b/thirdparty/freetype/src/autofit/afindic.h index 0772e07a29..ec9e263161 100644 --- a/thirdparty/freetype/src/autofit/afindic.h +++ b/thirdparty/freetype/src/autofit/afindic.h @@ -5,7 +5,7 @@ /* Auto-fitter hinting routines for Indic writing system */ /* (specification). */ /* */ -/* Copyright 2007-2016 by */ +/* Copyright 2007-2017 by */ /* Rahul Bhalerao <rahul.bhalerao@redhat.com>, <b.rahul.pm@gmail.com>. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/thirdparty/freetype/src/autofit/aflatin.c b/thirdparty/freetype/src/autofit/aflatin.c index 7ccf3f6e37..11fa523c83 100644 --- a/thirdparty/freetype/src/autofit/aflatin.c +++ b/thirdparty/freetype/src/autofit/aflatin.c @@ -4,7 +4,7 @@ /* */ /* Auto-fitter hinting routines for latin writing system (body). */ /* */ -/* Copyright 2003-2016 by */ +/* Copyright 2003-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -265,6 +265,45 @@ } + static void + af_latin_sort_blue( FT_UInt count, + AF_LatinBlue* table ) + { + FT_UInt i, j; + AF_LatinBlue swap; + + + /* we sort from bottom to top */ + for ( i = 1; i < count; i++ ) + { + for ( j = i; j > 0; j-- ) + { + FT_Pos a, b; + + + if ( table[j - 1]->flags & ( AF_LATIN_BLUE_TOP | + AF_LATIN_BLUE_SUB_TOP ) ) + a = table[j - 1]->ref.org; + else + a = table[j - 1]->shoot.org; + + if ( table[j]->flags & ( AF_LATIN_BLUE_TOP | + AF_LATIN_BLUE_SUB_TOP ) ) + b = table[j]->ref.org; + else + b = table[j]->shoot.org; + + if ( b >= a ) + break; + + swap = table[j]; + table[j] = table[j - 1]; + table[j - 1] = swap; + } + } + } + + /* Find all blue zones. Flat segments give the reference points, */ /* round segments the overshoot positions. */ @@ -928,6 +967,60 @@ af_shaper_buf_destroy( face, shaper_buf ); + /* we finally check whether blue zones are ordered; */ + /* `ref' and `shoot' values of two blue zones must not overlap */ + if ( axis->blue_count ) + { + FT_UInt i; + AF_LatinBlue blue_sorted[AF_BLUE_STRINGSET_MAX_LEN + 2]; + + + for ( i = 0; i < axis->blue_count; i++ ) + blue_sorted[i] = &axis->blues[i]; + + /* sort bottoms of blue zones... */ + af_latin_sort_blue( axis->blue_count, blue_sorted ); + + /* ...and adjust top values if necessary */ + for ( i = 0; i < axis->blue_count - 1; i++ ) + { + FT_Pos* a; + FT_Pos* b; + +#ifdef FT_DEBUG_LEVEL_TRACE + FT_Bool a_is_top = 0; +#endif + + + if ( blue_sorted[i]->flags & ( AF_LATIN_BLUE_TOP | + AF_LATIN_BLUE_SUB_TOP ) ) + { + a = &blue_sorted[i]->shoot.org; +#ifdef FT_DEBUG_LEVEL_TRACE + a_is_top = 1; +#endif + } + else + a = &blue_sorted[i]->ref.org; + + if ( blue_sorted[i + 1]->flags & ( AF_LATIN_BLUE_TOP | + AF_LATIN_BLUE_SUB_TOP ) ) + b = &blue_sorted[i + 1]->shoot.org; + else + b = &blue_sorted[i + 1]->ref.org; + + if ( *a > *b ) + { + *a = *b; + FT_TRACE5(( "blue zone overlap:" + " adjusting %s %d to %ld\n", + a_is_top ? "overshoot" : "reference", + blue_sorted[i] - axis->blues, + *a )); + } + } + } + FT_TRACE5(( "\n" )); return; @@ -941,7 +1034,7 @@ FT_Face face ) { FT_Bool started = 0, same_width = 1; - FT_Fixed advance, old_advance = 0; + FT_Fixed advance = 0, old_advance = 0; void* shaper_buf; @@ -1076,7 +1169,7 @@ FT_UInt ppem; - scaled = FT_MulFix( blue->shoot.org, scaler->y_scale ); + scaled = FT_MulFix( blue->shoot.org, scale ); ppem = metrics->root.scaler.face->size->metrics.x_ppem; limit = metrics->root.globals->increase_x_height; threshold = 40; @@ -1123,18 +1216,18 @@ if ( dist == 0 ) { - scale = new_scale; - FT_TRACE5(( "af_latin_metrics_scale_dim:" " x height alignment (style `%s'):\n" " " - " vertical scaling changed from %.4f to %.4f (by %d%%)\n" + " vertical scaling changed from %.5f to %.5f (by %d%%)\n" "\n", af_style_names[metrics->root.style_class->style], - axis->org_scale / 65536.0, scale / 65536.0, + new_scale / 65536.0, ( fitted - scaled ) * 100 / scaled )); + + scale = new_scale; } #ifdef FT_DEBUG_LEVEL_TRACE else @@ -1536,8 +1629,9 @@ /* points are different: we are just leaving an edge, thus */ /* record a new segment */ - segment->last = point; - segment->pos = (FT_Short)( ( min_pos + max_pos ) >> 1 ); + segment->last = point; + segment->pos = (FT_Short)( ( min_pos + max_pos ) >> 1 ); + segment->delta = (FT_Short)( ( max_pos - min_pos ) >> 1 ); /* a segment is round if either its first or last point */ /* is a control point, and the length of the on points */ @@ -1950,6 +2044,10 @@ FT_Memory memory = hints->memory; AF_LatinAxis laxis = &((AF_LatinMetrics)hints->metrics)->axis[dim]; +#ifdef FT_CONFIG_OPTION_PIC + AF_FaceGlobals globals = hints->metrics->globals; +#endif + AF_StyleClass style_class = hints->metrics->style_class; AF_ScriptClass script_class = AF_SCRIPT_CLASSES_GET [style_class->script]; @@ -1966,6 +2064,7 @@ FT_Fixed scale; FT_Pos edge_distance_threshold; FT_Pos segment_length_threshold; + FT_Pos segment_width_threshold; axis->num_edges = 0; @@ -1987,9 +2086,15 @@ * corresponding threshold in font units. */ if ( dim == AF_DIMENSION_HORZ ) - segment_length_threshold = FT_DivFix( 64, hints->y_scale ); + segment_length_threshold = FT_DivFix( 64, hints->y_scale ); else - segment_length_threshold = 0; + segment_length_threshold = 0; + + /* + * Similarly, we ignore segments that have a width delta + * larger than 0.5px (i.e., a width larger than 1px). + */ + segment_width_threshold = FT_DivFix( 32, scale ); /*********************************************************************/ /* */ @@ -2022,9 +2127,10 @@ FT_Int ee; - /* ignore too short segments and, in this loop, */ - /* one-point segments without a direction */ + /* ignore too short segments, too wide ones, and, in this loop, */ + /* one-point segments without a direction */ if ( seg->height < segment_length_threshold || + seg->delta > segment_width_threshold || seg->dir == AF_DIR_NONE ) continue; @@ -2202,7 +2308,7 @@ seg->serif->edge && seg->serif->edge != edge ); - if ( ( seg->link && seg->link->edge != NULL ) || is_serif ) + if ( ( seg->link && seg->link->edge ) || is_serif ) { AF_Edge edge2; AF_Segment seg2; @@ -2469,23 +2575,23 @@ other_flags |= AF_LATIN_HINTS_VERT_SNAP; /* - * We adjust stems to full pixels only if we don't use the `light' mode. + * We adjust stems to full pixels unless in `light' or `lcd' mode. */ - if ( mode != FT_RENDER_MODE_LIGHT ) + if ( mode != FT_RENDER_MODE_LIGHT && mode != FT_RENDER_MODE_LCD ) other_flags |= AF_LATIN_HINTS_STEM_ADJUST; if ( mode == FT_RENDER_MODE_MONO ) other_flags |= AF_LATIN_HINTS_MONO; /* - * In `light' hinting mode we disable horizontal hinting completely. + * In `light' or `lcd' mode we disable horizontal hinting completely. * We also do it if the face is italic. * * However, if warping is enabled (which only works in `light' hinting * mode), advance widths get adjusted, too. */ - if ( mode == FT_RENDER_MODE_LIGHT || - ( face->style_flags & FT_STYLE_FLAG_ITALIC ) != 0 ) + if ( mode == FT_RENDER_MODE_LIGHT || mode == FT_RENDER_MODE_LCD || + ( face->style_flags & FT_STYLE_FLAG_ITALIC ) != 0 ) scaler_flags |= AF_SCALER_FLAG_NO_HORIZONTAL; #ifdef AF_CONFIG_OPTION_USE_WARPER @@ -2825,6 +2931,10 @@ AF_Edge anchor = NULL; FT_Int has_serifs = 0; +#ifdef FT_CONFIG_OPTION_PIC + AF_FaceGlobals globals = hints->metrics->globals; +#endif + AF_StyleClass style_class = hints->metrics->style_class; AF_ScriptClass script_class = AF_SCRIPT_CLASSES_GET [style_class->script]; @@ -3468,13 +3578,13 @@ sizeof ( AF_LatinMetricsRec ), - (AF_WritingSystem_InitMetricsFunc) af_latin_metrics_init, - (AF_WritingSystem_ScaleMetricsFunc)af_latin_metrics_scale, - (AF_WritingSystem_DoneMetricsFunc) NULL, - (AF_WritingSystem_GetStdWidthsFunc)af_latin_get_standard_widths, + (AF_WritingSystem_InitMetricsFunc) af_latin_metrics_init, /* style_metrics_init */ + (AF_WritingSystem_ScaleMetricsFunc)af_latin_metrics_scale, /* style_metrics_scale */ + (AF_WritingSystem_DoneMetricsFunc) NULL, /* style_metrics_done */ + (AF_WritingSystem_GetStdWidthsFunc)af_latin_get_standard_widths, /* style_metrics_getstdw */ - (AF_WritingSystem_InitHintsFunc) af_latin_hints_init, - (AF_WritingSystem_ApplyHintsFunc) af_latin_hints_apply + (AF_WritingSystem_InitHintsFunc) af_latin_hints_init, /* style_hints_init */ + (AF_WritingSystem_ApplyHintsFunc) af_latin_hints_apply /* style_hints_apply */ ) diff --git a/thirdparty/freetype/src/autofit/aflatin.h b/thirdparty/freetype/src/autofit/aflatin.h index fe6bbd801a..d80e125ddc 100644 --- a/thirdparty/freetype/src/autofit/aflatin.h +++ b/thirdparty/freetype/src/autofit/aflatin.h @@ -5,7 +5,7 @@ /* Auto-fitter hinting routines for latin writing system */ /* (specification). */ /* */ -/* Copyright 2003-2016 by */ +/* Copyright 2003-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/thirdparty/freetype/src/autofit/aflatin2.c b/thirdparty/freetype/src/autofit/aflatin2.c index 5db4a41141..0607278b1e 100644 --- a/thirdparty/freetype/src/autofit/aflatin2.c +++ b/thirdparty/freetype/src/autofit/aflatin2.c @@ -9,7 +9,7 @@ /* */ /* Auto-fitter hinting routines for latin writing system (body). */ /* */ -/* Copyright 2003-2016 by */ +/* Copyright 2003-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -23,6 +23,9 @@ #include FT_ADVANCES_H + +#ifdef FT_OPTION_AUTOFIT2 + #include "afglobal.h" #include "aflatin.h" #include "aflatin2.h" @@ -1303,7 +1306,7 @@ seg->serif->edge && seg->serif->edge != edge ); - if ( ( seg->link && seg->link->edge != NULL ) || is_serif ) + if ( ( seg->link && seg->link->edge ) || is_serif ) { AF_Edge edge2; AF_Segment seg2; @@ -1555,20 +1558,20 @@ other_flags |= AF_LATIN_HINTS_VERT_SNAP; /* - * We adjust stems to full pixels only if we don't use the `light' mode. + * We adjust stems to full pixels unless in `light' or `lcd' mode. */ - if ( mode != FT_RENDER_MODE_LIGHT ) + if ( mode != FT_RENDER_MODE_LIGHT && mode != FT_RENDER_MODE_LCD ) other_flags |= AF_LATIN_HINTS_STEM_ADJUST; if ( mode == FT_RENDER_MODE_MONO ) other_flags |= AF_LATIN_HINTS_MONO; /* - * In `light' hinting mode we disable horizontal hinting completely. + * In `light' or `lcd' mode we disable horizontal hinting completely. * We also do it if the face is italic. */ - if ( mode == FT_RENDER_MODE_LIGHT || - ( face->style_flags & FT_STYLE_FLAG_ITALIC ) != 0 ) + if ( mode == FT_RENDER_MODE_LIGHT || mode == FT_RENDER_MODE_LCD || + ( face->style_flags & FT_STYLE_FLAG_ITALIC ) != 0 ) scaler_flags |= AF_SCALER_FLAG_NO_HORIZONTAL; #ifdef AF_CONFIG_OPTION_USE_WARPER @@ -2410,14 +2413,21 @@ sizeof ( AF_LatinMetricsRec ), - (AF_WritingSystem_InitMetricsFunc) af_latin2_metrics_init, - (AF_WritingSystem_ScaleMetricsFunc)af_latin2_metrics_scale, - (AF_WritingSystem_DoneMetricsFunc) NULL, - (AF_WritingSystem_GetStdWidthsFunc)af_latin2_get_standard_widths, + (AF_WritingSystem_InitMetricsFunc) af_latin2_metrics_init, /* style_metrics_init */ + (AF_WritingSystem_ScaleMetricsFunc)af_latin2_metrics_scale, /* style_metrics_scale */ + (AF_WritingSystem_DoneMetricsFunc) NULL, /* style_metrics_done */ + (AF_WritingSystem_GetStdWidthsFunc)af_latin2_get_standard_widths, /* style_metrics_getstdw */ - (AF_WritingSystem_InitHintsFunc) af_latin2_hints_init, - (AF_WritingSystem_ApplyHintsFunc) af_latin2_hints_apply + (AF_WritingSystem_InitHintsFunc) af_latin2_hints_init, /* style_hints_init */ + (AF_WritingSystem_ApplyHintsFunc) af_latin2_hints_apply /* style_hints_apply */ ) +#else /* !FT_OPTION_AUTOFIT2 */ + + /* ANSI C doesn't like empty source files */ + typedef int _af_latin2_dummy; + +#endif /* !FT_OPTION_AUTOFIT2 */ + /* END */ diff --git a/thirdparty/freetype/src/autofit/aflatin2.h b/thirdparty/freetype/src/autofit/aflatin2.h index f83f704289..2d0b154f58 100644 --- a/thirdparty/freetype/src/autofit/aflatin2.h +++ b/thirdparty/freetype/src/autofit/aflatin2.h @@ -10,7 +10,7 @@ /* Auto-fitter hinting routines for latin writing system */ /* (specification). */ /* */ -/* Copyright 2003-2016 by */ +/* Copyright 2003-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/thirdparty/freetype/src/autofit/afloader.c b/thirdparty/freetype/src/autofit/afloader.c index 26bba065bb..78c4368b61 100644 --- a/thirdparty/freetype/src/autofit/afloader.c +++ b/thirdparty/freetype/src/autofit/afloader.c @@ -4,7 +4,7 @@ /* */ /* Auto-fitter glyph loading routines (body). */ /* */ -/* Copyright 2003-2016 by */ +/* Copyright 2003-2017 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 @@ loader->face = face; loader->globals = (AF_FaceGlobals)face->autohint.data; - if ( loader->globals == NULL ) + if ( !loader->globals ) { error = af_face_globals_new( face, &loader->globals, module ); if ( !error ) @@ -86,169 +86,316 @@ ( (FT_Fixed)( (f) * 65536.0 + 0.5 ) ) - /* Do the main work of `af_loader_load_glyph'. Note that we never */ - /* have to deal with composite glyphs as those get loaded into */ - /* FT_GLYPH_FORMAT_OUTLINE by the recursed `FT_Load_Glyph' function. */ - /* In the rare cases where FT_LOAD_NO_RECURSE is set, it implies */ - /* FT_LOAD_NO_SCALE and as such the auto-hinter is never called. */ - static FT_Error - af_loader_load_g( AF_Loader loader, - AF_Scaler scaler, - FT_UInt glyph_index, - FT_Int32 load_flags ) + af_loader_embolden_glyph_in_slot( AF_Loader loader, + FT_Face face, + AF_StyleMetrics style_metrics ) { - AF_Module module = loader->globals->module; + FT_Error error = FT_Err_Ok; - FT_Error error; - FT_Face face = loader->face; - AF_StyleMetrics metrics = loader->metrics; - AF_GlyphHints hints = loader->hints; - FT_GlyphSlot slot = face->glyph; - FT_Slot_Internal internal = slot->internal; - FT_GlyphLoader gloader = internal->loader; - FT_Int32 flags; + FT_GlyphSlot slot = face->glyph; + AF_FaceGlobals globals = loader->globals; + AF_WritingSystemClass writing_system_class; + FT_Size_Metrics* size_metrics = &face->size->internal->autohint_metrics; - flags = load_flags | FT_LOAD_LINEAR_DESIGN; - error = FT_Load_Glyph( face, glyph_index, flags ); - if ( error ) + FT_Pos stdVW = 0; + FT_Pos stdHW = 0; + + FT_Bool size_changed = size_metrics->x_ppem != + globals->stem_darkening_for_ppem; + + FT_Fixed em_size = af_intToFixed( face->units_per_EM ); + FT_Fixed em_ratio = FT_DivFix( af_intToFixed( 1000 ), em_size ); + + FT_Matrix scale_down_matrix = { 0x10000L, 0, 0, 0x10000L }; + + + /* Skip stem darkening for broken fonts. */ + if ( !face->units_per_EM ) + { + error = FT_ERR( Corrupted_Font_Header ); goto Exit; + } /* - * Apply stem darkening (emboldening) here before hints are applied to - * the outline. Glyphs are scaled down proportionally to the - * emboldening so that curve points don't fall outside their precomputed - * blue zones. - * - * Any emboldening done by the font driver (e.g., the CFF driver) - * doesn't reach here because the autohinter loads the unprocessed - * glyphs in font units for analysis (functions `af_*_metrics_init_*') - * and then above to prepare it for the rasterizers by itself, - * independently of the font driver. So emboldening must be done here, - * within the autohinter. - * - * All glyphs to be autohinted pass through here one by one. The - * standard widths can therefore change from one glyph to the next, - * depending on what script a glyph is assigned to (each script has its - * own set of standard widths and other metrics). The darkening amount - * must therefore be recomputed for each size and - * `standard_{vertical,horizontal}_width' change. + * We depend on the writing system (script analyzers) to supply + * standard widths for the script of the glyph we are looking at. If + * it can't deliver, stem darkening is disabled. */ - if ( !module->no_stem_darkening ) + writing_system_class = + AF_WRITING_SYSTEM_CLASSES_GET[style_metrics->style_class->writing_system]; + + if ( writing_system_class->style_metrics_getstdw ) + writing_system_class->style_metrics_getstdw( style_metrics, + &stdHW, + &stdVW ); + else { - AF_FaceGlobals globals = loader->globals; - AF_WritingSystemClass writing_system_class; + error = FT_ERR( Unimplemented_Feature ); + goto Exit; + } - FT_Pos stdVW = 0; - FT_Pos stdHW = 0; + if ( size_changed || + ( stdVW > 0 && stdVW != globals->standard_vertical_width ) ) + { + FT_Fixed darken_by_font_units_x, darken_x; - FT_Bool size_changed = face->size->metrics.x_ppem - != globals->stem_darkening_for_ppem; - FT_Fixed em_size = af_intToFixed( face->units_per_EM ); - FT_Fixed em_ratio = FT_DivFix( af_intToFixed( 1000 ), em_size ); + darken_by_font_units_x = + af_intToFixed( af_loader_compute_darkening( loader, + face, + stdVW ) ); + darken_x = FT_DivFix( FT_MulFix( darken_by_font_units_x, + size_metrics->x_scale ), + em_ratio ); - FT_Matrix scale_down_matrix = { 0x10000L, 0, 0, 0x10000L }; + globals->standard_vertical_width = stdVW; + globals->stem_darkening_for_ppem = size_metrics->x_ppem; + globals->darken_x = af_fixedToInt( darken_x ); + } + if ( size_changed || + ( stdHW > 0 && stdHW != globals->standard_horizontal_width ) ) + { + FT_Fixed darken_by_font_units_y, darken_y; + + + darken_by_font_units_y = + af_intToFixed( af_loader_compute_darkening( loader, + face, + stdHW ) ); + darken_y = FT_DivFix( FT_MulFix( darken_by_font_units_y, + size_metrics->y_scale ), + em_ratio ); - /* Skip stem darkening for broken fonts. */ - if ( !face->units_per_EM ) - goto After_Emboldening; + globals->standard_horizontal_width = stdHW; + globals->stem_darkening_for_ppem = size_metrics->x_ppem; + globals->darken_y = af_fixedToInt( darken_y ); /* - * We depend on the writing system (script analyzers) to supply - * standard widths for the script of the glyph we are looking at. If - * it can't deliver, stem darkening is effectively disabled. + * Scale outlines down on the Y-axis to keep them inside their blue + * zones. The stronger the emboldening, the stronger the downscaling + * (plus heuristical padding to prevent outlines still falling out + * their zones due to rounding). + * + * Reason: `FT_Outline_Embolden' works by shifting the rightmost + * points of stems farther to the right, and topmost points farther + * up. This positions points on the Y-axis outside their + * pre-computed blue zones and leads to distortion when applying the + * hints in the code further below. Code outside this emboldening + * block doesn't know we are presenting it with modified outlines the + * analyzer didn't see! + * + * An unfortunate side effect of downscaling is that the emboldening + * effect is slightly decreased. The loss becomes more pronounced + * versus the CFF driver at smaller sizes, e.g., at 9ppem and below. */ - writing_system_class = - AF_WRITING_SYSTEM_CLASSES_GET[metrics->style_class->writing_system]; + globals->scale_down_factor = + FT_DivFix( em_size - ( darken_by_font_units_y + af_intToFixed( 8 ) ), + em_size ); + } - if ( writing_system_class->style_metrics_getstdw ) - writing_system_class->style_metrics_getstdw( metrics, - &stdHW, - &stdVW ); - else - goto After_Emboldening; + FT_Outline_EmboldenXY( &slot->outline, + globals->darken_x, + globals->darken_y ); + scale_down_matrix.yy = globals->scale_down_factor; + FT_Outline_Transform( &slot->outline, &scale_down_matrix ); - if ( size_changed || - ( stdVW > 0 && stdVW != globals->standard_vertical_width ) ) - { - FT_Fixed darken_by_font_units_x, darken_x; + Exit: + return error; + } - darken_by_font_units_x = - af_intToFixed( af_loader_compute_darkening( loader, - face, - stdVW ) ); - darken_x = FT_DivFix( FT_MulFix( darken_by_font_units_x, - face->size->metrics.x_scale ), - em_ratio ); + /* Load the glyph at index into the current slot of a face and hint it. */ - globals->standard_vertical_width = stdVW; - globals->stem_darkening_for_ppem = face->size->metrics.x_ppem; - globals->darken_x = af_fixedToInt( darken_x ); - } + FT_LOCAL_DEF( FT_Error ) + af_loader_load_glyph( AF_Loader loader, + AF_Module module, + FT_Face face, + FT_UInt glyph_index, + FT_Int32 load_flags ) + { + FT_Error error; + + FT_Size size = face->size; + FT_Size_Internal size_internal = size->internal; + FT_GlyphSlot slot = face->glyph; + FT_Slot_Internal slot_internal = slot->internal; + FT_GlyphLoader gloader = slot_internal->loader; + + AF_GlyphHints hints = loader->hints; + AF_ScalerRec scaler; + AF_StyleMetrics style_metrics; + FT_UInt style_options = AF_STYLE_NONE_DFLT; + AF_StyleClass style_class; + AF_WritingSystemClass writing_system_class; - if ( size_changed || - ( stdHW > 0 && stdHW != globals->standard_horizontal_width ) ) +#ifdef FT_CONFIG_OPTION_PIC + AF_FaceGlobals globals = loader->globals; +#endif + + + if ( !size ) + return FT_THROW( Invalid_Size_Handle ); + + FT_ZERO( &scaler ); + + if ( !size_internal->autohint_metrics.x_scale || + size_internal->autohint_mode != FT_LOAD_TARGET_MODE( load_flags ) ) + { + /* switching between hinting modes usually means different scaling */ + /* values; this later on enforces recomputation of everything */ + /* related to the current size */ + + size_internal->autohint_mode = FT_LOAD_TARGET_MODE( load_flags ); + size_internal->autohint_metrics = size->metrics; + +#ifdef AF_CONFIG_OPTION_TT_SIZE_METRICS { - FT_Fixed darken_by_font_units_y, darken_y; - - - darken_by_font_units_y = - af_intToFixed( af_loader_compute_darkening( loader, - face, - stdHW ) ); - darken_y = FT_DivFix( FT_MulFix( darken_by_font_units_y, - face->size->metrics.y_scale ), - em_ratio ); - - globals->standard_horizontal_width = stdHW; - globals->stem_darkening_for_ppem = face->size->metrics.x_ppem; - globals->darken_y = af_fixedToInt( darken_y ); - - /* - * Scale outlines down on the Y-axis to keep them inside their blue - * zones. The stronger the emboldening, the stronger the - * downscaling (plus heuristical padding to prevent outlines still - * falling out their zones due to rounding). - * - * Reason: `FT_Outline_Embolden' works by shifting the rightmost - * points of stems farther to the right, and topmost points farther - * up. This positions points on the Y-axis outside their - * pre-computed blue zones and leads to distortion when applying the - * hints in the code further below. Code outside this emboldening - * block doesn't know we are presenting it with modified outlines - * the analyzer didn't see! - * - * An unfortunate side effect of downscaling is that the emboldening - * effect is slightly decreased. The loss becomes more pronounced - * versus the CFF driver at smaller sizes, e.g., at 9ppem and below. - */ - globals->scale_down_factor = - FT_DivFix( em_size - ( darken_by_font_units_y + af_intToFixed( 8 ) ), - em_size ); + FT_Size_Metrics* size_metrics = &size_internal->autohint_metrics; + + + /* set metrics to integer values and adjust scaling accordingly; */ + /* this is the same setup as with TrueType fonts, cf. function */ + /* `tt_size_reset' in file `ttobjs.c' */ + size_metrics->ascender = FT_PIX_ROUND( + FT_MulFix( face->ascender, + size_metrics->y_scale ) ); + size_metrics->descender = FT_PIX_ROUND( + FT_MulFix( face->descender, + size_metrics->y_scale ) ); + size_metrics->height = FT_PIX_ROUND( + FT_MulFix( face->height, + size_metrics->y_scale ) ); + + size_metrics->x_scale = FT_DivFix( size_metrics->x_ppem << 6, + face->units_per_EM ); + size_metrics->y_scale = FT_DivFix( size_metrics->y_ppem << 6, + face->units_per_EM ); + size_metrics->max_advance = FT_PIX_ROUND( + FT_MulFix( face->max_advance_width, + size_metrics->x_scale ) ); } +#endif /* AF_CONFIG_OPTION_TT_SIZE_METRICS */ + } + + /* + * TODO: This code currently doesn't support fractional advance widths, + * i.e., placing hinted glyphs at anything other than integer + * x-positions. This is only relevant for the warper code, which + * scales and shifts glyphs to optimize blackness of stems (hinting on + * the x-axis by nature places things on pixel integers, hinting on the + * y-axis only, i.e., LIGHT mode, doesn't touch the x-axis). The delta + * values of the scaler would need to be adjusted. + */ + scaler.face = face; + scaler.x_scale = size_internal->autohint_metrics.x_scale; + scaler.x_delta = 0; + scaler.y_scale = size_internal->autohint_metrics.y_scale; + scaler.y_delta = 0; + + scaler.render_mode = FT_LOAD_TARGET_MODE( load_flags ); + scaler.flags = 0; + + /* note that the fallback style can't be changed anymore */ + /* after the first call of `af_loader_load_glyph' */ + error = af_loader_reset( loader, module, face ); + if ( error ) + goto Exit; + +#ifdef FT_OPTION_AUTOFIT2 + /* XXX: undocumented hook to activate the latin2 writing system. */ + if ( load_flags & ( 1UL << 20 ) ) + style_options = AF_STYLE_LTN2_DFLT; +#endif + + /* + * Glyphs (really code points) are assigned to scripts. Script + * analysis is done lazily: For each glyph that passes through here, + * the corresponding script analyzer is called, but returns immediately + * if it has been run already. + */ + error = af_face_globals_get_metrics( loader->globals, glyph_index, + style_options, &style_metrics ); + if ( error ) + goto Exit; + + style_class = style_metrics->style_class; + writing_system_class = + AF_WRITING_SYSTEM_CLASSES_GET[style_class->writing_system]; - FT_Outline_EmboldenXY( &slot->outline, - globals->darken_x, - globals->darken_y ); + loader->metrics = style_metrics; - scale_down_matrix.yy = globals->scale_down_factor; - FT_Outline_Transform( &slot->outline, &scale_down_matrix ); + if ( writing_system_class->style_metrics_scale ) + writing_system_class->style_metrics_scale( style_metrics, &scaler ); + else + style_metrics->scaler = scaler; + + if ( writing_system_class->style_hints_init ) + { + error = writing_system_class->style_hints_init( hints, + style_metrics ); + if ( error ) + goto Exit; } - After_Emboldening: - loader->transformed = internal->glyph_transformed; + /* + * Do the main work of `af_loader_load_glyph'. Note that we never have + * to deal with composite glyphs as those get loaded into + * FT_GLYPH_FORMAT_OUTLINE by the recursed `FT_Load_Glyph' function. + * In the rare cases where FT_LOAD_NO_RECURSE is set, it implies + * FT_LOAD_NO_SCALE and as such the auto-hinter is never called. + */ + load_flags |= FT_LOAD_NO_SCALE | + FT_LOAD_IGNORE_TRANSFORM | + FT_LOAD_LINEAR_DESIGN; + load_flags &= ~FT_LOAD_RENDER; + + error = FT_Load_Glyph( face, glyph_index, load_flags ); + if ( error ) + goto Exit; + + /* + * Apply stem darkening (emboldening) here before hints are applied to + * the outline. Glyphs are scaled down proportionally to the + * emboldening so that curve points don't fall outside their + * precomputed blue zones. + * + * Any emboldening done by the font driver (e.g., the CFF driver) + * doesn't reach here because the autohinter loads the unprocessed + * glyphs in font units for analysis (functions `af_*_metrics_init_*') + * and then above to prepare it for the rasterizers by itself, + * independently of the font driver. So emboldening must be done here, + * within the autohinter. + * + * All glyphs to be autohinted pass through here one by one. The + * standard widths can therefore change from one glyph to the next, + * depending on what script a glyph is assigned to (each script has its + * own set of standard widths and other metrics). The darkening amount + * must therefore be recomputed for each size and + * `standard_{vertical,horizontal}_width' change. + * + * Ignore errors and carry on without emboldening. + * + */ + + /* stem darkening only works well in `light' mode */ + if ( scaler.render_mode == FT_RENDER_MODE_LIGHT && + ( !face->internal->no_stem_darkening || + ( face->internal->no_stem_darkening < 0 && + !module->no_stem_darkening ) ) ) + af_loader_embolden_glyph_in_slot( loader, face, style_metrics ); + + loader->transformed = slot_internal->glyph_transformed; if ( loader->transformed ) { FT_Matrix inverse; - loader->trans_matrix = internal->glyph_matrix; - loader->trans_delta = internal->glyph_delta; + loader->trans_matrix = slot_internal->glyph_matrix; + loader->trans_delta = slot_internal->glyph_delta; inverse = loader->trans_matrix; if ( !FT_Matrix_Invert( &inverse ) ) @@ -264,8 +411,8 @@ loader->trans_delta.x, loader->trans_delta.y ); - /* compute original horizontal phantom points (and ignore */ - /* vertical ones) */ + /* compute original horizontal phantom points */ + /* (and ignore vertical ones) */ loader->pp1.x = hints->x_delta; loader->pp1.y = hints->y_delta; loader->pp2.x = FT_MulFix( slot->metrics.horiAdvance, @@ -276,30 +423,21 @@ if ( slot->outline.n_points == 0 ) goto Hint_Metrics; - /* now load the slot image into the auto-outline and run the */ - /* automatic hinting process */ - { -#ifdef FT_CONFIG_OPTION_PIC - AF_FaceGlobals globals = loader->globals; -#endif - AF_StyleClass style_class = metrics->style_class; - AF_WritingSystemClass writing_system_class = - AF_WRITING_SYSTEM_CLASSES_GET[style_class->writing_system]; - - - if ( writing_system_class->style_hints_apply ) - writing_system_class->style_hints_apply( glyph_index, - hints, - &gloader->base.outline, - metrics ); - } + /* now load the slot image into the auto-outline */ + /* and run the automatic hinting process */ + if ( writing_system_class->style_hints_apply ) + writing_system_class->style_hints_apply( glyph_index, + hints, + &gloader->base.outline, + style_metrics ); /* we now need to adjust the metrics according to the change in */ /* width/positioning that occurred during the hinting process */ - if ( scaler->render_mode != FT_RENDER_MODE_LIGHT ) + if ( scaler.render_mode != FT_RENDER_MODE_LIGHT ) { - FT_Pos old_rsb, old_lsb, new_lsb; - FT_Pos pp1x_uh, pp2x_uh; + FT_Pos old_rsb, old_lsb, new_lsb; + FT_Pos pp1x_uh, pp2x_uh; + AF_AxisHints axis = &hints->axis[AF_DIMENSION_HORZ]; AF_Edge edge1 = axis->edges; /* leftmost edge */ AF_Edge edge2 = edge1 + @@ -309,12 +447,12 @@ if ( axis->num_edges > 1 && AF_HINTS_DO_ADVANCE( hints ) ) { old_rsb = loader->pp2.x - edge2->opos; - old_lsb = edge1->opos; + /* loader->pp1.x is always zero at this point of time */ + old_lsb = edge1->opos /* - loader->pp1.x */; new_lsb = edge1->pos; /* remember unhinted values to later account */ /* for rounding errors */ - pp1x_uh = new_lsb - old_lsb; pp2x_uh = edge2->pos + old_rsb; @@ -352,6 +490,8 @@ slot->rsb_delta = loader->pp2.x - pp2x; } } + /* `light' mode uses integer advance widths */ + /* but sets `lsb_delta' and `rsb_delta' */ else { FT_Pos pp1x = loader->pp1.x; @@ -380,8 +520,8 @@ vvector.x = slot->metrics.vertBearingX - slot->metrics.horiBearingX; vvector.y = slot->metrics.vertBearingY - slot->metrics.horiBearingY; - vvector.x = FT_MulFix( vvector.x, metrics->scaler.x_scale ); - vvector.y = FT_MulFix( vvector.y, metrics->scaler.y_scale ); + vvector.x = FT_MulFix( vvector.x, style_metrics->scaler.x_scale ); + vvector.y = FT_MulFix( vvector.y, style_metrics->scaler.y_scale ); /* transform the hinted outline if needed */ if ( loader->transformed ) @@ -389,12 +529,12 @@ FT_Outline_Transform( &gloader->base.outline, &loader->trans_matrix ); FT_Vector_Transform( &vvector, &loader->trans_matrix ); } -#if 1 + /* we must translate our final outline by -pp1.x and compute */ /* the new metrics */ if ( loader->pp1.x ) FT_Outline_Translate( &gloader->base.outline, -loader->pp1.x, 0 ); -#endif + FT_Outline_Get_CBox( &gloader->base.outline, &bbox ); bbox.xMin = FT_PIX_FLOOR( bbox.xMin ); @@ -413,20 +553,14 @@ /* for mono-width fonts (like Andale, Courier, etc.) we need */ /* to keep the original rounded advance width; ditto for */ /* digits if all have the same advance width */ -#if 0 - if ( !FT_IS_FIXED_WIDTH( slot->face ) ) - slot->metrics.horiAdvance = loader->pp2.x - loader->pp1.x; - else - slot->metrics.horiAdvance = FT_MulFix( slot->metrics.horiAdvance, - x_scale ); -#else - if ( scaler->render_mode != FT_RENDER_MODE_LIGHT && + if ( scaler.render_mode != FT_RENDER_MODE_LIGHT && ( FT_IS_FIXED_WIDTH( slot->face ) || ( af_face_globals_is_digit( loader->globals, glyph_index ) && - metrics->digits_have_same_width ) ) ) + style_metrics->digits_have_same_width ) ) ) { - slot->metrics.horiAdvance = FT_MulFix( slot->metrics.horiAdvance, - metrics->scaler.x_scale ); + slot->metrics.horiAdvance = + FT_MulFix( slot->metrics.horiAdvance, + style_metrics->scaler.x_scale ); /* Set delta values to 0. Otherwise code that uses them is */ /* going to ruin the fixed advance width. */ @@ -439,23 +573,13 @@ if ( slot->metrics.horiAdvance ) slot->metrics.horiAdvance = loader->pp2.x - loader->pp1.x; } -#endif slot->metrics.vertAdvance = FT_MulFix( slot->metrics.vertAdvance, - metrics->scaler.y_scale ); + style_metrics->scaler.y_scale ); slot->metrics.horiAdvance = FT_PIX_ROUND( slot->metrics.horiAdvance ); slot->metrics.vertAdvance = FT_PIX_ROUND( slot->metrics.vertAdvance ); -#if 0 - /* reassign all outline fields except flags to protect them */ - slot->outline.n_contours = internal->loader->base.outline.n_contours; - slot->outline.n_points = internal->loader->base.outline.n_points; - slot->outline.points = internal->loader->base.outline.points; - slot->outline.tags = internal->loader->base.outline.tags; - slot->outline.contours = internal->loader->base.outline.contours; -#endif - slot->format = FT_GLYPH_FORMAT_OUTLINE; } @@ -464,85 +588,6 @@ } - /* Load a glyph. */ - - FT_LOCAL_DEF( FT_Error ) - af_loader_load_glyph( AF_Loader loader, - AF_Module module, - FT_Face face, - FT_UInt gindex, - FT_Int32 load_flags ) - { - FT_Error error; - FT_Size size = face->size; - AF_ScalerRec scaler; - - - if ( !size ) - return FT_THROW( Invalid_Size_Handle ); - - FT_ZERO( &scaler ); - - scaler.face = face; - scaler.x_scale = size->metrics.x_scale; - scaler.x_delta = 0; /* XXX: TODO: add support for sub-pixel hinting */ - scaler.y_scale = size->metrics.y_scale; - scaler.y_delta = 0; /* XXX: TODO: add support for sub-pixel hinting */ - - scaler.render_mode = FT_LOAD_TARGET_MODE( load_flags ); - scaler.flags = 0; /* XXX: fix this */ - - error = af_loader_reset( loader, module, face ); - if ( !error ) - { - AF_StyleMetrics metrics; - FT_UInt options = AF_STYLE_NONE_DFLT; - - -#ifdef FT_OPTION_AUTOFIT2 - /* XXX: undocumented hook to activate the latin2 writing system */ - if ( load_flags & ( 1UL << 20 ) ) - options = AF_STYLE_LTN2_DFLT; -#endif - - error = af_face_globals_get_metrics( loader->globals, gindex, - options, &metrics ); - if ( !error ) - { -#ifdef FT_CONFIG_OPTION_PIC - AF_FaceGlobals globals = loader->globals; -#endif - AF_StyleClass style_class = metrics->style_class; - AF_WritingSystemClass writing_system_class = - AF_WRITING_SYSTEM_CLASSES_GET[style_class->writing_system]; - - - loader->metrics = metrics; - - if ( writing_system_class->style_metrics_scale ) - writing_system_class->style_metrics_scale( metrics, &scaler ); - else - metrics->scaler = scaler; - - load_flags |= FT_LOAD_NO_SCALE | FT_LOAD_IGNORE_TRANSFORM; - load_flags &= ~FT_LOAD_RENDER; - - if ( writing_system_class->style_hints_init ) - { - error = writing_system_class->style_hints_init( loader->hints, - metrics ); - if ( error ) - goto Exit; - } - - error = af_loader_load_g( loader, &scaler, gindex, load_flags ); - } - } - Exit: - return error; - } - - /* * Compute amount of font units the face should be emboldened by, in * analogy to the CFF driver's `cf2_computeDarkening' function. See there diff --git a/thirdparty/freetype/src/autofit/afloader.h b/thirdparty/freetype/src/autofit/afloader.h index 0062eb9b07..2578abed16 100644 --- a/thirdparty/freetype/src/autofit/afloader.h +++ b/thirdparty/freetype/src/autofit/afloader.h @@ -4,7 +4,7 @@ /* */ /* Auto-fitter glyph loading routines (specification). */ /* */ -/* Copyright 2003-2016 by */ +/* Copyright 2003-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/thirdparty/freetype/src/autofit/afmodule.c b/thirdparty/freetype/src/autofit/afmodule.c index 4127382c00..9d7ba224da 100644 --- a/thirdparty/freetype/src/autofit/afmodule.c +++ b/thirdparty/freetype/src/autofit/afmodule.c @@ -4,7 +4,7 @@ /* */ /* Auto-fitter module implementation (body). */ /* */ -/* Copyright 2003-2016 by */ +/* Copyright 2003-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -104,21 +104,45 @@ } +#ifdef FT_CONFIG_OPTION_PIC + +#undef AF_SCRIPT_CLASSES_GET +#define AF_SCRIPT_CLASSES_GET \ + ( GET_PIC( ft_module->library )->af_script_classes ) + +#undef AF_STYLE_CLASSES_GET +#define AF_STYLE_CLASSES_GET \ + ( GET_PIC( ft_module->library )->af_style_classes ) + +#endif + + static FT_Error af_property_set( FT_Module ft_module, const char* property_name, - const void* value ) + const void* value, + FT_Bool value_is_string ) { FT_Error error = FT_Err_Ok; AF_Module module = (AF_Module)ft_module; +#ifndef FT_CONFIG_OPTION_ENVIRONMENT_PROPERTIES + FT_UNUSED( value_is_string ); +#endif + if ( !ft_strcmp( property_name, "fallback-script" ) ) { - FT_UInt* fallback_script = (FT_UInt*)value; + FT_UInt* fallback_script; + FT_UInt ss; - FT_UInt ss; +#ifdef FT_CONFIG_OPTION_ENVIRONMENT_PROPERTIES + if ( value_is_string ) + return FT_THROW( Invalid_Argument ); +#endif + + fallback_script = (FT_UInt*)value; /* We translate the fallback script to a fallback style that uses */ /* `fallback-script' as its script and `AF_COVERAGE_NONE' as its */ @@ -147,19 +171,33 @@ } else if ( !ft_strcmp( property_name, "default-script" ) ) { - FT_UInt* default_script = (FT_UInt*)value; + FT_UInt* default_script; +#ifdef FT_CONFIG_OPTION_ENVIRONMENT_PROPERTIES + if ( value_is_string ) + return FT_THROW( Invalid_Argument ); +#endif + + default_script = (FT_UInt*)value; + module->default_script = *default_script; return error; } else if ( !ft_strcmp( property_name, "increase-x-height" ) ) { - FT_Prop_IncreaseXHeight* prop = (FT_Prop_IncreaseXHeight*)value; + FT_Prop_IncreaseXHeight* prop; AF_FaceGlobals globals; +#ifdef FT_CONFIG_OPTION_ENVIRONMENT_PROPERTIES + if ( value_is_string ) + return FT_THROW( Invalid_Argument ); +#endif + + prop = (FT_Prop_IncreaseXHeight*)value; + error = af_property_get_face_globals( prop->face, &globals, module ); if ( !error ) globals->increase_x_height = prop->limit; @@ -169,27 +207,76 @@ #ifdef AF_CONFIG_OPTION_USE_WARPER else if ( !ft_strcmp( property_name, "warping" ) ) { - FT_Bool* warping = (FT_Bool*)value; +#ifdef FT_CONFIG_OPTION_ENVIRONMENT_PROPERTIES + if ( value_is_string ) + { + const char* s = (const char*)value; + long w = ft_strtol( s, NULL, 10 ); + + + if ( w == 0 ) + module->warping = 0; + else if ( w == 1 ) + module->warping = 1; + else + return FT_THROW( Invalid_Argument ); + } + else +#endif + { + FT_Bool* warping = (FT_Bool*)value; - module->warping = *warping; + module->warping = *warping; + } return error; } #endif /* AF_CONFIG_OPTION_USE_WARPER */ else if ( !ft_strcmp( property_name, "darkening-parameters" ) ) { - FT_Int* darken_params = (FT_Int*)value; + FT_Int* darken_params; + FT_Int x1, y1, x2, y2, x3, y3, x4, y4; + +#ifdef FT_CONFIG_OPTION_ENVIRONMENT_PROPERTIES + FT_Int dp[8]; + + + if ( value_is_string ) + { + const char* s = (const char*)value; + char* ep; + int i; + + + /* eight comma-separated numbers */ + for ( i = 0; i < 7; i++ ) + { + dp[i] = (FT_Int)ft_strtol( s, &ep, 10 ); + if ( *ep != ',' || s == ep ) + return FT_THROW( Invalid_Argument ); - FT_Int x1 = darken_params[0]; - FT_Int y1 = darken_params[1]; - FT_Int x2 = darken_params[2]; - FT_Int y2 = darken_params[3]; - FT_Int x3 = darken_params[4]; - FT_Int y3 = darken_params[5]; - FT_Int x4 = darken_params[6]; - FT_Int y4 = darken_params[7]; + s = ep + 1; + } + dp[7] = (FT_Int)ft_strtol( s, &ep, 10 ); + if ( !( *ep == '\0' || *ep == ' ' ) || s == ep ) + return FT_THROW( Invalid_Argument ); + + darken_params = dp; + } + else +#endif + darken_params = (FT_Int*)value; + + x1 = darken_params[0]; + y1 = darken_params[1]; + x2 = darken_params[2]; + y2 = darken_params[3]; + x3 = darken_params[4]; + y3 = darken_params[5]; + x4 = darken_params[6]; + y4 = darken_params[7]; if ( x1 < 0 || x2 < 0 || x3 < 0 || x4 < 0 || y1 < 0 || y2 < 0 || y3 < 0 || y4 < 0 || @@ -210,10 +297,26 @@ } else if ( !ft_strcmp( property_name, "no-stem-darkening" ) ) { - FT_Bool* no_stem_darkening = (FT_Bool*)value; +#ifdef FT_CONFIG_OPTION_ENVIRONMENT_PROPERTIES + if ( value_is_string ) + { + const char* s = (const char*)value; + long nsd = ft_strtol( s, NULL, 10 ); - module->no_stem_darkening = *no_stem_darkening; + if ( !nsd ) + module->no_stem_darkening = FALSE; + else + module->no_stem_darkening = TRUE; + } + else +#endif + { + FT_Bool* no_stem_darkening = (FT_Bool*)value; + + + module->no_stem_darkening = *no_stem_darkening; + } return error; } @@ -329,12 +432,14 @@ FT_DEFINE_SERVICE_PROPERTIESREC( af_service_properties, + (FT_Properties_SetFunc)af_property_set, /* set_property */ (FT_Properties_GetFunc)af_property_get ) /* get_property */ FT_DEFINE_SERVICEDESCREC1( af_services, + FT_SERVICE_ID_PROPERTIES, &AF_SERVICE_PROPERTIES_GET ) @@ -427,9 +532,16 @@ error = af_loader_load_glyph( loader, module, slot->face, glyph_index, load_flags ); - af_glyph_hints_dump_points( hints, 0 ); - af_glyph_hints_dump_segments( hints, 0 ); - af_glyph_hints_dump_edges( hints, 0 ); +#ifdef FT_DEBUG_LEVEL_TRACE + if ( ft_trace_levels[FT_COMPONENT] ) + { +#endif + af_glyph_hints_dump_points( hints, 0 ); + af_glyph_hints_dump_segments( hints, 0 ); + af_glyph_hints_dump_edges( hints, 0 ); +#ifdef FT_DEBUG_LEVEL_TRACE + } +#endif af_loader_done( loader ); @@ -460,6 +572,7 @@ FT_DEFINE_AUTOHINTER_INTERFACE( af_autofitter_interface, + NULL, /* reset_face */ NULL, /* get_global_hints */ NULL, /* done_global_hints */ @@ -478,9 +591,10 @@ (const void*)&AF_INTERFACE_GET, - (FT_Module_Constructor)af_autofitter_init, - (FT_Module_Destructor) af_autofitter_done, - (FT_Module_Requester) af_get_interface ) + (FT_Module_Constructor)af_autofitter_init, /* module_init */ + (FT_Module_Destructor) af_autofitter_done, /* module_done */ + (FT_Module_Requester) af_get_interface /* get_interface */ + ) /* END */ diff --git a/thirdparty/freetype/src/autofit/afmodule.h b/thirdparty/freetype/src/autofit/afmodule.h index e65db5f5cb..0571d14d59 100644 --- a/thirdparty/freetype/src/autofit/afmodule.h +++ b/thirdparty/freetype/src/autofit/afmodule.h @@ -4,7 +4,7 @@ /* */ /* Auto-fitter module implementation (specification). */ /* */ -/* Copyright 2003-2016 by */ +/* Copyright 2003-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/thirdparty/freetype/src/autofit/afpic.c b/thirdparty/freetype/src/autofit/afpic.c index 3cbd9168e3..3125e03e27 100644 --- a/thirdparty/freetype/src/autofit/afpic.c +++ b/thirdparty/freetype/src/autofit/afpic.c @@ -4,7 +4,7 @@ /* */ /* The FreeType position independent code services for autofit module. */ /* */ -/* Copyright 2009-2016 by */ +/* Copyright 2009-2017 by */ /* Oran Agra and Mickey Gabel. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/thirdparty/freetype/src/autofit/afpic.h b/thirdparty/freetype/src/autofit/afpic.h index 98a45a26ba..8cd3392123 100644 --- a/thirdparty/freetype/src/autofit/afpic.h +++ b/thirdparty/freetype/src/autofit/afpic.h @@ -4,7 +4,7 @@ /* */ /* The FreeType position independent code services for autofit module. */ /* */ -/* Copyright 2009-2016 by */ +/* Copyright 2009-2017 by */ /* Oran Agra and Mickey Gabel. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -69,7 +69,7 @@ FT_BEGIN_HEADER #define GET_PIC( lib ) \ - ( (AFModulePIC*)((lib)->pic_container.autofit) ) + ( (AFModulePIC*)( (lib)->pic_container.autofit ) ) #define AF_SERVICES_GET \ ( GET_PIC( library )->af_services ) diff --git a/thirdparty/freetype/src/autofit/afranges.c b/thirdparty/freetype/src/autofit/afranges.c index 732f3d1629..7f37eea1e0 100644 --- a/thirdparty/freetype/src/autofit/afranges.c +++ b/thirdparty/freetype/src/autofit/afranges.c @@ -4,7 +4,7 @@ /* */ /* Auto-fitter Unicode script ranges (body). */ /* */ -/* Copyright 2013-2016 by */ +/* Copyright 2013-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -52,8 +52,21 @@ /* not be affected by blue zones, regardless of whether this is a */ /* spacing or no-spacing glyph */ - /* the `ta_xxxx_nonbase_uniranges' ranges must be strict subsets */ - /* of the corresponding `ta_xxxx_uniranges' ranges */ + /* the `af_xxxx_nonbase_uniranges' ranges must be strict subsets */ + /* of the corresponding `af_xxxx_uniranges' ranges */ + + + const AF_Script_UniRangeRec af_adlm_uniranges[] = + { + AF_UNIRANGE_REC( 0x1E900, 0x1E95F ), /* Adlam */ + AF_UNIRANGE_REC( 0, 0 ) + }; + + const AF_Script_UniRangeRec af_adlm_nonbase_uniranges[] = + { + AF_UNIRANGE_REC( 0x1D944, 0x1E94A ), + AF_UNIRANGE_REC( 0, 0 ) + }; const AF_Script_UniRangeRec af_arab_uniranges[] = @@ -106,6 +119,37 @@ }; + const AF_Script_UniRangeRec af_avst_uniranges[] = + { + AF_UNIRANGE_REC( 0x10B00, 0x10B3F ), /* Avestan */ + AF_UNIRANGE_REC( 0, 0 ) + }; + + const AF_Script_UniRangeRec af_avst_nonbase_uniranges[] = + { + AF_UNIRANGE_REC( 0x10B39, 0x10B3F ), + AF_UNIRANGE_REC( 0, 0 ) + }; + + + const AF_Script_UniRangeRec af_bamu_uniranges[] = + { + AF_UNIRANGE_REC( 0xA6A0, 0xA6FF ), /* Bamum */ +#if 0 + /* The characters in the Bamum supplement are pictograms, */ + /* not (directly) related to the syllabic Bamum script */ + AF_UNIRANGE_REC( 0x16800, 0x16A3F ), /* Bamum Supplement */ +#endif + AF_UNIRANGE_REC( 0, 0 ) + }; + + const AF_Script_UniRangeRec af_bamu_nonbase_uniranges[] = + { + AF_UNIRANGE_REC( 0xA6F0, 0xA6F1 ), + AF_UNIRANGE_REC( 0, 0 ) + }; + + const AF_Script_UniRangeRec af_beng_uniranges[] = { AF_UNIRANGE_REC( 0x0980, 0x09FF ), /* Bengali */ @@ -123,6 +167,58 @@ }; + const AF_Script_UniRangeRec af_buhd_uniranges[] = + { + AF_UNIRANGE_REC( 0x1740, 0x175F ), /* Buhid */ + AF_UNIRANGE_REC( 0, 0 ) + }; + + const AF_Script_UniRangeRec af_buhd_nonbase_uniranges[] = + { + AF_UNIRANGE_REC( 0x1752, 0x1753 ), + AF_UNIRANGE_REC( 0, 0 ) + }; + + + const AF_Script_UniRangeRec af_cakm_uniranges[] = + { + AF_UNIRANGE_REC( 0x11100, 0x1114F ), /* Chakma */ + AF_UNIRANGE_REC( 0, 0 ) + }; + + const AF_Script_UniRangeRec af_cakm_nonbase_uniranges[] = + { + AF_UNIRANGE_REC( 0x11100, 0x11102 ), + AF_UNIRANGE_REC( 0x11127, 0x11134 ), + AF_UNIRANGE_REC( 0, 0 ) + }; + + + const AF_Script_UniRangeRec af_cans_uniranges[] = + { + AF_UNIRANGE_REC( 0x1400, 0x167F ), /* Unified Canadian Aboriginal Syllabics */ + AF_UNIRANGE_REC( 0x18B0, 0x18FF ), /* Unified Canadian Aboriginal Syllabics Extended */ + AF_UNIRANGE_REC( 0, 0 ) + }; + + const AF_Script_UniRangeRec af_cans_nonbase_uniranges[] = + { + AF_UNIRANGE_REC( 0, 0 ) + }; + + + const AF_Script_UniRangeRec af_cari_uniranges[] = + { + AF_UNIRANGE_REC( 0x102A0, 0x102DF ), /* Carian */ + AF_UNIRANGE_REC( 0, 0 ) + }; + + const AF_Script_UniRangeRec af_cari_nonbase_uniranges[] = + { + AF_UNIRANGE_REC( 0, 0 ) + }; + + const AF_Script_UniRangeRec af_cher_uniranges[] = { AF_UNIRANGE_REC( 0x13A0, 0x13FF ), /* Cherokee */ @@ -136,6 +232,31 @@ }; + const AF_Script_UniRangeRec af_copt_uniranges[] = + { + AF_UNIRANGE_REC( 0x2C80, 0x2CFF ), /* Coptic */ + AF_UNIRANGE_REC( 0, 0 ) + }; + + const AF_Script_UniRangeRec af_copt_nonbase_uniranges[] = + { + AF_UNIRANGE_REC( 0x2CEF, 0x2CF1 ), + AF_UNIRANGE_REC( 0, 0 ) + }; + + + const AF_Script_UniRangeRec af_cprt_uniranges[] = + { + AF_UNIRANGE_REC( 0x10800, 0x1083F ), /* Cypriot */ + AF_UNIRANGE_REC( 0, 0 ) + }; + + const AF_Script_UniRangeRec af_cprt_nonbase_uniranges[] = + { + AF_UNIRANGE_REC( 0, 0 ) + }; + + const AF_Script_UniRangeRec af_cyrl_uniranges[] = { AF_UNIRANGE_REC( 0x0400, 0x04FF ), /* Cyrillic */ @@ -187,6 +308,18 @@ }; + const AF_Script_UniRangeRec af_dsrt_uniranges[] = + { + AF_UNIRANGE_REC( 0x10400, 0x1044F ), /* Deseret */ + AF_UNIRANGE_REC( 0, 0 ) + }; + + const AF_Script_UniRangeRec af_dsrt_nonbase_uniranges[] = + { + AF_UNIRANGE_REC( 0, 0 ) + }; + + const AF_Script_UniRangeRec af_ethi_uniranges[] = { AF_UNIRANGE_REC( 0x1200, 0x137F ), /* Ethiopic */ @@ -233,6 +366,32 @@ }; + const AF_Script_UniRangeRec af_glag_uniranges[] = + { + AF_UNIRANGE_REC( 0x2C00, 0x2C5F ), /* Glagolitic */ + AF_UNIRANGE_REC( 0x1E000, 0x1E02F ), /* Glagolitic Supplement */ + AF_UNIRANGE_REC( 0, 0 ) + }; + + const AF_Script_UniRangeRec af_glag_nonbase_uniranges[] = + { + AF_UNIRANGE_REC( 0x1E000, 0x1E02F ), + AF_UNIRANGE_REC( 0, 0 ) + }; + + + const AF_Script_UniRangeRec af_goth_uniranges[] = + { + AF_UNIRANGE_REC( 0x10330, 0x1034F ), /* Gothic */ + AF_UNIRANGE_REC( 0, 0 ) + }; + + const AF_Script_UniRangeRec af_goth_nonbase_uniranges[] = + { + AF_UNIRANGE_REC( 0, 0 ) + }; + + const AF_Script_UniRangeRec af_grek_uniranges[] = { AF_UNIRANGE_REC( 0x0370, 0x03FF ), /* Greek and Coptic */ @@ -305,6 +464,19 @@ }; + const AF_Script_UniRangeRec af_kali_uniranges[] = + { + AF_UNIRANGE_REC( 0xA900, 0xA92F ), /* Kayah Li */ + AF_UNIRANGE_REC( 0, 0 ) + }; + + const AF_Script_UniRangeRec af_kali_nonbase_uniranges[] = + { + AF_UNIRANGE_REC( 0xA926, 0xA92D ), + AF_UNIRANGE_REC( 0, 0 ) + }; + + const AF_Script_UniRangeRec af_knda_uniranges[] = { AF_UNIRANGE_REC( 0x0C80, 0x0CFF ), /* Kannada */ @@ -463,6 +635,18 @@ }; + const AF_Script_UniRangeRec af_lisu_uniranges[] = + { + AF_UNIRANGE_REC( 0xA4D0, 0xA4FF ), /* Lisu */ + AF_UNIRANGE_REC( 0, 0 ) + }; + + const AF_Script_UniRangeRec af_lisu_nonbase_uniranges[] = + { + AF_UNIRANGE_REC( 0, 0 ) + }; + + const AF_Script_UniRangeRec af_mlym_uniranges[] = { AF_UNIRANGE_REC( 0x0D00, 0x0D7F ), /* Malayalam */ @@ -480,27 +664,40 @@ const AF_Script_UniRangeRec af_mymr_uniranges[] = { - AF_UNIRANGE_REC( 0x1000, 0x109F ), /* Myanmar */ - AF_UNIRANGE_REC( 0xA9E0, 0xA9FF ), /* Myanmar Extended-B */ - AF_UNIRANGE_REC( 0xAA60, 0xAA7F ), /* Myanmar Extended-A */ - AF_UNIRANGE_REC( 0, 0 ) + AF_UNIRANGE_REC( 0x1000, 0x109F ), /* Myanmar */ + AF_UNIRANGE_REC( 0xA9E0, 0xA9FF ), /* Myanmar Extended-B */ + AF_UNIRANGE_REC( 0xAA60, 0xAA7F ), /* Myanmar Extended-A */ + AF_UNIRANGE_REC( 0, 0 ) }; const AF_Script_UniRangeRec af_mymr_nonbase_uniranges[] = { - AF_UNIRANGE_REC( 0x102D, 0x1030 ), - AF_UNIRANGE_REC( 0x1032, 0x1037 ), - AF_UNIRANGE_REC( 0x103A, 0x103A ), - AF_UNIRANGE_REC( 0x103D, 0x103E ), - AF_UNIRANGE_REC( 0x1058, 0x1059 ), - AF_UNIRANGE_REC( 0x105E, 0x1060 ), - AF_UNIRANGE_REC( 0x1071, 0x1074 ), - AF_UNIRANGE_REC( 0x1082, 0x1082 ), - AF_UNIRANGE_REC( 0x1085, 0x1086 ), - AF_UNIRANGE_REC( 0x108D, 0x108D ), - AF_UNIRANGE_REC( 0xA9E5, 0xA9E5 ), - AF_UNIRANGE_REC( 0xAA7C, 0xAA7C ), - AF_UNIRANGE_REC( 0, 0 ) + AF_UNIRANGE_REC( 0x102D, 0x1030 ), + AF_UNIRANGE_REC( 0x1032, 0x1037 ), + AF_UNIRANGE_REC( 0x103A, 0x103A ), + AF_UNIRANGE_REC( 0x103D, 0x103E ), + AF_UNIRANGE_REC( 0x1058, 0x1059 ), + AF_UNIRANGE_REC( 0x105E, 0x1060 ), + AF_UNIRANGE_REC( 0x1071, 0x1074 ), + AF_UNIRANGE_REC( 0x1082, 0x1082 ), + AF_UNIRANGE_REC( 0x1085, 0x1086 ), + AF_UNIRANGE_REC( 0x108D, 0x108D ), + AF_UNIRANGE_REC( 0xA9E5, 0xA9E5 ), + AF_UNIRANGE_REC( 0xAA7C, 0xAA7C ), + AF_UNIRANGE_REC( 0, 0 ) + }; + + + const AF_Script_UniRangeRec af_nkoo_uniranges[] = + { + AF_UNIRANGE_REC( 0x07C0, 0x07FF ), /* N'Ko */ + AF_UNIRANGE_REC( 0, 0 ) + }; + + const AF_Script_UniRangeRec af_nkoo_nonbase_uniranges[] = + { + AF_UNIRANGE_REC( 0x07EB, 0x07F5 ), + AF_UNIRANGE_REC( 0, 0 ) }; @@ -515,6 +712,80 @@ }; + const AF_Script_UniRangeRec af_olck_uniranges[] = + { + AF_UNIRANGE_REC( 0x1C50, 0x1C7F ), /* Ol Chiki */ + AF_UNIRANGE_REC( 0, 0 ) + }; + + const AF_Script_UniRangeRec af_olck_nonbase_uniranges[] = + { + AF_UNIRANGE_REC( 0, 0 ) + }; + + + const AF_Script_UniRangeRec af_orkh_uniranges[] = + { + AF_UNIRANGE_REC( 0x10C00, 0x10C4F ), /* Old Turkic */ + AF_UNIRANGE_REC( 0, 0 ) + }; + + const AF_Script_UniRangeRec af_orkh_nonbase_uniranges[] = + { + AF_UNIRANGE_REC( 0, 0 ) + }; + + + const AF_Script_UniRangeRec af_osge_uniranges[] = + { + AF_UNIRANGE_REC( 0x104B0, 0x104FF ), /* Osage */ + AF_UNIRANGE_REC( 0, 0 ) + }; + + const AF_Script_UniRangeRec af_osge_nonbase_uniranges[] = + { + AF_UNIRANGE_REC( 0, 0 ) + }; + + + const AF_Script_UniRangeRec af_osma_uniranges[] = + { + AF_UNIRANGE_REC( 0x10480, 0x104AF ), /* Osmanya */ + AF_UNIRANGE_REC( 0, 0 ) + }; + + const AF_Script_UniRangeRec af_osma_nonbase_uniranges[] = + { + AF_UNIRANGE_REC( 0, 0 ) + }; + + + const AF_Script_UniRangeRec af_saur_uniranges[] = + { + AF_UNIRANGE_REC( 0xA880, 0xA8DF ), /* Saurashtra */ + AF_UNIRANGE_REC( 0, 0 ) + }; + + const AF_Script_UniRangeRec af_saur_nonbase_uniranges[] = + { + AF_UNIRANGE_REC( 0xA880, 0xA881 ), + AF_UNIRANGE_REC( 0xA8B4, 0xA8C5 ), + AF_UNIRANGE_REC( 0, 0 ) + }; + + + const AF_Script_UniRangeRec af_shaw_uniranges[] = + { + AF_UNIRANGE_REC( 0x10450, 0x1047F ), /* Shavian */ + AF_UNIRANGE_REC( 0, 0 ) + }; + + const AF_Script_UniRangeRec af_shaw_nonbase_uniranges[] = + { + AF_UNIRANGE_REC( 0, 0 ) + }; + + const AF_Script_UniRangeRec af_sinh_uniranges[] = { AF_UNIRANGE_REC( 0x0D80, 0x0DFF ), /* Sinhala */ @@ -529,6 +800,21 @@ }; + const AF_Script_UniRangeRec af_sund_uniranges[] = + { + AF_UNIRANGE_REC( 0x1B80, 0x1BBF ), /* Sundanese */ + AF_UNIRANGE_REC( 0x1CC0, 0x1CCF ), /* Sundanese Supplement */ + AF_UNIRANGE_REC( 0, 0 ) + }; + + const AF_Script_UniRangeRec af_sund_nonbase_uniranges[] = + { + AF_UNIRANGE_REC( 0x1B80, 0x1B82 ), + AF_UNIRANGE_REC( 0x1BA1, 0x1BAD ), + AF_UNIRANGE_REC( 0, 0 ) + }; + + const AF_Script_UniRangeRec af_taml_uniranges[] = { AF_UNIRANGE_REC( 0x0B80, 0x0BFF ), /* Tamil */ @@ -544,6 +830,23 @@ }; + const AF_Script_UniRangeRec af_tavt_uniranges[] = + { + AF_UNIRANGE_REC( 0xAA80, 0xAADF ), /* Tai Viet */ + AF_UNIRANGE_REC( 0, 0 ) + }; + + const AF_Script_UniRangeRec af_tavt_nonbase_uniranges[] = + { + AF_UNIRANGE_REC( 0xAAB0, 0xAAB0 ), + AF_UNIRANGE_REC( 0xAAB2, 0xAAB4 ), + AF_UNIRANGE_REC( 0xAAB7, 0xAAB8 ), + AF_UNIRANGE_REC( 0xAABE, 0xAABF ), + AF_UNIRANGE_REC( 0xAAC1, 0xAAC1 ), + AF_UNIRANGE_REC( 0, 0 ) + }; + + const AF_Script_UniRangeRec af_telu_uniranges[] = { AF_UNIRANGE_REC( 0x0C00, 0x0C7F ), /* Telugu */ @@ -575,6 +878,30 @@ }; + const AF_Script_UniRangeRec af_tfng_uniranges[] = + { + AF_UNIRANGE_REC( 0x2D30, 0x2D7F ), /* Tifinagh */ + AF_UNIRANGE_REC( 0, 0 ) + }; + + const AF_Script_UniRangeRec af_tfng_nonbase_uniranges[] = + { + AF_UNIRANGE_REC( 0, 0 ) + }; + + + const AF_Script_UniRangeRec af_vaii_uniranges[] = + { + AF_UNIRANGE_REC( 0xA500, 0xA63F ), /* Vai */ + AF_UNIRANGE_REC( 0, 0 ) + }; + + const AF_Script_UniRangeRec af_vaii_nonbase_uniranges[] = + { + AF_UNIRANGE_REC( 0, 0 ) + }; + + #ifdef AF_CONFIG_OPTION_INDIC const AF_Script_UniRangeRec af_limb_uniranges[] = @@ -610,21 +937,6 @@ }; - const AF_Script_UniRangeRec af_sund_uniranges[] = - { - AF_UNIRANGE_REC( 0x1B80, 0x1BBF ), /* Sundanese */ - AF_UNIRANGE_REC( 0x1CC0, 0x1CCF ), /* Sundanese Supplement */ - AF_UNIRANGE_REC( 0, 0 ) - }; - - const AF_Script_UniRangeRec af_sund_nonbase_uniranges[] = - { - AF_UNIRANGE_REC( 0x1B80, 0x1B82 ), - AF_UNIRANGE_REC( 0x1BA1, 0x1BAD ), - AF_UNIRANGE_REC( 0, 0 ) - }; - - const AF_Script_UniRangeRec af_sylo_uniranges[] = { AF_UNIRANGE_REC( 0xA800, 0xA82F ), /* Syloti Nagri */ diff --git a/thirdparty/freetype/src/autofit/afranges.h b/thirdparty/freetype/src/autofit/afranges.h index 1a0e4b1535..72d9eaad2c 100644 --- a/thirdparty/freetype/src/autofit/afranges.h +++ b/thirdparty/freetype/src/autofit/afranges.h @@ -4,7 +4,7 @@ /* */ /* Auto-fitter Unicode script ranges (specification). */ /* */ -/* Copyright 2013-2016 by */ +/* Copyright 2013-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/thirdparty/freetype/src/autofit/afscript.h b/thirdparty/freetype/src/autofit/afscript.h index 33c3012981..7547a9e6f9 100644 --- a/thirdparty/freetype/src/autofit/afscript.h +++ b/thirdparty/freetype/src/autofit/afscript.h @@ -4,7 +4,7 @@ /* */ /* Auto-fitter scripts (specification only). */ /* */ -/* Copyright 2013-2016 by */ +/* Copyright 2013-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -30,6 +30,12 @@ /* use `HB_SCRIPT_INVALID' as the HarfBuzz script name tag for */ /* them. */ + SCRIPT( adlm, ADLM, + "Adlam", + HB_SCRIPT_ADLAM, + HINTING_BOTTOM_TO_TOP, + "\xF0\x9E\xA4\x8C \xF0\x9E\xA4\xAE" ) /* 𞤌 𞤮 */ + SCRIPT( arab, ARAB, "Arabic", HB_SCRIPT_ARABIC, @@ -40,7 +46,19 @@ "Armenian", HB_SCRIPT_ARMENIAN, HINTING_BOTTOM_TO_TOP, - "\xD6\x85 \xD5\x95" ) /* օ Օ */ + "\xD5\xBD \xD5\x8D" ) /* ս Ս */ + + SCRIPT( avst, AVST, + "Avestan", + HB_SCRIPT_AVESTAN, + HINTING_BOTTOM_TO_TOP, + "\xF0\x90\xAC\x9A" ) /* 𐬚 */ + + SCRIPT( bamu, BAMU, + "Bamum", + HB_SCRIPT_BAMUM, + HINTING_BOTTOM_TO_TOP, + "\xEA\x9B\x81 \xEA\x9B\xAF" ) /* ꛁ ꛯ */ /* there are no simple forms for letters; we thus use two digit shapes */ SCRIPT( beng, BENG, @@ -49,12 +67,48 @@ HINTING_TOP_TO_BOTTOM, "\xE0\xA7\xA6 \xE0\xA7\xAA" ) /* ০ ৪ */ + SCRIPT( buhd, BUHD, + "Buhid", + HB_SCRIPT_BUHID, + HINTING_BOTTOM_TO_TOP, + "\xE1\x9D\x8B \xE1\x9D\x8F" ) /* ᝋ ᝏ */ + + SCRIPT( cakm, CAKM, + "Chakma", + HB_SCRIPT_CHAKMA, + HINTING_BOTTOM_TO_TOP, + "\xF0\x91\x84\xA4 \xF0\x91\x84\x89 \xF0\x91\x84\x9B" ) /* 𑄤 𑄉 𑄛 */ + + SCRIPT( cans, CANS, + "Canadian Syllabics", + HB_SCRIPT_CANADIAN_SYLLABICS, + HINTING_BOTTOM_TO_TOP, + "\xE1\x91\x8C \xE1\x93\x9A" ) /* ᑌ ᓚ */ + + SCRIPT( cari, CARI, + "Carian", + HB_SCRIPT_CARIAN, + HINTING_BOTTOM_TO_TOP, + "\xF0\x90\x8A\xAB \xF0\x90\x8B\x89" ) /* 𐊫 𐋉 */ + SCRIPT( cher, CHER, "Cherokee", HB_SCRIPT_CHEROKEE, HINTING_BOTTOM_TO_TOP, "\xE1\x8E\xA4 \xE1\x8F\x85 \xEA\xAE\x95" ) /* Ꭴ Ꮕ ꮕ */ + SCRIPT( copt, COPT, + "Coptic", + HB_SCRIPT_COPTIC, + HINTING_BOTTOM_TO_TOP, + "\xE2\xB2\x9E \xE2\xB2\x9F" ) /* Ⲟ ⲟ */ + + SCRIPT( cprt, CPRT, + "Cypriot", + HB_SCRIPT_CYPRIOT, + HINTING_BOTTOM_TO_TOP, + "\xF0\x90\xA0\x85 \xF0\x90\xA0\xA3" ) /* 𐠅 𐠣 */ + SCRIPT( cyrl, CYRL, "Cyrillic", HB_SCRIPT_CYRILLIC, @@ -67,6 +121,12 @@ HINTING_TOP_TO_BOTTOM, "\xE0\xA4\xA0 \xE0\xA4\xB5 \xE0\xA4\x9F" ) /* ठ व ट */ + SCRIPT( dsrt, DSRT, + "Deseret", + HB_SCRIPT_DESERET, + HINTING_BOTTOM_TO_TOP, + "\xF0\x90\x90\x84 \xF0\x90\x90\xAC" ) /* 𐐄 𐐬 */ + SCRIPT( ethi, ETHI, "Ethiopic", HB_SCRIPT_ETHIOPIC, @@ -85,6 +145,18 @@ HINTING_BOTTOM_TO_TOP, "\xE1\x82\xB6 \xE1\x82\xB1 \xE2\xB4\x99" ) /* Ⴖ Ⴑ ⴙ */ + SCRIPT( glag, GLAG, + "Glagolitic", + HB_SCRIPT_GLAGOLITIC, + HINTING_BOTTOM_TO_TOP, + "\xE2\xB0\x95 \xE2\xB1\x85" ) /* Ⱅ ⱅ */ + + SCRIPT( goth, GOTH, + "Gothic", + HB_SCRIPT_GOTHIC, + HINTING_TOP_TO_BOTTOM, + "\xF0\x90\x8C\xB4 \xF0\x90\x8C\xBE \xF0\x90\x8D\x83" ) /* 𐌴 𐌾 𐍃 */ + SCRIPT( grek, GREK, "Greek", HB_SCRIPT_GREEK, @@ -109,6 +181,12 @@ HINTING_BOTTOM_TO_TOP, "\xD7\x9D" ) /* ם */ + SCRIPT( kali, KALI, + "Kayah Li", + HB_SCRIPT_KAYAH_LI, + HINTING_BOTTOM_TO_TOP, + "\xEA\xA4\x8D \xEA\xA4\x80" ) /* ꤍ ꤀ */ + SCRIPT( knda, KNDA, "Kannada", HB_SCRIPT_KANNADA, @@ -153,6 +231,12 @@ HINTING_BOTTOM_TO_TOP, "\xE1\xB5\x92 \xE1\xB4\xBC \xE2\x81\xB0" ) /* ᵒ ᴼ ⁰ */ + SCRIPT( lisu, LISU, + "Lisu", + HB_SCRIPT_LISU, + HINTING_BOTTOM_TO_TOP, + "\xEA\x93\xB3" ) /* ꓳ */ + SCRIPT( mlym, MLYM, "Malayalam", HB_SCRIPT_MALAYALAM, @@ -165,18 +249,67 @@ HINTING_BOTTOM_TO_TOP, "\xE1\x80\x9D \xE1\x80\x84 \xE1\x80\x82" ) /* ဝ င ဂ */ + SCRIPT( nkoo, NKOO, + "N'Ko", + HB_SCRIPT_NKO, + HINTING_BOTTOM_TO_TOP, + "\xDF\x8B \xDF\x80" ) /* ߋ ߀ */ + SCRIPT( none, NONE, "no script", HB_SCRIPT_INVALID, HINTING_BOTTOM_TO_TOP, "" ) + SCRIPT( olck, OLCK, + "Ol Chiki", + HB_SCRIPT_OL_CHIKI, + HINTING_BOTTOM_TO_TOP, + "\xE1\xB1\x9B" ) /* ᱛ */ + + SCRIPT( orkh, ORKH, + "Old Turkic", + HB_SCRIPT_OLD_TURKIC, + HINTING_BOTTOM_TO_TOP, + "\xF0\x90\xB0\x97" ) /* 𐰗 */ + + SCRIPT( osge, OSGE, + "Osage", + HB_SCRIPT_OSAGE, + HINTING_BOTTOM_TO_TOP, + "\xF0\x90\x93\x82 \xF0\x90\x93\xAA" ) /* 𐓂 𐓪 */ + + SCRIPT( osma, OSMA, + "Osmanya", + HB_SCRIPT_OSMANYA, + HINTING_BOTTOM_TO_TOP, + "\xF0\x90\x92\x86 \xF0\x90\x92\xA0" ) /* 𐒆 𐒠 */ + + SCRIPT( saur, SAUR, + "Saurashtra", + HB_SCRIPT_SAURASHTRA, + HINTING_BOTTOM_TO_TOP, + "\xEA\xA2\x9D \xEA\xA3\x90" ) /* ꢝ ꣐ */ + + SCRIPT( shaw, SHAW, + "Shavian", + HB_SCRIPT_SHAVIAN, + HINTING_BOTTOM_TO_TOP, + "\xF0\x90\x91\xB4" ) /* 𐑴 */ + SCRIPT( sinh, SINH, "Sinhala", HB_SCRIPT_SINHALA, HINTING_BOTTOM_TO_TOP, "\xE0\xB6\xA7" ) /* ට */ + /* only digit zero has a simple (round) shape in the Sundanese script */ + SCRIPT( sund, SUND, + "Sundanese", + HB_SCRIPT_SUNDANESE, + HINTING_BOTTOM_TO_TOP, + "\xE1\xAE\xB0" ) /* ᮰ */ + /* only digit zero has a simple (round) shape in the Tamil script */ SCRIPT( taml, TAML, "Tamil", @@ -184,6 +317,12 @@ HINTING_BOTTOM_TO_TOP, "\xE0\xAF\xA6" ) /* ௦ */ + SCRIPT( tavt, TAVT, + "Tai Viet", + HB_SCRIPT_TAI_VIET, + HINTING_BOTTOM_TO_TOP, + "\xEA\xAA\x92 \xEA\xAA\xAB" ) /* ꪒ ꪫ */ + /* there are no simple forms for letters; we thus use two digit shapes */ SCRIPT( telu, TELU, "Telugu", @@ -197,6 +336,18 @@ HINTING_BOTTOM_TO_TOP, "\xE0\xB8\xB2 \xE0\xB9\x85 \xE0\xB9\x90" ) /* า ๅ ๐ */ + SCRIPT( tfng, TFNG, + "Tifinagh", + HB_SCRIPT_TIFINAGH, + HINTING_BOTTOM_TO_TOP, + "\xE2\xB5\x94" ) /* ⵔ */ + + SCRIPT( vaii, VAII, + "Vai", + HB_SCRIPT_VAI, + HINTING_BOTTOM_TO_TOP, + "\xEA\x98\x93 \xEA\x96\x9C \xEA\x96\xB4" ) /* ꘓ ꖜ ꖴ */ + #ifdef AF_CONFIG_OPTION_INDIC SCRIPT( limb, LIMB, @@ -211,12 +362,6 @@ HINTING_BOTTOM_TO_TOP, "o" ) /* XXX */ - SCRIPT( sund, SUND, - "Sundanese", - HB_SCRIPT_SUNDANESE, - HINTING_BOTTOM_TO_TOP, - "o" ) /* XXX */ - SCRIPT( sylo, SYLO, "Syloti Nagri", HB_SCRIPT_SYLOTI_NAGRI, diff --git a/thirdparty/freetype/src/autofit/afshaper.c b/thirdparty/freetype/src/autofit/afshaper.c index 6d13b65859..da92fad3ed 100644 --- a/thirdparty/freetype/src/autofit/afshaper.c +++ b/thirdparty/freetype/src/autofit/afshaper.c @@ -4,7 +4,7 @@ /* */ /* HarfBuzz interface for accessing OpenType features (body). */ /* */ -/* Copyright 2013-2016 by */ +/* Copyright 2013-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/thirdparty/freetype/src/autofit/afshaper.h b/thirdparty/freetype/src/autofit/afshaper.h index 0d41f78762..9185d19003 100644 --- a/thirdparty/freetype/src/autofit/afshaper.h +++ b/thirdparty/freetype/src/autofit/afshaper.h @@ -4,7 +4,7 @@ /* */ /* HarfBuzz interface for accessing OpenType features (specification). */ /* */ -/* Copyright 2013-2016 by */ +/* Copyright 2013-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/thirdparty/freetype/src/autofit/afstyles.h b/thirdparty/freetype/src/autofit/afstyles.h index e83a95bb59..a5e13d8944 100644 --- a/thirdparty/freetype/src/autofit/afstyles.h +++ b/thirdparty/freetype/src/autofit/afstyles.h @@ -4,7 +4,7 @@ /* */ /* Auto-fitter styles (specification only). */ /* */ -/* Copyright 2013-2016 by */ +/* Copyright 2013-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -83,6 +83,13 @@ DEFAULT ) + STYLE( adlm_dflt, ADLM_DFLT, + "Adlam default style", + AF_WRITING_SYSTEM_LATIN, + AF_SCRIPT_ADLM, + AF_BLUE_STRINGSET_ADLM, + AF_COVERAGE_DEFAULT ) + STYLE( arab_dflt, ARAB_DFLT, "Arabic default style", AF_WRITING_SYSTEM_LATIN, @@ -97,6 +104,20 @@ AF_BLUE_STRINGSET_ARMN, AF_COVERAGE_DEFAULT ) + STYLE( avst_dflt, AVST_DFLT, + "Avestan default style", + AF_WRITING_SYSTEM_LATIN, + AF_SCRIPT_AVST, + AF_BLUE_STRINGSET_AVST, + AF_COVERAGE_DEFAULT ) + + STYLE( bamu_dflt, BAMU_DFLT, + "Bamum default style", + AF_WRITING_SYSTEM_LATIN, + AF_SCRIPT_BAMU, + AF_BLUE_STRINGSET_BAMU, + AF_COVERAGE_DEFAULT ) + STYLE( beng_dflt, BENG_DFLT, "Bengali default style", AF_WRITING_SYSTEM_LATIN, @@ -104,6 +125,34 @@ AF_BLUE_STRINGSET_BENG, AF_COVERAGE_DEFAULT ) + STYLE( buhd_dflt, BUHD_DFLT, + "Buhid default style", + AF_WRITING_SYSTEM_LATIN, + AF_SCRIPT_BUHD, + AF_BLUE_STRINGSET_BUHD, + AF_COVERAGE_DEFAULT ) + + STYLE( cakm_dflt, CAKM_DFLT, + "Chakma default style", + AF_WRITING_SYSTEM_LATIN, + AF_SCRIPT_CAKM, + AF_BLUE_STRINGSET_CAKM, + AF_COVERAGE_DEFAULT ) + + STYLE( cans_dflt, CANS_DFLT, + "Canadian Syllabics default style", + AF_WRITING_SYSTEM_LATIN, + AF_SCRIPT_CANS, + AF_BLUE_STRINGSET_CANS, + AF_COVERAGE_DEFAULT ) + + STYLE( cari_dflt, CARI_DFLT, + "Carian default style", + AF_WRITING_SYSTEM_LATIN, + AF_SCRIPT_CARI, + AF_BLUE_STRINGSET_CARI, + AF_COVERAGE_DEFAULT ) + STYLE( cher_dflt, CHER_DFLT, "Cherokee default style", AF_WRITING_SYSTEM_LATIN, @@ -111,6 +160,20 @@ AF_BLUE_STRINGSET_CHER, AF_COVERAGE_DEFAULT ) + STYLE( copt_dflt, COPT_DFLT, + "Coptic default style", + AF_WRITING_SYSTEM_LATIN, + AF_SCRIPT_COPT, + AF_BLUE_STRINGSET_COPT, + AF_COVERAGE_DEFAULT ) + + STYLE( cprt_dflt, CPRT_DFLT, + "Cypriot default style", + AF_WRITING_SYSTEM_LATIN, + AF_SCRIPT_CPRT, + AF_BLUE_STRINGSET_CPRT, + AF_COVERAGE_DEFAULT ) + META_STYLE_LATIN( cyrl, CYRL, "Cyrillic" ) STYLE( deva_dflt, DEVA_DFLT, @@ -120,6 +183,13 @@ AF_BLUE_STRINGSET_DEVA, AF_COVERAGE_DEFAULT ) + STYLE( dsrt_dflt, DSRT_DFLT, + "Deseret default style", + AF_WRITING_SYSTEM_LATIN, + AF_SCRIPT_DSRT, + AF_BLUE_STRINGSET_DSRT, + AF_COVERAGE_DEFAULT ) + STYLE( ethi_dflt, ETHI_DFLT, "Ethiopic default style", AF_WRITING_SYSTEM_LATIN, @@ -141,6 +211,20 @@ AF_BLUE_STRINGSET_GEOK, AF_COVERAGE_DEFAULT ) + STYLE( glag_dflt, GLAG_DFLT, + "Glagolitic default style", + AF_WRITING_SYSTEM_LATIN, + AF_SCRIPT_GLAG, + AF_BLUE_STRINGSET_GLAG, + AF_COVERAGE_DEFAULT ) + + STYLE( goth_dflt, GOTH_DFLT, + "Gothic default style", + AF_WRITING_SYSTEM_LATIN, + AF_SCRIPT_GOTH, + AF_BLUE_STRINGSET_GOTH, + AF_COVERAGE_DEFAULT ) + META_STYLE_LATIN( grek, GREK, "Greek" ) STYLE( gujr_dflt, GUJR_DFLT, @@ -164,6 +248,13 @@ AF_BLUE_STRINGSET_HEBR, AF_COVERAGE_DEFAULT ) + STYLE( kali_dflt, KALI_DFLT, + "Kayah Li default style", + AF_WRITING_SYSTEM_LATIN, + AF_SCRIPT_KALI, + AF_BLUE_STRINGSET_KALI, + AF_COVERAGE_DEFAULT ) + STYLE( knda_dflt, KNDA_DFLT, "Kannada default style", AF_WRITING_SYSTEM_LATIN, @@ -217,6 +308,13 @@ AF_COVERAGE_DEFAULT ) #endif + STYLE( lisu_dflt, LISU_DFLT, + "Lisu default style", + AF_WRITING_SYSTEM_LATIN, + AF_SCRIPT_LISU, + AF_BLUE_STRINGSET_LISU, + AF_COVERAGE_DEFAULT ) + STYLE( mlym_dflt, MLYM_DFLT, "Malayalam default style", AF_WRITING_SYSTEM_LATIN, @@ -231,6 +329,13 @@ AF_BLUE_STRINGSET_MYMR, AF_COVERAGE_DEFAULT ) + STYLE( nkoo_dflt, NKOO_DFLT, + "N'Ko default style", + AF_WRITING_SYSTEM_LATIN, + AF_SCRIPT_NKOO, + AF_BLUE_STRINGSET_NKOO, + AF_COVERAGE_DEFAULT ) + STYLE( none_dflt, NONE_DFLT, "no style", AF_WRITING_SYSTEM_DUMMY, @@ -238,6 +343,48 @@ AF_BLUE_STRINGSET_NONE, AF_COVERAGE_DEFAULT ) + STYLE( olck_dflt, OLCK_DFLT, + "Ol Chiki default style", + AF_WRITING_SYSTEM_LATIN, + AF_SCRIPT_OLCK, + AF_BLUE_STRINGSET_OLCK, + AF_COVERAGE_DEFAULT ) + + STYLE( orkh_dflt, ORKH_DFLT, + "Old Turkic default style", + AF_WRITING_SYSTEM_LATIN, + AF_SCRIPT_ORKH, + AF_BLUE_STRINGSET_ORKH, + AF_COVERAGE_DEFAULT ) + + STYLE( osge_dflt, OSGE_DFLT, + "Osage default style", + AF_WRITING_SYSTEM_LATIN, + AF_SCRIPT_OSGE, + AF_BLUE_STRINGSET_OSGE, + AF_COVERAGE_DEFAULT ) + + STYLE( osma_dflt, OSMA_DFLT, + "Osmanya default style", + AF_WRITING_SYSTEM_LATIN, + AF_SCRIPT_OSMA, + AF_BLUE_STRINGSET_OSMA, + AF_COVERAGE_DEFAULT ) + + STYLE( saur_dflt, SAUR_DFLT, + "Saurashtra default style", + AF_WRITING_SYSTEM_LATIN, + AF_SCRIPT_SAUR, + AF_BLUE_STRINGSET_SAUR, + AF_COVERAGE_DEFAULT ) + + STYLE( shaw_dflt, SHAW_DFLT, + "Shavian default style", + AF_WRITING_SYSTEM_LATIN, + AF_SCRIPT_SHAW, + AF_BLUE_STRINGSET_SHAW, + AF_COVERAGE_DEFAULT ) + STYLE( sinh_dflt, SINH_DFLT, "Sinhala default style", AF_WRITING_SYSTEM_LATIN, @@ -245,6 +392,13 @@ AF_BLUE_STRINGSET_SINH, AF_COVERAGE_DEFAULT ) + STYLE( sund_dflt, SUND_DFLT, + "Sundanese default style", + AF_WRITING_SYSTEM_LATIN, + AF_SCRIPT_SUND, + AF_BLUE_STRINGSET_SUND, + AF_COVERAGE_DEFAULT ) + STYLE( taml_dflt, TAML_DFLT, "Tamil default style", AF_WRITING_SYSTEM_LATIN, @@ -252,6 +406,13 @@ AF_BLUE_STRINGSET_TAML, AF_COVERAGE_DEFAULT ) + STYLE( tavt_dflt, TAVT_DFLT, + "Tai Viet default style", + AF_WRITING_SYSTEM_LATIN, + AF_SCRIPT_TAVT, + AF_BLUE_STRINGSET_TAVT, + AF_COVERAGE_DEFAULT ) + STYLE( telu_dflt, TELU_DFLT, "Telugu default style", AF_WRITING_SYSTEM_LATIN, @@ -266,6 +427,20 @@ AF_BLUE_STRINGSET_THAI, AF_COVERAGE_DEFAULT ) + STYLE( tfng_dflt, TFNG_DFLT, + "Tifinagh default style", + AF_WRITING_SYSTEM_LATIN, + AF_SCRIPT_TFNG, + AF_BLUE_STRINGSET_TFNG, + AF_COVERAGE_DEFAULT ) + + STYLE( vaii_dflt, VAII_DFLT, + "Vai default style", + AF_WRITING_SYSTEM_LATIN, + AF_SCRIPT_VAII, + AF_BLUE_STRINGSET_VAII, + AF_COVERAGE_DEFAULT ) + #ifdef AF_CONFIG_OPTION_INDIC /* no blue stringset support for the Indic writing system yet */ @@ -280,7 +455,6 @@ STYLE_DEFAULT_INDIC( limb, LIMB, "Limbu" ) STYLE_DEFAULT_INDIC( orya, ORYA, "Oriya" ) - STYLE_DEFAULT_INDIC( sund, SUND, "Sundanese" ) STYLE_DEFAULT_INDIC( sylo, SYLO, "Syloti Nagri" ) STYLE_DEFAULT_INDIC( tibt, TIBT, "Tibetan" ) diff --git a/thirdparty/freetype/src/autofit/aftypes.h b/thirdparty/freetype/src/autofit/aftypes.h index ef62043c8a..718dab70b6 100644 --- a/thirdparty/freetype/src/autofit/aftypes.h +++ b/thirdparty/freetype/src/autofit/aftypes.h @@ -4,7 +4,7 @@ /* */ /* Auto-fitter types (specification only). */ /* */ -/* Copyright 2003-2016 by */ +/* Copyright 2003-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -221,7 +221,7 @@ extern void* _af_debug_hints; (*AF_WritingSystem_InitHintsFunc)( AF_GlyphHints hints, AF_StyleMetrics metrics ); - typedef void + typedef FT_Error (*AF_WritingSystem_ApplyHintsFunc)( FT_UInt glyph_index, AF_GlyphHints hints, FT_Outline* outline, @@ -575,6 +575,7 @@ extern void* _af_debug_hints; m_init, \ m_scale, \ m_done, \ + m_stdw, \ h_init, \ h_apply ) \ FT_LOCAL_DEF( void ) \ diff --git a/thirdparty/freetype/src/autofit/afwarp.c b/thirdparty/freetype/src/autofit/afwarp.c index ce1806c9d3..f99aa6d987 100644 --- a/thirdparty/freetype/src/autofit/afwarp.c +++ b/thirdparty/freetype/src/autofit/afwarp.c @@ -4,7 +4,7 @@ /* */ /* Auto-fitter warping algorithm (body). */ /* */ -/* Copyright 2006-2016 by */ +/* Copyright 2006-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -98,7 +98,6 @@ if ( xx1min + w < warper->x2min ) xx1min = warper->x2min - w; - xx1max = warper->x1max; if ( xx1max + w > warper->x2max ) xx1max = warper->x2max - w; diff --git a/thirdparty/freetype/src/autofit/afwarp.h b/thirdparty/freetype/src/autofit/afwarp.h index 6d96f86d73..2e85cbd851 100644 --- a/thirdparty/freetype/src/autofit/afwarp.h +++ b/thirdparty/freetype/src/autofit/afwarp.h @@ -4,7 +4,7 @@ /* */ /* Auto-fitter warping algorithm (specification). */ /* */ -/* Copyright 2006-2016 by */ +/* Copyright 2006-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/thirdparty/freetype/src/autofit/afwrtsys.h b/thirdparty/freetype/src/autofit/afwrtsys.h index 842f4921a4..86749a2a83 100644 --- a/thirdparty/freetype/src/autofit/afwrtsys.h +++ b/thirdparty/freetype/src/autofit/afwrtsys.h @@ -4,7 +4,7 @@ /* */ /* Auto-fitter writing systems (specification only). */ /* */ -/* Copyright 2013-2016 by */ +/* Copyright 2013-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/thirdparty/freetype/src/autofit/autofit.c b/thirdparty/freetype/src/autofit/autofit.c index dda9aeb6d7..bbedad7b5f 100644 --- a/thirdparty/freetype/src/autofit/autofit.c +++ b/thirdparty/freetype/src/autofit/autofit.c @@ -4,7 +4,7 @@ /* */ /* Auto-fitter module (body). */ /* */ -/* Copyright 2003-2016 by */ +/* Copyright 2003-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -18,29 +18,22 @@ #define FT_MAKE_OPTION_SINGLE_OBJECT #include <ft2build.h> -#include "afpic.c" + #include "afangles.c" #include "afblue.c" +#include "afcjk.c" +#include "afdummy.c" #include "afglobal.c" #include "afhints.c" - -#include "afranges.c" - -#include "afdummy.c" +#include "afindic.c" #include "aflatin.c" -#ifdef FT_OPTION_AUTOFIT2 #include "aflatin2.c" -#endif -#include "afcjk.c" -#include "afindic.c" - -#include "afshaper.c" - #include "afloader.c" #include "afmodule.c" - -#ifdef AF_CONFIG_OPTION_USE_WARPER +#include "afpic.c" +#include "afranges.c" +#include "afshaper.c" #include "afwarp.c" -#endif + /* END */ diff --git a/thirdparty/freetype/src/autofit/module.mk b/thirdparty/freetype/src/autofit/module.mk index 98f0612b99..c4e249b6f1 100644 --- a/thirdparty/freetype/src/autofit/module.mk +++ b/thirdparty/freetype/src/autofit/module.mk @@ -3,7 +3,7 @@ # -# Copyright 2003-2016 by +# Copyright 2003-2017 by # David Turner, Robert Wilhelm, and Werner Lemberg. # # This file is part of the FreeType project, and may only be used, modified, diff --git a/thirdparty/freetype/src/autofit/rules.mk b/thirdparty/freetype/src/autofit/rules.mk index 1ef4704649..ec4e1302d1 100644 --- a/thirdparty/freetype/src/autofit/rules.mk +++ b/thirdparty/freetype/src/autofit/rules.mk @@ -3,7 +3,7 @@ # -# Copyright 2003-2016 by +# Copyright 2003-2017 by # David Turner, Robert Wilhelm, and Werner Lemberg. # # This file is part of the FreeType project, and may only be used, modified, diff --git a/thirdparty/freetype/src/base/basepic.c b/thirdparty/freetype/src/base/basepic.c index f2cea90d7c..57fb8169ad 100644 --- a/thirdparty/freetype/src/base/basepic.c +++ b/thirdparty/freetype/src/base/basepic.c @@ -4,7 +4,7 @@ /* */ /* The FreeType position independent code services for base. */ /* */ -/* Copyright 2009-2016 by */ +/* Copyright 2009-2017 by */ /* Oran Agra and Mickey Gabel. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/thirdparty/freetype/src/base/basepic.h b/thirdparty/freetype/src/base/basepic.h index a1a75a0bad..258d4ce2ba 100644 --- a/thirdparty/freetype/src/base/basepic.h +++ b/thirdparty/freetype/src/base/basepic.h @@ -4,7 +4,7 @@ /* */ /* The FreeType position independent code services for base. */ /* */ -/* Copyright 2009-2016 by */ +/* Copyright 2009-2017 by */ /* Oran Agra and Mickey Gabel. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/thirdparty/freetype/src/base/ftadvanc.c b/thirdparty/freetype/src/base/ftadvanc.c index 9e2ab89845..1557607fc5 100644 --- a/thirdparty/freetype/src/base/ftadvanc.c +++ b/thirdparty/freetype/src/base/ftadvanc.c @@ -4,7 +4,7 @@ /* */ /* Quick computation of advance widths (body). */ /* */ -/* Copyright 2008-2016 by */ +/* Copyright 2008-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -36,7 +36,7 @@ if ( flags & FT_LOAD_NO_SCALE ) return FT_Err_Ok; - if ( face->size == NULL ) + if ( !face->size ) return FT_THROW( Invalid_Size_Handle ); if ( flags & FT_LOAD_VERTICAL_LAYOUT ) @@ -60,12 +60,13 @@ /* - unscaled load */ /* - unhinted load */ /* - light-hinted load */ - /* - neither a MM nor a GX font */ + /* - if a variations font, it must have an `HVAR' or `VVAR' */ + /* table (thus the old MM or GX fonts don't qualify; this */ + /* gets checked by the driver-specific functions) */ -#define LOAD_ADVANCE_FAST_CHECK( face, flags ) \ - ( ( flags & ( FT_LOAD_NO_SCALE | FT_LOAD_NO_HINTING ) || \ - FT_LOAD_TARGET_MODE( flags ) == FT_RENDER_MODE_LIGHT ) && \ - !FT_HAS_MULTIPLE_MASTERS( face ) ) +#define LOAD_ADVANCE_FAST_CHECK( face, flags ) \ + ( flags & ( FT_LOAD_NO_SCALE | FT_LOAD_NO_HINTING ) || \ + FT_LOAD_TARGET_MODE( flags ) == FT_RENDER_MODE_LIGHT ) /* documentation is in ftadvanc.h */ diff --git a/thirdparty/freetype/src/base/ftapi.c b/thirdparty/freetype/src/base/ftapi.c index b94c3eb9fb..4262d37e39 100644 --- a/thirdparty/freetype/src/base/ftapi.c +++ b/thirdparty/freetype/src/base/ftapi.c @@ -4,7 +4,7 @@ /* */ /* The FreeType compatibility functions (body). */ /* */ -/* Copyright 2002-2016 by */ +/* Copyright 2002-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -38,7 +38,7 @@ /*************************************************************************/ /*************************************************************************/ - /* backwards compatibility API */ + /* backward compatibility API */ FT_BASE_DEF( void ) FT_New_Memory_Stream( FT_Library library, diff --git a/thirdparty/freetype/src/base/ftbase.c b/thirdparty/freetype/src/base/ftbase.c index ab1af6f9f3..55f7359942 100644 --- a/thirdparty/freetype/src/base/ftbase.c +++ b/thirdparty/freetype/src/base/ftbase.c @@ -4,7 +4,7 @@ /* */ /* Single object library component (body only). */ /* */ -/* Copyright 1996-2016 by */ +/* Copyright 1996-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -17,26 +17,23 @@ #include <ft2build.h> - #define FT_MAKE_OPTION_SINGLE_OBJECT -#include "ftpic.c" #include "basepic.c" #include "ftadvanc.c" #include "ftcalc.c" #include "ftdbgmem.c" #include "ftgloadr.c" #include "fthash.c" +#include "ftmac.c" #include "ftobjs.c" #include "ftoutln.c" +#include "ftpic.c" #include "ftrfork.c" #include "ftsnames.c" #include "ftstream.c" #include "fttrigon.c" #include "ftutil.c" -#ifdef FT_MACINTOSH -#include "ftmac.c" -#endif /* END */ diff --git a/thirdparty/freetype/src/base/ftbase.h b/thirdparty/freetype/src/base/ftbase.h index 717fdaae24..2072284f06 100644 --- a/thirdparty/freetype/src/base/ftbase.h +++ b/thirdparty/freetype/src/base/ftbase.h @@ -4,7 +4,7 @@ /* */ /* The FreeType private functions used in base module (specification). */ /* */ -/* Copyright 2008-2016 by */ +/* Copyright 2008-2017 by */ /* David Turner, Robert Wilhelm, Werner Lemberg, and suzuki toshiya. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/thirdparty/freetype/src/base/ftbbox.c b/thirdparty/freetype/src/base/ftbbox.c index d3e45ffa0d..6e19da63cb 100644 --- a/thirdparty/freetype/src/base/ftbbox.c +++ b/thirdparty/freetype/src/base/ftbbox.c @@ -4,7 +4,7 @@ /* */ /* FreeType bbox computation (body). */ /* */ -/* Copyright 1996-2016 by */ +/* Copyright 1996-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used */ @@ -423,12 +423,15 @@ } - FT_DEFINE_OUTLINE_FUNCS(bbox_interface, - (FT_Outline_MoveTo_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 + FT_DEFINE_OUTLINE_FUNCS( + bbox_interface, + + (FT_Outline_MoveTo_Func) BBox_Move_To, /* move_to */ + (FT_Outline_LineTo_Func) BBox_Line_To, /* line_to */ + (FT_Outline_ConicTo_Func)BBox_Conic_To, /* conic_to */ + (FT_Outline_CubicTo_Func)BBox_Cubic_To, /* cubic_to */ + 0, /* shift */ + 0 /* delta */ ) @@ -457,6 +460,7 @@ { abbox->xMin = abbox->xMax = 0; abbox->yMin = abbox->yMax = 0; + return 0; } @@ -468,10 +472,10 @@ for ( n = 0; n < outline->n_points; n++ ) { - FT_UPDATE_BBOX( vec, cbox); + FT_UPDATE_BBOX( vec, cbox ); if ( FT_CURVE_TAG( outline->tags[n] ) == FT_CURVE_TAG_ON ) - FT_UPDATE_BBOX( vec, bbox); + FT_UPDATE_BBOX( vec, bbox ); vec++; } @@ -487,8 +491,10 @@ TBBox_Rec user; #ifdef FT_CONFIG_OPTION_PIC - FT_Outline_Funcs bbox_interface; - Init_Class_bbox_interface(&bbox_interface); + FT_Outline_Funcs bbox_interface; + + + Init_Class_bbox_interface( &bbox_interface ); #endif user.bbox = bbox; diff --git a/thirdparty/freetype/src/base/ftbdf.c b/thirdparty/freetype/src/base/ftbdf.c index 4aafc2b98e..40f0ca2bb8 100644 --- a/thirdparty/freetype/src/base/ftbdf.c +++ b/thirdparty/freetype/src/base/ftbdf.c @@ -4,7 +4,7 @@ /* */ /* FreeType API for accessing BDF-specific strings (body). */ /* */ -/* Copyright 2002-2016 by */ +/* Copyright 2002-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/thirdparty/freetype/src/base/ftbitmap.c b/thirdparty/freetype/src/base/ftbitmap.c index 24fead3e15..88c88c4c1b 100644 --- a/thirdparty/freetype/src/base/ftbitmap.c +++ b/thirdparty/freetype/src/base/ftbitmap.c @@ -4,7 +4,7 @@ /* */ /* FreeType utility functions for bitmaps (body). */ /* */ -/* Copyright 2004-2016 by */ +/* Copyright 2004-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -76,7 +76,7 @@ source_pitch_sign = source->pitch < 0 ? -1 : 1; target_pitch_sign = target->pitch < 0 ? -1 : 1; - if ( source->buffer == NULL ) + if ( !source->buffer ) { *target = *source; if ( source_pitch_sign != target_pitch_sign ) diff --git a/thirdparty/freetype/src/base/ftcalc.c b/thirdparty/freetype/src/base/ftcalc.c index 67549d0c43..f0525502f3 100644 --- a/thirdparty/freetype/src/base/ftcalc.c +++ b/thirdparty/freetype/src/base/ftcalc.c @@ -4,7 +4,7 @@ /* */ /* Arithmetic computations (body). */ /* */ -/* Copyright 1996-2016 by */ +/* Copyright 1996-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -449,8 +449,8 @@ FT_Add64( &temp, &temp2, &temp ); /* last attempt to ditch long division */ - a = temp.hi == 0 ? temp.lo / c - : ft_div64by32( temp.hi, temp.lo, c ); + a = ( temp.hi == 0 ) ? temp.lo / c + : ft_div64by32( temp.hi, temp.lo, c ); } a_ = (FT_Long)a; @@ -492,8 +492,8 @@ 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 ); + a = ( temp.hi == 0 ) ? temp.lo / c + : ft_div64by32( temp.hi, temp.lo, c ); } a_ = (FT_Long)a; diff --git a/thirdparty/freetype/src/base/ftcid.c b/thirdparty/freetype/src/base/ftcid.c index 251bbd009a..398396b845 100644 --- a/thirdparty/freetype/src/base/ftcid.c +++ b/thirdparty/freetype/src/base/ftcid.c @@ -4,7 +4,7 @@ /* */ /* FreeType API for accessing CID font information. */ /* */ -/* Copyright 2007-2016 by */ +/* Copyright 2007-2017 by */ /* Derek Clegg and Michael Toftdal. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/thirdparty/freetype/src/base/ftdbgmem.c b/thirdparty/freetype/src/base/ftdbgmem.c index 6ab5072748..242246bfd1 100644 --- a/thirdparty/freetype/src/base/ftdbgmem.c +++ b/thirdparty/freetype/src/base/ftdbgmem.c @@ -4,7 +4,7 @@ /* */ /* Memory debugger (body). */ /* */ -/* Copyright 2001-2016 by */ +/* Copyright 2001-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -268,7 +268,7 @@ ft_mem_table_alloc( table, new_size * (FT_Long)sizeof ( FT_MemNode ) ); - if ( new_buckets == NULL ) + if ( !new_buckets ) return; FT_ARRAY_ZERO( new_buckets, new_size ); @@ -309,7 +309,7 @@ table = (FT_MemTable)memory->alloc( memory, sizeof ( *table ) ); - if ( table == NULL ) + if ( !table ) goto Exit; FT_ZERO( table ); @@ -466,7 +466,7 @@ for (;;) { node = *pnode; - if ( node == NULL ) + if ( !node ) break; if ( node->file_name == _ft_debug_file && @@ -477,7 +477,7 @@ } node = (FT_MemSource)ft_mem_table_alloc( table, sizeof ( *node ) ); - if ( node == NULL ) + if ( !node ) ft_mem_debug_panic( "not enough memory to perform memory debugging\n" ); @@ -545,7 +545,7 @@ /* we need to create a new node in this table */ node = (FT_MemNode)ft_mem_table_alloc( table, sizeof ( *node ) ); - if ( node == NULL ) + if ( !node ) ft_mem_debug_panic( "not enough memory to run memory tests" ); node->address = address; @@ -717,7 +717,7 @@ FT_MemTable table = (FT_MemTable)memory->user; - if ( block == NULL ) + if ( !block ) ft_mem_debug_panic( "trying to free NULL in (%s:%ld)", FT_FILENAME( _ft_debug_file ), _ft_debug_lineno ); @@ -755,7 +755,7 @@ /* the following is valid according to ANSI C */ #if 0 - if ( block == NULL || cur_size == 0 ) + if ( !block || !cur_size ) ft_mem_debug_panic( "trying to reallocate NULL in (%s:%ld)", file_name, line_no ); #endif @@ -799,7 +799,7 @@ return NULL; new_block = (FT_Pointer)ft_mem_table_alloc( table, new_size ); - if ( new_block == NULL ) + if ( !new_block ) return NULL; ft_mem_table_set( table, (FT_Byte*)new_block, new_size, delta ); @@ -840,9 +840,9 @@ memory->free = ft_mem_debug_free; p = getenv( "FT2_ALLOC_TOTAL_MAX" ); - if ( p != NULL ) + if ( p ) { - FT_Long total_max = ft_atol( p ); + FT_Long total_max = ft_strtol( p, NULL, 10 ); if ( total_max > 0 ) @@ -853,9 +853,9 @@ } p = getenv( "FT2_ALLOC_COUNT_MAX" ); - if ( p != NULL ) + if ( p ) { - FT_Long total_count = ft_atol( p ); + FT_Long total_count = ft_strtol( p, NULL, 10 ); if ( total_count > 0 ) @@ -866,9 +866,9 @@ } p = getenv( "FT2_KEEP_ALIVE" ); - if ( p != NULL ) + if ( p ) { - FT_Long keep_alive = ft_atol( p ); + FT_Long keep_alive = ft_strtol( p, NULL, 10 ); if ( keep_alive > 0 ) diff --git a/thirdparty/freetype/src/base/ftdebug.c b/thirdparty/freetype/src/base/ftdebug.c index 40925d14a0..20c617089f 100644 --- a/thirdparty/freetype/src/base/ftdebug.c +++ b/thirdparty/freetype/src/base/ftdebug.c @@ -4,7 +4,7 @@ /* */ /* Debugging and logging component (body). */ /* */ -/* Copyright 1996-2016 by */ +/* Copyright 1996-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/thirdparty/freetype/src/base/ftfntfmt.c b/thirdparty/freetype/src/base/ftfntfmt.c index c6eb3190c6..dcbeba0053 100644 --- a/thirdparty/freetype/src/base/ftfntfmt.c +++ b/thirdparty/freetype/src/base/ftfntfmt.c @@ -4,7 +4,7 @@ /* */ /* FreeType utility file for font formats (body). */ /* */ -/* Copyright 2002-2016 by */ +/* Copyright 2002-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/thirdparty/freetype/src/base/ftfstype.c b/thirdparty/freetype/src/base/ftfstype.c index ae56c8fc8d..cec4fb3025 100644 --- a/thirdparty/freetype/src/base/ftfstype.c +++ b/thirdparty/freetype/src/base/ftfstype.c @@ -4,7 +4,7 @@ /* */ /* FreeType utility file to access FSType data (body). */ /* */ -/* Copyright 2008-2016 by */ +/* Copyright 2008-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/thirdparty/freetype/src/base/ftgasp.c b/thirdparty/freetype/src/base/ftgasp.c index e38e55b6c0..477b72558c 100644 --- a/thirdparty/freetype/src/base/ftgasp.c +++ b/thirdparty/freetype/src/base/ftgasp.c @@ -4,7 +4,7 @@ /* */ /* Access of TrueType's `gasp' table (body). */ /* */ -/* Copyright 2007-2016 by */ +/* Copyright 2007-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/thirdparty/freetype/src/base/ftgloadr.c b/thirdparty/freetype/src/base/ftgloadr.c index c4f0ff70f4..8134003b4b 100644 --- a/thirdparty/freetype/src/base/ftgloadr.c +++ b/thirdparty/freetype/src/base/ftgloadr.c @@ -4,7 +4,7 @@ /* */ /* The FreeType glyph loader (body). */ /* */ -/* Copyright 2002-2016 by */ +/* Copyright 2002-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/thirdparty/freetype/src/base/ftglyph.c b/thirdparty/freetype/src/base/ftglyph.c index c2376dd03a..9bfb330508 100644 --- a/thirdparty/freetype/src/base/ftglyph.c +++ b/thirdparty/freetype/src/base/ftglyph.c @@ -4,7 +4,7 @@ /* */ /* FreeType convenience functions to handle glyphs (body). */ /* */ -/* Copyright 1996-2016 by */ +/* Copyright 1996-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -132,16 +132,18 @@ } - FT_DEFINE_GLYPH(ft_bitmap_glyph_class, + FT_DEFINE_GLYPH( + ft_bitmap_glyph_class, + sizeof ( FT_BitmapGlyphRec ), FT_GLYPH_FORMAT_BITMAP, - ft_bitmap_glyph_init, - ft_bitmap_glyph_done, - ft_bitmap_glyph_copy, - 0, /* FT_Glyph_TransformFunc */ - ft_bitmap_glyph_bbox, - 0 /* FT_Glyph_PrepareFunc */ + ft_bitmap_glyph_init, /* FT_Glyph_InitFunc glyph_init */ + ft_bitmap_glyph_done, /* FT_Glyph_DoneFunc glyph_done */ + ft_bitmap_glyph_copy, /* FT_Glyph_CopyFunc glyph_copy */ + NULL, /* FT_Glyph_TransformFunc glyph_transform */ + ft_bitmap_glyph_bbox, /* FT_Glyph_GetBBoxFunc glyph_bbox */ + NULL /* FT_Glyph_PrepareFunc glyph_prepare */ ) @@ -260,16 +262,18 @@ } - FT_DEFINE_GLYPH( ft_outline_glyph_class, + FT_DEFINE_GLYPH( + ft_outline_glyph_class, + sizeof ( FT_OutlineGlyphRec ), FT_GLYPH_FORMAT_OUTLINE, - ft_outline_glyph_init, - ft_outline_glyph_done, - ft_outline_glyph_copy, - ft_outline_glyph_transform, - ft_outline_glyph_bbox, - ft_outline_glyph_prepare + ft_outline_glyph_init, /* FT_Glyph_InitFunc glyph_init */ + ft_outline_glyph_done, /* FT_Glyph_DoneFunc glyph_done */ + ft_outline_glyph_copy, /* FT_Glyph_CopyFunc glyph_copy */ + ft_outline_glyph_transform, /* FT_Glyph_TransformFunc glyph_transform */ + ft_outline_glyph_bbox, /* FT_Glyph_GetBBoxFunc glyph_bbox */ + ft_outline_glyph_prepare /* FT_Glyph_PrepareFunc glyph_prepare */ ) @@ -542,8 +546,8 @@ /* we render the glyph into a glyph bitmap using a `dummy' glyph slot */ /* then calling FT_Render_Glyph_Internal() */ - FT_MEM_ZERO( &dummy, sizeof ( dummy ) ); - FT_MEM_ZERO( &dummy_internal, sizeof ( dummy_internal ) ); + FT_ZERO( &dummy ); + FT_ZERO( &dummy_internal ); dummy.internal = &dummy_internal; dummy.library = library; dummy.format = clazz->glyph_format; diff --git a/thirdparty/freetype/src/base/ftgxval.c b/thirdparty/freetype/src/base/ftgxval.c index 6667b371a1..ff24d336df 100644 --- a/thirdparty/freetype/src/base/ftgxval.c +++ b/thirdparty/freetype/src/base/ftgxval.c @@ -2,9 +2,9 @@ /* */ /* ftgxval.c */ /* */ -/* FreeType API for validating TrueTyepGX/AAT tables (body). */ +/* FreeType API for validating TrueTypeGX/AAT tables (body). */ /* */ -/* Copyright 2004-2016 by */ +/* Copyright 2004-2017 by */ /* Masatake YAMATO, Redhat K.K, */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ diff --git a/thirdparty/freetype/src/base/ftinit.c b/thirdparty/freetype/src/base/ftinit.c index c2dd0a7b37..b3b08fa541 100644 --- a/thirdparty/freetype/src/base/ftinit.c +++ b/thirdparty/freetype/src/base/ftinit.c @@ -4,7 +4,7 @@ /* */ /* FreeType initialization layer (body). */ /* */ -/* Copyright 1996-2016 by */ +/* Copyright 1996-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -226,6 +226,94 @@ } +#ifdef FT_CONFIG_OPTION_ENVIRONMENT_PROPERTIES + +#define MAX_LENGTH 128 + + /* documentation is in ftmodapi.h */ + + FT_EXPORT_DEF( void ) + FT_Set_Default_Properties( FT_Library library ) + { + const char* env; + const char* p; + const char* q; + + char module_name[MAX_LENGTH + 1]; + char property_name[MAX_LENGTH + 1]; + char property_value[MAX_LENGTH + 1]; + + int i; + + + env = ft_getenv( "FREETYPE_PROPERTIES" ); + if ( !env ) + return; + + for ( p = env; *p; p++ ) + { + /* skip leading whitespace and separators */ + if ( *p == ' ' || *p == '\t' ) + continue; + + /* read module name, followed by `:' */ + q = p; + for ( i = 0; i < MAX_LENGTH; i++ ) + { + if ( !*p || *p == ':' ) + break; + module_name[i] = *p++; + } + module_name[i] = '\0'; + + if ( !*p || *p != ':' || p == q ) + break; + + /* read property name, followed by `=' */ + q = ++p; + for ( i = 0; i < MAX_LENGTH; i++ ) + { + if ( !*p || *p == '=' ) + break; + property_name[i] = *p++; + } + property_name[i] = '\0'; + + if ( !*p || *p != '=' || p == q ) + break; + + /* read property value, followed by whitespace (if any) */ + q = ++p; + for ( i = 0; i < MAX_LENGTH; i++ ) + { + if ( !*p || *p == ' ' || *p == '\t' ) + break; + property_value[i] = *p++; + } + property_value[i] = '\0'; + + if ( !( *p == '\0' || *p == ' ' || *p == '\t' ) || p == q ) + break; + + /* we completely ignore errors */ + ft_property_string_set( library, + module_name, + property_name, + property_value ); + } + } + +#else + + FT_EXPORT_DEF( void ) + FT_Set_Default_Properties( FT_Library library ) + { + FT_UNUSED( library ); + } + +#endif + + /* documentation is in freetype.h */ FT_EXPORT_DEF( FT_Error ) @@ -256,6 +344,8 @@ else FT_Add_Default_Modules( *alibrary ); + FT_Set_Default_Properties( *alibrary ); + return error; } diff --git a/thirdparty/freetype/src/base/ftlcdfil.c b/thirdparty/freetype/src/base/ftlcdfil.c index 8bcbed7aab..611b39f570 100644 --- a/thirdparty/freetype/src/base/ftlcdfil.c +++ b/thirdparty/freetype/src/base/ftlcdfil.c @@ -4,7 +4,7 @@ /* */ /* FreeType API for color filtering of subpixel bitmap glyphs (body). */ /* */ -/* Copyright 2006-2016 by */ +/* Copyright 2006-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -30,14 +30,13 @@ #define USE_LEGACY /* FIR filter used by the default and light filters */ - static void - _ft_lcd_filter_fir( FT_Bitmap* bitmap, - FT_Render_Mode mode, - FT_Library library ) + FT_BASE( void ) + ft_lcd_filter_fir( FT_Bitmap* bitmap, + FT_Render_Mode mode, + FT_LcdFiveTapFilter weights ) { - FT_Byte* weights = library->lcd_weights; - FT_UInt width = (FT_UInt)bitmap->width; - FT_UInt height = (FT_UInt)bitmap->rows; + FT_UInt width = (FT_UInt)bitmap->width; + FT_UInt height = (FT_UInt)bitmap->rows; /* horizontal in-place FIR filter */ @@ -176,7 +175,7 @@ static void _ft_lcd_filter_legacy( FT_Bitmap* bitmap, FT_Render_Mode mode, - FT_Library library ) + FT_Byte* weights ) { FT_UInt width = (FT_UInt)bitmap->width; FT_UInt height = (FT_UInt)bitmap->rows; @@ -189,7 +188,7 @@ { 65538 * 1/13, 65538 * 1/6, 65538 * 9/13 } }; - FT_UNUSED( library ); + FT_UNUSED( weights ); /* horizontal in-place intra-pixel filter */ @@ -295,8 +294,8 @@ if ( !weights ) return FT_THROW( Invalid_Argument ); - ft_memcpy( library->lcd_weights, weights, 5 ); - library->lcd_filter_func = _ft_lcd_filter_fir; + ft_memcpy( library->lcd_weights, weights, FT_LCD_FILTER_FIVE_TAPS ); + library->lcd_filter_func = ft_lcd_filter_fir; library->lcd_extra = 2; return FT_Err_Ok; @@ -307,10 +306,10 @@ FT_Library_SetLcdFilter( FT_Library library, FT_LcdFilter filter ) { - static const FT_Byte default_filter[5] = - { 0x08, 0x4d, 0x56, 0x4d, 0x08 }; - static const FT_Byte light_filter[5] = - { 0x00, 0x55, 0x56, 0x55, 0x00 }; + static const FT_LcdFiveTapFilter default_weights = + { 0x08, 0x4d, 0x56, 0x4d, 0x08 }; + static const FT_LcdFiveTapFilter light_weights = + { 0x00, 0x55, 0x56, 0x55, 0x00 }; if ( !library ) @@ -324,14 +323,18 @@ break; case FT_LCD_FILTER_DEFAULT: - ft_memcpy( library->lcd_weights, default_filter, 5 ); - library->lcd_filter_func = _ft_lcd_filter_fir; + ft_memcpy( library->lcd_weights, + default_weights, + FT_LCD_FILTER_FIVE_TAPS ); + library->lcd_filter_func = ft_lcd_filter_fir; library->lcd_extra = 2; break; case FT_LCD_FILTER_LIGHT: - ft_memcpy( library->lcd_weights, light_filter, 5 ); - library->lcd_filter_func = _ft_lcd_filter_fir; + ft_memcpy( library->lcd_weights, + light_weights, + FT_LCD_FILTER_FIVE_TAPS ); + library->lcd_filter_func = ft_lcd_filter_fir; library->lcd_extra = 2; break; @@ -356,6 +359,17 @@ #else /* !FT_CONFIG_OPTION_SUBPIXEL_RENDERING */ + FT_BASE( void ) + ft_lcd_filter_fir( FT_Bitmap* bitmap, + FT_Render_Mode mode, + FT_LcdFiveTapFilter weights ) + { + FT_UNUSED( bitmap ); + FT_UNUSED( mode ); + FT_UNUSED( weights ); + } + + FT_EXPORT_DEF( FT_Error ) FT_Library_SetLcdFilterWeights( FT_Library library, unsigned char *weights ) diff --git a/thirdparty/freetype/src/base/ftmac.c b/thirdparty/freetype/src/base/ftmac.c index e97fdbfc22..4b92066da3 100644 --- a/thirdparty/freetype/src/base/ftmac.c +++ b/thirdparty/freetype/src/base/ftmac.c @@ -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-2016 by */ +/* Copyright 1996-2017 by */ /* Just van Rossum, David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -71,6 +71,9 @@ #include FT_INTERNAL_STREAM_H #include "ftbase.h" + +#ifdef FT_MACINTOSH + /* This is for Mac OS X. Without redefinition, OS_INLINE */ /* expands to `static inline' which doesn't survive the */ /* -ansi compilation flag of GCC. */ @@ -118,8 +121,6 @@ #endif -#ifdef FT_MACINTOSH - /* This function is deprecated because FSSpec is deprecated in Mac OS X */ FT_EXPORT_DEF( FT_Error ) FT_GetFile_From_Mac_Name( const char* fontName, @@ -605,7 +606,7 @@ for (;;) { post_data = Get1Resource( TTAG_POST, res_id++ ); - if ( post_data == NULL ) + if ( !post_data ) break; /* we are done */ code = (*post_data)[0]; @@ -644,7 +645,7 @@ for (;;) { post_data = Get1Resource( TTAG_POST, res_id++ ); - if ( post_data == NULL ) + if ( !post_data ) break; /* we are done */ post_size = (FT_ULong)GetHandleSize( post_data ) - 2; @@ -655,7 +656,7 @@ if ( last_code != -1 ) { /* we are done adding a chunk, fill in the size field */ - if ( size_p != NULL ) + if ( size_p ) { *size_p++ = (FT_Byte)( pfb_chunk_size & 0xFF ); *size_p++ = (FT_Byte)( ( pfb_chunk_size >> 8 ) & 0xFF ); @@ -743,7 +744,7 @@ sfnt = GetResource( TTAG_sfnt, sfnt_id ); - if ( sfnt == NULL ) + if ( !sfnt ) return FT_THROW( Invalid_Handle ); sfnt_size = (FT_ULong)GetHandleSize( sfnt ); @@ -821,7 +822,7 @@ return FT_THROW( Cannot_Open_Resource ); num_faces_in_res = 0; - for ( res_index = 1; ; ++res_index ) + for ( res_index = 1; ; res_index++ ) { short num_faces_in_fond; @@ -942,13 +943,14 @@ /* if it works, fine. */ error = FT_New_Face_From_Suitcase( library, pathname, face_index, aface ); - if ( error == 0 ) - return error; + if ( error ) + { + /* let it fall through to normal loader (.ttf, .otf, etc.); */ + /* we signal this by returning no error and no FT_Face */ + *aface = NULL; + } - /* let it fall through to normal loader (.ttf, .otf, etc.); */ - /* we signal this by returning no error and no FT_Face */ - *aface = NULL; - return 0; + return FT_Err_Ok; } @@ -982,12 +984,13 @@ /* try resourcefork based font: LWFN, FFIL */ error = FT_New_Face_From_Resource( library, (UInt8 *)pathname, face_index, aface ); - if ( error != 0 || *aface != NULL ) + if ( error || *aface ) return error; /* let it fall through to normal loader (.ttf, .otf, etc.) */ args.flags = FT_OPEN_PATHNAME; args.pathname = (char*)pathname; + return FT_Open_Face( library, &args, face_index, aface ); } @@ -1027,7 +1030,7 @@ error = FT_THROW( Cannot_Open_Resource ); error = FT_New_Face_From_Resource( library, pathname, face_index, aface ); - if ( error != 0 || *aface != NULL ) + if ( error || *aface ) return error; /* fallback to datafork font */ @@ -1074,7 +1077,12 @@ #endif } -#endif /* FT_MACINTOSH */ +#else /* !FT_MACINTOSH */ + + /* ANSI C doesn't like empty source files */ + typedef int _ft_mac_dummy; + +#endif /* !FT_MACINTOSH */ /* END */ diff --git a/thirdparty/freetype/src/base/ftmm.c b/thirdparty/freetype/src/base/ftmm.c index 6b759ca467..2cb56a39be 100644 --- a/thirdparty/freetype/src/base/ftmm.c +++ b/thirdparty/freetype/src/base/ftmm.c @@ -4,7 +4,7 @@ /* */ /* Multiple Master font support (body). */ /* */ -/* Copyright 1996-2016 by */ +/* Copyright 1996-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -22,6 +22,7 @@ #include FT_MULTIPLE_MASTERS_H #include FT_INTERNAL_OBJECTS_H #include FT_SERVICE_MULTIPLE_MASTERS_H +#include FT_SERVICE_METRICS_VARIATIONS_H /*************************************************************************/ @@ -62,6 +63,34 @@ } + static FT_Error + ft_face_get_mvar_service( FT_Face face, + FT_Service_MetricsVariations *aservice ) + { + FT_Error error; + + + *aservice = NULL; + + if ( !face ) + return FT_THROW( Invalid_Face_Handle ); + + error = FT_ERR( Invalid_Argument ); + + if ( FT_HAS_MULTIPLE_MASTERS( face ) ) + { + FT_FACE_LOOKUP_SERVICE( face, + *aservice, + METRICS_VARIATIONS ); + + if ( *aservice ) + error = FT_Err_Ok; + } + + return error; + } + + /* documentation is in ftmm.h */ FT_EXPORT_DEF( FT_Error ) @@ -140,6 +169,13 @@ error = service->set_mm_design( face, num_coords, coords ); } + /* enforce recomputation of auto-hinting data */ + if ( !error && face->autohint.finalizer ) + { + face->autohint.finalizer( face->autohint.data ); + face->autohint.data = NULL; + } + return error; } @@ -150,6 +186,50 @@ FT_Set_Var_Design_Coordinates( FT_Face face, FT_UInt num_coords, FT_Fixed* coords ) + { + FT_Error error; + FT_Service_MultiMasters service_mm = NULL; + FT_Service_MetricsVariations service_mvar = NULL; + + + /* 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_mm ); + if ( !error ) + { + error = FT_ERR( Invalid_Argument ); + if ( service_mm->set_var_design ) + error = service_mm->set_var_design( face, num_coords, coords ); + } + + if ( !error ) + { + (void)ft_face_get_mvar_service( face, &service_mvar ); + + if ( service_mvar && service_mvar->metrics_adjust ) + service_mvar->metrics_adjust( face ); + } + + /* enforce recomputation of auto-hinting data */ + if ( !error && face->autohint.finalizer ) + { + face->autohint.finalizer( face->autohint.data ); + face->autohint.data = NULL; + } + + return error; + } + + + /* documentation is in ftmm.h */ + + FT_EXPORT_DEF( FT_Error ) + FT_Get_Var_Design_Coordinates( FT_Face face, + FT_UInt num_coords, + FT_Fixed* coords ) { FT_Error error; FT_Service_MultiMasters service; @@ -164,8 +244,8 @@ if ( !error ) { error = FT_ERR( Invalid_Argument ); - if ( service->set_var_design ) - error = service->set_var_design( face, num_coords, coords ); + if ( service->get_var_design ) + error = service->get_var_design( face, num_coords, coords ); } return error; @@ -178,6 +258,97 @@ FT_Set_MM_Blend_Coordinates( FT_Face face, FT_UInt num_coords, FT_Fixed* coords ) + { + FT_Error error; + FT_Service_MultiMasters service_mm = NULL; + FT_Service_MetricsVariations service_mvar = NULL; + + + /* 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_mm ); + if ( !error ) + { + error = FT_ERR( Invalid_Argument ); + if ( service_mm->set_mm_blend ) + error = service_mm->set_mm_blend( face, num_coords, coords ); + } + + if ( !error ) + { + (void)ft_face_get_mvar_service( face, &service_mvar ); + + if ( service_mvar && service_mvar->metrics_adjust ) + service_mvar->metrics_adjust( face ); + } + + /* enforce recomputation of auto-hinting data */ + if ( !error && face->autohint.finalizer ) + { + face->autohint.finalizer( face->autohint.data ); + face->autohint.data = NULL; + } + + return error; + } + + + /* documentation is in ftmm.h */ + + /* This is exactly the same as the previous function. It exists for */ + /* orthogonality. */ + + FT_EXPORT_DEF( FT_Error ) + FT_Set_Var_Blend_Coordinates( FT_Face face, + FT_UInt num_coords, + FT_Fixed* coords ) + { + FT_Error error; + FT_Service_MultiMasters service_mm = NULL; + FT_Service_MetricsVariations service_mvar = NULL; + + + /* 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_mm ); + if ( !error ) + { + error = FT_ERR( Invalid_Argument ); + if ( service_mm->set_mm_blend ) + error = service_mm->set_mm_blend( face, num_coords, coords ); + } + + if ( !error ) + { + (void)ft_face_get_mvar_service( face, &service_mvar ); + + if ( service_mvar && service_mvar->metrics_adjust ) + service_mvar->metrics_adjust( face ); + } + + /* enforce recomputation of auto-hinting data */ + if ( !error && face->autohint.finalizer ) + { + face->autohint.finalizer( face->autohint.data ); + face->autohint.data = NULL; + } + + return error; + } + + + /* documentation is in ftmm.h */ + + FT_EXPORT_DEF( FT_Error ) + FT_Get_MM_Blend_Coordinates( FT_Face face, + FT_UInt num_coords, + FT_Fixed* coords ) { FT_Error error; FT_Service_MultiMasters service; @@ -192,8 +363,8 @@ if ( !error ) { error = FT_ERR( Invalid_Argument ); - if ( service->set_mm_blend ) - error = service->set_mm_blend( face, num_coords, coords ); + if ( service->get_mm_blend ) + error = service->get_mm_blend( face, num_coords, coords ); } return error; @@ -206,7 +377,7 @@ /* orthogonality. */ FT_EXPORT_DEF( FT_Error ) - FT_Set_Var_Blend_Coordinates( FT_Face face, + FT_Get_Var_Blend_Coordinates( FT_Face face, FT_UInt num_coords, FT_Fixed* coords ) { @@ -223,8 +394,8 @@ if ( !error ) { error = FT_ERR( Invalid_Argument ); - if ( service->set_mm_blend ) - error = service->set_mm_blend( face, num_coords, coords ); + if ( service->get_mm_blend ) + error = service->get_mm_blend( face, num_coords, coords ); } return error; diff --git a/thirdparty/freetype/src/base/ftobjs.c b/thirdparty/freetype/src/base/ftobjs.c index c2dc6183b0..539116e85c 100644 --- a/thirdparty/freetype/src/base/ftobjs.c +++ b/thirdparty/freetype/src/base/ftobjs.c @@ -4,7 +4,7 @@ /* */ /* The FreeType private base classes (body). */ /* */ -/* Copyright 1996-2016 by */ +/* Copyright 1996-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -37,6 +37,9 @@ #include FT_SERVICE_KERNING_H #include FT_SERVICE_TRUETYPE_ENGINE_H +#include FT_AUTOHINTER_H +#include FT_CFF_DRIVER_H + #ifdef FT_CONFIG_OPTION_MAC_FONTS #include "ftbase.h" #endif @@ -79,6 +82,15 @@ #define GRID_FIT_METRICS + /* forward declaration */ + static FT_Error + ft_open_face_internal( FT_Library library, + const FT_Open_Args* args, + FT_Long face_index, + FT_Face *aface, + FT_Bool test_mac_fonts ); + + FT_BASE_DEF( FT_Pointer ) ft_service_list_lookup( FT_ServiceDesc service_descriptors, const char* service_id ) @@ -453,7 +465,8 @@ Exit: - FT_TRACE4(( "FT_New_GlyphSlot: Return %d\n", error )); + FT_TRACE4(( "FT_New_GlyphSlot: Return 0x%x\n", error )); + return error; } @@ -641,6 +654,9 @@ load_flags &= ~FT_LOAD_RENDER; } + if ( load_flags & FT_LOAD_BITMAP_METRICS_ONLY ) + load_flags &= ~FT_LOAD_RENDER; + /* * Determine whether we need to auto-hint or not. * The general rules are: @@ -686,7 +702,7 @@ /* check the size of the `fpgm' and `prep' tables, too -- */ /* the assumption is that there don't exist real TTFs where */ /* both `fpgm' and `prep' tables are missing */ - if ( ( mode == FT_RENDER_MODE_LIGHT && + if ( ( mode == FT_RENDER_MODE_LIGHT && !FT_DRIVER_HINTS_LIGHTLY( driver ) ) || ( FT_IS_SFNT( face ) && ttface->num_locations && @@ -1102,7 +1118,7 @@ end = first + face->num_charmaps; /* points after the last one */ - for ( cur = first; cur < end; ++cur ) + for ( cur = first; cur < end; cur++ ) { if ( cur[0]->platform_id == TT_PLATFORM_APPLE_UNICODE && cur[0]->encoding_id == TT_APPLE_ID_VARIANT_SELECTOR && @@ -1173,6 +1189,8 @@ } #endif + face->internal->random_seed = -1; + if ( clazz->init_face ) error = clazz->init_face( *astream, face, @@ -1237,7 +1255,7 @@ args.pathname = (char*)pathname; args.stream = NULL; - return FT_Open_Face( library, &args, face_index, aface ); + return ft_open_face_internal( library, &args, face_index, aface, 1 ); } #endif @@ -1264,7 +1282,7 @@ args.memory_size = file_size; args.stream = NULL; - return FT_Open_Face( library, &args, face_index, aface ); + return ft_open_face_internal( library, &args, face_index, aface, 1 ); } @@ -1299,7 +1317,7 @@ /* Finalizer for a memory stream; gets called by FT_Done_Face(). */ /* It frees the memory it uses. */ - /* From ftmac.c. */ + /* From `ftmac.c'. */ static void memory_stream_close( FT_Stream stream ) { @@ -1315,7 +1333,7 @@ /* Create a new memory stream from a buffer and a size. */ - /* From ftmac.c. */ + /* From `ftmac.c'. */ static FT_Error new_memory_stream( FT_Library library, FT_Byte* base, @@ -1335,7 +1353,7 @@ return FT_THROW( Invalid_Argument ); *astream = NULL; - memory = library->memory; + memory = library->memory; if ( FT_NEW( stream ) ) goto Exit; @@ -1351,7 +1369,7 @@ /* Create a new FT_Face given a buffer and a driver name. */ - /* from ftmac.c */ + /* From `ftmac.c'. */ FT_LOCAL_DEF( FT_Error ) open_face_from_buffer( FT_Library library, FT_Byte* base, @@ -1377,11 +1395,11 @@ return error; } - args.flags = FT_OPEN_STREAM; + args.flags = FT_OPEN_STREAM; args.stream = stream; if ( driver_name ) { - args.flags = args.flags | FT_OPEN_DRIVER; + args.flags = args.flags | FT_OPEN_DRIVER; args.driver = FT_Get_Module( library, driver_name ); } @@ -1395,9 +1413,9 @@ face_index &= 0x7FFF0000L; /* retain GX data */ #endif - error = FT_Open_Face( library, &args, face_index, aface ); + error = ft_open_face_internal( library, &args, face_index, aface, 0 ); - if ( error == FT_Err_Ok ) + if ( !error ) (*aface)->face_flags &= ~FT_FACE_FLAG_EXTERNAL_STREAM; else #ifdef FT_MACINTOSH @@ -1589,6 +1607,7 @@ { FT_Error error = FT_ERR( Cannot_Open_Resource ); FT_Memory memory = library->memory; + FT_Byte* pfb_data = NULL; int i, type, flags; FT_ULong len; @@ -1604,12 +1623,12 @@ /* Find the length of all the POST resources, concatenated. Assume */ /* worst case (each resource in its own section). */ pfb_len = 0; - for ( i = 0; i < resource_cnt; ++i ) + for ( i = 0; i < resource_cnt; i++ ) { error = FT_Stream_Seek( stream, (FT_ULong)offsets[i] ); if ( error ) goto Exit; - if ( FT_READ_ULONG( temp ) ) + if ( FT_READ_ULONG( temp ) ) /* actually LONG */ goto Exit; /* FT2 allocator takes signed long buffer length, @@ -1617,12 +1636,15 @@ */ FT_TRACE4(( " POST fragment #%d: length=0x%08x" " total pfb_len=0x%08x\n", - i, temp, pfb_len + temp + 6)); + i, temp, pfb_len + temp + 6 )); + if ( FT_MAC_RFORK_MAX_LEN < temp || FT_MAC_RFORK_MAX_LEN - temp < pfb_len + 6 ) { FT_TRACE2(( " MacOS resource length cannot exceed" - " 0x%08x\n", FT_MAC_RFORK_MAX_LEN )); + " 0x%08x\n", + FT_MAC_RFORK_MAX_LEN )); + error = FT_THROW( Invalid_Offset ); goto Exit; } @@ -1630,15 +1652,20 @@ 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(( " 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 )); + " 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; @@ -1651,9 +1678,10 @@ pfb_pos = 6; pfb_lenpos = 2; - len = 0; + len = 0; type = 1; - for ( i = 0; i < resource_cnt; ++i ) + + for ( i = 0; i < resource_cnt; i++ ) { error = FT_Stream_Seek( stream, (FT_ULong)offsets[i] ); if ( error ) @@ -1672,18 +1700,24 @@ if ( FT_READ_USHORT( flags ) ) goto Exit2; - FT_TRACE3(( "POST fragment[%d]: offsets=0x%08x, rlen=0x%08x, flags=0x%04x\n", - i, offsets[i], rlen, flags )); + + 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() */ + + /* 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 )); + FT_TRACE3(( " Skip POST fragment #%d because it is a comment\n", + i )); continue; } - /* the flags are part of the resource, so rlen >= 2. */ + /* the flags are part of the resource, so rlen >= 2, */ /* but some fonts declare rlen = 0 for empty fragment */ if ( rlen > 2 ) rlen -= 2; @@ -1695,9 +1729,12 @@ else { FT_TRACE3(( " Write POST fragment #%d header (4-byte) to buffer" - " %p + 0x%08x\n", i, pfb_data, pfb_lenpos )); + " %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 ); pfb_data[pfb_lenpos + 1] = (FT_Byte)( len >> 8 ); pfb_data[pfb_lenpos + 2] = (FT_Byte)( len >> 16 ); @@ -1707,13 +1744,16 @@ break; FT_TRACE3(( " Write POST fragment #%d header (6-byte) to buffer" - " %p + 0x%08x\n", i, pfb_data, pfb_pos )); + " %p + 0x%08x\n", + i, pfb_data, pfb_pos )); + if ( pfb_pos + 6 > pfb_len + 2 ) goto Exit2; + pfb_data[pfb_pos++] = 0x80; type = flags >> 8; - len = rlen; + len = rlen; pfb_data[pfb_pos++] = (FT_Byte)type; pfb_lenpos = pfb_pos; @@ -1727,14 +1767,18 @@ goto Exit2; FT_TRACE3(( " Load POST fragment #%d (%d byte) to buffer" - " %p + 0x%08x\n", i, rlen, pfb_data, pfb_pos )); + " %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; @@ -1755,11 +1799,12 @@ aface ); Exit2: - if ( error == FT_ERR( Array_Too_Large ) ) + if ( FT_ERR_EQ( error, Array_Too_Large ) ) FT_TRACE2(( " Abort due to too-short buffer to store" " all POST fragments\n" )); - else if ( error == FT_ERR( Invalid_Offset ) ) + else if ( FT_ERR_EQ( error, 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 ); @@ -1803,7 +1848,7 @@ if ( FT_READ_LONG( rlen ) ) goto Exit; - if ( rlen == -1 ) + if ( rlen < 1 ) return FT_THROW( Cannot_Open_Resource ); if ( (FT_ULong)rlen > FT_MAC_RFORK_MAX_LEN ) return FT_THROW( Invalid_Offset ); @@ -1856,19 +1901,19 @@ { FT_Memory memory = library->memory; FT_Error error; - FT_Long map_offset, rdara_pos; + FT_Long map_offset, rdata_pos; FT_Long *data_offsets; FT_Long count; error = FT_Raccess_Get_HeaderInfo( library, stream, resource_offset, - &map_offset, &rdara_pos ); + &map_offset, &rdata_pos ); if ( error ) return error; /* POST resources must be sorted to concatenate properly */ error = FT_Raccess_Get_DataOffsets( library, stream, - map_offset, rdara_pos, + map_offset, rdata_pos, TTAG_POST, TRUE, &data_offsets, &count ); if ( !error ) @@ -1885,7 +1930,7 @@ /* sfnt resources should not be sorted to preserve the face order by QuickDraw API */ error = FT_Raccess_Get_DataOffsets( library, stream, - map_offset, rdara_pos, + map_offset, rdata_pos, TTAG_sfnt, FALSE, &data_offsets, &count ); if ( !error ) @@ -1918,7 +1963,7 @@ FT_Long dlen, offset; - if ( NULL == stream ) + if ( !stream ) return FT_THROW( Invalid_Stream_Operation ); error = FT_Stream_Seek( stream, 0 ); @@ -1992,13 +2037,15 @@ { FT_TRACE3(( "Skip rule %d: darwin vfs resource fork" " is already checked and" - " no font is found\n", i )); + " no font is found\n", + i )); continue; } if ( errors[i] ) { - FT_TRACE3(( "Error[%d] has occurred in rule %d\n", errors[i], i )); + FT_TRACE3(( "Error 0x%x has occurred in rule %d\n", + errors[i], i )); continue; } @@ -2107,6 +2154,17 @@ const FT_Open_Args* args, FT_Long face_index, FT_Face *aface ) + { + return ft_open_face_internal( library, args, face_index, aface, 1 ); + } + + + static FT_Error + ft_open_face_internal( FT_Library library, + const FT_Open_Args* args, + FT_Long face_index, + FT_Face *aface, + FT_Bool test_mac_fonts ) { FT_Error error; FT_Driver driver = NULL; @@ -2118,6 +2176,23 @@ FT_Module* cur; FT_Module* limit; +#ifndef FT_CONFIG_OPTION_MAC_FONTS + FT_UNUSED( test_mac_fonts ); +#endif + + +#ifdef FT_DEBUG_LEVEL_TRACE + FT_TRACE3(( "FT_Open_Face: " )); + if ( face_index < 0 ) + FT_TRACE3(( "Requesting number of faces and named instances\n")); + else + { + FT_TRACE3(( "Requesting face %ld", face_index & 0xFFFFL )); + if ( face_index & 0x7FFF0000L ) + FT_TRACE3(( ", named instance %ld", face_index >> 16 )); + FT_TRACE3(( "\n" )); + } +#endif /* test for valid `library' delayed to `FT_Stream_New' */ @@ -2195,7 +2270,8 @@ goto Success; #ifdef FT_CONFIG_OPTION_MAC_FONTS - if ( ft_strcmp( cur[0]->clazz->module_name, "truetype" ) == 0 && + if ( test_mac_fonts && + ft_strcmp( cur[0]->clazz->module_name, "truetype" ) == 0 && FT_ERR_EQ( error, Table_Missing ) ) { /* TrueType but essential tables are missing */ @@ -2232,16 +2308,20 @@ goto Fail2; #if !defined( FT_MACINTOSH ) && defined( FT_CONFIG_OPTION_MAC_FONTS ) - error = load_mac_face( library, stream, face_index, aface, args ); - if ( !error ) + if ( test_mac_fonts ) { - /* We don't want to go to Success here. We've already done that. */ - /* On the other hand, if we succeeded we still need to close this */ - /* stream (we opened a different stream which extracted the */ - /* interesting information out of this stream here. That stream */ - /* will still be open and the face will point to it). */ - FT_Stream_Free( stream, external_stream ); - return error; + error = load_mac_face( library, stream, face_index, aface, args ); + if ( !error ) + { + /* We don't want to go to Success here. We've already done */ + /* that. On the other hand, if we succeeded we still need to */ + /* close this stream (we opened a different stream which */ + /* extracted the interesting information out of this stream */ + /* here. That stream will still be open and the face will */ + /* point to it). */ + FT_Stream_Free( stream, external_stream ); + return error; + } } if ( FT_ERR_NEQ( error, Unknown_File_Format ) ) @@ -2314,11 +2394,24 @@ if ( bsize->height < 0 ) - bsize->height = (FT_Short)-bsize->height; + bsize->height = -bsize->height; if ( bsize->x_ppem < 0 ) - bsize->x_ppem = (FT_Short)-bsize->x_ppem; + bsize->x_ppem = -bsize->x_ppem; if ( bsize->y_ppem < 0 ) bsize->y_ppem = -bsize->y_ppem; + + /* check whether negation actually has worked */ + if ( bsize->height < 0 || bsize->x_ppem < 0 || bsize->y_ppem < 0 ) + { + FT_TRACE0(( "FT_Open_Face:" + " Invalid bitmap dimensions for strike %d," + " now disabled\n", i )); + bsize->width = 0; + bsize->height = 0; + bsize->size = 0; + bsize->x_ppem = 0; + bsize->y_ppem = 0; + } } } @@ -2336,6 +2429,12 @@ internal->transform_delta.y = 0; internal->refcount = 1; + + internal->no_stem_darkening = -1; + +#ifdef FT_CONFIG_OPTION_SUBPIXEL_RENDERING + ft_memset( internal->lcd_weights, 0, FT_LCD_FILTER_FIVE_TAPS ); +#endif } if ( aface ) @@ -2352,7 +2451,20 @@ destroy_face( memory, face, driver ); Exit: - FT_TRACE4(( "FT_Open_Face: Return %d\n", error )); +#ifdef FT_DEBUG_LEVEL_TRACE + if ( !error && face_index < 0 ) + { + FT_TRACE3(( "FT_Open_Face: The font has %ld face%s\n" + " and %ld named instance%s for face %ld\n", + face->num_faces, + face->num_faces == 1 ? "" : "s", + face->style_flags >> 16, + ( face->style_flags >> 16 ) == 1 ? "" : "s", + -face_index - 1 )); + } +#endif + + FT_TRACE4(( "FT_Open_Face: Return 0x%x\n", error )); return error; } @@ -2493,6 +2605,8 @@ FT_Size size = NULL; FT_ListNode node = NULL; + FT_Size_Internal internal = NULL; + if ( !face ) return FT_THROW( Invalid_Face_Handle ); @@ -2515,8 +2629,10 @@ size->face = face; - /* for now, do not use any internal fields in size objects */ - size->internal = NULL; + if ( FT_NEW( internal ) ) + goto Exit; + + size->internal = internal; if ( clazz->init_size ) error = clazz->init_size( size ); @@ -2618,6 +2734,9 @@ w = FT_PIX_ROUND( w ); h = FT_PIX_ROUND( h ); + if ( !w || !h ) + return FT_THROW( Invalid_Pixel_Size ); + for ( i = 0; i < face->num_fixed_sizes; i++ ) { FT_Bitmap_Size* bsize = face->available_sizes + i; @@ -2637,6 +2756,8 @@ } } + FT_TRACE3(( "FT_Match_Size: no matching bitmap strike\n" )); + return FT_THROW( Invalid_Pixel_Size ); } @@ -2939,6 +3060,10 @@ req->type >= FT_SIZE_REQUEST_TYPE_MAX ) return FT_THROW( Invalid_Argument ); + /* signal the auto-hinter to recompute its size metrics */ + /* (if requested) */ + face->size->internal->autohint_metrics.x_scale = 0; + clazz = face->driver->clazz; if ( clazz->request_size ) @@ -3356,7 +3481,7 @@ FT_CMap cmap = NULL; - if ( clazz == NULL || charmap == NULL || charmap->face == NULL ) + if ( !clazz || !charmap || !charmap->face ) return FT_THROW( Invalid_Argument ); face = charmap->face; @@ -3483,6 +3608,90 @@ } + /* documentation is in freetype.h */ + + FT_EXPORT_DEF( FT_Error ) + FT_Face_Properties( FT_Face face, + FT_UInt num_properties, + FT_Parameter* properties ) + { + FT_Error error = FT_Err_Ok; + + + if ( num_properties > 0 && !properties ) + { + error = FT_THROW( Invalid_Argument ); + goto Exit; + } + + for ( ; num_properties > 0; num_properties-- ) + { + if ( properties->tag == FT_PARAM_TAG_STEM_DARKENING ) + { + if ( properties->data ) + { + if ( *( (FT_Bool*)properties->data ) == TRUE ) + face->internal->no_stem_darkening = FALSE; + else + face->internal->no_stem_darkening = TRUE; + } + else + { + /* use module default */ + face->internal->no_stem_darkening = -1; + } + } + else if ( properties->tag == FT_PARAM_TAG_LCD_FILTER_WEIGHTS ) + { +#ifdef FT_CONFIG_OPTION_SUBPIXEL_RENDERING + if ( properties->data ) + ft_memcpy( face->internal->lcd_weights, + properties->data, + FT_LCD_FILTER_FIVE_TAPS ); + else + { + /* Value NULL indicates `no custom weights, use library */ + /* defaults', signaled by filling the weight field with zeros. */ + ft_memset( face->internal->lcd_weights, + 0, + FT_LCD_FILTER_FIVE_TAPS ); + } +#else + error = FT_THROW( Unimplemented_Feature ); + goto Exit; +#endif + } + else if ( properties->tag == FT_PARAM_TAG_RANDOM_SEED ) + { + if ( properties->data ) + { + face->internal->random_seed = *( (FT_Int32*)properties->data ); + if ( face->internal->random_seed < 0 ) + face->internal->random_seed = 0; + } + else + { + /* use module default */ + face->internal->random_seed = -1; + } + } + else + { + error = FT_THROW( Invalid_Argument ); + goto Exit; + } + + if ( error ) + break; + + properties++; + } + + Exit: + return error; + } + + /* documentation is in freetype.h */ FT_EXPORT_DEF( FT_UInt ) @@ -3501,19 +3710,21 @@ FT_CMap ucmap = FT_CMAP( face->charmap ); - if ( charmap != NULL ) + if ( charmap ) { FT_CMap vcmap = FT_CMAP( charmap ); if ( charcode > 0xFFFFFFFFUL ) { - FT_TRACE1(( "FT_Get_Char_Index: too large charcode" )); + FT_TRACE1(( "FT_Face_GetCharVariantIndex:" + " too large charcode" )); FT_TRACE1(( " 0x%x is truncated\n", charcode )); } if ( variantSelector > 0xFFFFFFFFUL ) { - FT_TRACE1(( "FT_Get_Char_Index: too large variantSelector" )); + FT_TRACE1(( "FT_Face_GetCharVariantIndex:" + " too large variantSelector" )); FT_TRACE1(( " 0x%x is truncated\n", variantSelector )); } @@ -3542,19 +3753,21 @@ FT_CharMap charmap = find_variant_selector_charmap( face ); - if ( charmap != NULL ) + if ( charmap ) { FT_CMap vcmap = FT_CMAP( charmap ); if ( charcode > 0xFFFFFFFFUL ) { - FT_TRACE1(( "FT_Get_Char_Index: too large charcode" )); + FT_TRACE1(( "FT_Face_GetCharVariantIsDefault:" + " too large charcode" )); FT_TRACE1(( " 0x%x is truncated\n", charcode )); } if ( variantSelector > 0xFFFFFFFFUL ) { - FT_TRACE1(( "FT_Get_Char_Index: too large variantSelector" )); + FT_TRACE1(( "FT_Face_GetCharVariantIsDefault:" + " too large variantSelector" )); FT_TRACE1(( " 0x%x is truncated\n", variantSelector )); } @@ -3581,7 +3794,7 @@ FT_CharMap charmap = find_variant_selector_charmap( face ); - if ( charmap != NULL ) + if ( charmap ) { FT_CMap vcmap = FT_CMAP( charmap ); FT_Memory memory = FT_FACE_MEMORY( face ); @@ -3609,7 +3822,7 @@ FT_CharMap charmap = find_variant_selector_charmap( face ); - if ( charmap != NULL ) + if ( charmap ) { FT_CMap vcmap = FT_CMAP( charmap ); FT_Memory memory = FT_FACE_MEMORY( face ); @@ -3617,7 +3830,7 @@ if ( charcode > 0xFFFFFFFFUL ) { - FT_TRACE1(( "FT_Get_Char_Index: too large charcode" )); + FT_TRACE1(( "FT_Face_GetVariantsOfChar: too large charcode" )); FT_TRACE1(( " 0x%x is truncated\n", charcode )); } @@ -3643,7 +3856,7 @@ FT_CharMap charmap = find_variant_selector_charmap( face ); - if ( charmap != NULL ) + if ( charmap ) { FT_CMap vcmap = FT_CMAP( charmap ); FT_Memory memory = FT_FACE_MEMORY( face ); @@ -3771,7 +3984,7 @@ if ( face && FT_IS_SFNT( face ) ) { FT_FACE_FIND_SERVICE( face, service, SFNT_TABLE ); - if ( service != NULL ) + if ( service ) table = service->get_table( face, tag ); } @@ -3795,7 +4008,7 @@ return FT_THROW( Invalid_Face_Handle ); FT_FACE_FIND_SERVICE( face, service, SFNT_TABLE ); - if ( service == NULL ) + if ( !service ) return FT_THROW( Unimplemented_Feature ); return service->load_table( face, tag, offset, buffer, length ); @@ -3820,7 +4033,7 @@ return FT_THROW( Invalid_Face_Handle ); FT_FACE_FIND_SERVICE( face, service, SFNT_TABLE ); - if ( service == NULL ) + if ( !service ) return FT_THROW( Unimplemented_Feature ); return service->table_info( face, table_index, tag, &offset, length ); @@ -3842,7 +4055,7 @@ face = charmap->face; FT_FACE_FIND_SERVICE( face, service, TT_CMAP ); - if ( service == NULL ) + if ( !service ) return 0; if ( service->get_cmap_info( charmap, &cmap_info )) return 0; @@ -3866,7 +4079,7 @@ face = charmap->face; FT_FACE_FIND_SERVICE( face, service, TT_CMAP ); - if ( service == NULL ) + if ( !service ) return -1; if ( service->get_cmap_info( charmap, &cmap_info )) return -1; @@ -4196,7 +4409,7 @@ if ( ft_trace_levels[trace_bitmap] >= 3 ) { /* we convert to a single bitmap format for computing the checksum */ - if ( !error ) + if ( !error && slot->bitmap.buffer ) { FT_Bitmap bitmap; FT_Error err; @@ -4475,7 +4688,8 @@ FT_BASE_DEF( FT_Pointer ) ft_module_get_service( FT_Module module, - const char* service_id ) + const char* service_id, + FT_Bool global ) { FT_Pointer result = NULL; @@ -4488,7 +4702,7 @@ if ( module->clazz->get_interface ) result = module->clazz->get_interface( module, service_id ); - if ( result == NULL ) + if ( global && !result ) { /* we didn't find it, look in all other modules then */ FT_Library library = module->library; @@ -4505,7 +4719,7 @@ if ( cur[0]->clazz->get_interface ) { result = cur[0]->clazz->get_interface( cur[0], service_id ); - if ( result != NULL ) + if ( result ) break; } } @@ -4564,7 +4778,8 @@ const FT_String* module_name, const FT_String* property_name, void* value, - FT_Bool set ) + FT_Bool set, + FT_Bool value_is_string ) { FT_Module* cur; FT_Module* limit; @@ -4634,8 +4849,13 @@ return FT_THROW( Unimplemented_Feature ); } - return set ? service->set_property( cur[0], property_name, value ) - : service->get_property( cur[0], property_name, value ); + return set ? service->set_property( cur[0], + property_name, + value, + value_is_string ) + : service->get_property( cur[0], + property_name, + value ); } @@ -4651,7 +4871,8 @@ module_name, property_name, (void*)value, - TRUE ); + TRUE, + FALSE ); } @@ -4667,10 +4888,33 @@ module_name, property_name, value, + FALSE, FALSE ); } +#ifdef FT_CONFIG_OPTION_ENVIRONMENT_PROPERTIES + + /* this variant is used for handling the FREETYPE_PROPERTIES */ + /* environment variable */ + + FT_BASE_DEF( FT_Error ) + ft_property_string_set( FT_Library library, + const FT_String* module_name, + const FT_String* property_name, + FT_String* value ) + { + return ft_property_do( library, + module_name, + property_name, + (void*)value, + TRUE, + TRUE ); + } + +#endif + + /*************************************************************************/ /*************************************************************************/ /*************************************************************************/ @@ -4926,7 +5170,8 @@ service = (FT_Service_TrueTypeEngine) ft_module_get_service( module, - FT_SERVICE_ID_TRUETYPE_ENGINE ); + FT_SERVICE_ID_TRUETYPE_ENGINE, + 0 ); if ( service ) result = service->engine_type; } diff --git a/thirdparty/freetype/src/base/ftotval.c b/thirdparty/freetype/src/base/ftotval.c index fe54e0228a..5fa098691e 100644 --- a/thirdparty/freetype/src/base/ftotval.c +++ b/thirdparty/freetype/src/base/ftotval.c @@ -4,7 +4,7 @@ /* */ /* FreeType API for validating OpenType tables (body). */ /* */ -/* Copyright 2004-2016 by */ +/* Copyright 2004-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/thirdparty/freetype/src/base/ftoutln.c b/thirdparty/freetype/src/base/ftoutln.c index fc28225c6a..464a066dcc 100644 --- a/thirdparty/freetype/src/base/ftoutln.c +++ b/thirdparty/freetype/src/base/ftoutln.c @@ -4,7 +4,7 @@ /* */ /* FreeType outline management (body). */ /* */ -/* Copyright 1996-2016 by */ +/* Copyright 1996-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -287,7 +287,7 @@ return FT_Err_Ok; Exit: - FT_TRACE5(( "FT_Outline_Decompose: Error %d\n", error )); + FT_TRACE5(( "FT_Outline_Decompose: Error 0x%x\n", error )); return error; Invalid_Outline: diff --git a/thirdparty/freetype/src/base/ftpatent.c b/thirdparty/freetype/src/base/ftpatent.c index 4861be130e..9900f99bfc 100644 --- a/thirdparty/freetype/src/base/ftpatent.c +++ b/thirdparty/freetype/src/base/ftpatent.c @@ -3,9 +3,9 @@ /* ftpatent.c */ /* */ /* FreeType API for checking patented TrueType bytecode instructions */ -/* (body). Obsolete, retained for backwards compatibility. */ +/* (body). Obsolete, retained for backward compatibility. */ /* */ -/* Copyright 2007-2016 by */ +/* Copyright 2007-2017 by */ /* David Turner. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/thirdparty/freetype/src/base/ftpfr.c b/thirdparty/freetype/src/base/ftpfr.c index 81faa529c3..5cc0b70726 100644 --- a/thirdparty/freetype/src/base/ftpfr.c +++ b/thirdparty/freetype/src/base/ftpfr.c @@ -4,7 +4,7 @@ /* */ /* FreeType API for accessing PFR-specific data (body). */ /* */ -/* Copyright 2002-2016 by */ +/* Copyright 2002-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/thirdparty/freetype/src/base/ftpic.c b/thirdparty/freetype/src/base/ftpic.c index 03769dba22..0f84fddc98 100644 --- a/thirdparty/freetype/src/base/ftpic.c +++ b/thirdparty/freetype/src/base/ftpic.c @@ -4,7 +4,7 @@ /* */ /* The FreeType position independent code services (body). */ /* */ -/* Copyright 2009-2016 by */ +/* Copyright 2009-2017 by */ /* Oran Agra and Mickey Gabel. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/thirdparty/freetype/src/base/ftrfork.c b/thirdparty/freetype/src/base/ftrfork.c index 4660c971cf..f7b81375dd 100644 --- a/thirdparty/freetype/src/base/ftrfork.c +++ b/thirdparty/freetype/src/base/ftrfork.c @@ -4,7 +4,7 @@ /* */ /* Embedded resource forks accessor (body). */ /* */ -/* Copyright 2004-2016 by */ +/* Copyright 2004-2017 by */ /* Masatake YAMATO and Redhat K.K. */ /* */ /* FT_Raccess_Get_HeaderInfo() and raccess_guess_darwin_hfsplus() are */ @@ -56,7 +56,7 @@ { FT_Error error; unsigned char head[16], head2[16]; - FT_Long map_pos, rdata_len; + FT_Long map_pos, map_len, rdata_len; int allzeros, allmatch, i; FT_Long type_list; @@ -67,12 +67,15 @@ if ( error ) return error; - error = FT_Stream_Read( stream, (FT_Byte *)head, 16 ); + error = FT_Stream_Read( stream, (FT_Byte*)head, 16 ); if ( error ) return error; /* ensure positive values */ - if ( head[0] >= 0x80 || head[4] >= 0x80 || head[8] >= 0x80 ) + if ( head[0] >= 0x80 || + head[4] >= 0x80 || + head[8] >= 0x80 || + head[12] >= 0x80 ) return FT_THROW( Unknown_File_Format ); *rdata_pos = ( head[ 0] << 24 ) | @@ -87,14 +90,36 @@ ( head[ 9] << 16 ) | ( head[10] << 8 ) | head[11]; + map_len = ( head[12] << 24 ) | + ( head[13] << 16 ) | + ( head[14] << 8 ) | + head[15]; - /* map_len = head[12] .. head[15] */ - - if ( *rdata_pos != map_pos - rdata_len || map_pos == 0 ) + /* the map must not be empty */ + if ( !map_pos ) return FT_THROW( Unknown_File_Format ); - if ( FT_LONG_MAX - rfork_offset < *rdata_pos || - FT_LONG_MAX - rfork_offset < map_pos ) + /* check whether rdata and map overlap */ + if ( *rdata_pos < map_pos ) + { + if ( *rdata_pos > map_pos - rdata_len ) + return FT_THROW( Unknown_File_Format ); + } + else + { + if ( map_pos > *rdata_pos - map_len ) + return FT_THROW( Unknown_File_Format ); + } + + /* check whether end of rdata or map exceeds stream size */ + if ( FT_LONG_MAX - rdata_len < *rdata_pos || + FT_LONG_MAX - map_len < map_pos || + + FT_LONG_MAX - ( *rdata_pos + rdata_len ) < rfork_offset || + FT_LONG_MAX - ( map_pos + map_len ) < rfork_offset || + + (FT_ULong)( rfork_offset + *rdata_pos + rdata_len ) > stream->size || + (FT_ULong)( rfork_offset + map_pos + map_len ) > stream->size ) return FT_THROW( Unknown_File_Format ); *rdata_pos += rfork_offset; @@ -112,7 +137,7 @@ allzeros = 1; allmatch = 1; - for ( i = 0; i < 16; ++i ) + for ( i = 0; i < 16; i++ ) { if ( head2[i] != 0 ) allzeros = 0; @@ -124,15 +149,14 @@ /* If we have reached this point then it is probably a mac resource */ /* file. Now, does it contain any interesting resources? */ - /* Skip handle to next resource map, the file resource number, and */ - /* attributes. */ + (void)FT_STREAM_SKIP( 4 /* skip handle to next resource map */ + 2 /* skip file resource number */ + 2 ); /* skip attributes */ - if ( FT_READ_USHORT( type_list ) ) + if ( FT_READ_SHORT( type_list ) ) return error; - if ( type_list == -1 ) + if ( type_list < 0 ) return FT_THROW( Unknown_File_Format ); error = FT_Stream_Seek( stream, (FT_ULong)( map_pos + type_list ) ); @@ -181,15 +205,34 @@ if ( error ) return error; - if ( FT_READ_USHORT( cnt ) ) + if ( FT_READ_SHORT( cnt ) ) return error; cnt++; - for ( i = 0; i < cnt; ++i ) + /* `rpos' is a signed 16bit integer offset to resource records; the */ + /* size of a resource record is 12 bytes. The map header is 28 bytes, */ + /* and a type list needs 10 bytes or more. If we assume that the name */ + /* list is empty and we have only a single entry in the type list, */ + /* there can be at most */ + /* */ + /* (32768 - 28 - 10) / 12 = 2727 */ + /* */ + /* resources. */ + /* */ + /* A type list starts with a two-byte counter, followed by 10-byte */ + /* type records. Assuming that there are no resources, the number of */ + /* type records can be at most */ + /* */ + /* (32768 - 28 - 2) / 8 = 4079 */ + /* */ + if ( cnt > 4079 ) + return FT_THROW( Invalid_Table ); + + for ( i = 0; i < cnt; i++ ) { if ( FT_READ_LONG( tag_internal ) || - FT_READ_USHORT( subcnt ) || - FT_READ_USHORT( rpos ) ) + FT_READ_SHORT( subcnt ) || + FT_READ_SHORT( rpos ) ) return error; FT_TRACE2(( "Resource tags: %c%c%c%c\n", @@ -205,6 +248,11 @@ *count = subcnt + 1; rpos += map_offset; + /* a zero count might be valid in the resource specification, */ + /* however, it is completely useless to us */ + if ( *count < 1 || *count > 2727 ) + return FT_THROW( Invalid_Table ); + error = FT_Stream_Seek( stream, (FT_ULong)rpos ); if ( error ) return error; @@ -212,35 +260,44 @@ if ( FT_NEW_ARRAY( ref, *count ) ) return error; - for ( j = 0; j < *count; ++j ) + for ( j = 0; j < *count; j++ ) { - if ( FT_READ_USHORT( ref[j].res_id ) ) + if ( FT_READ_SHORT( ref[j].res_id ) ) goto Exit; - if ( FT_STREAM_SKIP( 2 ) ) /* resource name */ + if ( FT_STREAM_SKIP( 2 ) ) /* resource name offset */ goto Exit; - if ( FT_READ_LONG( temp ) ) + if ( FT_READ_LONG( temp ) ) /* attributes (8bit), offset (24bit) */ goto Exit; - if ( FT_STREAM_SKIP( 4 ) ) /* mbz */ + if ( FT_STREAM_SKIP( 4 ) ) /* mbz */ + goto Exit; + + if ( ref[j].res_id < 0 || temp < 0 ) + { + error = FT_THROW( Invalid_Table ); goto Exit; + } ref[j].offset = temp & 0xFFFFFFL; + FT_TRACE3(( " [%d]:" " resource_id=0x%04x, offset=0x%08x\n", j, ref[j].res_id, ref[j].offset )); } - if (sort_by_res_id) + if ( sort_by_res_id ) { - ft_qsort( ref, (size_t)*count, sizeof ( FT_RFork_Ref ), - ( int(*)(const void*, const void*) ) - ft_raccess_sort_ref_by_id ); + ft_qsort( ref, + (size_t)*count, + sizeof ( FT_RFork_Ref ), + ( int(*)(const void*, + const void*) )ft_raccess_sort_ref_by_id ); FT_TRACE3(( " -- sort resources by their ids --\n" )); - for ( j = 0; j < *count; ++ j ) { + + for ( j = 0; j < *count; j++ ) FT_TRACE3(( " [%d]:" " resource_id=0x%04x, offset=0x%08x\n", j, ref[j].res_id, ref[j].offset )); - } } if ( FT_NEW_ARRAY( offsets_internal, *count ) ) @@ -250,7 +307,7 @@ * gap between reference IDs are acceptable? * further investigation on Apple implementation is needed. */ - for ( j = 0; j < *count; ++j ) + for ( j = 0; j < *count; j++ ) offsets_internal[j] = rdata_pos + ref[j].offset; *offsets = offsets_internal; diff --git a/thirdparty/freetype/src/base/ftsnames.c b/thirdparty/freetype/src/base/ftsnames.c index ce7964118c..3609450088 100644 --- a/thirdparty/freetype/src/base/ftsnames.c +++ b/thirdparty/freetype/src/base/ftsnames.c @@ -7,7 +7,7 @@ /* */ /* This is _not_ used to retrieve glyph names! */ /* */ -/* Copyright 1996-2016 by */ +/* Copyright 1996-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -20,6 +20,8 @@ #include <ft2build.h> +#include FT_INTERNAL_DEBUG_H + #include FT_SFNT_NAMES_H #include FT_INTERNAL_TRUETYPE_TYPES_H #include FT_INTERNAL_STREAM_H @@ -54,11 +56,11 @@ if ( idx < (FT_UInt)ttface->num_names ) { - TT_NameEntryRec* entry = ttface->name_table.names + idx; + TT_Name entry = ttface->name_table.names + idx; /* load name on demand */ - if ( entry->stringLength > 0 && entry->string == NULL ) + if ( entry->stringLength > 0 && !entry->string ) { FT_Memory memory = face->memory; FT_Stream stream = face->stream; @@ -88,6 +90,58 @@ } + /* documentation is in ftsnames.h */ + + FT_EXPORT_DEF( FT_Error ) + FT_Get_Sfnt_LangTag( FT_Face face, + FT_UInt langID, + FT_SfntLangTag *alangTag ) + { + FT_Error error = FT_ERR( Invalid_Argument ); + + + if ( alangTag && face && FT_IS_SFNT( face ) ) + { + TT_Face ttface = (TT_Face)face; + + + if ( ttface->name_table.format != 1 ) + return FT_THROW( Invalid_Table ); + + if ( langID > 0x8000U && + langID - 0x8000U < ttface->name_table.numLangTagRecords ) + { + TT_LangTag entry = ttface->name_table.langTags + + ( langID - 0x8000U ); + + + /* load name on demand */ + if ( entry->stringLength > 0 && !entry->string ) + { + FT_Memory memory = face->memory; + FT_Stream stream = face->stream; + + + if ( FT_NEW_ARRAY ( entry->string, entry->stringLength ) || + FT_STREAM_SEEK( entry->stringOffset ) || + FT_STREAM_READ( entry->string, entry->stringLength ) ) + { + FT_FREE( entry->string ); + entry->stringLength = 0; + } + } + + alangTag->string = (FT_Byte*)entry->string; + alangTag->string_len = entry->stringLength; + + error = FT_Err_Ok; + } + } + + return error; + } + + #endif /* TT_CONFIG_OPTION_SFNT_NAMES */ diff --git a/thirdparty/freetype/src/base/ftstream.c b/thirdparty/freetype/src/base/ftstream.c index bb512a7ccb..a3f8c8b3c9 100644 --- a/thirdparty/freetype/src/base/ftstream.c +++ b/thirdparty/freetype/src/base/ftstream.c @@ -4,7 +4,7 @@ /* */ /* I/O stream support (body). */ /* */ -/* Copyright 2000-2016 by */ +/* Copyright 2000-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/thirdparty/freetype/src/base/ftstroke.c b/thirdparty/freetype/src/base/ftstroke.c index 4f3c4937b5..d32de0d62b 100644 --- a/thirdparty/freetype/src/base/ftstroke.c +++ b/thirdparty/freetype/src/base/ftstroke.c @@ -4,7 +4,7 @@ /* */ /* FreeType path stroker (body). */ /* */ -/* Copyright 2002-2016 by */ +/* Copyright 2002-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/thirdparty/freetype/src/base/ftsynth.c b/thirdparty/freetype/src/base/ftsynth.c index 4b66a33c3f..66dae6037a 100644 --- a/thirdparty/freetype/src/base/ftsynth.c +++ b/thirdparty/freetype/src/base/ftsynth.c @@ -4,7 +4,7 @@ /* */ /* FreeType synthesizing code for emboldening and slanting (body). */ /* */ -/* Copyright 2000-2016 by */ +/* Copyright 2000-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -130,7 +130,7 @@ if ( ( ystr >> 6 ) > FT_INT_MAX || ( ystr >> 6 ) < FT_INT_MIN ) { FT_TRACE1(( "FT_GlyphSlot_Embolden:" )); - FT_TRACE1(( "too strong embolding parameter ystr=%d\n", ystr )); + FT_TRACE1(( "too strong emboldening parameter ystr=%d\n", ystr )); return; } error = FT_GlyphSlot_Own_Bitmap( slot ); diff --git a/thirdparty/freetype/src/base/ftsystem.c b/thirdparty/freetype/src/base/ftsystem.c index ac1f01c8bc..324f949a49 100644 --- a/thirdparty/freetype/src/base/ftsystem.c +++ b/thirdparty/freetype/src/base/ftsystem.c @@ -4,7 +4,7 @@ /* */ /* ANSI-specific FreeType low-level system interface (body). */ /* */ -/* Copyright 1996-2016 by */ +/* Copyright 1996-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/thirdparty/freetype/src/base/fttrigon.c b/thirdparty/freetype/src/base/fttrigon.c index 7b582c8a3d..7a4d17c829 100644 --- a/thirdparty/freetype/src/base/fttrigon.c +++ b/thirdparty/freetype/src/base/fttrigon.c @@ -4,7 +4,7 @@ /* */ /* FreeType trigonometric functions (body). */ /* */ -/* Copyright 2001-2016 by */ +/* Copyright 2001-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/thirdparty/freetype/src/base/fttype1.c b/thirdparty/freetype/src/base/fttype1.c index 5c0fce8686..4d16a6371a 100644 --- a/thirdparty/freetype/src/base/fttype1.c +++ b/thirdparty/freetype/src/base/fttype1.c @@ -4,7 +4,7 @@ /* */ /* FreeType utility file for PS names support (body). */ /* */ -/* Copyright 2002-2016 by */ +/* Copyright 2002-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/thirdparty/freetype/src/base/ftutil.c b/thirdparty/freetype/src/base/ftutil.c index fad7d1a5fb..dccc209f4d 100644 --- a/thirdparty/freetype/src/base/ftutil.c +++ b/thirdparty/freetype/src/base/ftutil.c @@ -4,7 +4,7 @@ /* */ /* FreeType utility file for memory and list management (body). */ /* */ -/* Copyright 2002-2016 by */ +/* Copyright 2002-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -74,7 +74,7 @@ if ( size > 0 ) { block = memory->alloc( memory, size ); - if ( block == NULL ) + if ( !block ) error = FT_THROW( Out_Of_Memory ); } else if ( size < 0 ) @@ -141,7 +141,7 @@ } else if ( cur_count == 0 ) { - FT_ASSERT( block == NULL ); + FT_ASSERT( !block ); block = ft_mem_alloc( memory, new_count*item_size, &error ); } @@ -153,7 +153,7 @@ block2 = memory->realloc( memory, cur_size, new_size, block ); - if ( block2 == NULL ) + if ( !block2 ) error = FT_THROW( Out_Of_Memory ); else block = block2; diff --git a/thirdparty/freetype/src/base/ftwinfnt.c b/thirdparty/freetype/src/base/ftwinfnt.c index 89e9155098..05baa02da6 100644 --- a/thirdparty/freetype/src/base/ftwinfnt.c +++ b/thirdparty/freetype/src/base/ftwinfnt.c @@ -4,7 +4,7 @@ /* */ /* FreeType API for accessing Windows FNT specific info (body). */ /* */ -/* Copyright 2003-2016 by */ +/* Copyright 2003-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/thirdparty/freetype/src/base/rules.mk b/thirdparty/freetype/src/base/rules.mk index aa424c5463..2a1e93cb00 100644 --- a/thirdparty/freetype/src/base/rules.mk +++ b/thirdparty/freetype/src/base/rules.mk @@ -3,7 +3,7 @@ # -# Copyright 1996-2016 by +# Copyright 1996-2017 by # David Turner, Robert Wilhelm, and Werner Lemberg. # # This file is part of the FreeType project, and may only be used, modified, diff --git a/thirdparty/freetype/src/bdf/bdf.c b/thirdparty/freetype/src/bdf/bdf.c index f95fb76225..e54df6649b 100644 --- a/thirdparty/freetype/src/bdf/bdf.c +++ b/thirdparty/freetype/src/bdf/bdf.c @@ -24,9 +24,10 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#define FT_MAKE_OPTION_SINGLE_OBJECT +#define FT_MAKE_OPTION_SINGLE_OBJECT #include <ft2build.h> + #include "bdflib.c" #include "bdfdrivr.c" diff --git a/thirdparty/freetype/src/bdf/bdfdrivr.c b/thirdparty/freetype/src/bdf/bdfdrivr.c index a381cf68f5..a2242be014 100644 --- a/thirdparty/freetype/src/bdf/bdfdrivr.c +++ b/thirdparty/freetype/src/bdf/bdfdrivr.c @@ -276,7 +276,7 @@ THE SOFTWARE. len = lengths[nn]; - if ( src == NULL ) + if ( !src ) continue; /* separate elements with a space */ @@ -423,7 +423,7 @@ THE SOFTWARE. else bdfface->family_name = NULL; - if ( ( error = bdf_interpret_style( face ) ) != 0 ) + if ( FT_SET_ERROR( bdf_interpret_style( face ) ) ) goto Exit; /* the number of glyphs (with one slot for the undefined glyph */ @@ -439,7 +439,7 @@ THE SOFTWARE. FT_Short resolution_x = 0, resolution_y = 0; - FT_MEM_ZERO( bsize, sizeof ( FT_Bitmap_Size ) ); + FT_ZERO( bsize ); bsize->height = (FT_Short)( font->font_ascent + font->font_descent ); @@ -866,10 +866,10 @@ THE SOFTWARE. 0x10000L, 0x20000L, - 0, /* module-specific interface */ + NULL, /* module-specific interface */ - 0, /* FT_Module_Constructor module_init */ - 0, /* FT_Module_Destructor module_done */ + NULL, /* FT_Module_Constructor module_init */ + NULL, /* FT_Module_Destructor module_done */ bdf_driver_requester /* FT_Module_Requester get_interface */ }, @@ -879,16 +879,16 @@ THE SOFTWARE. BDF_Face_Init, /* FT_Face_InitFunc init_face */ BDF_Face_Done, /* FT_Face_DoneFunc done_face */ - 0, /* FT_Size_InitFunc init_size */ - 0, /* FT_Size_DoneFunc done_size */ - 0, /* FT_Slot_InitFunc init_slot */ - 0, /* FT_Slot_DoneFunc done_slot */ + NULL, /* FT_Size_InitFunc init_size */ + NULL, /* FT_Size_DoneFunc done_size */ + NULL, /* FT_Slot_InitFunc init_slot */ + NULL, /* FT_Slot_DoneFunc done_slot */ BDF_Glyph_Load, /* FT_Slot_LoadFunc load_glyph */ - 0, /* FT_Face_GetKerningFunc get_kerning */ - 0, /* FT_Face_AttachFunc attach_file */ - 0, /* FT_Face_GetAdvancesFunc get_advances */ + NULL, /* FT_Face_GetKerningFunc get_kerning */ + NULL, /* FT_Face_AttachFunc attach_file */ + NULL, /* FT_Face_GetAdvancesFunc get_advances */ BDF_Size_Request, /* FT_Size_RequestFunc request_size */ BDF_Size_Select /* FT_Size_SelectFunc select_size */ diff --git a/thirdparty/freetype/src/bdf/bdflib.c b/thirdparty/freetype/src/bdf/bdflib.c index e1dce954ff..7fd95a7385 100644 --- a/thirdparty/freetype/src/bdf/bdflib.c +++ b/thirdparty/freetype/src/bdf/bdflib.c @@ -1119,7 +1119,7 @@ /* See whether this property type exists yet or not. */ /* If not, create it. */ propid = ft_hash_str_lookup( name, &(font->proptbl) ); - if ( propid == NULL ) + if ( !propid ) { error = bdf_create_property( name, BDF_ATOM, font ); if ( error ) @@ -1144,7 +1144,7 @@ } fp = font->props + font->props_size; - FT_MEM_ZERO( fp, sizeof ( bdf_property_t ) ); + FT_ZERO( fp ); font->props_size++; } @@ -2301,7 +2301,7 @@ p->font->comments[p->font->comments_len] = 0; } } - else if ( error == FT_Err_Ok ) + else if ( !error ) error = FT_THROW( Invalid_File_Format ); *font = p->font; diff --git a/thirdparty/freetype/src/bzip2/ftbzip2.c b/thirdparty/freetype/src/bzip2/ftbzip2.c new file mode 100644 index 0000000000..7fc71e7079 --- /dev/null +++ b/thirdparty/freetype/src/bzip2/ftbzip2.c @@ -0,0 +1,525 @@ +/***************************************************************************/ +/* */ +/* ftbzip2.c */ +/* */ +/* FreeType support for .bz2 compressed files. */ +/* */ +/* This optional component relies on libbz2. It should mainly be used to */ +/* parse compressed PCF fonts, as found with many X11 server */ +/* distributions. */ +/* */ +/* Copyright 2010-2017 by */ +/* Joel Klinghed. */ +/* */ +/* based on `src/gzip/ftgzip.c' */ +/* */ +/* This file is part of the FreeType project, and may only be used, */ +/* modified, and distributed under the terms of the FreeType project */ +/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ +/* this file you indicate that you have read the license and */ +/* understand and accept it fully. */ +/* */ +/***************************************************************************/ + + +#include <ft2build.h> +#include FT_INTERNAL_MEMORY_H +#include FT_INTERNAL_STREAM_H +#include FT_INTERNAL_DEBUG_H +#include FT_BZIP2_H +#include FT_CONFIG_STANDARD_LIBRARY_H + + +#include FT_MODULE_ERRORS_H + +#undef FTERRORS_H_ + +#undef FT_ERR_PREFIX +#define FT_ERR_PREFIX Bzip2_Err_ +#define FT_ERR_BASE FT_Mod_Err_Bzip2 + +#include FT_ERRORS_H + + +#ifdef FT_CONFIG_OPTION_USE_BZIP2 + +#ifdef FT_CONFIG_OPTION_PIC +#error "bzip2 code does not support PIC yet" +#endif + +#define BZ_NO_STDIO /* Do not need FILE */ +#include <bzlib.h> + + +/***************************************************************************/ +/***************************************************************************/ +/***** *****/ +/***** B Z I P 2 M E M O R Y M A N A G E M E N T *****/ +/***** *****/ +/***************************************************************************/ +/***************************************************************************/ + + /* it is better to use FreeType memory routines instead of raw + 'malloc/free' */ + + typedef void *(* alloc_func)(void*, int, int); + typedef void (* free_func)(void*, void*); + + static void* + ft_bzip2_alloc( FT_Memory memory, + int items, + int size ) + { + FT_ULong sz = (FT_ULong)size * (FT_ULong)items; + FT_Error error; + FT_Pointer p = NULL; + + + (void)FT_ALLOC( p, sz ); + return p; + } + + + static void + ft_bzip2_free( FT_Memory memory, + void* address ) + { + FT_MEM_FREE( address ); + } + + +/***************************************************************************/ +/***************************************************************************/ +/***** *****/ +/***** B Z I P 2 F I L E D E S C R I P T O R *****/ +/***** *****/ +/***************************************************************************/ +/***************************************************************************/ + +#define FT_BZIP2_BUFFER_SIZE 4096 + + typedef struct FT_BZip2FileRec_ + { + FT_Stream source; /* parent/source stream */ + FT_Stream stream; /* embedding stream */ + FT_Memory memory; /* memory allocator */ + bz_stream bzstream; /* bzlib input stream */ + + FT_Byte input[FT_BZIP2_BUFFER_SIZE]; /* input read buffer */ + + FT_Byte buffer[FT_BZIP2_BUFFER_SIZE]; /* output buffer */ + FT_ULong pos; /* position in output */ + FT_Byte* cursor; + FT_Byte* limit; + + } FT_BZip2FileRec, *FT_BZip2File; + + + /* check and skip .bz2 header - we don't support `transparent' compression */ + static FT_Error + ft_bzip2_check_header( FT_Stream stream ) + { + FT_Error error = FT_Err_Ok; + FT_Byte head[4]; + + + if ( FT_STREAM_SEEK( 0 ) || + FT_STREAM_READ( head, 4 ) ) + goto Exit; + + /* 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[2] != 0x68 ) /* only support bzip2 (huffman) */ + { + error = FT_THROW( Invalid_File_Format ); + goto Exit; + } + + Exit: + return error; + } + + + static FT_Error + ft_bzip2_file_init( FT_BZip2File zip, + FT_Stream stream, + FT_Stream source ) + { + bz_stream* bzstream = &zip->bzstream; + FT_Error error = FT_Err_Ok; + + + zip->stream = stream; + zip->source = source; + zip->memory = stream->memory; + + zip->limit = zip->buffer + FT_BZIP2_BUFFER_SIZE; + zip->cursor = zip->limit; + zip->pos = 0; + + /* check .bz2 header */ + { + stream = source; + + error = ft_bzip2_check_header( stream ); + if ( error ) + goto Exit; + + if ( FT_STREAM_SEEK( 0 ) ) + goto Exit; + } + + /* initialize bzlib */ + bzstream->bzalloc = (alloc_func)ft_bzip2_alloc; + bzstream->bzfree = (free_func) ft_bzip2_free; + bzstream->opaque = zip->memory; + + bzstream->avail_in = 0; + bzstream->next_in = (char*)zip->buffer; + + if ( BZ2_bzDecompressInit( bzstream, 0, 0 ) != BZ_OK || + !bzstream->next_in ) + error = FT_THROW( Invalid_File_Format ); + + Exit: + return error; + } + + + static void + ft_bzip2_file_done( FT_BZip2File zip ) + { + bz_stream* bzstream = &zip->bzstream; + + + BZ2_bzDecompressEnd( bzstream ); + + /* clear the rest */ + bzstream->bzalloc = NULL; + bzstream->bzfree = NULL; + bzstream->opaque = NULL; + bzstream->next_in = NULL; + bzstream->next_out = NULL; + bzstream->avail_in = 0; + bzstream->avail_out = 0; + + zip->memory = NULL; + zip->source = NULL; + zip->stream = NULL; + } + + + static FT_Error + ft_bzip2_file_reset( FT_BZip2File zip ) + { + FT_Stream stream = zip->source; + FT_Error error; + + + if ( !FT_STREAM_SEEK( 0 ) ) + { + bz_stream* bzstream = &zip->bzstream; + + + BZ2_bzDecompressEnd( bzstream ); + + bzstream->avail_in = 0; + bzstream->next_in = (char*)zip->input; + bzstream->avail_out = 0; + bzstream->next_out = (char*)zip->buffer; + + zip->limit = zip->buffer + FT_BZIP2_BUFFER_SIZE; + zip->cursor = zip->limit; + zip->pos = 0; + + BZ2_bzDecompressInit( bzstream, 0, 0 ); + } + + return error; + } + + + static FT_Error + ft_bzip2_file_fill_input( FT_BZip2File zip ) + { + bz_stream* bzstream = &zip->bzstream; + FT_Stream stream = zip->source; + FT_ULong size; + + + if ( stream->read ) + { + size = stream->read( stream, stream->pos, zip->input, + FT_BZIP2_BUFFER_SIZE ); + if ( size == 0 ) + { + zip->limit = zip->cursor; + return FT_THROW( Invalid_Stream_Operation ); + } + } + else + { + size = stream->size - stream->pos; + if ( size > FT_BZIP2_BUFFER_SIZE ) + size = FT_BZIP2_BUFFER_SIZE; + + if ( size == 0 ) + { + zip->limit = zip->cursor; + return FT_THROW( Invalid_Stream_Operation ); + } + + FT_MEM_COPY( zip->input, stream->base + stream->pos, size ); + } + stream->pos += size; + + bzstream->next_in = (char*)zip->input; + bzstream->avail_in = size; + + return FT_Err_Ok; + } + + + static FT_Error + ft_bzip2_file_fill_output( FT_BZip2File zip ) + { + bz_stream* bzstream = &zip->bzstream; + FT_Error error = FT_Err_Ok; + + + zip->cursor = zip->buffer; + bzstream->next_out = (char*)zip->cursor; + bzstream->avail_out = FT_BZIP2_BUFFER_SIZE; + + while ( bzstream->avail_out > 0 ) + { + int err; + + + if ( bzstream->avail_in == 0 ) + { + error = ft_bzip2_file_fill_input( zip ); + if ( error ) + break; + } + + err = BZ2_bzDecompress( bzstream ); + + if ( err == BZ_STREAM_END ) + { + zip->limit = (FT_Byte*)bzstream->next_out; + if ( zip->limit == zip->cursor ) + error = FT_THROW( Invalid_Stream_Operation ); + break; + } + else if ( err != BZ_OK ) + { + zip->limit = zip->cursor; + error = FT_THROW( Invalid_Stream_Operation ); + break; + } + } + + return error; + } + + + /* fill output buffer; `count' must be <= FT_BZIP2_BUFFER_SIZE */ + static FT_Error + ft_bzip2_file_skip_output( FT_BZip2File zip, + FT_ULong count ) + { + FT_Error error = FT_Err_Ok; + FT_ULong delta; + + + for (;;) + { + delta = (FT_ULong)( zip->limit - zip->cursor ); + if ( delta >= count ) + delta = count; + + zip->cursor += delta; + zip->pos += delta; + + count -= delta; + if ( count == 0 ) + break; + + error = ft_bzip2_file_fill_output( zip ); + if ( error ) + break; + } + + return error; + } + + + static FT_ULong + ft_bzip2_file_io( FT_BZip2File zip, + FT_ULong pos, + FT_Byte* buffer, + FT_ULong count ) + { + FT_ULong result = 0; + FT_Error error; + + + /* Reset inflate stream if we're seeking backwards. */ + /* Yes, that is not too efficient, but it saves memory :-) */ + if ( pos < zip->pos ) + { + error = ft_bzip2_file_reset( zip ); + if ( error ) + goto Exit; + } + + /* skip unwanted bytes */ + if ( pos > zip->pos ) + { + error = ft_bzip2_file_skip_output( zip, (FT_ULong)( pos - zip->pos ) ); + if ( error ) + goto Exit; + } + + if ( count == 0 ) + goto Exit; + + /* now read the data */ + for (;;) + { + FT_ULong delta; + + + delta = (FT_ULong)( zip->limit - zip->cursor ); + if ( delta >= count ) + delta = count; + + FT_MEM_COPY( buffer, zip->cursor, delta ); + buffer += delta; + result += delta; + zip->cursor += delta; + zip->pos += delta; + + count -= delta; + if ( count == 0 ) + break; + + error = ft_bzip2_file_fill_output( zip ); + if ( error ) + break; + } + + Exit: + return result; + } + + +/***************************************************************************/ +/***************************************************************************/ +/***** *****/ +/***** B Z E M B E D D I N G S T R E A M *****/ +/***** *****/ +/***************************************************************************/ +/***************************************************************************/ + + static void + ft_bzip2_stream_close( FT_Stream stream ) + { + FT_BZip2File zip = (FT_BZip2File)stream->descriptor.pointer; + FT_Memory memory = stream->memory; + + + if ( zip ) + { + /* finalize bzip file descriptor */ + ft_bzip2_file_done( zip ); + + FT_FREE( zip ); + + stream->descriptor.pointer = NULL; + } + } + + + static unsigned long + ft_bzip2_stream_io( FT_Stream stream, + unsigned long offset, + unsigned char* buffer, + unsigned long count ) + { + FT_BZip2File zip = (FT_BZip2File)stream->descriptor.pointer; + + + return ft_bzip2_file_io( zip, offset, buffer, count ); + } + + + FT_EXPORT_DEF( FT_Error ) + FT_Stream_OpenBzip2( FT_Stream stream, + FT_Stream source ) + { + FT_Error error; + 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 + */ + error = ft_bzip2_check_header( source ); + if ( error ) + goto Exit; + + FT_ZERO( stream ); + stream->memory = memory; + + if ( !FT_QNEW( zip ) ) + { + error = ft_bzip2_file_init( zip, stream, source ); + if ( error ) + { + FT_FREE( zip ); + goto Exit; + } + + stream->descriptor.pointer = zip; + } + + stream->size = 0x7FFFFFFFL; /* don't know the real size! */ + stream->pos = 0; + stream->base = 0; + stream->read = ft_bzip2_stream_io; + stream->close = ft_bzip2_stream_close; + + Exit: + return error; + } + +#else /* !FT_CONFIG_OPTION_USE_BZIP2 */ + + FT_EXPORT_DEF( FT_Error ) + FT_Stream_OpenBzip2( FT_Stream stream, + FT_Stream source ) + { + FT_UNUSED( stream ); + FT_UNUSED( source ); + + return FT_THROW( Unimplemented_Feature ); + } + +#endif /* !FT_CONFIG_OPTION_USE_BZIP2 */ + + +/* END */ diff --git a/thirdparty/freetype/src/bzip2/rules.mk b/thirdparty/freetype/src/bzip2/rules.mk new file mode 100644 index 0000000000..f63ddc4d34 --- /dev/null +++ b/thirdparty/freetype/src/bzip2/rules.mk @@ -0,0 +1,64 @@ +# +# FreeType 2 BZIP2 support configuration rules +# + +# Copyright 2010-2017 by +# Joel Klinghed. +# +# based on `src/lzw/rules.mk' +# +# 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. + + +# BZIP2 driver directory +# +BZIP2_DIR := $(SRC_DIR)/bzip2 + + +# compilation flags for the driver +# +BZIP2_COMPILE := $(CC) $(ANSIFLAGS) \ + $(INCLUDE_FLAGS) \ + $(FT_CFLAGS) + + +# BZIP2 support sources (i.e., C files) +# +BZIP2_DRV_SRC := $(BZIP2_DIR)/ftbzip2.c + +# BZIP2 driver object(s) +# +# BZIP2_DRV_OBJ_M is used during `multi' builds +# BZIP2_DRV_OBJ_S is used during `single' builds +# +BZIP2_DRV_OBJ_M := $(OBJ_DIR)/ftbzip2.$O +BZIP2_DRV_OBJ_S := $(OBJ_DIR)/ftbzip2.$O + +# BZIP2 support source file for single build +# +BZIP2_DRV_SRC_S := $(BZIP2_DIR)/ftbzip2.c + + +# BZIP2 support - single object +# +$(BZIP2_DRV_OBJ_S): $(BZIP2_DRV_SRC_S) $(BZIP2_DRV_SRC) $(FREETYPE_H) $(BZIP2_DRV_H) + $(BZIP2_COMPILE) $T$(subst /,$(COMPILER_SEP),$@ $(BZIP2_DRV_SRC_S)) + + +# BZIP2 support - multiple objects +# +$(OBJ_DIR)/%.$O: $(BZIP2_DIR)/%.c $(FREETYPE_H) $(BZIP2_DRV_H) + $(BZIP2_COMPILE) $T$(subst /,$(COMPILER_SEP),$@ $<) + + +# update main driver object lists +# +DRV_OBJS_S += $(BZIP2_DRV_OBJ_S) +DRV_OBJS_M += $(BZIP2_DRV_OBJ_M) + + +# EOF diff --git a/thirdparty/freetype/src/cache/ftcache.c b/thirdparty/freetype/src/cache/ftcache.c index 50941df4c4..8226188314 100644 --- a/thirdparty/freetype/src/cache/ftcache.c +++ b/thirdparty/freetype/src/cache/ftcache.c @@ -4,7 +4,7 @@ /* */ /* The FreeType Caching sub-system (body only). */ /* */ -/* Copyright 2000-2016 by */ +/* Copyright 2000-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -17,15 +17,16 @@ #define FT_MAKE_OPTION_SINGLE_OBJECT - #include <ft2build.h> -#include "ftcmru.c" -#include "ftcmanag.c" + +#include "ftcbasic.c" #include "ftccache.c" #include "ftccmap.c" #include "ftcglyph.c" #include "ftcimage.c" +#include "ftcmanag.c" +#include "ftcmru.c" #include "ftcsbits.c" -#include "ftcbasic.c" + /* END */ diff --git a/thirdparty/freetype/src/cache/ftcbasic.c b/thirdparty/freetype/src/cache/ftcbasic.c index 8e6de8c41c..289bd5c430 100644 --- a/thirdparty/freetype/src/cache/ftcbasic.c +++ b/thirdparty/freetype/src/cache/ftcbasic.c @@ -4,7 +4,7 @@ /* */ /* The FreeType basic cache interface (body). */ /* */ -/* Copyright 2003-2016 by */ +/* Copyright 2003-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -237,12 +237,14 @@ { { sizeof ( FTC_BasicFamilyRec ), - ftc_basic_family_compare, - ftc_basic_family_init, - 0, /* FTC_MruNode_ResetFunc */ - 0 /* FTC_MruNode_DoneFunc */ + + ftc_basic_family_compare, /* FTC_MruNode_CompareFunc node_compare */ + ftc_basic_family_init, /* FTC_MruNode_InitFunc node_init */ + NULL, /* FTC_MruNode_ResetFunc node_reset */ + NULL /* FTC_MruNode_DoneFunc node_done */ }, - ftc_basic_family_load_glyph + + ftc_basic_family_load_glyph /* FTC_IFamily_LoadGlyphFunc family_load_glyph */ }; @@ -250,16 +252,17 @@ const FTC_GCacheClassRec ftc_basic_image_cache_class = { { - ftc_inode_new, - ftc_inode_weight, - ftc_gnode_compare, - ftc_basic_gnode_compare_faceid, - ftc_inode_free, + ftc_inode_new, /* FTC_Node_NewFunc node_new */ + ftc_inode_weight, /* FTC_Node_WeightFunc node_weight */ + ftc_gnode_compare, /* FTC_Node_CompareFunc node_compare */ + ftc_basic_gnode_compare_faceid, /* FTC_Node_CompareFunc node_remove_faceid */ + ftc_inode_free, /* FTC_Node_FreeFunc node_free */ sizeof ( FTC_GCacheRec ), - ftc_gcache_init, - ftc_gcache_done + ftc_gcache_init, /* FTC_Cache_InitFunc cache_init */ + ftc_gcache_done /* FTC_Cache_DoneFunc cache_done */ }, + (FTC_MruListClass)&ftc_basic_image_family_class }; @@ -419,11 +422,12 @@ { { sizeof ( FTC_BasicFamilyRec ), - ftc_basic_family_compare, - ftc_basic_family_init, - 0, /* FTC_MruNode_ResetFunc */ - 0 /* FTC_MruNode_DoneFunc */ + ftc_basic_family_compare, /* FTC_MruNode_CompareFunc node_compare */ + ftc_basic_family_init, /* FTC_MruNode_InitFunc node_init */ + NULL, /* FTC_MruNode_ResetFunc node_reset */ + NULL /* FTC_MruNode_DoneFunc node_done */ }, + ftc_basic_family_get_count, ftc_basic_family_load_bitmap }; @@ -433,16 +437,17 @@ const FTC_GCacheClassRec ftc_basic_sbit_cache_class = { { - ftc_snode_new, - ftc_snode_weight, - ftc_snode_compare, - ftc_basic_gnode_compare_faceid, - ftc_snode_free, + ftc_snode_new, /* FTC_Node_NewFunc node_new */ + ftc_snode_weight, /* FTC_Node_WeightFunc node_weight */ + ftc_snode_compare, /* FTC_Node_CompareFunc node_compare */ + ftc_basic_gnode_compare_faceid, /* FTC_Node_CompareFunc node_remove_faceid */ + ftc_snode_free, /* FTC_Node_FreeFunc node_free */ sizeof ( FTC_GCacheRec ), - ftc_gcache_init, - ftc_gcache_done + ftc_gcache_init, /* FTC_Cache_InitFunc cache_init */ + ftc_gcache_done /* FTC_Cache_DoneFunc cache_done */ }, + (FTC_MruListClass)&ftc_basic_sbit_family_class }; diff --git a/thirdparty/freetype/src/cache/ftccache.c b/thirdparty/freetype/src/cache/ftccache.c index 3b1a4bc7e4..37dc3abb1d 100644 --- a/thirdparty/freetype/src/cache/ftccache.c +++ b/thirdparty/freetype/src/cache/ftccache.c @@ -4,7 +4,7 @@ /* */ /* The FreeType internal cache interface (body). */ /* */ -/* Copyright 2000-2016 by */ +/* Copyright 2000-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -147,7 +147,7 @@ for (;;) { node = *pnode; - if ( node == NULL ) + if ( !node ) break; if ( node->hash & ( mask + 1 ) ) @@ -232,7 +232,7 @@ FTC_Node node = *pnode; - if ( node == NULL ) + if ( !node ) { FT_TRACE0(( "ftc_node_hash_unlink: unknown node\n" )); return; @@ -288,7 +288,7 @@ cache = manager->caches[node->cache_index]; #ifdef FT_DEBUG_ERROR - if ( cache == NULL ) + if ( !cache ) { FT_TRACE0(( "ftc_node_destroy: invalid node handle\n" )); return; @@ -494,7 +494,7 @@ FTC_Node_CompareFunc compare = cache->clazz.node_compare; - if ( cache == NULL || anode == NULL ) + if ( !cache || !anode ) return FT_THROW( Invalid_Argument ); /* Go to the `top' node of the list sharing same masked hash */ @@ -505,7 +505,7 @@ for (;;) { node = *pnode; - if ( node == NULL ) + if ( !node ) goto NewNode; if ( node->hash == hash && @@ -523,7 +523,7 @@ /* Update pnode by modified linked list */ while ( *pnode != node ) { - if ( *pnode == NULL ) + if ( !*pnode ) { FT_ERROR(( "FTC_Cache_Lookup: oops!!! node missing\n" )); goto NewNode; @@ -582,7 +582,7 @@ FT_Bool list_changed = FALSE; - if ( node == NULL ) + if ( !node ) break; if ( cache->clazz.node_remove_faceid( node, face_id, diff --git a/thirdparty/freetype/src/cache/ftccache.h b/thirdparty/freetype/src/cache/ftccache.h index 1b1295951f..d3c11ce082 100644 --- a/thirdparty/freetype/src/cache/ftccache.h +++ b/thirdparty/freetype/src/cache/ftccache.h @@ -4,7 +4,7 @@ /* */ /* FreeType internal cache interface (specification). */ /* */ -/* Copyright 2000-2016 by */ +/* Copyright 2000-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -227,7 +227,7 @@ FT_BEGIN_HEADER for (;;) \ { \ _node = *_pnode; \ - if ( _node == NULL ) \ + if ( !_node ) \ goto NewNode_; \ \ if ( _node->hash == _hash && \ @@ -245,7 +245,7 @@ FT_BEGIN_HEADER /* Update _pnode by possibly modified linked list */ \ while ( *_pnode != _node ) \ { \ - if ( *_pnode == NULL ) \ + if ( !*_pnode ) \ { \ FT_ERROR(( "FTC_CACHE_LOOKUP_CMP: oops!!! node missing\n" )); \ goto NewNode_; \ @@ -325,7 +325,7 @@ FT_BEGIN_HEADER break; \ \ _try_done = FTC_Manager_FlushN( _try_manager, _try_count ); \ - if ( _try_done > 0 && ( list_changed != NULL ) ) \ + if ( _try_done > 0 && list_changed != NULL ) \ *(FT_Bool*)( list_changed ) = TRUE; \ \ if ( _try_done == 0 ) \ diff --git a/thirdparty/freetype/src/cache/ftccback.h b/thirdparty/freetype/src/cache/ftccback.h index 279e94d923..2681e8c022 100644 --- a/thirdparty/freetype/src/cache/ftccback.h +++ b/thirdparty/freetype/src/cache/ftccback.h @@ -4,7 +4,7 @@ /* */ /* Callback functions of the caching sub-system (specification only). */ /* */ -/* Copyright 2004-2016 by */ +/* Copyright 2004-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/thirdparty/freetype/src/cache/ftccmap.c b/thirdparty/freetype/src/cache/ftccmap.c index 41a0ce97dd..2fa84979c8 100644 --- a/thirdparty/freetype/src/cache/ftccmap.c +++ b/thirdparty/freetype/src/cache/ftccmap.c @@ -4,7 +4,7 @@ /* */ /* FreeType CharMap cache (body) */ /* */ -/* Copyright 2000-2016 by */ +/* Copyright 2000-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -201,15 +201,15 @@ static const FTC_CacheClassRec ftc_cmap_cache_class = { - ftc_cmap_node_new, - ftc_cmap_node_weight, - ftc_cmap_node_compare, - ftc_cmap_node_remove_faceid, - ftc_cmap_node_free, + ftc_cmap_node_new, /* FTC_Node_NewFunc node_new */ + ftc_cmap_node_weight, /* FTC_Node_WeightFunc node_weight */ + ftc_cmap_node_compare, /* FTC_Node_CompareFunc node_compare */ + ftc_cmap_node_remove_faceid, /* FTC_Node_CompareFunc node_remove_faceid */ + ftc_cmap_node_free, /* FTC_Node_FreeFunc node_free */ sizeof ( FTC_CacheRec ), - ftc_cache_init, - ftc_cache_done, + ftc_cache_init, /* FTC_Cache_InitFunc cache_init */ + ftc_cache_done, /* FTC_Cache_DoneFunc cache_done */ }; diff --git a/thirdparty/freetype/src/cache/ftcerror.h b/thirdparty/freetype/src/cache/ftcerror.h index 1fd7357a8b..84fe52f546 100644 --- a/thirdparty/freetype/src/cache/ftcerror.h +++ b/thirdparty/freetype/src/cache/ftcerror.h @@ -4,7 +4,7 @@ /* */ /* Caching sub-system error codes (specification only). */ /* */ -/* Copyright 2001-2016 by */ +/* Copyright 2001-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/thirdparty/freetype/src/cache/ftcglyph.c b/thirdparty/freetype/src/cache/ftcglyph.c index c4046812dd..d2468f2f43 100644 --- a/thirdparty/freetype/src/cache/ftcglyph.c +++ b/thirdparty/freetype/src/cache/ftcglyph.c @@ -4,7 +4,7 @@ /* */ /* FreeType Glyph Image (FT_Glyph) cache (body). */ /* */ -/* Copyright 2000-2016 by */ +/* Copyright 2000-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/thirdparty/freetype/src/cache/ftcglyph.h b/thirdparty/freetype/src/cache/ftcglyph.h index dc7be06f03..cab58ed311 100644 --- a/thirdparty/freetype/src/cache/ftcglyph.h +++ b/thirdparty/freetype/src/cache/ftcglyph.h @@ -4,7 +4,7 @@ /* */ /* FreeType abstract glyph cache (specification). */ /* */ -/* Copyright 2000-2016 by */ +/* Copyright 2000-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/thirdparty/freetype/src/cache/ftcimage.c b/thirdparty/freetype/src/cache/ftcimage.c index 74040aa745..359f818cce 100644 --- a/thirdparty/freetype/src/cache/ftcimage.c +++ b/thirdparty/freetype/src/cache/ftcimage.c @@ -4,7 +4,7 @@ /* */ /* FreeType Image cache (body). */ /* */ -/* Copyright 2000-2016 by */ +/* Copyright 2000-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/thirdparty/freetype/src/cache/ftcimage.h b/thirdparty/freetype/src/cache/ftcimage.h index 25aa43b97e..14049af9d2 100644 --- a/thirdparty/freetype/src/cache/ftcimage.h +++ b/thirdparty/freetype/src/cache/ftcimage.h @@ -4,7 +4,7 @@ /* */ /* FreeType Generic Image cache (specification) */ /* */ -/* Copyright 2000-2016 by */ +/* Copyright 2000-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/thirdparty/freetype/src/cache/ftcmanag.c b/thirdparty/freetype/src/cache/ftcmanag.c index 661a32af5b..edec2b6b5b 100644 --- a/thirdparty/freetype/src/cache/ftcmanag.c +++ b/thirdparty/freetype/src/cache/ftcmanag.c @@ -4,7 +4,7 @@ /* */ /* FreeType Cache Manager (body). */ /* */ -/* Copyright 2000-2016 by */ +/* Copyright 2000-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -156,10 +156,11 @@ const FTC_MruListClassRec ftc_size_list_class = { sizeof ( FTC_SizeNodeRec ), - ftc_size_node_compare, - ftc_size_node_init, - ftc_size_node_reset, - ftc_size_node_done + + ftc_size_node_compare, /* FTC_MruNode_CompareFunc node_compare */ + ftc_size_node_init, /* FTC_MruNode_InitFunc node_init */ + ftc_size_node_reset, /* FTC_MruNode_ResetFunc node_reset */ + ftc_size_node_done /* FTC_MruNode_DoneFunc node_done */ }; @@ -296,10 +297,10 @@ { sizeof ( FTC_FaceNodeRec), - ftc_face_node_compare, - ftc_face_node_init, - 0, /* FTC_MruNode_ResetFunc */ - ftc_face_node_done + ftc_face_node_compare, /* FTC_MruNode_CompareFunc node_compare */ + ftc_face_node_init, /* FTC_MruNode_InitFunc node_init */ + NULL, /* FTC_MruNode_ResetFunc node_reset */ + ftc_face_node_done /* FTC_MruNode_DoneFunc node_done */ }; @@ -552,7 +553,7 @@ manager->num_nodes )); #endif - if ( manager->cur_weight < manager->max_weight || first == NULL ) + if ( manager->cur_weight < manager->max_weight || !first ) return; /* go to last node -- it's a circular list */ @@ -637,7 +638,7 @@ /* try to remove `count' nodes from the list */ - if ( first == NULL ) /* empty list! */ + if ( !first ) /* empty list! */ return 0; /* go to last node - it's a circular list */ diff --git a/thirdparty/freetype/src/cache/ftcmanag.h b/thirdparty/freetype/src/cache/ftcmanag.h index f2c434a135..556842e131 100644 --- a/thirdparty/freetype/src/cache/ftcmanag.h +++ b/thirdparty/freetype/src/cache/ftcmanag.h @@ -4,7 +4,7 @@ /* */ /* FreeType Cache Manager (specification). */ /* */ -/* Copyright 2000-2016 by */ +/* Copyright 2000-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/thirdparty/freetype/src/cache/ftcmru.c b/thirdparty/freetype/src/cache/ftcmru.c index d107584a19..e293269f2f 100644 --- a/thirdparty/freetype/src/cache/ftcmru.c +++ b/thirdparty/freetype/src/cache/ftcmru.c @@ -4,7 +4,7 @@ /* */ /* FreeType MRU support (body). */ /* */ -/* Copyright 2003-2016 by */ +/* Copyright 2003-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -76,7 +76,7 @@ FTC_MruNode first = *plist; - FT_ASSERT( first != NULL ); + FT_ASSERT( first ); if ( first != node ) { @@ -126,7 +126,7 @@ FTC_MruNode prev, next; - FT_ASSERT( first != NULL ); + FT_ASSERT( first ); #ifdef FT_DEBUG_ERROR { @@ -238,7 +238,7 @@ FTC_MruNode *anode ) { FT_Error error; - FTC_MruNode node = NULL; + FTC_MruNode node = NULL; FT_Memory memory = list->memory; @@ -296,7 +296,7 @@ node = FTC_MruList_Find( list, key ); - if ( node == NULL ) + if ( !node ) return FTC_MruList_New( list, key, anode ); *anode = node; @@ -332,7 +332,7 @@ first = list->nodes; - while ( first && ( selection == NULL || selection( first, key ) ) ) + while ( first && ( !selection || selection( first, key ) ) ) { FTC_MruList_Remove( list, first ); first = list->nodes; diff --git a/thirdparty/freetype/src/cache/ftcmru.h b/thirdparty/freetype/src/cache/ftcmru.h index ae3c4ce23a..c4c330d558 100644 --- a/thirdparty/freetype/src/cache/ftcmru.h +++ b/thirdparty/freetype/src/cache/ftcmru.h @@ -4,7 +4,7 @@ /* */ /* Simple MRU list-cache (specification). */ /* */ -/* Copyright 2000-2016 by */ +/* Copyright 2000-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -108,6 +108,7 @@ FT_BEGIN_HEADER typedef struct FTC_MruListClassRec_ { FT_Offset node_size; + FTC_MruNode_CompareFunc node_compare; FTC_MruNode_InitFunc node_init; FTC_MruNode_ResetFunc node_reset; @@ -115,6 +116,7 @@ FT_BEGIN_HEADER } FTC_MruListClassRec; + typedef struct FTC_MruListRec_ { FT_UInt num_nodes; diff --git a/thirdparty/freetype/src/cache/ftcsbits.c b/thirdparty/freetype/src/cache/ftcsbits.c index d6f1ddcd4e..2f9336decd 100644 --- a/thirdparty/freetype/src/cache/ftcsbits.c +++ b/thirdparty/freetype/src/cache/ftcsbits.c @@ -4,7 +4,7 @@ /* */ /* FreeType sbits manager (body). */ /* */ -/* Copyright 2000-2016 by */ +/* Copyright 2000-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -378,7 +378,7 @@ * */ - if ( sbit->buffer == NULL && sbit->width == 255 ) + if ( !sbit->buffer && sbit->width == 255 ) { FT_ULong size; FT_Error error; diff --git a/thirdparty/freetype/src/cache/ftcsbits.h b/thirdparty/freetype/src/cache/ftcsbits.h index a0600ede09..1e15ce9764 100644 --- a/thirdparty/freetype/src/cache/ftcsbits.h +++ b/thirdparty/freetype/src/cache/ftcsbits.h @@ -4,7 +4,7 @@ /* */ /* A small-bitmap cache (specification). */ /* */ -/* Copyright 2000-2016 by */ +/* Copyright 2000-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/thirdparty/freetype/src/cache/rules.mk b/thirdparty/freetype/src/cache/rules.mk index 827e259f90..6204689505 100644 --- a/thirdparty/freetype/src/cache/rules.mk +++ b/thirdparty/freetype/src/cache/rules.mk @@ -3,7 +3,7 @@ # -# Copyright 2000-2016 by +# Copyright 2000-2017 by # David Turner, Robert Wilhelm, and Werner Lemberg. # # This file is part of the FreeType project, and may only be used, modified, diff --git a/thirdparty/freetype/src/cff/cf2arrst.c b/thirdparty/freetype/src/cff/cf2arrst.c index 89f3e9f1d7..6796450fe1 100644 --- a/thirdparty/freetype/src/cff/cf2arrst.c +++ b/thirdparty/freetype/src/cff/cf2arrst.c @@ -58,7 +58,7 @@ FT_Error* error, size_t sizeItem ) { - FT_ASSERT( arrstack != NULL ); + FT_ASSERT( arrstack ); /* initialize the structure */ arrstack->memory = memory; @@ -78,7 +78,7 @@ FT_Memory memory = arrstack->memory; /* for FT_FREE */ - FT_ASSERT( arrstack != NULL ); + FT_ASSERT( arrstack ); arrstack->allocated = 0; arrstack->count = 0; @@ -95,7 +95,7 @@ cf2_arrstack_setNumElements( CF2_ArrStack arrstack, size_t numElements ) { - FT_ASSERT( arrstack != NULL ); + FT_ASSERT( arrstack ); { FT_Error error = FT_Err_Ok; /* for FT_REALLOC */ @@ -140,7 +140,7 @@ cf2_arrstack_setCount( CF2_ArrStack arrstack, size_t numElements ) { - FT_ASSERT( arrstack != NULL ); + FT_ASSERT( arrstack ); if ( numElements > arrstack->allocated ) { @@ -157,7 +157,7 @@ FT_LOCAL_DEF( void ) cf2_arrstack_clear( CF2_ArrStack arrstack ) { - FT_ASSERT( arrstack != NULL ); + FT_ASSERT( arrstack ); arrstack->count = 0; } @@ -167,7 +167,7 @@ FT_LOCAL_DEF( size_t ) cf2_arrstack_size( const CF2_ArrStack arrstack ) { - FT_ASSERT( arrstack != NULL ); + FT_ASSERT( arrstack ); return arrstack->count; } @@ -176,7 +176,7 @@ FT_LOCAL_DEF( void* ) cf2_arrstack_getBuffer( const CF2_ArrStack arrstack ) { - FT_ASSERT( arrstack != NULL ); + FT_ASSERT( arrstack ); return arrstack->ptr; } @@ -190,7 +190,7 @@ void* newPtr; - FT_ASSERT( arrstack != NULL ); + FT_ASSERT( arrstack ); if ( idx >= arrstack->count ) { @@ -212,7 +212,7 @@ cf2_arrstack_push( CF2_ArrStack arrstack, const void* ptr ) { - FT_ASSERT( arrstack != NULL ); + FT_ASSERT( arrstack ); if ( arrstack->count == arrstack->allocated ) { @@ -225,7 +225,7 @@ } } - FT_ASSERT( ptr != NULL ); + FT_ASSERT( ptr ); { size_t offset = arrstack->count * arrstack->sizeItem; diff --git a/thirdparty/freetype/src/cff/cf2error.c b/thirdparty/freetype/src/cff/cf2error.c index b5595a3d1f..e3dd69f50d 100644 --- a/thirdparty/freetype/src/cff/cf2error.c +++ b/thirdparty/freetype/src/cff/cf2error.c @@ -44,7 +44,7 @@ cf2_setError( FT_Error* error, FT_Error value ) { - if ( error && *error == 0 ) + if ( error && !*error ) *error = value; } diff --git a/thirdparty/freetype/src/cff/cf2error.h b/thirdparty/freetype/src/cff/cf2error.h index 512edd1d21..d2c770d297 100644 --- a/thirdparty/freetype/src/cff/cf2error.h +++ b/thirdparty/freetype/src/cff/cf2error.h @@ -66,7 +66,7 @@ FT_BEGIN_HEADER * model our error mechanism on a Java-like exception mechanism. * When we assign an error code we are thus `throwing' an error. * - * The perservation of an error code is done by coding convention. + * The preservation of an error code is done by coding convention. * Upon a function call if the error code is anything other than * `FT_Err_Ok', which is guaranteed to be zero, we * will return without altering that error. This will allow the diff --git a/thirdparty/freetype/src/cff/cf2fixed.h b/thirdparty/freetype/src/cff/cf2fixed.h index 74af37708b..2e4b5032fa 100644 --- a/thirdparty/freetype/src/cff/cf2fixed.h +++ b/thirdparty/freetype/src/cff/cf2fixed.h @@ -51,8 +51,8 @@ FT_BEGIN_HEADER #define CF2_FIXED_MAX ( (CF2_Fixed)0x7FFFFFFFL ) #define CF2_FIXED_MIN ( (CF2_Fixed)0x80000000L ) -#define CF2_FIXED_ONE 0x10000L -#define CF2_FIXED_EPSILON 0x0001 +#define CF2_FIXED_ONE ( (CF2_Fixed)0x10000L ) +#define CF2_FIXED_EPSILON ( (CF2_Fixed)0x0001 ) /* in C 89, left and right shift of negative numbers is */ /* implementation specific behaviour in the general case */ diff --git a/thirdparty/freetype/src/cff/cf2font.c b/thirdparty/freetype/src/cff/cf2font.c index 83fd348f2d..a86e3619b4 100644 --- a/thirdparty/freetype/src/cff/cf2font.c +++ b/thirdparty/freetype/src/cff/cf2font.c @@ -234,7 +234,8 @@ } - /* set up values for the current FontDict and matrix */ + /* set up values for the current FontDict and matrix; */ + /* called for each glyph to be rendered */ /* caller's transform is adjusted for subpixel positioning */ static void @@ -246,6 +247,9 @@ FT_Bool needExtraSetup = FALSE; + CFF_VStoreRec* vstore; + FT_Bool hasVariations = FALSE; + /* character space units */ CF2_Fixed boldenX = font->syntheticEmboldeningAmountX; CF2_Fixed boldenY = font->syntheticEmboldeningAmountY; @@ -253,6 +257,9 @@ CFF_SubFont subFont; CF2_Fixed ppem; + CF2_UInt lenNormalizedV = 0; + FT_Fixed* normalizedV = NULL; + /* clear previous error */ font->error = FT_Err_Ok; @@ -266,6 +273,48 @@ needExtraSetup = TRUE; } + /* check for variation vectors */ + vstore = cf2_getVStore( decoder ); + hasVariations = ( vstore->dataCount != 0 ); + + if ( hasVariations ) + { +#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT + /* check whether Private DICT in this subfont needs to be reparsed */ + font->error = cf2_getNormalizedVector( decoder, + &lenNormalizedV, + &normalizedV ); + if ( font->error ) + return; + + if ( cff_blend_check_vector( &subFont->blend, + subFont->private_dict.vsindex, + lenNormalizedV, + normalizedV ) ) + { + /* blend has changed, reparse */ + cff_load_private_dict( decoder->cff, + subFont, + lenNormalizedV, + normalizedV ); + needExtraSetup = TRUE; + } +#endif + + /* copy from subfont */ + font->blend.font = subFont->blend.font; + + /* clear state of charstring blend */ + font->blend.usedBV = FALSE; + + /* initialize value for charstring */ + font->vsindex = subFont->private_dict.vsindex; + + /* store vector inputs for blends in charstring */ + font->lenNDV = lenNormalizedV; + font->NDV = normalizedV; + } + /* if ppem has changed, we need to recompute some cached data */ /* note: because of CID font matrix concatenation, ppem and transform */ /* do not necessarily track. */ @@ -423,7 +472,8 @@ /* compute blue zones for this instance */ cf2_blues_init( &font->blues, font ); - } + + } /* needExtraSetup */ } diff --git a/thirdparty/freetype/src/cff/cf2font.h b/thirdparty/freetype/src/cff/cf2font.h index bd05e69e7b..17ecd17bbb 100644 --- a/thirdparty/freetype/src/cff/cf2font.h +++ b/thirdparty/freetype/src/cff/cf2font.h @@ -42,6 +42,7 @@ #include "cf2ft.h" #include "cf2blues.h" +#include "cffload.h" FT_BEGIN_HEADER @@ -63,6 +64,7 @@ FT_BEGIN_HEADER FT_Memory memory; FT_Error error; /* shared error for this instance */ + FT_Bool isCFF2; CF2_RenderingFlags renderingFlags; /* variables that depend on Transform: */ @@ -74,6 +76,12 @@ FT_BEGIN_HEADER CF2_Matrix outerTransform; /* post hinting; includes rotations */ CF2_Fixed ppem; /* transform-dependent */ + /* variation data */ + CFF_BlendRec blend; /* cached charstring blend vector */ + CF2_UInt vsindex; /* current vsindex */ + CF2_UInt lenNDV; /* current length NDV or zero */ + FT_Fixed* NDV; /* ptr to current NDV or NULL */ + CF2_Int unitsPerEm; CF2_Fixed syntheticEmboldeningAmountX; /* character space units */ diff --git a/thirdparty/freetype/src/cff/cf2ft.c b/thirdparty/freetype/src/cff/cf2ft.c index 55f3206ac2..eb8472f119 100644 --- a/thirdparty/freetype/src/cff/cf2ft.c +++ b/thirdparty/freetype/src/cff/cf2ft.c @@ -104,7 +104,8 @@ FT_Memory memory = font->memory; - (void)memory; + FT_FREE( font->blend.lastNDV ); + FT_FREE( font->blend.BV ); } } @@ -239,7 +240,7 @@ FT_Memory memory, FT_Error* error ) { - FT_MEM_ZERO( outline, sizeof ( CF2_OutlineRec ) ); + FT_ZERO( outline ); outline->root.memory = memory; outline->root.error = error; @@ -311,7 +312,7 @@ font = (CF2_Font)decoder->cff->cf2_instance.data; /* on first glyph, allocate instance structure */ - if ( decoder->cff->cf2_instance.data == NULL ) + if ( !decoder->cff->cf2_instance.data ) { decoder->cff->cf2_instance.finalizer = (FT_Generic_Finalizer)cf2_free_instance; @@ -339,6 +340,11 @@ CFF_Builder* builder = &decoder->builder; CFF_Driver driver = (CFF_Driver)FT_FACE_DRIVER( builder->face ); + FT_Bool no_stem_darkening_driver = + driver->no_stem_darkening; + FT_Char no_stem_darkening_font = + builder->face->root.internal->no_stem_darkening; + /* local error */ FT_Error error2 = FT_Err_Ok; CF2_BufferRec buf; @@ -366,10 +372,15 @@ &hinted, &scaled ); + /* copy isCFF2 boolean from TT_Face to CF2_Font */ + font->isCFF2 = builder->face->is_cff2; + font->renderingFlags = 0; if ( hinted ) font->renderingFlags |= CF2_FlagsHinted; - if ( scaled && !driver->no_stem_darkening ) + if ( scaled && ( !no_stem_darkening_font || + ( no_stem_darkening_font < 0 && + !no_stem_darkening_driver ) ) ) font->renderingFlags |= CF2_FlagsDarkened; font->darkenParams[0] = driver->darken_params[0]; @@ -413,6 +424,44 @@ } + /* get pointer to VStore structure */ + FT_LOCAL_DEF( CFF_VStore ) + cf2_getVStore( CFF_Decoder* decoder ) + { + FT_ASSERT( decoder && decoder->cff ); + + return &decoder->cff->vstore; + } + + + /* get maxstack value from CFF2 Top DICT */ + FT_LOCAL_DEF( FT_UInt ) + cf2_getMaxstack( CFF_Decoder* decoder ) + { + FT_ASSERT( decoder && decoder->cff ); + + return decoder->cff->top_font.font_dict.maxstack; + } + + +#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT + /* Get normalized design vector for current render request; */ + /* return pointer and length. */ + /* */ + /* Note: Uses FT_Fixed not CF2_Fixed for the vector. */ + FT_LOCAL_DEF( FT_Error ) + cf2_getNormalizedVector( CFF_Decoder* decoder, + CF2_UInt *len, + FT_Fixed* *vec ) + { + FT_ASSERT( decoder && decoder->builder.face ); + FT_ASSERT( vec && len ); + + return cff_get_var_blend( decoder->builder.face, len, NULL, vec, NULL ); + } +#endif + + /* get `y_ppem' from `CFF_Size' */ FT_LOCAL_DEF( CF2_Fixed ) cf2_getPpemY( CFF_Decoder* decoder ) diff --git a/thirdparty/freetype/src/cff/cf2ft.h b/thirdparty/freetype/src/cff/cf2ft.h index 8e55e841a0..b054a6e950 100644 --- a/thirdparty/freetype/src/cff/cf2ft.h +++ b/thirdparty/freetype/src/cff/cf2ft.h @@ -64,6 +64,18 @@ FT_BEGIN_HEADER FT_LOCAL( CFF_SubFont ) cf2_getSubfont( CFF_Decoder* decoder ); + FT_LOCAL( CFF_VStore ) + cf2_getVStore( CFF_Decoder* decoder ); + + FT_LOCAL( FT_UInt ) + cf2_getMaxstack( CFF_Decoder* decoder ); + +#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT + FT_LOCAL( FT_Error ) + cf2_getNormalizedVector( CFF_Decoder* decoder, + CF2_UInt *len, + FT_Fixed* *vec ); +#endif FT_LOCAL( CF2_Fixed ) cf2_getPpemY( CFF_Decoder* decoder ); diff --git a/thirdparty/freetype/src/cff/cf2hints.c b/thirdparty/freetype/src/cff/cf2hints.c index bbbe8e3c32..c8f7dfeba6 100644 --- a/thirdparty/freetype/src/cff/cf2hints.c +++ b/thirdparty/freetype/src/cff/cf2hints.c @@ -401,10 +401,10 @@ /* calculate all four possibilities; moves down are negative */ CF2_Fixed downMoveDown = 0 - fracDown; CF2_Fixed upMoveDown = 0 - fracUp; - CF2_Fixed downMoveUp = fracDown == 0 + CF2_Fixed downMoveUp = ( fracDown == 0 ) ? 0 : cf2_intToFixed( 1 ) - fracDown; - CF2_Fixed upMoveUp = fracUp == 0 + CF2_Fixed upMoveUp = ( fracUp == 0 ) ? 0 : cf2_intToFixed( 1 ) - fracUp; diff --git a/thirdparty/freetype/src/cff/cf2intrp.c b/thirdparty/freetype/src/cff/cf2intrp.c index 7d663dd0ec..40bd9059a1 100644 --- a/thirdparty/freetype/src/cff/cf2intrp.c +++ b/thirdparty/freetype/src/cff/cf2intrp.c @@ -47,6 +47,8 @@ #include "cf2error.h" +#include "cffload.h" + /*************************************************************************/ /* */ @@ -58,12 +60,6 @@ #define FT_COMPONENT trace_cf2interp - /* some operators are not implemented yet */ -#define CF2_FIXME FT_TRACE4(( "cf2_interpT2CharString:" \ - " operator not implemented yet\n" )) - - - FT_LOCAL_DEF( void ) cf2_hintmask_init( CF2_HintMask hintmask, FT_Error* error ) @@ -215,8 +211,8 @@ cf2_cmdESC, /* 12 */ cf2_cmdRESERVED_13, /* 13 */ cf2_cmdENDCHAR, /* 14 */ - cf2_cmdRESERVED_15, /* 15 */ - cf2_cmdRESERVED_16, /* 16 */ + cf2_cmdVSINDEX, /* 15 */ + cf2_cmdBLEND, /* 16 */ cf2_cmdRESERVED_17, /* 17 */ cf2_cmdHSTEMHM, /* 18 */ cf2_cmdHINTMASK, /* 19 */ @@ -273,7 +269,8 @@ cf2_escHFLEX, /* 34 */ cf2_escFLEX, /* 35 */ cf2_escHFLEX1, /* 36 */ - cf2_escFLEX1 /* 37 */ + cf2_escFLEX1, /* 37 */ + cf2_escRESERVED_38 /* 38 & all higher */ }; @@ -336,22 +333,22 @@ FT_Bool doConditionalLastRead ) { CF2_Fixed vals[14]; - CF2_UInt index; + CF2_UInt idx; FT_Bool isHFlex; CF2_Int top, i, j; vals[0] = *curX; vals[1] = *curY; - index = 0; - isHFlex = readFromStack[9] == FALSE; + idx = 0; + isHFlex = FT_BOOL( readFromStack[9] == FALSE ); top = isHFlex ? 9 : 10; for ( i = 0; i < top; i++ ) { vals[i + 2] = vals[i]; if ( readFromStack[i] ) - vals[i + 2] += cf2_stack_getReal( opStack, index++ ); + vals[i + 2] += cf2_stack_getReal( opStack, idx++ ); } if ( isHFlex ) @@ -361,7 +358,7 @@ { FT_Bool lastIsX = (FT_Bool)( cf2_fixedAbs( vals[10] - *curX ) > cf2_fixedAbs( vals[11] - *curY ) ); - CF2_Fixed lastVal = cf2_stack_getReal( opStack, index ); + CF2_Fixed lastVal = cf2_stack_getReal( opStack, idx ); if ( lastIsX ) @@ -378,12 +375,12 @@ else { if ( readFromStack[10] ) - vals[12] = vals[10] + cf2_stack_getReal( opStack, index++ ); + vals[12] = vals[10] + cf2_stack_getReal( opStack, idx++ ); else vals[12] = *curX; if ( readFromStack[11] ) - vals[13] = vals[11] + cf2_stack_getReal( opStack, index ); + vals[13] = vals[11] + cf2_stack_getReal( opStack, idx ); else vals[13] = *curY; } @@ -403,6 +400,43 @@ } + /* Blend numOperands on the stack, */ + /* store results into the first numBlends values, */ + /* then pop remaining arguments. */ + static void + cf2_doBlend( const CFF_Blend blend, + CF2_Stack opStack, + CF2_UInt numBlends ) + { + CF2_UInt delta; + CF2_UInt base; + CF2_UInt i, j; + CF2_UInt numOperands = (CF2_UInt)( numBlends * blend->lenBV ); + + + base = cf2_stack_count( opStack ) - numOperands; + delta = base + numBlends; + + for ( i = 0; i < numBlends; i++ ) + { + const CF2_Fixed* weight = &blend->BV[1]; + + /* start with first term */ + CF2_Fixed sum = cf2_stack_getReal( opStack, i + base ); + + + for ( j = 1; j < blend->lenBV; j++ ) + sum += FT_MulFix( *weight++, cf2_stack_getReal( opStack, delta++ ) ); + + /* store blended result */ + cf2_stack_setReal( opStack, i + base, sum ); + } + + /* leave only `numBlends' results on stack */ + cf2_stack_pop( opStack, numOperands - numBlends ); + } + + /* * `error' is a shared error code used by many objects in this * routine. Before the code continues from an error, it must check and @@ -445,6 +479,7 @@ CF2_Fixed hintOriginY = curY; CF2_Stack opStack = NULL; + FT_UInt stackSize; FT_Byte op1; /* first opcode byte */ CF2_F16Dot16 storage[CF2_STORAGE_SIZE]; /* for `put' and `get' */ @@ -469,6 +504,8 @@ CF2_GlyphPathRec glyphPath; + FT_ZERO( &storage ); + /* initialize the remaining objects */ cf2_arrstack_init( &subrStack, memory, @@ -518,19 +555,24 @@ * If one of the above operators occurs without explicitly specifying * a width, we assume the default width. * + * CFF2 charstrings always return the default width (0). + * */ - haveWidth = FALSE; + haveWidth = font->isCFF2 ? TRUE : FALSE; *width = cf2_getDefaultWidthX( decoder ); /* - * Note: at this point, all pointers to resources must be NULL - * and all local objects must be initialized. - * There must be no branches to exit: above this point. + * Note: At this point, all pointers to resources must be NULL + * and all local objects must be initialized. + * There must be no branches to `exit:' above this point. * */ /* allocate an operand stack */ - opStack = cf2_stack_init( memory, error ); + stackSize = font->isCFF2 ? cf2_getMaxstack( decoder ) + : CF2_OPERAND_STACK_SIZE; + opStack = cf2_stack_init( memory, error, stackSize ); + if ( !opStack ) { lastError = FT_THROW( Out_Of_Memory ); @@ -559,14 +601,23 @@ { /* If we've reached the end of the charstring, simulate a */ /* cf2_cmdRETURN or cf2_cmdENDCHAR. */ + /* We do this for both CFF and CFF2. */ if ( charstringIndex ) op1 = cf2_cmdRETURN; /* end of buffer for subroutine */ else op1 = cf2_cmdENDCHAR; /* end of buffer for top level charstring */ } else + { op1 = (FT_Byte)cf2_buf_readByte( charstring ); + /* Explicit RETURN and ENDCHAR in CFF2 should be ignored. */ + /* Note: Trace message will report 0 instead of 11 or 14. */ + if ( ( op1 == cf2_cmdRETURN || op1 == cf2_cmdENDCHAR ) && + font->isCFF2 ) + op1 = cf2_cmdRESERVED_0; + } + /* check for errors once per loop */ if ( *error ) goto exit; @@ -584,13 +635,78 @@ case cf2_cmdRESERVED_2: case cf2_cmdRESERVED_9: case cf2_cmdRESERVED_13: - case cf2_cmdRESERVED_15: - case cf2_cmdRESERVED_16: case cf2_cmdRESERVED_17: /* we may get here if we have a prior error */ FT_TRACE4(( " unknown op (%d)\n", op1 )); break; + case cf2_cmdVSINDEX: + FT_TRACE4(( " vsindex\n" )); + + if ( !font->isCFF2 ) + break; /* clear stack & ignore */ + + if ( font->blend.usedBV ) + { + /* vsindex not allowed after blend */ + lastError = FT_THROW( Invalid_Glyph_Format ); + goto exit; + } + + { + FT_Int temp = cf2_stack_popInt( opStack ); + + + if ( temp >= 0 ) + font->vsindex = (FT_UInt)temp; + } + break; + + case cf2_cmdBLEND: + { + FT_UInt numBlends; + + + FT_TRACE4(( " blend\n" )); + + if ( !font->isCFF2 ) + break; /* clear stack & ignore */ + + /* do we have a `blend' op in a non-variant font? */ + if ( !font->blend.font ) + { + lastError = FT_THROW( Invalid_Glyph_Format ); + goto exit; + } + + /* check cached blend vector */ + if ( cff_blend_check_vector( &font->blend, + font->vsindex, + font->lenNDV, + font->NDV ) ) + { + lastError = cff_blend_build_vector( &font->blend, + font->vsindex, + font->lenNDV, + font->NDV ); + if ( lastError ) + goto exit; + } + + /* do the blend */ + numBlends = (FT_UInt)cf2_stack_popInt( opStack ); + if ( numBlends > stackSize ) + { + lastError = FT_THROW( Invalid_Glyph_Format ); + goto exit; + } + + cf2_doBlend( &font->blend, opStack, numBlends ); + + font->blend.usedBV = TRUE; + } + continue; /* do not clear the stack */ + case cf2_cmdHSTEMHM: case cf2_cmdHSTEM: FT_TRACE4(( op1 == cf2_cmdHSTEMHM ? " hstemhm\n" : " hstem\n" )); @@ -659,16 +775,16 @@ case cf2_cmdRLINETO: { - CF2_UInt index; + CF2_UInt idx; CF2_UInt count = cf2_stack_count( opStack ); FT_TRACE4(( " rlineto\n" )); - for ( index = 0; index < count; index += 2 ) + for ( idx = 0; idx < count; idx += 2 ) { - curX += cf2_stack_getReal( opStack, index + 0 ); - curY += cf2_stack_getReal( opStack, index + 1 ); + curX += cf2_stack_getReal( opStack, idx + 0 ); + curY += cf2_stack_getReal( opStack, idx + 1 ); cf2_glyphpath_lineTo( &glyphPath, curX, curY ); } @@ -680,17 +796,17 @@ case cf2_cmdHLINETO: case cf2_cmdVLINETO: { - CF2_UInt index; + CF2_UInt idx; CF2_UInt count = cf2_stack_count( opStack ); - FT_Bool isX = op1 == cf2_cmdHLINETO; + FT_Bool isX = FT_BOOL( op1 == cf2_cmdHLINETO ); FT_TRACE4(( isX ? " hlineto\n" : " vlineto\n" )); - for ( index = 0; index < count; index++ ) + for ( idx = 0; idx < count; idx++ ) { - CF2_Fixed v = cf2_stack_getReal( opStack, index ); + CF2_Fixed v = cf2_stack_getReal( opStack, idx ); if ( isX ) @@ -711,33 +827,33 @@ case cf2_cmdRRCURVETO: { CF2_UInt count = cf2_stack_count( opStack ); - CF2_UInt index = 0; + CF2_UInt idx = 0; FT_TRACE4(( op1 == cf2_cmdRCURVELINE ? " rcurveline\n" : " rrcurveto\n" )); - while ( index + 6 <= count ) + while ( idx + 6 <= count ) { - CF2_Fixed x1 = cf2_stack_getReal( opStack, index + 0 ) + curX; - CF2_Fixed y1 = cf2_stack_getReal( opStack, index + 1 ) + curY; - CF2_Fixed x2 = cf2_stack_getReal( opStack, index + 2 ) + x1; - CF2_Fixed y2 = cf2_stack_getReal( opStack, index + 3 ) + y1; - CF2_Fixed x3 = cf2_stack_getReal( opStack, index + 4 ) + x2; - CF2_Fixed y3 = cf2_stack_getReal( opStack, index + 5 ) + y2; + CF2_Fixed x1 = cf2_stack_getReal( opStack, idx + 0 ) + curX; + CF2_Fixed y1 = cf2_stack_getReal( opStack, idx + 1 ) + curY; + CF2_Fixed x2 = cf2_stack_getReal( opStack, idx + 2 ) + x1; + CF2_Fixed y2 = cf2_stack_getReal( opStack, idx + 3 ) + y1; + CF2_Fixed x3 = cf2_stack_getReal( opStack, idx + 4 ) + x2; + CF2_Fixed y3 = cf2_stack_getReal( opStack, idx + 5 ) + y2; cf2_glyphpath_curveTo( &glyphPath, x1, y1, x2, y2, x3, y3 ); - curX = x3; - curY = y3; - index += 6; + curX = x3; + curY = y3; + idx += 6; } if ( op1 == cf2_cmdRCURVELINE ) { - curX += cf2_stack_getReal( opStack, index + 0 ); - curY += cf2_stack_getReal( opStack, index + 1 ); + curX += cf2_stack_getReal( opStack, idx + 0 ); + curY += cf2_stack_getReal( opStack, idx + 1 ); cf2_glyphpath_lineTo( &glyphPath, curX, curY ); } @@ -828,440 +944,469 @@ FT_Byte op2 = (FT_Byte)cf2_buf_readByte( charstring ); + /* first switch for 2-byte operators handles CFF2 */ + /* and opcodes that are reserved for both CFF and CFF2 */ switch ( op2 ) { - case cf2_escDOTSECTION: - /* something about `flip type of locking' -- ignore it */ - FT_TRACE4(( " dotsection\n" )); + case cf2_escHFLEX: + { + static const FT_Bool readFromStack[12] = + { + TRUE /* dx1 */, FALSE /* dy1 */, + TRUE /* dx2 */, TRUE /* dy2 */, + TRUE /* dx3 */, FALSE /* dy3 */, + TRUE /* dx4 */, FALSE /* dy4 */, + TRUE /* dx5 */, FALSE /* dy5 */, + TRUE /* dx6 */, FALSE /* dy6 */ + }; - break; - case cf2_escAND: - { - CF2_F16Dot16 arg1; - CF2_F16Dot16 arg2; + FT_TRACE4(( " hflex\n" )); + + cf2_doFlex( opStack, + &curX, + &curY, + &glyphPath, + readFromStack, + FALSE /* doConditionalLastRead */ ); + } + continue; + case cf2_escFLEX: + { + static const FT_Bool readFromStack[12] = + { + TRUE /* dx1 */, TRUE /* dy1 */, + TRUE /* dx2 */, TRUE /* dy2 */, + TRUE /* dx3 */, TRUE /* dy3 */, + TRUE /* dx4 */, TRUE /* dy4 */, + TRUE /* dx5 */, TRUE /* dy5 */, + TRUE /* dx6 */, TRUE /* dy6 */ + }; - FT_TRACE4(( " and\n" )); - arg2 = cf2_stack_popFixed( opStack ); - arg1 = cf2_stack_popFixed( opStack ); + FT_TRACE4(( " flex\n" )); - cf2_stack_pushInt( opStack, arg1 && arg2 ); + cf2_doFlex( opStack, + &curX, + &curY, + &glyphPath, + readFromStack, + FALSE /* doConditionalLastRead */ ); } - continue; /* do not clear the stack */ + break; /* TODO: why is this not a continue? */ - case cf2_escOR: + case cf2_escHFLEX1: { - CF2_F16Dot16 arg1; - CF2_F16Dot16 arg2; - + static const FT_Bool readFromStack[12] = + { + TRUE /* dx1 */, TRUE /* dy1 */, + TRUE /* dx2 */, TRUE /* dy2 */, + TRUE /* dx3 */, FALSE /* dy3 */, + TRUE /* dx4 */, FALSE /* dy4 */, + TRUE /* dx5 */, TRUE /* dy5 */, + TRUE /* dx6 */, FALSE /* dy6 */ + }; - FT_TRACE4(( " or\n" )); - arg2 = cf2_stack_popFixed( opStack ); - arg1 = cf2_stack_popFixed( opStack ); + FT_TRACE4(( " hflex1\n" )); - cf2_stack_pushInt( opStack, arg1 || arg2 ); + cf2_doFlex( opStack, + &curX, + &curY, + &glyphPath, + readFromStack, + FALSE /* doConditionalLastRead */ ); } - continue; /* do not clear the stack */ + continue; - case cf2_escNOT: + case cf2_escFLEX1: { - CF2_F16Dot16 arg; - + static const FT_Bool readFromStack[12] = + { + TRUE /* dx1 */, TRUE /* dy1 */, + TRUE /* dx2 */, TRUE /* dy2 */, + TRUE /* dx3 */, TRUE /* dy3 */, + TRUE /* dx4 */, TRUE /* dy4 */, + TRUE /* dx5 */, TRUE /* dy5 */, + FALSE /* dx6 */, FALSE /* dy6 */ + }; - FT_TRACE4(( " not\n" )); - arg = cf2_stack_popFixed( opStack ); + FT_TRACE4(( " flex1\n" )); - cf2_stack_pushInt( opStack, !arg ); + cf2_doFlex( opStack, + &curX, + &curY, + &glyphPath, + readFromStack, + TRUE /* doConditionalLastRead */ ); } - continue; /* do not clear the stack */ + continue; + + /* these opcodes are reserved in both CFF & CFF2 */ + case cf2_escRESERVED_1: + case cf2_escRESERVED_2: + case cf2_escRESERVED_6: + case cf2_escRESERVED_7: + case cf2_escRESERVED_8: + case cf2_escRESERVED_13: + case cf2_escRESERVED_16: + case cf2_escRESERVED_17: + case cf2_escRESERVED_19: + case cf2_escRESERVED_25: + case cf2_escRESERVED_31: + case cf2_escRESERVED_32: + case cf2_escRESERVED_33: + FT_TRACE4(( " unknown op (12, %d)\n", op2 )); + break; - case cf2_escABS: + default: { - CF2_F16Dot16 arg; + if ( font->isCFF2 || op2 >= cf2_escRESERVED_38 ) + FT_TRACE4(( " unknown op (12, %d)\n", op2 )); + else + { + /* second switch for 2-byte operators handles just CFF */ + switch ( op2 ) + { + case cf2_escDOTSECTION: + /* something about `flip type of locking' -- ignore it */ + FT_TRACE4(( " dotsection\n" )); - FT_TRACE4(( " abs\n" )); + break; - arg = cf2_stack_popFixed( opStack ); + case cf2_escAND: + { + CF2_F16Dot16 arg1; + CF2_F16Dot16 arg2; - cf2_stack_pushFixed( opStack, FT_ABS( arg ) ); - } - continue; /* do not clear the stack */ - case cf2_escADD: - { - CF2_F16Dot16 summand1; - CF2_F16Dot16 summand2; + FT_TRACE4(( " and\n" )); + arg2 = cf2_stack_popFixed( opStack ); + arg1 = cf2_stack_popFixed( opStack ); - FT_TRACE4(( " add\n" )); + cf2_stack_pushInt( opStack, arg1 && arg2 ); + } + continue; /* do not clear the stack */ - summand2 = cf2_stack_popFixed( opStack ); - summand1 = cf2_stack_popFixed( opStack ); + case cf2_escOR: + { + CF2_F16Dot16 arg1; + CF2_F16Dot16 arg2; - cf2_stack_pushFixed( opStack, summand1 + summand2 ); - } - continue; /* do not clear the stack */ - case cf2_escSUB: - { - CF2_F16Dot16 minuend; - CF2_F16Dot16 subtrahend; + FT_TRACE4(( " or\n" )); + arg2 = cf2_stack_popFixed( opStack ); + arg1 = cf2_stack_popFixed( opStack ); - FT_TRACE4(( " sub\n" )); + cf2_stack_pushInt( opStack, arg1 || arg2 ); + } + continue; /* do not clear the stack */ - subtrahend = cf2_stack_popFixed( opStack ); - minuend = cf2_stack_popFixed( opStack ); + case cf2_escNOT: + { + CF2_F16Dot16 arg; - cf2_stack_pushFixed( opStack, minuend - subtrahend ); - } - continue; /* do not clear the stack */ - case cf2_escDIV: - { - CF2_F16Dot16 dividend; - CF2_F16Dot16 divisor; + FT_TRACE4(( " not\n" )); + arg = cf2_stack_popFixed( opStack ); - FT_TRACE4(( " div\n" )); + cf2_stack_pushInt( opStack, !arg ); + } + continue; /* do not clear the stack */ - divisor = cf2_stack_popFixed( opStack ); - dividend = cf2_stack_popFixed( opStack ); + case cf2_escABS: + { + CF2_F16Dot16 arg; - cf2_stack_pushFixed( opStack, FT_DivFix( dividend, divisor ) ); - } - continue; /* do not clear the stack */ - case cf2_escNEG: - { - CF2_F16Dot16 arg; + FT_TRACE4(( " abs\n" )); + arg = cf2_stack_popFixed( opStack ); - FT_TRACE4(( " neg\n" )); + cf2_stack_pushFixed( opStack, FT_ABS( arg ) ); + } + continue; /* do not clear the stack */ - arg = cf2_stack_popFixed( opStack ); + case cf2_escADD: + { + CF2_F16Dot16 summand1; + CF2_F16Dot16 summand2; - cf2_stack_pushFixed( opStack, -arg ); - } - continue; /* do not clear the stack */ - case cf2_escEQ: - { - CF2_F16Dot16 arg1; - CF2_F16Dot16 arg2; + FT_TRACE4(( " add\n" )); + summand2 = cf2_stack_popFixed( opStack ); + summand1 = cf2_stack_popFixed( opStack ); - FT_TRACE4(( " eq\n" )); + cf2_stack_pushFixed( opStack, summand1 + summand2 ); + } + continue; /* do not clear the stack */ - arg2 = cf2_stack_popFixed( opStack ); - arg1 = cf2_stack_popFixed( opStack ); + case cf2_escSUB: + { + CF2_F16Dot16 minuend; + CF2_F16Dot16 subtrahend; - cf2_stack_pushInt( opStack, arg1 == arg2 ); - } - continue; /* do not clear the stack */ - case cf2_escDROP: - FT_TRACE4(( " drop\n" )); + FT_TRACE4(( " sub\n" )); - (void)cf2_stack_popFixed( opStack ); - continue; /* do not clear the stack */ + subtrahend = cf2_stack_popFixed( opStack ); + minuend = cf2_stack_popFixed( opStack ); - case cf2_escPUT: - { - CF2_F16Dot16 val; - CF2_Int idx; + cf2_stack_pushFixed( opStack, minuend - subtrahend ); + } + continue; /* do not clear the stack */ + case cf2_escDIV: + { + CF2_F16Dot16 dividend; + CF2_F16Dot16 divisor; - FT_TRACE4(( " put\n" )); - idx = cf2_stack_popInt( opStack ); - val = cf2_stack_popFixed( opStack ); + FT_TRACE4(( " div\n" )); - if ( idx >= 0 && idx < CF2_STORAGE_SIZE ) - storage[idx] = val; - } - continue; /* do not clear the stack */ + divisor = cf2_stack_popFixed( opStack ); + dividend = cf2_stack_popFixed( opStack ); - case cf2_escGET: - { - CF2_Int idx; + cf2_stack_pushFixed( opStack, FT_DivFix( dividend, divisor ) ); + } + continue; /* do not clear the stack */ + case cf2_escNEG: + { + CF2_F16Dot16 arg; - FT_TRACE4(( " get\n" )); - idx = cf2_stack_popInt( opStack ); + FT_TRACE4(( " neg\n" )); - if ( idx >= 0 && idx < CF2_STORAGE_SIZE ) - cf2_stack_pushFixed( opStack, storage[idx] ); - } - continue; /* do not clear the stack */ + arg = cf2_stack_popFixed( opStack ); - case cf2_escIFELSE: - { - CF2_F16Dot16 arg1; - CF2_F16Dot16 arg2; - CF2_F16Dot16 cond1; - CF2_F16Dot16 cond2; + cf2_stack_pushFixed( opStack, -arg ); + } + continue; /* do not clear the stack */ + case cf2_escEQ: + { + CF2_F16Dot16 arg1; + CF2_F16Dot16 arg2; - FT_TRACE4(( " ifelse\n" )); - cond2 = cf2_stack_popFixed( opStack ); - cond1 = cf2_stack_popFixed( opStack ); - arg2 = cf2_stack_popFixed( opStack ); - arg1 = cf2_stack_popFixed( opStack ); + FT_TRACE4(( " eq\n" )); - cf2_stack_pushFixed( opStack, cond1 <= cond2 ? arg1 : arg2 ); - } - continue; /* do not clear the stack */ + arg2 = cf2_stack_popFixed( opStack ); + arg1 = cf2_stack_popFixed( opStack ); - case cf2_escRANDOM: /* in spec */ - FT_TRACE4(( " random\n" )); + cf2_stack_pushInt( opStack, arg1 == arg2 ); + } + continue; /* do not clear the stack */ - CF2_FIXME; - break; + case cf2_escDROP: + FT_TRACE4(( " drop\n" )); - case cf2_escMUL: - { - CF2_F16Dot16 factor1; - CF2_F16Dot16 factor2; + (void)cf2_stack_popFixed( opStack ); + continue; /* do not clear the stack */ + case cf2_escPUT: + { + CF2_F16Dot16 val; + CF2_Int idx; - FT_TRACE4(( " mul\n" )); - factor2 = cf2_stack_popFixed( opStack ); - factor1 = cf2_stack_popFixed( opStack ); + FT_TRACE4(( " put\n" )); - cf2_stack_pushFixed( opStack, FT_MulFix( factor1, factor2 ) ); - } - continue; /* do not clear the stack */ + idx = cf2_stack_popInt( opStack ); + val = cf2_stack_popFixed( opStack ); - case cf2_escSQRT: - { - CF2_F16Dot16 arg; + if ( idx >= 0 && idx < CF2_STORAGE_SIZE ) + storage[idx] = val; + } + continue; /* do not clear the stack */ + case cf2_escGET: + { + CF2_Int idx; - FT_TRACE4(( " sqrt\n" )); - arg = cf2_stack_popFixed( opStack ); - if ( arg > 0 ) - { - FT_Fixed root = arg; - FT_Fixed new_root; + FT_TRACE4(( " get\n" )); + idx = cf2_stack_popInt( opStack ); - /* Babylonian method */ - for (;;) - { - new_root = ( root + FT_DivFix( arg, root ) + 1 ) >> 1; - if ( new_root == root ) - break; - root = new_root; - } - arg = new_root; - } - else - arg = 0; + if ( idx >= 0 && idx < CF2_STORAGE_SIZE ) + cf2_stack_pushFixed( opStack, storage[idx] ); + } + continue; /* do not clear the stack */ - cf2_stack_pushFixed( opStack, arg ); - } - continue; /* do not clear the stack */ + case cf2_escIFELSE: + { + CF2_F16Dot16 arg1; + CF2_F16Dot16 arg2; + CF2_F16Dot16 cond1; + CF2_F16Dot16 cond2; - case cf2_escDUP: - { - CF2_F16Dot16 arg; + FT_TRACE4(( " ifelse\n" )); - FT_TRACE4(( " dup\n" )); + cond2 = cf2_stack_popFixed( opStack ); + cond1 = cf2_stack_popFixed( opStack ); + arg2 = cf2_stack_popFixed( opStack ); + arg1 = cf2_stack_popFixed( opStack ); - arg = cf2_stack_popFixed( opStack ); + cf2_stack_pushFixed( opStack, cond1 <= cond2 ? arg1 : arg2 ); + } + continue; /* do not clear the stack */ - cf2_stack_pushFixed( opStack, arg ); - cf2_stack_pushFixed( opStack, arg ); - } - continue; /* do not clear the stack */ + case cf2_escRANDOM: /* in spec */ + { + CF2_F16Dot16 r; - case cf2_escEXCH: - { - CF2_F16Dot16 arg1; - CF2_F16Dot16 arg2; + FT_TRACE4(( " random\n" )); - FT_TRACE4(( " exch\n" )); + /* only use the lower 16 bits of `random' */ + /* to generate a number in the range (0;1] */ + r = (CF2_F16Dot16) + ( ( decoder->current_subfont->random & 0xFFFF ) + 1 ); - arg2 = cf2_stack_popFixed( opStack ); - arg1 = cf2_stack_popFixed( opStack ); + decoder->current_subfont->random = + cff_random( decoder->current_subfont->random ); - cf2_stack_pushFixed( opStack, arg2 ); - cf2_stack_pushFixed( opStack, arg1 ); - } - continue; /* do not clear the stack */ + cf2_stack_pushFixed( opStack, r ); + } + continue; /* do not clear the stack */ - case cf2_escINDEX: - { - CF2_Int idx; - CF2_UInt size; + case cf2_escMUL: + { + CF2_F16Dot16 factor1; + CF2_F16Dot16 factor2; - FT_TRACE4(( " index\n" )); + FT_TRACE4(( " mul\n" )); - idx = cf2_stack_popInt( opStack ); - size = cf2_stack_count( opStack ); + factor2 = cf2_stack_popFixed( opStack ); + factor1 = cf2_stack_popFixed( opStack ); - if ( size > 0 ) - { - /* for `cf2_stack_getReal', index 0 is bottom of stack */ - CF2_UInt gr_idx; + cf2_stack_pushFixed( opStack, FT_MulFix( factor1, factor2 ) ); + } + continue; /* do not clear the stack */ + case cf2_escSQRT: + { + CF2_F16Dot16 arg; - if ( idx < 0 ) - gr_idx = size - 1; - else if ( (CF2_UInt)idx >= size ) - gr_idx = 0; - else - gr_idx = size - 1 - (CF2_UInt)idx; - cf2_stack_pushFixed( opStack, - cf2_stack_getReal( opStack, gr_idx ) ); - } - } - continue; /* do not clear the stack */ + FT_TRACE4(( " sqrt\n" )); - case cf2_escROLL: - { - CF2_Int idx; - CF2_Int count; + arg = cf2_stack_popFixed( opStack ); + if ( arg > 0 ) + { + FT_Fixed root = arg; + FT_Fixed new_root; - FT_TRACE4(( " roll\n" )); + /* Babylonian method */ + for (;;) + { + new_root = ( root + FT_DivFix( arg, root ) + 1 ) >> 1; + if ( new_root == root ) + break; + root = new_root; + } + arg = new_root; + } + else + arg = 0; - idx = cf2_stack_popInt( opStack ); - count = cf2_stack_popInt( opStack ); + cf2_stack_pushFixed( opStack, arg ); + } + continue; /* do not clear the stack */ - cf2_stack_roll( opStack, count, idx ); - } - continue; /* do not clear the stack */ + case cf2_escDUP: + { + CF2_F16Dot16 arg; - case cf2_escHFLEX: - { - static const FT_Bool readFromStack[12] = - { - TRUE /* dx1 */, FALSE /* dy1 */, - TRUE /* dx2 */, TRUE /* dy2 */, - TRUE /* dx3 */, FALSE /* dy3 */, - TRUE /* dx4 */, FALSE /* dy4 */, - TRUE /* dx5 */, FALSE /* dy5 */, - TRUE /* dx6 */, FALSE /* dy6 */ - }; + FT_TRACE4(( " dup\n" )); - FT_TRACE4(( " hflex\n" )); + arg = cf2_stack_popFixed( opStack ); - cf2_doFlex( opStack, - &curX, - &curY, - &glyphPath, - readFromStack, - FALSE /* doConditionalLastRead */ ); - } - continue; + cf2_stack_pushFixed( opStack, arg ); + cf2_stack_pushFixed( opStack, arg ); + } + continue; /* do not clear the stack */ - case cf2_escFLEX: - { - static const FT_Bool readFromStack[12] = - { - TRUE /* dx1 */, TRUE /* dy1 */, - TRUE /* dx2 */, TRUE /* dy2 */, - TRUE /* dx3 */, TRUE /* dy3 */, - TRUE /* dx4 */, TRUE /* dy4 */, - TRUE /* dx5 */, TRUE /* dy5 */, - TRUE /* dx6 */, TRUE /* dy6 */ - }; + case cf2_escEXCH: + { + CF2_F16Dot16 arg1; + CF2_F16Dot16 arg2; - FT_TRACE4(( " flex\n" )); + FT_TRACE4(( " exch\n" )); - cf2_doFlex( opStack, - &curX, - &curY, - &glyphPath, - readFromStack, - FALSE /* doConditionalLastRead */ ); - } - break; /* TODO: why is this not a continue? */ + arg2 = cf2_stack_popFixed( opStack ); + arg1 = cf2_stack_popFixed( opStack ); - case cf2_escHFLEX1: - { - static const FT_Bool readFromStack[12] = - { - TRUE /* dx1 */, TRUE /* dy1 */, - TRUE /* dx2 */, TRUE /* dy2 */, - TRUE /* dx3 */, FALSE /* dy3 */, - TRUE /* dx4 */, FALSE /* dy4 */, - TRUE /* dx5 */, TRUE /* dy5 */, - TRUE /* dx6 */, FALSE /* dy6 */ - }; + cf2_stack_pushFixed( opStack, arg2 ); + cf2_stack_pushFixed( opStack, arg1 ); + } + continue; /* do not clear the stack */ + case cf2_escINDEX: + { + CF2_Int idx; + CF2_UInt size; - FT_TRACE4(( " hflex1\n" )); - cf2_doFlex( opStack, - &curX, - &curY, - &glyphPath, - readFromStack, - FALSE /* doConditionalLastRead */ ); - } - continue; + FT_TRACE4(( " index\n" )); - case cf2_escFLEX1: - { - static const FT_Bool readFromStack[12] = - { - TRUE /* dx1 */, TRUE /* dy1 */, - TRUE /* dx2 */, TRUE /* dy2 */, - TRUE /* dx3 */, TRUE /* dy3 */, - TRUE /* dx4 */, TRUE /* dy4 */, - TRUE /* dx5 */, TRUE /* dy5 */, - FALSE /* dx6 */, FALSE /* dy6 */ - }; + idx = cf2_stack_popInt( opStack ); + size = cf2_stack_count( opStack ); + if ( size > 0 ) + { + /* for `cf2_stack_getReal', index 0 is bottom of stack */ + CF2_UInt gr_idx; - FT_TRACE4(( " flex1\n" )); - cf2_doFlex( opStack, - &curX, - &curY, - &glyphPath, - readFromStack, - TRUE /* doConditionalLastRead */ ); - } - continue; + if ( idx < 0 ) + gr_idx = size - 1; + else if ( (CF2_UInt)idx >= size ) + gr_idx = 0; + else + gr_idx = size - 1 - (CF2_UInt)idx; - case cf2_escRESERVED_1: - case cf2_escRESERVED_2: - case cf2_escRESERVED_6: - case cf2_escRESERVED_7: - case cf2_escRESERVED_8: - case cf2_escRESERVED_13: - case cf2_escRESERVED_16: - case cf2_escRESERVED_17: - case cf2_escRESERVED_19: - case cf2_escRESERVED_25: - case cf2_escRESERVED_31: - case cf2_escRESERVED_32: - case cf2_escRESERVED_33: - default: - FT_TRACE4(( " unknown op (12, %d)\n", op2 )); + cf2_stack_pushFixed( opStack, + cf2_stack_getReal( opStack, gr_idx ) ); + } + } + continue; /* do not clear the stack */ - }; /* end of switch statement checking `op2' */ + case cf2_escROLL: + { + CF2_Int idx; + CF2_Int count; + + FT_TRACE4(( " roll\n" )); + + idx = cf2_stack_popInt( opStack ); + count = cf2_stack_popInt( opStack ); + + cf2_stack_roll( opStack, count, idx ); + } + continue; /* do not clear the stack */ + + } /* end of 2nd switch checking op2 */ + } + } + } /* end of 1st switch checking op2 */ } /* case cf2_cmdESC */ + break; case cf2_cmdENDCHAR: @@ -1283,7 +1428,8 @@ /* close path if still open */ cf2_glyphpath_closeOpenPath( &glyphPath ); - if ( cf2_stack_count( opStack ) > 1 ) + /* disable seac for CFF2 (charstring ending with args on stack) */ + if ( !font->isCFF2 && cf2_stack_count( opStack ) > 1 ) { /* must be either 4 or 5 -- */ /* this is a (deprecated) implied `seac' operator */ @@ -1454,35 +1600,35 @@ case cf2_cmdRLINECURVE: { CF2_UInt count = cf2_stack_count( opStack ); - CF2_UInt index = 0; + CF2_UInt idx = 0; FT_TRACE4(( " rlinecurve\n" )); - while ( index + 6 < count ) + while ( idx + 6 < count ) { - curX += cf2_stack_getReal( opStack, index + 0 ); - curY += cf2_stack_getReal( opStack, index + 1 ); + curX += cf2_stack_getReal( opStack, idx + 0 ); + curY += cf2_stack_getReal( opStack, idx + 1 ); cf2_glyphpath_lineTo( &glyphPath, curX, curY ); - index += 2; + idx += 2; } - while ( index < count ) + while ( idx < count ) { - CF2_Fixed x1 = cf2_stack_getReal( opStack, index + 0 ) + curX; - CF2_Fixed y1 = cf2_stack_getReal( opStack, index + 1 ) + curY; - CF2_Fixed x2 = cf2_stack_getReal( opStack, index + 2 ) + x1; - CF2_Fixed y2 = cf2_stack_getReal( opStack, index + 3 ) + y1; - CF2_Fixed x3 = cf2_stack_getReal( opStack, index + 4 ) + x2; - CF2_Fixed y3 = cf2_stack_getReal( opStack, index + 5 ) + y2; + CF2_Fixed x1 = cf2_stack_getReal( opStack, idx + 0 ) + curX; + CF2_Fixed y1 = cf2_stack_getReal( opStack, idx + 1 ) + curY; + CF2_Fixed x2 = cf2_stack_getReal( opStack, idx + 2 ) + x1; + CF2_Fixed y2 = cf2_stack_getReal( opStack, idx + 3 ) + y1; + CF2_Fixed x3 = cf2_stack_getReal( opStack, idx + 4 ) + x2; + CF2_Fixed y3 = cf2_stack_getReal( opStack, idx + 5 ) + y2; cf2_glyphpath_curveTo( &glyphPath, x1, y1, x2, y2, x3, y3 ); - curX = x3; - curY = y3; - index += 6; + curX = x3; + curY = y3; + idx += 6; } cf2_stack_clear( opStack ); @@ -1492,42 +1638,42 @@ case cf2_cmdVVCURVETO: { CF2_UInt count, count1 = cf2_stack_count( opStack ); - CF2_UInt index = 0; + CF2_UInt idx = 0; /* if `cf2_stack_count' isn't of the form 4n or 4n+1, */ /* we enforce it by clearing the second bit */ /* (and sorting the stack indexing to suit) */ - count = count1 & ~2U; - index += count1 - count; + count = count1 & ~2U; + idx += count1 - count; FT_TRACE4(( " vvcurveto\n" )); - while ( index < count ) + while ( idx < count ) { CF2_Fixed x1, y1, x2, y2, x3, y3; - if ( ( count - index ) & 1 ) + if ( ( count - idx ) & 1 ) { - x1 = cf2_stack_getReal( opStack, index ) + curX; + x1 = cf2_stack_getReal( opStack, idx ) + curX; - ++index; + idx++; } else x1 = curX; - y1 = cf2_stack_getReal( opStack, index + 0 ) + curY; - x2 = cf2_stack_getReal( opStack, index + 1 ) + x1; - y2 = cf2_stack_getReal( opStack, index + 2 ) + y1; + y1 = cf2_stack_getReal( opStack, idx + 0 ) + curY; + x2 = cf2_stack_getReal( opStack, idx + 1 ) + x1; + y2 = cf2_stack_getReal( opStack, idx + 2 ) + y1; x3 = x2; - y3 = cf2_stack_getReal( opStack, index + 3 ) + y2; + y3 = cf2_stack_getReal( opStack, idx + 3 ) + y2; cf2_glyphpath_curveTo( &glyphPath, x1, y1, x2, y2, x3, y3 ); - curX = x3; - curY = y3; - index += 4; + curX = x3; + curY = y3; + idx += 4; } cf2_stack_clear( opStack ); @@ -1537,42 +1683,42 @@ case cf2_cmdHHCURVETO: { CF2_UInt count, count1 = cf2_stack_count( opStack ); - CF2_UInt index = 0; + CF2_UInt idx = 0; /* if `cf2_stack_count' isn't of the form 4n or 4n+1, */ /* we enforce it by clearing the second bit */ /* (and sorting the stack indexing to suit) */ - count = count1 & ~2U; - index += count1 - count; + count = count1 & ~2U; + idx += count1 - count; FT_TRACE4(( " hhcurveto\n" )); - while ( index < count ) + while ( idx < count ) { CF2_Fixed x1, y1, x2, y2, x3, y3; - if ( ( count - index ) & 1 ) + if ( ( count - idx ) & 1 ) { - y1 = cf2_stack_getReal( opStack, index ) + curY; + y1 = cf2_stack_getReal( opStack, idx ) + curY; - ++index; + idx++; } else y1 = curY; - x1 = cf2_stack_getReal( opStack, index + 0 ) + curX; - x2 = cf2_stack_getReal( opStack, index + 1 ) + x1; - y2 = cf2_stack_getReal( opStack, index + 2 ) + y1; - x3 = cf2_stack_getReal( opStack, index + 3 ) + x2; + x1 = cf2_stack_getReal( opStack, idx + 0 ) + curX; + x2 = cf2_stack_getReal( opStack, idx + 1 ) + x1; + y2 = cf2_stack_getReal( opStack, idx + 2 ) + y1; + x3 = cf2_stack_getReal( opStack, idx + 3 ) + x2; y3 = y2; cf2_glyphpath_curveTo( &glyphPath, x1, y1, x2, y2, x3, y3 ); - curX = x3; - curY = y3; - index += 4; + curX = x3; + curY = y3; + idx += 4; } cf2_stack_clear( opStack ); @@ -1583,38 +1729,38 @@ case cf2_cmdHVCURVETO: { CF2_UInt count, count1 = cf2_stack_count( opStack ); - CF2_UInt index = 0; + CF2_UInt idx = 0; - FT_Bool alternate = op1 == cf2_cmdHVCURVETO; + FT_Bool alternate = FT_BOOL( op1 == cf2_cmdHVCURVETO ); /* if `cf2_stack_count' isn't of the form 8n, 8n+1, */ /* 8n+4, or 8n+5, we enforce it by clearing the */ /* second bit */ /* (and sorting the stack indexing to suit) */ - count = count1 & ~2U; - index += count1 - count; + count = count1 & ~2U; + idx += count1 - count; FT_TRACE4(( alternate ? " hvcurveto\n" : " vhcurveto\n" )); - while ( index < count ) + while ( idx < count ) { CF2_Fixed x1, x2, x3, y1, y2, y3; if ( alternate ) { - x1 = cf2_stack_getReal( opStack, index + 0 ) + curX; + x1 = cf2_stack_getReal( opStack, idx + 0 ) + curX; y1 = curY; - x2 = cf2_stack_getReal( opStack, index + 1 ) + x1; - y2 = cf2_stack_getReal( opStack, index + 2 ) + y1; - y3 = cf2_stack_getReal( opStack, index + 3 ) + y2; + x2 = cf2_stack_getReal( opStack, idx + 1 ) + x1; + y2 = cf2_stack_getReal( opStack, idx + 2 ) + y1; + y3 = cf2_stack_getReal( opStack, idx + 3 ) + y2; - if ( count - index == 5 ) + if ( count - idx == 5 ) { - x3 = cf2_stack_getReal( opStack, index + 4 ) + x2; + x3 = cf2_stack_getReal( opStack, idx + 4 ) + x2; - ++index; + idx++; } else x3 = x2; @@ -1624,16 +1770,16 @@ else { x1 = curX; - y1 = cf2_stack_getReal( opStack, index + 0 ) + curY; - x2 = cf2_stack_getReal( opStack, index + 1 ) + x1; - y2 = cf2_stack_getReal( opStack, index + 2 ) + y1; - x3 = cf2_stack_getReal( opStack, index + 3 ) + x2; + y1 = cf2_stack_getReal( opStack, idx + 0 ) + curY; + x2 = cf2_stack_getReal( opStack, idx + 1 ) + x1; + y2 = cf2_stack_getReal( opStack, idx + 2 ) + y1; + x3 = cf2_stack_getReal( opStack, idx + 3 ) + x2; - if ( count - index == 5 ) + if ( count - idx == 5 ) { - y3 = cf2_stack_getReal( opStack, index + 4 ) + y2; + y3 = cf2_stack_getReal( opStack, idx + 4 ) + y2; - ++index; + idx++; } else y3 = y2; @@ -1643,9 +1789,9 @@ cf2_glyphpath_curveTo( &glyphPath, x1, y1, x2, y2, x3, y3 ); - curX = x3; - curY = y3; - index += 4; + curX = x3; + curY = y3; + idx += 4; } cf2_stack_clear( opStack ); @@ -1734,7 +1880,7 @@ ( byte3 << 8 ) | byte4 ); - FT_TRACE4(( " %.2f", v / 65536.0 )); + FT_TRACE4(( " %.5f", v / 65536.0 )); cf2_stack_pushFixed( opStack, v ); } @@ -1755,6 +1901,9 @@ /* check whether last error seen is also the first one */ cf2_setError( error, lastError ); + if ( *error ) + FT_TRACE4(( "charstring error %d\n", *error )); + /* free resources from objects we've used */ cf2_glyphpath_finalize( &glyphPath ); cf2_arrstack_finalize( &vStemHintArray ); diff --git a/thirdparty/freetype/src/cff/cf2stack.c b/thirdparty/freetype/src/cff/cf2stack.c index 6fafd901f3..12a026d21d 100644 --- a/thirdparty/freetype/src/cff/cf2stack.c +++ b/thirdparty/freetype/src/cff/cf2stack.c @@ -51,21 +51,31 @@ /* `error'). */ FT_LOCAL_DEF( CF2_Stack ) cf2_stack_init( FT_Memory memory, - FT_Error* e ) + FT_Error* e, + FT_UInt stackSize ) { - FT_Error error = FT_Err_Ok; /* for FT_QNEW */ + FT_Error error = FT_Err_Ok; /* for FT_NEW */ CF2_Stack stack = NULL; - if ( !FT_QNEW( stack ) ) + if ( !FT_NEW( stack ) ) { - /* initialize the structure; FT_QNEW zeroes it */ + /* initialize the structure; FT_NEW zeroes it */ stack->memory = memory; stack->error = e; - stack->top = &stack->buffer[0]; /* empty stack */ } + /* allocate the stack buffer */ + if ( FT_NEW_ARRAY( stack->buffer, stackSize ) ) + { + FT_FREE( stack ); + return NULL; + } + + stack->stackSize = stackSize; + stack->top = stack->buffer; /* empty stack */ + return stack; } @@ -77,6 +87,8 @@ { FT_Memory memory = stack->memory; + /* free the buffer */ + FT_FREE( stack->buffer ); /* free the main structure */ FT_FREE( stack ); @@ -87,7 +99,7 @@ FT_LOCAL_DEF( CF2_UInt ) cf2_stack_count( CF2_Stack stack ) { - return (CF2_UInt)( stack->top - &stack->buffer[0] ); + return (CF2_UInt)( stack->top - stack->buffer ); } @@ -95,7 +107,7 @@ cf2_stack_pushInt( CF2_Stack stack, CF2_Int val ) { - if ( stack->top == &stack->buffer[CF2_OPERAND_STACK_SIZE] ) + if ( stack->top == stack->buffer + stack->stackSize ) { CF2_SET_ERROR( stack->error, Stack_Overflow ); return; /* stack overflow */ @@ -103,7 +115,7 @@ stack->top->u.i = val; stack->top->type = CF2_NumberInt; - ++stack->top; + stack->top++; } @@ -111,7 +123,7 @@ cf2_stack_pushFixed( CF2_Stack stack, CF2_Fixed val ) { - if ( stack->top == &stack->buffer[CF2_OPERAND_STACK_SIZE] ) + if ( stack->top == stack->buffer + stack->stackSize ) { CF2_SET_ERROR( stack->error, Stack_Overflow ); return; /* stack overflow */ @@ -119,7 +131,7 @@ stack->top->u.r = val; stack->top->type = CF2_NumberFixed; - ++stack->top; + stack->top++; } @@ -127,7 +139,7 @@ FT_LOCAL_DEF( CF2_Int ) cf2_stack_popInt( CF2_Stack stack ) { - if ( stack->top == &stack->buffer[0] ) + if ( stack->top == stack->buffer ) { CF2_SET_ERROR( stack->error, Stack_Underflow ); return 0; /* underflow */ @@ -138,7 +150,7 @@ return 0; /* type mismatch */ } - --stack->top; + stack->top--; return stack->top->u.i; } @@ -149,13 +161,13 @@ FT_LOCAL_DEF( CF2_Fixed ) cf2_stack_popFixed( CF2_Stack stack ) { - if ( stack->top == &stack->buffer[0] ) + if ( stack->top == stack->buffer ) { CF2_SET_ERROR( stack->error, Stack_Underflow ); return cf2_intToFixed( 0 ); /* underflow */ } - --stack->top; + stack->top--; switch ( stack->top->type ) { @@ -175,7 +187,7 @@ cf2_stack_getReal( CF2_Stack stack, CF2_UInt idx ) { - FT_ASSERT( cf2_stack_count( stack ) <= CF2_OPERAND_STACK_SIZE ); + FT_ASSERT( cf2_stack_count( stack ) <= stack->stackSize ); if ( idx >= cf2_stack_count( stack ) ) { @@ -195,7 +207,38 @@ } - FT_LOCAL( void ) + /* provide random access to stack */ + FT_LOCAL_DEF( void ) + cf2_stack_setReal( CF2_Stack stack, + CF2_UInt idx, + CF2_Fixed val ) + { + if ( idx > cf2_stack_count( stack ) ) + { + CF2_SET_ERROR( stack->error, Stack_Overflow ); + return; + } + + stack->buffer[idx].u.r = val; + stack->buffer[idx].type = CF2_NumberFixed; + } + + + /* discard (pop) num values from stack */ + FT_LOCAL_DEF( void ) + cf2_stack_pop( CF2_Stack stack, + CF2_UInt num ) + { + if ( num > cf2_stack_count( stack ) ) + { + CF2_SET_ERROR( stack->error, Stack_Underflow ); + return; + } + stack->top -= num; + } + + + FT_LOCAL_DEF( void ) cf2_stack_roll( CF2_Stack stack, CF2_Int count, CF2_Int shift ) @@ -278,7 +321,7 @@ FT_LOCAL_DEF( void ) cf2_stack_clear( CF2_Stack stack ) { - stack->top = &stack->buffer[0]; + stack->top = stack->buffer; } diff --git a/thirdparty/freetype/src/cff/cf2stack.h b/thirdparty/freetype/src/cff/cf2stack.h index e740a7ac41..ef08eefe41 100644 --- a/thirdparty/freetype/src/cff/cf2stack.h +++ b/thirdparty/freetype/src/cff/cf2stack.h @@ -62,15 +62,17 @@ FT_BEGIN_HEADER { FT_Memory memory; FT_Error* error; - CF2_StackNumber buffer[CF2_OPERAND_STACK_SIZE]; + CF2_StackNumber* buffer; CF2_StackNumber* top; + FT_UInt stackSize; } CF2_StackRec, *CF2_Stack; FT_LOCAL( CF2_Stack ) cf2_stack_init( FT_Memory memory, - FT_Error* error ); + FT_Error* error, + FT_UInt stackSize ); FT_LOCAL( void ) cf2_stack_free( CF2_Stack stack ); @@ -92,6 +94,14 @@ FT_BEGIN_HEADER FT_LOCAL( CF2_Fixed ) cf2_stack_getReal( CF2_Stack stack, CF2_UInt idx ); + FT_LOCAL( void ) + cf2_stack_setReal( CF2_Stack stack, + CF2_UInt idx, + CF2_Fixed val ); + + FT_LOCAL( void ) + cf2_stack_pop( CF2_Stack stack, + CF2_UInt num ); FT_LOCAL( void ) cf2_stack_roll( CF2_Stack stack, diff --git a/thirdparty/freetype/src/cff/cff.c b/thirdparty/freetype/src/cff/cff.c index 86ca1be040..397f6dfafe 100644 --- a/thirdparty/freetype/src/cff/cff.c +++ b/thirdparty/freetype/src/cff/cff.c @@ -4,7 +4,7 @@ /* */ /* FreeType OpenType driver component (body only). */ /* */ -/* Copyright 1996-2016 by */ +/* Copyright 1996-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -17,16 +17,15 @@ #define FT_MAKE_OPTION_SINGLE_OBJECT - #include <ft2build.h> -#include "cffpic.c" +#include "cffcmap.c" #include "cffdrivr.c" +#include "cffgload.c" #include "cffparse.c" +#include "cffpic.c" #include "cffload.c" #include "cffobjs.c" -#include "cffgload.c" -#include "cffcmap.c" #include "cf2arrst.c" #include "cf2blues.c" @@ -38,4 +37,5 @@ #include "cf2read.c" #include "cf2stack.c" + /* END */ diff --git a/thirdparty/freetype/src/cff/cffcmap.c b/thirdparty/freetype/src/cff/cffcmap.c index 3ef48328c5..4adce7a54d 100644 --- a/thirdparty/freetype/src/cff/cffcmap.c +++ b/thirdparty/freetype/src/cff/cffcmap.c @@ -4,7 +4,7 @@ /* */ /* CFF character mapping table (cmap) support (body). */ /* */ -/* Copyright 2002-2016 by */ +/* Copyright 2002-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -104,15 +104,21 @@ } - FT_DEFINE_CMAP_CLASS(cff_cmap_encoding_class_rec, + FT_DEFINE_CMAP_CLASS( + cff_cmap_encoding_class_rec, + sizeof ( CFF_CMapStdRec ), - (FT_CMap_InitFunc) cff_cmap_encoding_init, - (FT_CMap_DoneFunc) cff_cmap_encoding_done, - (FT_CMap_CharIndexFunc)cff_cmap_encoding_char_index, - (FT_CMap_CharNextFunc) cff_cmap_encoding_char_next, + (FT_CMap_InitFunc) cff_cmap_encoding_init, /* init */ + (FT_CMap_DoneFunc) cff_cmap_encoding_done, /* done */ + (FT_CMap_CharIndexFunc)cff_cmap_encoding_char_index, /* char_index */ + (FT_CMap_CharNextFunc) cff_cmap_encoding_char_next, /* char_next */ - NULL, NULL, NULL, NULL, NULL + (FT_CMap_CharVarIndexFunc) NULL, /* char_var_index */ + (FT_CMap_CharVarIsDefaultFunc)NULL, /* char_var_default */ + (FT_CMap_VariantListFunc) NULL, /* variant_list */ + (FT_CMap_CharVariantListFunc) NULL, /* charvariant_list */ + (FT_CMap_VariantCharListFunc) NULL /* variantchar_list */ ) @@ -202,15 +208,22 @@ } - FT_DEFINE_CMAP_CLASS(cff_cmap_unicode_class_rec, + FT_DEFINE_CMAP_CLASS( + cff_cmap_unicode_class_rec, + sizeof ( PS_UnicodesRec ), - (FT_CMap_InitFunc) cff_cmap_unicode_init, - (FT_CMap_DoneFunc) cff_cmap_unicode_done, - (FT_CMap_CharIndexFunc)cff_cmap_unicode_char_index, - (FT_CMap_CharNextFunc) cff_cmap_unicode_char_next, + (FT_CMap_InitFunc) cff_cmap_unicode_init, /* init */ + (FT_CMap_DoneFunc) cff_cmap_unicode_done, /* done */ + (FT_CMap_CharIndexFunc)cff_cmap_unicode_char_index, /* char_index */ + (FT_CMap_CharNextFunc) cff_cmap_unicode_char_next, /* char_next */ - NULL, NULL, NULL, NULL, NULL + (FT_CMap_CharVarIndexFunc) NULL, /* char_var_index */ + (FT_CMap_CharVarIsDefaultFunc)NULL, /* char_var_default */ + (FT_CMap_VariantListFunc) NULL, /* variant_list */ + (FT_CMap_CharVariantListFunc) NULL, /* charvariant_list */ + (FT_CMap_VariantCharListFunc) NULL /* variantchar_list */ ) + /* END */ diff --git a/thirdparty/freetype/src/cff/cffcmap.h b/thirdparty/freetype/src/cff/cffcmap.h index 23795d5090..7792e04248 100644 --- a/thirdparty/freetype/src/cff/cffcmap.h +++ b/thirdparty/freetype/src/cff/cffcmap.h @@ -4,7 +4,7 @@ /* */ /* CFF character mapping table (cmap) support (specification). */ /* */ -/* Copyright 2002-2016 by */ +/* Copyright 2002-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/thirdparty/freetype/src/cff/cffdrivr.c b/thirdparty/freetype/src/cff/cffdrivr.c index 950a9605c3..38bfc2ca3d 100644 --- a/thirdparty/freetype/src/cff/cffdrivr.c +++ b/thirdparty/freetype/src/cff/cffdrivr.c @@ -4,7 +4,7 @@ /* */ /* OpenType font driver implementation (body). */ /* */ -/* Copyright 1996-2016 by */ +/* Copyright 1996-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -32,6 +32,11 @@ #include "cffcmap.h" #include "cffparse.h" +#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT +#include FT_SERVICE_MULTIPLE_MASTERS_H +#include FT_SERVICE_METRICS_VARIATIONS_H +#endif + #include "cfferrs.h" #include "cffpic.h" @@ -207,6 +212,13 @@ if ( flags & FT_LOAD_VERTICAL_LAYOUT ) { +#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT + /* no fast retrieval for blended MM fonts without VVAR table */ + if ( !ttface->is_default_instance && + !( ttface->variation_support & TT_FACE_FLAG_VAR_VADVANCE ) ) + return FT_THROW( Unimplemented_Feature ); +#endif + /* check whether we have data from the `vmtx' table at all; */ /* otherwise we extract the info from the CFF glyphstrings */ /* (instead of synthesizing a global value using the `OS/2' */ @@ -232,6 +244,13 @@ } else { +#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT + /* no fast retrieval for blended MM fonts without HVAR table */ + if ( !ttface->is_default_instance && + !( ttface->variation_support & TT_FACE_FLAG_VAR_HADVANCE ) ) + return FT_THROW( Unimplemented_Feature ); +#endif + /* check whether we have data from the `hmtx' table at all */ if ( !ttface->horizontal.number_Of_HMetrics ) goto Missing_Table; @@ -291,6 +310,35 @@ FT_Error error; + /* CFF2 table does not have glyph names; */ + /* we need to use `post' table method */ + if ( font->version_major == 2 ) + { + FT_Library library = FT_FACE_LIBRARY( face ); + FT_Module sfnt_module = FT_Get_Module( library, "sfnt" ); + FT_Service_GlyphDict service = + (FT_Service_GlyphDict)ft_module_get_service( + sfnt_module, + FT_SERVICE_ID_GLYPH_DICT, + 0 ); + + + if ( service && service->get_name ) + return service->get_name( FT_FACE( face ), + glyph_index, + buffer, + buffer_max ); + else + { + FT_ERROR(( "cff_get_glyph_name:" + " cannot get glyph name from a CFF2 font\n" + " " + " without the `PSNames' module\n" )); + error = FT_THROW( Missing_Module ); + goto Exit; + } + } + if ( !font->psnames ) { FT_ERROR(( "cff_get_glyph_name:" @@ -332,6 +380,31 @@ cff = (CFF_FontRec *)face->extra.data; charset = &cff->charset; + /* CFF2 table does not have glyph names; */ + /* we need to use `post' table method */ + if ( cff->version_major == 2 ) + { + FT_Library library = FT_FACE_LIBRARY( face ); + FT_Module sfnt_module = FT_Get_Module( library, "sfnt" ); + FT_Service_GlyphDict service = + (FT_Service_GlyphDict)ft_module_get_service( + sfnt_module, + FT_SERVICE_ID_GLYPH_DICT, + 0 ); + + + if ( service && service->name_index ) + return service->name_index( FT_FACE( face ), glyph_name ); + else + { + FT_ERROR(( "cff_get_name_index:" + " cannot get glyph index from a CFF2 font\n" + " " + " without the `PSNames' module\n" )); + return 0; + } + } + FT_FACE_FIND_GLOBAL_SERVICE( face, psnames, POSTSCRIPT_CMAPS ); if ( !psnames ) return 0; @@ -358,6 +431,7 @@ FT_DEFINE_SERVICE_GLYPHDICTREC( cff_service_glyph_dict, + (FT_GlyphDict_GetNameFunc) cff_get_glyph_name, /* get_name */ (FT_GlyphDict_NameIndexFunc)cff_get_name_index /* name_index */ ) @@ -383,11 +457,11 @@ FT_Error error = FT_Err_Ok; - if ( cff && cff->font_info == NULL ) + if ( cff && !cff->font_info ) { - CFF_FontRecDict dict = &cff->top_font.font_dict; + CFF_FontRecDict dict = &cff->top_font.font_dict; PS_FontInfoRec *font_info = NULL; - FT_Memory memory = face->root.memory; + FT_Memory memory = face->root.memory; if ( FT_ALLOC( font_info, sizeof ( *font_info ) ) ) @@ -421,6 +495,7 @@ FT_DEFINE_SERVICE_PSINFOREC( cff_service_ps_info, + (PS_GetFontInfoFunc) cff_ps_get_font_info, /* ps_get_font_info */ (PS_GetFontExtraFunc) NULL, /* ps_get_font_extra */ (PS_HasGlyphNamesFunc) cff_ps_has_glyph_names, /* ps_has_glyph_names */ @@ -453,7 +528,8 @@ FT_Service_PsFontName service = (FT_Service_PsFontName)ft_module_get_service( sfnt_module, - FT_SERVICE_ID_POSTSCRIPT_FONT_NAME ); + FT_SERVICE_ID_POSTSCRIPT_FONT_NAME, + 0 ); if ( service && service->get_ps_font_name ) @@ -466,6 +542,7 @@ FT_DEFINE_SERVICE_PSFONTNAMEREC( cff_service_ps_name, + (FT_PsName_GetFunc)cff_get_ps_name /* get_ps_font_name */ ) @@ -491,21 +568,21 @@ FT_Library library = FT_FACE_LIBRARY( face ); - cmap_info->language = 0; - cmap_info->format = 0; - if ( cmap->clazz != &CFF_CMAP_ENCODING_CLASS_REC_GET && cmap->clazz != &CFF_CMAP_UNICODE_CLASS_REC_GET ) { FT_Module sfnt = FT_Get_Module( library, "sfnt" ); FT_Service_TTCMaps service = (FT_Service_TTCMaps)ft_module_get_service( sfnt, - FT_SERVICE_ID_TT_CMAP ); + FT_SERVICE_ID_TT_CMAP, + 0 ); if ( service && service->get_cmap_info ) error = service->get_cmap_info( charmap, cmap_info ); } + else + error = FT_THROW( Invalid_CharMap_Format ); return error; } @@ -513,6 +590,7 @@ FT_DEFINE_SERVICE_TTCMAPSREC( cff_service_get_cmap_info, + (TT_CMap_Info_GetFunc)cff_get_cmap_info /* get_cmap_info */ ) @@ -544,7 +622,7 @@ if ( registry ) { - if ( cff->registry == NULL ) + if ( !cff->registry ) cff->registry = cff_index_get_sid_string( cff, dict->cid_registry ); *registry = cff->registry; @@ -552,7 +630,7 @@ if ( ordering ) { - if ( cff->ordering == NULL ) + if ( !cff->ordering ) cff->ordering = cff_index_get_sid_string( cff, dict->cid_ordering ); *ordering = cff->ordering; @@ -643,6 +721,7 @@ FT_DEFINE_SERVICE_CIDREC( cff_service_cid_info, + (FT_CID_GetRegistryOrderingSupplementFunc) cff_get_ros, /* get_ros */ (FT_CID_GetIsInternallyCIDKeyedFunc) @@ -659,26 +738,62 @@ static FT_Error cff_property_set( FT_Module module, /* CFF_Driver */ const char* property_name, - const void* value ) + const void* value, + FT_Bool value_is_string ) { FT_Error error = FT_Err_Ok; CFF_Driver driver = (CFF_Driver)module; +#ifndef FT_CONFIG_OPTION_ENVIRONMENT_PROPERTIES + FT_UNUSED( value_is_string ); +#endif + if ( !ft_strcmp( property_name, "darkening-parameters" ) ) { - FT_Int* darken_params = (FT_Int*)value; + FT_Int* darken_params; + FT_Int x1, y1, x2, y2, x3, y3, x4, y4; - FT_Int x1 = darken_params[0]; - FT_Int y1 = darken_params[1]; - FT_Int x2 = darken_params[2]; - FT_Int y2 = darken_params[3]; - FT_Int x3 = darken_params[4]; - FT_Int y3 = darken_params[5]; - FT_Int x4 = darken_params[6]; - FT_Int y4 = darken_params[7]; +#ifdef FT_CONFIG_OPTION_ENVIRONMENT_PROPERTIES + FT_Int dp[8]; + if ( value_is_string ) + { + const char* s = (const char*)value; + char* ep; + int i; + + + /* eight comma-separated numbers */ + for ( i = 0; i < 7; i++ ) + { + dp[i] = (FT_Int)ft_strtol( s, &ep, 10 ); + if ( *ep != ',' || s == ep ) + return FT_THROW( Invalid_Argument ); + + s = ep + 1; + } + + dp[7] = (FT_Int)ft_strtol( s, &ep, 10 ); + if ( !( *ep == '\0' || *ep == ' ' ) || s == ep ) + return FT_THROW( Invalid_Argument ); + + darken_params = dp; + } + else +#endif + darken_params = (FT_Int*)value; + + x1 = darken_params[0]; + y1 = darken_params[1]; + x2 = darken_params[2]; + y2 = darken_params[3]; + x3 = darken_params[4]; + y3 = darken_params[5]; + x4 = darken_params[6]; + y4 = darken_params[7]; + if ( x1 < 0 || x2 < 0 || x3 < 0 || x4 < 0 || y1 < 0 || y2 < 0 || y3 < 0 || y4 < 0 || x1 > x2 || x2 > x3 || x3 > x4 || @@ -698,26 +813,85 @@ } else if ( !ft_strcmp( property_name, "hinting-engine" ) ) { - FT_UInt* hinting_engine = (FT_UInt*)value; +#ifdef FT_CONFIG_OPTION_ENVIRONMENT_PROPERTIES + if ( value_is_string ) + { + const char* s = (const char*)value; - if ( *hinting_engine == FT_CFF_HINTING_ADOBE + if ( !ft_strcmp( s, "adobe" ) ) + driver->hinting_engine = FT_CFF_HINTING_ADOBE; #ifdef CFF_CONFIG_OPTION_OLD_ENGINE - || *hinting_engine == FT_CFF_HINTING_FREETYPE + else if ( !ft_strcmp( s, "freetype" ) ) + driver->hinting_engine = FT_CFF_HINTING_FREETYPE; #endif - ) - driver->hinting_engine = *hinting_engine; + else + return FT_THROW( Invalid_Argument ); + } else - error = FT_ERR( Unimplemented_Feature ); +#endif + { + FT_UInt* hinting_engine = (FT_UInt*)value; - return error; + + if ( *hinting_engine == FT_CFF_HINTING_ADOBE +#ifdef CFF_CONFIG_OPTION_OLD_ENGINE + || *hinting_engine == FT_CFF_HINTING_FREETYPE +#endif + ) + driver->hinting_engine = *hinting_engine; + else + error = FT_ERR( Unimplemented_Feature ); + + return error; + } } else if ( !ft_strcmp( property_name, "no-stem-darkening" ) ) { - FT_Bool* no_stem_darkening = (FT_Bool*)value; +#ifdef FT_CONFIG_OPTION_ENVIRONMENT_PROPERTIES + if ( value_is_string ) + { + const char* s = (const char*)value; + long nsd = ft_strtol( s, NULL, 10 ); + + + if ( !nsd ) + driver->no_stem_darkening = FALSE; + else + driver->no_stem_darkening = TRUE; + } + else +#endif + { + FT_Bool* no_stem_darkening = (FT_Bool*)value; + + + driver->no_stem_darkening = *no_stem_darkening; + } + + return error; + } + else if ( !ft_strcmp( property_name, "random-seed" ) ) + { + FT_Int32 random_seed; - driver->no_stem_darkening = *no_stem_darkening; +#ifdef FT_CONFIG_OPTION_ENVIRONMENT_PROPERTIES + if ( value_is_string ) + { + const char* s = (const char*)value; + + + random_seed = (FT_Int32)ft_strtol( s, NULL, 10 ); + } + else +#endif + random_seed = *(FT_Int32*)value; + + if ( random_seed < 0 ) + random_seed = 0; + + driver->random_seed = random_seed; return error; } @@ -783,10 +957,137 @@ FT_DEFINE_SERVICE_PROPERTIESREC( cff_service_properties, + (FT_Properties_SetFunc)cff_property_set, /* set_property */ (FT_Properties_GetFunc)cff_property_get ) /* get_property */ +#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT + + /* + * MULTIPLE MASTER SERVICE + * + */ + + static FT_Error + cff_set_mm_blend( CFF_Face face, + FT_UInt num_coords, + FT_Fixed* coords ) + { + FT_Service_MultiMasters mm = (FT_Service_MultiMasters)face->mm; + + + return mm->set_mm_blend( FT_FACE( face ), num_coords, coords ); + } + + + static FT_Error + cff_get_mm_blend( CFF_Face face, + FT_UInt num_coords, + FT_Fixed* coords ) + { + FT_Service_MultiMasters mm = (FT_Service_MultiMasters)face->mm; + + + return mm->get_mm_blend( FT_FACE( face ), num_coords, coords ); + } + + + static FT_Error + cff_get_mm_var( CFF_Face face, + FT_MM_Var* *master ) + { + FT_Service_MultiMasters mm = (FT_Service_MultiMasters)face->mm; + + + return mm->get_mm_var( FT_FACE( face ), master ); + } + + + static FT_Error + cff_set_var_design( CFF_Face face, + FT_UInt num_coords, + FT_Fixed* coords ) + { + FT_Service_MultiMasters mm = (FT_Service_MultiMasters)face->mm; + + + return mm->set_var_design( FT_FACE( face ), num_coords, coords ); + } + + + static FT_Error + cff_get_var_design( CFF_Face face, + FT_UInt num_coords, + FT_Fixed* coords ) + { + FT_Service_MultiMasters mm = (FT_Service_MultiMasters)face->mm; + + + return mm->get_var_design( FT_FACE( face ), num_coords, coords ); + } + + + FT_DEFINE_SERVICE_MULTIMASTERSREC( + cff_service_multi_masters, + + (FT_Get_MM_Func) NULL, /* get_mm */ + (FT_Set_MM_Design_Func) NULL, /* set_mm_design */ + (FT_Set_MM_Blend_Func) cff_set_mm_blend, /* set_mm_blend */ + (FT_Get_MM_Blend_Func) cff_get_mm_blend, /* get_mm_blend */ + (FT_Get_MM_Var_Func) cff_get_mm_var, /* get_mm_var */ + (FT_Set_Var_Design_Func)cff_set_var_design, /* set_var_design */ + (FT_Get_Var_Design_Func)cff_get_var_design, /* get_var_design */ + + (FT_Get_Var_Blend_Func) cff_get_var_blend, /* get_var_blend */ + (FT_Done_Blend_Func) cff_done_blend /* done_blend */ + ) + + + /* + * METRICS VARIATIONS SERVICE + * + */ + + static FT_Error + cff_hadvance_adjust( CFF_Face face, + FT_UInt gindex, + FT_Int *avalue ) + { + FT_Service_MetricsVariations var = (FT_Service_MetricsVariations)face->var; + + + return var->hadvance_adjust( FT_FACE( face ), gindex, avalue ); + } + + + static void + cff_metrics_adjust( CFF_Face face ) + { + FT_Service_MetricsVariations var = (FT_Service_MetricsVariations)face->var; + + + var->metrics_adjust( FT_FACE( face ) ); + } + + + FT_DEFINE_SERVICE_METRICSVARIATIONSREC( + cff_service_metrics_variations, + + (FT_HAdvance_Adjust_Func)cff_hadvance_adjust, /* hadvance_adjust */ + (FT_LSB_Adjust_Func) NULL, /* lsb_adjust */ + (FT_RSB_Adjust_Func) NULL, /* rsb_adjust */ + + (FT_VAdvance_Adjust_Func)NULL, /* vadvance_adjust */ + (FT_TSB_Adjust_Func) NULL, /* tsb_adjust */ + (FT_BSB_Adjust_Func) NULL, /* bsb_adjust */ + (FT_VOrg_Adjust_Func) NULL, /* vorg_adjust */ + + (FT_Metrics_Adjust_Func) cff_metrics_adjust /* metrics_adjust */ + ) +#endif + + /*************************************************************************/ /*************************************************************************/ /*************************************************************************/ @@ -799,9 +1100,25 @@ /*************************************************************************/ /*************************************************************************/ -#ifndef FT_CONFIG_OPTION_NO_GLYPH_NAMES +#if !defined FT_CONFIG_OPTION_NO_GLYPH_NAMES && \ + defined TT_CONFIG_OPTION_GX_VAR_SUPPORT + FT_DEFINE_SERVICEDESCREC9( + cff_services, + + FT_SERVICE_ID_FONT_FORMAT, FT_FONT_FORMAT_CFF, + FT_SERVICE_ID_MULTI_MASTERS, &CFF_SERVICE_MULTI_MASTERS_GET, + FT_SERVICE_ID_METRICS_VARIATIONS, &CFF_SERVICE_METRICS_VAR_GET, + FT_SERVICE_ID_POSTSCRIPT_INFO, &CFF_SERVICE_PS_INFO_GET, + FT_SERVICE_ID_POSTSCRIPT_FONT_NAME, &CFF_SERVICE_PS_NAME_GET, + FT_SERVICE_ID_GLYPH_DICT, &CFF_SERVICE_GLYPH_DICT_GET, + FT_SERVICE_ID_TT_CMAP, &CFF_SERVICE_GET_CMAP_INFO_GET, + FT_SERVICE_ID_CID, &CFF_SERVICE_CID_INFO_GET, + FT_SERVICE_ID_PROPERTIES, &CFF_SERVICE_PROPERTIES_GET + ) +#elif !defined FT_CONFIG_OPTION_NO_GLYPH_NAMES FT_DEFINE_SERVICEDESCREC7( cff_services, + FT_SERVICE_ID_FONT_FORMAT, FT_FONT_FORMAT_CFF, FT_SERVICE_ID_POSTSCRIPT_INFO, &CFF_SERVICE_PS_INFO_GET, FT_SERVICE_ID_POSTSCRIPT_FONT_NAME, &CFF_SERVICE_PS_NAME_GET, @@ -810,9 +1127,23 @@ FT_SERVICE_ID_CID, &CFF_SERVICE_CID_INFO_GET, FT_SERVICE_ID_PROPERTIES, &CFF_SERVICE_PROPERTIES_GET ) +#elif defined TT_CONFIG_OPTION_GX_VAR_SUPPORT + FT_DEFINE_SERVICEDESCREC8( + cff_services, + + FT_SERVICE_ID_FONT_FORMAT, FT_FONT_FORMAT_CFF, + FT_SERVICE_ID_MULTI_MASTERS, &CFF_SERVICE_MULTI_MASTERS_GET, + FT_SERVICE_ID_METRICS_VARIATIONS, &CFF_SERVICE_METRICS_VAR_GET, + FT_SERVICE_ID_POSTSCRIPT_INFO, &CFF_SERVICE_PS_INFO_GET, + FT_SERVICE_ID_POSTSCRIPT_FONT_NAME, &CFF_SERVICE_PS_NAME_GET, + FT_SERVICE_ID_TT_CMAP, &CFF_SERVICE_GET_CMAP_INFO_GET, + FT_SERVICE_ID_CID, &CFF_SERVICE_CID_INFO_GET, + FT_SERVICE_ID_PROPERTIES, &CFF_SERVICE_PROPERTIES_GET + ) #else FT_DEFINE_SERVICEDESCREC6( cff_services, + FT_SERVICE_ID_FONT_FORMAT, FT_FONT_FORMAT_CFF, FT_SERVICE_ID_POSTSCRIPT_INFO, &CFF_SERVICE_PS_INFO_GET, FT_SERVICE_ID_POSTSCRIPT_FONT_NAME, &CFF_SERVICE_PS_NAME_GET, @@ -842,7 +1173,7 @@ #endif result = ft_service_list_lookup( CFF_SERVICES_GET, module_interface ); - if ( result != NULL ) + if ( result ) return result; /* `driver' is not yet evaluated in non-PIC mode */ @@ -882,7 +1213,7 @@ 0x10000L, 0x20000L, - 0, /* module-specific interface */ + NULL, /* module-specific interface */ cff_driver_init, /* FT_Module_Constructor module_init */ cff_driver_done, /* FT_Module_Destructor module_done */ @@ -902,7 +1233,7 @@ cff_glyph_load, /* FT_Slot_LoadFunc load_glyph */ cff_get_kerning, /* FT_Face_GetKerningFunc get_kerning */ - 0, /* FT_Face_AttachFunc attach_file */ + NULL, /* FT_Face_AttachFunc attach_file */ cff_get_advances, /* FT_Face_GetAdvancesFunc get_advances */ cff_size_request, /* FT_Size_RequestFunc request_size */ diff --git a/thirdparty/freetype/src/cff/cffdrivr.h b/thirdparty/freetype/src/cff/cffdrivr.h index d7b0598374..05381e66db 100644 --- a/thirdparty/freetype/src/cff/cffdrivr.h +++ b/thirdparty/freetype/src/cff/cffdrivr.h @@ -4,7 +4,7 @@ /* */ /* High-level OpenType driver interface (specification). */ /* */ -/* Copyright 1996-2016 by */ +/* Copyright 1996-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/thirdparty/freetype/src/cff/cfferrs.h b/thirdparty/freetype/src/cff/cfferrs.h index e7fc6eb71c..40808c1051 100644 --- a/thirdparty/freetype/src/cff/cfferrs.h +++ b/thirdparty/freetype/src/cff/cfferrs.h @@ -4,7 +4,7 @@ /* */ /* CFF error codes (specification only). */ /* */ -/* Copyright 2001-2016 by */ +/* Copyright 2001-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/thirdparty/freetype/src/cff/cffgload.c b/thirdparty/freetype/src/cff/cffgload.c index 752c18ed92..940804850e 100644 --- a/thirdparty/freetype/src/cff/cffgload.c +++ b/thirdparty/freetype/src/cff/cffgload.c @@ -4,7 +4,7 @@ /* */ /* OpenType Glyph Loader (body). */ /* */ -/* Copyright 1996-2016 by */ +/* Copyright 1996-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -278,11 +278,15 @@ if ( hinting && size ) { - CFF_Internal internal = (CFF_Internal)size->root.internal; + FT_Size ftsize = FT_SIZE( size ); + CFF_Internal internal = (CFF_Internal)ftsize->internal->module_data; - builder->hints_globals = (void *)internal->topfont; - builder->hints_funcs = glyph->root.internal->glyph_hints; + if ( internal ) + { + builder->hints_globals = (void *)internal->topfont; + builder->hints_funcs = glyph->root.internal->glyph_hints; + } } } @@ -391,7 +395,7 @@ /* clear everything */ - FT_MEM_ZERO( decoder, sizeof ( *decoder ) ); + FT_ZERO( decoder ); /* initialize builder */ cff_builder_init( &decoder->builder, face, size, slot, hinting ); @@ -440,7 +444,8 @@ if ( builder->hints_funcs && size ) { - CFF_Internal internal = (CFF_Internal)size->root.internal; + FT_Size ftsize = FT_SIZE( size ); + CFF_Internal internal = (CFF_Internal)ftsize->internal->module_data; /* for CFFs without subfonts, this value has already been set */ @@ -457,7 +462,7 @@ decoder->glyph_width = sub->private_dict.default_width; decoder->nominal_width = sub->private_dict.nominal_width; - decoder->current_subfont = sub; /* for Adobe's CFF handler */ + decoder->current_subfont = sub; Exit: return error; @@ -913,7 +918,6 @@ FT_Byte* limit; CFF_Builder* builder = &decoder->builder; FT_Pos x, y; - FT_Fixed seed; FT_Fixed* stack; FT_Int charstring_type = decoder->cff->top_font.font_dict.charstring_type; @@ -929,15 +933,6 @@ decoder->num_hints = 0; decoder->read_width = 1; - /* compute random seed from stack address of parameter */ - seed = (FT_Fixed)( ( (FT_Offset)(char*)&seed ^ - (FT_Offset)(char*)&decoder ^ - (FT_Offset)(char*)&charstring_base ) & - FT_ULONG_MAX ); - seed = ( seed ^ ( seed >> 10 ) ^ ( seed >> 20 ) ) & 0xFFFFL; - if ( seed == 0 ) - seed = 0x7384; - /* initialize the decoder */ decoder->top = decoder->stack; decoder->zone = decoder->zones; @@ -1026,7 +1021,7 @@ if ( !( val & 0xFFFFL ) ) FT_TRACE4(( " %hd", (FT_Short)( (FT_UInt32)val >> 16 ) )); else - FT_TRACE4(( " %.2f", val / 65536.0 )); + FT_TRACE4(( " %.5f", val / 65536.0 )); #endif } @@ -2104,22 +2099,16 @@ break; case cff_op_random: - { - FT_Fixed Rand; - + FT_TRACE4(( " random\n" )); - FT_TRACE4(( " rand\n" )); - - Rand = seed; - if ( Rand >= 0x8000L ) - Rand++; + /* only use the lower 16 bits of `random' */ + /* to generate a number in the range (0;1] */ + args[0] = (FT_Fixed) + ( ( decoder->current_subfont->random & 0xFFFF ) + 1 ); + args++; - args[0] = Rand; - seed = FT_MulFix( seed, 0x10000L - seed ); - if ( seed == 0 ) - seed += 0x2873; - args++; - } + decoder->current_subfont->random = + cff_random( decoder->current_subfont->random ); break; case cff_op_mul: @@ -2445,7 +2434,7 @@ case cff_op_and: { - FT_Fixed cond = args[0] && args[1]; + FT_Fixed cond = ( args[0] && args[1] ); FT_TRACE4(( " and\n" )); @@ -2457,7 +2446,7 @@ case cff_op_or: { - FT_Fixed cond = args[0] || args[1]; + FT_Fixed cond = ( args[0] || args[1] ); FT_TRACE4(( " or\n" )); @@ -2481,7 +2470,7 @@ case cff_op_eq: { - FT_Fixed cond = args[0] == args[1]; + FT_Fixed cond = ( args[0] == args[1] ); FT_TRACE4(( " eq\n" )); @@ -2942,6 +2931,7 @@ cff_decoder_init( &decoder, face, size, glyph, hinting, FT_LOAD_TARGET_MODE( load_flags ) ); + /* this is for pure CFFs */ if ( load_flags & FT_LOAD_ADVANCE_ONLY ) decoder.width_only = TRUE; diff --git a/thirdparty/freetype/src/cff/cffgload.h b/thirdparty/freetype/src/cff/cffgload.h index b875fbed90..0fa93b4398 100644 --- a/thirdparty/freetype/src/cff/cffgload.h +++ b/thirdparty/freetype/src/cff/cffgload.h @@ -4,7 +4,7 @@ /* */ /* OpenType Glyph Loader (specification). */ /* */ -/* Copyright 1996-2016 by */ +/* Copyright 1996-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/thirdparty/freetype/src/cff/cffload.c b/thirdparty/freetype/src/cff/cffload.c index 3d1bda97b9..3beaeb1c8e 100644 --- a/thirdparty/freetype/src/cff/cffload.c +++ b/thirdparty/freetype/src/cff/cffload.c @@ -4,7 +4,7 @@ /* */ /* OpenType and CFF data/program tables loader (body). */ /* */ -/* Copyright 1996-2016 by */ +/* Copyright 1996-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -23,12 +23,20 @@ #include FT_TRUETYPE_TAGS_H #include FT_TYPE1_TABLES_H +#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT +#include FT_MULTIPLE_MASTERS_H +#include FT_SERVICE_MULTIPLE_MASTERS_H +#endif + #include "cffload.h" #include "cffparse.h" #include "cfferrs.h" +#define FT_FIXED_ONE ( (FT_Fixed)0x10000 ) + + #if 1 static const FT_UShort cff_isoadobe_charset[229] = @@ -225,19 +233,33 @@ static FT_Error cff_index_init( CFF_Index idx, FT_Stream stream, - FT_Bool load ) + FT_Bool load, + FT_Bool cff2 ) { FT_Error error; FT_Memory memory = stream->memory; - FT_UShort count; + FT_UInt count; - FT_MEM_ZERO( idx, sizeof ( *idx ) ); + FT_ZERO( idx ); idx->stream = stream; idx->start = FT_STREAM_POS(); - if ( !FT_READ_USHORT( count ) && - count > 0 ) + + if ( cff2 ) + { + if ( FT_READ_ULONG( count ) ) + goto Exit; + idx->hdr_size = 5; + } + else + { + if ( FT_READ_USHORT( count ) ) + goto Exit; + idx->hdr_size = 3; + } + + if ( count > 0 ) { FT_Byte offsize; FT_ULong size; @@ -258,7 +280,7 @@ idx->off_size = offsize; size = (FT_ULong)( count + 1 ) * offsize; - idx->data_offset = idx->start + 3 + size; + idx->data_offset = idx->start + idx->hdr_size + size; if ( FT_STREAM_SKIP( size - offsize ) ) goto Exit; @@ -310,7 +332,7 @@ FT_FRAME_RELEASE( idx->bytes ); FT_FREE( idx->offsets ); - FT_MEM_ZERO( idx, sizeof ( *idx ) ); + FT_ZERO( idx ); } } @@ -323,7 +345,7 @@ FT_Memory memory = stream->memory; - if ( idx->count > 0 && idx->offsets == NULL ) + if ( idx->count > 0 && !idx->offsets ) { FT_Byte offsize = idx->off_size; FT_ULong data_size; @@ -335,7 +357,7 @@ data_size = (FT_ULong)( idx->count + 1 ) * offsize; if ( FT_NEW_ARRAY( idx->offsets, idx->count + 1 ) || - FT_STREAM_SEEK( idx->start + 3 ) || + FT_STREAM_SEEK( idx->start + idx->hdr_size ) || FT_FRAME_ENTER( data_size ) ) goto Exit; @@ -395,7 +417,7 @@ *table = NULL; - if ( idx->offsets == NULL ) + if ( !idx->offsets ) { error = cff_index_load_offsets( idx ); if ( error ) @@ -493,7 +515,7 @@ FT_ULong pos = element * idx->off_size; - if ( FT_STREAM_SEEK( idx->start + 3 + pos ) ) + if ( FT_STREAM_SEEK( idx->start + idx->hdr_size + pos ) ) goto Exit; off1 = cff_index_read_offset( idx, &error ); @@ -589,20 +611,26 @@ FT_UInt element ) { CFF_Index idx = &font->name_index; - FT_Memory memory = idx->stream->memory; + FT_Memory memory; FT_Byte* bytes; FT_ULong byte_len; FT_Error error; FT_String* name = 0; + if ( !idx->stream ) /* CFF2 does not include a name index */ + goto Exit; + + memory = idx->stream->memory; + error = cff_index_access_element( idx, element, &bytes, &byte_len ); if ( error ) goto Exit; if ( !FT_ALLOC( name, byte_len + 1 ) ) { - FT_MEM_COPY( name, bytes, byte_len ); + if ( byte_len ) + FT_MEM_COPY( name, bytes, byte_len ); name[byte_len] = 0; } cff_index_forget_element( idx, &bytes ); @@ -724,6 +752,11 @@ FT_Byte fd = 0; + /* if there is no FDSelect, return zero */ + /* Note: CFF2 with just one Font Dict has no FDSelect */ + if ( !fdselect->data ) + goto Exit; + switch ( fdselect->format ) { case 0: @@ -776,6 +809,7 @@ ; } + Exit: return fd; } @@ -1053,6 +1087,522 @@ } + static void + cff_vstore_done( CFF_VStoreRec* vstore, + FT_Memory memory ) + { + FT_UInt i; + + + /* free regionList and axisLists */ + if ( vstore->varRegionList ) + { + for ( i = 0; i < vstore->regionCount; i++ ) + FT_FREE( vstore->varRegionList[i].axisList ); + } + FT_FREE( vstore->varRegionList ); + + /* free varData and indices */ + if ( vstore->varData ) + { + for ( i = 0; i < vstore->dataCount; i++ ) + FT_FREE( vstore->varData[i].regionIndices ); + } + FT_FREE( vstore->varData ); + } + + + /* convert 2.14 to Fixed */ + #define FT_fdot14ToFixed( x ) ( (FT_Fixed)( (FT_ULong)(x) << 2 ) ) + + + static FT_Error + cff_vstore_load( CFF_VStoreRec* vstore, + FT_Stream stream, + FT_ULong base_offset, + FT_ULong offset ) + { + FT_Memory memory = stream->memory; + FT_Error error = FT_ERR( Invalid_File_Format ); + + FT_ULong* dataOffsetArray = NULL; + FT_UInt i, j; + + + /* no offset means no vstore to parse */ + if ( offset ) + { + FT_UInt vsOffset; + FT_UInt format; + FT_ULong regionListOffset; + + + /* we need to parse the table to determine its size; */ + /* skip table length */ + if ( FT_STREAM_SEEK( base_offset + offset ) || + FT_STREAM_SKIP( 2 ) ) + goto Exit; + + /* actual variation store begins after the length */ + vsOffset = FT_STREAM_POS(); + + /* check the header */ + if ( FT_READ_USHORT( format ) ) + goto Exit; + if ( format != 1 ) + { + error = FT_THROW( Invalid_File_Format ); + goto Exit; + } + + /* read top level fields */ + if ( FT_READ_ULONG( regionListOffset ) || + FT_READ_USHORT( vstore->dataCount ) ) + goto Exit; + + /* make temporary copy of item variation data offsets; */ + /* we'll parse region list first, then come back */ + if ( FT_NEW_ARRAY( dataOffsetArray, vstore->dataCount ) ) + goto Exit; + + for ( i = 0; i < vstore->dataCount; i++ ) + { + if ( FT_READ_ULONG( dataOffsetArray[i] ) ) + goto Exit; + } + + /* parse regionList and axisLists */ + if ( FT_STREAM_SEEK( vsOffset + regionListOffset ) || + FT_READ_USHORT( vstore->axisCount ) || + FT_READ_USHORT( vstore->regionCount ) ) + goto Exit; + + if ( FT_NEW_ARRAY( vstore->varRegionList, vstore->regionCount ) ) + goto Exit; + + for ( i = 0; i < vstore->regionCount; i++ ) + { + CFF_VarRegion* region = &vstore->varRegionList[i]; + + + if ( FT_NEW_ARRAY( region->axisList, vstore->axisCount ) ) + goto Exit; + + for ( j = 0; j < vstore->axisCount; j++ ) + { + CFF_AxisCoords* axis = ®ion->axisList[j]; + + FT_Int16 start14, peak14, end14; + + + if ( FT_READ_SHORT( start14 ) || + FT_READ_SHORT( peak14 ) || + FT_READ_SHORT( end14 ) ) + goto Exit; + + axis->startCoord = FT_fdot14ToFixed( start14 ); + axis->peakCoord = FT_fdot14ToFixed( peak14 ); + axis->endCoord = FT_fdot14ToFixed( end14 ); + } + } + + /* use dataOffsetArray now to parse varData items */ + if ( FT_NEW_ARRAY( vstore->varData, vstore->dataCount ) ) + goto Exit; + + for ( i = 0; i < vstore->dataCount; i++ ) + { + CFF_VarData* data = &vstore->varData[i]; + + + if ( FT_STREAM_SEEK( vsOffset + dataOffsetArray[i] ) ) + goto Exit; + + /* ignore `itemCount' and `shortDeltaCount' */ + /* because CFF2 has no delta sets */ + if ( FT_STREAM_SKIP( 4 ) ) + goto Exit; + + /* Note: just record values; consistency is checked later */ + /* by cff_blend_build_vector when it consumes `vstore' */ + + if ( FT_READ_USHORT( data->regionIdxCount ) ) + goto Exit; + + if ( FT_NEW_ARRAY( data->regionIndices, data->regionIdxCount ) ) + goto Exit; + + for ( j = 0; j < data->regionIdxCount; j++ ) + { + if ( FT_READ_USHORT( data->regionIndices[j] ) ) + goto Exit; + } + } + } + + error = FT_Err_Ok; + + Exit: + FT_FREE( dataOffsetArray ); + if ( error ) + cff_vstore_done( vstore, memory ); + + return error; + } + + + /* Clear blend stack (after blend values are consumed). */ + /* */ + /* TODO: Should do this in cff_run_parse, but subFont */ + /* ref is not available there. */ + /* */ + /* Allocation is not changed when stack is cleared. */ + FT_LOCAL_DEF( void ) + cff_blend_clear( CFF_SubFont subFont ) + { + subFont->blend_top = subFont->blend_stack; + subFont->blend_used = 0; + } + + + /* Blend numOperands on the stack, */ + /* store results into the first numBlends values, */ + /* then pop remaining arguments. */ + /* */ + /* This is comparable to `cf2_doBlend' but */ + /* the cffparse stack is different and can't be written. */ + /* Blended values are written to a different buffer, */ + /* using reserved operator 255. */ + /* */ + /* Blend calculation is done in 16.16 fixed point. */ + FT_LOCAL_DEF( FT_Error ) + cff_blend_doBlend( CFF_SubFont subFont, + CFF_Parser parser, + FT_UInt numBlends ) + { + FT_UInt delta; + FT_UInt base; + FT_UInt i, j; + FT_UInt size; + + CFF_Blend blend = &subFont->blend; + + FT_Memory memory = subFont->blend.font->memory; /* for FT_REALLOC */ + FT_Error error = FT_Err_Ok; /* for FT_REALLOC */ + + /* compute expected number of operands for this blend */ + FT_UInt numOperands = (FT_UInt)( numBlends * blend->lenBV ); + FT_UInt count = (FT_UInt)( parser->top - 1 - parser->stack ); + + + if ( numOperands > count ) + { + FT_TRACE4(( " cff_blend_doBlend: Stack underflow %d args\n", count )); + + error = FT_THROW( Stack_Underflow ); + goto Exit; + } + + /* check whether we have room for `numBlends' values at `blend_top' */ + size = 5 * numBlends; /* add 5 bytes per entry */ + if ( subFont->blend_used + size > subFont->blend_alloc ) + { + FT_Byte* blend_stack_old = subFont->blend_stack; + FT_Byte* blend_top_old = subFont->blend_top; + + + /* increase or allocate `blend_stack' and reset `blend_top'; */ + /* prepare to append `numBlends' values to the buffer */ + if ( FT_REALLOC( subFont->blend_stack, + subFont->blend_alloc, + subFont->blend_alloc + size ) ) + goto Exit; + + subFont->blend_top = subFont->blend_stack + subFont->blend_used; + subFont->blend_alloc += size; + + /* iterate over the parser stack and adjust pointers */ + /* if the reallocated buffer has a different address */ + if ( blend_stack_old && + subFont->blend_stack != blend_stack_old ) + { + FT_PtrDist offset = subFont->blend_stack - blend_stack_old; + FT_Byte** p; + + + for ( p = parser->stack; p < parser->top; p++ ) + { + if ( *p >= blend_stack_old && *p < blend_top_old ) + *p += offset; + } + } + } + subFont->blend_used += size; + + base = count - numOperands; /* index of first blend arg */ + delta = base + numBlends; /* index of first delta arg */ + + for ( i = 0; i < numBlends; i++ ) + { + const FT_Int32* weight = &blend->BV[1]; + FT_Int32 sum; + + + /* convert inputs to 16.16 fixed point */ + sum = cff_parse_num( parser, &parser->stack[i + base] ) * 65536; + + for ( j = 1; j < blend->lenBV; j++ ) + sum += FT_MulFix( *weight++, + cff_parse_num( parser, + &parser->stack[delta++] ) * 65536 ); + + /* point parser stack to new value on blend_stack */ + parser->stack[i + base] = subFont->blend_top; + + /* Push blended result as Type 2 5-byte fixed point number. This */ + /* will not conflict with actual DICTs because 255 is a reserved */ + /* opcode in both CFF and CFF2 DICTs. See `cff_parse_num' for */ + /* decode of this, which rounds to an integer. */ + *subFont->blend_top++ = 255; + *subFont->blend_top++ = ( (FT_UInt32)sum & 0xFF000000U ) >> 24; + *subFont->blend_top++ = ( (FT_UInt32)sum & 0x00FF0000U ) >> 16; + *subFont->blend_top++ = ( (FT_UInt32)sum & 0x0000FF00U ) >> 8; + *subFont->blend_top++ = (FT_UInt32)sum & 0x000000FFU; + } + + /* leave only numBlends results on parser stack */ + parser->top = &parser->stack[base + numBlends]; + + Exit: + return error; + } + + + /* Compute a blend vector from variation store index and normalized */ + /* vector based on pseudo-code in OpenType Font Variations Overview. */ + /* */ + /* Note: lenNDV == 0 produces a default blend vector, (1,0,0,...). */ + FT_LOCAL_DEF( FT_Error ) + cff_blend_build_vector( CFF_Blend blend, + FT_UInt vsindex, + FT_UInt lenNDV, + FT_Fixed* NDV ) + { + FT_Error error = FT_Err_Ok; /* for FT_REALLOC */ + FT_Memory memory = blend->font->memory; /* for FT_REALLOC */ + + FT_UInt len; + CFF_VStore vs; + CFF_VarData* varData; + FT_UInt master; + + + FT_ASSERT( lenNDV == 0 || NDV ); + + blend->builtBV = FALSE; + + vs = &blend->font->vstore; + + /* VStore and fvar must be consistent */ + if ( lenNDV != 0 && lenNDV != vs->axisCount ) + { + FT_TRACE4(( " cff_blend_build_vector: Axis count mismatch\n" )); + error = FT_THROW( Invalid_File_Format ); + goto Exit; + } + + if ( vsindex >= vs->dataCount ) + { + FT_TRACE4(( " cff_blend_build_vector: vsindex out of range\n" )); + error = FT_THROW( Invalid_File_Format ); + goto Exit; + } + + /* select the item variation data structure */ + varData = &vs->varData[vsindex]; + + /* prepare buffer for the blend vector */ + len = varData->regionIdxCount + 1; /* add 1 for default component */ + if ( FT_REALLOC( blend->BV, + blend->lenBV * sizeof( *blend->BV ), + len * sizeof( *blend->BV ) ) ) + goto Exit; + + blend->lenBV = len; + + /* outer loop steps through master designs to be blended */ + for ( master = 0; master < len; master++ ) + { + FT_UInt j; + FT_UInt idx; + CFF_VarRegion* varRegion; + + + /* default factor is always one */ + if ( master == 0 ) + { + blend->BV[master] = FT_FIXED_ONE; + FT_TRACE4(( " build blend vector len %d\n" + " [ %f ", + len, + blend->BV[master] / 65536.0 )); + continue; + } + + /* VStore array does not include default master, so subtract one */ + idx = varData->regionIndices[master - 1]; + varRegion = &vs->varRegionList[idx]; + + if ( idx >= vs->regionCount ) + { + FT_TRACE4(( " cff_blend_build_vector:" + " region index out of range\n" )); + error = FT_THROW( Invalid_File_Format ); + goto Exit; + } + + /* Note: `lenNDV' could be zero. */ + /* In that case, build default blend vector (1,0,0...). */ + if ( !lenNDV ) + { + blend->BV[master] = 0; + continue; + } + + /* In the normal case, initialize each component to 1 */ + /* before inner loop. */ + blend->BV[master] = FT_FIXED_ONE; /* default */ + + /* inner loop steps through axes in this region */ + for ( j = 0; j < lenNDV; j++ ) + { + CFF_AxisCoords* axis = &varRegion->axisList[j]; + FT_Fixed axisScalar; + + + /* compute the scalar contribution of this axis; */ + /* ignore invalid ranges */ + if ( axis->startCoord > axis->peakCoord || + axis->peakCoord > axis->endCoord ) + axisScalar = FT_FIXED_ONE; + + else if ( axis->startCoord < 0 && + axis->endCoord > 0 && + axis->peakCoord != 0 ) + axisScalar = FT_FIXED_ONE; + + /* peak of 0 means ignore this axis */ + else if ( axis->peakCoord == 0 ) + axisScalar = FT_FIXED_ONE; + + /* ignore this region if coords are out of range */ + else if ( NDV[j] < axis->startCoord || + NDV[j] > axis->endCoord ) + axisScalar = 0; + + /* calculate a proportional factor */ + else + { + if ( NDV[j] == axis->peakCoord ) + axisScalar = FT_FIXED_ONE; + else if ( NDV[j] < axis->peakCoord ) + axisScalar = FT_DivFix( NDV[j] - axis->startCoord, + axis->peakCoord - axis->startCoord ); + else + axisScalar = FT_DivFix( axis->endCoord - NDV[j], + axis->endCoord - axis->peakCoord ); + } + + /* take product of all the axis scalars */ + blend->BV[master] = FT_MulFix( blend->BV[master], axisScalar ); + } + + FT_TRACE4(( ", %f ", + blend->BV[master] / 65536.0 )); + } + + FT_TRACE4(( "]\n" )); + + /* record the parameters used to build the blend vector */ + blend->lastVsindex = vsindex; + + if ( lenNDV != 0 ) + { + /* user has set a normalized vector */ + if ( FT_REALLOC( blend->lastNDV, + blend->lenNDV * sizeof ( *NDV ), + lenNDV * sizeof ( *NDV ) ) ) + goto Exit; + + FT_MEM_COPY( blend->lastNDV, + NDV, + lenNDV * sizeof ( *NDV ) ); + } + + blend->lenNDV = lenNDV; + blend->builtBV = TRUE; + + Exit: + return error; + } + + + /* `lenNDV' is zero for default vector; */ + /* return TRUE if blend vector needs to be built. */ + FT_LOCAL_DEF( FT_Bool ) + cff_blend_check_vector( CFF_Blend blend, + FT_UInt vsindex, + FT_UInt lenNDV, + FT_Fixed* NDV ) + { + if ( !blend->builtBV || + blend->lastVsindex != vsindex || + blend->lenNDV != lenNDV || + ( lenNDV && + memcmp( NDV, + blend->lastNDV, + lenNDV * sizeof ( *NDV ) ) != 0 ) ) + { + /* need to build blend vector */ + return TRUE; + } + + return FALSE; + } + + +#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT + + FT_LOCAL_DEF( FT_Error ) + cff_get_var_blend( CFF_Face face, + FT_UInt *num_coords, + FT_Fixed* *coords, + FT_Fixed* *normalizedcoords, + FT_MM_Var* *mm_var ) + { + FT_Service_MultiMasters mm = (FT_Service_MultiMasters)face->mm; + + + return mm->get_var_blend( FT_FACE( face ), + num_coords, + coords, + normalizedcoords, + mm_var ); + } + + + FT_LOCAL_DEF( void ) + cff_done_blend( CFF_Face face ) + { + FT_Service_MultiMasters mm = (FT_Service_MultiMasters)face->mm; + + + mm->done_blend( FT_FACE( face ) ); + } + +#endif /* TT_CONFIG_OPTION_GX_VAR_SUPPORT */ + + static void cff_encoding_done( CFF_Encoding encoding ) { @@ -1305,31 +1855,148 @@ } + /* Parse private dictionary; first call is always from `cff_face_init', */ + /* so NDV has not been set for CFF2 variation. */ + /* */ + /* `cff_slot_load' must call this function each time NDV changes. */ + FT_LOCAL_DEF( FT_Error ) + cff_load_private_dict( CFF_Font font, + CFF_SubFont subfont, + FT_UInt lenNDV, + FT_Fixed* NDV ) + { + FT_Error error = FT_Err_Ok; + CFF_ParserRec parser; + CFF_FontRecDict top = &subfont->font_dict; + CFF_Private priv = &subfont->private_dict; + FT_Stream stream = font->stream; + FT_UInt stackSize; + + + /* store handle needed to access memory, vstore for blend; */ + /* we need this for clean-up even if there is no private DICT */ + subfont->blend.font = font; + subfont->blend.usedBV = FALSE; /* clear state */ + + if ( !top->private_offset || !top->private_size ) + goto Exit2; /* no private DICT, do nothing */ + + /* set defaults */ + FT_ZERO( priv ); + + priv->blue_shift = 7; + priv->blue_fuzz = 1; + priv->lenIV = -1; + priv->expansion_factor = (FT_Fixed)( 0.06 * 0x10000L ); + priv->blue_scale = (FT_Fixed)( 0.039625 * 0x10000L * 1000 ); + + /* provide inputs for blend calculations */ + priv->subfont = subfont; + subfont->lenNDV = lenNDV; + subfont->NDV = NDV; + + /* add 1 for the operator */ + stackSize = font->cff2 ? font->top_font.font_dict.maxstack + 1 + : CFF_MAX_STACK_DEPTH + 1; + + if ( cff_parser_init( &parser, + font->cff2 ? CFF2_CODE_PRIVATE : CFF_CODE_PRIVATE, + priv, + font->library, + stackSize, + top->num_designs, + top->num_axes ) ) + goto Exit; + + if ( FT_STREAM_SEEK( font->base_offset + top->private_offset ) || + FT_FRAME_ENTER( top->private_size ) ) + goto Exit; + + FT_TRACE4(( " private dictionary:\n" )); + error = cff_parser_run( &parser, + (FT_Byte*)stream->cursor, + (FT_Byte*)stream->limit ); + FT_FRAME_EXIT(); + + if ( error ) + goto Exit; + + /* ensure that `num_blue_values' is even */ + priv->num_blue_values &= ~1; + + /* sanitize `initialRandomSeed' to be a positive value, if necessary; */ + /* this is not mandated by the specification but by our implementation */ + if ( priv->initial_random_seed < 0 ) + priv->initial_random_seed = -priv->initial_random_seed; + else if ( priv->initial_random_seed == 0 ) + priv->initial_random_seed = 987654321; + + Exit: + /* clean up */ + cff_blend_clear( subfont ); /* clear blend stack */ + cff_parser_done( &parser ); /* free parser stack */ + + Exit2: + /* no clean up (parser not initialized) */ + return error; + } + + + FT_LOCAL_DEF( FT_UInt32 ) + cff_random( FT_UInt32 r ) + { + /* a 32bit version of the `xorshift' algorithm */ + r ^= r << 13; + r ^= r >> 17; + r ^= r << 5; + + return r; + } + + + /* There are 3 ways to call this function, distinguished by code. */ + /* */ + /* . CFF_CODE_TOPDICT for either a CFF Top DICT or a CFF Font DICT */ + /* . CFF2_CODE_TOPDICT for CFF2 Top DICT */ + /* . CFF2_CODE_FONTDICT for CFF2 Font DICT */ + static FT_Error - cff_subfont_load( CFF_SubFont font, + cff_subfont_load( CFF_SubFont subfont, CFF_Index idx, FT_UInt font_index, FT_Stream stream, FT_ULong base_offset, - FT_Library library ) + FT_UInt code, + CFF_Font font, + CFF_Face face ) { FT_Error error; CFF_ParserRec parser; FT_Byte* dict = NULL; FT_ULong dict_len; - CFF_FontRecDict top = &font->font_dict; - CFF_Private priv = &font->private_dict; - - - cff_parser_init( &parser, - CFF_CODE_TOPDICT, - &font->font_dict, - library, - 0, - 0 ); + CFF_FontRecDict top = &subfont->font_dict; + CFF_Private priv = &subfont->private_dict; + + FT_Bool cff2 = FT_BOOL( code == CFF2_CODE_TOPDICT || + code == CFF2_CODE_FONTDICT ); + FT_UInt stackSize = cff2 ? CFF2_DEFAULT_STACK + : CFF_MAX_STACK_DEPTH; + + + /* Note: We use default stack size for CFF2 Font DICT because */ + /* Top and Font DICTs are not allowed to have blend operators. */ + error = cff_parser_init( &parser, + code, + &subfont->font_dict, + font->library, + stackSize, + 0, + 0 ); + if ( error ) + goto Exit; /* set defaults */ - FT_MEM_ZERO( top, sizeof ( *top ) ); + FT_ZERO( top ); top->underline_position = -( 100L << 16 ); top->underline_thickness = 50L << 16; @@ -1352,14 +2019,35 @@ top->cid_ordering = 0xFFFFU; top->cid_font_name = 0xFFFFU; - error = cff_index_access_element( idx, font_index, &dict, &dict_len ); + /* set default stack size */ + top->maxstack = cff2 ? CFF2_DEFAULT_STACK : 48; + + if ( idx->count ) /* count is nonzero for a real index */ + error = cff_index_access_element( idx, font_index, &dict, &dict_len ); + else + { + /* CFF2 has a fake top dict index; */ + /* simulate `cff_index_access_element' */ + + /* Note: macros implicitly use `stream' and set `error' */ + if ( FT_STREAM_SEEK( idx->data_offset ) || + FT_FRAME_EXTRACT( idx->data_size, dict ) ) + goto Exit; + + dict_len = idx->data_size; + } + if ( !error ) { FT_TRACE4(( " top dictionary:\n" )); error = cff_parser_run( &parser, dict, dict + dict_len ); } - cff_index_forget_element( idx, &dict ); + /* clean up regardless of error */ + if ( idx->count ) + cff_index_forget_element( idx, &dict ); + else + FT_FRAME_RELEASE( dict ); if ( error ) goto Exit; @@ -1368,39 +2056,62 @@ if ( top->cid_registry != 0xFFFFU ) goto Exit; - /* parse the private dictionary, if any */ - if ( top->private_offset && top->private_size ) + /* Parse the private dictionary, if any. */ + /* */ + /* CFF2 does not have a private dictionary in the Top DICT */ + /* but may have one in a Font DICT. We need to parse */ + /* the latter here in order to load any local subrs. */ + error = cff_load_private_dict( font, subfont, 0, 0 ); + if ( error ) + goto Exit; + + if ( !cff2 ) { - /* set defaults */ - FT_MEM_ZERO( priv, sizeof ( *priv ) ); - - priv->blue_shift = 7; - priv->blue_fuzz = 1; - priv->lenIV = -1; - priv->expansion_factor = (FT_Fixed)( 0.06 * 0x10000L ); - priv->blue_scale = (FT_Fixed)( 0.039625 * 0x10000L * 1000 ); - - cff_parser_init( &parser, - CFF_CODE_PRIVATE, - priv, - library, - top->num_designs, - top->num_axes ); - - if ( FT_STREAM_SEEK( base_offset + font->font_dict.private_offset ) || - FT_FRAME_ENTER( font->font_dict.private_size ) ) - goto Exit; + /* + * Initialize the random number generator. + * + * . If we have a face-specific seed, use it. + * If non-zero, update it to a positive value. + * + * . Otherwise, use the seed from the CFF driver. + * If non-zero, update it to a positive value. + * + * . If the random value is zero, use the seed given by the subfont's + * `initialRandomSeed' value. + * + */ + if ( face->root.internal->random_seed == -1 ) + { + CFF_Driver driver = (CFF_Driver)FT_FACE_DRIVER( face ); - FT_TRACE4(( " private dictionary:\n" )); - error = cff_parser_run( &parser, - (FT_Byte*)stream->cursor, - (FT_Byte*)stream->limit ); - FT_FRAME_EXIT(); - if ( error ) - goto Exit; - /* ensure that `num_blue_values' is even */ - priv->num_blue_values &= ~1; + subfont->random = (FT_UInt32)driver->random_seed; + if ( driver->random_seed ) + { + do + { + driver->random_seed = + (FT_Int32)cff_random( (FT_UInt32)driver->random_seed ); + + } while ( driver->random_seed < 0 ); + } + } + else + { + subfont->random = (FT_UInt32)face->root.internal->random_seed; + if ( face->root.internal->random_seed ) + { + do + { + face->root.internal->random_seed = + (FT_Int32)cff_random( (FT_UInt32)face->root.internal->random_seed ); + + } while ( face->root.internal->random_seed < 0 ); + } + } + + if ( !subfont->random ) + subfont->random = (FT_UInt32)priv->initial_random_seed; } /* read the local subrs, if any */ @@ -1410,17 +2121,19 @@ priv->local_subrs_offset ) ) goto Exit; - error = cff_index_init( &font->local_subrs_index, stream, 1 ); + error = cff_index_init( &subfont->local_subrs_index, stream, 1, cff2 ); if ( error ) goto Exit; - error = cff_index_get_pointers( &font->local_subrs_index, - &font->local_subrs, NULL, NULL ); + error = cff_index_get_pointers( &subfont->local_subrs_index, + &subfont->local_subrs, NULL, NULL ); if ( error ) goto Exit; } Exit: + cff_parser_done( &parser ); /* free parser stack */ + return error; } @@ -1433,6 +2146,10 @@ { cff_index_done( &subfont->local_subrs_index ); FT_FREE( subfont->local_subrs ); + + FT_FREE( subfont->blend.lastNDV ); + FT_FREE( subfont->blend.BV ); + FT_FREE( subfont->blend_stack ); } } @@ -1442,18 +2159,19 @@ FT_Stream stream, FT_Int face_index, CFF_Font font, - FT_Bool pure_cff ) + CFF_Face face, + FT_Bool pure_cff, + FT_Bool cff2 ) { static const FT_Frame_Field cff_header_fields[] = { #undef FT_STRUCTURE #define FT_STRUCTURE CFF_FontRec - FT_FRAME_START( 4 ), + FT_FRAME_START( 3 ), FT_FRAME_BYTE( version_major ), FT_FRAME_BYTE( version_minor ), FT_FRAME_BYTE( header_size ), - FT_FRAME_BYTE( absolute_offsize ), FT_FRAME_END }; @@ -1468,43 +2186,133 @@ FT_ZERO( font ); FT_ZERO( &string_index ); - font->stream = stream; - font->memory = memory; - dict = &font->top_font.font_dict; - base_offset = FT_STREAM_POS(); + dict = &font->top_font.font_dict; + base_offset = FT_STREAM_POS(); + + font->library = library; + font->stream = stream; + font->memory = memory; + font->cff2 = cff2; + font->base_offset = base_offset; /* read CFF font header */ if ( FT_STREAM_READ_FIELDS( cff_header_fields, font ) ) goto Exit; - /* check format */ - if ( font->version_major != 1 || - font->header_size < 4 || - font->absolute_offsize > 4 ) + if ( cff2 ) { - FT_TRACE2(( " not a CFF font header\n" )); - error = FT_THROW( Unknown_File_Format ); - goto Exit; + if ( font->version_major != 2 || + font->header_size < 5 ) + { + FT_TRACE2(( " not a CFF2 font header\n" )); + error = FT_THROW( Unknown_File_Format ); + goto Exit; + } + + if ( FT_READ_USHORT( font->top_dict_length ) ) + goto Exit; + } + else + { + FT_Byte absolute_offset; + + + if ( FT_READ_BYTE( absolute_offset ) ) + goto Exit; + + if ( font->version_major != 1 || + font->header_size < 4 || + absolute_offset > 4 ) + { + FT_TRACE2(( " not a CFF font header\n" )); + error = FT_THROW( Unknown_File_Format ); + goto Exit; + } } /* skip the rest of the header */ - if ( FT_STREAM_SKIP( font->header_size - 4 ) ) + if ( FT_STREAM_SEEK( base_offset + font->header_size ) ) + { + /* For pure CFFs we have read only four bytes so far. Contrary to */ + /* other formats like SFNT those bytes doesn't define a signature; */ + /* it is thus possible that the font isn't a CFF at all. */ + if ( pure_cff ) + { + FT_TRACE2(( " not a CFF file\n" )); + error = FT_THROW( Unknown_File_Format ); + } goto Exit; + } - /* read the name, top dict, string and global subrs index */ - if ( FT_SET_ERROR( cff_index_init( &font->name_index, - stream, 0 ) ) || - FT_SET_ERROR( cff_index_init( &font->font_dict_index, - stream, 0 ) ) || - FT_SET_ERROR( cff_index_init( &string_index, - stream, 1 ) ) || - FT_SET_ERROR( cff_index_init( &font->global_subrs_index, - stream, 1 ) ) || - FT_SET_ERROR( cff_index_get_pointers( &string_index, - &font->strings, - &font->string_pool, - &font->string_pool_size ) ) ) - goto Exit; + if ( cff2 ) + { + /* For CFF2, the top dict data immediately follow the header */ + /* and the length is stored in the header `offSize' field; */ + /* there is no index for it. */ + /* */ + /* Use the `font_dict_index' to save the current position */ + /* and length of data, but leave count at zero as an indicator. */ + FT_ZERO( &font->font_dict_index ); + + font->font_dict_index.data_offset = FT_STREAM_POS(); + font->font_dict_index.data_size = font->top_dict_length; + + /* skip the top dict data for now, we will parse it later */ + if ( FT_STREAM_SKIP( font->top_dict_length ) ) + goto Exit; + + /* next, read the global subrs index */ + if ( FT_SET_ERROR( cff_index_init( &font->global_subrs_index, + stream, 1, cff2 ) ) ) + goto Exit; + } + else + { + /* for CFF, read the name, top dict, string and global subrs index */ + if ( FT_SET_ERROR( cff_index_init( &font->name_index, + stream, 0, cff2 ) ) ) + { + if ( pure_cff ) + { + FT_TRACE2(( " not a CFF file\n" )); + error = FT_THROW( Unknown_File_Format ); + } + goto Exit; + } + + /* if we have an empty font name, */ + /* it must be the only font in the CFF */ + if ( font->name_index.count > 1 && + font->name_index.data_size < font->name_index.count ) + { + /* for pure CFFs, we still haven't checked enough bytes */ + /* to be sure that it is a CFF at all */ + error = pure_cff ? FT_THROW( Unknown_File_Format ) + : FT_THROW( Invalid_File_Format ); + goto Exit; + } + + if ( FT_SET_ERROR( cff_index_init( &font->font_dict_index, + stream, 0, cff2 ) ) || + FT_SET_ERROR( cff_index_init( &string_index, + stream, 1, cff2 ) ) || + FT_SET_ERROR( cff_index_init( &font->global_subrs_index, + stream, 1, cff2 ) ) || + FT_SET_ERROR( cff_index_get_pointers( &string_index, + &font->strings, + &font->string_pool, + &font->string_pool_size ) ) ) + goto Exit; + + /* there must be a Top DICT index entry for each name index entry */ + if ( font->name_index.count > font->font_dict_index.count ) + { + FT_ERROR(( "cff_font_load:" + " not enough entries in Top DICT index\n" )); + error = FT_THROW( Invalid_File_Format ); + goto Exit; + } + } font->num_strings = string_index.count; @@ -1550,34 +2358,48 @@ subfont_index, stream, base_offset, - library ); + cff2 ? CFF2_CODE_TOPDICT : CFF_CODE_TOPDICT, + font, + face ); if ( error ) goto Exit; if ( FT_STREAM_SEEK( base_offset + dict->charstrings_offset ) ) goto Exit; - error = cff_index_init( &font->charstrings_index, stream, 0 ); + error = cff_index_init( &font->charstrings_index, stream, 0, cff2 ); if ( error ) goto Exit; - /* now, check for a CID font */ - if ( dict->cid_registry != 0xFFFFU ) + /* now, check for a CID or CFF2 font */ + if ( dict->cid_registry != 0xFFFFU || + cff2 ) { CFF_IndexRec fd_index; CFF_SubFont sub = NULL; FT_UInt idx; + /* for CFF2, read the Variation Store if available; */ + /* this must follow the Top DICT parse and precede any Private DICT */ + error = cff_vstore_load( &font->vstore, + stream, + base_offset, + dict->vstore_offset ); + if ( error ) + goto Exit; + /* this is a CID-keyed font, we must now allocate a table of */ /* sub-fonts, then load each of them separately */ if ( FT_STREAM_SEEK( base_offset + dict->cid_fd_array_offset ) ) goto Exit; - error = cff_index_init( &fd_index, stream, 0 ); + error = cff_index_init( &fd_index, stream, 0, cff2 ); if ( error ) goto Exit; + /* Font Dicts are not limited to 256 for CFF2. */ + /* TODO: support this for CFF2 */ if ( fd_index.count > CFF_MAX_CID_FONTS ) { FT_TRACE0(( "cff_font_load: FD array too large in CID font\n" )); @@ -1598,17 +2420,26 @@ { sub = font->subfonts[idx]; FT_TRACE4(( "parsing subfont %u\n", idx )); - error = cff_subfont_load( sub, &fd_index, idx, - stream, base_offset, library ); + error = cff_subfont_load( sub, + &fd_index, + idx, + stream, + base_offset, + cff2 ? CFF2_CODE_FONTDICT + : CFF_CODE_TOPDICT, + font, + face ); if ( error ) goto Fail_CID; } - /* now load the FD Select array */ - error = CFF_Load_FD_Select( &font->fd_select, - font->charstrings_index.count, - stream, - base_offset + dict->cid_fd_select_offset ); + /* now load the FD Select array; */ + /* CFF2 omits FDSelect if there is only one FD */ + if ( !cff2 || fd_index.count > 1 ) + error = CFF_Load_FD_Select( &font->fd_select, + font->charstrings_index.count, + stream, + base_offset + dict->cid_fd_select_offset ); Fail_CID: cff_index_done( &fd_index ); @@ -1636,7 +2467,7 @@ goto Exit; /* read the Charset and Encoding tables if available */ - if ( font->num_glyphs > 0 ) + if ( !cff2 && font->num_glyphs > 0 ) { FT_Bool invert = FT_BOOL( dict->cid_registry != 0xFFFFU && pure_cff ); @@ -1684,7 +2515,7 @@ cff_index_done( &font->charstrings_index ); /* release font dictionaries, but only if working with */ - /* a CID keyed CFF font */ + /* a CID keyed CFF font or a CFF2 font */ if ( font->num_subfonts > 0 ) { for ( idx = 0; idx < font->num_subfonts; idx++ ) @@ -1696,6 +2527,7 @@ cff_encoding_done( &font->encoding ); cff_charset_done( &font->charset, font->stream ); + cff_vstore_done( &font->vstore, memory ); cff_subfont_done( memory, &font->top_font ); diff --git a/thirdparty/freetype/src/cff/cffload.h b/thirdparty/freetype/src/cff/cffload.h index 1dd07baf11..c745e8127b 100644 --- a/thirdparty/freetype/src/cff/cffload.h +++ b/thirdparty/freetype/src/cff/cffload.h @@ -4,7 +4,7 @@ /* */ /* OpenType & CFF data/program tables loader (specification). */ /* */ -/* Copyright 1996-2016 by */ +/* Copyright 1996-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -22,6 +22,8 @@ #include <ft2build.h> #include "cfftypes.h" +#include "cffparse.h" +#include "cffobjs.h" /* for CFF_Face */ FT_BEGIN_HEADER @@ -59,21 +61,64 @@ FT_BEGIN_HEADER FT_UInt cid ); + FT_LOCAL( FT_UInt32 ) + cff_random( FT_UInt32 r ); + FT_LOCAL( FT_Error ) - cff_font_load( FT_Library library, - FT_Stream stream, - FT_Int face_index, - CFF_Font font, - FT_Bool pure_cff ); + cff_font_load( FT_Library library, + FT_Stream stream, + FT_Int face_index, + CFF_Font font, + CFF_Face face, + FT_Bool pure_cff, + FT_Bool cff2 ); FT_LOCAL( void ) cff_font_done( CFF_Font font ); + FT_LOCAL( FT_Error ) + cff_load_private_dict( CFF_Font font, + CFF_SubFont subfont, + FT_UInt lenNDV, + FT_Fixed* NDV ); + FT_LOCAL( FT_Byte ) cff_fd_select_get( CFF_FDSelect fdselect, FT_UInt glyph_index ); + FT_LOCAL( FT_Bool ) + cff_blend_check_vector( CFF_Blend blend, + FT_UInt vsindex, + FT_UInt lenNDV, + FT_Fixed* NDV ); + + FT_LOCAL( FT_Error ) + cff_blend_build_vector( CFF_Blend blend, + FT_UInt vsindex, + FT_UInt lenNDV, + FT_Fixed* NDV ); + + FT_LOCAL( void ) + cff_blend_clear( CFF_SubFont subFont ); + + FT_LOCAL( FT_Error ) + cff_blend_doBlend( CFF_SubFont subfont, + CFF_Parser parser, + FT_UInt numBlends ); + +#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT + FT_LOCAL( FT_Error ) + cff_get_var_blend( CFF_Face face, + FT_UInt *num_coords, + FT_Fixed* *coords, + FT_Fixed* *normalizedcoords, + FT_MM_Var* *mm_var ); + + FT_LOCAL( void ) + cff_done_blend( CFF_Face face ); +#endif + FT_END_HEADER diff --git a/thirdparty/freetype/src/cff/cffobjs.c b/thirdparty/freetype/src/cff/cffobjs.c index 0f0769677f..61613933ff 100644 --- a/thirdparty/freetype/src/cff/cffobjs.c +++ b/thirdparty/freetype/src/cff/cffobjs.c @@ -4,7 +4,7 @@ /* */ /* OpenType objects manager (body). */ /* */ -/* Copyright 1996-2016 by */ +/* Copyright 1996-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -27,6 +27,11 @@ #include FT_INTERNAL_SFNT_H #include FT_CFF_DRIVER_H +#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT +#include FT_MULTIPLE_MASTERS_H +#include FT_SERVICE_MULTIPLE_MASTERS_H +#endif + #include "cffobjs.h" #include "cffload.h" #include "cffcmap.h" @@ -49,9 +54,6 @@ /* */ /* SIZE FUNCTIONS */ /* */ - /* Note that we store the global hints in the size's `internal' root */ - /* field. */ - /* */ /*************************************************************************/ @@ -75,10 +77,11 @@ FT_LOCAL_DEF( void ) cff_size_done( FT_Size cffsize ) /* CFF_Size */ { + FT_Memory memory = cffsize->face->memory; CFF_Size size = (CFF_Size)cffsize; CFF_Face face = (CFF_Face)size->root.face; CFF_Font font = (CFF_Font)face->extra.data; - CFF_Internal internal = (CFF_Internal)cffsize->internal; + CFF_Internal internal = (CFF_Internal)cffsize->internal->module_data; if ( internal ) @@ -98,7 +101,7 @@ funcs->destroy( internal->subfonts[i - 1] ); } - /* `internal' is freed by destroy_size (in ftobjs.c) */ + FT_FREE( internal ); } } @@ -114,7 +117,7 @@ FT_UInt n, count; - FT_MEM_ZERO( priv, sizeof ( *priv ) ); + FT_ZERO( priv ); count = priv->num_blue_values = cpriv->num_blue_values; for ( n = 0; n < count; n++ ) @@ -194,7 +197,7 @@ goto Exit; } - cffsize->internal = (FT_Size_Internal)(void*)internal; + cffsize->internal->module_data = internal; } size->strike_index = 0xFFFFFFFFUL; @@ -224,7 +227,7 @@ { CFF_Face face = (CFF_Face)size->face; CFF_Font font = (CFF_Font)face->extra.data; - CFF_Internal internal = (CFF_Internal)size->internal; + CFF_Internal internal = (CFF_Internal)size->internal->module_data; FT_Long top_upm = (FT_Long)font->top_font.font_dict.units_per_em; FT_UInt i; @@ -296,7 +299,7 @@ { CFF_Face cffface = (CFF_Face)size->face; CFF_Font font = (CFF_Font)cffface->extra.data; - CFF_Internal internal = (CFF_Internal)size->internal; + CFF_Internal internal = (CFF_Internal)size->internal->module_data; FT_Long top_upm = (FT_Long)font->top_font.font_dict.units_per_em; FT_UInt i; @@ -450,7 +453,7 @@ FT_Int idx; - for ( idx = 1; idx <= style_name_length; ++idx ) + for ( idx = 1; idx <= style_name_length; idx++ ) { if ( family_name[family_name_length - idx] != style_name[style_name_length - idx] ) @@ -469,7 +472,7 @@ family_name[idx] == ' ' || family_name[idx] == '_' || family_name[idx] == '+' ) ) - --idx; + idx--; if ( idx > 0 ) family_name[idx + 1] = '\0'; @@ -491,6 +494,7 @@ FT_Service_PsCMaps psnames; PSHinter_Service pshinter; FT_Bool pure_cff = 1; + FT_Bool cff2 = 0; FT_Bool sfnt_format = 0; FT_Library library = cffface->driver->root.library; @@ -516,6 +520,7 @@ goto Exit; /* check whether we have a valid OpenType file */ + FT_TRACE2(( " " )); error = sfnt->init_face( stream, face, face_index, num_params, params ); if ( !error ) { @@ -553,8 +558,18 @@ goto Exit; } - /* now load the CFF part of the file */ - error = face->goto_table( face, TTAG_CFF, stream, 0 ); + /* now load the CFF part of the file; */ + /* give priority to CFF2 */ + error = face->goto_table( face, TTAG_CFF2, stream, 0 ); + if ( !error ) + { + cff2 = 1; + face->is_cff2 = cff2; + } + + if ( FT_ERR_EQ( error, Table_Missing ) ) + error = face->goto_table( face, TTAG_CFF, stream, 0 ); + if ( error ) goto Exit; } @@ -579,7 +594,13 @@ goto Exit; face->extra.data = cff; - error = cff_font_load( library, stream, face_index, cff, pure_cff ); + error = cff_font_load( library, + stream, + face_index, + cff, + face, + pure_cff, + cff2 ); if ( error ) goto Exit; @@ -667,6 +688,56 @@ } #endif /* FT_DEBUG_LEVEL_TRACE */ +#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT + { + FT_Service_MultiMasters mm = (FT_Service_MultiMasters)face->mm; + + FT_Int instance_index = face_index >> 16; + + + if ( FT_HAS_MULTIPLE_MASTERS( cffface ) && + mm && + instance_index > 0 ) + { + FT_MM_Var* mm_var; + + + error = mm->get_mm_var( cffface, NULL ); + if ( error ) + goto Exit; + + mm->get_var_blend( cffface, NULL, NULL, NULL, &mm_var ); + + if ( mm_var->namedstyle ) + { + FT_Var_Named_Style* named_style; + FT_String* style_name; + + + /* in `face_index', the instance index starts with value 1 */ + named_style = mm_var->namedstyle + instance_index - 1; + error = sfnt->get_name( face, + (FT_UShort)named_style->strid, + &style_name ); + if ( error ) + goto Exit; + + /* set style name; if already set, replace it */ + if ( face->root.style_name ) + FT_FREE( face->root.style_name ); + face->root.style_name = style_name; + + /* finally, select the named instance */ + error = mm->set_var_design( cffface, + mm_var->num_axis, + named_style->coords ); + if ( error ) + goto Exit; + } + } + } +#endif /* TT_CONFIG_OPTION_GX_VAR_SUPPORT */ + if ( !dict->has_font_matrix ) dict->units_per_em = pure_cff ? 1000 : face->root.units_per_EM; @@ -949,7 +1020,6 @@ cffface->style_flags = flags; } - #ifndef FT_CONFIG_OPTION_NO_GLYPH_NAMES /* CID-keyed CFF fonts don't have glyph names -- the SFNT loader */ /* has unset this flag because of the 3.0 `post' table. */ @@ -960,7 +1030,6 @@ if ( dict->cid_registry != 0xFFFFU && pure_cff ) cffface->face_flags |= FT_FACE_FLAG_CID_KEYED; - /*******************************************************************/ /* */ /* Compute char maps. */ @@ -1011,7 +1080,7 @@ error = FT_Err_Ok; /* if no Unicode charmap was previously selected, select this one */ - if ( cffface->charmap == NULL && nn != (FT_UInt)cffface->num_charmaps ) + if ( !cffface->charmap && nn != (FT_UInt)cffface->num_charmaps ) cffface->charmap = cffface->charmaps[nn]; Skip_Unicode: @@ -1079,6 +1148,11 @@ FT_FREE( face->extra.data ); } } + +#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT + cff_done_blend( face ); + face->blend = NULL; +#endif } @@ -1087,6 +1161,8 @@ { CFF_Driver driver = (CFF_Driver)module; + FT_UInt32 seed; + /* set default property values, cf. `ftcffdrv.h' */ #ifdef CFF_CONFIG_OPTION_OLD_ENGINE @@ -1106,6 +1182,18 @@ driver->darken_params[6] = CFF_CONFIG_OPTION_DARKENING_PARAMETER_X4; driver->darken_params[7] = CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y4; + /* compute random seed from some memory addresses */ + seed = (FT_UInt32)( (FT_Offset)(char*)&seed ^ + (FT_Offset)(char*)&module ^ + (FT_Offset)(char*)module->memory ); + seed = seed ^ ( seed >> 10 ) ^ ( seed >> 20 ); + + driver->random_seed = (FT_Int32)seed; + if ( driver->random_seed < 0 ) + driver->random_seed = -driver->random_seed; + else if ( driver->random_seed == 0 ) + driver->random_seed = 123456789; + return FT_Err_Ok; } diff --git a/thirdparty/freetype/src/cff/cffobjs.h b/thirdparty/freetype/src/cff/cffobjs.h index 9dc77536bd..1dba694c53 100644 --- a/thirdparty/freetype/src/cff/cffobjs.h +++ b/thirdparty/freetype/src/cff/cffobjs.h @@ -4,7 +4,7 @@ /* */ /* OpenType objects manager (specification). */ /* */ -/* Copyright 1996-2016 by */ +/* Copyright 1996-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -118,10 +118,10 @@ FT_BEGIN_HEADER { FT_DriverRec root; - FT_UInt hinting_engine; - FT_Bool no_stem_darkening; - - FT_Int darken_params[8]; + FT_UInt hinting_engine; + FT_Bool no_stem_darkening; + FT_Int darken_params[8]; + FT_Int32 random_seed; } CFF_DriverRec; diff --git a/thirdparty/freetype/src/cff/cffparse.c b/thirdparty/freetype/src/cff/cffparse.c index a4f986b67c..e1511bdbd1 100644 --- a/thirdparty/freetype/src/cff/cffparse.c +++ b/thirdparty/freetype/src/cff/cffparse.c @@ -4,7 +4,7 @@ /* */ /* CFF token stream parser (body) */ /* */ -/* Copyright 1996-2016 by */ +/* Copyright 1996-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -24,6 +24,7 @@ #include "cfferrs.h" #include "cffpic.h" #include "cffgload.h" +#include "cffload.h" /*************************************************************************/ @@ -36,22 +37,52 @@ #define FT_COMPONENT trace_cffparse - FT_LOCAL_DEF( void ) + FT_LOCAL_DEF( FT_Error ) cff_parser_init( CFF_Parser parser, FT_UInt code, void* object, FT_Library library, + FT_UInt stackSize, FT_UShort num_designs, FT_UShort num_axes ) { - FT_MEM_ZERO( parser, sizeof ( *parser ) ); + FT_Memory memory = library->memory; /* for FT_NEW_ARRAY */ + FT_Error error; /* for FT_NEW_ARRAY */ + + + FT_ZERO( parser ); +#if 0 parser->top = parser->stack; +#endif parser->object_code = code; parser->object = object; parser->library = library; parser->num_designs = num_designs; parser->num_axes = num_axes; + + /* allocate the stack buffer */ + if ( FT_NEW_ARRAY( parser->stack, stackSize ) ) + { + FT_FREE( parser->stack ); + goto Exit; + } + + parser->stackSize = stackSize; + parser->top = parser->stack; /* empty stack */ + + Exit: + return error; + } + + + FT_LOCAL_DEF( void ) + cff_parser_done( CFF_Parser parser ) + { + FT_Memory memory = parser->library->memory; /* for FT_FREE */ + + + FT_FREE( parser->stack ); } @@ -402,24 +433,54 @@ /* read a number, either integer or real */ - static FT_Long - cff_parse_num( FT_Byte** d ) + FT_LOCAL_DEF( FT_Long ) + cff_parse_num( CFF_Parser parser, + FT_Byte** d ) { - return **d == 30 ? ( cff_parse_real( d[0], d[1], 0, NULL ) >> 16 ) - : cff_parse_integer( d[0], d[1] ); + if ( **d == 30 ) + { + /* binary-coded decimal is truncated to integer */ + return cff_parse_real( *d, parser->limit, 0, NULL ) >> 16; + } + + else if ( **d == 255 ) + { + /* 16.16 fixed point is used internally for CFF2 blend results. */ + /* Since these are trusted values, a limit check is not needed. */ + + /* After the 255, 4 bytes give the number. */ + /* The blend value is converted to integer, with rounding; */ + /* due to the right-shift we don't need the lowest byte. */ +#if 0 + return (FT_Short)( + ( ( ( (FT_UInt32)*( d[0] + 1 ) << 24 ) | + ( (FT_UInt32)*( d[0] + 2 ) << 16 ) | + ( (FT_UInt32)*( d[0] + 3 ) << 8 ) | + (FT_UInt32)*( d[0] + 4 ) ) + 0x8000U ) >> 16 ); +#else + return (FT_Short)( + ( ( ( (FT_UInt32)*( d[0] + 1 ) << 16 ) | + ( (FT_UInt32)*( d[0] + 2 ) << 8 ) | + (FT_UInt32)*( d[0] + 3 ) ) + 0x80U ) >> 8 ); +#endif + } + + else + return cff_parse_integer( *d, parser->limit ); } /* read a floating point number, either integer or real */ static FT_Fixed - do_fixed( FT_Byte** d, - FT_Long scaling ) + do_fixed( CFF_Parser parser, + FT_Byte** d, + FT_Long scaling ) { if ( **d == 30 ) - return cff_parse_real( d[0], d[1], scaling, NULL ); + return cff_parse_real( *d, parser->limit, scaling, NULL ); else { - FT_Long val = cff_parse_integer( d[0], d[1] ); + FT_Long val = cff_parse_integer( *d, parser->limit ); if ( scaling ) @@ -447,19 +508,21 @@ /* read a floating point number, either integer or real */ static FT_Fixed - cff_parse_fixed( FT_Byte** d ) + cff_parse_fixed( CFF_Parser parser, + FT_Byte** d ) { - return do_fixed( d, 0 ); + return do_fixed( parser, d, 0 ); } /* read a floating point number, either integer or real, */ /* but return `10^scaling' times the number read in */ static FT_Fixed - cff_parse_fixed_scaled( FT_Byte** d, - FT_Long scaling ) + cff_parse_fixed_scaled( CFF_Parser parser, + FT_Byte** d, + FT_Long scaling ) { - return do_fixed( d, scaling ); + return do_fixed( parser, d, scaling ); } @@ -467,13 +530,14 @@ /* and return it as precise as possible -- `scaling' returns */ /* the scaling factor (as a power of 10) */ static FT_Fixed - cff_parse_fixed_dynamic( FT_Byte** d, - FT_Long* scaling ) + cff_parse_fixed_dynamic( CFF_Parser parser, + FT_Byte** d, + FT_Long* scaling ) { FT_ASSERT( scaling ); if ( **d == 30 ) - return cff_parse_real( d[0], d[1], 0, scaling ); + return cff_parse_real( *d, parser->limit, 0, scaling ); else { FT_Long number; @@ -543,7 +607,7 @@ for ( i = 0; i < 6; i++ ) { - values[i] = cff_parse_fixed_dynamic( data++, &scalings[i] ); + values[i] = cff_parse_fixed_dynamic( parser, data++, &scalings[i] ); if ( values[i] ) { if ( scalings[i] > max_scaling ) @@ -640,10 +704,10 @@ if ( parser->top >= parser->stack + 4 ) { - bbox->xMin = FT_RoundFix( cff_parse_fixed( data++ ) ); - bbox->yMin = FT_RoundFix( cff_parse_fixed( data++ ) ); - bbox->xMax = FT_RoundFix( cff_parse_fixed( data++ ) ); - bbox->yMax = FT_RoundFix( cff_parse_fixed( data ) ); + bbox->xMin = FT_RoundFix( cff_parse_fixed( parser, data++ ) ); + bbox->yMin = FT_RoundFix( cff_parse_fixed( parser, data++ ) ); + bbox->xMax = FT_RoundFix( cff_parse_fixed( parser, data++ ) ); + bbox->yMax = FT_RoundFix( cff_parse_fixed( parser, data ) ); error = FT_Err_Ok; FT_TRACE4(( " [%d %d %d %d]\n", @@ -672,7 +736,7 @@ FT_Long tmp; - tmp = cff_parse_num( data++ ); + tmp = cff_parse_num( parser, data++ ); if ( tmp < 0 ) { FT_ERROR(( "cff_parse_private_dict: Invalid dictionary size\n" )); @@ -681,7 +745,7 @@ } dict->private_size = (FT_ULong)tmp; - tmp = cff_parse_num( data ); + tmp = cff_parse_num( parser, data ); if ( tmp < 0 ) { FT_ERROR(( "cff_parse_private_dict: Invalid dictionary offset\n" )); @@ -726,7 +790,7 @@ /* currently, we handle only the first argument */ if ( parser->top >= parser->stack + 5 ) { - FT_Long num_designs = cff_parse_num( parser->stack ); + FT_Long num_designs = cff_parse_num( parser, parser->stack ); if ( num_designs > 16 || num_designs < 2 ) @@ -763,11 +827,11 @@ if ( parser->top >= parser->stack + 3 ) { - dict->cid_registry = (FT_UInt)cff_parse_num( data++ ); - dict->cid_ordering = (FT_UInt)cff_parse_num( data++ ); + dict->cid_registry = (FT_UInt)cff_parse_num( parser, data++ ); + dict->cid_ordering = (FT_UInt)cff_parse_num( parser, data++ ); if ( **data == 30 ) FT_TRACE1(( "cff_parse_cid_ros: real supplement is rounded\n" )); - dict->cid_supplement = cff_parse_num( data ); + dict->cid_supplement = cff_parse_num( parser, data ); if ( dict->cid_supplement < 0 ) FT_TRACE1(( "cff_parse_cid_ros: negative supplement %d is found\n", dict->cid_supplement )); @@ -783,6 +847,123 @@ } + static FT_Error + cff_parse_vsindex( CFF_Parser parser ) + { + /* vsindex operator can only be used in a Private DICT */ + CFF_Private priv = (CFF_Private)parser->object; + FT_Byte** data = parser->stack; + CFF_Blend blend; + FT_Error error; + + + if ( !priv || !priv->subfont ) + { + error = FT_THROW( Invalid_File_Format ); + goto Exit; + } + + blend = &priv->subfont->blend; + + if ( blend->usedBV ) + { + FT_ERROR(( " cff_parse_vsindex: vsindex not allowed after blend\n" )); + error = FT_THROW( Syntax_Error ); + goto Exit; + } + + priv->vsindex = (FT_UInt)cff_parse_num( parser, data++ ); + + FT_TRACE4(( " %d\n", priv->vsindex )); + + error = FT_Err_Ok; + + Exit: + return error; + } + + + static FT_Error + cff_parse_blend( CFF_Parser parser ) + { + /* blend operator can only be used in a Private DICT */ + CFF_Private priv = (CFF_Private)parser->object; + CFF_SubFont subFont; + CFF_Blend blend; + FT_UInt numBlends; + FT_Error error; + + + if ( !priv || !priv->subfont ) + { + error = FT_THROW( Invalid_File_Format ); + goto Exit; + } + + subFont = priv->subfont; + blend = &subFont->blend; + + if ( cff_blend_check_vector( blend, + priv->vsindex, + subFont->lenNDV, + subFont->NDV ) ) + { + error = cff_blend_build_vector( blend, + priv->vsindex, + subFont->lenNDV, + subFont->NDV ); + if ( error ) + goto Exit; + } + + numBlends = (FT_UInt)cff_parse_num( parser, parser->top - 1 ); + if ( numBlends > parser->stackSize ) + { + FT_ERROR(( "cff_parse_blend: Invalid number of blends\n" )); + error = FT_THROW( Invalid_File_Format ); + goto Exit; + } + + FT_TRACE4(( " %d values blended\n", numBlends )); + + error = cff_blend_doBlend( subFont, parser, numBlends ); + + blend->usedBV = TRUE; + + Exit: + return error; + } + + + /* maxstack operator increases parser and operand stacks for CFF2 */ + static FT_Error + cff_parse_maxstack( CFF_Parser parser ) + { + /* maxstack operator can only be used in a Top DICT */ + CFF_FontRecDict dict = (CFF_FontRecDict)parser->object; + FT_Byte** data = parser->stack; + FT_Error error = FT_Err_Ok; + + + if ( !dict ) + { + error = FT_THROW( Invalid_File_Format ); + goto Exit; + } + + dict->maxstack = (FT_UInt)cff_parse_num( parser, data++ ); + if ( dict->maxstack > CFF2_MAX_STACK ) + dict->maxstack = CFF2_MAX_STACK; + if ( dict->maxstack < CFF2_DEFAULT_STACK ) + dict->maxstack = CFF2_DEFAULT_STACK; + + FT_TRACE4(( " %d\n", dict->maxstack )); + + Exit: + return error; + } + + #define CFF_FIELD_NUM( code, name, id ) \ CFF_FIELD( code, name, id, cff_kind_num ) #define CFF_FIELD_FIXED( code, name, id ) \ @@ -794,9 +975,6 @@ #define CFF_FIELD_BOOL( code, name, id ) \ CFF_FIELD( code, name, id, cff_kind_bool ) -#define CFFCODE_TOPDICT 0x1000 -#define CFFCODE_PRIVATE 0x2000 - #ifndef FT_CONFIG_OPTION_PIC @@ -817,6 +995,15 @@ 0, 0 \ }, +#define CFF_FIELD_BLEND( code, id ) \ + { \ + cff_kind_blend, \ + code | CFFCODE, \ + 0, 0, \ + cff_parse_blend, \ + 0, 0 \ + }, + #define CFF_FIELD( code, name, id, kind ) \ { \ kind, \ @@ -860,6 +1047,16 @@ id \ }, +#define CFF_FIELD_BLEND( code, id ) \ + { \ + cff_kind_blend, \ + code | CFFCODE, \ + 0, 0, \ + cff_parse_blend, \ + 0, 0, \ + id \ + }, + #define CFF_FIELD( code, name, id, kind ) \ { \ kind, \ @@ -926,6 +1123,8 @@ #define CFF_FIELD_DELTA( code, name, max, id ) i++; #undef CFF_FIELD_CALLBACK #define CFF_FIELD_CALLBACK( code, name, id ) i++; +#undef CFF_FIELD_BLEND +#define CFF_FIELD_BLEND( code, id ) i++; #include "cfftoken.h" @@ -973,6 +1172,17 @@ clazz[i].count_offset = FT_FIELD_OFFSET( num_ ## name_ ); \ i++; +#undef CFF_FIELD_BLEND +#define CFF_FIELD_BLEND( code_, id_ ) \ + clazz[i].kind = cff_kind_blend; \ + clazz[i].code = code_ | CFFCODE; \ + clazz[i].offset = 0; \ + clazz[i].size = 0; \ + clazz[i].reader = cff_parse_blend; \ + clazz[i].array_max = 0; \ + clazz[i].count_offset = 0; \ + i++; + #include "cfftoken.h" clazz[i].kind = 0; @@ -1023,6 +1233,18 @@ clazz[i].id = id_; \ i++; +#undef CFF_FIELD_BLEND +#define CFF_FIELD_BLEND( code_, id_ ) \ + clazz[i].kind = cff_kind_blend; \ + clazz[i].code = code_ | CFFCODE; \ + clazz[i].offset = 0; \ + clazz[i].size = 0; \ + clazz[i].reader = cff_parse_blend; \ + clazz[i].array_max = 0; \ + clazz[i].count_offset = 0; \ + clazz[i].id = id_; \ + i++; + #include "cfftoken.h" clazz[i].kind = 0; @@ -1067,11 +1289,13 @@ { FT_UInt v = *p; - - if ( v >= 27 && v != 31 ) + /* Opcode 31 is legacy MM T2 operator, not a number. */ + /* Opcode 255 is reserved and should not appear in fonts; */ + /* it is used internally for CFF2 blends. */ + if ( v >= 27 && v != 31 && v != 255 ) { /* it's a number; we will push its position on the stack */ - if ( parser->top - parser->stack >= CFF_MAX_STACK_DEPTH ) + if ( (FT_UInt)( parser->top - parser->stack ) >= parser->stackSize ) goto Stack_Overflow; *parser->top++ = p; @@ -1132,8 +1356,8 @@ charstring_len = (FT_ULong)( p - charstring_base ) + 1; /* construct CFF_Decoder object */ - FT_MEM_ZERO( &decoder, sizeof ( decoder ) ); - FT_MEM_ZERO( &cff_rec, sizeof ( cff_rec ) ); + FT_ZERO( &decoder ); + FT_ZERO( &cff_rec ); cff_rec.top_font.font_dict.num_designs = parser->num_designs; cff_rec.top_font.font_dict.num_axes = parser->num_axes; @@ -1162,7 +1386,7 @@ FT_Bool neg; - if ( parser->top - parser->stack >= CFF_MAX_STACK_DEPTH ) + if ( (FT_UInt)( parser->top - parser->stack ) >= parser->stackSize ) goto Stack_Overflow; *parser->top++ = q; @@ -1239,13 +1463,17 @@ /* and look for it in our current list. */ FT_UInt code; - FT_UInt num_args = (FT_UInt) - ( parser->top - parser->stack ); + FT_UInt num_args; const CFF_Field_Handler* field; + if ( (FT_UInt)( parser->top - parser->stack ) >= parser->stackSize ) + goto Stack_Overflow; + + num_args = (FT_UInt)( parser->top - parser->stack ); *parser->top = p; - code = v; + code = v; + if ( v == 12 ) { /* two byte operator */ @@ -1280,15 +1508,15 @@ case cff_kind_bool: case cff_kind_string: case cff_kind_num: - val = cff_parse_num( parser->stack ); + val = cff_parse_num( parser, parser->stack ); goto Store_Number; case cff_kind_fixed: - val = cff_parse_fixed( parser->stack ); + val = cff_parse_fixed( parser, parser->stack ); goto Store_Number; case cff_kind_fixed_thousand: - val = cff_parse_fixed_scaled( parser->stack, 3 ); + val = cff_parse_fixed_scaled( parser, parser->stack, 3 ); Store_Number: switch ( field->size ) @@ -1357,7 +1585,7 @@ val = 0; while ( num_args > 0 ) { - val += cff_parse_num( data++ ); + val += cff_parse_num( parser, data++ ); switch ( field->size ) { case (8 / FT_CHAR_BIT): @@ -1386,7 +1614,7 @@ } break; - default: /* callback */ + default: /* callback or blend */ error = field->reader( parser ); if ( error ) goto Exit; @@ -1400,7 +1628,10 @@ Found: /* clear stack */ - parser->top = parser->stack; + /* TODO: could clear blend stack here, */ + /* but we don't have access to subFont */ + if ( field->kind != cff_kind_blend ) + parser->top = parser->stack; } p++; } diff --git a/thirdparty/freetype/src/cff/cffparse.h b/thirdparty/freetype/src/cff/cffparse.h index a95970edcb..83d1bba45f 100644 --- a/thirdparty/freetype/src/cff/cffparse.h +++ b/thirdparty/freetype/src/cff/cffparse.h @@ -4,7 +4,7 @@ /* */ /* CFF token stream parser (specification) */ /* */ -/* Copyright 1996-2016 by */ +/* Copyright 1996-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -28,10 +28,25 @@ FT_BEGIN_HEADER + /* CFF uses constant parser stack size; */ + /* CFF2 can increase from default 193 */ #define CFF_MAX_STACK_DEPTH 96 -#define CFF_CODE_TOPDICT 0x1000 -#define CFF_CODE_PRIVATE 0x2000 + /* + * There are plans to remove the `maxstack' operator in a forthcoming + * revision of the CFF2 specification, increasing the (then static) stack + * size to 513. By making the default stack size equal to the maximum + * stack size, the operator is essentially disabled, which has the + * desired effect in FreeType. + */ +#define CFF2_MAX_STACK 513 +#define CFF2_DEFAULT_STACK 513 + +#define CFF_CODE_TOPDICT 0x1000 +#define CFF_CODE_PRIVATE 0x2000 +#define CFF2_CODE_TOPDICT 0x3000 +#define CFF2_CODE_FONTDICT 0x4000 +#define CFF2_CODE_PRIVATE 0x5000 typedef struct CFF_ParserRec_ @@ -41,8 +56,9 @@ FT_BEGIN_HEADER FT_Byte* limit; FT_Byte* cursor; - FT_Byte* stack[CFF_MAX_STACK_DEPTH + 1]; + FT_Byte** stack; FT_Byte** top; + FT_UInt stackSize; /* allocated size */ FT_UInt object_code; void* object; @@ -53,14 +69,22 @@ FT_BEGIN_HEADER } CFF_ParserRec, *CFF_Parser; - FT_LOCAL( void ) + FT_LOCAL( FT_Long ) + cff_parse_num( CFF_Parser parser, + FT_Byte** d ); + + FT_LOCAL( FT_Error ) cff_parser_init( CFF_Parser parser, FT_UInt code, void* object, FT_Library library, + FT_UInt stackSize, FT_UShort num_designs, FT_UShort num_axes ); + FT_LOCAL( void ) + cff_parser_done( CFF_Parser parser ); + FT_LOCAL( FT_Error ) cff_parser_run( CFF_Parser parser, FT_Byte* start, @@ -77,6 +101,7 @@ FT_BEGIN_HEADER cff_kind_bool, cff_kind_delta, cff_kind_callback, + cff_kind_blend, cff_kind_max /* do not remove */ }; diff --git a/thirdparty/freetype/src/cff/cffpic.c b/thirdparty/freetype/src/cff/cffpic.c index a0bc34fd5f..4e9ba12b3f 100644 --- a/thirdparty/freetype/src/cff/cffpic.c +++ b/thirdparty/freetype/src/cff/cffpic.c @@ -4,7 +4,7 @@ /* */ /* The FreeType position independent code services for cff module. */ /* */ -/* Copyright 2009-2016 by */ +/* Copyright 2009-2017 by */ /* Oran Agra and Mickey Gabel. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/thirdparty/freetype/src/cff/cffpic.h b/thirdparty/freetype/src/cff/cffpic.h index bed6b35a86..5db39cd627 100644 --- a/thirdparty/freetype/src/cff/cffpic.h +++ b/thirdparty/freetype/src/cff/cffpic.h @@ -4,7 +4,7 @@ /* */ /* The FreeType position independent code services for cff module. */ /* */ -/* Copyright 2009-2016 by */ +/* Copyright 2009-2017 by */ /* Oran Agra and Mickey Gabel. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -32,6 +32,8 @@ #define CFF_SERVICE_CID_INFO_GET cff_service_cid_info #define CFF_SERVICE_PROPERTIES_GET cff_service_properties #define CFF_SERVICES_GET cff_services +#define CFF_SERVICE_MULTI_MASTERS_GET cff_service_multi_masters +#define CFF_SERVICE_METRICS_VAR_GET cff_service_metrics_variations #define CFF_CMAP_ENCODING_CLASS_REC_GET cff_cmap_encoding_class_rec #define CFF_CMAP_UNICODE_CLASS_REC_GET cff_cmap_unicode_class_rec #define CFF_FIELD_HANDLERS_GET cff_field_handlers @@ -45,22 +47,26 @@ #include FT_SERVICE_TT_CMAP_H #include FT_SERVICE_CID_H #include FT_SERVICE_PROPERTIES_H +#include FT_SERVICE_MULTIPLE_MASTERS_H +#include FT_SERVICE_METRICS_VARIATIONS_H FT_BEGIN_HEADER typedef struct CffModulePIC_ { - FT_ServiceDescRec* cff_services; - CFF_Field_Handler* cff_field_handlers; - FT_Service_PsInfoRec cff_service_ps_info; - FT_Service_GlyphDictRec cff_service_glyph_dict; - FT_Service_PsFontNameRec cff_service_ps_name; - FT_Service_TTCMapsRec cff_service_get_cmap_info; - FT_Service_CIDRec cff_service_cid_info; - FT_Service_PropertiesRec cff_service_properties; - FT_CMap_ClassRec cff_cmap_encoding_class_rec; - FT_CMap_ClassRec cff_cmap_unicode_class_rec; + FT_ServiceDescRec* cff_services; + CFF_Field_Handler* cff_field_handlers; + FT_Service_PsInfoRec cff_service_ps_info; + FT_Service_GlyphDictRec cff_service_glyph_dict; + FT_Service_PsFontNameRec cff_service_ps_name; + FT_Service_TTCMapsRec cff_service_get_cmap_info; + FT_Service_CIDRec cff_service_cid_info; + FT_Service_PropertiesRec cff_service_properties; + FT_Service_MultiMastersRec cff_service_multi_masters; + FT_Service_MetricsVariationsRec cff_service_metrics_variations; + FT_CMap_ClassRec cff_cmap_encoding_class_rec; + FT_CMap_ClassRec cff_cmap_unicode_class_rec; } CffModulePIC; @@ -82,6 +88,10 @@ FT_BEGIN_HEADER ( GET_PIC( library )->cff_service_properties ) #define CFF_SERVICES_GET \ ( GET_PIC( library )->cff_services ) +#define CFF_SERVICE_MULTI_MASTERS_GET \ + ( GET_PIC( library )->cff_service_multi_masters ) +#define CFF_SERVICE_METRICS_VAR_GET \ + ( GET_PIC( library )->cff_service_metrics_variations ) #define CFF_CMAP_ENCODING_CLASS_REC_GET \ ( GET_PIC( library )->cff_cmap_encoding_class_rec ) #define CFF_CMAP_UNICODE_CLASS_REC_GET \ diff --git a/thirdparty/freetype/src/cff/cfftoken.h b/thirdparty/freetype/src/cff/cfftoken.h index 22637c780b..3222e933f1 100644 --- a/thirdparty/freetype/src/cff/cfftoken.h +++ b/thirdparty/freetype/src/cff/cfftoken.h @@ -4,7 +4,7 @@ /* */ /* CFF token definitions (specification only). */ /* */ -/* Copyright 1996-2016 by */ +/* Copyright 1996-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -20,7 +20,7 @@ #define FT_STRUCTURE CFF_FontRecDictRec #undef CFFCODE -#define CFFCODE CFFCODE_TOPDICT +#define CFFCODE CFF_CODE_TOPDICT CFF_FIELD_STRING ( 0, version, "Version" ) CFF_FIELD_STRING ( 1, notice, "Notice" ) @@ -78,7 +78,7 @@ #undef FT_STRUCTURE #define FT_STRUCTURE CFF_PrivateRec #undef CFFCODE -#define CFFCODE CFFCODE_PRIVATE +#define CFFCODE CFF_CODE_PRIVATE CFF_FIELD_DELTA ( 6, blue_values, 14, "BlueValues" ) CFF_FIELD_DELTA ( 7, other_blues, 10, "OtherBlues" ) @@ -102,4 +102,49 @@ CFF_FIELD_NUM ( 21, nominal_width, "nominalWidthX" ) +#undef FT_STRUCTURE +#define FT_STRUCTURE CFF_FontRecDictRec +#undef CFFCODE +#define CFFCODE CFF2_CODE_TOPDICT + + CFF_FIELD_CALLBACK( 0x107, font_matrix, "FontMatrix" ) + CFF_FIELD_NUM ( 17, charstrings_offset, "CharStrings" ) + CFF_FIELD_NUM ( 0x124, cid_fd_array_offset, "FDArray" ) + CFF_FIELD_NUM ( 0x125, cid_fd_select_offset, "FDSelect" ) + CFF_FIELD_NUM ( 24, vstore_offset, "vstore" ) + CFF_FIELD_CALLBACK( 25, maxstack, "maxstack" ) + + +#undef FT_STRUCTURE +#define FT_STRUCTURE CFF_FontRecDictRec +#undef CFFCODE +#define CFFCODE CFF2_CODE_FONTDICT + + CFF_FIELD_CALLBACK( 18, private_dict, "Private" ) + CFF_FIELD_CALLBACK( 0x107, font_matrix, "FontMatrix" ) + + +#undef FT_STRUCTURE +#define FT_STRUCTURE CFF_PrivateRec +#undef CFFCODE +#define CFFCODE CFF2_CODE_PRIVATE + + CFF_FIELD_DELTA ( 6, blue_values, 14, "BlueValues" ) + CFF_FIELD_DELTA ( 7, other_blues, 10, "OtherBlues" ) + CFF_FIELD_DELTA ( 8, family_blues, 14, "FamilyBlues" ) + CFF_FIELD_DELTA ( 9, family_other_blues, 10, "FamilyOtherBlues" ) + CFF_FIELD_FIXED_1000( 0x109, blue_scale, "BlueScale" ) + CFF_FIELD_NUM ( 0x10A, blue_shift, "BlueShift" ) + CFF_FIELD_NUM ( 0x10B, blue_fuzz, "BlueFuzz" ) + CFF_FIELD_NUM ( 10, standard_width, "StdHW" ) + CFF_FIELD_NUM ( 11, standard_height, "StdVW" ) + CFF_FIELD_DELTA ( 0x10C, snap_widths, 13, "StemSnapH" ) + CFF_FIELD_DELTA ( 0x10D, snap_heights, 13, "StemSnapV" ) + CFF_FIELD_NUM ( 0x111, language_group, "LanguageGroup" ) + CFF_FIELD_FIXED ( 0x112, expansion_factor, "ExpansionFactor" ) + CFF_FIELD_CALLBACK ( 22, vsindex, "vsindex" ) + CFF_FIELD_BLEND ( 23, "blend" ) + CFF_FIELD_NUM ( 19, local_subrs_offset, "Subrs" ) + + /* END */ diff --git a/thirdparty/freetype/src/cff/cfftypes.h b/thirdparty/freetype/src/cff/cfftypes.h index 4426c7e4f1..74f569f08b 100644 --- a/thirdparty/freetype/src/cff/cfftypes.h +++ b/thirdparty/freetype/src/cff/cfftypes.h @@ -5,7 +5,7 @@ /* Basic OpenType/CFF type definitions and interface (specification */ /* only). */ /* */ -/* Copyright 1996-2016 by */ +/* Copyright 1996-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -64,6 +64,7 @@ FT_BEGIN_HEADER { FT_Stream stream; FT_ULong start; + FT_UInt hdr_size; FT_UInt count; FT_Byte off_size; FT_ULong data_offset; @@ -102,6 +103,79 @@ FT_BEGIN_HEADER } CFF_CharsetRec, *CFF_Charset; + /* cf. similar fields in file `ttgxvar.h' from the `truetype' module */ + + typedef struct CFF_VarData_ + { +#if 0 + FT_UInt itemCount; /* not used; always zero */ + FT_UInt shortDeltaCount; /* not used; always zero */ +#endif + + FT_UInt regionIdxCount; /* number of region indexes */ + FT_UInt* regionIndices; /* array of `regionIdxCount' indices; */ + /* these index `varRegionList' */ + } CFF_VarData; + + + /* contribution of one axis to a region */ + typedef struct CFF_AxisCoords_ + { + FT_Fixed startCoord; + FT_Fixed peakCoord; /* zero peak means no effect (factor = 1) */ + FT_Fixed endCoord; + + } CFF_AxisCoords; + + + typedef struct CFF_VarRegion_ + { + CFF_AxisCoords* axisList; /* array of axisCount records */ + + } CFF_VarRegion; + + + typedef struct CFF_VStoreRec_ + { + FT_UInt dataCount; + CFF_VarData* varData; /* array of dataCount records */ + /* vsindex indexes this array */ + FT_UShort axisCount; + FT_UInt regionCount; /* total number of regions defined */ + CFF_VarRegion* varRegionList; + + } CFF_VStoreRec, *CFF_VStore; + + + /* forward reference */ + typedef struct CFF_FontRec_* CFF_Font; + + + /* This object manages one cached blend vector. */ + /* */ + /* There is a BlendRec for Private DICT parsing in each subfont */ + /* and a BlendRec for charstrings in CF2_Font instance data. */ + /* A cached BV may be used across DICTs or Charstrings if inputs */ + /* have not changed. */ + /* */ + /* `usedBV' is reset at the start of each parse or charstring. */ + /* vsindex cannot be changed after a BV is used. */ + /* */ + /* Note: NDV is long (32/64 bit), while BV is 16.16 (FT_Int32). */ + typedef struct CFF_BlendRec_ + { + FT_Bool builtBV; /* blendV has been built */ + FT_Bool usedBV; /* blendV has been used */ + CFF_Font font; /* top level font struct */ + FT_UInt lastVsindex; /* last vsindex used */ + FT_UInt lenNDV; /* normDV length (aka numAxes) */ + FT_Fixed* lastNDV; /* last NDV used */ + FT_UInt lenBV; /* BlendV length (aka numMasters) */ + FT_Int32* BV; /* current blendV (per DICT/glyph) */ + + } CFF_BlendRec, *CFF_Blend; + + typedef struct CFF_FontRecDictRec_ { FT_UInt version; @@ -151,9 +225,17 @@ FT_BEGIN_HEADER FT_UShort num_designs; FT_UShort num_axes; + /* fields for CFF2 */ + FT_ULong vstore_offset; + FT_UInt maxstack; + } CFF_FontRecDictRec, *CFF_FontRecDict; + /* forward reference */ + typedef struct CFF_SubFontRec_* CFF_SubFont; + + typedef struct CFF_PrivateRec_ { FT_Byte num_blue_values; @@ -186,6 +268,10 @@ FT_BEGIN_HEADER FT_Pos default_width; FT_Pos nominal_width; + /* fields for CFF2 */ + FT_UInt vsindex; + CFF_SubFont subfont; + } CFF_PrivateRec, *CFF_Private; @@ -213,10 +299,31 @@ FT_BEGIN_HEADER CFF_FontRecDictRec font_dict; CFF_PrivateRec private_dict; - CFF_IndexRec local_subrs_index; - FT_Byte** local_subrs; /* array of pointers into Local Subrs INDEX data */ + /* fields for CFF2 */ + CFF_BlendRec blend; /* current blend vector */ + FT_UInt lenNDV; /* current length NDV or zero */ + FT_Fixed* NDV; /* ptr to current NDV or NULL */ + + /* `blend_stack' is a writable buffer to hold blend results. */ + /* This buffer is to the side of the normal cff parser stack; */ + /* `cff_parse_blend' and `cff_blend_doBlend' push blend results here. */ + /* The normal stack then points to these values instead of the DICT */ + /* because all other operators in Private DICT clear the stack. */ + /* `blend_stack' could be cleared at each operator other than blend. */ + /* Blended values are stored as 5-byte fixed point values. */ + + FT_Byte* blend_stack; /* base of stack allocation */ + FT_Byte* blend_top; /* first empty slot */ + FT_UInt blend_used; /* number of bytes in use */ + FT_UInt blend_alloc; /* number of bytes allocated */ + + CFF_IndexRec local_subrs_index; + FT_Byte** local_subrs; /* array of pointers */ + /* into Local Subrs INDEX data */ - } CFF_SubFontRec, *CFF_SubFont; + FT_UInt32 random; + + } CFF_SubFontRec; #define CFF_MAX_CID_FONTS 256 @@ -224,16 +331,20 @@ FT_BEGIN_HEADER typedef struct CFF_FontRec_ { + FT_Library library; FT_Stream stream; - FT_Memory memory; + FT_Memory memory; /* TODO: take this from stream->memory? */ + FT_ULong base_offset; /* offset to start of CFF */ FT_UInt num_faces; FT_UInt num_glyphs; FT_Byte version_major; FT_Byte version_minor; FT_Byte header_size; - FT_Byte absolute_offsize; + FT_UInt top_dict_length; /* cff2 only */ + + FT_Bool cff2; CFF_IndexRec name_index; CFF_IndexRec top_dict_index; @@ -280,7 +391,10 @@ FT_BEGIN_HEADER /* since version 2.4.12 */ FT_Generic cf2_instance; - } CFF_FontRec, *CFF_Font; + /* since version 2.7.1 */ + CFF_VStoreRec vstore; /* parsed vstore structure */ + + } CFF_FontRec; FT_END_HEADER diff --git a/thirdparty/freetype/src/cff/module.mk b/thirdparty/freetype/src/cff/module.mk index 1b4781afed..2975aeed8c 100644 --- a/thirdparty/freetype/src/cff/module.mk +++ b/thirdparty/freetype/src/cff/module.mk @@ -3,7 +3,7 @@ # -# Copyright 1996-2016 by +# Copyright 1996-2017 by # David Turner, Robert Wilhelm, and Werner Lemberg. # # This file is part of the FreeType project, and may only be used, modified, diff --git a/thirdparty/freetype/src/cff/rules.mk b/thirdparty/freetype/src/cff/rules.mk index 92f68b1ede..86840bfe3c 100644 --- a/thirdparty/freetype/src/cff/rules.mk +++ b/thirdparty/freetype/src/cff/rules.mk @@ -3,7 +3,7 @@ # -# Copyright 1996-2016 by +# Copyright 1996-2017 by # David Turner, Robert Wilhelm, and Werner Lemberg. # # This file is part of the FreeType project, and may only be used, modified, diff --git a/thirdparty/freetype/src/cid/ciderrs.h b/thirdparty/freetype/src/cid/ciderrs.h index 1dc98c7cdd..709dc8cd1e 100644 --- a/thirdparty/freetype/src/cid/ciderrs.h +++ b/thirdparty/freetype/src/cid/ciderrs.h @@ -4,7 +4,7 @@ /* */ /* CID error codes (specification only). */ /* */ -/* Copyright 2001-2016 by */ +/* Copyright 2001-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/thirdparty/freetype/src/cid/cidgload.c b/thirdparty/freetype/src/cid/cidgload.c index c7b95593ee..b96c33334d 100644 --- a/thirdparty/freetype/src/cid/cidgload.c +++ b/thirdparty/freetype/src/cid/cidgload.c @@ -4,7 +4,7 @@ /* */ /* CID-keyed Type1 Glyph Loader (body). */ /* */ -/* Copyright 1996-2016 by */ +/* Copyright 1996-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/thirdparty/freetype/src/cid/cidgload.h b/thirdparty/freetype/src/cid/cidgload.h index 62d664b3af..7f816b5bc7 100644 --- a/thirdparty/freetype/src/cid/cidgload.h +++ b/thirdparty/freetype/src/cid/cidgload.h @@ -4,7 +4,7 @@ /* */ /* OpenType Glyph Loader (specification). */ /* */ -/* Copyright 1996-2016 by */ +/* Copyright 1996-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/thirdparty/freetype/src/cid/cidload.c b/thirdparty/freetype/src/cid/cidload.c index d4f1ad1a7f..ff0722110d 100644 --- a/thirdparty/freetype/src/cid/cidload.c +++ b/thirdparty/freetype/src/cid/cidload.c @@ -4,7 +4,7 @@ /* */ /* CID-keyed Type1 font loader (body). */ /* */ -/* Copyright 1996-2016 by */ +/* Copyright 1996-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -461,6 +461,9 @@ FT_Byte* p; + if ( !num_subrs ) + continue; + /* reallocate offsets array if needed */ if ( num_subrs + 1 > max_offsets ) { @@ -570,7 +573,7 @@ { FT_UNUSED( face ); - FT_MEM_ZERO( loader, sizeof ( *loader ) ); + FT_ZERO( loader ); } @@ -733,9 +736,11 @@ } /* we must convert the data section from hexadecimal to binary */ - if ( FT_ALLOC( face->binary_data, parser->binary_length ) || - cid_hex_to_binary( face->binary_data, parser->binary_length, - parser->data_offset, face ) ) + if ( FT_ALLOC( face->binary_data, parser->binary_length ) || + FT_SET_ERROR( cid_hex_to_binary( face->binary_data, + parser->binary_length, + parser->data_offset, + face ) ) ) goto Exit; FT_Stream_OpenMemory( face->cid_stream, @@ -777,7 +782,8 @@ CID_FaceDict dict = cid->font_dicts + n; - if ( dict->sd_bytes < 0 ) + if ( dict->sd_bytes < 0 || + ( dict->num_subrs && dict->sd_bytes < 1 ) ) { FT_ERROR(( "cid_parse_dict: Invalid `SDBytes' value\n" )); error = FT_THROW( Invalid_File_Format ); diff --git a/thirdparty/freetype/src/cid/cidload.h b/thirdparty/freetype/src/cid/cidload.h index 680f0d8fc5..45a0e6df25 100644 --- a/thirdparty/freetype/src/cid/cidload.h +++ b/thirdparty/freetype/src/cid/cidload.h @@ -4,7 +4,7 @@ /* */ /* CID-keyed Type1 font loader (specification). */ /* */ -/* Copyright 1996-2016 by */ +/* Copyright 1996-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/thirdparty/freetype/src/cid/cidobjs.c b/thirdparty/freetype/src/cid/cidobjs.c index 2d2600fd4c..ceda8ff97f 100644 --- a/thirdparty/freetype/src/cid/cidobjs.c +++ b/thirdparty/freetype/src/cid/cidobjs.c @@ -4,7 +4,7 @@ /* */ /* CID objects manager (body). */ /* */ -/* Copyright 1996-2016 by */ +/* Copyright 1996-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -113,16 +113,16 @@ CID_Size size = (CID_Size)cidsize; - if ( cidsize->internal ) + if ( cidsize->internal->module_data ) { PSH_Globals_Funcs funcs; funcs = cid_size_get_globals_funcs( size ); if ( funcs ) - funcs->destroy( (PSH_Globals)cidsize->internal ); + funcs->destroy( (PSH_Globals)cidsize->internal->module_data ); - cidsize->internal = NULL; + cidsize->internal->module_data = NULL; } } @@ -145,7 +145,7 @@ error = funcs->create( cidsize->face->memory, priv, &globals ); if ( !error ) - cidsize->internal = (FT_Size_Internal)(void*)globals; + cidsize->internal->module_data = globals; } return error; @@ -164,7 +164,7 @@ funcs = cid_size_get_globals_funcs( (CID_Size)size ); if ( funcs ) - funcs->set_scale( (PSH_Globals)size->internal, + funcs->set_scale( (PSH_Globals)size->internal->module_data, size->metrics.x_scale, size->metrics.y_scale, 0, 0 ); diff --git a/thirdparty/freetype/src/cid/cidobjs.h b/thirdparty/freetype/src/cid/cidobjs.h index 5dd377a9f8..8bcf886e10 100644 --- a/thirdparty/freetype/src/cid/cidobjs.h +++ b/thirdparty/freetype/src/cid/cidobjs.h @@ -4,7 +4,7 @@ /* */ /* CID objects manager (specification). */ /* */ -/* Copyright 1996-2016 by */ +/* Copyright 1996-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/thirdparty/freetype/src/cid/cidparse.c b/thirdparty/freetype/src/cid/cidparse.c index 73aca2ac6a..007609bbdf 100644 --- a/thirdparty/freetype/src/cid/cidparse.c +++ b/thirdparty/freetype/src/cid/cidparse.c @@ -4,7 +4,7 @@ /* */ /* CID-keyed Type1 parser (body). */ /* */ -/* Copyright 1996-2016 by */ +/* Copyright 1996-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -65,7 +65,7 @@ FT_Byte *arg1, *arg2; - FT_MEM_ZERO( parser, sizeof ( *parser ) ); + FT_ZERO( parser ); psaux->ps_parser_funcs->init( &parser->root, 0, 0, memory ); parser->stream = stream; @@ -138,13 +138,13 @@ ft_strncmp( (char*)p, STARTDATA, STARTDATA_LEN ) == 0 ) { /* save offset of binary data after `StartData' */ - offset += (FT_ULong)( p - buffer ) + STARTDATA_LEN; + offset += (FT_ULong)( p - buffer ) + STARTDATA_LEN + 1; goto Found; } else if ( p[1] == 's' && ft_strncmp( (char*)p, SFNTS, SFNTS_LEN ) == 0 ) { - offset += (FT_ULong)( p - buffer ) + SFNTS_LEN; + offset += (FT_ULong)( p - buffer ) + SFNTS_LEN + 1; goto Found; } } @@ -199,7 +199,7 @@ limit = parser->root.limit; cur = parser->root.cursor; - while ( cur < limit - SFNTS_LEN ) + while ( cur <= limit - SFNTS_LEN ) { if ( parser->root.error ) { @@ -208,12 +208,12 @@ } if ( cur[0] == 'S' && - cur < limit - STARTDATA_LEN && + cur <= limit - STARTDATA_LEN && ft_strncmp( (char*)cur, STARTDATA, STARTDATA_LEN ) == 0 ) { if ( ft_strncmp( (char*)arg1, "(Hex)", 5 ) == 0 ) { - FT_Long tmp = ft_atol( (const char *)arg2 ); + FT_Long tmp = ft_strtol( (const char *)arg2, NULL, 10 ); if ( tmp < 0 ) diff --git a/thirdparty/freetype/src/cid/cidparse.h b/thirdparty/freetype/src/cid/cidparse.h index 7268dc6ae8..20bebb942b 100644 --- a/thirdparty/freetype/src/cid/cidparse.h +++ b/thirdparty/freetype/src/cid/cidparse.h @@ -4,7 +4,7 @@ /* */ /* CID-keyed Type1 parser (specification). */ /* */ -/* Copyright 1996-2016 by */ +/* Copyright 1996-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/thirdparty/freetype/src/cid/cidriver.c b/thirdparty/freetype/src/cid/cidriver.c index 64141ab6b1..bb611a961e 100644 --- a/thirdparty/freetype/src/cid/cidriver.c +++ b/thirdparty/freetype/src/cid/cidriver.c @@ -4,7 +4,7 @@ /* */ /* CID driver interface (body). */ /* */ -/* Copyright 1996-2016 by */ +/* Copyright 1996-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -206,7 +206,7 @@ 0x10000L, /* version 1.0 of driver */ 0x20000L, /* requires FreeType 2.0 */ - 0, /* module-specific interface */ + NULL, /* module-specific interface */ cid_driver_init, /* FT_Module_Constructor module_init */ cid_driver_done, /* FT_Module_Destructor module_done */ @@ -226,12 +226,12 @@ cid_slot_load_glyph, /* FT_Slot_LoadFunc load_glyph */ - 0, /* FT_Face_GetKerningFunc get_kerning */ - 0, /* FT_Face_AttachFunc attach_file */ - 0, /* FT_Face_GetAdvancesFunc get_advances */ + NULL, /* FT_Face_GetKerningFunc get_kerning */ + NULL, /* FT_Face_AttachFunc attach_file */ + NULL, /* FT_Face_GetAdvancesFunc get_advances */ cid_size_request, /* FT_Size_RequestFunc request_size */ - 0 /* FT_Size_SelectFunc select_size */ + NULL /* FT_Size_SelectFunc select_size */ }; diff --git a/thirdparty/freetype/src/cid/cidriver.h b/thirdparty/freetype/src/cid/cidriver.h index a359a78907..76640c57ba 100644 --- a/thirdparty/freetype/src/cid/cidriver.h +++ b/thirdparty/freetype/src/cid/cidriver.h @@ -4,7 +4,7 @@ /* */ /* High-level CID driver interface (specification). */ /* */ -/* Copyright 1996-2016 by */ +/* Copyright 1996-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/thirdparty/freetype/src/cid/cidtoken.h b/thirdparty/freetype/src/cid/cidtoken.h index 9c773fd094..653cc5586e 100644 --- a/thirdparty/freetype/src/cid/cidtoken.h +++ b/thirdparty/freetype/src/cid/cidtoken.h @@ -4,7 +4,7 @@ /* */ /* CID token definitions (specification only). */ /* */ -/* Copyright 1996-2016 by */ +/* Copyright 1996-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/thirdparty/freetype/src/cid/module.mk b/thirdparty/freetype/src/cid/module.mk index d9585d7816..b30b8679b9 100644 --- a/thirdparty/freetype/src/cid/module.mk +++ b/thirdparty/freetype/src/cid/module.mk @@ -3,7 +3,7 @@ # -# Copyright 1996-2016 by +# Copyright 1996-2017 by # David Turner, Robert Wilhelm, and Werner Lemberg. # # This file is part of the FreeType project, and may only be used, modified, diff --git a/thirdparty/freetype/src/cid/rules.mk b/thirdparty/freetype/src/cid/rules.mk index f33aab00d6..fcddd92eca 100644 --- a/thirdparty/freetype/src/cid/rules.mk +++ b/thirdparty/freetype/src/cid/rules.mk @@ -3,7 +3,7 @@ # -# Copyright 1996-2016 by +# Copyright 1996-2017 by # David Turner, Robert Wilhelm, and Werner Lemberg. # # This file is part of the FreeType project, and may only be used, modified, diff --git a/thirdparty/freetype/src/cid/type1cid.c b/thirdparty/freetype/src/cid/type1cid.c index de3bdf7705..93e6f810db 100644 --- a/thirdparty/freetype/src/cid/type1cid.c +++ b/thirdparty/freetype/src/cid/type1cid.c @@ -4,7 +4,7 @@ /* */ /* FreeType OpenType driver component (body only). */ /* */ -/* Copyright 1996-2016 by */ +/* Copyright 1996-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -17,13 +17,13 @@ #define FT_MAKE_OPTION_SINGLE_OBJECT - #include <ft2build.h> -#include "cidparse.c" + +#include "cidgload.c" #include "cidload.c" #include "cidobjs.c" +#include "cidparse.c" #include "cidriver.c" -#include "cidgload.c" /* END */ diff --git a/thirdparty/freetype/src/gxvalid/README b/thirdparty/freetype/src/gxvalid/README index d3ac49c3e2..7201459aaf 100644 --- a/thirdparty/freetype/src/gxvalid/README +++ b/thirdparty/freetype/src/gxvalid/README @@ -413,7 +413,7 @@ gxvalid: TrueType GX validator format assured for Windows and OS/2 support is only subtable format 0. The Microsoft TrueType specification also describes subtable format 2, but does not mention which platforms support - it. Aubtable formats 1, 3, and higher are documented as reserved + it. Subtable formats 1, 3, and higher are documented as reserved for future use. Therefore, the classic version can store subtable formats 0 and 2, at least. `ttfdump.exe', a font tool provided by Microsoft, ignores the subtable format written in the subtable @@ -518,7 +518,7 @@ gxvalid: TrueType GX validator ------------------------------------------------------------------------ -Copyright 2004-2016 by +Copyright 2004-2017 by suzuki toshiya, Masatake YAMATO, Red hat K.K., David Turner, Robert Wilhelm, and Werner Lemberg. diff --git a/thirdparty/freetype/src/gxvalid/gxvalid.c b/thirdparty/freetype/src/gxvalid/gxvalid.c index 7fb868cad1..da485141d3 100644 --- a/thirdparty/freetype/src/gxvalid/gxvalid.c +++ b/thirdparty/freetype/src/gxvalid/gxvalid.c @@ -4,7 +4,7 @@ /* */ /* FreeType validator for TrueTypeGX/AAT tables (body only). */ /* */ -/* Copyright 2005-2016 by */ +/* Copyright 2005-2017 by */ /* suzuki toshiya, Masatake YAMATO, Red Hat K.K., */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ @@ -16,15 +16,17 @@ /* */ /***************************************************************************/ -#define FT_MAKE_OPTION_SINGLE_OBJECT +#define FT_MAKE_OPTION_SINGLE_OBJECT #include <ft2build.h> -#include "gxvfeat.c" -#include "gxvcommn.c" #include "gxvbsln.c" -#include "gxvtrak.c" +#include "gxvcommn.c" +#include "gxvfeat.c" #include "gxvjust.c" +#include "gxvkern.c" +#include "gxvlcar.c" +#include "gxvmod.c" #include "gxvmort.c" #include "gxvmort0.c" #include "gxvmort1.c" @@ -37,11 +39,9 @@ #include "gxvmorx2.c" #include "gxvmorx4.c" #include "gxvmorx5.c" -#include "gxvkern.c" #include "gxvopbd.c" #include "gxvprop.c" -#include "gxvlcar.c" -#include "gxvmod.c" +#include "gxvtrak.c" /* END */ diff --git a/thirdparty/freetype/src/gxvalid/gxvalid.h b/thirdparty/freetype/src/gxvalid/gxvalid.h index 7a3ab795ef..78116ef85a 100644 --- a/thirdparty/freetype/src/gxvalid/gxvalid.h +++ b/thirdparty/freetype/src/gxvalid/gxvalid.h @@ -2,9 +2,9 @@ /* */ /* gxvalid.h */ /* */ -/* TrueTyeeGX/AAT table validation (specification only). */ +/* TrueTypeGX/AAT table validation (specification only). */ /* */ -/* Copyright 2005-2016 by */ +/* Copyright 2005-2017 by */ /* suzuki toshiya, Masatake YAMATO, Red Hat K.K., */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ diff --git a/thirdparty/freetype/src/gxvalid/gxvbsln.c b/thirdparty/freetype/src/gxvalid/gxvbsln.c index 493b20c31a..81dff7304d 100644 --- a/thirdparty/freetype/src/gxvalid/gxvbsln.c +++ b/thirdparty/freetype/src/gxvalid/gxvbsln.c @@ -4,7 +4,7 @@ /* */ /* TrueTypeGX/AAT bsln table validation (body). */ /* */ -/* Copyright 2004-2016 by */ +/* Copyright 2004-2017 by */ /* suzuki toshiya, Masatake YAMATO, Red Hat K.K., */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ diff --git a/thirdparty/freetype/src/gxvalid/gxvcommn.c b/thirdparty/freetype/src/gxvalid/gxvcommn.c index 4b5e41539a..db0a91ea74 100644 --- a/thirdparty/freetype/src/gxvalid/gxvcommn.c +++ b/thirdparty/freetype/src/gxvalid/gxvcommn.c @@ -4,7 +4,7 @@ /* */ /* TrueTypeGX/AAT common tables validation (body). */ /* */ -/* Copyright 2004-2016 by */ +/* Copyright 2004-2017 by */ /* suzuki toshiya, Masatake YAMATO, Red Hat K.K., */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ @@ -454,7 +454,7 @@ } - /* ================= Segment Single Format 2 Loolup Table ============== */ + /* ================= Segment Single Format 2 Lookup Table ============== */ /* * Apple spec says: * @@ -789,7 +789,7 @@ FT_INVALID_FORMAT; func = fmt_funcs_table[format]; - if ( func == NULL ) + if ( !func ) FT_INVALID_FORMAT; func( p, limit, gxvalid ); @@ -972,7 +972,7 @@ FT_UShort i; - ft_memset( nGlyphInClass, 0, 256 ); + FT_MEM_ZERO( nGlyphInClass, 256 ); for ( i = 0; i < nGlyphs; i++ ) @@ -1161,7 +1161,7 @@ break; } - if ( NULL != gxvalid->statetable.entry_validate_func ) + if ( gxvalid->statetable.entry_validate_func ) gxvalid->statetable.entry_validate_func( state, flags, &glyphOffset, @@ -1244,10 +1244,10 @@ if ( stateSize > 0xFF ) FT_INVALID_DATA; - if ( gxvalid->statetable.optdata_load_func != NULL ) + if ( gxvalid->statetable.optdata_load_func ) gxvalid->statetable.optdata_load_func( p, limit, gxvalid ); - if ( gxvalid->statetable.subtable_setup_func != NULL) + if ( gxvalid->statetable.subtable_setup_func ) setup_func = gxvalid->statetable.subtable_setup_func; else setup_func = gxv_StateTable_subtable_setup; @@ -1534,7 +1534,7 @@ goto Exit; } - if ( NULL != gxvalid->xstatetable.entry_validate_func ) + if ( gxvalid->xstatetable.entry_validate_func ) gxvalid->xstatetable.entry_validate_func( state, flags, &glyphOffset, @@ -1591,10 +1591,10 @@ GXV_TRACE(( "StateTable Subtables\n" )); - if ( gxvalid->xstatetable.optdata_load_func != NULL ) + if ( gxvalid->xstatetable.optdata_load_func ) gxvalid->xstatetable.optdata_load_func( p, limit, gxvalid ); - if ( gxvalid->xstatetable.subtable_setup_func != NULL ) + if ( gxvalid->xstatetable.subtable_setup_func ) setup_func = gxvalid->xstatetable.subtable_setup_func; else setup_func = gxv_XStateTable_subtable_setup; diff --git a/thirdparty/freetype/src/gxvalid/gxvcommn.h b/thirdparty/freetype/src/gxvalid/gxvcommn.h index 9470c8412b..10b1c800f0 100644 --- a/thirdparty/freetype/src/gxvalid/gxvcommn.h +++ b/thirdparty/freetype/src/gxvalid/gxvcommn.h @@ -4,7 +4,7 @@ /* */ /* TrueTypeGX/AAT common tables validation (specification). */ /* */ -/* Copyright 2004-2016 by */ +/* Copyright 2004-2017 by */ /* suzuki toshiya, Masatake YAMATO, Red Hat K.K., */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ diff --git a/thirdparty/freetype/src/gxvalid/gxverror.h b/thirdparty/freetype/src/gxvalid/gxverror.h index 2e53355ce4..80a2b8a262 100644 --- a/thirdparty/freetype/src/gxvalid/gxverror.h +++ b/thirdparty/freetype/src/gxvalid/gxverror.h @@ -4,7 +4,7 @@ /* */ /* TrueTypeGX/AAT validation module error codes (specification only). */ /* */ -/* Copyright 2004-2016 by */ +/* Copyright 2004-2017 by */ /* suzuki toshiya, Masatake YAMATO, Red Hat K.K., */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ diff --git a/thirdparty/freetype/src/gxvalid/gxvfeat.c b/thirdparty/freetype/src/gxvalid/gxvfeat.c index 5bff7c261d..2e3ec6f9be 100644 --- a/thirdparty/freetype/src/gxvalid/gxvfeat.c +++ b/thirdparty/freetype/src/gxvalid/gxvfeat.c @@ -4,7 +4,7 @@ /* */ /* TrueTypeGX/AAT feat table validation (body). */ /* */ -/* Copyright 2004-2016 by */ +/* Copyright 2004-2017 by */ /* suzuki toshiya, Masatake YAMATO, Red Hat K.K., */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ diff --git a/thirdparty/freetype/src/gxvalid/gxvfeat.h b/thirdparty/freetype/src/gxvalid/gxvfeat.h index 284bada891..8c0e847eb7 100644 --- a/thirdparty/freetype/src/gxvalid/gxvfeat.h +++ b/thirdparty/freetype/src/gxvalid/gxvfeat.h @@ -4,7 +4,7 @@ /* */ /* TrueTypeGX/AAT feat table validation (specification). */ /* */ -/* Copyright 2004-2016 by */ +/* Copyright 2004-2017 by */ /* suzuki toshiya, Masatake YAMATO, Red Hat K.K., */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ diff --git a/thirdparty/freetype/src/gxvalid/gxvfgen.c b/thirdparty/freetype/src/gxvalid/gxvfgen.c index 667dac3cde..8cc08cd9c3 100644 --- a/thirdparty/freetype/src/gxvalid/gxvfgen.c +++ b/thirdparty/freetype/src/gxvalid/gxvfgen.c @@ -5,7 +5,7 @@ /* Generate feature registry data for gxv `feat' validator. */ /* This program is derived from gxfeatreg.c in gxlayout. */ /* */ -/* Copyright 2004-2016 by */ +/* Copyright 2004-2017 by */ /* Masatake YAMATO and Redhat K.K. */ /* */ /* This file may only be used, */ diff --git a/thirdparty/freetype/src/gxvalid/gxvjust.c b/thirdparty/freetype/src/gxvalid/gxvjust.c index 20d29bfbc8..c8cfd83eac 100644 --- a/thirdparty/freetype/src/gxvalid/gxvjust.c +++ b/thirdparty/freetype/src/gxvalid/gxvjust.c @@ -4,7 +4,7 @@ /* */ /* TrueTypeGX/AAT just table validation (body). */ /* */ -/* Copyright 2005-2016 by */ +/* Copyright 2005-2017 by */ /* suzuki toshiya, Masatake YAMATO, Red Hat K.K., */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ diff --git a/thirdparty/freetype/src/gxvalid/gxvkern.c b/thirdparty/freetype/src/gxvalid/gxvkern.c index ee1ab36f70..9f9037387d 100644 --- a/thirdparty/freetype/src/gxvalid/gxvkern.c +++ b/thirdparty/freetype/src/gxvalid/gxvkern.c @@ -4,7 +4,7 @@ /* */ /* TrueTypeGX/AAT kern table validation (body). */ /* */ -/* Copyright 2004-2016 by */ +/* Copyright 2004-2017 by */ /* suzuki toshiya, Masatake YAMATO, Red Hat K.K., */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ diff --git a/thirdparty/freetype/src/gxvalid/gxvlcar.c b/thirdparty/freetype/src/gxvalid/gxvlcar.c index d31b6410bd..775d5229f2 100644 --- a/thirdparty/freetype/src/gxvalid/gxvlcar.c +++ b/thirdparty/freetype/src/gxvalid/gxvlcar.c @@ -4,7 +4,7 @@ /* */ /* TrueTypeGX/AAT lcar table validation (body). */ /* */ -/* Copyright 2004-2016 by */ +/* Copyright 2004-2017 by */ /* suzuki toshiya, Masatake YAMATO, Red Hat K.K., */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ diff --git a/thirdparty/freetype/src/gxvalid/gxvmod.c b/thirdparty/freetype/src/gxvalid/gxvmod.c index e589a7fb79..84e9275baf 100644 --- a/thirdparty/freetype/src/gxvalid/gxvmod.c +++ b/thirdparty/freetype/src/gxvalid/gxvmod.c @@ -4,7 +4,7 @@ /* */ /* FreeType's TrueTypeGX/AAT validation module implementation (body). */ /* */ -/* Copyright 2004-2016 by */ +/* Copyright 2004-2017 by */ /* suzuki toshiya, Masatake YAMATO, Red Hat K.K., */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ @@ -274,11 +274,11 @@ 0x10000L, 0x20000L, - 0, /* module-specific interface */ + NULL, /* module-specific interface */ - (FT_Module_Constructor)0, - (FT_Module_Destructor) 0, - (FT_Module_Requester) gxvalid_get_service + (FT_Module_Constructor)NULL, /* module_init */ + (FT_Module_Destructor) NULL, /* module_done */ + (FT_Module_Requester) gxvalid_get_service /* get_interface */ }; diff --git a/thirdparty/freetype/src/gxvalid/gxvmod.h b/thirdparty/freetype/src/gxvalid/gxvmod.h index 8b82e91070..df25e60cb2 100644 --- a/thirdparty/freetype/src/gxvalid/gxvmod.h +++ b/thirdparty/freetype/src/gxvalid/gxvmod.h @@ -5,7 +5,7 @@ /* FreeType's TrueTypeGX/AAT validation module implementation */ /* (specification). */ /* */ -/* Copyright 2004-2016 by */ +/* Copyright 2004-2017 by */ /* suzuki toshiya, Masatake YAMATO, Red Hat K.K., */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ diff --git a/thirdparty/freetype/src/gxvalid/gxvmort.c b/thirdparty/freetype/src/gxvalid/gxvmort.c index b83a2b2c0f..184a6317c0 100644 --- a/thirdparty/freetype/src/gxvalid/gxvmort.c +++ b/thirdparty/freetype/src/gxvalid/gxvmort.c @@ -4,7 +4,7 @@ /* */ /* TrueTypeGX/AAT mort table validation (body). */ /* */ -/* Copyright 2005-2016 by */ +/* Copyright 2005-2017 by */ /* suzuki toshiya, Masatake YAMATO, Red Hat K.K., */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ @@ -205,7 +205,7 @@ FT_INVALID_FORMAT; func = fmt_funcs_table[type]; - if ( func == NULL ) + if ( !func ) GXV_TRACE(( "morx type %d is reserved\n", type )); func( p, p + rest, gxvalid ); diff --git a/thirdparty/freetype/src/gxvalid/gxvmort.h b/thirdparty/freetype/src/gxvalid/gxvmort.h index 5fd228212a..d0543adcc5 100644 --- a/thirdparty/freetype/src/gxvalid/gxvmort.h +++ b/thirdparty/freetype/src/gxvalid/gxvmort.h @@ -4,7 +4,7 @@ /* */ /* TrueTypeGX/AAT common definition for mort table (specification). */ /* */ -/* Copyright 2004-2016 by */ +/* Copyright 2004-2017 by */ /* suzuki toshiya, Masatake YAMATO, Red Hat K.K., */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ diff --git a/thirdparty/freetype/src/gxvalid/gxvmort0.c b/thirdparty/freetype/src/gxvalid/gxvmort0.c index e11f5ddc49..a75fad7768 100644 --- a/thirdparty/freetype/src/gxvalid/gxvmort0.c +++ b/thirdparty/freetype/src/gxvalid/gxvmort0.c @@ -5,7 +5,7 @@ /* TrueTypeGX/AAT mort table validation */ /* body for type0 (Indic Script Rearrangement) subtable. */ /* */ -/* Copyright 2005-2016 by */ +/* Copyright 2005-2017 by */ /* suzuki toshiya, Masatake YAMATO, Red Hat K.K., */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ diff --git a/thirdparty/freetype/src/gxvalid/gxvmort1.c b/thirdparty/freetype/src/gxvalid/gxvmort1.c index fd761d0692..361ef2262d 100644 --- a/thirdparty/freetype/src/gxvalid/gxvmort1.c +++ b/thirdparty/freetype/src/gxvalid/gxvmort1.c @@ -5,7 +5,7 @@ /* TrueTypeGX/AAT mort table validation */ /* body for type1 (Contextual Substitution) subtable. */ /* */ -/* Copyright 2005-2016 by */ +/* Copyright 2005-2017 by */ /* suzuki toshiya, Masatake YAMATO, Red Hat K.K., */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ diff --git a/thirdparty/freetype/src/gxvalid/gxvmort2.c b/thirdparty/freetype/src/gxvalid/gxvmort2.c index 08455dec6b..c17e51e323 100644 --- a/thirdparty/freetype/src/gxvalid/gxvmort2.c +++ b/thirdparty/freetype/src/gxvalid/gxvmort2.c @@ -5,7 +5,7 @@ /* TrueTypeGX/AAT mort table validation */ /* body for type2 (Ligature Substitution) subtable. */ /* */ -/* Copyright 2005-2016 by */ +/* Copyright 2005-2017 by */ /* suzuki toshiya, Masatake YAMATO, Red Hat K.K., */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ diff --git a/thirdparty/freetype/src/gxvalid/gxvmort4.c b/thirdparty/freetype/src/gxvalid/gxvmort4.c index 6f7bbb8710..041bab369f 100644 --- a/thirdparty/freetype/src/gxvalid/gxvmort4.c +++ b/thirdparty/freetype/src/gxvalid/gxvmort4.c @@ -5,7 +5,7 @@ /* TrueTypeGX/AAT mort table validation */ /* body for type4 (Non-Contextual Glyph Substitution) subtable. */ /* */ -/* Copyright 2005-2016 by */ +/* Copyright 2005-2017 by */ /* suzuki toshiya, Masatake YAMATO, Red Hat K.K., */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ diff --git a/thirdparty/freetype/src/gxvalid/gxvmort5.c b/thirdparty/freetype/src/gxvalid/gxvmort5.c index 54ddbe2b15..4751eceaa0 100644 --- a/thirdparty/freetype/src/gxvalid/gxvmort5.c +++ b/thirdparty/freetype/src/gxvalid/gxvmort5.c @@ -5,7 +5,7 @@ /* TrueTypeGX/AAT mort table validation */ /* body for type5 (Contextual Glyph Insertion) subtable. */ /* */ -/* Copyright 2005-2016 by */ +/* Copyright 2005-2017 by */ /* suzuki toshiya, Masatake YAMATO, Red Hat K.K., */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ diff --git a/thirdparty/freetype/src/gxvalid/gxvmorx.c b/thirdparty/freetype/src/gxvalid/gxvmorx.c index a3abe435a6..2bb4f3b8b1 100644 --- a/thirdparty/freetype/src/gxvalid/gxvmorx.c +++ b/thirdparty/freetype/src/gxvalid/gxvmorx.c @@ -4,7 +4,7 @@ /* */ /* TrueTypeGX/AAT morx table validation (body). */ /* */ -/* Copyright 2005-2016 by */ +/* Copyright 2005-2017 by */ /* suzuki toshiya, Masatake YAMATO, Red Hat K.K., */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ @@ -98,7 +98,7 @@ FT_INVALID_FORMAT; func = fmt_funcs_table[type]; - if ( func == NULL ) + if ( !func ) GXV_TRACE(( "morx type %d is reserved\n", type )); func( p, p + rest, gxvalid ); diff --git a/thirdparty/freetype/src/gxvalid/gxvmorx.h b/thirdparty/freetype/src/gxvalid/gxvmorx.h index 9ba25c14a4..20cec58672 100644 --- a/thirdparty/freetype/src/gxvalid/gxvmorx.h +++ b/thirdparty/freetype/src/gxvalid/gxvmorx.h @@ -4,7 +4,7 @@ /* */ /* TrueTypeGX/AAT common definition for morx table (specification). */ /* */ -/* Copyright 2005-2016 by */ +/* Copyright 2005-2017 by */ /* suzuki toshiya, Masatake YAMATO, Red Hat K.K., */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ diff --git a/thirdparty/freetype/src/gxvalid/gxvmorx0.c b/thirdparty/freetype/src/gxvalid/gxvmorx0.c index 4abb7368f2..e0a0a92438 100644 --- a/thirdparty/freetype/src/gxvalid/gxvmorx0.c +++ b/thirdparty/freetype/src/gxvalid/gxvmorx0.c @@ -5,7 +5,7 @@ /* TrueTypeGX/AAT morx table validation */ /* body for type0 (Indic Script Rearrangement) subtable. */ /* */ -/* Copyright 2005-2016 by */ +/* Copyright 2005-2017 by */ /* suzuki toshiya, Masatake YAMATO, Red Hat K.K., */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ diff --git a/thirdparty/freetype/src/gxvalid/gxvmorx1.c b/thirdparty/freetype/src/gxvalid/gxvmorx1.c index e581848c2b..9afebdbfa8 100644 --- a/thirdparty/freetype/src/gxvalid/gxvmorx1.c +++ b/thirdparty/freetype/src/gxvalid/gxvmorx1.c @@ -5,7 +5,7 @@ /* TrueTypeGX/AAT morx table validation */ /* body for type1 (Contextual Substitution) subtable. */ /* */ -/* Copyright 2005-2016 by */ +/* Copyright 2005-2017 by */ /* suzuki toshiya, Masatake YAMATO, Red Hat K.K., */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ diff --git a/thirdparty/freetype/src/gxvalid/gxvmorx2.c b/thirdparty/freetype/src/gxvalid/gxvmorx2.c index 9495cca489..3a60cf68a4 100644 --- a/thirdparty/freetype/src/gxvalid/gxvmorx2.c +++ b/thirdparty/freetype/src/gxvalid/gxvmorx2.c @@ -5,7 +5,7 @@ /* TrueTypeGX/AAT morx table validation */ /* body for type2 (Ligature Substitution) subtable. */ /* */ -/* Copyright 2005-2016 by */ +/* Copyright 2005-2017 by */ /* suzuki toshiya, Masatake YAMATO, Red Hat K.K., */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ diff --git a/thirdparty/freetype/src/gxvalid/gxvmorx4.c b/thirdparty/freetype/src/gxvalid/gxvmorx4.c index 3b7731bbce..29555685af 100644 --- a/thirdparty/freetype/src/gxvalid/gxvmorx4.c +++ b/thirdparty/freetype/src/gxvalid/gxvmorx4.c @@ -5,7 +5,7 @@ /* TrueTypeGX/AAT morx table validation */ /* body for "morx" type4 (Non-Contextual Glyph Substitution) subtable. */ /* */ -/* Copyright 2005-2016 by */ +/* Copyright 2005-2017 by */ /* suzuki toshiya, Masatake YAMATO, Red Hat K.K., */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ diff --git a/thirdparty/freetype/src/gxvalid/gxvmorx5.c b/thirdparty/freetype/src/gxvalid/gxvmorx5.c index 0e96166c02..05c11417ef 100644 --- a/thirdparty/freetype/src/gxvalid/gxvmorx5.c +++ b/thirdparty/freetype/src/gxvalid/gxvmorx5.c @@ -5,7 +5,7 @@ /* TrueTypeGX/AAT morx table validation */ /* body for type5 (Contextual Glyph Insertion) subtable. */ /* */ -/* Copyright 2005-2016 by */ +/* Copyright 2005-2017 by */ /* suzuki toshiya, Masatake YAMATO, Red Hat K.K., */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ diff --git a/thirdparty/freetype/src/gxvalid/gxvopbd.c b/thirdparty/freetype/src/gxvalid/gxvopbd.c index e3ba082e16..11580d8b2a 100644 --- a/thirdparty/freetype/src/gxvalid/gxvopbd.c +++ b/thirdparty/freetype/src/gxvalid/gxvopbd.c @@ -4,7 +4,7 @@ /* */ /* TrueTypeGX/AAT opbd table validation (body). */ /* */ -/* Copyright 2004-2016 by */ +/* Copyright 2004-2017 by */ /* suzuki toshiya, Masatake YAMATO, Red Hat K.K., */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ diff --git a/thirdparty/freetype/src/gxvalid/gxvprop.c b/thirdparty/freetype/src/gxvalid/gxvprop.c index 61b3aeee30..7d398b7e66 100644 --- a/thirdparty/freetype/src/gxvalid/gxvprop.c +++ b/thirdparty/freetype/src/gxvalid/gxvprop.c @@ -4,7 +4,7 @@ /* */ /* TrueTypeGX/AAT prop table validation (body). */ /* */ -/* Copyright 2004-2016 by */ +/* Copyright 2004-2017 by */ /* suzuki toshiya, Masatake YAMATO, Red Hat K.K., */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ diff --git a/thirdparty/freetype/src/gxvalid/gxvtrak.c b/thirdparty/freetype/src/gxvalid/gxvtrak.c index 0f07c04e2a..dd49825565 100644 --- a/thirdparty/freetype/src/gxvalid/gxvtrak.c +++ b/thirdparty/freetype/src/gxvalid/gxvtrak.c @@ -4,7 +4,7 @@ /* */ /* TrueTypeGX/AAT trak table validation (body). */ /* */ -/* Copyright 2004-2016 by */ +/* Copyright 2004-2017 by */ /* suzuki toshiya, Masatake YAMATO, Red Hat K.K., */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ diff --git a/thirdparty/freetype/src/gxvalid/module.mk b/thirdparty/freetype/src/gxvalid/module.mk index b431384a5c..7f87e10812 100644 --- a/thirdparty/freetype/src/gxvalid/module.mk +++ b/thirdparty/freetype/src/gxvalid/module.mk @@ -2,7 +2,7 @@ # FreeType 2 gxvalid module definition # -# Copyright 2004-2016 by +# Copyright 2004-2017 by # suzuki toshiya, Masatake YAMATO, Red Hat K.K., # David Turner, Robert Wilhelm, and Werner Lemberg. # diff --git a/thirdparty/freetype/src/gxvalid/rules.mk b/thirdparty/freetype/src/gxvalid/rules.mk index 424f2a6377..10ec08c5b0 100644 --- a/thirdparty/freetype/src/gxvalid/rules.mk +++ b/thirdparty/freetype/src/gxvalid/rules.mk @@ -3,7 +3,7 @@ # -# Copyright 2004-2016 by +# Copyright 2004-2017 by # suzuki toshiya, Masatake YAMATO, Red Hat K.K., # David Turner, Robert Wilhelm, and Werner Lemberg. # diff --git a/thirdparty/freetype/src/gzip/adler32.c b/thirdparty/freetype/src/gzip/adler32.c new file mode 100644 index 0000000000..c53f9dd125 --- /dev/null +++ b/thirdparty/freetype/src/gzip/adler32.c @@ -0,0 +1,48 @@ +/* adler32.c -- compute the Adler-32 checksum of a data stream + * Copyright (C) 1995-2002 Mark Adler + * For conditions of distribution and use, see copyright notice in zlib.h + */ + +/* @(#) $Id$ */ + +#include "zlib.h" + +#define BASE 65521L /* largest prime smaller than 65536 */ +#define NMAX 5552 +/* NMAX is the largest n such that 255n(n+1)/2 + (n+1)(BASE-1) <= 2^32-1 */ + +#define DO1(buf,i) {s1 += buf[i]; s2 += s1;} +#define DO2(buf,i) DO1(buf,i); DO1(buf,i+1); +#define DO4(buf,i) DO2(buf,i); DO2(buf,i+2); +#define DO8(buf,i) DO4(buf,i); DO4(buf,i+4); +#define DO16(buf) DO8(buf,0); DO8(buf,8); + +/* ========================================================================= */ +ZEXPORT(uLong) adler32( /* adler, buf, len) */ + uLong adler, + const Bytef *buf, + uInt len ) +{ + unsigned long s1 = adler & 0xffff; + unsigned long s2 = (adler >> 16) & 0xffff; + int k; + + if (buf == Z_NULL) return 1L; + + while (len > 0) { + k = len < NMAX ? len : NMAX; + len -= k; + while (k >= 16) { + DO16(buf); + buf += 16; + k -= 16; + } + if (k != 0) do { + s1 += *buf++; + s2 += s1; + } while (--k); + s1 %= BASE; + s2 %= BASE; + } + return (s2 << 16) | s1; +} diff --git a/thirdparty/freetype/src/gzip/ftgzip.c b/thirdparty/freetype/src/gzip/ftgzip.c new file mode 100644 index 0000000000..c487786d99 --- /dev/null +++ b/thirdparty/freetype/src/gzip/ftgzip.c @@ -0,0 +1,816 @@ +/***************************************************************************/ +/* */ +/* ftgzip.c */ +/* */ +/* FreeType support for .gz compressed files. */ +/* */ +/* This optional component relies on zlib. It should mainly be used to */ +/* parse compressed PCF fonts, as found with many X11 server */ +/* distributions. */ +/* */ +/* Copyright 2002-2017 by */ +/* David Turner, Robert Wilhelm, and Werner Lemberg. */ +/* */ +/* This file is part of the FreeType project, and may only be used, */ +/* modified, and distributed under the terms of the FreeType project */ +/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ +/* this file you indicate that you have read the license and */ +/* understand and accept it fully. */ +/* */ +/***************************************************************************/ + + +#include <ft2build.h> +#include FT_INTERNAL_MEMORY_H +#include FT_INTERNAL_STREAM_H +#include FT_INTERNAL_DEBUG_H +#include FT_GZIP_H +#include FT_CONFIG_STANDARD_LIBRARY_H + + +#include FT_MODULE_ERRORS_H + +#undef FTERRORS_H_ + +#undef FT_ERR_PREFIX +#define FT_ERR_PREFIX Gzip_Err_ +#define FT_ERR_BASE FT_Mod_Err_Gzip + +#include FT_ERRORS_H + + +#ifdef FT_CONFIG_OPTION_USE_ZLIB + +#ifdef FT_CONFIG_OPTION_PIC +#error "gzip code does not support PIC yet" +#endif + +#ifdef FT_CONFIG_OPTION_SYSTEM_ZLIB + +#include <zlib.h> + +#else /* !FT_CONFIG_OPTION_SYSTEM_ZLIB */ + + /* In this case, we include our own modified sources of the ZLib */ + /* within the `gzip' component. The modifications were necessary */ + /* to #include all files without conflicts, as well as preventing */ + /* the definition of `extern' functions that may cause linking */ + /* conflicts when a program is linked with both FreeType and the */ + /* original ZLib. */ + +#ifndef USE_ZLIB_ZCALLOC +#define MY_ZCALLOC /* prevent all zcalloc() & zfree() in zutil.c */ +#endif + + /* Note that our `zlib.h' includes `ftzconf.h' instead of `zconf.h'; */ + /* the main reason is that even a global `zlib.h' includes `zconf.h' */ + /* with */ + /* */ + /* #include "zconf.h" */ + /* */ + /* instead of the expected */ + /* */ + /* #include <zconf.h> */ + /* */ + /* so that configuration with `FT_CONFIG_OPTION_SYSTEM_ZLIB' might */ + /* include the wrong `zconf.h' file, leading to errors. */ +#include "zlib.h" + +#undef SLOW +#define SLOW 1 /* we can't use asm-optimized sources here! */ + +#if defined( _MSC_VER ) /* Visual C++ (and Intel C++) */ + /* We disable the warning `conversion from XXX to YYY, */ + /* possible loss of data' in order to compile cleanly with */ + /* the maximum level of warnings: zlib is non-FreeType */ + /* code. */ +#pragma warning( push ) +#pragma warning( disable : 4244 ) +#endif /* _MSC_VER */ + + /* Urgh. `inflate_mask' must not be declared twice -- C++ doesn't like + this. We temporarily disable it and load all necessary header files. */ +#define NO_INFLATE_MASK +#include "zutil.h" +#include "inftrees.h" +#include "infblock.h" +#include "infcodes.h" +#include "infutil.h" +#undef NO_INFLATE_MASK + + /* infutil.c must be included before infcodes.c */ +#include "zutil.c" +#include "inftrees.c" +#include "infutil.c" +#include "infcodes.c" +#include "infblock.c" +#include "inflate.c" +#include "adler32.c" + +#if defined( _MSC_VER ) +#pragma warning( pop ) +#endif + +#endif /* !FT_CONFIG_OPTION_SYSTEM_ZLIB */ + + +/***************************************************************************/ +/***************************************************************************/ +/***** *****/ +/***** Z L I B M E M O R Y M A N A G E M E N T *****/ +/***** *****/ +/***************************************************************************/ +/***************************************************************************/ + + /* it is better to use FreeType memory routines instead of raw + 'malloc/free' */ + + static voidpf + ft_gzip_alloc( FT_Memory memory, + uInt items, + uInt size ) + { + FT_ULong sz = (FT_ULong)size * items; + FT_Error error; + FT_Pointer p = NULL; + + + (void)FT_ALLOC( p, sz ); + return p; + } + + + static void + ft_gzip_free( FT_Memory memory, + voidpf address ) + { + FT_MEM_FREE( address ); + } + + +#if !defined( FT_CONFIG_OPTION_SYSTEM_ZLIB ) && !defined( USE_ZLIB_ZCALLOC ) + + local voidpf + zcalloc ( voidpf opaque, + unsigned items, + unsigned size ) + { + return ft_gzip_alloc( (FT_Memory)opaque, items, size ); + } + + local void + zcfree( voidpf opaque, + voidpf ptr ) + { + ft_gzip_free( (FT_Memory)opaque, ptr ); + } + +#endif /* !SYSTEM_ZLIB && !USE_ZLIB_ZCALLOC */ + + +/***************************************************************************/ +/***************************************************************************/ +/***** *****/ +/***** Z L I B F I L E D E S C R I P T O R *****/ +/***** *****/ +/***************************************************************************/ +/***************************************************************************/ + +#define FT_GZIP_BUFFER_SIZE 4096 + + typedef struct FT_GZipFileRec_ + { + FT_Stream source; /* parent/source stream */ + FT_Stream stream; /* embedding stream */ + FT_Memory memory; /* memory allocator */ + z_stream zstream; /* zlib input stream */ + + FT_ULong start; /* starting position, after .gz header */ + FT_Byte input[FT_GZIP_BUFFER_SIZE]; /* input read buffer */ + + FT_Byte buffer[FT_GZIP_BUFFER_SIZE]; /* output buffer */ + FT_ULong pos; /* position in output */ + FT_Byte* cursor; + FT_Byte* limit; + + } FT_GZipFileRec, *FT_GZipFile; + + + /* gzip flag byte */ +#define FT_GZIP_ASCII_FLAG 0x01 /* bit 0 set: file probably ascii text */ +#define FT_GZIP_HEAD_CRC 0x02 /* bit 1 set: header CRC present */ +#define FT_GZIP_EXTRA_FIELD 0x04 /* bit 2 set: extra field present */ +#define FT_GZIP_ORIG_NAME 0x08 /* bit 3 set: original file name present */ +#define FT_GZIP_COMMENT 0x10 /* bit 4 set: file comment present */ +#define FT_GZIP_RESERVED 0xE0 /* bits 5..7: reserved */ + + + /* check and skip .gz header - we don't support `transparent' compression */ + static FT_Error + ft_gzip_check_header( FT_Stream stream ) + { + FT_Error error; + FT_Byte head[4]; + + + if ( FT_STREAM_SEEK( 0 ) || + FT_STREAM_READ( head, 4 ) ) + goto Exit; + + /* 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 || + head[2] != Z_DEFLATED || + (head[3] & FT_GZIP_RESERVED) ) + { + error = FT_THROW( Invalid_File_Format ); + goto Exit; + } + + /* skip time, xflags and os code */ + (void)FT_STREAM_SKIP( 6 ); + + /* skip the extra field */ + if ( head[3] & FT_GZIP_EXTRA_FIELD ) + { + FT_UInt len; + + + if ( FT_READ_USHORT_LE( len ) || + FT_STREAM_SKIP( len ) ) + goto Exit; + } + + /* skip original file name */ + if ( head[3] & FT_GZIP_ORIG_NAME ) + for (;;) + { + FT_UInt c; + + + if ( FT_READ_BYTE( c ) ) + goto Exit; + + if ( c == 0 ) + break; + } + + /* skip .gz comment */ + if ( head[3] & FT_GZIP_COMMENT ) + for (;;) + { + FT_UInt c; + + + if ( FT_READ_BYTE( c ) ) + goto Exit; + + if ( c == 0 ) + break; + } + + /* skip CRC */ + if ( head[3] & FT_GZIP_HEAD_CRC ) + if ( FT_STREAM_SKIP( 2 ) ) + goto Exit; + + Exit: + return error; + } + + + static FT_Error + ft_gzip_file_init( FT_GZipFile zip, + FT_Stream stream, + FT_Stream source ) + { + z_stream* zstream = &zip->zstream; + FT_Error error = FT_Err_Ok; + + + zip->stream = stream; + zip->source = source; + zip->memory = stream->memory; + + zip->limit = zip->buffer + FT_GZIP_BUFFER_SIZE; + zip->cursor = zip->limit; + zip->pos = 0; + + /* check and skip .gz header */ + { + stream = source; + + error = ft_gzip_check_header( stream ); + if ( error ) + goto Exit; + + zip->start = FT_STREAM_POS(); + } + + /* initialize zlib -- there is no zlib header in the compressed stream */ + zstream->zalloc = (alloc_func)ft_gzip_alloc; + zstream->zfree = (free_func) ft_gzip_free; + zstream->opaque = stream->memory; + + zstream->avail_in = 0; + zstream->next_in = zip->buffer; + + if ( inflateInit2( zstream, -MAX_WBITS ) != Z_OK || + !zstream->next_in ) + error = FT_THROW( Invalid_File_Format ); + + Exit: + return error; + } + + + static void + ft_gzip_file_done( FT_GZipFile zip ) + { + z_stream* zstream = &zip->zstream; + + + inflateEnd( zstream ); + + /* clear the rest */ + zstream->zalloc = NULL; + zstream->zfree = NULL; + zstream->opaque = NULL; + zstream->next_in = NULL; + zstream->next_out = NULL; + zstream->avail_in = 0; + zstream->avail_out = 0; + + zip->memory = NULL; + zip->source = NULL; + zip->stream = NULL; + } + + + static FT_Error + ft_gzip_file_reset( FT_GZipFile zip ) + { + FT_Stream stream = zip->source; + FT_Error error; + + + if ( !FT_STREAM_SEEK( zip->start ) ) + { + z_stream* zstream = &zip->zstream; + + + inflateReset( zstream ); + + zstream->avail_in = 0; + zstream->next_in = zip->input; + zstream->avail_out = 0; + zstream->next_out = zip->buffer; + + zip->limit = zip->buffer + FT_GZIP_BUFFER_SIZE; + zip->cursor = zip->limit; + zip->pos = 0; + } + + return error; + } + + + static FT_Error + ft_gzip_file_fill_input( FT_GZipFile zip ) + { + z_stream* zstream = &zip->zstream; + FT_Stream stream = zip->source; + FT_ULong size; + + + if ( stream->read ) + { + size = stream->read( stream, stream->pos, zip->input, + FT_GZIP_BUFFER_SIZE ); + if ( size == 0 ) + { + zip->limit = zip->cursor; + return FT_THROW( Invalid_Stream_Operation ); + } + } + else + { + size = stream->size - stream->pos; + if ( size > FT_GZIP_BUFFER_SIZE ) + size = FT_GZIP_BUFFER_SIZE; + + if ( size == 0 ) + { + zip->limit = zip->cursor; + return FT_THROW( Invalid_Stream_Operation ); + } + + FT_MEM_COPY( zip->input, stream->base + stream->pos, size ); + } + stream->pos += size; + + zstream->next_in = zip->input; + zstream->avail_in = size; + + return FT_Err_Ok; + } + + + static FT_Error + ft_gzip_file_fill_output( FT_GZipFile zip ) + { + z_stream* zstream = &zip->zstream; + FT_Error error = FT_Err_Ok; + + + zip->cursor = zip->buffer; + zstream->next_out = zip->cursor; + zstream->avail_out = FT_GZIP_BUFFER_SIZE; + + while ( zstream->avail_out > 0 ) + { + int err; + + + if ( zstream->avail_in == 0 ) + { + error = ft_gzip_file_fill_input( zip ); + if ( error ) + break; + } + + err = inflate( zstream, Z_NO_FLUSH ); + + if ( err == Z_STREAM_END ) + { + zip->limit = zstream->next_out; + if ( zip->limit == zip->cursor ) + error = FT_THROW( Invalid_Stream_Operation ); + break; + } + else if ( err != Z_OK ) + { + zip->limit = zip->cursor; + error = FT_THROW( Invalid_Stream_Operation ); + break; + } + } + + return error; + } + + + /* fill output buffer; `count' must be <= FT_GZIP_BUFFER_SIZE */ + static FT_Error + ft_gzip_file_skip_output( FT_GZipFile zip, + FT_ULong count ) + { + FT_Error error = FT_Err_Ok; + FT_ULong delta; + + + for (;;) + { + delta = (FT_ULong)( zip->limit - zip->cursor ); + if ( delta >= count ) + delta = count; + + zip->cursor += delta; + zip->pos += delta; + + count -= delta; + if ( count == 0 ) + break; + + error = ft_gzip_file_fill_output( zip ); + if ( error ) + break; + } + + return error; + } + + + static FT_ULong + ft_gzip_file_io( FT_GZipFile zip, + FT_ULong pos, + FT_Byte* buffer, + FT_ULong count ) + { + FT_ULong result = 0; + FT_Error error; + + + /* Reset inflate stream if we're seeking backwards. */ + /* Yes, that is not too efficient, but it saves memory :-) */ + if ( pos < zip->pos ) + { + error = ft_gzip_file_reset( zip ); + if ( error ) + goto Exit; + } + + /* skip unwanted bytes */ + if ( pos > zip->pos ) + { + error = ft_gzip_file_skip_output( zip, (FT_ULong)( pos - zip->pos ) ); + if ( error ) + goto Exit; + } + + if ( count == 0 ) + goto Exit; + + /* now read the data */ + for (;;) + { + FT_ULong delta; + + + delta = (FT_ULong)( zip->limit - zip->cursor ); + if ( delta >= count ) + delta = count; + + FT_MEM_COPY( buffer, zip->cursor, delta ); + buffer += delta; + result += delta; + zip->cursor += delta; + zip->pos += delta; + + count -= delta; + if ( count == 0 ) + break; + + error = ft_gzip_file_fill_output( zip ); + if ( error ) + break; + } + + Exit: + return result; + } + + +/***************************************************************************/ +/***************************************************************************/ +/***** *****/ +/***** G Z E M B E D D I N G S T R E A M *****/ +/***** *****/ +/***************************************************************************/ +/***************************************************************************/ + + static void + ft_gzip_stream_close( FT_Stream stream ) + { + FT_GZipFile zip = (FT_GZipFile)stream->descriptor.pointer; + FT_Memory memory = stream->memory; + + + if ( zip ) + { + /* finalize gzip file descriptor */ + ft_gzip_file_done( zip ); + + FT_FREE( zip ); + + stream->descriptor.pointer = NULL; + } + + if ( !stream->read ) + FT_FREE( stream->base ); + } + + + static unsigned long + ft_gzip_stream_io( FT_Stream stream, + unsigned long offset, + unsigned char* buffer, + unsigned long count ) + { + FT_GZipFile zip = (FT_GZipFile)stream->descriptor.pointer; + + + return ft_gzip_file_io( zip, offset, buffer, count ); + } + + + static FT_ULong + ft_gzip_get_uncompressed_size( FT_Stream stream ) + { + FT_Error error; + FT_ULong old_pos; + FT_ULong result = 0; + + + old_pos = stream->pos; + if ( !FT_Stream_Seek( stream, stream->size - 4 ) ) + { + result = FT_Stream_ReadULongLE( stream, &error ); + if ( error ) + result = 0; + + (void)FT_Stream_Seek( stream, old_pos ); + } + + return result; + } + + + /* documentation is in ftgzip.h */ + + FT_EXPORT_DEF( FT_Error ) + FT_Stream_OpenGzip( FT_Stream stream, + FT_Stream source ) + { + FT_Error error; + 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 + */ + error = ft_gzip_check_header( source ); + if ( error ) + goto Exit; + + FT_ZERO( stream ); + stream->memory = memory; + + if ( !FT_QNEW( zip ) ) + { + error = ft_gzip_file_init( zip, stream, source ); + if ( error ) + { + FT_FREE( zip ); + goto Exit; + } + + stream->descriptor.pointer = zip; + } + + /* + * We use the following trick to try to dramatically improve the + * performance while dealing with small files. If the original stream + * size is less than a certain threshold, we try to load the whole font + * file into memory. This saves us from using the 32KB buffer needed + * to inflate the file, plus the two 4KB intermediate input/output + * buffers used in the `FT_GZipFile' structure. + */ + { + FT_ULong zip_size = ft_gzip_get_uncompressed_size( source ); + + + if ( zip_size != 0 && zip_size < 40 * 1024 ) + { + FT_Byte* zip_buff = NULL; + + + if ( !FT_ALLOC( zip_buff, zip_size ) ) + { + FT_ULong count; + + + count = ft_gzip_file_io( zip, 0, zip_buff, zip_size ); + if ( count == zip_size ) + { + ft_gzip_file_done( zip ); + FT_FREE( zip ); + + stream->descriptor.pointer = NULL; + + stream->size = zip_size; + stream->pos = 0; + stream->base = zip_buff; + stream->read = NULL; + stream->close = ft_gzip_stream_close; + + goto Exit; + } + + ft_gzip_file_io( zip, 0, NULL, 0 ); + FT_FREE( zip_buff ); + } + error = FT_Err_Ok; + } + + if ( zip_size ) + stream->size = zip_size; + else + stream->size = 0x7FFFFFFFL; /* don't know the real size! */ + } + + stream->pos = 0; + stream->base = NULL; + stream->read = ft_gzip_stream_io; + stream->close = ft_gzip_stream_close; + + Exit: + return error; + } + + + /* documentation is in ftgzip.h */ + + FT_EXPORT_DEF( FT_Error ) + FT_Gzip_Uncompress( FT_Memory memory, + FT_Byte* output, + FT_ULong* output_len, + const FT_Byte* input, + FT_ULong input_len ) + { + z_stream stream; + 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; + stream.avail_in = (uInt)input_len; + + stream.next_out = output; + stream.avail_out = (uInt)*output_len; + + stream.zalloc = (alloc_func)ft_gzip_alloc; + stream.zfree = (free_func) ft_gzip_free; + stream.opaque = memory; + + err = inflateInit2( &stream, MAX_WBITS ); + if ( err != Z_OK ) + return FT_THROW( Invalid_Argument ); + + err = inflate( &stream, Z_FINISH ); + if ( err != Z_STREAM_END ) + { + inflateEnd( &stream ); + if ( err == Z_OK ) + err = Z_BUF_ERROR; + } + else + { + *output_len = stream.total_out; + + err = inflateEnd( &stream ); + } + + if ( err == Z_MEM_ERROR ) + return FT_THROW( Out_Of_Memory ); + + if ( err == Z_BUF_ERROR ) + return FT_THROW( Array_Too_Large ); + + if ( err == Z_DATA_ERROR ) + return FT_THROW( Invalid_Table ); + + return FT_Err_Ok; + } + + +#else /* !FT_CONFIG_OPTION_USE_ZLIB */ + + FT_EXPORT_DEF( FT_Error ) + FT_Stream_OpenGzip( FT_Stream stream, + FT_Stream source ) + { + FT_UNUSED( stream ); + FT_UNUSED( source ); + + return FT_THROW( Unimplemented_Feature ); + } + + + FT_EXPORT_DEF( FT_Error ) + FT_Gzip_Uncompress( FT_Memory memory, + FT_Byte* output, + FT_ULong* output_len, + const FT_Byte* input, + FT_ULong input_len ) + { + FT_UNUSED( memory ); + FT_UNUSED( output ); + FT_UNUSED( output_len ); + FT_UNUSED( input ); + FT_UNUSED( input_len ); + + return FT_THROW( Unimplemented_Feature ); + } + +#endif /* !FT_CONFIG_OPTION_USE_ZLIB */ + + +/* END */ diff --git a/thirdparty/freetype/src/gzip/ftzconf.h b/thirdparty/freetype/src/gzip/ftzconf.h new file mode 100644 index 0000000000..3abf0ba03b --- /dev/null +++ b/thirdparty/freetype/src/gzip/ftzconf.h @@ -0,0 +1,284 @@ +/* zconf.h -- configuration of the zlib compression library + * Copyright (C) 1995-2002 Jean-loup Gailly. + * For conditions of distribution and use, see copyright notice in zlib.h + */ + +/* @(#) $Id$ */ + +#ifndef _ZCONF_H +#define _ZCONF_H + +/* + * If you *really* need a unique prefix for all types and library functions, + * compile with -DZ_PREFIX. The "standard" zlib should be compiled without it. + */ +#ifdef Z_PREFIX +# define deflateInit_ z_deflateInit_ +# define deflate z_deflate +# define deflateEnd z_deflateEnd +# define inflateInit_ z_inflateInit_ +# define inflate z_inflate +# define inflateEnd z_inflateEnd +# define deflateInit2_ z_deflateInit2_ +# define deflateSetDictionary z_deflateSetDictionary +# define deflateCopy z_deflateCopy +# define deflateReset z_deflateReset +# define deflateParams z_deflateParams +# define inflateInit2_ z_inflateInit2_ +# define inflateSetDictionary z_inflateSetDictionary +# define inflateSync z_inflateSync +# define inflateSyncPoint z_inflateSyncPoint +# define inflateReset z_inflateReset +# define compress z_compress +# define compress2 z_compress2 +# define uncompress z_uncompress +# define adler32 z_adler32 +# define crc32 z_crc32 +# define get_crc_table z_get_crc_table + +# define Byte z_Byte +# define uInt z_uInt +# define uLong z_uLong +# define Bytef z_Bytef +# define charf z_charf +# define intf z_intf +# define uIntf z_uIntf +# define uLongf z_uLongf +# define voidpf z_voidpf +# define voidp z_voidp +#endif + +#if (defined(_WIN32) || defined(__WIN32__)) && !defined(WIN32) +# define WIN32 +#endif +#if defined(__GNUC__) || defined(WIN32) || defined(__386__) || defined(i386) +# ifndef __32BIT__ +# define __32BIT__ +# endif +#endif +#if defined(__MSDOS__) && !defined(MSDOS) +# define MSDOS +#endif + +/* WinCE doesn't have errno.h */ +#ifdef _WIN32_WCE +# define NO_ERRNO_H +#endif + + +/* + * Compile with -DMAXSEG_64K if the alloc function cannot allocate more + * than 64k bytes at a time (needed on systems with 16-bit int). + */ +#if defined(MSDOS) && !defined(__32BIT__) +# define MAXSEG_64K +#endif +#ifdef MSDOS +# define UNALIGNED_OK +#endif + +#if (defined(MSDOS) || defined(_WINDOWS) || defined(WIN32)) && !defined(STDC) +# define STDC +#endif +#if defined(__STDC__) || defined(__cplusplus) || defined(__OS2__) +# ifndef STDC +# define STDC +# endif +#endif + +#ifndef STDC +# ifndef const /* cannot use !defined(STDC) && !defined(const) on Mac */ +# define const +# endif +#endif + +/* Some Mac compilers merge all .h files incorrectly: */ +#if defined(__MWERKS__) || defined(applec) ||defined(THINK_C) ||defined(__SC__) +# define NO_DUMMY_DECL +#endif + +/* Old Borland C and LCC incorrectly complains about missing returns: */ +#if defined(__BORLANDC__) && (__BORLANDC__ < 0x500) +# define NEED_DUMMY_RETURN +#endif + +#if defined(__LCC__) +# define NEED_DUMMY_RETURN +#endif + +/* Maximum value for memLevel in deflateInit2 */ +#ifndef MAX_MEM_LEVEL +# ifdef MAXSEG_64K +# define MAX_MEM_LEVEL 8 +# else +# define MAX_MEM_LEVEL 9 +# endif +#endif + +/* Maximum value for windowBits in deflateInit2 and inflateInit2. + * WARNING: reducing MAX_WBITS makes minigzip unable to extract .gz files + * created by gzip. (Files created by minigzip can still be extracted by + * gzip.) + */ +#ifndef MAX_WBITS +# define MAX_WBITS 15 /* 32K LZ77 window */ +#endif + +/* The memory requirements for deflate are (in bytes): + (1 << (windowBits+2)) + (1 << (memLevel+9)) + that is: 128K for windowBits=15 + 128K for memLevel = 8 (default values) + plus a few kilobytes for small objects. For example, if you want to reduce + the default memory requirements from 256K to 128K, compile with + make CFLAGS="-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7" + Of course this will generally degrade compression (there's no free lunch). + + The memory requirements for inflate are (in bytes) 1 << windowBits + that is, 32K for windowBits=15 (default value) plus a few kilobytes + for small objects. +*/ + + /* Type declarations */ + +#ifndef OF /* function prototypes */ +# ifdef STDC +# define OF(args) args +# else +# define OF(args) () +# endif +#endif + +/* The following definitions for FAR are needed only for MSDOS mixed + * model programming (small or medium model with some far allocations). + * This was tested only with MSC; for other MSDOS compilers you may have + * to define NO_MEMCPY in zutil.h. If you don't need the mixed model, + * just define FAR to be empty. + */ +#if (defined(M_I86SM) || defined(M_I86MM)) && !defined(__32BIT__) + /* MSC small or medium model */ +# define SMALL_MEDIUM +# ifdef _MSC_VER +# define FAR _far +# else +# define FAR far +# endif +#endif +#if defined(__BORLANDC__) && (defined(__SMALL__) || defined(__MEDIUM__)) +# ifndef __32BIT__ +# define SMALL_MEDIUM +# define FAR _far +# endif +#endif + +/* Compile with -DZLIB_DLL for Windows DLL support */ +#if defined(ZLIB_DLL) +# if defined(_WINDOWS) || defined(WINDOWS) +# ifdef FAR +# undef FAR +# endif +# include <windows.h> +# define ZEXPORT(x) x WINAPI +# ifdef WIN32 +# define ZEXPORTVA(x) x WINAPIV +# else +# define ZEXPORTVA(x) x FAR _cdecl _export +# endif +# endif +# if defined (__BORLANDC__) +# if (__BORLANDC__ >= 0x0500) && defined (WIN32) +# include <windows.h> +# define ZEXPORT(x) x __declspec(dllexport) WINAPI +# define ZEXPORTRVA(x) x __declspec(dllexport) WINAPIV +# else +# if defined (_Windows) && defined (__DLL__) +# define ZEXPORT(x) x _export +# define ZEXPORTVA(x) x _export +# endif +# endif +# endif +#endif + + +#ifndef ZEXPORT +# define ZEXPORT(x) static x +#endif +#ifndef ZEXPORTVA +# define ZEXPORTVA(x) static x +#endif +#ifndef ZEXTERN +# define ZEXTERN(x) static x +#endif +#ifndef ZEXTERNDEF +# define ZEXTERNDEF(x) static x +#endif + +#ifndef FAR +# define FAR +#endif + +#if !defined(MACOS) && !defined(TARGET_OS_MAC) +typedef unsigned char Byte; /* 8 bits */ +#endif +typedef unsigned int uInt; /* 16 bits or more */ +typedef unsigned long uLong; /* 32 bits or more */ + +#ifdef SMALL_MEDIUM + /* Borland C/C++ and some old MSC versions ignore FAR inside typedef */ +# define Bytef Byte FAR +#else + typedef Byte FAR Bytef; +#endif +typedef char FAR charf; +typedef int FAR intf; +typedef uInt FAR uIntf; +typedef uLong FAR uLongf; + +#ifdef STDC + typedef void FAR *voidpf; + typedef void *voidp; +#else + typedef Byte FAR *voidpf; + typedef Byte *voidp; +#endif + +#ifdef HAVE_UNISTD_H +# include <sys/types.h> /* for off_t */ +# include <unistd.h> /* for SEEK_* and off_t */ +# define z_off_t off_t +#endif +#ifndef SEEK_SET +# define SEEK_SET 0 /* Seek from beginning of file. */ +# define SEEK_CUR 1 /* Seek from current position. */ +# define SEEK_END 2 /* Set file pointer to EOF plus "offset" */ +#endif +#ifndef z_off_t +# define z_off_t long +#endif + +/* MVS linker does not support external names larger than 8 bytes */ +#if defined(__MVS__) +# pragma map(deflateInit_,"DEIN") +# pragma map(deflateInit2_,"DEIN2") +# pragma map(deflateEnd,"DEEND") +# pragma map(inflateInit_,"ININ") +# pragma map(inflateInit2_,"ININ2") +# pragma map(inflateEnd,"INEND") +# pragma map(inflateSync,"INSY") +# pragma map(inflateSetDictionary,"INSEDI") +# pragma map(inflate_blocks,"INBL") +# pragma map(inflate_blocks_new,"INBLNE") +# pragma map(inflate_blocks_free,"INBLFR") +# pragma map(inflate_blocks_reset,"INBLRE") +# pragma map(inflate_codes_free,"INCOFR") +# pragma map(inflate_codes,"INCO") +# pragma map(inflate_fast,"INFA") +# pragma map(inflate_flush,"INFLU") +# pragma map(inflate_mask,"INMA") +# pragma map(inflate_set_dictionary,"INSEDI2") +# pragma map(inflate_copyright,"INCOPY") +# pragma map(inflate_trees_bits,"INTRBI") +# pragma map(inflate_trees_dynamic,"INTRDY") +# pragma map(inflate_trees_fixed,"INTRFI") +# pragma map(inflate_trees_free,"INTRFR") +#endif + +#endif /* _ZCONF_H */ diff --git a/thirdparty/freetype/src/gzip/infblock.c b/thirdparty/freetype/src/gzip/infblock.c new file mode 100644 index 0000000000..d6e2dc297d --- /dev/null +++ b/thirdparty/freetype/src/gzip/infblock.c @@ -0,0 +1,387 @@ +/* infblock.c -- interpret and process block types to last block + * Copyright (C) 1995-2002 Mark Adler + * For conditions of distribution and use, see copyright notice in zlib.h + */ + +#include "zutil.h" +#include "infblock.h" +#include "inftrees.h" +#include "infcodes.h" +#include "infutil.h" + + +/* simplify the use of the inflate_huft type with some defines */ +#define exop word.what.Exop +#define bits word.what.Bits + +/* Table for deflate from PKZIP's appnote.txt. */ +local const uInt border[] = { /* Order of the bit length code lengths */ + 16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15}; + +/* + Notes beyond the 1.93a appnote.txt: + + 1. Distance pointers never point before the beginning of the output + stream. + 2. Distance pointers can point back across blocks, up to 32k away. + 3. There is an implied maximum of 7 bits for the bit length table and + 15 bits for the actual data. + 4. If only one code exists, then it is encoded using one bit. (Zero + would be more efficient, but perhaps a little confusing.) If two + codes exist, they are coded using one bit each (0 and 1). + 5. There is no way of sending zero distance codes--a dummy must be + sent if there are none. (History: a pre 2.0 version of PKZIP would + store blocks with no distance codes, but this was discovered to be + too harsh a criterion.) Valid only for 1.93a. 2.04c does allow + zero distance codes, which is sent as one code of zero bits in + length. + 6. There are up to 286 literal/length codes. Code 256 represents the + end-of-block. Note however that the static length tree defines + 288 codes just to fill out the Huffman codes. Codes 286 and 287 + cannot be used though, since there is no length base or extra bits + defined for them. Similarily, there are up to 30 distance codes. + However, static trees define 32 codes (all 5 bits) to fill out the + Huffman codes, but the last two had better not show up in the data. + 7. Unzip can check dynamic Huffman blocks for complete code sets. + The exception is that a single code would not be complete (see #4). + 8. The five bits following the block type is really the number of + literal codes sent minus 257. + 9. Length codes 8,16,16 are interpreted as 13 length codes of 8 bits + (1+6+6). Therefore, to output three times the length, you output + three codes (1+1+1), whereas to output four times the same length, + you only need two codes (1+3). Hmm. + 10. In the tree reconstruction algorithm, Code = Code + Increment + only if BitLength(i) is not zero. (Pretty obvious.) + 11. Correction: 4 Bits: # of Bit Length codes - 4 (4 - 19) + 12. Note: length code 284 can represent 227-258, but length code 285 + really is 258. The last length deserves its own, short code + since it gets used a lot in very redundant files. The length + 258 is special since 258 - 3 (the min match length) is 255. + 13. The literal/length and distance code bit lengths are read as a + single stream of lengths. It is possible (and advantageous) for + a repeat code (16, 17, or 18) to go across the boundary between + the two sets of lengths. + */ + + +local void inflate_blocks_reset( /* s, z, c) */ +inflate_blocks_statef *s, +z_streamp z, +uLongf *c ) +{ + if (c != Z_NULL) + *c = s->check; + if (s->mode == BTREE || s->mode == DTREE) + ZFREE(z, s->sub.trees.blens); + if (s->mode == CODES) + inflate_codes_free(s->sub.decode.codes, z); + s->mode = TYPE; + s->bitk = 0; + s->bitb = 0; + s->read = s->write = s->window; + if (s->checkfn != Z_NULL) + z->adler = s->check = (*s->checkfn)(0L, (const Bytef *)Z_NULL, 0); + Tracev((stderr, "inflate: blocks reset\n")); +} + + +local inflate_blocks_statef *inflate_blocks_new( /* z, c, w) */ +z_streamp z, +check_func c, +uInt w ) +{ + inflate_blocks_statef *s; + + if ((s = (inflate_blocks_statef *)ZALLOC + (z,1,sizeof(struct inflate_blocks_state))) == Z_NULL) + return s; + if ((s->hufts = + (inflate_huft *)ZALLOC(z, sizeof(inflate_huft), MANY)) == Z_NULL) + { + ZFREE(z, s); + return Z_NULL; + } + if ((s->window = (Bytef *)ZALLOC(z, 1, w)) == Z_NULL) + { + ZFREE(z, s->hufts); + ZFREE(z, s); + return Z_NULL; + } + s->end = s->window + w; + s->checkfn = c; + s->mode = TYPE; + Tracev((stderr, "inflate: blocks allocated\n")); + inflate_blocks_reset(s, z, Z_NULL); + return s; +} + + +local int inflate_blocks( /* s, z, r) */ +inflate_blocks_statef *s, +z_streamp z, +int r ) +{ + uInt t; /* temporary storage */ + uLong b; /* bit buffer */ + uInt k; /* bits in bit buffer */ + Bytef *p; /* input data pointer */ + uInt n; /* bytes available there */ + Bytef *q; /* output window write pointer */ + uInt m; /* bytes to end of window or read pointer */ + + /* copy input/output information to locals (UPDATE macro restores) */ + LOAD + + /* process input based on current state */ + while (1) switch (s->mode) + { + case TYPE: + NEEDBITS(3) + t = (uInt)b & 7; + s->last = t & 1; + switch (t >> 1) + { + case 0: /* stored */ + Tracev((stderr, "inflate: stored block%s\n", + s->last ? " (last)" : "")); + DUMPBITS(3) + t = k & 7; /* go to byte boundary */ + DUMPBITS(t) + s->mode = LENS; /* get length of stored block */ + break; + case 1: /* fixed */ + Tracev((stderr, "inflate: fixed codes block%s\n", + s->last ? " (last)" : "")); + { + uInt bl, bd; + inflate_huft *tl, *td; + + inflate_trees_fixed(&bl, &bd, (const inflate_huft**)&tl, + (const inflate_huft**)&td, z); + s->sub.decode.codes = inflate_codes_new(bl, bd, tl, td, z); + if (s->sub.decode.codes == Z_NULL) + { + r = Z_MEM_ERROR; + LEAVE + } + } + DUMPBITS(3) + s->mode = CODES; + break; + case 2: /* dynamic */ + Tracev((stderr, "inflate: dynamic codes block%s\n", + s->last ? " (last)" : "")); + DUMPBITS(3) + s->mode = TABLE; + break; + case 3: /* illegal */ + DUMPBITS(3) + s->mode = BAD; + z->msg = (char*)"invalid block type"; + r = Z_DATA_ERROR; + LEAVE + } + break; + case LENS: + NEEDBITS(32) + if ((((~b) >> 16) & 0xffff) != (b & 0xffff)) + { + s->mode = BAD; + z->msg = (char*)"invalid stored block lengths"; + r = Z_DATA_ERROR; + LEAVE + } + s->sub.left = (uInt)b & 0xffff; + b = k = 0; /* dump bits */ + Tracev((stderr, "inflate: stored length %u\n", s->sub.left)); + s->mode = s->sub.left ? STORED : (s->last ? DRY : TYPE); + break; + case STORED: + if (n == 0) + LEAVE + NEEDOUT + t = s->sub.left; + if (t > n) t = n; + if (t > m) t = m; + zmemcpy(q, p, t); + p += t; n -= t; + q += t; m -= t; + if ((s->sub.left -= t) != 0) + break; + Tracev((stderr, "inflate: stored end, %lu total out\n", + z->total_out + (q >= s->read ? q - s->read : + (s->end - s->read) + (q - s->window)))); + s->mode = s->last ? DRY : TYPE; + break; + case TABLE: + NEEDBITS(14) + s->sub.trees.table = t = (uInt)b & 0x3fff; +#ifndef PKZIP_BUG_WORKAROUND + if ((t & 0x1f) > 29 || ((t >> 5) & 0x1f) > 29) + { + s->mode = BAD; + z->msg = (char*)"too many length or distance symbols"; + r = Z_DATA_ERROR; + LEAVE + } +#endif + t = 258 + (t & 0x1f) + ((t >> 5) & 0x1f); + if ((s->sub.trees.blens = (uIntf*)ZALLOC(z, t, sizeof(uInt))) == Z_NULL) + { + r = Z_MEM_ERROR; + LEAVE + } + DUMPBITS(14) + s->sub.trees.index = 0; + Tracev((stderr, "inflate: table sizes ok\n")); + s->mode = BTREE; + case BTREE: + while (s->sub.trees.index < 4 + (s->sub.trees.table >> 10)) + { + NEEDBITS(3) + s->sub.trees.blens[border[s->sub.trees.index++]] = (uInt)b & 7; + DUMPBITS(3) + } + while (s->sub.trees.index < 19) + s->sub.trees.blens[border[s->sub.trees.index++]] = 0; + s->sub.trees.bb = 7; + t = inflate_trees_bits(s->sub.trees.blens, &s->sub.trees.bb, + &s->sub.trees.tb, s->hufts, z); + if (t != Z_OK) + { + r = t; + if (r == Z_DATA_ERROR) + { + ZFREE(z, s->sub.trees.blens); + s->mode = BAD; + } + LEAVE + } + s->sub.trees.index = 0; + Tracev((stderr, "inflate: bits tree ok\n")); + s->mode = DTREE; + case DTREE: + while (t = s->sub.trees.table, + s->sub.trees.index < 258 + (t & 0x1f) + ((t >> 5) & 0x1f)) + { + inflate_huft *h; + uInt i, j, c; + + t = s->sub.trees.bb; + NEEDBITS(t) + h = s->sub.trees.tb + ((uInt)b & inflate_mask[t]); + t = h->bits; + c = h->base; + if (c < 16) + { + DUMPBITS(t) + s->sub.trees.blens[s->sub.trees.index++] = c; + } + else /* c == 16..18 */ + { + i = c == 18 ? 7 : c - 14; + j = c == 18 ? 11 : 3; + NEEDBITS(t + i) + DUMPBITS(t) + j += (uInt)b & inflate_mask[i]; + DUMPBITS(i) + i = s->sub.trees.index; + t = s->sub.trees.table; + if (i + j > 258 + (t & 0x1f) + ((t >> 5) & 0x1f) || + (c == 16 && i < 1)) + { + ZFREE(z, s->sub.trees.blens); + s->mode = BAD; + z->msg = (char*)"invalid bit length repeat"; + r = Z_DATA_ERROR; + LEAVE + } + c = c == 16 ? s->sub.trees.blens[i - 1] : 0; + do { + s->sub.trees.blens[i++] = c; + } while (--j); + s->sub.trees.index = i; + } + } + s->sub.trees.tb = Z_NULL; + { + uInt bl, bd; + inflate_huft *tl, *td; + inflate_codes_statef *c; + + bl = 9; /* must be <= 9 for lookahead assumptions */ + bd = 6; /* must be <= 9 for lookahead assumptions */ + t = s->sub.trees.table; + t = inflate_trees_dynamic(257 + (t & 0x1f), 1 + ((t >> 5) & 0x1f), + s->sub.trees.blens, &bl, &bd, &tl, &td, + s->hufts, z); + if (t != Z_OK) + { + if (t == (uInt)Z_DATA_ERROR) + { + ZFREE(z, s->sub.trees.blens); + s->mode = BAD; + } + r = t; + LEAVE + } + Tracev((stderr, "inflate: trees ok\n")); + if ((c = inflate_codes_new(bl, bd, tl, td, z)) == Z_NULL) + { + r = Z_MEM_ERROR; + LEAVE + } + s->sub.decode.codes = c; + } + ZFREE(z, s->sub.trees.blens); + s->mode = CODES; + case CODES: + UPDATE + if ((r = inflate_codes(s, z, r)) != Z_STREAM_END) + return inflate_flush(s, z, r); + r = Z_OK; + inflate_codes_free(s->sub.decode.codes, z); + LOAD + Tracev((stderr, "inflate: codes end, %lu total out\n", + z->total_out + (q >= s->read ? q - s->read : + (s->end - s->read) + (q - s->window)))); + if (!s->last) + { + s->mode = TYPE; + break; + } + s->mode = DRY; + case DRY: + FLUSH + if (s->read != s->write) + LEAVE + s->mode = DONE; + case DONE: + r = Z_STREAM_END; + LEAVE + case BAD: + r = Z_DATA_ERROR; + LEAVE + default: + r = Z_STREAM_ERROR; + LEAVE + } +#ifdef NEED_DUMMY_RETURN + return 0; +#endif +} + + +local int inflate_blocks_free( /* s, z) */ +inflate_blocks_statef *s, +z_streamp z ) +{ + inflate_blocks_reset(s, z, Z_NULL); + ZFREE(z, s->window); + ZFREE(z, s->hufts); + ZFREE(z, s); + Tracev((stderr, "inflate: blocks freed\n")); + return Z_OK; +} + + diff --git a/thirdparty/freetype/src/gzip/infblock.h b/thirdparty/freetype/src/gzip/infblock.h new file mode 100644 index 0000000000..c2535a1e45 --- /dev/null +++ b/thirdparty/freetype/src/gzip/infblock.h @@ -0,0 +1,36 @@ +/* infblock.h -- header to use infblock.c + * Copyright (C) 1995-2002 Mark Adler + * For conditions of distribution and use, see copyright notice in zlib.h + */ + +/* WARNING: this file should *not* be used by applications. It is + part of the implementation of the compression library and is + subject to change. Applications should only use zlib.h. + */ + +#ifndef _INFBLOCK_H +#define _INFBLOCK_H + +struct inflate_blocks_state; +typedef struct inflate_blocks_state FAR inflate_blocks_statef; + +local inflate_blocks_statef * inflate_blocks_new OF(( + z_streamp z, + check_func c, /* check function */ + uInt w)); /* window size */ + +local int inflate_blocks OF(( + inflate_blocks_statef *, + z_streamp , + int)); /* initial return code */ + +local void inflate_blocks_reset OF(( + inflate_blocks_statef *, + z_streamp , + uLongf *)); /* check value on output */ + +local int inflate_blocks_free OF(( + inflate_blocks_statef *, + z_streamp)); + +#endif /* _INFBLOCK_H */ diff --git a/thirdparty/freetype/src/gzip/infcodes.c b/thirdparty/freetype/src/gzip/infcodes.c new file mode 100644 index 0000000000..f7bfd58c4f --- /dev/null +++ b/thirdparty/freetype/src/gzip/infcodes.c @@ -0,0 +1,250 @@ +/* infcodes.c -- process literals and length/distance pairs + * Copyright (C) 1995-2002 Mark Adler + * For conditions of distribution and use, see copyright notice in zlib.h + */ + +#include "zutil.h" +#include "inftrees.h" +#include "infblock.h" +#include "infcodes.h" +#include "infutil.h" + +/* simplify the use of the inflate_huft type with some defines */ +#define exop word.what.Exop +#define bits word.what.Bits + +typedef enum { /* waiting for "i:"=input, "o:"=output, "x:"=nothing */ + START, /* x: set up for LEN */ + LEN, /* i: get length/literal/eob next */ + LENEXT, /* i: getting length extra (have base) */ + DIST, /* i: get distance next */ + DISTEXT, /* i: getting distance extra */ + COPY, /* o: copying bytes in window, waiting for space */ + LIT, /* o: got literal, waiting for output space */ + WASH, /* o: got eob, possibly still output waiting */ + END, /* x: got eob and all data flushed */ + BADCODE} /* x: got error */ +inflate_codes_mode; + +/* inflate codes private state */ +struct inflate_codes_state { + + /* mode */ + inflate_codes_mode mode; /* current inflate_codes mode */ + + /* mode dependent information */ + uInt len; + union { + struct { + inflate_huft *tree; /* pointer into tree */ + uInt need; /* bits needed */ + } code; /* if LEN or DIST, where in tree */ + uInt lit; /* if LIT, literal */ + struct { + uInt get; /* bits to get for extra */ + uInt dist; /* distance back to copy from */ + } copy; /* if EXT or COPY, where and how much */ + } sub; /* submode */ + + /* mode independent information */ + Byte lbits; /* ltree bits decoded per branch */ + Byte dbits; /* dtree bits decoder per branch */ + inflate_huft *ltree; /* literal/length/eob tree */ + inflate_huft *dtree; /* distance tree */ + +}; + + +local inflate_codes_statef *inflate_codes_new( /* bl, bd, tl, td, z) */ +uInt bl, uInt bd, +inflate_huft *tl, +inflate_huft *td, /* need separate declaration for Borland C++ */ +z_streamp z ) +{ + inflate_codes_statef *c; + + if ((c = (inflate_codes_statef *) + ZALLOC(z,1,sizeof(struct inflate_codes_state))) != Z_NULL) + { + c->mode = START; + c->lbits = (Byte)bl; + c->dbits = (Byte)bd; + c->ltree = tl; + c->dtree = td; + Tracev((stderr, "inflate: codes new\n")); + } + return c; +} + + +local int inflate_codes( /* s, z, r) */ +inflate_blocks_statef *s, +z_streamp z, +int r ) +{ + uInt j; /* temporary storage */ + inflate_huft *t; /* temporary pointer */ + uInt e; /* extra bits or operation */ + uLong b; /* bit buffer */ + uInt k; /* bits in bit buffer */ + Bytef *p; /* input data pointer */ + uInt n; /* bytes available there */ + Bytef *q; /* output window write pointer */ + uInt m; /* bytes to end of window or read pointer */ + Bytef *f; /* pointer to copy strings from */ + inflate_codes_statef *c = s->sub.decode.codes; /* codes state */ + + /* copy input/output information to locals (UPDATE macro restores) */ + LOAD + + /* process input and output based on current state */ + while (1) switch (c->mode) + { /* waiting for "i:"=input, "o:"=output, "x:"=nothing */ + case START: /* x: set up for LEN */ +#ifndef SLOW + if (m >= 258 && n >= 10) + { + UPDATE + r = inflate_fast(c->lbits, c->dbits, c->ltree, c->dtree, s, z); + LOAD + if (r != Z_OK) + { + c->mode = r == Z_STREAM_END ? WASH : BADCODE; + break; + } + } +#endif /* !SLOW */ + c->sub.code.need = c->lbits; + c->sub.code.tree = c->ltree; + c->mode = LEN; + case LEN: /* i: get length/literal/eob next */ + j = c->sub.code.need; + NEEDBITS(j) + t = c->sub.code.tree + ((uInt)b & inflate_mask[j]); + DUMPBITS(t->bits) + e = (uInt)(t->exop); + if (e == 0) /* literal */ + { + c->sub.lit = t->base; + Tracevv((stderr, t->base >= 0x20 && t->base < 0x7f ? + "inflate: literal '%c'\n" : + "inflate: literal 0x%02x\n", t->base)); + c->mode = LIT; + break; + } + if (e & 16) /* length */ + { + c->sub.copy.get = e & 15; + c->len = t->base; + c->mode = LENEXT; + break; + } + if ((e & 64) == 0) /* next table */ + { + c->sub.code.need = e; + c->sub.code.tree = t + t->base; + break; + } + if (e & 32) /* end of block */ + { + Tracevv((stderr, "inflate: end of block\n")); + c->mode = WASH; + break; + } + c->mode = BADCODE; /* invalid code */ + z->msg = (char*)"invalid literal/length code"; + r = Z_DATA_ERROR; + LEAVE + case LENEXT: /* i: getting length extra (have base) */ + j = c->sub.copy.get; + NEEDBITS(j) + c->len += (uInt)b & inflate_mask[j]; + DUMPBITS(j) + c->sub.code.need = c->dbits; + c->sub.code.tree = c->dtree; + Tracevv((stderr, "inflate: length %u\n", c->len)); + c->mode = DIST; + case DIST: /* i: get distance next */ + j = c->sub.code.need; + NEEDBITS(j) + t = c->sub.code.tree + ((uInt)b & inflate_mask[j]); + DUMPBITS(t->bits) + e = (uInt)(t->exop); + if (e & 16) /* distance */ + { + c->sub.copy.get = e & 15; + c->sub.copy.dist = t->base; + c->mode = DISTEXT; + break; + } + if ((e & 64) == 0) /* next table */ + { + c->sub.code.need = e; + c->sub.code.tree = t + t->base; + break; + } + c->mode = BADCODE; /* invalid code */ + z->msg = (char*)"invalid distance code"; + r = Z_DATA_ERROR; + LEAVE + case DISTEXT: /* i: getting distance extra */ + j = c->sub.copy.get; + NEEDBITS(j) + c->sub.copy.dist += (uInt)b & inflate_mask[j]; + DUMPBITS(j) + Tracevv((stderr, "inflate: distance %u\n", c->sub.copy.dist)); + c->mode = COPY; + case COPY: /* o: copying bytes in window, waiting for space */ + f = q - c->sub.copy.dist; + while (f < s->window) /* modulo window size-"while" instead */ + f += s->end - s->window; /* of "if" handles invalid distances */ + while (c->len) + { + NEEDOUT + OUTBYTE(*f++) + if (f == s->end) + f = s->window; + c->len--; + } + c->mode = START; + break; + case LIT: /* o: got literal, waiting for output space */ + NEEDOUT + OUTBYTE(c->sub.lit) + c->mode = START; + break; + case WASH: /* o: got eob, possibly more output */ + if (k > 7) /* return unused byte, if any */ + { + Assert(k < 16, "inflate_codes grabbed too many bytes") + k -= 8; + n++; + p--; /* can always return one */ + } + FLUSH + if (s->read != s->write) + LEAVE + c->mode = END; + case END: + r = Z_STREAM_END; + LEAVE + case BADCODE: /* x: got error */ + r = Z_DATA_ERROR; + LEAVE + default: + r = Z_STREAM_ERROR; + LEAVE + } +#ifdef NEED_DUMMY_RETURN + return Z_STREAM_ERROR; /* Some dumb compilers complain without this */ +#endif +} + + +local void inflate_codes_free( /* c, z) */ +inflate_codes_statef *c, +z_streamp z ) +{ + ZFREE(z, c); + Tracev((stderr, "inflate: codes free\n")); +} diff --git a/thirdparty/freetype/src/gzip/infcodes.h b/thirdparty/freetype/src/gzip/infcodes.h new file mode 100644 index 0000000000..154d7f896c --- /dev/null +++ b/thirdparty/freetype/src/gzip/infcodes.h @@ -0,0 +1,31 @@ +/* infcodes.h -- header to use infcodes.c + * Copyright (C) 1995-2002 Mark Adler + * For conditions of distribution and use, see copyright notice in zlib.h + */ + +/* WARNING: this file should *not* be used by applications. It is + part of the implementation of the compression library and is + subject to change. Applications should only use zlib.h. + */ + +#ifndef _INFCODES_H +#define _INFCODES_H + +struct inflate_codes_state; +typedef struct inflate_codes_state FAR inflate_codes_statef; + +local inflate_codes_statef *inflate_codes_new OF(( + uInt, uInt, + inflate_huft *, inflate_huft *, + z_streamp )); + +local int inflate_codes OF(( + inflate_blocks_statef *, + z_streamp , + int)); + +local void inflate_codes_free OF(( + inflate_codes_statef *, + z_streamp )); + +#endif /* _INFCODES_H */ diff --git a/thirdparty/freetype/src/gzip/inffixed.h b/thirdparty/freetype/src/gzip/inffixed.h new file mode 100644 index 0000000000..4d4760ea00 --- /dev/null +++ b/thirdparty/freetype/src/gzip/inffixed.h @@ -0,0 +1,151 @@ +/* inffixed.h -- table for decoding fixed codes + * Generated automatically by the maketree.c program + */ + +/* WARNING: this file should *not* be used by applications. It is + part of the implementation of the compression library and is + subject to change. Applications should only use zlib.h. + */ + +local const uInt fixed_bl = 9; +local const uInt fixed_bd = 5; +local const inflate_huft fixed_tl[] = { + {{{96,7}},256}, {{{0,8}},80}, {{{0,8}},16}, {{{84,8}},115}, + {{{82,7}},31}, {{{0,8}},112}, {{{0,8}},48}, {{{0,9}},192}, + {{{80,7}},10}, {{{0,8}},96}, {{{0,8}},32}, {{{0,9}},160}, + {{{0,8}},0}, {{{0,8}},128}, {{{0,8}},64}, {{{0,9}},224}, + {{{80,7}},6}, {{{0,8}},88}, {{{0,8}},24}, {{{0,9}},144}, + {{{83,7}},59}, {{{0,8}},120}, {{{0,8}},56}, {{{0,9}},208}, + {{{81,7}},17}, {{{0,8}},104}, {{{0,8}},40}, {{{0,9}},176}, + {{{0,8}},8}, {{{0,8}},136}, {{{0,8}},72}, {{{0,9}},240}, + {{{80,7}},4}, {{{0,8}},84}, {{{0,8}},20}, {{{85,8}},227}, + {{{83,7}},43}, {{{0,8}},116}, {{{0,8}},52}, {{{0,9}},200}, + {{{81,7}},13}, {{{0,8}},100}, {{{0,8}},36}, {{{0,9}},168}, + {{{0,8}},4}, {{{0,8}},132}, {{{0,8}},68}, {{{0,9}},232}, + {{{80,7}},8}, {{{0,8}},92}, {{{0,8}},28}, {{{0,9}},152}, + {{{84,7}},83}, {{{0,8}},124}, {{{0,8}},60}, {{{0,9}},216}, + {{{82,7}},23}, {{{0,8}},108}, {{{0,8}},44}, {{{0,9}},184}, + {{{0,8}},12}, {{{0,8}},140}, {{{0,8}},76}, {{{0,9}},248}, + {{{80,7}},3}, {{{0,8}},82}, {{{0,8}},18}, {{{85,8}},163}, + {{{83,7}},35}, {{{0,8}},114}, {{{0,8}},50}, {{{0,9}},196}, + {{{81,7}},11}, {{{0,8}},98}, {{{0,8}},34}, {{{0,9}},164}, + {{{0,8}},2}, {{{0,8}},130}, {{{0,8}},66}, {{{0,9}},228}, + {{{80,7}},7}, {{{0,8}},90}, {{{0,8}},26}, {{{0,9}},148}, + {{{84,7}},67}, {{{0,8}},122}, {{{0,8}},58}, {{{0,9}},212}, + {{{82,7}},19}, {{{0,8}},106}, {{{0,8}},42}, {{{0,9}},180}, + {{{0,8}},10}, {{{0,8}},138}, {{{0,8}},74}, {{{0,9}},244}, + {{{80,7}},5}, {{{0,8}},86}, {{{0,8}},22}, {{{192,8}},0}, + {{{83,7}},51}, {{{0,8}},118}, {{{0,8}},54}, {{{0,9}},204}, + {{{81,7}},15}, {{{0,8}},102}, {{{0,8}},38}, {{{0,9}},172}, + {{{0,8}},6}, {{{0,8}},134}, {{{0,8}},70}, {{{0,9}},236}, + {{{80,7}},9}, {{{0,8}},94}, {{{0,8}},30}, {{{0,9}},156}, + {{{84,7}},99}, {{{0,8}},126}, {{{0,8}},62}, {{{0,9}},220}, + {{{82,7}},27}, {{{0,8}},110}, {{{0,8}},46}, {{{0,9}},188}, + {{{0,8}},14}, {{{0,8}},142}, {{{0,8}},78}, {{{0,9}},252}, + {{{96,7}},256}, {{{0,8}},81}, {{{0,8}},17}, {{{85,8}},131}, + {{{82,7}},31}, {{{0,8}},113}, {{{0,8}},49}, {{{0,9}},194}, + {{{80,7}},10}, {{{0,8}},97}, {{{0,8}},33}, {{{0,9}},162}, + {{{0,8}},1}, {{{0,8}},129}, {{{0,8}},65}, {{{0,9}},226}, + {{{80,7}},6}, {{{0,8}},89}, {{{0,8}},25}, {{{0,9}},146}, + {{{83,7}},59}, {{{0,8}},121}, {{{0,8}},57}, {{{0,9}},210}, + {{{81,7}},17}, {{{0,8}},105}, {{{0,8}},41}, {{{0,9}},178}, + {{{0,8}},9}, {{{0,8}},137}, {{{0,8}},73}, {{{0,9}},242}, + {{{80,7}},4}, {{{0,8}},85}, {{{0,8}},21}, {{{80,8}},258}, + {{{83,7}},43}, {{{0,8}},117}, {{{0,8}},53}, {{{0,9}},202}, + {{{81,7}},13}, {{{0,8}},101}, {{{0,8}},37}, {{{0,9}},170}, + {{{0,8}},5}, {{{0,8}},133}, {{{0,8}},69}, {{{0,9}},234}, + {{{80,7}},8}, {{{0,8}},93}, {{{0,8}},29}, {{{0,9}},154}, + {{{84,7}},83}, {{{0,8}},125}, {{{0,8}},61}, {{{0,9}},218}, + {{{82,7}},23}, {{{0,8}},109}, {{{0,8}},45}, {{{0,9}},186}, + {{{0,8}},13}, {{{0,8}},141}, {{{0,8}},77}, {{{0,9}},250}, + {{{80,7}},3}, {{{0,8}},83}, {{{0,8}},19}, {{{85,8}},195}, + {{{83,7}},35}, {{{0,8}},115}, {{{0,8}},51}, {{{0,9}},198}, + {{{81,7}},11}, {{{0,8}},99}, {{{0,8}},35}, {{{0,9}},166}, + {{{0,8}},3}, {{{0,8}},131}, {{{0,8}},67}, {{{0,9}},230}, + {{{80,7}},7}, {{{0,8}},91}, {{{0,8}},27}, {{{0,9}},150}, + {{{84,7}},67}, {{{0,8}},123}, {{{0,8}},59}, {{{0,9}},214}, + {{{82,7}},19}, {{{0,8}},107}, {{{0,8}},43}, {{{0,9}},182}, + {{{0,8}},11}, {{{0,8}},139}, {{{0,8}},75}, {{{0,9}},246}, + {{{80,7}},5}, {{{0,8}},87}, {{{0,8}},23}, {{{192,8}},0}, + {{{83,7}},51}, {{{0,8}},119}, {{{0,8}},55}, {{{0,9}},206}, + {{{81,7}},15}, {{{0,8}},103}, {{{0,8}},39}, {{{0,9}},174}, + {{{0,8}},7}, {{{0,8}},135}, {{{0,8}},71}, {{{0,9}},238}, + {{{80,7}},9}, {{{0,8}},95}, {{{0,8}},31}, {{{0,9}},158}, + {{{84,7}},99}, {{{0,8}},127}, {{{0,8}},63}, {{{0,9}},222}, + {{{82,7}},27}, {{{0,8}},111}, {{{0,8}},47}, {{{0,9}},190}, + {{{0,8}},15}, {{{0,8}},143}, {{{0,8}},79}, {{{0,9}},254}, + {{{96,7}},256}, {{{0,8}},80}, {{{0,8}},16}, {{{84,8}},115}, + {{{82,7}},31}, {{{0,8}},112}, {{{0,8}},48}, {{{0,9}},193}, + {{{80,7}},10}, {{{0,8}},96}, {{{0,8}},32}, {{{0,9}},161}, + {{{0,8}},0}, {{{0,8}},128}, {{{0,8}},64}, {{{0,9}},225}, + {{{80,7}},6}, {{{0,8}},88}, {{{0,8}},24}, {{{0,9}},145}, + {{{83,7}},59}, {{{0,8}},120}, {{{0,8}},56}, {{{0,9}},209}, + {{{81,7}},17}, {{{0,8}},104}, {{{0,8}},40}, {{{0,9}},177}, + {{{0,8}},8}, {{{0,8}},136}, {{{0,8}},72}, {{{0,9}},241}, + {{{80,7}},4}, {{{0,8}},84}, {{{0,8}},20}, {{{85,8}},227}, + {{{83,7}},43}, {{{0,8}},116}, {{{0,8}},52}, {{{0,9}},201}, + {{{81,7}},13}, {{{0,8}},100}, {{{0,8}},36}, {{{0,9}},169}, + {{{0,8}},4}, {{{0,8}},132}, {{{0,8}},68}, {{{0,9}},233}, + {{{80,7}},8}, {{{0,8}},92}, {{{0,8}},28}, {{{0,9}},153}, + {{{84,7}},83}, {{{0,8}},124}, {{{0,8}},60}, {{{0,9}},217}, + {{{82,7}},23}, {{{0,8}},108}, {{{0,8}},44}, {{{0,9}},185}, + {{{0,8}},12}, {{{0,8}},140}, {{{0,8}},76}, {{{0,9}},249}, + {{{80,7}},3}, {{{0,8}},82}, {{{0,8}},18}, {{{85,8}},163}, + {{{83,7}},35}, {{{0,8}},114}, {{{0,8}},50}, {{{0,9}},197}, + {{{81,7}},11}, {{{0,8}},98}, {{{0,8}},34}, {{{0,9}},165}, + {{{0,8}},2}, {{{0,8}},130}, {{{0,8}},66}, {{{0,9}},229}, + {{{80,7}},7}, {{{0,8}},90}, {{{0,8}},26}, {{{0,9}},149}, + {{{84,7}},67}, {{{0,8}},122}, {{{0,8}},58}, {{{0,9}},213}, + {{{82,7}},19}, {{{0,8}},106}, {{{0,8}},42}, {{{0,9}},181}, + {{{0,8}},10}, {{{0,8}},138}, {{{0,8}},74}, {{{0,9}},245}, + {{{80,7}},5}, {{{0,8}},86}, {{{0,8}},22}, {{{192,8}},0}, + {{{83,7}},51}, {{{0,8}},118}, {{{0,8}},54}, {{{0,9}},205}, + {{{81,7}},15}, {{{0,8}},102}, {{{0,8}},38}, {{{0,9}},173}, + {{{0,8}},6}, {{{0,8}},134}, {{{0,8}},70}, {{{0,9}},237}, + {{{80,7}},9}, {{{0,8}},94}, {{{0,8}},30}, {{{0,9}},157}, + {{{84,7}},99}, {{{0,8}},126}, {{{0,8}},62}, {{{0,9}},221}, + {{{82,7}},27}, {{{0,8}},110}, {{{0,8}},46}, {{{0,9}},189}, + {{{0,8}},14}, {{{0,8}},142}, {{{0,8}},78}, {{{0,9}},253}, + {{{96,7}},256}, {{{0,8}},81}, {{{0,8}},17}, {{{85,8}},131}, + {{{82,7}},31}, {{{0,8}},113}, {{{0,8}},49}, {{{0,9}},195}, + {{{80,7}},10}, {{{0,8}},97}, {{{0,8}},33}, {{{0,9}},163}, + {{{0,8}},1}, {{{0,8}},129}, {{{0,8}},65}, {{{0,9}},227}, + {{{80,7}},6}, {{{0,8}},89}, {{{0,8}},25}, {{{0,9}},147}, + {{{83,7}},59}, {{{0,8}},121}, {{{0,8}},57}, {{{0,9}},211}, + {{{81,7}},17}, {{{0,8}},105}, {{{0,8}},41}, {{{0,9}},179}, + {{{0,8}},9}, {{{0,8}},137}, {{{0,8}},73}, {{{0,9}},243}, + {{{80,7}},4}, {{{0,8}},85}, {{{0,8}},21}, {{{80,8}},258}, + {{{83,7}},43}, {{{0,8}},117}, {{{0,8}},53}, {{{0,9}},203}, + {{{81,7}},13}, {{{0,8}},101}, {{{0,8}},37}, {{{0,9}},171}, + {{{0,8}},5}, {{{0,8}},133}, {{{0,8}},69}, {{{0,9}},235}, + {{{80,7}},8}, {{{0,8}},93}, {{{0,8}},29}, {{{0,9}},155}, + {{{84,7}},83}, {{{0,8}},125}, {{{0,8}},61}, {{{0,9}},219}, + {{{82,7}},23}, {{{0,8}},109}, {{{0,8}},45}, {{{0,9}},187}, + {{{0,8}},13}, {{{0,8}},141}, {{{0,8}},77}, {{{0,9}},251}, + {{{80,7}},3}, {{{0,8}},83}, {{{0,8}},19}, {{{85,8}},195}, + {{{83,7}},35}, {{{0,8}},115}, {{{0,8}},51}, {{{0,9}},199}, + {{{81,7}},11}, {{{0,8}},99}, {{{0,8}},35}, {{{0,9}},167}, + {{{0,8}},3}, {{{0,8}},131}, {{{0,8}},67}, {{{0,9}},231}, + {{{80,7}},7}, {{{0,8}},91}, {{{0,8}},27}, {{{0,9}},151}, + {{{84,7}},67}, {{{0,8}},123}, {{{0,8}},59}, {{{0,9}},215}, + {{{82,7}},19}, {{{0,8}},107}, {{{0,8}},43}, {{{0,9}},183}, + {{{0,8}},11}, {{{0,8}},139}, {{{0,8}},75}, {{{0,9}},247}, + {{{80,7}},5}, {{{0,8}},87}, {{{0,8}},23}, {{{192,8}},0}, + {{{83,7}},51}, {{{0,8}},119}, {{{0,8}},55}, {{{0,9}},207}, + {{{81,7}},15}, {{{0,8}},103}, {{{0,8}},39}, {{{0,9}},175}, + {{{0,8}},7}, {{{0,8}},135}, {{{0,8}},71}, {{{0,9}},239}, + {{{80,7}},9}, {{{0,8}},95}, {{{0,8}},31}, {{{0,9}},159}, + {{{84,7}},99}, {{{0,8}},127}, {{{0,8}},63}, {{{0,9}},223}, + {{{82,7}},27}, {{{0,8}},111}, {{{0,8}},47}, {{{0,9}},191}, + {{{0,8}},15}, {{{0,8}},143}, {{{0,8}},79}, {{{0,9}},255} + }; +local const inflate_huft fixed_td[] = { + {{{80,5}},1}, {{{87,5}},257}, {{{83,5}},17}, {{{91,5}},4097}, + {{{81,5}},5}, {{{89,5}},1025}, {{{85,5}},65}, {{{93,5}},16385}, + {{{80,5}},3}, {{{88,5}},513}, {{{84,5}},33}, {{{92,5}},8193}, + {{{82,5}},9}, {{{90,5}},2049}, {{{86,5}},129}, {{{192,5}},24577}, + {{{80,5}},2}, {{{87,5}},385}, {{{83,5}},25}, {{{91,5}},6145}, + {{{81,5}},7}, {{{89,5}},1537}, {{{85,5}},97}, {{{93,5}},24577}, + {{{80,5}},4}, {{{88,5}},769}, {{{84,5}},49}, {{{92,5}},12289}, + {{{82,5}},13}, {{{90,5}},3073}, {{{86,5}},193}, {{{192,5}},24577} + }; diff --git a/thirdparty/freetype/src/gzip/inflate.c b/thirdparty/freetype/src/gzip/inflate.c new file mode 100644 index 0000000000..8877fa3eb2 --- /dev/null +++ b/thirdparty/freetype/src/gzip/inflate.c @@ -0,0 +1,273 @@ +/* inflate.c -- zlib interface to inflate modules + * Copyright (C) 1995-2002 Mark Adler + * For conditions of distribution and use, see copyright notice in zlib.h + */ + +#include "zutil.h" +#include "infblock.h" + +#define DONE INFLATE_DONE +#define BAD INFLATE_BAD + +typedef enum { + METHOD, /* waiting for method byte */ + FLAG, /* waiting for flag byte */ + DICT4, /* four dictionary check bytes to go */ + DICT3, /* three dictionary check bytes to go */ + DICT2, /* two dictionary check bytes to go */ + DICT1, /* one dictionary check byte to go */ + DICT0, /* waiting for inflateSetDictionary */ + BLOCKS, /* decompressing blocks */ + CHECK4, /* four check bytes to go */ + CHECK3, /* three check bytes to go */ + CHECK2, /* two check bytes to go */ + CHECK1, /* one check byte to go */ + DONE, /* finished check, done */ + BAD} /* got an error--stay here */ +inflate_mode; + +/* inflate private state */ +struct internal_state { + + /* mode */ + inflate_mode mode; /* current inflate mode */ + + /* mode dependent information */ + union { + uInt method; /* if FLAGS, method byte */ + struct { + uLong was; /* computed check value */ + uLong need; /* stream check value */ + } check; /* if CHECK, check values to compare */ + uInt marker; /* if BAD, inflateSync's marker bytes count */ + } sub; /* submode */ + + /* mode independent information */ + int nowrap; /* flag for no wrapper */ + uInt wbits; /* log2(window size) (8..15, defaults to 15) */ + inflate_blocks_statef + *blocks; /* current inflate_blocks state */ + +}; + + +ZEXPORT(int) inflateReset( /* z) */ +z_streamp z ) +{ + if (z == Z_NULL || z->state == Z_NULL) + return Z_STREAM_ERROR; + z->total_in = z->total_out = 0; + z->msg = Z_NULL; + z->state->mode = z->state->nowrap ? BLOCKS : METHOD; + inflate_blocks_reset(z->state->blocks, z, Z_NULL); + Tracev((stderr, "inflate: reset\n")); + return Z_OK; +} + + +ZEXPORT(int) inflateEnd( /* z) */ +z_streamp z ) +{ + if (z == Z_NULL || z->state == Z_NULL || z->zfree == Z_NULL) + return Z_STREAM_ERROR; + if (z->state->blocks != Z_NULL) + inflate_blocks_free(z->state->blocks, z); + ZFREE(z, z->state); + z->state = Z_NULL; + Tracev((stderr, "inflate: end\n")); + return Z_OK; +} + + +ZEXPORT(int) inflateInit2_( /* z, w, version, stream_size) */ +z_streamp z, +int w, +const char *version, +int stream_size ) +{ + if (version == Z_NULL || version[0] != ZLIB_VERSION[0] || + stream_size != sizeof(z_stream)) + return Z_VERSION_ERROR; + + /* initialize state */ + if (z == Z_NULL) + return Z_STREAM_ERROR; + z->msg = Z_NULL; + if (z->zalloc == Z_NULL) + { + z->zalloc = zcalloc; + z->opaque = (voidpf)0; + } + if (z->zfree == Z_NULL) z->zfree = zcfree; + if ((z->state = (struct internal_state FAR *) + ZALLOC(z,1,sizeof(struct internal_state))) == Z_NULL) + return Z_MEM_ERROR; + z->state->blocks = Z_NULL; + + /* handle undocumented nowrap option (no zlib header or check) */ + z->state->nowrap = 0; + if (w < 0) + { + w = - w; + z->state->nowrap = 1; + } + + /* set window size */ + if (w < 8 || w > 15) + { + inflateEnd(z); + return Z_STREAM_ERROR; + } + z->state->wbits = (uInt)w; + + /* create inflate_blocks state */ + if ((z->state->blocks = + inflate_blocks_new(z, z->state->nowrap ? Z_NULL : adler32, (uInt)1 << w)) + == Z_NULL) + { + inflateEnd(z); + return Z_MEM_ERROR; + } + Tracev((stderr, "inflate: allocated\n")); + + /* reset state */ + inflateReset(z); + return Z_OK; +} + + + +#undef NEEDBYTE +#define NEEDBYTE {if(z->avail_in==0)return r;r=f;} + +#undef NEXTBYTE +#define NEXTBYTE (z->avail_in--,z->total_in++,*z->next_in++) + + +ZEXPORT(int) inflate( /* z, f) */ +z_streamp z, +int f ) +{ + int r; + uInt b; + + if (z == Z_NULL || z->state == Z_NULL || z->next_in == Z_NULL) + return Z_STREAM_ERROR; + f = f == Z_FINISH ? Z_BUF_ERROR : Z_OK; + r = Z_BUF_ERROR; + while (1) switch (z->state->mode) + { + case METHOD: + NEEDBYTE + if (((z->state->sub.method = NEXTBYTE) & 0xf) != Z_DEFLATED) + { + z->state->mode = BAD; + z->msg = (char*)"unknown compression method"; + z->state->sub.marker = 5; /* can't try inflateSync */ + break; + } + if ((z->state->sub.method >> 4) + 8 > z->state->wbits) + { + z->state->mode = BAD; + z->msg = (char*)"invalid window size"; + z->state->sub.marker = 5; /* can't try inflateSync */ + break; + } + z->state->mode = FLAG; + case FLAG: + NEEDBYTE + b = NEXTBYTE; + if (((z->state->sub.method << 8) + b) % 31) + { + z->state->mode = BAD; + z->msg = (char*)"incorrect header check"; + z->state->sub.marker = 5; /* can't try inflateSync */ + break; + } + Tracev((stderr, "inflate: zlib header ok\n")); + if (!(b & PRESET_DICT)) + { + z->state->mode = BLOCKS; + break; + } + z->state->mode = DICT4; + case DICT4: + NEEDBYTE + z->state->sub.check.need = (uLong)NEXTBYTE << 24; + z->state->mode = DICT3; + case DICT3: + NEEDBYTE + z->state->sub.check.need += (uLong)NEXTBYTE << 16; + z->state->mode = DICT2; + case DICT2: + NEEDBYTE + z->state->sub.check.need += (uLong)NEXTBYTE << 8; + z->state->mode = DICT1; + case DICT1: + NEEDBYTE + z->state->sub.check.need += (uLong)NEXTBYTE; + z->adler = z->state->sub.check.need; + z->state->mode = DICT0; + return Z_NEED_DICT; + case DICT0: + z->state->mode = BAD; + z->msg = (char*)"need dictionary"; + z->state->sub.marker = 0; /* can try inflateSync */ + return Z_STREAM_ERROR; + case BLOCKS: + r = inflate_blocks(z->state->blocks, z, r); + if (r == Z_DATA_ERROR) + { + z->state->mode = BAD; + z->state->sub.marker = 0; /* can try inflateSync */ + break; + } + if (r == Z_OK) + r = f; + if (r != Z_STREAM_END) + return r; + r = f; + inflate_blocks_reset(z->state->blocks, z, &z->state->sub.check.was); + if (z->state->nowrap) + { + z->state->mode = DONE; + break; + } + z->state->mode = CHECK4; + case CHECK4: + NEEDBYTE + z->state->sub.check.need = (uLong)NEXTBYTE << 24; + z->state->mode = CHECK3; + case CHECK3: + NEEDBYTE + z->state->sub.check.need += (uLong)NEXTBYTE << 16; + z->state->mode = CHECK2; + case CHECK2: + NEEDBYTE + z->state->sub.check.need += (uLong)NEXTBYTE << 8; + z->state->mode = CHECK1; + case CHECK1: + NEEDBYTE + z->state->sub.check.need += (uLong)NEXTBYTE; + + if (z->state->sub.check.was != z->state->sub.check.need) + { + z->state->mode = BAD; + z->msg = (char*)"incorrect data check"; + z->state->sub.marker = 5; /* can't try inflateSync */ + break; + } + Tracev((stderr, "inflate: zlib check ok\n")); + z->state->mode = DONE; + case DONE: + return Z_STREAM_END; + case BAD: + return Z_DATA_ERROR; + default: + return Z_STREAM_ERROR; + } +#ifdef NEED_DUMMY_RETURN + return Z_STREAM_ERROR; /* Some dumb compilers complain without this */ +#endif +} + diff --git a/thirdparty/freetype/src/gzip/inftrees.c b/thirdparty/freetype/src/gzip/inftrees.c new file mode 100644 index 0000000000..56f52b1701 --- /dev/null +++ b/thirdparty/freetype/src/gzip/inftrees.c @@ -0,0 +1,468 @@ +/* inftrees.c -- generate Huffman trees for efficient decoding + * Copyright (C) 1995-2002 Mark Adler + * For conditions of distribution and use, see copyright notice in zlib.h + */ + +#include "zutil.h" +#include "inftrees.h" + +#if !defined(BUILDFIXED) && !defined(STDC) +# define BUILDFIXED /* non ANSI compilers may not accept inffixed.h */ +#endif + + +#if 0 +local const char inflate_copyright[] = + " inflate 1.1.4 Copyright 1995-2002 Mark Adler "; +#endif +/* + If you use the zlib library in a product, an acknowledgment is welcome + in the documentation of your product. If for some reason you cannot + include such an acknowledgment, I would appreciate that you keep this + copyright string in the executable of your product. + */ + +/* simplify the use of the inflate_huft type with some defines */ +#define exop word.what.Exop +#define bits word.what.Bits + + +local int huft_build OF(( + uIntf *, /* code lengths in bits */ + uInt, /* number of codes */ + uInt, /* number of "simple" codes */ + const uIntf *, /* list of base values for non-simple codes */ + const uIntf *, /* list of extra bits for non-simple codes */ + inflate_huft * FAR*,/* result: starting table */ + uIntf *, /* maximum lookup bits (returns actual) */ + inflate_huft *, /* space for trees */ + uInt *, /* hufts used in space */ + uIntf * )); /* space for values */ + +/* Tables for deflate from PKZIP's appnote.txt. */ +local const uInt cplens[31] = { /* Copy lengths for literal codes 257..285 */ + 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31, + 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0}; + /* see note #13 above about 258 */ +local const uInt cplext[31] = { /* Extra bits for literal codes 257..285 */ + 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, + 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0, 112, 112}; /* 112==invalid */ +local const uInt cpdist[30] = { /* Copy offsets for distance codes 0..29 */ + 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193, + 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145, + 8193, 12289, 16385, 24577}; +local const uInt cpdext[30] = { /* Extra bits for distance codes */ + 0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, + 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, + 12, 12, 13, 13}; + +/* + Huffman code decoding is performed using a multi-level table lookup. + The fastest way to decode is to simply build a lookup table whose + size is determined by the longest code. However, the time it takes + to build this table can also be a factor if the data being decoded + is not very long. The most common codes are necessarily the + shortest codes, so those codes dominate the decoding time, and hence + the speed. The idea is you can have a shorter table that decodes the + shorter, more probable codes, and then point to subsidiary tables for + the longer codes. The time it costs to decode the longer codes is + then traded against the time it takes to make longer tables. + + This results of this trade are in the variables lbits and dbits + below. lbits is the number of bits the first level table for literal/ + length codes can decode in one step, and dbits is the same thing for + the distance codes. Subsequent tables are also less than or equal to + those sizes. These values may be adjusted either when all of the + codes are shorter than that, in which case the longest code length in + bits is used, or when the shortest code is *longer* than the requested + table size, in which case the length of the shortest code in bits is + used. + + There are two different values for the two tables, since they code a + different number of possibilities each. The literal/length table + codes 286 possible values, or in a flat code, a little over eight + bits. The distance table codes 30 possible values, or a little less + than five bits, flat. The optimum values for speed end up being + about one bit more than those, so lbits is 8+1 and dbits is 5+1. + The optimum values may differ though from machine to machine, and + possibly even between compilers. Your mileage may vary. + */ + + +/* If BMAX needs to be larger than 16, then h and x[] should be uLong. */ +#define BMAX 15 /* maximum bit length of any code */ + +local int huft_build( /* b, n, s, d, e, t, m, hp, hn, v) */ +uIntf *b, /* code lengths in bits (all assumed <= BMAX) */ +uInt n, /* number of codes (assumed <= 288) */ +uInt s, /* number of simple-valued codes (0..s-1) */ +const uIntf *d, /* list of base values for non-simple codes */ +const uIntf *e, /* list of extra bits for non-simple codes */ +inflate_huft * FAR *t, /* result: starting table */ +uIntf *m, /* maximum lookup bits, returns actual */ +inflate_huft *hp, /* space for trees */ +uInt *hn, /* hufts used in space */ +uIntf *v /* working area: values in order of bit length */ +/* Given a list of code lengths and a maximum table size, make a set of + tables to decode that set of codes. Return Z_OK on success, Z_BUF_ERROR + if the given code set is incomplete (the tables are still built in this + case), or Z_DATA_ERROR if the input is invalid. */ +) +{ + + uInt a; /* counter for codes of length k */ + uInt c[BMAX+1]; /* bit length count table */ + uInt f; /* i repeats in table every f entries */ + int g; /* maximum code length */ + int h; /* table level */ + 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 */ + 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 */ + 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 */ + uInt z; /* number of entries in current table */ + + + /* Make compiler happy */ + r.base = 0; + + /* Generate counts for each bit length */ + p = c; +#define C0 *p++ = 0; +#define C2 C0 C0 C0 C0 +#define C4 C2 C2 C2 C2 + C4 /* clear c[]--assume BMAX+1 is 16 */ + p = b; i = n; + do { + c[*p++]++; /* assume all entries <= BMAX */ + } while (--i); + if (c[0] == n) /* null input--all zero length codes */ + { + *t = (inflate_huft *)Z_NULL; + *m = 0; + return Z_OK; + } + + + /* Find minimum and maximum length, bound *m by those */ + l = *m; + for (j = 1; j <= BMAX; j++) + if (c[j]) + break; + k = j; /* minimum code length */ + if ((uInt)l < j) + l = j; + for (i = BMAX; i; i--) + if (c[i]) + break; + g = i; /* maximum code length */ + if ((uInt)l > i) + l = i; + *m = l; + + + /* Adjust last length count to fill out codes, if needed */ + for (y = 1 << j; j < i; j++, y <<= 1) + if ((y -= c[j]) < 0) + return Z_DATA_ERROR; + if ((y -= c[i]) < 0) + return Z_DATA_ERROR; + c[i] += y; + + + /* Generate starting offsets into the value table for each length */ + x[1] = j = 0; + p = c + 1; xp = x + 2; + while (--i) { /* note that i == g from above */ + *xp++ = (j += *p++); + } + + + /* Make a table of values in order of bit lengths */ + p = b; i = 0; + do { + if ((j = *p++) != 0) + v[x[j]++] = i; + } while (++i < n); + n = x[g]; /* set n to length of v */ + + + /* Generate the Huffman codes and for each, make the table entries */ + x[0] = i = 0; /* first Huffman code is zero */ + p = v; /* grab values in bit order */ + h = -1; /* no tables yet--level -1 */ + w = -l; /* bits decoded == (l * h) */ + u[0] = (inflate_huft *)Z_NULL; /* just to keep compilers happy */ + q = (inflate_huft *)Z_NULL; /* ditto */ + z = 0; /* ditto */ + + /* go through the bit lengths (k already is bits in shortest code) */ + for (; k <= g; k++) + { + a = c[k]; + while (a--) + { + /* here i is the Huffman code of length k bits for value *p */ + /* make tables up to required level */ + while (k > w + l) + { + h++; + w += l; /* previous table always l bits */ + + /* compute minimum size table less than or equal to l bits */ + z = g - w; + z = z > (uInt)l ? (uInt)l : z; /* table size upper limit */ + if ((f = 1 << (j = k - w)) > a + 1) /* try a k-w bit table */ + { /* too few codes for k-w bit table */ + f -= a + 1; /* deduct codes from patterns left */ + xp = c + k; + if (j < z) + while (++j < z) /* try smaller tables up to z bits */ + { + if ((f <<= 1) <= *++xp) + break; /* enough codes to use up j bits */ + f -= *xp; /* else deduct codes from patterns */ + } + } + z = 1 << j; /* table entries for j-bit table */ + + /* allocate new table */ + if (*hn + z > MANY) /* (note: doesn't matter for fixed) */ + return Z_DATA_ERROR; /* overflow of MANY */ + u[h] = q = hp + *hn; + *hn += z; + + /* connect to last table, if there is one */ + if (h) + { + x[h] = i; /* save pattern for backing up */ + r.bits = (Byte)l; /* bits to dump before this table */ + r.exop = (Byte)j; /* bits in this table */ + j = i >> (w - l); + r.base = (uInt)(q - u[h-1] - j); /* offset to this table */ + u[h-1][j] = r; /* connect to last table */ + } + else + *t = q; /* first table is returned result */ + } + + /* set up table entry in r */ + r.bits = (Byte)(k - w); + if (p >= v + n) + r.exop = 128 + 64; /* out of values--invalid code */ + else if (*p < s) + { + r.exop = (Byte)(*p < 256 ? 0 : 32 + 64); /* 256 is end-of-block */ + r.base = *p++; /* simple code is just the value */ + } + else + { + r.exop = (Byte)(e[*p - s] + 16 + 64);/* non-simple--look up in lists */ + r.base = d[*p++ - s]; + } + + /* fill code-like entries with r */ + f = 1 << (k - w); + for (j = i >> w; j < z; j += f) + q[j] = r; + + /* backwards increment the k-bit code i */ + for (j = 1 << (k - 1); i & j; j >>= 1) + i ^= j; + i ^= j; + + /* backup over finished tables */ + mask = (1 << w) - 1; /* needed on HP, cc -O bug */ + while ((i & mask) != x[h]) + { + h--; /* don't need to update q */ + w -= l; + mask = (1 << w) - 1; + } + } + } + + + /* Return Z_BUF_ERROR if we were given an incomplete table */ + return y != 0 && g != 1 ? Z_BUF_ERROR : Z_OK; +} + + +local int inflate_trees_bits( /* c, bb, tb, hp, z) */ +uIntf *c, /* 19 code lengths */ +uIntf *bb, /* bits tree desired/actual depth */ +inflate_huft * FAR *tb, /* bits tree result */ +inflate_huft *hp, /* space for trees */ +z_streamp z /* for messages */ +) +{ + int r; + uInt hn = 0; /* hufts used in space */ + uIntf *v; /* work area for huft_build */ + + if ((v = (uIntf*)ZALLOC(z, 19, sizeof(uInt))) == Z_NULL) + return Z_MEM_ERROR; + r = huft_build(c, 19, 19, (uIntf*)Z_NULL, (uIntf*)Z_NULL, + tb, bb, hp, &hn, v); + if (r == Z_DATA_ERROR) + z->msg = (char*)"oversubscribed dynamic bit lengths tree"; + else if (r == Z_BUF_ERROR || *bb == 0) + { + z->msg = (char*)"incomplete dynamic bit lengths tree"; + r = Z_DATA_ERROR; + } + ZFREE(z, v); + return r; +} + + +local int inflate_trees_dynamic( /* nl, nd, c, bl, bd, tl, td, hp, z) */ +uInt nl, /* number of literal/length codes */ +uInt nd, /* number of distance codes */ +uIntf *c, /* that many (total) code lengths */ +uIntf *bl, /* literal desired/actual bit depth */ +uIntf *bd, /* distance desired/actual bit depth */ +inflate_huft * FAR *tl, /* literal/length tree result */ +inflate_huft * FAR *td, /* distance tree result */ +inflate_huft *hp, /* space for trees */ +z_streamp z /* for messages */ +) +{ + int r; + uInt hn = 0; /* hufts used in space */ + uIntf *v; /* work area for huft_build */ + + /* allocate work area */ + if ((v = (uIntf*)ZALLOC(z, 288, sizeof(uInt))) == Z_NULL) + return Z_MEM_ERROR; + + /* build literal/length tree */ + r = huft_build(c, nl, 257, cplens, cplext, tl, bl, hp, &hn, v); + if (r != Z_OK || *bl == 0) + { + if (r == Z_DATA_ERROR) + z->msg = (char*)"oversubscribed literal/length tree"; + else if (r != Z_MEM_ERROR) + { + z->msg = (char*)"incomplete literal/length tree"; + r = Z_DATA_ERROR; + } + ZFREE(z, v); + return r; + } + + /* build distance tree */ + r = huft_build(c + nl, nd, 0, cpdist, cpdext, td, bd, hp, &hn, v); + if (r != Z_OK || (*bd == 0 && nl > 257)) + { + if (r == Z_DATA_ERROR) + z->msg = (char*)"oversubscribed distance tree"; + else if (r == Z_BUF_ERROR) { +#if 0 + { +#endif +#ifdef PKZIP_BUG_WORKAROUND + r = Z_OK; + } +#else + z->msg = (char*)"incomplete distance tree"; + r = Z_DATA_ERROR; + } + else if (r != Z_MEM_ERROR) + { + z->msg = (char*)"empty distance tree with lengths"; + r = Z_DATA_ERROR; + } + ZFREE(z, v); + return r; +#endif + } + + /* done */ + ZFREE(z, v); + return Z_OK; +} + + +/* build fixed tables only once--keep them here */ +#ifdef BUILDFIXED +local int fixed_built = 0; +#define FIXEDH 544 /* number of hufts used by fixed tables */ +local inflate_huft fixed_mem[FIXEDH]; +local uInt fixed_bl; +local uInt fixed_bd; +local inflate_huft *fixed_tl; +local inflate_huft *fixed_td; +#else +#include "inffixed.h" +#endif + + +local int inflate_trees_fixed( /* bl, bd, tl, td, z) */ +uIntf *bl, /* literal desired/actual bit depth */ +uIntf *bd, /* distance desired/actual bit depth */ +const inflate_huft * FAR *tl, /* literal/length tree result */ +const inflate_huft * FAR *td, /* distance tree result */ +z_streamp z /* for memory allocation */ +) +{ +#ifdef BUILDFIXED + /* build fixed tables if not already */ + if (!fixed_built) + { + int k; /* temporary variable */ + uInt f = 0; /* number of hufts used in fixed_mem */ + uIntf *c; /* length list for huft_build */ + uIntf *v; /* work area for huft_build */ + + /* allocate memory */ + if ((c = (uIntf*)ZALLOC(z, 288, sizeof(uInt))) == Z_NULL) + return Z_MEM_ERROR; + if ((v = (uIntf*)ZALLOC(z, 288, sizeof(uInt))) == Z_NULL) + { + ZFREE(z, c); + return Z_MEM_ERROR; + } + + /* literal table */ + for (k = 0; k < 144; k++) + c[k] = 8; + for (; k < 256; k++) + c[k] = 9; + for (; k < 280; k++) + c[k] = 7; + for (; k < 288; k++) + c[k] = 8; + fixed_bl = 9; + huft_build(c, 288, 257, cplens, cplext, &fixed_tl, &fixed_bl, + fixed_mem, &f, v); + + /* distance table */ + for (k = 0; k < 30; k++) + c[k] = 5; + fixed_bd = 5; + huft_build(c, 30, 0, cpdist, cpdext, &fixed_td, &fixed_bd, + fixed_mem, &f, v); + + /* done */ + ZFREE(z, v); + ZFREE(z, c); + fixed_built = 1; + } +#else + FT_UNUSED(z); +#endif + *bl = fixed_bl; + *bd = fixed_bd; + *tl = fixed_tl; + *td = fixed_td; + return Z_OK; +} diff --git a/thirdparty/freetype/src/gzip/inftrees.h b/thirdparty/freetype/src/gzip/inftrees.h new file mode 100644 index 0000000000..07bf2aa0bf --- /dev/null +++ b/thirdparty/freetype/src/gzip/inftrees.h @@ -0,0 +1,63 @@ +/* inftrees.h -- header to use inftrees.c + * Copyright (C) 1995-2002 Mark Adler + * For conditions of distribution and use, see copyright notice in zlib.h + */ + +/* WARNING: this file should *not* be used by applications. It is + part of the implementation of the compression library and is + subject to change. Applications should only use zlib.h. + */ + +/* Huffman code lookup table entry--this entry is four bytes for machines + that have 16-bit pointers (e.g. PC's in the small or medium model). */ + +#ifndef _INFTREES_H +#define _INFTREES_H + +typedef struct inflate_huft_s FAR inflate_huft; + +struct inflate_huft_s { + union { + struct { + Byte Exop; /* number of extra bits or operation */ + Byte Bits; /* number of bits in this code or subcode */ + } what; + uInt pad; /* pad structure to a power of 2 (4 bytes for */ + } word; /* 16-bit, 8 bytes for 32-bit int's) */ + uInt base; /* literal, length base, distance base, + or table offset */ +}; + +/* Maximum size of dynamic tree. The maximum found in a long but non- + exhaustive search was 1004 huft structures (850 for length/literals + and 154 for distances, the latter actually the result of an + exhaustive search). The actual maximum is not known, but the + value below is more than safe. */ +#define MANY 1440 + +local int inflate_trees_bits OF(( + uIntf *, /* 19 code lengths */ + uIntf *, /* bits tree desired/actual depth */ + inflate_huft * FAR *, /* bits tree result */ + inflate_huft *, /* space for trees */ + z_streamp)); /* for messages */ + +local int inflate_trees_dynamic OF(( + uInt, /* number of literal/length codes */ + uInt, /* number of distance codes */ + uIntf *, /* that many (total) code lengths */ + uIntf *, /* literal desired/actual bit depth */ + uIntf *, /* distance desired/actual bit depth */ + inflate_huft * FAR *, /* literal/length tree result */ + inflate_huft * FAR *, /* distance tree result */ + inflate_huft *, /* space for trees */ + z_streamp)); /* for messages */ + +local int inflate_trees_fixed OF(( + uIntf *, /* literal desired/actual bit depth */ + uIntf *, /* distance desired/actual bit depth */ + const inflate_huft * FAR *, /* literal/length tree result */ + const inflate_huft * FAR *, /* distance tree result */ + z_streamp)); /* for memory allocation */ + +#endif /* _INFTREES_H */ diff --git a/thirdparty/freetype/src/gzip/infutil.c b/thirdparty/freetype/src/gzip/infutil.c new file mode 100644 index 0000000000..6087b40647 --- /dev/null +++ b/thirdparty/freetype/src/gzip/infutil.c @@ -0,0 +1,86 @@ +/* inflate_util.c -- data and routines common to blocks and codes + * Copyright (C) 1995-2002 Mark Adler + * For conditions of distribution and use, see copyright notice in zlib.h + */ + +#include "zutil.h" +#include "infblock.h" +#include "inftrees.h" +#include "infcodes.h" +#include "infutil.h" + + +/* And'ing with mask[n] masks the lower n bits */ +local const uInt inflate_mask[17] = { + 0x0000, + 0x0001, 0x0003, 0x0007, 0x000f, 0x001f, 0x003f, 0x007f, 0x00ff, + 0x01ff, 0x03ff, 0x07ff, 0x0fff, 0x1fff, 0x3fff, 0x7fff, 0xffff +}; + + +/* copy as much as possible from the sliding window to the output area */ +local int inflate_flush( /* s, z, r) */ +inflate_blocks_statef *s, +z_streamp z, +int r ) +{ + uInt n; + Bytef *p; + Bytef *q; + + /* local copies of source and destination pointers */ + p = z->next_out; + q = s->read; + + /* compute number of bytes to copy as far as end of window */ + n = (uInt)((q <= s->write ? s->write : s->end) - q); + if (n > z->avail_out) n = z->avail_out; + if (n && r == Z_BUF_ERROR) r = Z_OK; + + /* update counters */ + z->avail_out -= n; + z->total_out += n; + + /* update check information */ + if (s->checkfn != Z_NULL) + z->adler = s->check = (*s->checkfn)(s->check, q, n); + + /* copy as far as end of window */ + zmemcpy(p, q, n); + p += n; + q += n; + + /* see if more to copy at beginning of window */ + if (q == s->end) + { + /* wrap pointers */ + q = s->window; + if (s->write == s->end) + s->write = s->window; + + /* compute bytes to copy */ + n = (uInt)(s->write - q); + if (n > z->avail_out) n = z->avail_out; + if (n && r == Z_BUF_ERROR) r = Z_OK; + + /* update counters */ + z->avail_out -= n; + z->total_out += n; + + /* update check information */ + if (s->checkfn != Z_NULL) + z->adler = s->check = (*s->checkfn)(s->check, q, n); + + /* copy */ + zmemcpy(p, q, n); + p += n; + q += n; + } + + /* update pointers */ + z->next_out = p; + s->read = q; + + /* done */ + return r; +} diff --git a/thirdparty/freetype/src/gzip/infutil.h b/thirdparty/freetype/src/gzip/infutil.h new file mode 100644 index 0000000000..7174b6dd0f --- /dev/null +++ b/thirdparty/freetype/src/gzip/infutil.h @@ -0,0 +1,98 @@ +/* infutil.h -- types and macros common to blocks and codes + * Copyright (C) 1995-2002 Mark Adler + * For conditions of distribution and use, see copyright notice in zlib.h + */ + +/* WARNING: this file should *not* be used by applications. It is + part of the implementation of the compression library and is + subject to change. Applications should only use zlib.h. + */ + +#ifndef _INFUTIL_H +#define _INFUTIL_H + +typedef enum { + TYPE, /* get type bits (3, including end bit) */ + LENS, /* get lengths for stored */ + STORED, /* processing stored block */ + TABLE, /* get table lengths */ + BTREE, /* get bit lengths tree for a dynamic block */ + DTREE, /* get length, distance trees for a dynamic block */ + CODES, /* processing fixed or dynamic block */ + DRY, /* output remaining window bytes */ + DONE, /* finished last block, done */ + BAD} /* got a data error--stuck here */ +inflate_block_mode; + +/* inflate blocks semi-private state */ +struct inflate_blocks_state { + + /* mode */ + inflate_block_mode mode; /* current inflate_block mode */ + + /* mode dependent information */ + union { + uInt left; /* if STORED, bytes left to copy */ + struct { + uInt table; /* table lengths (14 bits) */ + uInt index; /* index into blens (or border) */ + uIntf *blens; /* bit lengths of codes */ + uInt bb; /* bit length tree depth */ + inflate_huft *tb; /* bit length decoding tree */ + } trees; /* if DTREE, decoding info for trees */ + struct { + inflate_codes_statef + *codes; + } decode; /* if CODES, current state */ + } sub; /* submode */ + uInt last; /* true if this block is the last block */ + + /* mode independent information */ + uInt bitk; /* bits in bit buffer */ + uLong bitb; /* bit buffer */ + inflate_huft *hufts; /* single malloc for tree space */ + Bytef *window; /* sliding window */ + Bytef *end; /* one byte after sliding window */ + Bytef *read; /* window read pointer */ + Bytef *write; /* window write pointer */ + check_func checkfn; /* check function */ + uLong check; /* check on output */ + +}; + + +/* defines for inflate input/output */ +/* update pointers and return */ +#define UPDBITS {s->bitb=b;s->bitk=k;} +#define UPDIN {z->avail_in=n;z->total_in+=p-z->next_in;z->next_in=p;} +#define UPDOUT {s->write=q;} +#define UPDATE {UPDBITS UPDIN UPDOUT} +#define LEAVE {UPDATE return inflate_flush(s,z,r);} +/* get bytes and bits */ +#define LOADIN {p=z->next_in;n=z->avail_in;b=s->bitb;k=s->bitk;} +#define NEEDBYTE {if(n)r=Z_OK;else LEAVE} +#define NEXTBYTE (n--,*p++) +#define NEEDBITS(j) {while(k<(j)){NEEDBYTE;b|=((uLong)NEXTBYTE)<<k;k+=8;}} +#define DUMPBITS(j) {b>>=(j);k-=(j);} +/* output bytes */ +#define WAVAIL (uInt)(q<s->read?s->read-q-1:s->end-q) +#define LOADOUT {q=s->write;m=(uInt)WAVAIL;} +#define WRAP {if(q==s->end&&s->read!=s->window){q=s->window;m=(uInt)WAVAIL;}} +#define FLUSH {UPDOUT r=inflate_flush(s,z,r); LOADOUT} +#define NEEDOUT {if(m==0){WRAP if(m==0){FLUSH WRAP if(m==0) LEAVE}}r=Z_OK;} +#define OUTBYTE(a) {*q++=(Byte)(a);m--;} +/* load local pointers */ +#define LOAD {LOADIN LOADOUT} + +/* masks for lower bits (size given to avoid silly warnings with Visual C++) */ +#ifndef NO_INFLATE_MASK +local uInt inflate_mask[17]; +#endif + +/* copy as much as possible from the sliding window to the output area */ +local int inflate_flush OF(( + inflate_blocks_statef *, + z_streamp , + int)); + +#endif diff --git a/thirdparty/freetype/src/gzip/rules.mk b/thirdparty/freetype/src/gzip/rules.mk new file mode 100644 index 0000000000..bc7d5fa631 --- /dev/null +++ b/thirdparty/freetype/src/gzip/rules.mk @@ -0,0 +1,83 @@ +# +# FreeType 2 GZip support configuration rules +# + + +# Copyright 2002-2017 by +# David Turner, Robert Wilhelm, and Werner Lemberg. +# +# This file is part of the FreeType project, and may only be used, modified, +# and distributed under the terms of the FreeType project license, +# LICENSE.TXT. By continuing to use, modify, or distribute this file you +# indicate that you have read the license and understand and accept it +# fully. + + +# gzip driver directory +# +GZIP_DIR := $(SRC_DIR)/gzip + + +# compilation flags for the driver +# +ifeq ($(SYSTEM_ZLIB),) + GZIP_COMPILE := $(CC) $(ANSIFLAGS) \ + $I$(subst /,$(COMPILER_SEP),$(GZIP_DIR)) \ + $(INCLUDE_FLAGS) \ + $(FT_CFLAGS) +else + GZIP_COMPILE := $(CC) $(ANSIFLAGS) \ + $(INCLUDE_FLAGS) \ + $(FT_CFLAGS) +endif + + +# gzip support sources +# +# All source and header files get loaded by `ftgzip.c' only if SYSTEM_ZLIB +# is not defined (regardless whether we have a `single' or a `multi' build). +# However, it doesn't harm if we add everything as a dependency +# unconditionally. +# +GZIP_DRV_SRCS := $(GZIP_DIR)/adler32.c \ + $(GZIP_DIR)/ftzconf.h \ + $(GZIP_DIR)/infblock.c \ + $(GZIP_DIR)/infblock.h \ + $(GZIP_DIR)/infcodes.c \ + $(GZIP_DIR)/infcodes.h \ + $(GZIP_DIR)/inffixed.h \ + $(GZIP_DIR)/inflate.c \ + $(GZIP_DIR)/inftrees.c \ + $(GZIP_DIR)/inftrees.h \ + $(GZIP_DIR)/infutil.c \ + $(GZIP_DIR)/infutil.h \ + $(GZIP_DIR)/zlib.h \ + $(GZIP_DIR)/zutil.c \ + $(GZIP_DIR)/zutil.h + + +# gzip driver object(s) +# +# GZIP_DRV_OBJ is used during both `single' and `multi' builds +# +GZIP_DRV_OBJ := $(OBJ_DIR)/ftgzip.$O + + +# gzip main source file +# +GZIP_DRV_SRC := $(GZIP_DIR)/ftgzip.c + + +# gzip support - object +# +$(GZIP_DRV_OBJ): $(GZIP_DRV_SRC) $(GZIP_DRV_SRCS) $(FREETYPE_H) + $(GZIP_COMPILE) $T$(subst /,$(COMPILER_SEP),$@ $(GZIP_DRV_SRC)) + + +# update main driver object lists +# +DRV_OBJS_S += $(GZIP_DRV_OBJ) +DRV_OBJS_M += $(GZIP_DRV_OBJ) + + +# EOF diff --git a/thirdparty/freetype/src/gzip/zlib.h b/thirdparty/freetype/src/gzip/zlib.h new file mode 100644 index 0000000000..a4e82c6a02 --- /dev/null +++ b/thirdparty/freetype/src/gzip/zlib.h @@ -0,0 +1,830 @@ +/* zlib.h -- interface of the 'zlib' general purpose compression library + version 1.1.4, March 11th, 2002 + + Copyright (C) 1995-2002 Jean-loup Gailly and Mark Adler + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. + + Jean-loup Gailly Mark Adler + jloup@gzip.org madler@alumni.caltech.edu + + + The data format used by the zlib library is described by RFCs (Request for + Comments) 1950 to 1952 in the files ftp://ds.internic.net/rfc/rfc1950.txt + (zlib format), rfc1951.txt (deflate format) and rfc1952.txt (gzip format). +*/ + +#ifndef _ZLIB_H +#define _ZLIB_H + +#include "ftzconf.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#define ZLIB_VERSION "1.1.4" + +/* + The 'zlib' compression library provides in-memory compression and + decompression functions, including integrity checks of the uncompressed + data. This version of the library supports only one compression method + (deflation) but other algorithms will be added later and will have the same + stream interface. + + Compression can be done in a single step if the buffers are large + enough (for example if an input file is mmap'ed), or can be done by + repeated calls of the compression function. In the latter case, the + application must provide more input and/or consume the output + (providing more output space) before each call. + + The library also supports reading and writing files in gzip (.gz) format + with an interface similar to that of stdio. + + The library does not install any signal handler. The decoder checks + the consistency of the compressed data, so the library should never + crash even in case of corrupted input. +*/ + +typedef voidpf (*alloc_func) OF((voidpf opaque, uInt items, uInt size)); +typedef void (*free_func) OF((voidpf opaque, voidpf address)); + +struct internal_state; + +typedef struct z_stream_s { + Bytef *next_in; /* next input byte */ + uInt avail_in; /* number of bytes available at next_in */ + uLong total_in; /* total nb of input bytes read so far */ + + Bytef *next_out; /* next output byte should be put there */ + uInt avail_out; /* remaining free space at next_out */ + uLong total_out; /* total nb of bytes output so far */ + + char *msg; /* last error message, NULL if no error */ + struct internal_state FAR *state; /* not visible by applications */ + + alloc_func zalloc; /* used to allocate the internal state */ + free_func zfree; /* used to free the internal state */ + voidpf opaque; /* private data object passed to zalloc and zfree */ + + int data_type; /* best guess about the data type: ascii or binary */ + uLong adler; /* adler32 value of the uncompressed data */ + uLong reserved; /* reserved for future use */ +} z_stream; + +typedef z_stream FAR *z_streamp; + +/* + The application must update next_in and avail_in when avail_in has + dropped to zero. It must update next_out and avail_out when avail_out + has dropped to zero. The application must initialize zalloc, zfree and + opaque before calling the init function. All other fields are set by the + compression library and must not be updated by the application. + + The opaque value provided by the application will be passed as the first + parameter for calls of zalloc and zfree. This can be useful for custom + memory management. The compression library attaches no meaning to the + opaque value. + + zalloc must return Z_NULL if there is not enough memory for the object. + If zlib is used in a multi-threaded application, zalloc and zfree must be + thread safe. + + On 16-bit systems, the functions zalloc and zfree must be able to allocate + exactly 65536 bytes, but will not be required to allocate more than this + if the symbol MAXSEG_64K is defined (see zconf.h). WARNING: On MSDOS, + pointers returned by zalloc for objects of exactly 65536 bytes *must* + have their offset normalized to zero. The default allocation function + provided by this library ensures this (see zutil.c). To reduce memory + requirements and avoid any allocation of 64K objects, at the expense of + compression ratio, compile the library with -DMAX_WBITS=14 (see zconf.h). + + The fields total_in and total_out can be used for statistics or + progress reports. After compression, total_in holds the total size of + the uncompressed data and may be saved for use in the decompressor + (particularly if the decompressor wants to decompress everything in + a single step). +*/ + + /* constants */ + +#define Z_NO_FLUSH 0 +#define Z_PARTIAL_FLUSH 1 /* will be removed, use Z_SYNC_FLUSH instead */ +#define Z_SYNC_FLUSH 2 +#define Z_FULL_FLUSH 3 +#define Z_FINISH 4 +/* Allowed flush values; see deflate() below for details */ + +#define Z_OK 0 +#define Z_STREAM_END 1 +#define Z_NEED_DICT 2 +#define Z_ERRNO (-1) +#define Z_STREAM_ERROR (-2) +#define Z_DATA_ERROR (-3) +#define Z_MEM_ERROR (-4) +#define Z_BUF_ERROR (-5) +#define Z_VERSION_ERROR (-6) +/* Return codes for the compression/decompression functions. Negative + * values are errors, positive values are used for special but normal events. + */ + +#define Z_NO_COMPRESSION 0 +#define Z_BEST_SPEED 1 +#define Z_BEST_COMPRESSION 9 +#define Z_DEFAULT_COMPRESSION (-1) +/* compression levels */ + +#define Z_FILTERED 1 +#define Z_HUFFMAN_ONLY 2 +#define Z_DEFAULT_STRATEGY 0 +/* compression strategy; see deflateInit2() below for details */ + +#define Z_BINARY 0 +#define Z_ASCII 1 +#define Z_UNKNOWN 2 +/* Possible values of the data_type field */ + +#define Z_DEFLATED 8 +/* The deflate compression method (the only one supported in this version) */ + +#define Z_NULL 0 /* for initializing zalloc, zfree, opaque */ + + + /* basic functions */ + +/* The application can compare zlibVersion and ZLIB_VERSION for consistency. + If the first character differs, the library code actually used is + not compatible with the zlib.h header file used by the application. + This check is automatically made by deflateInit and inflateInit. + */ + +/* +ZEXTERN(int) deflateInit OF((z_streamp strm, int level)); + + Initializes the internal stream state for compression. The fields + zalloc, zfree and opaque must be initialized before by the caller. + If zalloc and zfree are set to Z_NULL, deflateInit updates them to + use default allocation functions. + + The compression level must be Z_DEFAULT_COMPRESSION, or between 0 and 9: + 1 gives best speed, 9 gives best compression, 0 gives no compression at + all (the input data is simply copied a block at a time). + Z_DEFAULT_COMPRESSION requests a default compromise between speed and + compression (currently equivalent to level 6). + + deflateInit returns Z_OK if success, Z_MEM_ERROR if there was not + enough memory, Z_STREAM_ERROR if level is not a valid compression level, + Z_VERSION_ERROR if the zlib library version (zlib_version) is incompatible + with the version assumed by the caller (ZLIB_VERSION). + msg is set to null if there is no error message. deflateInit does not + perform any compression: this will be done by deflate(). +*/ + + +/* + deflate compresses as much data as possible, and stops when the input + buffer becomes empty or the output buffer becomes full. It may introduce some + output latency (reading input without producing any output) except when + forced to flush. + + The detailed semantics are as follows. deflate performs one or both of the + following actions: + + - Compress more input starting at next_in and update next_in and avail_in + accordingly. If not all input can be processed (because there is not + enough room in the output buffer), next_in and avail_in are updated and + processing will resume at this point for the next call of deflate(). + + - Provide more output starting at next_out and update next_out and avail_out + accordingly. This action is forced if the parameter flush is non zero. + Forcing flush frequently degrades the compression ratio, so this parameter + should be set only when necessary (in interactive applications). + Some output may be provided even if flush is not set. + + Before the call of deflate(), the application should ensure that at least + one of the actions is possible, by providing more input and/or consuming + more output, and updating avail_in or avail_out accordingly; avail_out + should never be zero before the call. The application can consume the + compressed output when it wants, for example when the output buffer is full + (avail_out == 0), or after each call of deflate(). If deflate returns Z_OK + and with zero avail_out, it must be called again after making room in the + output buffer because there might be more output pending. + + If the parameter flush is set to Z_SYNC_FLUSH, all pending output is + flushed to the output buffer and the output is aligned on a byte boundary, so + that the decompressor can get all input data available so far. (In particular + avail_in is zero after the call if enough output space has been provided + before the call.) Flushing may degrade compression for some compression + algorithms and so it should be used only when necessary. + + If flush is set to Z_FULL_FLUSH, all output is flushed as with + Z_SYNC_FLUSH, and the compression state is reset so that decompression can + restart from this point if previous compressed data has been damaged or if + random access is desired. Using Z_FULL_FLUSH too often can seriously degrade + the compression. + + If deflate returns with avail_out == 0, this function must be called again + with the same value of the flush parameter and more output space (updated + avail_out), until the flush is complete (deflate returns with non-zero + avail_out). + + If the parameter flush is set to Z_FINISH, pending input is processed, + pending output is flushed and deflate returns with Z_STREAM_END if there + was enough output space; if deflate returns with Z_OK, this function must be + called again with Z_FINISH and more output space (updated avail_out) but no + more input data, until it returns with Z_STREAM_END or an error. After + deflate has returned Z_STREAM_END, the only possible operations on the + stream are deflateReset or deflateEnd. + + Z_FINISH can be used immediately after deflateInit if all the compression + is to be done in a single step. In this case, avail_out must be at least + 0.1% larger than avail_in plus 12 bytes. If deflate does not return + Z_STREAM_END, then it must be called again as described above. + + deflate() sets strm->adler to the adler32 checksum of all input read + so far (that is, total_in bytes). + + deflate() may update data_type if it can make a good guess about + the input data type (Z_ASCII or Z_BINARY). In doubt, the data is considered + binary. This field is only for information purposes and does not affect + the compression algorithm in any manner. + + deflate() returns Z_OK if some progress has been made (more input + processed or more output produced), Z_STREAM_END if all input has been + consumed and all output has been produced (only when flush is set to + Z_FINISH), Z_STREAM_ERROR if the stream state was inconsistent (for example + if next_in or next_out was NULL), Z_BUF_ERROR if no progress is possible + (for example avail_in or avail_out was zero). +*/ + + +/* + All dynamically allocated data structures for this stream are freed. + This function discards any unprocessed input and does not flush any + pending output. + + deflateEnd returns Z_OK if success, Z_STREAM_ERROR if the + stream state was inconsistent, Z_DATA_ERROR if the stream was freed + prematurely (some input or output was discarded). In the error case, + msg may be set but then points to a static string (which must not be + deallocated). +*/ + + +/* +ZEXTERN(int) inflateInit OF((z_streamp strm)); + + Initializes the internal stream state for decompression. The fields + next_in, avail_in, zalloc, zfree and opaque must be initialized before by + the caller. If next_in is not Z_NULL and avail_in is large enough (the exact + value depends on the compression method), inflateInit determines the + compression method from the zlib header and allocates all data structures + accordingly; otherwise the allocation will be deferred to the first call of + inflate. If zalloc and zfree are set to Z_NULL, inflateInit updates them to + use default allocation functions. + + inflateInit returns Z_OK if success, Z_MEM_ERROR if there was not enough + memory, Z_VERSION_ERROR if the zlib library version is incompatible with the + version assumed by the caller. msg is set to null if there is no error + message. inflateInit does not perform any decompression apart from reading + the zlib header if present: this will be done by inflate(). (So next_in and + avail_in may be modified, but next_out and avail_out are unchanged.) +*/ + + +ZEXTERN(int) inflate OF((z_streamp strm, int flush)); +/* + inflate decompresses as much data as possible, and stops when the input + buffer becomes empty or the output buffer becomes full. It may some + introduce some output latency (reading input without producing any output) + except when forced to flush. + + The detailed semantics are as follows. inflate performs one or both of the + following actions: + + - Decompress more input starting at next_in and update next_in and avail_in + accordingly. If not all input can be processed (because there is not + enough room in the output buffer), next_in is updated and processing + will resume at this point for the next call of inflate(). + + - Provide more output starting at next_out and update next_out and avail_out + accordingly. inflate() provides as much output as possible, until there + is no more input data or no more space in the output buffer (see below + about the flush parameter). + + Before the call of inflate(), the application should ensure that at least + one of the actions is possible, by providing more input and/or consuming + more output, and updating the next_* and avail_* values accordingly. + The application can consume the uncompressed output when it wants, for + example when the output buffer is full (avail_out == 0), or after each + call of inflate(). If inflate returns Z_OK and with zero avail_out, it + must be called again after making room in the output buffer because there + might be more output pending. + + If the parameter flush is set to Z_SYNC_FLUSH, inflate flushes as much + output as possible to the output buffer. The flushing behavior of inflate is + not specified for values of the flush parameter other than Z_SYNC_FLUSH + and Z_FINISH, but the current implementation actually flushes as much output + as possible anyway. + + inflate() should normally be called until it returns Z_STREAM_END or an + error. However if all decompression is to be performed in a single step + (a single call of inflate), the parameter flush should be set to + Z_FINISH. In this case all pending input is processed and all pending + output is flushed; avail_out must be large enough to hold all the + uncompressed data. (The size of the uncompressed data may have been saved + by the compressor for this purpose.) The next operation on this stream must + be inflateEnd to deallocate the decompression state. The use of Z_FINISH + is never required, but can be used to inform inflate that a faster routine + may be used for the single inflate() call. + + If a preset dictionary is needed at this point (see inflateSetDictionary + below), inflate sets strm-adler to the adler32 checksum of the + dictionary chosen by the compressor and returns Z_NEED_DICT; otherwise + it sets strm->adler to the adler32 checksum of all output produced + so far (that is, total_out bytes) and returns Z_OK, Z_STREAM_END or + an error code as described below. At the end of the stream, inflate() + checks that its computed adler32 checksum is equal to that saved by the + compressor and returns Z_STREAM_END only if the checksum is correct. + + inflate() returns Z_OK if some progress has been made (more input processed + or more output produced), Z_STREAM_END if the end of the compressed data has + been reached and all uncompressed output has been produced, Z_NEED_DICT if a + preset dictionary is needed at this point, Z_DATA_ERROR if the input data was + corrupted (input stream not conforming to the zlib format or incorrect + adler32 checksum), Z_STREAM_ERROR if the stream structure was inconsistent + (for example if next_in or next_out was NULL), Z_MEM_ERROR if there was not + enough memory, Z_BUF_ERROR if no progress is possible or if there was not + enough room in the output buffer when Z_FINISH is used. In the Z_DATA_ERROR + case, the application may then call inflateSync to look for a good + compression block. +*/ + + +ZEXTERN(int) inflateEnd OF((z_streamp strm)); +/* + All dynamically allocated data structures for this stream are freed. + This function discards any unprocessed input and does not flush any + pending output. + + inflateEnd returns Z_OK if success, Z_STREAM_ERROR if the stream state + was inconsistent. In the error case, msg may be set but then points to a + static string (which must not be deallocated). +*/ + + /* Advanced functions */ + +/* + The following functions are needed only in some special applications. +*/ + +/* +ZEXTERN(int) deflateInit2 OF((z_streamp strm, + int level, + int method, + int windowBits, + int memLevel, + int strategy)); + + This is another version of deflateInit with more compression options. The + fields next_in, zalloc, zfree and opaque must be initialized before by + the caller. + + The method parameter is the compression method. It must be Z_DEFLATED in + this version of the library. + + The windowBits parameter is the base two logarithm of the window size + (the size of the history buffer). It should be in the range 8..15 for this + version of the library. Larger values of this parameter result in better + compression at the expense of memory usage. The default value is 15 if + deflateInit is used instead. + + The memLevel parameter specifies how much memory should be allocated + for the internal compression state. memLevel=1 uses minimum memory but + is slow and reduces compression ratio; memLevel=9 uses maximum memory + for optimal speed. The default value is 8. See zconf.h for total memory + usage as a function of windowBits and memLevel. + + The strategy parameter is used to tune the compression algorithm. Use the + value Z_DEFAULT_STRATEGY for normal data, Z_FILTERED for data produced by a + filter (or predictor), or Z_HUFFMAN_ONLY to force Huffman encoding only (no + string match). Filtered data consists mostly of small values with a + somewhat random distribution. In this case, the compression algorithm is + tuned to compress them better. The effect of Z_FILTERED is to force more + Huffman coding and less string matching; it is somewhat intermediate + between Z_DEFAULT and Z_HUFFMAN_ONLY. The strategy parameter only affects + the compression ratio but not the correctness of the compressed output even + if it is not set appropriately. + + deflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough + memory, Z_STREAM_ERROR if a parameter is invalid (such as an invalid + method). msg is set to null if there is no error message. deflateInit2 does + not perform any compression: this will be done by deflate(). +*/ + +/* + Initializes the compression dictionary from the given byte sequence + without producing any compressed output. This function must be called + immediately after deflateInit, deflateInit2 or deflateReset, before any + call of deflate. The compressor and decompressor must use exactly the same + dictionary (see inflateSetDictionary). + + The dictionary should consist of strings (byte sequences) that are likely + to be encountered later in the data to be compressed, with the most commonly + used strings preferably put towards the end of the dictionary. Using a + dictionary is most useful when the data to be compressed is short and can be + predicted with good accuracy; the data can then be compressed better than + with the default empty dictionary. + + Depending on the size of the compression data structures selected by + deflateInit or deflateInit2, a part of the dictionary may in effect be + discarded, for example if the dictionary is larger than the window size in + deflate or deflate2. Thus the strings most likely to be useful should be + put at the end of the dictionary, not at the front. + + Upon return of this function, strm->adler is set to the Adler32 value + of the dictionary; the decompressor may later use this value to determine + which dictionary has been used by the compressor. (The Adler32 value + applies to the whole dictionary even if only a subset of the dictionary is + actually used by the compressor.) + + deflateSetDictionary returns Z_OK if success, or Z_STREAM_ERROR if a + parameter is invalid (such as NULL dictionary) or the stream state is + inconsistent (for example if deflate has already been called for this stream + or if the compression method is bsort). deflateSetDictionary does not + perform any compression: this will be done by deflate(). +*/ + +/* + Sets the destination stream as a complete copy of the source stream. + + This function can be useful when several compression strategies will be + tried, for example when there are several ways of pre-processing the input + data with a filter. The streams that will be discarded should then be freed + by calling deflateEnd. Note that deflateCopy duplicates the internal + compression state which can be quite large, so this strategy is slow and + can consume lots of memory. + + deflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not + enough memory, Z_STREAM_ERROR if the source stream state was inconsistent + (such as zalloc being NULL). msg is left unchanged in both source and + destination. +*/ + +/* + This function is equivalent to deflateEnd followed by deflateInit, + but does not free and reallocate all the internal compression state. + The stream will keep the same compression level and any other attributes + that may have been set by deflateInit2. + + deflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source + stream state was inconsistent (such as zalloc or state being NULL). +*/ + +/* + Dynamically update the compression level and compression strategy. The + interpretation of level and strategy is as in deflateInit2. This can be + used to switch between compression and straight copy of the input data, or + to switch to a different kind of input data requiring a different + strategy. If the compression level is changed, the input available so far + is compressed with the old level (and may be flushed); the new level will + take effect only at the next call of deflate(). + + Before the call of deflateParams, the stream state must be set as for + a call of deflate(), since the currently available input may have to + be compressed and flushed. In particular, strm->avail_out must be non-zero. + + deflateParams returns Z_OK if success, Z_STREAM_ERROR if the source + stream state was inconsistent or if a parameter was invalid, Z_BUF_ERROR + if strm->avail_out was zero. +*/ + +/* +ZEXTERN(int) inflateInit2 OF((z_streamp strm, + int windowBits)); + + This is another version of inflateInit with an extra parameter. The + fields next_in, avail_in, zalloc, zfree and opaque must be initialized + before by the caller. + + The windowBits parameter is the base two logarithm of the maximum window + size (the size of the history buffer). It should be in the range 8..15 for + this version of the library. The default value is 15 if inflateInit is used + instead. If a compressed stream with a larger window size is given as + input, inflate() will return with the error code Z_DATA_ERROR instead of + trying to allocate a larger window. + + inflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough + memory, Z_STREAM_ERROR if a parameter is invalid (such as a negative + memLevel). msg is set to null if there is no error message. inflateInit2 + does not perform any decompression apart from reading the zlib header if + present: this will be done by inflate(). (So next_in and avail_in may be + modified, but next_out and avail_out are unchanged.) +*/ + +/* + Initializes the decompression dictionary from the given uncompressed byte + sequence. This function must be called immediately after a call of inflate + if this call returned Z_NEED_DICT. The dictionary chosen by the compressor + can be determined from the Adler32 value returned by this call of + inflate. The compressor and decompressor must use exactly the same + dictionary (see deflateSetDictionary). + + inflateSetDictionary returns Z_OK if success, Z_STREAM_ERROR if a + parameter is invalid (such as NULL dictionary) or the stream state is + inconsistent, Z_DATA_ERROR if the given dictionary doesn't match the + expected one (incorrect Adler32 value). inflateSetDictionary does not + perform any decompression: this will be done by subsequent calls of + inflate(). +*/ + +/* + Skips invalid compressed data until a full flush point (see above the + description of deflate with Z_FULL_FLUSH) can be found, or until all + available input is skipped. No output is provided. + + inflateSync returns Z_OK if a full flush point has been found, Z_BUF_ERROR + if no more input was provided, Z_DATA_ERROR if no flush point has been found, + or Z_STREAM_ERROR if the stream structure was inconsistent. In the success + case, the application may save the current value of total_in which + indicates where valid compressed data was found. In the error case, the + application may repeatedly call inflateSync, providing more input each time, + until success or end of the input data. +*/ + +ZEXTERN(int) inflateReset OF((z_streamp strm)); +/* + This function is equivalent to inflateEnd followed by inflateInit, + but does not free and reallocate all the internal decompression state. + The stream will keep attributes that may have been set by inflateInit2. + + inflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source + stream state was inconsistent (such as zalloc or state being NULL). +*/ + + + /* utility functions */ + +/* + The following utility functions are implemented on top of the + basic stream-oriented functions. To simplify the interface, some + default options are assumed (compression level and memory usage, + standard memory allocation functions). The source code of these + utility functions can easily be modified if you need special options. +*/ + +/* + Compresses the source buffer into the destination buffer. sourceLen is + the byte length of the source buffer. Upon entry, destLen is the total + size of the destination buffer, which must be at least 0.1% larger than + sourceLen plus 12 bytes. Upon exit, destLen is the actual size of the + compressed buffer. + This function can be used to compress a whole file at once if the + input file is mmap'ed. + compress returns Z_OK if success, Z_MEM_ERROR if there was not + enough memory, Z_BUF_ERROR if there was not enough room in the output + buffer. +*/ + +/* + Compresses the source buffer into the destination buffer. The level + parameter has the same meaning as in deflateInit. sourceLen is the byte + length of the source buffer. Upon entry, destLen is the total size of the + destination buffer, which must be at least 0.1% larger than sourceLen plus + 12 bytes. Upon exit, destLen is the actual size of the compressed buffer. + + compress2 returns Z_OK if success, Z_MEM_ERROR if there was not enough + memory, Z_BUF_ERROR if there was not enough room in the output buffer, + Z_STREAM_ERROR if the level parameter is invalid. +*/ + +/* + Decompresses the source buffer into the destination buffer. sourceLen is + the byte length of the source buffer. Upon entry, destLen is the total + size of the destination buffer, which must be large enough to hold the + entire uncompressed data. (The size of the uncompressed data must have + been saved previously by the compressor and transmitted to the decompressor + by some mechanism outside the scope of this compression library.) + Upon exit, destLen is the actual size of the compressed buffer. + This function can be used to decompress a whole file at once if the + input file is mmap'ed. + + uncompress returns Z_OK if success, Z_MEM_ERROR if there was not + enough memory, Z_BUF_ERROR if there was not enough room in the output + buffer, or Z_DATA_ERROR if the input data was corrupted. +*/ + + +/* + Opens a gzip (.gz) file for reading or writing. The mode parameter + is as in fopen ("rb" or "wb") but can also include a compression level + ("wb9") or a strategy: 'f' for filtered data as in "wb6f", 'h' for + Huffman only compression as in "wb1h". (See the description + of deflateInit2 for more information about the strategy parameter.) + + gzopen can be used to read a file which is not in gzip format; in this + case gzread will directly read from the file without decompression. + + gzopen returns NULL if the file could not be opened or if there was + insufficient memory to allocate the (de)compression state; errno + can be checked to distinguish the two cases (if errno is zero, the + zlib error is Z_MEM_ERROR). */ + +/* + gzdopen() associates a gzFile with the file descriptor fd. File + descriptors are obtained from calls like open, dup, creat, pipe or + fileno (in the file has been previously opened with fopen). + The mode parameter is as in gzopen. + The next call of gzclose on the returned gzFile will also close the + file descriptor fd, just like fclose(fdopen(fd), mode) closes the file + descriptor fd. If you want to keep fd open, use gzdopen(dup(fd), mode). + gzdopen returns NULL if there was insufficient memory to allocate + the (de)compression state. +*/ + +/* + Dynamically update the compression level or strategy. See the description + of deflateInit2 for the meaning of these parameters. + gzsetparams returns Z_OK if success, or Z_STREAM_ERROR if the file was not + opened for writing. +*/ + +/* + Reads the given number of uncompressed bytes from the compressed file. + If the input file was not in gzip format, gzread copies the given number + of bytes into the buffer. + gzread returns the number of uncompressed bytes actually read (0 for + end of file, -1 for error). */ + +/* + Writes the given number of uncompressed bytes into the compressed file. + gzwrite returns the number of uncompressed bytes actually written + (0 in case of error). +*/ + +/* + Converts, formats, and writes the args to the compressed file under + control of the format string, as in fprintf. gzprintf returns the number of + uncompressed bytes actually written (0 in case of error). +*/ + +/* + Writes the given null-terminated string to the compressed file, excluding + the terminating null character. + gzputs returns the number of characters written, or -1 in case of error. +*/ + +/* + Reads bytes from the compressed file until len-1 characters are read, or + a newline character is read and transferred to buf, or an end-of-file + condition is encountered. The string is then terminated with a null + character. + gzgets returns buf, or Z_NULL in case of error. +*/ + +/* + Writes c, converted to an unsigned char, into the compressed file. + gzputc returns the value that was written, or -1 in case of error. +*/ + +/* + Reads one byte from the compressed file. gzgetc returns this byte + or -1 in case of end of file or error. +*/ + +/* + Flushes all pending output into the compressed file. The parameter + flush is as in the deflate() function. The return value is the zlib + error number (see function gzerror below). gzflush returns Z_OK if + the flush parameter is Z_FINISH and all output could be flushed. + gzflush should be called only when strictly necessary because it can + degrade compression. +*/ + +/* + Sets the starting position for the next gzread or gzwrite on the + given compressed file. The offset represents a number of bytes in the + uncompressed data stream. The whence parameter is defined as in lseek(2); + the value SEEK_END is not supported. + If the file is opened for reading, this function is emulated but can be + extremely slow. If the file is opened for writing, only forward seeks are + supported; gzseek then compresses a sequence of zeroes up to the new + starting position. + + gzseek returns the resulting offset location as measured in bytes from + the beginning of the uncompressed stream, or -1 in case of error, in + particular if the file is opened for writing and the new starting position + would be before the current position. +*/ + +/* + Rewinds the given file. This function is supported only for reading. + + gzrewind(file) is equivalent to (int)gzseek(file, 0L, SEEK_SET) +*/ + +/* + Returns the starting position for the next gzread or gzwrite on the + given compressed file. This position represents a number of bytes in the + uncompressed data stream. + + gztell(file) is equivalent to gzseek(file, 0L, SEEK_CUR) +*/ + +/* + Returns 1 when EOF has previously been detected reading the given + input stream, otherwise zero. +*/ + +/* + Flushes all pending output if necessary, closes the compressed file + and deallocates all the (de)compression state. The return value is the zlib + error number (see function gzerror below). +*/ + +/* + Returns the error message for the last error which occurred on the + given compressed file. errnum is set to zlib error number. If an + error occurred in the file system and not in the compression library, + errnum is set to Z_ERRNO and the application may consult errno + to get the exact error code. +*/ + + /* checksum functions */ + +/* + These functions are not related to compression but are exported + anyway because they might be useful in applications using the + compression library. +*/ + +ZEXTERN(uLong) adler32 OF((uLong adler, const Bytef *buf, uInt len)); + +/* + Update a running Adler-32 checksum with the bytes buf[0..len-1] and + return the updated checksum. If buf is NULL, this function returns + the required initial value for the checksum. + An Adler-32 checksum is almost as reliable as a CRC32 but can be computed + much faster. Usage example: + + uLong adler = adler32(0L, Z_NULL, 0); + + while (read_buffer(buffer, length) != EOF) { + adler = adler32(adler, buffer, length); + } + if (adler != original_adler) error(); +*/ + +/* + Update a running crc with the bytes buf[0..len-1] and return the updated + crc. If buf is NULL, this function returns the required initial value + for the crc. Pre- and post-conditioning (one's complement) is performed + within this function so it shouldn't be done by the application. + Usage example: + + uLong crc = crc32(0L, Z_NULL, 0); + + while (read_buffer(buffer, length) != EOF) { + crc = crc32(crc, buffer, length); + } + if (crc != original_crc) error(); +*/ + + + /* various hacks, don't look :) */ + +/* deflateInit and inflateInit are macros to allow checking the zlib version + * and the compiler's view of z_stream: + */ +ZEXTERN(int) inflateInit2_ OF((z_streamp strm, int windowBits, + const char *version, int stream_size)); +#define deflateInit(strm, level) \ + deflateInit_((strm), (level), ZLIB_VERSION, sizeof(z_stream)) +#define inflateInit(strm) \ + inflateInit_((strm), ZLIB_VERSION, sizeof(z_stream)) +#define deflateInit2(strm, level, method, windowBits, memLevel, strategy) \ + deflateInit2_((strm),(level),(method),(windowBits),(memLevel),\ + (strategy), ZLIB_VERSION, sizeof(z_stream)) +#define inflateInit2(strm, windowBits) \ + inflateInit2_((strm), (windowBits), ZLIB_VERSION, sizeof(z_stream)) + + +#ifdef __cplusplus +} +#endif + +#endif /* _ZLIB_H */ diff --git a/thirdparty/freetype/src/gzip/zutil.c b/thirdparty/freetype/src/gzip/zutil.c new file mode 100644 index 0000000000..7ad0c1f81b --- /dev/null +++ b/thirdparty/freetype/src/gzip/zutil.c @@ -0,0 +1,181 @@ +/* zutil.c -- target dependent utility functions for the compression library + * Copyright (C) 1995-2002 Jean-loup Gailly. + * For conditions of distribution and use, see copyright notice in zlib.h + */ + +/* @(#) $Id$ */ + +#include "zutil.h" + +#ifndef STDC +extern void exit OF((int)); +#endif + + +#ifndef HAVE_MEMCPY + +void zmemcpy(dest, source, len) + Bytef* dest; + const Bytef* source; + uInt len; +{ + if (len == 0) return; + do { + *dest++ = *source++; /* ??? to be unrolled */ + } while (--len != 0); +} + +int zmemcmp(s1, s2, len) + const Bytef* s1; + const Bytef* s2; + uInt len; +{ + uInt j; + + for (j = 0; j < len; j++) { + if (s1[j] != s2[j]) return 2*(s1[j] > s2[j])-1; + } + return 0; +} + +void zmemzero(dest, len) + Bytef* dest; + uInt len; +{ + if (len == 0) return; + do { + *dest++ = 0; /* ??? to be unrolled */ + } while (--len != 0); +} +#endif + +#if defined( MSDOS ) && defined( __TURBOC__ ) && !defined( MY_ZCALLOC ) +#if (defined( __BORLANDC__) || !defined(SMALL_MEDIUM)) && !defined(__32BIT__) +/* Small and medium model in Turbo C are for now limited to near allocation + * with reduced MAX_WBITS and MAX_MEM_LEVEL + */ +# define MY_ZCALLOC + +/* Turbo C malloc() does not allow dynamic allocation of 64K bytes + * and farmalloc(64K) returns a pointer with an offset of 8, so we + * must fix the pointer. Warning: the pointer must be put back to its + * original form in order to free it, use zcfree(). + */ + +#define MAX_PTR 10 +/* 10*64K = 640K */ + +local int next_ptr = 0; + +typedef struct ptr_table_s { + voidpf org_ptr; + voidpf new_ptr; +} ptr_table; + +local ptr_table table[MAX_PTR]; +/* This table is used to remember the original form of pointers + * to large buffers (64K). Such pointers are normalized with a zero offset. + * Since MSDOS is not a preemptive multitasking OS, this table is not + * protected from concurrent access. This hack doesn't work anyway on + * a protected system like OS/2. Use Microsoft C instead. + */ + +voidpf zcalloc (voidpf opaque, unsigned items, unsigned size) +{ + voidpf buf = opaque; /* just to make some compilers happy */ + ulg bsize = (ulg)items*size; + + /* If we allocate less than 65520 bytes, we assume that farmalloc + * will return a usable pointer which doesn't have to be normalized. + */ + if (bsize < 65520L) { + buf = farmalloc(bsize); + if (*(ush*)&buf != 0) return buf; + } else { + buf = farmalloc(bsize + 16L); + } + if (buf == NULL || next_ptr >= MAX_PTR) return NULL; + table[next_ptr].org_ptr = buf; + + /* Normalize the pointer to seg:0 */ + *((ush*)&buf+1) += ((ush)((uch*)buf-0) + 15) >> 4; + *(ush*)&buf = 0; + table[next_ptr++].new_ptr = buf; + return buf; +} + +void zcfree (voidpf opaque, voidpf ptr) +{ + int n; + if (*(ush*)&ptr != 0) { /* object < 64K */ + farfree(ptr); + return; + } + /* Find the original pointer */ + for (n = 0; n < next_ptr; n++) { + if (ptr != table[n].new_ptr) continue; + + farfree(table[n].org_ptr); + while (++n < next_ptr) { + table[n-1] = table[n]; + } + next_ptr--; + return; + } + ptr = opaque; /* just to make some compilers happy */ + Assert(0, "zcfree: ptr not found"); +} +#endif +#endif /* MSDOS && __TURBOC__ */ + + +#if defined(M_I86) && !defined(__32BIT__) && !defined( MY_ZCALLOC ) +/* Microsoft C in 16-bit mode */ + +# define MY_ZCALLOC + +#if (!defined(_MSC_VER) || (_MSC_VER <= 600)) +# define _halloc halloc +# define _hfree hfree +#endif + +voidpf zcalloc (voidpf opaque, unsigned items, unsigned size) +{ + if (opaque) opaque = 0; /* to make compiler happy */ + return _halloc((long)items, size); +} + +void zcfree (voidpf opaque, voidpf ptr) +{ + if (opaque) opaque = 0; /* to make compiler happy */ + _hfree(ptr); +} + +#endif /* MSC */ + + +#ifndef MY_ZCALLOC /* Any system without a special alloc function */ + +#ifndef STDC +extern voidp ft_scalloc OF((uInt items, uInt size)); +extern void ft_sfree OF((voidpf ptr)); +#endif + +voidpf zcalloc (opaque, items, size) + voidpf opaque; + unsigned items; + unsigned size; +{ + if (opaque) items += size - size; /* make compiler happy */ + return (voidpf)ft_scalloc(items, size); +} + +void zcfree (opaque, ptr) + voidpf opaque; + voidpf ptr; +{ + ft_sfree(ptr); + if (opaque) return; /* make compiler happy */ +} + +#endif /* MY_ZCALLOC */ diff --git a/thirdparty/freetype/src/gzip/zutil.h b/thirdparty/freetype/src/gzip/zutil.h new file mode 100644 index 0000000000..c9688cd9c0 --- /dev/null +++ b/thirdparty/freetype/src/gzip/zutil.h @@ -0,0 +1,215 @@ +/* zutil.h -- internal interface and configuration of the compression library + * Copyright (C) 1995-2002 Jean-loup Gailly. + * For conditions of distribution and use, see copyright notice in zlib.h + */ + +/* WARNING: this file should *not* be used by applications. It is + part of the implementation of the compression library and is + subject to change. Applications should only use zlib.h. + */ + +/* @(#) $Id$ */ + +#ifndef _Z_UTIL_H +#define _Z_UTIL_H + +#include "zlib.h" + +#ifdef STDC +# include <stddef.h> +# include <string.h> +# include <stdlib.h> +#endif +#ifdef NO_ERRNO_H + extern int errno; +#else +# include <errno.h> +#endif + +#ifndef local +# define local static +#endif +/* compile with -Dlocal if your debugger can't find static symbols */ + +typedef unsigned char uch; +typedef uch FAR uchf; +typedef unsigned short ush; +typedef ush FAR ushf; +typedef unsigned long ulg; + + +#define ERR_RETURN(strm,err) \ + return (strm->msg = (char*)ERR_MSG(err), (err)) +/* To be used only when the state is known to be valid */ + + /* common constants */ + +#ifndef DEF_WBITS +# define DEF_WBITS MAX_WBITS +#endif +/* default windowBits for decompression. MAX_WBITS is for compression only */ + +#if MAX_MEM_LEVEL >= 8 +# define DEF_MEM_LEVEL 8 +#else +# define DEF_MEM_LEVEL MAX_MEM_LEVEL +#endif +/* default memLevel */ + +#define STORED_BLOCK 0 +#define STATIC_TREES 1 +#define DYN_TREES 2 +/* The three kinds of block type */ + +#define MIN_MATCH 3 +#define MAX_MATCH 258 +/* The minimum and maximum match lengths */ + +#define PRESET_DICT 0x20 /* preset dictionary flag in zlib header */ + + /* target dependencies */ + +#ifdef MSDOS +# define OS_CODE 0x00 +# if defined(__TURBOC__) || defined(__BORLANDC__) +# if(__STDC__ == 1) && (defined(__LARGE__) || defined(__COMPACT__)) + /* Allow compilation with ANSI keywords only enabled */ + void _Cdecl farfree( void *block ); + void *_Cdecl farmalloc( unsigned long nbytes ); +# else +# include <alloc.h> +# endif +# else /* MSC or DJGPP */ +# endif +#endif + +#ifdef OS2 +# define OS_CODE 0x06 +#endif + +#ifdef WIN32 /* Window 95 & Windows NT */ +# define OS_CODE 0x0b +#endif + +#if defined(VAXC) || defined(VMS) +# define OS_CODE 0x02 +# define F_OPEN(name, mode) \ + ft_fopen((name), (mode), "mbc=60", "ctx=stm", "rfm=fix", "mrs=512") +#endif + +#ifdef AMIGA +# define OS_CODE 0x01 +#endif + +#if defined(ATARI) || defined(atarist) +# define OS_CODE 0x05 +#endif + +#if defined(MACOS) || defined(TARGET_OS_MAC) +# define OS_CODE 0x07 +# if defined(__MWERKS__) && __dest_os != __be_os && __dest_os != __win32_os +# include <unix.h> /* for fdopen */ +# else +# ifndef fdopen +# define fdopen(fd,mode) NULL /* No fdopen() */ +# endif +# endif +#endif + +#ifdef __50SERIES /* Prime/PRIMOS */ +# define OS_CODE 0x0F +#endif + +#ifdef TOPS20 +# define OS_CODE 0x0a +#endif + +#if defined(_BEOS_) || defined(RISCOS) +# define fdopen(fd,mode) NULL /* No fdopen() */ +#endif + +#if (defined(_MSC_VER) && (_MSC_VER > 600)) +# define fdopen(fd,type) _fdopen(fd,type) +#endif + + + /* Common defaults */ + +#ifndef OS_CODE +# define OS_CODE 0x03 /* assume Unix */ +#endif + +#ifndef F_OPEN +# define F_OPEN(name, mode) ft_fopen((name), (mode)) +#endif + + /* functions */ + +#ifdef HAVE_STRERROR + extern char *strerror OF((int)); +# define zstrerror(errnum) strerror(errnum) +#else +# define zstrerror(errnum) "" +#endif + +#if defined(pyr) +# define NO_MEMCPY +#endif +#if defined(SMALL_MEDIUM) && !defined(_MSC_VER) && !defined(__SC__) + /* Use our own functions for small and medium model with MSC <= 5.0. + * You may have to use the same strategy for Borland C (untested). + * The __SC__ check is for Symantec. + */ +# define NO_MEMCPY +#endif +#if defined(STDC) && !defined(HAVE_MEMCPY) && !defined(NO_MEMCPY) +# define HAVE_MEMCPY +#endif +#ifdef HAVE_MEMCPY +# ifdef SMALL_MEDIUM /* MSDOS small or medium model */ +# define zmemcpy _fmemcpy +# define zmemcmp _fmemcmp +# define zmemzero(dest, len) _fmemset(dest, 0, len) +# else +# define zmemcpy ft_memcpy +# define zmemcmp ft_memcmp +# define zmemzero(dest, len) ft_memset(dest, 0, len) +# endif +#else + extern void zmemcpy OF((Bytef* dest, const Bytef* source, uInt len)); + extern int zmemcmp OF((const Bytef* s1, const Bytef* s2, uInt len)); + extern void zmemzero OF((Bytef* dest, uInt len)); +#endif + +/* Diagnostic functions */ +#ifdef DEBUG +# include <stdio.h> + extern int z_verbose; + extern void z_error OF((char *m)); +# define Assert(cond,msg) {if(!(cond)) z_error(msg);} +# define Trace(x) {if (z_verbose>=0) fprintf x ;} +# define Tracev(x) {if (z_verbose>0) fprintf x ;} +# define Tracevv(x) {if (z_verbose>1) fprintf x ;} +# define Tracec(c,x) {if (z_verbose>0 && (c)) fprintf x ;} +# define Tracecv(c,x) {if (z_verbose>1 && (c)) fprintf x ;} +#else +# define Assert(cond,msg) +# define Trace(x) +# define Tracev(x) +# define Tracevv(x) +# define Tracec(c,x) +# define Tracecv(c,x) +#endif + + +typedef uLong (*check_func) OF((uLong check, const Bytef *buf, + uInt len)); +local voidpf zcalloc OF((voidpf opaque, unsigned items, unsigned size)); +local void zcfree OF((voidpf opaque, voidpf ptr)); + +#define ZALLOC(strm, items, size) \ + (*((strm)->zalloc))((strm)->opaque, (items), (size)) +#define ZFREE(strm, addr) (*((strm)->zfree))((strm)->opaque, (voidpf)(addr)) +#define TRY_FREE(s, p) {if (p) ZFREE(s, p);} + +#endif /* _Z_UTIL_H */ diff --git a/thirdparty/freetype/src/lzw/ftlzw.c b/thirdparty/freetype/src/lzw/ftlzw.c new file mode 100644 index 0000000000..941f6cef4c --- /dev/null +++ b/thirdparty/freetype/src/lzw/ftlzw.c @@ -0,0 +1,420 @@ +/***************************************************************************/ +/* */ +/* ftlzw.c */ +/* */ +/* FreeType support for .Z compressed files. */ +/* */ +/* This optional component relies on NetBSD's zopen(). It should mainly */ +/* be used to parse compressed PCF fonts, as found with many X11 server */ +/* distributions. */ +/* */ +/* Copyright 2004-2017 by */ +/* Albert Chin-A-Young. */ +/* */ +/* based on code in `src/gzip/ftgzip.c' */ +/* */ +/* This file is part of the FreeType project, and may only be used, */ +/* modified, and distributed under the terms of the FreeType project */ +/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ +/* this file you indicate that you have read the license and */ +/* understand and accept it fully. */ +/* */ +/***************************************************************************/ + +#include <ft2build.h> +#include FT_INTERNAL_MEMORY_H +#include FT_INTERNAL_STREAM_H +#include FT_INTERNAL_DEBUG_H +#include FT_LZW_H +#include FT_CONFIG_STANDARD_LIBRARY_H + + +#include FT_MODULE_ERRORS_H + +#undef FTERRORS_H_ + +#undef FT_ERR_PREFIX +#define FT_ERR_PREFIX LZW_Err_ +#define FT_ERR_BASE FT_Mod_Err_LZW + +#include FT_ERRORS_H + + +#ifdef FT_CONFIG_OPTION_USE_LZW + +#ifdef FT_CONFIG_OPTION_PIC +#error "lzw code does not support PIC yet" +#endif + +#include "ftzopen.h" + + +/***************************************************************************/ +/***************************************************************************/ +/***** *****/ +/***** M E M O R Y M A N A G E M E N T *****/ +/***** *****/ +/***************************************************************************/ +/***************************************************************************/ + +/***************************************************************************/ +/***************************************************************************/ +/***** *****/ +/***** F I L E D E S C R I P T O R *****/ +/***** *****/ +/***************************************************************************/ +/***************************************************************************/ + +#define FT_LZW_BUFFER_SIZE 4096 + + typedef struct FT_LZWFileRec_ + { + FT_Stream source; /* parent/source stream */ + FT_Stream stream; /* embedding stream */ + FT_Memory memory; /* memory allocator */ + FT_LzwStateRec lzw; /* lzw decompressor state */ + + FT_Byte buffer[FT_LZW_BUFFER_SIZE]; /* output buffer */ + FT_ULong pos; /* position in output */ + FT_Byte* cursor; + FT_Byte* limit; + + } FT_LZWFileRec, *FT_LZWFile; + + + /* check and skip .Z header */ + static FT_Error + ft_lzw_check_header( FT_Stream stream ) + { + FT_Error error; + FT_Byte head[2]; + + + if ( FT_STREAM_SEEK( 0 ) || + FT_STREAM_READ( head, 2 ) ) + goto Exit; + + /* head[0] && head[1] are the magic numbers */ + if ( head[0] != 0x1F || + head[1] != 0x9D ) + error = FT_THROW( Invalid_File_Format ); + + Exit: + return error; + } + + + static FT_Error + ft_lzw_file_init( FT_LZWFile zip, + FT_Stream stream, + FT_Stream source ) + { + FT_LzwState lzw = &zip->lzw; + FT_Error error; + + + zip->stream = stream; + zip->source = source; + zip->memory = stream->memory; + + zip->limit = zip->buffer + FT_LZW_BUFFER_SIZE; + zip->cursor = zip->limit; + zip->pos = 0; + + /* check and skip .Z header */ + error = ft_lzw_check_header( source ); + if ( error ) + goto Exit; + + /* initialize internal lzw variable */ + ft_lzwstate_init( lzw, source ); + + Exit: + return error; + } + + + static void + ft_lzw_file_done( FT_LZWFile zip ) + { + /* clear the rest */ + ft_lzwstate_done( &zip->lzw ); + + zip->memory = NULL; + zip->source = NULL; + zip->stream = NULL; + } + + + static FT_Error + ft_lzw_file_reset( FT_LZWFile zip ) + { + FT_Stream stream = zip->source; + FT_Error error; + + + if ( !FT_STREAM_SEEK( 0 ) ) + { + ft_lzwstate_reset( &zip->lzw ); + + zip->limit = zip->buffer + FT_LZW_BUFFER_SIZE; + zip->cursor = zip->limit; + zip->pos = 0; + } + + return error; + } + + + static FT_Error + ft_lzw_file_fill_output( FT_LZWFile zip ) + { + FT_LzwState lzw = &zip->lzw; + FT_ULong count; + FT_Error error = FT_Err_Ok; + + + zip->cursor = zip->buffer; + + count = ft_lzwstate_io( lzw, zip->buffer, FT_LZW_BUFFER_SIZE ); + + zip->limit = zip->cursor + count; + + if ( count == 0 ) + error = FT_THROW( Invalid_Stream_Operation ); + + return error; + } + + + /* fill output buffer; `count' must be <= FT_LZW_BUFFER_SIZE */ + static FT_Error + ft_lzw_file_skip_output( FT_LZWFile zip, + FT_ULong count ) + { + FT_Error error = FT_Err_Ok; + + + /* first, we skip what we can from the output buffer */ + { + FT_ULong delta = (FT_ULong)( zip->limit - zip->cursor ); + + + if ( delta >= count ) + delta = count; + + zip->cursor += delta; + zip->pos += delta; + + count -= delta; + } + + /* next, we skip as many bytes remaining as possible */ + while ( count > 0 ) + { + FT_ULong delta = FT_LZW_BUFFER_SIZE; + FT_ULong numread; + + + if ( delta > count ) + delta = count; + + numread = ft_lzwstate_io( &zip->lzw, NULL, delta ); + if ( numread < delta ) + { + /* not enough bytes */ + error = FT_THROW( Invalid_Stream_Operation ); + break; + } + + zip->pos += delta; + count -= delta; + } + + return error; + } + + + static FT_ULong + ft_lzw_file_io( FT_LZWFile zip, + FT_ULong pos, + FT_Byte* buffer, + FT_ULong count ) + { + FT_ULong result = 0; + FT_Error error; + + + /* seeking backwards. */ + if ( pos < zip->pos ) + { + /* If the new position is within the output buffer, simply */ + /* decrement pointers, otherwise we reset the stream completely! */ + if ( ( zip->pos - pos ) <= (FT_ULong)( zip->cursor - zip->buffer ) ) + { + zip->cursor -= zip->pos - pos; + zip->pos = pos; + } + else + { + error = ft_lzw_file_reset( zip ); + if ( error ) + goto Exit; + } + } + + /* skip unwanted bytes */ + if ( pos > zip->pos ) + { + error = ft_lzw_file_skip_output( zip, (FT_ULong)( pos - zip->pos ) ); + if ( error ) + goto Exit; + } + + if ( count == 0 ) + goto Exit; + + /* now read the data */ + for (;;) + { + FT_ULong delta; + + + delta = (FT_ULong)( zip->limit - zip->cursor ); + if ( delta >= count ) + delta = count; + + FT_MEM_COPY( buffer + result, zip->cursor, delta ); + result += delta; + zip->cursor += delta; + zip->pos += delta; + + count -= delta; + if ( count == 0 ) + break; + + error = ft_lzw_file_fill_output( zip ); + if ( error ) + break; + } + + Exit: + return result; + } + + +/***************************************************************************/ +/***************************************************************************/ +/***** *****/ +/***** L Z W E M B E D D I N G S T R E A M *****/ +/***** *****/ +/***************************************************************************/ +/***************************************************************************/ + + static void + ft_lzw_stream_close( FT_Stream stream ) + { + FT_LZWFile zip = (FT_LZWFile)stream->descriptor.pointer; + FT_Memory memory = stream->memory; + + + if ( zip ) + { + /* finalize lzw file descriptor */ + ft_lzw_file_done( zip ); + + FT_FREE( zip ); + + stream->descriptor.pointer = NULL; + } + } + + + static unsigned long + ft_lzw_stream_io( FT_Stream stream, + unsigned long offset, + unsigned char* buffer, + unsigned long count ) + { + FT_LZWFile zip = (FT_LZWFile)stream->descriptor.pointer; + + + return ft_lzw_file_io( zip, offset, buffer, count ); + } + + + FT_EXPORT_DEF( FT_Error ) + FT_Stream_OpenLZW( FT_Stream stream, + FT_Stream source ) + { + FT_Error error; + 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. + * + * Did I mention that you should never use .Z compressed font + * files? + */ + error = ft_lzw_check_header( source ); + if ( error ) + goto Exit; + + FT_ZERO( stream ); + stream->memory = memory; + + if ( !FT_NEW( zip ) ) + { + error = ft_lzw_file_init( zip, stream, source ); + if ( error ) + { + FT_FREE( zip ); + goto Exit; + } + + stream->descriptor.pointer = zip; + } + + stream->size = 0x7FFFFFFFL; /* don't know the real size! */ + stream->pos = 0; + stream->base = 0; + stream->read = ft_lzw_stream_io; + stream->close = ft_lzw_stream_close; + + Exit: + return error; + } + + +#include "ftzopen.c" + + +#else /* !FT_CONFIG_OPTION_USE_LZW */ + + + FT_EXPORT_DEF( FT_Error ) + FT_Stream_OpenLZW( FT_Stream stream, + FT_Stream source ) + { + FT_UNUSED( stream ); + FT_UNUSED( source ); + + return FT_THROW( Unimplemented_Feature ); + } + + +#endif /* !FT_CONFIG_OPTION_USE_LZW */ + + +/* END */ diff --git a/thirdparty/freetype/src/lzw/ftzopen.c b/thirdparty/freetype/src/lzw/ftzopen.c new file mode 100644 index 0000000000..486c546c14 --- /dev/null +++ b/thirdparty/freetype/src/lzw/ftzopen.c @@ -0,0 +1,424 @@ +/***************************************************************************/ +/* */ +/* ftzopen.c */ +/* */ +/* FreeType support for .Z compressed files. */ +/* */ +/* This optional component relies on NetBSD's zopen(). It should mainly */ +/* be used to parse compressed PCF fonts, as found with many X11 server */ +/* distributions. */ +/* */ +/* Copyright 2005-2017 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. */ +/* */ +/***************************************************************************/ + +#include "ftzopen.h" +#include FT_INTERNAL_MEMORY_H +#include FT_INTERNAL_STREAM_H +#include FT_INTERNAL_DEBUG_H + + + static int + ft_lzwstate_refill( FT_LzwState state ) + { + FT_ULong count; + + + if ( state->in_eof ) + return -1; + + count = FT_Stream_TryRead( state->source, + state->buf_tab, + state->num_bits ); /* WHY? */ + + state->buf_size = (FT_UInt)count; + state->buf_total += count; + state->in_eof = FT_BOOL( count < state->num_bits ); + state->buf_offset = 0; + + state->buf_size <<= 3; + if ( state->buf_size > state->num_bits ) + state->buf_size -= state->num_bits - 1; + else + return -1; /* not enough data */ + + if ( count == 0 ) /* end of file */ + return -1; + + return 0; + } + + + static FT_Int32 + ft_lzwstate_get_code( FT_LzwState state ) + { + FT_UInt num_bits = state->num_bits; + FT_UInt offset = state->buf_offset; + FT_Byte* p; + FT_Int result; + + + if ( state->buf_clear || + offset >= state->buf_size || + state->free_ent >= state->free_bits ) + { + if ( state->free_ent >= state->free_bits ) + { + state->num_bits = ++num_bits; + if ( num_bits > LZW_MAX_BITS ) + return -1; + + state->free_bits = state->num_bits < state->max_bits + ? (FT_UInt)( ( 1UL << num_bits ) - 256 ) + : state->max_free + 1; + } + + if ( state->buf_clear ) + { + state->num_bits = num_bits = LZW_INIT_BITS; + state->free_bits = (FT_UInt)( ( 1UL << num_bits ) - 256 ); + state->buf_clear = 0; + } + + if ( ft_lzwstate_refill( state ) < 0 ) + return -1; + + offset = 0; + } + + state->buf_offset = offset + num_bits; + + p = &state->buf_tab[offset >> 3]; + offset &= 7; + result = *p++ >> offset; + offset = 8 - offset; + num_bits -= offset; + + if ( num_bits >= 8 ) + { + result |= *p++ << offset; + offset += 8; + num_bits -= 8; + } + if ( num_bits > 0 ) + result |= ( *p & LZW_MASK( num_bits ) ) << offset; + + return result; + } + + + /* grow the character stack */ + static int + ft_lzwstate_stack_grow( FT_LzwState state ) + { + if ( state->stack_top >= state->stack_size ) + { + FT_Memory memory = state->memory; + FT_Error error; + FT_Offset old_size = state->stack_size; + FT_Offset new_size = old_size; + + new_size = new_size + ( new_size >> 1 ) + 4; + + if ( state->stack == state->stack_0 ) + { + state->stack = NULL; + old_size = 0; + } + + /* requirement of the character stack larger than 1<<LZW_MAX_BITS */ + /* implies bug in the decompression code */ + if ( new_size > ( 1 << LZW_MAX_BITS ) ) + { + new_size = 1 << LZW_MAX_BITS; + if ( new_size == old_size ) + return -1; + } + + if ( FT_RENEW_ARRAY( state->stack, old_size, new_size ) ) + return -1; + + state->stack_size = new_size; + } + return 0; + } + + + /* grow the prefix/suffix arrays */ + static int + ft_lzwstate_prefix_grow( FT_LzwState state ) + { + FT_UInt old_size = state->prefix_size; + FT_UInt new_size = old_size; + FT_Memory memory = state->memory; + FT_Error error; + + + if ( new_size == 0 ) /* first allocation -> 9 bits */ + new_size = 512; + else + new_size += new_size >> 2; /* don't grow too fast */ + + /* + * Note that the `suffix' array is located in the same memory block + * pointed to by `prefix'. + * + * I know that sizeof(FT_Byte) == 1 by definition, but it is clearer + * to write it literally. + * + */ + if ( FT_REALLOC_MULT( state->prefix, old_size, new_size, + sizeof ( FT_UShort ) + sizeof ( FT_Byte ) ) ) + return -1; + + /* now adjust `suffix' and move the data accordingly */ + state->suffix = (FT_Byte*)( state->prefix + new_size ); + + FT_MEM_MOVE( state->suffix, + state->prefix + old_size, + old_size * sizeof ( FT_Byte ) ); + + state->prefix_size = new_size; + return 0; + } + + + FT_LOCAL_DEF( void ) + ft_lzwstate_reset( FT_LzwState state ) + { + state->in_eof = 0; + state->buf_offset = 0; + state->buf_size = 0; + state->buf_clear = 0; + state->buf_total = 0; + state->stack_top = 0; + state->num_bits = LZW_INIT_BITS; + state->phase = FT_LZW_PHASE_START; + } + + + FT_LOCAL_DEF( void ) + ft_lzwstate_init( FT_LzwState state, + FT_Stream source ) + { + FT_ZERO( state ); + + state->source = source; + state->memory = source->memory; + + state->prefix = NULL; + state->suffix = NULL; + state->prefix_size = 0; + + state->stack = state->stack_0; + state->stack_size = sizeof ( state->stack_0 ); + + ft_lzwstate_reset( state ); + } + + + FT_LOCAL_DEF( void ) + ft_lzwstate_done( FT_LzwState state ) + { + FT_Memory memory = state->memory; + + + ft_lzwstate_reset( state ); + + if ( state->stack != state->stack_0 ) + FT_FREE( state->stack ); + + FT_FREE( state->prefix ); + state->suffix = NULL; + + FT_ZERO( state ); + } + + +#define FTLZW_STACK_PUSH( c ) \ + FT_BEGIN_STMNT \ + if ( state->stack_top >= state->stack_size && \ + ft_lzwstate_stack_grow( state ) < 0 ) \ + goto Eof; \ + \ + state->stack[state->stack_top++] = (FT_Byte)(c); \ + FT_END_STMNT + + + FT_LOCAL_DEF( FT_ULong ) + ft_lzwstate_io( FT_LzwState state, + FT_Byte* buffer, + FT_ULong out_size ) + { + FT_ULong result = 0; + + FT_UInt old_char = state->old_char; + FT_UInt old_code = state->old_code; + FT_UInt in_code = state->in_code; + + + if ( out_size == 0 ) + goto Exit; + + switch ( state->phase ) + { + case FT_LZW_PHASE_START: + { + FT_Byte max_bits; + FT_Int32 c; + + + /* skip magic bytes, and read max_bits + block_flag */ + if ( FT_Stream_Seek( state->source, 2 ) != 0 || + FT_Stream_TryRead( state->source, &max_bits, 1 ) != 1 ) + goto Eof; + + state->max_bits = max_bits & LZW_BIT_MASK; + state->block_mode = max_bits & LZW_BLOCK_MASK; + state->max_free = (FT_UInt)( ( 1UL << state->max_bits ) - 256 ); + + if ( state->max_bits > LZW_MAX_BITS ) + goto Eof; + + state->num_bits = LZW_INIT_BITS; + state->free_ent = ( state->block_mode ? LZW_FIRST + : LZW_CLEAR ) - 256; + in_code = 0; + + state->free_bits = state->num_bits < state->max_bits + ? (FT_UInt)( ( 1UL << state->num_bits ) - 256 ) + : state->max_free + 1; + + c = ft_lzwstate_get_code( state ); + if ( c < 0 || c > 255 ) + goto Eof; + + old_code = old_char = (FT_UInt)c; + + if ( buffer ) + buffer[result] = (FT_Byte)old_char; + + if ( ++result >= out_size ) + goto Exit; + + state->phase = FT_LZW_PHASE_CODE; + } + /* fall-through */ + + case FT_LZW_PHASE_CODE: + { + FT_Int32 c; + FT_UInt code; + + + NextCode: + c = ft_lzwstate_get_code( state ); + if ( c < 0 ) + goto Eof; + + code = (FT_UInt)c; + + if ( code == LZW_CLEAR && state->block_mode ) + { + /* why not LZW_FIRST-256 ? */ + state->free_ent = ( LZW_FIRST - 1 ) - 256; + state->buf_clear = 1; + + /* not quite right, but at least more predictable */ + old_code = 0; + old_char = 0; + + goto NextCode; + } + + in_code = code; /* save code for later */ + + if ( code >= 256U ) + { + /* special case for KwKwKwK */ + if ( code - 256U >= state->free_ent ) + { + /* corrupted LZW stream */ + if ( code - 256U > state->free_ent ) + goto Eof; + + FTLZW_STACK_PUSH( old_char ); + code = old_code; + } + + while ( code >= 256U ) + { + if ( !state->prefix ) + goto Eof; + + FTLZW_STACK_PUSH( state->suffix[code - 256] ); + code = state->prefix[code - 256]; + } + } + + old_char = code; + FTLZW_STACK_PUSH( old_char ); + + state->phase = FT_LZW_PHASE_STACK; + } + /* fall-through */ + + case FT_LZW_PHASE_STACK: + { + while ( state->stack_top > 0 ) + { + state->stack_top--; + + if ( buffer ) + buffer[result] = state->stack[state->stack_top]; + + if ( ++result == out_size ) + goto Exit; + } + + /* now create new entry */ + if ( state->free_ent < state->max_free ) + { + if ( state->free_ent >= state->prefix_size && + ft_lzwstate_prefix_grow( state ) < 0 ) + goto Eof; + + FT_ASSERT( state->free_ent < state->prefix_size ); + + state->prefix[state->free_ent] = (FT_UShort)old_code; + state->suffix[state->free_ent] = (FT_Byte) old_char; + + state->free_ent += 1; + } + + old_code = in_code; + + state->phase = FT_LZW_PHASE_CODE; + goto NextCode; + } + + default: /* state == EOF */ + ; + } + + Exit: + state->old_code = old_code; + state->old_char = old_char; + state->in_code = in_code; + + return result; + + Eof: + state->phase = FT_LZW_PHASE_EOF; + goto Exit; + } + + +/* END */ diff --git a/thirdparty/freetype/src/lzw/ftzopen.h b/thirdparty/freetype/src/lzw/ftzopen.h new file mode 100644 index 0000000000..a108862c0a --- /dev/null +++ b/thirdparty/freetype/src/lzw/ftzopen.h @@ -0,0 +1,172 @@ +/***************************************************************************/ +/* */ +/* ftzopen.h */ +/* */ +/* FreeType support for .Z compressed files. */ +/* */ +/* This optional component relies on NetBSD's zopen(). It should mainly */ +/* be used to parse compressed PCF fonts, as found with many X11 server */ +/* distributions. */ +/* */ +/* Copyright 2005-2017 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. */ +/* */ +/***************************************************************************/ + +#ifndef FTZOPEN_H_ +#define FTZOPEN_H_ + +#include <ft2build.h> +#include FT_FREETYPE_H + + + /* + * This is a complete re-implementation of the LZW file reader, + * since the old one was incredibly badly written, using + * 400 KByte of heap memory before decompressing anything. + * + */ + +#define FT_LZW_IN_BUFF_SIZE 64 +#define FT_LZW_DEFAULT_STACK_SIZE 64 + +#define LZW_INIT_BITS 9 +#define LZW_MAX_BITS 16 + +#define LZW_CLEAR 256 +#define LZW_FIRST 257 + +#define LZW_BIT_MASK 0x1F +#define LZW_BLOCK_MASK 0x80 +#define LZW_MASK( n ) ( ( 1U << (n) ) - 1U ) + + + typedef enum FT_LzwPhase_ + { + FT_LZW_PHASE_START = 0, + FT_LZW_PHASE_CODE, + FT_LZW_PHASE_STACK, + FT_LZW_PHASE_EOF + + } FT_LzwPhase; + + + /* + * state of LZW decompressor + * + * small technical note + * -------------------- + * + * We use a few tricks in this implementation that are explained here to + * ease debugging and maintenance. + * + * - First of all, the `prefix' and `suffix' arrays contain the suffix + * and prefix for codes over 256; this means that + * + * prefix_of(code) == state->prefix[code-256] + * suffix_of(code) == state->suffix[code-256] + * + * Each prefix is a 16-bit code, and each suffix an 8-bit byte. + * + * Both arrays are stored in a single memory block, pointed to by + * `state->prefix'. This means that the following equality is always + * true: + * + * state->suffix == (FT_Byte*)(state->prefix + state->prefix_size) + * + * Of course, state->prefix_size is the number of prefix/suffix slots + * in the arrays, corresponding to codes 256..255+prefix_size. + * + * - `free_ent' is the index of the next free entry in the `prefix' + * and `suffix' arrays. This means that the corresponding `next free + * code' is really `256+free_ent'. + * + * Moreover, `max_free' is the maximum value that `free_ent' can reach. + * + * `max_free' corresponds to `(1 << max_bits) - 256'. Note that this + * value is always <= 0xFF00, which means that both `free_ent' and + * `max_free' can be stored in an FT_UInt variable, even on 16-bit + * machines. + * + * If `free_ent == max_free', you cannot add new codes to the + * prefix/suffix table. + * + * - `num_bits' is the current number of code bits, starting at 9 and + * growing each time `free_ent' reaches the value of `free_bits'. The + * latter is computed as follows + * + * if num_bits < max_bits: + * free_bits = (1 << num_bits)-256 + * else: + * free_bits = max_free + 1 + * + * Since the value of `max_free + 1' can never be reached by + * `free_ent', `num_bits' cannot grow larger than `max_bits'. + */ + + typedef struct FT_LzwStateRec_ + { + FT_LzwPhase phase; + FT_Int in_eof; + + FT_Byte buf_tab[16]; + FT_UInt buf_offset; + FT_UInt buf_size; + FT_Bool buf_clear; + FT_Offset buf_total; + + FT_UInt max_bits; /* max code bits, from file header */ + FT_Int block_mode; /* block mode flag, from file header */ + FT_UInt max_free; /* (1 << max_bits) - 256 */ + + FT_UInt num_bits; /* current code bit number */ + FT_UInt free_ent; /* index of next free entry */ + FT_UInt free_bits; /* if reached by free_ent, increment num_bits */ + FT_UInt old_code; + FT_UInt old_char; + FT_UInt in_code; + + FT_UShort* prefix; /* always dynamically allocated / reallocated */ + FT_Byte* suffix; /* suffix = (FT_Byte*)(prefix + prefix_size) */ + FT_UInt prefix_size; /* number of slots in `prefix' or `suffix' */ + + FT_Byte* stack; /* character stack */ + FT_UInt stack_top; + FT_Offset stack_size; + FT_Byte stack_0[FT_LZW_DEFAULT_STACK_SIZE]; /* minimize heap alloc */ + + FT_Stream source; /* source stream */ + FT_Memory memory; + + } FT_LzwStateRec, *FT_LzwState; + + + FT_LOCAL( void ) + ft_lzwstate_init( FT_LzwState state, + FT_Stream source ); + + FT_LOCAL( void ) + ft_lzwstate_done( FT_LzwState state ); + + + FT_LOCAL( void ) + ft_lzwstate_reset( FT_LzwState state ); + + + FT_LOCAL( FT_ULong ) + ft_lzwstate_io( FT_LzwState state, + FT_Byte* buffer, + FT_ULong out_size ); + +/* */ + +#endif /* FTZOPEN_H_ */ + + +/* END */ diff --git a/thirdparty/freetype/src/lzw/rules.mk b/thirdparty/freetype/src/lzw/rules.mk new file mode 100644 index 0000000000..e7bf68a065 --- /dev/null +++ b/thirdparty/freetype/src/lzw/rules.mk @@ -0,0 +1,72 @@ +# +# FreeType 2 LZW support configuration rules +# + + +# Copyright 2004-2017 by +# Albert Chin-A-Young. +# +# based on `src/lzw/rules.mk' +# +# 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. + + +# LZW driver directory +# +LZW_DIR := $(SRC_DIR)/lzw + + +# compilation flags for the driver +# +LZW_COMPILE := $(CC) $(ANSIFLAGS) \ + $I$(subst /,$(COMPILER_SEP),$(LZW_DIR)) \ + $(INCLUDE_FLAGS) \ + $(FT_CFLAGS) + + +# LZW support sources (i.e., C files) +# +LZW_DRV_SRC := $(LZW_DIR)/ftlzw.c + +# LZW support headers +# +LZW_DRV_H := $(LZW_DIR)/ftzopen.h \ + $(LZW_DIR)/ftzopen.c + + +# LZW driver object(s) +# +# LZW_DRV_OBJ_M is used during `multi' builds +# LZW_DRV_OBJ_S is used during `single' builds +# +LZW_DRV_OBJ_M := $(OBJ_DIR)/ftlzw.$O +LZW_DRV_OBJ_S := $(OBJ_DIR)/ftlzw.$O + +# LZW support source file for single build +# +LZW_DRV_SRC_S := $(LZW_DIR)/ftlzw.c + + +# LZW support - single object +# +$(LZW_DRV_OBJ_S): $(LZW_DRV_SRC_S) $(LZW_DRV_SRC) $(FREETYPE_H) $(LZW_DRV_H) + $(LZW_COMPILE) $T$(subst /,$(COMPILER_SEP),$@ $(LZW_DRV_SRC_S)) + + +# LZW support - multiple objects +# +$(OBJ_DIR)/%.$O: $(LZW_DIR)/%.c $(FREETYPE_H) $(LZW_DRV_H) + $(LZW_COMPILE) $T$(subst /,$(COMPILER_SEP),$@ $<) + + +# update main driver object lists +# +DRV_OBJS_S += $(LZW_DRV_OBJ_S) +DRV_OBJS_M += $(LZW_DRV_OBJ_M) + + +# EOF diff --git a/thirdparty/freetype/src/otvalid/module.mk b/thirdparty/freetype/src/otvalid/module.mk index b929cdbab0..5ee1265db8 100644 --- a/thirdparty/freetype/src/otvalid/module.mk +++ b/thirdparty/freetype/src/otvalid/module.mk @@ -3,7 +3,7 @@ # -# Copyright 2004-2016 by +# Copyright 2004-2017 by # David Turner, Robert Wilhelm, and Werner Lemberg. # # This file is part of the FreeType project, and may only be used, modified, diff --git a/thirdparty/freetype/src/otvalid/otvalid.c b/thirdparty/freetype/src/otvalid/otvalid.c index 932a974a31..312751a1f4 100644 --- a/thirdparty/freetype/src/otvalid/otvalid.c +++ b/thirdparty/freetype/src/otvalid/otvalid.c @@ -4,7 +4,7 @@ /* */ /* FreeType validator for OpenType tables (body only). */ /* */ -/* Copyright 2004-2016 by */ +/* Copyright 2004-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -15,8 +15,8 @@ /* */ /***************************************************************************/ -#define FT_MAKE_OPTION_SINGLE_OBJECT +#define FT_MAKE_OPTION_SINGLE_OBJECT #include <ft2build.h> #include "otvbase.c" @@ -28,4 +28,5 @@ #include "otvmath.c" #include "otvmod.c" + /* END */ diff --git a/thirdparty/freetype/src/otvalid/otvalid.h b/thirdparty/freetype/src/otvalid/otvalid.h index 93438a0639..f2969ccccc 100644 --- a/thirdparty/freetype/src/otvalid/otvalid.h +++ b/thirdparty/freetype/src/otvalid/otvalid.h @@ -4,7 +4,7 @@ /* */ /* OpenType table validation (specification only). */ /* */ -/* Copyright 2004-2016 by */ +/* Copyright 2004-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/thirdparty/freetype/src/otvalid/otvbase.c b/thirdparty/freetype/src/otvalid/otvbase.c index e86e8bb2f0..3adad8439c 100644 --- a/thirdparty/freetype/src/otvalid/otvbase.c +++ b/thirdparty/freetype/src/otvalid/otvbase.c @@ -4,7 +4,7 @@ /* */ /* OpenType BASE table validation (body). */ /* */ -/* Copyright 2004-2016 by */ +/* Copyright 2004-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/thirdparty/freetype/src/otvalid/otvcommn.c b/thirdparty/freetype/src/otvalid/otvcommn.c index 2e88e102be..3407d2ad4a 100644 --- a/thirdparty/freetype/src/otvalid/otvcommn.c +++ b/thirdparty/freetype/src/otvalid/otvcommn.c @@ -4,7 +4,7 @@ /* */ /* OpenType common tables validation (body). */ /* */ -/* Copyright 2004-2016 by */ +/* Copyright 2004-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -68,7 +68,7 @@ OTV_LIMIT_CHECK( GlyphCount * 2 ); /* GlyphArray */ - for ( i = 0; i < GlyphCount; ++i ) + for ( i = 0; i < GlyphCount; i++ ) { FT_UInt gid; diff --git a/thirdparty/freetype/src/otvalid/otvcommn.h b/thirdparty/freetype/src/otvalid/otvcommn.h index 44e0c63793..10a603ebb9 100644 --- a/thirdparty/freetype/src/otvalid/otvcommn.h +++ b/thirdparty/freetype/src/otvalid/otvcommn.h @@ -4,7 +4,7 @@ /* */ /* OpenType common tables validation (specification). */ /* */ -/* Copyright 2004-2016 by */ +/* Copyright 2004-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/thirdparty/freetype/src/otvalid/otverror.h b/thirdparty/freetype/src/otvalid/otverror.h index e7c8db0d58..699903987c 100644 --- a/thirdparty/freetype/src/otvalid/otverror.h +++ b/thirdparty/freetype/src/otvalid/otverror.h @@ -4,7 +4,7 @@ /* */ /* OpenType validation module error codes (specification only). */ /* */ -/* Copyright 2004-2016 by */ +/* Copyright 2004-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/thirdparty/freetype/src/otvalid/otvgdef.c b/thirdparty/freetype/src/otvalid/otvgdef.c index f19e300e51..27b9a69ca8 100644 --- a/thirdparty/freetype/src/otvalid/otvgdef.c +++ b/thirdparty/freetype/src/otvalid/otvgdef.c @@ -4,7 +4,7 @@ /* */ /* OpenType GDEF table validation (body). */ /* */ -/* Copyright 2004-2016 by */ +/* Copyright 2004-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/thirdparty/freetype/src/otvalid/otvgpos.c b/thirdparty/freetype/src/otvalid/otvgpos.c index e904ea5d6c..0fbcc2077c 100644 --- a/thirdparty/freetype/src/otvalid/otvgpos.c +++ b/thirdparty/freetype/src/otvalid/otvgpos.c @@ -4,7 +4,7 @@ /* */ /* OpenType GPOS table validation (body). */ /* */ -/* Copyright 2002-2016 by */ +/* Copyright 2002-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/thirdparty/freetype/src/otvalid/otvgpos.h b/thirdparty/freetype/src/otvalid/otvgpos.h index 2c09e64f97..99b0ad3915 100644 --- a/thirdparty/freetype/src/otvalid/otvgpos.h +++ b/thirdparty/freetype/src/otvalid/otvgpos.h @@ -4,7 +4,7 @@ /* */ /* OpenType GPOS table validator (specification). */ /* */ -/* Copyright 2004-2016 by */ +/* Copyright 2004-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/thirdparty/freetype/src/otvalid/otvgsub.c b/thirdparty/freetype/src/otvalid/otvgsub.c index c2b28569f1..f9bd8dc5d8 100644 --- a/thirdparty/freetype/src/otvalid/otvgsub.c +++ b/thirdparty/freetype/src/otvalid/otvgsub.c @@ -4,7 +4,7 @@ /* */ /* OpenType GSUB table validation (body). */ /* */ -/* Copyright 2004-2016 by */ +/* Copyright 2004-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/thirdparty/freetype/src/otvalid/otvjstf.c b/thirdparty/freetype/src/otvalid/otvjstf.c index e19c1c1213..57a38f95c9 100644 --- a/thirdparty/freetype/src/otvalid/otvjstf.c +++ b/thirdparty/freetype/src/otvalid/otvjstf.c @@ -4,7 +4,7 @@ /* */ /* OpenType JSTF table validation (body). */ /* */ -/* Copyright 2004-2016 by */ +/* Copyright 2004-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/thirdparty/freetype/src/otvalid/otvmath.c b/thirdparty/freetype/src/otvalid/otvmath.c index 6c785b6fda..a14d369700 100644 --- a/thirdparty/freetype/src/otvalid/otvmath.c +++ b/thirdparty/freetype/src/otvalid/otvmath.c @@ -4,7 +4,7 @@ /* */ /* OpenType MATH table validation (body). */ /* */ -/* Copyright 2007-2016 by */ +/* Copyright 2007-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* Written by George Williams. */ @@ -60,7 +60,7 @@ table_size = 2 * ( 56 + 51 ); p += 4 * 2; /* First 4 constants have no device tables */ - for ( i = 0; i < 51; ++i ) + for ( i = 0; i < 51; i++ ) { p += 2; /* skip the value */ OTV_OPTIONAL_OFFSET( DeviceTableOffset ); @@ -110,7 +110,7 @@ OTV_SIZE_CHECK( Coverage ); otv_Coverage_validate( table + Coverage, otvalid, (FT_Int)cnt ); - for ( i = 0; i < cnt; ++i ) + for ( i = 0; i < cnt; i++ ) { p += 2; /* Skip the value */ OTV_OPTIONAL_OFFSET( DeviceTableOffset ); @@ -151,7 +151,7 @@ table_size = 4 + 4 * cnt; /* Heights */ - for ( i = 0; i < cnt; ++i ) + for ( i = 0; i < cnt; i++ ) { p += 2; /* Skip the value */ OTV_OPTIONAL_OFFSET( DeviceTableOffset ); @@ -161,7 +161,7 @@ } /* One more Kerning value */ - for ( i = 0; i < cnt + 1; ++i ) + for ( i = 0; i < cnt + 1; i++ ) { p += 2; /* Skip the value */ OTV_OPTIONAL_OFFSET( DeviceTableOffset ); @@ -198,9 +198,9 @@ OTV_SIZE_CHECK( Coverage ); otv_Coverage_validate( table + Coverage, otvalid, (FT_Int)cnt ); - for ( i = 0; i < cnt; ++i ) + for ( i = 0; i < cnt; i++ ) { - for ( j = 0; j < 4; ++j ) + for ( j = 0; j < 4; j++ ) { OTV_OPTIONAL_OFFSET( MKRecordOffset ); OTV_SIZE_CHECK( MKRecordOffset ); @@ -296,7 +296,7 @@ if ( DeviceTableOffset ) otv_Device_validate( table + DeviceTableOffset, otvalid ); - for ( i = 0; i < pcnt; ++i ) + for ( i = 0; i < pcnt; i++ ) { FT_UInt gid; @@ -332,7 +332,7 @@ OTV_LIMIT_CHECK( 4 * vcnt ); table_size = 4 + 4 * vcnt; - for ( i = 0; i < vcnt; ++i ) + for ( i = 0; i < vcnt; i++ ) { FT_UInt gid; @@ -384,14 +384,14 @@ if ( HCoverage ) otv_Coverage_validate( table + HCoverage, otvalid, (FT_Int)hcnt ); - for ( i = 0; i < vcnt; ++i ) + for ( i = 0; i < vcnt; i++ ) { OTV_OPTIONAL_OFFSET( Offset ); OTV_SIZE_CHECK( Offset ); otv_MathGlyphConstruction_validate( table + Offset, otvalid ); } - for ( i = 0; i < hcnt; ++i ) + for ( i = 0; i < hcnt; i++ ) { OTV_OPTIONAL_OFFSET( Offset ); OTV_SIZE_CHECK( Offset ); diff --git a/thirdparty/freetype/src/otvalid/otvmod.c b/thirdparty/freetype/src/otvalid/otvmod.c index 972bd1baac..35ffc43d3a 100644 --- a/thirdparty/freetype/src/otvalid/otvmod.c +++ b/thirdparty/freetype/src/otvalid/otvmod.c @@ -4,7 +4,7 @@ /* */ /* FreeType's OpenType validation module implementation (body). */ /* */ -/* Copyright 2004-2016 by */ +/* Copyright 2004-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -271,11 +271,11 @@ 0x10000L, 0x20000L, - 0, /* module-specific interface */ + NULL, /* module-specific interface */ - (FT_Module_Constructor)0, - (FT_Module_Destructor) 0, - (FT_Module_Requester) otvalid_get_service + (FT_Module_Constructor)NULL, /* module_init */ + (FT_Module_Destructor) NULL, /* module_done */ + (FT_Module_Requester) otvalid_get_service /* get_interface */ }; diff --git a/thirdparty/freetype/src/otvalid/otvmod.h b/thirdparty/freetype/src/otvalid/otvmod.h index e464030ab0..30d401ddca 100644 --- a/thirdparty/freetype/src/otvalid/otvmod.h +++ b/thirdparty/freetype/src/otvalid/otvmod.h @@ -5,7 +5,7 @@ /* FreeType's OpenType validation module implementation */ /* (specification). */ /* */ -/* Copyright 2004-2016 by */ +/* Copyright 2004-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/thirdparty/freetype/src/otvalid/rules.mk b/thirdparty/freetype/src/otvalid/rules.mk index 077447fcb6..10329a96ea 100644 --- a/thirdparty/freetype/src/otvalid/rules.mk +++ b/thirdparty/freetype/src/otvalid/rules.mk @@ -3,7 +3,7 @@ # -# Copyright 2004-2016 by +# Copyright 2004-2017 by # David Turner, Robert Wilhelm, and Werner Lemberg. # # This file is part of the FreeType project, and may only be used, modified, diff --git a/thirdparty/freetype/src/pcf/pcf.c b/thirdparty/freetype/src/pcf/pcf.c index 11d5b7b2a0..8ffd6e280b 100644 --- a/thirdparty/freetype/src/pcf/pcf.c +++ b/thirdparty/freetype/src/pcf/pcf.c @@ -26,11 +26,11 @@ THE SOFTWARE. #define FT_MAKE_OPTION_SINGLE_OBJECT - - #include <ft2build.h> -#include "pcfutil.c" -#include "pcfread.c" + #include "pcfdrivr.c" +#include "pcfread.c" +#include "pcfutil.c" + /* END */ diff --git a/thirdparty/freetype/src/pcf/pcf.h b/thirdparty/freetype/src/pcf/pcf.h index c726e5ec6b..f0390cb1eb 100644 --- a/thirdparty/freetype/src/pcf/pcf.h +++ b/thirdparty/freetype/src/pcf/pcf.h @@ -163,6 +163,15 @@ FT_BEGIN_HEADER } PCF_FaceRec, *PCF_Face; + typedef struct PCF_DriverRec_ + { + FT_DriverRec root; + + FT_Bool no_long_family_names; + + } PCF_DriverRec, *PCF_Driver; + + /* macros for pcf font format */ #define LSBFirst 0 diff --git a/thirdparty/freetype/src/pcf/pcfdrivr.c b/thirdparty/freetype/src/pcf/pcfdrivr.c index 0996d10793..9f4d36d111 100644 --- a/thirdparty/freetype/src/pcf/pcfdrivr.c +++ b/thirdparty/freetype/src/pcf/pcfdrivr.c @@ -49,6 +49,8 @@ THE SOFTWARE. #include FT_SERVICE_BDF_H #include FT_SERVICE_FONT_FORMAT_H +#include FT_SERVICE_PROPERTIES_H +#include FT_PCF_DRIVER_H /*************************************************************************/ @@ -286,6 +288,7 @@ THE SOFTWARE. /* this didn't work, try gzip support! */ + FT_TRACE2(( " ... try gzip stream\n" )); error2 = FT_Stream_OpenGzip( &face->comp_stream, stream ); if ( FT_ERR_EQ( error2, Unimplemented_Feature ) ) goto Fail; @@ -301,6 +304,7 @@ THE SOFTWARE. /* this didn't work, try LZW support! */ + FT_TRACE2(( " ... try LZW stream\n" )); error3 = FT_Stream_OpenLZW( &face->comp_stream, stream ); if ( FT_ERR_EQ( error3, Unimplemented_Feature ) ) goto Fail; @@ -316,6 +320,7 @@ THE SOFTWARE. /* this didn't work, try Bzip2 support! */ + FT_TRACE2(( " ... try Bzip2 stream\n" )); error4 = FT_Stream_OpenBzip2( &face->comp_stream, stream ); if ( FT_ERR_EQ( error4, Unimplemented_Feature ) ) goto Fail; @@ -492,8 +497,6 @@ THE SOFTWARE. PCF_Metric metric; FT_ULong bytes; - FT_UNUSED( load_flags ); - FT_TRACE1(( "PCF_Glyph_Load: glyph index %d\n", glyph_index )); @@ -523,11 +526,6 @@ THE SOFTWARE. bitmap->num_grays = 1; bitmap->pixel_mode = FT_PIXEL_MODE_MONO; - FT_TRACE6(( "BIT_ORDER %d ; BYTE_ORDER %d ; GLYPH_PAD %d\n", - PCF_BIT_ORDER( face->bitmapsFormat ), - PCF_BYTE_ORDER( face->bitmapsFormat ), - PCF_GLYPH_PAD( face->bitmapsFormat ) )); - switch ( PCF_GLYPH_PAD( face->bitmapsFormat ) ) { case 1: @@ -550,6 +548,24 @@ THE SOFTWARE. return FT_THROW( Invalid_File_Format ); } + slot->format = FT_GLYPH_FORMAT_BITMAP; + slot->bitmap_left = metric->leftSideBearing; + slot->bitmap_top = metric->ascent; + + slot->metrics.horiAdvance = (FT_Pos)( metric->characterWidth * 64 ); + slot->metrics.horiBearingX = (FT_Pos)( metric->leftSideBearing * 64 ); + slot->metrics.horiBearingY = (FT_Pos)( metric->ascent * 64 ); + slot->metrics.width = (FT_Pos)( ( metric->rightSideBearing - + metric->leftSideBearing ) * 64 ); + slot->metrics.height = (FT_Pos)( bitmap->rows * 64 ); + + ft_synthesize_vertical_metrics( &slot->metrics, + ( face->accel.fontAscent + + face->accel.fontDescent ) * 64 ); + + if ( load_flags & FT_LOAD_BITMAP_METRICS_ONLY ) + goto Exit; + /* XXX: to do: are there cases that need repadding the bitmap? */ bytes = (FT_ULong)bitmap->pitch * bitmap->rows; @@ -582,21 +598,6 @@ THE SOFTWARE. } } - slot->format = FT_GLYPH_FORMAT_BITMAP; - slot->bitmap_left = metric->leftSideBearing; - slot->bitmap_top = metric->ascent; - - slot->metrics.horiAdvance = (FT_Pos)( metric->characterWidth * 64 ); - slot->metrics.horiBearingX = (FT_Pos)( metric->leftSideBearing * 64 ); - slot->metrics.horiBearingY = (FT_Pos)( metric->ascent * 64 ); - slot->metrics.width = (FT_Pos)( ( metric->rightSideBearing - - metric->leftSideBearing ) * 64 ); - slot->metrics.height = (FT_Pos)( bitmap->rows * 64 ); - - ft_synthesize_vertical_metrics( &slot->metrics, - ( face->accel.fontAscent + - face->accel.fontDescent ) * 64 ); - Exit: return error; } @@ -617,7 +618,7 @@ THE SOFTWARE. prop = pcf_find_property( face, prop_name ); - if ( prop != NULL ) + if ( prop ) { if ( prop->isString ) { @@ -626,19 +627,23 @@ THE SOFTWARE. } else { - if ( prop->value.l > 0x7FFFFFFFL || prop->value.l < ( -1 - 0x7FFFFFFFL ) ) + if ( prop->value.l > 0x7FFFFFFFL || + prop->value.l < ( -1 - 0x7FFFFFFFL ) ) { - FT_TRACE1(( "pcf_get_bdf_property: " )); - FT_TRACE1(( "too large integer 0x%x is truncated\n" )); + FT_TRACE1(( "pcf_get_bdf_property:" )); + FT_TRACE1(( " too large integer 0x%x is truncated\n" )); } - /* Apparently, the PCF driver loads all properties as signed integers! - * This really doesn't seem to be a problem, because this is - * sufficient for any meaningful values. + + /* + * The PCF driver loads all properties as signed integers. + * This really doesn't seem to be a problem, because this is + * sufficient for any meaningful values. */ aproperty->type = BDF_PROPERTY_TYPE_INTEGER; aproperty->u.integer = (FT_Int32)prop->value.l; } - return 0; + + return FT_Err_Ok; } return FT_THROW( Invalid_Argument ); @@ -653,7 +658,7 @@ THE SOFTWARE. *acharset_encoding = face->charset_encoding; *acharset_registry = face->charset_registry; - return 0; + return FT_Err_Ok; } @@ -664,6 +669,116 @@ THE SOFTWARE. }; + /* + * PROPERTY SERVICE + * + */ + static FT_Error + pcf_property_set( FT_Module module, /* PCF_Driver */ + const char* property_name, + const void* value, + FT_Bool value_is_string ) + { +#ifdef PCF_CONFIG_OPTION_LONG_FAMILY_NAMES + + FT_Error error = FT_Err_Ok; + PCF_Driver driver = (PCF_Driver)module; + +#ifndef FT_CONFIG_OPTION_ENVIRONMENT_PROPERTIES + FT_UNUSED( value_is_string ); +#endif + + + if ( !ft_strcmp( property_name, "no-long-family-names" ) ) + { +#ifdef FT_CONFIG_OPTION_ENVIRONMENT_PROPERTIES + if ( value_is_string ) + { + const char* s = (const char*)value; + long lfn = ft_strtol( s, NULL, 10 ); + + + if ( lfn == 0 ) + driver->no_long_family_names = 0; + else if ( lfn == 1 ) + driver->no_long_family_names = 1; + else + return FT_THROW( Invalid_Argument ); + } + else +#endif + { + FT_Bool* no_long_family_names = (FT_Bool*)value; + + + driver->no_long_family_names = *no_long_family_names; + } + + return error; + } + +#else /* !PCF_CONFIG_OPTION_LONG_FAMILY_NAMES */ + + FT_UNUSED( module ); + FT_UNUSED( value ); + FT_UNUSED( value_is_string ); +#ifndef FT_DEBUG_LEVEL_TRACE + FT_UNUSED( property_name ); +#endif + +#endif /* !PCF_CONFIG_OPTION_LONG_FAMILY_NAMES */ + + FT_TRACE0(( "pcf_property_set: missing property `%s'\n", + property_name )); + return FT_THROW( Missing_Property ); + } + + + static FT_Error + pcf_property_get( FT_Module module, /* PCF_Driver */ + const char* property_name, + const void* value ) + { +#ifdef PCF_CONFIG_OPTION_LONG_FAMILY_NAMES + + FT_Error error = FT_Err_Ok; + PCF_Driver driver = (PCF_Driver)module; + + + if ( !ft_strcmp( property_name, "no-long-family-names" ) ) + { + FT_Bool no_long_family_names = driver->no_long_family_names; + FT_Bool* val = (FT_Bool*)value; + + + *val = no_long_family_names; + + return error; + } + +#else /* !PCF_CONFIG_OPTION_LONG_FAMILY_NAMES */ + + FT_UNUSED( module ); + FT_UNUSED( value ); +#ifndef FT_DEBUG_LEVEL_TRACE + FT_UNUSED( property_name ); +#endif + +#endif /* !PCF_CONFIG_OPTION_LONG_FAMILY_NAMES */ + + FT_TRACE0(( "pcf_property_get: missing property `%s'\n", + property_name )); + return FT_THROW( Missing_Property ); + } + + + FT_DEFINE_SERVICE_PROPERTIESREC( + pcf_service_properties, + + (FT_Properties_SetFunc)pcf_property_set, /* set_property */ + (FT_Properties_GetFunc)pcf_property_get ) /* get_property */ + + /* * * SERVICE LIST @@ -674,6 +789,7 @@ THE SOFTWARE. { { FT_SERVICE_ID_BDF, &pcf_service_bdf }, { FT_SERVICE_ID_FONT_FORMAT, FT_FONT_FORMAT_PCF }, + { FT_SERVICE_ID_PROPERTIES, &pcf_service_properties }, { NULL, NULL } }; @@ -688,22 +804,45 @@ THE SOFTWARE. } + FT_CALLBACK_DEF( FT_Error ) + pcf_driver_init( FT_Module module ) /* PCF_Driver */ + { +#ifdef PCF_CONFIG_OPTION_LONG_FAMILY_NAMES + PCF_Driver driver = (PCF_Driver)module; + + + driver->no_long_family_names = 0; +#else + FT_UNUSED( module ); +#endif + + return FT_Err_Ok; + } + + + FT_CALLBACK_DEF( void ) + pcf_driver_done( FT_Module module ) /* PCF_Driver */ + { + FT_UNUSED( module ); + } + + FT_CALLBACK_TABLE_DEF const FT_Driver_ClassRec pcf_driver_class = { { FT_MODULE_FONT_DRIVER | FT_MODULE_DRIVER_NO_OUTLINES, - sizeof ( FT_DriverRec ), + sizeof ( PCF_DriverRec ), "pcf", 0x10000L, 0x20000L, - 0, /* module-specific interface */ + NULL, /* module-specific interface */ - 0, /* FT_Module_Constructor module_init */ - 0, /* FT_Module_Destructor module_done */ + pcf_driver_init, /* FT_Module_Constructor module_init */ + pcf_driver_done, /* FT_Module_Destructor module_done */ pcf_driver_requester /* FT_Module_Requester get_interface */ }, @@ -713,16 +852,16 @@ THE SOFTWARE. PCF_Face_Init, /* FT_Face_InitFunc init_face */ PCF_Face_Done, /* FT_Face_DoneFunc done_face */ - 0, /* FT_Size_InitFunc init_size */ - 0, /* FT_Size_DoneFunc done_size */ - 0, /* FT_Slot_InitFunc init_slot */ - 0, /* FT_Slot_DoneFunc done_slot */ + NULL, /* FT_Size_InitFunc init_size */ + NULL, /* FT_Size_DoneFunc done_size */ + NULL, /* FT_Slot_InitFunc init_slot */ + NULL, /* FT_Slot_DoneFunc done_slot */ PCF_Glyph_Load, /* FT_Slot_LoadFunc load_glyph */ - 0, /* FT_Face_GetKerningFunc get_kerning */ - 0, /* FT_Face_AttachFunc attach_file */ - 0, /* FT_Face_GetAdvancesFunc get_advances */ + NULL, /* FT_Face_GetKerningFunc get_kerning */ + NULL, /* FT_Face_AttachFunc attach_file */ + NULL, /* FT_Face_GetAdvancesFunc get_advances */ PCF_Size_Request, /* FT_Size_RequestFunc request_size */ PCF_Size_Select /* FT_Size_SelectFunc select_size */ diff --git a/thirdparty/freetype/src/pcf/pcfread.c b/thirdparty/freetype/src/pcf/pcfread.c index a86b45d6bf..3eacf2baf6 100644 --- a/thirdparty/freetype/src/pcf/pcfread.c +++ b/thirdparty/freetype/src/pcf/pcfread.c @@ -50,8 +50,15 @@ THE SOFTWARE. #ifdef FT_DEBUG_LEVEL_TRACE static const char* const tableNames[] = { - "prop", "accl", "mtrcs", "bmps", "imtrcs", - "enc", "swidth", "names", "accel" + "properties", + "accelerators", + "metrics", + "bitmaps", + "ink metrics", + "encodings", + "swidths", + "glyph names", + "BDF accelerators" }; #endif @@ -109,17 +116,20 @@ THE SOFTWARE. if ( stream->size < 16 ) return FT_THROW( Invalid_File_Format ); - /* we need 16 bytes per TOC entry */ - if ( toc->count > stream->size >> 4 ) + /* we need 16 bytes per TOC entry, */ + /* and there can be most 9 tables */ + if ( toc->count > ( stream->size >> 4 ) || + toc->count > 9 ) { FT_TRACE0(( "pcf_read_TOC: adjusting number of tables" " (from %d to %d)\n", - toc->count, stream->size >> 4 )); - toc->count = stream->size >> 4; + toc->count, + FT_MIN( stream->size >> 4, 9 ) )); + toc->count = FT_MIN( stream->size >> 4, 9 ); } if ( FT_NEW_ARRAY( face->toc.tables, toc->count ) ) - return FT_THROW( Out_Of_Memory ); + return error; tables = face->toc.tables; for ( n = 0; n < toc->count; n++ ) @@ -232,8 +242,8 @@ THE SOFTWARE. if ( tables[i].type == (FT_UInt)( 1 << j ) ) name = tableNames[j]; - FT_TRACE4(( " %d: type=%s, format=0x%X, " - "size=%ld (0x%lX), offset=%ld (0x%lX)\n", + FT_TRACE4(( " %d: type=%s, format=0x%X," + " size=%ld (0x%lX), offset=%ld (0x%lX)\n", i, name, tables[i].format, tables[i].size, tables[i].size, @@ -319,7 +329,7 @@ THE SOFTWARE. /* parsing normal metrics */ - fields = PCF_BYTE_ORDER( format ) == MSBFirst + fields = ( PCF_BYTE_ORDER( format ) == MSBFirst ) ? pcf_metric_msb_header : pcf_metric_header; @@ -343,6 +353,17 @@ THE SOFTWARE. metric->attributes = 0; } + FT_TRACE5(( " width=%d," + " lsb=%d, rsb=%d," + " ascent=%d, descent=%d," + " attributes=%d\n", + metric->characterWidth, + metric->leftSideBearing, + metric->rightSideBearing, + metric->ascent, + metric->descent, + metric->attributes )); + Exit: return error; } @@ -461,7 +482,7 @@ THE SOFTWARE. { PCF_ParseProperty props = NULL; PCF_Property properties = NULL; - FT_ULong nprops, i; + FT_ULong nprops, orig_nprops, i; FT_ULong format, size; FT_Error error; FT_Memory memory = FT_FACE( face )->memory; @@ -481,32 +502,43 @@ THE SOFTWARE. if ( FT_READ_ULONG_LE( format ) ) goto Bail; - FT_TRACE4(( "pcf_get_properties:\n" )); - - FT_TRACE4(( " format = %ld\n", format )); + FT_TRACE4(( "pcf_get_properties:\n" + " format: 0x%lX (%s)\n", + format, + PCF_BYTE_ORDER( format ) == MSBFirst ? "MSB" : "LSB" )); if ( !PCF_FORMAT_MATCH( format, PCF_DEFAULT_FORMAT ) ) goto Bail; if ( PCF_BYTE_ORDER( format ) == MSBFirst ) - (void)FT_READ_ULONG( nprops ); + (void)FT_READ_ULONG( orig_nprops ); else - (void)FT_READ_ULONG_LE( nprops ); + (void)FT_READ_ULONG_LE( orig_nprops ); if ( error ) goto Bail; - FT_TRACE4(( " nprop = %d (truncate %d props)\n", - (int)nprops, nprops - (FT_ULong)(int)nprops )); - - nprops = (FT_ULong)(int)nprops; + FT_TRACE4(( " number of properties: %ld\n", orig_nprops )); /* rough estimate */ - if ( nprops > size / PCF_PROPERTY_SIZE ) + if ( orig_nprops > size / PCF_PROPERTY_SIZE ) { error = FT_THROW( Invalid_Table ); goto Bail; } + /* as a heuristic limit to avoid excessive allocation in */ + /* gzip bombs (i.e., very small, invalid input data that */ + /* pretends to expand to an insanely large file) we only */ + /* load the first 256 properties */ + if ( orig_nprops > 256 ) + { + FT_TRACE0(( "pcf_get_properties:" + " only loading first 256 properties\n" )); + nprops = 256; + } + else + nprops = orig_nprops; + face->nprops = (int)nprops; if ( FT_NEW_ARRAY( props, nprops ) ) @@ -526,14 +558,23 @@ THE SOFTWARE. } } + /* this skip will only work if we really have an extremely large */ + /* number of properties; it will fail for fake data, avoiding an */ + /* unnecessarily large allocation later on */ + if ( FT_STREAM_SKIP( ( orig_nprops - nprops ) * PCF_PROPERTY_SIZE ) ) + { + error = FT_THROW( Invalid_Stream_Skip ); + goto Bail; + } + /* pad the property array */ /* */ /* clever here - nprops is the same as the number of odd-units read, */ /* as only isStringProp are odd length (Keith Packard) */ /* */ - if ( nprops & 3 ) + if ( orig_nprops & 3 ) { - i = 4 - ( nprops & 3 ); + i = 4 - ( orig_nprops & 3 ); if ( FT_STREAM_SKIP( i ) ) { error = FT_THROW( Invalid_Stream_Skip ); @@ -548,15 +589,24 @@ THE SOFTWARE. if ( error ) goto Bail; - FT_TRACE4(( " string_size = %ld\n", string_size )); + FT_TRACE4(( " string size: %ld\n", string_size )); /* rough estimate */ - if ( string_size > size - nprops * PCF_PROPERTY_SIZE ) + if ( string_size > size - orig_nprops * PCF_PROPERTY_SIZE ) { error = FT_THROW( Invalid_Table ); goto Bail; } + /* the strings in the `strings' array are PostScript strings, */ + /* which can have a maximum length of 65536 characters each */ + if ( string_size > 16777472 ) /* 256 * (65536 + 1) */ + { + FT_TRACE0(( "pcf_get_properties:" + " loading only 16777472 bytes of strings array\n" )); + string_size = 16777472; + } + /* allocate one more byte so that we have a final null byte */ if ( FT_NEW_ARRAY( strings, string_size + 1 ) ) goto Bail; @@ -570,6 +620,7 @@ THE SOFTWARE. face->properties = properties; + FT_TRACE4(( "\n" )); for ( i = 0; i < nprops; i++ ) { FT_Long name_offset = props[i].name; @@ -632,7 +683,7 @@ THE SOFTWARE. FT_Memory memory = FT_FACE( face )->memory; FT_ULong format, size; PCF_Metric metrics = NULL; - FT_ULong nmetrics, i; + FT_ULong nmetrics, orig_nmetrics, i; error = pcf_seek_to_table_type( stream, @@ -647,6 +698,13 @@ THE SOFTWARE. if ( FT_READ_ULONG_LE( format ) ) goto Bail; + FT_TRACE4(( "pcf_get_metrics:\n" + " format: 0x%lX (%s, %s)\n", + format, + PCF_BYTE_ORDER( format ) == MSBFirst ? "MSB" : "LSB", + PCF_FORMAT_MATCH( format, PCF_COMPRESSED_METRICS ) ? + "compressed" : "uncompressed" )); + if ( !PCF_FORMAT_MATCH( format, PCF_DEFAULT_FORMAT ) && !PCF_FORMAT_MATCH( format, PCF_COMPRESSED_METRICS ) ) return FT_THROW( Invalid_File_Format ); @@ -654,61 +712,70 @@ THE SOFTWARE. if ( PCF_FORMAT_MATCH( format, PCF_DEFAULT_FORMAT ) ) { if ( PCF_BYTE_ORDER( format ) == MSBFirst ) - (void)FT_READ_ULONG( nmetrics ); + (void)FT_READ_ULONG( orig_nmetrics ); else - (void)FT_READ_ULONG_LE( nmetrics ); + (void)FT_READ_ULONG_LE( orig_nmetrics ); } else { if ( PCF_BYTE_ORDER( format ) == MSBFirst ) - (void)FT_READ_USHORT( nmetrics ); + (void)FT_READ_USHORT( orig_nmetrics ); else - (void)FT_READ_USHORT_LE( nmetrics ); + (void)FT_READ_USHORT_LE( orig_nmetrics ); } if ( error ) return FT_THROW( Invalid_File_Format ); - face->nmetrics = nmetrics; - - if ( !nmetrics ) - return FT_THROW( Invalid_Table ); - - FT_TRACE4(( "pcf_get_metrics:\n" )); - - FT_TRACE4(( " number of metrics: %d\n", nmetrics )); + FT_TRACE4(( " number of metrics: %ld\n", orig_nmetrics )); /* rough estimate */ if ( PCF_FORMAT_MATCH( format, PCF_DEFAULT_FORMAT ) ) { - if ( nmetrics > size / PCF_METRIC_SIZE ) + if ( orig_nmetrics > size / PCF_METRIC_SIZE ) return FT_THROW( Invalid_Table ); } else { - if ( nmetrics > size / PCF_COMPRESSED_METRIC_SIZE ) + if ( orig_nmetrics > size / PCF_COMPRESSED_METRIC_SIZE ) return FT_THROW( Invalid_Table ); } + if ( !orig_nmetrics ) + return FT_THROW( Invalid_Table ); + + /* PCF is a format from ancient times; Unicode was in its */ + /* infancy, and widely used two-byte character sets for CJK */ + /* scripts (Big 5, GB 2312, JIS X 0208, etc.) did have at most */ + /* 15000 characters. Even the more exotic CNS 11643 and CCCII */ + /* standards, which were essentially three-byte character sets, */ + /* provided less then 65536 assigned characters. */ + /* */ + /* While technically possible to have a larger number of glyphs */ + /* in PCF files, we thus limit the number to 65536. */ + if ( orig_nmetrics > 65536 ) + { + FT_TRACE0(( "pcf_get_metrics:" + " only loading first 65536 metrics\n" )); + nmetrics = 65536; + } + else + nmetrics = orig_nmetrics; + + face->nmetrics = nmetrics; + if ( FT_NEW_ARRAY( face->metrics, nmetrics ) ) - return FT_THROW( Out_Of_Memory ); + return error; metrics = face->metrics; + + FT_TRACE4(( "\n" )); for ( i = 0; i < nmetrics; i++, metrics++ ) { + FT_TRACE5(( " idx %ld:", i )); error = pcf_get_metric( stream, format, metrics ); metrics->bits = 0; - FT_TRACE5(( " idx %d: width=%d, " - "lsb=%d, rsb=%d, ascent=%d, descent=%d, swidth=%d\n", - i, - metrics->characterWidth, - metrics->leftSideBearing, - metrics->rightSideBearing, - metrics->ascent, - metrics->descent, - metrics->attributes )); - if ( error ) break; @@ -716,7 +783,7 @@ THE SOFTWARE. /* 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->ascent < -metrics->descent ) { metrics->characterWidth = 0; metrics->leftSideBearing = 0; @@ -746,7 +813,7 @@ THE SOFTWARE. FT_Long* offsets = NULL; FT_Long bitmapSizes[GLYPHPADOPTIONS]; FT_ULong format, size; - FT_ULong nbitmaps, i, sizebitmaps = 0; + FT_ULong nbitmaps, orig_nbitmaps, i, sizebitmaps = 0; error = pcf_seek_to_table_type( stream, @@ -764,18 +831,40 @@ THE SOFTWARE. format = FT_GET_ULONG_LE(); if ( PCF_BYTE_ORDER( format ) == MSBFirst ) - nbitmaps = FT_GET_ULONG(); + orig_nbitmaps = FT_GET_ULONG(); else - nbitmaps = FT_GET_ULONG_LE(); + orig_nbitmaps = FT_GET_ULONG_LE(); FT_Stream_ExitFrame( stream ); + FT_TRACE4(( "pcf_get_bitmaps:\n" + " format: 0x%lX\n" + " (%s, %s,\n" + " padding=%d bits, scanning=%d bits)\n", + format, + PCF_BYTE_ORDER( format ) == MSBFirst + ? "most significant byte first" + : "least significant byte first", + PCF_BIT_ORDER( format ) == MSBFirst + ? "most significant bit first" + : "least significant bit first", + 8 << PCF_GLYPH_PAD_INDEX( format ), + 8 << PCF_SCAN_UNIT_INDEX( format ) )); + if ( !PCF_FORMAT_MATCH( format, PCF_DEFAULT_FORMAT ) ) return FT_THROW( Invalid_File_Format ); - FT_TRACE4(( "pcf_get_bitmaps:\n" )); + FT_TRACE4(( " number of bitmaps: %ld\n", orig_nbitmaps )); - FT_TRACE4(( " number of bitmaps: %d\n", nbitmaps )); + /* see comment in `pcf_get_metrics' */ + if ( orig_nbitmaps > 65536 ) + { + FT_TRACE0(( "pcf_get_bitmaps:" + " only loading first 65536 bitmaps\n" )); + nbitmaps = 65536; + } + else + nbitmaps = orig_nbitmaps; if ( nbitmaps != face->nmetrics ) return FT_THROW( Invalid_File_Format ); @@ -783,6 +872,7 @@ THE SOFTWARE. if ( FT_NEW_ARRAY( offsets, nbitmaps ) ) return error; + FT_TRACE5(( "\n" )); for ( i = 0; i < nbitmaps; i++ ) { if ( PCF_BYTE_ORDER( format ) == MSBFirst ) @@ -790,7 +880,7 @@ THE SOFTWARE. else (void)FT_READ_LONG_LE( offsets[i] ); - FT_TRACE5(( " bitmap %d: offset %ld (0x%lX)\n", + FT_TRACE5(( " bitmap %ld: offset %ld (0x%lX)\n", i, offsets[i], offsets[i] )); } if ( error ) @@ -807,17 +897,19 @@ THE SOFTWARE. sizebitmaps = (FT_ULong)bitmapSizes[PCF_GLYPH_PAD_INDEX( format )]; - FT_TRACE4(( " padding %d implies a size of %ld\n", - i, bitmapSizes[i] )); + FT_TRACE4(( " %ld-bit padding implies a size of %ld\n", + 8 << i, bitmapSizes[i] )); } - FT_TRACE4(( " %d bitmaps, padding index %ld\n", + FT_TRACE4(( " %ld bitmaps, using %ld-bit padding\n", nbitmaps, - PCF_GLYPH_PAD_INDEX( format ) )); - FT_TRACE4(( " bitmap size = %d\n", sizebitmaps )); + 8 << PCF_GLYPH_PAD_INDEX( format ) )); + FT_TRACE4(( " bitmap size: %ld\n", sizebitmaps )); FT_UNUSED( sizebitmaps ); /* only used for debugging */ + /* right now, we only check the bitmap offsets; */ + /* actual bitmaps are only loaded on demand */ for ( i = 0; i < nbitmaps; i++ ) { /* rough estimate */ @@ -825,7 +917,7 @@ THE SOFTWARE. ( (FT_ULong)offsets[i] > size ) ) { FT_TRACE0(( "pcf_get_bitmaps:" - " invalid offset to bitmap data of glyph %d\n", i )); + " invalid offset to bitmap data of glyph %ld\n", i )); } else face->metrics[i].bits = stream->pos + (FT_ULong)offsets[i]; @@ -889,10 +981,20 @@ THE SOFTWARE. FT_Stream_ExitFrame( stream ); + FT_TRACE4(( "pcf_get_encodings:\n" + " format: 0x%lX (%s)\n", + format, + PCF_BYTE_ORDER( format ) == MSBFirst ? "MSB" : "LSB" )); + if ( !PCF_FORMAT_MATCH( format, PCF_DEFAULT_FORMAT ) ) return FT_THROW( Invalid_File_Format ); - /* sanity checks */ + FT_TRACE4(( " firstCol 0x%X, lastCol 0x%X\n" + " firstRow 0x%X, lastRow 0x%X\n", + firstCol, lastCol, + firstRow, lastRow )); + + /* sanity checks; we limit numbers of rows and columns to 256 */ if ( firstCol < 0 || firstCol > lastCol || lastCol > 0xFF || @@ -901,21 +1003,18 @@ THE SOFTWARE. lastRow > 0xFF ) return FT_THROW( Invalid_Table ); - FT_TRACE4(( "pdf_get_encodings:\n" )); - - FT_TRACE4(( " firstCol %d, lastCol %d, firstRow %d, lastRow %d\n", - firstCol, lastCol, firstRow, lastRow )); - nencoding = (FT_ULong)( lastCol - firstCol + 1 ) * (FT_ULong)( lastRow - firstRow + 1 ); if ( FT_NEW_ARRAY( encoding, nencoding ) ) - return FT_THROW( Out_Of_Memory ); + return error; error = FT_Stream_EnterFrame( stream, 2 * nencoding ); if ( error ) goto Bail; + FT_TRACE5(( "\n" )); + k = 0; for ( i = firstRow; i <= lastRow; i++ ) { @@ -1024,6 +1123,15 @@ THE SOFTWARE. if ( FT_READ_ULONG_LE( format ) ) goto Bail; + FT_TRACE4(( "pcf_get_accel%s:\n" + " format: 0x%lX (%s, %s)\n", + type == PCF_BDF_ACCELERATORS ? " (getting BDF accelerators)" + : "", + format, + PCF_BYTE_ORDER( format ) == MSBFirst ? "MSB" : "LSB", + PCF_FORMAT_MATCH( format, PCF_ACCEL_W_INKBOUNDS ) ? + "accelerated" : "not accelerated" )); + if ( !PCF_FORMAT_MATCH( format, PCF_DEFAULT_FORMAT ) && !PCF_FORMAT_MATCH( format, PCF_ACCEL_W_INKBOUNDS ) ) goto Bail; @@ -1039,12 +1147,29 @@ THE SOFTWARE. goto Bail; } + FT_TRACE5(( " noOverlap=%s, constantMetrics=%s," + " terminalFont=%s, constantWidth=%s\n" + " inkInside=%s, inkMetrics=%s, drawDirection=%s\n" + " fontAscent=%ld, fontDescent=%ld, maxOverlap=%ld\n", + accel->noOverlap ? "yes" : "no", + accel->constantMetrics ? "yes" : "no", + accel->terminalFont ? "yes" : "no", + accel->constantWidth ? "yes" : "no", + accel->inkInside ? "yes" : "no", + accel->inkMetrics ? "yes" : "no", + accel->drawDirection ? "RTL" : "LTR", + accel->fontAscent, + accel->fontDescent, + accel->maxOverlap )); + + FT_TRACE5(( " minbounds:" )); error = pcf_get_metric( stream, format & ( ~PCF_FORMAT_MASK ), &(accel->minbounds) ); if ( error ) goto Bail; + FT_TRACE5(( " maxbounds:" )); error = pcf_get_metric( stream, format & ( ~PCF_FORMAT_MASK ), &(accel->maxbounds) ); @@ -1053,12 +1178,14 @@ THE SOFTWARE. if ( PCF_FORMAT_MATCH( format, PCF_ACCEL_W_INKBOUNDS ) ) { + FT_TRACE5(( " ink minbounds:" )); error = pcf_get_metric( stream, format & ( ~PCF_FORMAT_MASK ), &(accel->ink_minbounds) ); if ( error ) goto Bail; + FT_TRACE5(( " ink maxbounds:" )); error = pcf_get_metric( stream, format & ( ~PCF_FORMAT_MASK ), &(accel->ink_maxbounds) ); @@ -1067,7 +1194,7 @@ THE SOFTWARE. } else { - accel->ink_minbounds = accel->minbounds; /* I'm not sure about this */ + accel->ink_minbounds = accel->minbounds; accel->ink_maxbounds = accel->maxbounds; } @@ -1156,7 +1283,7 @@ THE SOFTWARE. len = lengths[nn]; - if ( src == NULL ) + if ( !src ) continue; /* separate elements with a space */ @@ -1260,14 +1387,81 @@ THE SOFTWARE. if ( face->accel.constantWidth ) root->face_flags |= FT_FACE_FLAG_FIXED_WIDTH; - if ( ( error = pcf_interpret_style( face ) ) != 0 ) - goto Exit; + if ( FT_SET_ERROR( pcf_interpret_style( face ) ) ) + goto Exit; prop = pcf_find_property( face, "FAMILY_NAME" ); if ( prop && prop->isString ) { - if ( FT_STRDUP( root->family_name, prop->value.atom ) ) - goto Exit; + +#ifdef PCF_CONFIG_OPTION_LONG_FAMILY_NAMES + + PCF_Driver driver = (PCF_Driver)FT_FACE_DRIVER( face ); + + + if ( !driver->no_long_family_names ) + { + /* Prepend the foundry name plus a space to the family name. */ + /* There are many fonts just called `Fixed' which look */ + /* completely different, and which have nothing to do with each */ + /* other. When selecting `Fixed' in KDE or Gnome one gets */ + /* results that appear rather random, the style changes often if */ + /* one changes the size and one cannot select some fonts at all. */ + /* */ + /* We also check whether we have `wide' characters; all put */ + /* together, we get family names like `Sony Fixed' or `Misc */ + /* Fixed Wide'. */ + + PCF_Property foundry_prop, point_size_prop, average_width_prop; + + int l = ft_strlen( prop->value.atom ) + 1; + int wide = 0; + + + foundry_prop = pcf_find_property( face, "FOUNDRY" ); + point_size_prop = pcf_find_property( face, "POINT_SIZE" ); + average_width_prop = pcf_find_property( face, "AVERAGE_WIDTH" ); + + if ( point_size_prop && average_width_prop ) + { + if ( average_width_prop->value.l >= point_size_prop->value.l ) + { + /* This font is at least square shaped or even wider */ + wide = 1; + l += ft_strlen( " Wide" ); + } + } + + if ( foundry_prop && foundry_prop->isString ) + { + l += ft_strlen( foundry_prop->value.atom ) + 1; + + if ( FT_NEW_ARRAY( root->family_name, l ) ) + goto Exit; + + ft_strcpy( root->family_name, foundry_prop->value.atom ); + ft_strcat( root->family_name, " " ); + ft_strcat( root->family_name, prop->value.atom ); + } + else + { + if ( FT_NEW_ARRAY( root->family_name, l ) ) + goto Exit; + + ft_strcpy( root->family_name, prop->value.atom ); + } + + if ( wide ) + ft_strcat( root->family_name, " Wide" ); + } + else + +#endif /* PCF_CONFIG_OPTION_LONG_FAMILY_NAMES */ + + { + if ( FT_STRDUP( root->family_name, prop->value.atom ) ) + goto Exit; + } } else root->family_name = NULL; @@ -1290,7 +1484,7 @@ THE SOFTWARE. FT_Short resolution_x = 0, resolution_y = 0; - FT_MEM_ZERO( bsize, sizeof ( FT_Bitmap_Size ) ); + FT_ZERO( bsize ); /* for simplicity, we take absolute values of integer properties */ diff --git a/thirdparty/freetype/src/pfr/module.mk b/thirdparty/freetype/src/pfr/module.mk index bf7808c72f..7b84da9708 100644 --- a/thirdparty/freetype/src/pfr/module.mk +++ b/thirdparty/freetype/src/pfr/module.mk @@ -3,7 +3,7 @@ # -# Copyright 2002-2016 by +# Copyright 2002-2017 by # David Turner, Robert Wilhelm, and Werner Lemberg. # # This file is part of the FreeType project, and may only be used, modified, diff --git a/thirdparty/freetype/src/pfr/pfr.c b/thirdparty/freetype/src/pfr/pfr.c index 1a433960a5..4f31f5d9bc 100644 --- a/thirdparty/freetype/src/pfr/pfr.c +++ b/thirdparty/freetype/src/pfr/pfr.c @@ -4,7 +4,7 @@ /* */ /* FreeType PFR driver component. */ /* */ -/* Copyright 2002-2016 by */ +/* Copyright 2002-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -15,15 +15,16 @@ /* */ /***************************************************************************/ -#define FT_MAKE_OPTION_SINGLE_OBJECT +#define FT_MAKE_OPTION_SINGLE_OBJECT #include <ft2build.h> -#include "pfrload.c" -#include "pfrgload.c" #include "pfrcmap.c" -#include "pfrobjs.c" #include "pfrdrivr.c" +#include "pfrgload.c" +#include "pfrload.c" +#include "pfrobjs.c" #include "pfrsbit.c" + /* END */ diff --git a/thirdparty/freetype/src/pfr/pfrcmap.c b/thirdparty/freetype/src/pfr/pfrcmap.c index a1439c2e9f..1d6b15be48 100644 --- a/thirdparty/freetype/src/pfr/pfrcmap.c +++ b/thirdparty/freetype/src/pfr/pfrcmap.c @@ -4,7 +4,7 @@ /* */ /* FreeType PFR cmap handling (body). */ /* */ -/* Copyright 2002-2016 by */ +/* Copyright 2002-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -161,12 +161,16 @@ { sizeof ( PFR_CMapRec ), - (FT_CMap_InitFunc) pfr_cmap_init, - (FT_CMap_DoneFunc) pfr_cmap_done, - (FT_CMap_CharIndexFunc)pfr_cmap_char_index, - (FT_CMap_CharNextFunc) pfr_cmap_char_next, + (FT_CMap_InitFunc) pfr_cmap_init, /* init */ + (FT_CMap_DoneFunc) pfr_cmap_done, /* done */ + (FT_CMap_CharIndexFunc)pfr_cmap_char_index, /* char_index */ + (FT_CMap_CharNextFunc) pfr_cmap_char_next, /* char_next */ - NULL, NULL, NULL, NULL, NULL + (FT_CMap_CharVarIndexFunc) NULL, /* char_var_index */ + (FT_CMap_CharVarIsDefaultFunc)NULL, /* char_var_default */ + (FT_CMap_VariantListFunc) NULL, /* variant_list */ + (FT_CMap_CharVariantListFunc) NULL, /* charvariant_list */ + (FT_CMap_VariantCharListFunc) NULL /* variantchar_list */ }; diff --git a/thirdparty/freetype/src/pfr/pfrcmap.h b/thirdparty/freetype/src/pfr/pfrcmap.h index 4a8a4d0a67..957bf65b4c 100644 --- a/thirdparty/freetype/src/pfr/pfrcmap.h +++ b/thirdparty/freetype/src/pfr/pfrcmap.h @@ -4,7 +4,7 @@ /* */ /* FreeType PFR cmap handling (specification). */ /* */ -/* Copyright 2002-2016 by */ +/* Copyright 2002-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/thirdparty/freetype/src/pfr/pfrdrivr.c b/thirdparty/freetype/src/pfr/pfrdrivr.c index b81c15e560..195cdb76ac 100644 --- a/thirdparty/freetype/src/pfr/pfrdrivr.c +++ b/thirdparty/freetype/src/pfr/pfrdrivr.c @@ -4,7 +4,7 @@ /* */ /* FreeType PFR driver interface (body). */ /* */ -/* Copyright 2002-2016 by */ +/* Copyright 2002-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -181,10 +181,10 @@ 0x10000L, 0x20000L, - 0, /* module-specific interface */ + NULL, /* module-specific interface */ - 0, /* FT_Module_Constructor module_init */ - 0, /* FT_Module_Destructor module_done */ + NULL, /* FT_Module_Constructor module_init */ + NULL, /* FT_Module_Destructor module_done */ pfr_get_service /* FT_Module_Requester get_interface */ }, @@ -194,19 +194,19 @@ pfr_face_init, /* FT_Face_InitFunc init_face */ pfr_face_done, /* FT_Face_DoneFunc done_face */ - 0, /* FT_Size_InitFunc init_size */ - 0, /* FT_Size_DoneFunc done_size */ + NULL, /* FT_Size_InitFunc init_size */ + NULL, /* FT_Size_DoneFunc done_size */ pfr_slot_init, /* FT_Slot_InitFunc init_slot */ pfr_slot_done, /* FT_Slot_DoneFunc done_slot */ pfr_slot_load, /* FT_Slot_LoadFunc load_glyph */ pfr_get_kerning, /* FT_Face_GetKerningFunc get_kerning */ - 0, /* FT_Face_AttachFunc attach_file */ - 0, /* FT_Face_GetAdvancesFunc get_advances */ + NULL, /* FT_Face_AttachFunc attach_file */ + NULL, /* FT_Face_GetAdvancesFunc get_advances */ - 0, /* FT_Size_RequestFunc request_size */ - 0, /* FT_Size_SelectFunc select_size */ + NULL, /* FT_Size_RequestFunc request_size */ + NULL, /* FT_Size_SelectFunc select_size */ }; diff --git a/thirdparty/freetype/src/pfr/pfrdrivr.h b/thirdparty/freetype/src/pfr/pfrdrivr.h index 32b2d9eab3..b81d56017e 100644 --- a/thirdparty/freetype/src/pfr/pfrdrivr.h +++ b/thirdparty/freetype/src/pfr/pfrdrivr.h @@ -4,7 +4,7 @@ /* */ /* High-level Type PFR driver interface (specification). */ /* */ -/* Copyright 2002-2016 by */ +/* Copyright 2002-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/thirdparty/freetype/src/pfr/pfrerror.h b/thirdparty/freetype/src/pfr/pfrerror.h index 9305f8fb58..ef044e32c9 100644 --- a/thirdparty/freetype/src/pfr/pfrerror.h +++ b/thirdparty/freetype/src/pfr/pfrerror.h @@ -4,7 +4,7 @@ /* */ /* PFR error codes (specification only). */ /* */ -/* Copyright 2002-2016 by */ +/* Copyright 2002-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/thirdparty/freetype/src/pfr/pfrgload.c b/thirdparty/freetype/src/pfr/pfrgload.c index f9cd1f63bb..93f5fc7090 100644 --- a/thirdparty/freetype/src/pfr/pfrgload.c +++ b/thirdparty/freetype/src/pfr/pfrgload.c @@ -4,7 +4,7 @@ /* */ /* FreeType PFR glyph loader (body). */ /* */ -/* Copyright 2002-2016 by */ +/* Copyright 2002-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/thirdparty/freetype/src/pfr/pfrgload.h b/thirdparty/freetype/src/pfr/pfrgload.h index 908d4378a4..6612323871 100644 --- a/thirdparty/freetype/src/pfr/pfrgload.h +++ b/thirdparty/freetype/src/pfr/pfrgload.h @@ -4,7 +4,7 @@ /* */ /* FreeType PFR glyph loader (specification). */ /* */ -/* Copyright 2002-2016 by */ +/* Copyright 2002-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/thirdparty/freetype/src/pfr/pfrload.c b/thirdparty/freetype/src/pfr/pfrload.c index e509e70b5d..4f84165828 100644 --- a/thirdparty/freetype/src/pfr/pfrload.c +++ b/thirdparty/freetype/src/pfr/pfrload.c @@ -4,7 +4,7 @@ /* */ /* FreeType PFR loader (body). */ /* */ -/* Copyright 2002-2016 by */ +/* Copyright 2002-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -562,7 +562,7 @@ FT_UInt len = (FT_UInt)( limit - p ); - if ( phy_font->font_id != NULL ) + if ( phy_font->font_id ) goto Exit; if ( FT_ALLOC( phy_font->font_id, len + 1 ) ) @@ -589,7 +589,7 @@ FT_Memory memory = phy_font->memory; - if ( phy_font->vertical.stem_snaps != NULL ) + if ( phy_font->vertical.stem_snaps ) goto Exit; PFR_CHECK( 1 ); diff --git a/thirdparty/freetype/src/pfr/pfrload.h b/thirdparty/freetype/src/pfr/pfrload.h index 0f7a2bb239..f9475ae062 100644 --- a/thirdparty/freetype/src/pfr/pfrload.h +++ b/thirdparty/freetype/src/pfr/pfrload.h @@ -4,7 +4,7 @@ /* */ /* FreeType PFR loader (specification). */ /* */ -/* Copyright 2002-2016 by */ +/* Copyright 2002-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/thirdparty/freetype/src/pfr/pfrobjs.c b/thirdparty/freetype/src/pfr/pfrobjs.c index 769a3b6164..4b1703f51c 100644 --- a/thirdparty/freetype/src/pfr/pfrobjs.c +++ b/thirdparty/freetype/src/pfr/pfrobjs.c @@ -4,7 +4,7 @@ /* */ /* FreeType PFR object methods (body). */ /* */ -/* Copyright 2002-2016 by */ +/* Copyright 2002-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -185,7 +185,7 @@ * nothing. */ pfrface->family_name = phy_font->family_name; - if ( pfrface->family_name == NULL ) + if ( !pfrface->family_name ) pfrface->family_name = phy_font->font_id; /* note that the style name can be NULL in certain PFR fonts, @@ -342,8 +342,12 @@ /* try to load an embedded bitmap */ if ( ( load_flags & ( FT_LOAD_NO_SCALE | FT_LOAD_NO_BITMAP ) ) == 0 ) { - error = pfr_slot_load_bitmap( slot, size, gindex ); - if ( error == 0 ) + error = pfr_slot_load_bitmap( + slot, + size, + gindex, + ( load_flags & FT_LOAD_BITMAP_METRICS_ONLY ) != 0 ); + if ( !error ) goto Exit; } diff --git a/thirdparty/freetype/src/pfr/pfrobjs.h b/thirdparty/freetype/src/pfr/pfrobjs.h index 335aca8854..d6ad6562df 100644 --- a/thirdparty/freetype/src/pfr/pfrobjs.h +++ b/thirdparty/freetype/src/pfr/pfrobjs.h @@ -4,7 +4,7 @@ /* */ /* FreeType PFR object methods (specification). */ /* */ -/* Copyright 2002-2016 by */ +/* Copyright 2002-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/thirdparty/freetype/src/pfr/pfrsbit.c b/thirdparty/freetype/src/pfr/pfrsbit.c index 144f50c0b3..54e7d0e6cc 100644 --- a/thirdparty/freetype/src/pfr/pfrsbit.c +++ b/thirdparty/freetype/src/pfr/pfrsbit.c @@ -4,7 +4,7 @@ /* */ /* FreeType PFR bitmap loader (body). */ /* */ -/* Copyright 2002-2016 by */ +/* Copyright 2002-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -578,7 +578,8 @@ FT_LOCAL( FT_Error ) pfr_slot_load_bitmap( PFR_Slot glyph, PFR_Size size, - FT_UInt glyph_index ) + FT_UInt glyph_index, + FT_Bool metrics_only ) { FT_Error error; PFR_Face face = (PFR_Face) glyph->root.face; @@ -775,6 +776,9 @@ glyph->root.bitmap_left = (FT_Int)xpos; glyph->root.bitmap_top = (FT_Int)( ypos + (FT_Long)ysize ); + if ( metrics_only ) + goto Exit1; + /* Allocate and read bitmap data */ { FT_ULong len = (FT_ULong)glyph->root.bitmap.pitch * ysize; diff --git a/thirdparty/freetype/src/pfr/pfrsbit.h b/thirdparty/freetype/src/pfr/pfrsbit.h index 94ead28ca7..fc270f50a8 100644 --- a/thirdparty/freetype/src/pfr/pfrsbit.h +++ b/thirdparty/freetype/src/pfr/pfrsbit.h @@ -4,7 +4,7 @@ /* */ /* FreeType PFR bitmap loader (specification). */ /* */ -/* Copyright 2002-2016 by */ +/* Copyright 2002-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -26,7 +26,8 @@ FT_BEGIN_HEADER FT_LOCAL( FT_Error ) pfr_slot_load_bitmap( PFR_Slot glyph, PFR_Size size, - FT_UInt glyph_index ); + FT_UInt glyph_index, + FT_Bool metrics_only ); FT_END_HEADER diff --git a/thirdparty/freetype/src/pfr/pfrtypes.h b/thirdparty/freetype/src/pfr/pfrtypes.h index bd6c2cd30c..c3d542c209 100644 --- a/thirdparty/freetype/src/pfr/pfrtypes.h +++ b/thirdparty/freetype/src/pfr/pfrtypes.h @@ -4,7 +4,7 @@ /* */ /* FreeType PFR data structures (specification only). */ /* */ -/* Copyright 2002-2016 by */ +/* Copyright 2002-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/thirdparty/freetype/src/pfr/rules.mk b/thirdparty/freetype/src/pfr/rules.mk index 39bb9e941a..9940f62286 100644 --- a/thirdparty/freetype/src/pfr/rules.mk +++ b/thirdparty/freetype/src/pfr/rules.mk @@ -3,7 +3,7 @@ # -# Copyright 2002-2016 by +# Copyright 2002-2017 by # David Turner, Robert Wilhelm, and Werner Lemberg. # # This file is part of the FreeType project, and may only be used, modified, diff --git a/thirdparty/freetype/src/psaux/afmparse.c b/thirdparty/freetype/src/psaux/afmparse.c index 9fb0ac0e2b..ff2cc8cf08 100644 --- a/thirdparty/freetype/src/psaux/afmparse.c +++ b/thirdparty/freetype/src/psaux/afmparse.c @@ -4,7 +4,7 @@ /* */ /* AFM parser (body). */ /* */ -/* Copyright 2006-2016 by */ +/* Copyright 2006-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -20,6 +20,8 @@ #include FT_INTERNAL_DEBUG_H #include FT_INTERNAL_POSTSCRIPT_AUX_H +#ifndef T1_CONFIG_OPTION_NO_AFM + #include "afmparse.h" #include "psconv.h" @@ -973,5 +975,12 @@ return error; } +#else /* T1_CONFIG_OPTION_NO_AFM */ + + /* ANSI C doesn't like empty source files */ + typedef int _afm_parse_dummy; + +#endif /* T1_CONFIG_OPTION_NO_AFM */ + /* END */ diff --git a/thirdparty/freetype/src/psaux/afmparse.h b/thirdparty/freetype/src/psaux/afmparse.h index 6d8b193ffc..cd2beb7804 100644 --- a/thirdparty/freetype/src/psaux/afmparse.h +++ b/thirdparty/freetype/src/psaux/afmparse.h @@ -4,7 +4,7 @@ /* */ /* AFM parser (specification). */ /* */ -/* Copyright 2006-2016 by */ +/* Copyright 2006-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/thirdparty/freetype/src/psaux/module.mk b/thirdparty/freetype/src/psaux/module.mk index 630c4f39dd..c70a227166 100644 --- a/thirdparty/freetype/src/psaux/module.mk +++ b/thirdparty/freetype/src/psaux/module.mk @@ -3,7 +3,7 @@ # -# Copyright 1996-2016 by +# Copyright 1996-2017 by # David Turner, Robert Wilhelm, and Werner Lemberg. # # This file is part of the FreeType project, and may only be used, modified, diff --git a/thirdparty/freetype/src/psaux/psaux.c b/thirdparty/freetype/src/psaux/psaux.c index 33b462ef15..c373aa7d5b 100644 --- a/thirdparty/freetype/src/psaux/psaux.c +++ b/thirdparty/freetype/src/psaux/psaux.c @@ -4,7 +4,7 @@ /* */ /* FreeType auxiliary PostScript driver component (body only). */ /* */ -/* Copyright 1996-2016 by */ +/* Copyright 1996-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -17,18 +17,14 @@ #define FT_MAKE_OPTION_SINGLE_OBJECT - #include <ft2build.h> -#include "psobjs.c" -#include "psauxmod.c" -#include "t1decode.c" -#include "t1cmap.c" -#ifndef T1_CONFIG_OPTION_NO_AFM #include "afmparse.c" -#endif - +#include "psauxmod.c" #include "psconv.c" +#include "psobjs.c" +#include "t1cmap.c" +#include "t1decode.c" /* END */ diff --git a/thirdparty/freetype/src/psaux/psauxerr.h b/thirdparty/freetype/src/psaux/psauxerr.h index 9739157fc4..1d7ac6001b 100644 --- a/thirdparty/freetype/src/psaux/psauxerr.h +++ b/thirdparty/freetype/src/psaux/psauxerr.h @@ -4,7 +4,7 @@ /* */ /* PS auxiliary module error codes (specification only). */ /* */ -/* Copyright 2001-2016 by */ +/* Copyright 2001-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/thirdparty/freetype/src/psaux/psauxmod.c b/thirdparty/freetype/src/psaux/psauxmod.c index 80805e6951..1f589cefc2 100644 --- a/thirdparty/freetype/src/psaux/psauxmod.c +++ b/thirdparty/freetype/src/psaux/psauxmod.c @@ -4,7 +4,7 @@ /* */ /* FreeType auxiliary PostScript module implementation (body). */ /* */ -/* Copyright 2000-2016 by */ +/* Copyright 2000-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -30,52 +30,56 @@ FT_CALLBACK_TABLE_DEF const PS_Table_FuncsRec ps_table_funcs = { - ps_table_new, - ps_table_done, - ps_table_add, - ps_table_release + ps_table_new, /* init */ + ps_table_done, /* done */ + ps_table_add, /* add */ + ps_table_release /* release */ }; FT_CALLBACK_TABLE_DEF const PS_Parser_FuncsRec ps_parser_funcs = { - ps_parser_init, - ps_parser_done, - ps_parser_skip_spaces, - ps_parser_skip_PS_token, - ps_parser_to_int, - ps_parser_to_fixed, - ps_parser_to_bytes, - ps_parser_to_coord_array, - ps_parser_to_fixed_array, - ps_parser_to_token, - ps_parser_to_token_array, - ps_parser_load_field, - ps_parser_load_field_table + ps_parser_init, /* init */ + ps_parser_done, /* done */ + + ps_parser_skip_spaces, /* skip_spaces */ + ps_parser_skip_PS_token, /* skip_PS_token */ + + ps_parser_to_int, /* to_int */ + ps_parser_to_fixed, /* to_fixed */ + ps_parser_to_bytes, /* to_bytes */ + ps_parser_to_coord_array, /* to_coord_array */ + ps_parser_to_fixed_array, /* to_fixed_array */ + ps_parser_to_token, /* to_token */ + ps_parser_to_token_array, /* to_token_array */ + + ps_parser_load_field, /* load_field */ + ps_parser_load_field_table /* load_field_table */ }; FT_CALLBACK_TABLE_DEF const T1_Builder_FuncsRec t1_builder_funcs = { - t1_builder_init, - t1_builder_done, - t1_builder_check_points, - t1_builder_add_point, - t1_builder_add_point1, - t1_builder_add_contour, - t1_builder_start_point, - t1_builder_close_contour + t1_builder_init, /* init */ + t1_builder_done, /* done */ + + t1_builder_check_points, /* check_points */ + t1_builder_add_point, /* add_point */ + t1_builder_add_point1, /* add_point1 */ + t1_builder_add_contour, /* add_contour */ + t1_builder_start_point, /* start_point */ + t1_builder_close_contour /* close_contour */ }; FT_CALLBACK_TABLE_DEF const T1_Decoder_FuncsRec t1_decoder_funcs = { - t1_decoder_init, - t1_decoder_done, - t1_decoder_parse_charstrings + t1_decoder_init, /* init */ + t1_decoder_done, /* done */ + t1_decoder_parse_charstrings /* parse_charstrings */ }; @@ -83,9 +87,9 @@ FT_CALLBACK_TABLE_DEF const AFM_Parser_FuncsRec afm_parser_funcs = { - afm_parser_init, - afm_parser_done, - afm_parser_parse + afm_parser_init, /* init */ + afm_parser_done, /* done */ + afm_parser_parse /* parse */ }; #endif @@ -130,9 +134,9 @@ &psaux_interface, /* module-specific interface */ - (FT_Module_Constructor)0, - (FT_Module_Destructor) 0, - (FT_Module_Requester) 0 + (FT_Module_Constructor)NULL, /* module_init */ + (FT_Module_Destructor) NULL, /* module_done */ + (FT_Module_Requester) NULL /* get_interface */ }; diff --git a/thirdparty/freetype/src/psaux/psauxmod.h b/thirdparty/freetype/src/psaux/psauxmod.h index b1dbb06904..926f37eba5 100644 --- a/thirdparty/freetype/src/psaux/psauxmod.h +++ b/thirdparty/freetype/src/psaux/psauxmod.h @@ -4,7 +4,7 @@ /* */ /* FreeType auxiliary PostScript module implementation (specification). */ /* */ -/* Copyright 2000-2016 by */ +/* Copyright 2000-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/thirdparty/freetype/src/psaux/psconv.c b/thirdparty/freetype/src/psaux/psconv.c index fdaca7fb5d..b092482194 100644 --- a/thirdparty/freetype/src/psaux/psconv.c +++ b/thirdparty/freetype/src/psaux/psconv.c @@ -4,7 +4,7 @@ /* */ /* Some convenience conversions (body). */ /* */ -/* Copyright 2006-2016 by */ +/* Copyright 2006-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/thirdparty/freetype/src/psaux/psconv.h b/thirdparty/freetype/src/psaux/psconv.h index 062de36413..cab254ac5a 100644 --- a/thirdparty/freetype/src/psaux/psconv.h +++ b/thirdparty/freetype/src/psaux/psconv.h @@ -4,7 +4,7 @@ /* */ /* Some convenience conversions (specification). */ /* */ -/* Copyright 2006-2016 by */ +/* Copyright 2006-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/thirdparty/freetype/src/psaux/psobjs.c b/thirdparty/freetype/src/psaux/psobjs.c index f208b5fc63..f04edea411 100644 --- a/thirdparty/freetype/src/psaux/psobjs.c +++ b/thirdparty/freetype/src/psaux/psobjs.c @@ -4,7 +4,7 @@ /* */ /* Auxiliary functions for PostScript fonts (body). */ /* */ -/* Copyright 1996-2016 by */ +/* Copyright 1996-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -344,7 +344,7 @@ FT_Byte c = *cur; - ++cur; + cur++; if ( c == '\\' ) { @@ -370,17 +370,17 @@ case '\\': case '(': case ')': - ++cur; + cur++; break; default: /* skip octal escape or ignore backslash */ - for ( i = 0; i < 3 && cur < limit; ++i ) + for ( i = 0; i < 3 && cur < limit; i++ ) { if ( !IS_OCTAL_DIGIT( *cur ) ) break; - ++cur; + cur++; } } } @@ -455,19 +455,19 @@ FT_ASSERT( **acur == '{' ); - for ( cur = *acur; cur < limit && error == FT_Err_Ok; ++cur ) + for ( cur = *acur; cur < limit && error == FT_Err_Ok; cur++ ) { switch ( *cur ) { case '{': - ++embed; + embed++; break; case '}': - --embed; + embed--; if ( embed == 0 ) { - ++cur; + cur++; goto end; } break; @@ -695,7 +695,7 @@ /* ************ otherwise, it is any token **************/ default: token->start = cur; - token->type = ( *cur == '/' ? T1_TOKEN_TYPE_KEY : T1_TOKEN_TYPE_ANY ); + token->type = ( *cur == '/' ) ? T1_TOKEN_TYPE_KEY : T1_TOKEN_TYPE_ANY; ps_parser_skip_PS_token( parser ); cur = parser->cursor; if ( !parser->error ) @@ -750,7 +750,7 @@ if ( !token.type ) break; - if ( tokens != NULL && cur < limit ) + if ( tokens && cur < limit ) *cur = token; cur++; @@ -815,12 +815,12 @@ old_cur = cur; - if ( coords != NULL && count >= max_coords ) + if ( coords && count >= max_coords ) break; /* call PS_Conv_ToFixed() even if coords == NULL */ /* to properly parse number at `cur' */ - *( coords != NULL ? &coords[count] : &dummy ) = + *( coords ? &coords[count] : &dummy ) = (FT_Short)( PS_Conv_ToFixed( &cur, limit, 0 ) >> 16 ); if ( old_cur == cur ) @@ -895,12 +895,12 @@ old_cur = cur; - if ( values != NULL && count >= max_values ) + if ( values && count >= max_values ) break; /* call PS_Conv_ToFixed() even if coords == NULL */ /* to properly parse number at `cur' */ - *( values != NULL ? &values[count] : &dummy ) = + *( values ? &values[count] : &dummy ) = PS_Conv_ToFixed( &cur, limit, power_ten ); if ( old_cur == cur ) @@ -1172,7 +1172,7 @@ /* for this to work (FT_String**)q must have been */ /* initialized to NULL */ - if ( *(FT_String**)q != NULL ) + if ( *(FT_String**)q ) { FT_TRACE0(( "ps_parser_load_field: overwriting field %s\n", field->ident )); @@ -1551,7 +1551,7 @@ builder->current = &loader->current.outline; FT_GlyphLoader_Rewind( loader ); - builder->hints_globals = size->internal; + builder->hints_globals = size->internal->module_data; builder->hints_funcs = NULL; if ( hinting ) @@ -1718,6 +1718,14 @@ first = outline->n_contours <= 1 ? 0 : outline->contours[outline->n_contours - 2] + 1; + /* in malformed fonts it can happen that a contour was started */ + /* but no points were added */ + if ( outline->n_contours && first == outline->n_points ) + { + outline->n_contours--; + return; + } + /* We must not include the last point in the path if it */ /* is located on the first point. */ if ( outline->n_points > 1 ) diff --git a/thirdparty/freetype/src/psaux/psobjs.h b/thirdparty/freetype/src/psaux/psobjs.h index 4c7178e79f..202e5b2416 100644 --- a/thirdparty/freetype/src/psaux/psobjs.h +++ b/thirdparty/freetype/src/psaux/psobjs.h @@ -4,7 +4,7 @@ /* */ /* Auxiliary functions for PostScript fonts (specification). */ /* */ -/* Copyright 1996-2016 by */ +/* Copyright 1996-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/thirdparty/freetype/src/psaux/rules.mk b/thirdparty/freetype/src/psaux/rules.mk index 19787b5f82..542ae12d2b 100644 --- a/thirdparty/freetype/src/psaux/rules.mk +++ b/thirdparty/freetype/src/psaux/rules.mk @@ -3,7 +3,7 @@ # -# Copyright 1996-2016 by +# Copyright 1996-2017 by # David Turner, Robert Wilhelm, and Werner Lemberg. # # This file is part of the FreeType project, and may only be used, modified, diff --git a/thirdparty/freetype/src/psaux/t1cmap.c b/thirdparty/freetype/src/psaux/t1cmap.c index 43abb98615..45b713eb7b 100644 --- a/thirdparty/freetype/src/psaux/t1cmap.c +++ b/thirdparty/freetype/src/psaux/t1cmap.c @@ -4,7 +4,7 @@ /* */ /* Type 1 character map support (body). */ /* */ -/* Copyright 2002-2016 by */ +/* Copyright 2002-2017 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 @@ cmap->code_to_sid = is_expert ? psnames->adobe_expert_encoding : psnames->adobe_std_encoding; - FT_ASSERT( cmap->code_to_sid != NULL ); + FT_ASSERT( cmap->code_to_sid ); } @@ -136,12 +136,16 @@ { sizeof ( T1_CMapStdRec ), - (FT_CMap_InitFunc) t1_cmap_standard_init, - (FT_CMap_DoneFunc) t1_cmap_std_done, - (FT_CMap_CharIndexFunc)t1_cmap_std_char_index, - (FT_CMap_CharNextFunc) t1_cmap_std_char_next, + (FT_CMap_InitFunc) t1_cmap_standard_init, /* init */ + (FT_CMap_DoneFunc) t1_cmap_std_done, /* done */ + (FT_CMap_CharIndexFunc)t1_cmap_std_char_index, /* char_index */ + (FT_CMap_CharNextFunc) t1_cmap_std_char_next, /* char_next */ - NULL, NULL, NULL, NULL, NULL + (FT_CMap_CharVarIndexFunc) NULL, /* char_var_index */ + (FT_CMap_CharVarIsDefaultFunc)NULL, /* char_var_default */ + (FT_CMap_VariantListFunc) NULL, /* variant_list */ + (FT_CMap_CharVariantListFunc) NULL, /* charvariant_list */ + (FT_CMap_VariantCharListFunc) NULL /* variantchar_list */ }; @@ -161,12 +165,16 @@ { sizeof ( T1_CMapStdRec ), - (FT_CMap_InitFunc) t1_cmap_expert_init, - (FT_CMap_DoneFunc) t1_cmap_std_done, - (FT_CMap_CharIndexFunc)t1_cmap_std_char_index, - (FT_CMap_CharNextFunc) t1_cmap_std_char_next, + (FT_CMap_InitFunc) t1_cmap_expert_init, /* init */ + (FT_CMap_DoneFunc) t1_cmap_std_done, /* done */ + (FT_CMap_CharIndexFunc)t1_cmap_std_char_index, /* char_index */ + (FT_CMap_CharNextFunc) t1_cmap_std_char_next, /* char_next */ - NULL, NULL, NULL, NULL, NULL + (FT_CMap_CharVarIndexFunc) NULL, /* char_var_index */ + (FT_CMap_CharVarIsDefaultFunc)NULL, /* char_var_default */ + (FT_CMap_VariantListFunc) NULL, /* variant_list */ + (FT_CMap_CharVariantListFunc) NULL, /* charvariant_list */ + (FT_CMap_VariantCharListFunc) NULL /* variantchar_list */ }; @@ -193,7 +201,7 @@ cmap->count = (FT_UInt)encoding->code_last - cmap->first; cmap->indices = encoding->char_index; - FT_ASSERT( cmap->indices != NULL ); + FT_ASSERT( cmap->indices ); FT_ASSERT( encoding->code_first <= encoding->code_last ); return 0; @@ -232,7 +240,7 @@ FT_UInt32 char_code = *pchar_code; - ++char_code; + char_code++; if ( char_code < cmap->first ) char_code = cmap->first; @@ -257,12 +265,16 @@ { sizeof ( T1_CMapCustomRec ), - (FT_CMap_InitFunc) t1_cmap_custom_init, - (FT_CMap_DoneFunc) t1_cmap_custom_done, - (FT_CMap_CharIndexFunc)t1_cmap_custom_char_index, - (FT_CMap_CharNextFunc) t1_cmap_custom_char_next, + (FT_CMap_InitFunc) t1_cmap_custom_init, /* init */ + (FT_CMap_DoneFunc) t1_cmap_custom_done, /* done */ + (FT_CMap_CharIndexFunc)t1_cmap_custom_char_index, /* char_index */ + (FT_CMap_CharNextFunc) t1_cmap_custom_char_next, /* char_next */ - NULL, NULL, NULL, NULL, NULL + (FT_CMap_CharVarIndexFunc) NULL, /* char_var_index */ + (FT_CMap_CharVarIsDefaultFunc)NULL, /* char_var_default */ + (FT_CMap_VariantListFunc) NULL, /* variant_list */ + (FT_CMap_CharVariantListFunc) NULL, /* charvariant_list */ + (FT_CMap_VariantCharListFunc) NULL /* variantchar_list */ }; @@ -343,12 +355,16 @@ { sizeof ( PS_UnicodesRec ), - (FT_CMap_InitFunc) t1_cmap_unicode_init, - (FT_CMap_DoneFunc) t1_cmap_unicode_done, - (FT_CMap_CharIndexFunc)t1_cmap_unicode_char_index, - (FT_CMap_CharNextFunc) t1_cmap_unicode_char_next, + (FT_CMap_InitFunc) t1_cmap_unicode_init, /* init */ + (FT_CMap_DoneFunc) t1_cmap_unicode_done, /* done */ + (FT_CMap_CharIndexFunc)t1_cmap_unicode_char_index, /* char_index */ + (FT_CMap_CharNextFunc) t1_cmap_unicode_char_next, /* char_next */ - NULL, NULL, NULL, NULL, NULL + (FT_CMap_CharVarIndexFunc) NULL, /* char_var_index */ + (FT_CMap_CharVarIsDefaultFunc)NULL, /* char_var_default */ + (FT_CMap_VariantListFunc) NULL, /* variant_list */ + (FT_CMap_CharVariantListFunc) NULL, /* charvariant_list */ + (FT_CMap_VariantCharListFunc) NULL /* variantchar_list */ }; diff --git a/thirdparty/freetype/src/psaux/t1cmap.h b/thirdparty/freetype/src/psaux/t1cmap.h index 5e1277dc63..7870245a3a 100644 --- a/thirdparty/freetype/src/psaux/t1cmap.h +++ b/thirdparty/freetype/src/psaux/t1cmap.h @@ -4,7 +4,7 @@ /* */ /* Type 1 character map support (specification). */ /* */ -/* Copyright 2002-2016 by */ +/* Copyright 2002-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/thirdparty/freetype/src/psaux/t1decode.c b/thirdparty/freetype/src/psaux/t1decode.c index 98f6ce1c87..7dd45135de 100644 --- a/thirdparty/freetype/src/psaux/t1decode.c +++ b/thirdparty/freetype/src/psaux/t1decode.c @@ -4,7 +4,7 @@ /* */ /* PostScript Type 1 decoding routines (body). */ /* */ -/* Copyright 2000-2016 by */ +/* Copyright 2000-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -405,9 +405,7 @@ ( decoder->buildchar == NULL ) ); if ( decoder->buildchar && decoder->len_buildchar > 0 ) - ft_memset( &decoder->buildchar[0], - 0, - sizeof ( decoder->buildchar[0] ) * decoder->len_buildchar ); + FT_ARRAY_ZERO( decoder->buildchar, decoder->len_buildchar ); FT_TRACE4(( "\n" "Start charstring\n" )); @@ -668,9 +666,9 @@ #ifdef FT_DEBUG_LEVEL_TRACE if ( large_int ) - FT_TRACE4(( " %ld", value )); + FT_TRACE4(( " %d", value )); else - FT_TRACE4(( " %ld", value / 65536 )); + FT_TRACE4(( " %d", value / 65536 )); #endif *top++ = value; @@ -736,7 +734,7 @@ if ( arg_cnt != 3 ) goto Unexpected_OtherSubr; - if ( decoder->flex_state == 0 || + if ( !decoder->flex_state || decoder->num_flex_vectors != 7 ) { FT_ERROR(( "t1_decoder_parse_charstrings:" @@ -754,13 +752,12 @@ if ( arg_cnt != 0 ) goto Unexpected_OtherSubr; + if ( FT_SET_ERROR( t1_builder_start_point( builder, x, y ) ) || + FT_SET_ERROR( t1_builder_check_points( builder, 6 ) ) ) + goto Fail; + decoder->flex_state = 1; decoder->num_flex_vectors = 0; - if ( ( error = t1_builder_start_point( builder, x, y ) ) - != FT_Err_Ok || - ( error = t1_builder_check_points( builder, 6 ) ) - != FT_Err_Ok ) - goto Fail; break; case 2: /* add flex vectors */ @@ -771,7 +768,7 @@ if ( arg_cnt != 0 ) goto Unexpected_OtherSubr; - if ( decoder->flex_state == 0 ) + if ( !decoder->flex_state ) { FT_ERROR(( "t1_decoder_parse_charstrings:" " missing flex start\n" )); @@ -783,10 +780,19 @@ /* point without adding any point to the outline */ idx = decoder->num_flex_vectors++; if ( idx > 0 && idx < 7 ) + { + /* in malformed fonts it is possible to have other */ + /* opcodes in the middle of a flex (which don't */ + /* increase `num_flex_vectors'); we thus have to */ + /* check whether we can add a point */ + if ( FT_SET_ERROR( t1_builder_check_points( builder, 1 ) ) ) + goto Syntax_Error; + t1_builder_add_point( builder, x, y, (FT_Byte)( idx == 3 || idx == 6 ) ); + } } break; @@ -876,7 +882,7 @@ PS_Blend blend = decoder->blend; - if ( arg_cnt != 1 || blend == NULL ) + if ( arg_cnt != 1 || !blend ) goto Unexpected_OtherSubr; idx = Fix2Int( top[0] ); @@ -944,7 +950,7 @@ PS_Blend blend = decoder->blend; - if ( arg_cnt != 2 || blend == NULL ) + if ( arg_cnt != 2 || !blend ) goto Unexpected_OtherSubr; idx = Fix2Int( top[1] ); @@ -965,7 +971,7 @@ PS_Blend blend = decoder->blend; - if ( arg_cnt != 1 || blend == NULL ) + if ( arg_cnt != 1 || !blend ) goto Unexpected_OtherSubr; idx = Fix2Int( top[0] ); @@ -1123,7 +1129,7 @@ FT_TRACE4(( "BuildCharArray = [ " )); - for ( i = 0; i < decoder->len_buildchar; ++i ) + for ( i = 0; i < decoder->len_buildchar; i++ ) FT_TRACE4(( "%d ", decoder->buildchar[i] )); FT_TRACE4(( "]\n" )); @@ -1201,8 +1207,7 @@ case op_hlineto: FT_TRACE4(( " hlineto" )); - if ( ( error = t1_builder_start_point( builder, x, y ) ) - != FT_Err_Ok ) + if ( FT_SET_ERROR( t1_builder_start_point( builder, x, y ) ) ) goto Fail; x += top[0]; @@ -1223,10 +1228,8 @@ case op_hvcurveto: FT_TRACE4(( " hvcurveto" )); - if ( ( error = t1_builder_start_point( builder, x, y ) ) - != FT_Err_Ok || - ( error = t1_builder_check_points( builder, 3 ) ) - != FT_Err_Ok ) + if ( FT_SET_ERROR( t1_builder_start_point( builder, x, y ) ) || + FT_SET_ERROR( t1_builder_check_points( builder, 3 ) ) ) goto Fail; x += top[0]; @@ -1241,16 +1244,14 @@ case op_rlineto: FT_TRACE4(( " rlineto" )); - if ( ( error = t1_builder_start_point( builder, x, y ) ) - != FT_Err_Ok ) + if ( FT_SET_ERROR( t1_builder_start_point( builder, x, y ) ) ) goto Fail; x += top[0]; y += top[1]; Add_Line: - if ( ( error = t1_builder_add_point1( builder, x, y ) ) - != FT_Err_Ok ) + if ( FT_SET_ERROR( t1_builder_add_point1( builder, x, y ) ) ) goto Fail; break; @@ -1270,10 +1271,8 @@ case op_rrcurveto: FT_TRACE4(( " rrcurveto" )); - if ( ( error = t1_builder_start_point( builder, x, y ) ) - != FT_Err_Ok || - ( error = t1_builder_check_points( builder, 3 ) ) - != FT_Err_Ok ) + if ( FT_SET_ERROR( t1_builder_start_point( builder, x, y ) ) || + FT_SET_ERROR( t1_builder_check_points( builder, 3 ) ) ) goto Fail; x += top[0]; @@ -1292,10 +1291,8 @@ case op_vhcurveto: FT_TRACE4(( " vhcurveto" )); - if ( ( error = t1_builder_start_point( builder, x, y ) ) - != FT_Err_Ok || - ( error = t1_builder_check_points( builder, 3 ) ) - != FT_Err_Ok ) + if ( FT_SET_ERROR( t1_builder_start_point( builder, x, y ) ) || + FT_SET_ERROR( t1_builder_check_points( builder, 3 ) ) ) goto Fail; y += top[0]; @@ -1310,8 +1307,7 @@ case op_vlineto: FT_TRACE4(( " vlineto" )); - if ( ( error = t1_builder_start_point( builder, x, y ) ) - != FT_Err_Ok ) + if ( FT_SET_ERROR( t1_builder_start_point( builder, x, y ) ) ) goto Fail; y += top[0]; @@ -1336,7 +1332,7 @@ /* otherwise, we divide numbers in 16.16 format -- */ /* in both cases, it is the same operation */ *top = FT_DivFix( top[0], top[1] ); - ++top; + top++; large_int = FALSE; break; @@ -1591,7 +1587,7 @@ FT_Render_Mode hint_mode, T1_Decoder_Callback parse_callback ) { - FT_MEM_ZERO( decoder, sizeof ( *decoder ) ); + FT_ZERO( decoder ); /* retrieve PSNames interface from list of current modules */ { diff --git a/thirdparty/freetype/src/psaux/t1decode.h b/thirdparty/freetype/src/psaux/t1decode.h index 0f5adfa156..12c27de775 100644 --- a/thirdparty/freetype/src/psaux/t1decode.h +++ b/thirdparty/freetype/src/psaux/t1decode.h @@ -4,7 +4,7 @@ /* */ /* PostScript Type 1 decoding routines (specification). */ /* */ -/* Copyright 2000-2016 by */ +/* Copyright 2000-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/thirdparty/freetype/src/pshinter/module.mk b/thirdparty/freetype/src/pshinter/module.mk index 63110c46a6..77e35c4c10 100644 --- a/thirdparty/freetype/src/pshinter/module.mk +++ b/thirdparty/freetype/src/pshinter/module.mk @@ -3,7 +3,7 @@ # -# Copyright 1996-2016 by +# Copyright 1996-2017 by # David Turner, Robert Wilhelm, and Werner Lemberg. # # This file is part of the FreeType project, and may only be used, modified, diff --git a/thirdparty/freetype/src/pshinter/pshalgo.c b/thirdparty/freetype/src/pshinter/pshalgo.c index 8f131be759..9ad1a3a02a 100644 --- a/thirdparty/freetype/src/pshinter/pshalgo.c +++ b/thirdparty/freetype/src/pshinter/pshalgo.c @@ -4,7 +4,7 @@ /* */ /* PostScript hinting algorithm (body). */ /* */ -/* Copyright 2001-2016 by */ +/* Copyright 2001-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used */ @@ -898,7 +898,7 @@ static void psh_print_zone( PSH_Zone zone ) { - printf( "zone [scale,delta,min,max] = [%.3f,%.3f,%d,%d]\n", + printf( "zone [scale,delta,min,max] = [%.5f,%.2f,%d,%d]\n", zone->scale / 65536.0, zone->delta / 64.0, zone->min, @@ -1162,7 +1162,7 @@ /* clear all fields */ - FT_MEM_ZERO( glyph, sizeof ( *glyph ) ); + FT_ZERO( glyph ); memory = glyph->memory = globals->memory; @@ -1531,7 +1531,7 @@ } } - if ( point->hint == NULL ) + if ( !point->hint ) { for ( nn = 0; nn < num_hints; nn++ ) { @@ -1572,8 +1572,8 @@ PS_Mask mask = table->hint_masks->masks; FT_UInt num_masks = table->hint_masks->num_masks; FT_UInt first = 0; - FT_Int major_dir = dimension == 0 ? PSH_DIR_VERTICAL - : PSH_DIR_HORIZONTAL; + FT_Int major_dir = ( dimension == 0 ) ? PSH_DIR_VERTICAL + : PSH_DIR_HORIZONTAL; PSH_Dimension dim = &glyph->globals->dimension[dimension]; FT_Fixed scale = dim->scale_mult; FT_Int threshold; diff --git a/thirdparty/freetype/src/pshinter/pshalgo.h b/thirdparty/freetype/src/pshinter/pshalgo.h index f1bda65013..62e97d152b 100644 --- a/thirdparty/freetype/src/pshinter/pshalgo.h +++ b/thirdparty/freetype/src/pshinter/pshalgo.h @@ -4,7 +4,7 @@ /* */ /* PostScript hinting algorithm (specification). */ /* */ -/* Copyright 2001-2016 by */ +/* Copyright 2001-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/thirdparty/freetype/src/pshinter/pshglob.c b/thirdparty/freetype/src/pshinter/pshglob.c index 2ac5ef1558..c68770c73a 100644 --- a/thirdparty/freetype/src/pshinter/pshglob.c +++ b/thirdparty/freetype/src/pshinter/pshglob.c @@ -5,7 +5,7 @@ /* PostScript hinter global hinting management (body). */ /* Inspired by the new auto-hinter module. */ /* */ -/* Copyright 2001-2016 by */ +/* Copyright 2001-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used */ diff --git a/thirdparty/freetype/src/pshinter/pshglob.h b/thirdparty/freetype/src/pshinter/pshglob.h index 45c957b6ef..8801cbada4 100644 --- a/thirdparty/freetype/src/pshinter/pshglob.h +++ b/thirdparty/freetype/src/pshinter/pshglob.h @@ -4,7 +4,7 @@ /* */ /* PostScript hinter global hinting management. */ /* */ -/* Copyright 2001-2016 by */ +/* Copyright 2001-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/thirdparty/freetype/src/pshinter/pshinter.c b/thirdparty/freetype/src/pshinter/pshinter.c index 614e0bb3d8..13e07e1485 100644 --- a/thirdparty/freetype/src/pshinter/pshinter.c +++ b/thirdparty/freetype/src/pshinter/pshinter.c @@ -4,7 +4,7 @@ /* */ /* FreeType PostScript Hinting module */ /* */ -/* Copyright 2001-2016 by */ +/* Copyright 2001-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -17,13 +17,13 @@ #define FT_MAKE_OPTION_SINGLE_OBJECT - #include <ft2build.h> -#include "pshpic.c" -#include "pshrec.c" -#include "pshglob.c" + #include "pshalgo.c" +#include "pshglob.c" #include "pshmod.c" +#include "pshpic.c" +#include "pshrec.c" /* END */ diff --git a/thirdparty/freetype/src/pshinter/pshmod.c b/thirdparty/freetype/src/pshinter/pshmod.c index fa4ad1f564..860dc0ae82 100644 --- a/thirdparty/freetype/src/pshinter/pshmod.c +++ b/thirdparty/freetype/src/pshinter/pshmod.c @@ -4,7 +4,7 @@ /* */ /* FreeType PostScript hinter module implementation (body). */ /* */ -/* Copyright 2001-2016 by */ +/* Copyright 2001-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -95,9 +95,11 @@ FT_DEFINE_PSHINTER_INTERFACE( pshinter_interface, + pshinter_get_globals_funcs, pshinter_get_t1_funcs, - pshinter_get_t2_funcs ) + pshinter_get_t2_funcs + ) FT_DEFINE_MODULE( @@ -111,9 +113,9 @@ &PSHINTER_INTERFACE_GET, /* module-specific interface */ - (FT_Module_Constructor)ps_hinter_init, - (FT_Module_Destructor) ps_hinter_done, - (FT_Module_Requester) NULL ) /* no additional interface for now */ - + (FT_Module_Constructor)ps_hinter_init, /* module_init */ + (FT_Module_Destructor) ps_hinter_done, /* module_done */ + (FT_Module_Requester) NULL /* get_interface */ + ) /* END */ diff --git a/thirdparty/freetype/src/pshinter/pshmod.h b/thirdparty/freetype/src/pshinter/pshmod.h index 39112a9561..1d2b40fa13 100644 --- a/thirdparty/freetype/src/pshinter/pshmod.h +++ b/thirdparty/freetype/src/pshinter/pshmod.h @@ -4,7 +4,7 @@ /* */ /* PostScript hinter module interface (specification). */ /* */ -/* Copyright 2001-2016 by */ +/* Copyright 2001-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/thirdparty/freetype/src/pshinter/pshnterr.h b/thirdparty/freetype/src/pshinter/pshnterr.h index 7a94588b87..73d144e34c 100644 --- a/thirdparty/freetype/src/pshinter/pshnterr.h +++ b/thirdparty/freetype/src/pshinter/pshnterr.h @@ -4,7 +4,7 @@ /* */ /* PS Hinter error codes (specification only). */ /* */ -/* Copyright 2003-2016 by */ +/* Copyright 2003-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/thirdparty/freetype/src/pshinter/pshpic.c b/thirdparty/freetype/src/pshinter/pshpic.c index d0a3d8ebc9..c0d3a64f29 100644 --- a/thirdparty/freetype/src/pshinter/pshpic.c +++ b/thirdparty/freetype/src/pshinter/pshpic.c @@ -4,7 +4,7 @@ /* */ /* The FreeType position independent code services for pshinter module. */ /* */ -/* Copyright 2009-2016 by */ +/* Copyright 2009-2017 by */ /* Oran Agra and Mickey Gabel. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/thirdparty/freetype/src/pshinter/pshpic.h b/thirdparty/freetype/src/pshinter/pshpic.h index 75ee573544..8d9a01c9c5 100644 --- a/thirdparty/freetype/src/pshinter/pshpic.h +++ b/thirdparty/freetype/src/pshinter/pshpic.h @@ -4,7 +4,7 @@ /* */ /* The FreeType position independent code services for pshinter module. */ /* */ -/* Copyright 2009-2016 by */ +/* Copyright 2009-2017 by */ /* Oran Agra and Mickey Gabel. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/thirdparty/freetype/src/pshinter/pshrec.c b/thirdparty/freetype/src/pshinter/pshrec.c index d7cc4a0d21..fff6d34250 100644 --- a/thirdparty/freetype/src/pshinter/pshrec.c +++ b/thirdparty/freetype/src/pshinter/pshrec.c @@ -4,7 +4,7 @@ /* */ /* FreeType PostScript hints recorder (body). */ /* */ -/* Copyright 2001-2016 by */ +/* Copyright 2001-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -818,7 +818,7 @@ ps_hints_init( PS_Hints hints, FT_Memory memory ) { - FT_MEM_ZERO( hints, sizeof ( *hints ) ); + FT_ZERO( hints ); hints->memory = memory; } @@ -1140,7 +1140,7 @@ FT_LOCAL_DEF( void ) t1_hints_funcs_init( T1_Hints_FuncsRec* funcs ) { - FT_MEM_ZERO( (char*)funcs, sizeof ( *funcs ) ); + FT_ZERO( funcs ); funcs->open = (T1_Hints_OpenFunc) t1_hints_open; funcs->close = (T1_Hints_CloseFunc) ps_hints_close; @@ -1206,7 +1206,7 @@ FT_LOCAL_DEF( void ) t2_hints_funcs_init( T2_Hints_FuncsRec* funcs ) { - FT_MEM_ZERO( funcs, sizeof ( *funcs ) ); + FT_ZERO( funcs ); funcs->open = (T2_Hints_OpenFunc) t2_hints_open; funcs->close = (T2_Hints_CloseFunc) ps_hints_close; diff --git a/thirdparty/freetype/src/pshinter/pshrec.h b/thirdparty/freetype/src/pshinter/pshrec.h index 97e6f0ed51..e10bc2b120 100644 --- a/thirdparty/freetype/src/pshinter/pshrec.h +++ b/thirdparty/freetype/src/pshinter/pshrec.h @@ -4,7 +4,7 @@ /* */ /* Postscript (Type1/Type2) hints recorder (specification). */ /* */ -/* Copyright 2001-2016 by */ +/* Copyright 2001-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/thirdparty/freetype/src/pshinter/rules.mk b/thirdparty/freetype/src/pshinter/rules.mk index 67ecf7862f..2be6404380 100644 --- a/thirdparty/freetype/src/pshinter/rules.mk +++ b/thirdparty/freetype/src/pshinter/rules.mk @@ -3,7 +3,7 @@ # -# Copyright 2001-2016 by +# Copyright 2001-2017 by # David Turner, Robert Wilhelm, and Werner Lemberg. # # This file is part of the FreeType project, and may only be used, modified, diff --git a/thirdparty/freetype/src/psnames/module.mk b/thirdparty/freetype/src/psnames/module.mk index ba29af813c..ddd22960c1 100644 --- a/thirdparty/freetype/src/psnames/module.mk +++ b/thirdparty/freetype/src/psnames/module.mk @@ -3,7 +3,7 @@ # -# Copyright 1996-2016 by +# Copyright 1996-2017 by # David Turner, Robert Wilhelm, and Werner Lemberg. # # This file is part of the FreeType project, and may only be used, modified, diff --git a/thirdparty/freetype/src/psnames/psmodule.c b/thirdparty/freetype/src/psnames/psmodule.c index 345402d7cc..3ff8cb911b 100644 --- a/thirdparty/freetype/src/psnames/psmodule.c +++ b/thirdparty/freetype/src/psnames/psmodule.c @@ -4,7 +4,7 @@ /* */ /* PSNames module implementation (body). */ /* */ -/* Copyright 1996-2016 by */ +/* Copyright 1996-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -22,6 +22,9 @@ #include FT_SERVICE_POSTSCRIPT_CMAPS_H #include "psmodule.h" + +#include "pstables.h" +#define DEFINE_PS_TABLES #include "pstables.h" #include "psnamerr.h" @@ -525,6 +528,7 @@ FT_DEFINE_SERVICE_PSCMAPSREC( pscmaps_interface, + (PS_Unicode_ValueFunc) ps_unicode_value, /* unicode_value */ (PS_Unicodes_InitFunc) ps_unicodes_init, /* unicodes_init */ (PS_Unicodes_CharIndexFunc)ps_unicodes_char_index, /* unicodes_char_index */ @@ -534,12 +538,14 @@ (PS_Adobe_Std_StringsFunc) ps_get_standard_strings, /* adobe_std_strings */ t1_standard_encoding, /* adobe_std_encoding */ - t1_expert_encoding ) /* adobe_expert_encoding */ + t1_expert_encoding /* adobe_expert_encoding */ + ) #else FT_DEFINE_SERVICE_PSCMAPSREC( pscmaps_interface, + NULL, /* unicode_value */ NULL, /* unicodes_init */ NULL, /* unicodes_char_index */ @@ -549,13 +555,15 @@ (PS_Adobe_Std_StringsFunc) ps_get_standard_strings, /* adobe_std_strings */ t1_standard_encoding, /* adobe_std_encoding */ - t1_expert_encoding ) /* adobe_expert_encoding */ + t1_expert_encoding /* adobe_expert_encoding */ + ) #endif /* FT_CONFIG_OPTION_ADOBE_GLYPH_LIST */ FT_DEFINE_SERVICEDESCREC1( pscmaps_services, + FT_SERVICE_ID_POSTSCRIPT_CMAPS, &PSCMAPS_INTERFACE_GET ) @@ -601,9 +609,11 @@ PUT_PS_NAMES_SERVICE( (void*)&PSCMAPS_INTERFACE_GET ), /* module specific interface */ - (FT_Module_Constructor)NULL, - (FT_Module_Destructor) NULL, - (FT_Module_Requester) PUT_PS_NAMES_SERVICE( psnames_get_service ) ) + + (FT_Module_Constructor)NULL, /* module_init */ + (FT_Module_Destructor) NULL, /* module_done */ + (FT_Module_Requester) PUT_PS_NAMES_SERVICE( psnames_get_service ) /* get_interface */ + ) /* END */ diff --git a/thirdparty/freetype/src/psnames/psmodule.h b/thirdparty/freetype/src/psnames/psmodule.h index ee3c6cb631..6983b79234 100644 --- a/thirdparty/freetype/src/psnames/psmodule.h +++ b/thirdparty/freetype/src/psnames/psmodule.h @@ -4,7 +4,7 @@ /* */ /* High-level PSNames module interface (specification). */ /* */ -/* Copyright 1996-2016 by */ +/* Copyright 1996-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/thirdparty/freetype/src/psnames/psnamerr.h b/thirdparty/freetype/src/psnames/psnamerr.h index 3a9f65323b..f90bf5ea43 100644 --- a/thirdparty/freetype/src/psnames/psnamerr.h +++ b/thirdparty/freetype/src/psnames/psnamerr.h @@ -4,7 +4,7 @@ /* */ /* PS names module error codes (specification only). */ /* */ -/* Copyright 2001-2016 by */ +/* Copyright 2001-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/thirdparty/freetype/src/psnames/psnames.c b/thirdparty/freetype/src/psnames/psnames.c index e7b2c0b5ef..22466d6230 100644 --- a/thirdparty/freetype/src/psnames/psnames.c +++ b/thirdparty/freetype/src/psnames/psnames.c @@ -4,7 +4,7 @@ /* */ /* FreeType PSNames module component (body only). */ /* */ -/* Copyright 1996-2016 by */ +/* Copyright 1996-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -17,10 +17,10 @@ #define FT_MAKE_OPTION_SINGLE_OBJECT - #include <ft2build.h> -#include "pspic.c" + #include "psmodule.c" +#include "pspic.c" /* END */ diff --git a/thirdparty/freetype/src/psnames/pspic.c b/thirdparty/freetype/src/psnames/pspic.c index a78ec5aa81..8b9003439b 100644 --- a/thirdparty/freetype/src/psnames/pspic.c +++ b/thirdparty/freetype/src/psnames/pspic.c @@ -4,7 +4,7 @@ /* */ /* The FreeType position independent code services for psnames module. */ /* */ -/* Copyright 2009-2016 by */ +/* Copyright 2009-2017 by */ /* Oran Agra and Mickey Gabel. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/thirdparty/freetype/src/psnames/pspic.h b/thirdparty/freetype/src/psnames/pspic.h index 48348765cf..14497e73fa 100644 --- a/thirdparty/freetype/src/psnames/pspic.h +++ b/thirdparty/freetype/src/psnames/pspic.h @@ -4,7 +4,7 @@ /* */ /* The FreeType position independent code services for psnames module. */ /* */ -/* Copyright 2009-2016 by */ +/* Copyright 2009-2017 by */ /* Oran Agra and Mickey Gabel. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/thirdparty/freetype/src/psnames/pstables.h b/thirdparty/freetype/src/psnames/pstables.h index eb827fa5ea..e0f5e30804 100644 --- a/thirdparty/freetype/src/psnames/pstables.h +++ b/thirdparty/freetype/src/psnames/pstables.h @@ -4,7 +4,7 @@ /* */ /* PostScript glyph names. */ /* */ -/* Copyright 2005-2016 by */ +/* Copyright 2005-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -19,7 +19,16 @@ /* This file has been generated automatically -- do not edit! */ - static const char ft_standard_glyph_names[3696] = +#ifndef DEFINE_PS_TABLES +#ifdef __cplusplus + extern "C" +#else + extern +#endif +#endif + const char ft_standard_glyph_names[3696] +#ifdef DEFINE_PS_TABLES + = { '.','n','u','l','l', 0, 'n','o','n','m','a','r','k','i','n','g','r','e','t','u','r','n', 0, @@ -441,14 +450,25 @@ 'R','e','g','u','l','a','r', 0, 'R','o','m','a','n', 0, 'S','e','m','i','b','o','l','d', 0, - }; + } +#endif /* DEFINE_PS_TABLES */ + ; #define FT_NUM_MAC_NAMES 258 /* Values are offsets into the `ft_standard_glyph_names' table */ - static const short ft_mac_names[FT_NUM_MAC_NAMES] = +#ifndef DEFINE_PS_TABLES +#ifdef __cplusplus + extern "C" +#else + extern +#endif +#endif + const short ft_mac_names[FT_NUM_MAC_NAMES] +#ifdef DEFINE_PS_TABLES + = { 253, 0, 6, 261, 267, 274, 283, 294, 301, 309, 758, 330, 340, 351, 360, 365, 371, 378, 385, 391, 396, 400, 404, 410, 415, 420, 424, 430, @@ -469,14 +489,25 @@ 1066,1073,1101,1143,1536,1783,1596,1843,1253,1207,1319,1579,1826,1229, 1270,1313,1323,1171,1290,1332,1211,1235,1276, 169, 175, 182, 189, 200, 209, 218, 225, 232, 239, 246 - }; + } +#endif /* DEFINE_PS_TABLES */ + ; #define FT_NUM_SID_NAMES 391 /* Values are offsets into the `ft_standard_glyph_names' table */ - static const short ft_sid_names[FT_NUM_SID_NAMES] = +#ifndef DEFINE_PS_TABLES +#ifdef __cplusplus + extern "C" +#else + extern +#endif +#endif + const short ft_sid_names[FT_NUM_SID_NAMES] +#ifdef DEFINE_PS_TABLES + = { 253, 261, 267, 274, 283, 294, 301, 309, 319, 330, 340, 351, 360, 365, 371, 378, 385, 391, 396, 400, 404, 410, 415, 420, 424, 430, 436, 441, @@ -506,11 +537,22 @@ 3237,3249,3264,3275,3283,3297,3309,3321,3338,3353,3365,3377,3394,3409, 3418,3430,3442,3454,3471,3483,3498,3506,3518,3530,3542,3559,3574,3586, 3597,3612,3620,3628,3636,3644,3650,3655,3660,3666,3673,3681,3687 - }; + } +#endif /* DEFINE_PS_TABLES */ + ; /* the following are indices into the SID name table */ - static const unsigned short t1_standard_encoding[256] = +#ifndef DEFINE_PS_TABLES +#ifdef __cplusplus + extern "C" +#else + extern +#endif +#endif + const unsigned short t1_standard_encoding[256] +#ifdef DEFINE_PS_TABLES + = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, @@ -528,11 +570,22 @@ 137, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,138, 0,139, 0, 0, 0, 0,140,141,142,143, 0, 0, 0, 0, 0,144, 0, 0, 0,145, 0, 0,146,147,148,149, 0, 0, 0, 0 - }; + } +#endif /* DEFINE_PS_TABLES */ + ; /* the following are indices into the SID name table */ - static const unsigned short t1_expert_encoding[256] = +#ifndef DEFINE_PS_TABLES +#ifdef __cplusplus + extern "C" +#else + extern +#endif +#endif + const unsigned short t1_expert_encoding[256] +#ifdef DEFINE_PS_TABLES + = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, @@ -550,7 +603,9 @@ 331,332,333,334,335,336,337,338,339,340,341,342,343,344,345,346, 347,348,349,350,351,352,353,354,355,356,357,358,359,360,361,362, 363,364,365,366,367,368,369,370,371,372,373,374,375,376,377,378 - }; + } +#endif /* DEFINE_PS_TABLES */ + ; /* @@ -564,7 +619,16 @@ #ifdef FT_CONFIG_OPTION_ADOBE_GLYPH_LIST - static const unsigned char ft_adobe_glyph_list[55997L] = +#ifndef DEFINE_PS_TABLES +#ifdef __cplusplus + extern "C" +#else + extern +#endif +#endif + const unsigned char ft_adobe_glyph_list[55997L] +#ifdef DEFINE_PS_TABLES + = { 0, 52, 0,106, 2,167, 3, 63, 4,220, 6,125, 9,143, 10, 23, 11,137, 12,199, 14,246, 15, 87, 16,233, 17,219, 18,104, 19, 88, @@ -4066,9 +4130,12 @@ 248,232,239,239,107,128, 2,144,243,244,242,239,235,101,128, 1, 182,117, 2,218,167,218,178,232,233,242,225,231,225,238, 97,128, 48, 90,235,225,244,225,235,225,238, 97,128, 48,186 - }; + } +#endif /* DEFINE_PS_TABLES */ + ; +#ifdef DEFINE_PS_TABLES /* * This function searches the compressed table efficiently. */ @@ -4163,6 +4230,7 @@ NotFound: return 0; } +#endif /* DEFINE_PS_TABLES */ #endif /* FT_CONFIG_OPTION_ADOBE_GLYPH_LIST */ diff --git a/thirdparty/freetype/src/psnames/rules.mk b/thirdparty/freetype/src/psnames/rules.mk index 9849f4053a..69fa732200 100644 --- a/thirdparty/freetype/src/psnames/rules.mk +++ b/thirdparty/freetype/src/psnames/rules.mk @@ -3,7 +3,7 @@ # -# Copyright 1996-2016 by +# Copyright 1996-2017 by # David Turner, Robert Wilhelm, and Werner Lemberg. # # This file is part of the FreeType project, and may only be used, modified, diff --git a/thirdparty/freetype/src/raster/ftmisc.h b/thirdparty/freetype/src/raster/ftmisc.h index 981ce32279..d1e6627ab4 100644 --- a/thirdparty/freetype/src/raster/ftmisc.h +++ b/thirdparty/freetype/src/raster/ftmisc.h @@ -5,7 +5,7 @@ /* Miscellaneous macros for stand-alone rasterizer (specification */ /* only). */ /* */ -/* Copyright 2005-2016 by */ +/* Copyright 2005-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used */ diff --git a/thirdparty/freetype/src/raster/ftraster.c b/thirdparty/freetype/src/raster/ftraster.c index 0fa2f2687f..c5643f6334 100644 --- a/thirdparty/freetype/src/raster/ftraster.c +++ b/thirdparty/freetype/src/raster/ftraster.c @@ -4,7 +4,7 @@ /* */ /* The FreeType glyph rasterizer (body). */ /* */ -/* Copyright 1996-2016 by */ +/* Copyright 1996-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -249,6 +249,10 @@ #ifndef FT_MEM_ZERO #define FT_MEM_ZERO( dest, count ) FT_MEM_SET( dest, 0, count ) +#endif + +#ifndef FT_ZERO +#define FT_ZERO( p ) FT_MEM_ZERO( p, sizeof ( *(p) ) ) #endif /* FMulDiv means `Fast MulDiv'; it is used in case where `b' is */ @@ -1516,8 +1520,9 @@ state_bez = y1 < y3 ? Ascending_State : Descending_State; if ( ras.state != state_bez ) { - Bool o = state_bez == Ascending_State ? IS_BOTTOM_OVERSHOOT( y1 ) - : IS_TOP_OVERSHOOT( y1 ); + Bool o = ( state_bez == Ascending_State ) + ? IS_BOTTOM_OVERSHOOT( y1 ) + : IS_TOP_OVERSHOOT( y1 ); /* finalize current profile if any */ @@ -1652,8 +1657,9 @@ /* detect a change of direction */ if ( ras.state != state_bez ) { - Bool o = state_bez == Ascending_State ? IS_BOTTOM_OVERSHOOT( y1 ) - : IS_TOP_OVERSHOOT( y1 ); + Bool o = ( state_bez == Ascending_State ) + ? IS_BOTTOM_OVERSHOOT( y1 ) + : IS_TOP_OVERSHOOT( y1 ); /* finalize current profile if any */ @@ -2386,7 +2392,7 @@ pxl = e2; /* check that the other pixel isn't set */ - e1 = pxl == e1 ? e2 : e1; + e1 = ( pxl == e1 ) ? e2 : e1; e1 = TRUNC( e1 ); @@ -2587,7 +2593,7 @@ pxl = e2; /* check that the other pixel isn't set */ - e1 = pxl == e1 ? e2 : e1; + e1 = ( pxl == e1 ) ? e2 : e1; e1 = TRUNC( e1 ); @@ -3057,7 +3063,7 @@ *araster = (FT_Raster)&the_raster; - FT_MEM_ZERO( &the_raster, sizeof ( the_raster ) ); + FT_ZERO( &the_raster ); ft_black_init( &the_raster ); return 0; @@ -3208,11 +3214,12 @@ FT_GLYPH_FORMAT_OUTLINE, - (FT_Raster_New_Func) ft_black_new, - (FT_Raster_Reset_Func) ft_black_reset, - (FT_Raster_Set_Mode_Func)ft_black_set_mode, - (FT_Raster_Render_Func) ft_black_render, - (FT_Raster_Done_Func) ft_black_done ) + (FT_Raster_New_Func) ft_black_new, /* raster_new */ + (FT_Raster_Reset_Func) ft_black_reset, /* raster_reset */ + (FT_Raster_Set_Mode_Func)ft_black_set_mode, /* raster_set_mode */ + (FT_Raster_Render_Func) ft_black_render, /* raster_render */ + (FT_Raster_Done_Func) ft_black_done /* raster_done */ + ) /* END */ diff --git a/thirdparty/freetype/src/raster/ftraster.h b/thirdparty/freetype/src/raster/ftraster.h index 65cd5f9609..6b3050cb3d 100644 --- a/thirdparty/freetype/src/raster/ftraster.h +++ b/thirdparty/freetype/src/raster/ftraster.h @@ -4,7 +4,7 @@ /* */ /* The FreeType glyph rasterizer (specification). */ /* */ -/* Copyright 1996-2016 by */ +/* Copyright 1996-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used */ diff --git a/thirdparty/freetype/src/raster/ftrend1.c b/thirdparty/freetype/src/raster/ftrend1.c index 494f112234..1a83e9e477 100644 --- a/thirdparty/freetype/src/raster/ftrend1.c +++ b/thirdparty/freetype/src/raster/ftrend1.c @@ -4,7 +4,7 @@ /* */ /* The FreeType glyph rasterizer interface (body). */ /* */ -/* Copyright 1996-2016 by */ +/* Copyright 1996-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -88,7 +88,7 @@ FT_GlyphSlot slot, FT_BBox* cbox ) { - FT_MEM_ZERO( cbox, sizeof ( *cbox ) ); + FT_ZERO( cbox ); if ( slot->format == render->glyph_format ) FT_Outline_Get_CBox( &slot->outline, cbox ); @@ -224,7 +224,8 @@ } - FT_DEFINE_RENDERER( ft_raster1_renderer_class, + FT_DEFINE_RENDERER( + ft_raster1_renderer_class, FT_MODULE_RENDERER, sizeof ( FT_RendererRec ), @@ -233,21 +234,20 @@ 0x10000L, 0x20000L, - 0, /* module specific interface */ + NULL, /* module specific interface */ - (FT_Module_Constructor)ft_raster1_init, - (FT_Module_Destructor) 0, - (FT_Module_Requester) 0 - , + (FT_Module_Constructor)ft_raster1_init, /* module_init */ + (FT_Module_Destructor) NULL, /* module_done */ + (FT_Module_Requester) NULL, /* get_interface */ FT_GLYPH_FORMAT_OUTLINE, - (FT_Renderer_RenderFunc) ft_raster1_render, - (FT_Renderer_TransformFunc)ft_raster1_transform, - (FT_Renderer_GetCBoxFunc) ft_raster1_get_cbox, - (FT_Renderer_SetModeFunc) ft_raster1_set_mode, + (FT_Renderer_RenderFunc) ft_raster1_render, /* render_glyph */ + (FT_Renderer_TransformFunc)ft_raster1_transform, /* transform_glyph */ + (FT_Renderer_GetCBoxFunc) ft_raster1_get_cbox, /* get_glyph_cbox */ + (FT_Renderer_SetModeFunc) ft_raster1_set_mode, /* set_mode */ - (FT_Raster_Funcs*) &FT_STANDARD_RASTER_GET + (FT_Raster_Funcs*)&FT_STANDARD_RASTER_GET /* raster_class */ ) diff --git a/thirdparty/freetype/src/raster/ftrend1.h b/thirdparty/freetype/src/raster/ftrend1.h index a431f185d2..cff702d140 100644 --- a/thirdparty/freetype/src/raster/ftrend1.h +++ b/thirdparty/freetype/src/raster/ftrend1.h @@ -4,7 +4,7 @@ /* */ /* The FreeType glyph rasterizer interface (specification). */ /* */ -/* Copyright 1996-2016 by */ +/* Copyright 1996-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/thirdparty/freetype/src/raster/module.mk b/thirdparty/freetype/src/raster/module.mk index f4a5f8e838..aad39cb56a 100644 --- a/thirdparty/freetype/src/raster/module.mk +++ b/thirdparty/freetype/src/raster/module.mk @@ -3,7 +3,7 @@ # -# Copyright 1996-2016 by +# Copyright 1996-2017 by # David Turner, Robert Wilhelm, and Werner Lemberg. # # This file is part of the FreeType project, and may only be used, modified, diff --git a/thirdparty/freetype/src/raster/raster.c b/thirdparty/freetype/src/raster/raster.c index 5b21dcbc6a..46a6690b17 100644 --- a/thirdparty/freetype/src/raster/raster.c +++ b/thirdparty/freetype/src/raster/raster.c @@ -4,7 +4,7 @@ /* */ /* FreeType monochrome rasterer module component (body only). */ /* */ -/* Copyright 1996-2016 by */ +/* Copyright 1996-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -17,11 +17,11 @@ #define FT_MAKE_OPTION_SINGLE_OBJECT - #include <ft2build.h> -#include "rastpic.c" + #include "ftraster.c" #include "ftrend1.c" +#include "rastpic.c" /* END */ diff --git a/thirdparty/freetype/src/raster/rasterrs.h b/thirdparty/freetype/src/raster/rasterrs.h index 44da7fca56..0d646908ad 100644 --- a/thirdparty/freetype/src/raster/rasterrs.h +++ b/thirdparty/freetype/src/raster/rasterrs.h @@ -4,7 +4,7 @@ /* */ /* monochrome renderer error codes (specification only). */ /* */ -/* Copyright 2001-2016 by */ +/* Copyright 2001-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/thirdparty/freetype/src/raster/rastpic.c b/thirdparty/freetype/src/raster/rastpic.c index dcfa92eef7..7085339b7b 100644 --- a/thirdparty/freetype/src/raster/rastpic.c +++ b/thirdparty/freetype/src/raster/rastpic.c @@ -4,7 +4,7 @@ /* */ /* The FreeType position independent code services for raster module. */ /* */ -/* Copyright 2009-2016 by */ +/* Copyright 2009-2017 by */ /* Oran Agra and Mickey Gabel. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/thirdparty/freetype/src/raster/rastpic.h b/thirdparty/freetype/src/raster/rastpic.h index 7815876383..dcd691310d 100644 --- a/thirdparty/freetype/src/raster/rastpic.h +++ b/thirdparty/freetype/src/raster/rastpic.h @@ -4,7 +4,7 @@ /* */ /* The FreeType position independent code services for raster module. */ /* */ -/* Copyright 2009-2016 by */ +/* Copyright 2009-2017 by */ /* Oran Agra and Mickey Gabel. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/thirdparty/freetype/src/raster/rules.mk b/thirdparty/freetype/src/raster/rules.mk index 929faa3a95..0462c93177 100644 --- a/thirdparty/freetype/src/raster/rules.mk +++ b/thirdparty/freetype/src/raster/rules.mk @@ -3,7 +3,7 @@ # -# Copyright 1996-2016 by +# Copyright 1996-2017 by # David Turner, Robert Wilhelm, and Werner Lemberg. # # This file is part of the FreeType project, and may only be used, modified, diff --git a/thirdparty/freetype/src/sfnt/module.mk b/thirdparty/freetype/src/sfnt/module.mk index ca19e096a3..81dea17de0 100644 --- a/thirdparty/freetype/src/sfnt/module.mk +++ b/thirdparty/freetype/src/sfnt/module.mk @@ -3,7 +3,7 @@ # -# Copyright 1996-2016 by +# Copyright 1996-2017 by # David Turner, Robert Wilhelm, and Werner Lemberg. # # This file is part of the FreeType project, and may only be used, modified, diff --git a/thirdparty/freetype/src/sfnt/pngshim.c b/thirdparty/freetype/src/sfnt/pngshim.c index 2815759ccb..b9b296ea5f 100644 --- a/thirdparty/freetype/src/sfnt/pngshim.c +++ b/thirdparty/freetype/src/sfnt/pngshim.c @@ -4,7 +4,7 @@ /* */ /* PNG Bitmap glyph support. */ /* */ -/* Copyright 2013-2016 by */ +/* Copyright 2013-2017 by */ /* Google, Inc. */ /* Written by Stuart Gill and Behdad Esfahbod. */ /* */ @@ -24,9 +24,10 @@ #include FT_CONFIG_STANDARD_LIBRARY_H -#ifdef FT_CONFIG_OPTION_USE_PNG +#if defined( TT_CONFIG_OPTION_EMBEDDED_BITMAPS ) && \ + defined( FT_CONFIG_OPTION_USE_PNG ) - /* We always include <stjmp.h>, so make libpng shut up! */ + /* We always include <setjmp.h>, so make libpng shut up! */ #define PNG_SKIP_SETJMP_CHECK 1 #include <png.h> #include "pngshim.h" @@ -184,7 +185,8 @@ FT_Memory memory, FT_Byte* data, FT_UInt png_len, - FT_Bool populate_map_and_metrics ) + FT_Bool populate_map_and_metrics, + FT_Bool metrics_only ) { FT_Bitmap *map = &slot->bitmap; FT_Error error = FT_Err_Ok; @@ -258,9 +260,6 @@ if ( populate_map_and_metrics ) { - FT_ULong size; - - metrics->width = (FT_UShort)imgWidth; metrics->height = (FT_UShort)imgHeight; @@ -276,13 +275,6 @@ error = FT_THROW( Array_Too_Large ); goto DestroyExit; } - - /* this doesn't overflow: 0x7FFF * 0x7FFF * 4 < 2^32 */ - size = map->rows * (FT_ULong)map->pitch; - - error = ft_glyphslot_alloc_bitmap( slot, size ); - if ( error ) - goto DestroyExit; } /* convert palette/gray image to rgb */ @@ -334,6 +326,9 @@ goto DestroyExit; } + if ( metrics_only ) + goto DestroyExit; + switch ( color_type ) { default: @@ -349,6 +344,17 @@ break; } + if ( populate_map_and_metrics ) + { + /* this doesn't overflow: 0x7FFF * 0x7FFF * 4 < 2^32 */ + FT_ULong size = map->rows * (FT_ULong)map->pitch; + + + error = ft_glyphslot_alloc_bitmap( slot, size ); + if ( error ) + goto DestroyExit; + } + if ( FT_NEW_ARRAY( rows, imgHeight ) ) { error = FT_THROW( Out_Of_Memory ); @@ -372,7 +378,12 @@ return error; } -#endif /* FT_CONFIG_OPTION_USE_PNG */ +#else /* !(TT_CONFIG_OPTION_EMBEDDED_BITMAPS && FT_CONFIG_OPTION_USE_PNG) */ + + /* ANSI C doesn't like empty source files */ + typedef int _pngshim_dummy; + +#endif /* !(TT_CONFIG_OPTION_EMBEDDED_BITMAPS && FT_CONFIG_OPTION_USE_PNG) */ /* END */ diff --git a/thirdparty/freetype/src/sfnt/pngshim.h b/thirdparty/freetype/src/sfnt/pngshim.h index ff05871332..344eceac12 100644 --- a/thirdparty/freetype/src/sfnt/pngshim.h +++ b/thirdparty/freetype/src/sfnt/pngshim.h @@ -4,7 +4,7 @@ /* */ /* PNG Bitmap glyph support. */ /* */ -/* Copyright 2013-2016 by */ +/* Copyright 2013-2017 by */ /* Google, Inc. */ /* Written by Stuart Gill and Behdad Esfahbod. */ /* */ @@ -38,7 +38,8 @@ FT_BEGIN_HEADER FT_Memory memory, FT_Byte* data, FT_UInt png_len, - FT_Bool populate_map_and_metrics ); + FT_Bool populate_map_and_metrics, + FT_Bool metrics_only ); #endif diff --git a/thirdparty/freetype/src/sfnt/rules.mk b/thirdparty/freetype/src/sfnt/rules.mk index e9fc421567..230d56c946 100644 --- a/thirdparty/freetype/src/sfnt/rules.mk +++ b/thirdparty/freetype/src/sfnt/rules.mk @@ -3,7 +3,7 @@ # -# Copyright 1996-2016 by +# Copyright 1996-2017 by # David Turner, Robert Wilhelm, and Werner Lemberg. # # This file is part of the FreeType project, and may only be used, modified, diff --git a/thirdparty/freetype/src/sfnt/sfdriver.c b/thirdparty/freetype/src/sfnt/sfdriver.c index 47e8967752..991433ee4c 100644 --- a/thirdparty/freetype/src/sfnt/sfdriver.c +++ b/thirdparty/freetype/src/sfnt/sfdriver.c @@ -4,7 +4,7 @@ /* */ /* High-level SFNT driver interface (body). */ /* */ -/* Copyright 1996-2016 by */ +/* Copyright 1996-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -20,6 +20,7 @@ #include FT_INTERNAL_DEBUG_H #include FT_INTERNAL_SFNT_H #include FT_INTERNAL_OBJECTS_H +#include FT_TRUETYPE_IDS_H #include "sfdriver.h" #include "ttload.h" @@ -50,6 +51,11 @@ #include FT_SERVICE_SFNT_H #include FT_SERVICE_TT_CMAP_H +#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT +#include FT_MULTIPLE_MASTERS_H +#include FT_SERVICE_MULTIPLE_MASTERS_H +#endif + /*************************************************************************/ /* */ @@ -88,7 +94,7 @@ break; case FT_SFNT_OS2: - table = face->os2.version == 0xFFFFU ? NULL : &face->os2; + table = ( face->os2.version == 0xFFFFU ) ? NULL : &face->os2; break; case FT_SFNT_POST: @@ -139,9 +145,11 @@ FT_DEFINE_SERVICE_SFNT_TABLEREC( sfnt_service_sfnt_table, + (FT_SFNT_TableLoadFunc)tt_face_load_any, /* load_table */ (FT_SFNT_TableGetFunc) get_sfnt_table, /* get_table */ - (FT_SFNT_TableInfoFunc)sfnt_table_info ) /* table_info */ + (FT_SFNT_TableInfoFunc)sfnt_table_info /* table_info */ + ) #ifdef TT_CONFIG_OPTION_POSTSCRIPT_NAMES @@ -152,7 +160,7 @@ */ static FT_Error - sfnt_get_glyph_name( TT_Face face, + sfnt_get_glyph_name( FT_Face face, FT_UInt glyph_index, FT_Pointer buffer, FT_UInt buffer_max ) @@ -161,7 +169,7 @@ FT_Error error; - error = tt_face_get_ps_name( face, glyph_index, &gname ); + error = tt_face_get_ps_name( (TT_Face)face, glyph_index, &gname ); if ( !error ) FT_STRCPYN( buffer, gname, buffer_max ); @@ -170,26 +178,26 @@ static FT_UInt - sfnt_get_name_index( TT_Face face, + sfnt_get_name_index( FT_Face face, FT_String* glyph_name ) { - FT_Face root = &face->root; + TT_Face ttface = (TT_Face)face; FT_UInt i, max_gid = FT_UINT_MAX; - if ( root->num_glyphs < 0 ) + if ( face->num_glyphs < 0 ) return 0; - else if ( (FT_ULong)root->num_glyphs < FT_UINT_MAX ) - max_gid = (FT_UInt)root->num_glyphs; + else if ( (FT_ULong)face->num_glyphs < FT_UINT_MAX ) + max_gid = (FT_UInt)face->num_glyphs; else FT_TRACE0(( "Ignore glyph names for invalid GID 0x%08x - 0x%08x\n", - FT_UINT_MAX, root->num_glyphs )); + FT_UINT_MAX, face->num_glyphs )); for ( i = 0; i < max_gid; i++ ) { FT_String* gname; - FT_Error error = tt_face_get_ps_name( face, i, &gname ); + FT_Error error = tt_face_get_ps_name( ttface, i, &gname ); if ( error ) @@ -205,9 +213,10 @@ FT_DEFINE_SERVICE_GLYPHDICTREC( sfnt_service_glyph_dict, - (FT_GlyphDict_GetNameFunc) sfnt_get_glyph_name, /* get_name */ - (FT_GlyphDict_NameIndexFunc)sfnt_get_name_index ) /* name_index */ + (FT_GlyphDict_GetNameFunc) sfnt_get_glyph_name, /* get_name */ + (FT_GlyphDict_NameIndexFunc)sfnt_get_name_index /* name_index */ + ) #endif /* TT_CONFIG_OPTION_POSTSCRIPT_NAMES */ @@ -217,120 +226,847 @@ * */ - static const char* - sfnt_get_ps_name( TT_Face face ) + /* an array representing allowed ASCII characters in a PS string */ + static const unsigned char sfnt_ps_map[16] = { - FT_Int n, found_win, found_apple; - const char* result = NULL; + /* 4 0 C 8 */ + 0x00, 0x00, /* 0x00: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 */ + 0x00, 0x00, /* 0x10: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 */ + 0xDE, 0x7C, /* 0x20: 1 1 0 1 1 1 1 0 0 1 1 1 1 1 0 0 */ + 0xFF, 0xAF, /* 0x30: 1 1 1 1 1 1 1 1 1 0 1 0 1 1 1 1 */ + 0xFF, 0xFF, /* 0x40: 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 */ + 0xFF, 0xD7, /* 0x50: 1 1 1 1 1 1 1 1 1 1 0 1 0 1 1 1 */ + 0xFF, 0xFF, /* 0x60: 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 */ + 0xFF, 0x57 /* 0x70: 1 1 1 1 1 1 1 1 0 1 0 1 0 1 1 1 */ + }; + + + static int + sfnt_is_postscript( int c ) + { + unsigned int cc; - /* shouldn't happen, but just in case to avoid memory leaks */ - if ( face->postscript_name ) - return face->postscript_name; + if ( c < 0 || c >= 0x80 ) + return 0; - /* scan the name table to see whether we have a Postscript name here, */ - /* either in Macintosh or Windows platform encodings */ - found_win = -1; - found_apple = -1; + cc = (unsigned int)c; + + return sfnt_ps_map[cc >> 3] & ( 1 << ( cc & 0x07 ) ); + } + + +#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT + + /* Only ASCII letters and digits are taken for a variation font */ + /* instance's PostScript name. */ + /* */ + /* `ft_isalnum' is a macro, but we need a function here, thus */ + /* this definition. */ + static int + sfnt_is_alphanumeric( int c ) + { + return ft_isalnum( c ); + } + + + /* the implementation of MurmurHash3 is taken and adapted from */ + /* https://github.com/aappleby/smhasher/blob/master/src/MurmurHash3.cpp */ + +#define ROTL32( x, r ) ( x << r ) | ( x >> ( 32 - r ) ) + + + static FT_UInt32 + fmix32( FT_UInt32 h ) + { + h ^= h >> 16; + h *= 0x85ebca6b; + h ^= h >> 13; + h *= 0xc2b2ae35; + h ^= h >> 16; + + return h; + } + + + static void + murmur_hash_3_128( const void* key, + const unsigned int len, + FT_UInt32 seed, + void* out ) + { + const FT_Byte* data = (const FT_Byte*)key; + const int nblocks = (int)len / 16; + + FT_UInt32 h1 = seed; + FT_UInt32 h2 = seed; + FT_UInt32 h3 = seed; + FT_UInt32 h4 = seed; + + const FT_UInt32 c1 = 0x239b961b; + const FT_UInt32 c2 = 0xab0e9789; + const FT_UInt32 c3 = 0x38b34ae5; + const FT_UInt32 c4 = 0xa1e38b93; + + const FT_UInt32* blocks = (const FT_UInt32*)( data + nblocks * 16 ); + + int i; + + + for( i = -nblocks; i; i++ ) + { + FT_UInt32 k1 = blocks[i * 4 + 0]; + FT_UInt32 k2 = blocks[i * 4 + 1]; + FT_UInt32 k3 = blocks[i * 4 + 2]; + FT_UInt32 k4 = blocks[i * 4 + 3]; + + + k1 *= c1; + k1 = ROTL32( k1, 15 ); + k1 *= c2; + h1 ^= k1; + + h1 = ROTL32( h1, 19 ); + h1 += h2; + h1 = h1 * 5 + 0x561ccd1b; + + k2 *= c2; + k2 = ROTL32( k2, 16 ); + k2 *= c3; + h2 ^= k2; + + h2 = ROTL32( h2, 17 ); + h2 += h3; + h2 = h2 * 5 + 0x0bcaa747; + + k3 *= c3; + k3 = ROTL32( k3, 17 ); + k3 *= c4; + h3 ^= k3; + + h3 = ROTL32( h3, 15 ); + h3 += h4; + h3 = h3 * 5 + 0x96cd1c35; + + k4 *= c4; + k4 = ROTL32( k4, 18 ); + k4 *= c1; + h4 ^= k4; + + h4 = ROTL32( h4, 13 ); + h4 += h1; + h4 = h4 * 5 + 0x32ac3b17; + } - for ( n = 0; n < face->num_names; n++ ) { - TT_NameEntryRec* name = face->name_table.names + n; + const FT_Byte* tail = (const FT_Byte*)( data + nblocks * 16 ); + FT_UInt32 k1 = 0; + FT_UInt32 k2 = 0; + FT_UInt32 k3 = 0; + FT_UInt32 k4 = 0; - if ( name->nameID == 6 && name->stringLength > 0 ) + + switch ( len & 15 ) { - if ( name->platformID == 3 && - name->encodingID == 1 && - name->languageID == 0x409 ) - found_win = n; - - if ( name->platformID == 1 && - name->encodingID == 0 && - name->languageID == 0 ) - found_apple = n; + case 15: + k4 ^= (FT_UInt32)tail[14] << 16; + case 14: + k4 ^= (FT_UInt32)tail[13] << 8; + case 13: + k4 ^= (FT_UInt32)tail[12]; + k4 *= c4; + k4 = ROTL32( k4, 18 ); + k4 *= c1; + h4 ^= k4; + + case 12: + k3 ^= (FT_UInt32)tail[11] << 24; + case 11: + k3 ^= (FT_UInt32)tail[10] << 16; + case 10: + k3 ^= (FT_UInt32)tail[9] << 8; + case 9: + k3 ^= (FT_UInt32)tail[8]; + k3 *= c3; + k3 = ROTL32( k3, 17 ); + k3 *= c4; + h3 ^= k3; + + case 8: + k2 ^= (FT_UInt32)tail[7] << 24; + case 7: + k2 ^= (FT_UInt32)tail[6] << 16; + case 6: + k2 ^= (FT_UInt32)tail[5] << 8; + case 5: + k2 ^= (FT_UInt32)tail[4]; + k2 *= c2; + k2 = ROTL32( k2, 16 ); + k2 *= c3; + h2 ^= k2; + + case 4: + k1 ^= (FT_UInt32)tail[3] << 24; + case 3: + k1 ^= (FT_UInt32)tail[2] << 16; + case 2: + k1 ^= (FT_UInt32)tail[1] << 8; + case 1: + k1 ^= (FT_UInt32)tail[0]; + k1 *= c1; + k1 = ROTL32( k1, 15 ); + k1 *= c2; + h1 ^= k1; } } - if ( found_win != -1 ) + h1 ^= len; + h2 ^= len; + h3 ^= len; + h4 ^= len; + + h1 += h2; + h1 += h3; + h1 += h4; + + h2 += h1; + h3 += h1; + h4 += h1; + + h1 = fmix32( h1 ); + h2 = fmix32( h2 ); + h3 = fmix32( h3 ); + h4 = fmix32( h4 ); + + h1 += h2; + h1 += h3; + h1 += h4; + + h2 += h1; + h3 += h1; + h4 += h1; + + ((FT_UInt32*)out)[0] = h1; + ((FT_UInt32*)out)[1] = h2; + ((FT_UInt32*)out)[2] = h3; + ((FT_UInt32*)out)[3] = h4; + } + + +#endif /* TT_CONFIG_OPTION_GX_VAR_SUPPORT */ + + + typedef int (*char_type_func)( int c ); + + + /* handling of PID/EID 3/0 and 3/1 is the same */ +#define IS_WIN( n ) ( (n)->platformID == 3 && \ + ( (n)->encodingID == 1 || (n)->encodingID == 0 ) && \ + (n)->languageID == 0x409 ) + +#define IS_APPLE( n ) ( (n)->platformID == 1 && \ + (n)->encodingID == 0 && \ + (n)->languageID == 0 ) + + static char* + get_win_string( FT_Memory memory, + FT_Stream stream, + TT_Name entry, + char_type_func char_type, + FT_Bool report_invalid_characters ) + { + FT_Error error = FT_Err_Ok; + + char* result = NULL; + FT_String* r; + FT_Char* p; + FT_UInt len; + + FT_UNUSED( error ); + + + if ( FT_ALLOC( result, entry->stringLength / 2 + 1 ) ) + return NULL; + + if ( FT_STREAM_SEEK( entry->stringOffset ) || + FT_FRAME_ENTER( entry->stringLength ) ) { - FT_Memory memory = face->root.memory; - TT_NameEntryRec* name = face->name_table.names + found_win; - FT_UInt len = name->stringLength / 2; - FT_Error error = FT_Err_Ok; + FT_FREE( result ); + entry->stringLength = 0; + entry->stringOffset = 0; + FT_FREE( entry->string ); - FT_UNUSED( error ); + return NULL; + } + r = (FT_String*)result; + p = (FT_Char*)stream->cursor; - if ( !FT_ALLOC( result, name->stringLength + 1 ) ) + for ( len = entry->stringLength / 2; len > 0; len--, p += 2 ) + { + if ( p[0] == 0 ) { - FT_Stream stream = face->name_table.stream; - FT_String* r = (FT_String*)result; - FT_Char* p; + if ( char_type( p[1] ) ) + *r++ = p[1]; + else + { + if ( report_invalid_characters ) + { + FT_TRACE0(( "get_win_string:" + " Character `%c' (0x%X) invalid in PS name string\n", + p[1], p[1] )); + /* it's not the job of FreeType to correct PS names... */ + *r++ = p[1]; + } + } + } + } + *r = '\0'; + + FT_FRAME_EXIT(); + + return result; + } + + + static char* + get_apple_string( FT_Memory memory, + FT_Stream stream, + TT_Name entry, + char_type_func char_type, + FT_Bool report_invalid_characters ) + { + FT_Error error = FT_Err_Ok; + + char* result = NULL; + FT_String* r; + FT_Char* p; + FT_UInt len; + + FT_UNUSED( error ); + + if ( FT_ALLOC( result, entry->stringLength + 1 ) ) + return NULL; + + if ( FT_STREAM_SEEK( entry->stringOffset ) || + FT_FRAME_ENTER( entry->stringLength ) ) + { + FT_FREE( result ); + entry->stringOffset = 0; + entry->stringLength = 0; + FT_FREE( entry->string ); - if ( FT_STREAM_SEEK( name->stringOffset ) || - FT_FRAME_ENTER( name->stringLength ) ) + return NULL; + } + + r = (FT_String*)result; + p = (FT_Char*)stream->cursor; + + for ( len = entry->stringLength; len > 0; len--, p++ ) + { + if ( char_type( *p ) ) + *r++ = *p; + else + { + if ( report_invalid_characters ) { - FT_FREE( result ); - name->stringLength = 0; - name->stringOffset = 0; - FT_FREE( name->string ); + FT_TRACE0(( "get_apple_string:" + " Character `%c' (0x%X) invalid in PS name string\n", + *p, *p )); + /* it's not the job of FreeType to correct PS names... */ + *r++ = *p; + } + } + } + *r = '\0'; + + FT_FRAME_EXIT(); + + return result; + } + + + static FT_Bool + sfnt_get_name_id( TT_Face face, + FT_UShort id, + FT_Int *win, + FT_Int *apple ) + { + FT_Int n; + + + *win = -1; + *apple = -1; + + for ( n = 0; n < face->num_names; n++ ) + { + TT_Name name = face->name_table.names + n; + + + if ( name->nameID == id && name->stringLength > 0 ) + { + if ( IS_WIN( name ) ) + *win = n; + + if ( IS_APPLE( name ) ) + *apple = n; + } + } + + return ( *win >= 0 ) || ( *apple >= 0 ); + } + + +#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT + + /* + The maximum length of an axis value descriptor. + + We need 65536 different values for the decimal fraction; this fits + nicely into five decimal places. Consequently, it consists of + + . the minus sign if the number is negative, + . up to five characters for the digits before the decimal point, + . the decimal point if there is a fractional part, and + . up to five characters for the digits after the decimal point. + + We also need one byte for the leading `_' character and up to four + bytes for the axis tag. + */ +#define MAX_VALUE_DESCRIPTOR_LEN ( 1 + 5 + 1 + 5 + 1 + 4 ) + + + /* the maximum length of PostScript font names */ +#define MAX_PS_NAME_LEN 127 + + + /* + * Find the shortest decimal representation of a 16.16 fixed point + * number. The function fills `buf' with the result, returning a pointer + * to the position after the representation's last byte. + */ + + static char* + fixed2float( FT_Int fixed, + char* buf ) + { + char* p; + char* q; + char tmp[5]; + + FT_Int int_part; + FT_Int frac_part; + + FT_Int i; + - goto Exit; + p = buf; + + if ( fixed == 0 ) + { + *p++ = '0'; + return p; + } + + if ( fixed < 0 ) + { + *p++ = '-'; + fixed = -fixed; + } + + int_part = ( fixed >> 16 ) & 0xFFFF; + frac_part = fixed & 0xFFFF; + + /* get digits of integer part (in reverse order) */ + q = tmp; + while ( int_part > 0 ) + { + *q++ = '0' + int_part % 10; + int_part /= 10; + } + + /* copy digits in correct order to buffer */ + while ( q > tmp ) + *p++ = *--q; + + if ( !frac_part ) + return p; + + /* save position of point */ + q = p; + *p++ = '.'; + + /* apply rounding */ + frac_part = frac_part * 10 + 5; + + /* get digits of fractional part */ + for ( i = 0; i < 5; i++ ) + { + *p++ = '0' + (char)( frac_part / 0x10000L ); + + frac_part %= 0x10000L; + if ( !frac_part ) + break; + + frac_part *= 10; + } + + /* + If the remainder stored in `frac_part' (after the last FOR loop) is + smaller than 34480*10, the resulting decimal value minus 0.00001 is + an equivalent representation of `fixed'. + + The above FOR loop always finds the larger of the two values; I + verified this by iterating over all possible fixed point numbers. + + If the remainder is 17232*10, both values are equally good, and we + take the next even number (following IEEE 754's `round to nearest, + ties to even' rounding rule). + + If the remainder is smaller than 17232*10, the lower of the two + numbers is nearer to the exact result (values 17232 and 34480 were + also found by testing all possible fixed point values). + + We use this to find a shorter decimal representation. If not ending + with digit zero, we take the representation with less error. + */ + p--; + if ( p - q == 5 ) /* five digits? */ + { + /* take the representation that has zero as the last digit */ + if ( frac_part < 34480 * 10 && + *p == '1' ) + *p = '0'; + + /* otherwise use the one with less error */ + else if ( frac_part == 17232 * 10 && + *p & 1 ) + *p -= 1; + + else if ( frac_part < 17232 * 10 && + *p != '0' ) + *p -= 1; + } + + /* remove trailing zeros */ + while ( *p == '0' ) + *p-- = '\0'; + + return p + 1; + } + + + static const char hexdigits[16] = + { + '0', '1', '2', '3', '4', '5', '6', '7', + '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' + }; + + + static const char* + sfnt_get_var_ps_name( TT_Face face ) + { + FT_Error error; + FT_Memory memory = face->root.memory; + + FT_Service_MultiMasters mm = (FT_Service_MultiMasters)face->mm; + + FT_UInt num_coords; + FT_Fixed* coords; + FT_MM_Var* mm_var; + + FT_Int found, win, apple; + FT_UInt i, j; + + char* result = NULL; + char* p; + + + if ( !face->var_postscript_prefix ) + { + FT_UInt len; + + + /* check whether we have a Variations PostScript Name Prefix */ + found = sfnt_get_name_id( face, + TT_NAME_ID_VARIATIONS_PREFIX, + &win, + &apple ); + if ( !found ) + { + /* otherwise use the typographic family name */ + found = sfnt_get_name_id( face, + TT_NAME_ID_TYPOGRAPHIC_FAMILY, + &win, + &apple ); + } + + if ( !found ) + { + /* as a last resort we try the family name; note that this is */ + /* not in the Adobe TechNote, but GX fonts (which predate the */ + /* TechNote) benefit from this behaviour */ + found = sfnt_get_name_id( face, + TT_NAME_ID_FONT_FAMILY, + &win, + &apple ); + } + + if ( !found ) + { + FT_TRACE0(( "sfnt_get_var_ps_name:" + " Can't construct PS name prefix for font instances\n" )); + return NULL; + } + + /* prefer Windows entries over Apple */ + if ( win != -1 ) + result = get_win_string( face->root.memory, + face->name_table.stream, + face->name_table.names + win, + sfnt_is_alphanumeric, + 0 ); + else + result = get_apple_string( face->root.memory, + face->name_table.stream, + face->name_table.names + apple, + sfnt_is_alphanumeric, + 0 ); + + len = ft_strlen( result ); + + /* sanitize if necessary; we reserve space for 36 bytes (a 128bit */ + /* checksum as a hex number, preceded by `-' and followed by three */ + /* ASCII dots, to be used if the constructed PS name would be too */ + /* long); this is also sufficient for a single instance */ + if ( len > MAX_PS_NAME_LEN - ( 1 + 32 + 3 ) ) + { + len = MAX_PS_NAME_LEN - ( 1 + 32 + 3 ); + result[len] = '\0'; + + FT_TRACE0(( "sfnt_get_var_ps_name:" + " Shortening variation PS name prefix\n" + " " + " to %d characters\n", len )); + } + + face->var_postscript_prefix = result; + face->var_postscript_prefix_len = len; + } + + mm->get_var_blend( FT_FACE( face ), + &num_coords, + &coords, + NULL, + &mm_var ); + + if ( FT_IS_NAMED_INSTANCE( FT_FACE( face ) ) ) + { + SFNT_Service sfnt = (SFNT_Service)face->sfnt; + + FT_Long instance = ( ( face->root.face_index & 0x7FFF0000L ) >> 16 ) - 1; + FT_UInt psid = mm_var->namedstyle[instance].psid; + + char* ps_name = NULL; + + + /* try first to load the name string with index `postScriptNameID' */ + if ( psid == 6 || + ( psid > 255 && psid < 32768 ) ) + (void)sfnt->get_name( face, (FT_UShort)psid, &ps_name ); + + if ( ps_name ) + { + result = ps_name; + p = result + ft_strlen( result ) + 1; + + goto check_length; + } + else + { + /* otherwise construct a name using `subfamilyNameID' */ + FT_UInt strid = mm_var->namedstyle[instance].strid; + + char* subfamily_name; + char* s; + + + (void)sfnt->get_name( face, (FT_UShort)strid, &subfamily_name ); + + if ( !subfamily_name ) + { + FT_TRACE1(( "sfnt_get_var_ps_name:" + " can't construct named instance PS name;\n" + " " + " trying to construct normal instance PS name\n" )); + goto construct_instance_name; } - p = (FT_Char*)stream->cursor; + /* after the prefix we have character `-' followed by the */ + /* subfamily name (using only characters a-z, A-Z, and 0-9) */ + if ( FT_ALLOC( result, face->var_postscript_prefix_len + + 1 + ft_strlen( subfamily_name ) + 1 ) ) + return NULL; - for ( ; len > 0; len--, p += 2 ) + ft_strcpy( result, face->var_postscript_prefix ); + + p = result + face->var_postscript_prefix_len; + *p++ = '-'; + + s = subfamily_name; + while ( *s ) { - if ( p[0] == 0 && p[1] >= 32 ) - *r++ = p[1]; + if ( ft_isalnum( *s ) ) + *p++ = *s; + s++; } - *r = '\0'; + *p++ = '\0'; + + FT_FREE( subfamily_name ); + } + } + else + { + FT_Var_Axis* axis; - FT_FRAME_EXIT(); + + construct_instance_name: + axis = mm_var->axis; + + if ( FT_ALLOC( result, + face->var_postscript_prefix_len + + num_coords * MAX_VALUE_DESCRIPTOR_LEN + 1 ) ) + return NULL; + + p = result; + + ft_strcpy( p, face->var_postscript_prefix ); + p += face->var_postscript_prefix_len; + + for ( i = 0; i < num_coords; i++, coords++, axis++ ) + { + char t; + + + /* omit axis value descriptor if it is identical */ + /* to the default axis value */ + if ( *coords == axis->def ) + continue; + + *p++ = '_'; + p = fixed2float( *coords, p ); + + t = (char)( axis->tag >> 24 ); + if ( t != ' ' && ft_isalnum( t ) ) + *p++ = t; + t = (char)( axis->tag >> 16 ); + if ( t != ' ' && ft_isalnum( t ) ) + *p++ = t; + t = (char)( axis->tag >> 8 ); + if ( t != ' ' && ft_isalnum( t ) ) + *p++ = t; + t = (char)axis->tag; + if ( t != ' ' && ft_isalnum( t ) ) + *p++ = t; } - goto Exit; } - if ( found_apple != -1 ) + check_length: + if ( p - result > MAX_PS_NAME_LEN ) { - FT_Memory memory = face->root.memory; - TT_NameEntryRec* name = face->name_table.names + found_apple; - FT_UInt len = name->stringLength; - FT_Error error = FT_Err_Ok; + /* the PS name is too long; replace the part after the prefix with */ + /* a checksum; we use MurmurHash 3 with a hash length of 128 bit */ + + FT_UInt32 seed = 123456789; + + FT_UInt32 hash[4]; + FT_UInt32* h; + - FT_UNUSED( error ); + murmur_hash_3_128( result, p - result, seed, hash ); + p = result + face->var_postscript_prefix_len; + *p++ = '-'; - if ( !FT_ALLOC( result, len + 1 ) ) + /* we convert the hash value to hex digits from back to front */ + p += 32 + 3; + h = hash + 3; + + *p-- = '\0'; + *p-- = '.'; + *p-- = '.'; + *p-- = '.'; + + for ( i = 0; i < 4; i++, h-- ) { - FT_Stream stream = face->name_table.stream; + FT_UInt32 v = *h; - if ( FT_STREAM_SEEK( name->stringOffset ) || - FT_STREAM_READ( result, len ) ) + for ( j = 0; j < 8; j++ ) { - name->stringOffset = 0; - name->stringLength = 0; - FT_FREE( name->string ); - FT_FREE( result ); - goto Exit; + *p-- = hexdigits[v & 0xF]; + v >>= 4; } - ((char*)result)[len] = '\0'; } } - Exit: + return result; + } + +#endif /* TT_CONFIG_OPTION_GX_VAR_SUPPORT */ + + + static const char* + sfnt_get_ps_name( TT_Face face ) + { + FT_Int found, win, apple; + const char* result = NULL; + + + if ( face->postscript_name ) + return face->postscript_name; + +#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT + if ( face->blend ) + { + face->postscript_name = sfnt_get_var_ps_name( face ); + return face->postscript_name; + } +#endif + + /* scan the name table to see whether we have a Postscript name here, */ + /* either in Macintosh or Windows platform encodings */ + found = sfnt_get_name_id( face, TT_NAME_ID_PS_NAME, &win, &apple ); + if ( !found ) + return NULL; + + /* prefer Windows entries over Apple */ + if ( win != -1 ) + result = get_win_string( face->root.memory, + face->name_table.stream, + face->name_table.names + win, + sfnt_is_postscript, + 1 ); + else + result = get_apple_string( face->root.memory, + face->name_table.stream, + face->name_table.names + apple, + sfnt_is_postscript, + 1 ); + face->postscript_name = result; + return result; } FT_DEFINE_SERVICE_PSFONTNAMEREC( sfnt_service_ps_name, - (FT_PsName_GetFunc)sfnt_get_ps_name ) /* get_ps_font_name */ + + (FT_PsName_GetFunc)sfnt_get_ps_name /* get_ps_font_name */ + ) /* @@ -338,7 +1074,9 @@ */ FT_DEFINE_SERVICE_TTCMAPSREC( tt_service_get_cmap_info, - (TT_CMap_Info_GetFunc)tt_get_cmap_info ) /* get_cmap_info */ + + (TT_CMap_Info_GetFunc)tt_get_cmap_info /* get_cmap_info */ + ) #ifdef TT_CONFIG_OPTION_BDF @@ -381,8 +1119,10 @@ FT_DEFINE_SERVICE_BDFRec( sfnt_service_bdf, + (FT_BDF_GetCharsetIdFunc)sfnt_get_charset_id, /* get_charset_id */ - (FT_BDF_GetPropertyFunc) tt_face_find_bdf_prop ) /* get_property */ + (FT_BDF_GetPropertyFunc) tt_face_find_bdf_prop /* get_property */ + ) #endif /* TT_CONFIG_OPTION_BDF */ @@ -395,6 +1135,7 @@ #if defined TT_CONFIG_OPTION_POSTSCRIPT_NAMES && defined TT_CONFIG_OPTION_BDF FT_DEFINE_SERVICEDESCREC5( sfnt_services, + FT_SERVICE_ID_SFNT_TABLE, &SFNT_SERVICE_SFNT_TABLE_GET, FT_SERVICE_ID_POSTSCRIPT_FONT_NAME, &SFNT_SERVICE_PS_NAME_GET, FT_SERVICE_ID_GLYPH_DICT, &SFNT_SERVICE_GLYPH_DICT_GET, @@ -403,6 +1144,7 @@ #elif defined TT_CONFIG_OPTION_POSTSCRIPT_NAMES FT_DEFINE_SERVICEDESCREC4( sfnt_services, + FT_SERVICE_ID_SFNT_TABLE, &SFNT_SERVICE_SFNT_TABLE_GET, FT_SERVICE_ID_POSTSCRIPT_FONT_NAME, &SFNT_SERVICE_PS_NAME_GET, FT_SERVICE_ID_GLYPH_DICT, &SFNT_SERVICE_GLYPH_DICT_GET, @@ -410,6 +1152,7 @@ #elif defined TT_CONFIG_OPTION_BDF FT_DEFINE_SERVICEDESCREC4( sfnt_services, + FT_SERVICE_ID_SFNT_TABLE, &SFNT_SERVICE_SFNT_TABLE_GET, FT_SERVICE_ID_POSTSCRIPT_FONT_NAME, &SFNT_SERVICE_PS_NAME_GET, FT_SERVICE_ID_BDF, &SFNT_SERVICE_BDF_GET, @@ -417,6 +1160,7 @@ #else FT_DEFINE_SERVICEDESCREC3( sfnt_services, + FT_SERVICE_ID_SFNT_TABLE, &SFNT_SERVICE_SFNT_TABLE_GET, FT_SERVICE_ID_POSTSCRIPT_FONT_NAME, &SFNT_SERVICE_PS_NAME_GET, FT_SERVICE_ID_TT_CMAP, &TT_SERVICE_CMAP_INFO_GET ) @@ -459,55 +1203,64 @@ FT_DEFINE_SFNT_INTERFACE( sfnt_interface, - tt_face_goto_table, - sfnt_init_face, - sfnt_load_face, - sfnt_done_face, - sfnt_get_interface, + tt_face_goto_table, /* TT_Loader_GotoTableFunc goto_table */ + + sfnt_init_face, /* TT_Init_Face_Func init_face */ + sfnt_load_face, /* TT_Load_Face_Func load_face */ + sfnt_done_face, /* TT_Done_Face_Func done_face */ + sfnt_get_interface, /* FT_Module_Requester get_interface */ - tt_face_load_any, + tt_face_load_any, /* TT_Load_Any_Func load_any */ - tt_face_load_head, - tt_face_load_hhea, - tt_face_load_cmap, - tt_face_load_maxp, - tt_face_load_os2, - tt_face_load_post, + tt_face_load_head, /* TT_Load_Table_Func load_head */ + tt_face_load_hhea, /* TT_Load_Metrics_Func load_hhea */ + tt_face_load_cmap, /* TT_Load_Table_Func load_cmap */ + tt_face_load_maxp, /* TT_Load_Table_Func load_maxp */ + tt_face_load_os2, /* TT_Load_Table_Func load_os2 */ + tt_face_load_post, /* TT_Load_Table_Func load_post */ - tt_face_load_name, - tt_face_free_name, + tt_face_load_name, /* TT_Load_Table_Func load_name */ + tt_face_free_name, /* TT_Free_Table_Func free_name */ - tt_face_load_kern, - tt_face_load_gasp, - tt_face_load_pclt, + tt_face_load_kern, /* TT_Load_Table_Func load_kern */ + tt_face_load_gasp, /* TT_Load_Table_Func load_gasp */ + tt_face_load_pclt, /* TT_Load_Table_Func load_init */ /* see `ttload.h' */ PUT_EMBEDDED_BITMAPS( tt_face_load_bhed ), - + /* TT_Load_Table_Func load_bhed */ PUT_EMBEDDED_BITMAPS( tt_face_load_sbit_image ), + /* TT_Load_SBit_Image_Func load_sbit_image */ /* see `ttpost.h' */ PUT_PS_NAMES( tt_face_get_ps_name ), + /* TT_Get_PS_Name_Func get_psname */ PUT_PS_NAMES( tt_face_free_ps_names ), + /* TT_Free_Table_Func free_psnames */ /* since version 2.1.8 */ - tt_face_get_kerning, + tt_face_get_kerning, /* TT_Face_GetKerningFunc get_kerning */ /* since version 2.2 */ - tt_face_load_font_dir, - tt_face_load_hmtx, + tt_face_load_font_dir, /* TT_Load_Table_Func load_font_dir */ + tt_face_load_hmtx, /* TT_Load_Metrics_Func load_hmtx */ /* see `ttsbit.h' and `sfnt.h' */ PUT_EMBEDDED_BITMAPS( tt_face_load_sbit ), + /* TT_Load_Table_Func load_eblc */ PUT_EMBEDDED_BITMAPS( tt_face_free_sbit ), + /* TT_Free_Table_Func free_eblc */ PUT_EMBEDDED_BITMAPS( tt_face_set_sbit_strike ), + /* TT_Set_SBit_Strike_Func set_sbit_strike */ PUT_EMBEDDED_BITMAPS( tt_face_load_strike_metrics ), + /* TT_Load_Strike_Metrics_Func load_strike_metrics */ - tt_face_get_metrics, + tt_face_get_metrics, /* TT_Get_Metrics_Func get_metrics */ - tt_face_get_name + tt_face_get_name, /* TT_Get_Name_Func get_name */ + sfnt_get_name_id /* TT_Get_Name_ID_Func get_name_id */ ) @@ -523,9 +1276,10 @@ (const void*)&SFNT_INTERFACE_GET, /* module specific interface */ - (FT_Module_Constructor)0, - (FT_Module_Destructor) 0, - (FT_Module_Requester) sfnt_get_interface ) + (FT_Module_Constructor)NULL, /* module_init */ + (FT_Module_Destructor) NULL, /* module_done */ + (FT_Module_Requester) sfnt_get_interface /* get_interface */ + ) /* END */ diff --git a/thirdparty/freetype/src/sfnt/sfdriver.h b/thirdparty/freetype/src/sfnt/sfdriver.h index 2694488e20..38710b60f2 100644 --- a/thirdparty/freetype/src/sfnt/sfdriver.h +++ b/thirdparty/freetype/src/sfnt/sfdriver.h @@ -4,7 +4,7 @@ /* */ /* High-level SFNT driver interface (specification). */ /* */ -/* Copyright 1996-2016 by */ +/* Copyright 1996-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/thirdparty/freetype/src/sfnt/sferrors.h b/thirdparty/freetype/src/sfnt/sferrors.h index c2f9fdfead..3cf73d725d 100644 --- a/thirdparty/freetype/src/sfnt/sferrors.h +++ b/thirdparty/freetype/src/sfnt/sferrors.h @@ -4,7 +4,7 @@ /* */ /* SFNT error codes (specification only). */ /* */ -/* Copyright 2001-2016 by */ +/* Copyright 2001-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/thirdparty/freetype/src/sfnt/sfnt.c b/thirdparty/freetype/src/sfnt/sfnt.c index 952d6d425a..6cf8c9ef30 100644 --- a/thirdparty/freetype/src/sfnt/sfnt.c +++ b/thirdparty/freetype/src/sfnt/sfnt.c @@ -4,7 +4,7 @@ /* */ /* Single object library component. */ /* */ -/* Copyright 1996-2016 by */ +/* Copyright 1996-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -17,27 +17,19 @@ #define FT_MAKE_OPTION_SINGLE_OBJECT - #include <ft2build.h> + +#include "pngshim.c" +#include "sfdriver.c" #include "sfntpic.c" -#include "ttload.c" -#include "ttmtx.c" +#include "sfobjs.c" +#include "ttbdf.c" #include "ttcmap.c" #include "ttkern.c" -#include "sfobjs.c" -#include "sfdriver.c" - -#ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS -#include "pngshim.c" -#include "ttsbit.c" -#endif - -#ifdef TT_CONFIG_OPTION_POSTSCRIPT_NAMES +#include "ttload.c" +#include "ttmtx.c" #include "ttpost.c" -#endif +#include "ttsbit.c" -#ifdef TT_CONFIG_OPTION_BDF -#include "ttbdf.c" -#endif /* END */ diff --git a/thirdparty/freetype/src/sfnt/sfntpic.c b/thirdparty/freetype/src/sfnt/sfntpic.c index 1f596c0936..8eadd601fd 100644 --- a/thirdparty/freetype/src/sfnt/sfntpic.c +++ b/thirdparty/freetype/src/sfnt/sfntpic.c @@ -4,7 +4,7 @@ /* */ /* The FreeType position independent code services for sfnt module. */ /* */ -/* Copyright 2009-2016 by */ +/* Copyright 2009-2017 by */ /* Oran Agra and Mickey Gabel. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/thirdparty/freetype/src/sfnt/sfntpic.h b/thirdparty/freetype/src/sfnt/sfntpic.h index 5ce96d3938..3afb668db0 100644 --- a/thirdparty/freetype/src/sfnt/sfntpic.h +++ b/thirdparty/freetype/src/sfnt/sfntpic.h @@ -4,7 +4,7 @@ /* */ /* The FreeType position independent code services for sfnt module. */ /* */ -/* Copyright 2009-2016 by */ +/* Copyright 2009-2017 by */ /* Oran Agra and Mickey Gabel. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/thirdparty/freetype/src/sfnt/sfobjs.c b/thirdparty/freetype/src/sfnt/sfobjs.c index 2e8c1ecde6..ac2e620e5d 100644 --- a/thirdparty/freetype/src/sfnt/sfobjs.c +++ b/thirdparty/freetype/src/sfnt/sfobjs.c @@ -4,7 +4,7 @@ /* */ /* SFNT object management (base). */ /* */ -/* Copyright 1996-2016 by */ +/* Copyright 1996-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -28,6 +28,12 @@ #include FT_SERVICE_POSTSCRIPT_CMAPS_H #include FT_SFNT_NAMES_H #include FT_GZIP_H + +#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT +#include FT_SERVICE_MULTIPLE_MASTERS_H +#include FT_SERVICE_METRICS_VARIATIONS_H +#endif + #include "sferrors.h" #ifdef TT_CONFIG_OPTION_BDF @@ -48,8 +54,8 @@ /* convert a UTF-16 name entry to ASCII */ static FT_String* - tt_name_entry_ascii_from_utf16( TT_NameEntry entry, - FT_Memory memory ) + tt_name_ascii_from_utf16( TT_Name entry, + FT_Memory memory ) { FT_String* string = NULL; FT_UInt len, code, n; @@ -83,8 +89,8 @@ /* convert an Apple Roman or symbol name entry to ASCII */ static FT_String* - tt_name_entry_ascii_from_other( TT_NameEntry entry, - FT_Memory memory ) + tt_name_ascii_from_other( TT_Name entry, + FT_Memory memory ) { FT_String* string = NULL; FT_UInt len, code, n; @@ -116,8 +122,8 @@ } - typedef FT_String* (*TT_NameEntry_ConvertFunc)( TT_NameEntry entry, - FT_Memory memory ); + typedef FT_String* (*TT_Name_ConvertFunc)( TT_Name entry, + FT_Memory memory ); /* documentation is in sfnt.h */ @@ -127,20 +133,21 @@ FT_UShort nameid, FT_String** name ) { - FT_Memory memory = face->root.memory; - FT_Error error = FT_Err_Ok; - FT_String* result = NULL; - FT_UShort n; - TT_NameEntryRec* rec; - FT_Int found_apple = -1; - FT_Int found_apple_roman = -1; - FT_Int found_apple_english = -1; - FT_Int found_win = -1; - FT_Int found_unicode = -1; + FT_Memory memory = face->root.memory; + FT_Error error = FT_Err_Ok; + FT_String* result = NULL; + FT_UShort n; + TT_Name rec; + + FT_Int found_apple = -1; + FT_Int found_apple_roman = -1; + FT_Int found_apple_english = -1; + FT_Int found_win = -1; + FT_Int found_unicode = -1; - FT_Bool is_english = 0; + FT_Bool is_english = 0; - TT_NameEntry_ConvertFunc convert; + TT_Name_ConvertFunc convert; FT_ASSERT( name ); @@ -225,7 +232,7 @@ /* all Unicode strings are encoded using UTF-16BE */ case TT_MS_ID_UNICODE_CS: case TT_MS_ID_SYMBOL_CS: - convert = tt_name_entry_ascii_from_utf16; + convert = tt_name_ascii_from_utf16; break; case TT_MS_ID_UCS_4: @@ -234,7 +241,7 @@ /* MsGothic font shipped with Windows Vista shows that this really */ /* means UTF-16 encoded names (UCS-4 values are only used within */ /* charmaps). */ - convert = tt_name_entry_ascii_from_utf16; + convert = tt_name_ascii_from_utf16; break; default: @@ -244,17 +251,17 @@ else if ( found_apple >= 0 ) { rec = face->name_table.names + found_apple; - convert = tt_name_entry_ascii_from_other; + convert = tt_name_ascii_from_other; } else if ( found_unicode >= 0 ) { rec = face->name_table.names + found_unicode; - convert = tt_name_entry_ascii_from_utf16; + convert = tt_name_ascii_from_utf16; } if ( rec && convert ) { - if ( rec->string == NULL ) + if ( !rec->string ) { FT_Stream stream = face->name_table.stream; @@ -304,7 +311,7 @@ { TT_PLATFORM_MICROSOFT, TT_MS_ID_UCS_4, FT_ENCODING_UNICODE }, { TT_PLATFORM_MICROSOFT, TT_MS_ID_UNICODE_CS, FT_ENCODING_UNICODE }, { TT_PLATFORM_MICROSOFT, TT_MS_ID_SJIS, FT_ENCODING_SJIS }, - { TT_PLATFORM_MICROSOFT, TT_MS_ID_GB2312, FT_ENCODING_GB2312 }, + { TT_PLATFORM_MICROSOFT, TT_MS_ID_PRC, FT_ENCODING_PRC }, { TT_PLATFORM_MICROSOFT, TT_MS_ID_BIG_5, FT_ENCODING_BIG5 }, { TT_PLATFORM_MICROSOFT, TT_MS_ID_WANSUNG, FT_ENCODING_WANSUNG }, { TT_PLATFORM_MICROSOFT, TT_MS_ID_JOHAB, FT_ENCODING_JOHAB } @@ -798,6 +805,9 @@ if ( FT_STREAM_READ_FIELDS( ttc_header_fields, &face->ttc_header ) ) return error; + FT_TRACE3(( " with %ld subfonts\n", + face->ttc_header.count )); + if ( face->ttc_header.count == 0 ) return FT_THROW( Invalid_Table ); @@ -872,6 +882,31 @@ FT_FACE_FIND_GLOBAL_SERVICE( face, face->psnames, POSTSCRIPT_CMAPS ); +#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT + if ( !face->mm ) + { + /* we want the MM interface from the `truetype' module only */ + FT_Module tt_module = FT_Get_Module( library, "truetype" ); + + + face->mm = ft_module_get_service( tt_module, + FT_SERVICE_ID_MULTI_MASTERS, + 0 ); + } + + if ( !face->var ) + { + /* we want the metrics variations interface */ + /* from the `truetype' module only */ + FT_Module tt_module = FT_Get_Module( library, "truetype" ); + + + face->var = ft_module_get_service( tt_module, + FT_SERVICE_ID_METRICS_VARIATIONS, + 0 ); + } +#endif + FT_TRACE2(( "SFNT driver\n" )); error = sfnt_open_font( stream, face ); @@ -881,10 +916,14 @@ /* Stream may have changed in sfnt_open_font. */ stream = face->root.stream; - FT_TRACE2(( "sfnt_init_face: %08p, %ld\n", face, face_instance_index )); + FT_TRACE2(( "sfnt_init_face: %08p, %d\n", face, face_instance_index )); face_index = FT_ABS( face_instance_index ) & 0xFFFF; + /* value -(N+1) requests information on index N */ + if ( face_instance_index < 0 ) + face_index--; + if ( face_index >= face->ttc_header.count ) { if ( face_instance_index >= 0 ) @@ -903,6 +942,8 @@ #ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT { + FT_Memory memory = face->root.memory; + FT_ULong fvar_len; FT_ULong version; @@ -915,6 +956,11 @@ FT_Int instance_index; + FT_Byte* default_values = NULL; + FT_Byte* instance_values = NULL; + + + face->is_default_instance = 1; instance_index = FT_ABS( face_instance_index ) >> 16; @@ -923,7 +969,7 @@ fvar_len < 20 || FT_READ_ULONG( version ) || FT_READ_USHORT( offset ) || - FT_STREAM_SKIP( 2 ) || + FT_STREAM_SKIP( 2 ) /* reserved */ || FT_READ_USHORT( num_axes ) || FT_READ_USHORT( axis_size ) || FT_READ_USHORT( num_instances ) || @@ -937,31 +983,90 @@ instance_size = 0; } - /* check that the data is bound by the table length; */ - /* based on similar code in function `TT_Get_MM_Var' */ + /* check that the data is bound by the table length */ if ( version != 0x00010000UL || axis_size != 20 || + num_axes == 0 || + /* `num_axes' limit implied by 16-bit `instance_size' */ num_axes > 0x3FFE || - instance_size != 4 + 4 * num_axes || + !( instance_size == 4 + 4 * num_axes || + instance_size == 6 + 4 * num_axes ) || + /* `num_instances' limit implied by limited range of name IDs */ num_instances > 0x7EFF || offset + axis_size * num_axes + instance_size * num_instances > fvar_len ) num_instances = 0; + else + face->variation_support |= TT_FACE_FLAG_VAR_FVAR; - /* we don't support Multiple Master CFFs yet */ - if ( !face->goto_table( face, TTAG_CFF, stream, 0 ) ) - num_instances = 0; + /* + * As documented in the OpenType specification, an entry for the + * default instance may be omitted in the named instance table. In + * particular this means that even if there is no named instance + * table in the font we actually do have a named instance, namely the + * default instance. + * + * For consistency, we always want the default instance in our list + * of named instances. If it is missing, we try to synthesize it + * later on. Here, we have to adjust `num_instances' accordingly. + */ - /* we support at most 2^15 - 1 instances */ - if ( num_instances >= ( 1U << 15 ) - 1 ) + if ( ( face->variation_support & TT_FACE_FLAG_VAR_FVAR ) && + !( FT_ALLOC( default_values, num_axes * 4 ) || + FT_ALLOC( instance_values, num_axes * 4 ) ) ) { - if ( face_instance_index >= 0 ) - return FT_THROW( Invalid_Argument ); - else - num_instances = 0; + /* the current stream position is 16 bytes after the table start */ + FT_ULong array_start = FT_STREAM_POS() - 16 + offset; + FT_ULong default_value_offset, instance_offset; + + FT_Byte* p; + FT_UInt i; + + + default_value_offset = array_start + 8; + p = default_values; + + for ( i = 0; i < num_axes; i++ ) + { + (void)FT_STREAM_READ_AT( default_value_offset, p, 4 ); + + default_value_offset += axis_size; + p += 4; + } + + instance_offset = array_start + axis_size * num_axes + 4; + + for ( i = 0; i < num_instances; i++ ) + { + (void)FT_STREAM_READ_AT( instance_offset, + instance_values, + num_axes * 4 ); + + if ( !ft_memcmp( default_values, instance_values, num_axes * 4 ) ) + break; + + instance_offset += instance_size; + } + + if ( i == num_instances ) + { + /* no default instance in named instance table; */ + /* we thus have to synthesize it */ + num_instances++; + } } + FT_FREE( default_values ); + FT_FREE( instance_values ); + + /* we don't support Multiple Master CFFs yet; */ + /* note that `glyf' or `CFF2' have precedence */ + if ( face->goto_table( face, TTAG_glyf, stream, 0 ) && + face->goto_table( face, TTAG_CFF2, stream, 0 ) && + !face->goto_table( face, TTAG_CFF, stream, 0 ) ) + num_instances = 0; + /* instance indices in `face_instance_index' start with index 1, */ /* thus `>' and not `>=' */ if ( instance_index > num_instances ) @@ -977,7 +1082,7 @@ #endif face->root.num_faces = face->ttc_header.count; - face->root.face_index = face_index; + face->root.face_index = face_instance_index; return error; } @@ -1039,8 +1144,8 @@ FT_Bool has_outline; FT_Bool is_apple_sbit; FT_Bool is_apple_sbix; - FT_Bool ignore_preferred_family = FALSE; - FT_Bool ignore_preferred_subfamily = FALSE; + FT_Bool ignore_typographic_family = FALSE; + FT_Bool ignore_typographic_subfamily = FALSE; SFNT_Service sfnt = (SFNT_Service)face->sfnt; @@ -1055,10 +1160,10 @@ for ( i = 0; i < num_params; i++ ) { - if ( params[i].tag == FT_PARAM_TAG_IGNORE_PREFERRED_FAMILY ) - ignore_preferred_family = TRUE; - else if ( params[i].tag == FT_PARAM_TAG_IGNORE_PREFERRED_SUBFAMILY ) - ignore_preferred_subfamily = TRUE; + if ( params[i].tag == FT_PARAM_TAG_IGNORE_TYPOGRAPHIC_FAMILY ) + ignore_typographic_family = TRUE; + else if ( params[i].tag == FT_PARAM_TAG_IGNORE_TYPOGRAPHIC_SUBFAMILY ) + ignore_typographic_subfamily = TRUE; } } @@ -1083,12 +1188,14 @@ /* do we have outlines in there? */ #ifdef FT_CONFIG_OPTION_INCREMENTAL - has_outline = FT_BOOL( face->root.internal->incremental_interface != 0 || - tt_face_lookup_table( face, TTAG_glyf ) != 0 || - tt_face_lookup_table( face, TTAG_CFF ) != 0 ); + has_outline = FT_BOOL( face->root.internal->incremental_interface || + tt_face_lookup_table( face, TTAG_glyf ) || + tt_face_lookup_table( face, TTAG_CFF ) || + tt_face_lookup_table( face, TTAG_CFF2 ) ); #else - has_outline = FT_BOOL( tt_face_lookup_table( face, TTAG_glyf ) != 0 || - tt_face_lookup_table( face, TTAG_CFF ) != 0 ); + has_outline = FT_BOOL( tt_face_lookup_table( face, TTAG_glyf ) || + tt_face_lookup_table( face, TTAG_CFF ) || + tt_face_lookup_table( face, TTAG_CFF2 ) ); #endif is_apple_sbit = 0; @@ -1220,30 +1327,10 @@ /* embedded bitmap support */ if ( sfnt->load_eblc ) - { LOAD_( eblc ); - if ( error ) - { - /* a font which contains neither bitmaps nor outlines is */ - /* still valid (although rather useless in most cases); */ - /* however, you can find such stripped fonts in PDFs */ - if ( FT_ERR_EQ( error, Table_Missing ) ) - error = FT_Err_Ok; - else - goto Exit; - } - } + /* consider the pclt, kerning, and gasp tables as optional */ LOAD_( pclt ); - if ( error ) - { - if ( FT_ERR_NEQ( error, Table_Missing ) ) - goto Exit; - - face->pclt.Version = 0; - } - - /* consider the kerning and gasp tables as optional */ LOAD_( gasp ); LOAD_( kern ); @@ -1259,27 +1346,27 @@ face->root.style_name = NULL; if ( face->os2.version != 0xFFFFU && face->os2.fsSelection & 256 ) { - if ( !ignore_preferred_family ) - GET_NAME( PREFERRED_FAMILY, &face->root.family_name ); + if ( !ignore_typographic_family ) + GET_NAME( TYPOGRAPHIC_FAMILY, &face->root.family_name ); if ( !face->root.family_name ) GET_NAME( FONT_FAMILY, &face->root.family_name ); - if ( !ignore_preferred_subfamily ) - GET_NAME( PREFERRED_SUBFAMILY, &face->root.style_name ); + if ( !ignore_typographic_subfamily ) + GET_NAME( TYPOGRAPHIC_SUBFAMILY, &face->root.style_name ); if ( !face->root.style_name ) GET_NAME( FONT_SUBFAMILY, &face->root.style_name ); } else { GET_NAME( WWS_FAMILY, &face->root.family_name ); - if ( !face->root.family_name && !ignore_preferred_family ) - GET_NAME( PREFERRED_FAMILY, &face->root.family_name ); + if ( !face->root.family_name && !ignore_typographic_family ) + GET_NAME( TYPOGRAPHIC_FAMILY, &face->root.family_name ); if ( !face->root.family_name ) GET_NAME( FONT_FAMILY, &face->root.family_name ); GET_NAME( WWS_SUBFAMILY, &face->root.style_name ); - if ( !face->root.style_name && !ignore_preferred_subfamily ) - GET_NAME( PREFERRED_SUBFAMILY, &face->root.style_name ); + if ( !face->root.style_name && !ignore_typographic_subfamily ) + GET_NAME( TYPOGRAPHIC_SUBFAMILY, &face->root.style_name ); if ( !face->root.style_name ) GET_NAME( FONT_SUBFAMILY, &face->root.style_name ); } @@ -1327,10 +1414,14 @@ #ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT /* Don't bother to load the tables unless somebody asks for them. */ /* No need to do work which will (probably) not be used. */ - if ( tt_face_lookup_table( face, TTAG_glyf ) != 0 && - tt_face_lookup_table( face, TTAG_fvar ) != 0 && - tt_face_lookup_table( face, TTAG_gvar ) != 0 ) - flags |= FT_FACE_FLAG_MULTIPLE_MASTERS; + if ( face->variation_support & TT_FACE_FLAG_VAR_FVAR ) + { + if ( tt_face_lookup_table( face, TTAG_glyf ) != 0 && + tt_face_lookup_table( face, TTAG_gvar ) != 0 ) + flags |= FT_FACE_FLAG_MULTIPLE_MASTERS; + if ( tt_face_lookup_table( face, TTAG_CFF2 ) != 0 ) + flags |= FT_FACE_FLAG_MULTIPLE_MASTERS; + } #endif root->face_flags = flags; @@ -1393,7 +1484,7 @@ charmap->encoding_id ); #if 0 - if ( root->charmap == NULL && + if ( !root->charmap && charmap->encoding == FT_ENCODING_UNICODE ) { /* set 'root->charmap' to the first Unicode encoding we find */ @@ -1411,7 +1502,7 @@ * depths in the FT_Bitmap_Size record. This is a design error. */ { - FT_UInt i, count; + FT_UInt count; count = face->sbit_num_strikes; @@ -1423,6 +1514,9 @@ FT_Short avgwidth = face->os2.xAvgCharWidth; FT_Size_Metrics metrics; + FT_UInt* sbit_strike_map = NULL; + FT_UInt strike_idx, bsize_idx; + if ( em_size == 0 || face->os2.version == 0xFFFFU ) { @@ -1430,31 +1524,50 @@ em_size = 1; } - if ( FT_NEW_ARRAY( root->available_sizes, count ) ) + /* to avoid invalid strike data in the `available_sizes' field */ + /* of `FT_Face', we map `available_sizes' indices to strike */ + /* indices */ + if ( FT_NEW_ARRAY( root->available_sizes, count ) || + FT_NEW_ARRAY( sbit_strike_map, count ) ) goto Exit; - for ( i = 0; i < count; i++ ) + bsize_idx = 0; + for ( strike_idx = 0; strike_idx < count; strike_idx++ ) { - FT_Bitmap_Size* bsize = root->available_sizes + i; + FT_Bitmap_Size* bsize = root->available_sizes + bsize_idx; - error = sfnt->load_strike_metrics( face, i, &metrics ); + error = sfnt->load_strike_metrics( face, strike_idx, &metrics ); if ( error ) - goto Exit; + continue; bsize->height = (FT_Short)( metrics.height >> 6 ); - bsize->width = (FT_Short)( - ( avgwidth * metrics.x_ppem + em_size / 2 ) / em_size ); + bsize->width = (FT_Short)( + ( avgwidth * metrics.x_ppem + em_size / 2 ) / em_size ); bsize->x_ppem = metrics.x_ppem << 6; bsize->y_ppem = metrics.y_ppem << 6; /* assume 72dpi */ bsize->size = metrics.y_ppem << 6; + + /* only use strikes with valid PPEM values */ + if ( bsize->x_ppem && bsize->y_ppem ) + sbit_strike_map[bsize_idx++] = strike_idx; } - root->face_flags |= FT_FACE_FLAG_FIXED_SIZES; - root->num_fixed_sizes = (FT_Int)count; + /* reduce array size to the actually used elements */ + (void)FT_RENEW_ARRAY( sbit_strike_map, count, bsize_idx ); + + /* from now on, all strike indices are mapped */ + /* using `sbit_strike_map' */ + if ( bsize_idx ) + { + face->sbit_strike_map = sbit_strike_map; + + root->face_flags |= FT_FACE_FLAG_FIXED_SIZES; + root->num_fixed_sizes = (FT_Int)bsize_idx; + } } } @@ -1615,18 +1728,10 @@ face->cmap_size = 0; } - /* freeing the horizontal metrics */ - { - FT_Stream stream = FT_FACE_STREAM( face ); - + face->horz_metrics_size = 0; + face->vert_metrics_size = 0; - FT_FRAME_RELEASE( face->horz_metrics ); - FT_FRAME_RELEASE( face->vert_metrics ); - face->horz_metrics_size = 0; - face->vert_metrics_size = 0; - } - - /* freeing the vertical ones, if any */ + /* freeing vertical metrics, if any */ if ( face->vertical_info ) { FT_FREE( face->vertical.long_metrics ); @@ -1648,9 +1753,13 @@ /* freeing sbit size table */ FT_FREE( face->root.available_sizes ); + FT_FREE( face->sbit_strike_map ); face->root.num_fixed_sizes = 0; +#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT FT_FREE( face->postscript_name ); + FT_FREE( face->var_postscript_prefix ); +#endif face->sfnt = NULL; } diff --git a/thirdparty/freetype/src/sfnt/sfobjs.h b/thirdparty/freetype/src/sfnt/sfobjs.h index 60b5698edd..705381459a 100644 --- a/thirdparty/freetype/src/sfnt/sfobjs.h +++ b/thirdparty/freetype/src/sfnt/sfobjs.h @@ -4,7 +4,7 @@ /* */ /* SFNT object management (specification). */ /* */ -/* Copyright 1996-2016 by */ +/* Copyright 1996-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/thirdparty/freetype/src/sfnt/ttbdf.c b/thirdparty/freetype/src/sfnt/ttbdf.c index f891691118..2196e3791e 100644 --- a/thirdparty/freetype/src/sfnt/ttbdf.c +++ b/thirdparty/freetype/src/sfnt/ttbdf.c @@ -4,7 +4,7 @@ /* */ /* TrueType and OpenType embedded BDF properties (body). */ /* */ -/* Copyright 2005-2016 by */ +/* Copyright 2005-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -48,7 +48,7 @@ FT_Stream stream = FT_FACE(face)->stream; - if ( bdf->table != NULL ) + if ( bdf->table ) FT_FRAME_RELEASE( bdf->table ); bdf->table_end = NULL; @@ -165,7 +165,7 @@ error = FT_ERR( Invalid_Argument ); - if ( size == NULL || property_name == NULL ) + if ( !size || !property_name ) goto Exit; property_len = ft_strlen( property_name ); @@ -177,6 +177,7 @@ FT_UInt _ppem = FT_NEXT_USHORT( p ); FT_UInt _count = FT_NEXT_USHORT( p ); + if ( _ppem == size->metrics.y_ppem ) { count = _count; @@ -193,6 +194,7 @@ { FT_UInt type = FT_PEEK_USHORT( p + 4 ); + if ( ( type & 0x10 ) != 0 ) { FT_UInt32 name_offset = FT_PEEK_ULONG( p ); @@ -244,7 +246,12 @@ return error; } -#endif /* TT_CONFIG_OPTION_BDF */ +#else /* !TT_CONFIG_OPTION_BDF */ + + /* ANSI C doesn't like empty source files */ + typedef int _tt_bdf_dummy; + +#endif /* !TT_CONFIG_OPTION_BDF */ /* END */ diff --git a/thirdparty/freetype/src/sfnt/ttbdf.h b/thirdparty/freetype/src/sfnt/ttbdf.h index ae521c60b6..398b620600 100644 --- a/thirdparty/freetype/src/sfnt/ttbdf.h +++ b/thirdparty/freetype/src/sfnt/ttbdf.h @@ -4,7 +4,7 @@ /* */ /* TrueType and OpenType embedded BDF properties (specification). */ /* */ -/* Copyright 2005-2016 by */ +/* Copyright 2005-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/thirdparty/freetype/src/sfnt/ttcmap.c b/thirdparty/freetype/src/sfnt/ttcmap.c index 01255a887e..5afa6ae4b7 100644 --- a/thirdparty/freetype/src/sfnt/ttcmap.c +++ b/thirdparty/freetype/src/sfnt/ttcmap.c @@ -4,7 +4,7 @@ /* */ /* TrueType character mapping table (cmap) support (body). */ /* */ -/* Copyright 2002-2016 by */ +/* Copyright 2002-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -180,22 +180,24 @@ FT_DEFINE_TT_CMAP( tt_cmap0_class_rec, - sizeof ( TT_CMapRec ), - (FT_CMap_InitFunc) tt_cmap_init, - (FT_CMap_DoneFunc) NULL, - (FT_CMap_CharIndexFunc)tt_cmap0_char_index, - (FT_CMap_CharNextFunc) tt_cmap0_char_next, + sizeof ( TT_CMapRec ), - NULL, - NULL, - NULL, - NULL, - NULL, + (FT_CMap_InitFunc) tt_cmap_init, /* init */ + (FT_CMap_DoneFunc) NULL, /* done */ + (FT_CMap_CharIndexFunc)tt_cmap0_char_index, /* char_index */ + (FT_CMap_CharNextFunc) tt_cmap0_char_next, /* char_next */ + + (FT_CMap_CharVarIndexFunc) NULL, /* char_var_index */ + (FT_CMap_CharVarIsDefaultFunc)NULL, /* char_var_default */ + (FT_CMap_VariantListFunc) NULL, /* variant_list */ + (FT_CMap_CharVariantListFunc) NULL, /* charvariant_list */ + (FT_CMap_VariantCharListFunc) NULL, /* variantchar_list */ 0, - (TT_CMap_ValidateFunc)tt_cmap0_validate, - (TT_CMap_Info_GetFunc)tt_cmap0_get_info ) + (TT_CMap_ValidateFunc)tt_cmap0_validate, /* validate */ + (TT_CMap_Info_GetFunc)tt_cmap0_get_info /* get_cmap_info */ + ) #endif /* TT_CONFIG_CMAP_FORMAT_0 */ @@ -571,22 +573,24 @@ FT_DEFINE_TT_CMAP( tt_cmap2_class_rec, - sizeof ( TT_CMapRec ), - (FT_CMap_InitFunc) tt_cmap_init, - (FT_CMap_DoneFunc) NULL, - (FT_CMap_CharIndexFunc)tt_cmap2_char_index, - (FT_CMap_CharNextFunc) tt_cmap2_char_next, + sizeof ( TT_CMapRec ), - NULL, - NULL, - NULL, - NULL, - NULL, + (FT_CMap_InitFunc) tt_cmap_init, /* init */ + (FT_CMap_DoneFunc) NULL, /* done */ + (FT_CMap_CharIndexFunc)tt_cmap2_char_index, /* char_index */ + (FT_CMap_CharNextFunc) tt_cmap2_char_next, /* char_next */ + + (FT_CMap_CharVarIndexFunc) NULL, /* char_var_index */ + (FT_CMap_CharVarIsDefaultFunc)NULL, /* char_var_default */ + (FT_CMap_VariantListFunc) NULL, /* variant_list */ + (FT_CMap_CharVariantListFunc) NULL, /* charvariant_list */ + (FT_CMap_VariantCharListFunc) NULL, /* variantchar_list */ 2, - (TT_CMap_ValidateFunc)tt_cmap2_validate, - (TT_CMap_Info_GetFunc)tt_cmap2_get_info ) + (TT_CMap_ValidateFunc)tt_cmap2_validate, /* validate */ + (TT_CMap_Info_GetFunc)tt_cmap2_get_info /* get_cmap_info */ + ) #endif /* TT_CONFIG_CMAP_FORMAT_2 */ @@ -763,6 +767,9 @@ static void tt_cmap4_next( TT_CMap4 cmap ) { + TT_Face face = (TT_Face)cmap->cmap.cmap.charmap.face; + FT_Byte* limit = face->cmap_table + face->cmap_size; + FT_UInt charcode; @@ -788,15 +795,19 @@ FT_Byte* p = values + 2 * ( charcode - cmap->cur_start ); + /* if p > limit, the whole segment is invalid */ + if ( p > limit ) + goto Next_Segment; + do { FT_UInt gindex = FT_NEXT_USHORT( p ); - if ( gindex != 0 ) + if ( gindex ) { gindex = (FT_UInt)( (FT_Int)gindex + delta ) & 0xFFFFU; - if ( gindex != 0 ) + if ( gindex ) { cmap->cur_charcode = charcode; cmap->cur_gindex = gindex; @@ -812,7 +823,26 @@ FT_UInt gindex = (FT_UInt)( (FT_Int)charcode + delta ) & 0xFFFFU; - if ( gindex != 0 ) + if ( gindex >= (FT_UInt)face->root.num_glyphs ) + { + /* we have an invalid glyph index; if there is an overflow, */ + /* we can adjust `charcode', otherwise the whole segment is */ + /* invalid */ + gindex = 0; + + if ( (FT_Int)charcode + delta < 0 && + (FT_Int)end + delta >= 0 ) + charcode = (FT_UInt)( -delta ); + + else if ( (FT_Int)charcode + delta < 0x10000L && + (FT_Int)end + delta >= 0x10000L ) + charcode = (FT_UInt)( 0x10000L - delta ); + + else + goto Next_Segment; + } + + if ( gindex ) { cmap->cur_charcode = charcode; cmap->cur_gindex = gindex; @@ -822,6 +852,7 @@ } } + Next_Segment: /* we need to find another range */ if ( tt_cmap4_set_range( cmap, cmap->cur_range + 1 ) < 0 ) break; @@ -1170,6 +1201,9 @@ FT_UInt32* pcharcode, FT_Bool next ) { + TT_Face face = (TT_Face)cmap->cmap.charmap.face; + FT_Byte* limit = face->cmap_table + face->cmap_size; + FT_UInt num_segs2, start, end, offset; FT_Int delta; FT_UInt max, min, mid, num_segs; @@ -1221,10 +1255,6 @@ if ( mid >= num_segs - 1 && start == 0xFFFFU && end == 0xFFFFU ) { - TT_Face face = (TT_Face)cmap->cmap.charmap.face; - FT_Byte* limit = face->cmap_table + face->cmap_size; - - if ( offset && p + offset + 2 > limit ) { delta = 1; @@ -1347,13 +1377,40 @@ if ( offset ) { p += offset + ( charcode - start ) * 2; + + /* if p > limit, the whole segment is invalid */ + if ( next && p > limit ) + break; + gindex = TT_PEEK_USHORT( p ); - if ( gindex != 0 ) + if ( gindex ) + { gindex = (FT_UInt)( (FT_Int)gindex + delta ) & 0xFFFFU; + if ( gindex >= (FT_UInt)face->root.num_glyphs ) + gindex = 0; + } } else + { gindex = (FT_UInt)( (FT_Int)charcode + delta ) & 0xFFFFU; + if ( next && gindex >= (FT_UInt)face->root.num_glyphs ) + { + /* we have an invalid glyph index; if there is an overflow, */ + /* we can adjust `charcode', otherwise the whole segment is */ + /* invalid */ + gindex = 0; + + if ( (FT_Int)charcode + delta < 0 && + (FT_Int)end + delta >= 0 ) + charcode = (FT_UInt)( -delta ); + + else if ( (FT_Int)charcode + delta < 0x10000L && + (FT_Int)end + delta >= 0x10000L ) + charcode = (FT_UInt)( 0x10000L - delta ); + } + } + break; } } @@ -1463,21 +1520,24 @@ FT_DEFINE_TT_CMAP( tt_cmap4_class_rec, - sizeof ( TT_CMap4Rec ), - (FT_CMap_InitFunc) tt_cmap4_init, - (FT_CMap_DoneFunc) NULL, - (FT_CMap_CharIndexFunc)tt_cmap4_char_index, - (FT_CMap_CharNextFunc) tt_cmap4_char_next, - NULL, - NULL, - NULL, - NULL, - NULL, + sizeof ( TT_CMap4Rec ), + + (FT_CMap_InitFunc) tt_cmap4_init, /* init */ + (FT_CMap_DoneFunc) NULL, /* done */ + (FT_CMap_CharIndexFunc)tt_cmap4_char_index, /* char_index */ + (FT_CMap_CharNextFunc) tt_cmap4_char_next, /* char_next */ + + (FT_CMap_CharVarIndexFunc) NULL, /* char_var_index */ + (FT_CMap_CharVarIsDefaultFunc)NULL, /* char_var_default */ + (FT_CMap_VariantListFunc) NULL, /* variant_list */ + (FT_CMap_CharVariantListFunc) NULL, /* charvariant_list */ + (FT_CMap_VariantCharListFunc) NULL, /* variantchar_list */ 4, - (TT_CMap_ValidateFunc)tt_cmap4_validate, - (TT_CMap_Info_GetFunc)tt_cmap4_get_info ) + (TT_CMap_ValidateFunc)tt_cmap4_validate, /* validate */ + (TT_CMap_Info_GetFunc)tt_cmap4_get_info /* get_cmap_info */ + ) #endif /* TT_CONFIG_CMAP_FORMAT_4 */ @@ -1630,22 +1690,24 @@ FT_DEFINE_TT_CMAP( tt_cmap6_class_rec, - sizeof ( TT_CMapRec ), - (FT_CMap_InitFunc) tt_cmap_init, - (FT_CMap_DoneFunc) NULL, - (FT_CMap_CharIndexFunc)tt_cmap6_char_index, - (FT_CMap_CharNextFunc) tt_cmap6_char_next, + sizeof ( TT_CMapRec ), - NULL, - NULL, - NULL, - NULL, - NULL, + (FT_CMap_InitFunc) tt_cmap_init, /* init */ + (FT_CMap_DoneFunc) NULL, /* done */ + (FT_CMap_CharIndexFunc)tt_cmap6_char_index, /* char_index */ + (FT_CMap_CharNextFunc) tt_cmap6_char_next, /* char_next */ + + (FT_CMap_CharVarIndexFunc) NULL, /* char_var_index */ + (FT_CMap_CharVarIsDefaultFunc)NULL, /* char_var_default */ + (FT_CMap_VariantListFunc) NULL, /* variant_list */ + (FT_CMap_CharVariantListFunc) NULL, /* charvariant_list */ + (FT_CMap_VariantCharListFunc) NULL, /* variantchar_list */ 6, - (TT_CMap_ValidateFunc)tt_cmap6_validate, - (TT_CMap_Info_GetFunc)tt_cmap6_get_info ) + (TT_CMap_ValidateFunc)tt_cmap6_validate, /* validate */ + (TT_CMap_Info_GetFunc)tt_cmap6_get_info /* get_cmap_info */ + ) #endif /* TT_CONFIG_CMAP_FORMAT_6 */ @@ -1922,22 +1984,24 @@ FT_DEFINE_TT_CMAP( tt_cmap8_class_rec, - sizeof ( TT_CMapRec ), - (FT_CMap_InitFunc) tt_cmap_init, - (FT_CMap_DoneFunc) NULL, - (FT_CMap_CharIndexFunc)tt_cmap8_char_index, - (FT_CMap_CharNextFunc) tt_cmap8_char_next, + sizeof ( TT_CMapRec ), - NULL, - NULL, - NULL, - NULL, - NULL, + (FT_CMap_InitFunc) tt_cmap_init, /* init */ + (FT_CMap_DoneFunc) NULL, /* done */ + (FT_CMap_CharIndexFunc)tt_cmap8_char_index, /* char_index */ + (FT_CMap_CharNextFunc) tt_cmap8_char_next, /* char_next */ + + (FT_CMap_CharVarIndexFunc) NULL, /* char_var_index */ + (FT_CMap_CharVarIsDefaultFunc)NULL, /* char_var_default */ + (FT_CMap_VariantListFunc) NULL, /* variant_list */ + (FT_CMap_CharVariantListFunc) NULL, /* charvariant_list */ + (FT_CMap_VariantCharListFunc) NULL, /* variantchar_list */ 8, - (TT_CMap_ValidateFunc)tt_cmap8_validate, - (TT_CMap_Info_GetFunc)tt_cmap8_get_info ) + (TT_CMap_ValidateFunc)tt_cmap8_validate, /* validate */ + (TT_CMap_Info_GetFunc)tt_cmap8_get_info /* get_cmap_info */ + ) #endif /* TT_CONFIG_CMAP_FORMAT_8 */ @@ -2092,22 +2156,24 @@ FT_DEFINE_TT_CMAP( tt_cmap10_class_rec, - sizeof ( TT_CMapRec ), - (FT_CMap_InitFunc) tt_cmap_init, - (FT_CMap_DoneFunc) NULL, - (FT_CMap_CharIndexFunc)tt_cmap10_char_index, - (FT_CMap_CharNextFunc) tt_cmap10_char_next, + sizeof ( TT_CMapRec ), - NULL, - NULL, - NULL, - NULL, - NULL, + (FT_CMap_InitFunc) tt_cmap_init, /* init */ + (FT_CMap_DoneFunc) NULL, /* done */ + (FT_CMap_CharIndexFunc)tt_cmap10_char_index, /* char_index */ + (FT_CMap_CharNextFunc) tt_cmap10_char_next, /* char_next */ + + (FT_CMap_CharVarIndexFunc) NULL, /* char_var_index */ + (FT_CMap_CharVarIsDefaultFunc)NULL, /* char_var_default */ + (FT_CMap_VariantListFunc) NULL, /* variant_list */ + (FT_CMap_CharVariantListFunc) NULL, /* charvariant_list */ + (FT_CMap_VariantCharListFunc) NULL, /* variantchar_list */ 10, - (TT_CMap_ValidateFunc)tt_cmap10_validate, - (TT_CMap_Info_GetFunc)tt_cmap10_get_info ) + (TT_CMap_ValidateFunc)tt_cmap10_validate, /* validate */ + (TT_CMap_Info_GetFunc)tt_cmap10_get_info /* get_cmap_info */ + ) #endif /* TT_CONFIG_CMAP_FORMAT_10 */ @@ -2446,22 +2512,24 @@ FT_DEFINE_TT_CMAP( tt_cmap12_class_rec, - sizeof ( TT_CMap12Rec ), - (FT_CMap_InitFunc) tt_cmap12_init, - (FT_CMap_DoneFunc) NULL, - (FT_CMap_CharIndexFunc)tt_cmap12_char_index, - (FT_CMap_CharNextFunc) tt_cmap12_char_next, + sizeof ( TT_CMap12Rec ), - NULL, - NULL, - NULL, - NULL, - NULL, + (FT_CMap_InitFunc) tt_cmap12_init, /* init */ + (FT_CMap_DoneFunc) NULL, /* done */ + (FT_CMap_CharIndexFunc)tt_cmap12_char_index, /* char_index */ + (FT_CMap_CharNextFunc) tt_cmap12_char_next, /* char_next */ + + (FT_CMap_CharVarIndexFunc) NULL, /* char_var_index */ + (FT_CMap_CharVarIsDefaultFunc)NULL, /* char_var_default */ + (FT_CMap_VariantListFunc) NULL, /* variant_list */ + (FT_CMap_CharVariantListFunc) NULL, /* charvariant_list */ + (FT_CMap_VariantCharListFunc) NULL, /* variantchar_list */ 12, - (TT_CMap_ValidateFunc)tt_cmap12_validate, - (TT_CMap_Info_GetFunc)tt_cmap12_get_info ) + (TT_CMap_ValidateFunc)tt_cmap12_validate, /* validate */ + (TT_CMap_Info_GetFunc)tt_cmap12_get_info /* get_cmap_info */ + ) #endif /* TT_CONFIG_CMAP_FORMAT_12 */ @@ -2770,22 +2838,24 @@ FT_DEFINE_TT_CMAP( tt_cmap13_class_rec, - sizeof ( TT_CMap13Rec ), - (FT_CMap_InitFunc) tt_cmap13_init, - (FT_CMap_DoneFunc) NULL, - (FT_CMap_CharIndexFunc)tt_cmap13_char_index, - (FT_CMap_CharNextFunc) tt_cmap13_char_next, + sizeof ( TT_CMap13Rec ), - NULL, - NULL, - NULL, - NULL, - NULL, + (FT_CMap_InitFunc) tt_cmap13_init, /* init */ + (FT_CMap_DoneFunc) NULL, /* done */ + (FT_CMap_CharIndexFunc)tt_cmap13_char_index, /* char_index */ + (FT_CMap_CharNextFunc) tt_cmap13_char_next, /* char_next */ + + (FT_CMap_CharVarIndexFunc) NULL, /* char_var_index */ + (FT_CMap_CharVarIsDefaultFunc)NULL, /* char_var_default */ + (FT_CMap_VariantListFunc) NULL, /* variant_list */ + (FT_CMap_CharVariantListFunc) NULL, /* charvariant_list */ + (FT_CMap_VariantCharListFunc) NULL, /* variantchar_list */ 13, - (TT_CMap_ValidateFunc)tt_cmap13_validate, - (TT_CMap_Info_GetFunc)tt_cmap13_get_info ) + (TT_CMap_ValidateFunc)tt_cmap13_validate, /* validate */ + (TT_CMap_Info_GetFunc)tt_cmap13_get_info /* get_cmap_info */ + ) #endif /* TT_CONFIG_CMAP_FORMAT_13 */ @@ -2876,7 +2946,7 @@ cmap->max_results = 0; - if ( memory != NULL && cmap->results != NULL ) + if ( memory && cmap->results ) FT_FREE( cmap->results ); } @@ -2983,7 +3053,7 @@ if ( numRanges > (FT_ULong)( valid->limit - defp ) / 4 ) FT_INVALID_TOO_SHORT; - for ( i = 0; i < numRanges; ++i ) + for ( i = 0; i < numRanges; i++ ) { FT_ULong base = TT_NEXT_UINT24( defp ); FT_ULong cnt = FT_NEXT_BYTE( defp ); @@ -3016,7 +3086,7 @@ if ( numMappings > ( (FT_ULong)( valid->limit - ndp ) ) / 5 ) FT_INVALID_TOO_SHORT; - for ( i = 0; i < numMappings; ++i ) + for ( i = 0; i < numMappings; i++ ) { FT_ULong uni = TT_NEXT_UINT24( ndp ); FT_ULong gid = TT_NEXT_USHORT( ndp ); @@ -3257,7 +3327,7 @@ return NULL; result = cmap14->results; - for ( i = 0; i < count; ++i ) + for ( i = 0; i < count; i++ ) { result[i] = (FT_UInt32)TT_NEXT_UINT24( p ); p += 8; @@ -3282,7 +3352,7 @@ if ( tt_cmap14_ensure( cmap14, ( count + 1 ), memory ) ) return NULL; - for ( q = cmap14->results; count > 0; --count ) + for ( q = cmap14->results; count > 0; count-- ) { FT_UInt32 varSel = TT_NEXT_UINT24( p ); FT_ULong defOff = TT_NEXT_ULONG( p ); @@ -3341,7 +3411,7 @@ if ( tt_cmap14_ensure( cmap14, ( cnt + 1 ), memory ) ) return NULL; - for ( q = cmap14->results; numRanges > 0; --numRanges ) + for ( q = cmap14->results; numRanges > 0; numRanges-- ) { FT_UInt32 uni = (FT_UInt32)TT_NEXT_UINT24( p ); @@ -3378,7 +3448,7 @@ return NULL; ret = cmap14->results; - for ( i = 0; i < numMappings; ++i ) + for ( i = 0; i < numMappings; i++ ) { ret[i] = (FT_UInt32)TT_NEXT_UINT24( p ); p += 2; @@ -3462,10 +3532,10 @@ { if ( nuni > duni + dcnt ) { - for ( k = 0; k <= dcnt; ++k ) + for ( k = 0; k <= dcnt; k++ ) ret[i++] = duni + k; - ++di; + di++; if ( di > numRanges ) break; @@ -3479,7 +3549,7 @@ ret[i++] = nuni; /* If it is within the default range then ignore it -- */ /* that should not have happened */ - ++ni; + ni++; if ( ni > numMappings ) break; @@ -3498,7 +3568,7 @@ { ret[i++] = (FT_UInt32)TT_NEXT_UINT24( p ); p += 2; - ++ni; + ni++; } } else if ( di <= numRanges ) @@ -3506,7 +3576,7 @@ /* If we get here then we have run out of all non-default */ /* mappings. We have read one default range which we haven't */ /* stored and there may be others that need to be read. */ - for ( k = 0; k <= dcnt; ++k ) + for ( k = 0; k <= dcnt; k++ ) ret[i++] = duni + k; while ( di < numRanges ) @@ -3514,9 +3584,9 @@ duni = (FT_UInt32)TT_NEXT_UINT24( dp ); dcnt = FT_NEXT_BYTE( dp ); - for ( k = 0; k <= dcnt; ++k ) + for ( k = 0; k <= dcnt; k++ ) ret[i++] = duni + k; - ++di; + di++; } } @@ -3529,23 +3599,25 @@ FT_DEFINE_TT_CMAP( tt_cmap14_class_rec, - sizeof ( TT_CMap14Rec ), - (FT_CMap_InitFunc) tt_cmap14_init, - (FT_CMap_DoneFunc) tt_cmap14_done, - (FT_CMap_CharIndexFunc)tt_cmap14_char_index, - (FT_CMap_CharNextFunc) tt_cmap14_char_next, + sizeof ( TT_CMap14Rec ), + + (FT_CMap_InitFunc) tt_cmap14_init, /* init */ + (FT_CMap_DoneFunc) tt_cmap14_done, /* done */ + (FT_CMap_CharIndexFunc)tt_cmap14_char_index, /* char_index */ + (FT_CMap_CharNextFunc) tt_cmap14_char_next, /* char_next */ - /* Format 14 extension functions */ - (FT_CMap_CharVarIndexFunc) tt_cmap14_char_var_index, - (FT_CMap_CharVarIsDefaultFunc)tt_cmap14_char_var_isdefault, - (FT_CMap_VariantListFunc) tt_cmap14_variants, - (FT_CMap_CharVariantListFunc) tt_cmap14_char_variants, - (FT_CMap_VariantCharListFunc) tt_cmap14_variant_chars, + /* Format 14 extension functions */ + (FT_CMap_CharVarIndexFunc) tt_cmap14_char_var_index, + (FT_CMap_CharVarIsDefaultFunc)tt_cmap14_char_var_isdefault, + (FT_CMap_VariantListFunc) tt_cmap14_variants, + (FT_CMap_CharVariantListFunc) tt_cmap14_char_variants, + (FT_CMap_VariantCharListFunc) tt_cmap14_variant_chars, 14, - (TT_CMap_ValidateFunc)tt_cmap14_validate, - (TT_CMap_Info_GetFunc)tt_cmap14_get_info ) + (TT_CMap_ValidateFunc)tt_cmap14_validate, /* validate */ + (TT_CMap_Info_GetFunc)tt_cmap14_get_info /* get_cmap_info */ + ) #endif /* TT_CONFIG_CMAP_FORMAT_14 */ @@ -3684,7 +3756,7 @@ error = clazz->validate( cmap, FT_VALIDATOR( &valid ) ); } - if ( valid.validator.error == 0 ) + if ( !valid.validator.error ) { FT_CMap ttcmap; @@ -3710,7 +3782,7 @@ } } - if ( *pclazz == NULL ) + if ( !*pclazz ) { FT_TRACE0(( "tt_face_build_cmaps:" " unsupported cmap sub-table ignored\n" )); diff --git a/thirdparty/freetype/src/sfnt/ttcmap.h b/thirdparty/freetype/src/sfnt/ttcmap.h index 2273cbd961..83f12df241 100644 --- a/thirdparty/freetype/src/sfnt/ttcmap.h +++ b/thirdparty/freetype/src/sfnt/ttcmap.h @@ -4,7 +4,7 @@ /* */ /* TrueType character mapping table (cmap) support (specification). */ /* */ -/* Copyright 2002-2016 by */ +/* Copyright 2002-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/thirdparty/freetype/src/sfnt/ttcmapc.h b/thirdparty/freetype/src/sfnt/ttcmapc.h index 7c732fbd36..9a5e70825e 100644 --- a/thirdparty/freetype/src/sfnt/ttcmapc.h +++ b/thirdparty/freetype/src/sfnt/ttcmapc.h @@ -4,7 +4,7 @@ /* */ /* TT CMAP classes definitions (specification only). */ /* */ -/* Copyright 2009-2016 by */ +/* Copyright 2009-2017 by */ /* Oran Agra and Mickey Gabel. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/thirdparty/freetype/src/sfnt/ttkern.c b/thirdparty/freetype/src/sfnt/ttkern.c index 6f9fa522d5..c97e5789ac 100644 --- a/thirdparty/freetype/src/sfnt/ttkern.c +++ b/thirdparty/freetype/src/sfnt/ttkern.c @@ -5,7 +5,7 @@ /* Load the basic TrueType kerning table. This doesn't handle */ /* kerning data within the GPOS table at the moment. */ /* */ -/* Copyright 1996-2016 by */ +/* Copyright 1996-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -108,8 +108,8 @@ p_next = p_limit; /* only use horizontal kerning tables */ - if ( ( coverage & ~8U ) != 0x0001 || - p + 8 > p_limit ) + if ( ( coverage & 3U ) != 0x0001 || + p + 8 > p_next ) goto NextTable; num_pairs = FT_NEXT_USHORT( p ); @@ -214,8 +214,7 @@ if ( ( face->kern_avail_bits & mask ) == 0 ) goto NextTable; - if ( p + 8 > next ) - goto NextTable; + FT_ASSERT( p + 8 <= next ); /* tested in tt_face_load_kern */ num_pairs = FT_NEXT_USHORT( p ); p += 6; diff --git a/thirdparty/freetype/src/sfnt/ttkern.h b/thirdparty/freetype/src/sfnt/ttkern.h index 85dd5c31ae..db1a30bdb0 100644 --- a/thirdparty/freetype/src/sfnt/ttkern.h +++ b/thirdparty/freetype/src/sfnt/ttkern.h @@ -5,7 +5,7 @@ /* Load the basic TrueType kerning table. This doesn't handle */ /* kerning data within the GPOS table at the moment. */ /* */ -/* Copyright 1996-2016 by */ +/* Copyright 1996-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/thirdparty/freetype/src/sfnt/ttload.c b/thirdparty/freetype/src/sfnt/ttload.c index 2f5b2c3843..df99baa53e 100644 --- a/thirdparty/freetype/src/sfnt/ttload.c +++ b/thirdparty/freetype/src/sfnt/ttload.c @@ -5,7 +5,7 @@ /* Load the basic TrueType tables, i.e., tables that can be either in */ /* TTF or OTF fonts (body). */ /* */ -/* Copyright 1996-2016 by */ +/* Copyright 1996-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -679,7 +679,7 @@ /*************************************************************************/ /* */ /* <Function> */ - /* tt_face_load_max_profile */ + /* tt_face_load_maxp */ /* */ /* <Description> */ /* Loads the maximum profile into a face object. */ @@ -775,15 +775,6 @@ maxProfile->maxTwilightPoints = 0xFFFFU - 4; } - - /* we arbitrarily limit recursion to avoid stack exhaustion */ - if ( maxProfile->maxComponentDepth > 100 ) - { - FT_TRACE0(( "tt_face_load_maxp:" - " abnormally large component depth (%d) set to 100\n", - maxProfile->maxComponentDepth )); - maxProfile->maxComponentDepth = 100; - } } FT_TRACE3(( "numGlyphs: %u\n", maxProfile->numGlyphs )); @@ -817,7 +808,6 @@ FT_Memory memory = stream->memory; FT_ULong table_pos, table_len; FT_ULong storage_start, storage_limit; - FT_UInt count; TT_NameTable table; static const FT_Frame_Field name_table_fields[] = @@ -835,7 +825,7 @@ static const FT_Frame_Field name_record_fields[] = { #undef FT_STRUCTURE -#define FT_STRUCTURE TT_NameEntryRec +#define FT_STRUCTURE TT_NameRec /* no FT_FRAME_START */ FT_FRAME_USHORT( platformID ), @@ -847,6 +837,17 @@ FT_FRAME_END }; + static const FT_Frame_Field langTag_record_fields[] = + { +#undef FT_STRUCTURE +#define FT_STRUCTURE TT_LangTagRec + + /* no FT_FRAME_START */ + FT_FRAME_USHORT( stringLength ), + FT_FRAME_USHORT( stringOffset ), + FT_FRAME_END + }; + table = &face->name_table; table->stream = stream; @@ -857,18 +858,17 @@ table_pos = FT_STREAM_POS(); - if ( FT_STREAM_READ_FIELDS( name_table_fields, table ) ) goto Exit; - /* Some popular Asian fonts have an invalid `storageOffset' value */ - /* (it should be at least "6 + 12*num_names"). However, the string */ - /* offsets, computed as "storageOffset + entry->stringOffset", are */ - /* valid pointers within the name table... */ - /* */ - /* We thus can't check `storageOffset' right now. */ - /* */ - storage_start = table_pos + 6 + 12*table->numNameRecords; + /* Some popular Asian fonts have an invalid `storageOffset' value (it */ + /* should be at least `6 + 12*numNameRecords'). However, the string */ + /* offsets, computed as `storageOffset + entry->stringOffset', are */ + /* valid pointers within the name table... */ + /* */ + /* We thus can't check `storageOffset' right now. */ + /* */ + storage_start = table_pos + 6 + 12 * table->numNameRecords; storage_limit = table_pos + table_len; if ( storage_start > storage_limit ) @@ -878,18 +878,56 @@ goto Exit; } - /* Allocate the array of name records. */ - count = table->numNameRecords; - table->numNameRecords = 0; + /* `name' format 1 contains additional language tag records, */ + /* which we load first */ + if ( table->format == 1 ) + { + if ( FT_STREAM_SEEK( storage_start ) || + FT_READ_USHORT( table->numLangTagRecords ) ) + goto Exit; + + storage_start += 2 + 4 * table->numLangTagRecords; + + /* allocate language tag records array */ + if ( FT_NEW_ARRAY( table->langTags, table->numLangTagRecords ) || + FT_FRAME_ENTER( table->numLangTagRecords * 4 ) ) + goto Exit; + + /* load language tags */ + { + TT_LangTag entry = table->langTags; + TT_LangTag limit = entry + table->numLangTagRecords; + - if ( FT_NEW_ARRAY( table->names, count ) || - FT_FRAME_ENTER( count * 12 ) ) + for ( ; entry < limit; entry++ ) + { + (void)FT_STREAM_READ_FIELDS( langTag_record_fields, entry ); + + /* check that the langTag string is within the table */ + entry->stringOffset += table_pos + table->storageOffset; + if ( entry->stringOffset < storage_start || + entry->stringOffset + entry->stringLength > storage_limit ) + { + /* invalid entry; ignore it */ + entry->stringLength = 0; + } + } + } + + FT_FRAME_EXIT(); + + (void)FT_STREAM_SEEK( table_pos + 6 ); + } + + /* allocate name records array */ + if ( FT_NEW_ARRAY( table->names, table->numNameRecords ) || + FT_FRAME_ENTER( table->numNameRecords * 12 ) ) goto Exit; - /* Load the name records and determine how much storage is needed */ - /* to hold the strings themselves. */ + /* load name records */ { - TT_NameEntryRec* entry = table->names; + TT_Name entry = table->names; + FT_UInt count = table->numNameRecords; for ( ; count > 0; count-- ) @@ -906,22 +944,37 @@ if ( entry->stringOffset < storage_start || entry->stringOffset + entry->stringLength > storage_limit ) { - /* invalid entry - ignore it */ - entry->stringOffset = 0; - entry->stringLength = 0; + /* invalid entry; ignore it */ continue; } + /* assure that we have a valid language tag ID, and */ + /* that the corresponding langTag entry is valid, too */ + if ( table->format == 1 && entry->languageID >= 0x8000U ) + { + if ( entry->languageID - 0x8000U >= table->numLangTagRecords || + !table->langTags[entry->languageID - 0x8000U].stringLength ) + { + /* invalid entry; ignore it */ + continue; + } + } + entry++; } - table->numNameRecords = (FT_UInt)( entry - table->names ); + /* reduce array size to the actually used elements */ + count = (FT_UInt)( entry - table->names ); + (void)FT_RENEW_ARRAY( table->names, + table->numNameRecords, + count ); + table->numNameRecords = count; } FT_FRAME_EXIT(); /* everything went well, update face->num_names */ - face->num_names = (FT_UShort) table->numNameRecords; + face->num_names = (FT_UShort)table->numNameRecords; Exit: return error; @@ -931,7 +984,7 @@ /*************************************************************************/ /* */ /* <Function> */ - /* tt_face_free_names */ + /* tt_face_free_name */ /* */ /* <Description> */ /* Frees the name records. */ @@ -944,25 +997,36 @@ { FT_Memory memory = face->root.driver->root.memory; TT_NameTable table = &face->name_table; - TT_NameEntry entry = table->names; - FT_UInt count = table->numNameRecords; if ( table->names ) { - for ( ; count > 0; count--, entry++ ) - { + TT_Name entry = table->names; + TT_Name limit = entry + table->numNameRecords; + + + for ( ; entry < limit; entry++ ) FT_FREE( entry->string ); - entry->stringLength = 0; - } - /* free strings table */ FT_FREE( table->names ); } - table->numNameRecords = 0; - table->format = 0; - table->storageOffset = 0; + if ( table->langTags ) + { + TT_LangTag entry = table->langTags; + TT_LangTag limit = entry + table->numLangTagRecords; + + + for ( ; entry < limit; entry++ ) + FT_FREE( entry->string ); + + FT_FREE( table->langTags ); + } + + table->numNameRecords = 0; + table->numLangTagRecords = 0; + table->format = 0; + table->storageOffset = 0; } @@ -1193,8 +1257,8 @@ #define FT_STRUCTURE TT_Postscript FT_FRAME_START( 32 ), - FT_FRAME_ULONG( FormatType ), - FT_FRAME_ULONG( italicAngle ), + FT_FRAME_LONG ( FormatType ), + FT_FRAME_LONG ( italicAngle ), FT_FRAME_SHORT( underlinePosition ), FT_FRAME_SHORT( underlineThickness ), FT_FRAME_ULONG( isFixedPitch ), diff --git a/thirdparty/freetype/src/sfnt/ttload.h b/thirdparty/freetype/src/sfnt/ttload.h index bec42b94b4..296da86ed3 100644 --- a/thirdparty/freetype/src/sfnt/ttload.h +++ b/thirdparty/freetype/src/sfnt/ttload.h @@ -5,7 +5,7 @@ /* Load the basic TrueType tables, i.e., tables that can be either in */ /* TTF or OTF fonts (specification). */ /* */ -/* Copyright 1996-2016 by */ +/* Copyright 1996-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/thirdparty/freetype/src/sfnt/ttmtx.c b/thirdparty/freetype/src/sfnt/ttmtx.c index 186f873dae..394c6db85c 100644 --- a/thirdparty/freetype/src/sfnt/ttmtx.c +++ b/thirdparty/freetype/src/sfnt/ttmtx.c @@ -4,7 +4,7 @@ /* */ /* Load the metrics tables common to TTF and OTF fonts (body). */ /* */ -/* Copyright 2006-2016 by */ +/* Copyright 2006-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -20,11 +20,24 @@ #include FT_INTERNAL_DEBUG_H #include FT_INTERNAL_STREAM_H #include FT_TRUETYPE_TAGS_H + +#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT +#include FT_SERVICE_METRICS_VARIATIONS_H +#endif + #include "ttmtx.h" #include "sferrors.h" + /* IMPORTANT: The TT_HoriHeader and TT_VertHeader structures should */ + /* be identical except for the names of their fields, */ + /* which are different. */ + /* */ + /* This ensures that `tt_face_load_hmtx' is able to read */ + /* both the horizontal and vertical headers. */ + + /*************************************************************************/ /* */ /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ @@ -214,6 +227,11 @@ FT_ULong table_pos, table_size, table_end; FT_UShort k; +#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT + FT_Service_MetricsVariations var = + (FT_Service_MetricsVariations)face->var; +#endif + if ( vertical ) { @@ -274,6 +292,34 @@ *abearing = 0; *aadvance = 0; } + +#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT + if ( var ) + { + FT_Face f = FT_FACE( face ); + FT_Int a = (FT_Int)*aadvance; + FT_Int b = (FT_Int)*abearing; + + + if ( vertical ) + { + if ( var->vadvance_adjust ) + var->vadvance_adjust( f, gindex, &a ); + if ( var->tsb_adjust ) + var->tsb_adjust( f, gindex, &b ); + } + else + { + if ( var->hadvance_adjust ) + var->hadvance_adjust( f, gindex, &a ); + if ( var->lsb_adjust ) + var->lsb_adjust( f, gindex, &b ); + } + + *aadvance = (FT_UShort)a; + *abearing = (FT_Short)b; + } +#endif } diff --git a/thirdparty/freetype/src/sfnt/ttmtx.h b/thirdparty/freetype/src/sfnt/ttmtx.h index 78395def33..2b93ab2f0e 100644 --- a/thirdparty/freetype/src/sfnt/ttmtx.h +++ b/thirdparty/freetype/src/sfnt/ttmtx.h @@ -4,7 +4,7 @@ /* */ /* Load the metrics tables common to TTF and OTF fonts (specification). */ /* */ -/* Copyright 2006-2016 by */ +/* Copyright 2006-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/thirdparty/freetype/src/sfnt/ttpost.c b/thirdparty/freetype/src/sfnt/ttpost.c index 3277f1ec4f..540d5f2546 100644 --- a/thirdparty/freetype/src/sfnt/ttpost.c +++ b/thirdparty/freetype/src/sfnt/ttpost.c @@ -5,7 +5,7 @@ /* PostScript name table processing for TrueType and OpenType fonts */ /* (body). */ /* */ -/* Copyright 1996-2016 by */ +/* Copyright 1996-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -29,6 +29,10 @@ #include FT_INTERNAL_DEBUG_H #include FT_INTERNAL_STREAM_H #include FT_TRUETYPE_TAGS_H + + +#ifdef TT_CONFIG_OPTION_POSTSCRIPT_NAMES + #include "ttpost.h" #include "sferrors.h" @@ -326,7 +330,9 @@ goto Exit; /* check the number of glyphs */ - if ( num_glyphs > face->max_profile.numGlyphs || num_glyphs > 258 ) + if ( num_glyphs > face->max_profile.numGlyphs || + num_glyphs > 258 || + num_glyphs < 1 ) { error = FT_THROW( Invalid_File_Format ); goto Exit; @@ -559,5 +565,12 @@ return FT_Err_Ok; } +#else /* !TT_CONFIG_OPTION_POSTSCRIPT_NAMES */ + + /* ANSI C doesn't like empty source files */ + typedef int _tt_post_dummy; + +#endif /* !TT_CONFIG_OPTION_POSTSCRIPT_NAMES */ + /* END */ diff --git a/thirdparty/freetype/src/sfnt/ttpost.h b/thirdparty/freetype/src/sfnt/ttpost.h index ede45fd84c..722485e32d 100644 --- a/thirdparty/freetype/src/sfnt/ttpost.h +++ b/thirdparty/freetype/src/sfnt/ttpost.h @@ -5,7 +5,7 @@ /* PostScript name table processing for TrueType and OpenType fonts */ /* (specification). */ /* */ -/* Copyright 1996-2016 by */ +/* Copyright 1996-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/thirdparty/freetype/src/sfnt/ttsbit.c b/thirdparty/freetype/src/sfnt/ttsbit.c index e24e7d6cdd..0c76a55779 100644 --- a/thirdparty/freetype/src/sfnt/ttsbit.c +++ b/thirdparty/freetype/src/sfnt/ttsbit.c @@ -4,7 +4,7 @@ /* */ /* TrueType and OpenType embedded bitmap support (body). */ /* */ -/* Copyright 2005-2016 by */ +/* Copyright 2005-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* Copyright 2013 by Google, Inc. */ @@ -24,6 +24,10 @@ #include FT_INTERNAL_STREAM_H #include FT_TRUETYPE_TAGS_H #include FT_BITMAP_H + + +#ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS + #include "ttsbit.h" #include "sferrors.h" @@ -48,6 +52,7 @@ { FT_Error error; FT_ULong table_size; + FT_ULong table_start; face->sbit_table = NULL; @@ -83,6 +88,8 @@ goto Exit; } + table_start = FT_STREAM_POS(); + switch ( (FT_UInt)face->sbit_table_type ) { case TT_SBIT_TABLE_TYPE_EBLC: @@ -104,8 +111,12 @@ version = FT_NEXT_LONG( p ); num_strikes = FT_NEXT_ULONG( p ); + /* there's at least one font (FZShuSong-Z01, version 3) */ + /* that uses the wrong byte order for the `version' field */ if ( ( (FT_ULong)version & 0xFFFF0000UL ) != 0x00020000UL && - ( (FT_ULong)version & 0xFFFF0000UL ) != 0x00030000UL ) + ( (FT_ULong)version & 0x0000FFFFUL ) != 0x00000200UL && + ( (FT_ULong)version & 0xFFFF0000UL ) != 0x00030000UL && + ( (FT_ULong)version & 0x0000FFFFUL ) != 0x00000300UL ) { error = FT_THROW( Unknown_File_Format ); goto Exit; @@ -190,12 +201,51 @@ break; default: + /* we ignore unknown table formats */ error = FT_THROW( Unknown_File_Format ); break; } if ( !error ) - FT_TRACE3(( "sbit_num_strikes: %u\n", face->sbit_num_strikes )); + FT_TRACE3(( "tt_face_load_sbit_strikes: found %u strikes\n", + face->sbit_num_strikes )); + + face->ebdt_start = 0; + face->ebdt_size = 0; + + if ( face->sbit_table_type == TT_SBIT_TABLE_TYPE_SBIX ) + { + /* the `sbix' table is self-contained; */ + /* it has no associated data table */ + face->ebdt_start = table_start; + face->ebdt_size = table_size; + } + else if ( face->sbit_table_type != TT_SBIT_TABLE_TYPE_NONE ) + { + FT_ULong ebdt_size; + + + error = face->goto_table( face, TTAG_CBDT, stream, &ebdt_size ); + if ( error ) + error = face->goto_table( face, TTAG_EBDT, stream, &ebdt_size ); + if ( error ) + error = face->goto_table( face, TTAG_bdat, stream, &ebdt_size ); + + if ( !error ) + { + face->ebdt_start = FT_STREAM_POS(); + face->ebdt_size = ebdt_size; + } + } + + if ( !face->ebdt_size ) + { + FT_TRACE2(( "tt_face_load_sbit_strikes:" + " no embedded bitmap data table found;\n" + " " + " resetting number of strikes to zero\n" )); + face->sbit_num_strikes = 0; + } return FT_Err_Ok; @@ -239,8 +289,22 @@ FT_ULong strike_index, FT_Size_Metrics* metrics ) { - if ( strike_index >= (FT_ULong)face->sbit_num_strikes ) - return FT_THROW( Invalid_Argument ); + /* we have to test for the existence of `sbit_strike_map' */ + /* because the function gets also used at the very beginning */ + /* to construct `sbit_strike_map' itself */ + if ( face->sbit_strike_map ) + { + if ( strike_index >= (FT_ULong)face->root.num_fixed_sizes ) + return FT_THROW( Invalid_Argument ); + + /* map to real index */ + strike_index = face->sbit_strike_map[strike_index]; + } + else + { + if ( strike_index >= (FT_ULong)face->sbit_num_strikes ) + return FT_THROW( Invalid_Argument ); + } switch ( (FT_UInt)face->sbit_table_type ) { @@ -284,7 +348,8 @@ FT_TRACE2(( "tt_face_load_strike_metrics:" " sanitizing invalid ascender and descender\n" " " - " values for strike (%d, %d)\n", + " values for strike %d (%dppem, %dppem)\n", + strike_index, metrics->x_ppem, metrics->y_ppem )); /* sanitize buggy ascender and descender values */ @@ -323,6 +388,16 @@ strike[18] + /* max_width */ (FT_Char)strike[23] /* min_advance_SB */ ) * 64; + + /* set the scale values (in 16.16 units) so advances */ + /* from the hmtx and vmtx table are scaled correctly */ + metrics->x_scale = FT_MulDiv( metrics->x_ppem, + 64 * 0x10000, + face->header.Units_Per_EM ); + metrics->y_scale = FT_MulDiv( metrics->y_ppem, + 64 * 0x10000, + face->header.Units_Per_EM ); + return FT_Err_Ok; } @@ -332,7 +407,6 @@ FT_UInt offset; FT_UShort upem, ppem, resolution; TT_HoriHeader *hori; - FT_ULong table_size; FT_Pos ppem_; /* to reduce casts */ FT_Error error; @@ -342,15 +416,11 @@ p = face->sbit_table + 8 + 4 * strike_index; offset = FT_NEXT_ULONG( p ); - error = face->goto_table( face, TTAG_sbix, stream, &table_size ); - if ( error ) - return error; - - if ( offset + 4 > table_size ) + if ( offset + 4 > face->ebdt_size ) return FT_THROW( Invalid_File_Format ); - if ( FT_STREAM_SEEK( FT_STREAM_POS() + offset ) || - FT_FRAME_ENTER( 4 ) ) + if ( FT_STREAM_SEEK( face->ebdt_start + offset ) || + FT_FRAME_ENTER( 4 ) ) return error; ppem = FT_GET_USHORT(); @@ -414,17 +484,15 @@ FT_ULong strike_index, TT_SBit_MetricsRec* metrics ) { - FT_Error error; + FT_Error error = FT_ERR( Table_Missing ); FT_Stream stream = face->root.stream; - FT_ULong ebdt_size; - error = face->goto_table( face, TTAG_CBDT, stream, &ebdt_size ); - if ( error ) - error = face->goto_table( face, TTAG_EBDT, stream, &ebdt_size ); - if ( error ) - error = face->goto_table( face, TTAG_bdat, stream, &ebdt_size ); - if ( error ) + strike_index = face->sbit_strike_map[strike_index]; + + if ( !face->ebdt_size ) + goto Exit; + if ( FT_STREAM_SEEK( face->ebdt_start ) ) goto Exit; decoder->face = face; @@ -435,8 +503,8 @@ decoder->metrics_loaded = 0; decoder->bitmap_allocated = 0; - decoder->ebdt_start = FT_STREAM_POS(); - decoder->ebdt_size = ebdt_size; + decoder->ebdt_start = face->ebdt_start; + decoder->ebdt_size = face->ebdt_size; decoder->eblc_base = face->sbit_table; decoder->eblc_limit = face->sbit_table + face->sbit_table_size; @@ -481,7 +549,8 @@ static FT_Error - tt_sbit_decoder_alloc_bitmap( TT_SBitDecoder decoder ) + tt_sbit_decoder_alloc_bitmap( TT_SBitDecoder decoder, + FT_Bool metrics_only ) { FT_Error error = FT_Err_Ok; FT_UInt width, height; @@ -544,6 +613,9 @@ if ( size == 0 ) goto Exit; /* exit successfully! */ + if ( metrics_only ) + goto Exit; /* only metrics are requested */ + error = ft_glyphslot_alloc_bitmap( decoder->face->root.glyph, size ); if ( error ) goto Exit; @@ -610,7 +682,8 @@ FT_UInt glyph_index, FT_Int x_pos, FT_Int y_pos, - FT_UInt recurse_count ); + FT_UInt recurse_count, + FT_Bool metrics_only ); typedef FT_Error (*TT_SBitDecoder_LoadFunc)( TT_SBitDecoder decoder, @@ -854,7 +927,7 @@ } *pwrite++ |= ( ( rval >> nbits ) & 0xFF ) & - ( ~( 0xFF << w ) << ( 8 - w - x_pos ) ); + ( ~( 0xFFU << w ) << ( 8 - w - x_pos ) ); rval <<= 8; w = line_bits - w; @@ -940,7 +1013,9 @@ gindex, x_pos + dx, y_pos + dy, - recurse_count + 1 ); + recurse_count + 1, + /* request full bitmap image */ + FALSE ); if ( error ) break; } @@ -1004,6 +1079,7 @@ decoder->stream->memory, p, png_len, + FALSE, FALSE ); Exit: @@ -1022,7 +1098,8 @@ FT_ULong glyph_size, FT_Int x_pos, FT_Int y_pos, - FT_UInt recurse_count ) + FT_UInt recurse_count, + FT_Bool metrics_only ) { FT_Error error; FT_Stream stream = decoder->stream; @@ -1144,11 +1221,15 @@ if ( !decoder->bitmap_allocated ) { - error = tt_sbit_decoder_alloc_bitmap( decoder ); + error = tt_sbit_decoder_alloc_bitmap( decoder, metrics_only ); + if ( error ) goto Fail; } + if ( metrics_only ) + goto Fail; /* this is not an error */ + error = loader( decoder, p, p_limit, x_pos, y_pos, recurse_count ); } @@ -1165,7 +1246,8 @@ FT_UInt glyph_index, FT_Int x_pos, FT_Int y_pos, - FT_UInt recurse_count ) + FT_UInt recurse_count, + FT_Bool metrics_only ) { FT_Byte* p = decoder->eblc_base + decoder->strike_index_array; FT_Byte* p_limit = decoder->eblc_limit; @@ -1350,7 +1432,8 @@ image_end, x_pos, y_pos, - recurse_count ); + recurse_count, + metrics_only ); Failure: return FT_THROW( Invalid_Table ); @@ -1369,10 +1452,10 @@ FT_UInt glyph_index, FT_Stream stream, FT_Bitmap *map, - TT_SBit_MetricsRec *metrics ) + TT_SBit_MetricsRec *metrics, + FT_Bool metrics_only ) { - FT_UInt sbix_pos, strike_offset, glyph_start, glyph_end; - FT_ULong table_size; + FT_UInt strike_offset, glyph_start, glyph_end; FT_Int originOffsetX, originOffsetY; FT_Tag graphicType; FT_Int recurse_depth = 0; @@ -1381,7 +1464,12 @@ FT_Byte* p; FT_UNUSED( map ); +#ifndef FT_CONFIG_OPTION_USE_PNG + FT_UNUSED( metrics_only ); +#endif + + strike_index = face->sbit_strike_map[strike_index]; metrics->width = 0; metrics->height = 0; @@ -1389,21 +1477,18 @@ p = face->sbit_table + 8 + 4 * strike_index; strike_offset = FT_NEXT_ULONG( p ); - error = face->goto_table( face, TTAG_sbix, stream, &table_size ); - if ( error ) - return error; - sbix_pos = FT_STREAM_POS(); - retry: if ( glyph_index > (FT_UInt)face->root.num_glyphs ) return FT_THROW( Invalid_Argument ); - if ( strike_offset >= table_size || - table_size - strike_offset < 4 + glyph_index * 4 + 8 ) + if ( strike_offset >= face->ebdt_size || + face->ebdt_size - strike_offset < 4 + glyph_index * 4 + 8 ) return FT_THROW( Invalid_File_Format ); - if ( FT_STREAM_SEEK( sbix_pos + strike_offset + 4 + glyph_index * 4 ) || - FT_FRAME_ENTER( 8 ) ) + if ( FT_STREAM_SEEK( face->ebdt_start + + strike_offset + 4 + + glyph_index * 4 ) || + FT_FRAME_ENTER( 8 ) ) return error; glyph_start = FT_GET_ULONG(); @@ -1413,13 +1498,13 @@ if ( glyph_start == glyph_end ) return FT_THROW( Invalid_Argument ); - if ( glyph_start > glyph_end || - glyph_end - glyph_start < 8 || - table_size - strike_offset < glyph_end ) + if ( glyph_start > glyph_end || + glyph_end - glyph_start < 8 || + face->ebdt_size - strike_offset < glyph_end ) return FT_THROW( Invalid_File_Format ); - if ( FT_STREAM_SEEK( sbix_pos + strike_offset + glyph_start ) || - FT_FRAME_ENTER( glyph_end - glyph_start ) ) + if ( FT_STREAM_SEEK( face->ebdt_start + strike_offset + glyph_start ) || + FT_FRAME_ENTER( glyph_end - glyph_start ) ) return error; originOffsetX = FT_GET_SHORT(); @@ -1450,7 +1535,8 @@ stream->memory, stream->cursor, glyph_end - glyph_start - 8, - TRUE ); + TRUE, + metrics_only ); #else error = FT_THROW( Unimplemented_Feature ); #endif @@ -1510,23 +1596,27 @@ error = tt_sbit_decoder_init( decoder, face, strike_index, metrics ); if ( !error ) { - error = tt_sbit_decoder_load_image( decoder, - glyph_index, - 0, - 0, - 0 ); + error = tt_sbit_decoder_load_image( + decoder, + glyph_index, + 0, + 0, + 0, + ( load_flags & FT_LOAD_BITMAP_METRICS_ONLY ) != 0 ); tt_sbit_decoder_done( decoder ); } } break; case TT_SBIT_TABLE_TYPE_SBIX: - error = tt_face_load_sbix_image( face, - strike_index, - glyph_index, - stream, - map, - metrics ); + error = tt_face_load_sbix_image( + face, + strike_index, + glyph_index, + stream, + map, + metrics, + ( load_flags & FT_LOAD_BITMAP_METRICS_ONLY ) != 0 ); break; default: @@ -1535,9 +1625,10 @@ } /* Flatten color bitmaps if color was not requested. */ - if ( !error && - !( load_flags & FT_LOAD_COLOR ) && - map->pixel_mode == FT_PIXEL_MODE_BGRA ) + if ( !error && + !( load_flags & FT_LOAD_COLOR ) && + !( load_flags & FT_LOAD_BITMAP_METRICS_ONLY ) && + map->pixel_mode == FT_PIXEL_MODE_BGRA ) { FT_Bitmap new_map; FT_Library library = face->root.glyph->library; @@ -1563,5 +1654,12 @@ return error; } +#else /* !TT_CONFIG_OPTION_EMBEDDED_BITMAPS */ + + /* ANSI C doesn't like empty source files */ + typedef int _tt_sbit_dummy; + +#endif /* !TT_CONFIG_OPTION_EMBEDDED_BITMAPS */ + -/* EOF */ +/* END */ diff --git a/thirdparty/freetype/src/sfnt/ttsbit.h b/thirdparty/freetype/src/sfnt/ttsbit.h index d8a8167083..e859ddda45 100644 --- a/thirdparty/freetype/src/sfnt/ttsbit.h +++ b/thirdparty/freetype/src/sfnt/ttsbit.h @@ -4,7 +4,7 @@ /* */ /* TrueType and OpenType embedded bitmap support (specification). */ /* */ -/* Copyright 1996-2016 by */ +/* Copyright 1996-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/thirdparty/freetype/src/smooth/ftgrays.c b/thirdparty/freetype/src/smooth/ftgrays.c index 0bf3ac6ffb..e9a3ce7a7c 100644 --- a/thirdparty/freetype/src/smooth/ftgrays.c +++ b/thirdparty/freetype/src/smooth/ftgrays.c @@ -4,7 +4,7 @@ /* */ /* A new `perfect' anti-aliasing renderer (body). */ /* */ -/* Copyright 2000-2016 by */ +/* Copyright 2000-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -284,6 +284,10 @@ typedef ptrdiff_t FT_PtrDist; #ifndef FT_MEM_ZERO #define FT_MEM_ZERO( dest, count ) FT_MEM_SET( dest, 0, count ) +#endif + +#ifndef FT_ZERO +#define FT_ZERO( p ) FT_MEM_ZERO( p, sizeof ( *(p) ) ) #endif /* as usual, for the speed hungry :-) */ @@ -337,7 +341,8 @@ typedef ptrdiff_t FT_PtrDist; /* Compute `dividend / divisor' and return both its quotient and */ /* remainder, cast to a specific type. This macro also ensures that */ - /* the remainder is always positive. */ + /* the remainder is always positive. We use the remainder to keep */ + /* track of accumulating errors and compensate for them. */ #define FT_DIV_MOD( type, dividend, divisor, quotient, remainder ) \ FT_BEGIN_STMNT \ (quotient) = (type)( (dividend) / (divisor) ); \ @@ -371,8 +376,9 @@ typedef ptrdiff_t FT_PtrDist; /* These macros speed up repetitive divisions by replacing them */ /* with multiplications and right shifts. */ -#define FT_UDIVPREP( b ) \ - long b ## _r = (long)( FT_ULONG_MAX >> PIXEL_BITS ) / ( b ) +#define FT_UDIVPREP( c, b ) \ + long b ## _r = c ? (long)( FT_ULONG_MAX >> PIXEL_BITS ) / ( b ) \ + : 0 #define FT_UDIV( a, b ) \ ( ( (unsigned long)( a ) * (unsigned long)( b ## _r ) ) >> \ ( sizeof( long ) * FT_CHAR_BIT - PIXEL_BITS ) ) @@ -403,9 +409,12 @@ typedef ptrdiff_t FT_PtrDist; } TCell; + typedef struct TPixmap_ + { + unsigned char* origin; /* pixmap origin at the bottom-left */ + int pitch; /* pitch to go down one row */ - /* maximum number of gray spans in a call to the span callback */ -#define FT_MAX_GRAY_SPANS 32 + } TPixmap; /* maximum number of gray cells in the buffer */ #if FT_RENDER_POOL_SIZE > 2048 @@ -430,12 +439,12 @@ typedef ptrdiff_t FT_PtrDist; TCoord ex, ey; TCoord min_ex, max_ex; TCoord min_ey, max_ey; - TCoord count_ex, count_ey; TArea area; TCoord cover; int invalid; + PCell* ycells; PCell cells; FT_PtrDist max_cells; FT_PtrDist num_cells; @@ -443,16 +452,10 @@ typedef ptrdiff_t FT_PtrDist; TPos x, y; FT_Outline outline; - FT_Bitmap target; - - FT_Span gray_spans[FT_MAX_GRAY_SPANS]; - int num_gray_spans; + TPixmap target; FT_Raster_Span_Func render_span; void* render_span_data; - int span_y; - - PCell* ycells; } gray_TWorker, *gray_PWorker; @@ -482,17 +485,17 @@ typedef ptrdiff_t FT_PtrDist; static void gray_dump_cells( RAS_ARG ) { - int yindex; + int y; - for ( yindex = 0; yindex < ras.count_ey; yindex++ ) + for ( y = ras.min_ey; y < ras.max_ey; y++ ) { - PCell cell; + PCell cell = ras.ycells[y - ras.min_ey]; - printf( "%3d:", yindex ); + printf( "%3d:", y ); - for ( cell = ras.ycells[yindex]; cell != NULL; cell = cell->next ) + for ( ; cell != NULL; cell = cell->next ) printf( " (%3d, c:%4d, a:%6d)", cell->x, cell->cover, cell->area ); printf( "\n" ); @@ -506,25 +509,22 @@ typedef ptrdiff_t FT_PtrDist; /* */ /* Record the current cell in the table. */ /* */ - static PCell - gray_find_cell( RAS_ARG ) + static void + gray_record_cell( RAS_ARG ) { PCell *pcell, cell; TCoord x = ras.ex; - if ( x > ras.count_ex ) - x = ras.count_ex; - - pcell = &ras.ycells[ras.ey]; + pcell = &ras.ycells[ras.ey - ras.min_ey]; for (;;) { cell = *pcell; - if ( cell == NULL || cell->x > x ) + if ( !cell || cell->x > x ) break; if ( cell->x == x ) - goto Exit; + goto Found; pcell = &cell->next; } @@ -532,30 +532,21 @@ typedef ptrdiff_t FT_PtrDist; if ( ras.num_cells >= ras.max_cells ) ft_longjmp( ras.jump_buffer, 1 ); + /* insert new cell */ cell = ras.cells + ras.num_cells++; cell->x = x; - cell->area = 0; - cell->cover = 0; + cell->area = ras.area; + cell->cover = ras.cover; cell->next = *pcell; *pcell = cell; - Exit: - return cell; - } - + return; - static void - gray_record_cell( RAS_ARG ) - { - if ( ras.area | ras.cover ) - { - PCell cell = gray_find_cell( RAS_VAR ); - - - cell->area += ras.area; - cell->cover += ras.cover; - } + Found: + /* update old cell */ + cell->area += ras.area; + cell->cover += ras.cover; } @@ -577,58 +568,23 @@ typedef ptrdiff_t FT_PtrDist; /* Note that if a cell is to the left of the clipping region, it is */ /* actually set to the (min_ex-1) horizontal position. */ - /* All cells that are on the left of the clipping region go to the */ - /* min_ex - 1 horizontal position. */ - ey -= ras.min_ey; - - if ( ex > ras.max_ex ) - ex = ras.max_ex; - - ex -= ras.min_ex; - if ( ex < 0 ) - ex = -1; - - /* are we moving to a different cell ? */ - if ( ex != ras.ex || ey != ras.ey ) - { - /* record the current one if it is valid */ - if ( !ras.invalid ) - gray_record_cell( RAS_VAR ); - - ras.area = 0; - ras.cover = 0; - ras.ex = ex; - ras.ey = ey; - } - - ras.invalid = ( (unsigned int)ey >= (unsigned int)ras.count_ey || - ex >= ras.count_ex ); - } - - - /*************************************************************************/ - /* */ - /* Start a new contour at a given cell. */ - /* */ - static void - gray_start_cell( RAS_ARG_ TCoord ex, - TCoord ey ) - { - if ( ex > ras.max_ex ) - ex = ras.max_ex; - if ( ex < ras.min_ex ) ex = ras.min_ex - 1; - ras.area = 0; - ras.cover = 0; - ras.ex = ex - ras.min_ex; - ras.ey = ey - ras.min_ey; - ras.invalid = 0; + /* record the current one if it is valid */ + if ( !ras.invalid ) + gray_record_cell( RAS_VAR ); + + ras.area = 0; + ras.cover = 0; + ras.ex = ex; + ras.ey = ey; - gray_set_cell( RAS_VAR_ ex, ey ); + ras.invalid = ( ey >= ras.max_ey || ey < ras.min_ey || + ex >= ras.max_ex ); } + #ifndef FT_LONG64 /*************************************************************************/ @@ -642,7 +598,7 @@ typedef ptrdiff_t FT_PtrDist; TPos x2, TCoord y2 ) { - TCoord ex1, ex2, fx1, fx2, first, delta, mod; + TCoord ex1, ex2, fx1, fx2, first, dy, delta, mod; TPos p, dx; int incr; @@ -657,30 +613,29 @@ typedef ptrdiff_t FT_PtrDist; return; } - fx1 = (TCoord)( x1 - SUBPIXELS( ex1 ) ); - fx2 = (TCoord)( x2 - SUBPIXELS( ex2 ) ); + fx1 = (TCoord)( x1 - SUBPIXELS( ex1 ) ); + fx2 = (TCoord)( x2 - SUBPIXELS( ex2 ) ); /* everything is located in a single cell. That is easy! */ /* */ if ( ex1 == ex2 ) - { - delta = y2 - y1; - ras.area += (TArea)(( fx1 + fx2 ) * delta); - ras.cover += delta; - return; - } + goto End; /* ok, we'll have to render a run of adjacent cells on the same */ /* scanline... */ /* */ - p = ( ONE_PIXEL - fx1 ) * ( y2 - y1 ); - first = ONE_PIXEL; - incr = 1; - dx = x2 - x1; + dx = x2 - x1; + dy = y2 - y1; - if ( dx < 0 ) + if ( dx > 0 ) { - p = fx1 * ( y2 - y1 ); + p = ( ONE_PIXEL - fx1 ) * dy; + first = ONE_PIXEL; + incr = 1; + } + else + { + p = fx1 * dy; first = 0; incr = -1; dx = -dx; @@ -688,34 +643,31 @@ typedef ptrdiff_t FT_PtrDist; FT_DIV_MOD( TCoord, p, dx, delta, mod ); - ras.area += (TArea)(( fx1 + first ) * delta); + ras.area += (TArea)( ( fx1 + first ) * delta ); ras.cover += delta; - - ex1 += incr; + y1 += delta; + ex1 += incr; gray_set_cell( RAS_VAR_ ex1, ey ); - y1 += delta; if ( ex1 != ex2 ) { TCoord lift, rem; - p = ONE_PIXEL * ( y2 - y1 + delta ); + p = ONE_PIXEL * dy; FT_DIV_MOD( TCoord, p, dx, lift, rem ); - mod -= (int)dx; - do { delta = lift; mod += rem; - if ( mod >= 0 ) + if ( mod >= (TCoord)dx ) { mod -= (TCoord)dx; delta++; } - ras.area += (TArea)(ONE_PIXEL * delta); + ras.area += (TArea)( ONE_PIXEL * delta ); ras.cover += delta; y1 += delta; ex1 += incr; @@ -723,9 +675,13 @@ typedef ptrdiff_t FT_PtrDist; } while ( ex1 != ex2 ); } - delta = y2 - y1; - ras.area += (TArea)(( fx2 + ONE_PIXEL - first ) * delta); - ras.cover += delta; + fx1 = ONE_PIXEL - first; + + End: + dy = y2 - y1; + + ras.area += (TArea)( ( fx1 + fx2 ) * dy ); + ras.cover += dy; } @@ -764,8 +720,6 @@ typedef ptrdiff_t FT_PtrDist; dy = to_y - ras.y; /* vertical line - avoid calling gray_render_scanline */ - incr = 1; - if ( dx == 0 ) { TCoord ex = TRUNC( ras.x ); @@ -773,8 +727,12 @@ typedef ptrdiff_t FT_PtrDist; TArea area; - first = ONE_PIXEL; - if ( dy < 0 ) + if ( dy > 0) + { + first = ONE_PIXEL; + incr = 1; + } + else { first = 0; incr = -1; @@ -806,11 +764,13 @@ typedef ptrdiff_t FT_PtrDist; } /* ok, we have to render several scanlines */ - p = ( ONE_PIXEL - fy1 ) * dx; - first = ONE_PIXEL; - incr = 1; - - if ( dy < 0 ) + if ( dy > 0) + { + p = ( ONE_PIXEL - fy1 ) * dx; + first = ONE_PIXEL; + incr = 1; + } + else { p = fy1 * dx; first = 0; @@ -833,13 +793,12 @@ typedef ptrdiff_t FT_PtrDist; p = ONE_PIXEL * dx; FT_DIV_MOD( TCoord, p, dy, lift, rem ); - mod -= (TCoord)dy; do { delta = lift; mod += rem; - if ( mod >= 0 ) + if ( mod >= (TCoord)dy ) { mod -= (TCoord)dy; delta++; @@ -929,8 +888,8 @@ typedef ptrdiff_t FT_PtrDist; else /* any other line */ { TPos prod = dx * fy1 - dy * fx1; - FT_UDIVPREP( dx ); - FT_UDIVPREP( dy ); + FT_UDIVPREP( ex1 != ex2, dx ); + FT_UDIVPREP( ey1 != ey2, dy ); /* The fundamental value `prod' determines which side and the */ @@ -1218,15 +1177,11 @@ typedef ptrdiff_t FT_PtrDist; TPos x, y; - /* record current cell, if any */ - if ( !ras.invalid ) - gray_record_cell( RAS_VAR ); - /* start to a new position */ x = UPSCALE( to->x ); y = UPSCALE( to->y ); - gray_start_cell( RAS_VAR_ TRUNC( x ), TRUNC( y ) ); + gray_set_cell( RAS_VAR_ TRUNC( x ), TRUNC( y ) ); ras.x = x; ras.y = y; @@ -1264,80 +1219,24 @@ typedef ptrdiff_t FT_PtrDist; } - static void - gray_render_span( int y, - int count, - const FT_Span* spans, - gray_PWorker worker ) - { - unsigned char* p; - FT_Bitmap* map = &worker->target; - - - /* first of all, compute the scanline offset */ - p = (unsigned char*)map->buffer - y * map->pitch; - if ( map->pitch >= 0 ) - p += ( map->rows - 1 ) * (unsigned int)map->pitch; - - for ( ; count > 0; count--, spans++ ) - { - unsigned char coverage = spans->coverage; - - - if ( coverage ) - { - unsigned char* q = p + spans->x; - - - /* For small-spans it is faster to do it by ourselves than - * calling `memset'. This is mainly due to the cost of the - * function call. - */ - switch ( spans->len ) - { - case 7: *q++ = coverage; - case 6: *q++ = coverage; - case 5: *q++ = coverage; - case 4: *q++ = coverage; - case 3: *q++ = coverage; - case 2: *q++ = coverage; - case 1: *q = coverage; - case 0: break; - default: - FT_MEM_SET( q, coverage, spans->len ); - } - } - } - } - - static void gray_hline( RAS_ARG_ TCoord x, TCoord y, - TArea area, + TArea coverage, TCoord acount ) { - int coverage; - - - /* compute the coverage line's coverage, depending on the */ - /* outline fill rule */ - /* */ - /* the coverage percentage is area/(PIXEL_BITS*PIXEL_BITS*2) */ - /* */ - coverage = (int)( area >> ( PIXEL_BITS * 2 + 1 - 8 ) ); - /* use range 0..256 */ + /* scale the coverage from 0..(ONE_PIXEL*ONE_PIXEL*2) to 0..256 */ + coverage >>= PIXEL_BITS * 2 + 1 - 8; if ( coverage < 0 ) - coverage = -coverage; + coverage = -coverage - 1; + /* compute the line's coverage depending on the outline fill rule */ if ( ras.outline.flags & FT_OUTLINE_EVEN_ODD_FILL ) { coverage &= 511; - if ( coverage > 256 ) - coverage = 512 - coverage; - else if ( coverage == 256 ) - coverage = 255; + if ( coverage >= 256 ) + coverage = 511 - coverage; } else { @@ -1346,64 +1245,40 @@ typedef ptrdiff_t FT_PtrDist; coverage = 255; } - y += ras.min_ey; - x += ras.min_ex; - - if ( coverage ) + if ( ras.render_span ) /* for FT_RASTER_FLAG_DIRECT only */ { - FT_Span* span; - int count; - - - /* see whether we can add this span to the current list */ - count = ras.num_gray_spans; - span = ras.gray_spans + count - 1; - if ( span->coverage == coverage && - span->x + span->len == x && - ras.span_y == y && - count > 0 ) - { - span->len = (unsigned short)( span->len + acount ); - return; - } - - if ( ras.span_y != y || count >= FT_MAX_GRAY_SPANS ) - { - if ( ras.render_span && count > 0 ) - ras.render_span( ras.span_y, count, ras.gray_spans, - ras.render_span_data ); + FT_Span span; -#ifdef FT_DEBUG_LEVEL_TRACE - - if ( count > 0 ) - { - int n; + span.x = (short)x; + span.len = (unsigned short)acount; + span.coverage = (unsigned char)coverage; - FT_TRACE7(( "y = %3d ", ras.span_y )); - span = ras.gray_spans; - for ( n = 0; n < count; n++, span++ ) - FT_TRACE7(( "[%d..%d]:%02x ", - span->x, span->x + span->len - 1, span->coverage )); - FT_TRACE7(( "\n" )); - } - -#endif /* FT_DEBUG_LEVEL_TRACE */ + ras.render_span( y, 1, &span, ras.render_span_data ); + } + else + { + unsigned char* q = ras.target.origin - ras.target.pitch * y + x; + unsigned char c = (unsigned char)coverage; - ras.num_gray_spans = 0; - ras.span_y = (int)y; - span = ras.gray_spans; + /* For small-spans it is faster to do it by ourselves than + * calling `memset'. This is mainly due to the cost of the + * function call. + */ + switch ( acount ) + { + case 7: *q++ = c; + case 6: *q++ = c; + case 5: *q++ = c; + case 4: *q++ = c; + case 3: *q++ = c; + case 2: *q++ = c; + case 1: *q = c; + case 0: break; + default: + FT_MEM_SET( q, c, acount ); } - else - span++; - - /* add a gray span to the current list */ - span->x = (short)x; - span->len = (unsigned short)acount; - span->coverage = (unsigned char)coverage; - - ras.num_gray_spans++; } } @@ -1411,71 +1286,38 @@ typedef ptrdiff_t FT_PtrDist; static void gray_sweep( RAS_ARG ) { - int yindex; + int y; - if ( ras.num_cells == 0 ) - return; - - ras.num_gray_spans = 0; - ras.span_y = 0; - FT_TRACE7(( "gray_sweep: start\n" )); - for ( yindex = 0; yindex < ras.count_ey; yindex++ ) + for ( y = ras.min_ey; y < ras.max_ey; y++ ) { - PCell cell = ras.ycells[yindex]; - TCoord cover = 0; - TCoord x = 0; + PCell cell = ras.ycells[y - ras.min_ey]; + TCoord x = ras.min_ex; + TArea cover = 0; + TArea area; for ( ; cell != NULL; cell = cell->next ) { - TArea area; - - - if ( cell->x > x && cover != 0 ) - gray_hline( RAS_VAR_ x, yindex, (TArea)cover * ( ONE_PIXEL * 2 ), - cell->x - x ); + if ( cover != 0 && cell->x > x ) + gray_hline( RAS_VAR_ x, y, cover, cell->x - x ); - cover += cell->cover; - area = (TArea)cover * ( ONE_PIXEL * 2 ) - cell->area; + cover += (TArea)cell->cover * ( ONE_PIXEL * 2 ); + area = cover - cell->area; - if ( area != 0 && cell->x >= 0 ) - gray_hline( RAS_VAR_ cell->x, yindex, area, 1 ); + if ( area != 0 && cell->x >= ras.min_ex ) + gray_hline( RAS_VAR_ cell->x, y, area, 1 ); x = cell->x + 1; } if ( cover != 0 ) - gray_hline( RAS_VAR_ x, yindex, (TArea)cover * ( ONE_PIXEL * 2 ), - ras.count_ex - x ); - } - - if ( ras.render_span && ras.num_gray_spans > 0 ) - ras.render_span( ras.span_y, ras.num_gray_spans, - ras.gray_spans, ras.render_span_data ); - -#ifdef FT_DEBUG_LEVEL_TRACE - - if ( ras.num_gray_spans > 0 ) - { - FT_Span* span; - int n; - - - FT_TRACE7(( "y = %3d ", ras.span_y )); - span = ras.gray_spans; - for ( n = 0; n < ras.num_gray_spans; n++, span++ ) - FT_TRACE7(( "[%d..%d]:%02x ", - span->x, span->x + span->len - 1, span->coverage )); - FT_TRACE7(( "\n" )); + gray_hline( RAS_VAR_ x, y, cover, ras.max_ex - x ); } FT_TRACE7(( "gray_sweep: end\n" )); - -#endif /* FT_DEBUG_LEVEL_TRACE */ - } @@ -1754,7 +1596,7 @@ typedef ptrdiff_t FT_PtrDist; return 0; Exit: - FT_TRACE5(( "FT_Outline_Decompose: Error %d\n", error )); + FT_TRACE5(( "FT_Outline_Decompose: Error 0x%x\n", error )); return error; Invalid_Outline: @@ -1839,22 +1681,17 @@ typedef ptrdiff_t FT_PtrDist; #endif /* STANDALONE_ */ - typedef struct gray_TBand_ - { - TCoord min, max; - - } gray_TBand; - - FT_DEFINE_OUTLINE_FUNCS( func_interface, - (FT_Outline_MoveTo_Func) gray_move_to, - (FT_Outline_LineTo_Func) gray_line_to, - (FT_Outline_ConicTo_Func)gray_conic_to, - (FT_Outline_CubicTo_Func)gray_cubic_to, - 0, - 0 ) + (FT_Outline_MoveTo_Func) gray_move_to, /* move_to */ + (FT_Outline_LineTo_Func) gray_line_to, /* line_to */ + (FT_Outline_ConicTo_Func)gray_conic_to, /* conic_to */ + (FT_Outline_CubicTo_Func)gray_cubic_to, /* cubic_to */ + + 0, /* shift */ + 0 /* delta */ + ) static int @@ -1892,20 +1729,21 @@ typedef ptrdiff_t FT_PtrDist; static int gray_convert_glyph( RAS_ARG ) { - TCell buffer[FT_MAX_GRAY_POOL]; - TCoord band_size = FT_MAX_GRAY_POOL / 8; - int num_bands; - TCoord min, max, max_y; - gray_TBand bands[32]; /* enough to accommodate bisections */ - gray_TBand* band; + TCell buffer[FT_MAX_GRAY_POOL]; + TCoord band_size = FT_MAX_GRAY_POOL / 8; + TCoord count = ras.max_ey - ras.min_ey; + int num_bands; + TCoord min, max, max_y; + TCoord bands[32]; /* enough to accommodate bisections */ + TCoord* band; /* set up vertical bands */ - if ( ras.count_ey > band_size ) + if ( count > band_size ) { /* two divisions rounded up */ - num_bands = (int)( ( ras.count_ey + band_size - 1) / band_size ); - band_size = ( ras.count_ey + num_bands - 1 ) / num_bands; + num_bands = (int)( ( count + band_size - 1) / band_size ); + band_size = ( count + num_bands - 1 ) / num_bands; } min = ras.min_ey; @@ -1917,41 +1755,37 @@ typedef ptrdiff_t FT_PtrDist; if ( max > max_y ) max = max_y; - bands[0].min = min; - bands[0].max = max; - band = bands; + band = bands; + band[1] = min; + band[0] = max; do { - TCoord bottom, top, middle; + TCoord width = band[0] - band[1]; int error; /* memory management */ { - size_t ycount = (size_t)( band->max - band->min ); + size_t ycount = (size_t)width; size_t cell_start; cell_start = ( ycount * sizeof ( PCell ) + sizeof ( TCell ) - 1 ) / sizeof ( TCell ); - if ( FT_MAX_GRAY_POOL - cell_start < 2 ) - goto ReduceBands; - ras.cells = buffer + cell_start; ras.max_cells = (FT_PtrDist)( FT_MAX_GRAY_POOL - cell_start ); + ras.num_cells = 0; ras.ycells = (PCell*)buffer; while ( ycount ) ras.ycells[--ycount] = NULL; } - ras.num_cells = 0; ras.invalid = 1; - ras.min_ey = band->min; - ras.max_ey = band->max; - ras.count_ey = band->max - band->min; + ras.min_ey = band[1]; + ras.max_ey = band[0]; error = gray_convert_glyph_inner( RAS_VAR ); @@ -1964,25 +1798,20 @@ typedef ptrdiff_t FT_PtrDist; else if ( error != ErrRaster_Memory_Overflow ) return 1; - ReduceBands: /* render pool overflow; we will reduce the render band by half */ - bottom = band->min; - top = band->max; - middle = bottom + ( ( top - bottom ) >> 1 ); + width >>= 1; /* This is too complex for a single scanline; there must */ /* be some problems. */ - if ( middle == bottom ) + if ( width == 0 ) { FT_TRACE7(( "gray_convert_glyph: rotten glyph\n" )); return 1; } - band[1].min = bottom; - band[1].max = middle; - band[0].min = middle; - band[0].max = top; band++; + band[1] = band[0]; + band[0] += width; } while ( band >= bands ); } @@ -1994,16 +1823,22 @@ typedef ptrdiff_t FT_PtrDist; gray_raster_render( FT_Raster raster, const FT_Raster_Params* params ) { - const FT_Outline* outline = (const FT_Outline*)params->source; - const FT_Bitmap* target_map = params->target; + const FT_Outline* outline = (const FT_Outline*)params->source; + const FT_Bitmap* target_map = params->target; FT_BBox cbox, clip; +#ifndef FT_STATIC_RASTER gray_TWorker worker[1]; +#endif if ( !raster ) return FT_THROW( Invalid_Argument ); + /* this version does not support monochrome rendering */ + if ( !( params->flags & FT_RASTER_FLAG_AA ) ) + return FT_THROW( Invalid_Mode ); + if ( !outline ) return FT_THROW( Invalid_Outline ); @@ -2018,9 +1853,19 @@ typedef ptrdiff_t FT_PtrDist; outline->contours[outline->n_contours - 1] + 1 ) return FT_THROW( Invalid_Outline ); - /* if direct mode is not set, we must have a target bitmap */ - if ( !( params->flags & FT_RASTER_FLAG_DIRECT ) ) + ras.outline = *outline; + + if ( params->flags & FT_RASTER_FLAG_DIRECT ) + { + if ( !params->gray_spans ) + return 0; + + ras.render_span = (FT_Raster_Span_Func)params->gray_spans; + ras.render_span_data = params->user; + } + else { + /* if direct mode is not set, we must have a target bitmap */ if ( !target_map ) return FT_THROW( Invalid_Argument ); @@ -2030,11 +1875,18 @@ typedef ptrdiff_t FT_PtrDist; if ( !target_map->buffer ) return FT_THROW( Invalid_Argument ); - } - /* this version does not support monochrome rendering */ - if ( !( params->flags & FT_RASTER_FLAG_AA ) ) - return FT_THROW( Invalid_Mode ); + if ( target_map->pitch < 0 ) + ras.target.origin = target_map->buffer; + else + ras.target.origin = target_map->buffer + + ( target_map->rows - 1 ) * (unsigned int)target_map->pitch; + + ras.target.pitch = target_map->pitch; + + ras.render_span = (FT_Raster_Span_Func)NULL; + ras.render_span_data = NULL; + } FT_Outline_Get_CBox( outline, &cbox ); @@ -2077,23 +1929,6 @@ typedef ptrdiff_t FT_PtrDist; if ( ras.max_ex <= ras.min_ex || ras.max_ey <= ras.min_ey ) return 0; - ras.count_ex = ras.max_ex - ras.min_ex; - ras.count_ey = ras.max_ey - ras.min_ey; - - ras.outline = *outline; - - if ( params->flags & FT_RASTER_FLAG_DIRECT ) - { - ras.render_span = (FT_Raster_Span_Func)params->gray_spans; - ras.render_span_data = params->user; - } - else - { - ras.target = *target_map; - ras.render_span = (FT_Raster_Span_Func)gray_render_span; - ras.render_span_data = &ras; - } - return gray_convert_glyph( RAS_VAR ); } @@ -2113,7 +1948,7 @@ typedef ptrdiff_t FT_PtrDist; *araster = (FT_Raster)&the_raster; - FT_MEM_ZERO( &the_raster, sizeof ( the_raster ) ); + FT_ZERO( &the_raster ); return 0; } @@ -2189,11 +2024,12 @@ typedef ptrdiff_t FT_PtrDist; FT_GLYPH_FORMAT_OUTLINE, - (FT_Raster_New_Func) gray_raster_new, - (FT_Raster_Reset_Func) gray_raster_reset, - (FT_Raster_Set_Mode_Func)gray_raster_set_mode, - (FT_Raster_Render_Func) gray_raster_render, - (FT_Raster_Done_Func) gray_raster_done ) + (FT_Raster_New_Func) gray_raster_new, /* raster_new */ + (FT_Raster_Reset_Func) gray_raster_reset, /* raster_reset */ + (FT_Raster_Set_Mode_Func)gray_raster_set_mode, /* raster_set_mode */ + (FT_Raster_Render_Func) gray_raster_render, /* raster_render */ + (FT_Raster_Done_Func) gray_raster_done /* raster_done */ + ) /* END */ diff --git a/thirdparty/freetype/src/smooth/ftgrays.h b/thirdparty/freetype/src/smooth/ftgrays.h index 21c2badcaf..a5447da1a9 100644 --- a/thirdparty/freetype/src/smooth/ftgrays.h +++ b/thirdparty/freetype/src/smooth/ftgrays.h @@ -4,7 +4,7 @@ /* */ /* FreeType smooth renderer declaration */ /* */ -/* Copyright 1996-2016 by */ +/* Copyright 1996-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/thirdparty/freetype/src/smooth/ftsmerrs.h b/thirdparty/freetype/src/smooth/ftsmerrs.h index a759b91c17..a528c61832 100644 --- a/thirdparty/freetype/src/smooth/ftsmerrs.h +++ b/thirdparty/freetype/src/smooth/ftsmerrs.h @@ -4,7 +4,7 @@ /* */ /* smooth renderer error codes (specification only). */ /* */ -/* Copyright 2001-2016 by */ +/* Copyright 2001-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/thirdparty/freetype/src/smooth/ftsmooth.c b/thirdparty/freetype/src/smooth/ftsmooth.c index 79276765b1..435854e673 100644 --- a/thirdparty/freetype/src/smooth/ftsmooth.c +++ b/thirdparty/freetype/src/smooth/ftsmooth.c @@ -4,7 +4,7 @@ /* */ /* Anti-aliasing renderer interface (body). */ /* */ -/* Copyright 2000-2016 by */ +/* Copyright 2000-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -87,7 +87,7 @@ FT_GlyphSlot slot, FT_BBox* cbox ) { - FT_MEM_ZERO( cbox, sizeof ( *cbox ) ); + FT_ZERO( cbox ); if ( slot->format == render->glyph_format ) FT_Outline_Get_CBox( &slot->outline, cbox ); @@ -114,14 +114,68 @@ #ifndef FT_CONFIG_OPTION_SUBPIXEL_RENDERING FT_Pos height_org, width_org; #endif - FT_Int hmul = mode == FT_RENDER_MODE_LCD; - FT_Int vmul = mode == FT_RENDER_MODE_LCD_V; + FT_Int hmul = ( mode == FT_RENDER_MODE_LCD ); + FT_Int vmul = ( mode == FT_RENDER_MODE_LCD_V ); FT_Raster_Params params; FT_Bool have_outline_shifted = FALSE; FT_Bool have_buffer = FALSE; +#ifdef FT_CONFIG_OPTION_SUBPIXEL_RENDERING + + FT_Int lcd_extra = 0; + FT_LcdFiveTapFilter lcd_weights = { 0 }; + FT_Bool have_custom_weight = FALSE; + FT_Bitmap_LcdFilterFunc lcd_filter_func = NULL; + + + if ( slot->face ) + { + FT_Char i; + + + for ( i = 0; i < FT_LCD_FILTER_FIVE_TAPS; i++ ) + if ( slot->face->internal->lcd_weights[i] != 0 ) + { + have_custom_weight = TRUE; + break; + } + } + + /* + * The LCD filter can be set library-wide and per-face. Face overrides + * library. If the face filter weights are all zero (the default), it + * means that the library default should be used. + */ + if ( have_custom_weight ) + { + /* + * A per-font filter is set. It always uses the default 5-tap + * in-place FIR filter that needs 2 extra pixels. + */ + ft_memcpy( lcd_weights, + slot->face->internal->lcd_weights, + FT_LCD_FILTER_FIVE_TAPS ); + lcd_filter_func = ft_lcd_filter_fir; + lcd_extra = 2; + } + else + { + /* + * The face's lcd_weights is {0, 0, 0, 0, 0}, meaning `use library + * default'. If the library is set to use no LCD filtering + * (lcd_filter_func == NULL), `lcd_filter_func' here is also set to + * NULL and the tests further below pass over the filtering process. + */ + ft_memcpy( lcd_weights, + slot->library->lcd_weights, + FT_LCD_FILTER_FIVE_TAPS ); + lcd_filter_func = slot->library->lcd_filter_func; + lcd_extra = slot->library->lcd_extra; + } + +#endif /*FT_CONFIG_OPTION_SUBPIXEL_RENDERING */ /* check glyph image format */ if ( slot->format != render->glyph_format ) @@ -177,28 +231,23 @@ height *= 3; #ifdef FT_CONFIG_OPTION_SUBPIXEL_RENDERING - - if ( slot->library->lcd_filter_func ) + if ( lcd_filter_func ) { - FT_Int extra = slot->library->lcd_extra; - - if ( hmul ) { - x_shift += 64 * ( extra >> 1 ); - x_left -= extra >> 1; - width += 3 * extra; + x_shift += 64 * ( lcd_extra >> 1 ); + x_left -= lcd_extra >> 1; + width += 3 * lcd_extra; pitch = FT_PAD_CEIL( width, 4 ); } if ( vmul ) { - y_shift += 64 * ( extra >> 1 ); - y_top += extra >> 1; - height += 3 * extra; + y_shift += 64 * ( lcd_extra >> 1 ); + y_top += lcd_extra >> 1; + height += 3 * lcd_extra; } } - #endif /* @@ -299,8 +348,8 @@ if ( error ) goto Exit; - if ( slot->library->lcd_filter_func ) - slot->library->lcd_filter_func( bitmap, mode, slot->library ); + if ( lcd_filter_func ) + lcd_filter_func( bitmap, mode, lcd_weights ); #else /* !FT_CONFIG_OPTION_SUBPIXEL_RENDERING */ @@ -428,7 +477,8 @@ } - FT_DEFINE_RENDERER( ft_smooth_renderer_class, + FT_DEFINE_RENDERER( + ft_smooth_renderer_class, FT_MODULE_RENDERER, sizeof ( FT_RendererRec ), @@ -437,25 +487,25 @@ 0x10000L, 0x20000L, - 0, /* module specific interface */ + NULL, /* module specific interface */ - (FT_Module_Constructor)ft_smooth_init, - (FT_Module_Destructor) 0, - (FT_Module_Requester) 0 - , + (FT_Module_Constructor)ft_smooth_init, /* module_init */ + (FT_Module_Destructor) NULL, /* module_done */ + (FT_Module_Requester) NULL, /* get_interface */ FT_GLYPH_FORMAT_OUTLINE, - (FT_Renderer_RenderFunc) ft_smooth_render, - (FT_Renderer_TransformFunc)ft_smooth_transform, - (FT_Renderer_GetCBoxFunc) ft_smooth_get_cbox, - (FT_Renderer_SetModeFunc) ft_smooth_set_mode, + (FT_Renderer_RenderFunc) ft_smooth_render, /* render_glyph */ + (FT_Renderer_TransformFunc)ft_smooth_transform, /* transform_glyph */ + (FT_Renderer_GetCBoxFunc) ft_smooth_get_cbox, /* get_glyph_cbox */ + (FT_Renderer_SetModeFunc) ft_smooth_set_mode, /* set_mode */ - (FT_Raster_Funcs*) &FT_GRAYS_RASTER_GET + (FT_Raster_Funcs*)&FT_GRAYS_RASTER_GET /* raster_class */ ) - FT_DEFINE_RENDERER( ft_smooth_lcd_renderer_class, + FT_DEFINE_RENDERER( + ft_smooth_lcd_renderer_class, FT_MODULE_RENDERER, sizeof ( FT_RendererRec ), @@ -464,24 +514,25 @@ 0x10000L, 0x20000L, - 0, /* module specific interface */ + NULL, /* module specific interface */ - (FT_Module_Constructor)ft_smooth_init, - (FT_Module_Destructor) 0, - (FT_Module_Requester) 0 - , + (FT_Module_Constructor)ft_smooth_init, /* module_init */ + (FT_Module_Destructor) NULL, /* module_done */ + (FT_Module_Requester) NULL, /* get_interface */ FT_GLYPH_FORMAT_OUTLINE, - (FT_Renderer_RenderFunc) ft_smooth_render_lcd, - (FT_Renderer_TransformFunc)ft_smooth_transform, - (FT_Renderer_GetCBoxFunc) ft_smooth_get_cbox, - (FT_Renderer_SetModeFunc) ft_smooth_set_mode, + (FT_Renderer_RenderFunc) ft_smooth_render_lcd, /* render_glyph */ + (FT_Renderer_TransformFunc)ft_smooth_transform, /* transform_glyph */ + (FT_Renderer_GetCBoxFunc) ft_smooth_get_cbox, /* get_glyph_cbox */ + (FT_Renderer_SetModeFunc) ft_smooth_set_mode, /* set_mode */ - (FT_Raster_Funcs*) &FT_GRAYS_RASTER_GET + (FT_Raster_Funcs*)&FT_GRAYS_RASTER_GET /* raster_class */ ) - FT_DEFINE_RENDERER( ft_smooth_lcdv_renderer_class, + + FT_DEFINE_RENDERER( + ft_smooth_lcdv_renderer_class, FT_MODULE_RENDERER, sizeof ( FT_RendererRec ), @@ -490,21 +541,20 @@ 0x10000L, 0x20000L, - 0, /* module specific interface */ + NULL, /* module specific interface */ - (FT_Module_Constructor)ft_smooth_init, - (FT_Module_Destructor) 0, - (FT_Module_Requester) 0 - , + (FT_Module_Constructor)ft_smooth_init, /* module_init */ + (FT_Module_Destructor) NULL, /* module_done */ + (FT_Module_Requester) NULL, /* get_interface */ FT_GLYPH_FORMAT_OUTLINE, - (FT_Renderer_RenderFunc) ft_smooth_render_lcd_v, - (FT_Renderer_TransformFunc)ft_smooth_transform, - (FT_Renderer_GetCBoxFunc) ft_smooth_get_cbox, - (FT_Renderer_SetModeFunc) ft_smooth_set_mode, + (FT_Renderer_RenderFunc) ft_smooth_render_lcd_v, /* render_glyph */ + (FT_Renderer_TransformFunc)ft_smooth_transform, /* transform_glyph */ + (FT_Renderer_GetCBoxFunc) ft_smooth_get_cbox, /* get_glyph_cbox */ + (FT_Renderer_SetModeFunc) ft_smooth_set_mode, /* set_mode */ - (FT_Raster_Funcs*) &FT_GRAYS_RASTER_GET + (FT_Raster_Funcs*)&FT_GRAYS_RASTER_GET /* raster_class */ ) diff --git a/thirdparty/freetype/src/smooth/ftsmooth.h b/thirdparty/freetype/src/smooth/ftsmooth.h index c7c28c244c..6dfd65726c 100644 --- a/thirdparty/freetype/src/smooth/ftsmooth.h +++ b/thirdparty/freetype/src/smooth/ftsmooth.h @@ -4,7 +4,7 @@ /* */ /* Anti-aliasing renderer interface (specification). */ /* */ -/* Copyright 1996-2016 by */ +/* Copyright 1996-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -27,18 +27,11 @@ FT_BEGIN_HEADER -#ifndef FT_CONFIG_OPTION_NO_STD_RASTER - FT_DECLARE_RENDERER( ft_std_renderer_class ) -#endif - -#ifndef FT_CONFIG_OPTION_NO_SMOOTH_RASTER FT_DECLARE_RENDERER( ft_smooth_renderer_class ) FT_DECLARE_RENDERER( ft_smooth_lcd_renderer_class ) - FT_DECLARE_RENDERER( ft_smooth_lcd_v_renderer_class ) -#endif - + FT_DECLARE_RENDERER( ft_smooth_lcdv_renderer_class ) FT_END_HEADER diff --git a/thirdparty/freetype/src/smooth/ftspic.c b/thirdparty/freetype/src/smooth/ftspic.c index 6c2b2329b3..fb89be3488 100644 --- a/thirdparty/freetype/src/smooth/ftspic.c +++ b/thirdparty/freetype/src/smooth/ftspic.c @@ -4,7 +4,7 @@ /* */ /* The FreeType position independent code services for smooth module. */ /* */ -/* Copyright 2009-2016 by */ +/* Copyright 2009-2017 by */ /* Oran Agra and Mickey Gabel. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/thirdparty/freetype/src/smooth/ftspic.h b/thirdparty/freetype/src/smooth/ftspic.h index fe76152770..9ddd1c7905 100644 --- a/thirdparty/freetype/src/smooth/ftspic.h +++ b/thirdparty/freetype/src/smooth/ftspic.h @@ -4,7 +4,7 @@ /* */ /* The FreeType position independent code services for smooth module. */ /* */ -/* Copyright 2009-2016 by */ +/* Copyright 2009-2017 by */ /* Oran Agra and Mickey Gabel. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/thirdparty/freetype/src/smooth/module.mk b/thirdparty/freetype/src/smooth/module.mk index f3cb044039..804e9b1386 100644 --- a/thirdparty/freetype/src/smooth/module.mk +++ b/thirdparty/freetype/src/smooth/module.mk @@ -3,7 +3,7 @@ # -# Copyright 1996-2016 by +# Copyright 1996-2017 by # David Turner, Robert Wilhelm, and Werner Lemberg. # # This file is part of the FreeType project, and may only be used, modified, diff --git a/thirdparty/freetype/src/smooth/rules.mk b/thirdparty/freetype/src/smooth/rules.mk index 5e94f73519..dfdc9bc30f 100644 --- a/thirdparty/freetype/src/smooth/rules.mk +++ b/thirdparty/freetype/src/smooth/rules.mk @@ -3,7 +3,7 @@ # -# Copyright 1996-2016 by +# Copyright 1996-2017 by # David Turner, Robert Wilhelm, and Werner Lemberg. # # This file is part of the FreeType project, and may only be used, modified, diff --git a/thirdparty/freetype/src/smooth/smooth.c b/thirdparty/freetype/src/smooth/smooth.c index 97ca3e5995..e0460d9d46 100644 --- a/thirdparty/freetype/src/smooth/smooth.c +++ b/thirdparty/freetype/src/smooth/smooth.c @@ -4,7 +4,7 @@ /* */ /* FreeType anti-aliasing rasterer module component (body only). */ /* */ -/* Copyright 1996-2016 by */ +/* Copyright 1996-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -17,11 +17,11 @@ #define FT_MAKE_OPTION_SINGLE_OBJECT - #include <ft2build.h> -#include "ftspic.c" + #include "ftgrays.c" #include "ftsmooth.c" +#include "ftspic.c" /* END */ diff --git a/thirdparty/freetype/src/truetype/module.mk b/thirdparty/freetype/src/truetype/module.mk index 80c9832b2c..563c584e2b 100644 --- a/thirdparty/freetype/src/truetype/module.mk +++ b/thirdparty/freetype/src/truetype/module.mk @@ -3,7 +3,7 @@ # -# Copyright 1996-2016 by +# Copyright 1996-2017 by # David Turner, Robert Wilhelm, and Werner Lemberg. # # This file is part of the FreeType project, and may only be used, modified, diff --git a/thirdparty/freetype/src/truetype/rules.mk b/thirdparty/freetype/src/truetype/rules.mk index 3bf7cf770d..ad3d007455 100644 --- a/thirdparty/freetype/src/truetype/rules.mk +++ b/thirdparty/freetype/src/truetype/rules.mk @@ -3,7 +3,7 @@ # -# Copyright 1996-2016 by +# Copyright 1996-2017 by # David Turner, Robert Wilhelm, and Werner Lemberg. # # This file is part of the FreeType project, and may only be used, modified, diff --git a/thirdparty/freetype/src/truetype/truetype.c b/thirdparty/freetype/src/truetype/truetype.c index 23e2ea00a7..301b82ad1c 100644 --- a/thirdparty/freetype/src/truetype/truetype.c +++ b/thirdparty/freetype/src/truetype/truetype.c @@ -4,7 +4,7 @@ /* */ /* FreeType TrueType driver component (body only). */ /* */ -/* Copyright 1996-2016 by */ +/* Copyright 1996-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -17,22 +17,16 @@ #define FT_MAKE_OPTION_SINGLE_OBJECT - #include <ft2build.h> -#include "ttpic.c" + #include "ttdriver.c" /* driver interface */ -#include "ttpload.c" /* tables loader */ #include "ttgload.c" /* glyph loader */ -#include "ttobjs.c" /* object manager */ - -#ifdef TT_USE_BYTECODE_INTERPRETER +#include "ttgxvar.c" /* gx distortable font */ #include "ttinterp.c" +#include "ttobjs.c" /* object manager */ +#include "ttpic.c" +#include "ttpload.c" /* tables loader */ #include "ttsubpix.c" -#endif - -#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT -#include "ttgxvar.c" /* gx distortable font */ -#endif /* END */ diff --git a/thirdparty/freetype/src/truetype/ttdriver.c b/thirdparty/freetype/src/truetype/ttdriver.c index c9d4081efe..a1653b241c 100644 --- a/thirdparty/freetype/src/truetype/ttdriver.c +++ b/thirdparty/freetype/src/truetype/ttdriver.c @@ -4,7 +4,7 @@ /* */ /* TrueType font driver implementation (body). */ /* */ -/* Copyright 1996-2016 by */ +/* Copyright 1996-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -25,6 +25,7 @@ #ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT #include FT_MULTIPLE_MASTERS_H #include FT_SERVICE_MULTIPLE_MASTERS_H +#include FT_SERVICE_METRICS_VARIATIONS_H #endif #include FT_SERVICE_TRUETYPE_ENGINE_H @@ -61,26 +62,48 @@ static FT_Error tt_property_set( FT_Module module, /* TT_Driver */ const char* property_name, - const void* value ) + const void* value, + FT_Bool value_is_string ) { FT_Error error = FT_Err_Ok; TT_Driver driver = (TT_Driver)module; +#ifndef FT_CONFIG_OPTION_ENVIRONMENT_PROPERTIES + FT_UNUSED( value_is_string ); +#endif + if ( !ft_strcmp( property_name, "interpreter-version" ) ) { - FT_UInt* interpreter_version = (FT_UInt*)value; + FT_UInt interpreter_version; - if ( *interpreter_version == TT_INTERPRETER_VERSION_35 +#ifdef FT_CONFIG_OPTION_ENVIRONMENT_PROPERTIES + if ( value_is_string ) + { + const char* s = (const char*)value; + + + interpreter_version = (FT_UInt)ft_strtol( s, NULL, 10 ); + } + else +#endif + { + FT_UInt* iv = (FT_UInt*)value; + + + interpreter_version = *iv; + } + + if ( interpreter_version == TT_INTERPRETER_VERSION_35 #ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY - || *interpreter_version == TT_INTERPRETER_VERSION_38 + || interpreter_version == TT_INTERPRETER_VERSION_38 #endif #ifdef TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL - || *interpreter_version == TT_INTERPRETER_VERSION_40 + || interpreter_version == TT_INTERPRETER_VERSION_40 #endif ) - driver->interpreter_version = *interpreter_version; + driver->interpreter_version = interpreter_version; else error = FT_ERR( Unimplemented_Feature ); @@ -122,8 +145,10 @@ FT_DEFINE_SERVICE_PROPERTIESREC( tt_service_properties, + (FT_Properties_SetFunc)tt_property_set, /* set_property */ - (FT_Properties_GetFunc)tt_property_get ) /* get_property */ + (FT_Properties_GetFunc)tt_property_get /* get_property */ + ) /*************************************************************************/ @@ -199,13 +224,20 @@ FT_Fixed *advances ) { FT_UInt nn; - TT_Face face = (TT_Face) ttface; + TT_Face face = (TT_Face)ttface; /* XXX: TODO: check for sbits */ if ( flags & FT_LOAD_VERTICAL_LAYOUT ) { +#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT + /* no fast retrieval for blended MM fonts without VVAR table */ + if ( !face->is_default_instance && + !( face->variation_support & TT_FACE_FLAG_VAR_VADVANCE ) ) + return FT_THROW( Unimplemented_Feature ); +#endif + for ( nn = 0; nn < count; nn++ ) { FT_Short tsb; @@ -219,6 +251,13 @@ } else { +#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT + /* no fast retrieval for blended MM fonts without HVAR table */ + if ( !face->is_default_instance && + !( face->variation_support & TT_FACE_FLAG_VAR_HADVANCE ) ) + return FT_THROW( Unimplemented_Feature ); +#endif + for ( nn = 0; nn < count; nn++ ) { FT_Short lsb; @@ -265,15 +304,17 @@ /* use the scaled metrics, even when tt_size_reset fails */ FT_Select_Metrics( size->face, strike_index ); - tt_size_reset( ttsize ); /* ignore return value */ + tt_size_reset( ttsize, 0 ); /* ignore return value */ } else { - SFNT_Service sfnt = (SFNT_Service) ttface->sfnt; - FT_Size_Metrics* metrics = &size->metrics; + SFNT_Service sfnt = (SFNT_Service)ttface->sfnt; + FT_Size_Metrics* size_metrics = &size->metrics; - error = sfnt->load_strike_metrics( ttface, strike_index, metrics ); + error = sfnt->load_strike_metrics( ttface, + strike_index, + size_metrics ); if ( error ) ttsize->strike_index = 0xFFFFFFFFUL; } @@ -297,7 +338,7 @@ if ( FT_HAS_FIXED_SIZES( size->face ) ) { TT_Face ttface = (TT_Face)size->face; - SFNT_Service sfnt = (SFNT_Service) ttface->sfnt; + SFNT_Service sfnt = (SFNT_Service)ttface->sfnt; FT_ULong strike_index; @@ -315,8 +356,28 @@ if ( FT_IS_SCALABLE( size->face ) ) { - error = tt_size_reset( ttsize ); - ttsize->root.metrics = ttsize->metrics; + error = tt_size_reset( ttsize, 0 ); + +#ifdef TT_USE_BYTECODE_INTERPRETER + /* for the `MPS' bytecode instruction we need the point size */ + if ( !error ) + { + FT_UInt resolution = + ttsize->metrics->x_ppem > ttsize->metrics->y_ppem + ? req->horiResolution + : req->vertResolution; + + + /* if we don't have a resolution value, assume 72dpi */ + if ( req->type == FT_SIZE_REQUEST_TYPE_SCALES || + !resolution ) + resolution = 72; + + ttsize->point_size = FT_MulDiv( ttsize->ttmetrics.ppem, + 64 * 72, + resolution ); + } +#endif } return error; @@ -398,6 +459,11 @@ load_flags |= FT_LOAD_NO_HINTING; } + /* use hinted metrics only if we load a glyph with hinting */ + size->metrics = ( load_flags & FT_LOAD_NO_HINTING ) + ? &ttsize->metrics + : &size->hinted_metrics; + /* now load the glyph outline if necessary */ error = TT_Load_Glyph( size, slot, glyph_index, load_flags ); @@ -421,14 +487,38 @@ /*************************************************************************/ #ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT + FT_DEFINE_SERVICE_MULTIMASTERSREC( tt_service_gx_multi_masters, + (FT_Get_MM_Func) NULL, /* get_mm */ (FT_Set_MM_Design_Func) NULL, /* set_mm_design */ (FT_Set_MM_Blend_Func) TT_Set_MM_Blend, /* set_mm_blend */ + (FT_Get_MM_Blend_Func) TT_Get_MM_Blend, /* get_mm_blend */ (FT_Get_MM_Var_Func) TT_Get_MM_Var, /* get_mm_var */ - (FT_Set_Var_Design_Func)TT_Set_Var_Design ) /* set_var_design */ -#endif + (FT_Set_Var_Design_Func)TT_Set_Var_Design, /* set_var_design */ + (FT_Get_Var_Design_Func)TT_Get_Var_Design, /* get_var_design */ + + (FT_Get_Var_Blend_Func) tt_get_var_blend, /* get_var_blend */ + (FT_Done_Blend_Func) tt_done_blend /* done_blend */ + ) + + FT_DEFINE_SERVICE_METRICSVARIATIONSREC( + tt_service_metrics_variations, + + (FT_HAdvance_Adjust_Func)tt_hadvance_adjust, /* hadvance_adjust */ + (FT_LSB_Adjust_Func) NULL, /* lsb_adjust */ + (FT_RSB_Adjust_Func) NULL, /* rsb_adjust */ + + (FT_VAdvance_Adjust_Func)tt_vadvance_adjust, /* vadvance_adjust */ + (FT_TSB_Adjust_Func) NULL, /* tsb_adjust */ + (FT_BSB_Adjust_Func) NULL, /* bsb_adjust */ + (FT_VOrg_Adjust_Func) NULL, /* vorg_adjust */ + + (FT_Metrics_Adjust_Func) tt_apply_mvar /* metrics_adjust */ + ) + +#endif /* TT_CONFIG_OPTION_GX_VAR_SUPPORT */ static const FT_Service_TrueTypeEngineRec tt_service_truetype_engine = @@ -447,20 +537,25 @@ FT_DEFINE_SERVICE_TTGLYFREC( tt_service_truetype_glyf, - (TT_Glyf_GetLocationFunc)tt_face_get_location ) /* get_location */ + + (TT_Glyf_GetLocationFunc)tt_face_get_location /* get_location */ + ) #ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT - FT_DEFINE_SERVICEDESCREC5( + FT_DEFINE_SERVICEDESCREC6( tt_services, - FT_SERVICE_ID_FONT_FORMAT, FT_FONT_FORMAT_TRUETYPE, - FT_SERVICE_ID_MULTI_MASTERS, &TT_SERVICE_GX_MULTI_MASTERS_GET, - FT_SERVICE_ID_TRUETYPE_ENGINE, &tt_service_truetype_engine, - FT_SERVICE_ID_TT_GLYF, &TT_SERVICE_TRUETYPE_GLYF_GET, - FT_SERVICE_ID_PROPERTIES, &TT_SERVICE_PROPERTIES_GET ) + + FT_SERVICE_ID_FONT_FORMAT, FT_FONT_FORMAT_TRUETYPE, + FT_SERVICE_ID_MULTI_MASTERS, &TT_SERVICE_GX_MULTI_MASTERS_GET, + FT_SERVICE_ID_METRICS_VARIATIONS, &TT_SERVICE_METRICS_VARIATIONS_GET, + FT_SERVICE_ID_TRUETYPE_ENGINE, &tt_service_truetype_engine, + FT_SERVICE_ID_TT_GLYF, &TT_SERVICE_TRUETYPE_GLYF_GET, + FT_SERVICE_ID_PROPERTIES, &TT_SERVICE_PROPERTIES_GET ) #else FT_DEFINE_SERVICEDESCREC4( tt_services, + FT_SERVICE_ID_FONT_FORMAT, FT_FONT_FORMAT_TRUETYPE, FT_SERVICE_ID_TRUETYPE_ENGINE, &tt_service_truetype_engine, FT_SERVICE_ID_TT_GLYF, &TT_SERVICE_TRUETYPE_GLYF_GET, @@ -488,7 +583,7 @@ #endif result = ft_service_list_lookup( TT_SERVICES_GET, tt_interface ); - if ( result != NULL ) + if ( result ) return result; #ifndef FT_CONFIG_OPTION_PIC @@ -539,7 +634,7 @@ 0x10000L, /* driver version == 1.0 */ 0x20000L, /* driver requires FreeType 2.0 or above */ - 0, /* module-specific interface */ + NULL, /* module-specific interface */ tt_driver_init, /* FT_Module_Constructor module_init */ tt_driver_done, /* FT_Module_Destructor module_done */ @@ -554,12 +649,12 @@ tt_size_init, /* FT_Size_InitFunc init_size */ tt_size_done, /* FT_Size_DoneFunc done_size */ tt_slot_init, /* FT_Slot_InitFunc init_slot */ - 0, /* FT_Slot_DoneFunc done_slot */ + NULL, /* FT_Slot_DoneFunc done_slot */ tt_glyph_load, /* FT_Slot_LoadFunc load_glyph */ tt_get_kerning, /* FT_Face_GetKerningFunc get_kerning */ - 0, /* FT_Face_AttachFunc attach_file */ + NULL, /* FT_Face_AttachFunc attach_file */ tt_get_advances, /* FT_Face_GetAdvancesFunc get_advances */ tt_size_request, /* FT_Size_RequestFunc request_size */ diff --git a/thirdparty/freetype/src/truetype/ttdriver.h b/thirdparty/freetype/src/truetype/ttdriver.h index 74392bbd02..3bcba7f745 100644 --- a/thirdparty/freetype/src/truetype/ttdriver.h +++ b/thirdparty/freetype/src/truetype/ttdriver.h @@ -4,7 +4,7 @@ /* */ /* High-level TrueType driver interface (specification). */ /* */ -/* Copyright 1996-2016 by */ +/* Copyright 1996-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/thirdparty/freetype/src/truetype/tterrors.h b/thirdparty/freetype/src/truetype/tterrors.h index 895989f5fd..a49f205156 100644 --- a/thirdparty/freetype/src/truetype/tterrors.h +++ b/thirdparty/freetype/src/truetype/tterrors.h @@ -4,7 +4,7 @@ /* */ /* TrueType error codes (specification only). */ /* */ -/* Copyright 2001-2016 by */ +/* Copyright 2001-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/thirdparty/freetype/src/truetype/ttgload.c b/thirdparty/freetype/src/truetype/ttgload.c index 8be9b6ae65..b7a844a6c7 100644 --- a/thirdparty/freetype/src/truetype/ttgload.c +++ b/thirdparty/freetype/src/truetype/ttgload.c @@ -4,7 +4,7 @@ /* */ /* TrueType Glyph Loader (body). */ /* */ -/* Copyright 1996-2016 by */ +/* Copyright 1996-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -18,6 +18,7 @@ #include <ft2build.h> #include FT_INTERNAL_DEBUG_H +#include FT_CONFIG_CONFIG_H #include FT_INTERNAL_CALC_H #include FT_INTERNAL_STREAM_H #include FT_INTERNAL_SFNT_H @@ -162,7 +163,7 @@ /* This may not be the right place for this, but it works... */ /* Note that we have to unconditionally load the tweaks since */ /* it is possible that glyphs individually switch ClearType's */ - /* backwards compatibility mode on and off. */ + /* backward compatibility mode on and off. */ sph_set_tweaks( loader, glyph_index ); } #endif /* TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY */ @@ -194,39 +195,39 @@ if ( face->root.internal->incremental_interface && face->root.internal->incremental_interface->funcs->get_glyph_metrics ) { - FT_Incremental_MetricsRec metrics; + FT_Incremental_MetricsRec incr_metrics; FT_Error error; - metrics.bearing_x = loader->left_bearing; - metrics.bearing_y = 0; - metrics.advance = loader->advance; - metrics.advance_v = 0; + incr_metrics.bearing_x = loader->left_bearing; + incr_metrics.bearing_y = 0; + incr_metrics.advance = loader->advance; + incr_metrics.advance_v = 0; error = face->root.internal->incremental_interface->funcs->get_glyph_metrics( face->root.internal->incremental_interface->object, - glyph_index, FALSE, &metrics ); + glyph_index, FALSE, &incr_metrics ); if ( error ) goto Exit; - left_bearing = (FT_Short)metrics.bearing_x; - advance_width = (FT_UShort)metrics.advance; + left_bearing = (FT_Short)incr_metrics.bearing_x; + advance_width = (FT_UShort)incr_metrics.advance; #if 0 /* GWW: Do I do the same for vertical metrics? */ - metrics.bearing_x = 0; - metrics.bearing_y = loader->top_bearing; - metrics.advance = loader->vadvance; + incr_metrics.bearing_x = 0; + incr_metrics.bearing_y = loader->top_bearing; + incr_metrics.advance = loader->vadvance; error = face->root.internal->incremental_interface->funcs->get_glyph_metrics( face->root.internal->incremental_interface->object, - glyph_index, TRUE, &metrics ); + glyph_index, TRUE, &incr_metrics ); if ( error ) goto Exit; - top_bearing = (FT_Short)metrics.bearing_y; - advance_height = (FT_UShort)metrics.advance; + top_bearing = (FT_Short)incr_metrics.bearing_y; + advance_height = (FT_UShort)incr_metrics.advance; #endif /* 0 */ @@ -332,7 +333,6 @@ FT_Outline* outline; FT_UShort n_ins; FT_Int n_points; - FT_ULong tmp; FT_Byte *flag, *flag_limit; FT_Byte c, count; @@ -398,18 +398,21 @@ FT_TRACE5(( " Instructions size: %u\n", n_ins )); - /* check it */ - if ( ( limit - p ) < n_ins ) - { - FT_TRACE0(( "TT_Load_Simple_Glyph: instruction count mismatch\n" )); - error = FT_THROW( Too_Many_Hints ); - goto Fail; - } - #ifdef TT_USE_BYTECODE_INTERPRETER if ( IS_HINTED( load->load_flags ) ) { + FT_ULong tmp; + + + /* check instructions size */ + if ( ( limit - p ) < n_ins ) + { + FT_TRACE1(( "TT_Load_Simple_Glyph: instruction count mismatch\n" )); + error = FT_THROW( Too_Many_Hints ); + goto Fail; + } + /* we don't trust `maxSizeOfInstructions' in the `maxp' table */ /* and thus update the bytecode array size by ourselves */ @@ -441,7 +444,7 @@ flag = (FT_Byte*)outline->tags; flag_limit = flag + n_points; - FT_ASSERT( flag != NULL ); + FT_ASSERT( flag ); while ( flag < flag_limit ) { @@ -775,8 +778,8 @@ } else { - loader->exec->metrics.x_scale = loader->size->metrics.x_scale; - loader->exec->metrics.y_scale = loader->size->metrics.y_scale; + loader->exec->metrics.x_scale = loader->size->metrics->x_scale; + loader->exec->metrics.y_scale = loader->size->metrics->y_scale; } #endif @@ -818,11 +821,11 @@ #endif #ifdef TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL - /* Save possibly modified glyph phantom points unless in v40 backwards */ + /* Save possibly modified glyph phantom points unless in v40 backward */ /* compatibility mode, where no movement on the x axis means no reason */ /* to change bearings or advance widths. */ if ( !( driver->interpreter_version == TT_INTERPRETER_VERSION_40 && - !loader->exec->backwards_compatibility ) ) + !loader->exec->backward_compatibility ) ) { #endif loader->pp1 = zone->cur[zone->n_points - 4]; @@ -886,13 +889,23 @@ #ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT - if ( loader->face->doblend ) + if ( !loader->face->is_default_instance ) { /* Deltas apply to the unscaled data. */ error = TT_Vary_Apply_Glyph_Deltas( loader->face, loader->glyph_index, outline, (FT_UInt)n_points ); + + /* recalculate linear horizontal and vertical advances */ + /* if we don't have HVAR and VVAR, respectively */ + if ( !( loader->face->variation_support & TT_FACE_FLAG_VAR_HADVANCE ) ) + loader->linear = outline->points[n_points - 3].x - + outline->points[n_points - 4].x; + if ( !( loader->face->variation_support & TT_FACE_FLAG_VAR_VADVANCE ) ) + loader->vadvance = outline->points[n_points - 1].x - + outline->points[n_points - 2].x; + if ( error ) return error; } @@ -913,7 +926,7 @@ TT_Driver driver = (TT_Driver)FT_FACE_DRIVER( face ); FT_String* family = face->root.family_name; - FT_UInt ppem = loader->size->metrics.x_ppem; + FT_UInt ppem = loader->size->metrics->x_ppem; FT_String* style = face->root.style_name; FT_UInt x_scale_factor = 1000; #endif @@ -942,9 +955,9 @@ if ( ( loader->load_flags & FT_LOAD_NO_SCALE ) == 0 || x_scale_factor != 1000 ) { - x_scale = FT_MulDiv( loader->size->metrics.x_scale, + x_scale = FT_MulDiv( loader->size->metrics->x_scale, (FT_Long)x_scale_factor, 1000 ); - y_scale = loader->size->metrics.y_scale; + y_scale = loader->size->metrics->y_scale; /* compensate for any scaling by de/emboldening; */ /* the amount was determined via experimentation */ @@ -964,8 +977,8 @@ /* scale the glyph */ if ( ( loader->load_flags & FT_LOAD_NO_SCALE ) == 0 ) { - x_scale = loader->size->metrics.x_scale; - y_scale = loader->size->metrics.y_scale; + x_scale = loader->size->metrics->x_scale; + y_scale = loader->size->metrics->y_scale; do_scale = TRUE; } @@ -1123,8 +1136,8 @@ if ( !( loader->load_flags & FT_LOAD_NO_SCALE ) ) { - FT_Fixed x_scale = loader->size->metrics.x_scale; - FT_Fixed y_scale = loader->size->metrics.y_scale; + FT_Fixed x_scale = loader->size->metrics->x_scale; + FT_Fixed y_scale = loader->size->metrics->y_scale; x = FT_MulFix( x, x_scale ); @@ -1382,7 +1395,7 @@ /* a utility function to retrieve i-th node from given FT_List */ static FT_ListNode ft_list_get_node_at( FT_List list, - FT_UInt index ) + FT_UInt idx ) { FT_ListNode cur; @@ -1392,10 +1405,10 @@ for ( cur = list->head; cur; cur = cur->next ) { - if ( !index ) + if ( !idx ) return cur; - index--; + idx--; } return NULL; @@ -1436,13 +1449,12 @@ FT_TRACE5(( " nesting level: %d\n", recurse_count )); #endif - /* some fonts have an incorrect value of `maxComponentDepth', */ - /* thus we allow depth 1 to catch the majority of them */ - if ( recurse_count > 1 && - recurse_count > face->max_profile.maxComponentDepth ) + /* some fonts have an incorrect value of `maxComponentDepth' */ + if ( recurse_count > face->max_profile.maxComponentDepth ) { - error = FT_THROW( Invalid_Composite ); - goto Exit; + FT_TRACE1(( "load_truetype_glyph: maxComponentDepth set to %d\n", + recurse_count )); + face->max_profile.maxComponentDepth = (FT_UShort)recurse_count; } #ifndef FT_CONFIG_OPTION_INCREMENTAL @@ -1458,8 +1470,8 @@ if ( ( loader->load_flags & FT_LOAD_NO_SCALE ) == 0 ) { - x_scale = loader->size->metrics.x_scale; - y_scale = loader->size->metrics.y_scale; + x_scale = loader->size->metrics->x_scale; + y_scale = loader->size->metrics->y_scale; } else { @@ -1488,7 +1500,7 @@ offset = 0; loader->byte_len = glyph_data.length; - FT_MEM_ZERO( &inc_stream, sizeof ( inc_stream ) ); + FT_ZERO( &inc_stream ); FT_Stream_OpenMemory( &inc_stream, glyph_data.pointer, (FT_ULong)glyph_data.length ); @@ -1506,10 +1518,10 @@ { #ifdef FT_CONFIG_OPTION_INCREMENTAL /* for the incremental interface, `glyf_offset' is always zero */ - if ( !loader->glyf_offset && + if ( !face->glyf_offset && !face->root.internal->incremental_interface ) #else - if ( !loader->glyf_offset ) + if ( !face->glyf_offset ) #endif /* FT_CONFIG_OPTION_INCREMENTAL */ { FT_TRACE2(( "no `glyf' table but non-zero `loca' entry\n" )); @@ -1518,7 +1530,7 @@ } error = face->access_glyph_frame( loader, glyph_index, - loader->glyf_offset + offset, + face->glyf_offset + offset, (FT_UInt)loader->byte_len ); if ( error ) goto Exit; @@ -1565,7 +1577,7 @@ #ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT - if ( loader->face->doblend ) + if ( !loader->face->is_default_instance ) { /* a small outline structure with four elements for */ /* communication with `TT_Vary_Apply_Glyph_Deltas' */ @@ -1608,6 +1620,14 @@ loader->pp3.y = points[2].y; loader->pp4.x = points[3].x; loader->pp4.y = points[3].y; + + + /* recalculate linear horizontal and vertical advances */ + /* if we don't have HVAR and VVAR, respectively */ + if ( !( loader->face->variation_support & TT_FACE_FLAG_VAR_HADVANCE ) ) + loader->linear = loader->pp2.x - loader->pp1.x; + if ( !( loader->face->variation_support & TT_FACE_FLAG_VAR_VADVANCE ) ) + loader->vadvance = loader->pp4.x - loader->pp3.x; } #endif /* TT_CONFIG_OPTION_GX_VAR_SUPPORT */ @@ -1692,7 +1712,7 @@ /* check whether we already have a composite glyph with this index */ if ( FT_List_Find( &loader->composites, - (void*)(unsigned long)glyph_index ) ) + FT_UINT_TO_POINTER( glyph_index ) ) ) { FT_TRACE1(( "TT_Load_Composite_Glyph:" " infinite recursion detected\n" )); @@ -1701,13 +1721,13 @@ } else if ( node ) - node->data = (void*)(unsigned long)glyph_index; + node->data = FT_UINT_TO_POINTER( glyph_index ); else { if ( FT_NEW( node ) ) goto Exit; - node->data = (void*)(unsigned long)glyph_index; + node->data = FT_UINT_TO_POINTER( glyph_index ); FT_List_Add( &loader->composites, node ); } @@ -1728,7 +1748,7 @@ #ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT - if ( face->doblend ) + if ( !face->is_default_instance ) { short i, limit; FT_SubGlyph subglyph; @@ -1797,22 +1817,22 @@ /* this call provides additional offsets */ /* for each component's translation */ - if ( ( error = TT_Vary_Apply_Glyph_Deltas( - face, - glyph_index, - &outline, - (FT_UInt)outline.n_points ) ) != 0 ) + if ( FT_SET_ERROR( TT_Vary_Apply_Glyph_Deltas( + face, + glyph_index, + &outline, + (FT_UInt)outline.n_points ) ) ) goto Exit1; subglyph = gloader->current.subglyphs; for ( i = 0; i < limit; i++, subglyph++ ) { - /* XXX: overflow check for subglyph->{arg1,arg2}. */ - /* Deltas must be within signed 16-bit, */ - /* but the restriction of summed deltas is not clear */ - subglyph->arg1 = (FT_Int16)points[i].x; - subglyph->arg2 = (FT_Int16)points[i].y; + if ( subglyph->flags & ARGS_ARE_XY_VALUES ) + { + subglyph->arg1 = (FT_Int16)points[i].x; + subglyph->arg2 = (FT_Int16)points[i].y; + } } loader->pp1.x = points[i + 0].x; @@ -1825,6 +1845,13 @@ loader->pp4.x = points[i + 3].x; loader->pp4.y = points[i + 3].y; + /* recalculate linear horizontal and vertical advances */ + /* if we don't have HVAR and VVAR, respectively */ + if ( !( face->variation_support & TT_FACE_FLAG_VAR_HADVANCE ) ) + loader->linear = loader->pp2.x - loader->pp1.x; + if ( !( face->variation_support & TT_FACE_FLAG_VAR_VADVANCE ) ) + loader->vadvance = loader->pp4.x - loader->pp3.x; + Exit1: FT_FREE( outline.points ); FT_FREE( outline.tags ); @@ -1884,6 +1911,9 @@ { FT_Vector pp[4]; + FT_Int linear_hadvance; + FT_Int linear_vadvance; + /* Each time we call load_truetype_glyph in this loop, the */ /* value of `gloader.base.subglyphs' can change due to table */ @@ -1896,6 +1926,9 @@ pp[2] = loader->pp3; pp[3] = loader->pp4; + linear_hadvance = loader->linear; + linear_vadvance = loader->vadvance; + num_base_points = (FT_UInt)gloader->base.outline.n_points; error = load_truetype_glyph( loader, @@ -1915,6 +1948,9 @@ loader->pp2 = pp[1]; loader->pp3 = pp[2]; loader->pp4 = pp[3]; + + loader->linear = linear_hadvance; + loader->vadvance = linear_vadvance; } num_points = (FT_UInt)gloader->base.outline.n_points; @@ -2002,7 +2038,7 @@ y_scale = 0x10000L; if ( ( loader->load_flags & FT_LOAD_NO_SCALE ) == 0 ) - y_scale = size->root.metrics.y_scale; + y_scale = size->metrics->y_scale; if ( glyph->format != FT_GLYPH_FORMAT_COMPOSITE ) FT_Outline_Get_CBox( &glyph->outline, &bbox ); @@ -2017,24 +2053,24 @@ glyph->metrics.horiBearingY = bbox.yMax; glyph->metrics.horiAdvance = loader->pp2.x - loader->pp1.x; - /* Adjust advance width to the value contained in the hdmx table */ - /* unless FT_LOAD_COMPUTE_METRICS is set or backwards compatibility */ - /* mode of the v40 interpreter is active. See `ttinterp.h' for */ - /* details on backwards compatibility mode. */ + /* Adjust advance width to the value contained in the hdmx table */ + /* unless FT_LOAD_COMPUTE_METRICS is set or backward compatibility */ + /* mode of the v40 interpreter is active. See `ttinterp.h' for */ + /* details on backward compatibility mode. */ if ( #ifdef TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL - !( driver->interpreter_version == TT_INTERPRETER_VERSION_40 && - ( loader->exec && loader->exec->backwards_compatibility ) ) && + !( driver->interpreter_version == TT_INTERPRETER_VERSION_40 && + ( loader->exec && loader->exec->backward_compatibility ) ) && #endif - !face->postscript.isFixedPitch && - IS_HINTED( loader->load_flags ) && - !( loader->load_flags & FT_LOAD_COMPUTE_METRICS ) ) + !face->postscript.isFixedPitch && + IS_HINTED( loader->load_flags ) && + !( loader->load_flags & FT_LOAD_COMPUTE_METRICS ) ) { FT_Byte* widthp; widthp = tt_face_get_device_metrics( face, - size->root.metrics.x_ppem, + size->metrics->x_ppem, glyph_index ); #ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY @@ -2116,7 +2152,7 @@ #ifdef FT_CONFIG_OPTION_INCREMENTAL { FT_Incremental_InterfaceRec* incr; - FT_Incremental_MetricsRec metrics; + FT_Incremental_MetricsRec incr_metrics; FT_Error error; @@ -2126,19 +2162,19 @@ /* overriding metrics for this glyph. */ if ( incr && incr->funcs->get_glyph_metrics ) { - metrics.bearing_x = 0; - metrics.bearing_y = top; - metrics.advance = advance; + incr_metrics.bearing_x = 0; + incr_metrics.bearing_y = top; + incr_metrics.advance = advance; error = incr->funcs->get_glyph_metrics( incr->object, glyph_index, TRUE, - &metrics ); + &incr_metrics ); if ( error ) return error; - top = metrics.bearing_y; - advance = metrics.advance; + top = incr_metrics.bearing_y; + advance = incr_metrics.advance; } } @@ -2180,7 +2216,7 @@ SFNT_Service sfnt; FT_Stream stream; FT_Error error; - TT_SBit_MetricsRec metrics; + TT_SBit_MetricsRec sbit_metrics; face = (TT_Face)glyph->face; @@ -2193,34 +2229,34 @@ (FT_UInt)load_flags, stream, &glyph->bitmap, - &metrics ); + &sbit_metrics ); if ( !error ) { glyph->outline.n_points = 0; glyph->outline.n_contours = 0; - glyph->metrics.width = (FT_Pos)metrics.width * 64; - glyph->metrics.height = (FT_Pos)metrics.height * 64; + glyph->metrics.width = (FT_Pos)sbit_metrics.width * 64; + glyph->metrics.height = (FT_Pos)sbit_metrics.height * 64; - glyph->metrics.horiBearingX = (FT_Pos)metrics.horiBearingX * 64; - glyph->metrics.horiBearingY = (FT_Pos)metrics.horiBearingY * 64; - glyph->metrics.horiAdvance = (FT_Pos)metrics.horiAdvance * 64; + glyph->metrics.horiBearingX = (FT_Pos)sbit_metrics.horiBearingX * 64; + glyph->metrics.horiBearingY = (FT_Pos)sbit_metrics.horiBearingY * 64; + glyph->metrics.horiAdvance = (FT_Pos)sbit_metrics.horiAdvance * 64; - glyph->metrics.vertBearingX = (FT_Pos)metrics.vertBearingX * 64; - glyph->metrics.vertBearingY = (FT_Pos)metrics.vertBearingY * 64; - glyph->metrics.vertAdvance = (FT_Pos)metrics.vertAdvance * 64; + glyph->metrics.vertBearingX = (FT_Pos)sbit_metrics.vertBearingX * 64; + glyph->metrics.vertBearingY = (FT_Pos)sbit_metrics.vertBearingY * 64; + glyph->metrics.vertAdvance = (FT_Pos)sbit_metrics.vertAdvance * 64; glyph->format = FT_GLYPH_FORMAT_BITMAP; if ( load_flags & FT_LOAD_VERTICAL_LAYOUT ) { - glyph->bitmap_left = metrics.vertBearingX; - glyph->bitmap_top = metrics.vertBearingY; + glyph->bitmap_left = sbit_metrics.vertBearingX; + glyph->bitmap_top = sbit_metrics.vertBearingY; } else { - glyph->bitmap_left = metrics.horiBearingX; - glyph->bitmap_top = metrics.horiBearingY; + glyph->bitmap_left = sbit_metrics.horiBearingX; + glyph->bitmap_top = sbit_metrics.horiBearingY; } } @@ -2237,23 +2273,23 @@ FT_Int32 load_flags, FT_Bool glyf_table_only ) { - FT_Error error; - TT_Face face; FT_Stream stream; + #ifdef TT_USE_BYTECODE_INTERPRETER + FT_Error error; FT_Bool pedantic = FT_BOOL( load_flags & FT_LOAD_PEDANTIC ); -#endif #if defined TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY || \ defined TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL TT_Driver driver = (TT_Driver)FT_FACE_DRIVER( (TT_Face)glyph->face ); #endif +#endif face = (TT_Face)glyph->face; stream = face->root.stream; - FT_MEM_ZERO( loader, sizeof ( TT_LoaderRec ) ); + FT_ZERO( loader ); #ifdef TT_USE_BYTECODE_INTERPRETER @@ -2498,32 +2534,6 @@ #endif /* TT_USE_BYTECODE_INTERPRETER */ - /* seek to the beginning of the glyph table -- for Type 42 fonts */ - /* the table might be accessed from a Postscript stream or something */ - /* else... */ - -#ifdef FT_CONFIG_OPTION_INCREMENTAL - - if ( face->root.internal->incremental_interface ) - loader->glyf_offset = 0; - else - -#endif - - { - error = face->goto_table( face, TTAG_glyf, stream, 0 ); - - if ( FT_ERR_EQ( error, Table_Missing ) ) - loader->glyf_offset = 0; - else if ( error ) - { - FT_ERROR(( "tt_loader_init: could not access glyph table\n" )); - return error; - } - else - loader->glyf_offset = FT_STREAM_POS(); - } - /* get face's glyph loader */ if ( !glyf_table_only ) { @@ -2594,17 +2604,21 @@ FT_Error error; TT_LoaderRec loader; +#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT +#define IS_DEFAULT_INSTANCE ( ( (TT_Face)glyph->face )->is_default_instance ) +#else +#define IS_DEFAULT_INSTANCE 1 +#endif + FT_TRACE1(( "TT_Load_Glyph: glyph index %d\n", glyph_index )); #ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS - /* try to load embedded bitmap if any */ - /* */ - /* XXX: The convention should be emphasized in */ - /* the documents because it can be confusing. */ + /* try to load embedded bitmap (if any) */ if ( size->strike_index != 0xFFFFFFFFUL && - ( load_flags & FT_LOAD_NO_BITMAP ) == 0 ) + ( load_flags & FT_LOAD_NO_BITMAP ) == 0 && + IS_DEFAULT_INSTANCE ) { error = load_sbit_image( size, glyph, glyph_index, load_flags ); if ( !error ) @@ -2623,11 +2637,11 @@ if ( !glyph->metrics.horiAdvance && glyph->linearHoriAdvance ) glyph->metrics.horiAdvance = FT_MulFix( glyph->linearHoriAdvance, - size->root.metrics.x_scale ); + size->metrics->x_scale ); if ( !glyph->metrics.vertAdvance && glyph->linearVertAdvance ) glyph->metrics.vertAdvance = FT_MulFix( glyph->linearVertAdvance, - size->root.metrics.y_scale ); + size->metrics->y_scale ); } return FT_Err_Ok; @@ -2638,14 +2652,20 @@ /* if FT_LOAD_NO_SCALE is not set, `ttmetrics' must be valid */ if ( !( load_flags & FT_LOAD_NO_SCALE ) && !size->ttmetrics.valid ) - return FT_THROW( Invalid_Size_Handle ); + { + error = FT_THROW( Invalid_Size_Handle ); + goto Exit; + } if ( load_flags & FT_LOAD_SBITS_ONLY ) - return FT_THROW( Invalid_Argument ); + { + error = FT_THROW( Invalid_Argument ); + goto Exit; + } error = tt_loader_init( &loader, size, glyph, load_flags, FALSE ); if ( error ) - return error; + goto Exit; glyph->format = FT_GLYPH_FORMAT_OUTLINE; glyph->num_subglyphs = 0; @@ -2717,9 +2737,16 @@ /* TrueType glyphs at all sizes using the bytecode interpreter. */ /* */ if ( !( load_flags & FT_LOAD_NO_SCALE ) && - size->root.metrics.y_ppem < 24 ) + size->metrics->y_ppem < 24 ) glyph->outline.flags |= FT_OUTLINE_HIGH_PRECISION; + Exit: +#ifdef FT_DEBUG_LEVEL_TRACE + if ( error ) + FT_TRACE1(( " failed (error code 0x%x)\n", + error )); +#endif + return error; } diff --git a/thirdparty/freetype/src/truetype/ttgload.h b/thirdparty/freetype/src/truetype/ttgload.h index bfa29e4ff8..1dd6c841db 100644 --- a/thirdparty/freetype/src/truetype/ttgload.h +++ b/thirdparty/freetype/src/truetype/ttgload.h @@ -4,7 +4,7 @@ /* */ /* TrueType Glyph Loader (specification). */ /* */ -/* Copyright 1996-2016 by */ +/* Copyright 1996-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/thirdparty/freetype/src/truetype/ttgxvar.c b/thirdparty/freetype/src/truetype/ttgxvar.c index 9a02c5a8c1..0cedb6bdfa 100644 --- a/thirdparty/freetype/src/truetype/ttgxvar.c +++ b/thirdparty/freetype/src/truetype/ttgxvar.c @@ -4,7 +4,7 @@ /* */ /* TrueType GX Font Variation loader */ /* */ -/* Copyright 2004-2016 by */ +/* Copyright 2004-2017 by */ /* David Turner, Robert Wilhelm, Werner Lemberg, and George Williams. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -22,10 +22,6 @@ /* */ /* https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6[fgca]var.html */ /* */ - /* The documentation for `fvar' is inconsistent. At one point it says */ - /* that `countSizePairs' should be 3, at another point 2. It should */ - /* be 2. */ - /* */ /* The documentation for `gvar' is not intelligible; `cvar' refers you */ /* to `gvar' and is thus also incomprehensible. */ /* */ @@ -49,7 +45,9 @@ #include FT_INTERNAL_STREAM_H #include FT_INTERNAL_SFNT_H #include FT_TRUETYPE_TAGS_H +#include FT_TRUETYPE_IDS_H #include FT_MULTIPLE_MASTERS_H +#include FT_LIST_H #include "ttpload.h" #include "ttgxvar.h" @@ -158,48 +156,49 @@ return NULL; } - if ( FT_NEW_ARRAY( points, n ) ) + /* in the nested loops below we increase `i' twice; */ + /* it is faster to simply allocate one more slot */ + /* than to add another test within the loop */ + if ( FT_NEW_ARRAY( points, n + 1 ) ) return NULL; *point_cnt = n; - i = 0; + first = 0; + i = 0; while ( i < n ) { runcnt = FT_GET_BYTE(); if ( runcnt & GX_PT_POINTS_ARE_WORDS ) { runcnt &= GX_PT_POINT_RUN_COUNT_MASK; - first = FT_GET_USHORT(); + first += FT_GET_USHORT(); points[i++] = first; - if ( runcnt < 1 || i + runcnt > n ) - goto Exit; - /* first point not included in run count */ for ( j = 0; j < runcnt; j++ ) { first += FT_GET_USHORT(); points[i++] = first; + if ( i >= n ) + break; } } else { - first = FT_GET_BYTE(); + first += FT_GET_BYTE(); points[i++] = first; - if ( runcnt < 1 || i + runcnt > n ) - goto Exit; - for ( j = 0; j < runcnt; j++ ) { first += FT_GET_BYTE(); points[i++] = first; + if ( i >= n ) + break; } } } - Exit: return points; } @@ -321,7 +320,7 @@ FT_TRACE2(( "AVAR " )); - blend->avar_checked = TRUE; + blend->avar_loaded = TRUE; error = face->goto_table( face, TTAG_avar, stream, &table_len ); if ( error ) { @@ -345,7 +344,7 @@ if ( axisCount != (FT_Long)blend->mmvar->num_axis ) { - FT_TRACE2(( "ft_var_load_avar: number of axes in `avar' and `cvar'\n" + FT_TRACE2(( "ft_var_load_avar: number of axes in `avar' and `fvar'\n" " table are different\n" )); goto Exit; } @@ -379,7 +378,7 @@ segment->correspondence[j].fromCoord = FT_GET_SHORT() * 4; segment->correspondence[j].toCoord = FT_GET_SHORT() * 4; - FT_TRACE5(( " mapping %.4f to %.4f\n", + FT_TRACE5(( " mapping %.5f to %.5f\n", segment->correspondence[j].fromCoord / 65536.0, segment->correspondence[j].toCoord / 65536.0 )); } @@ -392,318 +391,1491 @@ } - typedef struct GX_GVar_Head_ - { - FT_Long version; - FT_UShort axisCount; - FT_UShort globalCoordCount; - FT_ULong offsetToCoord; - FT_UShort glyphCount; - FT_UShort flags; - FT_ULong offsetToData; + /* some macros we need */ + #define FT_FIXED_ONE ( (FT_Fixed)0x10000 ) - } GX_GVar_Head; + #define FT_fdot14ToFixed( x ) \ + ( (FT_Fixed)( (FT_ULong)(x) << 2 ) ) + #define FT_intToFixed( i ) \ + ( (FT_Fixed)( (FT_ULong)(i) << 16 ) ) + #define FT_fixedToInt( x ) \ + ( (FT_Short)( ( (FT_UInt32)(x) + 0x8000U ) >> 16 ) ) - /*************************************************************************/ - /* */ - /* <Function> */ - /* ft_var_load_gvar */ - /* */ - /* <Description> */ - /* Parse the `gvar' table if present. If `fvar' is there, `gvar' had */ - /* better be there too. */ - /* */ - /* <InOut> */ - /* face :: The font face. */ - /* */ - /* <Return> */ - /* FreeType error code. 0 means success. */ - /* */ static FT_Error - ft_var_load_gvar( TT_Face face ) + ft_var_load_item_variation_store( TT_Face face, + FT_ULong offset, + GX_ItemVarStore itemStore ) { - FT_Stream stream = FT_FACE_STREAM( face ); - FT_Memory memory = stream->memory; - GX_Blend blend = face->blend; - FT_Error error; - FT_UInt i, j; - FT_ULong table_len; - FT_ULong gvar_start; - FT_ULong offsetToData; - GX_GVar_Head gvar_head; + FT_Stream stream = FT_FACE_STREAM( face ); + FT_Memory memory = stream->memory; - static const FT_Frame_Field gvar_fields[] = - { + FT_Error error; + FT_UShort format; + FT_ULong region_offset; + FT_UInt i, j, k; + FT_UInt shortDeltaCount; -#undef FT_STRUCTURE -#define FT_STRUCTURE GX_GVar_Head + GX_Blend blend = face->blend; + GX_ItemVarData varData; - FT_FRAME_START( 20 ), - FT_FRAME_LONG ( version ), - FT_FRAME_USHORT( axisCount ), - FT_FRAME_USHORT( globalCoordCount ), - FT_FRAME_ULONG ( offsetToCoord ), - FT_FRAME_USHORT( glyphCount ), - FT_FRAME_USHORT( flags ), - FT_FRAME_ULONG ( offsetToData ), - FT_FRAME_END - }; + FT_ULong* dataOffsetArray = NULL; - FT_TRACE2(( "GVAR " )); + if ( FT_STREAM_SEEK( offset ) || + FT_READ_USHORT( format ) ) + goto Exit; - if ( ( error = face->goto_table( face, - TTAG_gvar, - stream, - &table_len ) ) != 0 ) + if ( format != 1 ) { - FT_TRACE2(( "is missing\n" )); + FT_TRACE2(( "ft_var_load_item_variation_store: bad store format %d\n", + format )); + error = FT_THROW( Invalid_Table ); goto Exit; } - gvar_start = FT_STREAM_POS( ); - if ( FT_STREAM_READ_FIELDS( gvar_fields, &gvar_head ) ) + /* read top level fields */ + if ( FT_READ_ULONG( region_offset ) || + FT_READ_USHORT( itemStore->dataCount ) ) goto Exit; - if ( gvar_head.version != 0x00010000L ) + /* we need at least one entry in `itemStore->varData' */ + if ( !itemStore->dataCount ) { - FT_TRACE1(( "bad table version\n" )); + FT_TRACE2(( "ft_var_load_item_variation_store: missing varData\n" )); error = FT_THROW( Invalid_Table ); goto Exit; } - if ( gvar_head.axisCount != (FT_UShort)blend->mmvar->num_axis ) - { - FT_TRACE1(( "ft_var_load_gvar: number of axes in `gvar' and `cvar'\n" - " table are different\n" )); - error = FT_THROW( Invalid_Table ); + /* make temporary copy of item variation data offsets; */ + /* we will parse region list first, then come back */ + if ( FT_NEW_ARRAY( dataOffsetArray, itemStore->dataCount ) ) goto Exit; - } - /* rough sanity check, ignoring offsets */ - if ( (FT_ULong)gvar_head.globalCoordCount * gvar_head.axisCount > - table_len / 2 ) + for ( i = 0; i < itemStore->dataCount; i++ ) { - FT_TRACE1(( "ft_var_load_gvar:" - " invalid number of global coordinates\n" )); - error = FT_THROW( Invalid_Table ); - goto Exit; + if ( FT_READ_ULONG( dataOffsetArray[i] ) ) + goto Exit; } - /* rough sanity check: offsets can be either 2 or 4 bytes, */ - /* and a single variation needs at least 4 bytes per glyph */ - if ( (FT_ULong)gvar_head.glyphCount * - ( ( gvar_head.flags & 1 ) ? 8 : 6 ) > table_len ) + /* parse array of region records (region list) */ + if ( FT_STREAM_SEEK( offset + region_offset ) ) + goto Exit; + + if ( FT_READ_USHORT( itemStore->axisCount ) || + FT_READ_USHORT( itemStore->regionCount ) ) + goto Exit; + + if ( itemStore->axisCount != (FT_Long)blend->mmvar->num_axis ) { - FT_TRACE1(( "ft_var_load_gvar: invalid number of glyphs\n" )); + FT_TRACE2(( "ft_var_load_item_variation_store:" + " number of axes in item variation store\n" + " " + " and `fvar' table are different\n" )); error = FT_THROW( Invalid_Table ); goto Exit; } - FT_TRACE2(( "loaded\n" )); - - blend->gvar_size = table_len; - blend->tuplecount = gvar_head.globalCoordCount; - blend->gv_glyphcnt = gvar_head.glyphCount; - offsetToData = gvar_start + gvar_head.offsetToData; - - FT_TRACE5(( "gvar: there are %d shared coordinates:\n", - blend->tuplecount )); - - if ( FT_NEW_ARRAY( blend->glyphoffsets, blend->gv_glyphcnt + 1 ) ) + if ( FT_NEW_ARRAY( itemStore->varRegionList, itemStore->regionCount ) ) goto Exit; - if ( gvar_head.flags & 1 ) + for ( i = 0; i < itemStore->regionCount; i++ ) { - /* long offsets (one more offset than glyphs, to mark size of last) */ - if ( FT_FRAME_ENTER( ( blend->gv_glyphcnt + 1 ) * 4L ) ) + GX_AxisCoords axisCoords; + + + if ( FT_NEW_ARRAY( itemStore->varRegionList[i].axisList, + itemStore->axisCount ) ) goto Exit; - for ( i = 0; i <= blend->gv_glyphcnt; i++ ) - blend->glyphoffsets[i] = offsetToData + FT_GET_ULONG(); + axisCoords = itemStore->varRegionList[i].axisList; - FT_FRAME_EXIT(); + for ( j = 0; j < itemStore->axisCount; j++ ) + { + FT_Short start, peak, end; + + + if ( FT_READ_SHORT( start ) || + FT_READ_SHORT( peak ) || + FT_READ_SHORT( end ) ) + goto Exit; + + axisCoords[j].startCoord = FT_fdot14ToFixed( start ); + axisCoords[j].peakCoord = FT_fdot14ToFixed( peak ); + axisCoords[j].endCoord = FT_fdot14ToFixed( end ); + } } - else + + /* end of region list parse */ + + /* use dataOffsetArray now to parse varData items */ + if ( FT_NEW_ARRAY( itemStore->varData, itemStore->dataCount ) ) + goto Exit; + + for ( i = 0; i < itemStore->dataCount; i++ ) { - /* short offsets (one more offset than glyphs, to mark size of last) */ - if ( FT_FRAME_ENTER( ( blend->gv_glyphcnt + 1 ) * 2L ) ) + varData = &itemStore->varData[i]; + + if ( FT_STREAM_SEEK( offset + dataOffsetArray[i] ) ) goto Exit; - for ( i = 0; i <= blend->gv_glyphcnt; i++ ) - blend->glyphoffsets[i] = offsetToData + FT_GET_USHORT() * 2; - /* XXX: Undocumented: `*2'! */ + if ( FT_READ_USHORT( varData->itemCount ) || + FT_READ_USHORT( shortDeltaCount ) || + FT_READ_USHORT( varData->regionIdxCount ) ) + goto Exit; - FT_FRAME_EXIT(); - } + /* check some data consistency */ + if ( shortDeltaCount > varData->regionIdxCount ) + { + FT_TRACE2(( "bad short count %d or region count %d\n", + shortDeltaCount, + varData->regionIdxCount )); + error = FT_THROW( Invalid_Table ); + goto Exit; + } - if ( blend->tuplecount != 0 ) - { - if ( FT_NEW_ARRAY( blend->tuplecoords, - gvar_head.axisCount * blend->tuplecount ) ) + if ( varData->regionIdxCount > itemStore->regionCount ) + { + FT_TRACE2(( "inconsistent regionCount %d in varData[%d]\n", + varData->regionIdxCount, + i )); + error = FT_THROW( Invalid_Table ); goto Exit; + } - if ( FT_STREAM_SEEK( gvar_start + gvar_head.offsetToCoord ) || - FT_FRAME_ENTER( blend->tuplecount * gvar_head.axisCount * 2L ) ) + /* parse region indices */ + if ( FT_NEW_ARRAY( varData->regionIndices, + varData->regionIdxCount ) ) goto Exit; - for ( i = 0; i < blend->tuplecount; i++ ) + for ( j = 0; j < varData->regionIdxCount; j++ ) { - FT_TRACE5(( " [ " )); - for ( j = 0; j < (FT_UInt)gvar_head.axisCount; j++ ) + if ( FT_READ_USHORT( varData->regionIndices[j] ) ) + goto Exit; + + if ( varData->regionIndices[j] >= itemStore->regionCount ) { - blend->tuplecoords[i * gvar_head.axisCount + j] = - FT_GET_SHORT() * 4; /* convert to FT_Fixed */ - FT_TRACE5(( "%.4f ", - blend->tuplecoords[i * gvar_head.axisCount + j] / 65536.0 )); + FT_TRACE2(( "bad region index %d\n", + varData->regionIndices[j] )); + error = FT_THROW( Invalid_Table ); + goto Exit; } - FT_TRACE5(( "]\n" )); } - FT_TRACE5(( "\n" )); + /* Parse delta set. */ + /* */ + /* On input, deltas are (shortDeltaCount + regionIdxCount) bytes */ + /* each; on output, deltas are expanded to `regionIdxCount' shorts */ + /* each. */ + if ( FT_NEW_ARRAY( varData->deltaSet, + varData->regionIdxCount * varData->itemCount ) ) + goto Exit; - FT_FRAME_EXIT(); + /* the delta set is stored as a 2-dimensional array of shorts; */ + /* sign-extend signed bytes to signed shorts */ + for ( j = 0; j < varData->itemCount * varData->regionIdxCount; ) + { + for ( k = 0; k < shortDeltaCount; k++, j++ ) + { + /* read the short deltas */ + FT_Short delta; + + + if ( FT_READ_SHORT( delta ) ) + goto Exit; + + varData->deltaSet[j] = delta; + } + + for ( ; k < varData->regionIdxCount; k++, j++ ) + { + /* read the (signed) byte deltas */ + FT_Char delta; + + + if ( FT_READ_CHAR( delta ) ) + goto Exit; + + varData->deltaSet[j] = delta; + } + } } Exit: + FT_FREE( dataOffsetArray ); + return error; } - /*************************************************************************/ - /* */ - /* <Function> */ - /* ft_var_apply_tuple */ - /* */ - /* <Description> */ - /* Figure out whether a given tuple (design) applies to the current */ - /* blend, and if so, what is the scaling factor. */ - /* */ - /* <Input> */ - /* blend :: The current blend of the font. */ - /* */ - /* tupleIndex :: A flag saying whether this is an intermediate */ - /* tuple or not. */ - /* */ - /* tuple_coords :: The coordinates of the tuple in normalized axis */ - /* units. */ - /* */ - /* im_start_coords :: The initial coordinates where this tuple starts */ - /* to apply (for intermediate coordinates). */ - /* */ - /* im_end_coords :: The final coordinates after which this tuple no */ - /* longer applies (for intermediate coordinates). */ - /* */ - /* <Return> */ - /* An FT_Fixed value containing the scaling factor. */ - /* */ - static FT_Fixed - ft_var_apply_tuple( GX_Blend blend, - FT_UShort tupleIndex, - FT_Fixed* tuple_coords, - FT_Fixed* im_start_coords, - FT_Fixed* im_end_coords ) + static FT_Error + ft_var_load_delta_set_index_mapping( TT_Face face, + FT_ULong offset, + GX_DeltaSetIdxMap map, + GX_ItemVarStore itemStore ) { - FT_UInt i; - FT_Fixed apply = 0x10000L; + FT_Stream stream = FT_FACE_STREAM( face ); + FT_Memory memory = stream->memory; + FT_Error error; - for ( i = 0; i < blend->num_axis; i++ ) + FT_UShort format; + FT_UInt entrySize; + FT_UInt innerBitCount; + FT_UInt innerIndexMask; + FT_UInt i, j; + + + if ( FT_STREAM_SEEK( offset ) || + FT_READ_USHORT( format ) || + FT_READ_USHORT( map->mapCount ) ) + goto Exit; + + if ( format & 0xFFC0 ) { - FT_TRACE6(( " axis coordinate %d (%.4f):\n", - i, blend->normalizedcoords[i] / 65536.0 )); - if ( !( tupleIndex & GX_TI_INTERMEDIATE_TUPLE ) ) - FT_TRACE6(( " intermediate coordinates %d (%.4f, %.4f):\n", - i, - im_start_coords[i] / 65536.0, - im_end_coords[i] / 65536.0 )); + FT_TRACE2(( "bad map format %d\n", format )); + error = FT_THROW( Invalid_Table ); + goto Exit; + } - /* It's not clear why (for intermediate tuples) we don't need */ - /* to check against start/end -- the documentation says we don't. */ - /* Similarly, it's unclear why we don't need to scale along the */ - /* axis. */ + /* bytes per entry: 1, 2, 3, or 4 */ + entrySize = ( ( format & 0x0030 ) >> 4 ) + 1; + innerBitCount = ( format & 0x000F ) + 1; + innerIndexMask = ( 1 << innerBitCount ) - 1; - if ( tuple_coords[i] == 0 ) + if ( FT_NEW_ARRAY( map->innerIndex, map->mapCount ) ) + goto Exit; + + if ( FT_NEW_ARRAY( map->outerIndex, map->mapCount ) ) + goto Exit; + + for ( i = 0; i < map->mapCount; i++ ) + { + FT_UInt mapData = 0; + FT_UInt outerIndex, innerIndex; + + + /* read map data one unsigned byte at a time, big endian */ + for ( j = 0; j < entrySize; j++ ) { - FT_TRACE6(( " tuple coordinate is zero, ignored\n", i )); - continue; + FT_Byte data; + + + if ( FT_READ_BYTE( data ) ) + goto Exit; + + mapData = ( mapData << 8 ) | data; } - if ( blend->normalizedcoords[i] == 0 ) + outerIndex = mapData >> innerBitCount; + + if ( outerIndex >= itemStore->dataCount ) { - FT_TRACE6(( " axis coordinate is zero, stop\n" )); - apply = 0; - break; + FT_TRACE2(( "outerIndex[%d] == %d out of range\n", + i, + outerIndex )); + error = FT_THROW( Invalid_Table ); + goto Exit; } - if ( blend->normalizedcoords[i] == tuple_coords[i] ) + map->outerIndex[i] = outerIndex; + + innerIndex = mapData & innerIndexMask; + + if ( innerIndex >= itemStore->varData[outerIndex].itemCount ) { - FT_TRACE6(( " tuple coordinate value %.4f fits perfectly\n", - tuple_coords[i] / 65536.0 )); - /* `apply' does not change */ - continue; + FT_TRACE2(( "innerIndex[%d] == %d out of range\n", + i, + innerIndex )); + error = FT_THROW( Invalid_Table ); + goto Exit; } - if ( !( tupleIndex & GX_TI_INTERMEDIATE_TUPLE ) ) - { - /* not an intermediate tuple */ + map->innerIndex[i] = innerIndex; + } + + Exit: + return error; + } + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* ft_var_load_hvvar */ + /* */ + /* <Description> */ + /* If `vertical' is zero, parse the `HVAR' table and set */ + /* `blend->hvar_loaded' to TRUE. On success, `blend->hvar_checked' */ + /* is set to TRUE. */ + /* */ + /* If `vertical' is not zero, parse the `VVAR' table and set */ + /* `blend->vvar_loaded' to TRUE. On success, `blend->vvar_checked' */ + /* is set to TRUE. */ + /* */ + /* Some memory may remain allocated on error; it is always freed in */ + /* `tt_done_blend', however. */ + /* */ + /* <InOut> */ + /* face :: The font face. */ + /* */ + /* <Return> */ + /* FreeType error code. 0 means success. */ + /* */ + static FT_Error + ft_var_load_hvvar( TT_Face face, + FT_Bool vertical ) + { + FT_Stream stream = FT_FACE_STREAM( face ); + FT_Memory memory = stream->memory; + + GX_Blend blend = face->blend; + + GX_HVVarTable table; + + FT_Error error; + FT_UShort majorVersion; + FT_ULong table_len; + FT_ULong table_offset; + FT_ULong store_offset; + FT_ULong widthMap_offset; + + + if ( vertical ) + { + blend->vvar_loaded = TRUE; + + FT_TRACE2(( "VVAR " )); + + error = face->goto_table( face, TTAG_VVAR, stream, &table_len ); + } + else + { + blend->hvar_loaded = TRUE; + + FT_TRACE2(( "HVAR " )); + + error = face->goto_table( face, TTAG_HVAR, stream, &table_len ); + } + + if ( error ) + { + FT_TRACE2(( "is missing\n" )); + goto Exit; + } + + table_offset = FT_STREAM_POS(); + + /* skip minor version */ + if ( FT_READ_USHORT( majorVersion ) || + FT_STREAM_SKIP( 2 ) ) + goto Exit; + + if ( majorVersion != 1 ) + { + FT_TRACE2(( "bad table version %d\n", majorVersion )); + error = FT_THROW( Invalid_Table ); + goto Exit; + } + + if ( FT_READ_ULONG( store_offset ) || + FT_READ_ULONG( widthMap_offset ) ) + goto Exit; + + if ( vertical ) + { + if ( FT_NEW( blend->vvar_table ) ) + goto Exit; + table = blend->vvar_table; + } + else + { + if ( FT_NEW( blend->hvar_table ) ) + goto Exit; + table = blend->hvar_table; + } + + error = ft_var_load_item_variation_store( + face, + table_offset + store_offset, + &table->itemStore ); + if ( error ) + goto Exit; + + if ( widthMap_offset ) + { + error = ft_var_load_delta_set_index_mapping( + face, + table_offset + widthMap_offset, + &table->widthMap, + &table->itemStore ); + if ( error ) + goto Exit; + } + + FT_TRACE2(( "loaded\n" )); + error = FT_Err_Ok; + + Exit: + if ( !error ) + { + if ( vertical ) + { + blend->vvar_checked = TRUE; + + /* FreeType doesn't provide functions to quickly retrieve */ + /* TSB, BSB, or VORG values; we thus don't have to implement */ + /* support for those three item variation stores. */ + + face->variation_support |= TT_FACE_FLAG_VAR_VADVANCE; + } + else + { + blend->hvar_checked = TRUE; + + /* FreeType doesn't provide functions to quickly retrieve */ + /* LSB or RSB values; we thus don't have to implement */ + /* support for those two item variation stores. */ + + face->variation_support |= TT_FACE_FLAG_VAR_HADVANCE; + } + } + + return error; + } + + + static FT_Int + ft_var_get_item_delta( TT_Face face, + GX_ItemVarStore itemStore, + FT_UInt outerIndex, + FT_UInt innerIndex ) + { + GX_ItemVarData varData; + FT_Short* deltaSet; + + FT_UInt master, j; + FT_Fixed netAdjustment = 0; /* accumulated adjustment */ + FT_Fixed scaledDelta; + FT_Fixed delta; + + + /* See pseudo code from `Font Variations Overview' */ + /* in the OpenType specification. */ + + varData = &itemStore->varData[outerIndex]; + deltaSet = &varData->deltaSet[varData->regionIdxCount * innerIndex]; + + /* outer loop steps through master designs to be blended */ + for ( master = 0; master < varData->regionIdxCount; master++ ) + { + FT_Fixed scalar = FT_FIXED_ONE; + FT_UInt regionIndex = varData->regionIndices[master]; + + GX_AxisCoords axis = itemStore->varRegionList[regionIndex].axisList; + + + /* inner loop steps through axes in this region */ + for ( j = 0; j < itemStore->axisCount; j++, axis++ ) + { + FT_Fixed axisScalar; + + + /* compute the scalar contribution of this axis; */ + /* ignore invalid ranges */ + if ( axis->startCoord > axis->peakCoord || + axis->peakCoord > axis->endCoord ) + axisScalar = FT_FIXED_ONE; + + else if ( axis->startCoord < 0 && + axis->endCoord > 0 && + axis->peakCoord != 0 ) + axisScalar = FT_FIXED_ONE; + + /* peak of 0 means ignore this axis */ + else if ( axis->peakCoord == 0 ) + axisScalar = FT_FIXED_ONE; + + /* ignore this region if coords are out of range */ + else if ( face->blend->normalizedcoords[j] < axis->startCoord || + face->blend->normalizedcoords[j] > axis->endCoord ) + axisScalar = 0; + + /* calculate a proportional factor */ + else + { + if ( face->blend->normalizedcoords[j] == axis->peakCoord ) + axisScalar = FT_FIXED_ONE; + else if ( face->blend->normalizedcoords[j] < axis->peakCoord ) + axisScalar = + FT_DivFix( face->blend->normalizedcoords[j] - axis->startCoord, + axis->peakCoord - axis->startCoord ); + else + axisScalar = + FT_DivFix( axis->endCoord - face->blend->normalizedcoords[j], + axis->endCoord - axis->peakCoord ); + } + + /* take product of all the axis scalars */ + scalar = FT_MulFix( scalar, axisScalar ); + + } /* per-axis loop */ + + /* get the scaled delta for this region */ + delta = FT_intToFixed( deltaSet[master] ); + scaledDelta = FT_MulFix( scalar, delta ); + + /* accumulate the adjustments from each region */ + netAdjustment = netAdjustment + scaledDelta; + + } /* per-region loop */ + + return FT_fixedToInt( netAdjustment ); + } + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* tt_hvadvance_adjust */ + /* */ + /* <Description> */ + /* Apply `HVAR' advance width or `VVAR' advance height adjustment of */ + /* a given glyph. */ + /* */ + /* <Input> */ + /* gindex :: The glyph index. */ + /* */ + /* vertical :: If set, handle `VVAR' table. */ + /* */ + /* <InOut> */ + /* face :: The font face. */ + /* */ + /* adelta :: Points to width or height value that gets modified. */ + /* */ + static FT_Error + tt_hvadvance_adjust( TT_Face face, + FT_UInt gindex, + FT_Int *avalue, + FT_Bool vertical ) + { + FT_Error error = FT_Err_Ok; + FT_UInt innerIndex, outerIndex; + FT_Int delta; + + GX_HVVarTable table; + + + if ( !face->doblend || !face->blend ) + goto Exit; + + if ( vertical ) + { + if ( !face->blend->vvar_loaded ) + { + /* initialize vvar table */ + face->blend->vvar_error = ft_var_load_hvvar( face, 1 ); + } + + if ( !face->blend->vvar_checked ) + { + error = face->blend->vvar_error; + goto Exit; + } + + table = face->blend->vvar_table; + } + else + { + if ( !face->blend->hvar_loaded ) + { + /* initialize hvar table */ + face->blend->hvar_error = ft_var_load_hvvar( face, 0 ); + } + + if ( !face->blend->hvar_checked ) + { + error = face->blend->hvar_error; + goto Exit; + } + + table = face->blend->hvar_table; + } + + /* advance width or height adjustments are always present in an */ + /* `HVAR' or `VVAR' table; no need to test for this capability */ + + if ( table->widthMap.innerIndex ) + { + FT_UInt idx = gindex; + + + if ( idx >= table->widthMap.mapCount ) + idx = table->widthMap.mapCount - 1; + + /* trust that HVAR parser has checked indices */ + outerIndex = table->widthMap.outerIndex[idx]; + innerIndex = table->widthMap.innerIndex[idx]; + } + else + { + GX_ItemVarData varData; + + + /* no widthMap data */ + outerIndex = 0; + innerIndex = gindex; + + varData = &table->itemStore.varData[outerIndex]; + if ( gindex >= varData->itemCount ) + { + FT_TRACE2(( "gindex %d out of range\n", gindex )); + error = FT_THROW( Invalid_Argument ); + goto Exit; + } + } + + delta = ft_var_get_item_delta( face, + &table->itemStore, + outerIndex, + innerIndex ); + + FT_TRACE5(( "%s value %d adjusted by %d units (%s)\n", + vertical ? "vertical height" : "horizontal width", + *avalue, + delta, + vertical ? "VVAR" : "HVAR" )); + + *avalue += delta; + + Exit: + return error; + } + + + FT_LOCAL_DEF( FT_Error ) + tt_hadvance_adjust( TT_Face face, + FT_UInt gindex, + FT_Int *avalue ) + { + return tt_hvadvance_adjust( face, gindex, avalue, 0 ); + } + + + FT_LOCAL_DEF( FT_Error ) + tt_vadvance_adjust( TT_Face face, + FT_UInt gindex, + FT_Int *avalue ) + { + return tt_hvadvance_adjust( face, gindex, avalue, 1 ); + } + + +#define GX_VALUE_SIZE 8 + + /* all values are FT_Short or FT_UShort entities; */ + /* we treat them consistently as FT_Short */ +#define GX_VALUE_CASE( tag, dflt ) \ + case MVAR_TAG_ ## tag : \ + p = (FT_Short*)&face->dflt; \ + break + +#define GX_GASP_CASE( idx ) \ + case MVAR_TAG_GASP_ ## idx : \ + if ( idx < face->gasp.numRanges - 1 ) \ + p = (FT_Short*)&face->gasp.gaspRanges[idx].maxPPEM; \ + else \ + p = NULL; \ + break + + + static FT_Short* + ft_var_get_value_pointer( TT_Face face, + FT_ULong mvar_tag ) + { + FT_Short* p; + + + switch ( mvar_tag ) + { + GX_GASP_CASE( 0 ); + GX_GASP_CASE( 1 ); + GX_GASP_CASE( 2 ); + GX_GASP_CASE( 3 ); + GX_GASP_CASE( 4 ); + GX_GASP_CASE( 5 ); + GX_GASP_CASE( 6 ); + GX_GASP_CASE( 7 ); + GX_GASP_CASE( 8 ); + GX_GASP_CASE( 9 ); + + GX_VALUE_CASE( CPHT, os2.sCapHeight ); + GX_VALUE_CASE( HASC, os2.sTypoAscender ); + GX_VALUE_CASE( HCLA, os2.usWinAscent ); + GX_VALUE_CASE( HCLD, os2.usWinDescent ); + GX_VALUE_CASE( HCOF, horizontal.caret_Offset ); + GX_VALUE_CASE( HCRN, horizontal.caret_Slope_Run ); + GX_VALUE_CASE( HCRS, horizontal.caret_Slope_Rise ); + GX_VALUE_CASE( HDSC, os2.sTypoDescender ); + GX_VALUE_CASE( HLGP, os2.sTypoLineGap ); + GX_VALUE_CASE( SBXO, os2.ySubscriptXOffset); + GX_VALUE_CASE( SBXS, os2.ySubscriptXSize ); + GX_VALUE_CASE( SBYO, os2.ySubscriptYOffset ); + GX_VALUE_CASE( SBYS, os2.ySubscriptYSize ); + GX_VALUE_CASE( SPXO, os2.ySuperscriptXOffset ); + GX_VALUE_CASE( SPXS, os2.ySuperscriptXSize ); + GX_VALUE_CASE( SPYO, os2.ySuperscriptYOffset ); + GX_VALUE_CASE( SPYS, os2.ySuperscriptYSize ); + GX_VALUE_CASE( STRO, os2.yStrikeoutPosition ); + GX_VALUE_CASE( STRS, os2.yStrikeoutSize ); + GX_VALUE_CASE( UNDO, postscript.underlinePosition ); + GX_VALUE_CASE( UNDS, postscript.underlineThickness ); + GX_VALUE_CASE( VASC, vertical.Ascender ); + GX_VALUE_CASE( VCOF, vertical.caret_Offset ); + GX_VALUE_CASE( VCRN, vertical.caret_Slope_Run ); + GX_VALUE_CASE( VCRS, vertical.caret_Slope_Rise ); + GX_VALUE_CASE( VDSC, vertical.Descender ); + GX_VALUE_CASE( VLGP, vertical.Line_Gap ); + GX_VALUE_CASE( XHGT, os2.sxHeight ); + + default: + /* ignore unknown tag */ + p = NULL; + } + + return p; + } + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* ft_var_load_mvar */ + /* */ + /* <Description> */ + /* Parse the `MVAR' table. */ + /* */ + /* Some memory may remain allocated on error; it is always freed in */ + /* `tt_done_blend', however. */ + /* */ + /* <InOut> */ + /* face :: The font face. */ + /* */ + static void + ft_var_load_mvar( TT_Face face ) + { + FT_Stream stream = FT_FACE_STREAM( face ); + FT_Memory memory = stream->memory; + + GX_Blend blend = face->blend; + GX_ItemVarStore itemStore; + GX_Value value, limit; + + FT_Error error; + FT_UShort majorVersion; + FT_ULong table_len; + FT_ULong table_offset; + FT_UShort store_offset; + FT_ULong records_offset; + + + FT_TRACE2(( "MVAR " )); + + error = face->goto_table( face, TTAG_MVAR, stream, &table_len ); + if ( error ) + { + FT_TRACE2(( "is missing\n" )); + return; + } + + table_offset = FT_STREAM_POS(); + + /* skip minor version */ + if ( FT_READ_USHORT( majorVersion ) || + FT_STREAM_SKIP( 2 ) ) + return; + + if ( majorVersion != 1 ) + { + FT_TRACE2(( "bad table version %d\n", majorVersion )); + return; + } + + if ( FT_NEW( blend->mvar_table ) ) + return; + + /* skip reserved entry and value record size */ + if ( FT_STREAM_SKIP( 4 ) || + FT_READ_USHORT( blend->mvar_table->valueCount ) || + FT_READ_USHORT( store_offset ) ) + return; + + records_offset = FT_STREAM_POS(); + + error = ft_var_load_item_variation_store( + face, + table_offset + store_offset, + &blend->mvar_table->itemStore ); + if ( error ) + return; + + if ( FT_NEW_ARRAY( blend->mvar_table->values, + blend->mvar_table->valueCount ) ) + return; + + if ( FT_STREAM_SEEK( records_offset ) || + FT_FRAME_ENTER( blend->mvar_table->valueCount * GX_VALUE_SIZE ) ) + return; + + value = blend->mvar_table->values; + limit = value + blend->mvar_table->valueCount; + itemStore = &blend->mvar_table->itemStore; + + for ( ; value < limit; value++ ) + { + value->tag = FT_GET_ULONG(); + value->outerIndex = FT_GET_USHORT(); + value->innerIndex = FT_GET_USHORT(); + + if ( value->outerIndex >= itemStore->dataCount || + value->innerIndex >= itemStore->varData[value->outerIndex] + .itemCount ) + { + error = FT_THROW( Invalid_Table ); + break; + } + } + + FT_FRAME_EXIT(); + + if ( error ) + return; + + FT_TRACE2(( "loaded\n" )); + + value = blend->mvar_table->values; + limit = value + blend->mvar_table->valueCount; + + /* save original values of the data MVAR is going to modify */ + for ( ; value < limit; value++ ) + { + FT_Short* p = ft_var_get_value_pointer( face, value->tag ); + + + if ( p ) + value->unmodified = *p; +#ifdef FT_DEBUG_LEVEL_TRACE + else + FT_TRACE1(( "ft_var_load_mvar: Ignoring unknown tag `%c%c%c%c'\n", + (FT_Char)( value->tag >> 24 ), + (FT_Char)( value->tag >> 16 ), + (FT_Char)( value->tag >> 8 ), + (FT_Char)( value->tag ) )); +#endif + } + + face->variation_support |= TT_FACE_FLAG_VAR_MVAR; + } + + + static FT_Error + tt_size_reset_iterator( FT_ListNode node, + void* user ) + { + TT_Size size = (TT_Size)node->data; + + FT_UNUSED( user ); + + + tt_size_reset( size, 1 ); + + return FT_Err_Ok; + } + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* tt_apply_mvar */ + /* */ + /* <Description> */ + /* Apply `MVAR' table adjustments. */ + /* */ + /* <InOut> */ + /* face :: The font face. */ + /* */ + FT_LOCAL_DEF( void ) + tt_apply_mvar( TT_Face face ) + { + GX_Blend blend = face->blend; + GX_Value value, limit; + + + if ( !( face->variation_support & TT_FACE_FLAG_VAR_MVAR ) ) + return; + + value = blend->mvar_table->values; + limit = value + blend->mvar_table->valueCount; + + for ( ; value < limit; value++ ) + { + FT_Short* p = ft_var_get_value_pointer( face, value->tag ); + FT_Int delta; + + + delta = ft_var_get_item_delta( face, + &blend->mvar_table->itemStore, + value->outerIndex, + value->innerIndex ); + + if ( p ) + { + FT_TRACE5(( "value %c%c%c%c (%d units) adjusted by %d units (MVAR)\n", + (FT_Char)( value->tag >> 24 ), + (FT_Char)( value->tag >> 16 ), + (FT_Char)( value->tag >> 8 ), + (FT_Char)( value->tag ), + value->unmodified, + delta )); + + /* since we handle both signed and unsigned values as FT_Short, */ + /* ensure proper overflow arithmetic */ + *p = (FT_Short)( value->unmodified + (FT_Short)delta ); + } + } + + /* adjust all derived values */ + { + FT_Face root = &face->root; + + + if ( face->os2.version != 0xFFFFU ) + { + if ( face->os2.sTypoAscender || face->os2.sTypoDescender ) + { + root->ascender = face->os2.sTypoAscender; + root->descender = face->os2.sTypoDescender; + + root->height = root->ascender - root->descender + + face->os2.sTypoLineGap; + } + else + { + root->ascender = (FT_Short)face->os2.usWinAscent; + root->descender = -(FT_Short)face->os2.usWinDescent; + + root->height = root->ascender - root->descender; + } + } + + root->underline_position = face->postscript.underlinePosition - + face->postscript.underlineThickness / 2; + root->underline_thickness = face->postscript.underlineThickness; + + /* iterate over all FT_Size objects and call `tt_size_reset' */ + /* to propagate the metrics changes */ + FT_List_Iterate( &root->sizes_list, + tt_size_reset_iterator, + NULL ); + } + } + + + typedef struct GX_GVar_Head_ + { + FT_Long version; + FT_UShort axisCount; + FT_UShort globalCoordCount; + FT_ULong offsetToCoord; + FT_UShort glyphCount; + FT_UShort flags; + FT_ULong offsetToData; + + } GX_GVar_Head; + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* ft_var_load_gvar */ + /* */ + /* <Description> */ + /* Parse the `gvar' table if present. If `fvar' is there, `gvar' had */ + /* better be there too. */ + /* */ + /* <InOut> */ + /* face :: The font face. */ + /* */ + /* <Return> */ + /* FreeType error code. 0 means success. */ + /* */ + static FT_Error + ft_var_load_gvar( TT_Face face ) + { + FT_Stream stream = FT_FACE_STREAM( face ); + FT_Memory memory = stream->memory; + GX_Blend blend = face->blend; + FT_Error error; + FT_UInt i, j; + FT_ULong table_len; + FT_ULong gvar_start; + FT_ULong offsetToData; + GX_GVar_Head gvar_head; + + static const FT_Frame_Field gvar_fields[] = + { + +#undef FT_STRUCTURE +#define FT_STRUCTURE GX_GVar_Head + + FT_FRAME_START( 20 ), + FT_FRAME_LONG ( version ), + FT_FRAME_USHORT( axisCount ), + FT_FRAME_USHORT( globalCoordCount ), + FT_FRAME_ULONG ( offsetToCoord ), + FT_FRAME_USHORT( glyphCount ), + FT_FRAME_USHORT( flags ), + FT_FRAME_ULONG ( offsetToData ), + FT_FRAME_END + }; + + + FT_TRACE2(( "GVAR " )); + + if ( FT_SET_ERROR( face->goto_table( face, + TTAG_gvar, + stream, + &table_len ) ) ) + { + FT_TRACE2(( "is missing\n" )); + goto Exit; + } + + gvar_start = FT_STREAM_POS( ); + if ( FT_STREAM_READ_FIELDS( gvar_fields, &gvar_head ) ) + goto Exit; + + if ( gvar_head.version != 0x00010000L ) + { + FT_TRACE1(( "bad table version\n" )); + error = FT_THROW( Invalid_Table ); + goto Exit; + } + + if ( gvar_head.axisCount != (FT_UShort)blend->mmvar->num_axis ) + { + FT_TRACE1(( "ft_var_load_gvar: number of axes in `gvar' and `cvar'\n" + " table are different\n" )); + error = FT_THROW( Invalid_Table ); + goto Exit; + } + + /* rough sanity check, ignoring offsets */ + if ( (FT_ULong)gvar_head.globalCoordCount * gvar_head.axisCount > + table_len / 2 ) + { + FT_TRACE1(( "ft_var_load_gvar:" + " invalid number of global coordinates\n" )); + error = FT_THROW( Invalid_Table ); + goto Exit; + } + + /* rough sanity check: offsets can be either 2 or 4 bytes */ + if ( (FT_ULong)gvar_head.glyphCount * + ( ( gvar_head.flags & 1 ) ? 4 : 2 ) > table_len ) + { + FT_TRACE1(( "ft_var_load_gvar: invalid number of glyphs\n" )); + error = FT_THROW( Invalid_Table ); + goto Exit; + } + + FT_TRACE2(( "loaded\n" )); + + blend->gvar_size = table_len; + blend->tuplecount = gvar_head.globalCoordCount; + blend->gv_glyphcnt = gvar_head.glyphCount; + offsetToData = gvar_start + gvar_head.offsetToData; + + FT_TRACE5(( "gvar: there are %d shared coordinates:\n", + blend->tuplecount )); + + if ( FT_NEW_ARRAY( blend->glyphoffsets, blend->gv_glyphcnt + 1 ) ) + goto Exit; + + if ( gvar_head.flags & 1 ) + { + /* long offsets (one more offset than glyphs, to mark size of last) */ + if ( FT_FRAME_ENTER( ( blend->gv_glyphcnt + 1 ) * 4L ) ) + goto Exit; + + for ( i = 0; i <= blend->gv_glyphcnt; i++ ) + blend->glyphoffsets[i] = offsetToData + FT_GET_ULONG(); + + FT_FRAME_EXIT(); + } + else + { + /* short offsets (one more offset than glyphs, to mark size of last) */ + if ( FT_FRAME_ENTER( ( blend->gv_glyphcnt + 1 ) * 2L ) ) + goto Exit; + + for ( i = 0; i <= blend->gv_glyphcnt; i++ ) + blend->glyphoffsets[i] = offsetToData + FT_GET_USHORT() * 2; + /* XXX: Undocumented: `*2'! */ + + FT_FRAME_EXIT(); + } + + if ( blend->tuplecount != 0 ) + { + if ( FT_NEW_ARRAY( blend->tuplecoords, + gvar_head.axisCount * blend->tuplecount ) ) + goto Exit; + + if ( FT_STREAM_SEEK( gvar_start + gvar_head.offsetToCoord ) || + FT_FRAME_ENTER( blend->tuplecount * gvar_head.axisCount * 2L ) ) + goto Exit; + + for ( i = 0; i < blend->tuplecount; i++ ) + { + FT_TRACE5(( " [ " )); + for ( j = 0; j < (FT_UInt)gvar_head.axisCount; j++ ) + { + blend->tuplecoords[i * gvar_head.axisCount + j] = + FT_GET_SHORT() * 4; /* convert to FT_Fixed */ + FT_TRACE5(( "%.5f ", + blend->tuplecoords[i * gvar_head.axisCount + j] / 65536.0 )); + } + FT_TRACE5(( "]\n" )); + } + + FT_TRACE5(( "\n" )); + + FT_FRAME_EXIT(); + } + + Exit: + return error; + } + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* ft_var_apply_tuple */ + /* */ + /* <Description> */ + /* Figure out whether a given tuple (design) applies to the current */ + /* blend, and if so, what is the scaling factor. */ + /* */ + /* <Input> */ + /* blend :: The current blend of the font. */ + /* */ + /* tupleIndex :: A flag saying whether this is an intermediate */ + /* tuple or not. */ + /* */ + /* tuple_coords :: The coordinates of the tuple in normalized axis */ + /* units. */ + /* */ + /* im_start_coords :: The initial coordinates where this tuple starts */ + /* to apply (for intermediate coordinates). */ + /* */ + /* im_end_coords :: The final coordinates after which this tuple no */ + /* longer applies (for intermediate coordinates). */ + /* */ + /* <Return> */ + /* An FT_Fixed value containing the scaling factor. */ + /* */ + static FT_Fixed + ft_var_apply_tuple( GX_Blend blend, + FT_UShort tupleIndex, + FT_Fixed* tuple_coords, + FT_Fixed* im_start_coords, + FT_Fixed* im_end_coords ) + { + FT_UInt i; + FT_Fixed apply = 0x10000L; + + + for ( i = 0; i < blend->num_axis; i++ ) + { + FT_TRACE6(( " axis coordinate %d (%.5f):\n", + i, blend->normalizedcoords[i] / 65536.0 )); + if ( !( tupleIndex & GX_TI_INTERMEDIATE_TUPLE ) ) + FT_TRACE6(( " intermediate coordinates %d (%.5f, %.5f):\n", + i, + im_start_coords[i] / 65536.0, + im_end_coords[i] / 65536.0 )); + + /* It's not clear why (for intermediate tuples) we don't need */ + /* to check against start/end -- the documentation says we don't. */ + /* Similarly, it's unclear why we don't need to scale along the */ + /* axis. */ + + if ( tuple_coords[i] == 0 ) + { + FT_TRACE6(( " tuple coordinate is zero, ignored\n", i )); + continue; + } + + if ( blend->normalizedcoords[i] == 0 ) + { + FT_TRACE6(( " axis coordinate is zero, stop\n" )); + apply = 0; + break; + } + + if ( blend->normalizedcoords[i] == tuple_coords[i] ) + { + FT_TRACE6(( " tuple coordinate value %.5f fits perfectly\n", + tuple_coords[i] / 65536.0 )); + /* `apply' does not change */ + continue; + } + + if ( !( tupleIndex & GX_TI_INTERMEDIATE_TUPLE ) ) + { + /* not an intermediate tuple */ if ( blend->normalizedcoords[i] < FT_MIN( 0, tuple_coords[i] ) || blend->normalizedcoords[i] > FT_MAX( 0, tuple_coords[i] ) ) { - FT_TRACE6(( " tuple coordinate value %.4f is exceeded, stop\n", + FT_TRACE6(( " tuple coordinate value %.5f is exceeded, stop\n", tuple_coords[i] / 65536.0 )); apply = 0; break; } - FT_TRACE6(( " tuple coordinate value %.4f fits\n", + FT_TRACE6(( " tuple coordinate value %.5f fits\n", tuple_coords[i] / 65536.0 )); apply = FT_MulDiv( apply, blend->normalizedcoords[i], tuple_coords[i] ); } else - { - /* intermediate tuple */ + { + /* intermediate tuple */ + + if ( blend->normalizedcoords[i] < im_start_coords[i] || + blend->normalizedcoords[i] > im_end_coords[i] ) + { + FT_TRACE6(( " intermediate tuple range [%.5f;%.5f] is exceeded," + " stop\n", + im_start_coords[i] / 65536.0, + im_end_coords[i] / 65536.0 )); + apply = 0; + break; + } + + else if ( blend->normalizedcoords[i] < tuple_coords[i] ) + { + FT_TRACE6(( " intermediate tuple range [%.5f;%.5f] fits\n", + im_start_coords[i] / 65536.0, + im_end_coords[i] / 65536.0 )); + apply = FT_MulDiv( apply, + blend->normalizedcoords[i] - im_start_coords[i], + tuple_coords[i] - im_start_coords[i] ); + } + + else + { + FT_TRACE6(( " intermediate tuple range [%.5f;%.5f] fits\n", + im_start_coords[i] / 65536.0, + im_end_coords[i] / 65536.0 )); + apply = FT_MulDiv( apply, + im_end_coords[i] - blend->normalizedcoords[i], + im_end_coords[i] - tuple_coords[i] ); + } + } + } + + FT_TRACE6(( " apply factor is %.5f\n", apply / 65536.0 )); + + return apply; + } + + + /* convert from design coordinates to normalized coordinates */ + + static void + ft_var_to_normalized( TT_Face face, + FT_UInt num_coords, + FT_Fixed* coords, + FT_Fixed* normalized ) + { + GX_Blend blend; + FT_MM_Var* mmvar; + FT_UInt i, j; + FT_Var_Axis* a; + GX_AVarSegment av; + + + blend = face->blend; + mmvar = blend->mmvar; + + if ( num_coords > mmvar->num_axis ) + { + FT_TRACE2(( "ft_var_to_normalized:" + " only using first %d of %d coordinates\n", + mmvar->num_axis, num_coords )); + num_coords = mmvar->num_axis; + } + + /* Axis normalization is a two-stage process. First we normalize */ + /* based on the [min,def,max] values for the axis to be [-1,0,1]. */ + /* Then, if there's an `avar' table, we renormalize this range. */ + + FT_TRACE5(( "design coordinates:\n" )); + + a = mmvar->axis; + for ( i = 0; i < num_coords; i++, a++ ) + { + FT_Fixed coord = coords[i]; + + + FT_TRACE5(( " %.5f\n", coord / 65536.0 )); + if ( coord > a->maximum || coord < a->minimum ) + { + FT_TRACE1(( + "ft_var_to_normalized: design coordinate %.5f\n" + " is out of range [%.5f;%.5f]; clamping\n", + coord / 65536.0, + a->minimum / 65536.0, + a->maximum / 65536.0 )); + + if ( coord > a->maximum) + coord = a->maximum; + else + coord = a->minimum; + } + + if ( coord < a->def ) + normalized[i] = -FT_DivFix( coords[i] - a->def, + a->minimum - a->def ); + else if ( coord > a->def ) + normalized[i] = FT_DivFix( coords[i] - a->def, + a->maximum - a->def ); + else + normalized[i] = 0; + } - if ( blend->normalizedcoords[i] < im_start_coords[i] || - blend->normalizedcoords[i] > im_end_coords[i] ) - { - FT_TRACE6(( " intermediate tuple range [%.4f;%.4f] is exceeded," - " stop\n", - im_start_coords[i] / 65536.0, - im_end_coords[i] / 65536.0 )); - apply = 0; - break; - } + FT_TRACE5(( "\n" )); - else if ( blend->normalizedcoords[i] < tuple_coords[i] ) + for ( ; i < mmvar->num_axis; i++ ) + normalized[i] = 0; + + if ( blend->avar_segment ) + { + FT_TRACE5(( "normalized design coordinates" + " before applying `avar' data:\n" )); + + av = blend->avar_segment; + for ( i = 0; i < mmvar->num_axis; i++, av++ ) + { + for ( j = 1; j < (FT_UInt)av->pairCount; j++ ) { - FT_TRACE6(( " intermediate tuple range [%.4f;%.4f] fits\n", - im_start_coords[i] / 65536.0, - im_end_coords[i] / 65536.0 )); - apply = FT_MulDiv( apply, - blend->normalizedcoords[i] - im_start_coords[i], - tuple_coords[i] - im_start_coords[i] ); + if ( normalized[i] < av->correspondence[j].fromCoord ) + { + FT_TRACE5(( " %.5f\n", normalized[i] / 65536.0 )); + + normalized[i] = + FT_MulDiv( normalized[i] - av->correspondence[j - 1].fromCoord, + av->correspondence[j].toCoord - + av->correspondence[j - 1].toCoord, + av->correspondence[j].fromCoord - + av->correspondence[j - 1].fromCoord ) + + av->correspondence[j - 1].toCoord; + break; + } } + } + } + } - else + + /* convert from normalized coordinates to design coordinates */ + + static void + ft_var_to_design( TT_Face face, + FT_UInt num_coords, + FT_Fixed* coords, + FT_Fixed* design ) + { + GX_Blend blend; + FT_MM_Var* mmvar; + FT_Var_Axis* a; + + FT_UInt i, j, nc; + + + blend = face->blend; + + nc = num_coords; + if ( num_coords > blend->num_axis ) + { + FT_TRACE2(( "ft_var_to_design:" + " only using first %d of %d coordinates\n", + blend->num_axis, num_coords )); + nc = blend->num_axis; + } + + if ( face->doblend ) + { + for ( i = 0; i < nc; i++ ) + design[i] = coords[i]; + } + else + { + for ( i = 0; i < nc; i++ ) + design[i] = 0; + } + + for ( ; i < num_coords; i++ ) + design[i] = 0; + + if ( blend->avar_segment ) + { + GX_AVarSegment av = blend->avar_segment; + + + FT_TRACE5(( "design coordinates" + " after removing `avar' distortion:\n" )); + + for ( i = 0; i < nc; i++, av++ ) + { + for ( j = 1; j < (FT_UInt)av->pairCount; j++ ) { - FT_TRACE6(( " intermediate tuple range [%.4f;%.4f] fits\n", - im_start_coords[i] / 65536.0, - im_end_coords[i] / 65536.0 )); - apply = FT_MulDiv( apply, - im_end_coords[i] - blend->normalizedcoords[i], - im_end_coords[i] - tuple_coords[i] ); + if ( design[i] < av->correspondence[j].toCoord ) + { + design[i] = + FT_MulDiv( design[i] - av->correspondence[j - 1].toCoord, + av->correspondence[j].fromCoord - + av->correspondence[j - 1].fromCoord, + av->correspondence[j].toCoord - + av->correspondence[j - 1].toCoord ) + + av->correspondence[j - 1].fromCoord; + + FT_TRACE5(( " %.5f\n", design[i] / 65536.0 )); + break; + } } } } - FT_TRACE6(( " apply factor is %.4f\n", apply / 65536.0 )); + mmvar = blend->mmvar; + a = mmvar->axis; - return apply; + for ( i = 0; i < nc; i++, a++ ) + { + if ( design[i] < 0 ) + design[i] = a->def + FT_MulFix( design[i], + a->def - a->minimum ); + else if ( design[i] > 0 ) + design[i] = a->def + FT_MulFix( design[i], + a->maximum - a->def ); + else + design[i] = a->def; + } } @@ -720,7 +1892,6 @@ { FT_Long version; FT_UShort offsetToData; - FT_UShort countSizePairs; FT_UShort axisCount; FT_UShort axisSize; FT_UShort instanceCount; @@ -748,7 +1919,8 @@ /* */ /* <Description> */ /* Check that the font's `fvar' table is valid, parse it, and return */ - /* those data. */ + /* those data. It also loads (and parses) the `MVAR' table, if */ + /* possible. */ /* */ /* <InOut> */ /* face :: The font face. */ @@ -770,13 +1942,17 @@ FT_ULong table_len; FT_Error error = FT_Err_Ok; FT_ULong fvar_start; - FT_Int i, j; + FT_UInt i, j; FT_MM_Var* mmvar = NULL; FT_Fixed* next_coords; + FT_Fixed* nsc; FT_String* next_name; FT_Var_Axis* a; + FT_Fixed* c; FT_Var_Named_Style* ns; GX_FVar_Head fvar_head; + FT_Bool usePsName; + FT_UInt num_instances; static const FT_Frame_Field fvar_fields[] = { @@ -785,13 +1961,13 @@ #define FT_STRUCTURE GX_FVar_Head FT_FRAME_START( 16 ), - FT_FRAME_LONG ( version ), - FT_FRAME_USHORT( offsetToData ), - FT_FRAME_USHORT( countSizePairs ), - FT_FRAME_USHORT( axisCount ), - FT_FRAME_USHORT( axisSize ), - FT_FRAME_USHORT( instanceCount ), - FT_FRAME_USHORT( instanceSize ), + FT_FRAME_LONG ( version ), + FT_FRAME_USHORT ( offsetToData ), + FT_FRAME_SKIP_SHORT, + FT_FRAME_USHORT ( axisCount ), + FT_FRAME_USHORT ( axisSize ), + FT_FRAME_USHORT ( instanceCount ), + FT_FRAME_USHORT ( instanceSize ), FT_FRAME_END }; @@ -815,21 +1991,26 @@ /* read the font data and set up the internal representation */ /* if not already done */ - if ( face->blend == NULL ) + if ( !face->blend ) { FT_TRACE2(( "FVAR " )); /* both `fvar' and `gvar' must be present */ - if ( ( error = face->goto_table( face, TTAG_gvar, - stream, &table_len ) ) != 0 ) + if ( FT_SET_ERROR( face->goto_table( face, TTAG_gvar, + stream, &table_len ) ) ) { - FT_TRACE1(( "\n" - "TT_Get_MM_Var: `gvar' table is missing\n" )); - goto Exit; + /* CFF2 is an alternate to gvar here */ + if ( FT_SET_ERROR( face->goto_table( face, TTAG_CFF2, + stream, &table_len ) ) ) + { + FT_TRACE1(( "\n" + "TT_Get_MM_Var: `gvar' or `CFF2' table is missing\n" )); + goto Exit; + } } - if ( ( error = face->goto_table( face, TTAG_fvar, - stream, &table_len ) ) != 0 ) + if ( FT_SET_ERROR( face->goto_table( face, TTAG_fvar, + stream, &table_len ) ) ) { FT_TRACE1(( "is missing\n" )); goto Exit; @@ -837,30 +2018,13 @@ fvar_start = FT_STREAM_POS( ); + /* the validity of the `fvar' header data was already checked */ + /* in function `sfnt_init_face' */ if ( FT_STREAM_READ_FIELDS( fvar_fields, &fvar_head ) ) goto Exit; - if ( fvar_head.version != (FT_Long)0x00010000L || -#if 0 - /* fonts like `JamRegular.ttf' have an incorrect value for */ - /* `countSizePairs'; since value 2 is hard-coded in `fvar' */ - /* version 1.0, we simply ignore it */ - fvar_head.countSizePairs != 2 || -#endif - fvar_head.axisSize != 20 || - /* axisCount limit implied by 16-bit instanceSize */ - fvar_head.axisCount > 0x3FFE || - fvar_head.instanceSize != 4 + 4 * fvar_head.axisCount || - /* instanceCount limit implied by limited range of name IDs */ - fvar_head.instanceCount > 0x7EFF || - fvar_head.offsetToData + fvar_head.axisCount * 20U + - fvar_head.instanceCount * fvar_head.instanceSize > table_len ) - { - FT_TRACE1(( "\n" - "TT_Get_MM_Var: invalid `fvar' header\n" )); - error = FT_THROW( Invalid_Table ); - goto Exit; - } + usePsName = FT_BOOL( fvar_head.instanceSize == + 6 + 4 * fvar_head.axisCount ); FT_TRACE2(( "loaded\n" )); @@ -869,12 +2033,18 @@ if ( FT_NEW( face->blend ) ) goto Exit; - /* cannot overflow 32-bit arithmetic because of limits above */ + /* `num_instances' holds the number of all named instances, */ + /* including the default instance which might be missing */ + /* in fvar's table of named instances */ + num_instances = face->root.style_flags >> 16; + + /* cannot overflow 32-bit arithmetic because of the size limits */ + /* used in the `fvar' table validity check in `sfnt_init_face' */ face->blend->mmvar_len = sizeof ( FT_MM_Var ) + fvar_head.axisCount * sizeof ( FT_Var_Axis ) + - fvar_head.instanceCount * sizeof ( FT_Var_Named_Style ) + - fvar_head.instanceCount * fvar_head.axisCount * sizeof ( FT_Fixed ) + + num_instances * sizeof ( FT_Var_Named_Style ) + + num_instances * fvar_head.axisCount * sizeof ( FT_Fixed ) + 5 * fvar_head.axisCount; if ( FT_ALLOC( mmvar, face->blend->mmvar_len ) ) @@ -891,15 +2061,15 @@ /* may have a different number of designs */ /* (or tuples, as called by Apple) */ mmvar->num_namedstyles = - fvar_head.instanceCount; + num_instances; mmvar->axis = (FT_Var_Axis*)&( mmvar[1] ); mmvar->namedstyle = (FT_Var_Named_Style*)&( mmvar->axis[fvar_head.axisCount] ); next_coords = - (FT_Fixed*)&( mmvar->namedstyle[fvar_head.instanceCount] ); - for ( i = 0; i < fvar_head.instanceCount; i++ ) + (FT_Fixed*)&( mmvar->namedstyle[num_instances] ); + for ( i = 0; i < num_instances; i++ ) { mmvar->namedstyle[i].coords = next_coords; next_coords += fvar_head.axisCount; @@ -937,7 +2107,18 @@ a->name[3] = (FT_String)( ( a->tag ) & 0xFF ); a->name[4] = '\0'; - FT_TRACE5(( " \"%s\": minimum=%.4f, default=%.4f, maximum=%.4f\n", + if ( a->minimum > a->def || + a->def > a->maximum ) + { + FT_TRACE2(( "TT_Get_MM_Var:" + " invalid \"%s\" axis record; disabling\n", + a->name )); + + a->minimum = a->def; + a->maximum = a->def; + } + + FT_TRACE5(( " \"%s\": minimum=%.5f, default=%.5f, maximum=%.5f\n", a->name, a->minimum / 65536.0, a->def / 65536.0, @@ -948,25 +2129,99 @@ FT_TRACE5(( "\n" )); - ns = mmvar->namedstyle; + /* named instance coordinates are stored as design coordinates; */ + /* we have to convert them to normalized coordinates also */ + if ( FT_NEW_ARRAY( face->blend->normalized_stylecoords, + fvar_head.axisCount * num_instances ) ) + goto Exit; + + if ( fvar_head.instanceCount && !face->blend->avar_loaded ) + ft_var_load_avar( face ); + + ns = mmvar->namedstyle; + nsc = face->blend->normalized_stylecoords; for ( i = 0; i < fvar_head.instanceCount; i++, ns++ ) { - if ( FT_FRAME_ENTER( 4L + 4L * fvar_head.axisCount ) ) + /* PostScript names add 2 bytes to the instance record size */ + if ( FT_FRAME_ENTER( ( usePsName ? 6L : 4L ) + + 4L * fvar_head.axisCount ) ) goto Exit; ns->strid = FT_GET_USHORT(); (void) /* flags = */ FT_GET_USHORT(); - for ( j = 0; j < fvar_head.axisCount; j++ ) - ns->coords[j] = FT_GET_LONG(); + c = ns->coords; + for ( j = 0; j < fvar_head.axisCount; j++, c++ ) + *c = FT_GET_LONG(); + + if ( usePsName ) + ns->psid = FT_GET_USHORT(); + + ft_var_to_normalized( face, + fvar_head.axisCount, + ns->coords, + nsc ); + nsc += fvar_head.axisCount; FT_FRAME_EXIT(); } + + if ( num_instances != fvar_head.instanceCount ) + { + SFNT_Service sfnt = (SFNT_Service)face->sfnt; + + FT_Int found, dummy1, dummy2; + FT_UInt strid = 0xFFFFFFFFUL; + + + /* the default instance is missing in array the */ + /* of named instances; try to synthesize an entry */ + found = sfnt->get_name_id( face, + TT_NAME_ID_TYPOGRAPHIC_SUBFAMILY, + &dummy1, + &dummy2 ); + if ( found ) + strid = TT_NAME_ID_TYPOGRAPHIC_SUBFAMILY; + else + { + found = sfnt->get_name_id( face, + TT_NAME_ID_FONT_SUBFAMILY, + &dummy1, + &dummy2 ); + if ( found ) + strid = TT_NAME_ID_FONT_SUBFAMILY; + } + + if ( found ) + { + found = sfnt->get_name_id( face, + TT_NAME_ID_PS_NAME, + &dummy1, + &dummy2 ); + if ( found ) + { + FT_TRACE5(( "TT_Get_MM_Var:" + " Adding default instance to named instances\n" )); + + ns = &mmvar->namedstyle[fvar_head.instanceCount]; + + ns->strid = strid; + ns->psid = TT_NAME_ID_PS_NAME; + + a = mmvar->axis; + c = ns->coords; + for ( j = 0; j < fvar_head.axisCount; j++, a++, c++ ) + *c = a->def; + } + } + } + + ft_var_load_mvar( face ); } /* fill the output array if requested */ - if ( master != NULL ) + if ( master ) { FT_UInt n; @@ -1016,40 +2271,17 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* TT_Set_MM_Blend */ - /* */ - /* <Description> */ - /* Set the blend (normalized) coordinates for this instance of the */ - /* font. Check that the `gvar' table is reasonable and does some */ - /* initial preparation. */ - /* */ - /* <InOut> */ - /* face :: The font. */ - /* Initialize the blend structure with `gvar' data. */ - /* */ - /* <Input> */ - /* num_coords :: The number of available coordinates. If it is */ - /* larger than the number of axes, ignore the excess */ - /* values. If it is smaller than the number of axes, */ - /* use the default value (0) for the remaining axes. */ - /* */ - /* coords :: An array of `num_coords', each between [-1,1]. */ - /* */ - /* <Return> */ - /* FreeType error code. 0 means success. */ - /* */ - FT_LOCAL_DEF( FT_Error ) - TT_Set_MM_Blend( TT_Face face, + static FT_Error + tt_set_mm_blend( TT_Face face, FT_UInt num_coords, - FT_Fixed* coords ) + FT_Fixed* coords, + FT_Bool set_design_coords ) { FT_Error error = FT_Err_Ok; GX_Blend blend; FT_MM_Var* mmvar; - FT_UInt i; + FT_UInt i, j; + FT_Bool is_default_instance = 1; FT_Memory memory = face->root.memory; enum @@ -1063,9 +2295,9 @@ face->doblend = FALSE; - if ( face->blend == NULL ) + if ( !face->blend ) { - if ( ( error = TT_Get_MM_Var( face, NULL ) ) != 0 ) + if ( FT_SET_ERROR( TT_Get_MM_Var( face, NULL ) ) ) goto Exit; } @@ -1074,7 +2306,8 @@ if ( num_coords > mmvar->num_axis ) { - FT_TRACE2(( "TT_Set_MM_Blend: only using first %d of %d coordinates\n", + FT_TRACE2(( "TT_Set_MM_Blend:" + " only using first %d of %d coordinates\n", mmvar->num_axis, num_coords )); num_coords = mmvar->num_axis; } @@ -1083,24 +2316,33 @@ for ( i = 0; i < num_coords; i++ ) { - FT_TRACE5(( " %.4f\n", coords[i] / 65536.0 )); + FT_TRACE5(( " %.5f\n", coords[i] / 65536.0 )); if ( coords[i] < -0x00010000L || coords[i] > 0x00010000L ) { - FT_TRACE1(( "TT_Set_MM_Blend: normalized design coordinate %.4f\n" + FT_TRACE1(( "TT_Set_MM_Blend: normalized design coordinate %.5f\n" " is out of range [-1;1]\n", coords[i] / 65536.0 )); error = FT_THROW( Invalid_Argument ); goto Exit; } + + if ( coords[i] != 0 ) + is_default_instance = 0; } FT_TRACE5(( "\n" )); - if ( blend->glyphoffsets == NULL ) - if ( ( error = ft_var_load_gvar( face ) ) != 0 ) + if ( !face->is_cff2 && !blend->glyphoffsets ) + if ( FT_SET_ERROR( ft_var_load_gvar( face ) ) ) + goto Exit; + + if ( !blend->coords ) + { + if ( FT_NEW_ARRAY( blend->coords, mmvar->num_axis ) ) goto Exit; + } - if ( blend->normalizedcoords == NULL ) + if ( !blend->normalizedcoords ) { if ( FT_NEW_ARRAY( blend->normalizedcoords, mmvar->num_axis ) ) goto Exit; @@ -1133,46 +2375,184 @@ } } - /* If we don't change the blend coords then we don't need to do */ - /* anything to the cvt table. It will be correct. Otherwise we */ - /* no longer have the original cvt (it was modified when we set */ - /* the blend last time), so we must reload and then modify it. */ - } + /* If we don't change the blend coords then we don't need to do */ + /* anything to the cvt table. It will be correct. Otherwise we */ + /* no longer have the original cvt (it was modified when we set */ + /* the blend last time), so we must reload and then modify it. */ + } + + blend->num_axis = mmvar->num_axis; + FT_MEM_COPY( blend->normalizedcoords, + coords, + num_coords * sizeof ( FT_Fixed ) ); + + if ( set_design_coords ) + ft_var_to_design( face, + num_coords, + blend->normalizedcoords, + blend->coords ); + + face->doblend = TRUE; + + if ( face->cvt ) + { + switch ( manageCvt ) + { + case mcvt_load: + /* The cvt table has been loaded already; every time we change the */ + /* blend we may need to reload and remodify the cvt table. */ + FT_FREE( face->cvt ); + face->cvt = NULL; + + 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). */ + error = tt_face_vary_cvt( face, face->root.stream ); + break; + + case mcvt_retain: + /* The cvt table is correct for this set of coordinates. */ + break; + } + } + + /* check whether the current variation tuple coincides */ + /* with a named instance */ + + for ( i = 0; i < blend->mmvar->num_namedstyles; i++ ) + { + FT_Fixed* nsc = blend->normalized_stylecoords + i * blend->num_axis; + FT_Fixed* ns = blend->normalizedcoords; + + + for ( j = 0; j < blend->num_axis; j++, nsc++, ns++ ) + { + if ( *nsc != *ns ) + break; + } + + if ( j == blend->num_axis ) + break; + } + + /* adjust named instance index */ + face->root.face_index &= 0xFFFF; + if ( i < blend->mmvar->num_namedstyles ) + face->root.face_index |= ( i + 1 ) << 16; + + face->is_default_instance = is_default_instance; + + /* enforce recomputation of the PostScript name; */ + FT_FREE( face->postscript_name ); + face->postscript_name = NULL; + + Exit: + return error; + } + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* TT_Set_MM_Blend */ + /* */ + /* <Description> */ + /* Set the blend (normalized) coordinates for this instance of the */ + /* font. Check that the `gvar' table is reasonable and does some */ + /* initial preparation. */ + /* */ + /* <InOut> */ + /* face :: The font. */ + /* Initialize the blend structure with `gvar' data. */ + /* */ + /* <Input> */ + /* num_coords :: The number of available coordinates. If it is */ + /* larger than the number of axes, ignore the excess */ + /* values. If it is smaller than the number of axes, */ + /* use the default value (0) for the remaining axes. */ + /* */ + /* coords :: An array of `num_coords', each between [-1,1]. */ + /* */ + /* <Return> */ + /* FreeType error code. 0 means success. */ + /* */ + FT_LOCAL_DEF( FT_Error ) + TT_Set_MM_Blend( TT_Face face, + FT_UInt num_coords, + FT_Fixed* coords ) + { + return tt_set_mm_blend( face, num_coords, coords, 1 ); + } + - blend->num_axis = mmvar->num_axis; - FT_MEM_COPY( blend->normalizedcoords, - coords, - num_coords * sizeof ( FT_Fixed ) ); + /*************************************************************************/ + /* */ + /* <Function> */ + /* TT_Get_MM_Blend */ + /* */ + /* <Description> */ + /* Get the blend (normalized) coordinates for this instance of the */ + /* font. */ + /* */ + /* <InOut> */ + /* face :: The font. */ + /* Initialize the blend structure with `gvar' data. */ + /* */ + /* <Input> */ + /* num_coords :: The number of available coordinates. If it is */ + /* larger than the number of axes, set the excess */ + /* values to 0. */ + /* */ + /* coords :: An array of `num_coords', each between [-1,1]. */ + /* */ + /* <Return> */ + /* FreeType error code. 0 means success. */ + /* */ + FT_LOCAL_DEF( FT_Error ) + TT_Get_MM_Blend( TT_Face face, + FT_UInt num_coords, + FT_Fixed* coords ) + { + FT_Error error = FT_Err_Ok; + GX_Blend blend; + FT_UInt i, nc; - face->doblend = TRUE; - if ( face->cvt != NULL ) + if ( !face->blend ) { - switch ( manageCvt ) - { - case mcvt_load: - /* The cvt table has been loaded already; every time we change the */ - /* blend we may need to reload and remodify the cvt table. */ - FT_FREE( face->cvt ); - face->cvt = NULL; + if ( FT_SET_ERROR( TT_Get_MM_Var( face, NULL ) ) ) + return error; + } - error = tt_face_load_cvt( face, face->root.stream ); - break; + blend = face->blend; - case mcvt_modify: - /* The original cvt table is in memory. All we need to do is */ - /* apply the `cvar' table (if any). */ - error = tt_face_vary_cvt( face, face->root.stream ); - break; + nc = num_coords; + if ( num_coords > blend->num_axis ) + { + FT_TRACE2(( "TT_Get_MM_Blend:" + " only using first %d of %d coordinates\n", + blend->num_axis, num_coords )); + nc = blend->num_axis; + } - case mcvt_retain: - /* The cvt table is correct for this set of coordinates. */ - break; - } + if ( face->doblend ) + { + for ( i = 0; i < nc; i++ ) + coords[i] = blend->normalizedcoords[i]; + } + else + { + for ( i = 0; i < nc; i++ ) + coords[i] = 0; } - Exit: - return error; + for ( ; i < num_coords; i++ ) + coords[i] = 0; + + return FT_Err_Ok; } @@ -1206,19 +2586,21 @@ FT_UInt num_coords, FT_Fixed* coords ) { - FT_Error error = FT_Err_Ok; - FT_Fixed* normalized = NULL; - GX_Blend blend; - FT_MM_Var* mmvar; - FT_UInt i, j; - FT_Var_Axis* a; - GX_AVarSegment av; - FT_Memory memory = face->root.memory; + FT_Error error = FT_Err_Ok; + GX_Blend blend; + FT_MM_Var* mmvar; + FT_UInt i; + FT_Memory memory = face->root.memory; + + FT_Var_Axis* a; + FT_Fixed* c; + FT_Fixed* normalized = NULL; - if ( face->blend == NULL ) + + if ( !face->blend ) { - if ( ( error = TT_Get_MM_Var( face, NULL ) ) != 0 ) + if ( FT_SET_ERROR( TT_Get_MM_Var( face, NULL ) ) ) goto Exit; } @@ -1233,79 +2615,101 @@ num_coords = mmvar->num_axis; } - /* Axis normalization is a two stage process. First we normalize */ - /* based on the [min,def,max] values for the axis to be [-1,0,1]. */ - /* Then, if there's an `avar' table, we renormalize this range. */ + if ( !blend->coords ) + { + if ( FT_NEW_ARRAY( blend->coords, mmvar->num_axis ) ) + goto Exit; + } + + FT_MEM_COPY( blend->coords, + coords, + num_coords * sizeof ( FT_Fixed ) ); + + a = mmvar->axis + num_coords; + c = coords + num_coords; + for ( i = num_coords; i < mmvar->num_axis; i++, a++, c++ ) + *c = a->def; if ( FT_NEW_ARRAY( normalized, mmvar->num_axis ) ) goto Exit; - FT_TRACE5(( "design coordinates:\n" )); + if ( !face->blend->avar_loaded ) + ft_var_load_avar( face ); - a = mmvar->axis; - for ( i = 0; i < num_coords; i++, a++ ) - { - FT_TRACE5(( " %.4f\n", coords[i] / 65536.0 )); - if ( coords[i] > a->maximum || coords[i] < a->minimum ) - { - FT_TRACE1(( "TT_Set_Var_Design: normalized design coordinate %.4f\n" - " is out of range [%.4f;%.4f]\n", - coords[i] / 65536.0, - a->minimum / 65536.0, - a->maximum / 65536.0 )); - error = FT_THROW( Invalid_Argument ); - goto Exit; - } + ft_var_to_normalized( face, num_coords, coords, normalized ); - if ( coords[i] < a->def ) - normalized[i] = -FT_DivFix( coords[i] - a->def, - a->minimum - a->def ); - else if ( a->maximum == a->def ) - normalized[i] = 0; - else - normalized[i] = FT_DivFix( coords[i] - a->def, - a->maximum - a->def ); - } + error = tt_set_mm_blend( face, mmvar->num_axis, normalized, 0 ); - FT_TRACE5(( "\n" )); + Exit: + FT_FREE( normalized ); + return error; + } - for ( ; i < mmvar->num_axis; i++ ) - normalized[i] = 0; - if ( !blend->avar_checked ) - ft_var_load_avar( face ); + /*************************************************************************/ + /* */ + /* <Function> */ + /* TT_Get_Var_Design */ + /* */ + /* <Description> */ + /* Get the design coordinates of the currently selected interpolated */ + /* font. */ + /* */ + /* <Input> */ + /* face :: A handle to the source face. */ + /* */ + /* num_coords :: The number of design coordinates to retrieve. If it */ + /* is larger than the number of axes, set the excess */ + /* values to~0. */ + /* */ + /* <Output> */ + /* coords :: The design coordinates array. */ + /* */ + /* <Return> */ + /* FreeType error code. 0~means success. */ + /* */ + FT_LOCAL_DEF( FT_Error ) + TT_Get_Var_Design( TT_Face face, + FT_UInt num_coords, + FT_Fixed* coords ) + { + FT_Error error = FT_Err_Ok; + GX_Blend blend; + FT_UInt i, nc; + - if ( blend->avar_segment != NULL ) + if ( !face->blend ) { - FT_TRACE5(( "normalized design coordinates" - " before applying `avar' data:\n" )); + if ( FT_SET_ERROR( TT_Get_MM_Var( face, NULL ) ) ) + return error; + } - av = blend->avar_segment; - for ( i = 0; i < mmvar->num_axis; i++, av++ ) - { - for ( j = 1; j < (FT_UInt)av->pairCount; j++ ) - { - FT_TRACE5(( " %.4f\n", normalized[i] / 65536.0 )); - if ( normalized[i] < av->correspondence[j].fromCoord ) - { - normalized[i] = - FT_MulDiv( normalized[i] - av->correspondence[j - 1].fromCoord, - av->correspondence[j].toCoord - - av->correspondence[j - 1].toCoord, - av->correspondence[j].fromCoord - - av->correspondence[j - 1].fromCoord ) + - av->correspondence[j - 1].toCoord; - break; - } - } - } + blend = face->blend; + + nc = num_coords; + if ( num_coords > blend->num_axis ) + { + FT_TRACE2(( "TT_Get_Var_Design:" + " only using first %d of %d coordinates\n", + blend->num_axis, num_coords )); + nc = blend->num_axis; + } + + if ( face->doblend ) + { + for ( i = 0; i < nc; i++ ) + coords[i] = blend->coords[i]; + } + else + { + for ( i = 0; i < nc; i++ ) + coords[i] = 0; } - error = TT_Set_MM_Blend( face, mmvar->num_axis, normalized ); + for ( ; i < num_coords; i++ ) + coords[i] = 0; - Exit: - FT_FREE( normalized ); - return error; + return FT_Err_Ok; } @@ -1362,7 +2766,7 @@ FT_TRACE2(( "CVAR " )); - if ( blend == NULL ) + if ( !blend ) { FT_TRACE2(( "\n" "tt_face_vary_cvt: no blend specified\n" )); @@ -1370,7 +2774,7 @@ goto Exit; } - if ( face->cvt == NULL ) + if ( !face->cvt ) { FT_TRACE2(( "\n" "tt_face_vary_cvt: no `cvt ' table\n" )); @@ -1413,7 +2817,8 @@ offsetToData = FT_GET_USHORT(); /* rough sanity test */ - if ( offsetToData + tupleCount * 4 > table_len ) + if ( offsetToData + ( tupleCount & GX_TC_TUPLE_COUNT_MASK ) * 4 > + table_len ) { FT_TRACE2(( "tt_face_vary_cvt:" " invalid CVT variation array header\n" )); @@ -1497,7 +2902,7 @@ table_len, point_count == 0 ? face->cvt_size : point_count ); - if ( localpoints == NULL || deltas == NULL ) + if ( !localpoints || !deltas ) ; /* failure, ignore it */ else if ( localpoints == ALL_POINTS ) @@ -1545,10 +2950,15 @@ for ( j = 0; j < point_count; j++ ) { - int pindex = localpoints[j]; - FT_Long orig_cvt = face->cvt[pindex]; + int pindex; + FT_Long orig_cvt; + pindex = localpoints[j]; + if ( (FT_ULong)pindex >= face->cvt_size ) + continue; + + orig_cvt = face->cvt[pindex]; face->cvt[pindex] = (FT_Short)( orig_cvt + FT_MulFix( deltas[j], apply ) ); @@ -1671,25 +3081,12 @@ d1 = out1 - in1; d2 = out2 - in2; - if ( out1 == out2 || in1 == in2 ) - { - for ( p = p1; p <= p2; p++ ) - { - out = in_points[p].x; - - if ( out <= in1 ) - out += d1; - else if ( out >= in2 ) - out += d2; - else - out = out1; - - out_points[p].x = out; - } - } - else + /* If the reference points have the same coordinate but different */ + /* delta, inferred delta is zero. Otherwise interpolate. */ + if ( in1 != in2 || out1 == out2 ) { - FT_Fixed scale = FT_DivFix( out2 - out1, in2 - in1 ); + FT_Fixed scale = in1 != in2 ? FT_DivFix( out2 - out1, in2 - in1 ) + : 0; for ( p = p1; p <= p2; p++ ) @@ -1716,12 +3113,11 @@ /* modeled after `Ins_IUP */ static void - tt_handle_deltas( FT_Outline* outline, - FT_Vector* in_points, - FT_Bool* has_delta ) + tt_interpolate_deltas( FT_Outline* outline, + FT_Vector* out_points, + FT_Vector* in_points, + FT_Bool* has_delta ) { - FT_Vector* out_points; - FT_Int first_point; FT_Int end_point; @@ -1736,8 +3132,6 @@ if ( !outline->n_contours ) return; - out_points = outline->points; - contour = 0; point = 0; @@ -1841,6 +3235,7 @@ GX_Blend blend = face->blend; FT_Vector* points_org = NULL; + FT_Vector* points_out = NULL; FT_Bool* has_delta = NULL; FT_Error error; @@ -1859,7 +3254,7 @@ FT_Short *deltas_x, *deltas_y; - if ( !face->doblend || blend == NULL ) + if ( !face->doblend || !blend ) return FT_THROW( Invalid_Argument ); if ( glyph_index >= blend->gv_glyphcnt || @@ -1872,6 +3267,7 @@ } if ( FT_NEW_ARRAY( points_org, n_points ) || + FT_NEW_ARRAY( points_out, n_points ) || FT_NEW_ARRAY( has_delta, n_points ) ) goto Fail1; @@ -1894,7 +3290,8 @@ offsetToData = FT_GET_USHORT(); /* rough sanity test */ - if ( offsetToData + tupleCount * 4 > blend->gvar_size ) + if ( offsetToData + ( tupleCount & GX_TC_TUPLE_COUNT_MASK ) * 4 > + blend->gvar_size ) { FT_TRACE2(( "TT_Vary_Apply_Glyph_Deltas:" " invalid glyph variation array header\n" )); @@ -1922,6 +3319,9 @@ FT_TRACE5(( "gvar: there are %d tuples:\n", tupleCount & GX_TC_TUPLE_COUNT_MASK )); + for ( j = 0; j < n_points; j++ ) + points_org[j] = outline->points[j]; + for ( i = 0; i < ( tupleCount & GX_TC_TUPLE_COUNT_MASK ); i++ ) { FT_UInt tupleDataSize; @@ -1976,10 +3376,10 @@ here = FT_Stream_FTell( stream ); + FT_Stream_SeekSet( stream, offsetToData ); + if ( tupleIndex & GX_TI_PRIVATE_POINT_NUMBERS ) { - FT_Stream_SeekSet( stream, offsetToData ); - localpoints = ft_var_readpackedpoints( stream, blend->gvar_size, &point_count ); @@ -2000,7 +3400,7 @@ point_count == 0 ? n_points : point_count ); - if ( points == NULL || deltas_y == NULL || deltas_x == NULL ) + if ( !points || !deltas_y || !deltas_x ) ; /* failure, ignore it */ else if ( points == ALL_POINTS ) @@ -2015,22 +3415,48 @@ /* this means that there are deltas for every point in the glyph */ for ( j = 0; j < n_points; j++ ) { -#ifdef FT_DEBUG_LEVEL_TRACE - FT_Vector point_org = outline->points[j]; -#endif + FT_Pos delta_x = FT_MulFix( deltas_x[j], apply ); + FT_Pos delta_y = FT_MulFix( deltas_y[j], apply ); - outline->points[j].x += FT_MulFix( deltas_x[j], apply ); - outline->points[j].y += FT_MulFix( deltas_y[j], apply ); + if ( j < n_points - 3 ) + { + outline->points[j].x += delta_x; + outline->points[j].y += delta_y; + } + else + { + /* To avoid double adjustment of advance width or height, */ + /* adjust phantom points only if there is no HVAR or VVAR */ + /* support, respectively. */ + if ( j == ( n_points - 3 ) && + !( face->variation_support & + TT_FACE_FLAG_VAR_HADVANCE ) ) + outline->points[j].x += delta_x; + + else if ( j == ( n_points - 2 ) && + !( face->variation_support & + TT_FACE_FLAG_VAR_LSB ) ) + outline->points[j].x += delta_x; + + else if ( j == ( n_points - 1 ) && + !( face->variation_support & + TT_FACE_FLAG_VAR_VADVANCE ) ) + outline->points[j].y += delta_y; + + else if ( j == ( n_points - 0 ) && + !( face->variation_support & + TT_FACE_FLAG_VAR_TSB ) ) + outline->points[j].y += delta_y; + } #ifdef FT_DEBUG_LEVEL_TRACE - if ( ( point_org.x != outline->points[j].x ) || - ( point_org.y != outline->points[j].y ) ) + if ( delta_x || delta_y ) { FT_TRACE7(( " %d: (%d, %d) -> (%d, %d)\n", j, - point_org.x, - point_org.y, + outline->points[j].x - delta_x, + outline->points[j].y - delta_y, outline->points[j].x, outline->points[j].y )); count++; @@ -2044,9 +3470,6 @@ #endif } - else if ( localpoints == NULL ) - ; /* failure, ignore it */ - else { #ifdef FT_DEBUG_LEVEL_TRACE @@ -2058,13 +3481,13 @@ /* IUP bytecode instruction */ for ( j = 0; j < n_points; j++ ) { - points_org[j] = outline->points[j]; has_delta[j] = FALSE; + points_out[j] = points_org[j]; } for ( j = 0; j < point_count; j++ ) { - FT_UShort idx = localpoints[j]; + FT_UShort idx = points[j]; if ( idx >= n_points ) @@ -2072,34 +3495,43 @@ has_delta[idx] = TRUE; - outline->points[idx].x += FT_MulFix( deltas_x[j], apply ); - outline->points[idx].y += FT_MulFix( deltas_y[j], apply ); + points_out[idx].x += FT_MulFix( deltas_x[j], apply ); + points_out[idx].y += FT_MulFix( deltas_y[j], apply ); } /* no need to handle phantom points here, */ /* since solitary points can't be interpolated */ - tt_handle_deltas( outline, - points_org, - has_delta ); + tt_interpolate_deltas( outline, + points_out, + points_org, + has_delta ); -#ifdef FT_DEBUG_LEVEL_TRACE FT_TRACE7(( " point deltas:\n" )); - for ( j = 0; j < n_points; j++) + for ( j = 0; j < n_points; j++ ) { - if ( ( points_org[j].x != outline->points[j].x ) || - ( points_org[j].y != outline->points[j].y ) ) + FT_Pos delta_x = points_out[j].x - points_org[j].x; + FT_Pos delta_y = points_out[j].y - points_org[j].y; + + + outline->points[j].x += delta_x; + outline->points[j].y += delta_y; + +#ifdef FT_DEBUG_LEVEL_TRACE + if ( delta_x || delta_y ) { FT_TRACE7(( " %d: (%d, %d) -> (%d, %d)\n", j, - points_org[j].x, - points_org[j].y, + outline->points[j].x - delta_x, + outline->points[j].y - delta_y, outline->points[j].x, outline->points[j].y )); count++; } +#endif } +#ifdef FT_DEBUG_LEVEL_TRACE if ( !count ) FT_TRACE7(( " none\n" )); #endif @@ -2128,12 +3560,84 @@ Fail1: FT_FREE( points_org ); + FT_FREE( points_out ); FT_FREE( has_delta ); return error; } + /*************************************************************************/ + /* */ + /* <Function> */ + /* tt_get_var_blend */ + /* */ + /* <Description> */ + /* An extended internal version of `TT_Get_MM_Blend' that returns */ + /* pointers instead of copying data, without any initialization of */ + /* the MM machinery in case it isn't loaded yet. */ + /* */ + FT_LOCAL_DEF( FT_Error ) + tt_get_var_blend( TT_Face face, + FT_UInt *num_coords, + FT_Fixed* *coords, + FT_Fixed* *normalizedcoords, + FT_MM_Var* *mm_var ) + { + if ( face->blend ) + { + if ( num_coords ) + *num_coords = face->blend->num_axis; + if ( coords ) + *coords = face->blend->coords; + if ( normalizedcoords ) + *normalizedcoords = face->blend->normalizedcoords; + if ( mm_var ) + *mm_var = face->blend->mmvar; + } + else + { + if ( num_coords ) + *num_coords = 0; + if ( coords ) + *coords = NULL; + if ( mm_var ) + *mm_var = NULL; + } + + return FT_Err_Ok; + } + + + static void + ft_var_done_item_variation_store( TT_Face face, + GX_ItemVarStore itemStore ) + { + FT_Memory memory = FT_FACE_MEMORY( face ); + FT_UInt i; + + + if ( itemStore->varData ) + { + for ( i = 0; i < itemStore->dataCount; i++ ) + { + FT_FREE( itemStore->varData[i].regionIndices ); + FT_FREE( itemStore->varData[i].deltaSet ); + } + + FT_FREE( itemStore->varData ); + } + + if ( itemStore->varRegionList ) + { + for ( i = 0; i < itemStore->regionCount; i++ ) + FT_FREE( itemStore->varRegionList[i].axisList ); + + FT_FREE( itemStore->varRegionList ); + } + } + + /*************************************************************************/ /* */ /* <Function> */ @@ -2143,31 +3647,73 @@ /* Free the blend internal data structure. */ /* */ FT_LOCAL_DEF( void ) - tt_done_blend( FT_Memory memory, - GX_Blend blend ) + tt_done_blend( TT_Face face ) { - if ( blend != NULL ) + FT_Memory memory = FT_FACE_MEMORY( face ); + GX_Blend blend = face->blend; + + + if ( blend ) { - FT_UInt i; + FT_UInt i, num_axes; + + /* blend->num_axis might not be set up yet */ + num_axes = blend->mmvar->num_axis; + FT_FREE( blend->coords ); FT_FREE( blend->normalizedcoords ); + FT_FREE( blend->normalized_stylecoords ); FT_FREE( blend->mmvar ); - if ( blend->avar_segment != NULL ) + if ( blend->avar_segment ) { - for ( i = 0; i < blend->num_axis; i++ ) + for ( i = 0; i < num_axes; i++ ) FT_FREE( blend->avar_segment[i].correspondence ); FT_FREE( blend->avar_segment ); } + if ( blend->hvar_table ) + { + ft_var_done_item_variation_store( face, + &blend->hvar_table->itemStore ); + + FT_FREE( blend->hvar_table->widthMap.innerIndex ); + FT_FREE( blend->hvar_table->widthMap.outerIndex ); + FT_FREE( blend->hvar_table ); + } + + if ( blend->vvar_table ) + { + ft_var_done_item_variation_store( face, + &blend->vvar_table->itemStore ); + + FT_FREE( blend->vvar_table->widthMap.innerIndex ); + FT_FREE( blend->vvar_table->widthMap.outerIndex ); + FT_FREE( blend->vvar_table ); + } + + if ( blend->mvar_table ) + { + ft_var_done_item_variation_store( face, + &blend->mvar_table->itemStore ); + + FT_FREE( blend->mvar_table->values ); + FT_FREE( blend->mvar_table ); + } + FT_FREE( blend->tuplecoords ); FT_FREE( blend->glyphoffsets ); FT_FREE( blend ); } } -#endif /* TT_CONFIG_OPTION_GX_VAR_SUPPORT */ +#else /* !TT_CONFIG_OPTION_GX_VAR_SUPPORT */ + + /* ANSI C doesn't like empty source files */ + typedef int _tt_gxvar_dummy; + +#endif /* !TT_CONFIG_OPTION_GX_VAR_SUPPORT */ /* END */ diff --git a/thirdparty/freetype/src/truetype/ttgxvar.h b/thirdparty/freetype/src/truetype/ttgxvar.h index aa8f6ea592..7e81719a3e 100644 --- a/thirdparty/freetype/src/truetype/ttgxvar.h +++ b/thirdparty/freetype/src/truetype/ttgxvar.h @@ -4,7 +4,7 @@ /* */ /* TrueType GX Font Variation loader (specification) */ /* */ -/* Copyright 2004-2016 by */ +/* Copyright 2004-2017 by */ /* David Turner, Robert Wilhelm, Werner Lemberg and George Williams. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -61,6 +61,152 @@ FT_BEGIN_HEADER } GX_AVarSegmentRec, *GX_AVarSegment; + typedef struct GX_ItemVarDataRec_ + { + FT_UInt itemCount; /* number of delta sets per item */ + FT_UInt regionIdxCount; /* number of region indices in this data */ + FT_UInt* regionIndices; /* array of `regionCount' indices; */ + /* these index `varRegionList' */ + FT_Short* deltaSet; /* array of `itemCount' deltas */ + /* use `innerIndex' for this array */ + + } GX_ItemVarDataRec, *GX_ItemVarData; + + + /* contribution of one axis to a region */ + typedef struct GX_AxisCoordsRec_ + { + FT_Fixed startCoord; + FT_Fixed peakCoord; /* zero means no effect (factor = 1) */ + FT_Fixed endCoord; + + } GX_AxisCoordsRec, *GX_AxisCoords; + + + typedef struct GX_VarRegionRec_ + { + GX_AxisCoords axisList; /* array of axisCount records */ + + } GX_VarRegionRec, *GX_VarRegion; + + + /* item variation store */ + typedef struct GX_ItemVarStoreRec_ + { + FT_UInt dataCount; + GX_ItemVarData varData; /* array of dataCount records; */ + /* use `outerIndex' for this array */ + FT_UShort axisCount; + FT_UInt regionCount; /* total number of regions defined */ + GX_VarRegion varRegionList; + + } GX_ItemVarStoreRec, *GX_ItemVarStore; + + + typedef struct GX_DeltaSetIdxMapRec_ + { + FT_UInt mapCount; + FT_UInt* outerIndex; /* indices to item var data */ + FT_UInt* innerIndex; /* indices to delta set */ + + } GX_DeltaSetIdxMapRec, *GX_DeltaSetIdxMap; + + + /*************************************************************************/ + /* */ + /* <Struct> */ + /* GX_HVVarTableRec */ + /* */ + /* <Description> */ + /* Data from either the `HVAR' or `VVAR' table. */ + /* */ + typedef struct GX_HVVarTableRec_ + { + GX_ItemVarStoreRec itemStore; /* Item Variation Store */ + GX_DeltaSetIdxMapRec widthMap; /* Advance Width Mapping */ + +#if 0 + GX_DeltaSetIdxMapRec lsbMap; /* not implemented */ + GX_DeltaSetIdxMapRec rsbMap; /* not implemented */ + + GX_DeltaSetIdxMapRec tsbMap; /* not implemented */ + GX_DeltaSetIdxMapRec bsbMap; /* not implemented */ + GX_DeltaSetIdxMapRec vorgMap; /* not implemented */ +#endif + + } GX_HVVarTableRec, *GX_HVVarTable; + + +#define MVAR_TAG_GASP_0 FT_MAKE_TAG( 'g', 's', 'p', '0' ) +#define MVAR_TAG_GASP_1 FT_MAKE_TAG( 'g', 's', 'p', '1' ) +#define MVAR_TAG_GASP_2 FT_MAKE_TAG( 'g', 's', 'p', '2' ) +#define MVAR_TAG_GASP_3 FT_MAKE_TAG( 'g', 's', 'p', '3' ) +#define MVAR_TAG_GASP_4 FT_MAKE_TAG( 'g', 's', 'p', '4' ) +#define MVAR_TAG_GASP_5 FT_MAKE_TAG( 'g', 's', 'p', '5' ) +#define MVAR_TAG_GASP_6 FT_MAKE_TAG( 'g', 's', 'p', '6' ) +#define MVAR_TAG_GASP_7 FT_MAKE_TAG( 'g', 's', 'p', '7' ) +#define MVAR_TAG_GASP_8 FT_MAKE_TAG( 'g', 's', 'p', '8' ) +#define MVAR_TAG_GASP_9 FT_MAKE_TAG( 'g', 's', 'p', '9' ) + +#define MVAR_TAG_CPHT FT_MAKE_TAG( 'c', 'p', 'h', 't' ) +#define MVAR_TAG_HASC FT_MAKE_TAG( 'h', 'a', 's', 'c' ) +#define MVAR_TAG_HCLA FT_MAKE_TAG( 'h', 'c', 'l', 'a' ) +#define MVAR_TAG_HCLD FT_MAKE_TAG( 'h', 'c', 'l', 'd' ) +#define MVAR_TAG_HCOF FT_MAKE_TAG( 'h', 'c', 'o', 'f' ) +#define MVAR_TAG_HCRN FT_MAKE_TAG( 'h', 'c', 'r', 'n' ) +#define MVAR_TAG_HCRS FT_MAKE_TAG( 'h', 'c', 'r', 's' ) +#define MVAR_TAG_HDSC FT_MAKE_TAG( 'h', 'd', 's', 'c' ) +#define MVAR_TAG_HLGP FT_MAKE_TAG( 'h', 'l', 'g', 'p' ) +#define MVAR_TAG_SBXO FT_MAKE_TAG( 's', 'b', 'x', 'o' ) +#define MVAR_TAG_SBXS FT_MAKE_TAG( 's', 'b', 'x', 's' ) +#define MVAR_TAG_SBYO FT_MAKE_TAG( 's', 'b', 'y', 'o' ) +#define MVAR_TAG_SBYS FT_MAKE_TAG( 's', 'b', 'y', 's' ) +#define MVAR_TAG_SPXO FT_MAKE_TAG( 's', 'p', 'x', 'o' ) +#define MVAR_TAG_SPXS FT_MAKE_TAG( 's', 'p', 'x', 's' ) +#define MVAR_TAG_SPYO FT_MAKE_TAG( 's', 'p', 'y', 'o' ) +#define MVAR_TAG_SPYS FT_MAKE_TAG( 's', 'p', 'y', 's' ) +#define MVAR_TAG_STRO FT_MAKE_TAG( 's', 't', 'r', 'o' ) +#define MVAR_TAG_STRS FT_MAKE_TAG( 's', 't', 'r', 's' ) +#define MVAR_TAG_UNDO FT_MAKE_TAG( 'u', 'n', 'd', 'o' ) +#define MVAR_TAG_UNDS FT_MAKE_TAG( 'u', 'n', 'd', 's' ) +#define MVAR_TAG_VASC FT_MAKE_TAG( 'v', 'a', 's', 'c' ) +#define MVAR_TAG_VCOF FT_MAKE_TAG( 'v', 'c', 'o', 'f' ) +#define MVAR_TAG_VCRN FT_MAKE_TAG( 'v', 'c', 'r', 'n' ) +#define MVAR_TAG_VCRS FT_MAKE_TAG( 'v', 'c', 'r', 's' ) +#define MVAR_TAG_VDSC FT_MAKE_TAG( 'v', 'd', 's', 'c' ) +#define MVAR_TAG_VLGP FT_MAKE_TAG( 'v', 'l', 'g', 'p' ) +#define MVAR_TAG_XHGT FT_MAKE_TAG( 'x', 'h', 'g', 't' ) + + + typedef struct GX_ValueRec_ + { + FT_ULong tag; + FT_UShort outerIndex; + FT_UShort innerIndex; + + FT_Short unmodified; /* values are either FT_Short or FT_UShort */ + + } GX_ValueRec, *GX_Value; + + + /*************************************************************************/ + /* */ + /* <Struct> */ + /* GX_MVarTableRec */ + /* */ + /* <Description> */ + /* Data from the `MVAR' table. */ + /* */ + typedef struct GX_MVarTableRec_ + { + FT_UShort valueCount; + + GX_ItemVarStoreRec itemStore; /* Item Variation Store */ + GX_Value values; /* Value Records */ + + } GX_MVarTableRec, *GX_MVarTable; + + /*************************************************************************/ /* */ /* <Struct> */ @@ -68,32 +214,120 @@ FT_BEGIN_HEADER /* */ /* <Description> */ /* Data for interpolating a font from a distortable font specified */ - /* by the GX *var tables ([fgca]var). */ + /* by the GX *var tables ([fgcahvm]var). */ /* */ /* <Fields> */ - /* num_axis :: The number of axes along which interpolation */ - /* may happen */ + /* num_axis :: */ + /* The number of axes along which interpolation may happen. */ + /* */ + /* coords :: */ + /* An array of design coordinates (in user space) indicating the */ + /* contribution along each axis to the final interpolated font. */ + /* `normalizedcoords' holds the same values. */ + /* */ + /* normalizedcoords :: */ + /* An array of normalized values (between [-1,1]) indicating the */ + /* contribution along each axis to the final interpolated font. */ + /* `coords' holds the same values. */ + /* */ + /* mmvar :: */ + /* Data from the `fvar' table. */ + /* */ + /* mmvar_len :: */ + /* The length of the `mmvar' structure. */ + /* */ + /* normalized_stylecoords :: */ + /* A two-dimensional array that holds the named instance data from */ + /* `mmvar' as normalized values. */ + /* */ + /* avar_loaded :: */ + /* A Boolean; if set, FreeType tried to load (and parse) the `avar' */ + /* table. */ + /* */ + /* avar_segment :: */ + /* Data from the `avar' table. */ + /* */ + /* hvar_loaded :: */ + /* A Boolean; if set, FreeType tried to load (and parse) the `hvar' */ + /* table. */ + /* */ + /* hvar_checked :: */ + /* A Boolean; if set, FreeType successfully loaded and parsed the */ + /* `hvar' table. */ + /* */ + /* hvar_error :: */ + /* If loading and parsing of the `hvar' table failed, this field */ + /* holds the corresponding error code. */ + /* */ + /* hvar_table :: */ + /* Data from the `hvar' table. */ + /* */ + /* vvar_loaded :: */ + /* A Boolean; if set, FreeType tried to load (and parse) the `vvar' */ + /* table. */ + /* */ + /* vvar_checked :: */ + /* A Boolean; if set, FreeType successfully loaded and parsed the */ + /* `vvar' table. */ + /* */ + /* vvar_error :: */ + /* If loading and parsing of the `vvar' table failed, this field */ + /* holds the corresponding error code. */ + /* */ + /* vvar_table :: */ + /* Data from the `vvar' table. */ + /* */ + /* mvar_table :: */ + /* Data from the `mvar' table. */ + /* */ + /* tuplecount :: */ + /* The number of shared tuples in the `gvar' table. */ + /* */ + /* tuplecoords :: */ + /* A two-dimensional array that holds the shared tuple coordinates */ + /* in the `gvar' table. */ /* */ - /* normalizedcoords :: A normalized value (between [-1,1]) indicating */ - /* the contribution along each axis to the final */ - /* interpolated font. */ + /* gv_glyphcnt :: */ + /* The number of glyphs handled in the `gvar' table. */ + /* */ + /* glyphoffsets :: */ + /* Offsets into the glyph variation data array. */ + /* */ + /* gvar_size :: */ + /* The size of the `gvar' table. */ /* */ typedef struct GX_BlendRec_ { FT_UInt num_axis; + FT_Fixed* coords; FT_Fixed* normalizedcoords; FT_MM_Var* mmvar; FT_Offset mmvar_len; - FT_Bool avar_checked; - GX_AVarSegment avar_segment; + FT_Fixed* normalized_stylecoords; + /* normalized_stylecoords[num_namedstyles][num_axis] */ + + FT_Bool avar_loaded; + GX_AVarSegment avar_segment; /* avar_segment[num_axis] */ + + FT_Bool hvar_loaded; + FT_Bool hvar_checked; + FT_Error hvar_error; + GX_HVVarTable hvar_table; + + FT_Bool vvar_loaded; + FT_Bool vvar_checked; + FT_Error vvar_error; + GX_HVVarTable vvar_table; - FT_UInt tuplecount; /* shared tuples in `gvar' */ - FT_Fixed* tuplecoords; /* tuplecoords[tuplecount][num_axis] */ + GX_MVarTable mvar_table; + + FT_UInt tuplecount; + FT_Fixed* tuplecoords; /* tuplecoords[tuplecount][num_axis] */ FT_UInt gv_glyphcnt; - FT_ULong* glyphoffsets; + FT_ULong* glyphoffsets; /* glyphoffsets[gv_glyphcnt + 1] */ FT_ULong gvar_size; @@ -148,6 +382,11 @@ FT_BEGIN_HEADER FT_UInt num_coords, FT_Fixed* coords ); + FT_LOCAL( FT_Error ) + TT_Get_MM_Blend( TT_Face face, + FT_UInt num_coords, + FT_Fixed* coords ); + FT_LOCAL( FT_Error ) TT_Set_Var_Design( TT_Face face, FT_UInt num_coords, @@ -157,6 +396,10 @@ FT_BEGIN_HEADER TT_Get_MM_Var( TT_Face face, FT_MM_Var* *master ); + FT_LOCAL( FT_Error ) + TT_Get_Var_Design( TT_Face face, + FT_UInt num_coords, + FT_Fixed* coords ); FT_LOCAL( FT_Error ) tt_face_vary_cvt( TT_Face face, @@ -169,10 +412,28 @@ FT_BEGIN_HEADER FT_Outline* outline, FT_UInt n_points ); + FT_LOCAL( FT_Error ) + tt_hadvance_adjust( TT_Face face, + FT_UInt gindex, + FT_Int *adelta ); + + FT_LOCAL( FT_Error ) + tt_vadvance_adjust( TT_Face face, + FT_UInt gindex, + FT_Int *adelta ); + + FT_LOCAL( void ) + tt_apply_mvar( TT_Face face ); + + FT_LOCAL( FT_Error ) + tt_get_var_blend( TT_Face face, + FT_UInt *num_coords, + FT_Fixed* *coords, + FT_Fixed* *normalizedcoords, + FT_MM_Var* *mm_var ); FT_LOCAL( void ) - tt_done_blend( FT_Memory memory, - GX_Blend blend ); + tt_done_blend( TT_Face face ); FT_END_HEADER diff --git a/thirdparty/freetype/src/truetype/ttinterp.c b/thirdparty/freetype/src/truetype/ttinterp.c index 8fe83c5ea8..af31408cbf 100644 --- a/thirdparty/freetype/src/truetype/ttinterp.c +++ b/thirdparty/freetype/src/truetype/ttinterp.c @@ -4,7 +4,7 @@ /* */ /* TrueType bytecode interpreter (body). */ /* */ -/* Copyright 1996-2016 by */ +/* Copyright 1996-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -26,10 +26,14 @@ #include FT_TRIGONOMETRY_H #include FT_SYSTEM_H #include FT_TRUETYPE_DRIVER_H +#include FT_MULTIPLE_MASTERS_H #include "ttinterp.h" #include "tterrors.h" #include "ttsubpix.h" +#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT +#include "ttgxvar.h" +#endif #ifdef TT_USE_BYTECODE_INTERPRETER @@ -125,7 +129,7 @@ coderange = &exec->codeRangeTable[range - 1]; - FT_ASSERT( coderange->base != NULL ); + FT_ASSERT( coderange->base ); /* NOTE: Because the last instruction of a program may be a CALL */ /* which will return to the first byte *after* the code */ @@ -396,8 +400,9 @@ exec->maxIDefs = size->max_instruction_defs; exec->FDefs = size->function_defs; exec->IDefs = size->instruction_defs; + exec->pointSize = size->point_size; exec->tt_metrics = size->ttmetrics; - exec->metrics = size->metrics; + exec->metrics = *size->metrics; exec->maxFunc = size->max_func; exec->maxIns = size->max_ins; @@ -418,7 +423,7 @@ /* In case of multi-threading it can happen that the old size object */ /* no longer exists, thus we must clear all glyph zone references. */ - ft_memset( &exec->zp0, 0, sizeof ( exec->zp0 ) ); + FT_ZERO( &exec->zp0 ); exec->zp1 = exec->zp0; exec->zp2 = exec->zp0; } @@ -681,17 +686,17 @@ /* IUP[0] */ PACK( 0, 0 ), /* IUP[1] */ PACK( 0, 0 ), - /* SHP[0] */ PACK( 0, 0 ), - /* SHP[1] */ PACK( 0, 0 ), + /* SHP[0] */ PACK( 0, 0 ), /* loops */ + /* SHP[1] */ PACK( 0, 0 ), /* loops */ /* SHC[0] */ PACK( 1, 0 ), /* SHC[1] */ PACK( 1, 0 ), /* SHZ[0] */ PACK( 1, 0 ), /* SHZ[1] */ PACK( 1, 0 ), - /* SHPIX */ PACK( 1, 0 ), - /* IP */ PACK( 0, 0 ), + /* SHPIX */ PACK( 1, 0 ), /* loops */ + /* IP */ PACK( 0, 0 ), /* loops */ /* MSIRP[0] */ PACK( 2, 0 ), /* MSIRP[1] */ PACK( 2, 0 ), - /* AlignRP */ PACK( 0, 0 ), + /* AlignRP */ PACK( 0, 0 ), /* loops */ /* RTDG */ PACK( 0, 0 ), /* MIAP[0] */ PACK( 2, 0 ), /* MIAP[1] */ PACK( 2, 0 ), @@ -764,7 +769,7 @@ /* SANGW */ PACK( 1, 0 ), /* AA */ PACK( 1, 0 ), - /* FlipPT */ PACK( 0, 0 ), + /* FlipPT */ PACK( 0, 0 ), /* loops */ /* FlipRgON */ PACK( 2, 0 ), /* FlipRgOFF */ PACK( 2, 0 ), /* INS_$83 */ PACK( 0, 0 ), @@ -782,8 +787,8 @@ /* INS_$8F */ PACK( 0, 0 ), /* INS_$90 */ PACK( 0, 0 ), - /* INS_$91 */ PACK( 0, 0 ), - /* INS_$92 */ PACK( 0, 0 ), + /* GETVAR */ PACK( 0, 0 ), /* will be handled specially */ + /* GETDATA */ PACK( 0, 1 ), /* INS_$93 */ PACK( 0, 0 ), /* INS_$94 */ PACK( 0, 0 ), /* INS_$95 */ PACK( 0, 0 ), @@ -1065,8 +1070,13 @@ "7 INS_$8F", "7 INS_$90", +#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT + "6 GETVAR", + "7 GETDATA", +#else "7 INS_$91", "7 INS_$92", +#endif "7 INS_$93", "7 INS_$94", "7 INS_$95", @@ -1603,7 +1613,7 @@ range = &exc->codeRangeTable[aRange - 1]; - if ( range->base == NULL ) /* invalid coderange */ + if ( !range->base ) /* invalid coderange */ { exc->error = FT_THROW( Invalid_CodeRange ); return FAILURE; @@ -1646,7 +1656,7 @@ /* zone :: The affected glyph zone. */ /* */ /* <Note> */ - /* See `ttinterp.h' for details on backwards compatibility mode. */ + /* See `ttinterp.h' for details on backward compatibility mode. */ /* `Touches' the point. */ /* */ static void @@ -1674,7 +1684,7 @@ /* Exception to the post-IUP curfew: Allow the x component of */ /* diagonal moves, but only post-IUP. DejaVu tries to adjust */ /* diagonal stems like on `Z' and `z' post-IUP. */ - if ( SUBPIXEL_HINTING_MINIMAL && !exc->backwards_compatibility ) + if ( SUBPIXEL_HINTING_MINIMAL && !exc->backward_compatibility ) zone->cur[point].x += FT_MulDiv( distance, v, exc->F_dot_P ); else #endif @@ -1690,10 +1700,10 @@ if ( v != 0 ) { #ifdef TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL - if ( !( SUBPIXEL_HINTING_MINIMAL && - exc->backwards_compatibility && - exc->iupx_called && - exc->iupy_called ) ) + if ( !( SUBPIXEL_HINTING_MINIMAL && + exc->backward_compatibility && + exc->iupx_called && + exc->iupy_called ) ) #endif zone->cur[point].y += FT_MulDiv( distance, v, exc->F_dot_P ); @@ -1746,7 +1756,7 @@ /* */ /* The following versions are used whenever both vectors are both */ /* along one of the coordinate unit vectors, i.e. in 90% of the cases. */ - /* See `ttinterp.h' for details on backwards compatibility mode. */ + /* See `ttinterp.h' for details on backward compatibility mode. */ /* */ /*************************************************************************/ @@ -1764,7 +1774,7 @@ #endif /* TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY */ #ifdef TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL - if ( SUBPIXEL_HINTING_MINIMAL && !exc->backwards_compatibility ) + if ( SUBPIXEL_HINTING_MINIMAL && !exc->backward_compatibility ) zone->cur[point].x += distance; else #endif @@ -1786,7 +1796,7 @@ #ifdef TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL if ( !( SUBPIXEL_HINTING_MINIMAL && - exc->backwards_compatibility && + exc->backward_compatibility && exc->iupx_called && exc->iupy_called ) ) #endif zone->cur[point].y += distance; @@ -2574,13 +2584,20 @@ Ins_MPS( TT_ExecContext exc, FT_Long* args ) { - /* Note: The point size should be irrelevant in a given font program; */ - /* we thus decide to return only the PPEM value. */ -#if 0 - args[0] = exc->metrics.pointSize; -#else - args[0] = exc->func_cur_ppem( exc ); -#endif + if ( NO_SUBPIXEL_HINTING ) + { + /* Microsoft's GDI bytecode interpreter always returns value 12; */ + /* we return the current PPEM value instead. */ + args[0] = exc->func_cur_ppem( exc ); + } + else + { + /* A possible practical application of the MPS instruction is to */ + /* implement optical scaling and similar features, which should be */ + /* based on perceptual attributes, thus independent of the */ + /* resolution. */ + args[0] = exc->pointSize; + } } @@ -2873,7 +2890,7 @@ /* */ /* NEG[]: NEGate */ /* Opcode range: 0x65 */ - /* Stack: f26.6 --> f26.6 */ + /* Stack: f26.6 --> f26.6 */ /* */ static void Ins_NEG( FT_Long* args ) @@ -3113,7 +3130,7 @@ /*************************************************************************/ /* */ /* MAX[]: MAXimum */ - /* Opcode range: 0x68 */ + /* Opcode range: 0x8B */ /* Stack: int32? int32? --> int32 */ /* */ static void @@ -3127,7 +3144,7 @@ /*************************************************************************/ /* */ /* MIN[]: MINimum */ - /* Opcode range: 0x69 */ + /* Opcode range: 0x8C */ /* Stack: int32? int32? --> int32 */ /* */ static void @@ -3371,13 +3388,27 @@ FT_Long* args ) { if ( args[0] == 0 && exc->args == 0 ) + { exc->error = FT_THROW( Bad_Argument ); + return; + } + exc->IP += args[0]; if ( exc->IP < 0 || ( exc->callTop > 0 && exc->IP > exc->callStack[exc->callTop - 1].Def->end ) ) + { exc->error = FT_THROW( Bad_Argument ); + return; + } + exc->step_ins = FALSE; + + if ( args[0] < 0 ) + { + if ( ++exc->neg_jump_counter > exc->neg_jump_counter_max ) + exc->error = FT_THROW( Execution_Too_Long ); + } } @@ -3533,6 +3564,13 @@ #endif /* TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY */ + /* FDEF is only allowed in `prep' or `fpgm' */ + if ( exc->curRange == tt_coderange_glyph ) + { + exc->error = FT_THROW( DEF_In_Glyf_Bytecode ); + return; + } + /* some font programs are broken enough to redefine functions! */ /* We will then parse the current table. */ @@ -3932,6 +3970,10 @@ Ins_Goto_CodeRange( exc, def->range, def->start ); exc->step_ins = FALSE; + + exc->loopcall_counter += (FT_ULong)args[0]; + if ( exc->loopcall_counter > exc->loopcall_counter_max ) + exc->error = FT_THROW( Execution_Too_Long ); } return; @@ -3955,6 +3997,13 @@ TT_DefRecord* limit; + /* we enable IDEF only in `prep' or `fpgm' */ + if ( exc->curRange == tt_coderange_glyph ) + { + exc->error = FT_THROW( DEF_In_Glyf_Bytecode ); + return; + } + /* First of all, look for the same function in our table */ def = exc->IDefs; @@ -4002,6 +4051,7 @@ exc->error = FT_THROW( Nested_DEFS ); return; case 0x2D: /* ENDF */ + def->end = exc->IP; return; } } @@ -4485,7 +4535,7 @@ /* */ /* FLIPOFF[]: Set auto-FLIP to OFF */ /* Opcode range: 0x4E */ - /* Stack: --> */ + /* Stack: --> */ /* */ static void Ins_FLIPOFF( TT_ExecContext exc ) @@ -5076,11 +5126,11 @@ #endif #ifdef TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL - /* Native ClearType fonts sign a waiver that turns off all backwards */ + /* Native ClearType fonts sign a waiver that turns off all backward */ /* compatibility hacks and lets them program points to the grid like */ /* it's 1996. They might sign a waiver for just one glyph, though. */ if ( SUBPIXEL_HINTING_MINIMAL ) - exc->backwards_compatibility = !FT_BOOL( L == 4 ); + exc->backward_compatibility = !FT_BOOL( L == 4 ); #endif } } @@ -5137,14 +5187,14 @@ /* */ /* SCANTYPE[]: SCAN TYPE */ /* Opcode range: 0x8D */ - /* Stack: uint32? --> */ + /* Stack: uint16 --> */ /* */ static void Ins_SCANTYPE( TT_ExecContext exc, FT_Long* args ) { if ( args[0] >= 0 ) - exc->GS.scan_type = (FT_Int)args[0]; + exc->GS.scan_type = (FT_Int)args[0] & 0xFFFF; } @@ -5168,11 +5218,11 @@ #ifdef TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL - /* See `ttinterp.h' for details on backwards compatibility mode. */ - if ( SUBPIXEL_HINTING_MINIMAL && - exc->backwards_compatibility && - exc->iupx_called && - exc->iupy_called ) + /* See `ttinterp.h' for details on backward compatibility mode. */ + if ( SUBPIXEL_HINTING_MINIMAL && + exc->backward_compatibility && + exc->iupx_called && + exc->iupy_called ) goto Fail; #endif @@ -5223,11 +5273,11 @@ #ifdef TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL - /* See `ttinterp.h' for details on backwards compatibility mode. */ - if ( SUBPIXEL_HINTING_MINIMAL && - exc->backwards_compatibility && - exc->iupx_called && - exc->iupy_called ) + /* See `ttinterp.h' for details on backward compatibility mode. */ + if ( SUBPIXEL_HINTING_MINIMAL && + exc->backward_compatibility && + exc->iupx_called && + exc->iupy_called ) return; #endif @@ -5261,11 +5311,11 @@ #ifdef TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL - /* See `ttinterp.h' for details on backwards compatibility mode. */ - if ( SUBPIXEL_HINTING_MINIMAL && - exc->backwards_compatibility && - exc->iupx_called && - exc->iupy_called ) + /* See `ttinterp.h' for details on backward compatibility mode. */ + if ( SUBPIXEL_HINTING_MINIMAL && + exc->backward_compatibility && + exc->iupx_called && + exc->iupy_called ) return; #endif @@ -5328,7 +5378,7 @@ } - /* See `ttinterp.h' for details on backwards compatibility mode. */ + /* See `ttinterp.h' for details on backward compatibility mode. */ static void Move_Zp2_Point( TT_ExecContext exc, FT_UShort point, @@ -5339,8 +5389,8 @@ if ( exc->GS.freeVector.x != 0 ) { #ifdef TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL - if ( !( SUBPIXEL_HINTING_MINIMAL && - exc->backwards_compatibility ) ) + if ( !( SUBPIXEL_HINTING_MINIMAL && + exc->backward_compatibility ) ) #endif exc->zp2.cur[point].x += dx; @@ -5351,10 +5401,10 @@ if ( exc->GS.freeVector.y != 0 ) { #ifdef TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL - if ( !( SUBPIXEL_HINTING_MINIMAL && - exc->backwards_compatibility && - exc->iupx_called && - exc->iupy_called ) ) + if ( !( SUBPIXEL_HINTING_MINIMAL && + exc->backward_compatibility && + exc->iupx_called && + exc->iupy_called ) ) #endif exc->zp2.cur[point].y += dy; @@ -5541,9 +5591,9 @@ FT_Int B1, B2; #endif #ifdef TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL - FT_Bool in_twilight = exc->GS.gep0 == 0 || \ - exc->GS.gep1 == 0 || \ - exc->GS.gep2 == 0; + FT_Bool in_twilight = FT_BOOL( exc->GS.gep0 == 0 || + exc->GS.gep1 == 0 || + exc->GS.gep2 == 0 ); #endif @@ -5651,14 +5701,14 @@ else #endif #ifdef TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL - if ( SUBPIXEL_HINTING_MINIMAL && - exc->backwards_compatibility ) + if ( SUBPIXEL_HINTING_MINIMAL && + exc->backward_compatibility ) { /* Special case: allow SHPIX to move points in the twilight zone. */ /* Otherwise, treat SHPIX the same as DELTAP. Unbreaks various */ /* fonts such as older versions of Rokkitt and DTL Argo T Light */ - /* that would glitch severly after calling ALIGNRP after a blocked */ - /* SHPIX. */ + /* that would glitch severely after calling ALIGNRP after a */ + /* blocked SHPIX. */ if ( in_twilight || ( !( exc->iupx_called && exc->iupy_called ) && ( ( exc->is_composite && exc->GS.freeVector.y != 0 ) || @@ -6088,7 +6138,6 @@ exc->GS.freeVector.x != 0 && !( exc->sph_tweak_flags & SPH_TWEAK_NORMAL_ROUND ) ) control_value_cutin = minimum_distance = 0; - else #endif /* TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY */ /* XXX: UNDOCUMENTED! cvt[-1] = 0 always */ @@ -6417,7 +6466,7 @@ R.x = FT_MulDiv( val, dax, discriminant ); R.y = FT_MulDiv( val, day, discriminant ); - /* XXX: Block in backwards_compatibility and/or post-IUP? */ + /* XXX: Block in backward_compatibility and/or post-IUP? */ exc->zp2.cur[point].x = exc->zp1.cur[a0].x + R.x; exc->zp2.cur[point].y = exc->zp1.cur[a0].y + R.y; } @@ -6425,7 +6474,7 @@ { /* else, take the middle of the middles of A and B */ - /* XXX: Block in backwards_compatibility and/or post-IUP? */ + /* XXX: Block in backward_compatibility and/or post-IUP? */ exc->zp2.cur[point].x = ( exc->zp1.cur[a0].x + exc->zp1.cur[a1].x + exc->zp0.cur[b0].x + @@ -6502,7 +6551,9 @@ * Otherwise, by definition, the value of exc->twilight.orus[n] is (0,0), * for every n. */ - twilight = exc->GS.gep0 == 0 || exc->GS.gep1 == 0 || exc->GS.gep2 == 0; + twilight = ( exc->GS.gep0 == 0 || + exc->GS.gep1 == 0 || + exc->GS.gep2 == 0 ); if ( BOUNDS( exc->GS.rp1, exc->zp0.n_points ) ) { @@ -6550,7 +6601,7 @@ cur_range = PROJECT( &exc->zp1.cur[exc->GS.rp2], cur_base ); } - for ( ; exc->GS.loop > 0; --exc->GS.loop ) + for ( ; exc->GS.loop > 0; exc->GS.loop-- ) { FT_UInt point = (FT_UInt)exc->stack[--exc->args]; FT_F26Dot6 org_dist, cur_dist, new_dist; @@ -6815,11 +6866,11 @@ #ifdef TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL - /* See `ttinterp.h' for details on backwards compatibility mode. */ + /* See `ttinterp.h' for details on backward compatibility mode. */ /* Allow IUP until it has been called on both axes. Immediately */ /* return on subsequent ones. */ - if ( SUBPIXEL_HINTING_MINIMAL && - exc->backwards_compatibility ) + if ( SUBPIXEL_HINTING_MINIMAL && + exc->backward_compatibility ) { if ( exc->iupx_called && exc->iupy_called ) return; @@ -7061,10 +7112,10 @@ { #ifdef TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL - /* See `ttinterp.h' for details on backwards compatibility */ - /* mode. */ - if ( SUBPIXEL_HINTING_MINIMAL && - exc->backwards_compatibility ) + /* See `ttinterp.h' for details on backward compatibility */ + /* mode. */ + if ( SUBPIXEL_HINTING_MINIMAL && + exc->backward_compatibility ) { if ( !( exc->iupx_called && exc->iupy_called ) && ( ( exc->is_composite && exc->GS.freeVector.y != 0 ) || @@ -7208,7 +7259,7 @@ { if ( exc->ignore_x_mode ) { - /* if in ClearType backwards compatibility mode, */ + /* if in ClearType backward compatibility mode, */ /* we sometimes change the TrueType version dynamically */ K = exc->rasterizer_version; FT_TRACE6(( "Setting rasterizer version %d\n", @@ -7228,7 +7279,7 @@ /* Return Bit(s): 8 */ /* */ if ( ( args[0] & 2 ) != 0 && exc->tt_metrics.rotated ) - K |= 0x80; + K |= 1 << 8; /********************************/ /* GLYPH STRETCHED */ @@ -7236,7 +7287,18 @@ /* Return Bit(s): 9 */ /* */ if ( ( args[0] & 4 ) != 0 && exc->tt_metrics.stretched ) - K |= 1 << 8; + K |= 1 << 9; + +#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT + /********************************/ + /* VARIATION GLYPH */ + /* Selector Bit: 3 */ + /* Return Bit(s): 10 */ + /* */ + /* XXX: UNDOCUMENTED! */ + if ( (args[0] & 8 ) != 0 && exc->face->blend ) + K |= 1 << 10; +#endif /********************************/ /* BI-LEVEL HINTING AND */ @@ -7380,6 +7442,57 @@ } +#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT + + /*************************************************************************/ + /* */ + /* GETVARIATION[]: get normalized variation (blend) coordinates */ + /* Opcode range: 0x91 */ + /* Stack: --> f2.14... */ + /* */ + /* XXX: UNDOCUMENTED! There is no official documentation from Apple for */ + /* this bytecode instruction. Active only if a font has GX */ + /* variation axes. */ + /* */ + static void + Ins_GETVARIATION( TT_ExecContext exc, + FT_Long* args ) + { + FT_UInt num_axes = exc->face->blend->num_axis; + FT_Fixed* coords = exc->face->blend->normalizedcoords; + + FT_UInt i; + + + if ( BOUNDS( num_axes, exc->stackSize + 1 - exc->top ) ) + { + exc->error = FT_THROW( Stack_Overflow ); + return; + } + + for ( i = 0; i < num_axes; i++ ) + args[i] = coords[i] >> 2; /* convert 16.16 to 2.14 format */ + } + + + /*************************************************************************/ + /* */ + /* GETDATA[]: no idea what this is good for */ + /* Opcode range: 0x92 */ + /* Stack: --> 17 */ + /* */ + /* XXX: UNDOCUMENTED! There is no documentation from Apple for this */ + /* very weird bytecode instruction. */ + /* */ + static void + Ins_GETDATA( FT_Long* args ) + { + args[0] = 17; + } + +#endif /* TT_CONFIG_OPTION_GX_VAR_SUPPORT */ + + static void Ins_UNKNOWN( TT_ExecContext exc ) { @@ -7453,7 +7566,8 @@ FT_EXPORT_DEF( FT_Error ) TT_RunIns( TT_ExecContext exc ) { - FT_Long ins_counter = 0; /* executed instructions counter */ + FT_ULong ins_counter = 0; /* executed instructions counter */ + FT_ULong num_twilight_points; FT_UShort i; #ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY @@ -7475,20 +7589,72 @@ #endif /* TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY */ #ifdef TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL - /* Toggle backwards compatibility according to what font says, except */ + /* Toggle backward compatibility according to what font says, except */ /* when it's a `tricky' font that heavily relies on the interpreter to */ - /* render glyphs correctly, e.g. DFKai-SB. Backwards compatibility */ + /* render glyphs correctly, e.g. DFKai-SB. Backward compatibility */ /* hacks may break it. */ if ( SUBPIXEL_HINTING_MINIMAL && !FT_IS_TRICKY( &exc->face->root ) ) - exc->backwards_compatibility = !( exc->GS.instruct_control & 4 ); + exc->backward_compatibility = !( exc->GS.instruct_control & 4 ); else - exc->backwards_compatibility = FALSE; + exc->backward_compatibility = FALSE; exc->iupx_called = FALSE; exc->iupy_called = FALSE; #endif + /* We restrict the number of twilight points to a reasonable, */ + /* heuristic value to avoid slow execution of malformed bytecode. */ + num_twilight_points = FT_MAX( 30, + 2 * ( exc->pts.n_points + exc->cvtSize ) ); + if ( exc->twilight.n_points > num_twilight_points ) + { + if ( num_twilight_points > 0xFFFFU ) + num_twilight_points = 0xFFFFU; + + FT_TRACE5(( "TT_RunIns: Resetting number of twilight points\n" + " from %d to the more reasonable value %d\n", + exc->twilight.n_points, + num_twilight_points )); + exc->twilight.n_points = (FT_UShort)num_twilight_points; + } + + /* Set up loop detectors. We restrict the number of LOOPCALL loops */ + /* and the number of JMPR, JROT, and JROF calls with a negative */ + /* argument to values that depend on various parameters like the */ + /* size of the CVT table or the number of points in the current */ + /* glyph (if applicable). */ + /* */ + /* The idea is that in real-world bytecode you either iterate over */ + /* all CVT entries (in the `prep' table), or over all points (or */ + /* contours, in the `glyf' table) of a glyph, and such iterations */ + /* don't happen very often. */ + exc->loopcall_counter = 0; + exc->neg_jump_counter = 0; + + /* The maximum values are heuristic. */ + if ( exc->pts.n_points ) + exc->loopcall_counter_max = FT_MAX( 50, + 10 * exc->pts.n_points ) + + FT_MAX( 50, + exc->cvtSize / 10 ); + else + exc->loopcall_counter_max = FT_MAX( 100, + 10 * exc->cvtSize ); + + /* as a protection against an unreasonable number of CVT entries */ + /* we assume at most 100 control values per glyph for the counter */ + if ( exc->loopcall_counter_max > + 100 * (FT_ULong)exc->face->root.num_glyphs ) + exc->loopcall_counter_max = 100 * (FT_ULong)exc->face->root.num_glyphs; + + FT_TRACE5(( "TT_RunIns: Limiting total number of loops in LOOPCALL" + " to %d\n", exc->loopcall_counter_max )); + + exc->neg_jump_counter_max = exc->loopcall_counter_max; + FT_TRACE5(( "TT_RunIns: Limiting total number of backward jumps" + " to %d\n", exc->neg_jump_counter_max )); + /* set PPEM and CVT functions */ exc->tt_metrics.ratio = 0; if ( exc->metrics.x_ppem != exc->metrics.y_ppem ) @@ -7566,7 +7732,21 @@ exc->args = 0; } - exc->new_top = exc->args + ( Pop_Push_Count[exc->opcode] & 15 ); +#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT + if ( exc->opcode == 0x91 ) + { + /* this is very special: GETVARIATION returns */ + /* a variable number of arguments */ + + /* it is the job of the application to `activate' GX handling, */ + /* this is, calling any of the GX API functions on the current */ + /* font to select a variation instance */ + if ( exc->face->blend ) + exc->new_top = exc->args + exc->face->blend->num_axis; + } + else +#endif + exc->new_top = exc->args + ( Pop_Push_Count[exc->opcode] & 15 ); /* `new_top' is the new top of the stack, after the instruction's */ /* execution. `top' will be set to `new_top' after the `switch' */ @@ -7759,7 +7939,7 @@ Ins_ALIGNPTS( exc, args ); break; - case 0x28: /* ???? */ + case 0x28: /* RAW */ Ins_UNKNOWN( exc ); break; @@ -8111,10 +8291,33 @@ Ins_INSTCTRL( exc, args ); break; - case 0x8F: + case 0x8F: /* ADJUST */ + case 0x90: /* ADJUST */ Ins_UNKNOWN( exc ); break; +#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT + case 0x91: + /* it is the job of the application to `activate' GX handling, */ + /* this is, calling any of the GX API functions on the current */ + /* font to select a variation instance */ + if ( exc->face->blend ) + Ins_GETVARIATION( exc, args ); + else + Ins_UNKNOWN( exc ); + break; + + case 0x92: + /* there is at least one MS font (LaoUI.ttf version 5.01) that */ + /* uses IDEFs for 0x91 and 0x92; for this reason we activate */ + /* GETDATA for GX fonts only, similar to GETVARIATION */ + if ( exc->face->blend ) + Ins_GETDATA( args ); + else + Ins_UNKNOWN( exc ); + break; +#endif + default: if ( opcode >= 0xE0 ) Ins_MIRP( exc, args ); @@ -8212,29 +8415,25 @@ } while ( !exc->instruction_trap ); LNo_Error_: + FT_TRACE4(( " %d instructions executed\n", ins_counter )); return FT_Err_Ok; LErrorCodeOverflow_: exc->error = FT_THROW( Code_Overflow ); LErrorLabel_: - /* 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 ( exc->error && - !exc->instruction_trap && - exc->curRange == tt_coderange_glyph ) - { + if ( exc->error && !exc->instruction_trap ) FT_TRACE1(( " The interpreter returned error 0x%x\n", exc->error )); - exc->size->bytecode_ready = -1; - exc->size->cvt_ready = -1; - } return exc->error; } +#else /* !TT_USE_BYTECODE_INTERPRETER */ + + /* ANSI C doesn't like empty source files */ + typedef int _tt_interp_dummy; -#endif /* TT_USE_BYTECODE_INTERPRETER */ +#endif /* !TT_USE_BYTECODE_INTERPRETER */ /* END */ diff --git a/thirdparty/freetype/src/truetype/ttinterp.h b/thirdparty/freetype/src/truetype/ttinterp.h index df7ce51f1c..55e472091c 100644 --- a/thirdparty/freetype/src/truetype/ttinterp.h +++ b/thirdparty/freetype/src/truetype/ttinterp.h @@ -4,7 +4,7 @@ /* */ /* TrueType bytecode interpreter (specification). */ /* */ -/* Copyright 1996-2016 by */ +/* Copyright 1996-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -170,6 +170,7 @@ FT_BEGIN_HEADER pts, twilight; + FT_Long pointSize; /* in 26.6 format */ FT_Size_Metrics metrics; TT_Size_Metrics tt_metrics; /* size metrics */ @@ -255,7 +256,7 @@ FT_BEGIN_HEADER * Modern TrueType fonts are usually rendered through Microsoft's * collection of rendering techniques called ClearType (e.g., subpixel * rendering and subpixel hinting). When ClearType was introduced, most - * fonts were not ready. Microsoft decided to implement a backwards + * fonts were not ready. Microsoft decided to implement a backward * compatibility mode that employed several simple to complicated * assumptions and tricks that modified the interpretation of the * bytecode contained in these fonts to make them look ClearType-y @@ -315,12 +316,12 @@ FT_BEGIN_HEADER * very specific patterns (`superhinting') for pre-ClearType-displays, * the worse the results. * - * Microsoft defines a way to turn off backwards compatibility and + * Microsoft defines a way to turn off backward compatibility and * interpret instructions as before (called `native ClearType')[2][3]. * The font designer then regains full control and is responsible for * making the font work correctly with ClearType without any * hand-holding by the interpreter or rasterizer[4]. The v40 - * interpreter assumes backwards compatibility by default, which can be + * interpreter assumes backward compatibility by default, which can be * turned off the same way by executing the following in the control * program (cf. `Ins_INSTCTRL'). * @@ -330,7 +331,7 @@ FT_BEGIN_HEADER * [1] Tricky fonts as FreeType defines them rely on the bytecode * interpreter to display correctly. Hacks can interfere with them, * so they get treated like native ClearType fonts (v40 with - * backwards compatibility turned off). Cf. `TT_RunIns'. + * backward compatibility turned off). Cf. `TT_RunIns'. * * [2] Proposed by Microsoft's Greg Hitchcock in * https://www.microsoft.com/typography/cleartype/truetypecleartype.aspx @@ -356,10 +357,10 @@ FT_BEGIN_HEADER /* is managed differently. */ FT_Bool vertical_lcd_lean; - /* Default to backwards compatibility mode in v40 interpreter. If */ + /* Default to backward compatibility mode in v40 interpreter. If */ /* this is false, it implies the interpreter is in v35 or in native */ /* ClearType mode. */ - FT_Bool backwards_compatibility; + FT_Bool backward_compatibility; /* Useful for detecting and denying post-IUP trickery that is usually */ /* used to fix pixel patterns (`superhinting'). */ @@ -407,6 +408,14 @@ FT_BEGIN_HEADER #endif /* TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY */ + /* We maintain two counters (in addition to the instruction counter) */ + /* that act as loop detectors for LOOPCALL and jump opcodes with */ + /* negative arguments. */ + FT_ULong loopcall_counter; + FT_ULong loopcall_counter_max; + FT_ULong neg_jump_counter; + FT_ULong neg_jump_counter_max; + } TT_ExecContextRec; diff --git a/thirdparty/freetype/src/truetype/ttobjs.c b/thirdparty/freetype/src/truetype/ttobjs.c index ed3be2dbee..4db0f289f8 100644 --- a/thirdparty/freetype/src/truetype/ttobjs.c +++ b/thirdparty/freetype/src/truetype/ttobjs.c @@ -4,7 +4,7 @@ /* */ /* Objects manager (body). */ /* */ -/* Copyright 1996-2016 by */ +/* Copyright 1996-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -117,7 +117,7 @@ FT_Error error; - FT_MEM_ZERO( zone, sizeof ( *zone ) ); + FT_ZERO( zone ); zone->memory = memory; if ( FT_NEW_ARRAY( zone->org, maxPoints ) || @@ -147,20 +147,43 @@ { #define TRICK_NAMES_MAX_CHARACTERS 19 -#define TRICK_NAMES_COUNT 9 +#define TRICK_NAMES_COUNT 18 static const char trick_names[TRICK_NAMES_COUNT] [TRICK_NAMES_MAX_CHARACTERS + 1] = { + /* + PostScript names are given in brackets if they differ from the + family name. The version numbers, together with the copyright or + release year data, are taken from fonts available to the + developers. + + Note that later versions of the fonts might be no longer tricky; + for example, `MingLiU' version 7.00 (file `mingliu.ttc' from + Windows 7) is an ordinary TTC with non-tricky subfonts. + */ + + "cpop", /* dftt-p7.ttf; version 1.00, 1992 [DLJGyShoMedium] */ + "DFGirl-W6-WIN-BF", /* dftt-h6.ttf; version 1.00, 1993 */ "DFKaiSho-SB", /* dfkaisb.ttf */ "DFKaiShu", - "DFKai-SB", /* kaiu.ttf */ + "DFKai-SB", /* kaiu.ttf; version 3.00, 1998 [DFKaiShu-SB-Estd-BF] */ + "DLC", /* dftt-m7.ttf; version 1.00, 1993 [DLCMingBold] */ + /* dftt-f5.ttf; version 1.00, 1993 [DLCFongSung] */ + "DLCHayMedium", /* dftt-b5.ttf; version 1.00, 1993 */ + "DLCHayBold", /* dftt-b7.ttf; version 1.00, 1993 */ + "DLCKaiMedium", /* dftt-k5.ttf; version 1.00, 1992 */ + "DLCLiShu", /* dftt-l5.ttf; version 1.00, 1992 */ + "DLCRoundBold", /* dftt-r7.ttf; version 1.00, 1993 */ "HuaTianKaiTi?", /* htkt2.ttf */ "HuaTianSongTi?", /* htst3.ttf */ - "Ming(for ISO10646)", /* hkscsiic.ttf & iicore.ttf */ - "MingLiU", /* mingliu.ttf & mingliu.ttc */ - "PMingLiU", /* mingliu.ttc */ - "MingLi43", /* mingli.ttf */ + "Ming(for ISO10646)", /* hkscsiic.ttf; version 0.12, 2007 [Ming] */ + /* iicore.ttf; version 0.07, 2007 [Ming] */ + "MingLiU", /* mingliu.ttf */ + /* mingliu.ttc; version 3.21, 2001 */ + "MingMedium", /* dftt-m5.ttf; version 1.00, 1993 [DLCMingMedium] */ + "PMingLiU", /* mingliu.ttc; version 3.21, 2001 */ + "MingLi43", /* mingli.ttf; version 1.00, 1992 */ }; int nn; @@ -242,7 +265,7 @@ tt_check_trickyness_sfnt_ids( TT_Face face ) { #define TRICK_SFNT_IDS_PER_FACE 3 -#define TRICK_SFNT_IDS_NUM_FACES 18 +#define TRICK_SFNT_IDS_NUM_FACES 19 static const tt_sfnt_id_rec sfnt_id[TRICK_SFNT_IDS_NUM_FACES] [TRICK_SFNT_IDS_PER_FACE] = { @@ -266,7 +289,7 @@ { 0x5A30CA3BUL, 0x00009063UL }, /* fpgm */ { 0x13A42602UL, 0x0000007EUL } /* prep */ }, - { /* DFKaiShu2 */ + { /* DFKaiShu, variant */ { 0x11E5EAD4UL, 0x00000350UL }, /* cvt */ { 0xA6E78C01UL, 0x00008998UL }, /* fpgm */ { 0x13A42602UL, 0x0000007EUL } /* prep */ @@ -340,6 +363,11 @@ { 0x00000000UL, 0x00000000UL }, /* cvt */ { 0xF055FC48UL, 0x000001C2UL }, /* fpgm */ { 0x3900DED3UL, 0x00001E18UL } /* prep */ + }, + { /* MINGLI.TTF, 1992 */ + { 0x00170003UL, 0x00000060UL }, /* cvt */ + { 0xDBB4306EUL, 0x000058AAUL }, /* fpgm */ + { 0xD643482AUL, 0x00000035UL } /* prep */ } }; @@ -536,6 +564,7 @@ goto Exit; /* check that we have a valid TrueType file */ + FT_TRACE2(( " " )); error = sfnt->init_face( stream, face, face_index, num_params, params ); /* Stream may have changed. */ @@ -577,58 +606,50 @@ if ( FT_IS_SCALABLE( ttface ) ) { - #ifdef FT_CONFIG_OPTION_INCREMENTAL - if ( !ttface->internal->incremental_interface ) - error = tt_face_load_loca( face, stream ); - if ( !error ) - error = tt_face_load_cvt( face, stream ); - if ( !error ) - error = tt_face_load_fpgm( face, stream ); - if ( !error ) - error = tt_face_load_prep( face, stream ); - - /* Check the scalable flag based on `loca'. */ - if ( !ttface->internal->incremental_interface && - ttface->num_fixed_sizes && - face->glyph_locations && - tt_check_single_notdef( ttface ) ) +#endif { - FT_TRACE5(( "tt_face_init:" - " Only the `.notdef' glyph has an outline.\n" - " " - " Resetting scalable flag to FALSE.\n" )); + error = tt_face_load_loca( face, stream ); - ttface->face_flags &= ~FT_FACE_FLAG_SCALABLE; + /* having a (non-zero) `glyf' table without */ + /* a `loca' table is not valid */ + if ( face->glyf_len && FT_ERR_EQ( error, Table_Missing ) ) + goto Exit; + if ( error ) + goto Exit; } -#else /* !FT_CONFIG_OPTION_INCREMENTAL */ + /* `fpgm', `cvt', and `prep' are optional */ + error = tt_face_load_cvt( face, stream ); + if ( error && FT_ERR_NEQ( error, Table_Missing ) ) + goto Exit; - if ( !error ) - error = tt_face_load_loca( face, stream ); - if ( !error ) - error = tt_face_load_cvt( face, stream ); - if ( !error ) - error = tt_face_load_fpgm( face, stream ); - if ( !error ) - error = tt_face_load_prep( face, stream ); + error = tt_face_load_fpgm( face, stream ); + if ( error && FT_ERR_NEQ( error, Table_Missing ) ) + goto Exit; + + error = tt_face_load_prep( face, stream ); + if ( error && FT_ERR_NEQ( error, Table_Missing ) ) + goto Exit; /* Check the scalable flag based on `loca'. */ - if ( ttface->num_fixed_sizes && - face->glyph_locations && - tt_check_single_notdef( ttface ) ) +#ifdef FT_CONFIG_OPTION_INCREMENTAL + if ( !ttface->internal->incremental_interface ) +#endif { - FT_TRACE5(( "tt_face_init:" - " Only the `.notdef' glyph has an outline.\n" - " " - " Resetting scalable flag to FALSE.\n" )); + if ( ttface->num_fixed_sizes && + face->glyph_locations && + tt_check_single_notdef( ttface ) ) + { + FT_TRACE5(( "tt_face_init:" + " Only the `.notdef' glyph has an outline.\n" + " " + " Resetting scalable flag to FALSE.\n" )); - ttface->face_flags &= ~FT_FACE_FLAG_SCALABLE; + ttface->face_flags &= ~FT_FACE_FLAG_SCALABLE; + } } - -#endif /* !FT_CONFIG_OPTION_INCREMENTAL */ - } #ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT @@ -671,6 +692,8 @@ named_style->coords ); if ( error ) goto Exit; + + tt_apply_mvar( face ); } } } @@ -739,7 +762,7 @@ face->cvt_program_size = 0; #ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT - tt_done_blend( memory, face->blend ); + tt_done_blend( face ); face->blend = NULL; #endif } @@ -797,14 +820,14 @@ exec->pedantic_hinting = pedantic; { - FT_Size_Metrics* metrics = &exec->metrics; - TT_Size_Metrics* tt_metrics = &exec->tt_metrics; + FT_Size_Metrics* size_metrics = &exec->metrics; + TT_Size_Metrics* tt_metrics = &exec->tt_metrics; - metrics->x_ppem = 0; - metrics->y_ppem = 0; - metrics->x_scale = 0; - metrics->y_scale = 0; + size_metrics->x_ppem = 0; + size_metrics->y_ppem = 0; + size_metrics->x_scale = 0; + size_metrics->y_scale = 0; tt_metrics->ppem = 0; tt_metrics->scale = 0; @@ -827,6 +850,11 @@ FT_TRACE4(( "Executing `fpgm' table.\n" )); error = face->interpreter( exec ); +#ifdef FT_DEBUG_LEVEL_TRACE + if ( error ) + FT_TRACE4(( " interpretation failed with error code 0x%x\n", + error )); +#endif } else error = FT_Err_Ok; @@ -890,8 +918,12 @@ TT_Goto_CodeRange( exec, tt_coderange_cvt, 0 ); FT_TRACE4(( "Executing `prep' table.\n" )); - error = face->interpreter( exec ); +#ifdef FT_DEBUG_LEVEL_TRACE + if ( error ) + FT_TRACE4(( " interpretation failed with error code 0x%x\n", + error )); +#endif } else error = FT_Err_Ok; @@ -1010,17 +1042,17 @@ /* Set default metrics */ { - TT_Size_Metrics* metrics = &size->ttmetrics; + TT_Size_Metrics* tt_metrics = &size->ttmetrics; - metrics->rotated = FALSE; - metrics->stretched = FALSE; + tt_metrics->rotated = FALSE; + tt_metrics->stretched = FALSE; /* set default engine compensation */ - metrics->compensations[0] = 0; /* gray */ - metrics->compensations[1] = 0; /* black */ - metrics->compensations[2] = 0; /* white */ - metrics->compensations[3] = 0; /* reserved */ + tt_metrics->compensations[0] = 0; /* gray */ + tt_metrics->compensations[1] = 0; /* black */ + tt_metrics->compensations[2] = 0; /* white */ + tt_metrics->compensations[3] = 0; /* reserved */ } /* allocate function defs, instruction defs, cvt, and storage area */ @@ -1083,8 +1115,10 @@ if ( size->bytecode_ready < 0 ) error = tt_size_init_bytecode( (FT_Size)size, pedantic ); + else + error = size->bytecode_ready; - if ( error || size->bytecode_ready ) + if ( error ) goto Exit; /* rescale CVT when needed */ @@ -1116,6 +1150,8 @@ error = tt_size_run_prep( size, pedantic ); } + else + error = size->cvt_ready; Exit: return error; @@ -1192,26 +1228,32 @@ /* have been changed. */ /* */ /* <Input> */ - /* size :: A handle to the target size object. */ + /* size :: A handle to the target size object. */ + /* */ + /* only_height :: Only recompute ascender, descender, and height. */ /* */ FT_LOCAL_DEF( FT_Error ) - tt_size_reset( TT_Size size ) + tt_size_reset( TT_Size size, + FT_Bool only_height ) { TT_Face face; - FT_Error error = FT_Err_Ok; - FT_Size_Metrics* metrics; - + FT_Size_Metrics* size_metrics; - size->ttmetrics.valid = FALSE; face = (TT_Face)size->root.face; - metrics = &size->metrics; + /* nothing to do for CFF2 */ + if ( face->is_cff2 ) + return FT_Err_Ok; + + size->ttmetrics.valid = FALSE; + + size_metrics = &size->hinted_metrics; /* copy the result from base layer */ - *metrics = size->root.metrics; + *size_metrics = size->root.metrics; - if ( metrics->x_ppem < 1 || metrics->y_ppem < 1 ) + if ( size_metrics->x_ppem < 1 || size_metrics->y_ppem < 1 ) return FT_THROW( Invalid_PPem ); /* This bit flag, if set, indicates that the ppems must be */ @@ -1220,48 +1262,62 @@ /* */ if ( face->header.Flags & 8 ) { - metrics->x_scale = FT_DivFix( metrics->x_ppem << 6, - face->root.units_per_EM ); - metrics->y_scale = FT_DivFix( metrics->y_ppem << 6, - face->root.units_per_EM ); - - metrics->ascender = - FT_PIX_ROUND( FT_MulFix( face->root.ascender, metrics->y_scale ) ); - metrics->descender = - FT_PIX_ROUND( FT_MulFix( face->root.descender, metrics->y_scale ) ); - metrics->height = - FT_PIX_ROUND( FT_MulFix( face->root.height, metrics->y_scale ) ); - metrics->max_advance = - FT_PIX_ROUND( FT_MulFix( face->root.max_advance_width, - metrics->x_scale ) ); + /* the TT spec always asks for ROUND, not FLOOR or CEIL */ + size_metrics->ascender = FT_PIX_ROUND( + FT_MulFix( face->root.ascender, + size_metrics->y_scale ) ); + size_metrics->descender = FT_PIX_ROUND( + FT_MulFix( face->root.descender, + size_metrics->y_scale ) ); + size_metrics->height = FT_PIX_ROUND( + FT_MulFix( face->root.height, + size_metrics->y_scale ) ); + } + + size->ttmetrics.valid = TRUE; + + if ( only_height ) + return FT_Err_Ok; + + if ( face->header.Flags & 8 ) + { + /* base scaling values on integer ppem values, */ + /* as mandated by the TrueType specification */ + size_metrics->x_scale = FT_DivFix( size_metrics->x_ppem << 6, + face->root.units_per_EM ); + size_metrics->y_scale = FT_DivFix( size_metrics->y_ppem << 6, + face->root.units_per_EM ); + + size_metrics->max_advance = FT_PIX_ROUND( + FT_MulFix( face->root.max_advance_width, + size_metrics->x_scale ) ); } /* compute new transformation */ - if ( metrics->x_ppem >= metrics->y_ppem ) + if ( size_metrics->x_ppem >= size_metrics->y_ppem ) { - size->ttmetrics.scale = metrics->x_scale; - size->ttmetrics.ppem = metrics->x_ppem; + size->ttmetrics.scale = size_metrics->x_scale; + size->ttmetrics.ppem = size_metrics->x_ppem; size->ttmetrics.x_ratio = 0x10000L; - size->ttmetrics.y_ratio = FT_DivFix( metrics->y_ppem, - metrics->x_ppem ); + size->ttmetrics.y_ratio = FT_DivFix( size_metrics->y_ppem, + size_metrics->x_ppem ); } else { - size->ttmetrics.scale = metrics->y_scale; - size->ttmetrics.ppem = metrics->y_ppem; - size->ttmetrics.x_ratio = FT_DivFix( metrics->x_ppem, - metrics->y_ppem ); + size->ttmetrics.scale = size_metrics->y_scale; + size->ttmetrics.ppem = size_metrics->y_ppem; + size->ttmetrics.x_ratio = FT_DivFix( size_metrics->x_ppem, + size_metrics->y_ppem ); size->ttmetrics.y_ratio = 0x10000L; } + size->metrics = size_metrics; + #ifdef TT_USE_BYTECODE_INTERPRETER size->cvt_ready = -1; #endif /* TT_USE_BYTECODE_INTERPRETER */ - if ( !error ) - size->ttmetrics.valid = TRUE; - - return error; + return FT_Err_Ok; } diff --git a/thirdparty/freetype/src/truetype/ttobjs.h b/thirdparty/freetype/src/truetype/ttobjs.h index ed61a7d517..cdacee75e5 100644 --- a/thirdparty/freetype/src/truetype/ttobjs.h +++ b/thirdparty/freetype/src/truetype/ttobjs.h @@ -4,7 +4,7 @@ /* */ /* Objects manager (specification). */ /* */ -/* Copyright 1996-2016 by */ +/* Copyright 1996-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -278,7 +278,8 @@ FT_BEGIN_HEADER /* we have our own copy of metrics so that we can modify */ /* it without affecting auto-hinting (when used) */ - FT_Size_Metrics metrics; + FT_Size_Metrics* metrics; /* for the current rendering mode */ + FT_Size_Metrics hinted_metrics; /* for the hinted rendering mode */ TT_Size_Metrics ttmetrics; @@ -286,6 +287,8 @@ FT_BEGIN_HEADER #ifdef TT_USE_BYTECODE_INTERPRETER + FT_Long point_size; /* for the `MPS' bytecode instruction */ + FT_UInt num_function_defs; /* number of function definitions */ FT_UInt max_function_defs; TT_DefArray function_defs; /* table of function definitions */ @@ -387,7 +390,8 @@ FT_BEGIN_HEADER #endif /* TT_USE_BYTECODE_INTERPRETER */ FT_LOCAL( FT_Error ) - tt_size_reset( TT_Size size ); + tt_size_reset( TT_Size size, + FT_Bool only_height ); /*************************************************************************/ diff --git a/thirdparty/freetype/src/truetype/ttpic.c b/thirdparty/freetype/src/truetype/ttpic.c index 54a5b8bed6..66bd7e1934 100644 --- a/thirdparty/freetype/src/truetype/ttpic.c +++ b/thirdparty/freetype/src/truetype/ttpic.c @@ -4,7 +4,7 @@ /* */ /* The FreeType position independent code services for truetype module. */ /* */ -/* Copyright 2009-2016 by */ +/* Copyright 2009-2017 by */ /* Oran Agra and Mickey Gabel. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/thirdparty/freetype/src/truetype/ttpic.h b/thirdparty/freetype/src/truetype/ttpic.h index f725865c5c..1410cd73c3 100644 --- a/thirdparty/freetype/src/truetype/ttpic.h +++ b/thirdparty/freetype/src/truetype/ttpic.h @@ -4,7 +4,7 @@ /* */ /* The FreeType position independent code services for truetype module. */ /* */ -/* Copyright 2009-2016 by */ +/* Copyright 2009-2017 by */ /* Oran Agra and Mickey Gabel. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -25,15 +25,17 @@ #ifndef FT_CONFIG_OPTION_PIC -#define TT_SERVICES_GET tt_services -#define TT_SERVICE_GX_MULTI_MASTERS_GET tt_service_gx_multi_masters -#define TT_SERVICE_TRUETYPE_GLYF_GET tt_service_truetype_glyf -#define TT_SERVICE_PROPERTIES_GET tt_service_properties +#define TT_SERVICES_GET tt_services +#define TT_SERVICE_GX_MULTI_MASTERS_GET tt_service_gx_multi_masters +#define TT_SERVICE_METRICS_VARIATIONS_GET tt_service_metrics_variations +#define TT_SERVICE_TRUETYPE_GLYF_GET tt_service_truetype_glyf +#define TT_SERVICE_PROPERTIES_GET tt_service_properties #else /* FT_CONFIG_OPTION_PIC */ #include FT_MULTIPLE_MASTERS_H #include FT_SERVICE_MULTIPLE_MASTERS_H +#include FT_SERVICE_METRICS_VARIATIONS_H #include FT_SERVICE_TRUETYPE_GLYF_H #include FT_SERVICE_PROPERTIES_H @@ -42,12 +44,13 @@ FT_BEGIN_HEADER typedef struct TTModulePIC_ { - FT_ServiceDescRec* tt_services; + FT_ServiceDescRec* tt_services; #ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT - FT_Service_MultiMastersRec tt_service_gx_multi_masters; + FT_Service_MultiMastersRec tt_service_gx_multi_masters; + FT_Service_MetricsVariationsRec tt_service_metrics_variations; #endif - FT_Service_TTGlyfRec tt_service_truetype_glyf; - FT_Service_PropertiesRec tt_service_properties; + FT_Service_TTGlyfRec tt_service_truetype_glyf; + FT_Service_PropertiesRec tt_service_properties; } TTModulePIC; @@ -56,6 +59,8 @@ FT_BEGIN_HEADER ( (TTModulePIC*)((lib)->pic_container.truetype) ) #define TT_SERVICES_GET \ ( GET_PIC( library )->tt_services ) +#define TT_SERVICE_METRICS_VARIATIONS_GET \ + ( GET_PIC( library )->tt_service_metrics_variations ) #define TT_SERVICE_GX_MULTI_MASTERS_GET \ ( GET_PIC( library )->tt_service_gx_multi_masters ) #define TT_SERVICE_TRUETYPE_GLYF_GET \ diff --git a/thirdparty/freetype/src/truetype/ttpload.c b/thirdparty/freetype/src/truetype/ttpload.c index ca158ac50b..70ac15da4a 100644 --- a/thirdparty/freetype/src/truetype/ttpload.c +++ b/thirdparty/freetype/src/truetype/ttpload.c @@ -4,7 +4,7 @@ /* */ /* TrueType-specific tables loader (body). */ /* */ -/* Copyright 1996-2016 by */ +/* Copyright 1996-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -73,9 +73,21 @@ /* it is possible that a font doesn't have a glyf table at all */ /* or its size is zero */ if ( FT_ERR_EQ( error, Table_Missing ) ) - face->glyf_len = 0; + { + face->glyf_len = 0; + face->glyf_offset = 0; + } else if ( error ) goto Exit; + else + { +#ifdef FT_CONFIG_OPTION_INCREMENTAL + if ( face->root.internal->incremental_interface ) + face->glyf_offset = 0; + else +#endif + face->glyf_offset = FT_STREAM_POS(); + } FT_TRACE2(( "Locations " )); error = face->goto_table( face, TTAG_loca, stream, &table_len ); @@ -92,8 +104,7 @@ if ( table_len >= 0x40000L ) { FT_TRACE2(( "table too large\n" )); - error = FT_THROW( Invalid_Table ); - goto Exit; + table_len = 0x3FFFFL; } face->num_locations = table_len >> shift; } @@ -104,8 +115,7 @@ if ( table_len >= 0x20000L ) { FT_TRACE2(( "table too large\n" )); - error = FT_THROW( Invalid_Table ); - goto Exit; + table_len = 0x1FFFFL; } face->num_locations = table_len >> shift; } @@ -222,13 +232,13 @@ } } - /* Check broken location data */ + /* Check broken location data. */ if ( pos1 > face->glyf_len ) { FT_TRACE1(( "tt_face_get_location:" - " too large offset=0x%08lx found for gid=0x%04lx,\n" + " too large offset (0x%08lx) found for glyph index %ld,\n" " " - " exceeding the end of glyf table (0x%08lx)\n", + " exceeding the end of `glyf' table (0x%08lx)\n", pos1, gindex, face->glyf_len )); *asize = 0; return 0; @@ -236,12 +246,26 @@ if ( pos2 > face->glyf_len ) { - FT_TRACE1(( "tt_face_get_location:" - " too large offset=0x%08lx found for gid=0x%04lx,\n" - " " - " truncate at the end of glyf table (0x%08lx)\n", - pos2, gindex + 1, face->glyf_len )); - pos2 = face->glyf_len; + /* We try to sanitize the last `loca' entry. */ + if ( gindex == face->num_locations - 1 ) + { + FT_TRACE1(( "tt_face_get_location:" + " too large offset (0x%08lx) found for glyph index %ld,\n" + " " + " truncating at the end of `glyf' table (0x%08lx)\n", + pos2, gindex + 1, face->glyf_len )); + pos2 = face->glyf_len; + } + else + { + FT_TRACE1(( "tt_face_get_location:" + " too large offset (0x%08lx) found for glyph index %ld,\n" + " " + " exceeding the end of `glyf' table (0x%08lx)\n", + pos2, gindex + 1, face->glyf_len )); + *asize = 0; + return 0; + } } /* The `loca' table must be ordered; it refers to the length of */ @@ -500,7 +524,7 @@ { FT_Error error; FT_Memory memory = stream->memory; - FT_UInt version, nn, num_records; + FT_UInt nn, num_records; FT_ULong table_size, record_size; FT_Byte* p; FT_Byte* limit; @@ -517,7 +541,10 @@ p = face->hdmx_table; limit = p + table_size; - version = FT_NEXT_USHORT( p ); + /* Given that `hdmx' tables are losing its importance (for example, */ + /* variation fonts introduced in OpenType 1.8 must not have this */ + /* table) we no longer test for a correct `version' field. */ + p += 2; num_records = FT_NEXT_USHORT( p ); record_size = FT_NEXT_ULONG( p ); @@ -536,10 +563,10 @@ record_size &= 0xFFFFU; /* The limit for `num_records' is a heuristic value. */ - if ( version != 0 || - num_records > 255 || - record_size > 0x10001L || - record_size < 4 ) + if ( num_records > 255 || + ( num_records > 0 && + ( record_size > 0x10001L || + record_size < 4 ) ) ) { error = FT_THROW( Invalid_File_Format ); goto Fail; diff --git a/thirdparty/freetype/src/truetype/ttpload.h b/thirdparty/freetype/src/truetype/ttpload.h index aa2e38e6e7..79079f345a 100644 --- a/thirdparty/freetype/src/truetype/ttpload.h +++ b/thirdparty/freetype/src/truetype/ttpload.h @@ -4,7 +4,7 @@ /* */ /* TrueType-specific tables loader (specification). */ /* */ -/* Copyright 1996-2016 by */ +/* Copyright 1996-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/thirdparty/freetype/src/truetype/ttsubpix.c b/thirdparty/freetype/src/truetype/ttsubpix.c index 03950960a4..1c8cf01109 100644 --- a/thirdparty/freetype/src/truetype/ttsubpix.c +++ b/thirdparty/freetype/src/truetype/ttsubpix.c @@ -4,7 +4,7 @@ /* */ /* TrueType Subpixel Hinting. */ /* */ -/* Copyright 2010-2016 by */ +/* Copyright 2010-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -27,7 +27,8 @@ #include "ttsubpix.h" -#ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY +#if defined( TT_USE_BYTECODE_INTERPRETER ) && \ + defined( TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY ) /*************************************************************************/ /* */ @@ -905,7 +906,7 @@ { TT_Face face = loader->face; FT_String* family = face->root.family_name; - FT_UInt ppem = loader->size->metrics.x_ppem; + FT_UInt ppem = loader->size->metrics->x_ppem; FT_String* style = face->root.style_name; @@ -1000,12 +1001,14 @@ } } -#else /* !TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY */ +#else /* !(TT_USE_BYTECODE_INTERPRETER && */ + /* TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY) */ /* ANSI C doesn't like empty source files */ typedef int _tt_subpix_dummy; -#endif /* !TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY */ +#endif /* !(TT_USE_BYTECODE_INTERPRETER && */ + /* TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY) */ /* END */ diff --git a/thirdparty/freetype/src/truetype/ttsubpix.h b/thirdparty/freetype/src/truetype/ttsubpix.h index 86844da666..c68f97ff07 100644 --- a/thirdparty/freetype/src/truetype/ttsubpix.h +++ b/thirdparty/freetype/src/truetype/ttsubpix.h @@ -4,7 +4,7 @@ /* */ /* TrueType Subpixel Hinting. */ /* */ -/* Copyright 2010-2016 by */ +/* Copyright 2010-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/thirdparty/freetype/src/type1/module.mk b/thirdparty/freetype/src/type1/module.mk index d7ab520c74..f299d6fe88 100644 --- a/thirdparty/freetype/src/type1/module.mk +++ b/thirdparty/freetype/src/type1/module.mk @@ -3,7 +3,7 @@ # -# Copyright 1996-2016 by +# Copyright 1996-2017 by # David Turner, Robert Wilhelm, and Werner Lemberg. # # This file is part of the FreeType project, and may only be used, modified, diff --git a/thirdparty/freetype/src/type1/rules.mk b/thirdparty/freetype/src/type1/rules.mk index bdec29479f..97bef288f0 100644 --- a/thirdparty/freetype/src/type1/rules.mk +++ b/thirdparty/freetype/src/type1/rules.mk @@ -3,7 +3,7 @@ # -# Copyright 1996-2016 by +# Copyright 1996-2017 by # David Turner, Robert Wilhelm, and Werner Lemberg. # # This file is part of the FreeType project, and may only be used, modified, diff --git a/thirdparty/freetype/src/type1/t1afm.c b/thirdparty/freetype/src/type1/t1afm.c index bbd843c1c3..11a2646fc2 100644 --- a/thirdparty/freetype/src/type1/t1afm.c +++ b/thirdparty/freetype/src/type1/t1afm.c @@ -4,7 +4,7 @@ /* */ /* AFM support for Type 1 fonts (body). */ /* */ -/* Copyright 1996-2016 by */ +/* Copyright 1996-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -24,6 +24,8 @@ #include "t1errors.h" +#ifndef T1_CONFIG_OPTION_NO_AFM + /*************************************************************************/ /* */ /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ @@ -208,7 +210,7 @@ kp++; } - if ( oldcharmap != NULL ) + if ( oldcharmap ) error = FT_Set_Charmap( t1_face, oldcharmap ); if ( error ) goto Exit; @@ -309,14 +311,14 @@ { t1_face->face_flags |= FT_FACE_FLAG_KERNING; face->afm_data = fi; - fi = NULL; + fi = NULL; } } FT_FRAME_EXIT(); Exit: - if ( fi != NULL ) + if ( fi ) T1_Done_Metrics( memory, fi ); return error; @@ -402,5 +404,12 @@ return FT_Err_Ok; } +#else /* T1_CONFIG_OPTION_NO_AFM */ + + /* ANSI C doesn't like empty source files */ + typedef int _t1_afm_dummy; + +#endif /* T1_CONFIG_OPTION_NO_AFM */ + /* END */ diff --git a/thirdparty/freetype/src/type1/t1afm.h b/thirdparty/freetype/src/type1/t1afm.h index 3a864f2379..9f62cd013d 100644 --- a/thirdparty/freetype/src/type1/t1afm.h +++ b/thirdparty/freetype/src/type1/t1afm.h @@ -4,7 +4,7 @@ /* */ /* AFM support for Type 1 fonts (specification). */ /* */ -/* Copyright 1996-2016 by */ +/* Copyright 1996-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/thirdparty/freetype/src/type1/t1driver.c b/thirdparty/freetype/src/type1/t1driver.c index f1e60d4523..c2089947f9 100644 --- a/thirdparty/freetype/src/type1/t1driver.c +++ b/thirdparty/freetype/src/type1/t1driver.c @@ -4,7 +4,7 @@ /* */ /* Type 1 driver interface (body). */ /* */ -/* Copyright 1996-2016 by */ +/* Copyright 1996-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -122,8 +122,13 @@ (FT_Get_MM_Func) T1_Get_Multi_Master, /* get_mm */ (FT_Set_MM_Design_Func) T1_Set_MM_Design, /* set_mm_design */ (FT_Set_MM_Blend_Func) T1_Set_MM_Blend, /* set_mm_blend */ + (FT_Get_MM_Blend_Func) T1_Get_MM_Blend, /* get_mm_blend */ (FT_Get_MM_Var_Func) T1_Get_MM_Var, /* get_mm_var */ - (FT_Set_Var_Design_Func)T1_Set_Var_Design /* set_var_design */ + (FT_Set_Var_Design_Func)T1_Set_Var_Design, /* set_var_design */ + (FT_Get_Var_Design_Func)T1_Get_Var_Design, /* get_var_design */ + + (FT_Get_Var_Blend_Func) NULL, /* get_var_blend */ + (FT_Done_Blend_Func) T1_Done_Blend /* done_blend */ }; #endif @@ -714,7 +719,7 @@ 0x10000L, 0x20000L, - 0, /* module-specific interface */ + NULL, /* module-specific interface */ T1_Driver_Init, /* FT_Module_Constructor module_init */ T1_Driver_Done, /* FT_Module_Destructor module_done */ @@ -735,8 +740,8 @@ T1_Load_Glyph, /* FT_Slot_LoadFunc load_glyph */ #ifdef T1_CONFIG_OPTION_NO_AFM - 0, /* FT_Face_GetKerningFunc get_kerning */ - 0, /* FT_Face_AttachFunc attach_file */ + NULL, /* FT_Face_GetKerningFunc get_kerning */ + NULL, /* FT_Face_AttachFunc attach_file */ #else Get_Kerning, /* FT_Face_GetKerningFunc get_kerning */ T1_Read_Metrics, /* FT_Face_AttachFunc attach_file */ @@ -744,7 +749,7 @@ T1_Get_Advances, /* FT_Face_GetAdvancesFunc get_advances */ T1_Size_Request, /* FT_Size_RequestFunc request_size */ - 0 /* FT_Size_SelectFunc select_size */ + NULL /* FT_Size_SelectFunc select_size */ }; diff --git a/thirdparty/freetype/src/type1/t1driver.h b/thirdparty/freetype/src/type1/t1driver.h index 78d8e38aa9..292786448d 100644 --- a/thirdparty/freetype/src/type1/t1driver.h +++ b/thirdparty/freetype/src/type1/t1driver.h @@ -4,7 +4,7 @@ /* */ /* High-level Type 1 driver interface (specification). */ /* */ -/* Copyright 1996-2016 by */ +/* Copyright 1996-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/thirdparty/freetype/src/type1/t1errors.h b/thirdparty/freetype/src/type1/t1errors.h index 9ba470ed6c..492dbb4a42 100644 --- a/thirdparty/freetype/src/type1/t1errors.h +++ b/thirdparty/freetype/src/type1/t1errors.h @@ -4,7 +4,7 @@ /* */ /* Type 1 error codes (specification only). */ /* */ -/* Copyright 2001-2016 by */ +/* Copyright 2001-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/thirdparty/freetype/src/type1/t1gload.c b/thirdparty/freetype/src/type1/t1gload.c index ea36f64142..aaf19b6dcc 100644 --- a/thirdparty/freetype/src/type1/t1gload.c +++ b/thirdparty/freetype/src/type1/t1gload.c @@ -4,7 +4,7 @@ /* */ /* Type 1 Glyph Loader (body). */ /* */ -/* Copyright 1996-2016 by */ +/* Copyright 1996-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/thirdparty/freetype/src/type1/t1gload.h b/thirdparty/freetype/src/type1/t1gload.h index 975f227853..cc4d5e734f 100644 --- a/thirdparty/freetype/src/type1/t1gload.h +++ b/thirdparty/freetype/src/type1/t1gload.h @@ -4,7 +4,7 @@ /* */ /* Type 1 Glyph Loader (specification). */ /* */ -/* Copyright 1996-2016 by */ +/* Copyright 1996-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/thirdparty/freetype/src/type1/t1load.c b/thirdparty/freetype/src/type1/t1load.c index c981adcf2c..f5c661f7de 100644 --- a/thirdparty/freetype/src/type1/t1load.c +++ b/thirdparty/freetype/src/type1/t1load.c @@ -4,7 +4,7 @@ /* */ /* Type 1 font loader (body). */ /* */ -/* Copyright 1996-2016 by */ +/* Copyright 1996-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -237,7 +237,7 @@ if ( ncv <= axismap->blend_points[0] ) return INT_TO_FIXED( axismap->design_points[0] ); - for ( j = 1; j < axismap->num_points; ++j ) + for ( j = 1; j < axismap->num_points; j++ ) { if ( ncv <= axismap->blend_points[j] ) return INT_TO_FIXED( axismap->design_points[j - 1] ) + @@ -321,12 +321,12 @@ mmvar->num_axis = mmaster.num_axis; mmvar->num_designs = mmaster.num_designs; - mmvar->num_namedstyles = ~0U; /* Does not apply */ + mmvar->num_namedstyles = 0; /* Not supported */ mmvar->axis = (FT_Var_Axis*)&mmvar[1]; /* Point to axes after MM_Var struct */ mmvar->namedstyle = NULL; - for ( i = 0; i < mmaster.num_axis; ++i ) + for ( i = 0; i < mmaster.num_axis; i++ ) { mmvar->axis[i].name = mmaster.axis[i].name; mmvar->axis[i].minimum = INT_TO_FIXED( mmaster.axis[i].minimum); @@ -354,7 +354,7 @@ axiscoords, blend->num_axis ); - for ( i = 0; i < mmaster.num_axis; ++i ) + for ( i = 0; i < mmaster.num_axis; i++ ) mmvar->axis[i].def = mm_axis_unmap( &blend->design_map[i], axiscoords[i] ); } @@ -412,6 +412,41 @@ } + FT_LOCAL_DEF( FT_Error ) + T1_Get_MM_Blend( T1_Face face, + FT_UInt num_coords, + FT_Fixed* coords ) + { + PS_Blend blend = face->blend; + + FT_Fixed axiscoords[4]; + FT_UInt i, nc; + + + if ( !blend ) + return FT_THROW( Invalid_Argument ); + + mm_weights_unmap( blend->weight_vector, + axiscoords, + blend->num_axis ); + + nc = num_coords; + if ( num_coords > blend->num_axis ) + { + FT_TRACE2(( "T1_Get_MM_Blend: only using first %d of %d coordinates\n", + blend->num_axis, num_coords )); + nc = blend->num_axis; + } + + for ( i = 0; i < nc; i++ ) + coords[i] = axiscoords[i]; + for ( ; i < num_coords; i++ ) + coords[i] = 0x8000; + + return FT_Err_Ok; + } + + FT_LOCAL_DEF( FT_Error ) T1_Set_MM_Design( T1_Face face, FT_UInt num_coords, @@ -504,13 +539,49 @@ if ( num_coords > T1_MAX_MM_AXIS ) num_coords = T1_MAX_MM_AXIS; - for ( i = 0; i < num_coords; ++i ) + for ( i = 0; i < num_coords; i++ ) lcoords[i] = FIXED_TO_INT( coords[i] ); return T1_Set_MM_Design( face, num_coords, lcoords ); } + FT_LOCAL_DEF( FT_Error ) + T1_Get_Var_Design( T1_Face face, + FT_UInt num_coords, + FT_Fixed* coords ) + { + PS_Blend blend = face->blend; + + FT_Fixed axiscoords[4]; + FT_UInt i, nc; + + + if ( !blend ) + return FT_THROW( Invalid_Argument ); + + mm_weights_unmap( blend->weight_vector, + axiscoords, + blend->num_axis ); + + nc = num_coords; + if ( num_coords > blend->num_axis ) + { + FT_TRACE2(( "T1_Get_Var_Design:" + " only using first %d of %d coordinates\n", + blend->num_axis, num_coords )); + nc = blend->num_axis; + } + + for ( i = 0; i < nc; i++ ) + coords[i] = mm_axis_unmap( &blend->design_map[i], axiscoords[i] ); + for ( ; i < num_coords; i++ ) + coords[i] = 0; + + return FT_Err_Ok; + } + + FT_LOCAL_DEF( void ) T1_Done_Blend( T1_Face face ) { @@ -1406,7 +1477,6 @@ FT_Error error; FT_Int num_subrs; FT_UInt count; - FT_Hash hash = NULL; PSAux_Service psaux = (PSAux_Service)face->psaux; @@ -1433,7 +1503,7 @@ } /* we certainly need more than 8 bytes per subroutine */ - if ( parser->root.limit > parser->root.cursor && + if ( parser->root.limit >= parser->root.cursor && num_subrs > ( parser->root.limit - parser->root.cursor ) >> 3 ) { /* @@ -1457,14 +1527,12 @@ ( parser->root.limit - parser->root.cursor ) >> 3 )); num_subrs = ( parser->root.limit - parser->root.cursor ) >> 3; - if ( !hash ) + if ( !loader->subrs_hash ) { - if ( FT_NEW( hash ) ) + if ( FT_NEW( loader->subrs_hash ) ) goto Fail; - loader->subrs_hash = hash; - - error = ft_hash_num_init( hash, memory ); + error = ft_hash_num_init( loader->subrs_hash, memory ); if ( error ) goto Fail; } @@ -1527,9 +1595,9 @@ /* if we use a hash, the subrs index is the key, and a running */ /* counter specified for `T1_Add_Table' acts as the value */ - if ( hash ) + if ( loader->subrs_hash ) { - ft_hash_num_insert( idx, count, hash, memory ); + ft_hash_num_insert( idx, count, loader->subrs_hash, memory ); idx = count; } @@ -1776,6 +1844,12 @@ } } + if ( !n ) + { + error = FT_THROW( Invalid_File_Format ); + goto Fail; + } + loader->num_glyphs = n; /* if /.notdef is found but does not occupy index 0, do our magic. */ @@ -2104,7 +2178,7 @@ parser->root.error = t1_load_keyword( face, loader, keyword ); - if ( parser->root.error != FT_Err_Ok ) + if ( parser->root.error ) { if ( FT_ERR_EQ( parser->root.error, Ignore ) ) parser->root.error = FT_Err_Ok; @@ -2143,7 +2217,7 @@ { FT_UNUSED( face ); - FT_MEM_ZERO( loader, sizeof ( *loader ) ); + FT_ZERO( loader ); } diff --git a/thirdparty/freetype/src/type1/t1load.h b/thirdparty/freetype/src/type1/t1load.h index b96fe5a746..2d86984f0e 100644 --- a/thirdparty/freetype/src/type1/t1load.h +++ b/thirdparty/freetype/src/type1/t1load.h @@ -4,7 +4,7 @@ /* */ /* Type 1 font loader (specification). */ /* */ -/* Copyright 1996-2016 by */ +/* Copyright 1996-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -70,7 +70,7 @@ FT_BEGIN_HEADER T1_Get_Multi_Master( T1_Face face, FT_Multi_Master* master ); - FT_LOCAL_DEF( FT_Error ) + FT_LOCAL( FT_Error ) T1_Get_MM_Var( T1_Face face, FT_MM_Var* *master ); @@ -79,12 +79,22 @@ FT_BEGIN_HEADER FT_UInt num_coords, FT_Fixed* coords ); + FT_LOCAL( FT_Error ) + T1_Get_MM_Blend( T1_Face face, + FT_UInt num_coords, + FT_Fixed* coords ); + FT_LOCAL( FT_Error ) T1_Set_MM_Design( T1_Face face, FT_UInt num_coords, FT_Long* coords ); - FT_LOCAL_DEF( FT_Error ) + FT_LOCAL( FT_Error ) + T1_Get_Var_Design( T1_Face face, + FT_UInt num_coords, + FT_Fixed* coords ); + + FT_LOCAL( FT_Error ) T1_Set_Var_Design( T1_Face face, FT_UInt num_coords, FT_Fixed* coords ); diff --git a/thirdparty/freetype/src/type1/t1objs.c b/thirdparty/freetype/src/type1/t1objs.c index a009117133..97c16b0fdf 100644 --- a/thirdparty/freetype/src/type1/t1objs.c +++ b/thirdparty/freetype/src/type1/t1objs.c @@ -4,7 +4,7 @@ /* */ /* Type 1 objects manager (body). */ /* */ -/* Copyright 1996-2016 by */ +/* Copyright 1996-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -49,9 +49,6 @@ /* */ /* SIZE FUNCTIONS */ /* */ - /* note that we store the global hints in the size's "internal" root */ - /* field */ - /* */ /*************************************************************************/ @@ -77,16 +74,16 @@ T1_Size size = (T1_Size)t1size; - if ( size->root.internal ) + if ( t1size->internal->module_data ) { PSH_Globals_Funcs funcs; funcs = T1_Size_Get_Globals_Funcs( size ); if ( funcs ) - funcs->destroy( (PSH_Globals)size->root.internal ); + funcs->destroy( (PSH_Globals)t1size->internal->module_data ); - size->root.internal = NULL; + t1size->internal->module_data = NULL; } } @@ -108,7 +105,7 @@ error = funcs->create( size->root.face->memory, &face->type1.private_dict, &globals ); if ( !error ) - size->root.internal = (FT_Size_Internal)(void*)globals; + t1size->internal->module_data = globals; } return error; @@ -126,7 +123,7 @@ FT_Request_Metrics( size->root.face, req ); if ( funcs ) - funcs->set_scale( (PSH_Globals)size->root.internal, + funcs->set_scale( (PSH_Globals)t1size->internal->module_data, size->root.metrics.x_scale, size->root.metrics.y_scale, 0, 0 ); diff --git a/thirdparty/freetype/src/type1/t1objs.h b/thirdparty/freetype/src/type1/t1objs.h index 94fbdee9ae..39d26bf8b9 100644 --- a/thirdparty/freetype/src/type1/t1objs.h +++ b/thirdparty/freetype/src/type1/t1objs.h @@ -4,7 +4,7 @@ /* */ /* Type 1 objects manager (specification). */ /* */ -/* Copyright 1996-2016 by */ +/* Copyright 1996-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/thirdparty/freetype/src/type1/t1parse.c b/thirdparty/freetype/src/type1/t1parse.c index 563d9f37bb..18dd26434c 100644 --- a/thirdparty/freetype/src/type1/t1parse.c +++ b/thirdparty/freetype/src/type1/t1parse.c @@ -4,7 +4,7 @@ /* */ /* Type 1 parser (body). */ /* */ -/* Copyright 1996-2016 by */ +/* Copyright 1996-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -437,7 +437,7 @@ *cur == '\t' || (test_cr && *cur == '\r' ) || *cur == '\n' ) ) - ++cur; + cur++; if ( cur >= limit ) { FT_ERROR(( "T1_Get_Private_Dict:" diff --git a/thirdparty/freetype/src/type1/t1parse.h b/thirdparty/freetype/src/type1/t1parse.h index affa818e63..3396680d1a 100644 --- a/thirdparty/freetype/src/type1/t1parse.h +++ b/thirdparty/freetype/src/type1/t1parse.h @@ -4,7 +4,7 @@ /* */ /* Type 1 parser (specification). */ /* */ -/* Copyright 1996-2016 by */ +/* Copyright 1996-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/thirdparty/freetype/src/type1/t1tokens.h b/thirdparty/freetype/src/type1/t1tokens.h index a84f291a6b..ca0c55f903 100644 --- a/thirdparty/freetype/src/type1/t1tokens.h +++ b/thirdparty/freetype/src/type1/t1tokens.h @@ -4,7 +4,7 @@ /* */ /* Type 1 tokenizer (specification). */ /* */ -/* Copyright 1996-2016 by */ +/* Copyright 1996-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/thirdparty/freetype/src/type1/type1.c b/thirdparty/freetype/src/type1/type1.c index bb8aca97f9..81795376ef 100644 --- a/thirdparty/freetype/src/type1/type1.c +++ b/thirdparty/freetype/src/type1/type1.c @@ -4,7 +4,7 @@ /* */ /* FreeType Type 1 driver component (body only). */ /* */ -/* Copyright 1996-2016 by */ +/* Copyright 1996-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -17,17 +17,14 @@ #define FT_MAKE_OPTION_SINGLE_OBJECT - #include <ft2build.h> -#include "t1parse.c" -#include "t1load.c" -#include "t1objs.c" -#include "t1driver.c" -#include "t1gload.c" -#ifndef T1_CONFIG_OPTION_NO_AFM #include "t1afm.c" -#endif +#include "t1driver.c" +#include "t1gload.c" +#include "t1load.c" +#include "t1objs.c" +#include "t1parse.c" /* END */ diff --git a/thirdparty/freetype/src/type42/module.mk b/thirdparty/freetype/src/type42/module.mk index a7e27b7236..2f52806808 100644 --- a/thirdparty/freetype/src/type42/module.mk +++ b/thirdparty/freetype/src/type42/module.mk @@ -3,7 +3,7 @@ # -# Copyright 2002-2016 by +# Copyright 2002-2017 by # David Turner, Robert Wilhelm, and Werner Lemberg. # # This file is part of the FreeType project, and may only be used, modified, diff --git a/thirdparty/freetype/src/type42/rules.mk b/thirdparty/freetype/src/type42/rules.mk index 80710eff67..d7e8965015 100644 --- a/thirdparty/freetype/src/type42/rules.mk +++ b/thirdparty/freetype/src/type42/rules.mk @@ -3,7 +3,7 @@ # -# Copyright 2002-2016 by +# Copyright 2002-2017 by # David Turner, Robert Wilhelm, and Werner Lemberg. # # This file is part of the FreeType project, and may only be used, modified, diff --git a/thirdparty/freetype/src/type42/t42drivr.c b/thirdparty/freetype/src/type42/t42drivr.c index c63ed0c812..366cfb3a1d 100644 --- a/thirdparty/freetype/src/type42/t42drivr.c +++ b/thirdparty/freetype/src/type42/t42drivr.c @@ -4,7 +4,7 @@ /* */ /* High-level Type 42 driver interface (body). */ /* */ -/* Copyright 2002-2016 by */ +/* Copyright 2002-2017 by */ /* Roberto Alameda. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -81,7 +81,8 @@ if ( glyph_name[0] == gname[0] && !ft_strcmp( glyph_name, gname ) ) - return (FT_UInt)ft_atol( (const char *)face->type1.charstrings[i] ); + return (FT_UInt)ft_strtol( (const char *)face->type1.charstrings[i], + NULL, 10 ); } return 0; @@ -213,7 +214,7 @@ 0x10000L, 0x20000L, - 0, /* module-specific interface */ + NULL, /* module-specific interface */ T42_Driver_Init, /* FT_Module_Constructor module_init */ T42_Driver_Done, /* FT_Module_Destructor module_done */ @@ -233,9 +234,9 @@ T42_GlyphSlot_Load, /* FT_Slot_LoadFunc load_glyph */ - 0, /* FT_Face_GetKerningFunc get_kerning */ - 0, /* FT_Face_AttachFunc attach_file */ - 0, /* FT_Face_GetAdvancesFunc get_advances */ + NULL, /* FT_Face_GetKerningFunc get_kerning */ + NULL, /* FT_Face_AttachFunc attach_file */ + NULL, /* FT_Face_GetAdvancesFunc get_advances */ T42_Size_Request, /* FT_Size_RequestFunc request_size */ T42_Size_Select /* FT_Size_SelectFunc select_size */ diff --git a/thirdparty/freetype/src/type42/t42drivr.h b/thirdparty/freetype/src/type42/t42drivr.h index 6ddfb639d5..1ac4a0a1a1 100644 --- a/thirdparty/freetype/src/type42/t42drivr.h +++ b/thirdparty/freetype/src/type42/t42drivr.h @@ -4,7 +4,7 @@ /* */ /* High-level Type 42 driver interface (specification). */ /* */ -/* Copyright 2002-2016 by */ +/* Copyright 2002-2017 by */ /* Roberto Alameda. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/thirdparty/freetype/src/type42/t42error.h b/thirdparty/freetype/src/type42/t42error.h index e1097cc81e..fda92abf57 100644 --- a/thirdparty/freetype/src/type42/t42error.h +++ b/thirdparty/freetype/src/type42/t42error.h @@ -4,7 +4,7 @@ /* */ /* Type 42 error codes (specification only). */ /* */ -/* Copyright 2002-2016 by */ +/* Copyright 2002-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/thirdparty/freetype/src/type42/t42objs.c b/thirdparty/freetype/src/type42/t42objs.c index 4672c6e164..87e5206b7f 100644 --- a/thirdparty/freetype/src/type42/t42objs.c +++ b/thirdparty/freetype/src/type42/t42objs.c @@ -4,7 +4,7 @@ /* */ /* Type 42 objects manager (body). */ /* */ -/* Copyright 2002-2016 by */ +/* Copyright 2002-2017 by */ /* Roberto Alameda. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -590,7 +590,7 @@ FT_Error error = FT_Err_Ok; - if ( face->glyph == NULL ) + if ( !face->glyph ) { /* First glyph slot for this face */ slot->ttslot = t42face->ttf_face->glyph; @@ -656,8 +656,9 @@ FT_TRACE1(( "T42_GlyphSlot_Load: glyph index %d\n", glyph_index )); /* map T42 glyph index to embedded TTF's glyph index */ - glyph_index = (FT_UInt)ft_atol( - (const char *)t42face->type1.charstrings[glyph_index] ); + glyph_index = (FT_UInt)ft_strtol( + (const char *)t42face->type1.charstrings[glyph_index], + NULL, 10 ); t42_glyphslot_clear( t42slot->ttslot ); error = ttclazz->load_glyph( t42slot->ttslot, diff --git a/thirdparty/freetype/src/type42/t42objs.h b/thirdparty/freetype/src/type42/t42objs.h index 87a40452f4..eb4c5bf69f 100644 --- a/thirdparty/freetype/src/type42/t42objs.h +++ b/thirdparty/freetype/src/type42/t42objs.h @@ -4,7 +4,7 @@ /* */ /* Type 42 objects manager (specification). */ /* */ -/* Copyright 2002-2016 by */ +/* Copyright 2002-2017 by */ /* Roberto Alameda. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/thirdparty/freetype/src/type42/t42parse.c b/thirdparty/freetype/src/type42/t42parse.c index f948916afa..e7c6770bd2 100644 --- a/thirdparty/freetype/src/type42/t42parse.c +++ b/thirdparty/freetype/src/type42/t42parse.c @@ -4,7 +4,7 @@ /* */ /* Type 42 font parser (body). */ /* */ -/* Copyright 2002-2016 by */ +/* Copyright 2002-2017 by */ /* Roberto Alameda. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -936,7 +936,7 @@ if ( *cur == '/' || *cur == '(' ) { FT_UInt len; - FT_Bool have_literal = ( *cur == '(' ); + FT_Bool have_literal = FT_BOOL( *cur == '(' ); if ( cur + ( have_literal ? 3 : 2 ) >= limit ) @@ -1268,7 +1268,7 @@ { FT_UNUSED( face ); - FT_MEM_ZERO( loader, sizeof ( *loader ) ); + FT_ZERO( loader ); loader->num_glyphs = 0; loader->num_chars = 0; diff --git a/thirdparty/freetype/src/type42/t42parse.h b/thirdparty/freetype/src/type42/t42parse.h index ba9e857190..7a68606f2e 100644 --- a/thirdparty/freetype/src/type42/t42parse.h +++ b/thirdparty/freetype/src/type42/t42parse.h @@ -4,7 +4,7 @@ /* */ /* Type 42 font parser (specification). */ /* */ -/* Copyright 2002-2016 by */ +/* Copyright 2002-2017 by */ /* Roberto Alameda. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/thirdparty/freetype/src/type42/t42types.h b/thirdparty/freetype/src/type42/t42types.h index 850a156e45..2306ab6c77 100644 --- a/thirdparty/freetype/src/type42/t42types.h +++ b/thirdparty/freetype/src/type42/t42types.h @@ -4,7 +4,7 @@ /* */ /* Type 42 font data types (specification only). */ /* */ -/* Copyright 2002-2016 by */ +/* Copyright 2002-2017 by */ /* Roberto Alameda. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/thirdparty/freetype/src/type42/type42.c b/thirdparty/freetype/src/type42/type42.c index 0d17a9b1dc..ae8ac26782 100644 --- a/thirdparty/freetype/src/type42/type42.c +++ b/thirdparty/freetype/src/type42/type42.c @@ -4,7 +4,7 @@ /* */ /* FreeType Type 42 driver component. */ /* */ -/* Copyright 2002-2016 by */ +/* Copyright 2002-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -15,11 +15,13 @@ /* */ /***************************************************************************/ -#define FT_MAKE_OPTION_SINGLE_OBJECT +#define FT_MAKE_OPTION_SINGLE_OBJECT #include <ft2build.h> + +#include "t42drivr.c" #include "t42objs.c" #include "t42parse.c" -#include "t42drivr.c" + /* END */ diff --git a/thirdparty/freetype/src/winfonts/fnterrs.h b/thirdparty/freetype/src/winfonts/fnterrs.h index 6835d3e64f..4251021a70 100644 --- a/thirdparty/freetype/src/winfonts/fnterrs.h +++ b/thirdparty/freetype/src/winfonts/fnterrs.h @@ -4,7 +4,7 @@ /* */ /* Win FNT/FON error codes (specification only). */ /* */ -/* Copyright 2001-2016 by */ +/* Copyright 2001-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/thirdparty/freetype/src/winfonts/module.mk b/thirdparty/freetype/src/winfonts/module.mk index 83da5732f1..ffc53a19f9 100644 --- a/thirdparty/freetype/src/winfonts/module.mk +++ b/thirdparty/freetype/src/winfonts/module.mk @@ -3,7 +3,7 @@ # -# Copyright 1996-2016 by +# Copyright 1996-2017 by # David Turner, Robert Wilhelm, and Werner Lemberg. # # This file is part of the FreeType project, and may only be used, modified, diff --git a/thirdparty/freetype/src/winfonts/rules.mk b/thirdparty/freetype/src/winfonts/rules.mk index 2fd7b822a2..73e825d9ae 100644 --- a/thirdparty/freetype/src/winfonts/rules.mk +++ b/thirdparty/freetype/src/winfonts/rules.mk @@ -3,7 +3,7 @@ # -# Copyright 1996-2016 by +# Copyright 1996-2017 by # David Turner, Robert Wilhelm, and Werner Lemberg. # # This file is part of the FreeType project, and may only be used, modified, diff --git a/thirdparty/freetype/src/winfonts/winfnt.c b/thirdparty/freetype/src/winfonts/winfnt.c index 1c74ccd5ab..9811fbb05a 100644 --- a/thirdparty/freetype/src/winfonts/winfnt.c +++ b/thirdparty/freetype/src/winfonts/winfnt.c @@ -4,7 +4,7 @@ /* */ /* FreeType font driver for Windows FNT/FON files */ /* */ -/* Copyright 1996-2016 by */ +/* Copyright 1996-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* Copyright 2003 Huw D M Davies for Codeweavers */ /* Copyright 2007 Dmitry Timoshkov for Codeweavers */ @@ -561,7 +561,7 @@ error = fnt_font_load( face->font, stream ); if ( error ) { - FT_TRACE2(( "font #%lu load error %d\n", + FT_TRACE2(( "font #%lu load error 0x%x\n", dir_entry2.name, error )); goto Fail; } @@ -759,6 +759,14 @@ if ( error ) goto Fail; + /* sanity check */ + if ( !face->font->header.pixel_height ) + { + FT_TRACE2(( "invalid pixel height\n" )); + error = FT_THROW( Invalid_File_Format ); + goto Fail; + } + /* we now need to fill the root FT_Face fields */ /* with relevant information */ { @@ -992,8 +1000,6 @@ FT_ULong offset; FT_Bool new_format; - FT_UNUSED( load_flags ); - if ( !face ) { @@ -1047,6 +1053,26 @@ goto Exit; } + bitmap->rows = font->header.pixel_height; + bitmap->pixel_mode = FT_PIXEL_MODE_MONO; + + slot->bitmap_left = 0; + slot->bitmap_top = font->header.ascent; + slot->format = FT_GLYPH_FORMAT_BITMAP; + + /* now set up metrics */ + slot->metrics.width = (FT_Pos)( bitmap->width << 6 ); + slot->metrics.height = (FT_Pos)( bitmap->rows << 6 ); + slot->metrics.horiAdvance = (FT_Pos)( bitmap->width << 6 ); + slot->metrics.horiBearingX = 0; + slot->metrics.horiBearingY = slot->bitmap_top << 6; + + ft_synthesize_vertical_metrics( &slot->metrics, + (FT_Pos)( bitmap->rows << 6 ) ); + + if ( load_flags & FT_LOAD_BITMAP_METRICS_ONLY ) + goto Exit; + /* jump to glyph data */ p = font->fnt_frame + /* font->header.bits_offset */ + offset; @@ -1058,11 +1084,9 @@ FT_Byte* write; - bitmap->pitch = (int)pitch; - bitmap->rows = font->header.pixel_height; - bitmap->pixel_mode = FT_PIXEL_MODE_MONO; - - if ( offset + pitch * bitmap->rows > font->header.file_size ) + bitmap->pitch = (int)pitch; + if ( !pitch || + offset + pitch * bitmap->rows > font->header.file_size ) { FT_TRACE2(( "invalid bitmap width\n" )); error = FT_THROW( Invalid_File_Format ); @@ -1084,22 +1108,9 @@ for ( write = column; p < limit; p++, write += bitmap->pitch ) *write = *p; } - } - slot->internal->flags = FT_GLYPH_OWN_BITMAP; - slot->bitmap_left = 0; - slot->bitmap_top = font->header.ascent; - slot->format = FT_GLYPH_FORMAT_BITMAP; - - /* now set up metrics */ - slot->metrics.width = (FT_Pos)( bitmap->width << 6 ); - slot->metrics.height = (FT_Pos)( bitmap->rows << 6 ); - slot->metrics.horiAdvance = (FT_Pos)( bitmap->width << 6 ); - slot->metrics.horiBearingX = 0; - slot->metrics.horiBearingY = slot->bitmap_top << 6; - - ft_synthesize_vertical_metrics( &slot->metrics, - (FT_Pos)( bitmap->rows << 6 ) ); + slot->internal->flags = FT_GLYPH_OWN_BITMAP; + } Exit: return error; @@ -1161,10 +1172,10 @@ 0x10000L, 0x20000L, - 0, /* module-specific interface */ + NULL, /* module-specific interface */ - 0, /* FT_Module_Constructor module_init */ - 0, /* FT_Module_Destructor module_done */ + NULL, /* FT_Module_Constructor module_init */ + NULL, /* FT_Module_Destructor module_done */ winfnt_get_service /* FT_Module_Requester get_interface */ }, @@ -1174,16 +1185,16 @@ FNT_Face_Init, /* FT_Face_InitFunc init_face */ FNT_Face_Done, /* FT_Face_DoneFunc done_face */ - 0, /* FT_Size_InitFunc init_size */ - 0, /* FT_Size_DoneFunc done_size */ - 0, /* FT_Slot_InitFunc init_slot */ - 0, /* FT_Slot_DoneFunc done_slot */ + NULL, /* FT_Size_InitFunc init_size */ + NULL, /* FT_Size_DoneFunc done_size */ + NULL, /* FT_Slot_InitFunc init_slot */ + NULL, /* FT_Slot_DoneFunc done_slot */ FNT_Load_Glyph, /* FT_Slot_LoadFunc load_glyph */ - 0, /* FT_Face_GetKerningFunc get_kerning */ - 0, /* FT_Face_AttachFunc attach_file */ - 0, /* FT_Face_GetAdvancesFunc get_advances */ + NULL, /* FT_Face_GetKerningFunc get_kerning */ + NULL, /* FT_Face_AttachFunc attach_file */ + NULL, /* FT_Face_GetAdvancesFunc get_advances */ FNT_Size_Request, /* FT_Size_RequestFunc request_size */ FNT_Size_Select /* FT_Size_SelectFunc select_size */ diff --git a/thirdparty/freetype/src/winfonts/winfnt.h b/thirdparty/freetype/src/winfonts/winfnt.h index 9a4f32d5b0..884b645a2d 100644 --- a/thirdparty/freetype/src/winfonts/winfnt.h +++ b/thirdparty/freetype/src/winfonts/winfnt.h @@ -4,7 +4,7 @@ /* */ /* FreeType font driver for Windows FNT/FON files */ /* */ -/* Copyright 1996-2016 by */ +/* Copyright 1996-2017 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* Copyright 2007 Dmitry Timoshkov for Codeweavers */ /* */ -- cgit v1.2.3