summaryrefslogtreecommitdiffstats
path: root/src/3rdparty/freetype/src
diff options
context:
space:
mode:
Diffstat (limited to 'src/3rdparty/freetype/src')
-rw-r--r--src/3rdparty/freetype/src/Jamfile2
-rw-r--r--src/3rdparty/freetype/src/autofit/Jamfile4
-rw-r--r--src/3rdparty/freetype/src/autofit/afangles.c2
-rw-r--r--src/3rdparty/freetype/src/autofit/afblue.c658
-rw-r--r--src/3rdparty/freetype/src/autofit/afblue.cin2
-rw-r--r--src/3rdparty/freetype/src/autofit/afblue.dat811
-rw-r--r--src/3rdparty/freetype/src/autofit/afblue.h377
-rw-r--r--src/3rdparty/freetype/src/autofit/afblue.hin70
-rw-r--r--src/3rdparty/freetype/src/autofit/afcjk.c242
-rw-r--r--src/3rdparty/freetype/src/autofit/afcjk.h8
-rw-r--r--src/3rdparty/freetype/src/autofit/afcover.h2
-rw-r--r--src/3rdparty/freetype/src/autofit/afdummy.c13
-rw-r--r--src/3rdparty/freetype/src/autofit/afdummy.h8
-rw-r--r--src/3rdparty/freetype/src/autofit/aferrors.h11
-rw-r--r--src/3rdparty/freetype/src/autofit/afglobal.c52
-rw-r--r--src/3rdparty/freetype/src/autofit/afglobal.h29
-rw-r--r--src/3rdparty/freetype/src/autofit/afhints.c260
-rw-r--r--src/3rdparty/freetype/src/autofit/afhints.h17
-rw-r--r--src/3rdparty/freetype/src/autofit/afindic.c42
-rw-r--r--src/3rdparty/freetype/src/autofit/afindic.h8
-rw-r--r--src/3rdparty/freetype/src/autofit/aflatin.c1555
-rw-r--r--src/3rdparty/freetype/src/autofit/aflatin.h18
-rw-r--r--src/3rdparty/freetype/src/autofit/aflatin2.c70
-rw-r--r--src/3rdparty/freetype/src/autofit/aflatin2.h13
-rw-r--r--src/3rdparty/freetype/src/autofit/afloader.c585
-rw-r--r--src/3rdparty/freetype/src/autofit/afloader.h13
-rw-r--r--src/3rdparty/freetype/src/autofit/afmodule.c231
-rw-r--r--src/3rdparty/freetype/src/autofit/afmodule.h10
-rw-r--r--src/3rdparty/freetype/src/autofit/afpic.c4
-rw-r--r--src/3rdparty/freetype/src/autofit/afpic.h10
-rw-r--r--src/3rdparty/freetype/src/autofit/afranges.c1084
-rw-r--r--src/3rdparty/freetype/src/autofit/afranges.h12
-rw-r--r--src/3rdparty/freetype/src/autofit/afscript.h337
-rw-r--r--src/3rdparty/freetype/src/autofit/afshaper.c683
-rw-r--r--src/3rdparty/freetype/src/autofit/afshaper.h72
-rw-r--r--src/3rdparty/freetype/src/autofit/afstyles.h296
-rw-r--r--src/3rdparty/freetype/src/autofit/aftypes.h78
-rw-r--r--src/3rdparty/freetype/src/autofit/afwarp.c5
-rw-r--r--src/3rdparty/freetype/src/autofit/afwarp.h8
-rw-r--r--src/3rdparty/freetype/src/autofit/afwrtsys.h8
-rw-r--r--src/3rdparty/freetype/src/autofit/autofit.c25
-rw-r--r--src/3rdparty/freetype/src/autofit/module.mk2
-rw-r--r--src/3rdparty/freetype/src/autofit/rules.mk6
-rw-r--r--src/3rdparty/freetype/src/base/Jamfile8
-rw-r--r--src/3rdparty/freetype/src/base/basepic.c2
-rw-r--r--src/3rdparty/freetype/src/base/basepic.h8
-rw-r--r--src/3rdparty/freetype/src/base/ftadvanc.c27
-rw-r--r--src/3rdparty/freetype/src/base/ftapi.c4
-rw-r--r--src/3rdparty/freetype/src/base/ftbase.c13
-rw-r--r--src/3rdparty/freetype/src/base/ftbase.h14
-rw-r--r--src/3rdparty/freetype/src/base/ftbbox.c28
-rw-r--r--src/3rdparty/freetype/src/base/ftbdf.c2
-rw-r--r--src/3rdparty/freetype/src/base/ftbitmap.c86
-rw-r--r--src/3rdparty/freetype/src/base/ftcalc.c162
-rw-r--r--src/3rdparty/freetype/src/base/ftcid.c2
-rw-r--r--src/3rdparty/freetype/src/base/ftdbgmem.c43
-rw-r--r--src/3rdparty/freetype/src/base/ftdebug.c4
-rw-r--r--src/3rdparty/freetype/src/base/ftfntfmt.c2
-rw-r--r--src/3rdparty/freetype/src/base/ftfstype.c2
-rw-r--r--src/3rdparty/freetype/src/base/ftgasp.c2
-rw-r--r--src/3rdparty/freetype/src/base/ftgloadr.c2
-rw-r--r--src/3rdparty/freetype/src/base/ftglyph.c68
-rw-r--r--src/3rdparty/freetype/src/base/ftgxval.c4
-rw-r--r--src/3rdparty/freetype/src/base/fthash.c339
-rw-r--r--src/3rdparty/freetype/src/base/ftinit.c92
-rw-r--r--src/3rdparty/freetype/src/base/ftlcdfil.c315
-rw-r--r--src/3rdparty/freetype/src/base/ftmac.c46
-rw-r--r--src/3rdparty/freetype/src/base/ftmm.c292
-rw-r--r--src/3rdparty/freetype/src/base/ftobjs.c920
-rw-r--r--src/3rdparty/freetype/src/base/ftotval.c2
-rw-r--r--src/3rdparty/freetype/src/base/ftoutln.c43
-rw-r--r--src/3rdparty/freetype/src/base/ftpatent.c246
-rw-r--r--src/3rdparty/freetype/src/base/ftpfr.c2
-rw-r--r--src/3rdparty/freetype/src/base/ftpic.c2
-rw-r--r--src/3rdparty/freetype/src/base/ftpsprop.c285
-rw-r--r--src/3rdparty/freetype/src/base/ftrfork.c129
-rw-r--r--src/3rdparty/freetype/src/base/ftsnames.c60
-rw-r--r--src/3rdparty/freetype/src/base/ftstream.c4
-rw-r--r--src/3rdparty/freetype/src/base/ftstroke.c9
-rw-r--r--src/3rdparty/freetype/src/base/ftsynth.c6
-rw-r--r--src/3rdparty/freetype/src/base/ftsystem.c2
-rw-r--r--src/3rdparty/freetype/src/base/fttrigon.c5
-rw-r--r--src/3rdparty/freetype/src/base/fttype1.c2
-rw-r--r--src/3rdparty/freetype/src/base/ftutil.c18
-rw-r--r--src/3rdparty/freetype/src/base/ftver.rc61
-rw-r--r--src/3rdparty/freetype/src/base/ftwinfnt.c2
-rw-r--r--src/3rdparty/freetype/src/base/md5.c57
-rw-r--r--src/3rdparty/freetype/src/base/rules.mk6
-rw-r--r--src/3rdparty/freetype/src/bdf/Jamfile2
-rw-r--r--src/3rdparty/freetype/src/bdf/README2
-rw-r--r--src/3rdparty/freetype/src/bdf/bdf.c3
-rw-r--r--src/3rdparty/freetype/src/bdf/bdf.h27
-rw-r--r--src/3rdparty/freetype/src/bdf/bdfdrivr.c188
-rw-r--r--src/3rdparty/freetype/src/bdf/bdfdrivr.h6
-rw-r--r--src/3rdparty/freetype/src/bdf/bdferror.h8
-rw-r--r--src/3rdparty/freetype/src/bdf/bdflib.c625
-rw-r--r--src/3rdparty/freetype/src/bzip2/Jamfile2
-rw-r--r--src/3rdparty/freetype/src/bzip2/ftbzip2.c6
-rw-r--r--src/3rdparty/freetype/src/bzip2/rules.mk2
-rw-r--r--src/3rdparty/freetype/src/cache/Jamfile2
-rw-r--r--src/3rdparty/freetype/src/cache/ftcache.c11
-rw-r--r--src/3rdparty/freetype/src/cache/ftcbasic.c91
-rw-r--r--src/3rdparty/freetype/src/cache/ftccache.c28
-rw-r--r--src/3rdparty/freetype/src/cache/ftccache.h40
-rw-r--r--src/3rdparty/freetype/src/cache/ftccback.h9
-rw-r--r--src/3rdparty/freetype/src/cache/ftccmap.c21
-rw-r--r--src/3rdparty/freetype/src/cache/ftcerror.h11
-rw-r--r--src/3rdparty/freetype/src/cache/ftcglyph.c4
-rw-r--r--src/3rdparty/freetype/src/cache/ftcglyph.h14
-rw-r--r--src/3rdparty/freetype/src/cache/ftcimage.c4
-rw-r--r--src/3rdparty/freetype/src/cache/ftcimage.h12
-rw-r--r--src/3rdparty/freetype/src/cache/ftcmanag.c39
-rw-r--r--src/3rdparty/freetype/src/cache/ftcmanag.h10
-rw-r--r--src/3rdparty/freetype/src/cache/ftcmru.c12
-rw-r--r--src/3rdparty/freetype/src/cache/ftcmru.h16
-rw-r--r--src/3rdparty/freetype/src/cache/ftcsbits.c8
-rw-r--r--src/3rdparty/freetype/src/cache/ftcsbits.h12
-rw-r--r--src/3rdparty/freetype/src/cache/rules.mk2
-rw-r--r--src/3rdparty/freetype/src/cff/Jamfile11
-rw-r--r--src/3rdparty/freetype/src/cff/cff.c19
-rw-r--r--src/3rdparty/freetype/src/cff/cffcmap.c39
-rw-r--r--src/3rdparty/freetype/src/cff/cffcmap.h10
-rw-r--r--src/3rdparty/freetype/src/cff/cffdrivr.c540
-rw-r--r--src/3rdparty/freetype/src/cff/cffdrivr.h8
-rw-r--r--src/3rdparty/freetype/src/cff/cfferrs.h10
-rw-r--r--src/3rdparty/freetype/src/cff/cffgload.c2481
-rw-r--r--src/3rdparty/freetype/src/cff/cffgload.h192
-rw-r--r--src/3rdparty/freetype/src/cff/cffload.c1065
-rw-r--r--src/3rdparty/freetype/src/cff/cffload.h62
-rw-r--r--src/3rdparty/freetype/src/cff/cffobjs.c235
-rw-r--r--src/3rdparty/freetype/src/cff/cffobjs.h112
-rw-r--r--src/3rdparty/freetype/src/cff/cffparse.c621
-rw-r--r--src/3rdparty/freetype/src/cff/cffparse.h64
-rw-r--r--src/3rdparty/freetype/src/cff/cffpic.c2
-rw-r--r--src/3rdparty/freetype/src/cff/cffpic.h43
-rw-r--r--src/3rdparty/freetype/src/cff/cfftoken.h61
-rw-r--r--src/3rdparty/freetype/src/cff/module.mk2
-rw-r--r--src/3rdparty/freetype/src/cff/rules.mk19
-rw-r--r--src/3rdparty/freetype/src/cid/Jamfile2
-rw-r--r--src/3rdparty/freetype/src/cid/ciderrs.h10
-rw-r--r--src/3rdparty/freetype/src/cid/cidgload.c123
-rw-r--r--src/3rdparty/freetype/src/cid/cidgload.h8
-rw-r--r--src/3rdparty/freetype/src/cid/cidload.c171
-rw-r--r--src/3rdparty/freetype/src/cid/cidload.h8
-rw-r--r--src/3rdparty/freetype/src/cid/cidobjs.c50
-rw-r--r--src/3rdparty/freetype/src/cid/cidobjs.h8
-rw-r--r--src/3rdparty/freetype/src/cid/cidparse.c93
-rw-r--r--src/3rdparty/freetype/src/cid/cidparse.h8
-rw-r--r--src/3rdparty/freetype/src/cid/cidriver.c82
-rw-r--r--src/3rdparty/freetype/src/cid/cidriver.h8
-rw-r--r--src/3rdparty/freetype/src/cid/cidtoken.h2
-rw-r--r--src/3rdparty/freetype/src/cid/module.mk2
-rw-r--r--src/3rdparty/freetype/src/cid/rules.mk2
-rw-r--r--src/3rdparty/freetype/src/cid/type1cid.c8
-rw-r--r--src/3rdparty/freetype/src/gxvalid/Jamfile2
-rw-r--r--src/3rdparty/freetype/src/gxvalid/README16
-rw-r--r--src/3rdparty/freetype/src/gxvalid/gxvalid.c16
-rw-r--r--src/3rdparty/freetype/src/gxvalid/gxvalid.h10
-rw-r--r--src/3rdparty/freetype/src/gxvalid/gxvbsln.c2
-rw-r--r--src/3rdparty/freetype/src/gxvalid/gxvcommn.c29
-rw-r--r--src/3rdparty/freetype/src/gxvalid/gxvcommn.h14
-rw-r--r--src/3rdparty/freetype/src/gxvalid/gxverror.h10
-rw-r--r--src/3rdparty/freetype/src/gxvalid/gxvfeat.c2
-rw-r--r--src/3rdparty/freetype/src/gxvalid/gxvfeat.h8
-rw-r--r--src/3rdparty/freetype/src/gxvalid/gxvfgen.c4
-rw-r--r--src/3rdparty/freetype/src/gxvalid/gxvjust.c4
-rw-r--r--src/3rdparty/freetype/src/gxvalid/gxvkern.c6
-rw-r--r--src/3rdparty/freetype/src/gxvalid/gxvlcar.c4
-rw-r--r--src/3rdparty/freetype/src/gxvalid/gxvmod.c14
-rw-r--r--src/3rdparty/freetype/src/gxvalid/gxvmod.h8
-rw-r--r--src/3rdparty/freetype/src/gxvalid/gxvmort.c4
-rw-r--r--src/3rdparty/freetype/src/gxvalid/gxvmort.h8
-rw-r--r--src/3rdparty/freetype/src/gxvalid/gxvmort0.c2
-rw-r--r--src/3rdparty/freetype/src/gxvalid/gxvmort1.c4
-rw-r--r--src/3rdparty/freetype/src/gxvalid/gxvmort2.c2
-rw-r--r--src/3rdparty/freetype/src/gxvalid/gxvmort4.c2
-rw-r--r--src/3rdparty/freetype/src/gxvalid/gxvmort5.c2
-rw-r--r--src/3rdparty/freetype/src/gxvalid/gxvmorx.c4
-rw-r--r--src/3rdparty/freetype/src/gxvalid/gxvmorx.h8
-rw-r--r--src/3rdparty/freetype/src/gxvalid/gxvmorx0.c2
-rw-r--r--src/3rdparty/freetype/src/gxvalid/gxvmorx1.c2
-rw-r--r--src/3rdparty/freetype/src/gxvalid/gxvmorx2.c2
-rw-r--r--src/3rdparty/freetype/src/gxvalid/gxvmorx4.c2
-rw-r--r--src/3rdparty/freetype/src/gxvalid/gxvmorx5.c2
-rw-r--r--src/3rdparty/freetype/src/gxvalid/gxvopbd.c2
-rw-r--r--src/3rdparty/freetype/src/gxvalid/gxvprop.c2
-rw-r--r--src/3rdparty/freetype/src/gxvalid/gxvtrak.c6
-rw-r--r--src/3rdparty/freetype/src/gxvalid/module.mk2
-rw-r--r--src/3rdparty/freetype/src/gxvalid/rules.mk2
-rw-r--r--src/3rdparty/freetype/src/gzip/Jamfile2
-rw-r--r--src/3rdparty/freetype/src/gzip/ftgzip.c38
-rw-r--r--src/3rdparty/freetype/src/gzip/ftzconf.h284
-rw-r--r--src/3rdparty/freetype/src/gzip/rules.mk8
-rw-r--r--src/3rdparty/freetype/src/gzip/zlib.h4
-rw-r--r--src/3rdparty/freetype/src/gzip/zutil.h2
-rw-r--r--src/3rdparty/freetype/src/lzw/Jamfile2
-rw-r--r--src/3rdparty/freetype/src/lzw/ftlzw.c4
-rw-r--r--src/3rdparty/freetype/src/lzw/ftzopen.c16
-rw-r--r--src/3rdparty/freetype/src/lzw/ftzopen.h8
-rw-r--r--src/3rdparty/freetype/src/lzw/rules.mk2
-rw-r--r--src/3rdparty/freetype/src/otvalid/Jamfile2
-rw-r--r--src/3rdparty/freetype/src/otvalid/module.mk2
-rw-r--r--src/3rdparty/freetype/src/otvalid/otvalid.c5
-rw-r--r--src/3rdparty/freetype/src/otvalid/otvalid.h8
-rw-r--r--src/3rdparty/freetype/src/otvalid/otvbase.c35
-rw-r--r--src/3rdparty/freetype/src/otvalid/otvcommn.c32
-rw-r--r--src/3rdparty/freetype/src/otvalid/otvcommn.h60
-rw-r--r--src/3rdparty/freetype/src/otvalid/otverror.h10
-rw-r--r--src/3rdparty/freetype/src/otvalid/otvgdef.c113
-rw-r--r--src/3rdparty/freetype/src/otvalid/otvgpos.c56
-rw-r--r--src/3rdparty/freetype/src/otvalid/otvgpos.h8
-rw-r--r--src/3rdparty/freetype/src/otvalid/otvgsub.c36
-rw-r--r--src/3rdparty/freetype/src/otvalid/otvjstf.c2
-rw-r--r--src/3rdparty/freetype/src/otvalid/otvmath.c24
-rw-r--r--src/3rdparty/freetype/src/otvalid/otvmod.c12
-rw-r--r--src/3rdparty/freetype/src/otvalid/otvmod.h8
-rw-r--r--src/3rdparty/freetype/src/otvalid/rules.mk2
-rw-r--r--src/3rdparty/freetype/src/pcf/Jamfile2
-rw-r--r--src/3rdparty/freetype/src/pcf/README4
-rw-r--r--src/3rdparty/freetype/src/pcf/pcf.c8
-rw-r--r--src/3rdparty/freetype/src/pcf/pcf.h20
-rw-r--r--src/3rdparty/freetype/src/pcf/pcfdrivr.c259
-rw-r--r--src/3rdparty/freetype/src/pcf/pcfdrivr.h6
-rw-r--r--src/3rdparty/freetype/src/pcf/pcferror.h8
-rw-r--r--src/3rdparty/freetype/src/pcf/pcfread.c470
-rw-r--r--src/3rdparty/freetype/src/pcf/pcfread.h6
-rw-r--r--src/3rdparty/freetype/src/pcf/pcfutil.h6
-rw-r--r--src/3rdparty/freetype/src/pfr/Jamfile2
-rw-r--r--src/3rdparty/freetype/src/pfr/module.mk2
-rw-r--r--src/3rdparty/freetype/src/pfr/pfr.c11
-rw-r--r--src/3rdparty/freetype/src/pfr/pfrcmap.c18
-rw-r--r--src/3rdparty/freetype/src/pfr/pfrcmap.h8
-rw-r--r--src/3rdparty/freetype/src/pfr/pfrdrivr.c41
-rw-r--r--src/3rdparty/freetype/src/pfr/pfrdrivr.h8
-rw-r--r--src/3rdparty/freetype/src/pfr/pfrerror.h10
-rw-r--r--src/3rdparty/freetype/src/pfr/pfrgload.c67
-rw-r--r--src/3rdparty/freetype/src/pfr/pfrgload.h8
-rw-r--r--src/3rdparty/freetype/src/pfr/pfrload.c190
-rw-r--r--src/3rdparty/freetype/src/pfr/pfrload.h23
-rw-r--r--src/3rdparty/freetype/src/pfr/pfrobjs.c45
-rw-r--r--src/3rdparty/freetype/src/pfr/pfrobjs.h8
-rw-r--r--src/3rdparty/freetype/src/pfr/pfrsbit.c221
-rw-r--r--src/3rdparty/freetype/src/pfr/pfrsbit.h11
-rw-r--r--src/3rdparty/freetype/src/pfr/pfrtypes.h122
-rw-r--r--src/3rdparty/freetype/src/pfr/rules.mk2
-rw-r--r--src/3rdparty/freetype/src/psaux/Jamfile12
-rw-r--r--src/3rdparty/freetype/src/psaux/afmparse.c11
-rw-r--r--src/3rdparty/freetype/src/psaux/afmparse.h8
-rw-r--r--src/3rdparty/freetype/src/psaux/cffdecode.c2370
-rw-r--r--src/3rdparty/freetype/src/psaux/cffdecode.h64
-rw-r--r--src/3rdparty/freetype/src/psaux/module.mk2
-rw-r--r--src/3rdparty/freetype/src/psaux/psarrst.c241
-rw-r--r--src/3rdparty/freetype/src/psaux/psarrst.h100
-rw-r--r--src/3rdparty/freetype/src/psaux/psaux.c25
-rw-r--r--src/3rdparty/freetype/src/psaux/psauxerr.h10
-rw-r--r--src/3rdparty/freetype/src/psaux/psauxmod.c122
-rw-r--r--src/3rdparty/freetype/src/psaux/psauxmod.h17
-rw-r--r--src/3rdparty/freetype/src/psaux/psblues.c582
-rw-r--r--src/3rdparty/freetype/src/psaux/psblues.h185
-rw-r--r--src/3rdparty/freetype/src/psaux/psconv.c10
-rw-r--r--src/3rdparty/freetype/src/psaux/psconv.h8
-rw-r--r--src/3rdparty/freetype/src/psaux/pserror.c52
-rw-r--r--src/3rdparty/freetype/src/psaux/pserror.h119
-rw-r--r--src/3rdparty/freetype/src/psaux/psfixed.h95
-rw-r--r--src/3rdparty/freetype/src/psaux/psfont.c567
-rw-r--r--src/3rdparty/freetype/src/psaux/psfont.h134
-rw-r--r--src/3rdparty/freetype/src/psaux/psft.c890
-rw-r--r--src/3rdparty/freetype/src/psaux/psft.h167
-rw-r--r--src/3rdparty/freetype/src/psaux/psglue.h144
-rw-r--r--src/3rdparty/freetype/src/psaux/pshints.c1939
-rw-r--r--src/3rdparty/freetype/src/psaux/pshints.h288
-rw-r--r--src/3rdparty/freetype/src/psaux/psintrp.c3040
-rw-r--r--src/3rdparty/freetype/src/psaux/psintrp.h83
-rw-r--r--src/3rdparty/freetype/src/psaux/psobjs.c799
-rw-r--r--src/3rdparty/freetype/src/psaux/psobjs.h109
-rw-r--r--src/3rdparty/freetype/src/psaux/psread.c112
-rw-r--r--src/3rdparty/freetype/src/psaux/psread.h68
-rw-r--r--src/3rdparty/freetype/src/psaux/psstack.c328
-rw-r--r--src/3rdparty/freetype/src/psaux/psstack.h121
-rw-r--r--src/3rdparty/freetype/src/psaux/pstypes.h78
-rw-r--r--src/3rdparty/freetype/src/psaux/rules.mk19
-rw-r--r--src/3rdparty/freetype/src/psaux/t1cmap.c64
-rw-r--r--src/3rdparty/freetype/src/psaux/t1cmap.h8
-rw-r--r--src/3rdparty/freetype/src/psaux/t1decode.c530
-rw-r--r--src/3rdparty/freetype/src/psaux/t1decode.h18
-rw-r--r--src/3rdparty/freetype/src/pshinter/Jamfile2
-rw-r--r--src/3rdparty/freetype/src/pshinter/module.mk2
-rw-r--r--src/3rdparty/freetype/src/pshinter/pshalgo.c18
-rw-r--r--src/3rdparty/freetype/src/pshinter/pshalgo.h8
-rw-r--r--src/3rdparty/freetype/src/pshinter/pshglob.c8
-rw-r--r--src/3rdparty/freetype/src/pshinter/pshglob.h8
-rw-r--r--src/3rdparty/freetype/src/pshinter/pshinter.c10
-rw-r--r--src/3rdparty/freetype/src/pshinter/pshmod.c14
-rw-r--r--src/3rdparty/freetype/src/pshinter/pshmod.h8
-rw-r--r--src/3rdparty/freetype/src/pshinter/pshnterr.h10
-rw-r--r--src/3rdparty/freetype/src/pshinter/pshpic.c2
-rw-r--r--src/3rdparty/freetype/src/pshinter/pshpic.h8
-rw-r--r--src/3rdparty/freetype/src/pshinter/pshrec.c8
-rw-r--r--src/3rdparty/freetype/src/pshinter/pshrec.h8
-rw-r--r--src/3rdparty/freetype/src/pshinter/rules.mk2
-rw-r--r--src/3rdparty/freetype/src/psnames/Jamfile2
-rw-r--r--src/3rdparty/freetype/src/psnames/module.mk2
-rw-r--r--src/3rdparty/freetype/src/psnames/psmodule.c63
-rw-r--r--src/3rdparty/freetype/src/psnames/psmodule.h8
-rw-r--r--src/3rdparty/freetype/src/psnames/psnamerr.h10
-rw-r--r--src/3rdparty/freetype/src/psnames/psnames.c6
-rw-r--r--src/3rdparty/freetype/src/psnames/pspic.c2
-rw-r--r--src/3rdparty/freetype/src/psnames/pspic.h8
-rw-r--r--src/3rdparty/freetype/src/psnames/pstables.h94
-rw-r--r--src/3rdparty/freetype/src/psnames/rules.mk2
-rw-r--r--src/3rdparty/freetype/src/raster/Jamfile2
-rw-r--r--src/3rdparty/freetype/src/raster/ftmisc.h8
-rw-r--r--src/3rdparty/freetype/src/raster/ftraster.c97
-rw-r--r--src/3rdparty/freetype/src/raster/ftraster.h10
-rw-r--r--src/3rdparty/freetype/src/raster/ftrend1.c142
-rw-r--r--src/3rdparty/freetype/src/raster/ftrend1.h8
-rw-r--r--src/3rdparty/freetype/src/raster/module.mk2
-rw-r--r--src/3rdparty/freetype/src/raster/raster.c6
-rw-r--r--src/3rdparty/freetype/src/raster/rasterrs.h10
-rw-r--r--src/3rdparty/freetype/src/raster/rastpic.c2
-rw-r--r--src/3rdparty/freetype/src/raster/rastpic.h8
-rw-r--r--src/3rdparty/freetype/src/raster/rules.mk2
-rw-r--r--src/3rdparty/freetype/src/sfnt/Jamfile2
-rw-r--r--src/3rdparty/freetype/src/sfnt/module.mk2
-rw-r--r--src/3rdparty/freetype/src/sfnt/pngshim.c119
-rw-r--r--src/3rdparty/freetype/src/sfnt/pngshim.h11
-rw-r--r--src/3rdparty/freetype/src/sfnt/rules.mk2
-rw-r--r--src/3rdparty/freetype/src/sfnt/sfdriver.c977
-rw-r--r--src/3rdparty/freetype/src/sfnt/sfdriver.h8
-rw-r--r--src/3rdparty/freetype/src/sfnt/sferrors.h11
-rw-r--r--src/3rdparty/freetype/src/sfnt/sfnt.c26
-rw-r--r--src/3rdparty/freetype/src/sfnt/sfntpic.c2
-rw-r--r--src/3rdparty/freetype/src/sfnt/sfntpic.h8
-rw-r--r--src/3rdparty/freetype/src/sfnt/sfobjs.c437
-rw-r--r--src/3rdparty/freetype/src/sfnt/sfobjs.h8
-rw-r--r--src/3rdparty/freetype/src/sfnt/ttbdf.c15
-rw-r--r--src/3rdparty/freetype/src/sfnt/ttbdf.h12
-rw-r--r--src/3rdparty/freetype/src/sfnt/ttcmap.c537
-rw-r--r--src/3rdparty/freetype/src/sfnt/ttcmap.h10
-rw-r--r--src/3rdparty/freetype/src/sfnt/ttcmapc.h2
-rw-r--r--src/3rdparty/freetype/src/sfnt/ttkern.c17
-rw-r--r--src/3rdparty/freetype/src/sfnt/ttkern.h8
-rw-r--r--src/3rdparty/freetype/src/sfnt/ttload.c162
-rw-r--r--src/3rdparty/freetype/src/sfnt/ttload.h8
-rw-r--r--src/3rdparty/freetype/src/sfnt/ttmtx.c48
-rw-r--r--src/3rdparty/freetype/src/sfnt/ttmtx.h8
-rw-r--r--src/3rdparty/freetype/src/sfnt/ttpost.c30
-rw-r--r--src/3rdparty/freetype/src/sfnt/ttpost.h10
-rw-r--r--src/3rdparty/freetype/src/sfnt/ttsbit.c402
-rw-r--r--src/3rdparty/freetype/src/sfnt/ttsbit.h8
-rw-r--r--src/3rdparty/freetype/src/smooth/Jamfile2
-rw-r--r--src/3rdparty/freetype/src/smooth/ftgrays.c1380
-rw-r--r--src/3rdparty/freetype/src/smooth/ftgrays.h10
-rw-r--r--src/3rdparty/freetype/src/smooth/ftsmerrs.h10
-rw-r--r--src/3rdparty/freetype/src/smooth/ftsmooth.c381
-rw-r--r--src/3rdparty/freetype/src/smooth/ftsmooth.h17
-rw-r--r--src/3rdparty/freetype/src/smooth/ftspic.c2
-rw-r--r--src/3rdparty/freetype/src/smooth/ftspic.h8
-rw-r--r--src/3rdparty/freetype/src/smooth/module.mk2
-rw-r--r--src/3rdparty/freetype/src/smooth/rules.mk2
-rw-r--r--src/3rdparty/freetype/src/smooth/smooth.c6
-rw-r--r--src/3rdparty/freetype/src/tools/afblue.pl17
-rw-r--r--src/3rdparty/freetype/src/tools/apinames.c33
-rw-r--r--src/3rdparty/freetype/src/tools/docmaker/content.py66
-rw-r--r--src/3rdparty/freetype/src/tools/docmaker/docbeauty.py18
-rw-r--r--src/3rdparty/freetype/src/tools/docmaker/docmaker.py26
-rw-r--r--src/3rdparty/freetype/src/tools/docmaker/formatter.py7
-rw-r--r--src/3rdparty/freetype/src/tools/docmaker/sources.py34
-rw-r--r--src/3rdparty/freetype/src/tools/docmaker/tohtml.py184
-rw-r--r--src/3rdparty/freetype/src/tools/docmaker/utils.py2
-rw-r--r--src/3rdparty/freetype/src/tools/ftfuzzer/README81
-rw-r--r--src/3rdparty/freetype/src/tools/ftfuzzer/ftfuzzer.cc428
-rw-r--r--src/3rdparty/freetype/src/tools/ftfuzzer/ftmutator.cc314
-rw-r--r--src/3rdparty/freetype/src/tools/ftfuzzer/rasterfuzzer.cc129
-rw-r--r--src/3rdparty/freetype/src/tools/ftfuzzer/runinput.cc58
-rw-r--r--src/3rdparty/freetype/src/tools/ftrandom/Makefile26
-rw-r--r--src/3rdparty/freetype/src/tools/ftrandom/README79
-rw-r--r--src/3rdparty/freetype/src/tools/ftrandom/ftrandom.c161
-rw-r--r--src/3rdparty/freetype/src/tools/glnames.py87
-rw-r--r--src/3rdparty/freetype/src/tools/no-copyright4
-rw-r--r--src/3rdparty/freetype/src/tools/update-copyright-year2
-rw-r--r--src/3rdparty/freetype/src/truetype/Jamfile2
-rw-r--r--src/3rdparty/freetype/src/truetype/module.mk2
-rw-r--r--src/3rdparty/freetype/src/truetype/rules.mk2
-rw-r--r--src/3rdparty/freetype/src/truetype/truetype.c18
-rw-r--r--src/3rdparty/freetype/src/truetype/ttdriver.c205
-rw-r--r--src/3rdparty/freetype/src/truetype/ttdriver.h8
-rw-r--r--src/3rdparty/freetype/src/truetype/tterrors.h11
-rw-r--r--src/3rdparty/freetype/src/truetype/ttgload.c795
-rw-r--r--src/3rdparty/freetype/src/truetype/ttgload.h8
-rw-r--r--src/3rdparty/freetype/src/truetype/ttgxvar.c2690
-rw-r--r--src/3rdparty/freetype/src/truetype/ttgxvar.h305
-rw-r--r--src/3rdparty/freetype/src/truetype/ttinterp.c1462
-rw-r--r--src/3rdparty/freetype/src/truetype/ttinterp.h171
-rw-r--r--src/3rdparty/freetype/src/truetype/ttobjs.c417
-rw-r--r--src/3rdparty/freetype/src/truetype/ttobjs.h20
-rw-r--r--src/3rdparty/freetype/src/truetype/ttpic.c2
-rw-r--r--src/3rdparty/freetype/src/truetype/ttpic.h29
-rw-r--r--src/3rdparty/freetype/src/truetype/ttpload.c81
-rw-r--r--src/3rdparty/freetype/src/truetype/ttpload.h8
-rw-r--r--src/3rdparty/freetype/src/truetype/ttsubpix.c39
-rw-r--r--src/3rdparty/freetype/src/truetype/ttsubpix.h13
-rw-r--r--src/3rdparty/freetype/src/type1/Jamfile2
-rw-r--r--src/3rdparty/freetype/src/type1/module.mk2
-rw-r--r--src/3rdparty/freetype/src/type1/rules.mk2
-rw-r--r--src/3rdparty/freetype/src/type1/t1afm.c35
-rw-r--r--src/3rdparty/freetype/src/type1/t1afm.h8
-rw-r--r--src/3rdparty/freetype/src/type1/t1driver.c126
-rw-r--r--src/3rdparty/freetype/src/type1/t1driver.h8
-rw-r--r--src/3rdparty/freetype/src/type1/t1errors.h10
-rw-r--r--src/3rdparty/freetype/src/type1/t1gload.c127
-rw-r--r--src/3rdparty/freetype/src/type1/t1gload.h8
-rw-r--r--src/3rdparty/freetype/src/type1/t1load.c290
-rw-r--r--src/3rdparty/freetype/src/type1/t1load.h27
-rw-r--r--src/3rdparty/freetype/src/type1/t1objs.c66
-rw-r--r--src/3rdparty/freetype/src/type1/t1objs.h14
-rw-r--r--src/3rdparty/freetype/src/type1/t1parse.c4
-rw-r--r--src/3rdparty/freetype/src/type1/t1parse.h8
-rw-r--r--src/3rdparty/freetype/src/type1/t1tokens.h2
-rw-r--r--src/3rdparty/freetype/src/type1/type1.c15
-rw-r--r--src/3rdparty/freetype/src/type42/Jamfile2
-rw-r--r--src/3rdparty/freetype/src/type42/module.mk2
-rw-r--r--src/3rdparty/freetype/src/type42/rules.mk2
-rw-r--r--src/3rdparty/freetype/src/type42/t42drivr.c54
-rw-r--r--src/3rdparty/freetype/src/type42/t42drivr.h8
-rw-r--r--src/3rdparty/freetype/src/type42/t42error.h10
-rw-r--r--src/3rdparty/freetype/src/type42/t42objs.c18
-rw-r--r--src/3rdparty/freetype/src/type42/t42objs.h8
-rw-r--r--src/3rdparty/freetype/src/type42/t42parse.c55
-rw-r--r--src/3rdparty/freetype/src/type42/t42parse.h8
-rw-r--r--src/3rdparty/freetype/src/type42/t42types.h8
-rw-r--r--src/3rdparty/freetype/src/type42/type42.c8
-rw-r--r--src/3rdparty/freetype/src/winfonts/Jamfile2
-rw-r--r--src/3rdparty/freetype/src/winfonts/fnterrs.h10
-rw-r--r--src/3rdparty/freetype/src/winfonts/module.mk2
-rw-r--r--src/3rdparty/freetype/src/winfonts/rules.mk2
-rw-r--r--src/3rdparty/freetype/src/winfonts/winfnt.c99
-rw-r--r--src/3rdparty/freetype/src/winfonts/winfnt.h8
438 files changed, 37583 insertions, 11529 deletions
diff --git a/src/3rdparty/freetype/src/Jamfile b/src/3rdparty/freetype/src/Jamfile
index 65e061910d..562480c94a 100644
--- a/src/3rdparty/freetype/src/Jamfile
+++ b/src/3rdparty/freetype/src/Jamfile
@@ -1,6 +1,6 @@
# FreeType 2 src Jamfile
#
-# Copyright 2001-2015 by
+# Copyright 2001-2018 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/src/3rdparty/freetype/src/autofit/Jamfile b/src/3rdparty/freetype/src/autofit/Jamfile
index 5cd0b46108..01b866ec61 100644
--- a/src/3rdparty/freetype/src/autofit/Jamfile
+++ b/src/3rdparty/freetype/src/autofit/Jamfile
@@ -1,6 +1,6 @@
# FreeType 2 src/autofit Jamfile
#
-# Copyright 2003-2015 by
+# Copyright 2003-2018 by
# David Turner, Robert Wilhelm, and Werner Lemberg.
#
# This file is part of the FreeType project, and may only be used, modified,
@@ -33,8 +33,8 @@ SubDir FT2_TOP src autofit ;
afmodule
afpic
afranges
+ afshaper
afwarp
- hbshim
;
if $(FT2_AUTOFIT2)
diff --git a/src/3rdparty/freetype/src/autofit/afangles.c b/src/3rdparty/freetype/src/autofit/afangles.c
index 1b1eb31fe7..c65a3ae23e 100644
--- a/src/3rdparty/freetype/src/autofit/afangles.c
+++ b/src/3rdparty/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-2015 by */
+/* Copyright 2003-2018 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
diff --git a/src/3rdparty/freetype/src/autofit/afblue.c b/src/3rdparty/freetype/src/autofit/afblue.c
index b871e0c651..e4078fd044 100644
--- a/src/3rdparty/freetype/src/autofit/afblue.c
+++ b/src/3rdparty/freetype/src/autofit/afblue.c
@@ -7,7 +7,7 @@
/* */
/* Auto-fitter data for blue strings (body). */
/* */
-/* Copyright 2013-2015 by */
+/* Copyright 2013-2018 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -26,139 +26,411 @@
af_blue_strings[] =
{
/* */
- '\xD8', '\xA7', '\xD8', '\xA5', '\xD9', '\x84', '\xD9', '\x83', '\xD8', '\xB7', '\xD8', '\xB8', /* ا إ ل ك ط ظ */
+ '\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',
- '\xD8', '\xAA', '\xD8', '\xAB', '\xD8', '\xB7', '\xD8', '\xB8', '\xD9', '\x83', /* ت ث ط ظ ك */
+ '\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',
- '\xD0', '\x91', '\xD0', '\x92', '\xD0', '\x95', '\xD0', '\x9F', '\xD0', '\x97', '\xD0', '\x9E', '\xD0', '\xA1', '\xD0', '\xAD', /* БВЕПЗОСЭ */
+ '\xD4', '\xB1', ' ', '\xD5', '\x84', ' ', '\xD5', '\x92', ' ', '\xD5', '\x8D', ' ', '\xD4', '\xB2', ' ', '\xD4', '\xB3', ' ', '\xD4', '\xB4', ' ', '\xD5', '\x95', /* Ա Մ Ւ Ս Բ Գ Դ Օ */
+ '\0',
+ '\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', '\x86', ' ', '\xD5', '\xB3', /* ե է ի մ վ ֆ ճ */
+ '\0',
+ '\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', /* ꮒ ꮤ ꮶ ꭴ ꭾ ꮗ ꮝ ꮿ */
+ '\0',
+ '\xEA', '\xAE', '\x96', ' ', '\xEA', '\xAD', '\xBC', ' ', '\xEA', '\xAE', '\x93', ' ', '\xEA', '\xAE', '\xA0', ' ', '\xEA', '\xAE', '\xB3', ' ', '\xEA', '\xAD', '\xB6', ' ', '\xEA', '\xAE', '\xA5', ' ', '\xEA', '\xAE', '\xBB', /* ꮖ ꭼ ꮓ ꮠ ꮳ ꭶ ꮥ ꮻ */
+ '\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', /* Б В Е Ш З О С Э */
+ '\0',
+ '\xD1', '\x85', ' ', '\xD0', '\xBF', ' ', '\xD0', '\xBD', ' ', '\xD1', '\x88', ' ', '\xD0', '\xB5', ' ', '\xD0', '\xB7', ' ', '\xD0', '\xBE', ' ', '\xD1', '\x81', /* х п н ш е з о с */
+ '\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', /* ई ऐ ओ औ ि ी ो ौ */
+ '\0',
+ '\xE0', '\xA4', '\x95', ' ', '\xE0', '\xA4', '\xAE', ' ', '\xE0', '\xA4', '\x85', ' ', '\xE0', '\xA4', '\x86', ' ', '\xE0', '\xA4', '\xA5', ' ', '\xE0', '\xA4', '\xA7', ' ', '\xE0', '\xA4', '\xAD', ' ', '\xE0', '\xA4', '\xB6', /* क म अ आ थ ध भ श */
+ '\0',
+ '\xE0', '\xA5', '\x81', ' ', '\xE0', '\xA5', '\x83', /* ु ृ */
+ '\0',
+ '\xE1', '\x88', '\x80', ' ', '\xE1', '\x88', '\x83', ' ', '\xE1', '\x8B', '\x98', ' ', '\xE1', '\x8D', '\x90', ' ', '\xE1', '\x88', '\x9B', ' ', '\xE1', '\x89', '\xA0', ' ', '\xE1', '\x8B', '\x8B', ' ', '\xE1', '\x8B', '\x90', /* ሀ ሃ ዘ ፐ ማ በ ዋ ዐ */
+ '\0',
+ '\xE1', '\x88', '\x88', ' ', '\xE1', '\x88', '\x90', ' ', '\xE1', '\x89', '\xA0', ' ', '\xE1', '\x8B', '\x98', ' ', '\xE1', '\x88', '\x80', ' ', '\xE1', '\x88', '\xAA', ' ', '\xE1', '\x8B', '\x90', ' ', '\xE1', '\x8C', '\xA8', /* ለ ሐ በ ዘ ሀ ሪ ዐ ጨ */
+ '\0',
+ '\xE1', '\x83', '\x92', ' ', '\xE1', '\x83', '\x93', ' ', '\xE1', '\x83', '\x94', ' ', '\xE1', '\x83', '\x95', ' ', '\xE1', '\x83', '\x97', ' ', '\xE1', '\x83', '\x98', ' ', '\xE1', '\x83', '\x9D', ' ', '\xE1', '\x83', '\xA6', /* გ დ ე ვ თ ი ო ღ */
+ '\0',
+ '\xE1', '\x83', '\x90', ' ', '\xE1', '\x83', '\x96', ' ', '\xE1', '\x83', '\x9B', ' ', '\xE1', '\x83', '\xA1', ' ', '\xE1', '\x83', '\xA8', ' ', '\xE1', '\x83', '\xAB', ' ', '\xE1', '\x83', '\xAE', ' ', '\xE1', '\x83', '\x9E', /* ა ზ მ ს შ ძ ხ პ */
+ '\0',
+ '\xE1', '\x83', '\xA1', ' ', '\xE1', '\x83', '\xAE', ' ', '\xE1', '\x83', '\xA5', ' ', '\xE1', '\x83', '\x96', ' ', '\xE1', '\x83', '\x9B', ' ', '\xE1', '\x83', '\xA8', ' ', '\xE1', '\x83', '\xA9', ' ', '\xE1', '\x83', '\xAC', /* ს ხ ქ ზ მ შ ჩ წ */
+ '\0',
+ '\xE1', '\x83', '\x94', ' ', '\xE1', '\x83', '\x95', ' ', '\xE1', '\x83', '\x9F', ' ', '\xE1', '\x83', '\xA2', ' ', '\xE1', '\x83', '\xA3', ' ', '\xE1', '\x83', '\xA4', ' ', '\xE1', '\x83', '\xA5', ' ', '\xE1', '\x83', '\xA7', /* ე ვ ჟ ტ უ ფ ქ ყ */
+ '\0',
+ '\xE1', '\x82', '\xB1', ' ', '\xE1', '\x82', '\xA7', ' ', '\xE1', '\x82', '\xB9', ' ', '\xE1', '\x82', '\xBC', ' ', '\xE1', '\x82', '\xA4', ' ', '\xE1', '\x82', '\xA5', ' ', '\xE1', '\x82', '\xB3', ' ', '\xE1', '\x82', '\xBA', /* Ⴑ Ⴇ Ⴙ Ⴜ Ⴄ Ⴅ Ⴓ Ⴚ */
+ '\0',
+ '\xE1', '\x82', '\xA4', ' ', '\xE1', '\x82', '\xA5', ' ', '\xE1', '\x82', '\xA7', ' ', '\xE1', '\x82', '\xA8', ' ', '\xE1', '\x82', '\xA6', ' ', '\xE1', '\x82', '\xB1', ' ', '\xE1', '\x82', '\xAA', ' ', '\xE1', '\x82', '\xAB', /* Ⴄ Ⴅ Ⴇ Ⴈ Ⴆ Ⴑ Ⴊ Ⴋ */
+ '\0',
+ '\xE2', '\xB4', '\x81', ' ', '\xE2', '\xB4', '\x97', ' ', '\xE2', '\xB4', '\x82', ' ', '\xE2', '\xB4', '\x84', ' ', '\xE2', '\xB4', '\x85', ' ', '\xE2', '\xB4', '\x87', ' ', '\xE2', '\xB4', '\x94', ' ', '\xE2', '\xB4', '\x96', /* ⴁ ⴗ ⴂ ⴄ ⴅ ⴇ ⴔ ⴖ */
+ '\0',
+ '\xE2', '\xB4', '\x88', ' ', '\xE2', '\xB4', '\x8C', ' ', '\xE2', '\xB4', '\x96', ' ', '\xE2', '\xB4', '\x8E', ' ', '\xE2', '\xB4', '\x83', ' ', '\xE2', '\xB4', '\x86', ' ', '\xE2', '\xB4', '\x8B', ' ', '\xE2', '\xB4', '\xA2', /* ⴈ ⴌ ⴖ ⴎ ⴃ ⴆ ⴋ ⴢ */
+ '\0',
+ '\xE2', '\xB4', '\x90', ' ', '\xE2', '\xB4', '\x91', ' ', '\xE2', '\xB4', '\x93', ' ', '\xE2', '\xB4', '\x95', ' ', '\xE2', '\xB4', '\x99', ' ', '\xE2', '\xB4', '\x9B', ' ', '\xE2', '\xB4', '\xA1', ' ', '\xE2', '\xB4', '\xA3', /* ⴐ ⴑ ⴓ ⴕ ⴙ ⴛ ⴡ ⴣ */
+ '\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',
+ '\xE1', '\xB2', '\x9C', ' ', '\xE1', '\xB2', '\x9F', ' ', '\xE1', '\xB2', '\xB3', ' ', '\xE1', '\xB2', '\xB8', ' ', '\xE1', '\xB2', '\x92', ' ', '\xE1', '\xB2', '\x94', ' ', '\xE1', '\xB2', '\x9D', ' ', '\xE1', '\xB2', '\xB4', /* Ნ Ჟ Ჳ Ჸ Გ Ე Ო Ჴ */
+ '\0',
+ '\xE1', '\xB2', '\x98', ' ', '\xE1', '\xB2', '\xB2', ' ', '\xE1', '\xB2', '\x9D', ' ', '\xE1', '\xB2', '\xA9', ' ', '\xE1', '\xB2', '\x9B', ' ', '\xE1', '\xB2', '\xA8', ' ', '\xE1', '\xB2', '\xAF', ' ', '\xE1', '\xB2', '\xBD', /* Ი Ჲ Ო Ჩ Მ Შ Ჯ Ჽ */
+ '\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', /* Β Δ Ζ Ξ Θ Ο */
+ '\0',
+ '\xCE', '\xB2', ' ', '\xCE', '\xB8', ' ', '\xCE', '\xB4', ' ', '\xCE', '\xB6', ' ', '\xCE', '\xBB', ' ', '\xCE', '\xBE', /* β θ δ ζ λ ξ */
'\0',
- '\xD0', '\x91', '\xD0', '\x92', '\xD0', '\x95', '\xD0', '\xA8', '\xD0', '\x97', '\xD0', '\x9E', '\xD0', '\xA1', '\xD0', '\xAD', /* БВЕШЗОСЭ */
+ '\xCE', '\xB1', ' ', '\xCE', '\xB5', ' ', '\xCE', '\xB9', ' ', '\xCE', '\xBF', ' ', '\xCF', '\x80', ' ', '\xCF', '\x83', ' ', '\xCF', '\x84', ' ', '\xCF', '\x89', /* α ε ι ο π σ τ ω */
'\0',
- '\xD1', '\x85', '\xD0', '\xBF', '\xD0', '\xBD', '\xD1', '\x88', '\xD0', '\xB5', '\xD0', '\xB7', '\xD0', '\xBE', '\xD1', '\x81', /* хпншезос */
+ '\xCE', '\xB2', ' ', '\xCE', '\xB3', ' ', '\xCE', '\xB7', ' ', '\xCE', '\xBC', ' ', '\xCF', '\x81', ' ', '\xCF', '\x86', ' ', '\xCF', '\x87', ' ', '\xCF', '\x88', /* β γ η μ ρ φ χ ψ */
'\0',
- '\xD1', '\x80', '\xD1', '\x83', '\xD1', '\x84', /* руф */
+ '\xE0', '\xAA', '\xA4', ' ', '\xE0', '\xAA', '\xA8', ' ', '\xE0', '\xAA', '\x8B', ' ', '\xE0', '\xAA', '\x8C', ' ', '\xE0', '\xAA', '\x9B', ' ', '\xE0', '\xAA', '\x9F', ' ', '\xE0', '\xAA', '\xB0', ' ', '\xE0', '\xAB', '\xA6', /* ત ન ઋ ઌ છ ટ ર ૦ */
'\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', /* क म अ आ थ ध भ श */
+ '\xE0', '\xAA', '\x96', ' ', '\xE0', '\xAA', '\x97', ' ', '\xE0', '\xAA', '\x98', ' ', '\xE0', '\xAA', '\x9E', ' ', '\xE0', '\xAA', '\x87', ' ', '\xE0', '\xAA', '\x88', ' ', '\xE0', '\xAA', '\xA0', ' ', '\xE0', '\xAA', '\x9C', /* ખ ગ ઘ ઞ ઇ ઈ ઠ જ */
'\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', /* ई ऐ ओ औ ि ी ो ौ */
+ '\xE0', '\xAA', '\x88', ' ', '\xE0', '\xAA', '\x8A', ' ', '\xE0', '\xAA', '\xBF', ' ', '\xE0', '\xAB', '\x80', ' ', '\xE0', '\xAA', '\xB2', '\xE0', '\xAB', '\x80', ' ', '\xE0', '\xAA', '\xB6', '\xE0', '\xAB', '\x8D', '\xE0', '\xAA', '\x9A', '\xE0', '\xAA', '\xBF', ' ', '\xE0', '\xAA', '\x9C', '\xE0', '\xAA', '\xBF', ' ', '\xE0', '\xAA', '\xB8', '\xE0', '\xAB', '\x80', /* ઈ ઊ િ ી લી શ્ચિ જિ સી */
'\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', /* क म अ आ थ ध भ श */
+ '\xE0', '\xAB', '\x81', ' ', '\xE0', '\xAB', '\x83', ' ', '\xE0', '\xAB', '\x84', ' ', '\xE0', '\xAA', '\x96', '\xE0', '\xAB', '\x81', ' ', '\xE0', '\xAA', '\x9B', '\xE0', '\xAB', '\x83', ' ', '\xE0', '\xAA', '\x9B', '\xE0', '\xAB', '\x84', /* ુ ૃ ૄ ખુ છૃ છૄ */
'\0',
- '\xE0', '\xA5', '\x81', '\xE0', '\xA5', '\x83', /* ु ृ */
+ '\xE0', '\xAB', '\xA6', ' ', '\xE0', '\xAB', '\xA7', ' ', '\xE0', '\xAB', '\xA8', ' ', '\xE0', '\xAB', '\xA9', ' ', '\xE0', '\xAB', '\xAD', /* ૦ ૧ ૨ ૩ ૭ */
'\0',
- '\xCE', '\x93', '\xCE', '\x92', '\xCE', '\x95', '\xCE', '\x96', '\xCE', '\x98', '\xCE', '\x9F', '\xCE', '\xA9', /* ΓΒΕΖΘΟΩ */
+ '\xE0', '\xA8', '\x95', ' ', '\xE0', '\xA8', '\x97', ' ', '\xE0', '\xA8', '\x99', ' ', '\xE0', '\xA8', '\x9A', ' ', '\xE0', '\xA8', '\x9C', ' ', '\xE0', '\xA8', '\xA4', ' ', '\xE0', '\xA8', '\xA7', ' ', '\xE0', '\xA8', '\xB8', /* ਕ ਗ ਙ ਚ ਜ ਤ ਧ ਸ */
'\0',
- '\xCE', '\x92', '\xCE', '\x94', '\xCE', '\x96', '\xCE', '\x9E', '\xCE', '\x98', '\xCE', '\x9F', /* ΒΔΖΞΘΟ */
+ '\xE0', '\xA8', '\x95', ' ', '\xE0', '\xA8', '\x97', ' ', '\xE0', '\xA8', '\x99', ' ', '\xE0', '\xA8', '\x9A', ' ', '\xE0', '\xA8', '\x9C', ' ', '\xE0', '\xA8', '\xA4', ' ', '\xE0', '\xA8', '\xA7', ' ', '\xE0', '\xA8', '\xB8', /* ਕ ਗ ਙ ਚ ਜ ਤ ਧ ਸ */
'\0',
- '\xCE', '\xB2', '\xCE', '\xB8', '\xCE', '\xB4', '\xCE', '\xB6', '\xCE', '\xBB', '\xCE', '\xBE', /* βθδζλξ */
+ '\xE0', '\xA8', '\x87', ' ', '\xE0', '\xA8', '\x88', ' ', '\xE0', '\xA8', '\x89', ' ', '\xE0', '\xA8', '\x8F', ' ', '\xE0', '\xA8', '\x93', ' ', '\xE0', '\xA9', '\xB3', ' ', '\xE0', '\xA8', '\xBF', ' ', '\xE0', '\xA9', '\x80', /* ਇ ਈ ਉ ਏ ਓ ੳ ਿ ੀ */
'\0',
- '\xCE', '\xB1', '\xCE', '\xB5', '\xCE', '\xB9', '\xCE', '\xBF', '\xCF', '\x80', '\xCF', '\x83', '\xCF', '\x84', '\xCF', '\x89', /* αειοπστω */
+ '\xE0', '\xA8', '\x85', ' ', '\xE0', '\xA8', '\x8F', ' ', '\xE0', '\xA8', '\x93', ' ', '\xE0', '\xA8', '\x97', ' ', '\xE0', '\xA8', '\x9C', ' ', '\xE0', '\xA8', '\xA0', ' ', '\xE0', '\xA8', '\xB0', ' ', '\xE0', '\xA8', '\xB8', /* ਅ ਏ ਓ ਗ ਜ ਠ ਰ ਸ */
'\0',
- '\xCE', '\xB2', '\xCE', '\xB3', '\xCE', '\xB7', '\xCE', '\xBC', '\xCF', '\x81', '\xCF', '\x86', '\xCF', '\x87', '\xCF', '\x88', /* βγημρφχψ */
+ '\xE0', '\xA9', '\xA6', ' ', '\xE0', '\xA9', '\xA7', ' ', '\xE0', '\xA9', '\xA8', ' ', '\xE0', '\xA9', '\xA9', ' ', '\xE0', '\xA9', '\xAD', /* ੦ ੧ ੨ ੩ ੭ */
'\0',
- '\xD7', '\x91', '\xD7', '\x93', '\xD7', '\x94', '\xD7', '\x97', '\xD7', '\x9A', '\xD7', '\x9B', '\xD7', '\x9D', '\xD7', '\xA1', /* בדהחךכםס */
+ '\xD7', '\x91', ' ', '\xD7', '\x93', ' ', '\xD7', '\x94', ' ', '\xD7', '\x97', ' ', '\xD7', '\x9A', ' ', '\xD7', '\x9B', ' ', '\xD7', '\x9D', ' ', '\xD7', '\xA1', /* ב ד ה ח ך כ ם ס */
'\0',
- '\xD7', '\x91', '\xD7', '\x98', '\xD7', '\x9B', '\xD7', '\x9D', '\xD7', '\xA1', '\xD7', '\xA6', /* בטכםסצ */
+ '\xD7', '\x91', ' ', '\xD7', '\x98', ' ', '\xD7', '\x9B', ' ', '\xD7', '\x9D', ' ', '\xD7', '\xA1', ' ', '\xD7', '\xA6', /* ב ט כ ם ס צ */
'\0',
- '\xD7', '\xA7', '\xD7', '\x9A', '\xD7', '\x9F', '\xD7', '\xA3', '\xD7', '\xA5', /* קךןףץ */
+ '\xD7', '\xA7', ' ', '\xD7', '\x9A', ' ', '\xD7', '\x9F', ' ', '\xD7', '\xA3', ' ', '\xD7', '\xA5', /* ק ך ן ף ץ */
'\0',
- '\xE0', '\xBA', '\xB2', '\xE0', '\xBA', '\x94', '\xE0', '\xBA', '\xAD', '\xE0', '\xBA', '\xA1', '\xE0', '\xBA', '\xA5', '\xE0', '\xBA', '\xA7', '\xE0', '\xBA', '\xA3', '\xE0', '\xBA', '\x87', /* າ ດ ອ ມ ລ ວ ຣ ງ */
+ '\xE0', '\xB2', '\x87', ' ', '\xE0', '\xB2', '\x8A', ' ', '\xE0', '\xB2', '\x90', ' ', '\xE0', '\xB2', '\xA3', ' ', '\xE0', '\xB2', '\xB8', '\xE0', '\xB2', '\xBE', ' ', '\xE0', '\xB2', '\xA8', '\xE0', '\xB2', '\xBE', ' ', '\xE0', '\xB2', '\xA6', '\xE0', '\xB2', '\xBE', ' ', '\xE0', '\xB2', '\xB0', '\xE0', '\xB2', '\xBE', /* ಇ ಊ ಐ ಣ ಸಾ ನಾ ದಾ ರಾ */
'\0',
- '\xE0', '\xBA', '\xB2', '\xE0', '\xBA', '\xAD', '\xE0', '\xBA', '\x9A', '\xE0', '\xBA', '\x8D', '\xE0', '\xBA', '\xA3', '\xE0', '\xBA', '\xAE', '\xE0', '\xBA', '\xA7', '\xE0', '\xBA', '\xA2', /* າ ອ ບ ຍ ຣ ຮ ວ ຢ */
+ '\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',
- '\xE0', '\xBA', '\x9B', '\xE0', '\xBA', '\xA2', '\xE0', '\xBA', '\x9F', '\xE0', '\xBA', '\x9D', /* ປ ຢ ຟ ຝ */
+ '\xEA', '\xA4', '\x85', ' ', '\xEA', '\xA4', '\x8F', ' ', '\xEA', '\xA4', '\x81', ' ', '\xEA', '\xA4', '\x8B', ' ', '\xEA', '\xA4', '\x80', ' ', '\xEA', '\xA4', '\x8D', /* ꤅ ꤏ ꤁ ꤋ ꤀ ꤍ */
'\0',
- '\xE0', '\xBB', '\x82', '\xE0', '\xBB', '\x84', '\xE0', '\xBB', '\x83', /* ໂ ໄ ໃ */
+ '\xEA', '\xA4', '\x88', ' ', '\xEA', '\xA4', '\x98', ' ', '\xEA', '\xA4', '\x80', ' ', '\xEA', '\xA4', '\x8D', ' ', '\xEA', '\xA4', '\xA2', /* ꤈ ꤘ ꤀ ꤍ ꤢ */
'\0',
- '\xE0', '\xBA', '\x87', '\xE0', '\xBA', '\x8A', '\xE0', '\xBA', '\x96', '\xE0', '\xBA', '\xBD', '\xE0', '\xBB', '\x86', '\xE0', '\xBA', '\xAF', /* ງ ຊ ຖ ຽ ໆ ຯ */
+ '\xEA', '\xA4', '\x96', ' ', '\xEA', '\xA4', '\xA1', /* ꤖ ꤡ */
'\0',
- 'T', 'H', 'E', 'Z', 'O', 'C', 'Q', 'S', /* THEZOCQS */
+ '\xEA', '\xA4', '\x91', ' ', '\xEA', '\xA4', '\x9C', ' ', '\xEA', '\xA4', '\x9E', /* ꤑ ꤜ ꤞ */
'\0',
- 'H', 'E', 'Z', 'L', 'O', 'C', 'U', 'S', /* HEZLOCUS */
+ '\xEA', '\xA4', '\x91', '\xEA', '\xA4', '\xAC', ' ', '\xEA', '\xA4', '\x9C', '\xEA', '\xA4', '\xAD', ' ', '\xEA', '\xA4', '\x94', '\xEA', '\xA4', '\xAC', /* ꤑ꤬ ꤜ꤭ ꤔ꤬ */
'\0',
- 'f', 'i', 'j', 'k', 'd', 'b', 'h', /* fijkdbh */
+ '\xE1', '\x9E', '\x81', ' ', '\xE1', '\x9E', '\x91', ' ', '\xE1', '\x9E', '\x93', ' ', '\xE1', '\x9E', '\xA7', ' ', '\xE1', '\x9E', '\xA9', ' ', '\xE1', '\x9E', '\xB6', /* ខ ទ ន ឧ ឩ ា */
'\0',
- 'x', 'z', 'r', 'o', 'e', 's', 'c', /* xzroesc */
+ '\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', /* ក្ក ក្ខ ក្គ ក្ថ */
'\0',
- 'p', 'q', 'g', 'j', 'y', /* pqgjy */
+ '\xE1', '\x9E', '\x81', ' ', '\xE1', '\x9E', '\x83', ' ', '\xE1', '\x9E', '\x85', ' ', '\xE1', '\x9E', '\x8B', ' ', '\xE1', '\x9E', '\x94', ' ', '\xE1', '\x9E', '\x98', ' ', '\xE1', '\x9E', '\x99', ' ', '\xE1', '\x9E', '\xB2', /* ខ ឃ ច ឋ ប ម យ ឲ */
'\0',
- '\xE2', '\x82', '\x80', '\xE2', '\x82', '\x83', '\xE2', '\x82', '\x85', '\xE2', '\x82', '\x87', '\xE2', '\x82', '\x88', /* ₀₃₅₇₈ */
+ '\xE1', '\x9E', '\x8F', '\xE1', '\x9F', '\x92', '\xE1', '\x9E', '\x9A', ' ', '\xE1', '\x9E', '\x9A', '\xE1', '\x9F', '\x80', ' ', '\xE1', '\x9E', '\xB2', '\xE1', '\x9F', '\x92', '\xE1', '\x9E', '\x99', ' ', '\xE1', '\x9E', '\xA2', '\xE1', '\x9E', '\xBF', /* ត្រ រៀ ឲ្យ អឿ */
'\0',
- '\xE2', '\x82', '\x80', '\xE2', '\x82', '\x81', '\xE2', '\x82', '\x82', '\xE2', '\x82', '\x83', '\xE2', '\x82', '\x88', /* ₀₁₂₃₈ */
+ '\xE1', '\x9E', '\x93', '\xE1', '\x9F', '\x92', '\xE1', '\x9E', '\x8F', '\xE1', '\x9F', '\x92', '\xE1', '\x9E', '\x9A', '\xE1', '\x9F', '\x83', ' ', '\xE1', '\x9E', '\x84', '\xE1', '\x9F', '\x92', '\xE1', '\x9E', '\x81', '\xE1', '\x9F', '\x92', '\xE1', '\x9E', '\x99', ' ', '\xE1', '\x9E', '\x80', '\xE1', '\x9F', '\x92', '\xE1', '\x9E', '\x94', '\xE1', '\x9F', '\x80', ' ', '\xE1', '\x9E', '\x85', '\xE1', '\x9F', '\x92', '\xE1', '\x9E', '\x9A', '\xE1', '\x9F', '\x80', ' ', '\xE1', '\x9E', '\x93', '\xE1', '\x9F', '\x92', '\xE1', '\x9E', '\x8F', '\xE1', '\x9E', '\xBF', ' ', '\xE1', '\x9E', '\x9B', '\xE1', '\x9F', '\x92', '\xE1', '\x9E', '\x94', '\xE1', '\x9E', '\xBF', /* ន្ត្រៃ ង្ខ្យ ក្បៀ ច្រៀ ន្តឿ ល្បឿ */
'\0',
- '\xE1', '\xB5', '\xA2', '\xE2', '\xB1', '\xBC', '\xE2', '\x82', '\x95', '\xE2', '\x82', '\x96', '\xE2', '\x82', '\x97', /* ᵢⱼₕₖₗ */
+ '\xE1', '\xA7', '\xA0', ' ', '\xE1', '\xA7', '\xA1', /* ᧠ ᧡ */
'\0',
- '\xE2', '\x82', '\x90', '\xE2', '\x82', '\x91', '\xE2', '\x82', '\x92', '\xE2', '\x82', '\x93', '\xE2', '\x82', '\x99', '\xE2', '\x82', '\x9B', '\xE1', '\xB5', '\xA5', '\xE1', '\xB5', '\xA4', '\xE1', '\xB5', '\xA3', /* ₐₑₒₓₙₛᵥᵤᵣ */
+ '\xE1', '\xA7', '\xB6', ' ', '\xE1', '\xA7', '\xB9', /* ᧶ ᧹ */
'\0',
- '\xE1', '\xB5', '\xA6', '\xE1', '\xB5', '\xA7', '\xE1', '\xB5', '\xA8', '\xE1', '\xB5', '\xA9', '\xE2', '\x82', '\x9A', /* ᵦᵧᵨᵩₚ */
+ '\xE0', '\xBA', '\xB2', ' ', '\xE0', '\xBA', '\x94', ' ', '\xE0', '\xBA', '\xAD', ' ', '\xE0', '\xBA', '\xA1', ' ', '\xE0', '\xBA', '\xA5', ' ', '\xE0', '\xBA', '\xA7', ' ', '\xE0', '\xBA', '\xA3', ' ', '\xE0', '\xBA', '\x87', /* າ ດ ອ ມ ລ ວ ຣ ງ */
'\0',
- '\xE2', '\x81', '\xB0', '\xC2', '\xB3', '\xE2', '\x81', '\xB5', '\xE2', '\x81', '\xB7', '\xE1', '\xB5', '\x80', '\xE1', '\xB4', '\xB4', '\xE1', '\xB4', '\xB1', '\xE1', '\xB4', '\xBC', /* ⁰³⁵⁷ᵀᴴᴱᴼ */
+ '\xE0', '\xBA', '\xB2', ' ', '\xE0', '\xBA', '\xAD', ' ', '\xE0', '\xBA', '\x9A', ' ', '\xE0', '\xBA', '\x8D', ' ', '\xE0', '\xBA', '\xA3', ' ', '\xE0', '\xBA', '\xAE', ' ', '\xE0', '\xBA', '\xA7', ' ', '\xE0', '\xBA', '\xA2', /* າ ອ ບ ຍ ຣ ຮ ວ ຢ */
'\0',
- '\xE2', '\x81', '\xB0', '\xC2', '\xB9', '\xC2', '\xB2', '\xC2', '\xB3', '\xE1', '\xB4', '\xB1', '\xE1', '\xB4', '\xB8', '\xE1', '\xB4', '\xBC', '\xE1', '\xB5', '\x81', /* ⁰¹²³ᴱᴸᴼᵁ */
+ '\xE0', '\xBA', '\x9B', ' ', '\xE0', '\xBA', '\xA2', ' ', '\xE0', '\xBA', '\x9F', ' ', '\xE0', '\xBA', '\x9D', /* ປ ຢ ຟ ຝ */
'\0',
- '\xE1', '\xB5', '\x87', '\xE1', '\xB5', '\x88', '\xE1', '\xB5', '\x8F', '\xCA', '\xB0', '\xCA', '\xB2', '\xE1', '\xB6', '\xA0', '\xE2', '\x81', '\xB1', /* ᵇᵈᵏʰʲᶠⁱ */
+ '\xE0', '\xBB', '\x82', ' ', '\xE0', '\xBB', '\x84', ' ', '\xE0', '\xBB', '\x83', /* ໂ ໄ ໃ */
'\0',
- '\xE1', '\xB5', '\x89', '\xE1', '\xB5', '\x92', '\xCA', '\xB3', '\xCB', '\xA2', '\xCB', '\xA3', '\xE1', '\xB6', '\x9C', '\xE1', '\xB6', '\xBB', /* ᵉᵒʳˢˣᶜᶻ */
+ '\xE0', '\xBA', '\x87', ' ', '\xE0', '\xBA', '\x8A', ' ', '\xE0', '\xBA', '\x96', ' ', '\xE0', '\xBA', '\xBD', ' ', '\xE0', '\xBB', '\x86', ' ', '\xE0', '\xBA', '\xAF', /* ງ ຊ ຖ ຽ ໆ ຯ */
'\0',
- '\xE1', '\xB5', '\x96', '\xCA', '\xB8', '\xE1', '\xB5', '\x8D', /* ᵖʸᵍ */
+ 'T', ' ', 'H', ' ', 'E', ' ', 'Z', ' ', 'O', ' ', 'C', ' ', 'Q', ' ', 'S', /* T H E Z O C Q S */
'\0',
- '\xE0', '\xB0', '\x87', '\xE0', '\xB0', '\x8C', '\xE0', '\xB0', '\x99', '\xE0', '\xB0', '\x9E', '\xE0', '\xB0', '\xA3', '\xE0', '\xB0', '\xB1', '\xE0', '\xB1', '\xAF', /* ఇ ఌ ఙ ఞ ణ ఱ ౯ */
+ 'H', ' ', 'E', ' ', 'Z', ' ', 'L', ' ', 'O', ' ', 'C', ' ', 'U', ' ', 'S', /* H E Z L O C U S */
'\0',
- '\xE0', '\xB0', '\x85', '\xE0', '\xB0', '\x95', '\xE0', '\xB0', '\x9A', '\xE0', '\xB0', '\xB0', '\xE0', '\xB0', '\xBD', '\xE0', '\xB1', '\xA8', '\xE0', '\xB1', '\xAC', /* అ క చ ర ఽ ౨ ౬ */
+ 'f', ' ', 'i', ' ', 'j', ' ', 'k', ' ', 'd', ' ', 'b', ' ', 'h', /* f i j k d b h */
'\0',
- '\xE0', '\xB8', '\x9A', '\xE0', '\xB9', '\x80', '\xE0', '\xB9', '\x81', '\xE0', '\xB8', '\xAD', '\xE0', '\xB8', '\x81', '\xE0', '\xB8', '\xB2', /* บ เ แ อ ก า */
+ 'u', ' ', 'v', ' ', 'x', ' ', 'z', ' ', 'o', ' ', 'e', ' ', 's', ' ', 'c', /* u v x z o e s c */
'\0',
- '\xE0', '\xB8', '\x9A', '\xE0', '\xB8', '\x9B', '\xE0', '\xB8', '\xA9', '\xE0', '\xB8', '\xAF', '\xE0', '\xB8', '\xAD', '\xE0', '\xB8', '\xA2', '\xE0', '\xB8', '\xAE', /* บ ป ษ ฯ อ ย ฮ */
+ 'n', ' ', 'r', ' ', 'x', ' ', 'z', ' ', 'o', ' ', 'e', ' ', 's', ' ', 'c', /* n r x z o e s c */
'\0',
- '\xE0', '\xB8', '\x9B', '\xE0', '\xB8', '\x9D', '\xE0', '\xB8', '\x9F', /* ป ฝ ฟ */
+ 'p', ' ', 'q', ' ', 'g', ' ', 'j', ' ', 'y', /* p q g j y */
'\0',
- '\xE0', '\xB9', '\x82', '\xE0', '\xB9', '\x83', '\xE0', '\xB9', '\x84', /* โ ใ ไ */
+ '\xE2', '\x82', '\x80', ' ', '\xE2', '\x82', '\x83', ' ', '\xE2', '\x82', '\x85', ' ', '\xE2', '\x82', '\x87', ' ', '\xE2', '\x82', '\x88', /* ₀ ₃ ₅ ₇ ₈ */
'\0',
- '\xE0', '\xB8', '\x8E', '\xE0', '\xB8', '\x8F', '\xE0', '\xB8', '\xA4', '\xE0', '\xB8', '\xA6', /* ฎ ฏ ฤ ฦ */
+ '\xE2', '\x82', '\x80', ' ', '\xE2', '\x82', '\x81', ' ', '\xE2', '\x82', '\x82', ' ', '\xE2', '\x82', '\x83', ' ', '\xE2', '\x82', '\x88', /* ₀ ₁ ₂ ₃ ₈ */
'\0',
- '\xE0', '\xB8', '\x8D', '\xE0', '\xB8', '\x90', /* ญ ฐ */
+ '\xE1', '\xB5', '\xA2', ' ', '\xE2', '\xB1', '\xBC', ' ', '\xE2', '\x82', '\x95', ' ', '\xE2', '\x82', '\x96', ' ', '\xE2', '\x82', '\x97', /* ᵢ ⱼ ₕ ₖ ₗ */
'\0',
- '\xE0', '\xB9', '\x90', '\xE0', '\xB9', '\x91', '\xE0', '\xB9', '\x93', /* ๐ ๑ ๓ */
+ '\xE2', '\x82', '\x90', ' ', '\xE2', '\x82', '\x91', ' ', '\xE2', '\x82', '\x92', ' ', '\xE2', '\x82', '\x93', ' ', '\xE2', '\x82', '\x99', ' ', '\xE2', '\x82', '\x9B', ' ', '\xE1', '\xB5', '\xA5', ' ', '\xE1', '\xB5', '\xA4', ' ', '\xE1', '\xB5', '\xA3', /* ₐ ₑ ₒ ₓ ₙ ₛ ᵥ ᵤ ᵣ */
+ '\0',
+ '\xE1', '\xB5', '\xA6', ' ', '\xE1', '\xB5', '\xA7', ' ', '\xE1', '\xB5', '\xA8', ' ', '\xE1', '\xB5', '\xA9', ' ', '\xE2', '\x82', '\x9A', /* ᵦ ᵧ ᵨ ᵩ ₚ */
+ '\0',
+ '\xE2', '\x81', '\xB0', ' ', '\xC2', '\xB3', ' ', '\xE2', '\x81', '\xB5', ' ', '\xE2', '\x81', '\xB7', ' ', '\xE1', '\xB5', '\x80', ' ', '\xE1', '\xB4', '\xB4', ' ', '\xE1', '\xB4', '\xB1', ' ', '\xE1', '\xB4', '\xBC', /* ⁰ ³ ⁵ ⁷ ᵀ ᴴ ᴱ ᴼ */
+ '\0',
+ '\xE2', '\x81', '\xB0', ' ', '\xC2', '\xB9', ' ', '\xC2', '\xB2', ' ', '\xC2', '\xB3', ' ', '\xE1', '\xB4', '\xB1', ' ', '\xE1', '\xB4', '\xB8', ' ', '\xE1', '\xB4', '\xBC', ' ', '\xE1', '\xB5', '\x81', /* ⁰ ¹ ² ³ ᴱ ᴸ ᴼ ᵁ */
+ '\0',
+ '\xE1', '\xB5', '\x87', ' ', '\xE1', '\xB5', '\x88', ' ', '\xE1', '\xB5', '\x8F', ' ', '\xCA', '\xB0', ' ', '\xCA', '\xB2', ' ', '\xE1', '\xB6', '\xA0', ' ', '\xE2', '\x81', '\xB1', /* ᵇ ᵈ ᵏ ʰ ʲ ᶠ ⁱ */
+ '\0',
+ '\xE1', '\xB5', '\x89', ' ', '\xE1', '\xB5', '\x92', ' ', '\xCA', '\xB3', ' ', '\xCB', '\xA2', ' ', '\xCB', '\xA3', ' ', '\xE1', '\xB6', '\x9C', ' ', '\xE1', '\xB6', '\xBB', /* ᵉ ᵒ ʳ ˢ ˣ ᶜ ᶻ */
+ '\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', /* ട ഠ ധ ശ ഘ ച ഥ ല */
+ '\0',
+ '\xE1', '\x80', '\x81', ' ', '\xE1', '\x80', '\x82', ' ', '\xE1', '\x80', '\x84', ' ', '\xE1', '\x80', '\x92', ' ', '\xE1', '\x80', '\x9D', ' ', '\xE1', '\x81', '\xA5', ' ', '\xE1', '\x81', '\x8A', ' ', '\xE1', '\x81', '\x8B', /* ခ ဂ င ဒ ဝ ၥ ၊ ။ */
+ '\0',
+ '\xE1', '\x80', '\x84', ' ', '\xE1', '\x80', '\x8E', ' ', '\xE1', '\x80', '\x92', ' ', '\xE1', '\x80', '\x95', ' ', '\xE1', '\x80', '\x97', ' ', '\xE1', '\x80', '\x9D', ' ', '\xE1', '\x81', '\x8A', ' ', '\xE1', '\x81', '\x8B', /* င ဎ ဒ ပ ဗ ဝ ၊ ။ */
+ '\0',
+ '\xE1', '\x80', '\xA9', ' ', '\xE1', '\x80', '\xBC', ' ', '\xE1', '\x81', '\x8D', ' ', '\xE1', '\x81', '\x8F', ' ', '\xE1', '\x81', '\x86', ' ', '\xE1', '\x80', '\xAB', ' ', '\xE1', '\x80', '\xAD', /* ဩ ြ ၍ ၏ ၆ ါ ိ */
+ '\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', /* க ச ல ஶ உ ங ட ப */
+ '\0',
+ '\xE0', '\xB0', '\x87', ' ', '\xE0', '\xB0', '\x8C', ' ', '\xE0', '\xB0', '\x99', ' ', '\xE0', '\xB0', '\x9E', ' ', '\xE0', '\xB0', '\xA3', ' ', '\xE0', '\xB0', '\xB1', ' ', '\xE0', '\xB1', '\xAF', /* ఇ ఌ ఙ ఞ ణ ఱ ౯ */
+ '\0',
+ '\xE0', '\xB0', '\x85', ' ', '\xE0', '\xB0', '\x95', ' ', '\xE0', '\xB0', '\x9A', ' ', '\xE0', '\xB0', '\xB0', ' ', '\xE0', '\xB0', '\xBD', ' ', '\xE0', '\xB1', '\xA8', ' ', '\xE0', '\xB1', '\xAC', /* అ క చ ర ఽ ౨ ౬ */
+ '\0',
+ '\xE0', '\xB8', '\x9A', ' ', '\xE0', '\xB9', '\x80', ' ', '\xE0', '\xB9', '\x81', ' ', '\xE0', '\xB8', '\xAD', ' ', '\xE0', '\xB8', '\x81', ' ', '\xE0', '\xB8', '\xB2', /* บ เ แ อ ก า */
+ '\0',
+ '\xE0', '\xB8', '\x9A', ' ', '\xE0', '\xB8', '\x9B', ' ', '\xE0', '\xB8', '\xA9', ' ', '\xE0', '\xB8', '\xAF', ' ', '\xE0', '\xB8', '\xAD', ' ', '\xE0', '\xB8', '\xA2', ' ', '\xE0', '\xB8', '\xAE', /* บ ป ษ ฯ อ ย ฮ */
+ '\0',
+ '\xE0', '\xB8', '\x9B', ' ', '\xE0', '\xB8', '\x9D', ' ', '\xE0', '\xB8', '\x9F', /* ป ฝ ฟ */
+ '\0',
+ '\xE0', '\xB9', '\x82', ' ', '\xE0', '\xB9', '\x83', ' ', '\xE0', '\xB9', '\x84', /* โ ใ ไ */
+ '\0',
+ '\xE0', '\xB8', '\x8E', ' ', '\xE0', '\xB8', '\x8F', ' ', '\xE0', '\xB8', '\xA4', ' ', '\xE0', '\xB8', '\xA6', /* ฎ ฏ ฤ ฦ */
+ '\0',
+ '\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', /* 他们你來們到和地 */
- '\xE5', '\xAF', '\xB9', '\xE5', '\xB0', '\x8D', '\xE5', '\xB0', '\xB1', '\xE5', '\xB8', '\xAD', '\xE6', '\x88', '\x91', '\xE6', '\x97', '\xB6', '\xE6', '\x99', '\x82', '\xE6', '\x9C', '\x83', /* 对對就席我时時會 */
- '\xE6', '\x9D', '\xA5', '\xE7', '\x82', '\xBA', '\xE8', '\x83', '\xBD', '\xE8', '\x88', '\xB0', '\xE8', '\xAA', '\xAA', '\xE8', '\xAF', '\xB4', '\xE8', '\xBF', '\x99', '\xE9', '\x80', '\x99', /* 来為能舰說说这這 */
- '\xE9', '\xBD', '\x8A', '|', /* 齊 | */
- '\xE5', '\x86', '\x9B', '\xE5', '\x90', '\x8C', '\xE5', '\xB7', '\xB2', '\xE6', '\x84', '\xBF', '\xE6', '\x97', '\xA2', '\xE6', '\x98', '\x9F', '\xE6', '\x98', '\xAF', '\xE6', '\x99', '\xAF', /* 军同已愿既星是景 */
- '\xE6', '\xB0', '\x91', '\xE7', '\x85', '\xA7', '\xE7', '\x8E', '\xB0', '\xE7', '\x8F', '\xBE', '\xE7', '\x90', '\x86', '\xE7', '\x94', '\xA8', '\xE7', '\xBD', '\xAE', '\xE8', '\xA6', '\x81', /* 民照现現理用置要 */
- '\xE8', '\xBB', '\x8D', '\xE9', '\x82', '\xA3', '\xE9', '\x85', '\x8D', '\xE9', '\x87', '\x8C', '\xE9', '\x96', '\x8B', '\xE9', '\x9B', '\xB7', '\xE9', '\x9C', '\xB2', '\xE9', '\x9D', '\xA2', /* 軍那配里開雷露面 */
- '\xE9', '\xA1', '\xBE', /* 顾 */
- '\0',
- '\xE4', '\xB8', '\xAA', '\xE4', '\xB8', '\xBA', '\xE4', '\xBA', '\xBA', '\xE4', '\xBB', '\x96', '\xE4', '\xBB', '\xA5', '\xE4', '\xBB', '\xAC', '\xE4', '\xBD', '\xA0', '\xE4', '\xBE', '\x86', /* 个为人他以们你來 */
- '\xE5', '\x80', '\x8B', '\xE5', '\x80', '\x91', '\xE5', '\x88', '\xB0', '\xE5', '\x92', '\x8C', '\xE5', '\xA4', '\xA7', '\xE5', '\xAF', '\xB9', '\xE5', '\xB0', '\x8D', '\xE5', '\xB0', '\xB1', /* 個們到和大对對就 */
- '\xE6', '\x88', '\x91', '\xE6', '\x97', '\xB6', '\xE6', '\x99', '\x82', '\xE6', '\x9C', '\x89', '\xE6', '\x9D', '\xA5', '\xE7', '\x82', '\xBA', '\xE8', '\xA6', '\x81', '\xE8', '\xAA', '\xAA', /* 我时時有来為要說 */
- '\xE8', '\xAF', '\xB4', '|', /* 说 | */
- '\xE4', '\xB8', '\xBB', '\xE4', '\xBA', '\x9B', '\xE5', '\x9B', '\xA0', '\xE5', '\xAE', '\x83', '\xE6', '\x83', '\xB3', '\xE6', '\x84', '\x8F', '\xE7', '\x90', '\x86', '\xE7', '\x94', '\x9F', /* 主些因它想意理生 */
- '\xE7', '\x95', '\xB6', '\xE7', '\x9C', '\x8B', '\xE7', '\x9D', '\x80', '\xE7', '\xBD', '\xAE', '\xE8', '\x80', '\x85', '\xE8', '\x87', '\xAA', '\xE8', '\x91', '\x97', '\xE8', '\xA3', '\xA1', /* 當看着置者自著裡 */
- '\xE8', '\xBF', '\x87', '\xE8', '\xBF', '\x98', '\xE8', '\xBF', '\x9B', '\xE9', '\x80', '\xB2', '\xE9', '\x81', '\x8E', '\xE9', '\x81', '\x93', '\xE9', '\x82', '\x84', '\xE9', '\x87', '\x8C', /* 过还进進過道還里 */
- '\xE9', '\x9D', '\xA2', /* 面 */
+ '\xE4', '\xBB', '\x96', ' ', '\xE4', '\xBB', '\xAC', ' ', '\xE4', '\xBD', '\xA0', ' ', '\xE4', '\xBE', '\x86', ' ', '\xE5', '\x80', '\x91', ' ', '\xE5', '\x88', '\xB0', ' ', '\xE5', '\x92', '\x8C', ' ', '\xE5', '\x9C', '\xB0', /* 他 们 你 來 們 到 和 地 */
+ ' ', '\xE5', '\xAF', '\xB9', ' ', '\xE5', '\xB0', '\x8D', ' ', '\xE5', '\xB0', '\xB1', ' ', '\xE5', '\xB8', '\xAD', ' ', '\xE6', '\x88', '\x91', ' ', '\xE6', '\x97', '\xB6', ' ', '\xE6', '\x99', '\x82', ' ', '\xE6', '\x9C', '\x83', /* 对 對 就 席 我 时 時 會 */
+ ' ', '\xE6', '\x9D', '\xA5', ' ', '\xE7', '\x82', '\xBA', ' ', '\xE8', '\x83', '\xBD', ' ', '\xE8', '\x88', '\xB0', ' ', '\xE8', '\xAA', '\xAA', ' ', '\xE8', '\xAF', '\xB4', ' ', '\xE8', '\xBF', '\x99', ' ', '\xE9', '\x80', '\x99', /* 来 為 能 舰 說 说 这 這 */
+ ' ', '\xE9', '\xBD', '\x8A', ' ', '|', /* 齊 | */
+ ' ', '\xE5', '\x86', '\x9B', ' ', '\xE5', '\x90', '\x8C', ' ', '\xE5', '\xB7', '\xB2', ' ', '\xE6', '\x84', '\xBF', ' ', '\xE6', '\x97', '\xA2', ' ', '\xE6', '\x98', '\x9F', ' ', '\xE6', '\x98', '\xAF', ' ', '\xE6', '\x99', '\xAF', /* 军 同 已 愿 既 星 是 景 */
+ ' ', '\xE6', '\xB0', '\x91', ' ', '\xE7', '\x85', '\xA7', ' ', '\xE7', '\x8E', '\xB0', ' ', '\xE7', '\x8F', '\xBE', ' ', '\xE7', '\x90', '\x86', ' ', '\xE7', '\x94', '\xA8', ' ', '\xE7', '\xBD', '\xAE', ' ', '\xE8', '\xA6', '\x81', /* 民 照 现 現 理 用 置 要 */
+ ' ', '\xE8', '\xBB', '\x8D', ' ', '\xE9', '\x82', '\xA3', ' ', '\xE9', '\x85', '\x8D', ' ', '\xE9', '\x87', '\x8C', ' ', '\xE9', '\x96', '\x8B', ' ', '\xE9', '\x9B', '\xB7', ' ', '\xE9', '\x9C', '\xB2', ' ', '\xE9', '\x9D', '\xA2', /* 軍 那 配 里 開 雷 露 面 */
+ ' ', '\xE9', '\xA1', '\xBE', /* 顾 */
+ '\0',
+ '\xE4', '\xB8', '\xAA', ' ', '\xE4', '\xB8', '\xBA', ' ', '\xE4', '\xBA', '\xBA', ' ', '\xE4', '\xBB', '\x96', ' ', '\xE4', '\xBB', '\xA5', ' ', '\xE4', '\xBB', '\xAC', ' ', '\xE4', '\xBD', '\xA0', ' ', '\xE4', '\xBE', '\x86', /* 个 为 人 他 以 们 你 來 */
+ ' ', '\xE5', '\x80', '\x8B', ' ', '\xE5', '\x80', '\x91', ' ', '\xE5', '\x88', '\xB0', ' ', '\xE5', '\x92', '\x8C', ' ', '\xE5', '\xA4', '\xA7', ' ', '\xE5', '\xAF', '\xB9', ' ', '\xE5', '\xB0', '\x8D', ' ', '\xE5', '\xB0', '\xB1', /* 個 們 到 和 大 对 對 就 */
+ ' ', '\xE6', '\x88', '\x91', ' ', '\xE6', '\x97', '\xB6', ' ', '\xE6', '\x99', '\x82', ' ', '\xE6', '\x9C', '\x89', ' ', '\xE6', '\x9D', '\xA5', ' ', '\xE7', '\x82', '\xBA', ' ', '\xE8', '\xA6', '\x81', ' ', '\xE8', '\xAA', '\xAA', /* 我 时 時 有 来 為 要 說 */
+ ' ', '\xE8', '\xAF', '\xB4', ' ', '|', /* 说 | */
+ ' ', '\xE4', '\xB8', '\xBB', ' ', '\xE4', '\xBA', '\x9B', ' ', '\xE5', '\x9B', '\xA0', ' ', '\xE5', '\xAE', '\x83', ' ', '\xE6', '\x83', '\xB3', ' ', '\xE6', '\x84', '\x8F', ' ', '\xE7', '\x90', '\x86', ' ', '\xE7', '\x94', '\x9F', /* 主 些 因 它 想 意 理 生 */
+ ' ', '\xE7', '\x95', '\xB6', ' ', '\xE7', '\x9C', '\x8B', ' ', '\xE7', '\x9D', '\x80', ' ', '\xE7', '\xBD', '\xAE', ' ', '\xE8', '\x80', '\x85', ' ', '\xE8', '\x87', '\xAA', ' ', '\xE8', '\x91', '\x97', ' ', '\xE8', '\xA3', '\xA1', /* 當 看 着 置 者 自 著 裡 */
+ ' ', '\xE8', '\xBF', '\x87', ' ', '\xE8', '\xBF', '\x98', ' ', '\xE8', '\xBF', '\x9B', ' ', '\xE9', '\x80', '\xB2', ' ', '\xE9', '\x81', '\x8E', ' ', '\xE9', '\x81', '\x93', ' ', '\xE9', '\x82', '\x84', ' ', '\xE9', '\x87', '\x8C', /* 过 还 进 進 過 道 還 里 */
+ ' ', '\xE9', '\x9D', '\xA2', /* 面 */
#ifdef AF_CONFIG_OPTION_CJK_BLUE_HANI_VERT
'\0',
- '\xE4', '\xBA', '\x9B', '\xE4', '\xBB', '\xAC', '\xE4', '\xBD', '\xA0', '\xE4', '\xBE', '\x86', '\xE5', '\x80', '\x91', '\xE5', '\x88', '\xB0', '\xE5', '\x92', '\x8C', '\xE5', '\x9C', '\xB0', /* 些们你來們到和地 */
- '\xE5', '\xA5', '\xB9', '\xE5', '\xB0', '\x86', '\xE5', '\xB0', '\x87', '\xE5', '\xB0', '\xB1', '\xE5', '\xB9', '\xB4', '\xE5', '\xBE', '\x97', '\xE6', '\x83', '\x85', '\xE6', '\x9C', '\x80', /* 她将將就年得情最 */
- '\xE6', '\xA0', '\xB7', '\xE6', '\xA8', '\xA3', '\xE7', '\x90', '\x86', '\xE8', '\x83', '\xBD', '\xE8', '\xAA', '\xAA', '\xE8', '\xAF', '\xB4', '\xE8', '\xBF', '\x99', '\xE9', '\x80', '\x99', /* 样樣理能說说这這 */
- '\xE9', '\x80', '\x9A', '|', /* 通 | */
- '\xE5', '\x8D', '\xB3', '\xE5', '\x90', '\x97', '\xE5', '\x90', '\xA7', '\xE5', '\x90', '\xAC', '\xE5', '\x91', '\xA2', '\xE5', '\x93', '\x81', '\xE5', '\x93', '\x8D', '\xE5', '\x97', '\x8E', /* 即吗吧听呢品响嗎 */
- '\xE5', '\xB8', '\x88', '\xE5', '\xB8', '\xAB', '\xE6', '\x94', '\xB6', '\xE6', '\x96', '\xAD', '\xE6', '\x96', '\xB7', '\xE6', '\x98', '\x8E', '\xE7', '\x9C', '\xBC', '\xE9', '\x96', '\x93', /* 师師收断斷明眼間 */
- '\xE9', '\x97', '\xB4', '\xE9', '\x99', '\x85', '\xE9', '\x99', '\x88', '\xE9', '\x99', '\x90', '\xE9', '\x99', '\xA4', '\xE9', '\x99', '\xB3', '\xE9', '\x9A', '\x8F', '\xE9', '\x9A', '\x9B', /* 间际陈限除陳随際 */
- '\xE9', '\x9A', '\xA8', /* 隨 */
- '\0',
- '\xE4', '\xBA', '\x8B', '\xE5', '\x89', '\x8D', '\xE5', '\xAD', '\xB8', '\xE5', '\xB0', '\x86', '\xE5', '\xB0', '\x87', '\xE6', '\x83', '\x85', '\xE6', '\x83', '\xB3', '\xE6', '\x88', '\x96', /* 事前學将將情想或 */
- '\xE6', '\x94', '\xBF', '\xE6', '\x96', '\xAF', '\xE6', '\x96', '\xB0', '\xE6', '\xA0', '\xB7', '\xE6', '\xA8', '\xA3', '\xE6', '\xB0', '\x91', '\xE6', '\xB2', '\x92', '\xE6', '\xB2', '\xA1', /* 政斯新样樣民沒没 */
- '\xE7', '\x84', '\xB6', '\xE7', '\x89', '\xB9', '\xE7', '\x8E', '\xB0', '\xE7', '\x8F', '\xBE', '\xE7', '\x90', '\x83', '\xE7', '\xAC', '\xAC', '\xE7', '\xB6', '\x93', '\xE8', '\xB0', '\x81', /* 然特现現球第經谁 */
- '\xE8', '\xB5', '\xB7', '|', /* 起 | */
- '\xE4', '\xBE', '\x8B', '\xE5', '\x88', '\xA5', '\xE5', '\x88', '\xAB', '\xE5', '\x88', '\xB6', '\xE5', '\x8A', '\xA8', '\xE5', '\x8B', '\x95', '\xE5', '\x90', '\x97', '\xE5', '\x97', '\x8E', /* 例別别制动動吗嗎 */
- '\xE5', '\xA2', '\x9E', '\xE6', '\x8C', '\x87', '\xE6', '\x98', '\x8E', '\xE6', '\x9C', '\x9D', '\xE6', '\x9C', '\x9F', '\xE6', '\x9E', '\x84', '\xE7', '\x89', '\xA9', '\xE7', '\xA1', '\xAE', /* 增指明朝期构物确 */
- '\xE7', '\xA7', '\x8D', '\xE8', '\xAA', '\xBF', '\xE8', '\xB0', '\x83', '\xE8', '\xB2', '\xBB', '\xE8', '\xB4', '\xB9', '\xE9', '\x82', '\xA3', '\xE9', '\x83', '\xBD', '\xE9', '\x96', '\x93', /* 种調调費费那都間 */
- '\xE9', '\x97', '\xB4', /* 间 */
+ ' ', '\xE4', '\xBA', '\x9B', ' ', '\xE4', '\xBB', '\xAC', ' ', '\xE4', '\xBD', '\xA0', ' ', '\xE4', '\xBE', '\x86', ' ', '\xE5', '\x80', '\x91', ' ', '\xE5', '\x88', '\xB0', ' ', '\xE5', '\x92', '\x8C', ' ', '\xE5', '\x9C', '\xB0', /* 些 们 你 來 們 到 和 地 */
+ ' ', '\xE5', '\xA5', '\xB9', ' ', '\xE5', '\xB0', '\x86', ' ', '\xE5', '\xB0', '\x87', ' ', '\xE5', '\xB0', '\xB1', ' ', '\xE5', '\xB9', '\xB4', ' ', '\xE5', '\xBE', '\x97', ' ', '\xE6', '\x83', '\x85', ' ', '\xE6', '\x9C', '\x80', /* 她 将 將 就 年 得 情 最 */
+ ' ', '\xE6', '\xA0', '\xB7', ' ', '\xE6', '\xA8', '\xA3', ' ', '\xE7', '\x90', '\x86', ' ', '\xE8', '\x83', '\xBD', ' ', '\xE8', '\xAA', '\xAA', ' ', '\xE8', '\xAF', '\xB4', ' ', '\xE8', '\xBF', '\x99', ' ', '\xE9', '\x80', '\x99', /* 样 樣 理 能 說 说 这 這 */
+ ' ', '\xE9', '\x80', '\x9A', ' ', '|', /* 通 | */
+ ' ', '\xE5', '\x8D', '\xB3', ' ', '\xE5', '\x90', '\x97', ' ', '\xE5', '\x90', '\xA7', ' ', '\xE5', '\x90', '\xAC', ' ', '\xE5', '\x91', '\xA2', ' ', '\xE5', '\x93', '\x81', ' ', '\xE5', '\x93', '\x8D', ' ', '\xE5', '\x97', '\x8E', /* 即 吗 吧 听 呢 品 响 嗎 */
+ ' ', '\xE5', '\xB8', '\x88', ' ', '\xE5', '\xB8', '\xAB', ' ', '\xE6', '\x94', '\xB6', ' ', '\xE6', '\x96', '\xAD', ' ', '\xE6', '\x96', '\xB7', ' ', '\xE6', '\x98', '\x8E', ' ', '\xE7', '\x9C', '\xBC', ' ', '\xE9', '\x96', '\x93', /* 师 師 收 断 斷 明 眼 間 */
+ ' ', '\xE9', '\x97', '\xB4', ' ', '\xE9', '\x99', '\x85', ' ', '\xE9', '\x99', '\x88', ' ', '\xE9', '\x99', '\x90', ' ', '\xE9', '\x99', '\xA4', ' ', '\xE9', '\x99', '\xB3', ' ', '\xE9', '\x9A', '\x8F', ' ', '\xE9', '\x9A', '\x9B', /* 间 际 陈 限 除 陳 随 際 */
+ ' ', '\xE9', '\x9A', '\xA8', /* 隨 */
+ '\0',
+ '\xE4', '\xBA', '\x8B', ' ', '\xE5', '\x89', '\x8D', ' ', '\xE5', '\xAD', '\xB8', ' ', '\xE5', '\xB0', '\x86', ' ', '\xE5', '\xB0', '\x87', ' ', '\xE6', '\x83', '\x85', ' ', '\xE6', '\x83', '\xB3', ' ', '\xE6', '\x88', '\x96', /* 事 前 學 将 將 情 想 或 */
+ ' ', '\xE6', '\x94', '\xBF', ' ', '\xE6', '\x96', '\xAF', ' ', '\xE6', '\x96', '\xB0', ' ', '\xE6', '\xA0', '\xB7', ' ', '\xE6', '\xA8', '\xA3', ' ', '\xE6', '\xB0', '\x91', ' ', '\xE6', '\xB2', '\x92', ' ', '\xE6', '\xB2', '\xA1', /* 政 斯 新 样 樣 民 沒 没 */
+ ' ', '\xE7', '\x84', '\xB6', ' ', '\xE7', '\x89', '\xB9', ' ', '\xE7', '\x8E', '\xB0', ' ', '\xE7', '\x8F', '\xBE', ' ', '\xE7', '\x90', '\x83', ' ', '\xE7', '\xAC', '\xAC', ' ', '\xE7', '\xB6', '\x93', ' ', '\xE8', '\xB0', '\x81', /* 然 特 现 現 球 第 經 谁 */
+ ' ', '\xE8', '\xB5', '\xB7', ' ', '|', /* 起 | */
+ ' ', '\xE4', '\xBE', '\x8B', ' ', '\xE5', '\x88', '\xA5', ' ', '\xE5', '\x88', '\xAB', ' ', '\xE5', '\x88', '\xB6', ' ', '\xE5', '\x8A', '\xA8', ' ', '\xE5', '\x8B', '\x95', ' ', '\xE5', '\x90', '\x97', ' ', '\xE5', '\x97', '\x8E', /* 例 別 别 制 动 動 吗 嗎 */
+ ' ', '\xE5', '\xA2', '\x9E', ' ', '\xE6', '\x8C', '\x87', ' ', '\xE6', '\x98', '\x8E', ' ', '\xE6', '\x9C', '\x9D', ' ', '\xE6', '\x9C', '\x9F', ' ', '\xE6', '\x9E', '\x84', ' ', '\xE7', '\x89', '\xA9', ' ', '\xE7', '\xA1', '\xAE', /* 增 指 明 朝 期 构 物 确 */
+ ' ', '\xE7', '\xA7', '\x8D', ' ', '\xE8', '\xAA', '\xBF', ' ', '\xE8', '\xB0', '\x83', ' ', '\xE8', '\xB2', '\xBB', ' ', '\xE8', '\xB4', '\xB9', ' ', '\xE9', '\x82', '\xA3', ' ', '\xE9', '\x83', '\xBD', ' ', '\xE9', '\x96', '\x93', /* 种 調 调 費 费 那 都 間 */
+ ' ', '\xE9', '\x97', '\xB4', /* 间 */
#endif /* AF_CONFIG_OPTION_CJK_BLUE_HANI_VERT */
#endif /* AF_CONFIG_OPTION_CJK */
'\0',
@@ -171,10 +443,77 @@
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 },
{ AF_BLUE_STRING_MAX, 0 },
+ { AF_BLUE_STRING_ARMENIAN_CAPITAL_TOP, AF_BLUE_PROPERTY_LATIN_TOP },
+ { AF_BLUE_STRING_ARMENIAN_CAPITAL_BOTTOM, 0 },
+ { AF_BLUE_STRING_ARMENIAN_SMALL_ASCENDER, AF_BLUE_PROPERTY_LATIN_TOP },
+ { AF_BLUE_STRING_ARMENIAN_SMALL_TOP, AF_BLUE_PROPERTY_LATIN_TOP |
+ AF_BLUE_PROPERTY_LATIN_X_HEIGHT },
+ { 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 |
+ AF_BLUE_PROPERTY_LATIN_NEUTRAL |
+ 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 },
+ { AF_BLUE_STRING_CHEROKEE_SMALL, AF_BLUE_PROPERTY_LATIN_TOP |
+ AF_BLUE_PROPERTY_LATIN_X_HEIGHT },
+ { 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 |
@@ -190,6 +529,40 @@
{ 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 },
+ { AF_BLUE_STRING_GEORGIAN_MKHEDRULI_TOP, AF_BLUE_PROPERTY_LATIN_TOP |
+ AF_BLUE_PROPERTY_LATIN_X_HEIGHT },
+ { AF_BLUE_STRING_GEORGIAN_MKHEDRULI_BOTTOM, 0 },
+ { AF_BLUE_STRING_GEORGIAN_MKHEDRULI_ASCENDER, AF_BLUE_PROPERTY_LATIN_TOP },
+ { AF_BLUE_STRING_GEORGIAN_MKHEDRULI_DESCENDER, 0 },
+ { AF_BLUE_STRING_GEORGIAN_MTAVRULI_TOP, AF_BLUE_PROPERTY_LATIN_TOP },
+ { AF_BLUE_STRING_GEORGIAN_MTAVRULI_BOTTOM, 0 },
+ { AF_BLUE_STRING_MAX, 0 },
+ { AF_BLUE_STRING_GEORGIAN_ASOMTAVRULI_TOP, AF_BLUE_PROPERTY_LATIN_TOP },
+ { AF_BLUE_STRING_GEORGIAN_ASOMTAVRULI_BOTTOM, 0 },
+ { AF_BLUE_STRING_GEORGIAN_NUSKHURI_TOP, AF_BLUE_PROPERTY_LATIN_TOP |
+ AF_BLUE_PROPERTY_LATIN_X_HEIGHT },
+ { AF_BLUE_STRING_GEORGIAN_NUSKHURI_BOTTOM, 0 },
+ { 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 },
@@ -198,24 +571,60 @@
{ AF_BLUE_STRING_GREEK_SMALL, 0 },
{ AF_BLUE_STRING_GREEK_SMALL_DESCENDER, 0 },
{ AF_BLUE_STRING_MAX, 0 },
+ { AF_BLUE_STRING_GUJARATI_TOP, AF_BLUE_PROPERTY_LATIN_TOP |
+ AF_BLUE_PROPERTY_LATIN_X_HEIGHT },
+ { AF_BLUE_STRING_GUJARATI_BOTTOM, 0 },
+ { AF_BLUE_STRING_GUJARATI_ASCENDER, AF_BLUE_PROPERTY_LATIN_TOP },
+ { AF_BLUE_STRING_GUJARATI_DESCENDER, 0 },
+ { AF_BLUE_STRING_GUJARATI_DIGIT_TOP, AF_BLUE_PROPERTY_LATIN_TOP },
+ { AF_BLUE_STRING_MAX, 0 },
+ { AF_BLUE_STRING_GURMUKHI_TOP, AF_BLUE_PROPERTY_LATIN_TOP },
+ { AF_BLUE_STRING_GURMUKHI_HEAD, AF_BLUE_PROPERTY_LATIN_TOP },
+ { AF_BLUE_STRING_GURMUKHI_BASE, AF_BLUE_PROPERTY_LATIN_TOP |
+ AF_BLUE_PROPERTY_LATIN_NEUTRAL |
+ AF_BLUE_PROPERTY_LATIN_X_HEIGHT },
+ { AF_BLUE_STRING_GURMUKHI_BOTTOM, 0 },
+ { AF_BLUE_STRING_GURMUKHI_DIGIT_TOP, AF_BLUE_PROPERTY_LATIN_TOP },
+ { AF_BLUE_STRING_MAX, 0 },
{ AF_BLUE_STRING_HEBREW_TOP, AF_BLUE_PROPERTY_LATIN_TOP |
AF_BLUE_PROPERTY_LATIN_LONG },
{ AF_BLUE_STRING_HEBREW_BOTTOM, 0 },
{ AF_BLUE_STRING_HEBREW_DESCENDER, 0 },
{ AF_BLUE_STRING_MAX, 0 },
- { AF_BLUE_STRING_LAO_TOP, AF_BLUE_PROPERTY_LATIN_TOP |
- AF_BLUE_PROPERTY_LATIN_X_HEIGHT },
- { AF_BLUE_STRING_LAO_BOTTOM, 0 },
- { AF_BLUE_STRING_LAO_ASCENDER, AF_BLUE_PROPERTY_LATIN_TOP },
- { AF_BLUE_STRING_LAO_LARGE_ASCENDER, AF_BLUE_PROPERTY_LATIN_TOP },
- { AF_BLUE_STRING_LAO_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_KHMER_TOP, AF_BLUE_PROPERTY_LATIN_TOP |
+ AF_BLUE_PROPERTY_LATIN_X_HEIGHT },
+ { AF_BLUE_STRING_KHMER_SUBSCRIPT_TOP, AF_BLUE_PROPERTY_LATIN_SUB_TOP },
+ { AF_BLUE_STRING_KHMER_BOTTOM, 0 },
+ { AF_BLUE_STRING_KHMER_DESCENDER, 0 },
+ { AF_BLUE_STRING_KHMER_LARGE_DESCENDER, 0 },
+ { AF_BLUE_STRING_MAX, 0 },
+ { AF_BLUE_STRING_KHMER_SYMBOLS_WAXING_TOP, AF_BLUE_PROPERTY_LATIN_TOP |
+ AF_BLUE_PROPERTY_LATIN_X_HEIGHT },
+ { AF_BLUE_STRING_KHMER_SYMBOLS_WANING_BOTTOM, 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 },
+ { AF_BLUE_STRING_LAO_TOP, AF_BLUE_PROPERTY_LATIN_TOP |
+ AF_BLUE_PROPERTY_LATIN_X_HEIGHT },
+ { AF_BLUE_STRING_LAO_BOTTOM, 0 },
+ { AF_BLUE_STRING_LAO_ASCENDER, AF_BLUE_PROPERTY_LATIN_TOP },
+ { AF_BLUE_STRING_LAO_LARGE_ASCENDER, AF_BLUE_PROPERTY_LATIN_TOP },
+ { AF_BLUE_STRING_LAO_DESCENDER, 0 },
+ { AF_BLUE_STRING_MAX, 0 },
{ AF_BLUE_STRING_LATIN_CAPITAL_TOP, AF_BLUE_PROPERTY_LATIN_TOP },
{ AF_BLUE_STRING_LATIN_CAPITAL_BOTTOM, 0 },
{ AF_BLUE_STRING_LATIN_SMALL_F_TOP, AF_BLUE_PROPERTY_LATIN_TOP },
- { AF_BLUE_STRING_LATIN_SMALL, AF_BLUE_PROPERTY_LATIN_TOP |
+ { AF_BLUE_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 },
@@ -234,9 +643,73 @@
{ 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 },
+ { AF_BLUE_STRING_MYANMAR_TOP, AF_BLUE_PROPERTY_LATIN_TOP |
+ AF_BLUE_PROPERTY_LATIN_X_HEIGHT },
+ { AF_BLUE_STRING_MYANMAR_BOTTOM, 0 },
+ { 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 },
+ { AF_BLUE_STRING_TIFINAGH, AF_BLUE_PROPERTY_LATIN_TOP },
+ { AF_BLUE_STRING_TIFINAGH, 0 },
+ { AF_BLUE_STRING_MAX, 0 },
{ AF_BLUE_STRING_THAI_TOP, AF_BLUE_PROPERTY_LATIN_TOP |
AF_BLUE_PROPERTY_LATIN_X_HEIGHT },
{ AF_BLUE_STRING_THAI_BOTTOM, 0 },
@@ -246,6 +719,9 @@
{ AF_BLUE_STRING_THAI_LARGE_DESCENDER, 0 },
{ AF_BLUE_STRING_THAI_DIGIT_TOP, 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/src/3rdparty/freetype/src/autofit/afblue.cin b/src/3rdparty/freetype/src/autofit/afblue.cin
index b303a4b2b0..4913e2eb6f 100644
--- a/src/3rdparty/freetype/src/autofit/afblue.cin
+++ b/src/3rdparty/freetype/src/autofit/afblue.cin
@@ -4,7 +4,7 @@
/* */
/* Auto-fitter data for blue strings (body). */
/* */
-/* Copyright 2013-2015 by */
+/* Copyright 2013-2018 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
diff --git a/src/3rdparty/freetype/src/autofit/afblue.dat b/src/3rdparty/freetype/src/autofit/afblue.dat
index 1b52378ed3..bc2f0d2754 100644
--- a/src/3rdparty/freetype/src/autofit/afblue.dat
+++ b/src/3rdparty/freetype/src/autofit/afblue.dat
@@ -2,7 +2,7 @@
//
// Auto-fitter data for blue strings.
//
-// Copyright 2013-2015 by
+// Copyright 2013-2018 by
// David Turner, Robert Wilhelm, and Werner Lemberg.
//
// This file is part of the FreeType project, and may only be used,
@@ -20,9 +20,8 @@
// labels separated by whitespace and followed by a colon (everything in a
// single line); the first label gives the name of the enumeration template,
// the second the name of the array template, and the third the name of the
-// `maximum' template, holding the size of the largest array element. The
-// script then fills the corresponding templates (indicated by `@'
-// characters around the name).
+// `maximum' template. The script then fills the corresponding templates
+// (indicated by `@' characters around the name).
//
// A section contains one or more data records. Each data record consists
// of two or more lines. The first line holds the enumeration name, and the
@@ -30,15 +29,20 @@
//
// There are two possible representations for array data.
//
-// - A string of characters in UTF-8 encoding enclosed in double quotes,
-// using C syntax. There can be only one string per line, thus the
-// starting and ending double quote must be the first and last character
-// in the line, respectively, ignoring whitespace before and after the
-// string. Space characters within the string are ignored too. If there
-// are multiple strings (in multiple lines), they are concatenated to a
-// single string. In the output, a string gets represented as a series of
-// singles bytes, followed by a zero byte. The enumeration values simply
-// hold byte offsets to the start of the corresponding strings.
+// - A string of characters or character clusters (for example, representing
+// Aksharas, Devanagari syllables) in UTF-8 encoding enclosed in double
+// quotes, using C syntax, where the elements are separated by spaces.
+// There can be only one string per line, thus the starting and ending
+// double quote must be the first and last character in the line,
+// respectively, ignoring whitespace before and after the string. If
+// there are multiple strings (in multiple lines), they are concatenated
+// to a single string. In the output, a string gets represented as a
+// series of singles bytes, followed by a zero byte. The enumeration
+// values simply hold byte offsets to the start of the corresponding
+// strings.
+//
+// For strings, the `maximum' template holds the maximum number of
+// non-space characters in all strings.
//
// - Data blocks enclosed in balanced braces, which get copied verbatim and
// which can span multiple lines. The opening brace of a block must be
@@ -47,6 +51,9 @@
// character after each block and counts the number of blocks to set the
// enumeration values.
//
+// For data blocks, the `maximum' template holds the maximum number of
+// array elements.
+//
// A section can contain either strings only or data blocks only.
//
// A comment line starts with `//'; it gets removed. A preprocessor
@@ -58,8 +65,8 @@
// values; this essentially means that the maximum values can easily be too
// large. Given that the purpose of those values is to create local
// fixed-size arrays at compile time for further processing of the blue zone
-// data, this isn't a problem. Note the the final zero byte of a string is
-// not counted. Note also that the count holds the number of UTF-8 encoded
+// data, this isn't a problem. Note the final zero byte of a string is not
+// counted. Note also that the count holds the number of UTF-8 encoded
// characters, not bytes.
@@ -67,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
@@ -79,17 +95,113 @@ AF_BLUE_STRING_ENUM AF_BLUE_STRINGS_ARRAY AF_BLUE_STRING_MAX_LEN:
AF_BLUE_STRING_ARABIC_JOIN
"ـ"
+ 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
+ "ই ট ঠ ি ী ৈ ৗ"
+ 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
+ "ꮒ ꮤ ꮶ ꭴ ꭾ ꮗ ꮝ ꮿ"
+ AF_BLUE_STRING_CHEROKEE_SMALL
+ "ꮖ ꭼ ꮓ ꮠ ꮳ ꭶ ꮥ ꮻ"
+ 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
- "БВЕШЗОСЭ"
+ "Б В Е Ш З О С Э"
AF_BLUE_STRING_CYRILLIC_SMALL
- "хпншезос"
+ "х п н ш е з о с"
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
+ "𐐨 𐐪 𐐬 𐐿 𐑃"
- // we separate the letters with spaces to avoid ligatures;
- // this is just for convenience to simplify reading
AF_BLUE_STRING_DEVANAGARI_BASE
"क म अ आ थ ध भ श"
AF_BLUE_STRING_DEVANAGARI_TOP
@@ -102,23 +214,124 @@ AF_BLUE_STRING_ENUM AF_BLUE_STRINGS_ARRAY AF_BLUE_STRING_MAX_LEN:
AF_BLUE_STRING_DEVANAGARI_BOTTOM
"ु ृ"
+ AF_BLUE_STRING_ETHIOPIC_TOP
+ "ሀ ሃ ዘ ፐ ማ በ ዋ ዐ"
+ AF_BLUE_STRING_ETHIOPIC_BOTTOM
+ "ለ ሐ በ ዘ ሀ ሪ ዐ ጨ"
+
+ AF_BLUE_STRING_GEORGIAN_MKHEDRULI_TOP
+ "გ დ ე ვ თ ი ო ღ"
+ AF_BLUE_STRING_GEORGIAN_MKHEDRULI_BOTTOM
+ "ა ზ მ ს შ ძ ხ პ"
+ AF_BLUE_STRING_GEORGIAN_MKHEDRULI_ASCENDER
+ "ს ხ ქ ზ მ შ ჩ წ"
+ AF_BLUE_STRING_GEORGIAN_MKHEDRULI_DESCENDER
+ "ე ვ ჟ ტ უ ფ ქ ყ"
+
+ AF_BLUE_STRING_GEORGIAN_ASOMTAVRULI_TOP
+ "Ⴑ Ⴇ Ⴙ Ⴜ Ⴄ Ⴅ Ⴓ Ⴚ"
+ AF_BLUE_STRING_GEORGIAN_ASOMTAVRULI_BOTTOM
+ "Ⴄ Ⴅ Ⴇ Ⴈ Ⴆ Ⴑ Ⴊ Ⴋ"
+
+ AF_BLUE_STRING_GEORGIAN_NUSKHURI_TOP
+ "ⴁ ⴗ ⴂ ⴄ ⴅ ⴇ ⴔ ⴖ"
+ AF_BLUE_STRING_GEORGIAN_NUSKHURI_BOTTOM
+ "ⴈ ⴌ ⴖ ⴎ ⴃ ⴆ ⴋ ⴢ"
+ AF_BLUE_STRING_GEORGIAN_NUSKHURI_ASCENDER
+ "ⴐ ⴑ ⴓ ⴕ ⴙ ⴛ ⴡ ⴣ"
+ AF_BLUE_STRING_GEORGIAN_NUSKHURI_DESCENDER
+ "ⴄ ⴅ ⴔ ⴕ ⴁ ⴂ ⴘ ⴝ"
+
+ AF_BLUE_STRING_GEORGIAN_MTAVRULI_TOP
+ "Ნ Ჟ Ჳ Ჸ Გ Ე Ო Ჴ"
+ AF_BLUE_STRING_GEORGIAN_MTAVRULI_BOTTOM
+ "Ი Ჲ Ო Ჩ Მ Შ Ჯ Ჽ"
+
+ 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
- "ΒΔΖΞΘΟ"
+ "Β Δ Ζ Ξ Θ Ο"
AF_BLUE_STRING_GREEK_SMALL_BETA_TOP
- "βθδζλξ"
+ "β θ δ ζ λ ξ"
AF_BLUE_STRING_GREEK_SMALL
- "αειοπστω"
+ "α ε ι ο π σ τ ω"
AF_BLUE_STRING_GREEK_SMALL_DESCENDER
- "βγημρφχψ"
+ "β γ η μ ρ φ χ ψ"
+
+ AF_BLUE_STRING_GUJARATI_TOP
+ "ત ન ઋ ઌ છ ટ ર ૦"
+ AF_BLUE_STRING_GUJARATI_BOTTOM
+ "ખ ગ ઘ ઞ ઇ ઈ ઠ જ"
+ AF_BLUE_STRING_GUJARATI_ASCENDER
+ "ઈ ઊ િ ી લી શ્ચિ જિ સી"
+ AF_BLUE_STRING_GUJARATI_DESCENDER
+ "ુ ૃ ૄ ખુ છૃ છૄ"
+ AF_BLUE_STRING_GUJARATI_DIGIT_TOP
+ "૦ ૧ ૨ ૩ ૭"
+
+ AF_BLUE_STRING_GURMUKHI_BASE
+ "ਕ ਗ ਙ ਚ ਜ ਤ ਧ ਸ"
+ AF_BLUE_STRING_GURMUKHI_HEAD
+ "ਕ ਗ ਙ ਚ ਜ ਤ ਧ ਸ"
+ AF_BLUE_STRING_GURMUKHI_TOP
+ "ਇ ਈ ਉ ਏ ਓ ੳ ਿ ੀ"
+ AF_BLUE_STRING_GURMUKHI_BOTTOM
+ "ਅ ਏ ਓ ਗ ਜ ਠ ਰ ਸ"
+ AF_BLUE_STRING_GURMUKHI_DIGIT_TOP
+ "੦ ੧ ੨ ੩ ੭"
AF_BLUE_STRING_HEBREW_TOP
- "בדהחךכםס"
+ "ב ד ה ח ך כ ם ס"
AF_BLUE_STRING_HEBREW_BOTTOM
- "בטכםסצ"
+ "ב ט כ ם ס צ"
AF_BLUE_STRING_HEBREW_DESCENDER
- "קךןףץ"
+ "ק ך ן ף ץ"
+
+ AF_BLUE_STRING_KANNADA_TOP
+ "ಇ ಊ ಐ ಣ ಸಾ ನಾ ದಾ ರಾ"
+ 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
+ "ក្ក ក្ខ ក្គ ក្ថ"
+ AF_BLUE_STRING_KHMER_BOTTOM
+ "ខ ឃ ច ឋ ប ម យ ឲ"
+ AF_BLUE_STRING_KHMER_DESCENDER
+ "ត្រ រៀ ឲ្យ អឿ"
+ AF_BLUE_STRING_KHMER_LARGE_DESCENDER
+ "ន្ត្រៃ ង្ខ្យ ក្បៀ ច្រៀ ន្តឿ ល្បឿ"
+
+ AF_BLUE_STRING_KHMER_SYMBOLS_WAXING_TOP
+ "᧠ ᧡"
+ AF_BLUE_STRING_KHMER_SYMBOLS_WANING_BOTTOM
+ "᧶ ᧹"
AF_BLUE_STRING_LAO_TOP
"າ ດ ອ ມ ລ ວ ຣ ງ"
@@ -132,43 +345,139 @@ AF_BLUE_STRING_ENUM AF_BLUE_STRINGS_ARRAY AF_BLUE_STRING_MAX_LEN:
"ງ ຊ ຖ ຽ ໆ ຯ"
AF_BLUE_STRING_LATIN_CAPITAL_TOP
- "THEZOCQS"
+ "T H E Z O C Q S"
AF_BLUE_STRING_LATIN_CAPITAL_BOTTOM
- "HEZLOCUS"
+ "H E Z L O C U S"
AF_BLUE_STRING_LATIN_SMALL_F_TOP
- "fijkdbh"
- AF_BLUE_STRING_LATIN_SMALL
- "xzroesc"
+ "f i j k d b h"
+ 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
- "pqgjy"
+ "p q g j y"
// we assume that both the subscript and superscript ranges
// don't contain oldstyle digits (actually, most fonts probably
// have digits only in those ranges)
AF_BLUE_STRING_LATIN_SUBS_CAPITAL_TOP
- "₀₃₅₇₈"
+ "₀ ₃ ₅ ₇ ₈"
AF_BLUE_STRING_LATIN_SUBS_CAPITAL_BOTTOM
- "₀₁₂₃₈"
+ "₀ ₁ ₂ ₃ ₈"
AF_BLUE_STRING_LATIN_SUBS_SMALL_F_TOP
- "ᵢⱼₕₖₗ"
+ "ᵢ ⱼ ₕ ₖ ₗ"
AF_BLUE_STRING_LATIN_SUBS_SMALL
- "ₐₑₒₓₙₛᵥᵤᵣ"
+ "ₐ ₑ ₒ ₓ ₙ ₛ ᵥ ᵤ ᵣ"
AF_BLUE_STRING_LATIN_SUBS_SMALL_DESCENDER
- "ᵦᵧᵨᵩₚ"
+ "ᵦ ᵧ ᵨ ᵩ ₚ"
AF_BLUE_STRING_LATIN_SUPS_CAPITAL_TOP
- "⁰³⁵⁷ᵀᴴᴱᴼ"
+ "⁰ ³ ⁵ ⁷ ᵀ ᴴ ᴱ ᴼ"
AF_BLUE_STRING_LATIN_SUPS_CAPITAL_BOTTOM
- "⁰¹²³ᴱᴸᴼᵁ"
+ "⁰ ¹ ² ³ ᴱ ᴸ ᴼ ᵁ"
AF_BLUE_STRING_LATIN_SUPS_SMALL_F_TOP
- "ᵇᵈᵏʰʲᶠⁱ"
+ "ᵇ ᵈ ᵏ ʰ ʲ ᶠ ⁱ"
AF_BLUE_STRING_LATIN_SUPS_SMALL
- "ᵉᵒʳˢˣᶜᶻ"
+ "ᵉ ᵒ ʳ ˢ ˣ ᶜ ᶻ"
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
+ "ട ഠ ധ ശ ഘ ച ഥ ല"
+
+ AF_BLUE_STRING_MYANMAR_TOP
+ "ခ ဂ င ဒ ဝ ၥ ၊ ။"
+ AF_BLUE_STRING_MYANMAR_BOTTOM
+ "င ဎ ဒ ပ ဗ ဝ ၊ ။"
+ AF_BLUE_STRING_MYANMAR_ASCENDER
+ "ဩ ြ ၍ ၏ ၆ ါ ိ"
+ 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
+ "එ ඔ ඝ ජ ට ථ ධ ර"
+ 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
+ "க ச ல ஶ உ ங ட ப"
- // we separate the letters with spaces to avoid ligatures;
- // this is just for convenience to simplify reading
AF_BLUE_STRING_TELUGU_TOP
"ఇ ఌ ఙ ఞ ణ ఱ ౯"
AF_BLUE_STRING_TELUGU_BOTTOM
@@ -189,48 +498,56 @@ 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
AF_BLUE_STRING_CJK_TOP
- "他们你來們到和地"
- "对對就席我时時會"
- "来為能舰說说这這"
- "齊 |"
- "军同已愿既星是景"
- "民照现現理用置要"
- "軍那配里開雷露面"
- "顾"
+ "他 们 你 來 們 到 和 地"
+ " 对 對 就 席 我 时 時 會"
+ " 来 為 能 舰 說 说 这 這"
+ " 齊 |"
+ " 军 同 已 愿 既 星 是 景"
+ " 民 照 现 現 理 用 置 要"
+ " 軍 那 配 里 開 雷 露 面"
+ " 顾"
AF_BLUE_STRING_CJK_BOTTOM
- "个为人他以们你來"
- "個們到和大对對就"
- "我时時有来為要說"
- "说 |"
- "主些因它想意理生"
- "當看着置者自著裡"
- "过还进進過道還里"
- "面"
+ "个 为 人 他 以 们 你 來"
+ " 個 們 到 和 大 对 對 就"
+ " 我 时 時 有 来 為 要 說"
+ " 说 |"
+ " 主 些 因 它 想 意 理 生"
+ " 當 看 着 置 者 自 著 裡"
+ " 过 还 进 進 過 道 還 里"
+ " 面"
#ifdef AF_CONFIG_OPTION_CJK_BLUE_HANI_VERT
AF_BLUE_STRING_CJK_LEFT
- "些们你來們到和地"
- "她将將就年得情最"
- "样樣理能說说这這"
- "通 |"
- "即吗吧听呢品响嗎"
- "师師收断斷明眼間"
- "间际陈限除陳随際"
- "隨"
+ " 些 们 你 來 們 到 和 地"
+ " 她 将 將 就 年 得 情 最"
+ " 样 樣 理 能 說 说 这 這"
+ " 通 |"
+ " 即 吗 吧 听 呢 品 响 嗎"
+ " 师 師 收 断 斷 明 眼 間"
+ " 间 际 陈 限 除 陳 随 際"
+ " 隨"
AF_BLUE_STRING_CJK_RIGHT
- "事前學将將情想或"
- "政斯新样樣民沒没"
- "然特现現球第經谁"
- "起 |"
- "例別别制动動吗嗎"
- "增指明朝期构物确"
- "种調调費费那都間"
- "间"
+ "事 前 學 将 將 情 想 或"
+ " 政 斯 新 样 樣 民 沒 没"
+ " 然 特 现 現 球 第 經 谁"
+ " 起 |"
+ " 例 別 别 制 动 動 吗 嗎"
+ " 增 指 明 朝 期 构 物 确"
+ " 种 調 调 費 费 那 都 間"
+ " 间"
#endif /* AF_CONFIG_OPTION_CJK_BLUE_HANI_VERT */
@@ -262,6 +579,14 @@ AF_BLUE_STRING_ENUM AF_BLUE_STRINGS_ARRAY AF_BLUE_STRING_MAX_LEN:
// respectively. Only horizontal blue zones (i.e., adjusting vertical
// coordinate values) are supported.
//
+// Some scripts like Khmer need character composition to get all necessary
+// blue zones, since Unicode only provides an abstract data model that
+// doesn't represent all possible glyph shapes. For such character
+// clusters, the HarfBuzz library is used to convert them into the
+// corresponding glyphs. The largest glyph element (where `largest' can be
+// either `largest ascender' or `largest descender') then defines the
+// corresponding flat or round extremum.
+//
// For the latin auto-hinter, the overshoot should be larger than the
// reference for top zones, and vice versa for bottom zones.
//
@@ -272,6 +597,21 @@ AF_BLUE_STRING_ENUM AF_BLUE_STRINGS_ARRAY AF_BLUE_STRING_MAX_LEN:
//
// If not set, take the minimum values.
//
+// Mutually exclusive with `LATIN_SUB_TOP'.
+//
+// LATIN_SUB_TOP
+// For all glyphs of a character cluster, compute the maximum flat
+// and round coordinate values of each component, then take the
+// smallest of the maximum values. The idea is to get the top of
+// subscript glyphs, as used in Khmer, for example. Note that
+// this mechanism doesn't work for ordinary ligatures.
+//
+// This flags indicates a secondary blue zone: It gets removed if
+// there is a non-LATIN_SUB_TOP blue zone at the same coordinate
+// value (after scaling).
+//
+// Mutually exclusive with `LATIN_TOP'.
+//
// LATIN_NEUTRAL
// Ignore round extrema and define the blue zone with flat values only.
// Both top and bottom of contours can match. This is useful for
@@ -307,11 +647,11 @@ AF_BLUE_STRING_ENUM AF_BLUE_STRINGS_ARRAY AF_BLUE_STRING_MAX_LEN:
//
// Characters in a blue string are *not* automatically classified. Instead,
// first come the characters used for the overshoot value, then the
-// character `|', then the characters used for the reference value. The
-// blue zone is then set up by the mean values of all reference values and
-// all overshoot values, respectively. Both horizontal and vertical blue
-// zones (i.e., adjusting vertical and horizontal coordinate values,
-// respectively) are supported.
+// character `|', then the characters used for the reference value
+// (everything separated by space characters). The blue zone is then set up
+// by the mean values of all reference values and all overshoot values,
+// respectively. Both horizontal and vertical blue zones (i.e., adjusting
+// vertical and horizontal coordinate values, respectively) are supported.
//
// For the cjk auto-hinter, the overshoot should be smaller than the
// reference for top zones, and vice versa for bottom zones.
@@ -331,12 +671,103 @@ 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 }
{ AF_BLUE_STRING_ARABIC_JOIN, AF_BLUE_PROPERTY_LATIN_NEUTRAL }
{ AF_BLUE_STRING_MAX, 0 }
+ AF_BLUE_STRINGSET_ARMN
+ { AF_BLUE_STRING_ARMENIAN_CAPITAL_TOP, AF_BLUE_PROPERTY_LATIN_TOP }
+ { AF_BLUE_STRING_ARMENIAN_CAPITAL_BOTTOM, 0 }
+ { AF_BLUE_STRING_ARMENIAN_SMALL_ASCENDER, AF_BLUE_PROPERTY_LATIN_TOP }
+ { AF_BLUE_STRING_ARMENIAN_SMALL_TOP, AF_BLUE_PROPERTY_LATIN_TOP |
+ AF_BLUE_PROPERTY_LATIN_X_HEIGHT }
+ { AF_BLUE_STRING_ARMENIAN_SMALL_BOTTOM, 0 }
+ { 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 }
+ { AF_BLUE_STRING_BENGALI_BASE, AF_BLUE_PROPERTY_LATIN_TOP |
+ AF_BLUE_PROPERTY_LATIN_NEUTRAL |
+ AF_BLUE_PROPERTY_LATIN_X_HEIGHT }
+ { 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 }
+ { AF_BLUE_STRING_CHEROKEE_SMALL_ASCENDER, AF_BLUE_PROPERTY_LATIN_TOP }
+ { AF_BLUE_STRING_CHEROKEE_SMALL, AF_BLUE_PROPERTY_LATIN_TOP |
+ AF_BLUE_PROPERTY_LATIN_X_HEIGHT }
+ { AF_BLUE_STRING_CHEROKEE_SMALL, 0 }
+ { 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 }
@@ -356,6 +787,52 @@ 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 }
+ { AF_BLUE_STRING_MAX, 0 }
+
+ AF_BLUE_STRINGSET_GEOR
+ { AF_BLUE_STRING_GEORGIAN_MKHEDRULI_TOP, AF_BLUE_PROPERTY_LATIN_TOP |
+ AF_BLUE_PROPERTY_LATIN_X_HEIGHT }
+ { AF_BLUE_STRING_GEORGIAN_MKHEDRULI_BOTTOM, 0 }
+ { AF_BLUE_STRING_GEORGIAN_MKHEDRULI_ASCENDER, AF_BLUE_PROPERTY_LATIN_TOP }
+ { AF_BLUE_STRING_GEORGIAN_MKHEDRULI_DESCENDER, 0 }
+ { AF_BLUE_STRING_GEORGIAN_MTAVRULI_TOP, AF_BLUE_PROPERTY_LATIN_TOP }
+ { AF_BLUE_STRING_GEORGIAN_MTAVRULI_BOTTOM, 0 }
+ { AF_BLUE_STRING_MAX, 0 }
+
+ AF_BLUE_STRINGSET_GEOK
+ { AF_BLUE_STRING_GEORGIAN_ASOMTAVRULI_TOP, AF_BLUE_PROPERTY_LATIN_TOP }
+ { AF_BLUE_STRING_GEORGIAN_ASOMTAVRULI_BOTTOM, 0 }
+ { AF_BLUE_STRING_GEORGIAN_NUSKHURI_TOP, AF_BLUE_PROPERTY_LATIN_TOP |
+ AF_BLUE_PROPERTY_LATIN_X_HEIGHT }
+ { AF_BLUE_STRING_GEORGIAN_NUSKHURI_BOTTOM, 0 }
+ { 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_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 }
@@ -366,6 +843,25 @@ AF_BLUE_STRINGSET_ENUM AF_BLUE_STRINGSETS_ARRAY AF_BLUE_STRINGSET_MAX_LEN:
{ AF_BLUE_STRING_GREEK_SMALL_DESCENDER, 0 }
{ AF_BLUE_STRING_MAX, 0 }
+ AF_BLUE_STRINGSET_GUJR
+ { AF_BLUE_STRING_GUJARATI_TOP, AF_BLUE_PROPERTY_LATIN_TOP |
+ AF_BLUE_PROPERTY_LATIN_X_HEIGHT }
+ { AF_BLUE_STRING_GUJARATI_BOTTOM, 0 }
+ { AF_BLUE_STRING_GUJARATI_ASCENDER, AF_BLUE_PROPERTY_LATIN_TOP }
+ { AF_BLUE_STRING_GUJARATI_DESCENDER, 0 }
+ { AF_BLUE_STRING_GUJARATI_DIGIT_TOP, AF_BLUE_PROPERTY_LATIN_TOP }
+ { AF_BLUE_STRING_MAX, 0 }
+
+ AF_BLUE_STRINGSET_GURU
+ { AF_BLUE_STRING_GURMUKHI_TOP, AF_BLUE_PROPERTY_LATIN_TOP }
+ { AF_BLUE_STRING_GURMUKHI_HEAD, AF_BLUE_PROPERTY_LATIN_TOP }
+ { AF_BLUE_STRING_GURMUKHI_BASE, AF_BLUE_PROPERTY_LATIN_TOP |
+ AF_BLUE_PROPERTY_LATIN_NEUTRAL |
+ AF_BLUE_PROPERTY_LATIN_X_HEIGHT }
+ { AF_BLUE_STRING_GURMUKHI_BOTTOM, 0 }
+ { AF_BLUE_STRING_GURMUKHI_DIGIT_TOP, AF_BLUE_PROPERTY_LATIN_TOP }
+ { AF_BLUE_STRING_MAX, 0 }
+
AF_BLUE_STRINGSET_HEBR
{ AF_BLUE_STRING_HEBREW_TOP, AF_BLUE_PROPERTY_LATIN_TOP |
AF_BLUE_PROPERTY_LATIN_LONG }
@@ -373,22 +869,51 @@ 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_KHMR
+ { AF_BLUE_STRING_KHMER_TOP, AF_BLUE_PROPERTY_LATIN_TOP |
+ AF_BLUE_PROPERTY_LATIN_X_HEIGHT }
+ { AF_BLUE_STRING_KHMER_SUBSCRIPT_TOP, AF_BLUE_PROPERTY_LATIN_SUB_TOP }
+ { AF_BLUE_STRING_KHMER_BOTTOM, 0 }
+ { AF_BLUE_STRING_KHMER_DESCENDER, 0 }
+ { AF_BLUE_STRING_KHMER_LARGE_DESCENDER, 0 }
+ { AF_BLUE_STRING_MAX, 0 }
+
+ AF_BLUE_STRINGSET_KHMS
+ { AF_BLUE_STRING_KHMER_SYMBOLS_WAXING_TOP, AF_BLUE_PROPERTY_LATIN_TOP |
+ AF_BLUE_PROPERTY_LATIN_X_HEIGHT }
+ { AF_BLUE_STRING_KHMER_SYMBOLS_WANING_BOTTOM, 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 }
+ { AF_BLUE_STRING_MAX, 0 }
+
AF_BLUE_STRINGSET_LAO
- { AF_BLUE_STRING_LAO_TOP, AF_BLUE_PROPERTY_LATIN_TOP |
- AF_BLUE_PROPERTY_LATIN_X_HEIGHT }
- { AF_BLUE_STRING_LAO_BOTTOM, 0 }
- { AF_BLUE_STRING_LAO_ASCENDER, AF_BLUE_PROPERTY_LATIN_TOP }
- { AF_BLUE_STRING_LAO_LARGE_ASCENDER, AF_BLUE_PROPERTY_LATIN_TOP }
- { AF_BLUE_STRING_LAO_DESCENDER, 0 }
- { AF_BLUE_STRING_MAX, 0 }
+ { AF_BLUE_STRING_LAO_TOP, AF_BLUE_PROPERTY_LATIN_TOP |
+ AF_BLUE_PROPERTY_LATIN_X_HEIGHT }
+ { AF_BLUE_STRING_LAO_BOTTOM, 0 }
+ { AF_BLUE_STRING_LAO_ASCENDER, AF_BLUE_PROPERTY_LATIN_TOP }
+ { AF_BLUE_STRING_LAO_LARGE_ASCENDER, AF_BLUE_PROPERTY_LATIN_TOP }
+ { AF_BLUE_STRING_LAO_DESCENDER, 0 }
+ { AF_BLUE_STRING_MAX, 0 }
AF_BLUE_STRINGSET_LATN
{ AF_BLUE_STRING_LATIN_CAPITAL_TOP, AF_BLUE_PROPERTY_LATIN_TOP }
{ AF_BLUE_STRING_LATIN_CAPITAL_BOTTOM, 0 }
{ AF_BLUE_STRING_LATIN_SMALL_F_TOP, AF_BLUE_PROPERTY_LATIN_TOP }
- { AF_BLUE_STRING_LATIN_SMALL, AF_BLUE_PROPERTY_LATIN_TOP |
+ { AF_BLUE_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 }
@@ -412,11 +937,107 @@ 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 }
+ { AF_BLUE_STRING_MAX, 0 }
+
+ AF_BLUE_STRINGSET_MYMR
+ { AF_BLUE_STRING_MYANMAR_TOP, AF_BLUE_PROPERTY_LATIN_TOP |
+ AF_BLUE_PROPERTY_LATIN_X_HEIGHT }
+ { AF_BLUE_STRING_MYANMAR_BOTTOM, 0 }
+ { AF_BLUE_STRING_MYANMAR_ASCENDER, AF_BLUE_PROPERTY_LATIN_TOP }
+ { 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 }
{ 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_THAI
{ AF_BLUE_STRING_THAI_TOP, AF_BLUE_PROPERTY_LATIN_TOP |
AF_BLUE_PROPERTY_LATIN_X_HEIGHT }
@@ -428,6 +1049,10 @@ 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_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/src/3rdparty/freetype/src/autofit/afblue.h b/src/3rdparty/freetype/src/autofit/afblue.h
index c26a9c792b..de31e259c3 100644
--- a/src/3rdparty/freetype/src/autofit/afblue.h
+++ b/src/3rdparty/freetype/src/autofit/afblue.h
@@ -7,7 +7,7 @@
/* */
/* Auto-fitter data for blue strings (specification). */
/* */
-/* Copyright 2013-2015 by */
+/* Copyright 2013-2018 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -19,8 +19,8 @@
/***************************************************************************/
-#ifndef __AFBLUE_H__
-#define __AFBLUE_H__
+#ifndef AFBLUE_H_
+#define AFBLUE_H_
FT_BEGIN_HEADER
@@ -28,32 +28,35 @@ FT_BEGIN_HEADER
/* an auxiliary macro to decode a UTF-8 character -- since we only use */
/* hard-coded, self-converted data, no error checking is performed */
-#define GET_UTF8_CHAR( ch, p ) \
- ch = (unsigned char)*p++; \
- if ( ch >= 0x80 ) \
- { \
- FT_UInt len; \
- \
- \
- if ( ch < 0xE0 ) \
- { \
- len = 1; \
- ch &= 0x1F; \
- } \
- else if ( ch < 0xF0 ) \
- { \
- len = 2; \
- ch &= 0x0F; \
- } \
- else \
- { \
- len = 3; \
- ch &= 0x07; \
- } \
- \
- for ( ; len > 0; len-- ) \
- ch = ( ch << 6 ) | ( *p++ & 0x3F ); \
- }
+#define GET_UTF8_CHAR( ch, p ) \
+ do \
+ { \
+ ch = (unsigned char)*p++; \
+ if ( ch >= 0x80 ) \
+ { \
+ FT_UInt len_; \
+ \
+ \
+ if ( ch < 0xE0 ) \
+ { \
+ len_ = 1; \
+ ch &= 0x1F; \
+ } \
+ else if ( ch < 0xF0 ) \
+ { \
+ len_ = 2; \
+ ch &= 0x0F; \
+ } \
+ else \
+ { \
+ len_ = 3; \
+ ch &= 0x07; \
+ } \
+ \
+ for ( ; len_ > 0; len_-- ) \
+ ch = ( ch << 6 ) | ( *p++ & 0x3F ); \
+ } \
+ } while ( 0 )
/*************************************************************************/
@@ -74,63 +77,199 @@ FT_BEGIN_HEADER
typedef enum AF_Blue_String_
{
- AF_BLUE_STRING_ARABIC_TOP = 0,
- AF_BLUE_STRING_ARABIC_BOTTOM = 13,
- AF_BLUE_STRING_ARABIC_JOIN = 24,
- AF_BLUE_STRING_CYRILLIC_CAPITAL_TOP = 27,
- AF_BLUE_STRING_CYRILLIC_CAPITAL_BOTTOM = 44,
- AF_BLUE_STRING_CYRILLIC_SMALL = 61,
- AF_BLUE_STRING_CYRILLIC_SMALL_DESCENDER = 78,
- AF_BLUE_STRING_DEVANAGARI_BASE = 85,
- AF_BLUE_STRING_DEVANAGARI_TOP = 110,
- AF_BLUE_STRING_DEVANAGARI_HEAD = 135,
- AF_BLUE_STRING_DEVANAGARI_BOTTOM = 160,
- AF_BLUE_STRING_GREEK_CAPITAL_TOP = 167,
- AF_BLUE_STRING_GREEK_CAPITAL_BOTTOM = 182,
- AF_BLUE_STRING_GREEK_SMALL_BETA_TOP = 195,
- AF_BLUE_STRING_GREEK_SMALL = 208,
- AF_BLUE_STRING_GREEK_SMALL_DESCENDER = 225,
- AF_BLUE_STRING_HEBREW_TOP = 242,
- AF_BLUE_STRING_HEBREW_BOTTOM = 259,
- AF_BLUE_STRING_HEBREW_DESCENDER = 272,
- AF_BLUE_STRING_LAO_TOP = 283,
- AF_BLUE_STRING_LAO_BOTTOM = 308,
- AF_BLUE_STRING_LAO_ASCENDER = 333,
- AF_BLUE_STRING_LAO_LARGE_ASCENDER = 346,
- AF_BLUE_STRING_LAO_DESCENDER = 356,
- AF_BLUE_STRING_LATIN_CAPITAL_TOP = 375,
- AF_BLUE_STRING_LATIN_CAPITAL_BOTTOM = 384,
- AF_BLUE_STRING_LATIN_SMALL_F_TOP = 393,
- AF_BLUE_STRING_LATIN_SMALL = 401,
- AF_BLUE_STRING_LATIN_SMALL_DESCENDER = 409,
- AF_BLUE_STRING_LATIN_SUBS_CAPITAL_TOP = 415,
- AF_BLUE_STRING_LATIN_SUBS_CAPITAL_BOTTOM = 431,
- AF_BLUE_STRING_LATIN_SUBS_SMALL_F_TOP = 447,
- AF_BLUE_STRING_LATIN_SUBS_SMALL = 463,
- AF_BLUE_STRING_LATIN_SUBS_SMALL_DESCENDER = 491,
- AF_BLUE_STRING_LATIN_SUPS_CAPITAL_TOP = 507,
- AF_BLUE_STRING_LATIN_SUPS_CAPITAL_BOTTOM = 531,
- AF_BLUE_STRING_LATIN_SUPS_SMALL_F_TOP = 553,
- AF_BLUE_STRING_LATIN_SUPS_SMALL = 573,
- AF_BLUE_STRING_LATIN_SUPS_SMALL_DESCENDER = 592,
- AF_BLUE_STRING_TELUGU_TOP = 601,
- AF_BLUE_STRING_TELUGU_BOTTOM = 623,
- AF_BLUE_STRING_THAI_TOP = 645,
- AF_BLUE_STRING_THAI_BOTTOM = 664,
- AF_BLUE_STRING_THAI_ASCENDER = 686,
- AF_BLUE_STRING_THAI_LARGE_ASCENDER = 696,
- AF_BLUE_STRING_THAI_DESCENDER = 706,
- AF_BLUE_STRING_THAI_LARGE_DESCENDER = 719,
- AF_BLUE_STRING_THAI_DIGIT_TOP = 726,
- af_blue_1_1 = 735,
+ 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_GEORGIAN_MTAVRULI_TOP = 1909,
+ AF_BLUE_STRING_GEORGIAN_MTAVRULI_BOTTOM = 1941,
+ AF_BLUE_STRING_GLAGOLITIC_CAPITAL_TOP = 1973,
+ AF_BLUE_STRING_GLAGOLITIC_CAPITAL_BOTTOM = 2005,
+ AF_BLUE_STRING_GLAGOLITIC_SMALL_TOP = 2037,
+ AF_BLUE_STRING_GLAGOLITIC_SMALL_BOTTOM = 2069,
+ AF_BLUE_STRING_GOTHIC_TOP = 2101,
+ AF_BLUE_STRING_GOTHIC_BOTTOM = 2141,
+ AF_BLUE_STRING_GREEK_CAPITAL_TOP = 2161,
+ AF_BLUE_STRING_GREEK_CAPITAL_BOTTOM = 2182,
+ AF_BLUE_STRING_GREEK_SMALL_BETA_TOP = 2200,
+ AF_BLUE_STRING_GREEK_SMALL = 2218,
+ AF_BLUE_STRING_GREEK_SMALL_DESCENDER = 2242,
+ AF_BLUE_STRING_GUJARATI_TOP = 2266,
+ AF_BLUE_STRING_GUJARATI_BOTTOM = 2298,
+ AF_BLUE_STRING_GUJARATI_ASCENDER = 2330,
+ AF_BLUE_STRING_GUJARATI_DESCENDER = 2380,
+ AF_BLUE_STRING_GUJARATI_DIGIT_TOP = 2413,
+ AF_BLUE_STRING_GURMUKHI_BASE = 2433,
+ AF_BLUE_STRING_GURMUKHI_HEAD = 2465,
+ AF_BLUE_STRING_GURMUKHI_TOP = 2497,
+ AF_BLUE_STRING_GURMUKHI_BOTTOM = 2529,
+ AF_BLUE_STRING_GURMUKHI_DIGIT_TOP = 2561,
+ AF_BLUE_STRING_HEBREW_TOP = 2581,
+ AF_BLUE_STRING_HEBREW_BOTTOM = 2605,
+ AF_BLUE_STRING_HEBREW_DESCENDER = 2623,
+ AF_BLUE_STRING_KANNADA_TOP = 2638,
+ AF_BLUE_STRING_KANNADA_BOTTOM = 2682,
+ AF_BLUE_STRING_KAYAH_LI_TOP = 2714,
+ AF_BLUE_STRING_KAYAH_LI_BOTTOM = 2738,
+ AF_BLUE_STRING_KAYAH_LI_ASCENDER = 2758,
+ AF_BLUE_STRING_KAYAH_LI_DESCENDER = 2766,
+ AF_BLUE_STRING_KAYAH_LI_LARGE_DESCENDER = 2778,
+ AF_BLUE_STRING_KHMER_TOP = 2799,
+ AF_BLUE_STRING_KHMER_SUBSCRIPT_TOP = 2823,
+ AF_BLUE_STRING_KHMER_BOTTOM = 2863,
+ AF_BLUE_STRING_KHMER_DESCENDER = 2895,
+ AF_BLUE_STRING_KHMER_LARGE_DESCENDER = 2929,
+ AF_BLUE_STRING_KHMER_SYMBOLS_WAXING_TOP = 3016,
+ AF_BLUE_STRING_KHMER_SYMBOLS_WANING_BOTTOM = 3024,
+ AF_BLUE_STRING_LAO_TOP = 3032,
+ AF_BLUE_STRING_LAO_BOTTOM = 3064,
+ AF_BLUE_STRING_LAO_ASCENDER = 3096,
+ AF_BLUE_STRING_LAO_LARGE_ASCENDER = 3112,
+ AF_BLUE_STRING_LAO_DESCENDER = 3124,
+ AF_BLUE_STRING_LATIN_CAPITAL_TOP = 3148,
+ AF_BLUE_STRING_LATIN_CAPITAL_BOTTOM = 3164,
+ AF_BLUE_STRING_LATIN_SMALL_F_TOP = 3180,
+ AF_BLUE_STRING_LATIN_SMALL_TOP = 3194,
+ AF_BLUE_STRING_LATIN_SMALL_BOTTOM = 3210,
+ AF_BLUE_STRING_LATIN_SMALL_DESCENDER = 3226,
+ AF_BLUE_STRING_LATIN_SUBS_CAPITAL_TOP = 3236,
+ AF_BLUE_STRING_LATIN_SUBS_CAPITAL_BOTTOM = 3256,
+ AF_BLUE_STRING_LATIN_SUBS_SMALL_F_TOP = 3276,
+ AF_BLUE_STRING_LATIN_SUBS_SMALL = 3296,
+ AF_BLUE_STRING_LATIN_SUBS_SMALL_DESCENDER = 3332,
+ AF_BLUE_STRING_LATIN_SUPS_CAPITAL_TOP = 3352,
+ AF_BLUE_STRING_LATIN_SUPS_CAPITAL_BOTTOM = 3383,
+ AF_BLUE_STRING_LATIN_SUPS_SMALL_F_TOP = 3412,
+ AF_BLUE_STRING_LATIN_SUPS_SMALL = 3438,
+ AF_BLUE_STRING_LATIN_SUPS_SMALL_DESCENDER = 3463,
+ AF_BLUE_STRING_LISU_TOP = 3474,
+ AF_BLUE_STRING_LISU_BOTTOM = 3506,
+ AF_BLUE_STRING_MALAYALAM_TOP = 3538,
+ AF_BLUE_STRING_MALAYALAM_BOTTOM = 3582,
+ AF_BLUE_STRING_MYANMAR_TOP = 3614,
+ AF_BLUE_STRING_MYANMAR_BOTTOM = 3646,
+ AF_BLUE_STRING_MYANMAR_ASCENDER = 3678,
+ AF_BLUE_STRING_MYANMAR_DESCENDER = 3706,
+ AF_BLUE_STRING_NKO_TOP = 3738,
+ AF_BLUE_STRING_NKO_BOTTOM = 3762,
+ AF_BLUE_STRING_NKO_SMALL_TOP = 3777,
+ AF_BLUE_STRING_NKO_SMALL_BOTTOM = 3786,
+ AF_BLUE_STRING_OL_CHIKI = 3798,
+ AF_BLUE_STRING_OLD_TURKIC_TOP = 3822,
+ AF_BLUE_STRING_OLD_TURKIC_BOTTOM = 3837,
+ AF_BLUE_STRING_OSAGE_CAPITAL_TOP = 3857,
+ AF_BLUE_STRING_OSAGE_CAPITAL_BOTTOM = 3897,
+ AF_BLUE_STRING_OSAGE_CAPITAL_DESCENDER = 3927,
+ AF_BLUE_STRING_OSAGE_SMALL_TOP = 3942,
+ AF_BLUE_STRING_OSAGE_SMALL_BOTTOM = 3982,
+ AF_BLUE_STRING_OSAGE_SMALL_ASCENDER = 4022,
+ AF_BLUE_STRING_OSAGE_SMALL_DESCENDER = 4047,
+ AF_BLUE_STRING_OSMANYA_TOP = 4062,
+ AF_BLUE_STRING_OSMANYA_BOTTOM = 4102,
+ AF_BLUE_STRING_SAURASHTRA_TOP = 4142,
+ AF_BLUE_STRING_SAURASHTRA_BOTTOM = 4174,
+ AF_BLUE_STRING_SHAVIAN_TOP = 4194,
+ AF_BLUE_STRING_SHAVIAN_BOTTOM = 4204,
+ AF_BLUE_STRING_SHAVIAN_DESCENDER = 4229,
+ AF_BLUE_STRING_SHAVIAN_SMALL_TOP = 4239,
+ AF_BLUE_STRING_SHAVIAN_SMALL_BOTTOM = 4274,
+ AF_BLUE_STRING_SINHALA_TOP = 4289,
+ AF_BLUE_STRING_SINHALA_BOTTOM = 4321,
+ AF_BLUE_STRING_SINHALA_DESCENDER = 4353,
+ AF_BLUE_STRING_SUNDANESE_TOP = 4397,
+ AF_BLUE_STRING_SUNDANESE_BOTTOM = 4421,
+ AF_BLUE_STRING_SUNDANESE_DESCENDER = 4453,
+ AF_BLUE_STRING_TAI_VIET_TOP = 4461,
+ AF_BLUE_STRING_TAI_VIET_BOTTOM = 4481,
+ AF_BLUE_STRING_TAMIL_TOP = 4493,
+ AF_BLUE_STRING_TAMIL_BOTTOM = 4525,
+ AF_BLUE_STRING_TELUGU_TOP = 4557,
+ AF_BLUE_STRING_TELUGU_BOTTOM = 4585,
+ AF_BLUE_STRING_THAI_TOP = 4613,
+ AF_BLUE_STRING_THAI_BOTTOM = 4637,
+ AF_BLUE_STRING_THAI_ASCENDER = 4665,
+ AF_BLUE_STRING_THAI_LARGE_ASCENDER = 4677,
+ AF_BLUE_STRING_THAI_DESCENDER = 4689,
+ AF_BLUE_STRING_THAI_LARGE_DESCENDER = 4705,
+ AF_BLUE_STRING_THAI_DIGIT_TOP = 4713,
+ AF_BLUE_STRING_TIFINAGH = 4725,
+ AF_BLUE_STRING_VAI_TOP = 4757,
+ AF_BLUE_STRING_VAI_BOTTOM = 4789,
+ af_blue_1_1 = 4820,
#ifdef AF_CONFIG_OPTION_CJK
AF_BLUE_STRING_CJK_TOP = af_blue_1_1 + 1,
- AF_BLUE_STRING_CJK_BOTTOM = af_blue_1_1 + 153,
- af_blue_1_1_1 = af_blue_1_1 + 304,
+ AF_BLUE_STRING_CJK_BOTTOM = af_blue_1_1 + 203,
+ af_blue_1_1_1 = af_blue_1_1 + 404,
#ifdef AF_CONFIG_OPTION_CJK_BLUE_HANI_VERT
AF_BLUE_STRING_CJK_LEFT = af_blue_1_1_1 + 1,
- AF_BLUE_STRING_CJK_RIGHT = af_blue_1_1_1 + 153,
- af_blue_1_1_2 = af_blue_1_1_1 + 304,
+ AF_BLUE_STRING_CJK_RIGHT = af_blue_1_1_1 + 204,
+ af_blue_1_1_2 = af_blue_1_1_1 + 405,
#else
af_blue_1_1_2 = af_blue_1_1_1 + 0,
#endif /* AF_CONFIG_OPTION_CJK_BLUE_HANI_VERT */
@@ -164,9 +303,10 @@ FT_BEGIN_HEADER
/* blue string can't be used in more than a single writing system, which */
/* is a safe bet. */
#define AF_BLUE_PROPERTY_LATIN_TOP ( 1U << 0 ) /* must have value 1 */
-#define AF_BLUE_PROPERTY_LATIN_NEUTRAL ( 1U << 1 )
-#define AF_BLUE_PROPERTY_LATIN_X_HEIGHT ( 1U << 2 )
-#define AF_BLUE_PROPERTY_LATIN_LONG ( 1U << 3 )
+#define AF_BLUE_PROPERTY_LATIN_SUB_TOP ( 1U << 1 )
+#define AF_BLUE_PROPERTY_LATIN_NEUTRAL ( 1U << 2 )
+#define AF_BLUE_PROPERTY_LATIN_X_HEIGHT ( 1U << 3 )
+#define AF_BLUE_PROPERTY_LATIN_LONG ( 1U << 4 )
#define AF_BLUE_PROPERTY_CJK_TOP ( 1U << 0 ) /* must have value 1 */
#define AF_BLUE_PROPERTY_CJK_HORIZ ( 1U << 1 ) /* must have value 2 */
@@ -180,18 +320,59 @@ FT_BEGIN_HEADER
typedef enum AF_Blue_Stringset_
{
- AF_BLUE_STRINGSET_ARAB = 0,
- AF_BLUE_STRINGSET_CYRL = 4,
- AF_BLUE_STRINGSET_DEVA = 10,
- AF_BLUE_STRINGSET_GREK = 16,
- AF_BLUE_STRINGSET_HEBR = 23,
- AF_BLUE_STRINGSET_LAO = 27,
- AF_BLUE_STRINGSET_LATN = 33,
- AF_BLUE_STRINGSET_LATB = 40,
- AF_BLUE_STRINGSET_LATP = 47,
- AF_BLUE_STRINGSET_TELU = 54,
- AF_BLUE_STRINGSET_THAI = 57,
- af_blue_2_1 = 65,
+ 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 = 90,
+ AF_BLUE_STRINGSET_GLAG = 97,
+ AF_BLUE_STRINGSET_GOTH = 102,
+ AF_BLUE_STRINGSET_GREK = 105,
+ AF_BLUE_STRINGSET_GUJR = 112,
+ AF_BLUE_STRINGSET_GURU = 118,
+ AF_BLUE_STRINGSET_HEBR = 124,
+ AF_BLUE_STRINGSET_KALI = 128,
+ AF_BLUE_STRINGSET_KHMR = 134,
+ AF_BLUE_STRINGSET_KHMS = 140,
+ AF_BLUE_STRINGSET_KNDA = 143,
+ AF_BLUE_STRINGSET_LAO = 146,
+ AF_BLUE_STRINGSET_LATN = 152,
+ AF_BLUE_STRINGSET_LATB = 159,
+ AF_BLUE_STRINGSET_LATP = 166,
+ AF_BLUE_STRINGSET_LISU = 173,
+ AF_BLUE_STRINGSET_MLYM = 176,
+ AF_BLUE_STRINGSET_MYMR = 179,
+ AF_BLUE_STRINGSET_NKOO = 184,
+ AF_BLUE_STRINGSET_NONE = 189,
+ AF_BLUE_STRINGSET_OLCK = 190,
+ AF_BLUE_STRINGSET_ORKH = 193,
+ AF_BLUE_STRINGSET_OSGE = 196,
+ AF_BLUE_STRINGSET_OSMA = 204,
+ AF_BLUE_STRINGSET_SAUR = 207,
+ AF_BLUE_STRINGSET_SHAW = 210,
+ AF_BLUE_STRINGSET_SINH = 216,
+ AF_BLUE_STRINGSET_SUND = 220,
+ AF_BLUE_STRINGSET_TAML = 224,
+ AF_BLUE_STRINGSET_TAVT = 227,
+ AF_BLUE_STRINGSET_TELU = 230,
+ AF_BLUE_STRINGSET_TFNG = 233,
+ AF_BLUE_STRINGSET_THAI = 236,
+ AF_BLUE_STRINGSET_VAII = 244,
+ af_blue_2_1 = 247,
#ifdef AF_CONFIG_OPTION_CJK
AF_BLUE_STRINGSET_HANI = af_blue_2_1 + 0,
af_blue_2_1_1 = af_blue_2_1 + 2,
@@ -227,7 +408,7 @@ FT_BEGIN_HEADER
FT_END_HEADER
-#endif /* __AFBLUE_H__ */
+#endif /* AFBLUE_H_ */
/* END */
diff --git a/src/3rdparty/freetype/src/autofit/afblue.hin b/src/3rdparty/freetype/src/autofit/afblue.hin
index ad43fe6cef..682147cb30 100644
--- a/src/3rdparty/freetype/src/autofit/afblue.hin
+++ b/src/3rdparty/freetype/src/autofit/afblue.hin
@@ -4,7 +4,7 @@
/* */
/* Auto-fitter data for blue strings (specification). */
/* */
-/* Copyright 2013-2015 by */
+/* Copyright 2013-2018 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -16,8 +16,8 @@
/***************************************************************************/
-#ifndef __AFBLUE_H__
-#define __AFBLUE_H__
+#ifndef AFBLUE_H_
+#define AFBLUE_H_
FT_BEGIN_HEADER
@@ -25,32 +25,35 @@ FT_BEGIN_HEADER
/* an auxiliary macro to decode a UTF-8 character -- since we only use */
/* hard-coded, self-converted data, no error checking is performed */
-#define GET_UTF8_CHAR( ch, p ) \
- ch = (unsigned char)*p++; \
- if ( ch >= 0x80 ) \
- { \
- FT_UInt len; \
- \
- \
- if ( ch < 0xE0 ) \
- { \
- len = 1; \
- ch &= 0x1F; \
- } \
- else if ( ch < 0xF0 ) \
- { \
- len = 2; \
- ch &= 0x0F; \
- } \
- else \
- { \
- len = 3; \
- ch &= 0x07; \
- } \
- \
- for ( ; len > 0; len-- ) \
- ch = ( ch << 6 ) | ( *p++ & 0x3F ); \
- }
+#define GET_UTF8_CHAR( ch, p ) \
+ do \
+ { \
+ ch = (unsigned char)*p++; \
+ if ( ch >= 0x80 ) \
+ { \
+ FT_UInt len_; \
+ \
+ \
+ if ( ch < 0xE0 ) \
+ { \
+ len_ = 1; \
+ ch &= 0x1F; \
+ } \
+ else if ( ch < 0xF0 ) \
+ { \
+ len_ = 2; \
+ ch &= 0x0F; \
+ } \
+ else \
+ { \
+ len_ = 3; \
+ ch &= 0x07; \
+ } \
+ \
+ for ( ; len_ > 0; len_-- ) \
+ ch = ( ch << 6 ) | ( *p++ & 0x3F ); \
+ } \
+ } while ( 0 )
/*************************************************************************/
@@ -97,9 +100,10 @@ FT_BEGIN_HEADER
/* blue string can't be used in more than a single writing system, which */
/* is a safe bet. */
#define AF_BLUE_PROPERTY_LATIN_TOP ( 1U << 0 ) /* must have value 1 */
-#define AF_BLUE_PROPERTY_LATIN_NEUTRAL ( 1U << 1 )
-#define AF_BLUE_PROPERTY_LATIN_X_HEIGHT ( 1U << 2 )
-#define AF_BLUE_PROPERTY_LATIN_LONG ( 1U << 3 )
+#define AF_BLUE_PROPERTY_LATIN_SUB_TOP ( 1U << 1 )
+#define AF_BLUE_PROPERTY_LATIN_NEUTRAL ( 1U << 2 )
+#define AF_BLUE_PROPERTY_LATIN_X_HEIGHT ( 1U << 3 )
+#define AF_BLUE_PROPERTY_LATIN_LONG ( 1U << 4 )
#define AF_BLUE_PROPERTY_CJK_TOP ( 1U << 0 ) /* must have value 1 */
#define AF_BLUE_PROPERTY_CJK_HORIZ ( 1U << 1 ) /* must have value 2 */
@@ -136,7 +140,7 @@ FT_BEGIN_HEADER
FT_END_HEADER
-#endif /* __AFBLUE_H__ */
+#endif /* AFBLUE_H_ */
/* END */
diff --git a/src/3rdparty/freetype/src/autofit/afcjk.c b/src/3rdparty/freetype/src/autofit/afcjk.c
index 0ade4be40b..21b6bffa33 100644
--- a/src/3rdparty/freetype/src/autofit/afcjk.c
+++ b/src/3rdparty/freetype/src/autofit/afcjk.c
@@ -4,7 +4,7 @@
/* */
/* Auto-fitter hinting routines for CJK writing system (body). */
/* */
-/* Copyright 2006-2015 by */
+/* Copyright 2006-2018 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -16,9 +16,9 @@
/***************************************************************************/
/*
- * The algorithm is based on akito's autohint patch, available here:
+ * The algorithm is based on akito's autohint patch, archived at
*
- * http://www.kde.gr.jp/~akito/patch/freetype2/
+ * https://web.archive.org/web/20051219160454/http://www.kde.gr.jp:80/~akito/patch/freetype2/2.1.7/
*
*/
@@ -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"
@@ -88,7 +88,6 @@
{
FT_Error error;
FT_ULong glyph_index;
- FT_Long y_offset;
int dim;
AF_CJKMetricsRec dummy[1];
AF_Scaler scaler = &dummy->root.scaler;
@@ -101,45 +100,61 @@
AF_ScriptClass script_class = AF_SCRIPT_CLASSES_GET
[style_class->script];
- FT_UInt32 standard_char;
+ void* shaper_buf;
+ const char* p;
+#ifdef FT_DEBUG_LEVEL_TRACE
+ FT_ULong ch = 0;
+#endif
- standard_char = script_class->standard_char1;
- af_get_char_index( &metrics->root,
- standard_char,
- &glyph_index,
- &y_offset );
- if ( !glyph_index )
+ p = script_class->standard_charstring;
+ shaper_buf = af_shaper_buf_create( face );
+
+ /* We check a list of standard characters. The first match wins. */
+
+ glyph_index = 0;
+ while ( *p )
{
- if ( script_class->standard_char2 )
- {
- standard_char = script_class->standard_char2;
- af_get_char_index( &metrics->root,
- standard_char,
- &glyph_index,
- &y_offset );
- if ( !glyph_index )
- {
- if ( script_class->standard_char3 )
- {
- standard_char = script_class->standard_char3;
- af_get_char_index( &metrics->root,
- standard_char,
- &glyph_index,
- &y_offset );
- if ( !glyph_index )
- goto Exit;
- }
- else
- goto Exit;
- }
- }
- else
- goto Exit;
+ unsigned int num_idx;
+
+#ifdef FT_DEBUG_LEVEL_TRACE
+ const char* p_old;
+#endif
+
+
+ while ( *p == ' ' )
+ p++;
+
+#ifdef FT_DEBUG_LEVEL_TRACE
+ p_old = p;
+ GET_UTF8_CHAR( ch, p_old );
+#endif
+
+ /* reject input that maps to more than a single glyph */
+ p = af_shaper_get_cluster( p, &metrics->root, shaper_buf, &num_idx );
+ if ( num_idx > 1 )
+ continue;
+
+ /* otherwise exit loop if we have a result */
+ glyph_index = af_shaper_get_elem( &metrics->root,
+ shaper_buf,
+ 0,
+ NULL,
+ NULL );
+ if ( glyph_index )
+ break;
}
+ af_shaper_buf_destroy( face, shaper_buf );
+
+ if ( !glyph_index )
+ goto Exit;
+
+ if ( !glyph_index )
+ goto Exit;
+
FT_TRACE5(( "standard character: U+%04lX (glyph index %d)\n",
- standard_char, glyph_index ));
+ ch, glyph_index ));
error = FT_Load_Glyph( face, glyph_index, FT_LOAD_NO_SCALE );
if ( error || face->glyph->outline.n_points <= 0 )
@@ -177,6 +192,12 @@
if ( error )
goto Exit;
+ /*
+ * We assume that the glyphs selected for the stem width
+ * computation are `featureless' enough so that the linking
+ * algorithm works fine without adjustments of its scoring
+ * function.
+ */
af_latin_hints_link_segments( hints,
0,
NULL,
@@ -275,6 +296,8 @@
AF_Blue_Stringset bss = sc->blue_stringset;
const AF_Blue_StringRec* bs = &af_blue_stringsets[bss];
+ void* shaper_buf;
+
/* we walk over the blue character strings as specified in the */
/* style's entry in the `af_blue_stringset' array, computing its */
@@ -284,6 +307,8 @@
"==========================\n"
"\n" ));
+ shaper_buf = af_shaper_buf_create( face );
+
for ( ; bs->string != AF_BLUE_STRING_MAX; bs++ )
{
const char* p = &af_blue_strings[bs->string];
@@ -322,26 +347,47 @@
while ( *p )
{
- FT_ULong ch;
FT_ULong glyph_index;
- FT_Long y_offset;
FT_Pos best_pos; /* same as points.y or points.x, resp. */
FT_Int best_point;
FT_Vector* points;
+ unsigned int num_idx;
+
+#ifdef FT_DEBUG_LEVEL_TRACE
+ const char* p_old;
+ FT_ULong ch;
+#endif
+
- GET_UTF8_CHAR( ch, p );
+ while ( *p == ' ' )
+ p++;
+
+#ifdef FT_DEBUG_LEVEL_TRACE
+ p_old = p;
+ GET_UTF8_CHAR( ch, p_old );
+#endif
/* switch to characters that define flat values */
- if ( ch == '|' )
+ if ( *p == '|' )
{
fill = 0;
FT_TRACE5(( " [reference values]\n" ));
+ p++;
continue;
}
+ /* reject input that maps to more than a single glyph */
+ p = af_shaper_get_cluster( p, &metrics->root, shaper_buf, &num_idx );
+ if ( num_idx > 1 )
+ continue;
+
/* load the character in the face -- skip unknown or empty ones */
- af_get_char_index( &metrics->root, ch, &glyph_index, &y_offset );
+ glyph_index = af_shaper_get_elem( &metrics->root,
+ shaper_buf,
+ 0,
+ NULL,
+ NULL );
if ( glyph_index == 0 )
{
FT_TRACE5(( " U+%04lX unavailable\n", ch ));
@@ -350,9 +396,9 @@
error = FT_Load_Glyph( face, glyph_index, FT_LOAD_NO_SCALE );
outline = face->glyph->outline;
- if ( error || outline.n_points <= 0 )
+ if ( error || outline.n_points <= 2 )
{
- FT_TRACE5(( " U+%04lX contains no outlines\n", ch ));
+ FT_TRACE5(( " U+%04lX contains no (usable) outlines\n", ch ));
continue;
}
@@ -431,7 +477,8 @@
fills[num_fills++] = best_pos;
else
flats[num_flats++] = best_pos;
- }
+
+ } /* end while loop */
if ( num_flats == 0 && num_fills == 0 )
{
@@ -498,7 +545,10 @@
FT_TRACE5(( " -> reference = %ld\n"
" overshoot = %ld\n",
*blue_ref, *blue_shoot ));
- }
+
+ } /* end for loop */
+
+ af_shaper_buf_destroy( face, shaper_buf );
FT_TRACE5(( "\n" ));
@@ -512,27 +562,36 @@
af_cjk_metrics_check_digits( AF_CJKMetrics metrics,
FT_Face face )
{
- FT_UInt i;
FT_Bool started = 0, same_width = 1;
- FT_Fixed advance, old_advance = 0;
+ FT_Fixed advance = 0, old_advance = 0;
+
+ void* shaper_buf;
+
+ /* in all supported charmaps, digits have character codes 0x30-0x39 */
+ const char digits[] = "0 1 2 3 4 5 6 7 8 9";
+ const char* p;
+
+ p = digits;
+ shaper_buf = af_shaper_buf_create( face );
- /* digit `0' is 0x30 in all supported charmaps */
- for ( i = 0x30; i <= 0x39; i++ )
+ while ( *p )
{
- FT_ULong glyph_index;
- FT_Long y_offset;
+ FT_ULong glyph_index;
+ unsigned int num_idx;
- af_get_char_index( &metrics->root, i, &glyph_index, &y_offset );
- if ( glyph_index == 0 )
+ /* reject input that maps to more than a single glyph */
+ p = af_shaper_get_cluster( p, &metrics->root, shaper_buf, &num_idx );
+ if ( num_idx > 1 )
continue;
- if ( FT_Get_Advance( face, glyph_index,
- FT_LOAD_NO_SCALE |
- FT_LOAD_NO_HINTING |
- FT_LOAD_IGNORE_TRANSFORM,
- &advance ) )
+ glyph_index = af_shaper_get_elem( &metrics->root,
+ shaper_buf,
+ 0,
+ &advance,
+ NULL );
+ if ( !glyph_index )
continue;
if ( started )
@@ -550,6 +609,8 @@
}
}
+ af_shaper_buf_destroy( face, shaper_buf );
+
metrics->root.digits_have_same_width = same_width;
}
@@ -688,6 +749,22 @@
}
+ /* Extract standard_width from writing system/script specific */
+ /* metrics class. */
+
+ FT_LOCAL_DEF( void )
+ af_cjk_get_standard_widths( AF_CJKMetrics metrics,
+ FT_Pos* stdHW,
+ FT_Pos* stdVW )
+ {
+ if ( stdHW )
+ *stdHW = metrics->axis[AF_DIMENSION_VERT].standard_width;
+
+ if ( stdVW )
+ *stdVW = metrics->axis[AF_DIMENSION_HORZ].standard_width;
+ }
+
+
/*************************************************************************/
/*************************************************************************/
/***** *****/
@@ -889,15 +966,12 @@
if ( seg2 )
{
- seg2->num_linked++;
if ( seg2->link != seg1 )
{
seg1->link = NULL;
if ( seg2->score < dist_threshold || seg1->score < seg2->score * 4 )
seg1->serif = seg2->link;
- else
- seg2->num_linked--;
}
}
}
@@ -1014,7 +1088,7 @@
/* insert a new edge in the list and */
/* sort according to the position */
error = af_axis_hints_new_edge( axis, seg->pos,
- (AF_Direction)seg->dir,
+ (AF_Direction)seg->dir, 0,
memory, &edge );
if ( error )
goto Exit;
@@ -1324,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 )
@@ -1451,7 +1525,7 @@
}
if ( dist < 54 )
- dist += ( 54 - dist ) / 2 ;
+ dist += ( 54 - dist ) / 2;
else if ( dist < 3 * 64 )
{
FT_Pos delta;
@@ -2198,13 +2272,7 @@
goto Exit;
/* analyze glyph outline */
-#ifdef AF_CONFIG_OPTION_USE_WARPER
- if ( ( metrics->root.scaler.render_mode == FT_RENDER_MODE_LIGHT &&
- AF_HINTS_DO_WARP( hints ) ) ||
- AF_HINTS_DO_HORIZONTAL( hints ) )
-#else
if ( AF_HINTS_DO_HORIZONTAL( hints ) )
-#endif
{
error = af_cjk_hints_detect_features( hints, AF_DIMENSION_HORZ );
if ( error )
@@ -2230,9 +2298,9 @@
{
#ifdef AF_CONFIG_OPTION_USE_WARPER
- if ( dim == AF_DIMENSION_HORZ &&
- metrics->root.scaler.render_mode == FT_RENDER_MODE_LIGHT &&
- AF_HINTS_DO_WARP( hints ) )
+ if ( dim == AF_DIMENSION_HORZ &&
+ metrics->root.scaler.render_mode == FT_RENDER_MODE_NORMAL &&
+ AF_HINTS_DO_WARP( hints ) )
{
AF_WarperRec warper;
FT_Fixed scale;
@@ -2277,12 +2345,13 @@
sizeof ( AF_CJKMetricsRec ),
- (AF_WritingSystem_InitMetricsFunc) af_cjk_metrics_init,
- (AF_WritingSystem_ScaleMetricsFunc)af_cjk_metrics_scale,
- (AF_WritingSystem_DoneMetricsFunc) NULL,
+ (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 */
)
@@ -2296,12 +2365,13 @@
sizeof ( AF_CJKMetricsRec ),
- (AF_WritingSystem_InitMetricsFunc) NULL,
- (AF_WritingSystem_ScaleMetricsFunc)NULL,
- (AF_WritingSystem_DoneMetricsFunc) 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/src/3rdparty/freetype/src/autofit/afcjk.h b/src/3rdparty/freetype/src/autofit/afcjk.h
index e395e74a01..d229c0c9cf 100644
--- a/src/3rdparty/freetype/src/autofit/afcjk.h
+++ b/src/3rdparty/freetype/src/autofit/afcjk.h
@@ -4,7 +4,7 @@
/* */
/* Auto-fitter hinting routines for CJK writing system (specification). */
/* */
-/* Copyright 2006-2015 by */
+/* Copyright 2006-2018 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -16,8 +16,8 @@
/***************************************************************************/
-#ifndef __AFCJK_H__
-#define __AFCJK_H__
+#ifndef AFCJK_H_
+#define AFCJK_H_
#include "afhints.h"
#include "aflatin.h"
@@ -135,7 +135,7 @@ FT_BEGIN_HEADER
FT_END_HEADER
-#endif /* __AFCJK_H__ */
+#endif /* AFCJK_H_ */
/* END */
diff --git a/src/3rdparty/freetype/src/autofit/afcover.h b/src/3rdparty/freetype/src/autofit/afcover.h
index 520e8a4ae0..6eeb8fc9fb 100644
--- a/src/3rdparty/freetype/src/autofit/afcover.h
+++ b/src/3rdparty/freetype/src/autofit/afcover.h
@@ -4,7 +4,7 @@
/* */
/* Auto-fitter coverages (specification only). */
/* */
-/* Copyright 2013-2015 by */
+/* Copyright 2013-2018 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
diff --git a/src/3rdparty/freetype/src/autofit/afdummy.c b/src/3rdparty/freetype/src/autofit/afdummy.c
index 18dd301d10..f30c517cbb 100644
--- a/src/3rdparty/freetype/src/autofit/afdummy.c
+++ b/src/3rdparty/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-2015 by */
+/* Copyright 2003-2018 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -62,12 +62,13 @@
sizeof ( AF_StyleMetricsRec ),
- (AF_WritingSystem_InitMetricsFunc) NULL,
- (AF_WritingSystem_ScaleMetricsFunc)NULL,
- (AF_WritingSystem_DoneMetricsFunc) 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/src/3rdparty/freetype/src/autofit/afdummy.h b/src/3rdparty/freetype/src/autofit/afdummy.h
index b4fdc78e39..b382acd92a 100644
--- a/src/3rdparty/freetype/src/autofit/afdummy.h
+++ b/src/3rdparty/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-2015 by */
+/* Copyright 2003-2018 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -17,8 +17,8 @@
/***************************************************************************/
-#ifndef __AFDUMMY_H__
-#define __AFDUMMY_H__
+#ifndef AFDUMMY_H_
+#define AFDUMMY_H_
#include "aftypes.h"
@@ -34,7 +34,7 @@ FT_BEGIN_HEADER
FT_END_HEADER
-#endif /* __AFDUMMY_H__ */
+#endif /* AFDUMMY_H_ */
/* END */
diff --git a/src/3rdparty/freetype/src/autofit/aferrors.h b/src/3rdparty/freetype/src/autofit/aferrors.h
index 7b416e470d..e5de54360f 100644
--- a/src/3rdparty/freetype/src/autofit/aferrors.h
+++ b/src/3rdparty/freetype/src/autofit/aferrors.h
@@ -4,7 +4,7 @@
/* */
/* Autofitter error codes (specification only). */
/* */
-/* Copyright 2005-2015 by */
+/* Copyright 2005-2018 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -23,12 +23,12 @@
/* */
/*************************************************************************/
-#ifndef __AFERRORS_H__
-#define __AFERRORS_H__
+#ifndef AFERRORS_H_
+#define AFERRORS_H_
#include FT_MODULE_ERRORS_H
-#undef __FTERRORS_H__
+#undef FTERRORS_H_
#undef FT_ERR_PREFIX
#define FT_ERR_PREFIX AF_Err_
@@ -36,6 +36,7 @@
#include FT_ERRORS_H
-#endif /* __AFERRORS_H__ */
+#endif /* AFERRORS_H_ */
+
/* END */
diff --git a/src/3rdparty/freetype/src/autofit/afglobal.c b/src/3rdparty/freetype/src/autofit/afglobal.c
index b071cc76fb..3d09c53e8a 100644
--- a/src/3rdparty/freetype/src/autofit/afglobal.c
+++ b/src/3rdparty/freetype/src/autofit/afglobal.c
@@ -4,7 +4,7 @@
/* */
/* Auto-fitter routines to compute global hinting values (body). */
/* */
-/* Copyright 2003-2015 by */
+/* Copyright 2003-2018 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -18,7 +18,7 @@
#include "afglobal.h"
#include "afranges.h"
-#include "hbshim.h"
+#include "afshaper.h"
#include FT_INTERNAL_DEBUG_H
@@ -42,13 +42,14 @@
#undef SCRIPT
-#define SCRIPT( s, S, d, h, sc1, sc2, sc3 ) \
+#define SCRIPT( s, S, d, h, H, ss ) \
AF_DEFINE_SCRIPT_CLASS( \
af_ ## s ## _script_class, \
AF_SCRIPT_ ## S, \
af_ ## s ## _uniranges, \
af_ ## s ## _nonbase_uniranges, \
- sc1, sc2, sc3 )
+ AF_ ## H, \
+ ss )
#include "afscript.h"
@@ -83,7 +84,7 @@
#undef SCRIPT
-#define SCRIPT( s, S, d, h, sc1, sc2, sc3 ) \
+#define SCRIPT( s, S, d, h, H, ss ) \
&af_ ## s ## _script_class,
FT_LOCAL_ARRAY_DEF( AF_ScriptClass )
@@ -167,7 +168,7 @@
AF_Script_UniRange range;
- if ( script_class->script_uni_ranges == NULL )
+ if ( !script_class->script_uni_ranges )
continue;
/*
@@ -240,23 +241,23 @@
else
{
/* get glyphs not directly addressable by cmap */
- af_get_coverage( globals, style_class, gstyles );
+ af_shaper_get_coverage( globals, style_class, gstyles, 0 );
}
}
- /* handle the default OpenType features of the default script ... */
- af_get_coverage( globals, AF_STYLE_CLASSES_GET[dflt], gstyles );
-
- /* ... and the remaining default OpenType features */
+ /* handle the remaining default OpenType features ... */
for ( ss = 0; AF_STYLE_CLASSES_GET[ss]; ss++ )
{
AF_StyleClass style_class = AF_STYLE_CLASSES_GET[ss];
- if ( ss != dflt && style_class->coverage == AF_COVERAGE_DEFAULT )
- af_get_coverage( globals, style_class, gstyles );
+ if ( style_class->coverage == AF_COVERAGE_DEFAULT )
+ af_shaper_get_coverage( globals, style_class, gstyles, 0 );
}
+ /* ... and finally the default OpenType features of the default script */
+ af_shaper_get_coverage( globals, AF_STYLE_CLASSES_GET[dflt], gstyles, 1 );
+
/* mark ASCII digits */
for ( i = 0x30; i <= 0x39; i++ )
{
@@ -350,14 +351,21 @@
(FT_ULong)face->num_glyphs * sizeof ( FT_UShort ) ) )
goto Exit;
- globals->face = face;
- globals->glyph_count = face->num_glyphs;
+ globals->face = face;
+ globals->glyph_count = face->num_glyphs;
/* right after the globals structure come the glyph styles */
- globals->glyph_styles = (FT_UShort*)( globals + 1 );
- globals->module = module;
+ globals->glyph_styles = (FT_UShort*)( globals + 1 );
+ globals->module = module;
+ 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;
#ifdef FT_CONFIG_OPTION_USE_HARFBUZZ
globals->hb_font = hb_ft_font_create( face, NULL );
+ globals->hb_buf = hb_buffer_create();
#endif
error = af_face_globals_compute_style_coverage( globals );
@@ -403,13 +411,11 @@
#ifdef FT_CONFIG_OPTION_USE_HARFBUZZ
hb_font_destroy( globals->hb_font );
- globals->hb_font = NULL;
+ hb_buffer_destroy( globals->hb_buf );
#endif
- globals->glyph_count = 0;
- globals->glyph_styles = NULL; /* no need to free this one! */
- globals->face = NULL;
-
+ /* no need to free `globals->glyph_styles'; */
+ /* it is part of the `globals' array */
FT_FREE( globals );
}
}
@@ -447,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/src/3rdparty/freetype/src/autofit/afglobal.h b/src/3rdparty/freetype/src/autofit/afglobal.h
index ffb2f86066..489ed46d9e 100644
--- a/src/3rdparty/freetype/src/autofit/afglobal.h
+++ b/src/3rdparty/freetype/src/autofit/afglobal.h
@@ -5,7 +5,7 @@
/* Auto-fitter routines to compute global hinting values */
/* (specification). */
/* */
-/* Copyright 2003-2015 by */
+/* Copyright 2003-2018 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 @@
/***************************************************************************/
-#ifndef __AFGLOBAL_H__
-#define __AFGLOBAL_H__
+#ifndef AFGLOBAL_H_
+#define AFGLOBAL_H_
#include "aftypes.h"
#include "afmodule.h"
-#include "hbshim.h"
+#include "afshaper.h"
FT_BEGIN_HEADER
@@ -34,7 +34,7 @@ FT_BEGIN_HEADER
#undef SCRIPT
-#define SCRIPT( s, S, d, h, sc1, sc2, sc3 ) \
+#define SCRIPT( s, S, d, h, H, ss ) \
AF_DECLARE_SCRIPT_CLASS( af_ ## s ## _script_class )
#include "afscript.h"
@@ -110,6 +110,7 @@ FT_BEGIN_HEADER
#ifdef FT_CONFIG_OPTION_USE_HARFBUZZ
hb_font_t* hb_font;
+ hb_buffer_t* hb_buf; /* for feature comparison */
#endif
/* per-face auto-hinter properties */
@@ -117,6 +118,22 @@ FT_BEGIN_HEADER
AF_StyleMetrics metrics[AF_STYLE_MAX];
+ /* Compute darkening amount once per size. Use this to check whether */
+ /* darken_{x,y} needs to be recomputed. */
+ FT_UShort stem_darkening_for_ppem;
+ /* Copy from e.g. AF_LatinMetrics.axis[AF_DIMENSION_HORZ] */
+ /* to compute the darkening amount. */
+ FT_Pos standard_vertical_width;
+ /* Copy from e.g. AF_LatinMetrics.axis[AF_DIMENSION_VERT] */
+ /* to compute the darkening amount. */
+ FT_Pos standard_horizontal_width;
+ /* The actual amount to darken a glyph along the X axis. */
+ FT_Pos darken_x;
+ /* The actual amount to darken a glyph along the Y axis. */
+ FT_Pos darken_y;
+ /* Amount to scale down by to keep emboldened points */
+ /* on the Y-axis in pre-computed blue zones. */
+ FT_Fixed scale_down_factor;
AF_Module module; /* to access global properties */
} AF_FaceGlobalsRec;
@@ -150,7 +167,7 @@ FT_BEGIN_HEADER
FT_END_HEADER
-#endif /* __AFGLOBAL_H__ */
+#endif /* AFGLOBAL_H_ */
/* END */
diff --git a/src/3rdparty/freetype/src/autofit/afhints.c b/src/3rdparty/freetype/src/autofit/afhints.c
index 37482ebd1f..0666dbc8e2 100644
--- a/src/3rdparty/freetype/src/autofit/afhints.c
+++ b/src/3rdparty/freetype/src/autofit/afhints.c
@@ -4,7 +4,7 @@
/* */
/* Auto-fitter hinting routines (body). */
/* */
-/* Copyright 2003-2015 by */
+/* Copyright 2003-2018 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;
@@ -99,6 +99,7 @@
af_axis_hints_new_edge( AF_AxisHints axis,
FT_Int fpos,
AF_Direction dir,
+ FT_Bool top_to_bottom_hinting,
FT_Memory memory,
AF_Edge *anedge )
{
@@ -109,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;
@@ -153,7 +154,8 @@
while ( edge > edges )
{
- if ( edge[-1].fpos < fpos )
+ if ( top_to_bottom_hinting ? ( edge[-1].fpos > fpos )
+ : ( edge[-1].fpos < fpos ) )
break;
/* we want the edge with same position and minor direction */
@@ -219,6 +221,82 @@
#define AF_INDEX_NUM( ptr, base ) (int)( (ptr) ? ( (ptr) - (base) ) : -1 )
+ static char*
+ af_print_idx( char* p,
+ int idx )
+ {
+ if ( idx == -1 )
+ {
+ p[0] = '-';
+ p[1] = '-';
+ p[2] = '\0';
+ }
+ else
+ ft_sprintf( p, "%d", idx );
+
+ return p;
+ }
+
+
+ static int
+ af_get_segment_index( AF_GlyphHints hints,
+ int point_idx,
+ int dimension )
+ {
+ AF_AxisHints axis = &hints->axis[dimension];
+ AF_Point point = hints->points + point_idx;
+ AF_Segment segments = axis->segments;
+ AF_Segment limit = segments + axis->num_segments;
+ AF_Segment segment;
+
+
+ for ( segment = segments; segment < limit; segment++ )
+ {
+ if ( segment->first <= segment->last )
+ {
+ if ( point >= segment->first && point <= segment->last )
+ break;
+ }
+ else
+ {
+ AF_Point p = segment->first;
+
+
+ for (;;)
+ {
+ if ( point == p )
+ goto Exit;
+
+ if ( p == segment->last )
+ break;
+
+ p = p->next;
+ }
+ }
+ }
+
+ Exit:
+ if ( segment == limit )
+ return -1;
+
+ return (int)( segment - segments );
+ }
+
+
+ static int
+ af_get_edge_index( AF_GlyphHints hints,
+ int segment_idx,
+ int dimension )
+ {
+ AF_AxisHints axis = &hints->axis[dimension];
+ AF_Edge edges = axis->edges;
+ AF_Segment segment = axis->segments + segment_idx;
+
+
+ return segment_idx == -1 ? -1 : AF_INDEX_NUM( segment->edge, edges );
+ }
+
+
#ifdef __cplusplus
extern "C" {
#endif
@@ -226,30 +304,63 @@
af_glyph_hints_dump_points( AF_GlyphHints hints,
FT_Bool to_stdout )
{
- AF_Point points = hints->points;
- AF_Point limit = points + hints->num_points;
- AF_Point point;
+ AF_Point points = hints->points;
+ AF_Point limit = points + hints->num_points;
+ AF_Point* contour = hints->contours;
+ AF_Point* climit = contour + hints->num_contours;
+ AF_Point point;
AF_DUMP(( "Table of points:\n" ));
if ( hints->num_points )
- AF_DUMP(( " [ index | xorg | yorg | xscale | yscale"
- " | xfit | yfit | flags ]\n" ));
+ {
+ AF_DUMP(( " index hedge hseg vedge vseg flags "
+ /* " XXXXX XXXXX XXXXX XXXXX XXXXX XXXXXX" */
+ " xorg yorg xscale yscale xfit yfit" ));
+ /* " XXXXX XXXXX XXXX.XX XXXX.XX XXXX.XX XXXX.XX" */
+ }
else
AF_DUMP(( " (none)\n" ));
for ( point = points; point < limit; point++ )
- AF_DUMP(( " [ %5d | %5d | %5d | %6.2f | %6.2f"
- " | %5.2f | %5.2f | %c ]\n",
- AF_INDEX_NUM( point, points ),
+ {
+ int point_idx = AF_INDEX_NUM( point, points );
+ int segment_idx_0 = af_get_segment_index( hints, point_idx, 0 );
+ int segment_idx_1 = af_get_segment_index( hints, point_idx, 1 );
+
+ char buf1[16], buf2[16], buf3[16], buf4[16];
+
+
+ /* insert extra newline at the beginning of a contour */
+ if ( contour < climit && *contour == point )
+ {
+ AF_DUMP(( "\n" ));
+ contour++;
+ }
+
+ AF_DUMP(( " %5d %5s %5s %5s %5s %s"
+ " %5d %5d %7.2f %7.2f %7.2f %7.2f\n",
+ point_idx,
+ af_print_idx( buf1,
+ af_get_edge_index( hints, segment_idx_1, 1 ) ),
+ af_print_idx( buf2, segment_idx_1 ),
+ af_print_idx( buf3,
+ af_get_edge_index( hints, segment_idx_0, 0 ) ),
+ af_print_idx( buf4, segment_idx_0 ),
+ ( point->flags & AF_FLAG_NEAR )
+ ? " near "
+ : ( point->flags & AF_FLAG_WEAK_INTERPOLATION )
+ ? " weak "
+ : "strong",
+
point->fx,
point->fy,
point->ox / 64.0,
point->oy / 64.0,
point->x / 64.0,
- point->y / 64.0,
- ( point->flags & AF_FLAG_WEAK_INTERPOLATION ) ? 'w' : ' '));
+ point->y / 64.0 ));
+ }
AF_DUMP(( "\n" ));
}
#ifdef __cplusplus
@@ -306,31 +417,39 @@
AF_Segment limit = segments + axis->num_segments;
AF_Segment seg;
+ char buf1[16], buf2[16], buf3[16];
+
AF_DUMP(( "Table of %s segments:\n",
dimension == AF_DIMENSION_HORZ ? "vertical"
: "horizontal" ));
if ( axis->num_segments )
- AF_DUMP(( " [ index | pos | dir | from"
- " | to | link | serif | edge"
- " | height | extra | flags ]\n" ));
+ {
+ AF_DUMP(( " index pos delta dir from to "
+ /* " XXXXX XXXXX XXXXX XXXXX XXXX XXXX" */
+ " link serif edge"
+ /* " XXXX XXXXX XXXX" */
+ " height extra flags\n" ));
+ /* " XXXXXX XXXXX XXXXXXXXXXX" */
+ }
else
AF_DUMP(( " (none)\n" ));
for ( seg = segments; seg < limit; seg++ )
- AF_DUMP(( " [ %5d | %5.2g | %5s | %4d"
- " | %4d | %4d | %5d | %4d"
- " | %6d | %5d | %11s ]\n",
+ 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 ),
- AF_INDEX_NUM( seg->link, segments ),
- AF_INDEX_NUM( seg->serif, segments ),
- AF_INDEX_NUM( seg->edge, edges ),
+
+ af_print_idx( buf1, AF_INDEX_NUM( seg->link, segments ) ),
+ af_print_idx( buf2, AF_INDEX_NUM( seg->serif, segments ) ),
+ af_print_idx( buf3, AF_INDEX_NUM( seg->edge, edges ) ),
+
seg->height,
seg->height - ( seg->max_coord - seg->min_coord ),
af_edge_flags_to_string( seg->flags ) ));
@@ -397,15 +516,15 @@
return FT_THROW( Invalid_Argument );
seg = &axis->segments[idx];
- *offset = ( dim == AF_DIMENSION_HORZ ) ? seg->first->ox
- : seg->first->oy;
+ *offset = ( dim == AF_DIMENSION_HORZ ) ? seg->first->fx
+ : seg->first->fy;
if ( seg->edge )
*is_blue = (FT_Bool)( seg->edge->blue_edge != 0 );
else
*is_blue = FALSE;
if ( *is_blue )
- *blue_offset = seg->edge->blue_edge->cur;
+ *blue_offset = seg->edge->blue_edge->org;
else
*blue_offset = 0;
@@ -435,28 +554,43 @@
AF_Edge limit = edges + axis->num_edges;
AF_Edge edge;
+ char buf1[16], buf2[16];
+
/*
* 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"
+ /* " XXXXX XXXX.XX XXXXX XXXX XXXXX" */
+ " blue opos pos flags\n" ));
+ /* " X XXXX.XX XXXX.XX XXXXXXXXXXX" */
+ }
else
AF_DUMP(( " (none)\n" ));
for ( edge = edges; edge < limit; edge++ )
- AF_DUMP(( " [ %5d | %5.2g | %5s | %4d"
- " | %5d | %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 ),
- AF_INDEX_NUM( edge->link, edges ),
- AF_INDEX_NUM( edge->serif, edges ),
+ af_print_idx( buf1, AF_INDEX_NUM( edge->link, edges ) ),
+ af_print_idx( buf2, AF_INDEX_NUM( edge->serif, edges ) ),
+
edge->blue_edge ? 'y' : 'n',
edge->opos / 64.0,
edge->pos / 64.0,
@@ -622,7 +756,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;
@@ -651,7 +785,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;
@@ -702,18 +836,26 @@
AF_Point point;
AF_Point point_limit = points + hints->num_points;
+ /* value 20 in `near_limit' is heuristic */
+ FT_UInt units_per_em = hints->metrics->scaler.face->units_per_EM;
+ FT_Int near_limit = 20 * units_per_em / 2048;
+
/* compute coordinates & Bezier flags, next and prev */
{
FT_Vector* vec = outline->points;
char* tag = outline->tags;
- AF_Point end = points + outline->contours[0];
+ FT_Short endpoint = outline->contours[0];
+ AF_Point end = points + endpoint;
AF_Point prev = end;
FT_Int contour_index = 0;
for ( point = points; point < point_limit; point++, vec++, tag++ )
{
+ FT_Pos out_x, out_y;
+
+
point->in_dir = (FT_Char)AF_DIR_NONE;
point->out_dir = (FT_Char)AF_DIR_NONE;
@@ -722,6 +864,9 @@
point->ox = point->x = FT_MulFix( vec->x, x_scale ) + x_delta;
point->oy = point->y = FT_MulFix( vec->y, y_scale ) + y_delta;
+ end->fx = (FT_Short)outline->points[endpoint].x;
+ end->fy = (FT_Short)outline->points[endpoint].y;
+
switch ( FT_CURVE_TAG( *tag ) )
{
case FT_CURVE_TAG_CONIC:
@@ -734,6 +879,12 @@
point->flags = AF_FLAG_NONE;
}
+ out_x = point->fx - prev->fx;
+ out_y = point->fy - prev->fy;
+
+ if ( FT_ABS( out_x ) + FT_ABS( out_y ) < near_limit )
+ prev->flags |= AF_FLAG_NEAR;
+
point->prev = prev;
prev->next = point;
prev = point;
@@ -742,8 +893,9 @@
{
if ( ++contour_index < outline->n_contours )
{
- end = points + outline->contours[contour_index];
- prev = end;
+ endpoint = outline->contours[contour_index];
+ end = points + endpoint;
+ prev = end;
}
}
}
@@ -769,17 +921,15 @@
* Compute directions of `in' and `out' vectors.
*
* Note that distances between points that are very near to each
- * other are accumulated. In other words, the auto-hinter
+ * other are accumulated. In other words, the auto-hinter either
* prepends the small vectors between near points to the first
- * non-near vector. All intermediate points are tagged as
- * weak; the directions are adjusted also to be equal to the
- * accumulated one.
+ * non-near vector, or the sum of small vector lengths exceeds a
+ * threshold, thus `grouping' the small vectors. All intermediate
+ * points are tagged as weak; the directions are adjusted also to
+ * be equal to the accumulated one.
*/
- /* value 20 in `near_limit' is heuristic */
- FT_UInt units_per_em = hints->metrics->scaler.face->units_per_EM;
- FT_Int near_limit = 20 * units_per_em / 2048;
- FT_Int near_limit2 = 2 * near_limit - 1;
+ FT_Int near_limit2 = 2 * near_limit - 1;
AF_Point* contour;
AF_Point* contour_limit = hints->contours + hints->num_contours;
@@ -826,7 +976,7 @@
/* now loop over all points of the contour to get */
/* `in' and `out' vector directions */
- curr = first;
+ curr = first;
/*
* We abuse the `u' and `v' fields to store index deltas to the
@@ -849,7 +999,7 @@
point = next;
- next = point->next;
+ next = point->next;
out_x += next->fx - point->fx;
out_y += next->fy - point->fy;
@@ -1045,7 +1195,7 @@
AF_Point point, first, last;
- if ( edge == NULL )
+ if ( !edge )
continue;
first = seg->first;
@@ -1071,7 +1221,7 @@
AF_Point point, first, last;
- if ( edge == NULL )
+ if ( !edge )
continue;
first = seg->first;
diff --git a/src/3rdparty/freetype/src/autofit/afhints.h b/src/3rdparty/freetype/src/autofit/afhints.h
index a64c7a4b11..3326ebc44e 100644
--- a/src/3rdparty/freetype/src/autofit/afhints.h
+++ b/src/3rdparty/freetype/src/autofit/afhints.h
@@ -4,7 +4,7 @@
/* */
/* Auto-fitter hinting routines (specification). */
/* */
-/* Copyright 2003-2015 by */
+/* Copyright 2003-2018 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -16,8 +16,8 @@
/***************************************************************************/
-#ifndef __AFHINTS_H__
-#define __AFHINTS_H__
+#ifndef AFHINTS_H_
+#define AFHINTS_H_
#include "aftypes.h"
@@ -62,7 +62,7 @@ FT_BEGIN_HEADER
*
* by David Turner and Werner Lemberg
*
- * http://www.tug.org/TUGboat/Articles/tb24-3/lemberg.pdf
+ * https://www.tug.org/TUGboat/Articles/tb24-3/lemberg.pdf
*
* with appropriate updates.
*
@@ -221,6 +221,9 @@ FT_BEGIN_HEADER
/* candidates for weak interpolation have this flag set */
#define AF_FLAG_WEAK_INTERPOLATION ( 1U << 4 )
+ /* the distance to the next point is very small */
+#define AF_FLAG_NEAR ( 1U << 5 )
+
/* edge hint flags */
#define AF_EDGE_NORMAL 0
@@ -257,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 */
@@ -266,7 +270,6 @@ FT_BEGIN_HEADER
AF_Segment link; /* (stem) link segment */
AF_Segment serif; /* primary segment for serifs */
- FT_Pos num_linked; /* number of linked segments */
FT_Pos score; /* used during stem matching */
FT_Pos len; /* used during stem matching */
@@ -289,7 +292,6 @@ FT_BEGIN_HEADER
AF_Width blue_edge; /* non-NULL if this is a blue edge */
AF_Edge link; /* link edge */
AF_Edge serif; /* primary edge for serifs */
- FT_Short num_linked; /* number of linked edges */
FT_Int score; /* used during stem matching */
AF_Segment first; /* first segment in edge */
@@ -419,6 +421,7 @@ FT_BEGIN_HEADER
af_axis_hints_new_edge( AF_AxisHints axis,
FT_Int fpos,
AF_Direction dir,
+ FT_Bool top_to_bottom_hinting,
FT_Memory memory,
AF_Edge *edge );
@@ -472,7 +475,7 @@ FT_BEGIN_HEADER
FT_END_HEADER
-#endif /* __AFHINTS_H__ */
+#endif /* AFHINTS_H_ */
/* END */
diff --git a/src/3rdparty/freetype/src/autofit/afindic.c b/src/3rdparty/freetype/src/autofit/afindic.c
index 05b6bdd887..dfbea5f34c 100644
--- a/src/3rdparty/freetype/src/autofit/afindic.c
+++ b/src/3rdparty/freetype/src/autofit/afindic.c
@@ -4,7 +4,7 @@
/* */
/* Auto-fitter hinting routines for Indic writing system (body). */
/* */
-/* Copyright 2007-2015 by */
+/* Copyright 2007-2018 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
@@ -89,6 +89,22 @@
}
+ /* Extract standard_width from writing system/script specific */
+ /* metrics class. */
+
+ static void
+ af_indic_get_standard_widths( AF_CJKMetrics metrics,
+ FT_Pos* stdHW,
+ FT_Pos* stdVW )
+ {
+ if ( stdHW )
+ *stdHW = metrics->axis[AF_DIMENSION_VERT].standard_width;
+
+ if ( stdVW )
+ *stdVW = metrics->axis[AF_DIMENSION_HORZ].standard_width;
+ }
+
+
/*************************************************************************/
/*************************************************************************/
/***** *****/
@@ -105,12 +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_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 */
)
@@ -124,12 +141,13 @@
sizeof ( AF_CJKMetricsRec ),
- (AF_WritingSystem_InitMetricsFunc) NULL,
- (AF_WritingSystem_ScaleMetricsFunc)NULL,
- (AF_WritingSystem_DoneMetricsFunc) 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/src/3rdparty/freetype/src/autofit/afindic.h b/src/3rdparty/freetype/src/autofit/afindic.h
index 4c36908ada..5688738e6e 100644
--- a/src/3rdparty/freetype/src/autofit/afindic.h
+++ b/src/3rdparty/freetype/src/autofit/afindic.h
@@ -5,7 +5,7 @@
/* Auto-fitter hinting routines for Indic writing system */
/* (specification). */
/* */
-/* Copyright 2007-2015 by */
+/* Copyright 2007-2018 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, */
@@ -17,8 +17,8 @@
/***************************************************************************/
-#ifndef __AFINDIC_H__
-#define __AFINDIC_H__
+#ifndef AFINDIC_H_
+#define AFINDIC_H_
#include "afhints.h"
@@ -35,7 +35,7 @@ FT_BEGIN_HEADER
FT_END_HEADER
-#endif /* __AFINDIC_H__ */
+#endif /* AFINDIC_H_ */
/* END */
diff --git a/src/3rdparty/freetype/src/autofit/aflatin.c b/src/3rdparty/freetype/src/autofit/aflatin.c
index 363f72114b..9f1b54056f 100644
--- a/src/3rdparty/freetype/src/autofit/aflatin.c
+++ b/src/3rdparty/freetype/src/autofit/aflatin.c
@@ -4,7 +4,7 @@
/* */
/* Auto-fitter hinting routines for latin writing system (body). */
/* */
-/* Copyright 2003-2015 by */
+/* Copyright 2003-2018 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -79,7 +79,6 @@
{
FT_Error error;
FT_ULong glyph_index;
- FT_Long y_offset;
int dim;
AF_LatinMetricsRec dummy[1];
AF_Scaler scaler = &dummy->root.scaler;
@@ -92,52 +91,63 @@
AF_ScriptClass script_class = AF_SCRIPT_CLASSES_GET
[style_class->script];
- FT_UInt32 standard_char;
+ void* shaper_buf;
+ const char* p;
+#ifdef FT_DEBUG_LEVEL_TRACE
+ FT_ULong ch = 0;
+#endif
+
+ p = script_class->standard_charstring;
+ shaper_buf = af_shaper_buf_create( face );
/*
- * We check more than a single standard character to catch features
- * like `c2sc' (small caps from caps) that don't contain lowercase
- * letters by definition, or other features that mainly operate on
- * numerals.
+ * We check a list of standard characters to catch features like
+ * `c2sc' (small caps from caps) that don't contain lowercase letters
+ * by definition, or other features that mainly operate on numerals.
+ * The first match wins.
*/
- standard_char = script_class->standard_char1;
- af_get_char_index( &metrics->root,
- standard_char,
- &glyph_index,
- &y_offset );
- if ( !glyph_index )
+ glyph_index = 0;
+ while ( *p )
{
- if ( script_class->standard_char2 )
- {
- standard_char = script_class->standard_char2;
- af_get_char_index( &metrics->root,
- standard_char,
- &glyph_index,
- &y_offset );
- if ( !glyph_index )
- {
- if ( script_class->standard_char3 )
- {
- standard_char = script_class->standard_char3;
- af_get_char_index( &metrics->root,
- standard_char,
- &glyph_index,
- &y_offset );
- if ( !glyph_index )
- goto Exit;
- }
- else
- goto Exit;
- }
- }
- else
- goto Exit;
+ unsigned int num_idx;
+
+#ifdef FT_DEBUG_LEVEL_TRACE
+ const char* p_old;
+#endif
+
+
+ while ( *p == ' ' )
+ p++;
+
+#ifdef FT_DEBUG_LEVEL_TRACE
+ p_old = p;
+ GET_UTF8_CHAR( ch, p_old );
+#endif
+
+ /* reject input that maps to more than a single glyph */
+ p = af_shaper_get_cluster( p, &metrics->root, shaper_buf, &num_idx );
+ if ( num_idx > 1 )
+ continue;
+
+ /* otherwise exit loop if we have a result */
+ glyph_index = af_shaper_get_elem( &metrics->root,
+ shaper_buf,
+ 0,
+ NULL,
+ NULL );
+ if ( glyph_index )
+ break;
}
+ af_shaper_buf_destroy( face, shaper_buf );
+
+ if ( !glyph_index )
+ goto Exit;
+
FT_TRACE5(( "standard character: U+%04lX (glyph index %d)\n",
- standard_char, glyph_index ));
+ ch, glyph_index ));
error = FT_Load_Glyph( face, glyph_index, FT_LOAD_NO_SCALE );
if ( error || face->glyph->outline.n_points <= 0 )
@@ -255,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. */
@@ -280,6 +329,8 @@
FT_Pos flat_threshold = FLAT_THRESHOLD( metrics->units_per_em );
+ void* shaper_buf;
+
/* we walk over the blue character strings as specified in the */
/* style's entry in the `af_blue_stringset' array */
@@ -288,11 +339,15 @@
"============================\n"
"\n" ));
+ shaper_buf = af_shaper_buf_create( face );
+
for ( ; bs->string != AF_BLUE_STRING_MAX; bs++ )
{
const char* p = &af_blue_strings[bs->string];
FT_Pos* blue_ref;
FT_Pos* blue_shoot;
+ FT_Pos ascender;
+ FT_Pos descender;
#ifdef FT_DEBUG_LEVEL_TRACE
@@ -311,6 +366,11 @@
FT_TRACE5(( "top" ));
have_flag = 1;
}
+ else if ( AF_LATIN_IS_SUB_TOP_BLUE( bs ) )
+ {
+ FT_TRACE5(( "sub top" ));
+ have_flag = 1;
+ }
if ( AF_LATIN_IS_NEUTRAL_BLUE( bs ) )
{
@@ -344,394 +404,482 @@
num_flats = 0;
num_rounds = 0;
+ ascender = 0;
+ descender = 0;
while ( *p )
{
- FT_ULong ch;
FT_ULong glyph_index;
FT_Long y_offset;
- FT_Pos best_y; /* same as points.y */
FT_Int best_point, best_contour_first, best_contour_last;
FT_Vector* points;
- FT_Bool round = 0;
+ FT_Pos best_y_extremum; /* same as points.y */
+ FT_Bool best_round = 0;
- GET_UTF8_CHAR( ch, p );
+ unsigned int i, num_idx;
- /* load the character in the face -- skip unknown or empty ones */
- af_get_char_index( &metrics->root, ch, &glyph_index, &y_offset );
- if ( glyph_index == 0 )
- {
- FT_TRACE5(( " U+%04lX unavailable\n", ch ));
- continue;
- }
+#ifdef FT_DEBUG_LEVEL_TRACE
+ const char* p_old;
+ FT_ULong ch;
+#endif
- error = FT_Load_Glyph( face, glyph_index, FT_LOAD_NO_SCALE );
- outline = face->glyph->outline;
- /* reject glyphs that don't produce any rendering */
- if ( error || outline.n_points <= 2 )
+
+ while ( *p == ' ' )
+ p++;
+
+#ifdef FT_DEBUG_LEVEL_TRACE
+ p_old = p;
+ GET_UTF8_CHAR( ch, p_old );
+#endif
+
+ p = af_shaper_get_cluster( p, &metrics->root, shaper_buf, &num_idx );
+
+ if ( !num_idx )
{
- FT_TRACE5(( " U+%04lX contains no (usable) outlines\n", ch ));
+ FT_TRACE5(( " U+%04lX unavailable\n", ch ));
continue;
}
- /* now compute min or max point indices and coordinates */
- points = outline.points;
- best_point = -1;
- best_y = 0; /* make compiler happy */
- best_contour_first = 0; /* ditto */
- best_contour_last = 0; /* ditto */
+ if ( AF_LATIN_IS_TOP_BLUE( bs ) )
+ best_y_extremum = FT_INT_MIN;
+ else
+ best_y_extremum = FT_INT_MAX;
+ /* iterate over all glyph elements of the character cluster */
+ /* and get the data of the `biggest' one */
+ for ( i = 0; i < num_idx; i++ )
{
- FT_Int nn;
- FT_Int first = 0;
- FT_Int last = -1;
+ FT_Pos best_y;
+ FT_Bool round = 0;
- for ( nn = 0; nn < outline.n_contours; first = last + 1, nn++ )
+ /* load the character in the face -- skip unknown or empty ones */
+ glyph_index = af_shaper_get_elem( &metrics->root,
+ shaper_buf,
+ i,
+ NULL,
+ &y_offset );
+ if ( glyph_index == 0 )
{
- FT_Int old_best_point = best_point;
- FT_Int pp;
+ FT_TRACE5(( " U+%04lX unavailable\n", ch ));
+ continue;
+ }
+ error = FT_Load_Glyph( face, glyph_index, FT_LOAD_NO_SCALE );
+ outline = face->glyph->outline;
+ /* reject glyphs that don't produce any rendering */
+ if ( error || outline.n_points <= 2 )
+ {
+#ifdef FT_DEBUG_LEVEL_TRACE
+ if ( num_idx == 1 )
+ FT_TRACE5(( " U+%04lX contains no (usable) outlines\n", ch ));
+ else
+ FT_TRACE5(( " component %d of cluster starting with U+%04lX"
+ " contains no (usable) outlines\n", i, ch ));
+#endif
+ continue;
+ }
- last = outline.contours[nn];
+ /* now compute min or max point indices and coordinates */
+ points = outline.points;
+ best_point = -1;
+ best_y = 0; /* make compiler happy */
+ best_contour_first = 0; /* ditto */
+ best_contour_last = 0; /* ditto */
+
+ {
+ FT_Int nn;
+ FT_Int first = 0;
+ FT_Int last = -1;
- /* Avoid single-point contours since they are never rasterized. */
- /* In some fonts, they correspond to mark attachment points */
- /* that are way outside of the glyph's real outline. */
- if ( last <= first )
- continue;
- if ( AF_LATIN_IS_TOP_BLUE( bs ) )
+ for ( nn = 0; nn < outline.n_contours; first = last + 1, nn++ )
{
- for ( pp = first; pp <= last; pp++ )
- if ( best_point < 0 || points[pp].y > best_y )
+ FT_Int old_best_point = best_point;
+ FT_Int pp;
+
+
+ last = outline.contours[nn];
+
+ /* Avoid single-point contours since they are never */
+ /* rasterized. In some fonts, they correspond to mark */
+ /* attachment points that are way outside of the glyph's */
+ /* real outline. */
+ if ( last <= first )
+ continue;
+
+ if ( AF_LATIN_IS_TOP_BLUE( bs ) ||
+ AF_LATIN_IS_SUB_TOP_BLUE( bs ) )
+ {
+ for ( pp = first; pp <= last; pp++ )
{
- best_point = pp;
- best_y = points[pp].y;
+ if ( best_point < 0 || points[pp].y > best_y )
+ {
+ best_point = pp;
+ best_y = points[pp].y;
+ ascender = FT_MAX( ascender, best_y + y_offset );
+ }
+ else
+ descender = FT_MIN( descender, points[pp].y + y_offset );
}
- }
- else
- {
- for ( pp = first; pp <= last; pp++ )
- if ( best_point < 0 || points[pp].y < best_y )
+ }
+ else
+ {
+ for ( pp = first; pp <= last; pp++ )
{
- best_point = pp;
- best_y = points[pp].y;
+ if ( best_point < 0 || points[pp].y < best_y )
+ {
+ best_point = pp;
+ best_y = points[pp].y;
+ descender = FT_MIN( descender, best_y + y_offset );
+ }
+ else
+ ascender = FT_MAX( ascender, points[pp].y + y_offset );
}
- }
+ }
- if ( best_point != old_best_point )
- {
- best_contour_first = first;
- best_contour_last = last;
+ if ( best_point != old_best_point )
+ {
+ best_contour_first = first;
+ best_contour_last = last;
+ }
}
}
- }
-
- /* now check whether the point belongs to a straight or round */
- /* segment; we first need to find in which contour the extremum */
- /* lies, then inspect its previous and next points */
- if ( best_point >= 0 )
- {
- FT_Pos best_x = points[best_point].x;
- FT_Int prev, next;
- FT_Int best_segment_first, best_segment_last;
- FT_Int best_on_point_first, best_on_point_last;
- FT_Pos dist;
-
- best_segment_first = best_point;
- best_segment_last = best_point;
-
- if ( FT_CURVE_TAG( outline.tags[best_point] ) == FT_CURVE_TAG_ON )
+ /* now check whether the point belongs to a straight or round */
+ /* segment; we first need to find in which contour the extremum */
+ /* lies, then inspect its previous and next points */
+ if ( best_point >= 0 )
{
- best_on_point_first = best_point;
- best_on_point_last = best_point;
- }
- else
- {
- best_on_point_first = -1;
- best_on_point_last = -1;
- }
+ FT_Pos best_x = points[best_point].x;
+ FT_Int prev, next;
+ FT_Int best_segment_first, best_segment_last;
+ FT_Int best_on_point_first, best_on_point_last;
+ FT_Pos dist;
- /* look for the previous and next points on the contour */
- /* that are not on the same Y coordinate, then threshold */
- /* the `closeness'... */
- prev = best_point;
- next = prev;
- do
- {
- if ( prev > best_contour_first )
- prev--;
- else
- prev = best_contour_last;
+ best_segment_first = best_point;
+ best_segment_last = best_point;
- dist = FT_ABS( points[prev].y - best_y );
- /* accept a small distance or a small angle (both values are */
- /* heuristic; value 20 corresponds to approx. 2.9 degrees) */
- if ( dist > 5 )
- if ( FT_ABS( points[prev].x - best_x ) <= 20 * dist )
- break;
+ if ( FT_CURVE_TAG( outline.tags[best_point] ) == FT_CURVE_TAG_ON )
+ {
+ best_on_point_first = best_point;
+ best_on_point_last = best_point;
+ }
+ else
+ {
+ best_on_point_first = -1;
+ best_on_point_last = -1;
+ }
- best_segment_first = prev;
+ /* look for the previous and next points on the contour */
+ /* that are not on the same Y coordinate, then threshold */
+ /* the `closeness'... */
+ prev = best_point;
+ next = prev;
- if ( FT_CURVE_TAG( outline.tags[prev] ) == FT_CURVE_TAG_ON )
+ do
{
- best_on_point_first = prev;
- if ( best_on_point_last < 0 )
- best_on_point_last = prev;
- }
+ if ( prev > best_contour_first )
+ prev--;
+ else
+ prev = best_contour_last;
- } while ( prev != best_point );
+ dist = FT_ABS( points[prev].y - best_y );
+ /* accept a small distance or a small angle (both values are */
+ /* heuristic; value 20 corresponds to approx. 2.9 degrees) */
+ if ( dist > 5 )
+ if ( FT_ABS( points[prev].x - best_x ) <= 20 * dist )
+ break;
- do
- {
- if ( next < best_contour_last )
- next++;
- else
- next = best_contour_first;
+ best_segment_first = prev;
- dist = FT_ABS( points[next].y - best_y );
- if ( dist > 5 )
- if ( FT_ABS( points[next].x - best_x ) <= 20 * dist )
- break;
+ if ( FT_CURVE_TAG( outline.tags[prev] ) == FT_CURVE_TAG_ON )
+ {
+ best_on_point_first = prev;
+ if ( best_on_point_last < 0 )
+ best_on_point_last = prev;
+ }
- best_segment_last = next;
+ } while ( prev != best_point );
- if ( FT_CURVE_TAG( outline.tags[next] ) == FT_CURVE_TAG_ON )
+ do
{
- best_on_point_last = next;
- if ( best_on_point_first < 0 )
- best_on_point_first = next;
- }
+ if ( next < best_contour_last )
+ next++;
+ else
+ next = best_contour_first;
- } while ( next != best_point );
+ dist = FT_ABS( points[next].y - best_y );
+ if ( dist > 5 )
+ if ( FT_ABS( points[next].x - best_x ) <= 20 * dist )
+ break;
- if ( AF_LATIN_IS_LONG_BLUE( bs ) )
- {
- /* If this flag is set, we have an additional constraint to */
- /* get the blue zone distance: Find a segment of the topmost */
- /* (or bottommost) contour that is longer than a heuristic */
- /* threshold. This ensures that small bumps in the outline */
- /* are ignored (for example, the `vertical serifs' found in */
- /* many Hebrew glyph designs). */
-
- /* If this segment is long enough, we are done. Otherwise, */
- /* search the segment next to the extremum that is long */
- /* enough, has the same direction, and a not too large */
- /* vertical distance from the extremum. Note that the */
- /* algorithm doesn't check whether the found segment is */
- /* actually the one (vertically) nearest to the extremum. */
-
- /* heuristic threshold value */
- FT_Pos length_threshold = metrics->units_per_em / 25;
-
-
- dist = FT_ABS( points[best_segment_last].x -
- points[best_segment_first].x );
-
- if ( dist < length_threshold &&
- best_segment_last - best_segment_first + 2 <=
- best_contour_last - best_contour_first )
+ best_segment_last = next;
+
+ if ( FT_CURVE_TAG( outline.tags[next] ) == FT_CURVE_TAG_ON )
+ {
+ best_on_point_last = next;
+ if ( best_on_point_first < 0 )
+ best_on_point_first = next;
+ }
+
+ } while ( next != best_point );
+
+ if ( AF_LATIN_IS_LONG_BLUE( bs ) )
{
+ /* If this flag is set, we have an additional constraint to */
+ /* get the blue zone distance: Find a segment of the topmost */
+ /* (or bottommost) contour that is longer than a heuristic */
+ /* threshold. This ensures that small bumps in the outline */
+ /* are ignored (for example, the `vertical serifs' found in */
+ /* many Hebrew glyph designs). */
+
+ /* If this segment is long enough, we are done. Otherwise, */
+ /* search the segment next to the extremum that is long */
+ /* enough, has the same direction, and a not too large */
+ /* vertical distance from the extremum. Note that the */
+ /* algorithm doesn't check whether the found segment is */
+ /* actually the one (vertically) nearest to the extremum. */
+
/* heuristic threshold value */
- FT_Pos height_threshold = metrics->units_per_em / 4;
+ FT_Pos length_threshold = metrics->units_per_em / 25;
- FT_Int first;
- FT_Int last;
- FT_Bool hit;
- /* we intentionally declare these two variables */
- /* outside of the loop since various compilers emit */
- /* incorrect warning messages otherwise, talking about */
- /* `possibly uninitialized variables' */
- FT_Int p_first = 0; /* make compiler happy */
- FT_Int p_last = 0;
+ dist = FT_ABS( points[best_segment_last].x -
+ points[best_segment_first].x );
- FT_Bool left2right;
+ if ( dist < length_threshold &&
+ best_segment_last - best_segment_first + 2 <=
+ best_contour_last - best_contour_first )
+ {
+ /* heuristic threshold value */
+ FT_Pos height_threshold = metrics->units_per_em / 4;
+ FT_Int first;
+ FT_Int last;
+ FT_Bool hit;
- /* compute direction */
- prev = best_point;
+ /* we intentionally declare these two variables */
+ /* outside of the loop since various compilers emit */
+ /* incorrect warning messages otherwise, talking about */
+ /* `possibly uninitialized variables' */
+ FT_Int p_first = 0; /* make compiler happy */
+ FT_Int p_last = 0;
- do
- {
- if ( prev > best_contour_first )
- prev--;
- else
- prev = best_contour_last;
+ FT_Bool left2right;
- if ( points[prev].x != best_x )
- break;
- } while ( prev != best_point );
+ /* compute direction */
+ prev = best_point;
- /* skip glyph for the degenerate case */
- if ( prev == best_point )
- continue;
+ do
+ {
+ if ( prev > best_contour_first )
+ prev--;
+ else
+ prev = best_contour_last;
- left2right = FT_BOOL( points[prev].x < points[best_point].x );
+ if ( points[prev].x != best_x )
+ break;
- first = best_segment_last;
- last = first;
- hit = 0;
+ } while ( prev != best_point );
- do
- {
- FT_Bool l2r;
- FT_Pos d;
+ /* skip glyph for the degenerate case */
+ if ( prev == best_point )
+ continue;
+
+ left2right = FT_BOOL( points[prev].x < points[best_point].x );
+ first = best_segment_last;
+ last = first;
+ hit = 0;
- if ( !hit )
+ do
{
- /* no hit; adjust first point */
- first = last;
+ FT_Bool l2r;
+ FT_Pos d;
- /* also adjust first and last on point */
- if ( FT_CURVE_TAG( outline.tags[first] ) ==
- FT_CURVE_TAG_ON )
- {
- p_first = first;
- p_last = first;
- }
- else
+
+ if ( !hit )
{
- p_first = -1;
- p_last = -1;
- }
+ /* no hit; adjust first point */
+ first = last;
- hit = 1;
- }
+ /* also adjust first and last on point */
+ if ( FT_CURVE_TAG( outline.tags[first] ) ==
+ FT_CURVE_TAG_ON )
+ {
+ p_first = first;
+ p_last = first;
+ }
+ else
+ {
+ p_first = -1;
+ p_last = -1;
+ }
- if ( last < best_contour_last )
- last++;
- else
- last = best_contour_first;
+ hit = 1;
+ }
- if ( FT_ABS( best_y - points[first].y ) > height_threshold )
- {
- /* vertical distance too large */
- hit = 0;
- continue;
- }
+ if ( last < best_contour_last )
+ last++;
+ else
+ last = best_contour_first;
- /* same test as above */
- dist = FT_ABS( points[last].y - points[first].y );
- if ( dist > 5 )
- if ( FT_ABS( points[last].x - points[first].x ) <=
- 20 * dist )
+ if ( FT_ABS( best_y - points[first].y ) > height_threshold )
{
+ /* vertical distance too large */
hit = 0;
continue;
}
- if ( FT_CURVE_TAG( outline.tags[last] ) == FT_CURVE_TAG_ON )
- {
- p_last = last;
- if ( p_first < 0 )
- p_first = last;
- }
+ /* same test as above */
+ dist = FT_ABS( points[last].y - points[first].y );
+ if ( dist > 5 )
+ if ( FT_ABS( points[last].x - points[first].x ) <=
+ 20 * dist )
+ {
+ hit = 0;
+ continue;
+ }
- l2r = FT_BOOL( points[first].x < points[last].x );
- d = FT_ABS( points[last].x - points[first].x );
+ if ( FT_CURVE_TAG( outline.tags[last] ) == FT_CURVE_TAG_ON )
+ {
+ p_last = last;
+ if ( p_first < 0 )
+ p_first = last;
+ }
- if ( l2r == left2right &&
- d >= length_threshold )
- {
- /* all constraints are met; update segment after finding */
- /* its end */
- do
+ l2r = FT_BOOL( points[first].x < points[last].x );
+ d = FT_ABS( points[last].x - points[first].x );
+
+ if ( l2r == left2right &&
+ d >= length_threshold )
{
- if ( last < best_contour_last )
- last++;
- else
- last = best_contour_first;
+ /* all constraints are met; update segment after */
+ /* finding its end */
+ do
+ {
+ if ( last < best_contour_last )
+ last++;
+ else
+ last = best_contour_first;
+
+ d = FT_ABS( points[last].y - points[first].y );
+ if ( d > 5 )
+ if ( FT_ABS( points[next].x - points[first].x ) <=
+ 20 * dist )
+ {
+ if ( last > best_contour_first )
+ last--;
+ else
+ last = best_contour_last;
+ break;
+ }
- d = FT_ABS( points[last].y - points[first].y );
- if ( d > 5 )
- if ( FT_ABS( points[next].x - points[first].x ) <=
- 20 * dist )
+ p_last = last;
+
+ if ( FT_CURVE_TAG( outline.tags[last] ) ==
+ FT_CURVE_TAG_ON )
{
- if ( last > best_contour_first )
- last--;
- else
- last = best_contour_last;
- break;
+ p_last = last;
+ if ( p_first < 0 )
+ p_first = last;
}
- p_last = last;
+ } while ( last != best_segment_first );
- if ( FT_CURVE_TAG( outline.tags[last] ) ==
- FT_CURVE_TAG_ON )
- {
- p_last = last;
- if ( p_first < 0 )
- p_first = last;
- }
+ best_y = points[first].y;
- } while ( last != best_segment_first );
+ best_segment_first = first;
+ best_segment_last = last;
- best_y = points[first].y;
+ best_on_point_first = p_first;
+ best_on_point_last = p_last;
- best_segment_first = first;
- best_segment_last = last;
+ break;
+ }
- best_on_point_first = p_first;
- best_on_point_last = p_last;
+ } while ( last != best_segment_first );
+ }
+ }
- break;
- }
+ /* for computing blue zones, we add the y offset as returned */
+ /* by the currently used OpenType feature -- for example, */
+ /* superscript glyphs might be identical to subscript glyphs */
+ /* with a vertical shift */
+ best_y += y_offset;
- } while ( last != best_segment_first );
+#ifdef FT_DEBUG_LEVEL_TRACE
+ if ( num_idx == 1 )
+ FT_TRACE5(( " U+%04lX: best_y = %5ld", ch, best_y ));
+ else
+ FT_TRACE5(( " component %d of cluster starting with U+%04lX:"
+ " best_y = %5ld", i, ch, best_y ));
+#endif
+
+ /* now set the `round' flag depending on the segment's kind: */
+ /* */
+ /* - if the horizontal distance between the first and last */
+ /* `on' point is larger than a heuristic threshold */
+ /* we have a flat segment */
+ /* - if either the first or the last point of the segment is */
+ /* an `off' point, the segment is round, otherwise it is */
+ /* flat */
+ if ( best_on_point_first >= 0 &&
+ best_on_point_last >= 0 &&
+ ( FT_ABS( points[best_on_point_last].x -
+ points[best_on_point_first].x ) ) >
+ flat_threshold )
+ round = 0;
+ else
+ round = FT_BOOL(
+ FT_CURVE_TAG( outline.tags[best_segment_first] ) !=
+ FT_CURVE_TAG_ON ||
+ FT_CURVE_TAG( outline.tags[best_segment_last] ) !=
+ FT_CURVE_TAG_ON );
+
+ if ( round && AF_LATIN_IS_NEUTRAL_BLUE( bs ) )
+ {
+ /* only use flat segments for a neutral blue zone */
+ FT_TRACE5(( " (round, skipped)\n" ));
+ continue;
}
+
+ FT_TRACE5(( " (%s)\n", round ? "round" : "flat" ));
}
- /* for computing blue zones, we add the y offset as returned */
- /* by the currently used OpenType feature -- for example, */
- /* superscript glyphs might be identical to subscript glyphs */
- /* with a vertical shift */
- best_y += y_offset;
-
- FT_TRACE5(( " U+%04lX: best_y = %5ld", ch, best_y ));
-
- /* now set the `round' flag depending on the segment's kind: */
- /* */
- /* - if the horizontal distance between the first and last */
- /* `on' point is larger than a heuristic threshold */
- /* we have a flat segment */
- /* - if either the first or the last point of the segment is */
- /* an `off' point, the segment is round, otherwise it is */
- /* flat */
- if ( best_on_point_first >= 0 &&
- best_on_point_last >= 0 &&
- ( FT_ABS( points[best_on_point_last].x -
- points[best_on_point_first].x ) ) >
- flat_threshold )
- round = 0;
+ if ( AF_LATIN_IS_TOP_BLUE( bs ) )
+ {
+ if ( best_y > best_y_extremum )
+ {
+ best_y_extremum = best_y;
+ best_round = round;
+ }
+ }
else
- round = FT_BOOL(
- FT_CURVE_TAG( outline.tags[best_segment_first] ) !=
- FT_CURVE_TAG_ON ||
- FT_CURVE_TAG( outline.tags[best_segment_last] ) !=
- FT_CURVE_TAG_ON );
-
- if ( round && AF_LATIN_IS_NEUTRAL_BLUE( bs ) )
{
- /* only use flat segments for a neutral blue zone */
- FT_TRACE5(( " (round, skipped)\n" ));
- continue;
+ if ( best_y < best_y_extremum )
+ {
+ best_y_extremum = best_y;
+ best_round = round;
+ }
}
- FT_TRACE5(( " (%s)\n", round ? "round" : "flat" ));
+ } /* end for loop */
+
+ if ( !( best_y_extremum == FT_INT_MIN ||
+ best_y_extremum == FT_INT_MAX ) )
+ {
+ if ( best_round )
+ rounds[num_rounds++] = best_y_extremum;
+ else
+ flats[num_flats++] = best_y_extremum;
}
- if ( round )
- rounds[num_rounds++] = best_y;
- else
- flats[num_flats++] = best_y;
- }
+ } /* end while loop */
if ( num_flats == 0 && num_rounds == 0 )
{
@@ -781,7 +929,8 @@
FT_Bool over_ref = FT_BOOL( shoot > ref );
- if ( AF_LATIN_IS_TOP_BLUE( bs ) ^ over_ref )
+ if ( ( AF_LATIN_IS_TOP_BLUE( bs ) ||
+ AF_LATIN_IS_SUB_TOP_BLUE( bs) ) ^ over_ref )
{
*blue_ref =
*blue_shoot = ( shoot + ref ) / 2;
@@ -791,9 +940,14 @@
}
}
+ blue->ascender = ascender;
+ blue->descender = descender;
+
blue->flags = 0;
if ( AF_LATIN_IS_TOP_BLUE( bs ) )
blue->flags |= AF_LATIN_BLUE_TOP;
+ if ( AF_LATIN_IS_SUB_TOP_BLUE( bs ) )
+ blue->flags |= AF_LATIN_BLUE_SUB_TOP;
if ( AF_LATIN_IS_NEUTRAL_BLUE( bs ) )
blue->flags |= AF_LATIN_BLUE_NEUTRAL;
@@ -808,6 +962,63 @@
FT_TRACE5(( " -> reference = %ld\n"
" overshoot = %ld\n",
*blue_ref, *blue_shoot ));
+
+ } /* end for loop */
+
+ 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" ));
@@ -822,27 +1033,36 @@
af_latin_metrics_check_digits( AF_LatinMetrics metrics,
FT_Face face )
{
- FT_UInt i;
FT_Bool started = 0, same_width = 1;
- FT_Fixed advance, old_advance = 0;
+ FT_Fixed advance = 0, old_advance = 0;
+
+ void* shaper_buf;
+
+ /* in all supported charmaps, digits have character codes 0x30-0x39 */
+ const char digits[] = "0 1 2 3 4 5 6 7 8 9";
+ const char* p;
- /* digit `0' is 0x30 in all supported charmaps */
- for ( i = 0x30; i <= 0x39; i++ )
+ p = digits;
+ shaper_buf = af_shaper_buf_create( face );
+
+ while ( *p )
{
- FT_ULong glyph_index;
- FT_Long y_offset;
+ FT_ULong glyph_index;
+ unsigned int num_idx;
- af_get_char_index( &metrics->root, i, &glyph_index, &y_offset );
- if ( glyph_index == 0 )
+ /* reject input that maps to more than a single glyph */
+ p = af_shaper_get_cluster( p, &metrics->root, shaper_buf, &num_idx );
+ if ( num_idx > 1 )
continue;
- if ( FT_Get_Advance( face, glyph_index,
- FT_LOAD_NO_SCALE |
- FT_LOAD_NO_HINTING |
- FT_LOAD_IGNORE_TRANSFORM,
- &advance ) )
+ glyph_index = af_shaper_get_elem( &metrics->root,
+ shaper_buf,
+ 0,
+ &advance,
+ NULL );
+ if ( !glyph_index )
continue;
if ( started )
@@ -860,6 +1080,8 @@
}
}
+ af_shaper_buf_destroy( face, shaper_buf );
+
metrics->root.digits_have_same_width = same_width;
}
@@ -947,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;
@@ -973,18 +1195,52 @@
#endif
if ( dim == AF_DIMENSION_VERT )
{
- scale = FT_MulDiv( scale, fitted, scaled );
-
- FT_TRACE5((
- "af_latin_metrics_scale_dim:"
- " x height alignment (style `%s'):\n"
- " "
- " vertical scaling changed from %.4f to %.4f (by %d%%)\n"
- "\n",
- af_style_names[metrics->root.style_class->style],
- axis->org_scale / 65536.0,
- scale / 65536.0,
- ( fitted - scaled ) * 100 / scaled ));
+ FT_Pos max_height;
+ FT_Pos dist;
+ FT_Fixed new_scale;
+
+
+ new_scale = FT_MulDiv( scale, fitted, scaled );
+
+ /* the scaling should not change the result by more than two pixels */
+ max_height = metrics->units_per_em;
+
+ for ( nn = 0; nn < Axis->blue_count; nn++ )
+ {
+ max_height = FT_MAX( max_height, Axis->blues[nn].ascender );
+ max_height = FT_MAX( max_height, -Axis->blues[nn].descender );
+ }
+
+ dist = FT_ABS( FT_MulFix( max_height, new_scale - scale ) );
+ dist &= ~127;
+
+ if ( dist == 0 )
+ {
+ FT_TRACE5((
+ "af_latin_metrics_scale_dim:"
+ " x height alignment (style `%s'):\n"
+ " "
+ " vertical scaling changed from %.5f to %.5f (by %d%%)\n"
+ "\n",
+ af_style_names[metrics->root.style_class->style],
+ scale / 65536.0,
+ new_scale / 65536.0,
+ ( fitted - scaled ) * 100 / scaled ));
+
+ scale = new_scale;
+ }
+#ifdef FT_DEBUG_LEVEL_TRACE
+ else
+ {
+ FT_TRACE5((
+ "af_latin_metrics_scale_dim:"
+ " x height alignment (style `%s'):\n"
+ " "
+ " excessive vertical scaling abandoned\n"
+ "\n",
+ af_style_names[metrics->root.style_class->style] ));
+ }
+#endif
}
}
}
@@ -1115,21 +1371,63 @@
#endif
blue->flags |= AF_LATIN_BLUE_ACTIVE;
+ }
+ }
+
+ /* use sub-top blue zone only if it doesn't overlap with */
+ /* another (non-sup-top) blue zone; otherwise, the */
+ /* effect would be similar to a neutral blue zone, which */
+ /* is not desired here */
+ for ( nn = 0; nn < axis->blue_count; nn++ )
+ {
+ AF_LatinBlue blue = &axis->blues[nn];
+ FT_UInt i;
+
+
+ if ( !( blue->flags & AF_LATIN_BLUE_SUB_TOP ) )
+ continue;
+ if ( !( blue->flags & AF_LATIN_BLUE_ACTIVE ) )
+ continue;
+
+ for ( i = 0; i < axis->blue_count; i++ )
+ {
+ AF_LatinBlue b = &axis->blues[i];
- FT_TRACE5(( " reference %d: %d scaled to %.2f%s\n"
- " overshoot %d: %d scaled to %.2f%s\n",
- nn,
- blue->ref.org,
- blue->ref.fit / 64.0,
- blue->flags & AF_LATIN_BLUE_ACTIVE ? ""
- : " (inactive)",
- nn,
- blue->shoot.org,
- blue->shoot.fit / 64.0,
- blue->flags & AF_LATIN_BLUE_ACTIVE ? ""
- : " (inactive)" ));
+
+ if ( b->flags & AF_LATIN_BLUE_SUB_TOP )
+ continue;
+ if ( !( b->flags & AF_LATIN_BLUE_ACTIVE ) )
+ continue;
+
+ if ( b->ref.fit <= blue->shoot.fit &&
+ b->shoot.fit >= blue->ref.fit )
+ {
+ blue->flags &= ~AF_LATIN_BLUE_ACTIVE;
+ break;
+ }
}
}
+
+#ifdef FT_DEBUG_LEVEL_TRACE
+ for ( nn = 0; nn < axis->blue_count; nn++ )
+ {
+ AF_LatinBlue blue = &axis->blues[nn];
+
+
+ FT_TRACE5(( " reference %d: %d scaled to %.2f%s\n"
+ " overshoot %d: %d scaled to %.2f%s\n",
+ nn,
+ blue->ref.org,
+ blue->ref.fit / 64.0,
+ blue->flags & AF_LATIN_BLUE_ACTIVE ? ""
+ : " (inactive)",
+ nn,
+ blue->shoot.org,
+ blue->shoot.fit / 64.0,
+ blue->flags & AF_LATIN_BLUE_ACTIVE ? ""
+ : " (inactive)" ));
+ }
+#endif
}
}
@@ -1149,6 +1447,22 @@
}
+ /* Extract standard_width from writing system/script specific */
+ /* metrics class. */
+
+ FT_LOCAL_DEF( void )
+ af_latin_get_standard_widths( AF_LatinMetrics metrics,
+ FT_Pos* stdHW,
+ FT_Pos* stdVW )
+ {
+ if ( stdHW )
+ *stdHW = metrics->axis[AF_DIMENSION_VERT].standard_width;
+
+ if ( stdVW )
+ *stdVW = metrics->axis[AF_DIMENSION_HORZ].standard_width;
+ }
+
+
/*************************************************************************/
/*************************************************************************/
/***** *****/
@@ -1215,19 +1529,36 @@
/* do each contour separately */
for ( ; contour < contour_limit; contour++ )
{
- AF_Point point = contour[0];
- AF_Point last = point->prev;
- int on_edge = 0;
- FT_Pos min_pos = 32000; /* minimum segment pos != min_coord */
- FT_Pos max_pos = -32000; /* maximum segment pos != max_coord */
- FT_Pos min_on_pos = 32000;
- FT_Pos max_on_pos = -32000;
- FT_Bool passed;
+ AF_Point point = contour[0];
+ AF_Point last = point->prev;
+ int on_edge = 0;
+
+ /* we call values measured along a segment (point->v) */
+ /* `coordinates', and values orthogonal to it (point->u) */
+ /* `positions' */
+ FT_Pos min_pos = 32000;
+ FT_Pos max_pos = -32000;
+ FT_Pos min_coord = 32000;
+ FT_Pos max_coord = -32000;
+ FT_UShort min_flags = AF_FLAG_NONE;
+ FT_UShort max_flags = AF_FLAG_NONE;
+ FT_Pos min_on_coord = 32000;
+ FT_Pos max_on_coord = -32000;
+
+ FT_Bool passed;
+
+ AF_Segment prev_segment = NULL;
+
+ FT_Pos prev_min_pos = min_pos;
+ FT_Pos prev_max_pos = max_pos;
+ FT_Pos prev_min_coord = min_coord;
+ FT_Pos prev_max_coord = max_coord;
+ FT_UShort prev_min_flags = min_flags;
+ FT_UShort prev_max_flags = max_flags;
+ FT_Pos prev_min_on_coord = min_on_coord;
+ FT_Pos prev_max_on_coord = max_on_coord;
- if ( point == last ) /* skip singletons -- just in case */
- continue;
-
if ( FT_ABS( last->out_dir ) == major_dir &&
FT_ABS( point->out_dir ) == major_dir )
{
@@ -1257,51 +1588,187 @@
if ( on_edge )
{
+ /* get minimum and maximum position */
u = point->u;
if ( u < min_pos )
min_pos = u;
if ( u > max_pos )
max_pos = u;
- /* get minimum and maximum coordinate of on points */
+ /* get minimum and maximum coordinate together with flags */
+ v = point->v;
+ if ( v < min_coord )
+ {
+ min_coord = v;
+ min_flags = point->flags;
+ }
+ if ( v > max_coord )
+ {
+ max_coord = v;
+ max_flags = point->flags;
+ }
+
+ /* get minimum and maximum coordinate of `on' points */
if ( !( point->flags & AF_FLAG_CONTROL ) )
{
v = point->v;
- if ( v < min_on_pos )
- min_on_pos = v;
- if ( v > max_on_pos )
- max_on_pos = v;
+ if ( v < min_on_coord )
+ min_on_coord = v;
+ if ( v > max_on_coord )
+ max_on_coord = v;
}
if ( point->out_dir != segment_dir || point == last )
{
- /* we are just leaving an edge; record a new segment! */
- segment->last = point;
- segment->pos = (FT_Short)( ( min_pos + max_pos ) >> 1 );
-
- /* a segment is round if either its first or last point */
- /* is a control point, and the length of the on points */
- /* inbetween doesn't exceed a heuristic limit */
- if ( ( segment->first->flags | point->flags ) & AF_FLAG_CONTROL &&
- ( max_on_pos - min_on_pos ) < flat_threshold )
- segment->flags |= AF_EDGE_ROUND;
+ /* check whether the new segment's start point is identical to */
+ /* the previous segment's end point; for example, this might */
+ /* happen for spikes */
+
+ if ( !prev_segment || segment->first != prev_segment->last )
+ {
+ /* 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->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 */
+ /* inbetween doesn't exceed a heuristic limit */
+ if ( ( min_flags | max_flags ) & AF_FLAG_CONTROL &&
+ ( max_on_coord - min_on_coord ) < flat_threshold )
+ segment->flags |= AF_EDGE_ROUND;
+
+ segment->min_coord = (FT_Short)min_coord;
+ segment->max_coord = (FT_Short)max_coord;
+ segment->height = segment->max_coord - segment->min_coord;
+
+ prev_segment = segment;
+ prev_min_pos = min_pos;
+ prev_max_pos = max_pos;
+ prev_min_coord = min_coord;
+ prev_max_coord = max_coord;
+ prev_min_flags = min_flags;
+ prev_max_flags = max_flags;
+ prev_min_on_coord = min_on_coord;
+ prev_max_on_coord = max_on_coord;
+ }
+ else
+ {
+ /* points are the same: we don't create a new segment but */
+ /* merge the current segment with the previous one */
+
+ if ( prev_segment->last->in_dir == point->in_dir )
+ {
+ /* we have identical directions (this can happen for */
+ /* degenerate outlines that move zig-zag along the main */
+ /* axis without changing the coordinate value of the other */
+ /* axis, and where the segments have just been merged): */
+ /* unify segments */
+
+ /* update constraints */
- /* compute segment size */
- min_pos = max_pos = point->v;
+ if ( prev_min_pos < min_pos )
+ min_pos = prev_min_pos;
+ if ( prev_max_pos > max_pos )
+ max_pos = prev_max_pos;
- v = segment->first->v;
- if ( v < min_pos )
- min_pos = v;
- if ( v > max_pos )
- max_pos = v;
+ if ( prev_min_coord < min_coord )
+ {
+ min_coord = prev_min_coord;
+ min_flags = prev_min_flags;
+ }
+ if ( prev_max_coord > max_coord )
+ {
+ max_coord = prev_max_coord;
+ max_flags = prev_max_flags;
+ }
+
+ if ( prev_min_on_coord < min_on_coord )
+ min_on_coord = prev_min_on_coord;
+ if ( prev_max_on_coord > max_on_coord )
+ max_on_coord = prev_max_on_coord;
+
+ prev_segment->last = point;
+ prev_segment->pos = (FT_Short)( ( min_pos +
+ max_pos ) >> 1 );
+ prev_segment->delta = (FT_Short)( ( max_pos -
+ min_pos ) >> 1 );
+
+ if ( ( min_flags | max_flags ) & AF_FLAG_CONTROL &&
+ ( max_on_coord - min_on_coord ) < flat_threshold )
+ prev_segment->flags |= AF_EDGE_ROUND;
+ else
+ prev_segment->flags &= ~AF_EDGE_ROUND;
- segment->min_coord = (FT_Short)min_pos;
- segment->max_coord = (FT_Short)max_pos;
- segment->height = (FT_Short)( segment->max_coord -
- segment->min_coord );
+ prev_segment->min_coord = (FT_Short)min_coord;
+ prev_segment->max_coord = (FT_Short)max_coord;
+ prev_segment->height = prev_segment->max_coord -
+ prev_segment->min_coord;
+ }
+ else
+ {
+ /* we have different directions; use the properties of the */
+ /* longer segment and discard the other one */
+
+ if ( FT_ABS( prev_max_coord - prev_min_coord ) >
+ FT_ABS( max_coord - min_coord ) )
+ {
+ /* discard current segment */
+
+ if ( min_pos < prev_min_pos )
+ prev_min_pos = min_pos;
+ if ( max_pos > prev_max_pos )
+ prev_max_pos = max_pos;
+
+ prev_segment->last = point;
+ prev_segment->pos = (FT_Short)( ( prev_min_pos +
+ prev_max_pos ) >> 1 );
+ prev_segment->delta = (FT_Short)( ( prev_max_pos -
+ prev_min_pos ) >> 1 );
+ }
+ else
+ {
+ /* discard previous segment */
+
+ if ( prev_min_pos < min_pos )
+ min_pos = prev_min_pos;
+ if ( prev_max_pos > max_pos )
+ max_pos = prev_max_pos;
+
+ segment->last = point;
+ segment->pos = (FT_Short)( ( min_pos + max_pos ) >> 1 );
+ segment->delta = (FT_Short)( ( max_pos - min_pos ) >> 1 );
+
+ if ( ( min_flags | max_flags ) & AF_FLAG_CONTROL &&
+ ( max_on_coord - min_on_coord ) < flat_threshold )
+ segment->flags |= AF_EDGE_ROUND;
+
+ segment->min_coord = (FT_Short)min_coord;
+ segment->max_coord = (FT_Short)max_coord;
+ segment->height = segment->max_coord -
+ segment->min_coord;
+
+ *prev_segment = *segment;
+
+ prev_min_pos = min_pos;
+ prev_max_pos = max_pos;
+ prev_min_coord = min_coord;
+ prev_max_coord = max_coord;
+ prev_min_flags = min_flags;
+ prev_max_flags = max_flags;
+ prev_min_on_coord = min_on_coord;
+ prev_max_on_coord = max_on_coord;
+ }
+ }
+
+ axis->num_segments--;
+ }
on_edge = 0;
segment = NULL;
+
/* fall through */
}
}
@@ -1314,7 +1781,12 @@
passed = 1;
}
- if ( !on_edge && FT_ABS( point->out_dir ) == major_dir )
+ /* if we are not on an edge, check whether the major direction */
+ /* coincides with the current point's `out' direction, or */
+ /* whether we have a single-point contour */
+ if ( !on_edge &&
+ ( FT_ABS( point->out_dir ) == major_dir ||
+ point == point->prev ) )
{
/* this is the start of a new segment! */
segment_dir = (AF_Direction)point->out_dir;
@@ -1330,17 +1802,42 @@
segment->first = point;
segment->last = point;
- min_pos = max_pos = point->u;
+ /* `af_axis_hints_new_segment' reallocates memory, */
+ /* thus we have to refresh the `prev_segment' pointer */
+ if ( prev_segment )
+ prev_segment = segment - 1;
+
+ min_pos = max_pos = point->u;
+ min_coord = max_coord = point->v;
+ min_flags = max_flags = point->flags;
if ( point->flags & AF_FLAG_CONTROL )
{
- min_on_pos = 32000;
- max_on_pos = -32000;
+ min_on_coord = 32000;
+ max_on_coord = -32000;
}
else
- min_on_pos = max_on_pos = point->v;
+ min_on_coord = max_on_coord = point->v;
on_edge = 1;
+
+ if ( point == point->prev )
+ {
+ /* we have a one-point segment: this is a one-point */
+ /* contour with `in' and `out' direction set to */
+ /* AF_DIR_NONE */
+ segment->pos = (FT_Short)min_pos;
+
+ if (point->flags & AF_FLAG_CONTROL)
+ segment->flags |= AF_EDGE_ROUND;
+
+ segment->min_coord = (FT_Short)point->v;
+ segment->max_coord = (FT_Short)point->v;
+ segment->height = 0;
+
+ on_edge = 0;
+ segment = NULL;
+ }
}
point = point->next;
@@ -1552,6 +2049,16 @@
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];
+
+ FT_Bool top_to_bottom_hinting = 0;
+
AF_Segment segments = axis->segments;
AF_Segment segment_limit = segments + axis->num_segments;
AF_Segment seg;
@@ -1562,6 +2069,7 @@
FT_Fixed scale;
FT_Pos edge_distance_threshold;
FT_Pos segment_length_threshold;
+ FT_Pos segment_width_threshold;
axis->num_edges = 0;
@@ -1574,15 +2082,24 @@
: AF_DIR_RIGHT;
#endif
+ if ( dim == AF_DIMENSION_VERT )
+ top_to_bottom_hinting = script_class->top_to_bottom_hinting;
+
/*
* We ignore all segments that are less than 1 pixel in length
* to avoid many problems with serif fonts. We compute the
* 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 );
/*********************************************************************/
/* */
@@ -1615,7 +2132,11 @@
FT_Int ee;
- if ( seg->height < segment_length_threshold )
+ /* 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;
/* A special case for serif edges: If they are smaller than */
@@ -1651,6 +2172,7 @@
/* sort according to the position */
error = af_axis_hints_new_edge( axis, seg->pos,
(AF_Direction)seg->dir,
+ top_to_bottom_hinting,
memory, &edge );
if ( error )
goto Exit;
@@ -1676,6 +2198,44 @@
}
}
+ /* we loop again over all segments to catch one-point segments */
+ /* without a direction: if possible, link them to existing edges */
+ for ( seg = segments; seg < segment_limit; seg++ )
+ {
+ AF_Edge found = NULL;
+ FT_Int ee;
+
+
+ if ( seg->dir != AF_DIR_NONE )
+ continue;
+
+ /* look for an edge corresponding to the segment */
+ for ( ee = 0; ee < axis->num_edges; ee++ )
+ {
+ AF_Edge edge = axis->edges + ee;
+ FT_Pos dist;
+
+
+ dist = seg->pos - edge->fpos;
+ if ( dist < 0 )
+ dist = -dist;
+
+ if ( dist < edge_distance_threshold )
+ {
+ found = edge;
+ break;
+ }
+ }
+
+ /* one-point segments without a match are ignored */
+ if ( found )
+ {
+ seg->edge_next = found->first;
+ found->last->edge_next = seg;
+ found->last = seg;
+ }
+ }
+
/******************************************************************/
/* */
@@ -1753,7 +2313,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;
@@ -1906,7 +2466,8 @@
/* the major direction) -- this assumes the TrueType convention */
/* for the orientation of contours */
is_top_blue =
- (FT_Byte)( ( blue->flags & AF_LATIN_BLUE_TOP ) != 0 );
+ (FT_Byte)( ( blue->flags & ( AF_LATIN_BLUE_TOP |
+ AF_LATIN_BLUE_SUB_TOP ) ) != 0 );
is_neutral_blue =
(FT_Byte)( ( blue->flags & AF_LATIN_BLUE_NEUTRAL ) != 0);
is_major_dir =
@@ -2019,23 +2580,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
@@ -2115,6 +2676,7 @@
af_latin_compute_stem_width( AF_GlyphHints hints,
AF_Dimension dim,
FT_Pos width,
+ FT_Pos base_delta,
FT_UInt base_flags,
FT_UInt stem_flags )
{
@@ -2192,7 +2754,39 @@
dist += delta;
}
else
- dist = ( dist + 32 ) & ~63;
+ {
+ /* A stem's end position depends on two values: the start */
+ /* position and the stem length. The former gets usually */
+ /* rounded to the grid, while the latter gets rounded also if it */
+ /* exceeds a certain length (see below in this function). This */
+ /* `double rounding' can lead to a great difference to the */
+ /* original, unhinted position; this normally doesn't matter for */
+ /* large PPEM values, but for small sizes it can easily make */
+ /* outlines collide. For this reason, we adjust the stem length */
+ /* by a small amount depending on the PPEM value in case the */
+ /* former and latter rounding both point into the same */
+ /* direction. */
+
+ FT_Pos bdelta = 0;
+
+
+ if ( ( ( width > 0 ) && ( base_delta > 0 ) ) ||
+ ( ( width < 0 ) && ( base_delta < 0 ) ) )
+ {
+ FT_UInt ppem = metrics->root.scaler.face->size->metrics.x_ppem;
+
+
+ if ( ppem < 10 )
+ bdelta = base_delta;
+ else if ( ppem < 30 )
+ bdelta = ( base_delta * (FT_Pos)( 30 - ppem ) ) / 20;
+
+ if ( bdelta < 0 )
+ bdelta = -bdelta;
+ }
+
+ dist = ( dist - bdelta + 32 ) & ~63;
+ }
}
}
else
@@ -2281,11 +2875,17 @@
AF_Edge base_edge,
AF_Edge stem_edge )
{
- FT_Pos dist = stem_edge->opos - base_edge->opos;
+ FT_Pos dist, base_delta;
+ FT_Pos fitted_width;
+
+
+ dist = stem_edge->opos - base_edge->opos;
+ base_delta = base_edge->pos - base_edge->opos;
- FT_Pos fitted_width = af_latin_compute_stem_width( hints, dim, dist,
- base_edge->flags,
- stem_edge->flags );
+ fitted_width = af_latin_compute_stem_width( hints, dim,
+ dist, base_delta,
+ base_edge->flags,
+ stem_edge->flags );
stem_edge->pos = base_edge->pos + fitted_width;
@@ -2336,8 +2936,18 @@
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];
+
+ FT_Bool top_to_bottom_hinting = 0;
+
#ifdef FT_DEBUG_LEVEL_TRACE
- FT_UInt num_actions = 0;
+ FT_UInt num_actions = 0;
#endif
@@ -2345,6 +2955,9 @@
dim == AF_DIMENSION_VERT ? "horizontal" : "vertical",
af_style_names[hints->metrics->style_class->style] ));
+ if ( dim == AF_DIMENSION_VERT )
+ top_to_bottom_hinting = script_class->top_to_bottom_hinting;
+
/* we begin by aligning all stems relative to the blue zone */
/* if needed -- that's only for horizontal edges */
@@ -2480,7 +3093,8 @@
org_len = edge2->opos - edge->opos;
- cur_len = af_latin_compute_stem_width( hints, dim, org_len,
+ cur_len = af_latin_compute_stem_width( hints, dim,
+ org_len, 0,
edge->flags,
edge2->flags );
@@ -2549,7 +3163,8 @@
org_len = edge2->opos - edge->opos;
org_center = org_pos + ( org_len >> 1 );
- cur_len = af_latin_compute_stem_width( hints, dim, org_len,
+ cur_len = af_latin_compute_stem_width( hints, dim,
+ org_len, 0,
edge->flags,
edge2->flags );
@@ -2609,7 +3224,8 @@
org_len = edge2->opos - edge->opos;
org_center = org_pos + ( org_len >> 1 );
- cur_len = af_latin_compute_stem_width( hints, dim, org_len,
+ cur_len = af_latin_compute_stem_width( hints, dim,
+ org_len, 0,
edge->flags,
edge2->flags );
@@ -2640,16 +3256,25 @@
edge->flags |= AF_EDGE_DONE;
edge2->flags |= AF_EDGE_DONE;
- if ( edge > edges && edge->pos < edge[-1].pos )
+ if ( edge > edges &&
+ ( top_to_bottom_hinting ? ( edge->pos > edge[-1].pos )
+ : ( edge->pos < edge[-1].pos ) ) )
{
+ /* don't move if stem would (almost) disappear otherwise; */
+ /* the ad-hoc value 16 corresponds to 1/4px */
+ if ( edge->link && FT_ABS( edge->link->pos - edge[-1].pos ) > 16 )
+ {
#ifdef FT_DEBUG_LEVEL_TRACE
- FT_TRACE5(( " BOUND: edge %d (pos=%.2f) moved to %.2f\n",
- edge - edges, edge->pos / 64.0, edge[-1].pos / 64.0 ));
+ FT_TRACE5(( " BOUND: edge %d (pos=%.2f) moved to %.2f\n",
+ edge - edges,
+ edge->pos / 64.0,
+ edge[-1].pos / 64.0 ));
- num_actions++;
+ num_actions++;
#endif
- edge->pos = edge[-1].pos;
+ edge->pos = edge[-1].pos;
+ }
}
}
}
@@ -2801,29 +3426,46 @@
#endif
edge->flags |= AF_EDGE_DONE;
- if ( edge > edges && edge->pos < edge[-1].pos )
+ if ( edge > edges &&
+ ( top_to_bottom_hinting ? ( edge->pos > edge[-1].pos )
+ : ( edge->pos < edge[-1].pos ) ) )
{
+ /* don't move if stem would (almost) disappear otherwise; */
+ /* the ad-hoc value 16 corresponds to 1/4px */
+ if ( edge->link && FT_ABS( edge->link->pos - edge[-1].pos ) > 16 )
+ {
#ifdef FT_DEBUG_LEVEL_TRACE
- FT_TRACE5(( " BOUND: edge %d (pos=%.2f) moved to %.2f\n",
- edge - edges, edge->pos / 64.0, edge[-1].pos / 64.0 ));
+ FT_TRACE5(( " BOUND: edge %d (pos=%.2f) moved to %.2f\n",
+ edge - edges,
+ edge->pos / 64.0,
+ edge[-1].pos / 64.0 ));
- num_actions++;
+ num_actions++;
#endif
- edge->pos = edge[-1].pos;
+ edge->pos = edge[-1].pos;
+ }
}
- if ( edge + 1 < edge_limit &&
- edge[1].flags & AF_EDGE_DONE &&
- edge->pos > edge[1].pos )
+ if ( edge + 1 < edge_limit &&
+ edge[1].flags & AF_EDGE_DONE &&
+ ( top_to_bottom_hinting ? ( edge->pos < edge[1].pos )
+ : ( edge->pos > edge[1].pos ) ) )
{
+ /* don't move if stem would (almost) disappear otherwise; */
+ /* the ad-hoc value 16 corresponds to 1/4px */
+ if ( edge->link && FT_ABS( edge->link->pos - edge[-1].pos ) > 16 )
+ {
#ifdef FT_DEBUG_LEVEL_TRACE
- FT_TRACE5(( " BOUND: edge %d (pos=%.2f) moved to %.2f\n",
- edge - edges, edge->pos / 64.0, edge[1].pos / 64.0 ));
+ FT_TRACE5(( " BOUND: edge %d (pos=%.2f) moved to %.2f\n",
+ edge - edges,
+ edge->pos / 64.0,
+ edge[1].pos / 64.0 ));
- num_actions++;
+ num_actions++;
#endif
- edge->pos = edge[1].pos;
+ edge->pos = edge[1].pos;
+ }
}
}
}
@@ -2855,13 +3497,7 @@
goto Exit;
/* analyze glyph outline */
-#ifdef AF_CONFIG_OPTION_USE_WARPER
- if ( ( metrics->root.scaler.render_mode == FT_RENDER_MODE_LIGHT &&
- AF_HINTS_DO_WARP( hints ) ) ||
- AF_HINTS_DO_HORIZONTAL( hints ) )
-#else
if ( AF_HINTS_DO_HORIZONTAL( hints ) )
-#endif
{
axis = &metrics->axis[AF_DIMENSION_HORZ];
error = af_latin_hints_detect_features( hints,
@@ -2891,9 +3527,9 @@
for ( dim = 0; dim < AF_DIMENSION_MAX; dim++ )
{
#ifdef AF_CONFIG_OPTION_USE_WARPER
- if ( dim == AF_DIMENSION_HORZ &&
- metrics->root.scaler.render_mode == FT_RENDER_MODE_LIGHT &&
- AF_HINTS_DO_WARP( hints ) )
+ if ( dim == AF_DIMENSION_HORZ &&
+ metrics->root.scaler.render_mode == FT_RENDER_MODE_NORMAL &&
+ AF_HINTS_DO_WARP( hints ) )
{
AF_WarperRec warper;
FT_Fixed scale;
@@ -2941,12 +3577,13 @@
sizeof ( AF_LatinMetricsRec ),
- (AF_WritingSystem_InitMetricsFunc) af_latin_metrics_init,
- (AF_WritingSystem_ScaleMetricsFunc)af_latin_metrics_scale,
- (AF_WritingSystem_DoneMetricsFunc) NULL,
+ (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/src/3rdparty/freetype/src/autofit/aflatin.h b/src/3rdparty/freetype/src/autofit/aflatin.h
index 6855492ca3..432cccce4e 100644
--- a/src/3rdparty/freetype/src/autofit/aflatin.h
+++ b/src/3rdparty/freetype/src/autofit/aflatin.h
@@ -5,7 +5,7 @@
/* Auto-fitter hinting routines for latin writing system */
/* (specification). */
/* */
-/* Copyright 2003-2015 by */
+/* Copyright 2003-2018 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -17,8 +17,8 @@
/***************************************************************************/
-#ifndef __AFLATIN_H__
-#define __AFLATIN_H__
+#ifndef AFLATIN_H_
+#define AFLATIN_H_
#include "afhints.h"
@@ -53,6 +53,8 @@ FT_BEGIN_HEADER
#define AF_LATIN_IS_TOP_BLUE( b ) \
( (b)->properties & AF_BLUE_PROPERTY_LATIN_TOP )
+#define AF_LATIN_IS_SUB_TOP_BLUE( b ) \
+ ( (b)->properties & AF_BLUE_PROPERTY_LATIN_SUB_TOP )
#define AF_LATIN_IS_NEUTRAL_BLUE( b ) \
( (b)->properties & AF_BLUE_PROPERTY_LATIN_NEUTRAL )
#define AF_LATIN_IS_X_HEIGHT_BLUE( b ) \
@@ -65,8 +67,10 @@ FT_BEGIN_HEADER
#define AF_LATIN_BLUE_ACTIVE ( 1U << 0 ) /* zone height is <= 3/4px */
#define AF_LATIN_BLUE_TOP ( 1U << 1 ) /* we have a top blue zone */
-#define AF_LATIN_BLUE_NEUTRAL ( 1U << 2 ) /* we have neutral blue zone */
-#define AF_LATIN_BLUE_ADJUSTMENT ( 1U << 3 ) /* used for scale adjustment */
+#define AF_LATIN_BLUE_SUB_TOP ( 1U << 2 ) /* we have a subscript top */
+ /* blue zone */
+#define AF_LATIN_BLUE_NEUTRAL ( 1U << 3 ) /* we have neutral blue zone */
+#define AF_LATIN_BLUE_ADJUSTMENT ( 1U << 4 ) /* used for scale adjustment */
/* optimization */
@@ -74,6 +78,8 @@ FT_BEGIN_HEADER
{
AF_WidthRec ref;
AF_WidthRec shoot;
+ FT_Pos ascender;
+ FT_Pos descender;
FT_UInt flags;
} AF_LatinBlueRec, *AF_LatinBlue;
@@ -182,7 +188,7 @@ FT_BEGIN_HEADER
FT_END_HEADER
-#endif /* __AFLATIN_H__ */
+#endif /* AFLATIN_H_ */
/* END */
diff --git a/src/3rdparty/freetype/src/autofit/aflatin2.c b/src/3rdparty/freetype/src/autofit/aflatin2.c
index 0380ffc04c..5c71378118 100644
--- a/src/3rdparty/freetype/src/autofit/aflatin2.c
+++ b/src/3rdparty/freetype/src/autofit/aflatin2.c
@@ -1,10 +1,15 @@
+/* ATTENTION: This file doesn't compile. It is only here as a reference */
+/* of an alternative latin hinting algorithm that was always */
+/* marked as experimental. */
+
+
/***************************************************************************/
/* */
/* aflatin2.c */
/* */
/* Auto-fitter hinting routines for latin writing system (body). */
/* */
-/* Copyright 2003-2015 by */
+/* Copyright 2003-2018 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -18,6 +23,9 @@
#include FT_ADVANCES_H
+
+#ifdef FT_OPTION_AUTOFIT2
+
#include "afglobal.h"
#include "aflatin.h"
#include "aflatin2.h"
@@ -693,6 +701,22 @@
}
+ /* Extract standard_width from writing system/script specific */
+ /* metrics class. */
+
+ FT_LOCAL_DEF( void )
+ af_latin2_get_standard_widths( AF_LatinMetrics metrics,
+ FT_Pos* stdHW,
+ FT_Pos* stdVW )
+ {
+ if ( stdHW )
+ *stdHW = metrics->axis[AF_DIMENSION_VERT].standard_width;
+
+ if ( stdVW )
+ *stdVW = metrics->axis[AF_DIMENSION_HORZ].standard_width;
+ }
+
+
/*************************************************************************/
/*************************************************************************/
/***** *****/
@@ -1179,7 +1203,7 @@
/* insert a new edge in the list and */
/* sort according to the position */
- error = af_axis_hints_new_edge( axis, seg->pos, seg->dir,
+ error = af_axis_hints_new_edge( axis, seg->pos, seg->dir, 0,
memory, &edge );
if ( error )
goto Exit;
@@ -1282,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;
@@ -1534,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
@@ -2316,13 +2340,7 @@
goto Exit;
/* analyze glyph outline */
-#ifdef AF_CONFIG_OPTION_USE_WARPER
- if ( ( metrics->root.scaler.render_mode == FT_RENDER_MODE_LIGHT &&
- AF_HINTS_DO_WARP( hints ) ) ||
- AF_HINTS_DO_HORIZONTAL( hints ) )
-#else
if ( AF_HINTS_DO_HORIZONTAL( hints ) )
-#endif
{
error = af_latin2_hints_detect_features( hints, AF_DIMENSION_HORZ );
if ( error )
@@ -2342,9 +2360,9 @@
for ( dim = 0; dim < AF_DIMENSION_MAX; dim++ )
{
#ifdef AF_CONFIG_OPTION_USE_WARPER
- if ( dim == AF_DIMENSION_HORZ &&
- metrics->root.scaler.render_mode == FT_RENDER_MODE_LIGHT &&
- AF_HINTS_DO_WARP( hints ) )
+ if ( dim == AF_DIMENSION_HORZ &&
+ metrics->root.scaler.render_mode == FT_RENDER_MODE_NORMAL &&
+ AF_HINTS_DO_WARP( hints ) )
{
AF_WarperRec warper;
FT_Fixed scale;
@@ -2389,13 +2407,21 @@
sizeof ( AF_LatinMetricsRec ),
- (AF_WritingSystem_InitMetricsFunc) af_latin2_metrics_init,
- (AF_WritingSystem_ScaleMetricsFunc)af_latin2_metrics_scale,
- (AF_WritingSystem_DoneMetricsFunc) NULL,
+ (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/src/3rdparty/freetype/src/autofit/aflatin2.h b/src/3rdparty/freetype/src/autofit/aflatin2.h
index 9326753130..0129dc707e 100644
--- a/src/3rdparty/freetype/src/autofit/aflatin2.h
+++ b/src/3rdparty/freetype/src/autofit/aflatin2.h
@@ -1,3 +1,8 @@
+/* ATTENTION: This file doesn't compile. It is only here as a reference */
+/* of an alternative latin hinting algorithm that was always */
+/* marked as experimental. */
+
+
/***************************************************************************/
/* */
/* aflatin2.h */
@@ -5,7 +10,7 @@
/* Auto-fitter hinting routines for latin writing system */
/* (specification). */
/* */
-/* Copyright 2003-2015 by */
+/* Copyright 2003-2018 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -17,8 +22,8 @@
/***************************************************************************/
-#ifndef __AFLATIN2_H__
-#define __AFLATIN2_H__
+#ifndef AFLATIN2_H_
+#define AFLATIN2_H_
#include "afhints.h"
@@ -35,7 +40,7 @@ FT_BEGIN_HEADER
FT_END_HEADER
-#endif /* __AFLATIN_H__ */
+#endif /* AFLATIN_H_ */
/* END */
diff --git a/src/3rdparty/freetype/src/autofit/afloader.c b/src/3rdparty/freetype/src/autofit/afloader.c
index 722ffd31ec..a55550b338 100644
--- a/src/3rdparty/freetype/src/autofit/afloader.c
+++ b/src/3rdparty/freetype/src/autofit/afloader.c
@@ -4,7 +4,7 @@
/* */
/* Auto-fitter glyph loading routines (body). */
/* */
-/* Copyright 2003-2015 by */
+/* Copyright 2003-2018 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -23,6 +23,8 @@
#include "afmodule.h"
#include "afpic.h"
+#include FT_INTERNAL_CALC_H
+
/* Initialize glyph loader. */
@@ -49,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 )
@@ -76,41 +78,324 @@
}
- /* 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. */
+#define af_intToFixed( i ) \
+ ( (FT_Fixed)( (FT_UInt32)(i) << 16 ) )
+#define af_fixedToInt( x ) \
+ ( (FT_Short)( ( (FT_UInt32)(x) + 0x8000U ) >> 16 ) )
+#define af_floatToFixed( f ) \
+ ( (FT_Fixed)( (f) * 65536.0 + 0.5 ) )
+
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 )
{
- 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;
-
-
- flags = load_flags | FT_LOAD_LINEAR_DESIGN;
- error = FT_Load_Glyph( face, glyph_index, flags );
+ FT_Error error = FT_Err_Ok;
+
+ 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;
+
+ 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;
+ }
+
+ /*
+ * 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.
+ */
+ 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
+ {
+ error = FT_ERR( Unimplemented_Feature );
+ goto Exit;
+ }
+
+ if ( size_changed ||
+ ( stdVW > 0 && stdVW != globals->standard_vertical_width ) )
+ {
+ FT_Fixed darken_by_font_units_x, darken_x;
+
+
+ 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 );
+
+ 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 );
+
+ globals->standard_horizontal_width = stdHW;
+ globals->stem_darkening_for_ppem = 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_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 );
+
+ Exit:
+ return error;
+ }
+
+
+ /* Load the glyph at index into the current slot of a face and hint it. */
+
+ 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;
+
+#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_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];
+
+ loader->metrics = style_metrics;
+
+ 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;
+ }
+
+ /*
+ * 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;
- loader->transformed = internal->glyph_transformed;
+ /*
+ * 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 ) )
@@ -126,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,
@@ -138,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 +
@@ -171,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;
@@ -207,21 +483,23 @@
FT_Pos pp2x = loader->pp2.x;
- loader->pp1.x = FT_PIX_ROUND( pp1x );
- loader->pp2.x = FT_PIX_ROUND( pp2x );
+ loader->pp1.x = FT_PIX_ROUND( pp1x + hints->xmin_delta );
+ loader->pp2.x = FT_PIX_ROUND( pp2x + hints->xmax_delta );
slot->lsb_delta = loader->pp1.x - pp1x;
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;
FT_Pos pp2x = loader->pp2.x;
- loader->pp1.x = FT_PIX_ROUND( pp1x + hints->xmin_delta );
- loader->pp2.x = FT_PIX_ROUND( pp2x + hints->xmax_delta );
+ loader->pp1.x = FT_PIX_ROUND( pp1x );
+ loader->pp2.x = FT_PIX_ROUND( pp2x );
slot->lsb_delta = loader->pp1.x - pp1x;
slot->rsb_delta = loader->pp2.x - pp2x;
@@ -242,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 )
@@ -251,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 );
@@ -275,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. */
@@ -301,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;
}
@@ -326,82 +588,133 @@
}
- /* 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 )
+ /*
+ * Compute amount of font units the face should be emboldened by, in
+ * analogy to the CFF driver's `cf2_computeDarkening' function. See there
+ * for details of the algorithm.
+ *
+ * XXX: Currently a crude adaption of the original algorithm. Do better?
+ */
+ FT_LOCAL_DEF( FT_Int32 )
+ af_loader_compute_darkening( AF_Loader loader,
+ FT_Face face,
+ FT_Pos standard_width )
{
- FT_Error error;
- FT_Size size = face->size;
- AF_ScalerRec scaler;
+ AF_Module module = loader->globals->module;
+ FT_UShort units_per_EM;
+ FT_Fixed ppem, em_ratio;
+ FT_Fixed stem_width, stem_width_per_1000, scaled_stem, darken_amount;
+ FT_Int log_base_2;
+ FT_Int x1, y1, x2, y2, x3, y3, x4, y4;
- if ( !size )
- return FT_THROW( Invalid_Size_Handle );
- FT_ZERO( &scaler );
+ ppem = FT_MAX( af_intToFixed( 4 ),
+ af_intToFixed( face->size->metrics.x_ppem ) );
+ units_per_EM = face->units_per_EM;
- 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 */
+ em_ratio = FT_DivFix( af_intToFixed( 1000 ),
+ af_intToFixed ( units_per_EM ) );
+ if ( em_ratio < af_floatToFixed( .01 ) )
+ {
+ /* If something goes wrong, don't embolden. */
+ return 0;
+ }
- scaler.render_mode = FT_LOAD_TARGET_MODE( load_flags );
- scaler.flags = 0; /* XXX: fix this */
+ x1 = module->darken_params[0];
+ y1 = module->darken_params[1];
+ x2 = module->darken_params[2];
+ y2 = module->darken_params[3];
+ x3 = module->darken_params[4];
+ y3 = module->darken_params[5];
+ x4 = module->darken_params[6];
+ y4 = module->darken_params[7];
- error = af_loader_reset( loader, module, face );
- if ( !error )
+ if ( standard_width <= 0 )
+ {
+ stem_width = af_intToFixed( 75 ); /* taken from cf2font.c */
+ stem_width_per_1000 = stem_width;
+ }
+ else
{
- AF_StyleMetrics metrics;
- FT_UInt options = AF_STYLE_NONE_DFLT;
+ stem_width = af_intToFixed( standard_width );
+ stem_width_per_1000 = FT_MulFix( stem_width, em_ratio );
+ }
+ log_base_2 = FT_MSB( (FT_UInt32)stem_width_per_1000 ) +
+ FT_MSB( (FT_UInt32)ppem );
-#ifdef FT_OPTION_AUTOFIT2
- /* XXX: undocumented hook to activate the latin2 writing system */
- if ( load_flags & ( 1UL << 20 ) )
- options = AF_STYLE_LTN2_DFLT;
-#endif
+ if ( log_base_2 >= 46 )
+ {
+ /* possible overflow */
+ scaled_stem = af_intToFixed( x4 );
+ }
+ else
+ scaled_stem = FT_MulFix( stem_width_per_1000, ppem );
- error = af_face_globals_get_metrics( loader->globals, gindex,
- options, &metrics );
- if ( !error )
+ /* now apply the darkening parameters */
+ if ( scaled_stem < af_intToFixed( x1 ) )
+ darken_amount = FT_DivFix( af_intToFixed( y1 ), ppem );
+
+ else if ( scaled_stem < af_intToFixed( x2 ) )
+ {
+ FT_Int xdelta = x2 - x1;
+ FT_Int ydelta = y2 - y1;
+ FT_Int x = stem_width_per_1000 -
+ FT_DivFix( af_intToFixed( x1 ), ppem );
+
+
+ if ( !xdelta )
+ goto Try_x3;
+
+ darken_amount = FT_MulDiv( x, ydelta, xdelta ) +
+ FT_DivFix( af_intToFixed( y1 ), ppem );
+ }
+
+ else if ( scaled_stem < af_intToFixed( x3 ) )
+ {
+ Try_x3:
{
-#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];
+ FT_Int xdelta = x3 - x2;
+ FT_Int ydelta = y3 - y2;
+ FT_Int x = stem_width_per_1000 -
+ FT_DivFix( af_intToFixed( x2 ), ppem );
- loader->metrics = metrics;
+ if ( !xdelta )
+ goto Try_x4;
- if ( writing_system_class->style_metrics_scale )
- writing_system_class->style_metrics_scale( metrics, &scaler );
- else
- metrics->scaler = scaler;
+ darken_amount = FT_MulDiv( x, ydelta, xdelta ) +
+ FT_DivFix( af_intToFixed( y2 ), ppem );
+ }
+ }
- load_flags |= FT_LOAD_NO_SCALE | FT_LOAD_IGNORE_TRANSFORM;
- load_flags &= ~FT_LOAD_RENDER;
+ else if ( scaled_stem < af_intToFixed( x4 ) )
+ {
+ Try_x4:
+ {
+ FT_Int xdelta = x4 - x3;
+ FT_Int ydelta = y4 - y3;
+ FT_Int x = stem_width_per_1000 -
+ FT_DivFix( af_intToFixed( x3 ), ppem );
- 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 );
+ if ( !xdelta )
+ goto Use_y4;
+
+ darken_amount = FT_MulDiv( x, ydelta, xdelta ) +
+ FT_DivFix( af_intToFixed( y3 ), ppem );
}
}
- Exit:
- return error;
+
+ else
+ {
+ Use_y4:
+ darken_amount = FT_DivFix( af_intToFixed( y4 ), ppem );
+ }
+
+ /* Convert darken_amount from per 1000 em to true character space. */
+ return af_fixedToInt( FT_DivFix( darken_amount, em_ratio ) );
}
diff --git a/src/3rdparty/freetype/src/autofit/afloader.h b/src/3rdparty/freetype/src/autofit/afloader.h
index 37cfd14239..d4d72d1583 100644
--- a/src/3rdparty/freetype/src/autofit/afloader.h
+++ b/src/3rdparty/freetype/src/autofit/afloader.h
@@ -4,7 +4,7 @@
/* */
/* Auto-fitter glyph loading routines (specification). */
/* */
-/* Copyright 2003-2015 by */
+/* Copyright 2003-2018 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -16,8 +16,8 @@
/***************************************************************************/
-#ifndef __AFLOADER_H__
-#define __AFLOADER_H__
+#ifndef AFLOADER_H_
+#define AFLOADER_H_
#include "afhints.h"
#include "afmodule.h"
@@ -75,12 +75,17 @@ FT_BEGIN_HEADER
FT_UInt gindex,
FT_Int32 load_flags );
+ FT_LOCAL_DEF( FT_Int32 )
+ af_loader_compute_darkening( AF_Loader loader,
+ FT_Face face,
+ FT_Pos standard_width );
+
/* */
FT_END_HEADER
-#endif /* __AFLOADER_H__ */
+#endif /* AFLOADER_H_ */
/* END */
diff --git a/src/3rdparty/freetype/src/autofit/afmodule.c b/src/3rdparty/freetype/src/autofit/afmodule.c
index bbf1372518..dcaa17a27e 100644
--- a/src/3rdparty/freetype/src/autofit/afmodule.c
+++ b/src/3rdparty/freetype/src/autofit/afmodule.c
@@ -4,7 +4,7 @@
/* */
/* Auto-fitter module implementation (body). */
/* */
-/* Copyright 2003-2015 by */
+/* Copyright 2003-2018 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -56,7 +56,7 @@
#include FT_INTERNAL_OBJECTS_H
#include FT_INTERNAL_DEBUG_H
-#include FT_AUTOHINTER_H
+#include FT_DRIVER_H
#include FT_SERVICE_PROPERTIES_H
@@ -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,8 +171,15 @@
}
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;
@@ -156,10 +187,17 @@
}
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,14 +207,119 @@
#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 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 );
+
+ 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 ||
+ y1 > 500 || y2 > 500 || y3 > 500 || y4 > 500 )
+ return FT_THROW( Invalid_Argument );
+
+ module->darken_params[0] = x1;
+ module->darken_params[1] = y1;
+ module->darken_params[2] = x2;
+ module->darken_params[3] = y2;
+ module->darken_params[4] = x3;
+ module->darken_params[5] = y3;
+ module->darken_params[6] = x4;
+ module->darken_params[7] = y4;
+
+ return error;
+ }
+ else if ( !ft_strcmp( property_name, "no-stem-darkening" ) )
+ {
+#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 )
+ 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;
+ }
FT_TRACE0(( "af_property_set: missing property `%s'\n",
property_name ));
@@ -253,6 +396,33 @@
return error;
}
#endif /* AF_CONFIG_OPTION_USE_WARPER */
+ else if ( !ft_strcmp( property_name, "darkening-parameters" ) )
+ {
+ FT_Int* darken_params = module->darken_params;
+ FT_Int* val = (FT_Int*)value;
+
+
+ val[0] = darken_params[0];
+ val[1] = darken_params[1];
+ val[2] = darken_params[2];
+ val[3] = darken_params[3];
+ val[4] = darken_params[4];
+ val[5] = darken_params[5];
+ val[6] = darken_params[6];
+ val[7] = darken_params[7];
+
+ return error;
+ }
+ else if ( !ft_strcmp( property_name, "no-stem-darkening" ) )
+ {
+ FT_Bool no_stem_darkening = module->no_stem_darkening;
+ FT_Bool* val = (FT_Bool*)value;
+
+
+ *val = no_stem_darkening;
+
+ return error;
+ }
FT_TRACE0(( "af_property_get: missing property `%s'\n",
property_name ));
@@ -262,12 +432,14 @@
FT_DEFINE_SERVICE_PROPERTIESREC(
af_service_properties,
- (FT_Properties_SetFunc)af_property_set,
- (FT_Properties_GetFunc)af_property_get )
+
+ (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 )
@@ -299,11 +471,21 @@
AF_Module module = (AF_Module)ft_module;
- module->fallback_style = AF_STYLE_FALLBACK;
- module->default_script = AF_SCRIPT_DEFAULT;
+ module->fallback_style = AF_STYLE_FALLBACK;
+ module->default_script = AF_SCRIPT_DEFAULT;
#ifdef AF_CONFIG_OPTION_USE_WARPER
- module->warping = 0;
+ module->warping = 0;
#endif
+ module->no_stem_darkening = TRUE;
+
+ module->darken_params[0] = CFF_CONFIG_OPTION_DARKENING_PARAMETER_X1;
+ module->darken_params[1] = CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y1;
+ module->darken_params[2] = CFF_CONFIG_OPTION_DARKENING_PARAMETER_X2;
+ module->darken_params[3] = CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y2;
+ module->darken_params[4] = CFF_CONFIG_OPTION_DARKENING_PARAMETER_X3;
+ module->darken_params[5] = CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y3;
+ module->darken_params[6] = CFF_CONFIG_OPTION_DARKENING_PARAMETER_X4;
+ module->darken_params[7] = CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y4;
return FT_Err_Ok;
}
@@ -350,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 );
@@ -383,6 +572,7 @@
FT_DEFINE_AUTOHINTER_INTERFACE(
af_autofitter_interface,
+
NULL, /* reset_face */
NULL, /* get_global_hints */
NULL, /* done_global_hints */
@@ -401,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/src/3rdparty/freetype/src/autofit/afmodule.h b/src/3rdparty/freetype/src/autofit/afmodule.h
index b9c2fd8a2d..56f64eaf23 100644
--- a/src/3rdparty/freetype/src/autofit/afmodule.h
+++ b/src/3rdparty/freetype/src/autofit/afmodule.h
@@ -4,7 +4,7 @@
/* */
/* Auto-fitter module implementation (specification). */
/* */
-/* Copyright 2003-2015 by */
+/* Copyright 2003-2018 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -16,8 +16,8 @@
/***************************************************************************/
-#ifndef __AFMODULE_H__
-#define __AFMODULE_H__
+#ifndef AFMODULE_H_
+#define AFMODULE_H_
#include <ft2build.h>
#include FT_INTERNAL_OBJECTS_H
@@ -41,6 +41,8 @@ FT_BEGIN_HEADER
#ifdef AF_CONFIG_OPTION_USE_WARPER
FT_Bool warping;
#endif
+ FT_Bool no_stem_darkening;
+ FT_Int darken_params[8];
} AF_ModuleRec, *AF_Module;
@@ -50,7 +52,7 @@ FT_DECLARE_MODULE( autofit_module_class )
FT_END_HEADER
-#endif /* __AFMODULE_H__ */
+#endif /* AFMODULE_H_ */
/* END */
diff --git a/src/3rdparty/freetype/src/autofit/afpic.c b/src/3rdparty/freetype/src/autofit/afpic.c
index 5589e612cf..d48d016a0e 100644
--- a/src/3rdparty/freetype/src/autofit/afpic.c
+++ b/src/3rdparty/freetype/src/autofit/afpic.c
@@ -4,7 +4,7 @@
/* */
/* The FreeType position independent code services for autofit module. */
/* */
-/* Copyright 2009-2015 by */
+/* Copyright 2009-2018 by */
/* Oran Agra and Mickey Gabel. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -122,7 +122,7 @@
#include "afwrtsys.h"
#undef SCRIPT
-#define SCRIPT( s, S, d, h, sc1, sc2, sc3 ) \
+#define SCRIPT( s, S, d, h, H, sss ) \
FT_Init_Class_af_ ## s ## _script_class( \
&container->af_script_classes_rec[ss++] );
diff --git a/src/3rdparty/freetype/src/autofit/afpic.h b/src/3rdparty/freetype/src/autofit/afpic.h
index 9b45069f5d..0c73456785 100644
--- a/src/3rdparty/freetype/src/autofit/afpic.h
+++ b/src/3rdparty/freetype/src/autofit/afpic.h
@@ -4,7 +4,7 @@
/* */
/* The FreeType position independent code services for autofit module. */
/* */
-/* Copyright 2009-2015 by */
+/* Copyright 2009-2018 by */
/* Oran Agra and Mickey Gabel. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -16,8 +16,8 @@
/***************************************************************************/
-#ifndef __AFPIC_H__
-#define __AFPIC_H__
+#ifndef AFPIC_H_
+#define AFPIC_H_
#include FT_INTERNAL_PIC_H
@@ -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 )
@@ -99,7 +99,7 @@ FT_END_HEADER
/* */
-#endif /* __AFPIC_H__ */
+#endif /* AFPIC_H_ */
/* END */
diff --git a/src/3rdparty/freetype/src/autofit/afranges.c b/src/3rdparty/freetype/src/autofit/afranges.c
index 13c221364c..cf67fafb11 100644
--- a/src/3rdparty/freetype/src/autofit/afranges.c
+++ b/src/3rdparty/freetype/src/autofit/afranges.c
@@ -4,7 +4,7 @@
/* */
/* Auto-fitter Unicode script ranges (body). */
/* */
-/* Copyright 2013-2015 by */
+/* Copyright 2013-2018 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -52,61 +52,230 @@
/* 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[] =
{
- AF_UNIRANGE_REC( 0x0600UL, 0x06FFUL ), /* Arabic */
- AF_UNIRANGE_REC( 0x0750UL, 0x07FFUL ), /* Arabic Supplement */
- AF_UNIRANGE_REC( 0x08A0UL, 0x08FFUL ), /* Arabic Extended-A */
- AF_UNIRANGE_REC( 0xFB50UL, 0xFDFFUL ), /* Arabic Presentation Forms-A */
- AF_UNIRANGE_REC( 0xFE70UL, 0xFEFFUL ), /* Arabic Presentation Forms-B */
- AF_UNIRANGE_REC( 0x1EE00UL, 0x1EEFFUL ), /* Arabic Mathematical Alphabetic Symbols */
- AF_UNIRANGE_REC( 0UL, 0UL )
+ AF_UNIRANGE_REC( 0x0600, 0x06FF ), /* Arabic */
+ AF_UNIRANGE_REC( 0x0750, 0x07FF ), /* Arabic Supplement */
+ AF_UNIRANGE_REC( 0x08A0, 0x08FF ), /* Arabic Extended-A */
+ AF_UNIRANGE_REC( 0xFB50, 0xFDFF ), /* Arabic Presentation Forms-A */
+ AF_UNIRANGE_REC( 0xFE70, 0xFEFF ), /* Arabic Presentation Forms-B */
+ AF_UNIRANGE_REC( 0x1EE00, 0x1EEFF ), /* Arabic Mathematical Alphabetic Symbols */
+ AF_UNIRANGE_REC( 0, 0 )
};
const AF_Script_UniRangeRec af_arab_nonbase_uniranges[] =
{
- AF_UNIRANGE_REC( 0x0600UL, 0x0605UL ),
- AF_UNIRANGE_REC( 0x0610UL, 0x061AUL ),
- AF_UNIRANGE_REC( 0x064BUL, 0x065FUL ),
- AF_UNIRANGE_REC( 0x0670UL, 0x0670UL ),
- AF_UNIRANGE_REC( 0x06D6UL, 0x06DCUL ),
- AF_UNIRANGE_REC( 0x06DFUL, 0x06E4UL ),
- AF_UNIRANGE_REC( 0x06E7UL, 0x06E8UL ),
- AF_UNIRANGE_REC( 0x06EAUL, 0x06EDUL ),
- AF_UNIRANGE_REC( 0x08E3UL, 0x08FFUL ),
- AF_UNIRANGE_REC( 0xFBB2UL, 0xFBC1UL ),
- AF_UNIRANGE_REC( 0xFE70UL, 0xFE70UL ),
- AF_UNIRANGE_REC( 0xFE72UL, 0xFE72UL ),
- AF_UNIRANGE_REC( 0xFE74UL, 0xFE74UL ),
- AF_UNIRANGE_REC( 0xFE76UL, 0xFE76UL ),
- AF_UNIRANGE_REC( 0xFE78UL, 0xFE78UL ),
- AF_UNIRANGE_REC( 0xFE7AUL, 0xFE7AUL ),
- AF_UNIRANGE_REC( 0xFE7CUL, 0xFE7CUL ),
- AF_UNIRANGE_REC( 0xFE7EUL, 0xFE7EUL ),
- AF_UNIRANGE_REC( 0UL, 0UL )
+ AF_UNIRANGE_REC( 0x0600, 0x0605 ),
+ AF_UNIRANGE_REC( 0x0610, 0x061A ),
+ AF_UNIRANGE_REC( 0x064B, 0x065F ),
+ AF_UNIRANGE_REC( 0x0670, 0x0670 ),
+ AF_UNIRANGE_REC( 0x06D6, 0x06DC ),
+ AF_UNIRANGE_REC( 0x06DF, 0x06E4 ),
+ AF_UNIRANGE_REC( 0x06E7, 0x06E8 ),
+ AF_UNIRANGE_REC( 0x06EA, 0x06ED ),
+ AF_UNIRANGE_REC( 0x08D4, 0x08E1 ),
+ AF_UNIRANGE_REC( 0x08D3, 0x08FF ),
+ AF_UNIRANGE_REC( 0xFBB2, 0xFBC1 ),
+ AF_UNIRANGE_REC( 0xFE70, 0xFE70 ),
+ AF_UNIRANGE_REC( 0xFE72, 0xFE72 ),
+ AF_UNIRANGE_REC( 0xFE74, 0xFE74 ),
+ AF_UNIRANGE_REC( 0xFE76, 0xFE76 ),
+ AF_UNIRANGE_REC( 0xFE78, 0xFE78 ),
+ AF_UNIRANGE_REC( 0xFE7A, 0xFE7A ),
+ AF_UNIRANGE_REC( 0xFE7C, 0xFE7C ),
+ AF_UNIRANGE_REC( 0xFE7E, 0xFE7E ),
+ AF_UNIRANGE_REC( 0, 0 )
+ };
+
+
+ const AF_Script_UniRangeRec af_armn_uniranges[] =
+ {
+ AF_UNIRANGE_REC( 0x0530, 0x058F ), /* Armenian */
+ AF_UNIRANGE_REC( 0xFB13, 0xFB17 ), /* Alphab. Present. Forms (Armenian) */
+ AF_UNIRANGE_REC( 0, 0 )
+ };
+
+ const AF_Script_UniRangeRec af_armn_nonbase_uniranges[] =
+ {
+ AF_UNIRANGE_REC( 0x0559, 0x055F ),
+ AF_UNIRANGE_REC( 0, 0 )
+ };
+
+
+ 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 */
+ AF_UNIRANGE_REC( 0, 0 )
+ };
+
+ const AF_Script_UniRangeRec af_beng_nonbase_uniranges[] =
+ {
+ AF_UNIRANGE_REC( 0x0981, 0x0981 ),
+ AF_UNIRANGE_REC( 0x09BC, 0x09BC ),
+ AF_UNIRANGE_REC( 0x09C1, 0x09C4 ),
+ AF_UNIRANGE_REC( 0x09CD, 0x09CD ),
+ AF_UNIRANGE_REC( 0x09E2, 0x09E3 ),
+ AF_UNIRANGE_REC( 0x09FE, 0x09FE ),
+ AF_UNIRANGE_REC( 0, 0 )
+ };
+
+
+ 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( 0x11146, 0x11146 ),
+ 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 */
+ AF_UNIRANGE_REC( 0xAB70, 0xABBF ), /* Cherokee Supplement */
+ AF_UNIRANGE_REC( 0, 0 )
+ };
+
+ const AF_Script_UniRangeRec af_cher_nonbase_uniranges[] =
+ {
+ AF_UNIRANGE_REC( 0, 0 )
+ };
+
+
+ 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( 0x0400UL, 0x04FFUL ), /* Cyrillic */
- AF_UNIRANGE_REC( 0x0500UL, 0x052FUL ), /* Cyrillic Supplement */
- AF_UNIRANGE_REC( 0x2DE0UL, 0x2DFFUL ), /* Cyrillic Extended-A */
- AF_UNIRANGE_REC( 0xA640UL, 0xA69FUL ), /* Cyrillic Extended-B */
- AF_UNIRANGE_REC( 0UL, 0UL )
+ AF_UNIRANGE_REC( 0x0400, 0x04FF ), /* Cyrillic */
+ AF_UNIRANGE_REC( 0x0500, 0x052F ), /* Cyrillic Supplement */
+ AF_UNIRANGE_REC( 0x2DE0, 0x2DFF ), /* Cyrillic Extended-A */
+ AF_UNIRANGE_REC( 0xA640, 0xA69F ), /* Cyrillic Extended-B */
+ AF_UNIRANGE_REC( 0x1C80, 0x1C8F ), /* Cyrillic Extended-C */
+ AF_UNIRANGE_REC( 0, 0 )
};
const AF_Script_UniRangeRec af_cyrl_nonbase_uniranges[] =
{
- AF_UNIRANGE_REC( 0x0483UL, 0x0489UL ),
- AF_UNIRANGE_REC( 0x2DE0UL, 0x2DFFUL ),
- AF_UNIRANGE_REC( 0xA66FUL, 0xA67FUL ),
- AF_UNIRANGE_REC( 0xA69EUL, 0xA69FUL ),
- AF_UNIRANGE_REC( 0UL, 0UL )
+ AF_UNIRANGE_REC( 0x0483, 0x0489 ),
+ AF_UNIRANGE_REC( 0x2DE0, 0x2DFF ),
+ AF_UNIRANGE_REC( 0xA66F, 0xA67F ),
+ AF_UNIRANGE_REC( 0xA69E, 0xA69F ),
+ AF_UNIRANGE_REC( 0, 0 )
};
@@ -116,420 +285,696 @@
const AF_Script_UniRangeRec af_deva_uniranges[] =
{
- AF_UNIRANGE_REC( 0x0900UL, 0x093BUL ), /* Devanagari */
+ AF_UNIRANGE_REC( 0x0900, 0x093B ), /* Devanagari */
/* omitting U+093C nukta */
- AF_UNIRANGE_REC( 0x093DUL, 0x0950UL ), /* ... continued */
+ AF_UNIRANGE_REC( 0x093D, 0x0950 ), /* ... continued */
/* omitting U+0951 udatta, U+0952 anudatta */
- AF_UNIRANGE_REC( 0x0953UL, 0x0963UL ), /* ... continued */
+ AF_UNIRANGE_REC( 0x0953, 0x0963 ), /* ... continued */
/* omitting U+0964 danda, U+0965 double danda */
- AF_UNIRANGE_REC( 0x0966UL, 0x097FUL ), /* ... continued */
- AF_UNIRANGE_REC( 0x20B9UL, 0x20B9UL ), /* (new) Rupee sign */
- AF_UNIRANGE_REC( 0xA8E0UL, 0xA8FFUL ), /* Devanagari Extended */
- AF_UNIRANGE_REC( 0UL, 0UL )
+ AF_UNIRANGE_REC( 0x0966, 0x097F ), /* ... continued */
+ AF_UNIRANGE_REC( 0x20B9, 0x20B9 ), /* (new) Rupee sign */
+ AF_UNIRANGE_REC( 0xA8E0, 0xA8FF ), /* Devanagari Extended */
+ AF_UNIRANGE_REC( 0, 0 )
};
const AF_Script_UniRangeRec af_deva_nonbase_uniranges[] =
{
- AF_UNIRANGE_REC( 0x0900UL, 0x0902UL ),
- AF_UNIRANGE_REC( 0x093AUL, 0x093AUL ),
- AF_UNIRANGE_REC( 0x0941UL, 0x0948UL ),
- AF_UNIRANGE_REC( 0x094DUL, 0x094DUL ),
- AF_UNIRANGE_REC( 0x0953UL, 0x0957UL ),
- AF_UNIRANGE_REC( 0x0962UL, 0x0963UL ),
- AF_UNIRANGE_REC( 0xA8E0UL, 0xA8F1UL ),
- AF_UNIRANGE_REC( 0UL, 0UL )
+ AF_UNIRANGE_REC( 0x0900, 0x0902 ),
+ AF_UNIRANGE_REC( 0x093A, 0x093A ),
+ AF_UNIRANGE_REC( 0x0941, 0x0948 ),
+ AF_UNIRANGE_REC( 0x094D, 0x094D ),
+ AF_UNIRANGE_REC( 0x0953, 0x0957 ),
+ AF_UNIRANGE_REC( 0x0962, 0x0963 ),
+ AF_UNIRANGE_REC( 0xA8E0, 0xA8F1 ),
+ AF_UNIRANGE_REC( 0xA8FF, 0xA8FF ),
+ AF_UNIRANGE_REC( 0, 0 )
+ };
+
+
+ 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 */
+ AF_UNIRANGE_REC( 0x1380, 0x139F ), /* Ethiopic Supplement */
+ AF_UNIRANGE_REC( 0x2D80, 0x2DDF ), /* Ethiopic Extended */
+ AF_UNIRANGE_REC( 0xAB00, 0xAB2F ), /* Ethiopic Extended-A */
+ AF_UNIRANGE_REC( 0, 0 )
+ };
+
+ const AF_Script_UniRangeRec af_ethi_nonbase_uniranges[] =
+ {
+ AF_UNIRANGE_REC( 0x135D, 0x135F ),
+ AF_UNIRANGE_REC( 0, 0 )
+ };
+
+
+ const AF_Script_UniRangeRec af_geor_uniranges[] =
+ {
+ AF_UNIRANGE_REC( 0x10D0, 0x10FF ), /* Georgian (Mkhedruli) */
+ AF_UNIRANGE_REC( 0x1C90, 0x1CBF ), /* Georgian Extended (Mtavruli) */
+ AF_UNIRANGE_REC( 0, 0 )
+ };
+
+ const AF_Script_UniRangeRec af_geor_nonbase_uniranges[] =
+ {
+ AF_UNIRANGE_REC( 0, 0 )
+ };
+
+
+ const AF_Script_UniRangeRec af_geok_uniranges[] =
+ {
+ /* Khutsuri */
+ AF_UNIRANGE_REC( 0x10A0, 0x10CD ), /* Georgian (Asomtavruli) */
+ AF_UNIRANGE_REC( 0x2D00, 0x2D2D ), /* Georgian Supplement (Nuskhuri) */
+ AF_UNIRANGE_REC( 0, 0 )
+ };
+
+ const AF_Script_UniRangeRec af_geok_nonbase_uniranges[] =
+ {
+ AF_UNIRANGE_REC( 0, 0 )
+ };
+
+
+ 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( 0x0370UL, 0x03FFUL ), /* Greek and Coptic */
- AF_UNIRANGE_REC( 0x1F00UL, 0x1FFFUL ), /* Greek Extended */
- AF_UNIRANGE_REC( 0UL, 0UL )
+ AF_UNIRANGE_REC( 0x0370, 0x03FF ), /* Greek and Coptic */
+ AF_UNIRANGE_REC( 0x1F00, 0x1FFF ), /* Greek Extended */
+ AF_UNIRANGE_REC( 0, 0 )
};
const AF_Script_UniRangeRec af_grek_nonbase_uniranges[] =
{
- AF_UNIRANGE_REC( 0x037AUL, 0x037AUL ),
- AF_UNIRANGE_REC( 0x0384UL, 0x0385UL ),
- AF_UNIRANGE_REC( 0x1FBDUL, 0x1FC1UL ),
- AF_UNIRANGE_REC( 0x1FCDUL, 0x1FCFUL ),
- AF_UNIRANGE_REC( 0x1FDDUL, 0x1FDFUL ),
- AF_UNIRANGE_REC( 0x1FEDUL, 0x1FEFUL ),
- AF_UNIRANGE_REC( 0x1FFDUL, 0x1FFEUL ),
- AF_UNIRANGE_REC( 0UL, 0UL )
+ AF_UNIRANGE_REC( 0x037A, 0x037A ),
+ AF_UNIRANGE_REC( 0x0384, 0x0385 ),
+ AF_UNIRANGE_REC( 0x1FBD, 0x1FC1 ),
+ AF_UNIRANGE_REC( 0x1FCD, 0x1FCF ),
+ AF_UNIRANGE_REC( 0x1FDD, 0x1FDF ),
+ AF_UNIRANGE_REC( 0x1FED, 0x1FEF ),
+ AF_UNIRANGE_REC( 0x1FFD, 0x1FFE ),
+ AF_UNIRANGE_REC( 0, 0 )
+ };
+
+
+ const AF_Script_UniRangeRec af_gujr_uniranges[] =
+ {
+ AF_UNIRANGE_REC( 0x0A80, 0x0AFF ), /* Gujarati */
+ AF_UNIRANGE_REC( 0, 0 )
+ };
+
+ const AF_Script_UniRangeRec af_gujr_nonbase_uniranges[] =
+ {
+ AF_UNIRANGE_REC( 0x0A81, 0x0A82 ),
+ AF_UNIRANGE_REC( 0x0ABC, 0x0ABC ),
+ AF_UNIRANGE_REC( 0x0AC1, 0x0AC8 ),
+ AF_UNIRANGE_REC( 0x0ACD, 0x0ACD ),
+ AF_UNIRANGE_REC( 0x0AE2, 0x0AE3 ),
+ AF_UNIRANGE_REC( 0x0AFA, 0x0AFF ),
+ AF_UNIRANGE_REC( 0, 0 )
+ };
+
+
+ const AF_Script_UniRangeRec af_guru_uniranges[] =
+ {
+ AF_UNIRANGE_REC( 0x0A00, 0x0A7F ), /* Gurmukhi */
+ AF_UNIRANGE_REC( 0, 0 )
+ };
+
+ const AF_Script_UniRangeRec af_guru_nonbase_uniranges[] =
+ {
+ AF_UNIRANGE_REC( 0x0A01, 0x0A02 ),
+ AF_UNIRANGE_REC( 0x0A3C, 0x0A3C ),
+ AF_UNIRANGE_REC( 0x0A41, 0x0A51 ),
+ AF_UNIRANGE_REC( 0x0A70, 0x0A71 ),
+ AF_UNIRANGE_REC( 0x0A75, 0x0A75 ),
+ AF_UNIRANGE_REC( 0, 0 )
};
const AF_Script_UniRangeRec af_hebr_uniranges[] =
{
- AF_UNIRANGE_REC( 0x0590UL, 0x05FFUL ), /* Hebrew */
- AF_UNIRANGE_REC( 0xFB1DUL, 0xFB4FUL ), /* Alphab. Present. Forms (Hebrew) */
- AF_UNIRANGE_REC( 0UL, 0UL )
+ AF_UNIRANGE_REC( 0x0590, 0x05FF ), /* Hebrew */
+ AF_UNIRANGE_REC( 0xFB1D, 0xFB4F ), /* Alphab. Present. Forms (Hebrew) */
+ AF_UNIRANGE_REC( 0, 0 )
};
const AF_Script_UniRangeRec af_hebr_nonbase_uniranges[] =
{
- AF_UNIRANGE_REC( 0x0591UL, 0x05BFUL ),
- AF_UNIRANGE_REC( 0x05C1UL, 0x05C2UL ),
- AF_UNIRANGE_REC( 0x05C4UL, 0x05C5UL ),
- AF_UNIRANGE_REC( 0x05C7UL, 0x05C7UL ),
- AF_UNIRANGE_REC( 0xFB1EUL, 0xFB1EUL ),
- AF_UNIRANGE_REC( 0UL, 0UL )
+ AF_UNIRANGE_REC( 0x0591, 0x05BF ),
+ AF_UNIRANGE_REC( 0x05C1, 0x05C2 ),
+ AF_UNIRANGE_REC( 0x05C4, 0x05C5 ),
+ AF_UNIRANGE_REC( 0x05C7, 0x05C7 ),
+ AF_UNIRANGE_REC( 0xFB1E, 0xFB1E ),
+ AF_UNIRANGE_REC( 0, 0 )
+ };
+
+
+ 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 */
+ AF_UNIRANGE_REC( 0, 0 )
+ };
+
+ const AF_Script_UniRangeRec af_knda_nonbase_uniranges[] =
+ {
+ AF_UNIRANGE_REC( 0x0C81, 0x0C81 ),
+ AF_UNIRANGE_REC( 0x0CBC, 0x0CBC ),
+ AF_UNIRANGE_REC( 0x0CBF, 0x0CBF ),
+ AF_UNIRANGE_REC( 0x0CC6, 0x0CC6 ),
+ AF_UNIRANGE_REC( 0x0CCC, 0x0CCD ),
+ AF_UNIRANGE_REC( 0x0CE2, 0x0CE3 ),
+ AF_UNIRANGE_REC( 0, 0 )
+ };
+
+
+ const AF_Script_UniRangeRec af_khmr_uniranges[] =
+ {
+ AF_UNIRANGE_REC( 0x1780, 0x17FF ), /* Khmer */
+ AF_UNIRANGE_REC( 0, 0 )
+ };
+
+ const AF_Script_UniRangeRec af_khmr_nonbase_uniranges[] =
+ {
+ AF_UNIRANGE_REC( 0x17B7, 0x17BD ),
+ AF_UNIRANGE_REC( 0x17C6, 0x17C6 ),
+ AF_UNIRANGE_REC( 0x17C9, 0x17D3 ),
+ AF_UNIRANGE_REC( 0x17DD, 0x17DD ),
+ AF_UNIRANGE_REC( 0, 0 )
+ };
+
+
+ const AF_Script_UniRangeRec af_khms_uniranges[] =
+ {
+ AF_UNIRANGE_REC( 0x19E0, 0x19FF ), /* Khmer Symbols */
+ AF_UNIRANGE_REC( 0, 0 )
+ };
+
+ const AF_Script_UniRangeRec af_khms_nonbase_uniranges[] =
+ {
+ AF_UNIRANGE_REC( 0, 0 )
};
const AF_Script_UniRangeRec af_lao_uniranges[] =
{
- AF_UNIRANGE_REC( 0x0E80UL, 0x0EFFUL ), /* Lao */
- AF_UNIRANGE_REC( 0UL, 0UL )
+ AF_UNIRANGE_REC( 0x0E80, 0x0EFF ), /* Lao */
+ AF_UNIRANGE_REC( 0, 0 )
};
const AF_Script_UniRangeRec af_lao_nonbase_uniranges[] =
{
- AF_UNIRANGE_REC( 0x0EB1UL, 0x0EB1UL ),
- AF_UNIRANGE_REC( 0x0EB4UL, 0x0EBCUL ),
- AF_UNIRANGE_REC( 0x0EC8UL, 0x0ECDUL ),
- AF_UNIRANGE_REC( 0UL, 0UL )
+ AF_UNIRANGE_REC( 0x0EB1, 0x0EB1 ),
+ AF_UNIRANGE_REC( 0x0EB4, 0x0EBC ),
+ AF_UNIRANGE_REC( 0x0EC8, 0x0ECD ),
+ AF_UNIRANGE_REC( 0, 0 )
};
const AF_Script_UniRangeRec af_latn_uniranges[] =
{
- AF_UNIRANGE_REC( 0x0020UL, 0x007FUL ), /* Basic Latin (no control chars) */
- AF_UNIRANGE_REC( 0x00A0UL, 0x00A9UL ), /* Latin-1 Supplement (no control chars) */
- AF_UNIRANGE_REC( 0x00ABUL, 0x00B1UL ), /* ... continued */
- AF_UNIRANGE_REC( 0x00B4UL, 0x00B8UL ), /* ... continued */
- AF_UNIRANGE_REC( 0x00BBUL, 0x00FFUL ), /* ... continued */
- AF_UNIRANGE_REC( 0x0100UL, 0x017FUL ), /* Latin Extended-A */
- AF_UNIRANGE_REC( 0x0180UL, 0x024FUL ), /* Latin Extended-B */
- AF_UNIRANGE_REC( 0x0250UL, 0x02AFUL ), /* IPA Extensions */
- AF_UNIRANGE_REC( 0x02B9UL, 0x02DFUL ), /* Spacing Modifier Letters */
- AF_UNIRANGE_REC( 0x02E5UL, 0x02FFUL ), /* ... continued */
- AF_UNIRANGE_REC( 0x0300UL, 0x036FUL ), /* Combining Diacritical Marks */
- AF_UNIRANGE_REC( 0x1AB0UL, 0x1ABEUL ), /* Combining Diacritical Marks Extended */
- AF_UNIRANGE_REC( 0x1D00UL, 0x1D2BUL ), /* Phonetic Extensions */
- AF_UNIRANGE_REC( 0x1D6BUL, 0x1D77UL ), /* ... continued */
- AF_UNIRANGE_REC( 0x1D79UL, 0x1D7FUL ), /* ... continued */
- AF_UNIRANGE_REC( 0x1D80UL, 0x1D9AUL ), /* Phonetic Extensions Supplement */
- AF_UNIRANGE_REC( 0x1DC0UL, 0x1DFFUL ), /* Combining Diacritical Marks Supplement */
- AF_UNIRANGE_REC( 0x1E00UL, 0x1EFFUL ), /* Latin Extended Additional */
- AF_UNIRANGE_REC( 0x2000UL, 0x206FUL ), /* General Punctuation */
- AF_UNIRANGE_REC( 0x20A0UL, 0x20B8UL ), /* Currency Symbols ... */
- AF_UNIRANGE_REC( 0x20BAUL, 0x20CFUL ), /* ... except new Rupee sign */
- AF_UNIRANGE_REC( 0x2150UL, 0x218FUL ), /* Number Forms */
- AF_UNIRANGE_REC( 0x2C60UL, 0x2C7BUL ), /* Latin Extended-C */
- AF_UNIRANGE_REC( 0x2C7EUL, 0x2C7FUL ), /* ... continued */
- AF_UNIRANGE_REC( 0x2E00UL, 0x2E7FUL ), /* Supplemental Punctuation */
- AF_UNIRANGE_REC( 0xA720UL, 0xA76FUL ), /* Latin Extended-D */
- AF_UNIRANGE_REC( 0xA771UL, 0xA7F7UL ), /* ... continued */
- AF_UNIRANGE_REC( 0xA7FAUL, 0xA7FFUL ), /* ... continued */
- AF_UNIRANGE_REC( 0xAB30UL, 0xAB5BUL ), /* Latin Extended-E */
- AF_UNIRANGE_REC( 0xAB60UL, 0xAB6FUL ), /* ... continued */
- AF_UNIRANGE_REC( 0xFB00UL, 0xFB06UL ), /* Alphab. Present. Forms (Latin Ligs) */
- AF_UNIRANGE_REC( 0x1D400UL, 0x1D7FFUL ), /* Mathematical Alphanumeric Symbols */
- AF_UNIRANGE_REC( 0UL, 0UL )
+ AF_UNIRANGE_REC( 0x0020, 0x007F ), /* Basic Latin (no control chars) */
+ AF_UNIRANGE_REC( 0x00A0, 0x00A9 ), /* Latin-1 Supplement (no control chars) */
+ AF_UNIRANGE_REC( 0x00AB, 0x00B1 ), /* ... continued */
+ AF_UNIRANGE_REC( 0x00B4, 0x00B8 ), /* ... continued */
+ AF_UNIRANGE_REC( 0x00BB, 0x00FF ), /* ... continued */
+ AF_UNIRANGE_REC( 0x0100, 0x017F ), /* Latin Extended-A */
+ AF_UNIRANGE_REC( 0x0180, 0x024F ), /* Latin Extended-B */
+ AF_UNIRANGE_REC( 0x0250, 0x02AF ), /* IPA Extensions */
+ AF_UNIRANGE_REC( 0x02B9, 0x02DF ), /* Spacing Modifier Letters */
+ AF_UNIRANGE_REC( 0x02E5, 0x02FF ), /* ... continued */
+ AF_UNIRANGE_REC( 0x0300, 0x036F ), /* Combining Diacritical Marks */
+ AF_UNIRANGE_REC( 0x1AB0, 0x1ABE ), /* Combining Diacritical Marks Extended */
+ AF_UNIRANGE_REC( 0x1D00, 0x1D2B ), /* Phonetic Extensions */
+ AF_UNIRANGE_REC( 0x1D6B, 0x1D77 ), /* ... continued */
+ AF_UNIRANGE_REC( 0x1D79, 0x1D7F ), /* ... continued */
+ AF_UNIRANGE_REC( 0x1D80, 0x1D9A ), /* Phonetic Extensions Supplement */
+ AF_UNIRANGE_REC( 0x1DC0, 0x1DFF ), /* Combining Diacritical Marks Supplement */
+ AF_UNIRANGE_REC( 0x1E00, 0x1EFF ), /* Latin Extended Additional */
+ AF_UNIRANGE_REC( 0x2000, 0x206F ), /* General Punctuation */
+ AF_UNIRANGE_REC( 0x20A0, 0x20B8 ), /* Currency Symbols ... */
+ AF_UNIRANGE_REC( 0x20BA, 0x20CF ), /* ... except new Rupee sign */
+ AF_UNIRANGE_REC( 0x2150, 0x218F ), /* Number Forms */
+ AF_UNIRANGE_REC( 0x2C60, 0x2C7B ), /* Latin Extended-C */
+ AF_UNIRANGE_REC( 0x2C7E, 0x2C7F ), /* ... continued */
+ AF_UNIRANGE_REC( 0x2E00, 0x2E7F ), /* Supplemental Punctuation */
+ AF_UNIRANGE_REC( 0xA720, 0xA76F ), /* Latin Extended-D */
+ AF_UNIRANGE_REC( 0xA771, 0xA7F7 ), /* ... continued */
+ AF_UNIRANGE_REC( 0xA7FA, 0xA7FF ), /* ... continued */
+ AF_UNIRANGE_REC( 0xAB30, 0xAB5B ), /* Latin Extended-E */
+ AF_UNIRANGE_REC( 0xAB60, 0xAB6F ), /* ... continued */
+ AF_UNIRANGE_REC( 0xFB00, 0xFB06 ), /* Alphab. Present. Forms (Latin Ligs) */
+ AF_UNIRANGE_REC( 0x1D400, 0x1D7FF ), /* Mathematical Alphanumeric Symbols */
+ AF_UNIRANGE_REC( 0, 0 )
};
const AF_Script_UniRangeRec af_latn_nonbase_uniranges[] =
{
- AF_UNIRANGE_REC( 0x005EUL, 0x0060UL ),
- AF_UNIRANGE_REC( 0x007EUL, 0x007EUL ),
- AF_UNIRANGE_REC( 0x00A8UL, 0x00A9UL ),
- AF_UNIRANGE_REC( 0x00AEUL, 0x00B0UL ),
- AF_UNIRANGE_REC( 0x00B4UL, 0x00B4UL ),
- AF_UNIRANGE_REC( 0x00B8UL, 0x00B8UL ),
- AF_UNIRANGE_REC( 0x00BCUL, 0x00BEUL ),
- AF_UNIRANGE_REC( 0x02B9UL, 0x02DFUL ),
- AF_UNIRANGE_REC( 0x02E5UL, 0x02FFUL ),
- AF_UNIRANGE_REC( 0x0300UL, 0x036FUL ),
- AF_UNIRANGE_REC( 0x1AB0UL, 0x1ABEUL ),
- AF_UNIRANGE_REC( 0x1DC0UL, 0x1DFFUL ),
- AF_UNIRANGE_REC( 0x2017UL, 0x2017UL ),
- AF_UNIRANGE_REC( 0x203EUL, 0x203EUL ),
- AF_UNIRANGE_REC( 0xA788UL, 0xA788UL ),
- AF_UNIRANGE_REC( 0xA7F8UL, 0xA7FAUL ),
- AF_UNIRANGE_REC( 0UL, 0UL )
+ AF_UNIRANGE_REC( 0x005E, 0x0060 ),
+ AF_UNIRANGE_REC( 0x007E, 0x007E ),
+ AF_UNIRANGE_REC( 0x00A8, 0x00A9 ),
+ AF_UNIRANGE_REC( 0x00AE, 0x00B0 ),
+ AF_UNIRANGE_REC( 0x00B4, 0x00B4 ),
+ AF_UNIRANGE_REC( 0x00B8, 0x00B8 ),
+ AF_UNIRANGE_REC( 0x00BC, 0x00BE ),
+ AF_UNIRANGE_REC( 0x02B9, 0x02DF ),
+ AF_UNIRANGE_REC( 0x02E5, 0x02FF ),
+ AF_UNIRANGE_REC( 0x0300, 0x036F ),
+ AF_UNIRANGE_REC( 0x1AB0, 0x1ABE ),
+ AF_UNIRANGE_REC( 0x1DC0, 0x1DFF ),
+ AF_UNIRANGE_REC( 0x2017, 0x2017 ),
+ AF_UNIRANGE_REC( 0x203E, 0x203E ),
+ AF_UNIRANGE_REC( 0xA788, 0xA788 ),
+ AF_UNIRANGE_REC( 0xA7F8, 0xA7FA ),
+ AF_UNIRANGE_REC( 0, 0 )
};
- const AF_Script_UniRangeRec af_latb_uniranges[] =
+ const AF_Script_UniRangeRec af_latb_uniranges[] =
{
- AF_UNIRANGE_REC( 0x1D62UL, 0x1D6AUL ), /* some small subscript letters */
- AF_UNIRANGE_REC( 0x2080UL, 0x209CUL ), /* subscript digits and letters */
- AF_UNIRANGE_REC( 0x2C7CUL, 0x2C7CUL ), /* latin subscript small letter j */
- AF_UNIRANGE_REC( 0UL, 0UL )
+ AF_UNIRANGE_REC( 0x1D62, 0x1D6A ), /* some small subscript letters */
+ AF_UNIRANGE_REC( 0x2080, 0x209C ), /* subscript digits and letters */
+ AF_UNIRANGE_REC( 0x2C7C, 0x2C7C ), /* latin subscript small letter j */
+ AF_UNIRANGE_REC( 0, 0 )
};
- const AF_Script_UniRangeRec af_latb_nonbase_uniranges[] =
+ const AF_Script_UniRangeRec af_latb_nonbase_uniranges[] =
{
- AF_UNIRANGE_REC( 0UL, 0UL )
+ AF_UNIRANGE_REC( 0, 0 )
};
- const AF_Script_UniRangeRec af_latp_uniranges[] =
+ const AF_Script_UniRangeRec af_latp_uniranges[] =
{
- AF_UNIRANGE_REC( 0x00AAUL, 0x00AAUL ), /* feminine ordinal indicator */
- AF_UNIRANGE_REC( 0x00B2UL, 0x00B3UL ), /* superscript two and three */
- AF_UNIRANGE_REC( 0x00B9UL, 0x00BAUL ), /* superscript one, masc. ord. indic. */
- AF_UNIRANGE_REC( 0x02B0UL, 0x02B8UL ), /* some latin superscript mod. letters */
- AF_UNIRANGE_REC( 0x02E0UL, 0x02E4UL ), /* some IPA modifier letters */
- AF_UNIRANGE_REC( 0x1D2CUL, 0x1D61UL ), /* latin superscript modifier letters */
- AF_UNIRANGE_REC( 0x1D78UL, 0x1D78UL ), /* modifier letter cyrillic en */
- AF_UNIRANGE_REC( 0x1D9BUL, 0x1DBFUL ), /* more modifier letters */
- AF_UNIRANGE_REC( 0x2070UL, 0x207FUL ), /* superscript digits and letters */
- AF_UNIRANGE_REC( 0x2C7DUL, 0x2C7DUL ), /* modifier letter capital v */
- AF_UNIRANGE_REC( 0xA770UL, 0xA770UL ), /* modifier letter us */
- AF_UNIRANGE_REC( 0xA7F8UL, 0xA7F9UL ), /* more modifier letters */
- AF_UNIRANGE_REC( 0xAB5CUL, 0xAB5FUL ), /* more modifier letters */
- AF_UNIRANGE_REC( 0UL, 0UL )
+ AF_UNIRANGE_REC( 0x00AA, 0x00AA ), /* feminine ordinal indicator */
+ AF_UNIRANGE_REC( 0x00B2, 0x00B3 ), /* superscript two and three */
+ AF_UNIRANGE_REC( 0x00B9, 0x00BA ), /* superscript one, masc. ord. indic. */
+ AF_UNIRANGE_REC( 0x02B0, 0x02B8 ), /* some latin superscript mod. letters */
+ AF_UNIRANGE_REC( 0x02E0, 0x02E4 ), /* some IPA modifier letters */
+ AF_UNIRANGE_REC( 0x1D2C, 0x1D61 ), /* latin superscript modifier letters */
+ AF_UNIRANGE_REC( 0x1D78, 0x1D78 ), /* modifier letter cyrillic en */
+ AF_UNIRANGE_REC( 0x1D9B, 0x1DBF ), /* more modifier letters */
+ AF_UNIRANGE_REC( 0x2070, 0x207F ), /* superscript digits and letters */
+ AF_UNIRANGE_REC( 0x2C7D, 0x2C7D ), /* modifier letter capital v */
+ AF_UNIRANGE_REC( 0xA770, 0xA770 ), /* modifier letter us */
+ AF_UNIRANGE_REC( 0xA7F8, 0xA7F9 ), /* more modifier letters */
+ AF_UNIRANGE_REC( 0xAB5C, 0xAB5F ), /* more modifier letters */
+ AF_UNIRANGE_REC( 0, 0 )
};
- const AF_Script_UniRangeRec af_latp_nonbase_uniranges[] =
+ const AF_Script_UniRangeRec af_latp_nonbase_uniranges[] =
{
- AF_UNIRANGE_REC( 0UL, 0UL )
+ AF_UNIRANGE_REC( 0, 0 )
};
- const AF_Script_UniRangeRec af_none_uniranges[] =
+ const AF_Script_UniRangeRec af_lisu_uniranges[] =
{
- AF_UNIRANGE_REC( 0UL, 0UL )
+ AF_UNIRANGE_REC( 0xA4D0, 0xA4FF ), /* Lisu */
+ AF_UNIRANGE_REC( 0, 0 )
};
- const AF_Script_UniRangeRec af_none_nonbase_uniranges[] =
+ const AF_Script_UniRangeRec af_lisu_nonbase_uniranges[] =
{
- AF_UNIRANGE_REC( 0UL, 0UL )
+ AF_UNIRANGE_REC( 0, 0 )
};
- const AF_Script_UniRangeRec af_telu_uniranges[] =
+ const AF_Script_UniRangeRec af_mlym_uniranges[] =
{
- AF_UNIRANGE_REC( 0x0C00UL, 0x0C7FUL ), /* Telugu */
- AF_UNIRANGE_REC( 0UL, 0UL )
+ AF_UNIRANGE_REC( 0x0D00, 0x0D7F ), /* Malayalam */
+ AF_UNIRANGE_REC( 0, 0 )
};
- const AF_Script_UniRangeRec af_telu_nonbase_uniranges[] =
+ const AF_Script_UniRangeRec af_mlym_nonbase_uniranges[] =
{
- AF_UNIRANGE_REC( 0x0C00UL, 0x0C00UL ),
- AF_UNIRANGE_REC( 0x0C3EUL, 0x0C40UL ),
- AF_UNIRANGE_REC( 0x0C46UL, 0x0C56UL ),
- AF_UNIRANGE_REC( 0x0C62UL, 0x0C63UL ),
- AF_UNIRANGE_REC( 0UL, 0UL )
+ AF_UNIRANGE_REC( 0x0D00, 0x0D01 ),
+ AF_UNIRANGE_REC( 0x0D3B, 0x0D3C ),
+ AF_UNIRANGE_REC( 0x0D4D, 0x0D4E ),
+ AF_UNIRANGE_REC( 0x0D62, 0x0D63 ),
+ AF_UNIRANGE_REC( 0, 0 )
};
- const AF_Script_UniRangeRec af_thai_uniranges[] =
+ const AF_Script_UniRangeRec af_mymr_uniranges[] =
{
- AF_UNIRANGE_REC( 0x0E00UL, 0x0E7FUL ), /* Thai */
- AF_UNIRANGE_REC( 0UL, 0UL )
+ 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_thai_nonbase_uniranges[] =
+ const AF_Script_UniRangeRec af_mymr_nonbase_uniranges[] =
{
- AF_UNIRANGE_REC( 0x0E31UL, 0x0E31UL ),
- AF_UNIRANGE_REC( 0x0E34UL, 0x0E3AUL ),
- AF_UNIRANGE_REC( 0x0E47UL, 0x0E4EUL ),
- AF_UNIRANGE_REC( 0UL, 0UL )
+ 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 )
};
-#ifdef AF_CONFIG_OPTION_INDIC
+ const AF_Script_UniRangeRec af_nkoo_uniranges[] =
+ {
+ AF_UNIRANGE_REC( 0x07C0, 0x07FF ), /* N'Ko */
+ AF_UNIRANGE_REC( 0, 0 )
+ };
- const AF_Script_UniRangeRec af_beng_uniranges[] =
+ const AF_Script_UniRangeRec af_nkoo_nonbase_uniranges[] =
{
- AF_UNIRANGE_REC( 0x0980UL, 0x09FFUL ), /* Bengali */
- AF_UNIRANGE_REC( 0UL, 0UL )
+ AF_UNIRANGE_REC( 0x07EB, 0x07F5 ),
+ AF_UNIRANGE_REC( 0x07FD, 0x07FD ),
+ AF_UNIRANGE_REC( 0, 0 )
};
- const AF_Script_UniRangeRec af_beng_nonbase_uniranges[] =
+
+ const AF_Script_UniRangeRec af_none_uniranges[] =
{
- AF_UNIRANGE_REC( 0x0981UL, 0x0981UL ),
- AF_UNIRANGE_REC( 0x09BCUL, 0x09BCUL ),
- AF_UNIRANGE_REC( 0x09C1UL, 0x09C4UL ),
- AF_UNIRANGE_REC( 0x09CDUL, 0x09CDUL ),
- AF_UNIRANGE_REC( 0x09E2UL, 0x09E3UL ),
- AF_UNIRANGE_REC( 0UL, 0UL )
+ AF_UNIRANGE_REC( 0, 0 )
};
+ const AF_Script_UniRangeRec af_none_nonbase_uniranges[] =
+ {
+ AF_UNIRANGE_REC( 0, 0 )
+ };
- const AF_Script_UniRangeRec af_gujr_uniranges[] =
+
+ const AF_Script_UniRangeRec af_olck_uniranges[] =
{
- AF_UNIRANGE_REC( 0x0A80UL, 0x0AFFUL ), /* Gujarati */
- AF_UNIRANGE_REC( 0UL, 0UL )
+ AF_UNIRANGE_REC( 0x1C50, 0x1C7F ), /* Ol Chiki */
+ AF_UNIRANGE_REC( 0, 0 )
};
- const AF_Script_UniRangeRec af_gujr_nonbase_uniranges[] =
+ const AF_Script_UniRangeRec af_olck_nonbase_uniranges[] =
{
- AF_UNIRANGE_REC( 0x0A81UL, 0x0A82UL ),
- AF_UNIRANGE_REC( 0x0ABCUL, 0x0ABCUL ),
- AF_UNIRANGE_REC( 0x0AC1UL, 0x0AC8UL ),
- AF_UNIRANGE_REC( 0x0ACDUL, 0x0ACDUL ),
- AF_UNIRANGE_REC( 0x0AE2UL, 0x0AE3UL ),
- AF_UNIRANGE_REC( 0UL, 0UL )
+ AF_UNIRANGE_REC( 0, 0 )
};
- const AF_Script_UniRangeRec af_guru_uniranges[] =
+ const AF_Script_UniRangeRec af_orkh_uniranges[] =
{
- AF_UNIRANGE_REC( 0x0A00UL, 0x0A7FUL ), /* Gurmukhi */
- AF_UNIRANGE_REC( 0UL, 0UL )
+ AF_UNIRANGE_REC( 0x10C00, 0x10C4F ), /* Old Turkic */
+ AF_UNIRANGE_REC( 0, 0 )
};
- const AF_Script_UniRangeRec af_guru_nonbase_uniranges[] =
+ const AF_Script_UniRangeRec af_orkh_nonbase_uniranges[] =
{
- AF_UNIRANGE_REC( 0x0A01UL, 0x0A02UL ),
- AF_UNIRANGE_REC( 0x0A3CUL, 0x0A3EUL ),
- AF_UNIRANGE_REC( 0x0A41UL, 0x0A51UL ),
- AF_UNIRANGE_REC( 0x0A70UL, 0x0A71UL ),
- AF_UNIRANGE_REC( 0x0A75UL, 0x0A75UL ),
- AF_UNIRANGE_REC( 0UL, 0UL )
+ AF_UNIRANGE_REC( 0, 0 )
};
- const AF_Script_UniRangeRec af_knda_uniranges[] =
+ const AF_Script_UniRangeRec af_osge_uniranges[] =
{
- AF_UNIRANGE_REC( 0x0C80UL, 0x0CFFUL ), /* Kannada */
- AF_UNIRANGE_REC( 0UL, 0UL )
+ AF_UNIRANGE_REC( 0x104B0, 0x104FF ), /* Osage */
+ AF_UNIRANGE_REC( 0, 0 )
};
- const AF_Script_UniRangeRec af_knda_nonbase_uniranges[] =
+ const AF_Script_UniRangeRec af_osge_nonbase_uniranges[] =
{
- AF_UNIRANGE_REC( 0x0C81UL, 0x0C81UL ),
- AF_UNIRANGE_REC( 0x0CBCUL, 0x0CBCUL ),
- AF_UNIRANGE_REC( 0x0CBFUL, 0x0CBFUL ),
- AF_UNIRANGE_REC( 0x0CC6UL, 0x0CC6UL ),
- AF_UNIRANGE_REC( 0x0CCCUL, 0x0CCDUL ),
- AF_UNIRANGE_REC( 0x0CE2UL, 0x0CE3UL ),
- AF_UNIRANGE_REC( 0UL, 0UL )
+ AF_UNIRANGE_REC( 0, 0 )
};
- const AF_Script_UniRangeRec af_limb_uniranges[] =
+ const AF_Script_UniRangeRec af_osma_uniranges[] =
{
- AF_UNIRANGE_REC( 0x1900UL, 0x194FUL ), /* Limbu */
- AF_UNIRANGE_REC( 0UL, 0UL )
+ AF_UNIRANGE_REC( 0x10480, 0x104AF ), /* Osmanya */
+ AF_UNIRANGE_REC( 0, 0 )
};
- const AF_Script_UniRangeRec af_limb_nonbase_uniranges[] =
+ const AF_Script_UniRangeRec af_osma_nonbase_uniranges[] =
{
- AF_UNIRANGE_REC( 0x1920UL, 0x1922UL ),
- AF_UNIRANGE_REC( 0x1927UL, 0x1934UL ),
- AF_UNIRANGE_REC( 0x1937UL, 0x193BUL ),
- AF_UNIRANGE_REC( 0UL, 0UL )
+ AF_UNIRANGE_REC( 0, 0 )
};
- const AF_Script_UniRangeRec af_mlym_uniranges[] =
+ const AF_Script_UniRangeRec af_saur_uniranges[] =
{
- AF_UNIRANGE_REC( 0x0D00UL, 0x0D7FUL ), /* Malayalam */
- AF_UNIRANGE_REC( 0UL, 0UL )
+ AF_UNIRANGE_REC( 0xA880, 0xA8DF ), /* Saurashtra */
+ AF_UNIRANGE_REC( 0, 0 )
};
- const AF_Script_UniRangeRec af_mlym_nonbase_uniranges[] =
+ const AF_Script_UniRangeRec af_saur_nonbase_uniranges[] =
{
- AF_UNIRANGE_REC( 0x0D01UL, 0x0D01UL ),
- AF_UNIRANGE_REC( 0x0D4DUL, 0x0D4EUL ),
- AF_UNIRANGE_REC( 0x0D62UL, 0x0D63UL ),
- AF_UNIRANGE_REC( 0UL, 0UL )
+ AF_UNIRANGE_REC( 0xA880, 0xA881 ),
+ AF_UNIRANGE_REC( 0xA8B4, 0xA8C5 ),
+ AF_UNIRANGE_REC( 0, 0 )
};
- const AF_Script_UniRangeRec af_orya_uniranges[] =
+ const AF_Script_UniRangeRec af_shaw_uniranges[] =
{
- AF_UNIRANGE_REC( 0x0B00UL, 0x0B7FUL ), /* Oriya */
- AF_UNIRANGE_REC( 0UL, 0UL )
+ AF_UNIRANGE_REC( 0x10450, 0x1047F ), /* Shavian */
+ AF_UNIRANGE_REC( 0, 0 )
};
- const AF_Script_UniRangeRec af_orya_nonbase_uniranges[] =
+ const AF_Script_UniRangeRec af_shaw_nonbase_uniranges[] =
{
- AF_UNIRANGE_REC( 0x0B01UL, 0x0B02UL ),
- AF_UNIRANGE_REC( 0x0B3CUL, 0x0B3CUL ),
- AF_UNIRANGE_REC( 0x0B3FUL, 0x0B3FUL ),
- AF_UNIRANGE_REC( 0x0B41UL, 0x0B44UL ),
- AF_UNIRANGE_REC( 0x0B4DUL, 0x0B56UL ),
- AF_UNIRANGE_REC( 0x0B62UL, 0x0B63UL ),
- AF_UNIRANGE_REC( 0UL, 0UL )
+ AF_UNIRANGE_REC( 0, 0 )
};
const AF_Script_UniRangeRec af_sinh_uniranges[] =
{
- AF_UNIRANGE_REC( 0x0D80UL, 0x0DFFUL ), /* Sinhala */
- AF_UNIRANGE_REC( 0UL, 0UL )
+ AF_UNIRANGE_REC( 0x0D80, 0x0DFF ), /* Sinhala */
+ AF_UNIRANGE_REC( 0, 0 )
};
const AF_Script_UniRangeRec af_sinh_nonbase_uniranges[] =
{
- AF_UNIRANGE_REC( 0x0DCAUL, 0x0DCAUL ),
- AF_UNIRANGE_REC( 0x0DD2UL, 0x0DD6UL ),
- AF_UNIRANGE_REC( 0UL, 0UL )
+ AF_UNIRANGE_REC( 0x0DCA, 0x0DCA ),
+ AF_UNIRANGE_REC( 0x0DD2, 0x0DD6 ),
+ AF_UNIRANGE_REC( 0, 0 )
};
const AF_Script_UniRangeRec af_sund_uniranges[] =
{
- AF_UNIRANGE_REC( 0x1B80UL, 0x1BBFUL ), /* Sundanese */
- AF_UNIRANGE_REC( 0x1CC0UL, 0x1CCFUL ), /* Sundanese Supplement */
- AF_UNIRANGE_REC( 0UL, 0UL )
+ 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( 0x1B80UL, 0x1B82UL ),
- AF_UNIRANGE_REC( 0x1BA1UL, 0x1BADUL ),
- AF_UNIRANGE_REC( 0UL, 0UL )
+ AF_UNIRANGE_REC( 0x1B80, 0x1B82 ),
+ AF_UNIRANGE_REC( 0x1BA1, 0x1BAD ),
+ AF_UNIRANGE_REC( 0, 0 )
};
- const AF_Script_UniRangeRec af_sylo_uniranges[] =
+ const AF_Script_UniRangeRec af_taml_uniranges[] =
{
- AF_UNIRANGE_REC( 0xA800UL, 0xA82FUL ), /* Syloti Nagri */
- AF_UNIRANGE_REC( 0UL, 0UL )
+ AF_UNIRANGE_REC( 0x0B80, 0x0BFF ), /* Tamil */
+ AF_UNIRANGE_REC( 0, 0 )
};
- const AF_Script_UniRangeRec af_sylo_nonbase_uniranges[] =
+ const AF_Script_UniRangeRec af_taml_nonbase_uniranges[] =
{
- AF_UNIRANGE_REC( 0xA802UL, 0xA802UL ),
- AF_UNIRANGE_REC( 0xA806UL, 0xA806UL ),
- AF_UNIRANGE_REC( 0xA80BUL, 0xA80BUL ),
- AF_UNIRANGE_REC( 0xA825UL, 0xA826UL ),
- AF_UNIRANGE_REC( 0UL, 0UL )
+ AF_UNIRANGE_REC( 0x0B82, 0x0B82 ),
+ AF_UNIRANGE_REC( 0x0BC0, 0x0BC2 ),
+ AF_UNIRANGE_REC( 0x0BCD, 0x0BCD ),
+ AF_UNIRANGE_REC( 0, 0 )
};
- const AF_Script_UniRangeRec af_taml_uniranges[] =
+ const AF_Script_UniRangeRec af_tavt_uniranges[] =
{
- AF_UNIRANGE_REC( 0x0B80UL, 0x0BFFUL ), /* Tamil */
- AF_UNIRANGE_REC( 0UL, 0UL )
+ AF_UNIRANGE_REC( 0xAA80, 0xAADF ), /* Tai Viet */
+ AF_UNIRANGE_REC( 0, 0 )
};
- const AF_Script_UniRangeRec af_taml_nonbase_uniranges[] =
+ 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 */
+ AF_UNIRANGE_REC( 0, 0 )
+ };
+
+ const AF_Script_UniRangeRec af_telu_nonbase_uniranges[] =
+ {
+ AF_UNIRANGE_REC( 0x0C00, 0x0C00 ),
+ AF_UNIRANGE_REC( 0x0C04, 0x0C04 ),
+ AF_UNIRANGE_REC( 0x0C3E, 0x0C40 ),
+ AF_UNIRANGE_REC( 0x0C46, 0x0C56 ),
+ AF_UNIRANGE_REC( 0x0C62, 0x0C63 ),
+ AF_UNIRANGE_REC( 0, 0 )
+ };
+
+
+ const AF_Script_UniRangeRec af_thai_uniranges[] =
+ {
+ AF_UNIRANGE_REC( 0x0E00, 0x0E7F ), /* Thai */
+ AF_UNIRANGE_REC( 0, 0 )
+ };
+
+ const AF_Script_UniRangeRec af_thai_nonbase_uniranges[] =
+ {
+ AF_UNIRANGE_REC( 0x0E31, 0x0E31 ),
+ AF_UNIRANGE_REC( 0x0E34, 0x0E3A ),
+ AF_UNIRANGE_REC( 0x0E47, 0x0E4E ),
+ AF_UNIRANGE_REC( 0, 0 )
+ };
+
+
+ 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[] =
+ {
+ AF_UNIRANGE_REC( 0x1900, 0x194F ), /* Limbu */
+ AF_UNIRANGE_REC( 0, 0 )
+ };
+
+ const AF_Script_UniRangeRec af_limb_nonbase_uniranges[] =
+ {
+ AF_UNIRANGE_REC( 0x1920, 0x1922 ),
+ AF_UNIRANGE_REC( 0x1927, 0x1934 ),
+ AF_UNIRANGE_REC( 0x1937, 0x193B ),
+ AF_UNIRANGE_REC( 0, 0 )
+ };
+
+
+ const AF_Script_UniRangeRec af_orya_uniranges[] =
+ {
+ AF_UNIRANGE_REC( 0x0B00, 0x0B7F ), /* Oriya */
+ AF_UNIRANGE_REC( 0, 0 )
+ };
+
+ const AF_Script_UniRangeRec af_orya_nonbase_uniranges[] =
+ {
+ AF_UNIRANGE_REC( 0x0B01, 0x0B02 ),
+ AF_UNIRANGE_REC( 0x0B3C, 0x0B3C ),
+ AF_UNIRANGE_REC( 0x0B3F, 0x0B3F ),
+ AF_UNIRANGE_REC( 0x0B41, 0x0B44 ),
+ AF_UNIRANGE_REC( 0x0B4D, 0x0B56 ),
+ AF_UNIRANGE_REC( 0x0B62, 0x0B63 ),
+ AF_UNIRANGE_REC( 0, 0 )
+ };
+
+
+ const AF_Script_UniRangeRec af_sylo_uniranges[] =
+ {
+ AF_UNIRANGE_REC( 0xA800, 0xA82F ), /* Syloti Nagri */
+ AF_UNIRANGE_REC( 0, 0 )
+ };
+
+ const AF_Script_UniRangeRec af_sylo_nonbase_uniranges[] =
{
- AF_UNIRANGE_REC( 0x0B82UL, 0x0B82UL ),
- AF_UNIRANGE_REC( 0x0BC0UL, 0x0BC2UL ),
- AF_UNIRANGE_REC( 0x0BCDUL, 0x0BCDUL ),
- AF_UNIRANGE_REC( 0UL, 0UL )
+ AF_UNIRANGE_REC( 0xA802, 0xA802 ),
+ AF_UNIRANGE_REC( 0xA806, 0xA806 ),
+ AF_UNIRANGE_REC( 0xA80B, 0xA80B ),
+ AF_UNIRANGE_REC( 0xA825, 0xA826 ),
+ AF_UNIRANGE_REC( 0, 0 )
};
const AF_Script_UniRangeRec af_tibt_uniranges[] =
{
- AF_UNIRANGE_REC( 0x0F00UL, 0x0FFFUL ), /* Tibetan */
- AF_UNIRANGE_REC( 0UL, 0UL )
+ AF_UNIRANGE_REC( 0x0F00, 0x0FFF ), /* Tibetan */
+ AF_UNIRANGE_REC( 0, 0 )
};
const AF_Script_UniRangeRec af_tibt_nonbase_uniranges[] =
{
- AF_UNIRANGE_REC( 0x0F18UL, 0x0F19UL ),
- AF_UNIRANGE_REC( 0x0F35UL, 0x0F35UL ),
- AF_UNIRANGE_REC( 0x0F37UL, 0x0F37UL ),
- AF_UNIRANGE_REC( 0x0F39UL, 0x0F39UL ),
- AF_UNIRANGE_REC( 0x0F3EUL, 0x0F3FUL ),
- AF_UNIRANGE_REC( 0x0F71UL, 0x0F7EUL ),
- AF_UNIRANGE_REC( 0x0F80UL, 0x0F84UL ),
- AF_UNIRANGE_REC( 0x0F86UL, 0x0F87UL ),
- AF_UNIRANGE_REC( 0x0F8DUL, 0x0FBCUL ),
- AF_UNIRANGE_REC( 0UL, 0UL )
+ AF_UNIRANGE_REC( 0x0F18, 0x0F19 ),
+ AF_UNIRANGE_REC( 0x0F35, 0x0F35 ),
+ AF_UNIRANGE_REC( 0x0F37, 0x0F37 ),
+ AF_UNIRANGE_REC( 0x0F39, 0x0F39 ),
+ AF_UNIRANGE_REC( 0x0F3E, 0x0F3F ),
+ AF_UNIRANGE_REC( 0x0F71, 0x0F7E ),
+ AF_UNIRANGE_REC( 0x0F80, 0x0F84 ),
+ AF_UNIRANGE_REC( 0x0F86, 0x0F87 ),
+ AF_UNIRANGE_REC( 0x0F8D, 0x0FBC ),
+ AF_UNIRANGE_REC( 0, 0 )
};
#endif /* !AF_CONFIG_OPTION_INDIC */
@@ -540,44 +985,47 @@
const AF_Script_UniRangeRec af_hani_uniranges[] =
{
- AF_UNIRANGE_REC( 0x1100UL, 0x11FFUL ), /* Hangul Jamo */
- AF_UNIRANGE_REC( 0x2E80UL, 0x2EFFUL ), /* CJK Radicals Supplement */
- AF_UNIRANGE_REC( 0x2F00UL, 0x2FDFUL ), /* Kangxi Radicals */
- AF_UNIRANGE_REC( 0x2FF0UL, 0x2FFFUL ), /* Ideographic Description Characters */
- AF_UNIRANGE_REC( 0x3000UL, 0x303FUL ), /* CJK Symbols and Punctuation */
- AF_UNIRANGE_REC( 0x3040UL, 0x309FUL ), /* Hiragana */
- AF_UNIRANGE_REC( 0x30A0UL, 0x30FFUL ), /* Katakana */
- AF_UNIRANGE_REC( 0x3100UL, 0x312FUL ), /* Bopomofo */
- AF_UNIRANGE_REC( 0x3130UL, 0x318FUL ), /* Hangul Compatibility Jamo */
- AF_UNIRANGE_REC( 0x3190UL, 0x319FUL ), /* Kanbun */
- AF_UNIRANGE_REC( 0x31A0UL, 0x31BFUL ), /* Bopomofo Extended */
- AF_UNIRANGE_REC( 0x31C0UL, 0x31EFUL ), /* CJK Strokes */
- AF_UNIRANGE_REC( 0x31F0UL, 0x31FFUL ), /* Katakana Phonetic Extensions */
- AF_UNIRANGE_REC( 0x3300UL, 0x33FFUL ), /* CJK Compatibility */
- AF_UNIRANGE_REC( 0x3400UL, 0x4DBFUL ), /* CJK Unified Ideographs Extension A */
- AF_UNIRANGE_REC( 0x4DC0UL, 0x4DFFUL ), /* Yijing Hexagram Symbols */
- AF_UNIRANGE_REC( 0x4E00UL, 0x9FFFUL ), /* CJK Unified Ideographs */
- AF_UNIRANGE_REC( 0xA960UL, 0xA97FUL ), /* Hangul Jamo Extended-A */
- AF_UNIRANGE_REC( 0xAC00UL, 0xD7AFUL ), /* Hangul Syllables */
- AF_UNIRANGE_REC( 0xD7B0UL, 0xD7FFUL ), /* Hangul Jamo Extended-B */
- AF_UNIRANGE_REC( 0xF900UL, 0xFAFFUL ), /* CJK Compatibility Ideographs */
- AF_UNIRANGE_REC( 0xFE10UL, 0xFE1FUL ), /* Vertical forms */
- AF_UNIRANGE_REC( 0xFE30UL, 0xFE4FUL ), /* CJK Compatibility Forms */
- AF_UNIRANGE_REC( 0xFF00UL, 0xFFEFUL ), /* Halfwidth and Fullwidth Forms */
- AF_UNIRANGE_REC( 0x1B000UL, 0x1B0FFUL ), /* Kana Supplement */
- AF_UNIRANGE_REC( 0x1D300UL, 0x1D35FUL ), /* Tai Xuan Hing Symbols */
- AF_UNIRANGE_REC( 0x20000UL, 0x2A6DFUL ), /* CJK Unified Ideographs Extension B */
- AF_UNIRANGE_REC( 0x2A700UL, 0x2B73FUL ), /* CJK Unified Ideographs Extension C */
- AF_UNIRANGE_REC( 0x2B740UL, 0x2B81FUL ), /* CJK Unified Ideographs Extension D */
- AF_UNIRANGE_REC( 0x2F800UL, 0x2FA1FUL ), /* CJK Compatibility Ideographs Supplement */
- AF_UNIRANGE_REC( 0UL, 0UL )
+ AF_UNIRANGE_REC( 0x1100, 0x11FF ), /* Hangul Jamo */
+ AF_UNIRANGE_REC( 0x2E80, 0x2EFF ), /* CJK Radicals Supplement */
+ AF_UNIRANGE_REC( 0x2F00, 0x2FDF ), /* Kangxi Radicals */
+ AF_UNIRANGE_REC( 0x2FF0, 0x2FFF ), /* Ideographic Description Characters */
+ AF_UNIRANGE_REC( 0x3000, 0x303F ), /* CJK Symbols and Punctuation */
+ AF_UNIRANGE_REC( 0x3040, 0x309F ), /* Hiragana */
+ AF_UNIRANGE_REC( 0x30A0, 0x30FF ), /* Katakana */
+ AF_UNIRANGE_REC( 0x3100, 0x312F ), /* Bopomofo */
+ AF_UNIRANGE_REC( 0x3130, 0x318F ), /* Hangul Compatibility Jamo */
+ AF_UNIRANGE_REC( 0x3190, 0x319F ), /* Kanbun */
+ AF_UNIRANGE_REC( 0x31A0, 0x31BF ), /* Bopomofo Extended */
+ AF_UNIRANGE_REC( 0x31C0, 0x31EF ), /* CJK Strokes */
+ AF_UNIRANGE_REC( 0x31F0, 0x31FF ), /* Katakana Phonetic Extensions */
+ AF_UNIRANGE_REC( 0x3300, 0x33FF ), /* CJK Compatibility */
+ AF_UNIRANGE_REC( 0x3400, 0x4DBF ), /* CJK Unified Ideographs Extension A */
+ AF_UNIRANGE_REC( 0x4DC0, 0x4DFF ), /* Yijing Hexagram Symbols */
+ AF_UNIRANGE_REC( 0x4E00, 0x9FFF ), /* CJK Unified Ideographs */
+ AF_UNIRANGE_REC( 0xA960, 0xA97F ), /* Hangul Jamo Extended-A */
+ AF_UNIRANGE_REC( 0xAC00, 0xD7AF ), /* Hangul Syllables */
+ AF_UNIRANGE_REC( 0xD7B0, 0xD7FF ), /* Hangul Jamo Extended-B */
+ AF_UNIRANGE_REC( 0xF900, 0xFAFF ), /* CJK Compatibility Ideographs */
+ AF_UNIRANGE_REC( 0xFE10, 0xFE1F ), /* Vertical forms */
+ AF_UNIRANGE_REC( 0xFE30, 0xFE4F ), /* CJK Compatibility Forms */
+ AF_UNIRANGE_REC( 0xFF00, 0xFFEF ), /* Halfwidth and Fullwidth Forms */
+ AF_UNIRANGE_REC( 0x1B000, 0x1B0FF ), /* Kana Supplement */
+ AF_UNIRANGE_REC( 0x1B100, 0x1B12F ), /* Kana Extended-A */
+ AF_UNIRANGE_REC( 0x1D300, 0x1D35F ), /* Tai Xuan Hing Symbols */
+ AF_UNIRANGE_REC( 0x20000, 0x2A6DF ), /* CJK Unified Ideographs Extension B */
+ AF_UNIRANGE_REC( 0x2A700, 0x2B73F ), /* CJK Unified Ideographs Extension C */
+ AF_UNIRANGE_REC( 0x2B740, 0x2B81F ), /* CJK Unified Ideographs Extension D */
+ AF_UNIRANGE_REC( 0x2B820, 0x2CEAF ), /* CJK Unified Ideographs Extension E */
+ AF_UNIRANGE_REC( 0x2CEB0, 0x2EBEF ), /* CJK Unified Ideographs Extension F */
+ AF_UNIRANGE_REC( 0x2F800, 0x2FA1F ), /* CJK Compatibility Ideographs Supplement */
+ AF_UNIRANGE_REC( 0, 0 )
};
const AF_Script_UniRangeRec af_hani_nonbase_uniranges[] =
{
- AF_UNIRANGE_REC( 0x302AUL, 0x302FUL ),
- AF_UNIRANGE_REC( 0x3190UL, 0x319FUL ),
- AF_UNIRANGE_REC( 0UL, 0UL )
+ AF_UNIRANGE_REC( 0x302A, 0x302F ),
+ AF_UNIRANGE_REC( 0x3190, 0x319F ),
+ AF_UNIRANGE_REC( 0, 0 )
};
#endif /* !AF_CONFIG_OPTION_CJK */
diff --git a/src/3rdparty/freetype/src/autofit/afranges.h b/src/3rdparty/freetype/src/autofit/afranges.h
index b080873e77..ba3b5e7ccb 100644
--- a/src/3rdparty/freetype/src/autofit/afranges.h
+++ b/src/3rdparty/freetype/src/autofit/afranges.h
@@ -4,7 +4,7 @@
/* */
/* Auto-fitter Unicode script ranges (specification). */
/* */
-/* Copyright 2013-2015 by */
+/* Copyright 2013-2018 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -16,8 +16,8 @@
/***************************************************************************/
-#ifndef __AFRANGES_H__
-#define __AFRANGES_H__
+#ifndef AFRANGES_H_
+#define AFRANGES_H_
#include "aftypes.h"
@@ -26,13 +26,13 @@
FT_BEGIN_HEADER
#undef SCRIPT
-#define SCRIPT( s, S, d, h, sc1, sc2, sc3 ) \
+#define SCRIPT( s, S, d, h, H, ss ) \
extern const AF_Script_UniRangeRec af_ ## s ## _uniranges[];
#include "afscript.h"
#undef SCRIPT
-#define SCRIPT( s, S, d, h, sc1, sc2, sc3 ) \
+#define SCRIPT( s, S, d, h, H, ss ) \
extern const AF_Script_UniRangeRec af_ ## s ## _nonbase_uniranges[];
#include "afscript.h"
@@ -41,7 +41,7 @@ FT_BEGIN_HEADER
FT_END_HEADER
-#endif /* __AFRANGES_H__ */
+#endif /* AFRANGES_H_ */
/* END */
diff --git a/src/3rdparty/freetype/src/autofit/afscript.h b/src/3rdparty/freetype/src/autofit/afscript.h
index b92e84f5ff..623a1734a6 100644
--- a/src/3rdparty/freetype/src/autofit/afscript.h
+++ b/src/3rdparty/freetype/src/autofit/afscript.h
@@ -4,7 +4,7 @@
/* */
/* Auto-fitter scripts (specification only). */
/* */
-/* Copyright 2013-2015 by */
+/* Copyright 2013-2018 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -30,129 +30,349 @@
/* 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,
- 0x644, 0x62D, 0x640 ) /* ل ح ـ */
+ HINTING_BOTTOM_TO_TOP,
+ "\xD9\x84 \xD8\xAD \xD9\x80" ) /* ل ح ـ */
+
+ SCRIPT( armn, ARMN,
+ "Armenian",
+ HB_SCRIPT_ARMENIAN,
+ HINTING_BOTTOM_TO_TOP,
+ "\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,
+ "Bengali",
+ HB_SCRIPT_BENGALI,
+ 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,
- 0x43E, 0x41E, 0x0 ) /* о О */
+ HINTING_BOTTOM_TO_TOP,
+ "\xD0\xBE \xD0\x9E" ) /* о О */
SCRIPT( deva, DEVA,
"Devanagari",
HB_SCRIPT_DEVANAGARI,
- 0x920, 0x935, 0x91F ) /* ठ व ट */
+ 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,
+ HINTING_BOTTOM_TO_TOP,
+ "\xE1\x8B\x90" ) /* ዐ */
+
+ SCRIPT( geor, GEOR,
+ "Georgian (Mkhedruli)",
+ HB_SCRIPT_GEORGIAN,
+ HINTING_BOTTOM_TO_TOP,
+ "\xE1\x83\x98 \xE1\x83\x94 \xE1\x83\x90 \xE1\xB2\xBF" ) /* ი ე ა Ი */
+
+ SCRIPT( geok, GEOK,
+ "Georgian (Khutsuri)",
+ HB_SCRIPT_INVALID,
+ 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,
- 0x3BF, 0x39F, 0x0 ) /* ο Ο */
+ HINTING_BOTTOM_TO_TOP,
+ "\xCE\xBF \xCE\x9F" ) /* ο Ο */
+
+ SCRIPT( gujr, GUJR,
+ "Gujarati",
+ HB_SCRIPT_GUJARATI,
+ HINTING_BOTTOM_TO_TOP,
+ "\xE0\xAA\x9F \xE0\xAB\xA6" ) /* ટ ૦ */
+
+ SCRIPT( guru, GURU,
+ "Gurmukhi",
+ HB_SCRIPT_GURMUKHI,
+ HINTING_TOP_TO_BOTTOM,
+ "\xE0\xA8\xA0 \xE0\xA8\xB0 \xE0\xA9\xA6" ) /* ਠ ਰ ੦ */
SCRIPT( hebr, HEBR,
"Hebrew",
HB_SCRIPT_HEBREW,
- 0x5DD, 0x0, 0x0 ) /* ם */
+ 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" ) /* ꤍ ꤀ */
+
+ /* only digit zero has a simple shape in the Khmer script */
+ SCRIPT( khmr, KHMR,
+ "Khmer",
+ HB_SCRIPT_KHMER,
+ HINTING_BOTTOM_TO_TOP,
+ "\xE1\x9F\xA0" ) /* ០ */
+
+ SCRIPT( khms, KHMS,
+ "Khmer Symbols",
+ HB_SCRIPT_INVALID,
+ HINTING_BOTTOM_TO_TOP,
+ "\xE1\xA7\xA1 \xE1\xA7\xAA" ) /* ᧡ ᧪ */
+
+ SCRIPT( knda, KNDA,
+ "Kannada",
+ HB_SCRIPT_KANNADA,
+ HINTING_BOTTOM_TO_TOP,
+ "\xE0\xB3\xA6 \xE0\xB2\xAC" ) /* ೦ ಬ */
/* only digit zero has a simple shape in the Lao script */
SCRIPT( lao, LAO,
"Lao",
HB_SCRIPT_LAO,
- 0xED0, 0x0, 0x0 ) /* ໐ */
+ HINTING_BOTTOM_TO_TOP,
+ "\xE0\xBB\x90" ) /* ໐ */
SCRIPT( latn, LATN,
"Latin",
HB_SCRIPT_LATIN,
- 'o', 'O', '0' )
+ HINTING_BOTTOM_TO_TOP,
+ "o O 0" )
SCRIPT( latb, LATB,
"Latin Subscript Fallback",
HB_SCRIPT_INVALID,
- 0x2092, 0x2080, 0x0 ) /* ₒ ₀ */
+ HINTING_BOTTOM_TO_TOP,
+ "\xE2\x82\x92 \xE2\x82\x80" ) /* ₒ ₀ */
SCRIPT( latp, LATP,
"Latin Superscript Fallback",
HB_SCRIPT_INVALID,
- 0x1D52, 0x1D3C, 0x2070 ) /* ᵒ ᴼ ⁰ */
+ 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,
+ HINTING_BOTTOM_TO_TOP,
+ "\xE0\xB4\xA0 \xE0\xB4\xB1" ) /* ഠ റ */
+
+ SCRIPT( mymr, MYMR,
+ "Myanmar",
+ HB_SCRIPT_MYANMAR,
+ 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,
- 0x0, 0x0, 0x0 )
+ 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",
+ HB_SCRIPT_TAMIL,
+ 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",
HB_SCRIPT_TELUGU,
- 0xC66, 0xC67, 0x0 ) /* ౦ ౧ */
+ HINTING_BOTTOM_TO_TOP,
+ "\xE0\xB1\xA6 \xE0\xB1\xA7" ) /* ౦ ౧ */
+
+ SCRIPT( tfng, TFNG,
+ "Tifinagh",
+ HB_SCRIPT_TIFINAGH,
+ HINTING_BOTTOM_TO_TOP,
+ "\xE2\xB5\x94" ) /* ⵔ */
SCRIPT( thai, THAI,
"Thai",
HB_SCRIPT_THAI,
- 0xE32, 0xE45, 0xE50 ) /* า ๅ ๐ */
+ HINTING_BOTTOM_TO_TOP,
+ "\xE0\xB8\xB2 \xE0\xB9\x85 \xE0\xB9\x90" ) /* า ๅ ๐ */
-#ifdef AF_CONFIG_OPTION_INDIC
-
- SCRIPT( beng, BENG,
- "Bengali",
- HB_SCRIPT_BENGALI,
- 'o', 0x0, 0x0 ) /* XXX */
+ SCRIPT( vaii, VAII,
+ "Vai",
+ HB_SCRIPT_VAI,
+ HINTING_BOTTOM_TO_TOP,
+ "\xEA\x98\x93 \xEA\x96\x9C \xEA\x96\xB4" ) /* ꘓ ꖜ ꖴ */
- SCRIPT( gujr, GUJR,
- "Gujarati",
- HB_SCRIPT_GUJARATI,
- 'o', 0x0, 0x0 ) /* XXX */
-
- SCRIPT( guru, GURU,
- "Gurmukhi",
- HB_SCRIPT_GURMUKHI,
- 'o', 0x0, 0x0 ) /* XXX */
-
- SCRIPT( knda, KNDA,
- "Kannada",
- HB_SCRIPT_KANNADA,
- 'o', 0x0, 0x0 ) /* XXX */
+#ifdef AF_CONFIG_OPTION_INDIC
SCRIPT( limb, LIMB,
"Limbu",
HB_SCRIPT_LIMBU,
- 'o', 0x0, 0x0 ) /* XXX */
-
- SCRIPT( mlym, MLYM,
- "Malayalam",
- HB_SCRIPT_MALAYALAM,
- 'o', 0x0, 0x0 ) /* XXX */
+ HINTING_BOTTOM_TO_TOP,
+ "o" ) /* XXX */
SCRIPT( orya, ORYA,
"Oriya",
HB_SCRIPT_ORIYA,
- 'o', 0x0, 0x0 ) /* XXX */
-
- SCRIPT( sinh, SINH,
- "Sinhala",
- HB_SCRIPT_SINHALA,
- 'o', 0x0, 0x0 ) /* XXX */
-
- SCRIPT( sund, SUND,
- "Sundanese",
- HB_SCRIPT_SUNDANESE,
- 'o', 0x0, 0x0 ) /* XXX */
+ HINTING_BOTTOM_TO_TOP,
+ "o" ) /* XXX */
SCRIPT( sylo, SYLO,
"Syloti Nagri",
HB_SCRIPT_SYLOTI_NAGRI,
- 'o', 0x0, 0x0 ) /* XXX */
-
- SCRIPT( taml, TAML,
- "Tamil",
- HB_SCRIPT_TAMIL,
- 'o', 0x0, 0x0 ) /* XXX */
+ HINTING_BOTTOM_TO_TOP,
+ "o" ) /* XXX */
SCRIPT( tibt, TIBT,
"Tibetan",
HB_SCRIPT_TIBETAN,
- 'o', 0x0, 0x0 ) /* XXX */
+ HINTING_BOTTOM_TO_TOP,
+ "o" ) /* XXX */
#endif /* AF_CONFIG_OPTION_INDIC */
@@ -161,7 +381,8 @@
SCRIPT( hani, HANI,
"CJKV ideographs",
HB_SCRIPT_HAN,
- 0x7530, 0x56D7, 0x0 ) /* 田囗 */
+ HINTING_BOTTOM_TO_TOP,
+ "\xE7\x94\xB0 \xE5\x9B\x97" ) /* 田 囗 */
#endif /* AF_CONFIG_OPTION_CJK */
diff --git a/src/3rdparty/freetype/src/autofit/afshaper.c b/src/3rdparty/freetype/src/autofit/afshaper.c
new file mode 100644
index 0000000000..f30828173c
--- /dev/null
+++ b/src/3rdparty/freetype/src/autofit/afshaper.c
@@ -0,0 +1,683 @@
+/***************************************************************************/
+/* */
+/* afshaper.c */
+/* */
+/* HarfBuzz interface for accessing OpenType features (body). */
+/* */
+/* Copyright 2013-2018 by */
+/* David Turner, Robert Wilhelm, and Werner Lemberg. */
+/* */
+/* This file is part of the FreeType project, and may only be used, */
+/* modified, and distributed under the terms of the FreeType project */
+/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
+/* this file you indicate that you have read the license and */
+/* understand and accept it fully. */
+/* */
+/***************************************************************************/
+
+
+#include <ft2build.h>
+#include FT_FREETYPE_H
+#include FT_ADVANCES_H
+#include "afglobal.h"
+#include "aftypes.h"
+#include "afshaper.h"
+
+#ifdef FT_CONFIG_OPTION_USE_HARFBUZZ
+
+
+ /*************************************************************************/
+ /* */
+ /* The macro FT_COMPONENT is used in trace mode. It is an implicit */
+ /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */
+ /* messages during execution. */
+ /* */
+#undef FT_COMPONENT
+#define FT_COMPONENT trace_afshaper
+
+
+ /*
+ * We use `sets' (in the HarfBuzz sense, which comes quite near to the
+ * usual mathematical meaning) to manage both lookups and glyph indices.
+ *
+ * 1. For each coverage, collect lookup IDs in a set. Note that an
+ * auto-hinter `coverage' is represented by one `feature', and a
+ * feature consists of an arbitrary number of (font specific) `lookup's
+ * that actually do the mapping job. Please check the OpenType
+ * specification for more details on features and lookups.
+ *
+ * 2. Create glyph ID sets from the corresponding lookup sets.
+ *
+ * 3. The glyph set corresponding to AF_COVERAGE_DEFAULT is computed
+ * with all lookups specific to the OpenType script activated. It
+ * relies on the order of AF_DEFINE_STYLE_CLASS entries so that
+ * special coverages (like `oldstyle figures') don't get overwritten.
+ *
+ */
+
+
+ /* load coverage tags */
+#undef COVERAGE
+#define COVERAGE( name, NAME, description, \
+ tag1, tag2, tag3, tag4 ) \
+ static const hb_tag_t name ## _coverage[] = \
+ { \
+ HB_TAG( tag1, tag2, tag3, tag4 ), \
+ HB_TAG_NONE \
+ };
+
+
+#include "afcover.h"
+
+
+ /* define mapping between coverage tags and AF_Coverage */
+#undef COVERAGE
+#define COVERAGE( name, NAME, description, \
+ tag1, tag2, tag3, tag4 ) \
+ name ## _coverage,
+
+
+ static const hb_tag_t* coverages[] =
+ {
+#include "afcover.h"
+
+ NULL /* AF_COVERAGE_DEFAULT */
+ };
+
+
+ /* load HarfBuzz script tags */
+#undef SCRIPT
+#define SCRIPT( s, S, d, h, H, ss ) h,
+
+
+ static const hb_script_t scripts[] =
+ {
+#include "afscript.h"
+ };
+
+
+ FT_Error
+ af_shaper_get_coverage( AF_FaceGlobals globals,
+ AF_StyleClass style_class,
+ FT_UShort* gstyles,
+ FT_Bool default_script )
+ {
+ hb_face_t* face;
+
+ hb_set_t* gsub_lookups = NULL; /* GSUB lookups for a given script */
+ hb_set_t* gsub_glyphs = NULL; /* glyphs covered by GSUB lookups */
+ hb_set_t* gpos_lookups = NULL; /* GPOS lookups for a given script */
+ hb_set_t* gpos_glyphs = NULL; /* glyphs covered by GPOS lookups */
+
+ hb_script_t script;
+ const hb_tag_t* coverage_tags;
+ hb_tag_t script_tags[] = { HB_TAG_NONE,
+ HB_TAG_NONE,
+ HB_TAG_NONE,
+ HB_TAG_NONE };
+
+ hb_codepoint_t idx;
+#ifdef FT_DEBUG_LEVEL_TRACE
+ int count;
+#endif
+
+
+ if ( !globals || !style_class || !gstyles )
+ return FT_THROW( Invalid_Argument );
+
+ face = hb_font_get_face( globals->hb_font );
+
+ coverage_tags = coverages[style_class->coverage];
+ script = scripts[style_class->script];
+
+ /* Convert a HarfBuzz script tag into the corresponding OpenType */
+ /* tag or tags -- some Indic scripts like Devanagari have an old */
+ /* and a new set of features. */
+ hb_ot_tags_from_script( script,
+ &script_tags[0],
+ &script_tags[1] );
+
+ /* `hb_ot_tags_from_script' usually returns HB_OT_TAG_DEFAULT_SCRIPT */
+ /* as the second tag. We change that to HB_TAG_NONE except for the */
+ /* default script. */
+ if ( default_script )
+ {
+ if ( script_tags[0] == HB_TAG_NONE )
+ script_tags[0] = HB_OT_TAG_DEFAULT_SCRIPT;
+ else
+ {
+ if ( script_tags[1] == HB_TAG_NONE )
+ script_tags[1] = HB_OT_TAG_DEFAULT_SCRIPT;
+ else if ( script_tags[1] != HB_OT_TAG_DEFAULT_SCRIPT )
+ script_tags[2] = HB_OT_TAG_DEFAULT_SCRIPT;
+ }
+ }
+ else
+ {
+ /* we use non-standard tags like `khms' for special purposes; */
+ /* HarfBuzz maps them to `DFLT', which we don't want to handle here */
+ if ( script_tags[0] == HB_OT_TAG_DEFAULT_SCRIPT )
+ goto Exit;
+
+ if ( script_tags[1] == HB_OT_TAG_DEFAULT_SCRIPT )
+ script_tags[1] = HB_TAG_NONE;
+ }
+
+ gsub_lookups = hb_set_create();
+ hb_ot_layout_collect_lookups( face,
+ HB_OT_TAG_GSUB,
+ script_tags,
+ NULL,
+ coverage_tags,
+ gsub_lookups );
+
+ if ( hb_set_is_empty( gsub_lookups ) )
+ goto Exit; /* nothing to do */
+
+ FT_TRACE4(( "GSUB lookups (style `%s'):\n"
+ " ",
+ af_style_names[style_class->style] ));
+
+#ifdef FT_DEBUG_LEVEL_TRACE
+ count = 0;
+#endif
+
+ gsub_glyphs = hb_set_create();
+ for ( idx = HB_SET_VALUE_INVALID; hb_set_next( gsub_lookups, &idx ); )
+ {
+#ifdef FT_DEBUG_LEVEL_TRACE
+ FT_TRACE4(( " %d", idx ));
+ count++;
+#endif
+
+ /* get output coverage of GSUB feature */
+ hb_ot_layout_lookup_collect_glyphs( face,
+ HB_OT_TAG_GSUB,
+ idx,
+ NULL,
+ NULL,
+ NULL,
+ gsub_glyphs );
+ }
+
+#ifdef FT_DEBUG_LEVEL_TRACE
+ if ( !count )
+ FT_TRACE4(( " (none)" ));
+ FT_TRACE4(( "\n\n" ));
+#endif
+
+ FT_TRACE4(( "GPOS lookups (style `%s'):\n"
+ " ",
+ af_style_names[style_class->style] ));
+
+ gpos_lookups = hb_set_create();
+ hb_ot_layout_collect_lookups( face,
+ HB_OT_TAG_GPOS,
+ script_tags,
+ NULL,
+ coverage_tags,
+ gpos_lookups );
+
+#ifdef FT_DEBUG_LEVEL_TRACE
+ count = 0;
+#endif
+
+ gpos_glyphs = hb_set_create();
+ for ( idx = HB_SET_VALUE_INVALID; hb_set_next( gpos_lookups, &idx ); )
+ {
+#ifdef FT_DEBUG_LEVEL_TRACE
+ FT_TRACE4(( " %d", idx ));
+ count++;
+#endif
+
+ /* get input coverage of GPOS feature */
+ hb_ot_layout_lookup_collect_glyphs( face,
+ HB_OT_TAG_GPOS,
+ idx,
+ NULL,
+ gpos_glyphs,
+ NULL,
+ NULL );
+ }
+
+#ifdef FT_DEBUG_LEVEL_TRACE
+ if ( !count )
+ FT_TRACE4(( " (none)" ));
+ FT_TRACE4(( "\n\n" ));
+#endif
+
+ /*
+ * We now check whether we can construct blue zones, using glyphs
+ * covered by the feature only. In case there is not a single zone
+ * (this is, not a single character is covered), we skip this coverage.
+ *
+ */
+ if ( style_class->coverage != AF_COVERAGE_DEFAULT )
+ {
+ AF_Blue_Stringset bss = style_class->blue_stringset;
+ const AF_Blue_StringRec* bs = &af_blue_stringsets[bss];
+
+ FT_Bool found = 0;
+
+
+ for ( ; bs->string != AF_BLUE_STRING_MAX; bs++ )
+ {
+ const char* p = &af_blue_strings[bs->string];
+
+
+ while ( *p )
+ {
+ hb_codepoint_t ch;
+
+
+ GET_UTF8_CHAR( ch, p );
+
+ for ( idx = HB_SET_VALUE_INVALID; hb_set_next( gsub_lookups,
+ &idx ); )
+ {
+ hb_codepoint_t gidx = FT_Get_Char_Index( globals->face, ch );
+
+
+ if ( hb_ot_layout_lookup_would_substitute( face, idx,
+ &gidx, 1, 1 ) )
+ {
+ found = 1;
+ break;
+ }
+ }
+ }
+ }
+
+ if ( !found )
+ {
+ FT_TRACE4(( " no blue characters found; style skipped\n" ));
+ goto Exit;
+ }
+ }
+
+ /*
+ * Various OpenType features might use the same glyphs at different
+ * vertical positions; for example, superscript and subscript glyphs
+ * could be the same. However, the auto-hinter is completely
+ * agnostic of OpenType features after the feature analysis has been
+ * completed: The engine then simply receives a glyph index and returns a
+ * hinted and usually rendered glyph.
+ *
+ * Consider the superscript feature of font `pala.ttf': Some of the
+ * glyphs are `real', this is, they have a zero vertical offset, but
+ * most of them are small caps glyphs shifted up to the superscript
+ * position (this is, the `sups' feature is present in both the GSUB and
+ * GPOS tables). The code for blue zones computation actually uses a
+ * feature's y offset so that the `real' glyphs get correct hints. But
+ * later on it is impossible to decide whether a glyph index belongs to,
+ * say, the small caps or superscript feature.
+ *
+ * For this reason, we don't assign a style to a glyph if the current
+ * feature covers the glyph in both the GSUB and the GPOS tables. This
+ * is quite a broad condition, assuming that
+ *
+ * (a) glyphs that get used in multiple features are present in a
+ * feature without vertical shift,
+ *
+ * and
+ *
+ * (b) a feature's GPOS data really moves the glyph vertically.
+ *
+ * Not fulfilling condition (a) makes a font larger; it would also
+ * reduce the number of glyphs that could be addressed directly without
+ * using OpenType features, so this assumption is rather strong.
+ *
+ * Condition (b) is much weaker, and there might be glyphs which get
+ * missed. However, the OpenType features we are going to handle are
+ * primarily located in GSUB, and HarfBuzz doesn't provide an API to
+ * directly get the necessary information from the GPOS table. A
+ * possible solution might be to directly parse the GPOS table to find
+ * out whether a glyph gets shifted vertically, but this is something I
+ * would like to avoid if not really necessary.
+ *
+ * Note that we don't follow this logic for the default coverage.
+ * Complex scripts like Devanagari have mandatory GPOS features to
+ * position many glyph elements, using mark-to-base or mark-to-ligature
+ * tables; the number of glyphs missed due to condition (b) would be far
+ * too large.
+ *
+ */
+ if ( style_class->coverage != AF_COVERAGE_DEFAULT )
+ hb_set_subtract( gsub_glyphs, gpos_glyphs );
+
+#ifdef FT_DEBUG_LEVEL_TRACE
+ FT_TRACE4(( " glyphs without GPOS data (`*' means already assigned)" ));
+ count = 0;
+#endif
+
+ for ( idx = HB_SET_VALUE_INVALID; hb_set_next( gsub_glyphs, &idx ); )
+ {
+#ifdef FT_DEBUG_LEVEL_TRACE
+ if ( !( count % 10 ) )
+ FT_TRACE4(( "\n"
+ " " ));
+
+ FT_TRACE4(( " %d", idx ));
+ count++;
+#endif
+
+ /* glyph indices returned by `hb_ot_layout_lookup_collect_glyphs' */
+ /* can be arbitrary: some fonts use fake indices for processing */
+ /* internal to GSUB or GPOS, which is fully valid */
+ if ( idx >= (hb_codepoint_t)globals->glyph_count )
+ continue;
+
+ if ( gstyles[idx] == AF_STYLE_UNASSIGNED )
+ gstyles[idx] = (FT_UShort)style_class->style;
+#ifdef FT_DEBUG_LEVEL_TRACE
+ else
+ FT_TRACE4(( "*" ));
+#endif
+ }
+
+#ifdef FT_DEBUG_LEVEL_TRACE
+ if ( !count )
+ FT_TRACE4(( "\n"
+ " (none)" ));
+ FT_TRACE4(( "\n\n" ));
+#endif
+
+ Exit:
+ hb_set_destroy( gsub_lookups );
+ hb_set_destroy( gsub_glyphs );
+ hb_set_destroy( gpos_lookups );
+ hb_set_destroy( gpos_glyphs );
+
+ return FT_Err_Ok;
+ }
+
+
+ /* construct HarfBuzz features */
+#undef COVERAGE
+#define COVERAGE( name, NAME, description, \
+ tag1, tag2, tag3, tag4 ) \
+ static const hb_feature_t name ## _feature[] = \
+ { \
+ { \
+ HB_TAG( tag1, tag2, tag3, tag4 ), \
+ 1, 0, (unsigned int)-1 \
+ } \
+ };
+
+
+#include "afcover.h"
+
+
+ /* define mapping between HarfBuzz features and AF_Coverage */
+#undef COVERAGE
+#define COVERAGE( name, NAME, description, \
+ tag1, tag2, tag3, tag4 ) \
+ name ## _feature,
+
+
+ static const hb_feature_t* features[] =
+ {
+#include "afcover.h"
+
+ NULL /* AF_COVERAGE_DEFAULT */
+ };
+
+
+ void*
+ af_shaper_buf_create( FT_Face face )
+ {
+ FT_UNUSED( face );
+
+ return (void*)hb_buffer_create();
+ }
+
+
+ void
+ af_shaper_buf_destroy( FT_Face face,
+ void* buf )
+ {
+ FT_UNUSED( face );
+
+ hb_buffer_destroy( (hb_buffer_t*)buf );
+ }
+
+
+ const char*
+ af_shaper_get_cluster( const char* p,
+ AF_StyleMetrics metrics,
+ void* buf_,
+ unsigned int* count )
+ {
+ AF_StyleClass style_class;
+ const hb_feature_t* feature;
+ FT_Int upem;
+ const char* q;
+ int len;
+
+ hb_buffer_t* buf = (hb_buffer_t*)buf_;
+ hb_font_t* font;
+ hb_codepoint_t dummy;
+
+
+ upem = (FT_Int)metrics->globals->face->units_per_EM;
+ style_class = metrics->style_class;
+ feature = features[style_class->coverage];
+
+ font = metrics->globals->hb_font;
+
+ /* we shape at a size of units per EM; this means font units */
+ hb_font_set_scale( font, upem, upem );
+
+ while ( *p == ' ' )
+ p++;
+
+ /* count bytes up to next space (or end of buffer) */
+ q = p;
+ while ( !( *q == ' ' || *q == '\0' ) )
+ GET_UTF8_CHAR( dummy, q );
+ len = (int)( q - p );
+
+ /* feed character(s) to the HarfBuzz buffer */
+ hb_buffer_clear_contents( buf );
+ hb_buffer_add_utf8( buf, p, len, 0, len );
+
+ /* we let HarfBuzz guess the script and writing direction */
+ hb_buffer_guess_segment_properties( buf );
+
+ /* shape buffer, which means conversion from character codes to */
+ /* glyph indices, possibly applying a feature */
+ hb_shape( font, buf, feature, feature ? 1 : 0 );
+
+ if ( feature )
+ {
+ hb_buffer_t* hb_buf = metrics->globals->hb_buf;
+
+ unsigned int gcount;
+ hb_glyph_info_t* ginfo;
+
+ unsigned int hb_gcount;
+ hb_glyph_info_t* hb_ginfo;
+
+
+ /* we have to check whether applying a feature does actually change */
+ /* glyph indices; otherwise the affected glyph or glyphs aren't */
+ /* available at all in the feature */
+
+ hb_buffer_clear_contents( hb_buf );
+ hb_buffer_add_utf8( hb_buf, p, len, 0, len );
+ hb_buffer_guess_segment_properties( hb_buf );
+ hb_shape( font, hb_buf, NULL, 0 );
+
+ ginfo = hb_buffer_get_glyph_infos( buf, &gcount );
+ hb_ginfo = hb_buffer_get_glyph_infos( hb_buf, &hb_gcount );
+
+ if ( gcount == hb_gcount )
+ {
+ unsigned int i;
+
+
+ for (i = 0; i < gcount; i++ )
+ if ( ginfo[i].codepoint != hb_ginfo[i].codepoint )
+ break;
+
+ if ( i == gcount )
+ {
+ /* both buffers have identical glyph indices */
+ hb_buffer_clear_contents( buf );
+ }
+ }
+ }
+
+ *count = hb_buffer_get_length( buf );
+
+#ifdef FT_DEBUG_LEVEL_TRACE
+ if ( feature && *count > 1 )
+ FT_TRACE1(( "af_shaper_get_cluster:"
+ " input character mapped to multiple glyphs\n" ));
+#endif
+
+ return q;
+ }
+
+
+ FT_ULong
+ af_shaper_get_elem( AF_StyleMetrics metrics,
+ void* buf_,
+ unsigned int idx,
+ FT_Long* advance,
+ FT_Long* y_offset )
+ {
+ hb_buffer_t* buf = (hb_buffer_t*)buf_;
+ hb_glyph_info_t* ginfo;
+ hb_glyph_position_t* gpos;
+ unsigned int gcount;
+
+ FT_UNUSED( metrics );
+
+
+ ginfo = hb_buffer_get_glyph_infos( buf, &gcount );
+ gpos = hb_buffer_get_glyph_positions( buf, &gcount );
+
+ if ( idx >= gcount )
+ return 0;
+
+ if ( advance )
+ *advance = gpos[idx].x_advance;
+ if ( y_offset )
+ *y_offset = gpos[idx].y_offset;
+
+ return ginfo[idx].codepoint;
+ }
+
+
+#else /* !FT_CONFIG_OPTION_USE_HARFBUZZ */
+
+
+ FT_Error
+ af_shaper_get_coverage( AF_FaceGlobals globals,
+ AF_StyleClass style_class,
+ FT_UShort* gstyles,
+ FT_Bool default_script )
+ {
+ FT_UNUSED( globals );
+ FT_UNUSED( style_class );
+ FT_UNUSED( gstyles );
+ FT_UNUSED( default_script );
+
+ return FT_Err_Ok;
+ }
+
+
+ void*
+ af_shaper_buf_create( FT_Face face )
+ {
+ FT_Error error;
+ FT_Memory memory = face->memory;
+ FT_ULong* buf;
+
+
+ FT_MEM_ALLOC( buf, sizeof ( FT_ULong ) );
+
+ return (void*)buf;
+ }
+
+
+ void
+ af_shaper_buf_destroy( FT_Face face,
+ void* buf )
+ {
+ FT_Memory memory = face->memory;
+
+
+ FT_FREE( buf );
+ }
+
+
+ const char*
+ af_shaper_get_cluster( const char* p,
+ AF_StyleMetrics metrics,
+ void* buf_,
+ unsigned int* count )
+ {
+ FT_Face face = metrics->globals->face;
+ FT_ULong ch, dummy = 0;
+ FT_ULong* buf = (FT_ULong*)buf_;
+
+
+ while ( *p == ' ' )
+ p++;
+
+ GET_UTF8_CHAR( ch, p );
+
+ /* since we don't have an engine to handle clusters, */
+ /* we scan the characters but return zero */
+ while ( !( *p == ' ' || *p == '\0' ) )
+ GET_UTF8_CHAR( dummy, p );
+
+ if ( dummy )
+ {
+ *buf = 0;
+ *count = 0;
+ }
+ else
+ {
+ *buf = FT_Get_Char_Index( face, ch );
+ *count = 1;
+ }
+
+ return p;
+ }
+
+
+ FT_ULong
+ af_shaper_get_elem( AF_StyleMetrics metrics,
+ void* buf_,
+ unsigned int idx,
+ FT_Long* advance,
+ FT_Long* y_offset )
+ {
+ FT_Face face = metrics->globals->face;
+ FT_ULong glyph_index = *(FT_ULong*)buf_;
+
+ FT_UNUSED( idx );
+
+
+ if ( advance )
+ FT_Get_Advance( face,
+ glyph_index,
+ FT_LOAD_NO_SCALE |
+ FT_LOAD_NO_HINTING |
+ FT_LOAD_IGNORE_TRANSFORM,
+ advance );
+
+ if ( y_offset )
+ *y_offset = 0;
+
+ return glyph_index;
+ }
+
+
+#endif /* !FT_CONFIG_OPTION_USE_HARFBUZZ */
+
+
+/* END */
diff --git a/src/3rdparty/freetype/src/autofit/afshaper.h b/src/3rdparty/freetype/src/autofit/afshaper.h
new file mode 100644
index 0000000000..7efd9f6a4e
--- /dev/null
+++ b/src/3rdparty/freetype/src/autofit/afshaper.h
@@ -0,0 +1,72 @@
+/***************************************************************************/
+/* */
+/* afshaper.h */
+/* */
+/* HarfBuzz interface for accessing OpenType features (specification). */
+/* */
+/* Copyright 2013-2018 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 AFSHAPER_H_
+#define AFSHAPER_H_
+
+
+#include <ft2build.h>
+#include FT_FREETYPE_H
+
+
+#ifdef FT_CONFIG_OPTION_USE_HARFBUZZ
+
+#include <hb.h>
+#include <hb-ot.h>
+#include <hb-ft.h>
+
+#endif
+
+
+FT_BEGIN_HEADER
+
+ FT_Error
+ af_shaper_get_coverage( AF_FaceGlobals globals,
+ AF_StyleClass style_class,
+ FT_UShort* gstyles,
+ FT_Bool default_script );
+
+
+ void*
+ af_shaper_buf_create( FT_Face face );
+
+ void
+ af_shaper_buf_destroy( FT_Face face,
+ void* buf );
+
+ const char*
+ af_shaper_get_cluster( const char* p,
+ AF_StyleMetrics metrics,
+ void* buf_,
+ unsigned int* count );
+
+ FT_ULong
+ af_shaper_get_elem( AF_StyleMetrics metrics,
+ void* buf_,
+ unsigned int idx,
+ FT_Long* x_advance,
+ FT_Long* y_offset );
+
+ /* */
+
+FT_END_HEADER
+
+#endif /* AFSHAPER_H_ */
+
+
+/* END */
diff --git a/src/3rdparty/freetype/src/autofit/afstyles.h b/src/3rdparty/freetype/src/autofit/afstyles.h
index 87663c9ee7..e2688b3fc2 100644
--- a/src/3rdparty/freetype/src/autofit/afstyles.h
+++ b/src/3rdparty/freetype/src/autofit/afstyles.h
@@ -4,7 +4,7 @@
/* */
/* Auto-fitter styles (specification only). */
/* */
-/* Copyright 2013-2015 by */
+/* Copyright 2013-2018 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -52,10 +52,10 @@
#undef META_STYLE_LATIN
#define META_STYLE_LATIN( s, S, ds ) \
STYLE_LATIN( s, S, c2cp, C2CP, ds, \
- "petite capticals from capitals", \
+ "petite capitals from capitals", \
PETITE_CAPITALS_FROM_CAPITALS ) \
STYLE_LATIN( s, S, c2sc, C2SC, ds, \
- "small capticals from capitals", \
+ "small capitals from capitals", \
SMALL_CAPITALS_FROM_CAPITALS ) \
STYLE_LATIN( s, S, ordn, ORDN, ds, \
"ordinals", \
@@ -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,
@@ -90,6 +97,83 @@
AF_BLUE_STRINGSET_ARAB,
AF_COVERAGE_DEFAULT )
+ STYLE( armn_dflt, ARMN_DFLT,
+ "Armenian default style",
+ AF_WRITING_SYSTEM_LATIN,
+ AF_SCRIPT_ARMN,
+ 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,
+ AF_SCRIPT_BENG,
+ 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,
+ AF_SCRIPT_CHER,
+ 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,
@@ -99,8 +183,64 @@
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,
+ AF_SCRIPT_ETHI,
+ AF_BLUE_STRINGSET_ETHI,
+ AF_COVERAGE_DEFAULT )
+
+ STYLE( geor_dflt, GEOR_DFLT,
+ "Georgian (Mkhedruli) default style",
+ AF_WRITING_SYSTEM_LATIN,
+ AF_SCRIPT_GEOR,
+ AF_BLUE_STRINGSET_GEOR,
+ AF_COVERAGE_DEFAULT )
+
+ STYLE( geok_dflt, GEOK_DFLT,
+ "Georgian (Khutsuri) default style",
+ AF_WRITING_SYSTEM_LATIN,
+ AF_SCRIPT_GEOK,
+ 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,
+ "Gujarati default style",
+ AF_WRITING_SYSTEM_LATIN,
+ AF_SCRIPT_GUJR,
+ AF_BLUE_STRINGSET_GUJR,
+ AF_COVERAGE_DEFAULT )
+
+ STYLE( guru_dflt, GURU_DFLT,
+ "Gurmukhi default style",
+ AF_WRITING_SYSTEM_LATIN,
+ AF_SCRIPT_GURU,
+ AF_BLUE_STRINGSET_GURU,
+ AF_COVERAGE_DEFAULT )
+
STYLE( hebr_dflt, HEBR_DFLT,
"Hebrew default style",
AF_WRITING_SYSTEM_LATIN,
@@ -108,6 +248,34 @@
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( khmr_dflt, KHMR_DFLT,
+ "Khmer default style",
+ AF_WRITING_SYSTEM_LATIN,
+ AF_SCRIPT_KHMR,
+ AF_BLUE_STRINGSET_KHMR,
+ AF_COVERAGE_DEFAULT )
+
+ STYLE( khms_dflt, KHMS_DFLT,
+ "Khmer Symbols default style",
+ AF_WRITING_SYSTEM_LATIN,
+ AF_SCRIPT_KHMS,
+ AF_BLUE_STRINGSET_KHMS,
+ AF_COVERAGE_DEFAULT )
+
+ STYLE( knda_dflt, KNDA_DFLT,
+ "Kannada default style",
+ AF_WRITING_SYSTEM_LATIN,
+ AF_SCRIPT_KNDA,
+ AF_BLUE_STRINGSET_KNDA,
+ AF_COVERAGE_DEFAULT )
+
STYLE( lao_dflt, LAO_DFLT,
"Lao default style",
AF_WRITING_SYSTEM_LATIN,
@@ -140,11 +308,109 @@
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,
+ AF_SCRIPT_MLYM,
+ AF_BLUE_STRINGSET_MLYM,
+ AF_COVERAGE_DEFAULT )
+
+ STYLE( mymr_dflt, MYMR_DFLT,
+ "Myanmar default style",
+ AF_WRITING_SYSTEM_LATIN,
+ AF_SCRIPT_MYMR,
+ 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,
AF_SCRIPT_NONE,
- (AF_Blue_Stringset)0,
+ 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,
+ AF_SCRIPT_SINH,
+ 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,
+ AF_SCRIPT_TAML,
+ 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,
@@ -154,6 +420,13 @@
AF_BLUE_STRINGSET_TELU,
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( thai_dflt, THAI_DFLT,
"Thai default style",
AF_WRITING_SYSTEM_LATIN,
@@ -161,6 +434,13 @@
AF_BLUE_STRINGSET_THAI,
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 */
@@ -173,17 +453,9 @@
(AF_Blue_Stringset)0, \
AF_COVERAGE_DEFAULT )
- STYLE_DEFAULT_INDIC( beng, BENG, "Bengali" )
- STYLE_DEFAULT_INDIC( gujr, GUJR, "Gujarati" )
- STYLE_DEFAULT_INDIC( guru, GURU, "Gurmukhi" )
- STYLE_DEFAULT_INDIC( knda, KNDA, "Kannada" )
STYLE_DEFAULT_INDIC( limb, LIMB, "Limbu" )
- STYLE_DEFAULT_INDIC( mlym, MLYM, "Malayalam" )
STYLE_DEFAULT_INDIC( orya, ORYA, "Oriya" )
- STYLE_DEFAULT_INDIC( sinh, SINH, "Sinhala" )
- STYLE_DEFAULT_INDIC( sund, SUND, "Sundanese" )
STYLE_DEFAULT_INDIC( sylo, SYLO, "Syloti Nagri" )
- STYLE_DEFAULT_INDIC( taml, TAML, "Tamil" )
STYLE_DEFAULT_INDIC( tibt, TIBT, "Tibetan" )
#endif /* AF_CONFIG_OPTION_INDIC */
diff --git a/src/3rdparty/freetype/src/autofit/aftypes.h b/src/3rdparty/freetype/src/autofit/aftypes.h
index 43b38006c2..6bd8c895b2 100644
--- a/src/3rdparty/freetype/src/autofit/aftypes.h
+++ b/src/3rdparty/freetype/src/autofit/aftypes.h
@@ -4,7 +4,7 @@
/* */
/* Auto-fitter types (specification only). */
/* */
-/* Copyright 2003-2015 by */
+/* Copyright 2003-2018 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -22,15 +22,15 @@
* Its main feature is the ability to differentiate between different
* writing systems and scripts in order to apply specific rules.
*
- * The code has also been compartmentized into several entities that
+ * The code has also been compartmentalized into several entities that
* should make algorithmic experimentation easier than with the old
* code.
*
*************************************************************************/
-#ifndef __AFTYPES_H__
-#define __AFTYPES_H__
+#ifndef AFTYPES_H_
+#define AFTYPES_H_
#include <ft2build.h>
@@ -76,9 +76,9 @@ extern void* _af_debug_hints;
typedef struct AF_WidthRec_
{
- FT_Pos org; /* original position/width in font units */
- FT_Pos cur; /* current/scaled position/width in device sub-pixels */
- FT_Pos fit; /* current/fitted position/width in device sub-pixels */
+ FT_Pos org; /* original position/width in font units */
+ FT_Pos cur; /* current/scaled position/width in device subpixels */
+ FT_Pos fit; /* current/fitted position/width in device subpixels */
} AF_WidthRec, *AF_Width;
@@ -211,12 +211,17 @@ extern void* _af_debug_hints;
typedef void
(*AF_WritingSystem_DoneMetricsFunc)( AF_StyleMetrics metrics );
+ typedef void
+ (*AF_WritingSystem_GetStdWidthsFunc)( AF_StyleMetrics metrics,
+ FT_Pos* stdHW,
+ FT_Pos* stdVW );
+
typedef FT_Error
(*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,
@@ -250,7 +255,7 @@ extern void* _af_debug_hints;
* outline according to the results of the glyph analyzer.
*/
-#define __AFWRTSYS_H__ /* don't load header files */
+#define AFWRTSYS_H_ /* don't load header files */
#undef WRITING_SYSTEM
#define WRITING_SYSTEM( ws, WS ) \
AF_WRITING_SYSTEM_ ## WS,
@@ -265,7 +270,7 @@ extern void* _af_debug_hints;
} AF_WritingSystem;
-#undef __AFWRTSYS_H__
+#undef AFWRTSYS_H_
typedef struct AF_WritingSystemClassRec_
@@ -276,6 +281,7 @@ extern void* _af_debug_hints;
AF_WritingSystem_InitMetricsFunc style_metrics_init;
AF_WritingSystem_ScaleMetricsFunc style_metrics_scale;
AF_WritingSystem_DoneMetricsFunc style_metrics_done;
+ AF_WritingSystem_GetStdWidthsFunc style_metrics_getstdw;
AF_WritingSystem_InitHintsFunc style_hints_init;
AF_WritingSystem_ApplyHintsFunc style_hints_apply;
@@ -303,7 +309,7 @@ extern void* _af_debug_hints;
*/
#undef SCRIPT
-#define SCRIPT( s, S, d, h, sc1, sc2, sc3 ) \
+#define SCRIPT( s, S, d, h, H, ss ) \
AF_SCRIPT_ ## S,
/* The list of known scripts. */
@@ -337,9 +343,9 @@ extern void* _af_debug_hints;
AF_Script_UniRange script_uni_ranges;
AF_Script_UniRange script_uni_nonbase_ranges;
- FT_UInt32 standard_char1; /* for default width and height */
- FT_UInt32 standard_char2; /* ditto */
- FT_UInt32 standard_char3; /* ditto */
+ FT_Bool top_to_bottom_hinting;
+
+ const char* standard_charstring; /* for default width and height */
} AF_ScriptClassRec;
@@ -475,6 +481,10 @@ extern void* _af_debug_hints;
} AF_StyleMetricsRec;
+#define AF_HINTING_BOTTOM_TO_TOP 0
+#define AF_HINTING_TOP_TO_BOTTOM 1
+
+
/* Declare and define vtables for classes */
#ifndef FT_CONFIG_OPTION_PIC
@@ -489,6 +499,7 @@ extern void* _af_debug_hints;
m_init, \
m_scale, \
m_done, \
+ m_stdw, \
h_init, \
h_apply ) \
FT_CALLBACK_TABLE_DEF \
@@ -501,6 +512,7 @@ extern void* _af_debug_hints;
m_init, \
m_scale, \
m_done, \
+ m_stdw, \
\
h_init, \
h_apply \
@@ -516,18 +528,16 @@ extern void* _af_debug_hints;
script, \
ranges, \
nonbase_ranges, \
- std_char1, \
- std_char2, \
- std_char3 ) \
+ top_to_bottom, \
+ std_charstring ) \
FT_CALLBACK_TABLE_DEF \
const AF_ScriptClassRec script_class = \
{ \
script, \
ranges, \
nonbase_ranges, \
- std_char1, \
- std_char2, \
- std_char3 \
+ top_to_bottom, \
+ std_charstring, \
};
@@ -565,21 +575,23 @@ extern void* _af_debug_hints;
m_init, \
m_scale, \
m_done, \
+ m_stdw, \
h_init, \
h_apply ) \
FT_LOCAL_DEF( void ) \
FT_Init_Class_ ## writing_system_class( AF_WritingSystemClassRec* ac ) \
{ \
- ac->writing_system = system; \
+ ac->writing_system = system; \
\
- ac->style_metrics_size = m_size; \
+ ac->style_metrics_size = m_size; \
\
- ac->style_metrics_init = m_init; \
- ac->style_metrics_scale = m_scale; \
- ac->style_metrics_done = m_done; \
+ ac->style_metrics_init = m_init; \
+ ac->style_metrics_scale = m_scale; \
+ ac->style_metrics_done = m_done; \
+ ac->style_metrics_getstdw = m_stdw; \
\
- ac->style_hints_init = h_init; \
- ac->style_hints_apply = h_apply; \
+ ac->style_hints_init = h_init; \
+ ac->style_hints_apply = h_apply; \
}
@@ -592,18 +604,16 @@ extern void* _af_debug_hints;
script_, \
ranges, \
nonbase_ranges, \
- std_char1, \
- std_char2, \
- std_char3 ) \
+ top_to_bottom, \
+ std_charstring ) \
FT_LOCAL_DEF( void ) \
FT_Init_Class_ ## script_class( AF_ScriptClassRec* ac ) \
{ \
ac->script = script_; \
ac->script_uni_ranges = ranges; \
ac->script_uni_nonbase_ranges = nonbase_ranges; \
- ac->standard_char1 = std_char1; \
- ac->standard_char2 = std_char2; \
- ac->standard_char3 = std_char3; \
+ ac->top_to_bottom_hinting = top_to_bottom; \
+ ac->standard_charstring = std_charstring; \
}
@@ -635,7 +645,7 @@ extern void* _af_debug_hints;
FT_END_HEADER
-#endif /* __AFTYPES_H__ */
+#endif /* AFTYPES_H_ */
/* END */
diff --git a/src/3rdparty/freetype/src/autofit/afwarp.c b/src/3rdparty/freetype/src/autofit/afwarp.c
index 59af4f02bd..2a75ea7b35 100644
--- a/src/3rdparty/freetype/src/autofit/afwarp.c
+++ b/src/3rdparty/freetype/src/autofit/afwarp.c
@@ -4,7 +4,7 @@
/* */
/* Auto-fitter warping algorithm (body). */
/* */
-/* Copyright 2006-2015 by */
+/* Copyright 2006-2018 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;
@@ -193,7 +192,7 @@
warper->best_scale = org_scale;
warper->best_delta = org_delta;
- warper->best_score = INT_MIN;
+ warper->best_score = FT_INT_MIN;
warper->best_distort = 0;
axis = &hints->axis[dim];
diff --git a/src/3rdparty/freetype/src/autofit/afwarp.h b/src/3rdparty/freetype/src/autofit/afwarp.h
index 6069b6b277..520b1be907 100644
--- a/src/3rdparty/freetype/src/autofit/afwarp.h
+++ b/src/3rdparty/freetype/src/autofit/afwarp.h
@@ -4,7 +4,7 @@
/* */
/* Auto-fitter warping algorithm (specification). */
/* */
-/* Copyright 2006-2015 by */
+/* Copyright 2006-2018 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -16,8 +16,8 @@
/***************************************************************************/
-#ifndef __AFWARP_H__
-#define __AFWARP_H__
+#ifndef AFWARP_H_
+#define AFWARP_H_
#include "afhints.h"
@@ -58,7 +58,7 @@ FT_BEGIN_HEADER
FT_END_HEADER
-#endif /* __AFWARP_H__ */
+#endif /* AFWARP_H_ */
/* END */
diff --git a/src/3rdparty/freetype/src/autofit/afwrtsys.h b/src/3rdparty/freetype/src/autofit/afwrtsys.h
index 4aa89d2356..4675f3242d 100644
--- a/src/3rdparty/freetype/src/autofit/afwrtsys.h
+++ b/src/3rdparty/freetype/src/autofit/afwrtsys.h
@@ -4,7 +4,7 @@
/* */
/* Auto-fitter writing systems (specification only). */
/* */
-/* Copyright 2013-2015 by */
+/* Copyright 2013-2018 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -16,8 +16,8 @@
/***************************************************************************/
-#ifndef __AFWRTSYS_H__
-#define __AFWRTSYS_H__
+#ifndef AFWRTSYS_H_
+#define AFWRTSYS_H_
/* Since preprocessor directives can't create other preprocessor */
/* directives, we have to include the header files manually. */
@@ -30,7 +30,7 @@
#include "aflatin2.h"
#endif
-#endif /* __AFWRTSYS_H__ */
+#endif /* AFWRTSYS_H_ */
/* The following part can be included multiple times. */
diff --git a/src/3rdparty/freetype/src/autofit/autofit.c b/src/3rdparty/freetype/src/autofit/autofit.c
index b6ed4a0ff1..c1605160a1 100644
--- a/src/3rdparty/freetype/src/autofit/autofit.c
+++ b/src/3rdparty/freetype/src/autofit/autofit.c
@@ -4,7 +4,7 @@
/* */
/* Auto-fitter module (body). */
/* */
-/* Copyright 2003-2015 by */
+/* Copyright 2003-2018 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 "hbshim.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/src/3rdparty/freetype/src/autofit/module.mk b/src/3rdparty/freetype/src/autofit/module.mk
index 33214387f5..ff05f83e7e 100644
--- a/src/3rdparty/freetype/src/autofit/module.mk
+++ b/src/3rdparty/freetype/src/autofit/module.mk
@@ -3,7 +3,7 @@
#
-# Copyright 2003-2015 by
+# Copyright 2003-2018 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/src/3rdparty/freetype/src/autofit/rules.mk b/src/3rdparty/freetype/src/autofit/rules.mk
index 6ef959f1ba..75171b412c 100644
--- a/src/3rdparty/freetype/src/autofit/rules.mk
+++ b/src/3rdparty/freetype/src/autofit/rules.mk
@@ -3,7 +3,7 @@
#
-# Copyright 2003-2015 by
+# Copyright 2003-2018 by
# David Turner, Robert Wilhelm, and Werner Lemberg.
#
# This file is part of the FreeType project, and may only be used, modified,
@@ -40,8 +40,8 @@ AUTOF_DRV_SRC := $(AUTOF_DIR)/afangles.c \
$(AUTOF_DIR)/afmodule.c \
$(AUTOF_DIR)/afpic.c \
$(AUTOF_DIR)/afranges.c \
- $(AUTOF_DIR)/afwarp.c \
- $(AUTOF_DIR)/hbshim.c
+ $(AUTOF_DIR)/afshaper.c \
+ $(AUTOF_DIR)/afwarp.c
# AUTOF driver headers
#
diff --git a/src/3rdparty/freetype/src/base/Jamfile b/src/3rdparty/freetype/src/base/Jamfile
index e39fb096b2..4994c1b4ca 100644
--- a/src/3rdparty/freetype/src/base/Jamfile
+++ b/src/3rdparty/freetype/src/base/Jamfile
@@ -1,6 +1,6 @@
# FreeType 2 src/base Jamfile
#
-# Copyright 2001-2015 by
+# Copyright 2001-2018 by
# David Turner, Robert Wilhelm, and Werner Lemberg.
#
# This file is part of the FreeType project, and may only be used, modified,
@@ -21,10 +21,14 @@ SubDir FT2_TOP $(FT2_SRC_DIR) base ;
ftadvanc
ftcalc
ftdbgmem
+ ftfntfmt
ftgloadr
+ fthash
+ ftlcdfil
ftobjs
ftoutln
ftpic
+ ftpsprop
ftrfork
ftsnames
ftstream
@@ -49,13 +53,11 @@ SubDir FT2_TOP $(FT2_SRC_DIR) base ;
ftbitmap
ftcid
ftdebug
- ftfntfmt
ftfstype
ftgasp
ftglyph
ftgxval
ftinit
- ftlcdfil
ftmm
ftotval
ftpatent
diff --git a/src/3rdparty/freetype/src/base/basepic.c b/src/3rdparty/freetype/src/base/basepic.c
index 9850ed96a4..bc80406441 100644
--- a/src/3rdparty/freetype/src/base/basepic.c
+++ b/src/3rdparty/freetype/src/base/basepic.c
@@ -4,7 +4,7 @@
/* */
/* The FreeType position independent code services for base. */
/* */
-/* Copyright 2009-2015 by */
+/* Copyright 2009-2018 by */
/* Oran Agra and Mickey Gabel. */
/* */
/* This file is part of the FreeType project, and may only be used, */
diff --git a/src/3rdparty/freetype/src/base/basepic.h b/src/3rdparty/freetype/src/base/basepic.h
index c5d7cbf5ab..492d1ede56 100644
--- a/src/3rdparty/freetype/src/base/basepic.h
+++ b/src/3rdparty/freetype/src/base/basepic.h
@@ -4,7 +4,7 @@
/* */
/* The FreeType position independent code services for base. */
/* */
-/* Copyright 2009-2015 by */
+/* Copyright 2009-2018 by */
/* Oran Agra and Mickey Gabel. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -16,8 +16,8 @@
/***************************************************************************/
-#ifndef __BASEPIC_H__
-#define __BASEPIC_H__
+#ifndef BASEPIC_H_
+#define BASEPIC_H_
#include FT_INTERNAL_PIC_H
@@ -85,7 +85,7 @@ FT_END_HEADER
/* */
-#endif /* __BASEPIC_H__ */
+#endif /* BASEPIC_H_ */
/* END */
diff --git a/src/3rdparty/freetype/src/base/ftadvanc.c b/src/3rdparty/freetype/src/base/ftadvanc.c
index f12908f518..230c84d6ad 100644
--- a/src/3rdparty/freetype/src/base/ftadvanc.c
+++ b/src/3rdparty/freetype/src/base/ftadvanc.c
@@ -4,7 +4,7 @@
/* */
/* Quick computation of advance widths (body). */
/* */
-/* Copyright 2008-2015 by */
+/* Copyright 2008-2018 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,8 +60,11 @@
/* - unscaled load */
/* - unhinted load */
/* - light-hinted load */
+ /* - 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( flags ) \
+#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 )
@@ -87,7 +90,7 @@
return FT_THROW( Invalid_Glyph_Index );
func = face->driver->clazz->get_advances;
- if ( func && LOAD_ADVANCE_FAST_CHECK( flags ) )
+ if ( func && LOAD_ADVANCE_FAST_CHECK( face, flags ) )
{
FT_Error error;
@@ -113,9 +116,12 @@
FT_Int32 flags,
FT_Fixed *padvances )
{
+ FT_Error error = FT_Err_Ok;
+
FT_Face_GetAdvancesFunc func;
- FT_UInt num, end, nn;
- FT_Error error = FT_Err_Ok;
+
+ FT_UInt num, end, nn;
+ FT_Int factor;
if ( !face )
@@ -133,7 +139,7 @@
return FT_Err_Ok;
func = face->driver->clazz->get_advances;
- if ( func && LOAD_ADVANCE_FAST_CHECK( flags ) )
+ if ( func && LOAD_ADVANCE_FAST_CHECK( face, flags ) )
{
error = func( face, start, count, flags, padvances );
if ( !error )
@@ -149,16 +155,17 @@
return FT_THROW( Unimplemented_Feature );
flags |= (FT_UInt32)FT_LOAD_ADVANCE_ONLY;
+ factor = ( flags & FT_LOAD_NO_SCALE ) ? 1 : 1024;
for ( nn = 0; nn < count; nn++ )
{
error = FT_Load_Glyph( face, start + nn, flags );
if ( error )
break;
- /* scale from 26.6 to 16.16 */
+ /* scale from 26.6 to 16.16, unless NO_SCALE was requested */
padvances[nn] = ( flags & FT_LOAD_VERTICAL_LAYOUT )
- ? face->glyph->advance.y << 10
- : face->glyph->advance.x << 10;
+ ? face->glyph->advance.y * factor
+ : face->glyph->advance.x * factor;
}
return error;
diff --git a/src/3rdparty/freetype/src/base/ftapi.c b/src/3rdparty/freetype/src/base/ftapi.c
index f22a181b59..32d6e95d19 100644
--- a/src/3rdparty/freetype/src/base/ftapi.c
+++ b/src/3rdparty/freetype/src/base/ftapi.c
@@ -4,7 +4,7 @@
/* */
/* The FreeType compatibility functions (body). */
/* */
-/* Copyright 2002-2015 by */
+/* Copyright 2002-2018 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/src/3rdparty/freetype/src/base/ftbase.c b/src/3rdparty/freetype/src/base/ftbase.c
index 253dfb7236..f914b9b247 100644
--- a/src/3rdparty/freetype/src/base/ftbase.c
+++ b/src/3rdparty/freetype/src/base/ftbase.c
@@ -4,7 +4,7 @@
/* */
/* Single object library component (body only). */
/* */
-/* Copyright 1996-2015 by */
+/* Copyright 1996-2018 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -17,25 +17,26 @@
#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 "ftfntfmt.c"
#include "ftgloadr.c"
+#include "fthash.c"
+#include "ftlcdfil.c"
+#include "ftmac.c"
#include "ftobjs.c"
#include "ftoutln.c"
+#include "ftpic.c"
+#include "ftpsprop.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/src/3rdparty/freetype/src/base/ftbase.h b/src/3rdparty/freetype/src/base/ftbase.h
index e37fefa411..7e8cfad959 100644
--- a/src/3rdparty/freetype/src/base/ftbase.h
+++ b/src/3rdparty/freetype/src/base/ftbase.h
@@ -2,9 +2,9 @@
/* */
/* ftbase.h */
/* */
-/* The FreeType private functions used in base module (specification). */
+/* Private functions used in the `base' module (specification). */
/* */
-/* Copyright 2008-2015 by */
+/* Copyright 2008-2018 by */
/* David Turner, Robert Wilhelm, Werner Lemberg, and suzuki toshiya. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -16,8 +16,8 @@
/***************************************************************************/
-#ifndef __FTBASE_H__
-#define __FTBASE_H__
+#ifndef FTBASE_H_
+#define FTBASE_H_
#include <ft2build.h>
@@ -27,6 +27,8 @@
FT_BEGIN_HEADER
+#ifdef FT_CONFIG_OPTION_MAC_FONTS
+
/* MacOS resource fork cannot exceed 16MB at least for Carbon code; */
/* see https://support.microsoft.com/en-us/kb/130437 */
#define FT_MAC_RFORK_MAX_LEN 0x00FFFFFFUL
@@ -65,10 +67,12 @@ FT_BEGIN_HEADER
ft_raccess_rule_by_darwin_vfs( FT_Library library, FT_UInt rule_index );
#endif
+#endif /* FT_CONFIG_OPTION_MAC_FONTS */
+
FT_END_HEADER
-#endif /* __FTBASE_H__ */
+#endif /* FTBASE_H_ */
/* END */
diff --git a/src/3rdparty/freetype/src/base/ftbbox.c b/src/3rdparty/freetype/src/base/ftbbox.c
index 10df98de6a..151e85c97a 100644
--- a/src/3rdparty/freetype/src/base/ftbbox.c
+++ b/src/3rdparty/freetype/src/base/ftbbox.c
@@ -4,7 +4,7 @@
/* */
/* FreeType bbox computation (body). */
/* */
-/* Copyright 1996-2015 by */
+/* Copyright 1996-2018 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/src/3rdparty/freetype/src/base/ftbdf.c b/src/3rdparty/freetype/src/base/ftbdf.c
index aa72ddcdf9..c4ea502fbc 100644
--- a/src/3rdparty/freetype/src/base/ftbdf.c
+++ b/src/3rdparty/freetype/src/base/ftbdf.c
@@ -4,7 +4,7 @@
/* */
/* FreeType API for accessing BDF-specific strings (body). */
/* */
-/* Copyright 2002-2015 by */
+/* Copyright 2002-2018 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
diff --git a/src/3rdparty/freetype/src/base/ftbitmap.c b/src/3rdparty/freetype/src/base/ftbitmap.c
index a54572aaa2..a9746663fa 100644
--- a/src/3rdparty/freetype/src/base/ftbitmap.c
+++ b/src/3rdparty/freetype/src/base/ftbitmap.c
@@ -4,7 +4,7 @@
/* */
/* FreeType utility functions for bitmaps (body). */
/* */
-/* Copyright 2004-2015 by */
+/* Copyright 2004-2018 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 )
@@ -153,38 +153,36 @@
FT_UInt ypixels )
{
FT_Error error;
- int pitch;
- int new_pitch;
+ unsigned int pitch;
+ unsigned int new_pitch;
FT_UInt bpp;
- FT_UInt i, width, height;
+ FT_UInt width, height;
unsigned char* buffer = NULL;
width = bitmap->width;
height = bitmap->rows;
- pitch = bitmap->pitch;
- if ( pitch < 0 )
- pitch = -pitch;
+ pitch = (unsigned int)FT_ABS( bitmap->pitch );
switch ( bitmap->pixel_mode )
{
case FT_PIXEL_MODE_MONO:
bpp = 1;
- new_pitch = (int)( ( width + xpixels + 7 ) >> 3 );
+ new_pitch = ( width + xpixels + 7 ) >> 3;
break;
case FT_PIXEL_MODE_GRAY2:
bpp = 2;
- new_pitch = (int)( ( width + xpixels + 3 ) >> 2 );
+ new_pitch = ( width + xpixels + 3 ) >> 2;
break;
case FT_PIXEL_MODE_GRAY4:
bpp = 4;
- new_pitch = (int)( ( width + xpixels + 1 ) >> 1 );
+ new_pitch = ( width + xpixels + 1 ) >> 1;
break;
case FT_PIXEL_MODE_GRAY:
case FT_PIXEL_MODE_LCD:
case FT_PIXEL_MODE_LCD_V:
bpp = 8;
- new_pitch = (int)( width + xpixels );
+ new_pitch = width + xpixels;
break;
default:
return FT_THROW( Invalid_Glyph_Format );
@@ -194,7 +192,7 @@
if ( ypixels == 0 && new_pitch <= pitch )
{
/* zero the padding */
- FT_UInt bit_width = (FT_UInt)pitch * 8;
+ FT_UInt bit_width = pitch * 8;
FT_UInt bit_last = ( width + xpixels ) * bpp;
@@ -226,7 +224,7 @@
}
/* otherwise allocate new buffer */
- if ( FT_QALLOC_MULT( buffer, new_pitch, bitmap->rows + ypixels ) )
+ if ( FT_QALLOC_MULT( buffer, bitmap->rows + ypixels, new_pitch ) )
return error;
/* new rows get added at the top of the bitmap, */
@@ -235,31 +233,60 @@
{
FT_UInt len = ( width * bpp + 7 ) >> 3;
+ unsigned char* in = bitmap->buffer;
+ unsigned char* out = buffer;
+
+ unsigned char* limit = bitmap->buffer + pitch * bitmap->rows;
+ unsigned int delta = new_pitch - len;
+
+
+ FT_MEM_ZERO( out, new_pitch * ypixels );
+ out += new_pitch * ypixels;
- for ( i = 0; i < bitmap->rows; i++ )
- FT_MEM_COPY( buffer + (FT_UInt)new_pitch * ( ypixels + i ),
- bitmap->buffer + (FT_UInt)pitch * i,
- len );
+ while ( in < limit )
+ {
+ FT_MEM_COPY( out, in, len );
+ in += pitch;
+ out += len;
+
+ /* we use FT_QALLOC_MULT, which doesn't zero out the buffer; */
+ /* consequently, we have to manually zero out the remaining bytes */
+ FT_MEM_ZERO( out, delta );
+ out += delta;
+ }
}
else
{
FT_UInt len = ( width * bpp + 7 ) >> 3;
+ unsigned char* in = bitmap->buffer;
+ unsigned char* out = buffer;
+
+ unsigned char* limit = bitmap->buffer + pitch * bitmap->rows;
+ unsigned int delta = new_pitch - len;
+
- for ( i = 0; i < bitmap->rows; i++ )
- FT_MEM_COPY( buffer + (FT_UInt)new_pitch * i,
- bitmap->buffer + (FT_UInt)pitch * i,
- len );
+ while ( in < limit )
+ {
+ FT_MEM_COPY( out, in, len );
+ in += pitch;
+ out += len;
+
+ FT_MEM_ZERO( out, delta );
+ out += delta;
+ }
+
+ FT_MEM_ZERO( out, new_pitch * ypixels );
}
FT_FREE( bitmap->buffer );
bitmap->buffer = buffer;
- if ( bitmap->pitch < 0 )
- new_pitch = -new_pitch;
-
/* set pitch only, width and height are left untouched */
- bitmap->pitch = new_pitch;
+ if ( bitmap->pitch < 0 )
+ bitmap->pitch = -(int)new_pitch;
+ else
+ bitmap->pitch = (int)new_pitch;
return FT_Err_Ok;
}
@@ -351,7 +378,7 @@
}
/* for each row */
- for ( y = 0; y < bitmap->rows ; y++ )
+ for ( y = 0; y < bitmap->rows; y++ )
{
/*
* Horizontally:
@@ -444,7 +471,7 @@
* A gamma of 2.2 is fair to assume. And then, we need to
* undo the premultiplication too.
*
- * http://accessibility.kde.org/hsl-adjusted.php
+ * https://accessibility.kde.org/hsl-adjusted.php
*
* We do the computation with integers only, applying a gamma of 2.0.
* We guarantee 32-bit arithmetic to avoid overflow but the resulting
@@ -534,8 +561,7 @@
(FT_ULong)target->rows > FT_ULONG_MAX / (FT_ULong)target_pitch )
return FT_THROW( Invalid_Argument );
- if ( target->rows * (FT_ULong)target_pitch > old_size &&
- FT_QREALLOC( target->buffer,
+ if ( FT_QREALLOC( target->buffer,
old_size, target->rows * (FT_UInt)target_pitch ) )
return error;
diff --git a/src/3rdparty/freetype/src/base/ftcalc.c b/src/3rdparty/freetype/src/base/ftcalc.c
index 619a08b3a0..f4ff45f8ef 100644
--- a/src/3rdparty/freetype/src/base/ftcalc.c
+++ b/src/3rdparty/freetype/src/base/ftcalc.c
@@ -4,7 +4,7 @@
/* */
/* Arithmetic computations (body). */
/* */
-/* Copyright 1996-2015 by */
+/* Copyright 1996-2018 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -68,14 +68,15 @@
#define FT_COMPONENT trace_calc
- /* transfer sign leaving a positive number */
-#define FT_MOVE_SIGN( x, s ) \
- FT_BEGIN_STMNT \
- if ( x < 0 ) \
- { \
- x = -x; \
- s = -s; \
- } \
+ /* transfer sign, leaving a positive number; */
+ /* we need an unsigned value to safely negate INT_MIN (or LONG_MIN) */
+#define FT_MOVE_SIGN( x, x_unsigned, s ) \
+ FT_BEGIN_STMNT \
+ if ( x < 0 ) \
+ { \
+ x_unsigned = 0U - (x_unsigned); \
+ s = -s; \
+ } \
FT_END_STMNT
/* The following three functions are available regardless of whether */
@@ -86,7 +87,7 @@
FT_EXPORT_DEF( FT_Fixed )
FT_RoundFix( FT_Fixed a )
{
- return ( a + 0x8000L - ( a < 0 ) ) & ~0xFFFFL;
+ return ( ADD_LONG( a, 0x8000L - ( a < 0 ) ) ) & ~0xFFFFL;
}
@@ -95,7 +96,7 @@
FT_EXPORT_DEF( FT_Fixed )
FT_CeilFix( FT_Fixed a )
{
- return ( a + 0xFFFFL ) & ~0xFFFFL;
+ return ( ADD_LONG( a, 0xFFFFL ) ) & ~0xFFFFL;
}
@@ -179,20 +180,20 @@
FT_Long d_;
- FT_MOVE_SIGN( a_, s );
- FT_MOVE_SIGN( b_, s );
- FT_MOVE_SIGN( c_, s );
-
a = (FT_UInt64)a_;
b = (FT_UInt64)b_;
c = (FT_UInt64)c_;
+ FT_MOVE_SIGN( a_, a, s );
+ FT_MOVE_SIGN( b_, b, s );
+ FT_MOVE_SIGN( c_, c, s );
+
d = c > 0 ? ( a * b + ( c >> 1 ) ) / c
: 0x7FFFFFFFUL;
d_ = (FT_Long)d;
- return s < 0 ? -d_ : d_;
+ return s < 0 ? NEG_LONG( d_ ) : d_;
}
@@ -208,20 +209,20 @@
FT_Long d_;
- FT_MOVE_SIGN( a_, s );
- FT_MOVE_SIGN( b_, s );
- FT_MOVE_SIGN( c_, s );
-
a = (FT_UInt64)a_;
b = (FT_UInt64)b_;
c = (FT_UInt64)c_;
+ FT_MOVE_SIGN( a_, a, s );
+ FT_MOVE_SIGN( b_, b, s );
+ FT_MOVE_SIGN( c_, c, s );
+
d = c > 0 ? a * b / c
: 0x7FFFFFFFUL;
d_ = (FT_Long)d;
- return s < 0 ? -d_ : d_;
+ return s < 0 ? NEG_LONG( d_ ) : d_;
}
@@ -233,7 +234,7 @@
{
#ifdef FT_MULFIX_ASSEMBLER
- return FT_MULFIX_ASSEMBLER( a_, b_ );
+ return FT_MULFIX_ASSEMBLER( (FT_Int32)a_, (FT_Int32)b_ );
#else
@@ -257,18 +258,18 @@
FT_Long q_;
- FT_MOVE_SIGN( a_, s );
- FT_MOVE_SIGN( b_, s );
-
a = (FT_UInt64)a_;
b = (FT_UInt64)b_;
+ FT_MOVE_SIGN( a_, a, s );
+ FT_MOVE_SIGN( b_, b, s );
+
q = b > 0 ? ( ( a << 16 ) + ( b >> 1 ) ) / b
: 0x7FFFFFFFUL;
q_ = (FT_Long)q;
- return s < 0 ? -q_ : q_;
+ return s < 0 ? NEG_LONG( q_ ) : q_;
}
@@ -422,14 +423,14 @@
/* XXX: this function does not allow 64-bit arguments */
- FT_MOVE_SIGN( a_, s );
- FT_MOVE_SIGN( b_, s );
- FT_MOVE_SIGN( c_, s );
-
a = (FT_UInt32)a_;
b = (FT_UInt32)b_;
c = (FT_UInt32)c_;
+ FT_MOVE_SIGN( a_, a, s );
+ FT_MOVE_SIGN( b_, b, s );
+ FT_MOVE_SIGN( c_, c, s );
+
if ( c == 0 )
a = 0x7FFFFFFFUL;
@@ -449,13 +450,13 @@
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;
- return s < 0 ? -a_ : a_;
+ return s < 0 ? NEG_LONG( a_ ) : a_;
}
@@ -470,14 +471,14 @@
/* XXX: this function does not allow 64-bit arguments */
- FT_MOVE_SIGN( a_, s );
- FT_MOVE_SIGN( b_, s );
- FT_MOVE_SIGN( c_, s );
-
a = (FT_UInt32)a_;
b = (FT_UInt32)b_;
c = (FT_UInt32)c_;
+ FT_MOVE_SIGN( a_, a, s );
+ FT_MOVE_SIGN( b_, b, s );
+ FT_MOVE_SIGN( c_, c, s );
+
if ( c == 0 )
a = 0x7FFFFFFFUL;
@@ -492,13 +493,13 @@
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;
- return s < 0 ? -a_ : a_;
+ return s < 0 ? NEG_LONG( a_ ) : a_;
}
@@ -575,12 +576,12 @@
/* XXX: this function does not allow 64-bit arguments */
- FT_MOVE_SIGN( a_, s );
- FT_MOVE_SIGN( b_, s );
-
a = (FT_UInt32)a_;
b = (FT_UInt32)b_;
+ FT_MOVE_SIGN( a_, a, s );
+ FT_MOVE_SIGN( b_, b, s );
+
if ( a + ( b >> 8 ) <= 8190UL )
a = ( a * b + 0x8000UL ) >> 16;
else
@@ -594,7 +595,7 @@
a_ = (FT_Long)a;
- return s < 0 ? -a_ : a_;
+ return s < 0 ? NEG_LONG( a_ ) : a_;
#endif /* 0 */
@@ -614,12 +615,12 @@
/* XXX: this function does not allow 64-bit arguments */
- FT_MOVE_SIGN( a_, s );
- FT_MOVE_SIGN( b_, s );
-
a = (FT_UInt32)a_;
b = (FT_UInt32)b_;
+ FT_MOVE_SIGN( a_, a, s );
+ FT_MOVE_SIGN( b_, b, s );
+
if ( b == 0 )
{
/* check for division by 0 */
@@ -647,7 +648,7 @@
q_ = (FT_Long)q;
- return s < 0 ? -q_ : q_;
+ return s < 0 ? NEG_LONG( q_ ) : q_;
}
@@ -666,13 +667,19 @@
if ( !a || !b )
return;
- xx = FT_MulFix( a->xx, b->xx ) + FT_MulFix( a->xy, b->yx );
- xy = FT_MulFix( a->xx, b->xy ) + FT_MulFix( a->xy, b->yy );
- yx = FT_MulFix( a->yx, b->xx ) + FT_MulFix( a->yy, b->yx );
- yy = FT_MulFix( a->yx, b->xy ) + FT_MulFix( a->yy, b->yy );
-
- b->xx = xx; b->xy = xy;
- b->yx = yx; b->yy = yy;
+ xx = ADD_LONG( FT_MulFix( a->xx, b->xx ),
+ FT_MulFix( a->xy, b->yx ) );
+ xy = ADD_LONG( FT_MulFix( a->xx, b->xy ),
+ FT_MulFix( a->xy, b->yy ) );
+ yx = ADD_LONG( FT_MulFix( a->yx, b->xx ),
+ FT_MulFix( a->yy, b->yx ) );
+ yy = ADD_LONG( FT_MulFix( a->yx, b->xy ),
+ FT_MulFix( a->yy, b->yy ) );
+
+ b->xx = xx;
+ b->xy = xy;
+ b->yx = yx;
+ b->yy = yy;
}
@@ -722,13 +729,19 @@
if ( !a || !b )
return;
- xx = FT_MulDiv( a->xx, b->xx, val ) + FT_MulDiv( a->xy, b->yx, val );
- xy = FT_MulDiv( a->xx, b->xy, val ) + FT_MulDiv( a->xy, b->yy, val );
- yx = FT_MulDiv( a->yx, b->xx, val ) + FT_MulDiv( a->yy, b->yx, val );
- yy = FT_MulDiv( a->yx, b->xy, val ) + FT_MulDiv( a->yy, b->yy, val );
-
- b->xx = xx; b->xy = xy;
- b->yx = yx; b->yy = yy;
+ xx = ADD_LONG( FT_MulDiv( a->xx, b->xx, val ),
+ FT_MulDiv( a->xy, b->yx, val ) );
+ xy = ADD_LONG( FT_MulDiv( a->xx, b->xy, val ),
+ FT_MulDiv( a->xy, b->yy, val ) );
+ yx = ADD_LONG( FT_MulDiv( a->yx, b->xx, val ),
+ FT_MulDiv( a->yy, b->yx, val ) );
+ yy = ADD_LONG( FT_MulDiv( a->yx, b->xy, val ),
+ FT_MulDiv( a->yy, b->yy, val ) );
+
+ b->xx = xx;
+ b->xy = xy;
+ b->yx = yx;
+ b->yy = yy;
}
@@ -747,11 +760,10 @@
if ( !vector || !matrix )
return;
- xz = FT_MulDiv( vector->x, matrix->xx, val ) +
- FT_MulDiv( vector->y, matrix->xy, val );
-
- yz = FT_MulDiv( vector->x, matrix->yx, val ) +
- FT_MulDiv( vector->y, matrix->yy, val );
+ xz = ADD_LONG( FT_MulDiv( vector->x, matrix->xx, val ),
+ FT_MulDiv( vector->y, matrix->xy, val ) );
+ yz = ADD_LONG( FT_MulDiv( vector->x, matrix->yx, val ),
+ FT_MulDiv( vector->y, matrix->yy, val ) );
vector->x = xz;
vector->y = yz;
@@ -770,12 +782,12 @@
FT_Int sx = 1, sy = 1, shift;
- FT_MOVE_SIGN( x_, sx );
- FT_MOVE_SIGN( y_, sy );
-
x = (FT_UInt32)x_;
y = (FT_UInt32)y_;
+ FT_MOVE_SIGN( x_, x, sx );
+ FT_MOVE_SIGN( y_, y, sy );
+
/* trivial cases */
if ( x == 0 )
{
@@ -913,11 +925,13 @@
FT_Int result;
- if ( (FT_ULong)FT_ABS( in_x ) + (FT_ULong)FT_ABS( out_y ) <= 131071UL &&
- (FT_ULong)FT_ABS( in_y ) + (FT_ULong)FT_ABS( out_x ) <= 131071UL )
+ /* we silently ignore overflow errors, since such large values */
+ /* lead to even more (harmless) rendering errors later on */
+ if ( ADD_LONG( FT_ABS( in_x ), FT_ABS( out_y ) ) <= 131071L &&
+ ADD_LONG( FT_ABS( in_y ), FT_ABS( out_x ) ) <= 131071L )
{
- FT_Long z1 = in_x * out_y;
- FT_Long z2 = in_y * out_x;
+ FT_Long z1 = MUL_LONG( in_x, out_y );
+ FT_Long z2 = MUL_LONG( in_y, out_x );
if ( z1 > z2 )
diff --git a/src/3rdparty/freetype/src/base/ftcid.c b/src/3rdparty/freetype/src/base/ftcid.c
index 0734881b71..f5184649bf 100644
--- a/src/3rdparty/freetype/src/base/ftcid.c
+++ b/src/3rdparty/freetype/src/base/ftcid.c
@@ -4,7 +4,7 @@
/* */
/* FreeType API for accessing CID font information. */
/* */
-/* Copyright 2007-2015 by */
+/* Copyright 2007-2018 by */
/* Derek Clegg and Michael Toftdal. */
/* */
/* This file is part of the FreeType project, and may only be used, */
diff --git a/src/3rdparty/freetype/src/base/ftdbgmem.c b/src/3rdparty/freetype/src/base/ftdbgmem.c
index 6f20313b34..c33d8acb4e 100644
--- a/src/3rdparty/freetype/src/base/ftdbgmem.c
+++ b/src/3rdparty/freetype/src/base/ftdbgmem.c
@@ -4,7 +4,7 @@
/* */
/* Memory debugger (body). */
/* */
-/* Copyright 2001-2015 by */
+/* Copyright 2001-2018 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 );
@@ -367,7 +367,8 @@
{
printf(
"leaked memory block at address %p, size %8ld in (%s:%ld)\n",
- node->address, node->size,
+ (void*)node->address,
+ node->size,
FT_FILENAME( node->source->file_name ),
node->source->line_no );
@@ -462,10 +463,10 @@
(FT_UInt32)( 5 * _ft_debug_lineno );
pnode = &table->sources[hash % FT_MEM_SOURCE_BUCKETS];
- for ( ;; )
+ for (;;)
{
node = *pnode;
- if ( node == NULL )
+ if ( !node )
break;
if ( node->file_name == _ft_debug_file &&
@@ -476,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" );
@@ -544,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;
@@ -716,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 );
@@ -754,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
@@ -798,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 );
@@ -825,7 +826,7 @@
FT_Int result = 0;
- if ( getenv( "FT2_DEBUG_MEMORY" ) )
+ if ( ft_getenv( "FT2_DEBUG_MEMORY" ) )
{
table = ft_mem_table_new( memory );
if ( table )
@@ -838,10 +839,10 @@
memory->realloc = ft_mem_debug_realloc;
memory->free = ft_mem_debug_free;
- p = getenv( "FT2_ALLOC_TOTAL_MAX" );
- if ( p != NULL )
+ p = ft_getenv( "FT2_ALLOC_TOTAL_MAX" );
+ if ( p )
{
- FT_Long total_max = ft_atol( p );
+ FT_Long total_max = ft_strtol( p, NULL, 10 );
if ( total_max > 0 )
@@ -851,10 +852,10 @@
}
}
- p = getenv( "FT2_ALLOC_COUNT_MAX" );
- if ( p != NULL )
+ p = ft_getenv( "FT2_ALLOC_COUNT_MAX" );
+ if ( p )
{
- FT_Long total_count = ft_atol( p );
+ FT_Long total_count = ft_strtol( p, NULL, 10 );
if ( total_count > 0 )
@@ -864,10 +865,10 @@
}
}
- p = getenv( "FT2_KEEP_ALIVE" );
- if ( p != NULL )
+ p = ft_getenv( "FT2_KEEP_ALIVE" );
+ 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/src/3rdparty/freetype/src/base/ftdebug.c b/src/3rdparty/freetype/src/base/ftdebug.c
index 03e18a8699..fe26309101 100644
--- a/src/3rdparty/freetype/src/base/ftdebug.c
+++ b/src/3rdparty/freetype/src/base/ftdebug.c
@@ -4,7 +4,7 @@
/* */
/* Debugging and logging component (body). */
/* */
-/* Copyright 1996-2015 by */
+/* Copyright 1996-2018 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -161,7 +161,7 @@
FT_BASE_DEF( void )
ft_debug_init( void )
{
- const char* ft2_debug = getenv( "FT2_DEBUG" );
+ const char* ft2_debug = ft_getenv( "FT2_DEBUG" );
if ( ft2_debug )
diff --git a/src/3rdparty/freetype/src/base/ftfntfmt.c b/src/3rdparty/freetype/src/base/ftfntfmt.c
index 98e7431a2b..a2900ceb09 100644
--- a/src/3rdparty/freetype/src/base/ftfntfmt.c
+++ b/src/3rdparty/freetype/src/base/ftfntfmt.c
@@ -4,7 +4,7 @@
/* */
/* FreeType utility file for font formats (body). */
/* */
-/* Copyright 2002-2015 by */
+/* Copyright 2002-2018 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
diff --git a/src/3rdparty/freetype/src/base/ftfstype.c b/src/3rdparty/freetype/src/base/ftfstype.c
index cd3458f73e..e6cdf6e2ec 100644
--- a/src/3rdparty/freetype/src/base/ftfstype.c
+++ b/src/3rdparty/freetype/src/base/ftfstype.c
@@ -4,7 +4,7 @@
/* */
/* FreeType utility file to access FSType data (body). */
/* */
-/* Copyright 2008-2015 by */
+/* Copyright 2008-2018 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
diff --git a/src/3rdparty/freetype/src/base/ftgasp.c b/src/3rdparty/freetype/src/base/ftgasp.c
index bbd257c479..4f80bba630 100644
--- a/src/3rdparty/freetype/src/base/ftgasp.c
+++ b/src/3rdparty/freetype/src/base/ftgasp.c
@@ -4,7 +4,7 @@
/* */
/* Access of TrueType's `gasp' table (body). */
/* */
-/* Copyright 2007-2015 by */
+/* Copyright 2007-2018 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
diff --git a/src/3rdparty/freetype/src/base/ftgloadr.c b/src/3rdparty/freetype/src/base/ftgloadr.c
index 7e28638b27..47202496b9 100644
--- a/src/3rdparty/freetype/src/base/ftgloadr.c
+++ b/src/3rdparty/freetype/src/base/ftgloadr.c
@@ -4,7 +4,7 @@
/* */
/* The FreeType glyph loader (body). */
/* */
-/* Copyright 2002-2015 by */
+/* Copyright 2002-2018 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg */
/* */
/* This file is part of the FreeType project, and may only be used, */
diff --git a/src/3rdparty/freetype/src/base/ftglyph.c b/src/3rdparty/freetype/src/base/ftglyph.c
index cb7fc37787..6759aa25d0 100644
--- a/src/3rdparty/freetype/src/base/ftglyph.c
+++ b/src/3rdparty/freetype/src/base/ftglyph.c
@@ -4,7 +4,7 @@
/* */
/* FreeType convenience functions to handle glyphs (body). */
/* */
-/* Copyright 1996-2015 by */
+/* Copyright 1996-2018 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -125,23 +125,25 @@
FT_BitmapGlyph glyph = (FT_BitmapGlyph)bitmap_glyph;
- cbox->xMin = glyph->left << 6;
- cbox->xMax = cbox->xMin + (FT_Pos)( glyph->bitmap.width << 6 );
- cbox->yMax = glyph->top << 6;
- cbox->yMin = cbox->yMax - (FT_Pos)( glyph->bitmap.rows << 6 );
+ cbox->xMin = glyph->left * 64;
+ cbox->xMax = cbox->xMin + (FT_Pos)( glyph->bitmap.width * 64 );
+ cbox->yMax = glyph->top * 64;
+ cbox->yMin = cbox->yMax - (FT_Pos)( glyph->bitmap.rows * 64 );
}
- 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 */
)
@@ -403,13 +407,29 @@
if ( error )
goto Exit;
- /* copy advance while converting it to 16.16 format */
- glyph->advance.x = slot->advance.x << 10;
- glyph->advance.y = slot->advance.y << 10;
+ /* copy advance while converting 26.6 to 16.16 format */
+ if ( slot->advance.x >= 0x8000L * 64 ||
+ slot->advance.x <= -0x8000L * 64 )
+ {
+ FT_ERROR(( "FT_Get_Glyph: advance width too large\n" ));
+ error = FT_THROW( Invalid_Argument );
+ goto Exit2;
+ }
+ if ( slot->advance.y >= 0x8000L * 64 ||
+ slot->advance.y <= -0x8000L * 64 )
+ {
+ FT_ERROR(( "FT_Get_Glyph: advance height too large\n" ));
+ error = FT_THROW( Invalid_Argument );
+ goto Exit2;
+ }
+
+ glyph->advance.x = slot->advance.x * 1024;
+ glyph->advance.y = slot->advance.y * 1024;
/* now import the image from the glyph slot */
error = clazz->glyph_init( glyph, slot );
+ Exit2:
/* if an error occurred, destroy the glyph */
if ( error )
FT_Done_Glyph( glyph );
@@ -542,8 +562,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/src/3rdparty/freetype/src/base/ftgxval.c b/src/3rdparty/freetype/src/base/ftgxval.c
index 58868f2e86..19e2d6acb5 100644
--- a/src/3rdparty/freetype/src/base/ftgxval.c
+++ b/src/3rdparty/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-2015 by */
+/* Copyright 2004-2018 by */
/* Masatake YAMATO, Redhat K.K, */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
diff --git a/src/3rdparty/freetype/src/base/fthash.c b/src/3rdparty/freetype/src/base/fthash.c
new file mode 100644
index 0000000000..21bc8dd5b4
--- /dev/null
+++ b/src/3rdparty/freetype/src/base/fthash.c
@@ -0,0 +1,339 @@
+/***************************************************************************/
+/* */
+/* fthash.c */
+/* */
+/* Hashing functions (body). */
+/* */
+/***************************************************************************/
+
+/*
+ * Copyright 2000 Computing Research Labs, New Mexico State University
+ * Copyright 2001-2015
+ * Francesco Zappa Nardelli
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE COMPUTING RESEARCH LAB OR NEW MEXICO STATE UNIVERSITY BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT
+ * OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+ /*************************************************************************/
+ /* */
+ /* This file is based on code from bdf.c,v 1.22 2000/03/16 20:08:50 */
+ /* */
+ /* taken from Mark Leisher's xmbdfed package */
+ /* */
+ /*************************************************************************/
+
+
+#include <ft2build.h>
+#include FT_INTERNAL_HASH_H
+#include FT_INTERNAL_MEMORY_H
+
+
+#define INITIAL_HT_SIZE 241
+
+
+ static FT_ULong
+ hash_str_lookup( FT_Hashkey* key )
+ {
+ const char* kp = key->str;
+ FT_ULong res = 0;
+
+
+ /* Mocklisp hash function. */
+ while ( *kp )
+ res = ( res << 5 ) - res + (FT_ULong)*kp++;
+
+ return res;
+ }
+
+
+ static FT_ULong
+ hash_num_lookup( FT_Hashkey* key )
+ {
+ FT_ULong num = (FT_ULong)key->num;
+ FT_ULong res;
+
+
+ /* Mocklisp hash function. */
+ res = num & 0xFF;
+ res = ( res << 5 ) - res + ( ( num >> 8 ) & 0xFF );
+ res = ( res << 5 ) - res + ( ( num >> 16 ) & 0xFF );
+ res = ( res << 5 ) - res + ( ( num >> 24 ) & 0xFF );
+
+ return res;
+ }
+
+
+ static FT_Bool
+ hash_str_compare( FT_Hashkey* a,
+ FT_Hashkey* b )
+ {
+ if ( a->str[0] == b->str[0] &&
+ ft_strcmp( a->str, b->str ) == 0 )
+ return 1;
+
+ return 0;
+ }
+
+
+ static FT_Bool
+ hash_num_compare( FT_Hashkey* a,
+ FT_Hashkey* b )
+ {
+ if ( a->num == b->num )
+ return 1;
+
+ return 0;
+ }
+
+
+ static FT_Hashnode*
+ hash_bucket( FT_Hashkey key,
+ FT_Hash hash )
+ {
+ FT_ULong res = 0;
+ FT_Hashnode* bp = hash->table;
+ FT_Hashnode* ndp;
+
+
+ res = (hash->lookup)( &key );
+
+ ndp = bp + ( res % hash->size );
+ while ( *ndp )
+ {
+ if ( (hash->compare)( &(*ndp)->key, &key ) )
+ break;
+
+ ndp--;
+ if ( ndp < bp )
+ ndp = bp + ( hash->size - 1 );
+ }
+
+ return ndp;
+ }
+
+
+ static FT_Error
+ hash_rehash( FT_Hash hash,
+ FT_Memory memory )
+ {
+ FT_Hashnode* obp = hash->table;
+ FT_Hashnode* bp;
+ FT_Hashnode* nbp;
+
+ FT_UInt i, sz = hash->size;
+ FT_Error error = FT_Err_Ok;
+
+
+ hash->size <<= 1;
+ hash->limit = hash->size / 3;
+
+ if ( FT_NEW_ARRAY( hash->table, hash->size ) )
+ goto Exit;
+
+ for ( i = 0, bp = obp; i < sz; i++, bp++ )
+ {
+ if ( *bp )
+ {
+ nbp = hash_bucket( (*bp)->key, hash );
+ *nbp = *bp;
+ }
+ }
+
+ FT_FREE( obp );
+
+ Exit:
+ return error;
+ }
+
+
+ static FT_Error
+ hash_init( FT_Hash hash,
+ FT_Bool is_num,
+ FT_Memory memory )
+ {
+ FT_UInt sz = INITIAL_HT_SIZE;
+ FT_Error error;
+
+
+ hash->size = sz;
+ hash->limit = sz / 3;
+ hash->used = 0;
+
+ if ( is_num )
+ {
+ hash->lookup = hash_num_lookup;
+ hash->compare = hash_num_compare;
+ }
+ else
+ {
+ hash->lookup = hash_str_lookup;
+ hash->compare = hash_str_compare;
+ }
+
+ FT_MEM_NEW_ARRAY( hash->table, sz );
+
+ return error;
+ }
+
+
+ FT_Error
+ ft_hash_str_init( FT_Hash hash,
+ FT_Memory memory )
+ {
+ return hash_init( hash, 0, memory );
+ }
+
+
+ FT_Error
+ ft_hash_num_init( FT_Hash hash,
+ FT_Memory memory )
+ {
+ return hash_init( hash, 1, memory );
+ }
+
+
+ void
+ ft_hash_str_free( FT_Hash hash,
+ FT_Memory memory )
+ {
+ if ( hash )
+ {
+ FT_UInt sz = hash->size;
+ FT_Hashnode* bp = hash->table;
+ FT_UInt i;
+
+
+ for ( i = 0; i < sz; i++, bp++ )
+ FT_FREE( *bp );
+
+ FT_FREE( hash->table );
+ }
+ }
+
+
+ /* `ft_hash_num_free' is the same as `ft_hash_str_free' */
+
+
+ static FT_Error
+ hash_insert( FT_Hashkey key,
+ size_t data,
+ FT_Hash hash,
+ FT_Memory memory )
+ {
+ FT_Hashnode nn;
+ FT_Hashnode* bp = hash_bucket( key, hash );
+ FT_Error error = FT_Err_Ok;
+
+
+ nn = *bp;
+ if ( !nn )
+ {
+ if ( FT_NEW( nn ) )
+ goto Exit;
+ *bp = nn;
+
+ nn->key = key;
+ nn->data = data;
+
+ if ( hash->used >= hash->limit )
+ {
+ error = hash_rehash( hash, memory );
+ if ( error )
+ goto Exit;
+ }
+
+ hash->used++;
+ }
+ else
+ nn->data = data;
+
+ Exit:
+ return error;
+ }
+
+
+ FT_Error
+ ft_hash_str_insert( const char* key,
+ size_t data,
+ FT_Hash hash,
+ FT_Memory memory )
+ {
+ FT_Hashkey hk;
+
+
+ hk.str = key;
+
+ return hash_insert( hk, data, hash, memory );
+ }
+
+
+ FT_Error
+ ft_hash_num_insert( FT_Int num,
+ size_t data,
+ FT_Hash hash,
+ FT_Memory memory )
+ {
+ FT_Hashkey hk;
+
+
+ hk.num = num;
+
+ return hash_insert( hk, data, hash, memory );
+ }
+
+
+ static size_t*
+ hash_lookup( FT_Hashkey key,
+ FT_Hash hash )
+ {
+ FT_Hashnode* np = hash_bucket( key, hash );
+
+
+ return (*np) ? &(*np)->data
+ : NULL;
+ }
+
+
+ size_t*
+ ft_hash_str_lookup( const char* key,
+ FT_Hash hash )
+ {
+ FT_Hashkey hk;
+
+
+ hk.str = key;
+
+ return hash_lookup( hk, hash );
+ }
+
+
+ size_t*
+ ft_hash_num_lookup( FT_Int num,
+ FT_Hash hash )
+ {
+ FT_Hashkey hk;
+
+
+ hk.num = num;
+
+ return hash_lookup( hk, hash );
+ }
+
+
+/* END */
diff --git a/src/3rdparty/freetype/src/base/ftinit.c b/src/3rdparty/freetype/src/base/ftinit.c
index b65a91d06c..1fa4721094 100644
--- a/src/3rdparty/freetype/src/base/ftinit.c
+++ b/src/3rdparty/freetype/src/base/ftinit.c
@@ -4,7 +4,7 @@
/* */
/* FreeType initialization layer (body). */
/* */
-/* Copyright 1996-2015 by */
+/* Copyright 1996-2018 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/src/3rdparty/freetype/src/base/ftlcdfil.c b/src/3rdparty/freetype/src/base/ftlcdfil.c
index ff6f7e98ce..8d314df080 100644
--- a/src/3rdparty/freetype/src/base/ftlcdfil.c
+++ b/src/3rdparty/freetype/src/base/ftlcdfil.c
@@ -4,7 +4,7 @@
/* */
/* FreeType API for color filtering of subpixel bitmap glyphs (body). */
/* */
-/* Copyright 2006-2015 by */
+/* Copyright 2006-2018 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -29,142 +29,140 @@
/* define USE_LEGACY to implement the legacy filter */
#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 )
+#define FT_SHIFTCLAMP( x ) ( x >>= 8, (FT_Byte)( x > 255 ? 255 : x ) )
+
+
+ /* add padding according to filter weights */
+ FT_BASE_DEF (void)
+ ft_lcd_padding( FT_Pos* Min,
+ FT_Pos* Max,
+ FT_GlyphSlot slot )
{
- FT_Byte* weights = library->lcd_weights;
- FT_UInt width = (FT_UInt)bitmap->width;
- FT_UInt height = (FT_UInt)bitmap->rows;
+ FT_Byte* lcd_weights;
+ FT_Bitmap_LcdFilterFunc lcd_filter_func;
- /* horizontal in-place FIR filter */
- if ( mode == FT_RENDER_MODE_LCD && width >= 4 )
+ /* Per-face LCD filtering takes priority if set up. */
+ if ( slot->face && slot->face->internal->lcd_filter_func )
+ {
+ lcd_weights = slot->face->internal->lcd_weights;
+ lcd_filter_func = slot->face->internal->lcd_filter_func;
+ }
+ else
{
- FT_Byte* line = bitmap->buffer;
+ lcd_weights = slot->library->lcd_weights;
+ lcd_filter_func = slot->library->lcd_filter_func;
+ }
+ if ( lcd_filter_func == ft_lcd_filter_fir )
+ {
+ *Min -= lcd_weights[0] ? 43 :
+ lcd_weights[1] ? 22 : 0;
+ *Max += lcd_weights[4] ? 43 :
+ lcd_weights[3] ? 22 : 0;
+ }
+ }
- /* take care of bitmap flow */
- if ( bitmap->pitch < 0 )
- line -= bitmap->pitch * (FT_Int)( bitmap->rows - 1 );
- /* `fir' and `pix' must be at least 32 bit wide, since the sum of */
- /* the values in `weights' can exceed 0xFF */
+ /* FIR filter used by the default and light filters */
+ FT_BASE_DEF( void )
+ ft_lcd_filter_fir( FT_Bitmap* bitmap,
+ FT_Render_Mode mode,
+ FT_LcdFiveTapFilter weights )
+ {
+ FT_UInt width = (FT_UInt)bitmap->width;
+ FT_UInt height = (FT_UInt)bitmap->rows;
+ FT_Int pitch = bitmap->pitch;
+ FT_Byte* origin = bitmap->buffer;
- for ( ; height > 0; height--, line += bitmap->pitch )
- {
- FT_UInt fir[4]; /* below, `pix' is used as the 5th element */
- FT_UInt val1, xx;
+ /* take care of bitmap flow */
+ if ( pitch > 0 && height > 0 )
+ origin += pitch * (FT_Int)( height - 1 );
- val1 = line[0];
- fir[0] = weights[2] * val1;
- fir[1] = weights[3] * val1;
- fir[2] = weights[4] * val1;
- fir[3] = 0;
+ /* horizontal in-place FIR filter */
+ if ( mode == FT_RENDER_MODE_LCD && width >= 2 )
+ {
+ FT_Byte* line = origin;
- val1 = line[1];
- fir[0] += weights[1] * val1;
- fir[1] += weights[2] * val1;
- fir[2] += weights[3] * val1;
- fir[3] += weights[4] * val1;
- for ( xx = 2; xx < width; xx++ )
- {
- FT_UInt val, pix;
+ /* `fir' must be at least 32 bit wide, since the sum of */
+ /* the values in `weights' can exceed 0xFF */
+ for ( ; height > 0; height--, line -= pitch )
+ {
+ FT_UInt fir[5];
+ FT_UInt val, xx;
- val = line[xx];
- pix = fir[0] + weights[0] * val;
- fir[0] = fir[1] + weights[1] * val;
- fir[1] = fir[2] + weights[2] * val;
- fir[2] = fir[3] + weights[3] * val;
- fir[3] = weights[4] * val;
-
- pix >>= 8;
- pix |= (FT_UInt)-(FT_Int)( pix >> 8 );
- line[xx - 2] = (FT_Byte)pix;
- }
- {
- FT_UInt pix;
+ val = line[0];
+ fir[2] = weights[2] * val;
+ fir[3] = weights[3] * val;
+ fir[4] = weights[4] * val;
+ val = line[1];
+ fir[1] = fir[2] + weights[1] * val;
+ fir[2] = fir[3] + weights[2] * val;
+ fir[3] = fir[4] + weights[3] * val;
+ fir[4] = weights[4] * val;
- pix = fir[0] >> 8;
- pix |= (FT_UInt)-(FT_Int)( pix >> 8 );
- line[xx - 2] = (FT_Byte)pix;
+ for ( xx = 2; xx < width; xx++ )
+ {
+ val = line[xx];
+ fir[0] = fir[1] + weights[0] * val;
+ fir[1] = fir[2] + weights[1] * val;
+ fir[2] = fir[3] + weights[2] * val;
+ fir[3] = fir[4] + weights[3] * val;
+ fir[4] = weights[4] * val;
- pix = fir[1] >> 8;
- pix |= (FT_UInt)-(FT_Int)( pix >> 8 );
- line[xx - 1] = (FT_Byte)pix;
+ line[xx - 2] = FT_SHIFTCLAMP( fir[0] );
}
+
+ line[xx - 2] = FT_SHIFTCLAMP( fir[1] );
+ line[xx - 1] = FT_SHIFTCLAMP( fir[2] );
}
}
/* vertical in-place FIR filter */
- else if ( mode == FT_RENDER_MODE_LCD_V && height >= 4 )
+ else if ( mode == FT_RENDER_MODE_LCD_V && height >= 2 )
{
- FT_Byte* column = bitmap->buffer;
- FT_Int pitch = bitmap->pitch;
-
+ FT_Byte* column = origin;
- /* take care of bitmap flow */
- if ( bitmap->pitch < 0 )
- column -= bitmap->pitch * (FT_Int)( bitmap->rows - 1 );
for ( ; width > 0; width--, column++ )
{
FT_Byte* col = column;
- FT_UInt fir[4]; /* below, `pix' is used as the 5th element */
- FT_UInt val1, yy;
+ FT_UInt fir[5];
+ FT_UInt val, yy;
- val1 = col[0];
- fir[0] = weights[2] * val1;
- fir[1] = weights[3] * val1;
- fir[2] = weights[4] * val1;
- fir[3] = 0;
- col += pitch;
+ val = col[0];
+ fir[2] = weights[2] * val;
+ fir[3] = weights[3] * val;
+ fir[4] = weights[4] * val;
+ col -= pitch;
- val1 = col[0];
- fir[0] += weights[1] * val1;
- fir[1] += weights[2] * val1;
- fir[2] += weights[3] * val1;
- fir[3] += weights[4] * val1;
- col += pitch;
+ val = col[0];
+ fir[1] = fir[2] + weights[1] * val;
+ fir[2] = fir[3] + weights[2] * val;
+ fir[3] = fir[4] + weights[3] * val;
+ fir[4] = weights[4] * val;
+ col -= pitch;
- for ( yy = 2; yy < height; yy++ )
+ for ( yy = 2; yy < height; yy++, col -= pitch )
{
- FT_UInt val, pix;
-
-
val = col[0];
- pix = fir[0] + weights[0] * val;
- fir[0] = fir[1] + weights[1] * val;
- fir[1] = fir[2] + weights[2] * val;
- fir[2] = fir[3] + weights[3] * val;
- fir[3] = weights[4] * val;
-
- pix >>= 8;
- pix |= (FT_UInt)-(FT_Int)( pix >> 8 );
- col[-2 * pitch] = (FT_Byte)pix;
- col += pitch;
- }
-
- {
- FT_UInt pix;
+ fir[0] = fir[1] + weights[0] * val;
+ fir[1] = fir[2] + weights[1] * val;
+ fir[2] = fir[3] + weights[2] * val;
+ fir[3] = fir[4] + weights[3] * val;
+ fir[4] = weights[4] * val;
-
- pix = fir[0] >> 8;
- pix |= (FT_UInt)-(FT_Int)( pix >> 8 );
- col[-2 * pitch] = (FT_Byte)pix;
-
- pix = fir[1] >> 8;
- pix |= (FT_UInt)-(FT_Int)( pix >> 8 );
- col[-pitch] = (FT_Byte)pix;
+ col[pitch * 2] = FT_SHIFTCLAMP( fir[0] );
}
+
+ col[pitch * 2] = FT_SHIFTCLAMP( fir[1] );
+ col[pitch] = FT_SHIFTCLAMP( fir[2] );
}
}
}
@@ -176,11 +174,12 @@
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;
- FT_Int pitch = bitmap->pitch;
+ FT_UInt width = (FT_UInt)bitmap->width;
+ FT_UInt height = (FT_UInt)bitmap->rows;
+ FT_Int pitch = bitmap->pitch;
+ FT_Byte* origin = bitmap->buffer;
static const unsigned int filters[3][3] =
{
@@ -189,36 +188,34 @@
{ 65538 * 1/13, 65538 * 1/6, 65538 * 9/13 }
};
- FT_UNUSED( library );
+ FT_UNUSED( weights );
+ /* take care of bitmap flow */
+ if ( pitch > 0 && height > 0 )
+ origin += pitch * (FT_Int)( height - 1 );
+
/* horizontal in-place intra-pixel filter */
if ( mode == FT_RENDER_MODE_LCD && width >= 3 )
{
- FT_Byte* line = bitmap->buffer;
-
+ FT_Byte* line = origin;
- /* take care of bitmap flow */
- if ( bitmap->pitch < 0 )
- line -= bitmap->pitch * (FT_Int)( bitmap->rows - 1 );
- for ( ; height > 0; height--, line += pitch )
+ for ( ; height > 0; height--, line -= pitch )
{
FT_UInt xx;
for ( xx = 0; xx < width; xx += 3 )
{
- FT_UInt r = 0;
- FT_UInt g = 0;
- FT_UInt b = 0;
+ FT_UInt r, g, b;
FT_UInt p;
p = line[xx];
- r += filters[0][0] * p;
- g += filters[0][1] * p;
- b += filters[0][2] * p;
+ r = filters[0][0] * p;
+ g = filters[0][1] * p;
+ b = filters[0][2] * p;
p = line[xx + 1];
r += filters[1][0] * p;
@@ -238,31 +235,24 @@
}
else if ( mode == FT_RENDER_MODE_LCD_V && height >= 3 )
{
- FT_Byte* column = bitmap->buffer;
+ FT_Byte* column = origin;
- /* take care of bitmap flow */
- if ( bitmap->pitch < 0 )
- column -= bitmap->pitch * (FT_Int)( bitmap->rows - 1 );
-
for ( ; width > 0; width--, column++ )
{
- FT_Byte* col = column;
- FT_Byte* col_end = col + (FT_Int)height * pitch;
+ FT_Byte* col = column - 2 * pitch;
- for ( ; col < col_end; col += 3 * pitch )
+ for ( ; height > 0; height -= 3, col -= 3 * pitch )
{
- FT_UInt r = 0;
- FT_UInt g = 0;
- FT_UInt b = 0;
+ FT_UInt r, g, b;
FT_UInt p;
p = col[0];
- r += filters[0][0] * p;
- g += filters[0][1] * p;
- b += filters[0][2] * p;
+ r = filters[0][0] * p;
+ g = filters[0][1] * p;
+ b = filters[0][2] * p;
p = col[pitch];
r += filters[1][0] * p;
@@ -276,7 +266,7 @@
col[0] = (FT_Byte)( r / 65536 );
col[pitch] = (FT_Byte)( g / 65536 );
- col[2 * pitch] = (FT_Byte)( b / 65536 );
+ col[pitch * 2] = (FT_Byte)( b / 65536 );
}
}
}
@@ -295,7 +285,8 @@
if ( !weights )
return FT_THROW( Invalid_Argument );
- ft_memcpy( library->lcd_weights, weights, 5 );
+ ft_memcpy( library->lcd_weights, weights, FT_LCD_FILTER_FIVE_TAPS );
+ library->lcd_filter_func = ft_lcd_filter_fir;
return FT_Err_Ok;
}
@@ -305,12 +296,10 @@
FT_Library_SetLcdFilter( FT_Library library,
FT_LcdFilter filter )
{
- static const FT_Byte light_filter[5] =
- { 0x00, 0x55, 0x56, 0x55, 0x00 };
- /* the values here sum up to a value larger than 256, */
- /* providing a cheap gamma correction */
- static const FT_Byte default_filter[5] =
- { 0x10, 0x40, 0x70, 0x40, 0x10 };
+ static const FT_LcdFiveTapFilter default_weights =
+ { 0x08, 0x4d, 0x56, 0x4d, 0x08 };
+ static const FT_LcdFiveTapFilter light_weights =
+ { 0x00, 0x55, 0x56, 0x55, 0x00 };
if ( !library )
@@ -320,42 +309,27 @@
{
case FT_LCD_FILTER_NONE:
library->lcd_filter_func = NULL;
- library->lcd_extra = 0;
break;
case FT_LCD_FILTER_DEFAULT:
-#if defined( FT_FORCE_LEGACY_LCD_FILTER )
-
- library->lcd_filter_func = _ft_lcd_filter_legacy;
- library->lcd_extra = 0;
-
-#elif defined( FT_FORCE_LIGHT_LCD_FILTER )
-
- ft_memcpy( library->lcd_weights, light_filter, 5 );
- library->lcd_filter_func = _ft_lcd_filter_fir;
- library->lcd_extra = 2;
-
-#else
-
- ft_memcpy( library->lcd_weights, default_filter, 5 );
- library->lcd_filter_func = _ft_lcd_filter_fir;
- library->lcd_extra = 2;
-
-#endif
-
+ ft_memcpy( library->lcd_weights,
+ default_weights,
+ FT_LCD_FILTER_FIVE_TAPS );
+ library->lcd_filter_func = ft_lcd_filter_fir;
break;
case FT_LCD_FILTER_LIGHT:
- ft_memcpy( library->lcd_weights, light_filter, 5 );
- library->lcd_filter_func = _ft_lcd_filter_fir;
- library->lcd_extra = 2;
+ ft_memcpy( library->lcd_weights,
+ light_weights,
+ FT_LCD_FILTER_FIVE_TAPS );
+ library->lcd_filter_func = ft_lcd_filter_fir;
break;
#ifdef USE_LEGACY
case FT_LCD_FILTER_LEGACY:
+ case FT_LCD_FILTER_LEGACY1:
library->lcd_filter_func = _ft_lcd_filter_legacy;
- library->lcd_extra = 0;
break;
#endif
@@ -364,13 +338,24 @@
return FT_THROW( Invalid_Argument );
}
- library->lcd_filter = filter;
-
return FT_Err_Ok;
}
#else /* !FT_CONFIG_OPTION_SUBPIXEL_RENDERING */
+ /* add padding according to accommodate outline shifts */
+ FT_BASE_DEF (void)
+ ft_lcd_padding( FT_Pos* Min,
+ FT_Pos* Max,
+ FT_GlyphSlot slot )
+ {
+ FT_UNUSED( slot );
+
+ *Min -= 21;
+ *Max += 21;
+ }
+
+
FT_EXPORT_DEF( FT_Error )
FT_Library_SetLcdFilterWeights( FT_Library library,
unsigned char *weights )
diff --git a/src/3rdparty/freetype/src/base/ftmac.c b/src/3rdparty/freetype/src/base/ftmac.c
index 114bbb6391..fd4c0cc274 100644
--- a/src/3rdparty/freetype/src/base/ftmac.c
+++ b/src/3rdparty/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-2015 by */
+/* Copyright 1996-2018 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,
@@ -228,7 +229,7 @@
if ( !fontName || !face_index )
- return FT_THROW( Invalid_Argument) ;
+ return FT_THROW( Invalid_Argument);
err = FT_GetFileRef_From_Mac_ATS_Name( fontName, &ref, face_index );
if ( err )
@@ -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 );
}
@@ -1002,7 +1005,7 @@
/* accepts an FSRef instead of a path. */
/* */
/* This function is deprecated because Carbon data types (FSRef) */
- /* are not cross-platform, and thus not suitable for the freetype API. */
+ /* are not cross-platform, and thus not suitable for the FreeType API. */
FT_EXPORT_DEF( FT_Error )
FT_New_Face_From_FSRef( FT_Library library,
const FSRef* ref,
@@ -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/src/3rdparty/freetype/src/base/ftmm.c b/src/3rdparty/freetype/src/base/ftmm.c
index 7c012aa438..800441bcac 100644
--- a/src/3rdparty/freetype/src/base/ftmm.c
+++ b/src/3rdparty/freetype/src/base/ftmm.c
@@ -4,7 +4,7 @@
/* */
/* Multiple Master font support (body). */
/* */
-/* Copyright 1996-2015 by */
+/* Copyright 1996-2018 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 )
@@ -119,6 +148,25 @@
/* documentation is in ftmm.h */
FT_EXPORT_DEF( FT_Error )
+ FT_Done_MM_Var( FT_Library library,
+ FT_MM_Var* amaster )
+ {
+ FT_Memory memory;
+
+
+ if ( !library )
+ return FT_THROW( Invalid_Library_Handle );
+
+ memory = library->memory;
+ FT_FREE( amaster );
+
+ return FT_Err_Ok;
+ }
+
+
+ /* documentation is in ftmm.h */
+
+ FT_EXPORT_DEF( FT_Error )
FT_Set_MM_Design_Coordinates( FT_Face face,
FT_UInt num_coords,
FT_Long* coords )
@@ -129,7 +177,7 @@
/* check of `face' delayed to `ft_face_get_mm_service' */
- if ( !coords )
+ if ( num_coords && !coords )
return FT_THROW( Invalid_Argument );
error = ft_face_get_mm_service( face, &service );
@@ -140,6 +188,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;
}
@@ -151,6 +206,54 @@
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 ( num_coords && !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 );
+
+ /* internal error code -1 means `no change'; we can exit immediately */
+ if ( error == -1 )
+ return FT_Err_Ok;
+ }
+
+ 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 +267,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;
@@ -179,6 +282,105 @@
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 ( num_coords && !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 );
+
+ /* internal error code -1 means `no change'; we can exit immediately */
+ if ( error == -1 )
+ return FT_Err_Ok;
+ }
+
+ 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 ( num_coords && !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 );
+
+ /* internal error code -1 means `no change'; we can exit immediately */
+ if ( error == -1 )
+ return FT_Err_Ok;
+ }
+
+ 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 +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;
@@ -206,7 +408,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 +425,80 @@
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;
+ }
+
+
+ /* documentation is in ftmm.h */
+
+ FT_EXPORT_DEF( FT_Error )
+ FT_Get_Var_Axis_Flags( FT_MM_Var* master,
+ FT_UInt axis_index,
+ FT_UInt* flags )
+ {
+ FT_UShort* axis_flags;
+
+
+ if ( !master || !flags )
+ return FT_THROW( Invalid_Argument );
+
+ if ( axis_index >= master->num_axis )
+ return FT_THROW( Invalid_Argument );
+
+ /* the axis flags array immediately follows the data of `master' */
+ axis_flags = (FT_UShort*)&( master[1] );
+ *flags = axis_flags[axis_index];
+
+ return FT_Err_Ok;
+ }
+
+
+ /* documentation is in ftmm.h */
+
+ FT_EXPORT_DEF( FT_Error )
+ FT_Set_Named_Instance( FT_Face face,
+ FT_UInt instance_index )
+ {
+ 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' */
+
+ error = ft_face_get_mm_service( face, &service_mm );
+ if ( !error )
+ {
+ error = FT_ERR( Invalid_Argument );
+ if ( service_mm->set_instance )
+ error = service_mm->set_instance( face, instance_index );
+ }
+
+ 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;
+ }
+
+ if ( !error )
+ {
+ face->face_index = ( instance_index << 16 ) |
+ ( face->face_index & 0xFFFFL );
+ face->face_flags &= ~FT_FACE_FLAG_VARIATION;
}
return error;
diff --git a/src/3rdparty/freetype/src/base/ftobjs.c b/src/3rdparty/freetype/src/base/ftobjs.c
index f0c2e77fcc..8d07e35ae3 100644
--- a/src/3rdparty/freetype/src/base/ftobjs.c
+++ b/src/3rdparty/freetype/src/base/ftobjs.c
@@ -4,7 +4,7 @@
/* */
/* The FreeType private base classes (body). */
/* */
-/* Copyright 1996-2015 by */
+/* Copyright 1996-2018 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -19,12 +19,16 @@
#include <ft2build.h>
#include FT_LIST_H
#include FT_OUTLINE_H
+#include FT_FONT_FORMATS_H
+
#include FT_INTERNAL_VALIDATE_H
#include FT_INTERNAL_OBJECTS_H
#include FT_INTERNAL_DEBUG_H
#include FT_INTERNAL_RFORK_H
#include FT_INTERNAL_STREAM_H
-#include FT_INTERNAL_SFNT_H /* for SFNT_Load_Table_Func */
+#include FT_INTERNAL_SFNT_H /* for SFNT_Load_Table_Func */
+#include FT_INTERNAL_POSTSCRIPT_AUX_H /* for PS_Driver */
+
#include FT_TRUETYPE_TABLES_H
#include FT_TRUETYPE_TAGS_H
#include FT_TRUETYPE_IDS_H
@@ -37,6 +41,8 @@
#include FT_SERVICE_KERNING_H
#include FT_SERVICE_TRUETYPE_ENGINE_H
+#include FT_DRIVER_H
+
#ifdef FT_CONFIG_OPTION_MAC_FONTS
#include "ftbase.h"
#endif
@@ -55,7 +61,18 @@
#pragma warning( disable : 4244 )
#endif /* _MSC_VER */
- /* it's easiest to include `md5.c' directly */
+ /* It's easiest to include `md5.c' directly. However, since OpenSSL */
+ /* also provides the same functions, there might be conflicts if */
+ /* both FreeType and OpenSSL are built as static libraries. For */
+ /* this reason, we put the MD5 stuff into the `FT_' namespace. */
+#define MD5_u32plus FT_MD5_u32plus
+#define MD5_CTX FT_MD5_CTX
+#define MD5_Init FT_MD5_Init
+#define MD5_Update FT_MD5_Update
+#define MD5_Final FT_MD5_Final
+
+#undef HAVE_OPENSSL
+
#include "md5.c"
#if defined( _MSC_VER )
@@ -68,6 +85,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 )
@@ -305,6 +331,138 @@
FT_BASE_DEF( void )
+ ft_glyphslot_preset_bitmap( FT_GlyphSlot slot,
+ FT_Render_Mode mode,
+ const FT_Vector* origin )
+ {
+ FT_Outline* outline = &slot->outline;
+ FT_Bitmap* bitmap = &slot->bitmap;
+
+ FT_Pixel_Mode pixel_mode;
+
+ FT_BBox cbox;
+ FT_Pos x_shift = 0;
+ FT_Pos y_shift = 0;
+ FT_Pos x_left, y_top;
+ FT_Pos width, height, pitch;
+
+
+ if ( slot->internal && ( slot->internal->flags & FT_GLYPH_OWN_BITMAP ) )
+ return;
+
+ if ( origin )
+ {
+ x_shift = origin->x;
+ y_shift = origin->y;
+ }
+
+ /* compute the control box, and grid-fit it, */
+ /* taking into account the origin shift */
+ FT_Outline_Get_CBox( outline, &cbox );
+
+ cbox.xMin += x_shift;
+ cbox.yMin += y_shift;
+ cbox.xMax += x_shift;
+ cbox.yMax += y_shift;
+
+ switch ( mode )
+ {
+ case FT_RENDER_MODE_MONO:
+ pixel_mode = FT_PIXEL_MODE_MONO;
+#if 1
+ /* undocumented but confirmed: bbox values get rounded */
+ /* unless the rounded box can collapse for a narrow glyph */
+ if ( cbox.xMax - cbox.xMin < 64 )
+ {
+ cbox.xMin = FT_PIX_FLOOR( cbox.xMin );
+ cbox.xMax = FT_PIX_CEIL_LONG( cbox.xMax );
+ }
+ else
+ {
+ cbox.xMin = FT_PIX_ROUND_LONG( cbox.xMin );
+ cbox.xMax = FT_PIX_ROUND_LONG( cbox.xMax );
+ }
+
+ if ( cbox.yMax - cbox.yMin < 64 )
+ {
+ cbox.yMin = FT_PIX_FLOOR( cbox.yMin );
+ cbox.yMax = FT_PIX_CEIL_LONG( cbox.yMax );
+ }
+ else
+ {
+ cbox.yMin = FT_PIX_ROUND_LONG( cbox.yMin );
+ cbox.yMax = FT_PIX_ROUND_LONG( cbox.yMax );
+ }
+#else
+ cbox.xMin = FT_PIX_FLOOR( cbox.xMin );
+ cbox.yMin = FT_PIX_FLOOR( cbox.yMin );
+ cbox.xMax = FT_PIX_CEIL_LONG( cbox.xMax );
+ cbox.yMax = FT_PIX_CEIL_LONG( cbox.yMax );
+#endif
+ break;
+
+ case FT_RENDER_MODE_LCD:
+ pixel_mode = FT_PIXEL_MODE_LCD;
+ ft_lcd_padding( &cbox.xMin, &cbox.xMax, slot );
+ goto Round;
+
+ case FT_RENDER_MODE_LCD_V:
+ pixel_mode = FT_PIXEL_MODE_LCD_V;
+ ft_lcd_padding( &cbox.yMin, &cbox.yMax, slot );
+ goto Round;
+
+ case FT_RENDER_MODE_NORMAL:
+ case FT_RENDER_MODE_LIGHT:
+ default:
+ pixel_mode = FT_PIXEL_MODE_GRAY;
+ Round:
+ cbox.xMin = FT_PIX_FLOOR( cbox.xMin );
+ cbox.yMin = FT_PIX_FLOOR( cbox.yMin );
+ cbox.xMax = FT_PIX_CEIL_LONG( cbox.xMax );
+ cbox.yMax = FT_PIX_CEIL_LONG( cbox.yMax );
+ }
+
+ x_shift = SUB_LONG( x_shift, cbox.xMin );
+ y_shift = SUB_LONG( y_shift, cbox.yMin );
+
+ x_left = cbox.xMin >> 6;
+ y_top = cbox.yMax >> 6;
+
+ width = ( (FT_ULong)cbox.xMax - (FT_ULong)cbox.xMin ) >> 6;
+ height = ( (FT_ULong)cbox.yMax - (FT_ULong)cbox.yMin ) >> 6;
+
+ switch ( pixel_mode )
+ {
+ case FT_PIXEL_MODE_MONO:
+ pitch = ( ( width + 15 ) >> 4 ) << 1;
+ break;
+
+ case FT_PIXEL_MODE_LCD:
+ width *= 3;
+ pitch = FT_PAD_CEIL( width, 4 );
+ break;
+
+ case FT_PIXEL_MODE_LCD_V:
+ height *= 3;
+ /* fall through */
+
+ case FT_PIXEL_MODE_GRAY:
+ default:
+ pitch = width;
+ }
+
+ slot->bitmap_left = (FT_Int)x_left;
+ slot->bitmap_top = (FT_Int)y_top;
+
+ bitmap->pixel_mode = (unsigned char)pixel_mode;
+ bitmap->num_grays = 256;
+ bitmap->width = (unsigned int)width;
+ bitmap->rows = (unsigned int)height;
+ bitmap->pitch = pitch;
+ }
+
+
+ FT_BASE_DEF( void )
ft_glyphslot_set_bitmap( FT_GlyphSlot slot,
FT_Byte* buffer )
{
@@ -442,7 +600,8 @@
Exit:
- FT_TRACE4(( "FT_New_GlyphSlot: Return %d\n", error ));
+ FT_TRACE4(( "FT_New_GlyphSlot: Return 0x%x\n", error ));
+
return error;
}
@@ -555,34 +714,42 @@
if ( vertical )
{
metrics->horiBearingX = FT_PIX_FLOOR( metrics->horiBearingX );
- metrics->horiBearingY = FT_PIX_CEIL ( metrics->horiBearingY );
+ metrics->horiBearingY = FT_PIX_CEIL_LONG( metrics->horiBearingY );
- right = FT_PIX_CEIL( metrics->vertBearingX + metrics->width );
- bottom = FT_PIX_CEIL( metrics->vertBearingY + metrics->height );
+ right = FT_PIX_CEIL_LONG( ADD_LONG( metrics->vertBearingX,
+ metrics->width ) );
+ bottom = FT_PIX_CEIL_LONG( ADD_LONG( metrics->vertBearingY,
+ metrics->height ) );
metrics->vertBearingX = FT_PIX_FLOOR( metrics->vertBearingX );
metrics->vertBearingY = FT_PIX_FLOOR( metrics->vertBearingY );
- metrics->width = right - metrics->vertBearingX;
- metrics->height = bottom - metrics->vertBearingY;
+ metrics->width = SUB_LONG( right,
+ metrics->vertBearingX );
+ metrics->height = SUB_LONG( bottom,
+ metrics->vertBearingY );
}
else
{
metrics->vertBearingX = FT_PIX_FLOOR( metrics->vertBearingX );
metrics->vertBearingY = FT_PIX_FLOOR( metrics->vertBearingY );
- right = FT_PIX_CEIL ( metrics->horiBearingX + metrics->width );
- bottom = FT_PIX_FLOOR( metrics->horiBearingY - metrics->height );
+ right = FT_PIX_CEIL_LONG( ADD_LONG( metrics->horiBearingX,
+ metrics->width ) );
+ bottom = FT_PIX_FLOOR( SUB_LONG( metrics->horiBearingY,
+ metrics->height ) );
metrics->horiBearingX = FT_PIX_FLOOR( metrics->horiBearingX );
- metrics->horiBearingY = FT_PIX_CEIL ( metrics->horiBearingY );
+ metrics->horiBearingY = FT_PIX_CEIL_LONG( metrics->horiBearingY );
- metrics->width = right - metrics->horiBearingX;
- metrics->height = metrics->horiBearingY - bottom;
+ metrics->width = SUB_LONG( right,
+ metrics->horiBearingX );
+ metrics->height = SUB_LONG( metrics->horiBearingY,
+ bottom );
}
- metrics->horiAdvance = FT_PIX_ROUND( metrics->horiAdvance );
- metrics->vertAdvance = FT_PIX_ROUND( metrics->vertAdvance );
+ metrics->horiAdvance = FT_PIX_ROUND_LONG( metrics->horiAdvance );
+ metrics->vertAdvance = FT_PIX_ROUND_LONG( metrics->vertAdvance );
}
#endif /* GRID_FIT_METRICS */
@@ -630,13 +797,20 @@
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:
*
- * - Do only auto-hinting if we have a hinter module, a scalable font
- * format dealing with outlines, and no transforms except simple
- * slants and/or rotations by integer multiples of 90 degrees.
+ * - Do only auto-hinting if we have
+ *
+ * - a hinter module,
+ * - a scalable font format dealing with outlines,
+ * - not a tricky font, and
+ * - no transforms except simple slants and/or rotations by
+ * integer multiples of 90 degrees.
*
* - Then, auto-hint if FT_LOAD_FORCE_AUTOHINT is set or if we don't
* have a native font hinter.
@@ -666,7 +840,14 @@
else
{
FT_Render_Mode mode = FT_LOAD_TARGET_MODE( load_flags );
+ FT_Bool is_light_type1;
+
+ /* only the new Adobe engine (for both CFF and Type 1) is `light'; */
+ /* we use `strstr' to catch both `Type 1' and `CID Type 1' */
+ is_light_type1 =
+ ft_strstr( FT_Get_Font_Format( face ), "Type 1" ) != NULL &&
+ ((PS_Driver)driver)->hinting_engine == FT_HINTING_ADOBE;
/* the check for `num_locations' assures that we actually */
/* test for instructions in a TTF and not in a CFF-based OTF */
@@ -675,8 +856,9 @@
/* 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 ||
- face->internal->ignore_unpatented_hinter ||
+ if ( ( mode == FT_RENDER_MODE_LIGHT &&
+ ( !FT_DRIVER_HINTS_LIGHTLY( driver ) &&
+ !is_light_type1 ) ) ||
( FT_IS_SFNT( face ) &&
ttface->num_locations &&
ttface->max_profile.maxSizeOfInstructions == 0 &&
@@ -696,8 +878,8 @@
/* XXX: This is really a temporary hack that should disappear */
/* promptly with FreeType 2.1! */
/* */
- if ( FT_HAS_FIXED_SIZES( face ) &&
- ( load_flags & FT_LOAD_NO_BITMAP ) == 0 )
+ if ( FT_HAS_FIXED_SIZES( face ) &&
+ ( load_flags & FT_LOAD_NO_BITMAP ) == 0 )
{
error = driver->clazz->load_glyph( slot, face->size,
glyph_index,
@@ -765,7 +947,7 @@
/* compute the linear advance in 16.16 pixels */
if ( ( load_flags & FT_LOAD_LINEAR_DESIGN ) == 0 &&
- ( FT_IS_SCALABLE( face ) ) )
+ FT_IS_SCALABLE( face ) )
{
FT_Size_Metrics* metrics = &face->size->metrics;
@@ -813,28 +995,37 @@
}
}
- FT_TRACE5(( " x advance: %d\n" , slot->advance.x ));
- FT_TRACE5(( " y advance: %d\n" , slot->advance.y ));
-
- FT_TRACE5(( " linear x advance: %d\n" , slot->linearHoriAdvance ));
- FT_TRACE5(( " linear y advance: %d\n" , slot->linearVertAdvance ));
-
- /* do we need to render the image now? */
+ /* do we need to render the image or preset the bitmap now? */
if ( !error &&
+ ( load_flags & FT_LOAD_NO_SCALE ) == 0 &&
slot->format != FT_GLYPH_FORMAT_BITMAP &&
- slot->format != FT_GLYPH_FORMAT_COMPOSITE &&
- load_flags & FT_LOAD_RENDER )
+ slot->format != FT_GLYPH_FORMAT_COMPOSITE )
{
FT_Render_Mode mode = FT_LOAD_TARGET_MODE( load_flags );
- if ( mode == FT_RENDER_MODE_NORMAL &&
- (load_flags & FT_LOAD_MONOCHROME ) )
+ if ( mode == FT_RENDER_MODE_NORMAL &&
+ load_flags & FT_LOAD_MONOCHROME )
mode = FT_RENDER_MODE_MONO;
- error = FT_Render_Glyph( slot, mode );
+ if ( load_flags & FT_LOAD_RENDER )
+ error = FT_Render_Glyph( slot, mode );
+ else
+ ft_glyphslot_preset_bitmap( slot, mode, NULL );
}
+ FT_TRACE5(( "FT_Load_Glyph: index %d, flags %x\n",
+ glyph_index, load_flags ));
+ FT_TRACE5(( " x advance: %f\n", slot->advance.x / 64.0 ));
+ FT_TRACE5(( " y advance: %f\n", slot->advance.y / 64.0 ));
+ FT_TRACE5(( " linear x advance: %f\n",
+ slot->linearHoriAdvance / 65536.0 ));
+ FT_TRACE5(( " linear y advance: %f\n",
+ slot->linearVertAdvance / 65536.0 ));
+ FT_TRACE5(( " bitmap %dx%d, mode %d\n",
+ slot->bitmap.width, slot->bitmap.rows,
+ slot->bitmap.pixel_mode ));
+
Exit:
return error;
}
@@ -1091,7 +1282,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 &&
@@ -1162,6 +1353,8 @@
}
#endif
+ face->internal->random_seed = -1;
+
if ( clazz->init_face )
error = clazz->init_face( *astream,
face,
@@ -1226,7 +1419,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
@@ -1253,7 +1446,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 );
}
@@ -1288,7 +1481,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 )
{
@@ -1304,7 +1497,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,
@@ -1324,7 +1517,7 @@
return FT_THROW( Invalid_Argument );
*astream = NULL;
- memory = library->memory;
+ memory = library->memory;
if ( FT_NEW( stream ) )
goto Exit;
@@ -1340,7 +1533,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,
@@ -1366,11 +1559,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 );
}
@@ -1384,9 +1577,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
@@ -1407,7 +1600,7 @@
/* Type 1 and CID-keyed font drivers should recognize sfnt-wrapped */
/* format too. Here, since we can't expect that the TrueType font */
- /* driver is loaded unconditially, we must parse the font by */
+ /* driver is loaded unconditionally, we must parse the font by */
/* ourselves. We are only interested in the name of the table and */
/* the offset. */
@@ -1472,6 +1665,7 @@
if ( face_index >= 0 && pstable_index == face_index )
return FT_Err_Ok;
}
+
return FT_THROW( Table_Missing );
}
@@ -1509,14 +1703,29 @@
if ( error )
goto Exit;
- if ( FT_Stream_Seek( stream, pos + offset ) )
+ if ( offset > stream->size )
+ {
+ FT_TRACE2(( "open_face_PS_from_sfnt_stream: invalid table offset\n" ));
+ error = FT_THROW( Invalid_Table );
+ goto Exit;
+ }
+ else if ( length > stream->size - offset )
+ {
+ FT_TRACE2(( "open_face_PS_from_sfnt_stream: invalid table length\n" ));
+ error = FT_THROW( Invalid_Table );
+ goto Exit;
+ }
+
+ error = FT_Stream_Seek( stream, pos + offset );
+ if ( error )
goto Exit;
if ( FT_ALLOC( sfnt_ps, (FT_Long)length ) )
goto Exit;
error = FT_Stream_Read( stream, (FT_Byte *)sfnt_ps, length );
- if ( error ) {
+ if ( error )
+ {
FT_FREE( sfnt_ps );
goto Exit;
}
@@ -1562,6 +1771,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;
@@ -1577,12 +1787,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,
@@ -1590,12 +1800,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;
}
@@ -1603,15 +1816,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;
@@ -1624,9 +1842,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 )
@@ -1645,18 +1864,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;
@@ -1668,9 +1893,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 );
@@ -1680,13 +1908,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;
@@ -1700,14 +1931,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;
@@ -1728,11 +1963,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 );
@@ -1764,8 +2000,8 @@
FT_Long face_index_in_resource = 0;
- if ( face_index == -1 )
- face_index = 0;
+ if ( face_index < 0 )
+ face_index = -face_index - 1;
if ( face_index >= resource_cnt )
return FT_THROW( Cannot_Open_Resource );
@@ -1776,7 +2012,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 );
@@ -1790,7 +2026,8 @@
goto Exit;
/* rewind sfnt stream before open_face_PS_from_sfnt_stream() */
- if ( FT_Stream_Seek( stream, flag_offset + 4 ) )
+ error = FT_Stream_Seek( stream, flag_offset + 4 );
+ if ( error )
goto Exit;
if ( FT_ALLOC( sfnt_data, rlen ) )
@@ -1828,19 +2065,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 )
@@ -1857,7 +2094,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 )
@@ -1890,7 +2127,7 @@
FT_Long dlen, offset;
- if ( NULL == stream )
+ if ( !stream )
return FT_THROW( Invalid_Stream_Operation );
error = FT_Stream_Seek( stream, 0 );
@@ -1964,13 +2201,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;
}
@@ -2080,6 +2319,17 @@
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;
FT_Memory memory = NULL;
@@ -2090,6 +2340,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' */
@@ -2167,11 +2434,13 @@
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 */
- if ( FT_Stream_Seek( stream, 0 ) )
+ error = FT_Stream_Seek( stream, 0 );
+ if ( error )
break;
error = open_face_PS_from_sfnt_stream( library,
@@ -2203,16 +2472,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 ) )
@@ -2285,11 +2558,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;
+ }
}
}
@@ -2307,6 +2593,13 @@
internal->transform_delta.y = 0;
internal->refcount = 1;
+
+ internal->no_stem_darkening = -1;
+
+#ifdef FT_CONFIG_OPTION_SUBPIXEL_RENDERING
+ /* Per-face filtering can only be set up by FT_Face_Properties */
+ internal->lcd_filter_func = NULL;
+#endif
}
if ( aface )
@@ -2323,7 +2616,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;
}
@@ -2464,6 +2770,8 @@
FT_Size size = NULL;
FT_ListNode node = NULL;
+ FT_Size_Internal internal = NULL;
+
if ( !face )
return FT_THROW( Invalid_Face_Handle );
@@ -2486,8 +2794,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 );
@@ -2589,6 +2899,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;
@@ -2608,6 +2921,8 @@
}
}
+ FT_TRACE3(( "FT_Match_Size: no matching bitmap strike\n" ));
+
return FT_THROW( Invalid_Pixel_Size );
}
@@ -2706,18 +3021,6 @@
metrics->height = bsize->height << 6;
metrics->max_advance = bsize->x_ppem;
}
-
- FT_TRACE5(( "FT_Select_Metrics:\n" ));
- FT_TRACE5(( " x scale: %d (%f)\n",
- metrics->x_scale, metrics->x_scale / 65536.0 ));
- FT_TRACE5(( " y scale: %d (%f)\n",
- metrics->y_scale, metrics->y_scale / 65536.0 ));
- FT_TRACE5(( " ascender: %f\n", metrics->ascender / 64.0 ));
- FT_TRACE5(( " descender: %f\n", metrics->descender / 64.0 ));
- FT_TRACE5(( " height: %f\n", metrics->height / 64.0 ));
- FT_TRACE5(( " max advance: %f\n", metrics->max_advance / 64.0 ));
- FT_TRACE5(( " x ppem: %d\n", metrics->x_ppem ));
- FT_TRACE5(( " y ppem: %d\n", metrics->y_ppem ));
}
@@ -2826,18 +3129,6 @@
metrics->x_scale = 1L << 16;
metrics->y_scale = 1L << 16;
}
-
- FT_TRACE5(( "FT_Request_Metrics:\n" ));
- FT_TRACE5(( " x scale: %d (%f)\n",
- metrics->x_scale, metrics->x_scale / 65536.0 ));
- FT_TRACE5(( " y scale: %d (%f)\n",
- metrics->y_scale, metrics->y_scale / 65536.0 ));
- FT_TRACE5(( " ascender: %f\n", metrics->ascender / 64.0 ));
- FT_TRACE5(( " descender: %f\n", metrics->descender / 64.0 ));
- FT_TRACE5(( " height: %f\n", metrics->height / 64.0 ));
- FT_TRACE5(( " max advance: %f\n", metrics->max_advance / 64.0 ));
- FT_TRACE5(( " x ppem: %d\n", metrics->x_ppem ));
- FT_TRACE5(( " y ppem: %d\n", metrics->y_ppem ));
}
@@ -2847,6 +3138,7 @@
FT_Select_Size( FT_Face face,
FT_Int strike_index )
{
+ FT_Error error = FT_Err_Ok;
FT_Driver_Class clazz;
@@ -2860,36 +3152,37 @@
if ( clazz->select_size )
{
- FT_Error error;
+ error = clazz->select_size( face->size, (FT_ULong)strike_index );
+ FT_TRACE5(( "FT_Select_Size (%s driver):\n",
+ face->driver->root.clazz->module_name ));
+ }
+ else
+ {
+ FT_Select_Metrics( face, (FT_ULong)strike_index );
- error = clazz->select_size( face->size, (FT_ULong)strike_index );
+ FT_TRACE5(( "FT_Select_Size:\n" ));
+ }
#ifdef FT_DEBUG_LEVEL_TRACE
- {
- FT_Size_Metrics* metrics = &face->size->metrics;
-
-
- FT_TRACE5(( "FT_Select_Size (font driver's `select_size'):\n" ));
- FT_TRACE5(( " x scale: %d (%f)\n",
- metrics->x_scale, metrics->x_scale / 65536.0 ));
- FT_TRACE5(( " y scale: %d (%f)\n",
- metrics->y_scale, metrics->y_scale / 65536.0 ));
- FT_TRACE5(( " ascender: %f\n", metrics->ascender / 64.0 ));
- FT_TRACE5(( " descender: %f\n", metrics->descender / 64.0 ));
- FT_TRACE5(( " height: %f\n", metrics->height / 64.0 ));
- FT_TRACE5(( " max advance: %f\n", metrics->max_advance / 64.0 ));
- FT_TRACE5(( " x ppem: %d\n", metrics->x_ppem ));
- FT_TRACE5(( " y ppem: %d\n", metrics->y_ppem ));
- }
-#endif
+ {
+ FT_Size_Metrics* metrics = &face->size->metrics;
- return error;
- }
- FT_Select_Metrics( face, (FT_ULong)strike_index );
+ FT_TRACE5(( " x scale: %d (%f)\n",
+ metrics->x_scale, metrics->x_scale / 65536.0 ));
+ FT_TRACE5(( " y scale: %d (%f)\n",
+ metrics->y_scale, metrics->y_scale / 65536.0 ));
+ FT_TRACE5(( " ascender: %f\n", metrics->ascender / 64.0 ));
+ FT_TRACE5(( " descender: %f\n", metrics->descender / 64.0 ));
+ FT_TRACE5(( " height: %f\n", metrics->height / 64.0 ));
+ FT_TRACE5(( " max advance: %f\n", metrics->max_advance / 64.0 ));
+ FT_TRACE5(( " x ppem: %d\n", metrics->x_ppem ));
+ FT_TRACE5(( " y ppem: %d\n", metrics->y_ppem ));
+ }
+#endif
- return FT_Err_Ok;
+ return error;
}
@@ -2899,6 +3192,7 @@
FT_Request_Size( FT_Face face,
FT_Size_Request req )
{
+ FT_Error error = FT_Err_Ok;
FT_Driver_Class clazz;
FT_ULong strike_index;
@@ -2910,59 +3204,60 @@
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 )
{
- FT_Error error;
-
-
error = clazz->request_size( face->size, req );
-#ifdef FT_DEBUG_LEVEL_TRACE
- {
- FT_Size_Metrics* metrics = &face->size->metrics;
-
-
- FT_TRACE5(( "FT_Request_Size (font driver's `request_size'):\n" ));
- FT_TRACE5(( " x scale: %d (%f)\n",
- metrics->x_scale, metrics->x_scale / 65536.0 ));
- FT_TRACE5(( " y scale: %d (%f)\n",
- metrics->y_scale, metrics->y_scale / 65536.0 ));
- FT_TRACE5(( " ascender: %f\n", metrics->ascender / 64.0 ));
- FT_TRACE5(( " descender: %f\n", metrics->descender / 64.0 ));
- FT_TRACE5(( " height: %f\n", metrics->height / 64.0 ));
- FT_TRACE5(( " max advance: %f\n", metrics->max_advance / 64.0 ));
- FT_TRACE5(( " x ppem: %d\n", metrics->x_ppem ));
- FT_TRACE5(( " y ppem: %d\n", metrics->y_ppem ));
- }
-#endif
-
- return error;
+ FT_TRACE5(( "FT_Request_Size (%s driver):\n",
+ face->driver->root.clazz->module_name ));
}
-
- /*
- * The reason that a driver doesn't have `request_size' defined is
- * either that the scaling here suffices or that the supported formats
- * are bitmap-only and size matching is not implemented.
- *
- * In the latter case, a simple size matching is done.
- */
- if ( !FT_IS_SCALABLE( face ) && FT_HAS_FIXED_SIZES( face ) )
+ else if ( !FT_IS_SCALABLE( face ) && FT_HAS_FIXED_SIZES( face ) )
{
- FT_Error error;
-
-
+ /*
+ * The reason that a driver doesn't have `request_size' defined is
+ * either that the scaling here suffices or that the supported formats
+ * are bitmap-only and size matching is not implemented.
+ *
+ * In the latter case, a simple size matching is done.
+ */
error = FT_Match_Size( face, req, 0, &strike_index );
if ( error )
return error;
return FT_Select_Size( face, (FT_Int)strike_index );
}
+ else
+ {
+ FT_Request_Metrics( face, req );
- FT_Request_Metrics( face, req );
+ FT_TRACE5(( "FT_Request_Size:\n" ));
+ }
- return FT_Err_Ok;
+#ifdef FT_DEBUG_LEVEL_TRACE
+ {
+ FT_Size_Metrics* metrics = &face->size->metrics;
+
+
+ FT_TRACE5(( " x scale: %d (%f)\n",
+ metrics->x_scale, metrics->x_scale / 65536.0 ));
+ FT_TRACE5(( " y scale: %d (%f)\n",
+ metrics->y_scale, metrics->y_scale / 65536.0 ));
+ FT_TRACE5(( " ascender: %f\n", metrics->ascender / 64.0 ));
+ FT_TRACE5(( " descender: %f\n", metrics->descender / 64.0 ));
+ FT_TRACE5(( " height: %f\n", metrics->height / 64.0 ));
+ FT_TRACE5(( " max advance: %f\n", metrics->max_advance / 64.0 ));
+ FT_TRACE5(( " x ppem: %d\n", metrics->x_ppem ));
+ FT_TRACE5(( " y ppem: %d\n", metrics->y_ppem ));
+ }
+#endif
+
+ return error;
}
@@ -3327,7 +3622,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;
@@ -3456,6 +3751,85 @@
/* 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 );
+ face->internal->lcd_filter_func = ft_lcd_filter_fir;
+ }
+#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 )
FT_Face_GetCharVariantIndex( FT_Face face,
FT_ULong charcode,
@@ -3472,19 +3846,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 ));
}
@@ -3513,19 +3889,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 ));
}
@@ -3552,7 +3930,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 );
@@ -3580,7 +3958,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 );
@@ -3588,7 +3966,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 ));
}
@@ -3614,7 +3992,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 );
@@ -3742,7 +4120,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 );
}
@@ -3766,7 +4144,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 );
@@ -3791,7 +4169,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 );
@@ -3813,7 +4191,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;
@@ -3837,7 +4215,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;
@@ -4156,8 +4534,17 @@
#undef FT_COMPONENT
#define FT_COMPONENT trace_bitmap
- /* we convert to a single bitmap format for computing the checksum */
- if ( !error )
+ /*
+ * Computing the MD5 checksum is expensive, unnecessarily distorting a
+ * possible profiling of FreeType if compiled with tracing support. For
+ * this reason, we execute the following code only if explicitly
+ * requested.
+ */
+
+ /* we use FT_TRACE3 in this block */
+ if ( !error &&
+ ft_trace_levels[trace_bitmap] >= 3 &&
+ slot->bitmap.buffer )
{
FT_Bitmap bitmap;
FT_Error err;
@@ -4165,24 +4552,35 @@
FT_Bitmap_Init( &bitmap );
- /* this also converts the bitmap flow to `down' (i.e., pitch > 0) */
+ /* we convert to a single bitmap format for computing the checksum */
+ /* this also converts the bitmap flow to `down' (i.e., pitch > 0) */
err = FT_Bitmap_Convert( library, &slot->bitmap, &bitmap, 1 );
if ( !err )
{
MD5_CTX ctx;
unsigned char md5[16];
- int i;
- unsigned int rows = bitmap.rows;
- unsigned int pitch = (unsigned int)bitmap.pitch;
+ unsigned long coverage = 0;
+ int i, j;
+ int rows = (int)bitmap.rows;
+ int pitch = bitmap.pitch;
+ FT_TRACE3(( "FT_Render_Glyph: bitmap %dx%d, mode %d\n",
+ rows, pitch, slot->bitmap.pixel_mode ));
+
+ for ( i = 0; i < rows; i++ )
+ for ( j = 0; j < pitch; j++ )
+ coverage += bitmap.buffer[i * pitch + j];
+
+ FT_TRACE3(( " Total coverage: %lu\n", coverage ));
+
MD5_Init( &ctx );
- MD5_Update( &ctx, bitmap.buffer, rows * pitch );
+ if ( bitmap.buffer )
+ MD5_Update( &ctx, bitmap.buffer,
+ (unsigned long)rows * (unsigned long)pitch );
MD5_Final( md5, &ctx );
- FT_TRACE3(( "MD5 checksum for %dx%d bitmap:\n"
- " ",
- rows, pitch ));
+ FT_TRACE3(( " MD5 checksum: " ));
for ( i = 0; i < 16; i++ )
FT_TRACE3(( "%02X", md5[i] ));
FT_TRACE3(( "\n" ));
@@ -4191,6 +4589,52 @@
FT_Bitmap_Done( library, &bitmap );
}
+ /*
+ * Dump bitmap in Netpbm format (PBM or PGM).
+ */
+
+ /* we use FT_TRACE7 in this block */
+ if ( !error &&
+ ft_trace_levels[trace_bitmap] >= 7 &&
+ slot->bitmap.rows < 128U &&
+ slot->bitmap.width < 128U &&
+ slot->bitmap.buffer )
+ {
+ int rows = (int)slot->bitmap.rows;
+ int width = (int)slot->bitmap.width;
+ int pitch = slot->bitmap.pitch;
+ int i, j, m;
+ unsigned char* topleft = slot->bitmap.buffer;
+
+ if ( pitch < 0 )
+ topleft -= pitch * ( rows - 1 );
+
+ FT_TRACE7(( "Netpbm image: start\n" ));
+ switch ( slot->bitmap.pixel_mode )
+ {
+ case FT_PIXEL_MODE_MONO:
+ FT_TRACE7(( "P1 %d %d\n", width, rows ));
+ for ( i = 0; i < rows; i++ )
+ {
+ for ( j = 0; j < width; )
+ for ( m = 128; m > 0 && j < width; m >>= 1, j++ )
+ FT_TRACE7(( " %d", ( topleft[i * pitch + j / 8] & m ) != 0 ));
+ FT_TRACE7(( "\n" ));
+ }
+ break;
+
+ default:
+ FT_TRACE7(( "P2 %d %d 255\n", width, rows ));
+ for ( i = 0; i < rows; i++ )
+ {
+ for ( j = 0; j < width; j += 1 )
+ FT_TRACE7(( " %3u", topleft[i * pitch + j] ));
+ FT_TRACE7(( "\n" ));
+ }
+ }
+ FT_TRACE7(( "Netpbm image: end\n" ));
+ }
+
#undef FT_COMPONENT
#define FT_COMPONENT trace_objs
@@ -4282,7 +4726,7 @@
{
FT_Error error;
FT_Memory memory;
- FT_Module module;
+ FT_Module module = NULL;
FT_UInt nn;
@@ -4295,7 +4739,7 @@
if ( !clazz )
return FT_THROW( Invalid_Argument );
- /* check freetype version */
+ /* check FreeType version */
if ( clazz->module_requires > FREETYPE_VER_FIXED )
return FT_THROW( Invalid_Version );
@@ -4434,7 +4878,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;
@@ -4447,7 +4892,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;
@@ -4464,7 +4909,7 @@
if ( cur[0]->clazz->get_interface )
{
result = cur[0]->clazz->get_interface( cur[0], service_id );
- if ( result != NULL )
+ if ( result )
break;
}
}
@@ -4523,7 +4968,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;
@@ -4593,8 +5039,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 );
}
@@ -4610,7 +5061,8 @@
module_name,
property_name,
(void*)value,
- TRUE );
+ TRUE,
+ FALSE );
}
@@ -4626,10 +5078,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
+
+
/*************************************************************************/
/*************************************************************************/
/*************************************************************************/
@@ -4688,10 +5163,6 @@
goto Fail;
#endif
- /* we don't use raster_pool anymore. */
- library->raster_pool_size = 0;
- library->raster_pool = NULL;
-
library->version_major = FREETYPE_MAJOR;
library->version_minor = FREETYPE_MINOR;
library->version_patch = FREETYPE_PATCH;
@@ -4706,9 +5177,9 @@
#ifdef FT_CONFIG_OPTION_PIC
Fail:
ft_pic_container_destroy( library );
-#endif
FT_FREE( library );
return error;
+#endif
}
@@ -4885,7 +5356,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/src/3rdparty/freetype/src/base/ftotval.c b/src/3rdparty/freetype/src/base/ftotval.c
index 786457ba2a..a2944a7950 100644
--- a/src/3rdparty/freetype/src/base/ftotval.c
+++ b/src/3rdparty/freetype/src/base/ftotval.c
@@ -4,7 +4,7 @@
/* */
/* FreeType API for validating OpenType tables (body). */
/* */
-/* Copyright 2004-2015 by */
+/* Copyright 2004-2018 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
diff --git a/src/3rdparty/freetype/src/base/ftoutln.c b/src/3rdparty/freetype/src/base/ftoutln.c
index 35cc9f5569..cb91321deb 100644
--- a/src/3rdparty/freetype/src/base/ftoutln.c
+++ b/src/3rdparty/freetype/src/base/ftoutln.c
@@ -4,7 +4,7 @@
/* */
/* FreeType outline management (body). */
/* */
-/* Copyright 1996-2015 by */
+/* Copyright 1996-2018 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -42,7 +42,7 @@
static
- const FT_Outline null_outline = { 0, 0, 0, 0, 0, 0 };
+ const FT_Outline null_outline = { 0, 0, NULL, NULL, NULL, 0 };
/* documentation is in ftoutln.h */
@@ -286,12 +286,13 @@
FT_TRACE5(( "FT_Outline_Decompose: Done\n", n ));
return FT_Err_Ok;
+ Invalid_Outline:
+ error = FT_THROW( Invalid_Outline );
+ /* fall through */
+
Exit:
- FT_TRACE5(( "FT_Outline_Decompose: Error %d\n", error ));
+ FT_TRACE5(( "FT_Outline_Decompose: Error 0x%x\n", error ));
return error;
-
- Invalid_Outline:
- return FT_THROW( Invalid_Outline );
}
@@ -415,11 +416,14 @@
if ( source == target )
return FT_Err_Ok;
- FT_ARRAY_COPY( target->points, source->points, source->n_points );
-
- FT_ARRAY_COPY( target->tags, source->tags, source->n_points );
+ if ( source->n_points )
+ {
+ FT_ARRAY_COPY( target->points, source->points, source->n_points );
+ FT_ARRAY_COPY( target->tags, source->tags, source->n_points );
+ }
- FT_ARRAY_COPY( target->contours, source->contours, source->n_contours );
+ if ( source->n_contours )
+ FT_ARRAY_COPY( target->contours, source->contours, source->n_contours );
/* copy all flags, except the `FT_OUTLINE_OWNER' one */
is_owner = target->flags & FT_OUTLINE_OWNER;
@@ -537,8 +541,8 @@
for ( n = 0; n < outline->n_points; n++ )
{
- vec->x += xOffset;
- vec->y += yOffset;
+ vec->x = ADD_LONG( vec->x, xOffset );
+ vec->y = ADD_LONG( vec->y, yOffset );
vec++;
}
}
@@ -942,6 +946,9 @@
l_in = 0;
last = outline->contours[c];
+ /* pacify compiler */
+ in.x = in.y = anchor.x = anchor.y = 0;
+
/* Counter j cycles though the points; counter i advances only */
/* when points are moved; anchor k marks the first moved point. */
for ( i = last, j = first, k = -1;
@@ -1074,13 +1081,17 @@
FT_Int last = outline->contours[c];
- v_prev = points[last];
+ v_prev.x = points[last].x >> xshift;
+ v_prev.y = points[last].y >> yshift;
for ( n = first; n <= last; n++ )
{
- v_cur = points[n];
- area += ( ( v_cur.y - v_prev.y ) >> yshift ) *
- ( ( v_cur.x + v_prev.x ) >> xshift );
+ v_cur.x = points[n].x >> xshift;
+ v_cur.y = points[n].y >> yshift;
+
+ area = ADD_LONG( area,
+ ( v_cur.y - v_prev.y ) * ( v_cur.x + v_prev.x ) );
+
v_prev = v_cur;
}
diff --git a/src/3rdparty/freetype/src/base/ftpatent.c b/src/3rdparty/freetype/src/base/ftpatent.c
index bf2b0855c9..e23ee2e3f4 100644
--- a/src/3rdparty/freetype/src/base/ftpatent.c
+++ b/src/3rdparty/freetype/src/base/ftpatent.c
@@ -3,9 +3,9 @@
/* ftpatent.c */
/* */
/* FreeType API for checking patented TrueType bytecode instructions */
-/* (body). */
+/* (body). Obsolete, retained for backward compatibility. */
/* */
-/* Copyright 2007-2015 by */
+/* Copyright 2007-2018 by */
/* David Turner. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -25,238 +25,14 @@
#include FT_SERVICE_TRUETYPE_GLYF_H
- static FT_Bool
- _tt_check_patents_in_range( FT_Stream stream,
- FT_ULong size )
- {
- FT_Bool result = FALSE;
- FT_Error error;
- FT_Bytes p, end;
-
-
- if ( FT_FRAME_ENTER( size ) )
- return 0;
-
- p = stream->cursor;
- end = p + size;
-
- while ( p < end )
- {
- switch (p[0])
- {
- case 0x06: /* SPvTL // */
- case 0x07: /* SPvTL + */
- case 0x08: /* SFvTL // */
- case 0x09: /* SFvTL + */
- case 0x0A: /* SPvFS */
- case 0x0B: /* SFvFS */
- result = TRUE;
- goto Exit;
-
- case 0x40:
- if ( p + 1 >= end )
- goto Exit;
-
- p += p[1] + 2;
- break;
-
- case 0x41:
- if ( p + 1 >= end )
- goto Exit;
-
- p += p[1] * 2 + 2;
- break;
-
- case 0x71: /* DELTAP2 */
- case 0x72: /* DELTAP3 */
- case 0x73: /* DELTAC0 */
- case 0x74: /* DELTAC1 */
- case 0x75: /* DELTAC2 */
- result = TRUE;
- goto Exit;
-
- case 0xB0:
- case 0xB1:
- case 0xB2:
- case 0xB3:
- case 0xB4:
- case 0xB5:
- case 0xB6:
- case 0xB7:
- p += ( p[0] - 0xB0 ) + 2;
- break;
-
- case 0xB8:
- case 0xB9:
- case 0xBA:
- case 0xBB:
- case 0xBC:
- case 0xBD:
- case 0xBE:
- case 0xBF:
- p += ( p[0] - 0xB8 ) * 2 + 3;
- break;
-
- default:
- p += 1;
- break;
- }
- }
-
- Exit:
- FT_UNUSED( error );
- FT_FRAME_EXIT();
- return result;
- }
-
-
- static FT_Bool
- _tt_check_patents_in_table( FT_Face face,
- FT_ULong tag )
- {
- FT_Stream stream = face->stream;
- FT_Error error = FT_Err_Ok;
- FT_Service_SFNT_Table service;
- FT_Bool result = FALSE;
-
-
- FT_FACE_FIND_SERVICE( face, service, SFNT_TABLE );
-
- if ( service )
- {
- FT_UInt i = 0;
- FT_ULong tag_i = 0, offset_i = 0, length_i = 0;
-
-
- for ( i = 0; !error && tag_i != tag ; i++ )
- error = service->table_info( face, i,
- &tag_i, &offset_i, &length_i );
-
- if ( error ||
- FT_STREAM_SEEK( offset_i ) )
- goto Exit;
-
- result = _tt_check_patents_in_range( stream, length_i );
- }
-
- Exit:
- return result;
- }
-
-
- static FT_Bool
- _tt_face_check_patents( FT_Face face )
- {
- FT_Stream stream = face->stream;
- FT_UInt gindex;
- FT_Error error;
- FT_Bool result;
-
- FT_Service_TTGlyf service;
-
-
- result = _tt_check_patents_in_table( face, TTAG_fpgm );
- if ( result )
- goto Exit;
-
- result = _tt_check_patents_in_table( face, TTAG_prep );
- if ( result )
- goto Exit;
-
- FT_FACE_FIND_SERVICE( face, service, TT_GLYF );
- if ( service == NULL )
- goto Exit;
-
- for ( gindex = 0; gindex < (FT_UInt)face->num_glyphs; gindex++ )
- {
- FT_ULong offset, num_ins, size;
- FT_Int num_contours;
-
-
- offset = service->get_location( face, gindex, &size );
- if ( size == 0 )
- continue;
-
- if ( FT_STREAM_SEEK( offset ) ||
- FT_READ_SHORT( num_contours ) )
- continue;
-
- if ( num_contours >= 0 ) /* simple glyph */
- {
- if ( FT_STREAM_SKIP( 8 + num_contours * 2 ) )
- continue;
- }
- else /* compound glyph */
- {
- FT_Bool has_instr = 0;
-
-
- if ( FT_STREAM_SKIP( 8 ) )
- continue;
-
- /* now read each component */
- for (;;)
- {
- FT_UInt flags, toskip;
-
-
- if( FT_READ_USHORT( flags ) )
- break;
-
- toskip = 2 + 1 + 1;
-
- if ( ( flags & ( 1 << 0 ) ) != 0 ) /* ARGS_ARE_WORDS */
- toskip += 2;
-
- if ( ( flags & ( 1 << 3 ) ) != 0 ) /* WE_HAVE_A_SCALE */
- toskip += 2;
- else if ( ( flags & ( 1 << 6 ) ) != 0 ) /* WE_HAVE_X_Y_SCALE */
- toskip += 4;
- else if ( ( flags & ( 1 << 7 ) ) != 0 ) /* WE_HAVE_A_2x2 */
- toskip += 8;
-
- if ( ( flags & ( 1 << 8 ) ) != 0 ) /* WE_HAVE_INSTRUCTIONS */
- has_instr = 1;
-
- if ( FT_STREAM_SKIP( toskip ) )
- goto NextGlyph;
-
- if ( ( flags & ( 1 << 5 ) ) == 0 ) /* MORE_COMPONENTS */
- break;
- }
-
- if ( !has_instr )
- goto NextGlyph;
- }
-
- if ( FT_READ_USHORT( num_ins ) )
- continue;
-
- result = _tt_check_patents_in_range( stream, num_ins );
- if ( result )
- goto Exit;
-
- NextGlyph:
- ;
- }
-
- Exit:
- return result;
- }
-
-
/* documentation is in freetype.h */
FT_EXPORT_DEF( FT_Bool )
FT_Face_CheckTrueTypePatents( FT_Face face )
{
- FT_Bool result = FALSE;
-
-
- if ( face && FT_IS_SFNT( face ) )
- result = _tt_face_check_patents( face );
+ FT_UNUSED( face );
- return result;
+ return FALSE;
}
@@ -266,22 +42,10 @@
FT_Face_SetUnpatentedHinting( FT_Face face,
FT_Bool value )
{
- FT_Bool result = FALSE;
-
-
-#if defined( TT_CONFIG_OPTION_UNPATENTED_HINTING ) && \
- !defined( TT_CONFIG_OPTION_BYTECODE_INTERPRETER )
- if ( face && FT_IS_SFNT( face ) )
- {
- result = !face->internal->ignore_unpatented_hinter;
- face->internal->ignore_unpatented_hinter = !value;
- }
-#else
FT_UNUSED( face );
FT_UNUSED( value );
-#endif
- return result;
+ return FALSE;
}
/* END */
diff --git a/src/3rdparty/freetype/src/base/ftpfr.c b/src/3rdparty/freetype/src/base/ftpfr.c
index 39f089e3e9..bfe13520eb 100644
--- a/src/3rdparty/freetype/src/base/ftpfr.c
+++ b/src/3rdparty/freetype/src/base/ftpfr.c
@@ -4,7 +4,7 @@
/* */
/* FreeType API for accessing PFR-specific data (body). */
/* */
-/* Copyright 2002-2015 by */
+/* Copyright 2002-2018 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
diff --git a/src/3rdparty/freetype/src/base/ftpic.c b/src/3rdparty/freetype/src/base/ftpic.c
index 6c4b1cd4e6..1492e1809a 100644
--- a/src/3rdparty/freetype/src/base/ftpic.c
+++ b/src/3rdparty/freetype/src/base/ftpic.c
@@ -4,7 +4,7 @@
/* */
/* The FreeType position independent code services (body). */
/* */
-/* Copyright 2009-2015 by */
+/* Copyright 2009-2018 by */
/* Oran Agra and Mickey Gabel. */
/* */
/* This file is part of the FreeType project, and may only be used, */
diff --git a/src/3rdparty/freetype/src/base/ftpsprop.c b/src/3rdparty/freetype/src/base/ftpsprop.c
new file mode 100644
index 0000000000..459b5e6054
--- /dev/null
+++ b/src/3rdparty/freetype/src/base/ftpsprop.c
@@ -0,0 +1,285 @@
+/***************************************************************************/
+/* */
+/* ftpsprop.c */
+/* */
+/* Get and set properties of PostScript drivers (body). */
+/* See `ftdriver.h' for available properties. */
+/* */
+/* Copyright 2017-2018 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_DRIVER_H
+#include FT_INTERNAL_DEBUG_H
+#include FT_INTERNAL_POSTSCRIPT_AUX_H
+#include FT_INTERNAL_OBJECTS_H
+#include FT_INTERNAL_POSTSCRIPT_PROPS_H
+
+
+ /*************************************************************************/
+ /* */
+ /* The macro FT_COMPONENT is used in trace mode. It is an implicit */
+ /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */
+ /* messages during execution. */
+ /* */
+#undef FT_COMPONENT
+#define FT_COMPONENT trace_psprops
+
+
+ FT_BASE_CALLBACK_DEF( FT_Error )
+ ps_property_set( FT_Module module, /* PS_Driver */
+ const char* property_name,
+ const void* value,
+ FT_Bool value_is_string )
+ {
+ FT_Error error = FT_Err_Ok;
+ PS_Driver driver = (PS_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 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 );
+
+ 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 ||
+ y1 > 500 || y2 > 500 || y3 > 500 || y4 > 500 )
+ return FT_THROW( Invalid_Argument );
+
+ driver->darken_params[0] = x1;
+ driver->darken_params[1] = y1;
+ driver->darken_params[2] = x2;
+ driver->darken_params[3] = y2;
+ driver->darken_params[4] = x3;
+ driver->darken_params[5] = y3;
+ driver->darken_params[6] = x4;
+ driver->darken_params[7] = y4;
+
+ return error;
+ }
+
+ else if ( !ft_strcmp( property_name, "hinting-engine" ) )
+ {
+#if defined( CFF_CONFIG_OPTION_OLD_ENGINE ) || \
+ defined( T1_CONFIG_OPTION_OLD_ENGINE )
+ const char* module_name = module->clazz->module_name;
+#endif
+
+
+#ifdef FT_CONFIG_OPTION_ENVIRONMENT_PROPERTIES
+ if ( value_is_string )
+ {
+ const char* s = (const char*)value;
+
+
+ if ( !ft_strcmp( s, "adobe" ) )
+ driver->hinting_engine = FT_HINTING_ADOBE;
+
+#ifdef CFF_CONFIG_OPTION_OLD_ENGINE
+ else if ( !ft_strcmp( module_name, "cff" ) &&
+ !ft_strcmp( s, "freetype" ) )
+ driver->hinting_engine = FT_HINTING_FREETYPE;
+#endif
+
+#ifdef T1_CONFIG_OPTION_OLD_ENGINE
+ else if ( ( !ft_strcmp( module_name, "type1" ) ||
+ !ft_strcmp( module_name, "t1cid" ) ) &&
+ !ft_strcmp( s, "freetype" ) )
+ driver->hinting_engine = FT_HINTING_FREETYPE;
+#endif
+
+ else
+ return FT_THROW( Invalid_Argument );
+ }
+ else
+#endif /* FT_CONFIG_OPTION_ENVIRONMENT_PROPERTIES */
+ {
+ FT_UInt* hinting_engine = (FT_UInt*)value;
+
+
+ if ( *hinting_engine == FT_HINTING_ADOBE
+#ifdef CFF_CONFIG_OPTION_OLD_ENGINE
+ || ( *hinting_engine == FT_HINTING_FREETYPE &&
+ !ft_strcmp( module_name, "cff" ) )
+#endif
+#ifdef T1_CONFIG_OPTION_OLD_ENGINE
+ || ( *hinting_engine == FT_HINTING_FREETYPE &&
+ ( !ft_strcmp( module_name, "type1" ) ||
+ !ft_strcmp( module_name, "t1cid" ) ) )
+#endif
+ )
+ driver->hinting_engine = *hinting_engine;
+ else
+ error = FT_ERR( Unimplemented_Feature );
+
+ return error;
+ }
+ }
+
+ else if ( !ft_strcmp( property_name, "no-stem-darkening" ) )
+ {
+#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;
+
+
+#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;
+ }
+
+ FT_TRACE0(( "ps_property_set: missing property `%s'\n",
+ property_name ));
+ return FT_THROW( Missing_Property );
+ }
+
+
+ FT_BASE_CALLBACK_DEF( FT_Error )
+ ps_property_get( FT_Module module, /* PS_Driver */
+ const char* property_name,
+ void* value )
+ {
+ FT_Error error = FT_Err_Ok;
+ PS_Driver driver = (PS_Driver)module;
+
+
+ if ( !ft_strcmp( property_name, "darkening-parameters" ) )
+ {
+ FT_Int* darken_params = driver->darken_params;
+ FT_Int* val = (FT_Int*)value;
+
+
+ val[0] = darken_params[0];
+ val[1] = darken_params[1];
+ val[2] = darken_params[2];
+ val[3] = darken_params[3];
+ val[4] = darken_params[4];
+ val[5] = darken_params[5];
+ val[6] = darken_params[6];
+ val[7] = darken_params[7];
+
+ return error;
+ }
+
+ else if ( !ft_strcmp( property_name, "hinting-engine" ) )
+ {
+ FT_UInt hinting_engine = driver->hinting_engine;
+ FT_UInt* val = (FT_UInt*)value;
+
+
+ *val = hinting_engine;
+
+ return error;
+ }
+
+ else if ( !ft_strcmp( property_name, "no-stem-darkening" ) )
+ {
+ FT_Bool no_stem_darkening = driver->no_stem_darkening;
+ FT_Bool* val = (FT_Bool*)value;
+
+
+ *val = no_stem_darkening;
+
+ return error;
+ }
+
+ FT_TRACE0(( "ps_property_get: missing property `%s'\n",
+ property_name ));
+ return FT_THROW( Missing_Property );
+ }
+
+
+/* END */
diff --git a/src/3rdparty/freetype/src/base/ftrfork.c b/src/3rdparty/freetype/src/base/ftrfork.c
index c30c76678e..c3a2b9151a 100644
--- a/src/3rdparty/freetype/src/base/ftrfork.c
+++ b/src/3rdparty/freetype/src/base/ftrfork.c
@@ -4,7 +4,7 @@
/* */
/* Embedded resource forks accessor (body). */
/* */
-/* Copyright 2004-2015 by */
+/* Copyright 2004-2018 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,50 @@
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;
+
+ /*
+ * According to Inside Macintosh: More Macintosh Toolbox,
+ * "Resource IDs" (1-46), there are some reserved IDs.
+ * However, FreeType2 is not a font synthesizer, no need
+ * to check the acceptable resource ID.
+ */
+ if ( 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 ));
+ j, (FT_UShort)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 +313,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;
@@ -403,7 +466,7 @@
errors[i] = FT_Err_Ok;
if ( errors[i] )
- continue ;
+ continue;
errors[i] = (FT_RACCESS_GUESS_TABLE_GET[i].func)( library,
stream, base_name,
@@ -415,7 +478,7 @@
}
-#ifndef FT_MACINTOSH
+#if defined( FT_CONFIG_OPTION_MAC_FONTS ) && !defined( FT_MACINTOSH )
static FT_RFork_Rule
raccess_get_rule_type_from_rule_index( FT_Library library,
FT_UInt rule_index )
diff --git a/src/3rdparty/freetype/src/base/ftsnames.c b/src/3rdparty/freetype/src/base/ftsnames.c
index 80304e5c85..90ea1e2be7 100644
--- a/src/3rdparty/freetype/src/base/ftsnames.c
+++ b/src/3rdparty/freetype/src/base/ftsnames.c
@@ -7,7 +7,7 @@
/* */
/* This is _not_ used to retrieve glyph names! */
/* */
-/* Copyright 1996-2015 by */
+/* Copyright 1996-2018 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/src/3rdparty/freetype/src/base/ftstream.c b/src/3rdparty/freetype/src/base/ftstream.c
index b68f3f82d2..18df7dcfef 100644
--- a/src/3rdparty/freetype/src/base/ftstream.c
+++ b/src/3rdparty/freetype/src/base/ftstream.c
@@ -4,7 +4,7 @@
/* */
/* I/O stream support (body). */
/* */
-/* Copyright 2000-2015 by */
+/* Copyright 2000-2018 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -778,7 +778,7 @@
case ft_frame_short_be:
case ft_frame_ushort_be: /* read a 2-byte big-endian short */
- value = FT_NEXT_USHORT( cursor) ;
+ value = FT_NEXT_USHORT( cursor );
sign_shift = 16;
break;
diff --git a/src/3rdparty/freetype/src/base/ftstroke.c b/src/3rdparty/freetype/src/base/ftstroke.c
index fecb3cc25c..6ae1819067 100644
--- a/src/3rdparty/freetype/src/base/ftstroke.c
+++ b/src/3rdparty/freetype/src/base/ftstroke.c
@@ -4,7 +4,7 @@
/* */
/* FreeType path stroker (body). */
/* */
-/* Copyright 2002-2015 by */
+/* Copyright 2002-2018 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -712,9 +712,10 @@
FT_Outline* outline )
{
/* copy point locations */
- FT_ARRAY_COPY( outline->points + outline->n_points,
- border->points,
- border->num_points );
+ if ( border->num_points )
+ FT_ARRAY_COPY( outline->points + outline->n_points,
+ border->points,
+ border->num_points );
/* copy tags */
{
diff --git a/src/3rdparty/freetype/src/base/ftsynth.c b/src/3rdparty/freetype/src/base/ftsynth.c
index cd68533957..c28346707b 100644
--- a/src/3rdparty/freetype/src/base/ftsynth.c
+++ b/src/3rdparty/freetype/src/base/ftsynth.c
@@ -4,7 +4,7 @@
/* */
/* FreeType synthesizing code for emboldening and slanting (body). */
/* */
-/* Copyright 2000-2015 by */
+/* Copyright 2000-2018 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -123,14 +123,14 @@
/*
* XXX: overflow check for 16-bit system, for compatibility
- * with FT_GlyphSlot_Embolden() since freetype-2.1.10.
+ * with FT_GlyphSlot_Embolden() since FreeType 2.1.10.
* unfortunately, this function return no informations
* about the cause of error.
*/
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/src/3rdparty/freetype/src/base/ftsystem.c b/src/3rdparty/freetype/src/base/ftsystem.c
index 1938fd8917..6adebdb938 100644
--- a/src/3rdparty/freetype/src/base/ftsystem.c
+++ b/src/3rdparty/freetype/src/base/ftsystem.c
@@ -4,7 +4,7 @@
/* */
/* ANSI-specific FreeType low-level system interface (body). */
/* */
-/* Copyright 1996-2015 by */
+/* Copyright 1996-2018 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
diff --git a/src/3rdparty/freetype/src/base/fttrigon.c b/src/3rdparty/freetype/src/base/fttrigon.c
index 5b24304c2f..d6dd098c42 100644
--- a/src/3rdparty/freetype/src/base/fttrigon.c
+++ b/src/3rdparty/freetype/src/base/fttrigon.c
@@ -4,7 +4,7 @@
/* */
/* FreeType trigonometric functions (body). */
/* */
-/* Copyright 2001-2015 by */
+/* Copyright 2001-2018 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -71,7 +71,8 @@
/* 0x40000000 comes from regression analysis between true */
/* and CORDIC hypotenuse, so it minimizes the error */
- val = (FT_Fixed)( ( (FT_Int64)val * FT_TRIG_SCALE + 0x40000000UL ) >> 32 );
+ val = (FT_Fixed)(
+ ( (FT_UInt64)val * FT_TRIG_SCALE + 0x40000000UL ) >> 32 );
return s < 0 ? -val : val;
}
diff --git a/src/3rdparty/freetype/src/base/fttype1.c b/src/3rdparty/freetype/src/base/fttype1.c
index c549382afd..aa8f8ccbbb 100644
--- a/src/3rdparty/freetype/src/base/fttype1.c
+++ b/src/3rdparty/freetype/src/base/fttype1.c
@@ -4,7 +4,7 @@
/* */
/* FreeType utility file for PS names support (body). */
/* */
-/* Copyright 2002-2015 by */
+/* Copyright 2002-2018 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
diff --git a/src/3rdparty/freetype/src/base/ftutil.c b/src/3rdparty/freetype/src/base/ftutil.c
index f5b72db708..4de5f2c145 100644
--- a/src/3rdparty/freetype/src/base/ftutil.c
+++ b/src/3rdparty/freetype/src/base/ftutil.c
@@ -4,7 +4,7 @@
/* */
/* FreeType utility file for memory and list management (body). */
/* */
-/* Copyright 2002-2015 by */
+/* Copyright 2002-2018 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 )
@@ -135,25 +135,27 @@
ft_mem_free( memory, block );
block = NULL;
}
- else if ( new_count > FT_INT_MAX/item_size )
+ else if ( new_count > FT_INT_MAX / item_size )
{
error = FT_THROW( Array_Too_Large );
}
else if ( cur_count == 0 )
{
- FT_ASSERT( block == NULL );
+ FT_ASSERT( !block );
- block = ft_mem_alloc( memory, new_count*item_size, &error );
+ block = memory->alloc( memory, new_count * item_size );
+ if ( block == NULL )
+ error = FT_THROW( Out_Of_Memory );
}
else
{
FT_Pointer block2;
- FT_Long cur_size = cur_count*item_size;
- FT_Long new_size = new_count*item_size;
+ FT_Long cur_size = cur_count * item_size;
+ FT_Long new_size = new_count * item_size;
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/src/3rdparty/freetype/src/base/ftver.rc b/src/3rdparty/freetype/src/base/ftver.rc
new file mode 100644
index 0000000000..a2903d5883
--- /dev/null
+++ b/src/3rdparty/freetype/src/base/ftver.rc
@@ -0,0 +1,61 @@
+/***************************************************************************/
+/* */
+/* ftver.rc */
+/* */
+/* FreeType VERSIONINFO resource for Windows DLLs. */
+/* */
+/* Copyright 2018 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<windows.h>
+
+#define FT_VERSION 2,9,1,0
+#define FT_VERSION_STR "2.9.1"
+
+VS_VERSION_INFO VERSIONINFO
+FILEVERSION FT_VERSION
+PRODUCTVERSION FT_VERSION
+FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
+#ifdef _DEBUG
+FILEFLAGS VS_FF_DEBUG
+#endif
+#ifdef _DLL
+FILETYPE VFT_DLL
+#define FT_FILENAME "freetype.dll"
+#else
+FILETYPE VFT_STATIC_LIB
+#define FT_FILENAME "freetype.lib"
+#endif
+BEGIN
+ BLOCK "StringFileInfo"
+ BEGIN
+ BLOCK "040904E4"
+ BEGIN
+ VALUE "CompanyName", "The FreeType Project"
+ VALUE "FileDescription", "Font Rendering Library"
+ VALUE "FileVersion", FT_VERSION_STR
+ VALUE "ProductName", "FreeType"
+ VALUE "ProductVersion", FT_VERSION_STR
+ VALUE "LegalCopyright", "\251 2018 The FreeType Project www.freetype.org. All rights reserved."
+ VALUE "InternalName", "freetype"
+ VALUE "OriginalFilename", FT_FILENAME
+ END
+ END
+
+ BLOCK "VarFileInfo"
+ BEGIN
+ /* The following line should only be modified for localized versions. */
+ /* It consists of any number of WORD,WORD pairs, with each pair */
+ /* describing a "language,codepage" combination supported by the file. */
+ VALUE "Translation", 0x409, 1252
+ END
+END
diff --git a/src/3rdparty/freetype/src/base/ftwinfnt.c b/src/3rdparty/freetype/src/base/ftwinfnt.c
index 76a19af983..11bd28afb7 100644
--- a/src/3rdparty/freetype/src/base/ftwinfnt.c
+++ b/src/3rdparty/freetype/src/base/ftwinfnt.c
@@ -4,7 +4,7 @@
/* */
/* FreeType API for accessing Windows FNT specific info (body). */
/* */
-/* Copyright 2003-2015 by */
+/* Copyright 2003-2018 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
diff --git a/src/3rdparty/freetype/src/base/md5.c b/src/3rdparty/freetype/src/base/md5.c
index 52d96accd3..b235e17a56 100644
--- a/src/3rdparty/freetype/src/base/md5.c
+++ b/src/3rdparty/freetype/src/base/md5.c
@@ -63,12 +63,19 @@
(a) += (b);
/*
- * SET reads 4 input bytes in little-endian byte order and stores them
- * in a properly aligned word in host byte order.
+ * SET reads 4 input bytes in little-endian byte order and stores them in a
+ * properly aligned word in host byte order.
*
- * The check for little-endian architectures that tolerate unaligned
- * memory accesses is just an optimization. Nothing will break if it
- * doesn't work.
+ * The check for little-endian architectures that tolerate unaligned memory
+ * accesses is just an optimization. Nothing will break if it fails to detect
+ * a suitable architecture.
+ *
+ * Unfortunately, this optimization may be a C strict aliasing rules violation
+ * if the caller's data buffer has effective type that cannot be aliased by
+ * MD5_u32plus. In practice, this problem may occur if these MD5 routines are
+ * inlined into a calling function, or with future and dangerously advanced
+ * link-time optimizations. For the time being, keeping these MD5 routines in
+ * their own translation unit avoids the problem.
*/
#if defined(__i386__) || defined(__x86_64__) || defined(__vax__)
#define SET(n) \
@@ -87,8 +94,8 @@
#endif
/*
- * This processes one or more 64-byte data blocks, but does NOT update
- * the bit counters. There are no alignment requirements.
+ * This processes one or more 64-byte data blocks, but does NOT update the bit
+ * counters. There are no alignment requirements.
*/
static const void *body(MD5_CTX *ctx, const void *data, unsigned long size)
{
@@ -242,6 +249,12 @@ void MD5_Update(MD5_CTX *ctx, const void *data, unsigned long size)
memcpy(ctx->buffer, data, size);
}
+#define OUT(dst, src) \
+ (dst)[0] = (unsigned char)(src); \
+ (dst)[1] = (unsigned char)((src) >> 8); \
+ (dst)[2] = (unsigned char)((src) >> 16); \
+ (dst)[3] = (unsigned char)((src) >> 24);
+
void MD5_Final(unsigned char *result, MD5_CTX *ctx)
{
unsigned long used, available;
@@ -262,33 +275,15 @@ void MD5_Final(unsigned char *result, MD5_CTX *ctx)
memset(&ctx->buffer[used], 0, available - 8);
ctx->lo <<= 3;
- ctx->buffer[56] = ctx->lo;
- ctx->buffer[57] = ctx->lo >> 8;
- ctx->buffer[58] = ctx->lo >> 16;
- ctx->buffer[59] = ctx->lo >> 24;
- ctx->buffer[60] = ctx->hi;
- ctx->buffer[61] = ctx->hi >> 8;
- ctx->buffer[62] = ctx->hi >> 16;
- ctx->buffer[63] = ctx->hi >> 24;
+ OUT(&ctx->buffer[56], ctx->lo)
+ OUT(&ctx->buffer[60], ctx->hi)
body(ctx, ctx->buffer, 64);
- result[0] = ctx->a;
- result[1] = ctx->a >> 8;
- result[2] = ctx->a >> 16;
- result[3] = ctx->a >> 24;
- result[4] = ctx->b;
- result[5] = ctx->b >> 8;
- result[6] = ctx->b >> 16;
- result[7] = ctx->b >> 24;
- result[8] = ctx->c;
- result[9] = ctx->c >> 8;
- result[10] = ctx->c >> 16;
- result[11] = ctx->c >> 24;
- result[12] = ctx->d;
- result[13] = ctx->d >> 8;
- result[14] = ctx->d >> 16;
- result[15] = ctx->d >> 24;
+ OUT(&result[0], ctx->a)
+ OUT(&result[4], ctx->b)
+ OUT(&result[8], ctx->c)
+ OUT(&result[12], ctx->d)
memset(ctx, 0, sizeof(*ctx));
}
diff --git a/src/3rdparty/freetype/src/base/rules.mk b/src/3rdparty/freetype/src/base/rules.mk
index 1852e08613..e9805bd068 100644
--- a/src/3rdparty/freetype/src/base/rules.mk
+++ b/src/3rdparty/freetype/src/base/rules.mk
@@ -3,7 +3,7 @@
#
-# Copyright 1996-2015 by
+# Copyright 1996-2018 by
# David Turner, Robert Wilhelm, and Werner Lemberg.
#
# This file is part of the FreeType project, and may only be used, modified,
@@ -40,10 +40,14 @@ BASE_SRC := $(BASE_DIR)/basepic.c \
$(BASE_DIR)/ftadvanc.c \
$(BASE_DIR)/ftcalc.c \
$(BASE_DIR)/ftdbgmem.c \
+ $(BASE_DIR)/ftfntfmt.c \
$(BASE_DIR)/ftgloadr.c \
+ $(BASE_DIR)/fthash.c \
+ $(BASE_DIR)/ftlcdfil.c \
$(BASE_DIR)/ftobjs.c \
$(BASE_DIR)/ftoutln.c \
$(BASE_DIR)/ftpic.c \
+ $(BASE_DIR)/ftpsprop.c \
$(BASE_DIR)/ftrfork.c \
$(BASE_DIR)/ftsnames.c \
$(BASE_DIR)/ftstream.c \
diff --git a/src/3rdparty/freetype/src/bdf/Jamfile b/src/3rdparty/freetype/src/bdf/Jamfile
index 86b85fa3e4..d9e441c188 100644
--- a/src/3rdparty/freetype/src/bdf/Jamfile
+++ b/src/3rdparty/freetype/src/bdf/Jamfile
@@ -1,6 +1,6 @@
# FreeType 2 src/bdf Jamfile
#
-# Copyright 2002-2015 by
+# Copyright 2002-2018 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/src/3rdparty/freetype/src/bdf/README b/src/3rdparty/freetype/src/bdf/README
index b761aba2b2..996ac2d2aa 100644
--- a/src/3rdparty/freetype/src/bdf/README
+++ b/src/3rdparty/freetype/src/bdf/README
@@ -13,7 +13,7 @@ This code implements a BDF driver for the FreeType library, following the
Adobe Specification V 2.2. The specification of the BDF font format is
available from Adobe's web site:
- http://partners.adobe.com/public/developer/en/font/5005.BDF_Spec.pdf
+ https://www.adobe.com/content/dam/acom/en/devnet/font/pdfs/5005.BDF_Spec.pdf
Many good bitmap fonts in bdf format come with XFree86 (www.XFree86.org).
They do not define vertical metrics, because the X Consortium BDF
diff --git a/src/3rdparty/freetype/src/bdf/bdf.c b/src/3rdparty/freetype/src/bdf/bdf.c
index f95fb76225..e54df6649b 100644
--- a/src/3rdparty/freetype/src/bdf/bdf.c
+++ b/src/3rdparty/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/src/3rdparty/freetype/src/bdf/bdf.h b/src/3rdparty/freetype/src/bdf/bdf.h
index f24d925d8f..9012727c7e 100644
--- a/src/3rdparty/freetype/src/bdf/bdf.h
+++ b/src/3rdparty/freetype/src/bdf/bdf.h
@@ -22,8 +22,8 @@
*/
-#ifndef __BDF_H__
-#define __BDF_H__
+#ifndef BDF_H_
+#define BDF_H_
/*
@@ -33,6 +33,7 @@
#include <ft2build.h>
#include FT_INTERNAL_OBJECTS_H
#include FT_INTERNAL_STREAM_H
+#include FT_INTERNAL_HASH_H
FT_BEGIN_HEADER
@@ -157,24 +158,6 @@ FT_BEGIN_HEADER
} bdf_glyph_t;
- typedef struct _hashnode_
- {
- const char* key;
- size_t data;
-
- } _hashnode, *hashnode;
-
-
- typedef struct hashtable_
- {
- unsigned int limit;
- unsigned int size;
- unsigned int used;
- hashnode* table;
-
- } hashtable;
-
-
typedef struct bdf_glyphlist_t_
{
unsigned short pad; /* Pad to 4-byte boundary. */
@@ -238,7 +221,7 @@ FT_BEGIN_HEADER
bdf_property_t* user_props;
unsigned long nuser_props;
- hashtable proptbl;
+ FT_HashRec proptbl;
} bdf_font_t;
@@ -291,7 +274,7 @@ FT_BEGIN_HEADER
FT_END_HEADER
-#endif /* __BDF_H__ */
+#endif /* BDF_H_ */
/* END */
diff --git a/src/3rdparty/freetype/src/bdf/bdfdrivr.c b/src/3rdparty/freetype/src/bdf/bdfdrivr.c
index 404af517e5..ca937f89ce 100644
--- a/src/3rdparty/freetype/src/bdf/bdfdrivr.c
+++ b/src/3rdparty/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 */
@@ -373,7 +373,7 @@ THE SOFTWARE.
/* we have a bdf font: let's construct the face object */
face->bdffont = font;
- /* BDF could not have multiple face in single font file.
+ /* BDF cannot have multiple faces in a single font file.
* XXX: non-zero face_index is already invalid argument, but
* Type1, Type42 driver has a convention to return
* an invalid argument error when the font could be
@@ -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 */
@@ -437,46 +437,156 @@ THE SOFTWARE.
{
FT_Bitmap_Size* bsize = bdfface->available_sizes;
FT_Short resolution_x = 0, resolution_y = 0;
+ long value;
- FT_MEM_ZERO( bsize, sizeof ( FT_Bitmap_Size ) );
+ FT_ZERO( bsize );
+
+ /* sanity checks */
+ if ( font->font_ascent > 0x7FFF || font->font_ascent < -0x7FFF )
+ {
+ font->font_ascent = font->font_ascent < 0 ? -0x7FFF : 0x7FFF;
+ FT_TRACE0(( "BDF_Face_Init: clamping font ascent to value %d\n",
+ font->font_ascent ));
+ }
+ if ( font->font_descent > 0x7FFF || font->font_descent < -0x7FFF )
+ {
+ font->font_descent = font->font_descent < 0 ? -0x7FFF : 0x7FFF;
+ FT_TRACE0(( "BDF_Face_Init: clamping font descent to value %d\n",
+ font->font_descent ));
+ }
bsize->height = (FT_Short)( font->font_ascent + font->font_descent );
prop = bdf_get_font_property( font, "AVERAGE_WIDTH" );
if ( prop )
- bsize->width = (FT_Short)( ( prop->value.l + 5 ) / 10 );
+ {
+#ifdef FT_DEBUG_LEVEL_TRACE
+ if ( prop->value.l < 0 )
+ FT_TRACE0(( "BDF_Face_Init: negative average width\n" ));
+#endif
+ if ( prop->value.l > 0x7FFFL * 10 - 5 ||
+ prop->value.l < -( 0x7FFFL * 10 - 5 ) )
+ {
+ bsize->width = 0x7FFF;
+ FT_TRACE0(( "BDF_Face_Init: clamping average width to value %d\n",
+ bsize->width ));
+ }
+ else
+ bsize->width = FT_ABS( (FT_Short)( ( prop->value.l + 5 ) / 10 ) );
+ }
else
- bsize->width = (FT_Short)( bsize->height * 2/3 );
+ {
+ /* this is a heuristical value */
+ bsize->width = (FT_Short)FT_MulDiv( bsize->height, 2, 3 );
+ }
prop = bdf_get_font_property( font, "POINT_SIZE" );
if ( prop )
+ {
+#ifdef FT_DEBUG_LEVEL_TRACE
+ if ( prop->value.l < 0 )
+ FT_TRACE0(( "BDF_Face_Init: negative point size\n" ));
+#endif
/* convert from 722.7 decipoints to 72 points per inch */
- bsize->size =
- (FT_Pos)( ( prop->value.l * 64 * 7200 + 36135L ) / 72270L );
+ if ( prop->value.l > 0x504C2L || /* 0x7FFF * 72270/7200 */
+ prop->value.l < -0x504C2L )
+ {
+ bsize->size = 0x7FFF;
+ FT_TRACE0(( "BDF_Face_Init: clamping point size to value %d\n",
+ bsize->size ));
+ }
+ else
+ bsize->size = FT_MulDiv( FT_ABS( prop->value.l ),
+ 64 * 7200,
+ 72270L );
+ }
+ else if ( font->point_size )
+ {
+ if ( font->point_size > 0x7FFF )
+ {
+ bsize->size = 0x7FFF;
+ FT_TRACE0(( "BDF_Face_Init: clamping point size to value %d\n",
+ bsize->size ));
+ }
+ else
+ bsize->size = (FT_Pos)font->point_size << 6;
+ }
else
- bsize->size = bsize->width << 6;
+ {
+ /* this is a heuristical value */
+ bsize->size = bsize->width * 64;
+ }
prop = bdf_get_font_property( font, "PIXEL_SIZE" );
if ( prop )
- bsize->y_ppem = (FT_Short)prop->value.l << 6;
+ {
+#ifdef FT_DEBUG_LEVEL_TRACE
+ if ( prop->value.l < 0 )
+ FT_TRACE0(( "BDF_Face_Init: negative pixel size\n" ));
+#endif
+ if ( prop->value.l > 0x7FFF || prop->value.l < -0x7FFF )
+ {
+ bsize->y_ppem = 0x7FFF << 6;
+ FT_TRACE0(( "BDF_Face_Init: clamping pixel size to value %d\n",
+ bsize->y_ppem ));
+ }
+ else
+ bsize->y_ppem = FT_ABS( (FT_Short)prop->value.l ) << 6;
+ }
prop = bdf_get_font_property( font, "RESOLUTION_X" );
if ( prop )
- resolution_x = (FT_Short)prop->value.l;
+ value = prop->value.l;
+ else
+ value = (long)font->resolution_x;
+ if ( value )
+ {
+#ifdef FT_DEBUG_LEVEL_TRACE
+ if ( value < 0 )
+ FT_TRACE0(( "BDF_Face_Init: negative X resolution\n" ));
+#endif
+ if ( value > 0x7FFF || value < -0x7FFF )
+ {
+ resolution_x = 0x7FFF;
+ FT_TRACE0(( "BDF_Face_Init: clamping X resolution to value %d\n",
+ resolution_x ));
+ }
+ else
+ resolution_x = FT_ABS( (FT_Short)value );
+ }
prop = bdf_get_font_property( font, "RESOLUTION_Y" );
if ( prop )
- resolution_y = (FT_Short)prop->value.l;
+ value = prop->value.l;
+ else
+ value = (long)font->resolution_y;
+ if ( value )
+ {
+#ifdef FT_DEBUG_LEVEL_TRACE
+ if ( value < 0 )
+ FT_TRACE0(( "BDF_Face_Init: negative Y resolution\n" ));
+#endif
+ if ( value > 0x7FFF || value < -0x7FFF )
+ {
+ resolution_y = 0x7FFF;
+ FT_TRACE0(( "BDF_Face_Init: clamping Y resolution to value %d\n",
+ resolution_y ));
+ }
+ else
+ resolution_y = FT_ABS( (FT_Short)value );
+ }
if ( bsize->y_ppem == 0 )
{
bsize->y_ppem = bsize->size;
if ( resolution_y )
- bsize->y_ppem = bsize->y_ppem * resolution_y / 72;
+ bsize->y_ppem = FT_MulDiv( bsize->y_ppem, resolution_y, 72 );
}
if ( resolution_x && resolution_y )
- bsize->x_ppem = bsize->y_ppem * resolution_x / resolution_y;
+ bsize->x_ppem = FT_MulDiv( bsize->y_ppem,
+ resolution_x,
+ resolution_y );
else
bsize->x_ppem = bsize->y_ppem;
}
@@ -545,7 +655,11 @@ THE SOFTWARE.
if ( !ft_strcmp( s, "10646" ) ||
( !ft_strcmp( s, "8859" ) &&
!ft_strcmp( face->charset_encoding, "1" ) ) )
- unicode_charmap = 1;
+ unicode_charmap = 1;
+ /* another name for ASCII */
+ else if ( !ft_strcmp( s, "646.1991" ) &&
+ !ft_strcmp( face->charset_encoding, "IRV" ) )
+ unicode_charmap = 1;
}
{
@@ -566,12 +680,6 @@ THE SOFTWARE.
}
error = FT_CMap_New( &bdf_cmap_class, NULL, &charmap, NULL );
-
-#if 0
- /* Select default charmap */
- if ( bdfface->num_charmaps )
- bdfface->charmap = bdfface->charmaps[0];
-#endif
}
goto Exit;
@@ -705,7 +813,7 @@ THE SOFTWARE.
bitmap->rows = glyph.bbx.height;
bitmap->width = glyph.bbx.width;
- if ( glyph.bpr > INT_MAX )
+ if ( glyph.bpr > FT_INT_MAX )
FT_TRACE1(( "BDF_Glyph_Load: too large pitch %d is truncated\n",
glyph.bpr ));
bitmap->pitch = (int)glyph.bpr; /* same as FT_Bitmap.pitch */
@@ -824,8 +932,8 @@ THE SOFTWARE.
static const FT_Service_BDFRec bdf_service_bdf =
{
- (FT_BDF_GetCharsetIdFunc)bdf_get_charset_id,
- (FT_BDF_GetPropertyFunc) bdf_get_bdf_property
+ (FT_BDF_GetCharsetIdFunc)bdf_get_charset_id, /* get_charset_id */
+ (FT_BDF_GetPropertyFunc) bdf_get_bdf_property /* get_property */
};
@@ -866,32 +974,32 @@ THE SOFTWARE.
0x10000L,
0x20000L,
- 0,
+ NULL, /* module-specific interface */
- 0, /* FT_Module_Constructor */
- 0, /* FT_Module_Destructor */
- bdf_driver_requester
+ NULL, /* FT_Module_Constructor module_init */
+ NULL, /* FT_Module_Destructor module_done */
+ bdf_driver_requester /* FT_Module_Requester get_interface */
},
sizeof ( BDF_FaceRec ),
sizeof ( FT_SizeRec ),
sizeof ( FT_GlyphSlotRec ),
- BDF_Face_Init,
- BDF_Face_Done,
- 0, /* FT_Size_InitFunc */
- 0, /* FT_Size_DoneFunc */
- 0, /* FT_Slot_InitFunc */
- 0, /* FT_Slot_DoneFunc */
+ BDF_Face_Init, /* FT_Face_InitFunc init_face */
+ BDF_Face_Done, /* FT_Face_DoneFunc done_face */
+ 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,
+ BDF_Glyph_Load, /* FT_Slot_LoadFunc load_glyph */
- 0, /* FT_Face_GetKerningFunc */
- 0, /* FT_Face_AttachFunc */
- 0, /* FT_Face_GetAdvancesFunc */
+ NULL, /* FT_Face_GetKerningFunc get_kerning */
+ NULL, /* FT_Face_AttachFunc attach_file */
+ NULL, /* FT_Face_GetAdvancesFunc get_advances */
- BDF_Size_Request,
- BDF_Size_Select
+ BDF_Size_Request, /* FT_Size_RequestFunc request_size */
+ BDF_Size_Select /* FT_Size_SelectFunc select_size */
};
diff --git a/src/3rdparty/freetype/src/bdf/bdfdrivr.h b/src/3rdparty/freetype/src/bdf/bdfdrivr.h
index 3c61d644f4..94550818c1 100644
--- a/src/3rdparty/freetype/src/bdf/bdfdrivr.h
+++ b/src/3rdparty/freetype/src/bdf/bdfdrivr.h
@@ -25,8 +25,8 @@ THE SOFTWARE.
*/
-#ifndef __BDFDRIVR_H__
-#define __BDFDRIVR_H__
+#ifndef BDFDRIVR_H_
+#define BDFDRIVR_H_
#include <ft2build.h>
#include FT_INTERNAL_DRIVER_H
@@ -74,7 +74,7 @@ FT_BEGIN_HEADER
FT_END_HEADER
-#endif /* __BDFDRIVR_H__ */
+#endif /* BDFDRIVR_H_ */
/* END */
diff --git a/src/3rdparty/freetype/src/bdf/bdferror.h b/src/3rdparty/freetype/src/bdf/bdferror.h
index ea545aca06..b462c7d3b5 100644
--- a/src/3rdparty/freetype/src/bdf/bdferror.h
+++ b/src/3rdparty/freetype/src/bdf/bdferror.h
@@ -26,12 +26,12 @@
/* */
/*************************************************************************/
-#ifndef __BDFERROR_H__
-#define __BDFERROR_H__
+#ifndef BDFERROR_H_
+#define BDFERROR_H_
#include FT_MODULE_ERRORS_H
-#undef __FTERRORS_H__
+#undef FTERRORS_H_
#undef FT_ERR_PREFIX
#define FT_ERR_PREFIX BDF_Err_
@@ -39,7 +39,7 @@
#include FT_ERRORS_H
-#endif /* __BDFERROR_H__ */
+#endif /* BDFERROR_H_ */
/* END */
diff --git a/src/3rdparty/freetype/src/bdf/bdflib.c b/src/3rdparty/freetype/src/bdf/bdflib.c
index 414deb58ad..2f5c99d544 100644
--- a/src/3rdparty/freetype/src/bdf/bdflib.c
+++ b/src/3rdparty/freetype/src/bdf/bdflib.c
@@ -201,6 +201,7 @@
#define ACMSG14 "Glyph %ld extra columns removed.\n"
#define ACMSG15 "Incorrect glyph count: %ld indicated but %ld found.\n"
#define ACMSG16 "Glyph %ld missing columns padded with zero bits.\n"
+#define ACMSG17 "Adjusting number of glyphs to %ld.\n"
/* Error messages. */
#define ERRMSG1 "[line %ld] Missing `%s' line.\n"
@@ -220,164 +221,6 @@
/*************************************************************************/
/* */
- /* Hash table utilities for the properties. */
- /* */
- /*************************************************************************/
-
- /* XXX: Replace this with FreeType's hash functions */
-
-
-#define INITIAL_HT_SIZE 241
-
- typedef void
- (*hash_free_func)( hashnode node );
-
- static hashnode*
- hash_bucket( const char* key,
- hashtable* ht )
- {
- const char* kp = key;
- unsigned long res = 0;
- hashnode* bp = ht->table, *ndp;
-
-
- /* Mocklisp hash function. */
- while ( *kp )
- res = ( res << 5 ) - res + (unsigned long)*kp++;
-
- ndp = bp + ( res % ht->size );
- while ( *ndp )
- {
- kp = (*ndp)->key;
- if ( kp[0] == key[0] && ft_strcmp( kp, key ) == 0 )
- break;
- ndp--;
- if ( ndp < bp )
- ndp = bp + ( ht->size - 1 );
- }
-
- return ndp;
- }
-
-
- static FT_Error
- hash_rehash( hashtable* ht,
- FT_Memory memory )
- {
- hashnode* obp = ht->table, *bp, *nbp;
- unsigned int i, sz = ht->size;
- FT_Error error = FT_Err_Ok;
-
-
- ht->size <<= 1;
- ht->limit = ht->size / 3;
-
- if ( FT_NEW_ARRAY( ht->table, ht->size ) )
- goto Exit;
-
- for ( i = 0, bp = obp; i < sz; i++, bp++ )
- {
- if ( *bp )
- {
- nbp = hash_bucket( (*bp)->key, ht );
- *nbp = *bp;
- }
- }
- FT_FREE( obp );
-
- Exit:
- return error;
- }
-
-
- static FT_Error
- hash_init( hashtable* ht,
- FT_Memory memory )
- {
- unsigned int sz = INITIAL_HT_SIZE;
- FT_Error error = FT_Err_Ok;
-
-
- ht->size = sz;
- ht->limit = sz / 3;
- ht->used = 0;
-
- if ( FT_NEW_ARRAY( ht->table, sz ) )
- goto Exit;
-
- Exit:
- return error;
- }
-
-
- static void
- hash_free( hashtable* ht,
- FT_Memory memory )
- {
- if ( ht != 0 )
- {
- unsigned int i, sz = ht->size;
- hashnode* bp = ht->table;
-
-
- for ( i = 0; i < sz; i++, bp++ )
- FT_FREE( *bp );
-
- FT_FREE( ht->table );
- }
- }
-
-
- static FT_Error
- hash_insert( char* key,
- size_t data,
- hashtable* ht,
- FT_Memory memory )
- {
- hashnode nn;
- hashnode* bp = hash_bucket( key, ht );
- FT_Error error = FT_Err_Ok;
-
-
- nn = *bp;
- if ( !nn )
- {
- if ( FT_NEW( nn ) )
- goto Exit;
- *bp = nn;
-
- nn->key = key;
- nn->data = data;
-
- if ( ht->used >= ht->limit )
- {
- error = hash_rehash( ht, memory );
- if ( error )
- goto Exit;
- }
- ht->used++;
- }
- else
- nn->data = data;
-
- Exit:
- return error;
- }
-
-
- static hashnode
- hash_lookup( const char* key,
- hashtable* ht )
- {
- hashnode *np = hash_bucket( key, ht );
-
-
- return *np;
- }
-
-
- /*************************************************************************/
- /* */
/* Utility types and functions. */
/* */
/*************************************************************************/
@@ -432,6 +275,7 @@
_bdf_list_t list;
FT_Memory memory;
+ unsigned long size; /* the stream size */
} _bdf_parse_t;
@@ -832,14 +676,6 @@
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
- static const unsigned char odigits[32] =
- {
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- };
-
static const unsigned char ddigits[32] =
{
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x03,
@@ -857,81 +693,41 @@
};
- /* Routine to convert an ASCII string into an unsigned long integer. */
+ /* Routine to convert a decimal ASCII string to an unsigned long integer. */
static unsigned long
- _bdf_atoul( char* s,
- char** end,
- unsigned int base )
+ _bdf_atoul( char* s )
{
- unsigned long v;
- const unsigned char* dmap;
+ unsigned long v;
if ( s == 0 || *s == 0 )
return 0;
- /* Make sure the radix is something recognizable. Default to 10. */
- switch ( base )
+ for ( v = 0; sbitset( ddigits, *s ); s++ )
{
- case 8:
- dmap = odigits;
- break;
- case 16:
- dmap = hdigits;
- break;
- default:
- base = 10;
- dmap = ddigits;
- break;
- }
-
- /* Check for the special hex prefix. */
- if ( *s == '0' &&
- ( *( s + 1 ) == 'x' || *( s + 1 ) == 'X' ) )
- {
- base = 16;
- dmap = hdigits;
- s += 2;
+ if ( v < ( FT_ULONG_MAX - 9 ) / 10 )
+ v = v * 10 + a2i[(int)*s];
+ else
+ {
+ v = FT_ULONG_MAX;
+ break;
+ }
}
- for ( v = 0; sbitset( dmap, *s ); s++ )
- v = v * base + a2i[(int)*s];
-
- if ( end != 0 )
- *end = s;
-
return v;
}
- /* Routine to convert an ASCII string into a signed long integer. */
+ /* Routine to convert a decimal ASCII string to a signed long integer. */
static long
- _bdf_atol( char* s,
- char** end,
- int base )
+ _bdf_atol( char* s )
{
- long v, neg;
- const unsigned char* dmap;
+ long v, neg;
if ( s == 0 || *s == 0 )
return 0;
- /* Make sure the radix is something recognizable. Default to 10. */
- switch ( base )
- {
- case 8:
- dmap = odigits;
- break;
- case 16:
- dmap = hdigits;
- break;
- default:
- base = 10;
- dmap = ddigits;
- break;
- }
-
/* Check for a minus sign. */
neg = 0;
if ( *s == '-' )
@@ -940,100 +736,56 @@
neg = 1;
}
- /* Check for the special hex prefix. */
- if ( *s == '0' &&
- ( *( s + 1 ) == 'x' || *( s + 1 ) == 'X' ) )
+ for ( v = 0; sbitset( ddigits, *s ); s++ )
{
- base = 16;
- dmap = hdigits;
- s += 2;
+ if ( v < ( FT_LONG_MAX - 9 ) / 10 )
+ v = v * 10 + a2i[(int)*s];
+ else
+ {
+ v = FT_LONG_MAX;
+ break;
+ }
}
- for ( v = 0; sbitset( dmap, *s ); s++ )
- v = v * base + a2i[(int)*s];
-
- if ( end != 0 )
- *end = s;
-
return ( !neg ) ? v : -v;
}
- /* Routine to convert an ASCII string into an unsigned short integer. */
+ /* Routine to convert a decimal ASCII string to an unsigned short integer. */
static unsigned short
- _bdf_atous( char* s,
- char** end,
- unsigned int base )
+ _bdf_atous( char* s )
{
- unsigned short v;
- const unsigned char* dmap;
+ unsigned short v;
if ( s == 0 || *s == 0 )
return 0;
- /* Make sure the radix is something recognizable. Default to 10. */
- switch ( base )
- {
- case 8:
- dmap = odigits;
- break;
- case 16:
- dmap = hdigits;
- break;
- default:
- base = 10;
- dmap = ddigits;
- break;
- }
-
- /* Check for the special hex prefix. */
- if ( *s == '0' &&
- ( *( s + 1 ) == 'x' || *( s + 1 ) == 'X' ) )
+ for ( v = 0; sbitset( ddigits, *s ); s++ )
{
- base = 16;
- dmap = hdigits;
- s += 2;
+ if ( v < ( FT_USHORT_MAX - 9 ) / 10 )
+ v = (unsigned short)( v * 10 + a2i[(int)*s] );
+ else
+ {
+ v = FT_USHORT_MAX;
+ break;
+ }
}
- for ( v = 0; sbitset( dmap, *s ); s++ )
- v = (unsigned short)( v * base + a2i[(int)*s] );
-
- if ( end != 0 )
- *end = s;
-
return v;
}
- /* Routine to convert an ASCII string into a signed short integer. */
+ /* Routine to convert a decimal ASCII string to a signed short integer. */
static short
- _bdf_atos( char* s,
- char** end,
- int base )
+ _bdf_atos( char* s )
{
- short v, neg;
- const unsigned char* dmap;
+ short v, neg;
if ( s == 0 || *s == 0 )
return 0;
- /* Make sure the radix is something recognizable. Default to 10. */
- switch ( base )
- {
- case 8:
- dmap = odigits;
- break;
- case 16:
- dmap = hdigits;
- break;
- default:
- base = 10;
- dmap = ddigits;
- break;
- }
-
/* Check for a minus. */
neg = 0;
if ( *s == '-' )
@@ -1042,21 +794,17 @@
neg = 1;
}
- /* Check for the special hex prefix. */
- if ( *s == '0' &&
- ( *( s + 1 ) == 'x' || *( s + 1 ) == 'X' ) )
+ for ( v = 0; sbitset( ddigits, *s ); s++ )
{
- base = 16;
- dmap = hdigits;
- s += 2;
+ if ( v < ( SHRT_MAX - 9 ) / 10 )
+ v = (short)( v * 10 + a2i[(int)*s] );
+ else
+ {
+ v = SHRT_MAX;
+ break;
+ }
}
- for ( v = 0; sbitset( dmap, *s ); s++ )
- v = (short)( v * base + a2i[(int)*s] );
-
- if ( end != 0 )
- *end = s;
-
return (short)( ( !neg ) ? v : -v );
}
@@ -1096,7 +844,7 @@
/* First check whether the property has */
/* already been added or not. If it has, then */
/* simply ignore it. */
- if ( hash_lookup( name, &(font->proptbl) ) )
+ if ( ft_hash_str_lookup( name, &(font->proptbl) ) )
goto Exit;
if ( FT_RENEW_ARRAY( font->user_props,
@@ -1121,7 +869,7 @@
n = _num_bdf_properties + font->nuser_props;
- error = hash_insert( p->name, n, &(font->proptbl), memory );
+ error = ft_hash_str_insert( p->name, n, &(font->proptbl), memory );
if ( error )
goto Exit;
@@ -1132,25 +880,23 @@
}
- FT_LOCAL_DEF( bdf_property_t * )
+ FT_LOCAL_DEF( bdf_property_t* )
bdf_get_property( char* name,
bdf_font_t* font )
{
- hashnode hn;
- size_t propid;
+ size_t* propid;
if ( name == 0 || *name == 0 )
return 0;
- if ( ( hn = hash_lookup( name, &(font->proptbl) ) ) == 0 )
+ if ( ( propid = ft_hash_str_lookup( name, &(font->proptbl) ) ) == NULL )
return 0;
- propid = hn->data;
- if ( propid >= _num_bdf_properties )
- return font->user_props + ( propid - _num_bdf_properties );
+ if ( *propid >= _num_bdf_properties )
+ return font->user_props + ( *propid - _num_bdf_properties );
- return (bdf_property_t*)_bdf_properties + propid;
+ return (bdf_property_t*)_bdf_properties + *propid;
}
@@ -1163,30 +909,30 @@
/* Parse flags. */
-#define _BDF_START 0x0001U
-#define _BDF_FONT_NAME 0x0002U
-#define _BDF_SIZE 0x0004U
-#define _BDF_FONT_BBX 0x0008U
-#define _BDF_PROPS 0x0010U
-#define _BDF_GLYPHS 0x0020U
-#define _BDF_GLYPH 0x0040U
-#define _BDF_ENCODING 0x0080U
-#define _BDF_SWIDTH 0x0100U
-#define _BDF_DWIDTH 0x0200U
-#define _BDF_BBX 0x0400U
-#define _BDF_BITMAP 0x0800U
+#define BDF_START_ 0x0001U
+#define BDF_FONT_NAME_ 0x0002U
+#define BDF_SIZE_ 0x0004U
+#define BDF_FONT_BBX_ 0x0008U
+#define BDF_PROPS_ 0x0010U
+#define BDF_GLYPHS_ 0x0020U
+#define BDF_GLYPH_ 0x0040U
+#define BDF_ENCODING_ 0x0080U
+#define BDF_SWIDTH_ 0x0100U
+#define BDF_DWIDTH_ 0x0200U
+#define BDF_BBX_ 0x0400U
+#define BDF_BITMAP_ 0x0800U
-#define _BDF_SWIDTH_ADJ 0x1000U
+#define BDF_SWIDTH_ADJ_ 0x1000U
-#define _BDF_GLYPH_BITS ( _BDF_GLYPH | \
- _BDF_ENCODING | \
- _BDF_SWIDTH | \
- _BDF_DWIDTH | \
- _BDF_BBX | \
- _BDF_BITMAP )
+#define BDF_GLYPH_BITS_ ( BDF_GLYPH_ | \
+ BDF_ENCODING_ | \
+ BDF_SWIDTH_ | \
+ BDF_DWIDTH_ | \
+ BDF_BBX_ | \
+ BDF_BITMAP_ )
-#define _BDF_GLYPH_WIDTH_CHECK 0x40000000UL
-#define _BDF_GLYPH_HEIGHT_CHECK 0x80000000UL
+#define BDF_GLYPH_WIDTH_CHECK_ 0x40000000UL
+#define BDF_GLYPH_HEIGHT_CHECK_ 0x80000000UL
static FT_Error
@@ -1358,8 +1104,7 @@
char* value,
unsigned long lineno )
{
- size_t propid;
- hashnode hn;
+ size_t* propid;
bdf_property_t *prop, *fp;
FT_Memory memory = font->memory;
FT_Error error = FT_Err_Ok;
@@ -1368,11 +1113,12 @@
/* First, check whether the property already exists in the font. */
- if ( ( hn = hash_lookup( name, (hashtable *)font->internal ) ) != 0 )
+ if ( ( propid = ft_hash_str_lookup( name,
+ (FT_Hash)font->internal ) ) != NULL )
{
/* The property already exists in the font, so simply replace */
/* the value of the property with the current value. */
- fp = font->props + hn->data;
+ fp = font->props + *propid;
switch ( fp->format )
{
@@ -1388,11 +1134,11 @@
break;
case BDF_INTEGER:
- fp->value.l = _bdf_atol( value, 0, 10 );
+ fp->value.l = _bdf_atol( value );
break;
case BDF_CARDINAL:
- fp->value.ul = _bdf_atoul( value, 0, 10 );
+ fp->value.ul = _bdf_atoul( value );
break;
default:
@@ -1404,16 +1150,16 @@
/* See whether this property type exists yet or not. */
/* If not, create it. */
- hn = hash_lookup( name, &(font->proptbl) );
- if ( hn == 0 )
+ propid = ft_hash_str_lookup( name, &(font->proptbl) );
+ if ( !propid )
{
error = bdf_create_property( name, BDF_ATOM, font );
if ( error )
goto Exit;
- hn = hash_lookup( name, &(font->proptbl) );
+ propid = ft_hash_str_lookup( name, &(font->proptbl) );
}
- /* Allocate another property if this is overflow. */
+ /* Allocate another property if this is overflowing. */
if ( font->props_used == font->props_size )
{
if ( font->props_size == 0 )
@@ -1430,15 +1176,14 @@
}
fp = font->props + font->props_size;
- FT_MEM_ZERO( fp, sizeof ( bdf_property_t ) );
+ FT_ZERO( fp );
font->props_size++;
}
- propid = hn->data;
- if ( propid >= _num_bdf_properties )
- prop = font->user_props + ( propid - _num_bdf_properties );
+ if ( *propid >= _num_bdf_properties )
+ prop = font->user_props + ( *propid - _num_bdf_properties );
else
- prop = (bdf_property_t*)_bdf_properties + propid;
+ prop = (bdf_property_t*)_bdf_properties + *propid;
fp = font->props + font->props_used;
@@ -1458,11 +1203,11 @@
break;
case BDF_INTEGER:
- fp->value.l = _bdf_atol( value, 0, 10 );
+ fp->value.l = _bdf_atol( value );
break;
case BDF_CARDINAL:
- fp->value.ul = _bdf_atoul( value, 0, 10 );
+ fp->value.ul = _bdf_atoul( value );
break;
}
@@ -1471,10 +1216,10 @@
if ( _bdf_strncmp( name, "COMMENT", 7 ) != 0 )
{
/* Add the property to the font property table. */
- error = hash_insert( fp->name,
- font->props_used,
- (hashtable *)font->internal,
- memory );
+ error = ft_hash_str_insert( fp->name,
+ font->props_used,
+ (FT_Hash)font->internal,
+ memory );
if ( error )
goto Exit;
}
@@ -1565,7 +1310,7 @@
}
/* The very first thing expected is the number of glyphs. */
- if ( !( p->flags & _BDF_GLYPHS ) )
+ if ( !( p->flags & BDF_GLYPHS_ ) )
{
if ( _bdf_strncmp( line, "CHARS", 5 ) != 0 )
{
@@ -1577,7 +1322,14 @@
error = _bdf_list_split( &p->list, (char *)" +", line, linelen );
if ( error )
goto Exit;
- p->cnt = font->glyphs_size = _bdf_atoul( p->list.field[1], 0, 10 );
+ p->cnt = font->glyphs_size = _bdf_atoul( p->list.field[1] );
+
+ /* We need at least 20 bytes per glyph. */
+ if ( p->cnt > p->size / 20 )
+ {
+ p->cnt = font->glyphs_size = p->size / 20;
+ FT_TRACE2(( "_bdf_parse_glyphs: " ACMSG17, p->cnt ));
+ }
/* Make sure the number of glyphs is non-zero. */
if ( p->cnt == 0 )
@@ -1595,7 +1347,7 @@
if ( FT_NEW_ARRAY( font->glyphs, font->glyphs_size ) )
goto Exit;
- p->flags |= _BDF_GLYPHS;
+ p->flags |= BDF_GLYPHS_;
goto Exit;
}
@@ -1603,7 +1355,7 @@
/* Check for the ENDFONT field. */
if ( _bdf_strncmp( line, "ENDFONT", 7 ) == 0 )
{
- if ( p->flags & _BDF_GLYPH_BITS )
+ if ( p->flags & BDF_GLYPH_BITS_ )
{
/* Missing ENDCHAR field. */
FT_ERROR(( "_bdf_parse_glyphs: " ERRMSG1, lineno, "ENDCHAR" ));
@@ -1617,7 +1369,7 @@
sizeof ( bdf_glyph_t ),
by_encoding );
- p->flags &= ~_BDF_START;
+ p->flags &= ~BDF_START_;
goto Exit;
}
@@ -1626,14 +1378,14 @@
if ( _bdf_strncmp( line, "ENDCHAR", 7 ) == 0 )
{
p->glyph_enc = 0;
- p->flags &= ~_BDF_GLYPH_BITS;
+ p->flags &= ~BDF_GLYPH_BITS_;
goto Exit;
}
/* Check whether a glyph is being scanned but should be */
/* ignored because it is an unencoded glyph. */
- if ( ( p->flags & _BDF_GLYPH ) &&
+ if ( ( p->flags & BDF_GLYPH_ ) &&
p->glyph_enc == -1 &&
p->opts->keep_unencoded == 0 )
goto Exit;
@@ -1641,6 +1393,14 @@
/* Check for the STARTCHAR field. */
if ( _bdf_strncmp( line, "STARTCHAR", 9 ) == 0 )
{
+ if ( p->flags & BDF_GLYPH_BITS_ )
+ {
+ /* Missing ENDCHAR field. */
+ FT_ERROR(( "_bdf_parse_glyphs: " ERRMSG1, lineno, "ENDCHAR" ));
+ error = FT_THROW( Missing_Startchar_Field );
+ goto Exit;
+ }
+
/* Set the character name in the parse info first until the */
/* encoding can be checked for an unencoded character. */
FT_FREE( p->glyph_name );
@@ -1665,7 +1425,7 @@
FT_MEM_COPY( p->glyph_name, s, slen + 1 );
- p->flags |= _BDF_GLYPH;
+ p->flags |= BDF_GLYPH_;
FT_TRACE4(( DBGMSG1, lineno, s ));
@@ -1675,7 +1435,7 @@
/* Check for the ENCODING field. */
if ( _bdf_strncmp( line, "ENCODING", 8 ) == 0 )
{
- if ( !( p->flags & _BDF_GLYPH ) )
+ if ( !( p->flags & BDF_GLYPH_ ) )
{
/* Missing STARTCHAR field. */
FT_ERROR(( "_bdf_parse_glyphs: " ERRMSG1, lineno, "STARTCHAR" ));
@@ -1687,7 +1447,7 @@
if ( error )
goto Exit;
- p->glyph_enc = _bdf_atol( p->list.field[1], 0, 10 );
+ p->glyph_enc = _bdf_atol( p->list.field[1] );
/* Normalize negative encoding values. The specification only */
/* allows -1, but we can be more generous here. */
@@ -1696,7 +1456,7 @@
/* Check for alternative encoding format. */
if ( p->glyph_enc == -1 && p->list.used > 2 )
- p->glyph_enc = _bdf_atol( p->list.field[2], 0, 10 );
+ p->glyph_enc = _bdf_atol( p->list.field[2] );
if ( p->glyph_enc < -1 )
p->glyph_enc = -1;
@@ -1773,20 +1533,25 @@
glyph = font->unencoded + font->unencoded_used;
glyph->name = p->glyph_name;
glyph->encoding = (long)font->unencoded_used++;
+
+ /* Reset the initial glyph info. */
+ p->glyph_name = NULL;
}
else
+ {
/* Free up the glyph name if the unencoded shouldn't be */
/* kept. */
FT_FREE( p->glyph_name );
+ }
p->glyph_name = NULL;
}
/* Clear the flags that might be added when width and height are */
/* checked for consistency. */
- p->flags &= ~( _BDF_GLYPH_WIDTH_CHECK | _BDF_GLYPH_HEIGHT_CHECK );
+ p->flags &= ~( BDF_GLYPH_WIDTH_CHECK_ | BDF_GLYPH_HEIGHT_CHECK_ );
- p->flags |= _BDF_ENCODING;
+ p->flags |= BDF_ENCODING_;
goto Exit;
}
@@ -1798,16 +1563,16 @@
glyph = font->glyphs + ( font->glyphs_used - 1 );
/* Check whether a bitmap is being constructed. */
- if ( p->flags & _BDF_BITMAP )
+ if ( p->flags & BDF_BITMAP_ )
{
/* If there are more rows than are specified in the glyph metrics, */
/* ignore the remaining lines. */
if ( p->row >= (unsigned long)glyph->bbx.height )
{
- if ( !( p->flags & _BDF_GLYPH_HEIGHT_CHECK ) )
+ if ( !( p->flags & BDF_GLYPH_HEIGHT_CHECK_ ) )
{
FT_TRACE2(( "_bdf_parse_glyphs: " ACMSG13, glyph->encoding ));
- p->flags |= _BDF_GLYPH_HEIGHT_CHECK;
+ p->flags |= BDF_GLYPH_HEIGHT_CHECK_;
font->modified = 1;
}
@@ -1832,10 +1597,10 @@
/* If any line has not enough columns, */
/* indicate they have been padded with zero bits. */
if ( i < nibbles &&
- !( p->flags & _BDF_GLYPH_WIDTH_CHECK ) )
+ !( p->flags & BDF_GLYPH_WIDTH_CHECK_ ) )
{
FT_TRACE2(( "_bdf_parse_glyphs: " ACMSG16, glyph->encoding ));
- p->flags |= _BDF_GLYPH_WIDTH_CHECK;
+ p->flags |= BDF_GLYPH_WIDTH_CHECK_;
font->modified = 1;
}
@@ -1847,10 +1612,10 @@
/* If any line has extra columns, indicate they have been removed. */
if ( i == nibbles &&
sbitset( hdigits, line[nibbles] ) &&
- !( p->flags & _BDF_GLYPH_WIDTH_CHECK ) )
+ !( p->flags & BDF_GLYPH_WIDTH_CHECK_ ) )
{
FT_TRACE2(( "_bdf_parse_glyphs: " ACMSG14, glyph->encoding ));
- p->flags |= _BDF_GLYPH_WIDTH_CHECK;
+ p->flags |= BDF_GLYPH_WIDTH_CHECK_;
font->modified = 1;
}
@@ -1861,15 +1626,15 @@
/* Expect the SWIDTH (scalable width) field next. */
if ( _bdf_strncmp( line, "SWIDTH", 6 ) == 0 )
{
- if ( !( p->flags & _BDF_ENCODING ) )
+ if ( !( p->flags & BDF_ENCODING_ ) )
goto Missing_Encoding;
error = _bdf_list_split( &p->list, (char *)" +", line, linelen );
if ( error )
goto Exit;
- glyph->swidth = (unsigned short)_bdf_atoul( p->list.field[1], 0, 10 );
- p->flags |= _BDF_SWIDTH;
+ glyph->swidth = (unsigned short)_bdf_atoul( p->list.field[1] );
+ p->flags |= BDF_SWIDTH_;
goto Exit;
}
@@ -1877,16 +1642,16 @@
/* Expect the DWIDTH (scalable width) field next. */
if ( _bdf_strncmp( line, "DWIDTH", 6 ) == 0 )
{
- if ( !( p->flags & _BDF_ENCODING ) )
+ if ( !( p->flags & BDF_ENCODING_ ) )
goto Missing_Encoding;
error = _bdf_list_split( &p->list, (char *)" +", line, linelen );
if ( error )
goto Exit;
- glyph->dwidth = (unsigned short)_bdf_atoul( p->list.field[1], 0, 10 );
+ glyph->dwidth = (unsigned short)_bdf_atoul( p->list.field[1] );
- if ( !( p->flags & _BDF_SWIDTH ) )
+ if ( !( p->flags & BDF_SWIDTH_ ) )
{
/* Missing SWIDTH field. Emit an auto correction message and set */
/* the scalable width from the device width. */
@@ -1898,24 +1663,24 @@
font->resolution_x ) );
}
- p->flags |= _BDF_DWIDTH;
+ p->flags |= BDF_DWIDTH_;
goto Exit;
}
/* Expect the BBX field next. */
if ( _bdf_strncmp( line, "BBX", 3 ) == 0 )
{
- if ( !( p->flags & _BDF_ENCODING ) )
+ if ( !( p->flags & BDF_ENCODING_ ) )
goto Missing_Encoding;
error = _bdf_list_split( &p->list, (char *)" +", line, linelen );
if ( error )
goto Exit;
- glyph->bbx.width = _bdf_atous( p->list.field[1], 0, 10 );
- glyph->bbx.height = _bdf_atous( p->list.field[2], 0, 10 );
- glyph->bbx.x_offset = _bdf_atos( p->list.field[3], 0, 10 );
- glyph->bbx.y_offset = _bdf_atos( p->list.field[4], 0, 10 );
+ glyph->bbx.width = _bdf_atous( p->list.field[1] );
+ glyph->bbx.height = _bdf_atous( p->list.field[2] );
+ glyph->bbx.x_offset = _bdf_atos( p->list.field[3] );
+ glyph->bbx.y_offset = _bdf_atos( p->list.field[4] );
/* Generate the ascent and descent of the character. */
glyph->bbx.ascent = (short)( glyph->bbx.height + glyph->bbx.y_offset );
@@ -1932,7 +1697,7 @@
p->minlb = (short)FT_MIN( glyph->bbx.x_offset, p->minlb );
p->maxlb = (short)FT_MAX( glyph->bbx.x_offset, p->maxlb );
- if ( !( p->flags & _BDF_DWIDTH ) )
+ if ( !( p->flags & BDF_DWIDTH_ ) )
{
/* Missing DWIDTH field. Emit an auto correction message and set */
/* the device width to the glyph width. */
@@ -1961,12 +1726,12 @@
else
_bdf_set_glyph_modified( font->nmod, glyph->encoding );
- p->flags |= _BDF_SWIDTH_ADJ;
+ p->flags |= BDF_SWIDTH_ADJ_;
font->modified = 1;
}
}
- p->flags |= _BDF_BBX;
+ p->flags |= BDF_BBX_;
goto Exit;
}
@@ -1976,7 +1741,7 @@
unsigned long bitmap_size;
- if ( !( p->flags & _BDF_BBX ) )
+ if ( !( p->flags & BDF_BBX_ ) )
{
/* Missing BBX field. */
FT_ERROR(( "_bdf_parse_glyphs: " ERRMSG1, lineno, "BBX" ));
@@ -2001,7 +1766,7 @@
goto Exit;
p->row = 0;
- p->flags |= _BDF_BITMAP;
+ p->flags |= BDF_BITMAP_;
goto Exit;
}
@@ -2016,7 +1781,7 @@
error = FT_THROW( Missing_Encoding_Field );
Exit:
- if ( error && ( p->flags & _BDF_GLYPH ) )
+ if ( error && ( p->flags & BDF_GLYPH_ ) )
FT_FREE( p->glyph_name );
return error;
@@ -2080,7 +1845,7 @@
p->font->modified = 1;
}
- p->flags &= ~_BDF_PROPS;
+ p->flags &= ~BDF_PROPS_;
*next = _bdf_parse_glyphs;
goto Exit;
@@ -2178,7 +1943,7 @@
goto Exit;
}
- if ( !( p->flags & _BDF_START ) )
+ if ( !( p->flags & BDF_START_ ) )
{
memory = p->memory;
@@ -2190,7 +1955,7 @@
goto Exit;
}
- p->flags = _BDF_START;
+ p->flags = BDF_START_;
font = p->font = 0;
if ( FT_NEW( font ) )
@@ -2205,22 +1970,22 @@
bdf_property_t* prop;
- error = hash_init( &(font->proptbl), memory );
+ error = ft_hash_str_init( &(font->proptbl), memory );
if ( error )
goto Exit;
for ( i = 0, prop = (bdf_property_t*)_bdf_properties;
i < _num_bdf_properties; i++, prop++ )
{
- error = hash_insert( prop->name, i,
- &(font->proptbl), memory );
+ error = ft_hash_str_insert( prop->name, i,
+ &(font->proptbl), memory );
if ( error )
goto Exit;
}
}
- if ( FT_ALLOC( p->font->internal, sizeof ( hashtable ) ) )
+ if ( FT_ALLOC( p->font->internal, sizeof ( FT_HashRec ) ) )
goto Exit;
- error = hash_init( (hashtable *)p->font->internal,memory );
+ error = ft_hash_str_init( (FT_Hash)p->font->internal, memory );
if ( error )
goto Exit;
p->font->spacing = p->opts->font_spacing;
@@ -2232,7 +1997,7 @@
/* Check for the start of the properties. */
if ( _bdf_strncmp( line, "STARTPROPERTIES", 15 ) == 0 )
{
- if ( !( p->flags & _BDF_FONT_BBX ) )
+ if ( !( p->flags & BDF_FONT_BBX_ ) )
{
/* Missing the FONTBOUNDINGBOX field. */
FT_ERROR(( "_bdf_parse_start: " ERRMSG1, lineno, "FONTBOUNDINGBOX" ));
@@ -2243,8 +2008,18 @@
error = _bdf_list_split( &p->list, (char *)" +", line, linelen );
if ( error )
goto Exit;
+
/* at this point, `p->font' can't be NULL */
- p->cnt = p->font->props_size = _bdf_atoul( p->list.field[1], 0, 10 );
+ p->cnt = p->font->props_size = _bdf_atoul( p->list.field[1] );
+ /* We need at least 4 bytes per property. */
+ if ( p->cnt > p->size / 4 )
+ {
+ p->font->props_size = 0;
+
+ FT_ERROR(( "_bdf_parse_glyphs: " ERRMSG5, lineno, "STARTPROPERTIES" ));
+ error = FT_THROW( Invalid_Argument );
+ goto Exit;
+ }
if ( FT_NEW_ARRAY( p->font->props, p->cnt ) )
{
@@ -2252,7 +2027,7 @@
goto Exit;
}
- p->flags |= _BDF_PROPS;
+ p->flags |= BDF_PROPS_;
*next = _bdf_parse_properties;
goto Exit;
@@ -2261,7 +2036,7 @@
/* Check for the FONTBOUNDINGBOX field. */
if ( _bdf_strncmp( line, "FONTBOUNDINGBOX", 15 ) == 0 )
{
- if ( !( p->flags & _BDF_SIZE ) )
+ if ( !( p->flags & BDF_SIZE_ ) )
{
/* Missing the SIZE field. */
FT_ERROR(( "_bdf_parse_start: " ERRMSG1, lineno, "SIZE" ));
@@ -2273,18 +2048,18 @@
if ( error )
goto Exit;
- p->font->bbx.width = _bdf_atous( p->list.field[1], 0, 10 );
- p->font->bbx.height = _bdf_atous( p->list.field[2], 0, 10 );
+ p->font->bbx.width = _bdf_atous( p->list.field[1] );
+ p->font->bbx.height = _bdf_atous( p->list.field[2] );
- p->font->bbx.x_offset = _bdf_atos( p->list.field[3], 0, 10 );
- p->font->bbx.y_offset = _bdf_atos( p->list.field[4], 0, 10 );
+ p->font->bbx.x_offset = _bdf_atos( p->list.field[3] );
+ p->font->bbx.y_offset = _bdf_atos( p->list.field[4] );
p->font->bbx.ascent = (short)( p->font->bbx.height +
p->font->bbx.y_offset );
p->font->bbx.descent = (short)( -p->font->bbx.y_offset );
- p->flags |= _BDF_FONT_BBX;
+ p->flags |= BDF_FONT_BBX_;
goto Exit;
}
@@ -2319,7 +2094,7 @@
if ( error )
goto Exit;
- p->flags |= _BDF_FONT_NAME;
+ p->flags |= BDF_FONT_NAME_;
goto Exit;
}
@@ -2327,7 +2102,7 @@
/* Check for the SIZE field. */
if ( _bdf_strncmp( line, "SIZE", 4 ) == 0 )
{
- if ( !( p->flags & _BDF_FONT_NAME ) )
+ if ( !( p->flags & BDF_FONT_NAME_ ) )
{
/* Missing the FONT field. */
FT_ERROR(( "_bdf_parse_start: " ERRMSG1, lineno, "FONT" ));
@@ -2339,9 +2114,9 @@
if ( error )
goto Exit;
- p->font->point_size = _bdf_atoul( p->list.field[1], 0, 10 );
- p->font->resolution_x = _bdf_atoul( p->list.field[2], 0, 10 );
- p->font->resolution_y = _bdf_atoul( p->list.field[3], 0, 10 );
+ p->font->point_size = _bdf_atoul( p->list.field[1] );
+ p->font->resolution_x = _bdf_atoul( p->list.field[2] );
+ p->font->resolution_y = _bdf_atoul( p->list.field[3] );
/* Check for the bits per pixel field. */
if ( p->list.used == 5 )
@@ -2349,7 +2124,7 @@
unsigned short bpp;
- bpp = (unsigned short)_bdf_atos( p->list.field[4], 0, 10 );
+ bpp = (unsigned short)_bdf_atos( p->list.field[4] );
/* Only values 1, 2, 4, 8 are allowed for greymap fonts. */
if ( bpp > 4 )
@@ -2367,7 +2142,7 @@
else
p->font->bpp = 1;
- p->flags |= _BDF_SIZE;
+ p->flags |= BDF_SIZE_;
goto Exit;
}
@@ -2378,7 +2153,7 @@
char nbuf[128];
- if ( !( p->flags & _BDF_FONT_BBX ) )
+ if ( !( p->flags & BDF_FONT_BBX_ ) )
{
/* Missing the FONTBOUNDINGBOX field. */
FT_ERROR(( "_bdf_parse_start: " ERRMSG1, lineno, "FONTBOUNDINGBOX" ));
@@ -2447,6 +2222,7 @@
memory = NULL;
p->opts = (bdf_options_t*)( ( opts != 0 ) ? opts : &_bdf_opts );
p->minlb = 32767;
+ p->size = stream->size;
p->memory = extmemory; /* only during font creation */
_bdf_list_init( &p->list, extmemory );
@@ -2518,27 +2294,27 @@
p->font->bbx.height = (unsigned short)( p->maxas + p->maxds );
}
- if ( p->flags & _BDF_SWIDTH_ADJ )
+ if ( p->flags & BDF_SWIDTH_ADJ_ )
FT_TRACE2(( "bdf_load_font: " ACMSG8 ));
}
}
- if ( p->flags & _BDF_START )
+ if ( p->flags & BDF_START_ )
{
/* The ENDFONT field was never reached or did not exist. */
- if ( !( p->flags & _BDF_GLYPHS ) )
+ if ( !( p->flags & BDF_GLYPHS_ ) )
{
/* Error happened while parsing header. */
FT_ERROR(( "bdf_load_font: " ERRMSG2, lineno ));
error = FT_THROW( Corrupted_Font_Header );
- goto Exit;
+ goto Fail;
}
else
{
/* Error happened when parsing glyphs. */
FT_ERROR(( "bdf_load_font: " ERRMSG3, lineno ));
error = FT_THROW( Corrupted_Font_Glyphs );
- goto Exit;
+ goto Fail;
}
}
@@ -2557,7 +2333,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;
@@ -2569,6 +2345,7 @@
memory = extmemory;
+ FT_FREE( p->glyph_name );
FT_FREE( p );
}
@@ -2604,7 +2381,7 @@
/* Free up the internal hash table of property names. */
if ( font->internal )
{
- hash_free( (hashtable *)font->internal, memory );
+ ft_hash_str_free( (FT_Hash)font->internal, memory );
FT_FREE( font->internal );
}
@@ -2649,7 +2426,7 @@
FT_FREE( font->overflow.glyphs );
/* bdf_cleanup */
- hash_free( &(font->proptbl), memory );
+ ft_hash_str_free( &(font->proptbl), memory );
/* Free up the user defined properties. */
for ( prop = font->user_props, i = 0;
@@ -2670,15 +2447,15 @@
bdf_get_font_property( bdf_font_t* font,
const char* name )
{
- hashnode hn;
+ size_t* propid;
if ( font == 0 || font->props_size == 0 || name == 0 || *name == 0 )
return 0;
- hn = hash_lookup( name, (hashtable *)font->internal );
+ propid = ft_hash_str_lookup( name, (FT_Hash)font->internal );
- return hn ? ( font->props + hn->data ) : 0;
+ return propid ? ( font->props + *propid ) : 0;
}
diff --git a/src/3rdparty/freetype/src/bzip2/Jamfile b/src/3rdparty/freetype/src/bzip2/Jamfile
index 53f850e6f2..3548eab597 100644
--- a/src/3rdparty/freetype/src/bzip2/Jamfile
+++ b/src/3rdparty/freetype/src/bzip2/Jamfile
@@ -1,6 +1,6 @@
# FreeType 2 src/bzip2 Jamfile
#
-# Copyright 2010-2015 by
+# Copyright 2010-2018 by
# Joel Klinghed
#
# based on `src/lzw/Jamfile'
diff --git a/src/3rdparty/freetype/src/bzip2/ftbzip2.c b/src/3rdparty/freetype/src/bzip2/ftbzip2.c
index cf94733762..16019485a9 100644
--- a/src/3rdparty/freetype/src/bzip2/ftbzip2.c
+++ b/src/3rdparty/freetype/src/bzip2/ftbzip2.c
@@ -8,7 +8,7 @@
/* parse compressed PCF fonts, as found with many X11 server */
/* distributions. */
/* */
-/* Copyright 2010-2015 by */
+/* Copyright 2010-2018 by */
/* Joel Klinghed. */
/* */
/* based on `src/gzip/ftgzip.c' */
@@ -32,7 +32,7 @@
#include FT_MODULE_ERRORS_H
-#undef __FTERRORS_H__
+#undef FTERRORS_H_
#undef FT_ERR_PREFIX
#define FT_ERR_PREFIX Bzip2_Err_
@@ -180,7 +180,7 @@
bzstream->next_in = (char*)zip->buffer;
if ( BZ2_bzDecompressInit( bzstream, 0, 0 ) != BZ_OK ||
- bzstream->next_in == NULL )
+ !bzstream->next_in )
error = FT_THROW( Invalid_File_Format );
Exit:
diff --git a/src/3rdparty/freetype/src/bzip2/rules.mk b/src/3rdparty/freetype/src/bzip2/rules.mk
index 7040588c1b..95954d7520 100644
--- a/src/3rdparty/freetype/src/bzip2/rules.mk
+++ b/src/3rdparty/freetype/src/bzip2/rules.mk
@@ -2,7 +2,7 @@
# FreeType 2 BZIP2 support configuration rules
#
-# Copyright 2010-2015 by
+# Copyright 2010-2018 by
# Joel Klinghed.
#
# based on `src/lzw/rules.mk'
diff --git a/src/3rdparty/freetype/src/cache/Jamfile b/src/3rdparty/freetype/src/cache/Jamfile
index 1d2bb29392..53f4c7b603 100644
--- a/src/3rdparty/freetype/src/cache/Jamfile
+++ b/src/3rdparty/freetype/src/cache/Jamfile
@@ -1,6 +1,6 @@
# FreeType 2 src/cache Jamfile
#
-# Copyright 2001-2015 by
+# Copyright 2001-2018 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/src/3rdparty/freetype/src/cache/ftcache.c b/src/3rdparty/freetype/src/cache/ftcache.c
index 8de527acab..1b425af911 100644
--- a/src/3rdparty/freetype/src/cache/ftcache.c
+++ b/src/3rdparty/freetype/src/cache/ftcache.c
@@ -4,7 +4,7 @@
/* */
/* The FreeType Caching sub-system (body only). */
/* */
-/* Copyright 2000-2015 by */
+/* Copyright 2000-2018 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/src/3rdparty/freetype/src/cache/ftcbasic.c b/src/3rdparty/freetype/src/cache/ftcbasic.c
index ac3290cef4..994aa12286 100644
--- a/src/3rdparty/freetype/src/cache/ftcbasic.c
+++ b/src/3rdparty/freetype/src/cache/ftcbasic.c
@@ -4,7 +4,7 @@
/* */
/* The FreeType basic cache interface (body). */
/* */
-/* Copyright 2003-2015 by */
+/* Copyright 2003-2018 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
};
@@ -301,10 +304,18 @@
if ( anode )
*anode = NULL;
- if ( (FT_ULong)( type->flags - FT_INT_MIN ) > FT_UINT_MAX )
+ /*
+ * Internal `FTC_BasicAttr->load_flags' is of type `FT_UInt',
+ * but public `FT_ImageType->flags' is of type `FT_Int32'.
+ *
+ * On 16bit systems, higher bits of type->flags cannot be handled.
+ */
+#if 0xFFFFFFFFUL > FT_UINT_MAX
+ if ( (type->flags & (FT_ULong)FT_UINT_MAX) )
FT_TRACE1(( "FTC_ImageCache_Lookup:"
" higher bits in load_flags 0x%x are dropped\n",
(FT_ULong)type->flags & ~((FT_ULong)FT_UINT_MAX) ));
+#endif
query.attrs.scaler.face_id = type->face_id;
query.attrs.scaler.width = type->width;
@@ -374,11 +385,18 @@
if ( anode )
*anode = NULL;
- /* `FT_Load_Glyph' and `FT_Load_Char' take FT_UInt flags */
+ /*
+ * Internal `FTC_BasicAttr->load_flags' is of type `FT_UInt',
+ * but public `FT_Face->face_flags' is of type `FT_Long'.
+ *
+ * On long > int systems, higher bits of load_flags cannot be handled.
+ */
+#if FT_ULONG_MAX > FT_UINT_MAX
if ( load_flags > FT_UINT_MAX )
FT_TRACE1(( "FTC_ImageCache_LookupScaler:"
" higher bits in load_flags 0x%x are dropped\n",
load_flags & ~((FT_ULong)FT_UINT_MAX) ));
+#endif
query.attrs.scaler = scaler[0];
query.attrs.load_flags = (FT_UInt)load_flags;
@@ -419,11 +437,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 +452,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
};
@@ -482,10 +502,18 @@
*ansbit = NULL;
- if ( (FT_ULong)( type->flags - FT_INT_MIN ) > FT_UINT_MAX )
+ /*
+ * Internal `FTC_BasicAttr->load_flags' is of type `FT_UInt',
+ * but public `FT_ImageType->flags' is of type `FT_Int32'.
+ *
+ * On 16bit systems, higher bits of type->flags cannot be handled.
+ */
+#if 0xFFFFFFFFUL > FT_UINT_MAX
+ if ( (type->flags & (FT_ULong)FT_UINT_MAX) )
FT_TRACE1(( "FTC_ImageCache_Lookup:"
" higher bits in load_flags 0x%x are dropped\n",
(FT_ULong)type->flags & ~((FT_ULong)FT_UINT_MAX) ));
+#endif
query.attrs.scaler.face_id = type->face_id;
query.attrs.scaler.width = type->width;
@@ -557,11 +585,18 @@
*ansbit = NULL;
- /* `FT_Load_Glyph' and `FT_Load_Char' take FT_UInt flags */
+ /*
+ * Internal `FTC_BasicAttr->load_flags' is of type `FT_UInt',
+ * but public `FT_Face->face_flags' is of type `FT_Long'.
+ *
+ * On long > int systems, higher bits of load_flags cannot be handled.
+ */
+#if FT_ULONG_MAX > FT_UINT_MAX
if ( load_flags > FT_UINT_MAX )
FT_TRACE1(( "FTC_ImageCache_LookupScaler:"
" higher bits in load_flags 0x%x are dropped\n",
load_flags & ~((FT_ULong)FT_UINT_MAX) ));
+#endif
query.attrs.scaler = scaler[0];
query.attrs.load_flags = (FT_UInt)load_flags;
diff --git a/src/3rdparty/freetype/src/cache/ftccache.c b/src/3rdparty/freetype/src/cache/ftccache.c
index d8c5b99681..12ec585a25 100644
--- a/src/3rdparty/freetype/src/cache/ftccache.c
+++ b/src/3rdparty/freetype/src/cache/ftccache.c
@@ -4,7 +4,7 @@
/* */
/* The FreeType internal cache interface (body). */
/* */
-/* Copyright 2000-2015 by */
+/* Copyright 2000-2018 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -85,7 +85,7 @@
/* get a top bucket for specified hash from cache,
- * body for FTC_NODE__TOP_FOR_HASH( cache, hash )
+ * body for FTC_NODE_TOP_FOR_HASH( cache, hash )
*/
FT_LOCAL_DEF( FTC_Node* )
ftc_get_top_node_for_hash( FTC_Cache cache,
@@ -147,7 +147,7 @@
for (;;)
{
node = *pnode;
- if ( node == NULL )
+ if ( !node )
break;
if ( node->hash & ( mask + 1 ) )
@@ -224,7 +224,7 @@
ftc_node_hash_unlink( FTC_Node node0,
FTC_Cache cache )
{
- FTC_Node *pnode = FTC_NODE__TOP_FOR_HASH( cache, node0->hash );
+ FTC_Node *pnode = FTC_NODE_TOP_FOR_HASH( cache, node0->hash );
for (;;)
@@ -232,7 +232,7 @@
FTC_Node node = *pnode;
- if ( node == NULL )
+ if ( !node )
{
FT_TRACE0(( "ftc_node_hash_unlink: unknown node\n" ));
return;
@@ -257,7 +257,7 @@
ftc_node_hash_link( FTC_Node node,
FTC_Cache cache )
{
- FTC_Node *pnode = FTC_NODE__TOP_FOR_HASH( cache, node->hash );
+ FTC_Node *pnode = FTC_NODE_TOP_FOR_HASH( cache, node->hash );
node->link = *pnode;
@@ -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,18 +494,18 @@
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 */
- bucket = pnode = FTC_NODE__TOP_FOR_HASH( cache, hash );
+ bucket = pnode = FTC_NODE_TOP_FOR_HASH( cache, hash );
/* Lookup a node with exactly same hash and queried properties. */
/* NOTE: _nodcomp() may change the linked list to reduce memory. */
for (;;)
{
node = *pnode;
- if ( node == NULL )
+ if ( !node )
goto NewNode;
if ( node->hash == hash &&
@@ -518,12 +518,12 @@
if ( list_changed )
{
/* Update bucket by modified linked list */
- bucket = pnode = FTC_NODE__TOP_FOR_HASH( cache, hash );
+ bucket = pnode = FTC_NODE_TOP_FOR_HASH( cache, hash );
/* 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;
@@ -576,13 +576,13 @@
FTC_Node* pnode = bucket;
- for ( ;; )
+ for (;;)
{
FTC_Node node = *pnode;
FT_Bool list_changed = FALSE;
- if ( node == NULL )
+ if ( !node )
break;
if ( cache->clazz.node_remove_faceid( node, face_id,
diff --git a/src/3rdparty/freetype/src/cache/ftccache.h b/src/3rdparty/freetype/src/cache/ftccache.h
index 4e17c7afef..859c547e46 100644
--- a/src/3rdparty/freetype/src/cache/ftccache.h
+++ b/src/3rdparty/freetype/src/cache/ftccache.h
@@ -4,7 +4,7 @@
/* */
/* FreeType internal cache interface (specification). */
/* */
-/* Copyright 2000-2015 by */
+/* Copyright 2000-2018 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -16,16 +16,16 @@
/***************************************************************************/
-#ifndef __FTCCACHE_H__
-#define __FTCCACHE_H__
+#ifndef FTCCACHE_H_
+#define FTCCACHE_H_
#include "ftcmru.h"
FT_BEGIN_HEADER
-#define _FTC_FACE_ID_HASH( i ) \
- ( ( (FT_Offset)(i) >> 3 ) ^ ( (FT_Offset)(i) << 7 ) )
+#define FTC_FACE_ID_HASH( i ) \
+ ( ( (FT_Offset)(i) >> 3 ) ^ ( (FT_Offset)(i) << 7 ) )
/* handle to cache object */
typedef struct FTC_CacheRec_* FTC_Cache;
@@ -69,11 +69,11 @@ FT_BEGIN_HEADER
#define FTC_NODE( x ) ( (FTC_Node)(x) )
#define FTC_NODE_P( x ) ( (FTC_Node*)(x) )
-#define FTC_NODE__NEXT( x ) FTC_NODE( (x)->mru.next )
-#define FTC_NODE__PREV( x ) FTC_NODE( (x)->mru.prev )
+#define FTC_NODE_NEXT( x ) FTC_NODE( (x)->mru.next )
+#define FTC_NODE_PREV( x ) FTC_NODE( (x)->mru.prev )
#ifdef FTC_INLINE
-#define FTC_NODE__TOP_FOR_HASH( cache, hash ) \
+#define FTC_NODE_TOP_FOR_HASH( cache, hash ) \
( ( cache )->buckets + \
( ( ( ( hash ) & ( cache )->mask ) < ( cache )->p ) \
? ( ( hash ) & ( ( cache )->mask * 2 + 1 ) ) \
@@ -82,7 +82,7 @@ FT_BEGIN_HEADER
FT_LOCAL( FTC_Node* )
ftc_get_top_node_for_hash( FTC_Cache cache,
FT_Offset hash );
-#define FTC_NODE__TOP_FOR_HASH( cache, hash ) \
+#define FTC_NODE_TOP_FOR_HASH( cache, hash ) \
ftc_get_top_node_for_hash( ( cache ), ( hash ) )
#endif
@@ -220,15 +220,15 @@ FT_BEGIN_HEADER
node = NULL; \
\
/* Go to the `top' node of the list sharing same masked hash */ \
- _bucket = _pnode = FTC_NODE__TOP_FOR_HASH( _cache, _hash ); \
+ _bucket = _pnode = FTC_NODE_TOP_FOR_HASH( _cache, _hash ); \
\
/* Look up a node with identical hash and queried properties. */ \
/* NOTE: _nodcomp() may change the linked list to reduce memory. */ \
for (;;) \
{ \
_node = *_pnode; \
- if ( _node == NULL ) \
- goto _NewNode; \
+ if ( !_node ) \
+ goto NewNode_; \
\
if ( _node->hash == _hash && \
_nodcomp( _node, query, _cache, &_list_changed ) ) \
@@ -240,15 +240,15 @@ FT_BEGIN_HEADER
if ( _list_changed ) \
{ \
/* Update _bucket by possibly modified linked list */ \
- _bucket = _pnode = FTC_NODE__TOP_FOR_HASH( _cache, _hash ); \
+ _bucket = _pnode = FTC_NODE_TOP_FOR_HASH( _cache, _hash ); \
\
/* 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; \
+ goto NewNode_; \
} \
else \
_pnode = &((*_pnode)->link); \
@@ -273,12 +273,12 @@ FT_BEGIN_HEADER
FTC_MruNode_Up( (FTC_MruNode*)_nl, \
(FTC_MruNode)_node ); \
} \
- goto _Ok; \
+ goto Ok_; \
\
- _NewNode: \
+ NewNode_: \
error = FTC_Cache_NewNode( _cache, _hash, query, &_node ); \
\
- _Ok: \
+ Ok_: \
node = _node; \
FT_END_STMNT
@@ -325,7 +325,7 @@ FT_BEGIN_HEADER
break; \
\
_try_done = FTC_Manager_FlushN( _try_manager, _try_count ); \
- if ( _try_done > 0 && ( list_changed ) ) \
+ if ( _try_done > 0 && list_changed != NULL ) \
*(FT_Bool*)( list_changed ) = TRUE; \
\
if ( _try_done == 0 ) \
@@ -346,7 +346,7 @@ FT_BEGIN_HEADER
FT_END_HEADER
-#endif /* __FTCCACHE_H__ */
+#endif /* FTCCACHE_H_ */
/* END */
diff --git a/src/3rdparty/freetype/src/cache/ftccback.h b/src/3rdparty/freetype/src/cache/ftccback.h
index b3237d5a3f..e51d8d6e55 100644
--- a/src/3rdparty/freetype/src/cache/ftccback.h
+++ b/src/3rdparty/freetype/src/cache/ftccback.h
@@ -4,7 +4,7 @@
/* */
/* Callback functions of the caching sub-system (specification only). */
/* */
-/* Copyright 2004-2015 by */
+/* Copyright 2004-2018 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 @@
/* */
/***************************************************************************/
-#ifndef __FTCCBACK_H__
-#define __FTCCBACK_H__
+#ifndef FTCCBACK_H_
+#define FTCCBACK_H_
#include <ft2build.h>
#include FT_CACHE_H
@@ -86,6 +86,7 @@
FTC_Manager manager );
-#endif /* __FTCCBACK_H__ */
+#endif /* FTCCBACK_H_ */
+
/* END */
diff --git a/src/3rdparty/freetype/src/cache/ftccmap.c b/src/3rdparty/freetype/src/cache/ftccmap.c
index b8262220c4..d20b0f48fe 100644
--- a/src/3rdparty/freetype/src/cache/ftccmap.c
+++ b/src/3rdparty/freetype/src/cache/ftccmap.c
@@ -4,7 +4,7 @@
/* */
/* FreeType CharMap cache (body) */
/* */
-/* Copyright 2000-2015 by */
+/* Copyright 2000-2018 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -50,7 +50,7 @@
/* compute a query/node hash */
#define FTC_CMAP_HASH( faceid, index, charcode ) \
- ( _FTC_FACE_ID_HASH( faceid ) + 211 * (index) + \
+ ( FTC_FACE_ID_HASH( faceid ) + 211 * (index) + \
( (charcode) / FTC_CMAP_INDICES_MAX ) )
/* the charmap query */
@@ -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 */
};
@@ -259,9 +259,6 @@
return 0;
}
- if ( !face_id )
- return 0;
-
query.face_id = face_id;
query.cmap_index = (FT_UInt)cmap_index;
query.char_code = char_code;
diff --git a/src/3rdparty/freetype/src/cache/ftcerror.h b/src/3rdparty/freetype/src/cache/ftcerror.h
index 15adec58de..a26cd5935b 100644
--- a/src/3rdparty/freetype/src/cache/ftcerror.h
+++ b/src/3rdparty/freetype/src/cache/ftcerror.h
@@ -4,7 +4,7 @@
/* */
/* Caching sub-system error codes (specification only). */
/* */
-/* Copyright 2001-2015 by */
+/* Copyright 2001-2018 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -23,12 +23,12 @@
/* */
/*************************************************************************/
-#ifndef __FTCERROR_H__
-#define __FTCERROR_H__
+#ifndef FTCERROR_H_
+#define FTCERROR_H_
#include FT_MODULE_ERRORS_H
-#undef __FTERRORS_H__
+#undef FTERRORS_H_
#undef FT_ERR_PREFIX
#define FT_ERR_PREFIX FTC_Err_
@@ -36,6 +36,7 @@
#include FT_ERRORS_H
-#endif /* __FTCERROR_H__ */
+#endif /* FTCERROR_H_ */
+
/* END */
diff --git a/src/3rdparty/freetype/src/cache/ftcglyph.c b/src/3rdparty/freetype/src/cache/ftcglyph.c
index 343b8a7793..782cc0ed09 100644
--- a/src/3rdparty/freetype/src/cache/ftcglyph.c
+++ b/src/3rdparty/freetype/src/cache/ftcglyph.c
@@ -4,7 +4,7 @@
/* */
/* FreeType Glyph Image (FT_Glyph) cache (body). */
/* */
-/* Copyright 2000-2015 by */
+/* Copyright 2000-2018 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 @@
FTC_Family_Init( FTC_Family family,
FTC_Cache cache )
{
- FTC_GCacheClass clazz = FTC_CACHE__GCACHE_CLASS( cache );
+ FTC_GCacheClass clazz = FTC_CACHE_GCACHE_CLASS( cache );
family->clazz = clazz->family_class;
diff --git a/src/3rdparty/freetype/src/cache/ftcglyph.h b/src/3rdparty/freetype/src/cache/ftcglyph.h
index 6cadbe2c10..23c24d223f 100644
--- a/src/3rdparty/freetype/src/cache/ftcglyph.h
+++ b/src/3rdparty/freetype/src/cache/ftcglyph.h
@@ -4,7 +4,7 @@
/* */
/* FreeType abstract glyph cache (specification). */
/* */
-/* Copyright 2000-2015 by */
+/* Copyright 2000-2018 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -113,8 +113,8 @@
/*************************************************************************/
-#ifndef __FTCGLYPH_H__
-#define __FTCGLYPH_H__
+#ifndef FTCGLYPH_H_
+#define FTCGLYPH_H_
#include <ft2build.h>
@@ -245,10 +245,10 @@ FT_BEGIN_HEADER
#define FTC_GCACHE_CLASS( x ) ((FTC_GCacheClass)(x))
-#define FTC_CACHE__GCACHE_CLASS( x ) \
+#define FTC_CACHE_GCACHE_CLASS( x ) \
FTC_GCACHE_CLASS( FTC_CACHE(x)->org_class )
-#define FTC_CACHE__FAMILY_CLASS( x ) \
- ( (FTC_MruListClass)FTC_CACHE__GCACHE_CLASS( x )->family_class )
+#define FTC_CACHE_FAMILY_CLASS( x ) \
+ ( (FTC_MruListClass)FTC_CACHE_GCACHE_CLASS( x )->family_class )
/* convenience function; use it instead of FTC_Manager_Register_Cache */
@@ -323,7 +323,7 @@ FT_BEGIN_HEADER
FT_END_HEADER
-#endif /* __FTCGLYPH_H__ */
+#endif /* FTCGLYPH_H_ */
/* END */
diff --git a/src/3rdparty/freetype/src/cache/ftcimage.c b/src/3rdparty/freetype/src/cache/ftcimage.c
index f519a6179c..77a100153e 100644
--- a/src/3rdparty/freetype/src/cache/ftcimage.c
+++ b/src/3rdparty/freetype/src/cache/ftcimage.c
@@ -4,7 +4,7 @@
/* */
/* FreeType Image cache (body). */
/* */
-/* Copyright 2000-2015 by */
+/* Copyright 2000-2018 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 @@
FTC_GNode gnode = FTC_GNODE( inode );
FTC_Family family = gquery->family;
FT_UInt gindex = gquery->gindex;
- FTC_IFamilyClass clazz = FTC_CACHE__IFAMILY_CLASS( cache );
+ FTC_IFamilyClass clazz = FTC_CACHE_IFAMILY_CLASS( cache );
/* initialize its inner fields */
diff --git a/src/3rdparty/freetype/src/cache/ftcimage.h b/src/3rdparty/freetype/src/cache/ftcimage.h
index b312eaa3d9..24a221053b 100644
--- a/src/3rdparty/freetype/src/cache/ftcimage.h
+++ b/src/3rdparty/freetype/src/cache/ftcimage.h
@@ -4,7 +4,7 @@
/* */
/* FreeType Generic Image cache (specification) */
/* */
-/* Copyright 2000-2015 by */
+/* Copyright 2000-2018 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -32,8 +32,8 @@
/*************************************************************************/
-#ifndef __FTCIMAGE_H__
-#define __FTCIMAGE_H__
+#ifndef FTCIMAGE_H_
+#define FTCIMAGE_H_
#include <ft2build.h>
@@ -72,8 +72,8 @@ FT_BEGIN_HEADER
#define FTC_IFAMILY_CLASS( x ) ((FTC_IFamilyClass)(x))
-#define FTC_CACHE__IFAMILY_CLASS( x ) \
- FTC_IFAMILY_CLASS( FTC_CACHE__GCACHE_CLASS(x)->family_class )
+#define FTC_CACHE_IFAMILY_CLASS( x ) \
+ FTC_IFAMILY_CLASS( FTC_CACHE_GCACHE_CLASS(x)->family_class )
/* can be used as a @FTC_Node_FreeFunc */
@@ -101,7 +101,7 @@ FT_BEGIN_HEADER
FT_END_HEADER
-#endif /* __FTCIMAGE_H__ */
+#endif /* FTCIMAGE_H_ */
/* END */
diff --git a/src/3rdparty/freetype/src/cache/ftcmanag.c b/src/3rdparty/freetype/src/cache/ftcmanag.c
index 658614c8db..2bcd9df502 100644
--- a/src/3rdparty/freetype/src/cache/ftcmanag.c
+++ b/src/3rdparty/freetype/src/cache/ftcmanag.c
@@ -4,7 +4,7 @@
/* */
/* FreeType Cache Manager (body). */
/* */
-/* Copyright 2000-2015 by */
+/* Copyright 2000-2018 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 */
};
@@ -314,7 +315,7 @@
FTC_MruNode mrunode;
- if ( !aface || !face_id )
+ if ( !aface )
return FT_THROW( Invalid_Argument );
*aface = NULL;
@@ -494,7 +495,7 @@
else
weight += cache->clazz.node_weight( node, cache );
- node = FTC_NODE__NEXT( node );
+ node = FTC_NODE_NEXT( node );
} while ( node != first );
@@ -513,7 +514,7 @@
do
{
count++;
- node = FTC_NODE__NEXT( node );
+ node = FTC_NODE_NEXT( node );
} while ( node != first );
@@ -552,17 +553,17 @@
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 */
- node = FTC_NODE__PREV( first );
+ node = FTC_NODE_PREV( first );
do
{
FTC_Node prev;
- prev = ( node == first ) ? NULL : FTC_NODE__PREV( node );
+ prev = ( node == first ) ? NULL : FTC_NODE_PREV( node );
if ( node->ref_count <= 0 )
ftc_node_destroy( node, manager );
@@ -637,14 +638,14 @@
/* 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 */
- node = FTC_NODE__PREV(first);
+ node = FTC_NODE_PREV(first);
for ( result = 0; result < count; )
{
- FTC_Node prev = FTC_NODE__PREV( node );
+ FTC_Node prev = FTC_NODE_PREV( node );
/* don't touch locked nodes */
@@ -672,7 +673,7 @@
FT_UInt nn;
- if ( !manager || !face_id )
+ if ( !manager )
return;
/* this will remove all FTC_SizeNode that correspond to
diff --git a/src/3rdparty/freetype/src/cache/ftcmanag.h b/src/3rdparty/freetype/src/cache/ftcmanag.h
index c6787b72c5..b4b4755356 100644
--- a/src/3rdparty/freetype/src/cache/ftcmanag.h
+++ b/src/3rdparty/freetype/src/cache/ftcmanag.h
@@ -4,7 +4,7 @@
/* */
/* FreeType Cache Manager (specification). */
/* */
-/* Copyright 2000-2015 by */
+/* Copyright 2000-2018 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -59,8 +59,8 @@
/*************************************************************************/
-#ifndef __FTCMANAG_H__
-#define __FTCMANAG_H__
+#ifndef FTCMANAG_H_
+#define FTCMANAG_H_
#include <ft2build.h>
@@ -161,7 +161,7 @@ FT_BEGIN_HEADER
(a)->y_res == (b)->y_res ) ) )
#define FTC_SCALER_HASH( q ) \
- ( _FTC_FACE_ID_HASH( (q)->face_id ) + \
+ ( FTC_FACE_ID_HASH( (q)->face_id ) + \
(q)->width + (q)->height*7 + \
( (q)->pixel ? 0 : ( (q)->x_res*33 ^ (q)->y_res*61 ) ) )
@@ -169,7 +169,7 @@ FT_BEGIN_HEADER
FT_END_HEADER
-#endif /* __FTCMANAG_H__ */
+#endif /* FTCMANAG_H_ */
/* END */
diff --git a/src/3rdparty/freetype/src/cache/ftcmru.c b/src/3rdparty/freetype/src/cache/ftcmru.c
index 10ce4f301e..1087be4d89 100644
--- a/src/3rdparty/freetype/src/cache/ftcmru.c
+++ b/src/3rdparty/freetype/src/cache/ftcmru.c
@@ -4,7 +4,7 @@
/* */
/* FreeType MRU support (body). */
/* */
-/* Copyright 2003-2015 by */
+/* Copyright 2003-2018 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/src/3rdparty/freetype/src/cache/ftcmru.h b/src/3rdparty/freetype/src/cache/ftcmru.h
index c0c35f934b..82396b917d 100644
--- a/src/3rdparty/freetype/src/cache/ftcmru.h
+++ b/src/3rdparty/freetype/src/cache/ftcmru.h
@@ -4,7 +4,7 @@
/* */
/* Simple MRU list-cache (specification). */
/* */
-/* Copyright 2000-2015 by */
+/* Copyright 2000-2018 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -40,8 +40,8 @@
/*************************************************************************/
-#ifndef __FTCMRU_H__
-#define __FTCMRU_H__
+#ifndef FTCMRU_H_
+#define FTCMRU_H_
#include <ft2build.h>
@@ -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;
@@ -181,15 +183,15 @@ FT_BEGIN_HEADER
FTC_MruNode_Up( _pfirst, _node ); \
\
node = _node; \
- goto _MruOk; \
+ goto MruOk_; \
} \
_node = _node->next; \
\
- } while ( _node != _first) ; \
+ } while ( _node != _first); \
} \
\
error = FTC_MruList_New( (list), (key), (FTC_MruNode*)(void*)&(node) ); \
- _MruOk: \
+ MruOk_: \
; \
FT_END_STMNT
@@ -240,7 +242,7 @@ FT_BEGIN_HEADER
FT_END_HEADER
-#endif /* __FTCMRU_H__ */
+#endif /* FTCMRU_H_ */
/* END */
diff --git a/src/3rdparty/freetype/src/cache/ftcsbits.c b/src/3rdparty/freetype/src/cache/ftcsbits.c
index 8141719167..018f1ecdb7 100644
--- a/src/3rdparty/freetype/src/cache/ftcsbits.c
+++ b/src/3rdparty/freetype/src/cache/ftcsbits.c
@@ -4,7 +4,7 @@
/* */
/* FreeType sbits manager (body). */
/* */
-/* Copyright 2000-2015 by */
+/* Copyright 2000-2018 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -53,6 +53,8 @@
pitch = -pitch;
size = (FT_ULong)pitch * bitmap->rows;
+ if ( !size )
+ return FT_Err_Ok;
if ( !FT_ALLOC( sbit->buffer, size ) )
FT_MEM_COPY( sbit->buffer, bitmap->buffer, size );
@@ -215,7 +217,7 @@
FT_UInt gindex = gquery->gindex;
FTC_Family family = gquery->family;
- FTC_SFamilyClass clazz = FTC_CACHE__SFAMILY_CLASS( cache );
+ FTC_SFamilyClass clazz = FTC_CACHE_SFAMILY_CLASS( cache );
FT_UInt total;
FT_UInt node_count;
@@ -376,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/src/3rdparty/freetype/src/cache/ftcsbits.h b/src/3rdparty/freetype/src/cache/ftcsbits.h
index 5a2fa1ac80..206a1bb3fc 100644
--- a/src/3rdparty/freetype/src/cache/ftcsbits.h
+++ b/src/3rdparty/freetype/src/cache/ftcsbits.h
@@ -4,7 +4,7 @@
/* */
/* A small-bitmap cache (specification). */
/* */
-/* Copyright 2000-2015 by */
+/* Copyright 2000-2018 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -16,8 +16,8 @@
/***************************************************************************/
-#ifndef __FTCSBITS_H__
-#define __FTCSBITS_H__
+#ifndef FTCSBITS_H_
+#define FTCSBITS_H_
#include <ft2build.h>
@@ -64,8 +64,8 @@ FT_BEGIN_HEADER
#define FTC_SFAMILY_CLASS( x ) ((FTC_SFamilyClass)(x))
-#define FTC_CACHE__SFAMILY_CLASS( x ) \
- FTC_SFAMILY_CLASS( FTC_CACHE__GCACHE_CLASS( x )->family_class )
+#define FTC_CACHE_SFAMILY_CLASS( x ) \
+ FTC_SFAMILY_CLASS( FTC_CACHE_GCACHE_CLASS( x )->family_class )
FT_LOCAL( void )
@@ -97,7 +97,7 @@ FT_BEGIN_HEADER
FT_END_HEADER
-#endif /* __FTCSBITS_H__ */
+#endif /* FTCSBITS_H_ */
/* END */
diff --git a/src/3rdparty/freetype/src/cache/rules.mk b/src/3rdparty/freetype/src/cache/rules.mk
index 6d5cf344b3..558935976d 100644
--- a/src/3rdparty/freetype/src/cache/rules.mk
+++ b/src/3rdparty/freetype/src/cache/rules.mk
@@ -3,7 +3,7 @@
#
-# Copyright 2000-2015 by
+# Copyright 2000-2018 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/src/3rdparty/freetype/src/cff/Jamfile b/src/3rdparty/freetype/src/cff/Jamfile
index deec0792ce..53c904fcfe 100644
--- a/src/3rdparty/freetype/src/cff/Jamfile
+++ b/src/3rdparty/freetype/src/cff/Jamfile
@@ -1,6 +1,6 @@
# FreeType 2 src/cff Jamfile
#
-# Copyright 2001-2015 by
+# Copyright 2001-2018 by
# David Turner, Robert Wilhelm, and Werner Lemberg.
#
# This file is part of the FreeType project, and may only be used, modified,
@@ -23,15 +23,6 @@ SubDir FT2_TOP $(FT2_SRC_DIR) cff ;
cffobjs
cffparse
cffpic
- cf2arrst
- cf2blues
- cf2error
- cf2font
- cf2ft
- cf2hints
- cf2intrp
- cf2read
- cf2stack
;
}
else
diff --git a/src/3rdparty/freetype/src/cff/cff.c b/src/3rdparty/freetype/src/cff/cff.c
index bb2cfb5253..1a755d5dad 100644
--- a/src/3rdparty/freetype/src/cff/cff.c
+++ b/src/3rdparty/freetype/src/cff/cff.c
@@ -4,7 +4,7 @@
/* */
/* FreeType OpenType driver component (body only). */
/* */
-/* Copyright 1996-2015 by */
+/* Copyright 1996-2018 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -17,25 +17,14 @@
#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"
-#include "cf2error.c"
-#include "cf2font.c"
-#include "cf2ft.c"
-#include "cf2hints.c"
-#include "cf2intrp.c"
-#include "cf2read.c"
-#include "cf2stack.c"
/* END */
diff --git a/src/3rdparty/freetype/src/cff/cffcmap.c b/src/3rdparty/freetype/src/cff/cffcmap.c
index e7538e9840..e45ae1127b 100644
--- a/src/3rdparty/freetype/src/cff/cffcmap.c
+++ b/src/3rdparty/freetype/src/cff/cffcmap.c
@@ -4,7 +4,7 @@
/* */
/* CFF character mapping table (cmap) support (body). */
/* */
-/* Copyright 2002-2015 by */
+/* Copyright 2002-2018 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/src/3rdparty/freetype/src/cff/cffcmap.h b/src/3rdparty/freetype/src/cff/cffcmap.h
index 6eaed636ec..856a43dd1b 100644
--- a/src/3rdparty/freetype/src/cff/cffcmap.h
+++ b/src/3rdparty/freetype/src/cff/cffcmap.h
@@ -4,7 +4,7 @@
/* */
/* CFF character mapping table (cmap) support (specification). */
/* */
-/* Copyright 2002-2015 by */
+/* Copyright 2002-2018 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -16,10 +16,10 @@
/***************************************************************************/
-#ifndef __CFFCMAP_H__
-#define __CFFCMAP_H__
+#ifndef CFFCMAP_H_
+#define CFFCMAP_H_
-#include "cffobjs.h"
+#include FT_INTERNAL_CFF_OBJECTS_TYPES_H
FT_BEGIN_HEADER
@@ -61,7 +61,7 @@ FT_BEGIN_HEADER
FT_END_HEADER
-#endif /* __CFFCMAP_H__ */
+#endif /* CFFCMAP_H_ */
/* END */
diff --git a/src/3rdparty/freetype/src/cff/cffdrivr.c b/src/3rdparty/freetype/src/cff/cffdrivr.c
index a718b7a002..df896848da 100644
--- a/src/3rdparty/freetype/src/cff/cffdrivr.c
+++ b/src/3rdparty/freetype/src/cff/cffdrivr.c
@@ -4,7 +4,7 @@
/* */
/* OpenType font driver implementation (body). */
/* */
-/* Copyright 1996-2015 by */
+/* Copyright 1996-2018 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -21,16 +21,25 @@
#include FT_INTERNAL_DEBUG_H
#include FT_INTERNAL_STREAM_H
#include FT_INTERNAL_SFNT_H
+#include FT_INTERNAL_POSTSCRIPT_AUX_H
+#include FT_INTERNAL_POSTSCRIPT_PROPS_H
#include FT_SERVICE_CID_H
#include FT_SERVICE_POSTSCRIPT_INFO_H
#include FT_SERVICE_POSTSCRIPT_NAME_H
#include FT_SERVICE_TT_CMAP_H
+#include FT_SERVICE_CFF_TABLE_LOAD_H
#include "cffdrivr.h"
#include "cffgload.h"
#include "cffload.h"
#include "cffcmap.h"
#include "cffparse.h"
+#include "cffobjs.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"
@@ -38,7 +47,7 @@
#include FT_SERVICE_FONT_FORMAT_H
#include FT_SERVICE_GLYPH_DICT_H
#include FT_SERVICE_PROPERTIES_H
-#include FT_CFF_DRIVER_H
+#include FT_DRIVER_H
/*************************************************************************/
@@ -207,6 +216,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 ( ( FT_IS_NAMED_INSTANCE( face ) || FT_IS_VARIATION( face ) ) &&
+ !( 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' */
@@ -225,13 +241,22 @@
&dummy,
&ah );
- FT_TRACE5(( " idx %d: advance height %d font units\n",
- start + nn, ah ));
+ FT_TRACE5(( " idx %d: advance height %d font unit%s\n",
+ start + nn,
+ ah,
+ ah == 1 ? "" : "s" ));
advances[nn] = ah;
}
}
else
{
+#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
+ /* no fast retrieval for blended MM fonts without HVAR table */
+ if ( ( FT_IS_NAMED_INSTANCE( face ) || FT_IS_VARIATION( face ) ) &&
+ !( 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;
@@ -247,8 +272,10 @@
&dummy,
&aw );
- FT_TRACE5(( " idx %d: advance width %d font units\n",
- start + nn, aw ));
+ FT_TRACE5(( " idx %d: advance width %d font unit%s\n",
+ start + nn,
+ aw,
+ aw == 1 ? "" : "s" ));
advances[nn] = aw;
}
}
@@ -291,6 +318,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 +388,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,8 +439,9 @@
FT_DEFINE_SERVICE_GLYPHDICTREC(
cff_service_glyph_dict,
- (FT_GlyphDict_GetNameFunc) cff_get_glyph_name,
- (FT_GlyphDict_NameIndexFunc)cff_get_name_index
+
+ (FT_GlyphDict_GetNameFunc) cff_get_glyph_name, /* get_name */
+ (FT_GlyphDict_NameIndexFunc)cff_get_name_index /* name_index */
)
@@ -383,11 +465,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 ) ) )
@@ -419,13 +501,94 @@
}
+ static FT_Error
+ cff_ps_get_font_extra( CFF_Face face,
+ PS_FontExtraRec* afont_extra )
+ {
+ CFF_Font cff = (CFF_Font)face->extra.data;
+ FT_Error error = FT_Err_Ok;
+
+
+ if ( cff && cff->font_extra == NULL )
+ {
+ CFF_FontRecDict dict = &cff->top_font.font_dict;
+ PS_FontExtraRec* font_extra = NULL;
+ FT_Memory memory = face->root.memory;
+ FT_String* embedded_postscript;
+
+
+ if ( FT_ALLOC( font_extra, sizeof ( *font_extra ) ) )
+ goto Fail;
+
+ font_extra->fs_type = 0U;
+
+ embedded_postscript = cff_index_get_sid_string(
+ cff,
+ dict->embedded_postscript );
+ if ( embedded_postscript )
+ {
+ FT_String* start_fstype;
+ FT_String* start_def;
+
+
+ /* Identify the XYZ integer in `/FSType XYZ def' substring. */
+ if ( ( start_fstype = ft_strstr( embedded_postscript,
+ "/FSType" ) ) != NULL &&
+ ( start_def = ft_strstr( start_fstype +
+ sizeof ( "/FSType" ) - 1,
+ "def" ) ) != NULL )
+ {
+ FT_String* s;
+
+
+ for ( s = start_fstype + sizeof ( "/FSType" ) - 1;
+ s != start_def;
+ s++ )
+ {
+ if ( *s >= '0' && *s <= '9' )
+ {
+ if ( font_extra->fs_type >= ( FT_USHORT_MAX - 9 ) / 10 )
+ {
+ /* Overflow - ignore the FSType value. */
+ font_extra->fs_type = 0U;
+ break;
+ }
+
+ font_extra->fs_type *= 10;
+ font_extra->fs_type += (FT_UShort)( *s - '0' );
+ }
+ else if ( *s != ' ' && *s != '\n' && *s != '\r' )
+ {
+ /* Non-whitespace character between `/FSType' and next `def' */
+ /* - ignore the FSType value. */
+ font_extra->fs_type = 0U;
+ break;
+ }
+ }
+ }
+ }
+
+ cff->font_extra = font_extra;
+ }
+
+ if ( cff )
+ *afont_extra = *cff->font_extra;
+
+ Fail:
+ return error;
+ }
+
+
FT_DEFINE_SERVICE_PSINFOREC(
cff_service_ps_info,
- (PS_GetFontInfoFunc) cff_ps_get_font_info,
- (PS_GetFontExtraFunc) NULL,
- (PS_HasGlyphNamesFunc) cff_ps_has_glyph_names,
- (PS_GetFontPrivateFunc)NULL, /* unsupported with CFF fonts */
- (PS_GetFontValueFunc) NULL /* not implemented */
+
+ (PS_GetFontInfoFunc) cff_ps_get_font_info, /* ps_get_font_info */
+ (PS_GetFontExtraFunc) cff_ps_get_font_extra, /* ps_get_font_extra */
+ (PS_HasGlyphNamesFunc) cff_ps_has_glyph_names, /* ps_has_glyph_names */
+ /* unsupported with CFF fonts */
+ (PS_GetFontPrivateFunc)NULL, /* ps_get_font_private */
+ /* not implemented */
+ (PS_GetFontValueFunc) NULL /* ps_get_font_value */
)
@@ -444,14 +607,15 @@
/* following the OpenType specification 1.7, we return the name stored */
/* in the `name' table for a CFF wrapped into an SFNT container */
- if ( sfnt )
+ if ( FT_IS_SFNT( FT_FACE( face ) ) && sfnt )
{
FT_Library library = FT_FACE_LIBRARY( face );
FT_Module sfnt_module = FT_Get_Module( library, "sfnt" );
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 )
@@ -464,7 +628,8 @@
FT_DEFINE_SERVICE_PSFONTNAMEREC(
cff_service_ps_name,
- (FT_PsName_GetFunc)cff_get_ps_name
+
+ (FT_PsName_GetFunc)cff_get_ps_name /* get_ps_font_name */
)
@@ -489,21 +654,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;
}
@@ -511,7 +676,8 @@
FT_DEFINE_SERVICE_TTCMAPSREC(
cff_service_get_cmap_info,
- (TT_CMap_Info_GetFunc)cff_get_cmap_info
+
+ (TT_CMap_Info_GetFunc)cff_get_cmap_info /* get_cmap_info */
)
@@ -542,7 +708,7 @@
if ( registry )
{
- if ( cff->registry == NULL )
+ if ( !cff->registry )
cff->registry = cff_index_get_sid_string( cff,
dict->cid_registry );
*registry = cff->registry;
@@ -550,7 +716,7 @@
if ( ordering )
{
- if ( cff->ordering == NULL )
+ if ( !cff->ordering )
cff->ordering = cff_index_get_sid_string( cff,
dict->cid_ordering );
*ordering = cff->ordering;
@@ -641,9 +807,13 @@
FT_DEFINE_SERVICE_CIDREC(
cff_service_cid_info,
- (FT_CID_GetRegistryOrderingSupplementFunc)cff_get_ros,
- (FT_CID_GetIsInternallyCIDKeyedFunc) cff_get_is_cid,
- (FT_CID_GetCIDFromGlyphIndexFunc) cff_get_cid_from_glyph_index
+
+ (FT_CID_GetRegistryOrderingSupplementFunc)
+ cff_get_ros, /* get_ros */
+ (FT_CID_GetIsInternallyCIDKeyedFunc)
+ cff_get_is_cid, /* get_is_cid */
+ (FT_CID_GetCIDFromGlyphIndexFunc)
+ cff_get_cid_from_glyph_index /* get_cid_from_glyph_index */
)
@@ -651,133 +821,166 @@
* PROPERTY SERVICE
*
*/
+
+ FT_DEFINE_SERVICE_PROPERTIESREC(
+ cff_service_properties,
+
+ (FT_Properties_SetFunc)ps_property_set, /* set_property */
+ (FT_Properties_GetFunc)ps_property_get ) /* get_property */
+
+
+#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
+
+ /*
+ * MULTIPLE MASTER SERVICE
+ *
+ */
+
static FT_Error
- cff_property_set( FT_Module module, /* CFF_Driver */
- const char* property_name,
- const void* value )
+ cff_set_mm_blend( CFF_Face face,
+ FT_UInt num_coords,
+ FT_Fixed* coords )
{
- FT_Error error = FT_Err_Ok;
- CFF_Driver driver = (CFF_Driver)module;
+ FT_Service_MultiMasters mm = (FT_Service_MultiMasters)face->mm;
- if ( !ft_strcmp( property_name, "darkening-parameters" ) )
- {
- FT_Int* darken_params = (FT_Int*)value;
-
- 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];
-
-
- if ( x1 < 0 || x2 < 0 || x3 < 0 || x4 < 0 ||
- y1 < 0 || y2 < 0 || y3 < 0 || y4 < 0 ||
- x1 > x2 || x2 > x3 || x3 > x4 ||
- y1 > 500 || y2 > 500 || y3 > 500 || y4 > 500 )
- return FT_THROW( Invalid_Argument );
-
- driver->darken_params[0] = x1;
- driver->darken_params[1] = y1;
- driver->darken_params[2] = x2;
- driver->darken_params[3] = y2;
- driver->darken_params[4] = x3;
- driver->darken_params[5] = y3;
- driver->darken_params[6] = x4;
- driver->darken_params[7] = y4;
+ return mm->set_mm_blend( FT_FACE( face ), num_coords, coords );
+ }
- return error;
- }
- else if ( !ft_strcmp( property_name, "hinting-engine" ) )
- {
- FT_UInt* hinting_engine = (FT_UInt*)value;
+ 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;
-#ifndef CFF_CONFIG_OPTION_OLD_ENGINE
- if ( *hinting_engine != FT_CFF_HINTING_ADOBE )
- error = FT_ERR( Unimplemented_Feature );
- else
-#endif
- driver->hinting_engine = *hinting_engine;
- return error;
- }
- else if ( !ft_strcmp( property_name, "no-stem-darkening" ) )
- {
- FT_Bool* no_stem_darkening = (FT_Bool*)value;
+ return mm->get_mm_blend( FT_FACE( face ), num_coords, coords );
+ }
- driver->no_stem_darkening = *no_stem_darkening;
+ static FT_Error
+ cff_get_mm_var( CFF_Face face,
+ FT_MM_Var* *master )
+ {
+ FT_Service_MultiMasters mm = (FT_Service_MultiMasters)face->mm;
- return error;
- }
- FT_TRACE0(( "cff_property_set: missing property `%s'\n",
- property_name ));
- return FT_THROW( Missing_Property );
+ return mm->get_mm_var( FT_FACE( face ), master );
}
static FT_Error
- cff_property_get( FT_Module module, /* CFF_Driver */
- const char* property_name,
- const void* value )
+ cff_set_var_design( CFF_Face face,
+ FT_UInt num_coords,
+ FT_Fixed* coords )
{
- FT_Error error = FT_Err_Ok;
- CFF_Driver driver = (CFF_Driver)module;
+ FT_Service_MultiMasters mm = (FT_Service_MultiMasters)face->mm;
- if ( !ft_strcmp( property_name, "darkening-parameters" ) )
- {
- FT_Int* darken_params = driver->darken_params;
- FT_Int* val = (FT_Int*)value;
+ return mm->set_var_design( FT_FACE( face ), num_coords, coords );
+ }
- val[0] = darken_params[0];
- val[1] = darken_params[1];
- val[2] = darken_params[2];
- val[3] = darken_params[3];
- val[4] = darken_params[4];
- val[5] = darken_params[5];
- val[6] = darken_params[6];
- val[7] = darken_params[7];
+ 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 error;
- }
- else if ( !ft_strcmp( property_name, "hinting-engine" ) )
- {
- FT_UInt hinting_engine = driver->hinting_engine;
- FT_UInt* val = (FT_UInt*)value;
+ return mm->get_var_design( FT_FACE( face ), num_coords, coords );
+ }
- *val = hinting_engine;
- return error;
- }
- else if ( !ft_strcmp( property_name, "no-stem-darkening" ) )
- {
- FT_Bool no_stem_darkening = driver->no_stem_darkening;
- FT_Bool* val = (FT_Bool*)value;
+ static FT_Error
+ cff_set_instance( CFF_Face face,
+ FT_UInt instance_index )
+ {
+ FT_Service_MultiMasters mm = (FT_Service_MultiMasters)face->mm;
- *val = no_stem_darkening;
+ return mm->set_instance( FT_FACE( face ), instance_index );
+ }
- return error;
- }
- FT_TRACE0(( "cff_property_get: missing property `%s'\n",
- property_name ));
- return FT_THROW( Missing_Property );
+ 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_Set_Instance_Func) cff_set_instance, /* set_instance */
+
+ (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 );
}
- FT_DEFINE_SERVICE_PROPERTIESREC(
- cff_service_properties,
- (FT_Properties_SetFunc)cff_property_set,
- (FT_Properties_GetFunc)cff_property_get )
+ 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
+
+
+ /*
+ * CFFLOAD SERVICE
+ *
+ */
+
+ FT_DEFINE_SERVICE_CFFLOADREC(
+ cff_service_cff_load,
+
+ (FT_Get_Standard_Encoding_Func)cff_get_standard_encoding,
+ (FT_Load_Private_Dict_Func) cff_load_private_dict,
+ (FT_FD_Select_Get_Func) cff_fd_select_get,
+ (FT_Blend_Check_Vector_Func) cff_blend_check_vector,
+ (FT_Blend_Build_Vector_Func) cff_blend_build_vector
+ )
/*************************************************************************/
@@ -792,26 +995,60 @@
/*************************************************************************/
/*************************************************************************/
-#ifndef FT_CONFIG_OPTION_NO_GLYPH_NAMES
- FT_DEFINE_SERVICEDESCREC7(
+#if !defined FT_CONFIG_OPTION_NO_GLYPH_NAMES && \
+ defined TT_CONFIG_OPTION_GX_VAR_SUPPORT
+ FT_DEFINE_SERVICEDESCREC10(
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
+ FT_SERVICE_ID_PROPERTIES, &CFF_SERVICE_PROPERTIES_GET,
+ FT_SERVICE_ID_CFF_LOAD, &CFF_SERVICE_CFF_LOAD_GET
+ )
+#elif !defined FT_CONFIG_OPTION_NO_GLYPH_NAMES
+ FT_DEFINE_SERVICEDESCREC8(
+ 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,
+ 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,
+ FT_SERVICE_ID_CFF_LOAD, &CFF_SERVICE_CFF_LOAD_GET
+ )
+#elif 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_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,
+ FT_SERVICE_ID_CFF_LOAD, &CFF_SERVICE_CFF_LOAD_GET
)
#else
- FT_DEFINE_SERVICEDESCREC6(
+ 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,
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
+ FT_SERVICE_ID_PROPERTIES, &CFF_SERVICE_PROPERTIES_GET,
+ FT_SERVICE_ID_CFF_LOAD, &CFF_SERVICE_CFF_LOAD_GET
)
#endif
@@ -835,7 +1072,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 */
@@ -865,42 +1102,41 @@
FT_DEFINE_DRIVER(
cff_driver_class,
- FT_MODULE_FONT_DRIVER |
- FT_MODULE_DRIVER_SCALABLE |
- FT_MODULE_DRIVER_HAS_HINTER,
+ FT_MODULE_FONT_DRIVER |
+ FT_MODULE_DRIVER_SCALABLE |
+ FT_MODULE_DRIVER_HAS_HINTER |
+ FT_MODULE_DRIVER_HINTS_LIGHTLY,
- sizeof ( CFF_DriverRec ),
+ sizeof ( PS_DriverRec ),
"cff",
0x10000L,
0x20000L,
- 0, /* module-specific interface */
+ NULL, /* module-specific interface */
- cff_driver_init,
- cff_driver_done,
- cff_get_interface,
+ cff_driver_init, /* FT_Module_Constructor module_init */
+ cff_driver_done, /* FT_Module_Destructor module_done */
+ cff_get_interface, /* FT_Module_Requester get_interface */
- /* now the specific driver fields */
sizeof ( TT_FaceRec ),
sizeof ( CFF_SizeRec ),
sizeof ( CFF_GlyphSlotRec ),
- cff_face_init,
- cff_face_done,
- cff_size_init,
- cff_size_done,
- cff_slot_init,
- cff_slot_done,
-
- cff_glyph_load,
+ cff_face_init, /* FT_Face_InitFunc init_face */
+ cff_face_done, /* FT_Face_DoneFunc done_face */
+ cff_size_init, /* FT_Size_InitFunc init_size */
+ cff_size_done, /* FT_Size_DoneFunc done_size */
+ cff_slot_init, /* FT_Slot_InitFunc init_slot */
+ cff_slot_done, /* FT_Slot_DoneFunc done_slot */
- cff_get_kerning,
- 0, /* FT_Face_AttachFunc */
- cff_get_advances,
+ cff_glyph_load, /* FT_Slot_LoadFunc load_glyph */
- cff_size_request,
+ cff_get_kerning, /* FT_Face_GetKerningFunc get_kerning */
+ NULL, /* FT_Face_AttachFunc attach_file */
+ cff_get_advances, /* FT_Face_GetAdvancesFunc get_advances */
- CFF_SIZE_SELECT
+ cff_size_request, /* FT_Size_RequestFunc request_size */
+ CFF_SIZE_SELECT /* FT_Size_SelectFunc select_size */
)
diff --git a/src/3rdparty/freetype/src/cff/cffdrivr.h b/src/3rdparty/freetype/src/cff/cffdrivr.h
index 9527f5e149..ad7c3ad70a 100644
--- a/src/3rdparty/freetype/src/cff/cffdrivr.h
+++ b/src/3rdparty/freetype/src/cff/cffdrivr.h
@@ -4,7 +4,7 @@
/* */
/* High-level OpenType driver interface (specification). */
/* */
-/* Copyright 1996-2015 by */
+/* Copyright 1996-2018 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -16,8 +16,8 @@
/***************************************************************************/
-#ifndef __CFFDRIVER_H__
-#define __CFFDRIVER_H__
+#ifndef CFFDRIVER_H_
+#define CFFDRIVER_H_
#include <ft2build.h>
@@ -32,7 +32,7 @@ FT_BEGIN_HEADER
FT_END_HEADER
-#endif /* __CFFDRIVER_H__ */
+#endif /* CFFDRIVER_H_ */
/* END */
diff --git a/src/3rdparty/freetype/src/cff/cfferrs.h b/src/3rdparty/freetype/src/cff/cfferrs.h
index 543bdb07c2..b2e1bfaf9d 100644
--- a/src/3rdparty/freetype/src/cff/cfferrs.h
+++ b/src/3rdparty/freetype/src/cff/cfferrs.h
@@ -4,7 +4,7 @@
/* */
/* CFF error codes (specification only). */
/* */
-/* Copyright 2001-2015 by */
+/* Copyright 2001-2018 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -22,12 +22,12 @@
/* */
/*************************************************************************/
-#ifndef __CFFERRS_H__
-#define __CFFERRS_H__
+#ifndef CFFERRS_H_
+#define CFFERRS_H_
#include FT_MODULE_ERRORS_H
-#undef __FTERRORS_H__
+#undef FTERRORS_H_
#undef FT_ERR_PREFIX
#define FT_ERR_PREFIX CFF_Err_
@@ -36,7 +36,7 @@
#include FT_ERRORS_H
-#endif /* __CFFERRS_H__ */
+#endif /* CFFERRS_H_ */
/* END */
diff --git a/src/3rdparty/freetype/src/cff/cffgload.c b/src/3rdparty/freetype/src/cff/cffgload.c
index 5f57403e22..c58471ce86 100644
--- a/src/3rdparty/freetype/src/cff/cffgload.c
+++ b/src/3rdparty/freetype/src/cff/cffgload.c
@@ -4,7 +4,7 @@
/* */
/* OpenType Glyph Loader (body). */
/* */
-/* Copyright 1996-2015 by */
+/* Copyright 1996-2018 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -20,13 +20,13 @@
#include FT_INTERNAL_DEBUG_H
#include FT_INTERNAL_STREAM_H
#include FT_INTERNAL_SFNT_H
+#include FT_INTERNAL_CALC_H
+#include FT_INTERNAL_POSTSCRIPT_AUX_H
#include FT_OUTLINE_H
-#include FT_CFF_DRIVER_H
+#include FT_DRIVER_H
-#include "cffobjs.h"
#include "cffload.h"
#include "cffgload.h"
-#include "cf2ft.h" /* for cf2_decoder_parse_charstrings */
#include "cfferrs.h"
@@ -41,618 +41,6 @@
#define FT_COMPONENT trace_cffgload
-#ifdef CFF_CONFIG_OPTION_OLD_ENGINE
-
- typedef enum CFF_Operator_
- {
- cff_op_unknown = 0,
-
- cff_op_rmoveto,
- cff_op_hmoveto,
- cff_op_vmoveto,
-
- cff_op_rlineto,
- cff_op_hlineto,
- cff_op_vlineto,
-
- cff_op_rrcurveto,
- cff_op_hhcurveto,
- cff_op_hvcurveto,
- cff_op_rcurveline,
- cff_op_rlinecurve,
- cff_op_vhcurveto,
- cff_op_vvcurveto,
-
- cff_op_flex,
- cff_op_hflex,
- cff_op_hflex1,
- cff_op_flex1,
-
- cff_op_endchar,
-
- cff_op_hstem,
- cff_op_vstem,
- cff_op_hstemhm,
- cff_op_vstemhm,
-
- cff_op_hintmask,
- cff_op_cntrmask,
- cff_op_dotsection, /* deprecated, acts as no-op */
-
- cff_op_abs,
- cff_op_add,
- cff_op_sub,
- cff_op_div,
- cff_op_neg,
- cff_op_random,
- cff_op_mul,
- cff_op_sqrt,
-
- cff_op_blend,
-
- cff_op_drop,
- cff_op_exch,
- cff_op_index,
- cff_op_roll,
- cff_op_dup,
-
- cff_op_put,
- cff_op_get,
- cff_op_store,
- cff_op_load,
-
- cff_op_and,
- cff_op_or,
- cff_op_not,
- cff_op_eq,
- cff_op_ifelse,
-
- cff_op_callsubr,
- cff_op_callgsubr,
- cff_op_return,
-
- /* Type 1 opcodes: invalid but seen in real life */
- cff_op_hsbw,
- cff_op_closepath,
- cff_op_callothersubr,
- cff_op_pop,
- cff_op_seac,
- cff_op_sbw,
- cff_op_setcurrentpoint,
-
- /* do not remove */
- cff_op_max
-
- } CFF_Operator;
-
-
-#define CFF_COUNT_CHECK_WIDTH 0x80
-#define CFF_COUNT_EXACT 0x40
-#define CFF_COUNT_CLEAR_STACK 0x20
-
- /* count values which have the `CFF_COUNT_CHECK_WIDTH' flag set are */
- /* used for checking the width and requested numbers of arguments */
- /* only; they are set to zero afterwards */
-
- /* the other two flags are informative only and unused currently */
-
- static const FT_Byte cff_argument_counts[] =
- {
- 0, /* unknown */
-
- 2 | CFF_COUNT_CHECK_WIDTH | CFF_COUNT_EXACT, /* rmoveto */
- 1 | CFF_COUNT_CHECK_WIDTH | CFF_COUNT_EXACT,
- 1 | CFF_COUNT_CHECK_WIDTH | CFF_COUNT_EXACT,
-
- 0 | CFF_COUNT_CLEAR_STACK, /* rlineto */
- 0 | CFF_COUNT_CLEAR_STACK,
- 0 | CFF_COUNT_CLEAR_STACK,
-
- 0 | CFF_COUNT_CLEAR_STACK, /* rrcurveto */
- 0 | CFF_COUNT_CLEAR_STACK,
- 0 | CFF_COUNT_CLEAR_STACK,
- 0 | CFF_COUNT_CLEAR_STACK,
- 0 | CFF_COUNT_CLEAR_STACK,
- 0 | CFF_COUNT_CLEAR_STACK,
- 0 | CFF_COUNT_CLEAR_STACK,
-
- 13, /* flex */
- 7,
- 9,
- 11,
-
- 0 | CFF_COUNT_CHECK_WIDTH, /* endchar */
-
- 2 | CFF_COUNT_CHECK_WIDTH, /* hstem */
- 2 | CFF_COUNT_CHECK_WIDTH,
- 2 | CFF_COUNT_CHECK_WIDTH,
- 2 | CFF_COUNT_CHECK_WIDTH,
-
- 0 | CFF_COUNT_CHECK_WIDTH, /* hintmask */
- 0 | CFF_COUNT_CHECK_WIDTH, /* cntrmask */
- 0, /* dotsection */
-
- 1, /* abs */
- 2,
- 2,
- 2,
- 1,
- 0,
- 2,
- 1,
-
- 1, /* blend */
-
- 1, /* drop */
- 2,
- 1,
- 2,
- 1,
-
- 2, /* put */
- 1,
- 4,
- 3,
-
- 2, /* and */
- 2,
- 1,
- 2,
- 4,
-
- 1, /* callsubr */
- 1,
- 0,
-
- 2, /* hsbw */
- 0,
- 0,
- 0,
- 5, /* seac */
- 4, /* sbw */
- 2 /* setcurrentpoint */
- };
-
-#endif /* CFF_CONFIG_OPTION_OLD_ENGINE */
-
-
- /*************************************************************************/
- /*************************************************************************/
- /*************************************************************************/
- /********** *********/
- /********** *********/
- /********** GENERIC CHARSTRING PARSING *********/
- /********** *********/
- /********** *********/
- /*************************************************************************/
- /*************************************************************************/
- /*************************************************************************/
-
-
- /*************************************************************************/
- /* */
- /* <Function> */
- /* cff_builder_init */
- /* */
- /* <Description> */
- /* Initializes a given glyph builder. */
- /* */
- /* <InOut> */
- /* builder :: A pointer to the glyph builder to initialize. */
- /* */
- /* <Input> */
- /* face :: The current face object. */
- /* */
- /* size :: The current size object. */
- /* */
- /* glyph :: The current glyph object. */
- /* */
- /* hinting :: Whether hinting is active. */
- /* */
- static void
- cff_builder_init( CFF_Builder* builder,
- TT_Face face,
- CFF_Size size,
- CFF_GlyphSlot glyph,
- FT_Bool hinting )
- {
- builder->path_begun = 0;
- builder->load_points = 1;
-
- builder->face = face;
- builder->glyph = glyph;
- builder->memory = face->root.memory;
-
- if ( glyph )
- {
- FT_GlyphLoader loader = glyph->root.internal->loader;
-
-
- builder->loader = loader;
- builder->base = &loader->base.outline;
- builder->current = &loader->current.outline;
- FT_GlyphLoader_Rewind( loader );
-
- builder->hints_globals = NULL;
- builder->hints_funcs = NULL;
-
- if ( hinting && size )
- {
- CFF_Internal internal = (CFF_Internal)size->root.internal;
-
-
- builder->hints_globals = (void *)internal->topfont;
- builder->hints_funcs = glyph->root.internal->glyph_hints;
- }
- }
-
- builder->pos_x = 0;
- builder->pos_y = 0;
-
- builder->left_bearing.x = 0;
- builder->left_bearing.y = 0;
- builder->advance.x = 0;
- builder->advance.y = 0;
- }
-
-
- /*************************************************************************/
- /* */
- /* <Function> */
- /* cff_builder_done */
- /* */
- /* <Description> */
- /* Finalizes a given glyph builder. Its contents can still be used */
- /* after the call, but the function saves important information */
- /* within the corresponding glyph slot. */
- /* */
- /* <Input> */
- /* builder :: A pointer to the glyph builder to finalize. */
- /* */
- static void
- cff_builder_done( CFF_Builder* builder )
- {
- CFF_GlyphSlot glyph = builder->glyph;
-
-
- if ( glyph )
- glyph->root.outline = *builder->base;
- }
-
-
- /*************************************************************************/
- /* */
- /* <Function> */
- /* cff_compute_bias */
- /* */
- /* <Description> */
- /* Computes the bias value in dependence of the number of glyph */
- /* subroutines. */
- /* */
- /* <Input> */
- /* in_charstring_type :: The `CharstringType' value of the top DICT */
- /* dictionary. */
- /* */
- /* num_subrs :: The number of glyph subroutines. */
- /* */
- /* <Return> */
- /* The bias value. */
- static FT_Int
- cff_compute_bias( FT_Int in_charstring_type,
- FT_UInt num_subrs )
- {
- FT_Int result;
-
-
- if ( in_charstring_type == 1 )
- result = 0;
- else if ( num_subrs < 1240 )
- result = 107;
- else if ( num_subrs < 33900U )
- result = 1131;
- else
- result = 32768U;
-
- return result;
- }
-
-
- /*************************************************************************/
- /* */
- /* <Function> */
- /* cff_decoder_init */
- /* */
- /* <Description> */
- /* Initializes a given glyph decoder. */
- /* */
- /* <InOut> */
- /* decoder :: A pointer to the glyph builder to initialize. */
- /* */
- /* <Input> */
- /* face :: The current face object. */
- /* */
- /* size :: The current size object. */
- /* */
- /* slot :: The current glyph object. */
- /* */
- /* hinting :: Whether hinting is active. */
- /* */
- /* hint_mode :: The hinting mode. */
- /* */
- FT_LOCAL_DEF( void )
- cff_decoder_init( CFF_Decoder* decoder,
- TT_Face face,
- CFF_Size size,
- CFF_GlyphSlot slot,
- FT_Bool hinting,
- FT_Render_Mode hint_mode )
- {
- CFF_Font cff = (CFF_Font)face->extra.data;
-
-
- /* clear everything */
- FT_MEM_ZERO( decoder, sizeof ( *decoder ) );
-
- /* initialize builder */
- cff_builder_init( &decoder->builder, face, size, slot, hinting );
-
- /* initialize Type2 decoder */
- decoder->cff = cff;
- decoder->num_globals = cff->global_subrs_index.count;
- decoder->globals = cff->global_subrs;
- decoder->globals_bias = cff_compute_bias(
- cff->top_font.font_dict.charstring_type,
- decoder->num_globals );
-
- decoder->hint_mode = hint_mode;
- }
-
-
- /* this function is used to select the subfont */
- /* and the locals subrs array */
- FT_LOCAL_DEF( FT_Error )
- cff_decoder_prepare( CFF_Decoder* decoder,
- CFF_Size size,
- FT_UInt glyph_index )
- {
- CFF_Builder *builder = &decoder->builder;
- CFF_Font cff = (CFF_Font)builder->face->extra.data;
- CFF_SubFont sub = &cff->top_font;
- FT_Error error = FT_Err_Ok;
-
-
- /* manage CID fonts */
- if ( cff->num_subfonts )
- {
- FT_Byte fd_index = cff_fd_select_get( &cff->fd_select, glyph_index );
-
-
- if ( fd_index >= cff->num_subfonts )
- {
- FT_TRACE4(( "cff_decoder_prepare: invalid CID subfont index\n" ));
- error = FT_THROW( Invalid_File_Format );
- goto Exit;
- }
-
- FT_TRACE3(( " in subfont %d:\n", fd_index ));
-
- sub = cff->subfonts[fd_index];
-
- if ( builder->hints_funcs && size )
- {
- CFF_Internal internal = (CFF_Internal)size->root.internal;
-
-
- /* for CFFs without subfonts, this value has already been set */
- builder->hints_globals = (void *)internal->subfonts[fd_index];
- }
- }
-
- decoder->num_locals = sub->local_subrs_index.count;
- decoder->locals = sub->local_subrs;
- decoder->locals_bias = cff_compute_bias(
- decoder->cff->top_font.font_dict.charstring_type,
- decoder->num_locals );
-
- 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 */
-
- Exit:
- return error;
- }
-
-
- /* check that there is enough space for `count' more points */
- FT_LOCAL_DEF( FT_Error )
- cff_check_points( CFF_Builder* builder,
- FT_Int count )
- {
- return FT_GLYPHLOADER_CHECK_POINTS( builder->loader, count, 0 );
- }
-
-
- /* add a new point, do not check space */
- FT_LOCAL_DEF( void )
- cff_builder_add_point( CFF_Builder* builder,
- FT_Pos x,
- FT_Pos y,
- FT_Byte flag )
- {
- FT_Outline* outline = builder->current;
-
-
- if ( builder->load_points )
- {
- FT_Vector* point = outline->points + outline->n_points;
- FT_Byte* control = (FT_Byte*)outline->tags + outline->n_points;
-
-#ifdef CFF_CONFIG_OPTION_OLD_ENGINE
- CFF_Driver driver = (CFF_Driver)FT_FACE_DRIVER( builder->face );
-
-
- if ( driver->hinting_engine == FT_CFF_HINTING_FREETYPE )
- {
- point->x = x >> 16;
- point->y = y >> 16;
- }
- else
-#endif
- {
- /* cf2_decoder_parse_charstrings uses 16.16 coordinates */
- point->x = x >> 10;
- point->y = y >> 10;
- }
- *control = (FT_Byte)( flag ? FT_CURVE_TAG_ON : FT_CURVE_TAG_CUBIC );
- }
-
- outline->n_points++;
- }
-
-
- /* check space for a new on-curve point, then add it */
- FT_LOCAL_DEF( FT_Error )
- cff_builder_add_point1( CFF_Builder* builder,
- FT_Pos x,
- FT_Pos y )
- {
- FT_Error error;
-
-
- error = cff_check_points( builder, 1 );
- if ( !error )
- cff_builder_add_point( builder, x, y, 1 );
-
- return error;
- }
-
-
- /* check space for a new contour, then add it */
- static FT_Error
- cff_builder_add_contour( CFF_Builder* builder )
- {
- FT_Outline* outline = builder->current;
- FT_Error error;
-
-
- if ( !builder->load_points )
- {
- outline->n_contours++;
- return FT_Err_Ok;
- }
-
- error = FT_GLYPHLOADER_CHECK_POINTS( builder->loader, 0, 1 );
- if ( !error )
- {
- if ( outline->n_contours > 0 )
- outline->contours[outline->n_contours - 1] =
- (short)( outline->n_points - 1 );
-
- outline->n_contours++;
- }
-
- return error;
- }
-
-
- /* if a path was begun, add its first on-curve point */
- FT_LOCAL_DEF( FT_Error )
- cff_builder_start_point( CFF_Builder* builder,
- FT_Pos x,
- FT_Pos y )
- {
- FT_Error error = FT_Err_Ok;
-
-
- /* test whether we are building a new contour */
- if ( !builder->path_begun )
- {
- builder->path_begun = 1;
- error = cff_builder_add_contour( builder );
- if ( !error )
- error = cff_builder_add_point1( builder, x, y );
- }
-
- return error;
- }
-
-
- /* close the current contour */
- FT_LOCAL_DEF( void )
- cff_builder_close_contour( CFF_Builder* builder )
- {
- FT_Outline* outline = builder->current;
- FT_Int first;
-
-
- if ( !outline )
- return;
-
- first = outline->n_contours <= 1
- ? 0 : outline->contours[outline->n_contours - 2] + 1;
-
- /* We must not include the last point in the path if it */
- /* is located on the first point. */
- if ( outline->n_points > 1 )
- {
- FT_Vector* p1 = outline->points + first;
- FT_Vector* p2 = outline->points + outline->n_points - 1;
- FT_Byte* control = (FT_Byte*)outline->tags + outline->n_points - 1;
-
-
- /* `delete' last point only if it coincides with the first */
- /* point and if it is not a control point (which can happen). */
- if ( p1->x == p2->x && p1->y == p2->y )
- if ( *control == FT_CURVE_TAG_ON )
- outline->n_points--;
- }
-
- if ( outline->n_contours > 0 )
- {
- /* Don't add contours only consisting of one point, i.e., */
- /* check whether begin point and last point are the same. */
- if ( first == outline->n_points - 1 )
- {
- outline->n_contours--;
- outline->n_points--;
- }
- else
- outline->contours[outline->n_contours - 1] =
- (short)( outline->n_points - 1 );
- }
- }
-
-
- FT_LOCAL_DEF( FT_Int )
- cff_lookup_glyph_by_stdcharcode( CFF_Font cff,
- FT_Int charcode )
- {
- FT_UInt n;
- FT_UShort glyph_sid;
-
-
- /* CID-keyed fonts don't have glyph names */
- if ( !cff->charset.sids )
- return -1;
-
- /* check range of standard char code */
- if ( charcode < 0 || charcode > 255 )
- return -1;
-
- /* Get code to SID mapping from `cff_standard_encoding'. */
- glyph_sid = cff_get_standard_encoding( (FT_UInt)charcode );
-
- for ( n = 0; n < cff->num_glyphs; n++ )
- {
- if ( cff->charset.sids[n] == glyph_sid )
- return (FT_Int)n;
- }
-
- return -1;
- }
-
-
FT_LOCAL_DEF( FT_Error )
cff_get_glyph_data( TT_Face face,
FT_UInt glyph_index,
@@ -680,7 +68,7 @@
#endif /* FT_CONFIG_OPTION_INCREMENTAL */
{
- CFF_Font cff = (CFF_Font)(face->extra.data);
+ CFF_Font cff = (CFF_Font)(face->extra.data);
return cff_index_access_element( &cff->charstrings_index, glyph_index,
@@ -724,1811 +112,6 @@
}
-#ifdef CFF_CONFIG_OPTION_OLD_ENGINE
-
- static FT_Error
- cff_operator_seac( CFF_Decoder* decoder,
- FT_Pos asb,
- FT_Pos adx,
- FT_Pos ady,
- FT_Int bchar,
- FT_Int achar )
- {
- FT_Error error;
- CFF_Builder* builder = &decoder->builder;
- FT_Int bchar_index, achar_index;
- TT_Face face = decoder->builder.face;
- FT_Vector left_bearing, advance;
- FT_Byte* charstring;
- FT_ULong charstring_len;
- FT_Pos glyph_width;
-
-
- if ( decoder->seac )
- {
- FT_ERROR(( "cff_operator_seac: invalid nested seac\n" ));
- return FT_THROW( Syntax_Error );
- }
-
- adx += decoder->builder.left_bearing.x;
- ady += decoder->builder.left_bearing.y;
-
-#ifdef FT_CONFIG_OPTION_INCREMENTAL
- /* Incremental fonts don't necessarily have valid charsets. */
- /* They use the character code, not the glyph index, in this case. */
- if ( face->root.internal->incremental_interface )
- {
- bchar_index = bchar;
- achar_index = achar;
- }
- else
-#endif /* FT_CONFIG_OPTION_INCREMENTAL */
- {
- CFF_Font cff = (CFF_Font)(face->extra.data);
-
-
- bchar_index = cff_lookup_glyph_by_stdcharcode( cff, bchar );
- achar_index = cff_lookup_glyph_by_stdcharcode( cff, achar );
- }
-
- if ( bchar_index < 0 || achar_index < 0 )
- {
- FT_ERROR(( "cff_operator_seac:"
- " invalid seac character code arguments\n" ));
- return FT_THROW( Syntax_Error );
- }
-
- /* If we are trying to load a composite glyph, do not load the */
- /* accent character and return the array of subglyphs. */
- if ( builder->no_recurse )
- {
- FT_GlyphSlot glyph = (FT_GlyphSlot)builder->glyph;
- FT_GlyphLoader loader = glyph->internal->loader;
- FT_SubGlyph subg;
-
-
- /* reallocate subglyph array if necessary */
- error = FT_GlyphLoader_CheckSubGlyphs( loader, 2 );
- if ( error )
- goto Exit;
-
- subg = loader->current.subglyphs;
-
- /* subglyph 0 = base character */
- subg->index = bchar_index;
- subg->flags = FT_SUBGLYPH_FLAG_ARGS_ARE_XY_VALUES |
- FT_SUBGLYPH_FLAG_USE_MY_METRICS;
- subg->arg1 = 0;
- subg->arg2 = 0;
- subg++;
-
- /* subglyph 1 = accent character */
- subg->index = achar_index;
- subg->flags = FT_SUBGLYPH_FLAG_ARGS_ARE_XY_VALUES;
- subg->arg1 = (FT_Int)( adx >> 16 );
- subg->arg2 = (FT_Int)( ady >> 16 );
-
- /* set up remaining glyph fields */
- glyph->num_subglyphs = 2;
- glyph->subglyphs = loader->base.subglyphs;
- glyph->format = FT_GLYPH_FORMAT_COMPOSITE;
-
- loader->current.num_subglyphs = 2;
- }
-
- FT_GlyphLoader_Prepare( builder->loader );
-
- /* First load `bchar' in builder */
- error = cff_get_glyph_data( face, (FT_UInt)bchar_index,
- &charstring, &charstring_len );
- if ( !error )
- {
- /* the seac operator must not be nested */
- decoder->seac = TRUE;
- error = cff_decoder_parse_charstrings( decoder, charstring,
- charstring_len );
- decoder->seac = FALSE;
-
- cff_free_glyph_data( face, &charstring, charstring_len );
-
- if ( error )
- goto Exit;
- }
-
- /* Save the left bearing, advance and glyph width of the base */
- /* character as they will be erased by the next load. */
-
- left_bearing = builder->left_bearing;
- advance = builder->advance;
- glyph_width = decoder->glyph_width;
-
- builder->left_bearing.x = 0;
- builder->left_bearing.y = 0;
-
- builder->pos_x = adx - asb;
- builder->pos_y = ady;
-
- /* Now load `achar' on top of the base outline. */
- error = cff_get_glyph_data( face, (FT_UInt)achar_index,
- &charstring, &charstring_len );
- if ( !error )
- {
- /* the seac operator must not be nested */
- decoder->seac = TRUE;
- error = cff_decoder_parse_charstrings( decoder, charstring,
- charstring_len );
- decoder->seac = FALSE;
-
- cff_free_glyph_data( face, &charstring, charstring_len );
-
- if ( error )
- goto Exit;
- }
-
- /* Restore the left side bearing, advance and glyph width */
- /* of the base character. */
- builder->left_bearing = left_bearing;
- builder->advance = advance;
- decoder->glyph_width = glyph_width;
-
- builder->pos_x = 0;
- builder->pos_y = 0;
-
- Exit:
- return error;
- }
-
-
- /*************************************************************************/
- /* */
- /* <Function> */
- /* cff_decoder_parse_charstrings */
- /* */
- /* <Description> */
- /* Parses a given Type 2 charstrings program. */
- /* */
- /* <InOut> */
- /* decoder :: The current Type 1 decoder. */
- /* */
- /* <Input> */
- /* charstring_base :: The base of the charstring stream. */
- /* */
- /* charstring_len :: The length in bytes of the charstring stream. */
- /* */
- /* <Return> */
- /* FreeType error code. 0 means success. */
- /* */
- FT_LOCAL_DEF( FT_Error )
- cff_decoder_parse_charstrings( CFF_Decoder* decoder,
- FT_Byte* charstring_base,
- FT_ULong charstring_len )
- {
- FT_Error error;
- CFF_Decoder_Zone* zone;
- FT_Byte* ip;
- 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;
-
- T2_Hints_Funcs hinter;
-
-
- /* set default width */
- 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;
- zone = decoder->zones;
- stack = decoder->top;
-
- hinter = (T2_Hints_Funcs)builder->hints_funcs;
-
- builder->path_begun = 0;
-
- zone->base = charstring_base;
- limit = zone->limit = charstring_base + charstring_len;
- ip = zone->cursor = zone->base;
-
- error = FT_Err_Ok;
-
- x = builder->pos_x;
- y = builder->pos_y;
-
- /* begin hints recording session, if any */
- if ( hinter )
- hinter->open( hinter->hints );
-
- /* now execute loop */
- while ( ip < limit )
- {
- CFF_Operator op;
- FT_Byte v;
-
-
- /********************************************************************/
- /* */
- /* Decode operator or operand */
- /* */
- v = *ip++;
- if ( v >= 32 || v == 28 )
- {
- FT_Int shift = 16;
- FT_Int32 val;
-
-
- /* this is an operand, push it on the stack */
-
- /* if we use shifts, all computations are done with unsigned */
- /* values; the conversion to a signed value is the last step */
- if ( v == 28 )
- {
- if ( ip + 1 >= limit )
- goto Syntax_Error;
- val = (FT_Short)( ( (FT_UShort)ip[0] << 8 ) | ip[1] );
- ip += 2;
- }
- else if ( v < 247 )
- val = (FT_Int32)v - 139;
- else if ( v < 251 )
- {
- if ( ip >= limit )
- goto Syntax_Error;
- val = ( (FT_Int32)v - 247 ) * 256 + *ip++ + 108;
- }
- else if ( v < 255 )
- {
- if ( ip >= limit )
- goto Syntax_Error;
- val = -( (FT_Int32)v - 251 ) * 256 - *ip++ - 108;
- }
- else
- {
- if ( ip + 3 >= limit )
- goto Syntax_Error;
- val = (FT_Int32)( ( (FT_UInt32)ip[0] << 24 ) |
- ( (FT_UInt32)ip[1] << 16 ) |
- ( (FT_UInt32)ip[2] << 8 ) |
- (FT_UInt32)ip[3] );
- ip += 4;
- if ( charstring_type == 2 )
- shift = 0;
- }
- if ( decoder->top - stack >= CFF_MAX_OPERANDS )
- goto Stack_Overflow;
-
- val = (FT_Int32)( (FT_UInt32)val << shift );
- *decoder->top++ = val;
-
-#ifdef FT_DEBUG_LEVEL_TRACE
- if ( !( val & 0xFFFFL ) )
- FT_TRACE4(( " %hd", (FT_Short)( (FT_UInt32)val >> 16 ) ));
- else
- FT_TRACE4(( " %.2f", val / 65536.0 ));
-#endif
-
- }
- else
- {
- /* The specification says that normally arguments are to be taken */
- /* from the bottom of the stack. However, this seems not to be */
- /* correct, at least for Acroread 7.0.8 on GNU/Linux: It pops the */
- /* arguments similar to a PS interpreter. */
-
- FT_Fixed* args = decoder->top;
- FT_Int num_args = (FT_Int)( args - decoder->stack );
- FT_Int req_args;
-
-
- /* find operator */
- op = cff_op_unknown;
-
- switch ( v )
- {
- case 1:
- op = cff_op_hstem;
- break;
- case 3:
- op = cff_op_vstem;
- break;
- case 4:
- op = cff_op_vmoveto;
- break;
- case 5:
- op = cff_op_rlineto;
- break;
- case 6:
- op = cff_op_hlineto;
- break;
- case 7:
- op = cff_op_vlineto;
- break;
- case 8:
- op = cff_op_rrcurveto;
- break;
- case 9:
- op = cff_op_closepath;
- break;
- case 10:
- op = cff_op_callsubr;
- break;
- case 11:
- op = cff_op_return;
- break;
- case 12:
- {
- if ( ip >= limit )
- goto Syntax_Error;
- v = *ip++;
-
- switch ( v )
- {
- case 0:
- op = cff_op_dotsection;
- break;
- case 1: /* this is actually the Type1 vstem3 operator */
- op = cff_op_vstem;
- break;
- case 2: /* this is actually the Type1 hstem3 operator */
- op = cff_op_hstem;
- break;
- case 3:
- op = cff_op_and;
- break;
- case 4:
- op = cff_op_or;
- break;
- case 5:
- op = cff_op_not;
- break;
- case 6:
- op = cff_op_seac;
- break;
- case 7:
- op = cff_op_sbw;
- break;
- case 8:
- op = cff_op_store;
- break;
- case 9:
- op = cff_op_abs;
- break;
- case 10:
- op = cff_op_add;
- break;
- case 11:
- op = cff_op_sub;
- break;
- case 12:
- op = cff_op_div;
- break;
- case 13:
- op = cff_op_load;
- break;
- case 14:
- op = cff_op_neg;
- break;
- case 15:
- op = cff_op_eq;
- break;
- case 16:
- op = cff_op_callothersubr;
- break;
- case 17:
- op = cff_op_pop;
- break;
- case 18:
- op = cff_op_drop;
- break;
- case 20:
- op = cff_op_put;
- break;
- case 21:
- op = cff_op_get;
- break;
- case 22:
- op = cff_op_ifelse;
- break;
- case 23:
- op = cff_op_random;
- break;
- case 24:
- op = cff_op_mul;
- break;
- case 26:
- op = cff_op_sqrt;
- break;
- case 27:
- op = cff_op_dup;
- break;
- case 28:
- op = cff_op_exch;
- break;
- case 29:
- op = cff_op_index;
- break;
- case 30:
- op = cff_op_roll;
- break;
- case 33:
- op = cff_op_setcurrentpoint;
- break;
- case 34:
- op = cff_op_hflex;
- break;
- case 35:
- op = cff_op_flex;
- break;
- case 36:
- op = cff_op_hflex1;
- break;
- case 37:
- op = cff_op_flex1;
- break;
- default:
- FT_TRACE4(( " unknown op (12, %d)\n", v ));
- break;
- }
- }
- break;
- case 13:
- op = cff_op_hsbw;
- break;
- case 14:
- op = cff_op_endchar;
- break;
- case 16:
- op = cff_op_blend;
- break;
- case 18:
- op = cff_op_hstemhm;
- break;
- case 19:
- op = cff_op_hintmask;
- break;
- case 20:
- op = cff_op_cntrmask;
- break;
- case 21:
- op = cff_op_rmoveto;
- break;
- case 22:
- op = cff_op_hmoveto;
- break;
- case 23:
- op = cff_op_vstemhm;
- break;
- case 24:
- op = cff_op_rcurveline;
- break;
- case 25:
- op = cff_op_rlinecurve;
- break;
- case 26:
- op = cff_op_vvcurveto;
- break;
- case 27:
- op = cff_op_hhcurveto;
- break;
- case 29:
- op = cff_op_callgsubr;
- break;
- case 30:
- op = cff_op_vhcurveto;
- break;
- case 31:
- op = cff_op_hvcurveto;
- break;
- default:
- FT_TRACE4(( " unknown op (%d)\n", v ));
- break;
- }
-
- if ( op == cff_op_unknown )
- continue;
-
- /* check arguments */
- req_args = cff_argument_counts[op];
- if ( req_args & CFF_COUNT_CHECK_WIDTH )
- {
- if ( num_args > 0 && decoder->read_width )
- {
- /* If `nominal_width' is non-zero, the number is really a */
- /* difference against `nominal_width'. Else, the number here */
- /* is truly a width, not a difference against `nominal_width'. */
- /* If the font does not set `nominal_width', then */
- /* `nominal_width' defaults to zero, and so we can set */
- /* `glyph_width' to `nominal_width' plus number on the stack */
- /* -- for either case. */
-
- FT_Int set_width_ok;
-
-
- switch ( op )
- {
- case cff_op_hmoveto:
- case cff_op_vmoveto:
- set_width_ok = num_args & 2;
- break;
-
- case cff_op_hstem:
- case cff_op_vstem:
- case cff_op_hstemhm:
- case cff_op_vstemhm:
- case cff_op_rmoveto:
- case cff_op_hintmask:
- case cff_op_cntrmask:
- set_width_ok = num_args & 1;
- break;
-
- case cff_op_endchar:
- /* If there is a width specified for endchar, we either have */
- /* 1 argument or 5 arguments. We like to argue. */
- set_width_ok = ( num_args == 5 ) || ( num_args == 1 );
- break;
-
- default:
- set_width_ok = 0;
- break;
- }
-
- if ( set_width_ok )
- {
- decoder->glyph_width = decoder->nominal_width +
- ( stack[0] >> 16 );
-
- if ( decoder->width_only )
- {
- /* we only want the advance width; stop here */
- break;
- }
-
- /* Consumed an argument. */
- num_args--;
- }
- }
-
- decoder->read_width = 0;
- req_args = 0;
- }
-
- req_args &= 0x000F;
- if ( num_args < req_args )
- goto Stack_Underflow;
- args -= req_args;
- num_args -= req_args;
-
- /* At this point, `args' points to the first argument of the */
- /* operand in case `req_args' isn't zero. Otherwise, we have */
- /* to adjust `args' manually. */
-
- /* Note that we only pop arguments from the stack which we */
- /* really need and can digest so that we can continue in case */
- /* of superfluous stack elements. */
-
- switch ( op )
- {
- case cff_op_hstem:
- case cff_op_vstem:
- case cff_op_hstemhm:
- case cff_op_vstemhm:
- /* the number of arguments is always even here */
- FT_TRACE4((
- op == cff_op_hstem ? " hstem\n" :
- ( op == cff_op_vstem ? " vstem\n" :
- ( op == cff_op_hstemhm ? " hstemhm\n" : " vstemhm\n" ) ) ));
-
- if ( hinter )
- hinter->stems( hinter->hints,
- ( op == cff_op_hstem || op == cff_op_hstemhm ),
- num_args / 2,
- args - ( num_args & ~1 ) );
-
- decoder->num_hints += num_args / 2;
- args = stack;
- break;
-
- case cff_op_hintmask:
- case cff_op_cntrmask:
- FT_TRACE4(( op == cff_op_hintmask ? " hintmask" : " cntrmask" ));
-
- /* implement vstem when needed -- */
- /* the specification doesn't say it, but this also works */
- /* with the 'cntrmask' operator */
- /* */
- if ( num_args > 0 )
- {
- if ( hinter )
- hinter->stems( hinter->hints,
- 0,
- num_args / 2,
- args - ( num_args & ~1 ) );
-
- decoder->num_hints += num_args / 2;
- }
-
- /* In a valid charstring there must be at least one byte */
- /* after `hintmask' or `cntrmask' (e.g., for a `return' */
- /* instruction). Additionally, there must be space for */
- /* `num_hints' bits. */
-
- if ( ( ip + ( ( decoder->num_hints + 7 ) >> 3 ) ) >= limit )
- goto Syntax_Error;
-
- if ( hinter )
- {
- if ( op == cff_op_hintmask )
- hinter->hintmask( hinter->hints,
- (FT_UInt)builder->current->n_points,
- (FT_UInt)decoder->num_hints,
- ip );
- else
- hinter->counter( hinter->hints,
- (FT_UInt)decoder->num_hints,
- ip );
- }
-
-#ifdef FT_DEBUG_LEVEL_TRACE
- {
- FT_UInt maskbyte;
-
-
- FT_TRACE4(( " (maskbytes:" ));
-
- for ( maskbyte = 0;
- maskbyte < (FT_UInt)( ( decoder->num_hints + 7 ) >> 3 );
- maskbyte++, ip++ )
- FT_TRACE4(( " 0x%02X", *ip ));
-
- FT_TRACE4(( ")\n" ));
- }
-#else
- ip += ( decoder->num_hints + 7 ) >> 3;
-#endif
- args = stack;
- break;
-
- case cff_op_rmoveto:
- FT_TRACE4(( " rmoveto\n" ));
-
- cff_builder_close_contour( builder );
- builder->path_begun = 0;
- x += args[-2];
- y += args[-1];
- args = stack;
- break;
-
- case cff_op_vmoveto:
- FT_TRACE4(( " vmoveto\n" ));
-
- cff_builder_close_contour( builder );
- builder->path_begun = 0;
- y += args[-1];
- args = stack;
- break;
-
- case cff_op_hmoveto:
- FT_TRACE4(( " hmoveto\n" ));
-
- cff_builder_close_contour( builder );
- builder->path_begun = 0;
- x += args[-1];
- args = stack;
- break;
-
- case cff_op_rlineto:
- FT_TRACE4(( " rlineto\n" ));
-
- if ( cff_builder_start_point( builder, x, y ) ||
- cff_check_points( builder, num_args / 2 ) )
- goto Fail;
-
- if ( num_args < 2 )
- goto Stack_Underflow;
-
- args -= num_args & ~1;
- while ( args < decoder->top )
- {
- x += args[0];
- y += args[1];
- cff_builder_add_point( builder, x, y, 1 );
- args += 2;
- }
- args = stack;
- break;
-
- case cff_op_hlineto:
- case cff_op_vlineto:
- {
- FT_Int phase = ( op == cff_op_hlineto );
-
-
- FT_TRACE4(( op == cff_op_hlineto ? " hlineto\n"
- : " vlineto\n" ));
-
- if ( num_args < 0 )
- goto Stack_Underflow;
-
- /* there exist subsetted fonts (found in PDFs) */
- /* which call `hlineto' without arguments */
- if ( num_args == 0 )
- break;
-
- if ( cff_builder_start_point( builder, x, y ) ||
- cff_check_points( builder, num_args ) )
- goto Fail;
-
- args = stack;
- while ( args < decoder->top )
- {
- if ( phase )
- x += args[0];
- else
- y += args[0];
-
- if ( cff_builder_add_point1( builder, x, y ) )
- goto Fail;
-
- args++;
- phase ^= 1;
- }
- args = stack;
- }
- break;
-
- case cff_op_rrcurveto:
- {
- FT_Int nargs;
-
-
- FT_TRACE4(( " rrcurveto\n" ));
-
- if ( num_args < 6 )
- goto Stack_Underflow;
-
- nargs = num_args - num_args % 6;
-
- if ( cff_builder_start_point( builder, x, y ) ||
- cff_check_points( builder, nargs / 2 ) )
- goto Fail;
-
- args -= nargs;
- while ( args < decoder->top )
- {
- x += args[0];
- y += args[1];
- cff_builder_add_point( builder, x, y, 0 );
- x += args[2];
- y += args[3];
- cff_builder_add_point( builder, x, y, 0 );
- x += args[4];
- y += args[5];
- cff_builder_add_point( builder, x, y, 1 );
- args += 6;
- }
- args = stack;
- }
- break;
-
- case cff_op_vvcurveto:
- {
- FT_Int nargs;
-
-
- FT_TRACE4(( " vvcurveto\n" ));
-
- if ( num_args < 4 )
- goto Stack_Underflow;
-
- /* if num_args isn't of the form 4n or 4n+1, */
- /* we enforce it by clearing the second bit */
-
- nargs = num_args & ~2;
-
- if ( cff_builder_start_point( builder, x, y ) )
- goto Fail;
-
- args -= nargs;
-
- if ( nargs & 1 )
- {
- x += args[0];
- args++;
- nargs--;
- }
-
- if ( cff_check_points( builder, 3 * ( nargs / 4 ) ) )
- goto Fail;
-
- while ( args < decoder->top )
- {
- y += args[0];
- cff_builder_add_point( builder, x, y, 0 );
- x += args[1];
- y += args[2];
- cff_builder_add_point( builder, x, y, 0 );
- y += args[3];
- cff_builder_add_point( builder, x, y, 1 );
- args += 4;
- }
- args = stack;
- }
- break;
-
- case cff_op_hhcurveto:
- {
- FT_Int nargs;
-
-
- FT_TRACE4(( " hhcurveto\n" ));
-
- if ( num_args < 4 )
- goto Stack_Underflow;
-
- /* if num_args isn't of the form 4n or 4n+1, */
- /* we enforce it by clearing the second bit */
-
- nargs = num_args & ~2;
-
- if ( cff_builder_start_point( builder, x, y ) )
- goto Fail;
-
- args -= nargs;
- if ( nargs & 1 )
- {
- y += args[0];
- args++;
- nargs--;
- }
-
- if ( cff_check_points( builder, 3 * ( nargs / 4 ) ) )
- goto Fail;
-
- while ( args < decoder->top )
- {
- x += args[0];
- cff_builder_add_point( builder, x, y, 0 );
- x += args[1];
- y += args[2];
- cff_builder_add_point( builder, x, y, 0 );
- x += args[3];
- cff_builder_add_point( builder, x, y, 1 );
- args += 4;
- }
- args = stack;
- }
- break;
-
- case cff_op_vhcurveto:
- case cff_op_hvcurveto:
- {
- FT_Int phase;
- FT_Int nargs;
-
-
- FT_TRACE4(( op == cff_op_vhcurveto ? " vhcurveto\n"
- : " hvcurveto\n" ));
-
- if ( cff_builder_start_point( builder, x, y ) )
- goto Fail;
-
- if ( num_args < 4 )
- goto Stack_Underflow;
-
- /* if num_args isn't of the form 8n, 8n+1, 8n+4, or 8n+5, */
- /* we enforce it by clearing the second bit */
-
- nargs = num_args & ~2;
-
- args -= nargs;
- if ( cff_check_points( builder, ( nargs / 4 ) * 3 ) )
- goto Stack_Underflow;
-
- phase = ( op == cff_op_hvcurveto );
-
- while ( nargs >= 4 )
- {
- nargs -= 4;
- if ( phase )
- {
- x += args[0];
- cff_builder_add_point( builder, x, y, 0 );
- x += args[1];
- y += args[2];
- cff_builder_add_point( builder, x, y, 0 );
- y += args[3];
- if ( nargs == 1 )
- x += args[4];
- cff_builder_add_point( builder, x, y, 1 );
- }
- else
- {
- y += args[0];
- cff_builder_add_point( builder, x, y, 0 );
- x += args[1];
- y += args[2];
- cff_builder_add_point( builder, x, y, 0 );
- x += args[3];
- if ( nargs == 1 )
- y += args[4];
- cff_builder_add_point( builder, x, y, 1 );
- }
- args += 4;
- phase ^= 1;
- }
- args = stack;
- }
- break;
-
- case cff_op_rlinecurve:
- {
- FT_Int num_lines;
- FT_Int nargs;
-
-
- FT_TRACE4(( " rlinecurve\n" ));
-
- if ( num_args < 8 )
- goto Stack_Underflow;
-
- nargs = num_args & ~1;
- num_lines = ( nargs - 6 ) / 2;
-
- if ( cff_builder_start_point( builder, x, y ) ||
- cff_check_points( builder, num_lines + 3 ) )
- goto Fail;
-
- args -= nargs;
-
- /* first, add the line segments */
- while ( num_lines > 0 )
- {
- x += args[0];
- y += args[1];
- cff_builder_add_point( builder, x, y, 1 );
- args += 2;
- num_lines--;
- }
-
- /* then the curve */
- x += args[0];
- y += args[1];
- cff_builder_add_point( builder, x, y, 0 );
- x += args[2];
- y += args[3];
- cff_builder_add_point( builder, x, y, 0 );
- x += args[4];
- y += args[5];
- cff_builder_add_point( builder, x, y, 1 );
- args = stack;
- }
- break;
-
- case cff_op_rcurveline:
- {
- FT_Int num_curves;
- FT_Int nargs;
-
-
- FT_TRACE4(( " rcurveline\n" ));
-
- if ( num_args < 8 )
- goto Stack_Underflow;
-
- nargs = num_args - 2;
- nargs = nargs - nargs % 6 + 2;
- num_curves = ( nargs - 2 ) / 6;
-
- if ( cff_builder_start_point( builder, x, y ) ||
- cff_check_points( builder, num_curves * 3 + 2 ) )
- goto Fail;
-
- args -= nargs;
-
- /* first, add the curves */
- while ( num_curves > 0 )
- {
- x += args[0];
- y += args[1];
- cff_builder_add_point( builder, x, y, 0 );
- x += args[2];
- y += args[3];
- cff_builder_add_point( builder, x, y, 0 );
- x += args[4];
- y += args[5];
- cff_builder_add_point( builder, x, y, 1 );
- args += 6;
- num_curves--;
- }
-
- /* then the final line */
- x += args[0];
- y += args[1];
- cff_builder_add_point( builder, x, y, 1 );
- args = stack;
- }
- break;
-
- case cff_op_hflex1:
- {
- FT_Pos start_y;
-
-
- FT_TRACE4(( " hflex1\n" ));
-
- /* adding five more points: 4 control points, 1 on-curve point */
- /* -- make sure we have enough space for the start point if it */
- /* needs to be added */
- if ( cff_builder_start_point( builder, x, y ) ||
- cff_check_points( builder, 6 ) )
- goto Fail;
-
- /* record the starting point's y position for later use */
- start_y = y;
-
- /* first control point */
- x += args[0];
- y += args[1];
- cff_builder_add_point( builder, x, y, 0 );
-
- /* second control point */
- x += args[2];
- y += args[3];
- cff_builder_add_point( builder, x, y, 0 );
-
- /* join point; on curve, with y-value the same as the last */
- /* control point's y-value */
- x += args[4];
- cff_builder_add_point( builder, x, y, 1 );
-
- /* third control point, with y-value the same as the join */
- /* point's y-value */
- x += args[5];
- cff_builder_add_point( builder, x, y, 0 );
-
- /* fourth control point */
- x += args[6];
- y += args[7];
- cff_builder_add_point( builder, x, y, 0 );
-
- /* ending point, with y-value the same as the start */
- x += args[8];
- y = start_y;
- cff_builder_add_point( builder, x, y, 1 );
-
- args = stack;
- break;
- }
-
- case cff_op_hflex:
- {
- FT_Pos start_y;
-
-
- FT_TRACE4(( " hflex\n" ));
-
- /* adding six more points; 4 control points, 2 on-curve points */
- if ( cff_builder_start_point( builder, x, y ) ||
- cff_check_points( builder, 6 ) )
- goto Fail;
-
- /* record the starting point's y-position for later use */
- start_y = y;
-
- /* first control point */
- x += args[0];
- cff_builder_add_point( builder, x, y, 0 );
-
- /* second control point */
- x += args[1];
- y += args[2];
- cff_builder_add_point( builder, x, y, 0 );
-
- /* join point; on curve, with y-value the same as the last */
- /* control point's y-value */
- x += args[3];
- cff_builder_add_point( builder, x, y, 1 );
-
- /* third control point, with y-value the same as the join */
- /* point's y-value */
- x += args[4];
- cff_builder_add_point( builder, x, y, 0 );
-
- /* fourth control point */
- x += args[5];
- y = start_y;
- cff_builder_add_point( builder, x, y, 0 );
-
- /* ending point, with y-value the same as the start point's */
- /* y-value -- we don't add this point, though */
- x += args[6];
- cff_builder_add_point( builder, x, y, 1 );
-
- args = stack;
- break;
- }
-
- case cff_op_flex1:
- {
- FT_Pos start_x, start_y; /* record start x, y values for */
- /* alter use */
- FT_Fixed dx = 0, dy = 0; /* used in horizontal/vertical */
- /* algorithm below */
- FT_Int horizontal, count;
- FT_Fixed* temp;
-
-
- FT_TRACE4(( " flex1\n" ));
-
- /* adding six more points; 4 control points, 2 on-curve points */
- if ( cff_builder_start_point( builder, x, y ) ||
- cff_check_points( builder, 6 ) )
- goto Fail;
-
- /* record the starting point's x, y position for later use */
- start_x = x;
- start_y = y;
-
- /* XXX: figure out whether this is supposed to be a horizontal */
- /* or vertical flex; the Type 2 specification is vague... */
-
- temp = args;
-
- /* grab up to the last argument */
- for ( count = 5; count > 0; count-- )
- {
- dx += temp[0];
- dy += temp[1];
- temp += 2;
- }
-
- if ( dx < 0 )
- dx = -dx;
- if ( dy < 0 )
- dy = -dy;
-
- /* strange test, but here it is... */
- horizontal = ( dx > dy );
-
- for ( count = 5; count > 0; count-- )
- {
- x += args[0];
- y += args[1];
- cff_builder_add_point( builder, x, y,
- (FT_Bool)( count == 3 ) );
- args += 2;
- }
-
- /* is last operand an x- or y-delta? */
- if ( horizontal )
- {
- x += args[0];
- y = start_y;
- }
- else
- {
- x = start_x;
- y += args[0];
- }
-
- cff_builder_add_point( builder, x, y, 1 );
-
- args = stack;
- break;
- }
-
- case cff_op_flex:
- {
- FT_UInt count;
-
-
- FT_TRACE4(( " flex\n" ));
-
- if ( cff_builder_start_point( builder, x, y ) ||
- cff_check_points( builder, 6 ) )
- goto Fail;
-
- for ( count = 6; count > 0; count-- )
- {
- x += args[0];
- y += args[1];
- cff_builder_add_point( builder, x, y,
- (FT_Bool)( count == 4 || count == 1 ) );
- args += 2;
- }
-
- args = stack;
- }
- break;
-
- case cff_op_seac:
- FT_TRACE4(( " seac\n" ));
-
- error = cff_operator_seac( decoder,
- args[0], args[1], args[2],
- (FT_Int)( args[3] >> 16 ),
- (FT_Int)( args[4] >> 16 ) );
-
- /* add current outline to the glyph slot */
- FT_GlyphLoader_Add( builder->loader );
-
- /* return now! */
- FT_TRACE4(( "\n" ));
- return error;
-
- case cff_op_endchar:
- FT_TRACE4(( " endchar\n" ));
-
- /* We are going to emulate the seac operator. */
- if ( num_args >= 4 )
- {
- /* Save glyph width so that the subglyphs don't overwrite it. */
- FT_Pos glyph_width = decoder->glyph_width;
-
-
- error = cff_operator_seac( decoder,
- 0L, args[-4], args[-3],
- (FT_Int)( args[-2] >> 16 ),
- (FT_Int)( args[-1] >> 16 ) );
-
- decoder->glyph_width = glyph_width;
- }
- else
- {
- cff_builder_close_contour( builder );
-
- /* close hints recording session */
- if ( hinter )
- {
- if ( hinter->close( hinter->hints,
- (FT_UInt)builder->current->n_points ) )
- goto Syntax_Error;
-
- /* apply hints to the loaded glyph outline now */
- error = hinter->apply( hinter->hints,
- builder->current,
- (PSH_Globals)builder->hints_globals,
- decoder->hint_mode );
- if ( error )
- goto Fail;
- }
-
- /* add current outline to the glyph slot */
- FT_GlyphLoader_Add( builder->loader );
- }
-
- /* return now! */
- FT_TRACE4(( "\n" ));
- return error;
-
- case cff_op_abs:
- FT_TRACE4(( " abs\n" ));
-
- if ( args[0] < 0 )
- args[0] = -args[0];
- args++;
- break;
-
- case cff_op_add:
- FT_TRACE4(( " add\n" ));
-
- args[0] += args[1];
- args++;
- break;
-
- case cff_op_sub:
- FT_TRACE4(( " sub\n" ));
-
- args[0] -= args[1];
- args++;
- break;
-
- case cff_op_div:
- FT_TRACE4(( " div\n" ));
-
- args[0] = FT_DivFix( args[0], args[1] );
- args++;
- break;
-
- case cff_op_neg:
- FT_TRACE4(( " neg\n" ));
-
- args[0] = -args[0];
- args++;
- break;
-
- case cff_op_random:
- {
- FT_Fixed Rand;
-
-
- FT_TRACE4(( " rand\n" ));
-
- Rand = seed;
- if ( Rand >= 0x8000L )
- Rand++;
-
- args[0] = Rand;
- seed = FT_MulFix( seed, 0x10000L - seed );
- if ( seed == 0 )
- seed += 0x2873;
- args++;
- }
- break;
-
- case cff_op_mul:
- FT_TRACE4(( " mul\n" ));
-
- args[0] = FT_MulFix( args[0], args[1] );
- args++;
- break;
-
- case cff_op_sqrt:
- FT_TRACE4(( " sqrt\n" ));
-
- if ( args[0] > 0 )
- {
- FT_Int count = 9;
- FT_Fixed root = args[0];
- FT_Fixed new_root;
-
-
- for (;;)
- {
- new_root = ( root + FT_DivFix( args[0], root ) + 1 ) >> 1;
- if ( new_root == root || count <= 0 )
- break;
- root = new_root;
- }
- args[0] = new_root;
- }
- else
- args[0] = 0;
- args++;
- break;
-
- case cff_op_drop:
- /* nothing */
- FT_TRACE4(( " drop\n" ));
-
- break;
-
- case cff_op_exch:
- {
- FT_Fixed tmp;
-
-
- FT_TRACE4(( " exch\n" ));
-
- tmp = args[0];
- args[0] = args[1];
- args[1] = tmp;
- args += 2;
- }
- break;
-
- case cff_op_index:
- {
- FT_Int idx = (FT_Int)( args[0] >> 16 );
-
-
- FT_TRACE4(( " index\n" ));
-
- if ( idx < 0 )
- idx = 0;
- else if ( idx > num_args - 2 )
- idx = num_args - 2;
- args[0] = args[-( idx + 1 )];
- args++;
- }
- break;
-
- case cff_op_roll:
- {
- FT_Int count = (FT_Int)( args[0] >> 16 );
- FT_Int idx = (FT_Int)( args[1] >> 16 );
-
-
- FT_TRACE4(( " roll\n" ));
-
- if ( count <= 0 )
- count = 1;
-
- args -= count;
- if ( args < stack )
- goto Stack_Underflow;
-
- if ( idx >= 0 )
- {
- while ( idx > 0 )
- {
- FT_Fixed tmp = args[count - 1];
- FT_Int i;
-
-
- for ( i = count - 2; i >= 0; i-- )
- args[i + 1] = args[i];
- args[0] = tmp;
- idx--;
- }
- }
- else
- {
- while ( idx < 0 )
- {
- FT_Fixed tmp = args[0];
- FT_Int i;
-
-
- for ( i = 0; i < count - 1; i++ )
- args[i] = args[i + 1];
- args[count - 1] = tmp;
- idx++;
- }
- }
- args += count;
- }
- break;
-
- case cff_op_dup:
- FT_TRACE4(( " dup\n" ));
-
- args[1] = args[0];
- args += 2;
- break;
-
- case cff_op_put:
- {
- FT_Fixed val = args[0];
- FT_Int idx = (FT_Int)( args[1] >> 16 );
-
-
- FT_TRACE4(( " put\n" ));
-
- if ( idx >= 0 && idx < CFF_MAX_TRANS_ELEMENTS )
- decoder->buildchar[idx] = val;
- }
- break;
-
- case cff_op_get:
- {
- FT_Int idx = (FT_Int)( args[0] >> 16 );
- FT_Fixed val = 0;
-
-
- FT_TRACE4(( " get\n" ));
-
- if ( idx >= 0 && idx < CFF_MAX_TRANS_ELEMENTS )
- val = decoder->buildchar[idx];
-
- args[0] = val;
- args++;
- }
- break;
-
- case cff_op_store:
- FT_TRACE4(( " store\n"));
-
- goto Unimplemented;
-
- case cff_op_load:
- FT_TRACE4(( " load\n" ));
-
- goto Unimplemented;
-
- case cff_op_dotsection:
- /* this operator is deprecated and ignored by the parser */
- FT_TRACE4(( " dotsection\n" ));
- break;
-
- case cff_op_closepath:
- /* this is an invalid Type 2 operator; however, there */
- /* exist fonts which are incorrectly converted from probably */
- /* Type 1 to CFF, and some parsers seem to accept it */
-
- FT_TRACE4(( " closepath (invalid op)\n" ));
-
- args = stack;
- break;
-
- case cff_op_hsbw:
- /* this is an invalid Type 2 operator; however, there */
- /* exist fonts which are incorrectly converted from probably */
- /* Type 1 to CFF, and some parsers seem to accept it */
-
- FT_TRACE4(( " hsbw (invalid op)\n" ));
-
- decoder->glyph_width = decoder->nominal_width + ( args[1] >> 16 );
-
- decoder->builder.left_bearing.x = args[0];
- decoder->builder.left_bearing.y = 0;
-
- x = decoder->builder.pos_x + args[0];
- y = decoder->builder.pos_y;
- args = stack;
- break;
-
- case cff_op_sbw:
- /* this is an invalid Type 2 operator; however, there */
- /* exist fonts which are incorrectly converted from probably */
- /* Type 1 to CFF, and some parsers seem to accept it */
-
- FT_TRACE4(( " sbw (invalid op)\n" ));
-
- decoder->glyph_width = decoder->nominal_width + ( args[2] >> 16 );
-
- decoder->builder.left_bearing.x = args[0];
- decoder->builder.left_bearing.y = args[1];
-
- x = decoder->builder.pos_x + args[0];
- y = decoder->builder.pos_y + args[1];
- args = stack;
- break;
-
- case cff_op_setcurrentpoint:
- /* this is an invalid Type 2 operator; however, there */
- /* exist fonts which are incorrectly converted from probably */
- /* Type 1 to CFF, and some parsers seem to accept it */
-
- FT_TRACE4(( " setcurrentpoint (invalid op)\n" ));
-
- x = decoder->builder.pos_x + args[0];
- y = decoder->builder.pos_y + args[1];
- args = stack;
- break;
-
- case cff_op_callothersubr:
- /* this is an invalid Type 2 operator; however, there */
- /* exist fonts which are incorrectly converted from probably */
- /* Type 1 to CFF, and some parsers seem to accept it */
-
- FT_TRACE4(( " callothersubr (invalid op)\n" ));
-
- /* subsequent `pop' operands should add the arguments, */
- /* this is the implementation described for `unknown' other */
- /* subroutines in the Type1 spec. */
- /* */
- /* XXX Fix return arguments (see discussion below). */
- args -= 2 + ( args[-2] >> 16 );
- if ( args < stack )
- goto Stack_Underflow;
- break;
-
- case cff_op_pop:
- /* this is an invalid Type 2 operator; however, there */
- /* exist fonts which are incorrectly converted from probably */
- /* Type 1 to CFF, and some parsers seem to accept it */
-
- FT_TRACE4(( " pop (invalid op)\n" ));
-
- /* XXX Increasing `args' is wrong: After a certain number of */
- /* `pop's we get a stack overflow. Reason for doing it is */
- /* code like this (actually found in a CFF font): */
- /* */
- /* 17 1 3 callothersubr */
- /* pop */
- /* callsubr */
- /* */
- /* Since we handle `callothersubr' as a no-op, and */
- /* `callsubr' needs at least one argument, `pop' can't be a */
- /* no-op too as it basically should be. */
- /* */
- /* The right solution would be to provide real support for */
- /* `callothersubr' as done in `t1decode.c', however, given */
- /* the fact that CFF fonts with `pop' are invalid, it is */
- /* questionable whether it is worth the time. */
- args++;
- break;
-
- case cff_op_and:
- {
- FT_Fixed cond = args[0] && args[1];
-
-
- FT_TRACE4(( " and\n" ));
-
- args[0] = cond ? 0x10000L : 0;
- args++;
- }
- break;
-
- case cff_op_or:
- {
- FT_Fixed cond = args[0] || args[1];
-
-
- FT_TRACE4(( " or\n" ));
-
- args[0] = cond ? 0x10000L : 0;
- args++;
- }
- break;
-
- case cff_op_eq:
- {
- FT_Fixed cond = !args[0];
-
-
- FT_TRACE4(( " eq\n" ));
-
- args[0] = cond ? 0x10000L : 0;
- args++;
- }
- break;
-
- case cff_op_ifelse:
- {
- FT_Fixed cond = ( args[2] <= args[3] );
-
-
- FT_TRACE4(( " ifelse\n" ));
-
- if ( !cond )
- args[0] = args[1];
- args++;
- }
- break;
-
- case cff_op_callsubr:
- {
- FT_UInt idx = (FT_UInt)( ( args[0] >> 16 ) +
- decoder->locals_bias );
-
-
- FT_TRACE4(( " callsubr (idx %d, entering level %d)\n",
- idx,
- zone - decoder->zones + 1 ));
-
- if ( idx >= decoder->num_locals )
- {
- FT_ERROR(( "cff_decoder_parse_charstrings:"
- " invalid local subr index\n" ));
- goto Syntax_Error;
- }
-
- if ( zone - decoder->zones >= CFF_MAX_SUBRS_CALLS )
- {
- FT_ERROR(( "cff_decoder_parse_charstrings:"
- " too many nested subrs\n" ));
- goto Syntax_Error;
- }
-
- zone->cursor = ip; /* save current instruction pointer */
-
- zone++;
- zone->base = decoder->locals[idx];
- zone->limit = decoder->locals[idx + 1];
- zone->cursor = zone->base;
-
- if ( !zone->base || zone->limit == zone->base )
- {
- FT_ERROR(( "cff_decoder_parse_charstrings:"
- " invoking empty subrs\n" ));
- goto Syntax_Error;
- }
-
- decoder->zone = zone;
- ip = zone->base;
- limit = zone->limit;
- }
- break;
-
- case cff_op_callgsubr:
- {
- FT_UInt idx = (FT_UInt)( ( args[0] >> 16 ) +
- decoder->globals_bias );
-
-
- FT_TRACE4(( " callgsubr (idx %d, entering level %d)\n",
- idx,
- zone - decoder->zones + 1 ));
-
- if ( idx >= decoder->num_globals )
- {
- FT_ERROR(( "cff_decoder_parse_charstrings:"
- " invalid global subr index\n" ));
- goto Syntax_Error;
- }
-
- if ( zone - decoder->zones >= CFF_MAX_SUBRS_CALLS )
- {
- FT_ERROR(( "cff_decoder_parse_charstrings:"
- " too many nested subrs\n" ));
- goto Syntax_Error;
- }
-
- zone->cursor = ip; /* save current instruction pointer */
-
- zone++;
- zone->base = decoder->globals[idx];
- zone->limit = decoder->globals[idx + 1];
- zone->cursor = zone->base;
-
- if ( !zone->base || zone->limit == zone->base )
- {
- FT_ERROR(( "cff_decoder_parse_charstrings:"
- " invoking empty subrs\n" ));
- goto Syntax_Error;
- }
-
- decoder->zone = zone;
- ip = zone->base;
- limit = zone->limit;
- }
- break;
-
- case cff_op_return:
- FT_TRACE4(( " return (leaving level %d)\n",
- decoder->zone - decoder->zones ));
-
- if ( decoder->zone <= decoder->zones )
- {
- FT_ERROR(( "cff_decoder_parse_charstrings:"
- " unexpected return\n" ));
- goto Syntax_Error;
- }
-
- decoder->zone--;
- zone = decoder->zone;
- ip = zone->cursor;
- limit = zone->limit;
- break;
-
- default:
- Unimplemented:
- FT_ERROR(( "Unimplemented opcode: %d", ip[-1] ));
-
- if ( ip[-1] == 12 )
- FT_ERROR(( " %d", ip[0] ));
- FT_ERROR(( "\n" ));
-
- return FT_THROW( Unimplemented_Feature );
- }
-
- decoder->top = args;
-
- if ( decoder->top - stack >= CFF_MAX_OPERANDS )
- goto Stack_Overflow;
-
- } /* general operator processing */
-
- } /* while ip < limit */
-
- FT_TRACE4(( "..end..\n\n" ));
-
- Fail:
- return error;
-
- Syntax_Error:
- FT_TRACE4(( "cff_decoder_parse_charstrings: syntax error\n" ));
- return FT_THROW( Invalid_File_Format );
-
- Stack_Underflow:
- FT_TRACE4(( "cff_decoder_parse_charstrings: stack underflow\n" ));
- return FT_THROW( Too_Few_Arguments );
-
- Stack_Overflow:
- FT_TRACE4(( "cff_decoder_parse_charstrings: stack overflow\n" ));
- return FT_THROW( Stack_Overflow );
- }
-
-#endif /* CFF_CONFIG_OPTION_OLD_ENGINE */
-
-
/*************************************************************************/
/*************************************************************************/
/*************************************************************************/
@@ -2559,11 +142,14 @@
FT_Int glyph_index;
CFF_Font cff = (CFF_Font)face->other;
+ PSAux_Service psaux = (PSAux_Service)face->psaux;
+ const CFF_Decoder_Funcs decoder_funcs = psaux->cff_decoder_funcs;
+
*max_advance = 0;
/* Initialize load decoder */
- cff_decoder_init( &decoder, face, 0, 0, 0, 0 );
+ decoder_funcs->init( &decoder, face, 0, 0, 0, 0, 0, 0 );
decoder.builder.metrics_only = 1;
decoder.builder.load_points = 0;
@@ -2582,11 +168,12 @@
&charstring, &charstring_len );
if ( !error )
{
- error = cff_decoder_prepare( &decoder, size, glyph_index );
+ error = decoder_funcs->prepare( &decoder, size, glyph_index );
if ( !error )
- error = cff_decoder_parse_charstrings( &decoder,
- charstring,
- charstring_len );
+ error = decoder_funcs->parse_charstrings_old( &decoder,
+ charstring,
+ charstring_len,
+ 0 );
cff_free_glyph_data( face, &charstring, &charstring_len );
}
@@ -2612,10 +199,14 @@
{
FT_Error error;
CFF_Decoder decoder;
+ PS_Decoder psdecoder;
TT_Face face = (TT_Face)glyph->root.face;
FT_Bool hinting, scaled, force_scaling;
CFF_Font cff = (CFF_Font)face->extra.data;
+ PSAux_Service psaux = (PSAux_Service)face->psaux;
+ const CFF_Decoder_Funcs decoder_funcs = psaux->cff_decoder_funcs;
+
FT_Matrix font_matrix;
FT_Vector font_offset;
@@ -2805,7 +396,7 @@
{
#ifdef CFF_CONFIG_OPTION_OLD_ENGINE
- CFF_Driver driver = (CFF_Driver)FT_FACE_DRIVER( face );
+ PS_Driver driver = (PS_Driver)FT_FACE_DRIVER( face );
#endif
@@ -2813,9 +404,12 @@
FT_ULong charstring_len;
- cff_decoder_init( &decoder, face, size, glyph, hinting,
- FT_LOAD_TARGET_MODE( load_flags ) );
+ decoder_funcs->init( &decoder, face, size, glyph, hinting,
+ FT_LOAD_TARGET_MODE( load_flags ),
+ cff_get_glyph_data,
+ cff_free_glyph_data );
+ /* this is for pure CFFs */
if ( load_flags & FT_LOAD_ADVANCE_ONLY )
decoder.width_only = TRUE;
@@ -2828,22 +422,25 @@
if ( error )
goto Glyph_Build_Finished;
- error = cff_decoder_prepare( &decoder, size, glyph_index );
+ error = decoder_funcs->prepare( &decoder, size, glyph_index );
if ( error )
goto Glyph_Build_Finished;
#ifdef CFF_CONFIG_OPTION_OLD_ENGINE
/* choose which CFF renderer to use */
- if ( driver->hinting_engine == FT_CFF_HINTING_FREETYPE )
- error = cff_decoder_parse_charstrings( &decoder,
- charstring,
- charstring_len );
+ if ( driver->hinting_engine == FT_HINTING_FREETYPE )
+ error = decoder_funcs->parse_charstrings_old( &decoder,
+ charstring,
+ charstring_len,
+ 0 );
else
#endif
{
- error = cf2_decoder_parse_charstrings( &decoder,
- charstring,
- charstring_len );
+ psaux->ps_decoder_init( &psdecoder, &decoder, FALSE );
+
+ error = decoder_funcs->parse_charstrings( &psdecoder,
+ charstring,
+ charstring_len );
/* Adobe's engine uses 16.16 numbers everywhere; */
/* as a consequence, glyphs larger than 2000ppem get rejected */
@@ -2856,9 +453,9 @@
force_scaling = TRUE;
glyph->hint = hinting;
- error = cf2_decoder_parse_charstrings( &decoder,
- charstring,
- charstring_len );
+ error = decoder_funcs->parse_charstrings( &psdecoder,
+ charstring,
+ charstring_len );
}
}
@@ -2896,7 +493,7 @@
Glyph_Build_Finished:
/* save new glyph tables, if no error */
if ( !error )
- cff_builder_done( &decoder.builder );
+ decoder.builder.funcs.done( &decoder.builder );
/* XXX: anything to do for broken glyph entry? */
}
diff --git a/src/3rdparty/freetype/src/cff/cffgload.h b/src/3rdparty/freetype/src/cff/cffgload.h
index 5f2655f3d9..803f3974fc 100644
--- a/src/3rdparty/freetype/src/cff/cffgload.h
+++ b/src/3rdparty/freetype/src/cff/cffgload.h
@@ -4,7 +4,7 @@
/* */
/* OpenType Glyph Loader (specification). */
/* */
-/* Copyright 1996-2015 by */
+/* Copyright 1996-2018 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -16,125 +16,17 @@
/***************************************************************************/
-#ifndef __CFFGLOAD_H__
-#define __CFFGLOAD_H__
+#ifndef CFFGLOAD_H_
+#define CFFGLOAD_H_
#include <ft2build.h>
#include FT_FREETYPE_H
-#include "cffobjs.h"
+#include FT_INTERNAL_CFF_OBJECTS_TYPES_H
FT_BEGIN_HEADER
-
-#define CFF_MAX_OPERANDS 48
-#define CFF_MAX_SUBRS_CALLS 16 /* maximum subroutine nesting; */
- /* only 10 are allowed but there exist */
- /* fonts like `HiraKakuProN-W3.ttf' */
- /* (Hiragino Kaku Gothic ProN W3; */
- /* 8.2d6e1; 2014-12-19) that exceed */
- /* this limit */
-#define CFF_MAX_TRANS_ELEMENTS 32
-
-
- /*************************************************************************/
- /* */
- /* <Structure> */
- /* CFF_Builder */
- /* */
- /* <Description> */
- /* A structure used during glyph loading to store its outline. */
- /* */
- /* <Fields> */
- /* memory :: The current memory object. */
- /* */
- /* face :: The current face object. */
- /* */
- /* glyph :: The current glyph slot. */
- /* */
- /* loader :: The current glyph loader. */
- /* */
- /* base :: The base glyph outline. */
- /* */
- /* current :: The current glyph outline. */
- /* */
- /* pos_x :: The horizontal translation (if composite glyph). */
- /* */
- /* pos_y :: The vertical translation (if composite glyph). */
- /* */
- /* left_bearing :: The left side bearing point. */
- /* */
- /* advance :: The horizontal advance vector. */
- /* */
- /* bbox :: Unused. */
- /* */
- /* path_begun :: A flag which indicates that a new path has begun. */
- /* */
- /* load_points :: If this flag is not set, no points are loaded. */
- /* */
- /* no_recurse :: Set but not used. */
- /* */
- /* metrics_only :: A boolean indicating that we only want to compute */
- /* the metrics of a given glyph, not load all of its */
- /* points. */
- /* */
- /* hints_funcs :: Auxiliary pointer for hinting. */
- /* */
- /* hints_globals :: Auxiliary pointer for hinting. */
- /* */
- typedef struct CFF_Builder_
- {
- FT_Memory memory;
- TT_Face face;
- CFF_GlyphSlot glyph;
- FT_GlyphLoader loader;
- FT_Outline* base;
- FT_Outline* current;
-
- FT_Pos pos_x;
- FT_Pos pos_y;
-
- FT_Vector left_bearing;
- FT_Vector advance;
-
- FT_BBox bbox; /* bounding box */
- FT_Bool path_begun;
- FT_Bool load_points;
- FT_Bool no_recurse;
-
- FT_Bool metrics_only;
-
- void* hints_funcs; /* hinter-specific */
- void* hints_globals; /* hinter-specific */
-
- } CFF_Builder;
-
-
- FT_LOCAL( FT_Error )
- cff_check_points( CFF_Builder* builder,
- FT_Int count );
-
- FT_LOCAL( void )
- cff_builder_add_point( CFF_Builder* builder,
- FT_Pos x,
- FT_Pos y,
- FT_Byte flag );
- FT_LOCAL( FT_Error )
- cff_builder_add_point1( CFF_Builder* builder,
- FT_Pos x,
- FT_Pos y );
- FT_LOCAL( FT_Error )
- cff_builder_start_point( CFF_Builder* builder,
- FT_Pos x,
- FT_Pos y );
- FT_LOCAL( void )
- cff_builder_close_contour( CFF_Builder* builder );
-
-
- FT_LOCAL( FT_Int )
- cff_lookup_glyph_by_stdcharcode( CFF_Font cff,
- FT_Int charcode );
FT_LOCAL( FT_Error )
cff_get_glyph_data( TT_Face face,
FT_UInt glyph_index,
@@ -146,74 +38,6 @@ FT_BEGIN_HEADER
FT_ULong length );
- /* execution context charstring zone */
-
- typedef struct CFF_Decoder_Zone_
- {
- FT_Byte* base;
- FT_Byte* limit;
- FT_Byte* cursor;
-
- } CFF_Decoder_Zone;
-
-
- typedef struct CFF_Decoder_
- {
- CFF_Builder builder;
- CFF_Font cff;
-
- FT_Fixed stack[CFF_MAX_OPERANDS + 1];
- FT_Fixed* top;
-
- CFF_Decoder_Zone zones[CFF_MAX_SUBRS_CALLS + 1];
- CFF_Decoder_Zone* zone;
-
- FT_Int flex_state;
- FT_Int num_flex_vectors;
- FT_Vector flex_vectors[7];
-
- FT_Pos glyph_width;
- FT_Pos nominal_width;
-
- FT_Bool read_width;
- FT_Bool width_only;
- FT_Int num_hints;
- FT_Fixed buildchar[CFF_MAX_TRANS_ELEMENTS];
-
- FT_UInt num_locals;
- FT_UInt num_globals;
-
- FT_Int locals_bias;
- FT_Int globals_bias;
-
- FT_Byte** locals;
- FT_Byte** globals;
-
- FT_Byte** glyph_names; /* for pure CFF fonts only */
- FT_UInt num_glyphs; /* number of glyphs in font */
-
- FT_Render_Mode hint_mode;
-
- FT_Bool seac;
-
- CFF_SubFont current_subfont; /* for current glyph_index */
-
- } CFF_Decoder;
-
-
- FT_LOCAL( void )
- cff_decoder_init( CFF_Decoder* decoder,
- TT_Face face,
- CFF_Size size,
- CFF_GlyphSlot slot,
- FT_Bool hinting,
- FT_Render_Mode hint_mode );
-
- FT_LOCAL( FT_Error )
- cff_decoder_prepare( CFF_Decoder* decoder,
- CFF_Size size,
- FT_UInt glyph_index );
-
#if 0 /* unused until we support pure CFF fonts */
/* Compute the maximum advance width of a font through quick parsing */
@@ -223,12 +47,6 @@ FT_BEGIN_HEADER
#endif /* 0 */
-#ifdef CFF_CONFIG_OPTION_OLD_ENGINE
- FT_LOCAL( FT_Error )
- cff_decoder_parse_charstrings( CFF_Decoder* decoder,
- FT_Byte* charstring_base,
- FT_ULong charstring_len );
-#endif
FT_LOCAL( FT_Error )
cff_slot_load( CFF_GlyphSlot glyph,
@@ -239,7 +57,7 @@ FT_BEGIN_HEADER
FT_END_HEADER
-#endif /* __CFFGLOAD_H__ */
+#endif /* CFFGLOAD_H_ */
/* END */
diff --git a/src/3rdparty/freetype/src/cff/cffload.c b/src/3rdparty/freetype/src/cff/cffload.c
index c61222d651..1c6fe51566 100644
--- a/src/3rdparty/freetype/src/cff/cffload.c
+++ b/src/3rdparty/freetype/src/cff/cffload.c
@@ -4,7 +4,7 @@
/* */
/* OpenType and CFF data/program tables loader (body). */
/* */
-/* Copyright 1996-2015 by */
+/* Copyright 1996-2018 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -22,6 +22,12 @@
#include FT_INTERNAL_STREAM_H
#include FT_TRUETYPE_TAGS_H
#include FT_TYPE1_TABLES_H
+#include FT_INTERNAL_POSTSCRIPT_AUX_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"
@@ -29,6 +35,9 @@
#include "cfferrs.h"
+#define FT_FIXED_ONE ( (FT_Fixed)0x10000 )
+
+
#if 1
static const FT_UShort cff_isoadobe_charset[229] =
@@ -225,19 +234,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 +281,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 +333,7 @@
FT_FRAME_RELEASE( idx->bytes );
FT_FREE( idx->offsets );
- FT_MEM_ZERO( idx, sizeof ( *idx ) );
+ FT_ZERO( idx );
}
}
@@ -323,7 +346,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 +358,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;
@@ -382,28 +405,31 @@
static FT_Error
cff_index_get_pointers( CFF_Index idx,
FT_Byte*** table,
- FT_Byte** pool )
+ FT_Byte** pool,
+ FT_ULong* pool_size )
{
FT_Error error = FT_Err_Ok;
FT_Memory memory = idx->stream->memory;
FT_Byte** t = NULL;
FT_Byte* new_bytes = NULL;
+ FT_ULong new_size;
*table = NULL;
- if ( idx->offsets == NULL )
+ if ( !idx->offsets )
{
error = cff_index_load_offsets( idx );
if ( error )
goto Exit;
}
- if ( idx->count > 0 &&
- !FT_NEW_ARRAY( t, idx->count + 1 ) &&
- ( !pool || !FT_ALLOC( new_bytes,
- idx->data_size + idx->count ) ) )
+ new_size = idx->data_size + idx->count;
+
+ if ( idx->count > 0 &&
+ !FT_NEW_ARRAY( t, idx->count + 1 ) &&
+ ( !pool || !FT_ALLOC( new_bytes, new_size ) ) )
{
FT_ULong n, cur_offset;
FT_ULong extra = 0;
@@ -459,6 +485,8 @@
if ( pool )
*pool = new_bytes;
+ if ( pool_size )
+ *pool_size = new_size;
}
Exit:
@@ -488,7 +516,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 );
@@ -501,8 +529,8 @@
{
element++;
off2 = cff_index_read_offset( idx, &error );
- }
- while ( off2 == 0 && element < idx->count );
+
+ } while ( off2 == 0 && element < idx->count );
}
}
else /* use offsets table */
@@ -584,20 +612,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 );
@@ -719,6 +753,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:
@@ -771,6 +810,7 @@
;
}
+ Exit:
return fd;
}
@@ -809,7 +849,7 @@
/* When multiple GIDs map to the same CID, we choose the lowest */
/* GID. This is not described in any spec, but it matches the */
/* behaviour of recent Acroread versions. */
- for ( j = (FT_Long)num_glyphs - 1; j >= 0 ; j-- )
+ for ( j = (FT_Long)num_glyphs - 1; j >= 0; j-- )
charset->cids[charset->sids[j]] = (FT_UShort)j;
charset->max_cid = max_cid;
@@ -871,8 +911,8 @@
FT_UShort glyph_sid;
- /* If the the offset is greater than 2, we have to parse the */
- /* charset table. */
+ /* If the offset is greater than 2, we have to parse the charset */
+ /* table. */
if ( offset > 2 )
{
FT_UInt j;
@@ -1049,6 +1089,523 @@
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 = &region->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 argument%s\n",
+ count,
+ count == 1 ? "" : "s" ));
+
+ 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_UInt32 sum;
+
+
+ /* convert inputs to 16.16 fixed point */
+ sum = cff_parse_num( parser, &parser->stack[i + base] ) * 0x10000;
+
+ for ( j = 1; j < blend->lenBV; j++ )
+ sum += cff_parse_num( parser, &parser->stack[delta++] ) * *weight++;
+
+ /* 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_Byte)( sum >> 24 );
+ *subFont->blend_top++ = (FT_Byte)( sum >> 16 );
+ *subFont->blend_top++ = (FT_Byte)( sum >> 8 );
+ *subFont->blend_top++ = (FT_Byte)sum;
+ }
+
+ /* 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 &&
+ ft_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;
+
+
+ if (mm)
+ mm->done_blend( FT_FACE( face ) );
+ }
+
+#endif /* TT_CONFIG_OPTION_GX_VAR_SUPPORT */
+
+
+ static void
cff_encoding_done( CFF_Encoding encoding )
{
encoding->format = 0;
@@ -1300,26 +1857,156 @@
}
+ /* 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;
+
+ /* some sanitizing to avoid overflows later on; */
+ /* the upper limits are ad-hoc values */
+ if ( priv->blue_shift > 1000 || priv->blue_shift < 0 )
+ {
+ FT_TRACE2(( "cff_load_private_dict:"
+ " setting unlikely BlueShift value %d to default (7)\n",
+ priv->blue_shift ));
+ priv->blue_shift = 7;
+ }
+
+ if ( priv->blue_fuzz > 1000 || priv->blue_fuzz < 0 )
+ {
+ FT_TRACE2(( "cff_load_private_dict:"
+ " setting unlikely BlueFuzz value %d to default (1)\n",
+ priv->blue_fuzz ));
+ priv->blue_fuzz = 1;
+ }
+
+ 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;
+ }
+
+
+ /* 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 );
+ CFF_FontRecDict top = &subfont->font_dict;
+ CFF_Private priv = &subfont->private_dict;
+
+ PSAux_Service psaux = (PSAux_Service)face->psaux;
+
+ 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;
@@ -1342,14 +2029,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;
@@ -1358,34 +2066,63 @@
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 ) );
+ /*
+ * 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 )
+ {
+ PS_Driver driver = (PS_Driver)FT_FACE_DRIVER( face );
- 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 );
+ subfont->random = (FT_UInt32)driver->random_seed;
+ if ( driver->random_seed )
+ {
+ do
+ {
+ driver->random_seed =
+ (FT_Int32)psaux->cff_random( (FT_UInt32)driver->random_seed );
- if ( FT_STREAM_SEEK( base_offset + font->font_dict.private_offset ) ||
- FT_FRAME_ENTER( font->font_dict.private_size ) )
- goto Exit;
+ } 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)psaux->cff_random(
+ (FT_UInt32)face->root.internal->random_seed );
- 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;
+ } while ( face->root.internal->random_seed < 0 );
+ }
+ }
- /* ensure that `num_blue_values' is even */
- priv->num_blue_values &= ~1;
+ if ( !subfont->random )
+ subfont->random = (FT_UInt32)priv->initial_random_seed;
}
/* read the local subrs, if any */
@@ -1395,17 +2132,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 );
+ 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;
}
@@ -1418,6 +2157,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 );
}
}
@@ -1427,18 +2170,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
};
@@ -1453,42 +2197,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 ) ) )
- 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;
@@ -1534,34 +2369,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" ));
@@ -1582,17 +2431,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 );
@@ -1614,13 +2472,13 @@
font->num_glyphs = font->charstrings_index.count;
error = cff_index_get_pointers( &font->global_subrs_index,
- &font->global_subrs, NULL );
+ &font->global_subrs, NULL, NULL );
if ( error )
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 );
@@ -1668,7 +2526,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++ )
@@ -1680,6 +2538,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 );
@@ -1697,6 +2556,8 @@
font->cf2_instance.finalizer( font->cf2_instance.data );
FT_FREE( font->cf2_instance.data );
}
+
+ FT_FREE( font->font_extra );
}
diff --git a/src/3rdparty/freetype/src/cff/cffload.h b/src/3rdparty/freetype/src/cff/cffload.h
index 459e7b0446..14d14e2112 100644
--- a/src/3rdparty/freetype/src/cff/cffload.h
+++ b/src/3rdparty/freetype/src/cff/cffload.h
@@ -4,7 +4,7 @@
/* */
/* OpenType & CFF data/program tables loader (specification). */
/* */
-/* Copyright 1996-2015 by */
+/* Copyright 1996-2018 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -16,12 +16,14 @@
/***************************************************************************/
-#ifndef __CFFLOAD_H__
-#define __CFFLOAD_H__
+#ifndef CFFLOAD_H_
+#define CFFLOAD_H_
#include <ft2build.h>
-#include "cfftypes.h"
+#include FT_INTERNAL_CFF_TYPES_H
+#include "cffparse.h"
+#include FT_INTERNAL_CFF_OBJECTS_TYPES_H /* for CFF_Face */
FT_BEGIN_HEADER
@@ -60,24 +62,64 @@ FT_BEGIN_HEADER
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
-#endif /* __CFFLOAD_H__ */
+#endif /* CFFLOAD_H_ */
/* END */
diff --git a/src/3rdparty/freetype/src/cff/cffobjs.c b/src/3rdparty/freetype/src/cff/cffobjs.c
index 0e0d5b034b..a2d7aec65e 100644
--- a/src/3rdparty/freetype/src/cff/cffobjs.c
+++ b/src/3rdparty/freetype/src/cff/cffobjs.c
@@ -4,7 +4,7 @@
/* */
/* OpenType objects manager (body). */
/* */
-/* Copyright 1996-2015 by */
+/* Copyright 1996-2018 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -25,8 +25,15 @@
#include FT_TRUETYPE_IDS_H
#include FT_TRUETYPE_TAGS_H
#include FT_INTERNAL_SFNT_H
-#include FT_CFF_DRIVER_H
+#include FT_DRIVER_H
+#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_INTERNAL_CFF_OBJECTS_TYPES_H
#include "cffobjs.h"
#include "cffload.h"
#include "cffcmap.h"
@@ -34,6 +41,9 @@
#include "cfferrs.h"
+#include FT_INTERNAL_POSTSCRIPT_AUX_H
+#include FT_SERVICE_CFF_TABLE_LOAD_H
+
/*************************************************************************/
/* */
@@ -49,9 +59,6 @@
/* */
/* SIZE FUNCTIONS */
/* */
- /* Note that we store the global hints in the size's `internal' root */
- /* field. */
- /* */
/*************************************************************************/
@@ -75,10 +82,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 +106,7 @@
funcs->destroy( internal->subfonts[i - 1] );
}
- /* `internal' is freed by destroy_size (in ftobjs.c) */
+ FT_FREE( internal );
}
}
@@ -114,7 +122,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 +202,7 @@
goto Exit;
}
- cffsize->internal = (FT_Size_Internal)(void*)internal;
+ cffsize->internal->module_data = internal;
}
size->strike_index = 0xFFFFFFFFUL;
@@ -224,7 +232,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 +304,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;
@@ -405,7 +413,7 @@
remove_subset_prefix( FT_String* name )
{
FT_Int32 idx = 0;
- FT_Int32 length = (FT_Int32)strlen( name ) + 1;
+ FT_Int32 length = (FT_Int32)ft_strlen( name ) + 1;
FT_Bool continue_search = 1;
@@ -442,15 +450,15 @@
FT_Int32 family_name_length, style_name_length;
- family_name_length = (FT_Int32)strlen( family_name );
- style_name_length = (FT_Int32)strlen( style_name );
+ family_name_length = (FT_Int32)ft_strlen( family_name );
+ style_name_length = (FT_Int32)ft_strlen( style_name );
if ( family_name_length > style_name_length )
{
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 +477,7 @@
family_name[idx] == ' ' ||
family_name[idx] == '_' ||
family_name[idx] == '+' ) )
- --idx;
+ idx--;
if ( idx > 0 )
family_name[idx + 1] = '\0';
@@ -490,13 +498,16 @@
SFNT_Service sfnt;
FT_Service_PsCMaps psnames;
PSHinter_Service pshinter;
+ PSAux_Service psaux;
+ FT_Service_CFFLoad cffload;
FT_Bool pure_cff = 1;
+ FT_Bool cff2 = 0;
FT_Bool sfnt_format = 0;
FT_Library library = cffface->driver->root.library;
- sfnt = (SFNT_Service)FT_Get_Module_Interface(
- library, "sfnt" );
+ sfnt = (SFNT_Service)FT_Get_Module_Interface( library,
+ "sfnt" );
if ( !sfnt )
{
FT_ERROR(( "cff_face_init: cannot access `sfnt' module\n" ));
@@ -506,8 +517,20 @@
FT_FACE_FIND_GLOBAL_SERVICE( face, psnames, POSTSCRIPT_CMAPS );
- pshinter = (PSHinter_Service)FT_Get_Module_Interface(
- library, "pshinter" );
+ pshinter = (PSHinter_Service)FT_Get_Module_Interface( library,
+ "pshinter" );
+
+ psaux = (PSAux_Service)FT_Get_Module_Interface( library,
+ "psaux" );
+ if ( !psaux )
+ {
+ FT_ERROR(( "cff_face_init: cannot access `psaux' module\n" ));
+ error = FT_THROW( Missing_Module );
+ goto Exit;
+ }
+ face->psaux = psaux;
+
+ FT_FACE_FIND_GLOBAL_SERVICE( face, cffload, CFF_LOAD );
FT_TRACE2(( "CFF driver\n" ));
@@ -516,6 +539,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 +577,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,17 +613,27 @@
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;
/* if we are performing a simple font format check, exit immediately */
/* (this is here for pure CFF) */
if ( face_index < 0 )
+ {
+ cffface->num_faces = (FT_Long)cff->num_faces;
return FT_Err_Ok;
+ }
cff->pshinter = pshinter;
cff->psnames = psnames;
+ cff->cffload = cffload;
cffface->face_index = face_index & 0xFFFF;
@@ -622,22 +666,78 @@
FT_TRACE4(( "SIDs\n" ));
/* dump string index, including default strings for convenience */
- for ( idx = 0; idx < cff->num_strings + 390; idx++ )
+ for ( idx = 0; idx <= 390; idx++ )
{
s = cff_index_get_sid_string( cff, idx );
if ( s )
- FT_TRACE4((" %5d %s\n", idx, s ));
+ FT_TRACE4(( " %5d %s\n", idx, s ));
+ }
+
+ /* In Multiple Master CFFs, two SIDs hold the Normalize Design */
+ /* Vector (NDV) and Convert Design Vector (CDV) charstrings, */
+ /* which may contain NULL bytes in the middle of the data, too. */
+ /* We thus access `cff->strings' directly. */
+ for ( idx = 1; idx < cff->num_strings; idx++ )
+ {
+ FT_Byte* s1 = cff->strings[idx - 1];
+ FT_Byte* s2 = cff->strings[idx];
+ FT_PtrDist s1len = s2 - s1 - 1; /* without the final NULL byte */
+ FT_PtrDist l;
+
+
+ FT_TRACE4(( " %5d ", idx + 390 ));
+ for ( l = 0; l < s1len; l++ )
+ FT_TRACE4(( "%c", s1[l] ));
+ FT_TRACE4(( "\n" ));
+ }
+
+ /* print last element */
+ if ( cff->num_strings )
+ {
+ FT_Byte* s1 = cff->strings[cff->num_strings - 1];
+ FT_Byte* s2 = cff->string_pool + cff->string_pool_size;
+ FT_PtrDist s1len = s2 - s1 - 1;
+ FT_PtrDist l;
+
+
+ FT_TRACE4(( " %5d ", cff->num_strings + 390 ));
+ for ( l = 0; l < s1len; l++ )
+ FT_TRACE4(( "%c", s1[l] ));
+ FT_TRACE4(( "\n" ));
}
}
#endif /* FT_DEBUG_LEVEL_TRACE */
+#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
+ {
+ FT_Service_MultiMasters mm = (FT_Service_MultiMasters)face->mm;
+ FT_Service_MetricsVariations var = (FT_Service_MetricsVariations)face->var;
+
+ FT_UInt instance_index = (FT_UInt)face_index >> 16;
+
+
+ if ( FT_HAS_MULTIPLE_MASTERS( cffface ) &&
+ mm &&
+ instance_index > 0 )
+ {
+ error = mm->set_instance( cffface, instance_index );
+ if ( error )
+ goto Exit;
+
+ if ( var )
+ var->metrics_adjust( cffface );
+ }
+ }
+#endif /* TT_CONFIG_OPTION_GX_VAR_SUPPORT */
+
if ( !dict->has_font_matrix )
dict->units_per_em = pure_cff ? 1000 : face->root.units_per_EM;
- /* Normalize the font matrix so that `matrix->yy' is 1; the */
- /* scaling is done with `units_per_em' then (at this point, */
- /* it already contains the scaling factor, but without */
- /* normalization of the matrix). */
+ /* Normalize the font matrix so that `matrix->yy' is 1; if */
+ /* it is zero, we use `matrix->yx' instead. The scaling is */
+ /* done with `units_per_em' then (at this point, it already */
+ /* contains the scaling factor, but without normalization */
+ /* of the matrix). */
/* */
/* Note that the offsets must be expressed in integer font */
/* units. */
@@ -646,9 +746,12 @@
FT_Matrix* matrix = &dict->font_matrix;
FT_Vector* offset = &dict->font_offset;
FT_ULong* upm = &dict->units_per_em;
- FT_Fixed temp = FT_ABS( matrix->yy );
+ FT_Fixed temp;
+ temp = matrix->yy ? FT_ABS( matrix->yy )
+ : FT_ABS( matrix->yx );
+
if ( temp != 0x10000L )
{
*upm = (FT_ULong)FT_DivFix( (FT_Long)*upm, temp );
@@ -716,7 +819,10 @@
matrix = &sub->font_matrix;
offset = &sub->font_offset;
upm = &sub->units_per_em;
- temp = FT_ABS( matrix->yy );
+
+ temp = matrix->yy ? FT_ABS( matrix->yy )
+ : FT_ABS( matrix->yx );
+
if ( temp != 0x10000L )
{
@@ -762,7 +868,8 @@
cffface->height = (FT_Short)( ( cffface->units_per_EM * 12 ) / 10 );
if ( cffface->height < cffface->ascender - cffface->descender )
- cffface->height = (FT_Short)( cffface->ascender - cffface->descender );
+ cffface->height = (FT_Short)( cffface->ascender -
+ cffface->descender );
cffface->underline_position =
(FT_Short)( dict->underline_position >> 16 );
@@ -770,28 +877,33 @@
(FT_Short)( dict->underline_thickness >> 16 );
/* retrieve font family & style name */
- cffface->family_name = cff_index_get_name(
- cff,
- (FT_UInt)( face_index & 0xFFFF ) );
+ if ( dict->family_name )
+ {
+ char* family_name;
+
+
+ family_name = cff_index_get_sid_string( cff, dict->family_name );
+ if ( family_name )
+ cffface->family_name = cff_strcpy( memory, family_name );
+ }
+
+ if ( !cffface->family_name )
+ {
+ cffface->family_name = cff_index_get_name(
+ cff,
+ (FT_UInt)( face_index & 0xFFFF ) );
+ if ( cffface->family_name )
+ remove_subset_prefix( cffface->family_name );
+ }
+
if ( cffface->family_name )
{
char* full = cff_index_get_sid_string( cff,
dict->full_name );
char* fullp = full;
char* family = cffface->family_name;
- char* family_name = NULL;
- remove_subset_prefix( cffface->family_name );
-
- if ( dict->family_name )
- {
- family_name = cff_index_get_sid_string( cff,
- dict->family_name );
- if ( family_name )
- family = family_name;
- }
-
/* We try to extract the style name from the full name. */
/* We need to ignore spaces and dashes during the search. */
if ( full && family )
@@ -906,7 +1018,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. */
@@ -917,7 +1028,6 @@
if ( dict->cid_registry != 0xFFFFU && pure_cff )
cffface->face_flags |= FT_FACE_FLAG_CID_KEYED;
-
/*******************************************************************/
/* */
/* Compute char maps. */
@@ -968,7 +1078,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:
@@ -1036,23 +1146,30 @@
FT_FREE( face->extra.data );
}
}
+
+#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
+ cff_done_blend( face );
+ face->blend = NULL;
+#endif
}
FT_LOCAL_DEF( FT_Error )
cff_driver_init( FT_Module module ) /* CFF_Driver */
{
- CFF_Driver driver = (CFF_Driver)module;
+ PS_Driver driver = (PS_Driver)module;
+
+ FT_UInt32 seed;
/* set default property values, cf. `ftcffdrv.h' */
#ifdef CFF_CONFIG_OPTION_OLD_ENGINE
- driver->hinting_engine = FT_CFF_HINTING_FREETYPE;
+ driver->hinting_engine = FT_HINTING_FREETYPE;
#else
- driver->hinting_engine = FT_CFF_HINTING_ADOBE;
+ driver->hinting_engine = FT_HINTING_ADOBE;
#endif
- driver->no_stem_darkening = FALSE;
+ driver->no_stem_darkening = TRUE;
driver->darken_params[0] = CFF_CONFIG_OPTION_DARKENING_PARAMETER_X1;
driver->darken_params[1] = CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y1;
@@ -1063,6 +1180,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/src/3rdparty/freetype/src/cff/cffobjs.h b/src/3rdparty/freetype/src/cff/cffobjs.h
index 3cc953143b..616a25b3b5 100644
--- a/src/3rdparty/freetype/src/cff/cffobjs.h
+++ b/src/3rdparty/freetype/src/cff/cffobjs.h
@@ -4,7 +4,7 @@
/* */
/* OpenType objects manager (specification). */
/* */
-/* Copyright 1996-2015 by */
+/* Copyright 1996-2018 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -16,116 +16,16 @@
/***************************************************************************/
-#ifndef __CFFOBJS_H__
-#define __CFFOBJS_H__
+#ifndef CFFOBJS_H_
+#define CFFOBJS_H_
#include <ft2build.h>
-#include FT_INTERNAL_OBJECTS_H
-#include "cfftypes.h"
-#include FT_INTERNAL_TRUETYPE_TYPES_H
-#include FT_SERVICE_POSTSCRIPT_CMAPS_H
-#include FT_INTERNAL_POSTSCRIPT_HINTS_H
FT_BEGIN_HEADER
- /*************************************************************************/
- /* */
- /* <Type> */
- /* CFF_Driver */
- /* */
- /* <Description> */
- /* A handle to an OpenType driver object. */
- /* */
- typedef struct CFF_DriverRec_* CFF_Driver;
-
- typedef TT_Face CFF_Face;
-
-
- /*************************************************************************/
- /* */
- /* <Type> */
- /* CFF_Size */
- /* */
- /* <Description> */
- /* A handle to an OpenType size object. */
- /* */
- typedef struct CFF_SizeRec_
- {
- FT_SizeRec root;
- FT_ULong strike_index; /* 0xFFFFFFFF to indicate invalid */
-
- } CFF_SizeRec, *CFF_Size;
-
-
- /*************************************************************************/
- /* */
- /* <Type> */
- /* CFF_GlyphSlot */
- /* */
- /* <Description> */
- /* A handle to an OpenType glyph slot object. */
- /* */
- typedef struct CFF_GlyphSlotRec_
- {
- FT_GlyphSlotRec root;
-
- FT_Bool hint;
- FT_Bool scaled;
-
- FT_Fixed x_scale;
- FT_Fixed y_scale;
-
- } CFF_GlyphSlotRec, *CFF_GlyphSlot;
-
-
- /*************************************************************************/
- /* */
- /* <Type> */
- /* CFF_Internal */
- /* */
- /* <Description> */
- /* The interface to the `internal' field of `FT_Size'. */
- /* */
- typedef struct CFF_InternalRec_
- {
- PSH_Globals topfont;
- PSH_Globals subfonts[CFF_MAX_CID_FONTS];
-
- } CFF_InternalRec, *CFF_Internal;
-
-
- /*************************************************************************/
- /* */
- /* Subglyph transformation record. */
- /* */
- typedef struct CFF_Transform_
- {
- FT_Fixed xx, xy; /* transformation matrix coefficients */
- FT_Fixed yx, yy;
- FT_F26Dot6 ox, oy; /* offsets */
-
- } CFF_Transform;
-
-
- /***********************************************************************/
- /* */
- /* CFF driver class. */
- /* */
- typedef struct CFF_DriverRec_
- {
- FT_DriverRec root;
-
- FT_UInt hinting_engine;
- FT_Bool no_stem_darkening;
-
- FT_Int darken_params[8];
-
- } CFF_DriverRec;
-
-
FT_LOCAL( FT_Error )
cff_size_init( FT_Size size ); /* CFF_Size */
@@ -171,15 +71,15 @@ FT_BEGIN_HEADER
/* Driver functions */
/* */
FT_LOCAL( FT_Error )
- cff_driver_init( FT_Module module ); /* CFF_Driver */
+ cff_driver_init( FT_Module module ); /* PS_Driver */
FT_LOCAL( void )
- cff_driver_done( FT_Module module ); /* CFF_Driver */
+ cff_driver_done( FT_Module module ); /* PS_Driver */
FT_END_HEADER
-#endif /* __CFFOBJS_H__ */
+#endif /* CFFOBJS_H_ */
/* END */
diff --git a/src/3rdparty/freetype/src/cff/cffparse.c b/src/3rdparty/freetype/src/cff/cffparse.c
index 063b3517c5..b9611cf548 100644
--- a/src/3rdparty/freetype/src/cff/cffparse.c
+++ b/src/3rdparty/freetype/src/cff/cffparse.c
@@ -4,7 +4,7 @@
/* */
/* CFF token stream parser (body) */
/* */
-/* Copyright 1996-2015 by */
+/* Copyright 1996-2018 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -20,9 +20,12 @@
#include "cffparse.h"
#include FT_INTERNAL_STREAM_H
#include FT_INTERNAL_DEBUG_H
+#include FT_INTERNAL_CALC_H
+#include FT_INTERNAL_POSTSCRIPT_AUX_H
#include "cfferrs.h"
#include "cffpic.h"
+#include "cffload.h"
/*************************************************************************/
@@ -35,18 +38,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_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 );
}
@@ -120,6 +157,22 @@
1000000000L
};
+ /* maximum values allowed for multiplying */
+ /* with the corresponding `power_tens' element */
+ static const FT_Long power_ten_limits[] =
+ {
+ FT_LONG_MAX / 1L,
+ FT_LONG_MAX / 10L,
+ FT_LONG_MAX / 100L,
+ FT_LONG_MAX / 1000L,
+ FT_LONG_MAX / 10000L,
+ FT_LONG_MAX / 100000L,
+ FT_LONG_MAX / 1000000L,
+ FT_LONG_MAX / 10000000L,
+ FT_LONG_MAX / 100000000L,
+ FT_LONG_MAX / 1000000000L,
+ };
+
/* read a real */
static FT_Fixed
@@ -397,28 +450,66 @@
/* 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 )
+ {
+ if ( FT_ABS( val ) > power_ten_limits[scaling] )
+ {
+ val = val > 0 ? 0x7FFFFFFFL : -0x7FFFFFFFL;
+ goto Overflow;
+ }
+
val *= power_tens[scaling];
+ }
if ( val > 0x7FFF )
{
@@ -442,19 +533,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 );
}
@@ -462,13 +555,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;
@@ -516,7 +610,11 @@
if ( parser->top >= parser->stack + 6 )
{
- FT_Long scaling;
+ FT_Fixed values[6];
+ FT_Long scalings[6];
+
+ FT_Long min_scaling, max_scaling;
+ int i;
error = FT_Err_Ok;
@@ -525,22 +623,36 @@
/* We expect a well-formed font matrix, this is, the matrix elements */
/* `xx' and `yy' are of approximately the same magnitude. To avoid */
- /* loss of precision, we use the magnitude of element `xx' to scale */
- /* all other elements. The scaling factor is then contained in the */
- /* `units_per_em' value. */
+ /* loss of precision, we use the magnitude of the largest matrix */
+ /* element to scale all other elements. The scaling factor is then */
+ /* contained in the `units_per_em' value. */
- matrix->xx = cff_parse_fixed_dynamic( data++, &scaling );
+ max_scaling = FT_LONG_MIN;
+ min_scaling = FT_LONG_MAX;
- scaling = -scaling;
+ for ( i = 0; i < 6; i++ )
+ {
+ values[i] = cff_parse_fixed_dynamic( parser, data++, &scalings[i] );
+ if ( values[i] )
+ {
+ if ( scalings[i] > max_scaling )
+ max_scaling = scalings[i];
+ if ( scalings[i] < min_scaling )
+ min_scaling = scalings[i];
+ }
+ }
- if ( scaling < 0 || scaling > 9 )
+ if ( max_scaling < -9 ||
+ max_scaling > 0 ||
+ ( max_scaling - min_scaling ) < 0 ||
+ ( max_scaling - min_scaling ) > 9 )
{
/* Return default matrix in case of unlikely values. */
FT_TRACE1(( "cff_parse_font_matrix:"
- " strange scaling value for xx element (%d),\n"
+ " strange scaling values (minimum %d, maximum %d),\n"
" "
- " using default matrix\n", scaling ));
+ " using default matrix\n", min_scaling, max_scaling ));
matrix->xx = 0x10000L;
matrix->yx = 0;
@@ -553,13 +665,42 @@
goto Exit;
}
- matrix->yx = cff_parse_fixed_scaled( data++, scaling );
- matrix->xy = cff_parse_fixed_scaled( data++, scaling );
- matrix->yy = cff_parse_fixed_scaled( data++, scaling );
- offset->x = cff_parse_fixed_scaled( data++, scaling );
- offset->y = cff_parse_fixed_scaled( data, scaling );
+ for ( i = 0; i < 6; i++ )
+ {
+ FT_Fixed value = values[i];
+ FT_Long divisor, half_divisor;
+
- *upm = (FT_ULong)power_tens[scaling];
+ if ( !value )
+ continue;
+
+ divisor = power_tens[max_scaling - scalings[i]];
+ half_divisor = divisor >> 1;
+
+ if ( value < 0 )
+ {
+ if ( FT_LONG_MIN + half_divisor < value )
+ values[i] = ( value - half_divisor ) / divisor;
+ else
+ values[i] = FT_LONG_MIN / divisor;
+ }
+ else
+ {
+ if ( FT_LONG_MAX - half_divisor > value )
+ values[i] = ( value + half_divisor ) / divisor;
+ else
+ values[i] = FT_LONG_MAX / divisor;
+ }
+ }
+
+ matrix->xx = values[0];
+ matrix->yx = values[1];
+ matrix->xy = values[2];
+ matrix->yy = values[3];
+ offset->x = values[4];
+ offset->y = values[5];
+
+ *upm = (FT_ULong)power_tens[-max_scaling];
FT_TRACE4(( " [%f %f %f %f %f %f]\n",
(double)matrix->xx / *upm / 65536,
@@ -588,10 +729,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",
@@ -620,7 +761,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" ));
@@ -629,7 +770,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" ));
@@ -649,6 +790,56 @@
}
+ /* The `MultipleMaster' operator comes before any */
+ /* top DICT operators that contain T2 charstrings. */
+
+ static FT_Error
+ cff_parse_multiple_master( CFF_Parser parser )
+ {
+ CFF_FontRecDict dict = (CFF_FontRecDict)parser->object;
+ FT_Error error;
+
+
+#ifdef FT_DEBUG_LEVEL_TRACE
+ /* beautify tracing message */
+ if ( ft_trace_levels[FT_COMPONENT] < 4 )
+ FT_TRACE1(( "Multiple Master CFFs not supported yet,"
+ " handling first master design only\n" ));
+ else
+ FT_TRACE1(( " (not supported yet,"
+ " handling first master design only)\n" ));
+#endif
+
+ error = FT_ERR( Stack_Underflow );
+
+ /* currently, we handle only the first argument */
+ if ( parser->top >= parser->stack + 5 )
+ {
+ FT_Long num_designs = cff_parse_num( parser, parser->stack );
+
+
+ if ( num_designs > 16 || num_designs < 2 )
+ {
+ FT_ERROR(( "cff_parse_multiple_master:"
+ " Invalid number of designs\n" ));
+ error = FT_THROW( Invalid_File_Format );
+ }
+ else
+ {
+ dict->num_designs = (FT_UShort)num_designs;
+ dict->num_axes = (FT_UShort)( parser->top - parser->stack - 4 );
+
+ parser->num_designs = dict->num_designs;
+ parser->num_axes = dict->num_axes;
+
+ error = FT_Err_Ok;
+ }
+ }
+
+ return error;
+ }
+
+
static FT_Error
cff_parse_cid_ros( CFF_Parser parser )
{
@@ -661,11 +852,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 ));
@@ -681,6 +872,125 @@
}
+ 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 value%s blended\n",
+ numBlends,
+ numBlends == 1 ? "" : "s" ));
+
+ 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 ) \
@@ -692,9 +1002,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
@@ -715,6 +1022,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, \
@@ -758,6 +1074,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, \
@@ -824,6 +1150,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"
@@ -871,6 +1199,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;
@@ -921,6 +1260,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;
@@ -950,9 +1301,14 @@
FT_Byte* start,
FT_Byte* limit )
{
+#ifdef CFF_CONFIG_OPTION_OLD_ENGINE
+ PSAux_Service psaux;
+#endif
+
FT_Byte* p = start;
FT_Error error = FT_Err_Ok;
FT_Library library = parser->library;
+
FT_UNUSED( library );
@@ -965,14 +1321,16 @@
{
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;
+ *parser->top++ = p;
/* now, skip it */
if ( v == 30 )
@@ -1001,19 +1359,159 @@
else if ( v > 246 )
p += 1;
}
+#ifdef CFF_CONFIG_OPTION_OLD_ENGINE
+ else if ( v == 31 )
+ {
+ /* a Type 2 charstring */
+
+ CFF_Decoder decoder;
+ CFF_FontRec cff_rec;
+ FT_Byte* charstring_base;
+ FT_ULong charstring_len;
+
+ FT_Fixed* stack;
+ FT_Byte* q;
+
+
+ charstring_base = ++p;
+
+ /* search `endchar' operator */
+ for (;;)
+ {
+ if ( p >= limit )
+ goto Exit;
+ if ( *p == 14 )
+ break;
+ p++;
+ }
+
+ charstring_len = (FT_ULong)( p - charstring_base ) + 1;
+
+ /* construct CFF_Decoder object */
+ 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;
+ decoder.cff = &cff_rec;
+
+ psaux = (PSAux_Service)FT_Get_Module_Interface( library, "psaux" );
+ if ( !psaux )
+ {
+ FT_ERROR(( "cff_parser_run: cannot access `psaux' module\n" ));
+ error = FT_THROW( Missing_Module );
+ goto Exit;
+ }
+
+ error = psaux->cff_decoder_funcs->parse_charstrings_old(
+ &decoder, charstring_base, charstring_len, 1 );
+
+ /* Now copy the stack data in the temporary decoder object, */
+ /* converting it back to charstring number representations */
+ /* (this is ugly, I know). */
+ /* */
+ /* We overwrite the original top DICT charstring under the */
+ /* assumption that the charstring representation of the result */
+ /* of `cff_decoder_parse_charstrings' is shorter, which should */
+ /* be always true. */
+
+ q = charstring_base - 1;
+ stack = decoder.stack;
+
+ while ( stack < decoder.top )
+ {
+ FT_ULong num;
+ FT_Bool neg;
+
+
+ if ( (FT_UInt)( parser->top - parser->stack ) >= parser->stackSize )
+ goto Stack_Overflow;
+
+ *parser->top++ = q;
+
+ if ( *stack < 0 )
+ {
+ num = (FT_ULong)-*stack;
+ neg = 1;
+ }
+ else
+ {
+ num = (FT_ULong)*stack;
+ neg = 0;
+ }
+
+ if ( num & 0xFFFFU )
+ {
+ if ( neg )
+ num = (FT_ULong)-num;
+
+ *q++ = 255;
+ *q++ = ( num & 0xFF000000U ) >> 24;
+ *q++ = ( num & 0x00FF0000U ) >> 16;
+ *q++ = ( num & 0x0000FF00U ) >> 8;
+ *q++ = num & 0x000000FFU;
+ }
+ else
+ {
+ num >>= 16;
+
+ if ( neg )
+ {
+ if ( num <= 107 )
+ *q++ = (FT_Byte)( 139 - num );
+ else if ( num <= 1131 )
+ {
+ *q++ = (FT_Byte)( ( ( num - 108 ) >> 8 ) + 251 );
+ *q++ = (FT_Byte)( ( num - 108 ) & 0xFF );
+ }
+ else
+ {
+ num = (FT_ULong)-num;
+
+ *q++ = 28;
+ *q++ = (FT_Byte)( num >> 8 );
+ *q++ = (FT_Byte)( num & 0xFF );
+ }
+ }
+ else
+ {
+ if ( num <= 107 )
+ *q++ = (FT_Byte)( num + 139 );
+ else if ( num <= 1131 )
+ {
+ *q++ = (FT_Byte)( ( ( num - 108 ) >> 8 ) + 247 );
+ *q++ = (FT_Byte)( ( num - 108 ) & 0xFF );
+ }
+ else
+ {
+ *q++ = 28;
+ *q++ = (FT_Byte)( num >> 8 );
+ *q++ = (FT_Byte)( num & 0xFF );
+ }
+ }
+ }
+
+ stack++;
+ }
+ }
+#endif /* CFF_CONFIG_OPTION_OLD_ENGINE */
else
{
/* This is not a number, hence it's an operator. Compute its code */
/* 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 */
@@ -1048,15 +1546,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 )
@@ -1125,7 +1623,7 @@
val = 0;
while ( num_args > 0 )
{
- val += cff_parse_num( data++ );
+ val = ADD_LONG( val, cff_parse_num( parser, data++ ) );
switch ( field->size )
{
case (8 / FT_CHAR_BIT):
@@ -1154,7 +1652,7 @@
}
break;
- default: /* callback */
+ default: /* callback or blend */
error = field->reader( parser );
if ( error )
goto Exit;
@@ -1168,7 +1666,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/src/3rdparty/freetype/src/cff/cffparse.h b/src/3rdparty/freetype/src/cff/cffparse.h
index 8ad02ea1e2..8a8caeca44 100644
--- a/src/3rdparty/freetype/src/cff/cffparse.h
+++ b/src/3rdparty/freetype/src/cff/cffparse.h
@@ -4,7 +4,7 @@
/* */
/* CFF token stream parser (specification) */
/* */
-/* Copyright 1996-2015 by */
+/* Copyright 1996-2018 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -16,45 +16,74 @@
/***************************************************************************/
-#ifndef __CFF_PARSE_H__
-#define __CFF_PARSE_H__
+#ifndef CFFPARSE_H_
+#define CFFPARSE_H_
#include <ft2build.h>
-#include "cfftypes.h"
+#include FT_INTERNAL_CFF_TYPES_H
#include FT_INTERNAL_OBJECTS_H
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_
{
- FT_Library library;
- FT_Byte* start;
- FT_Byte* limit;
- FT_Byte* cursor;
+ FT_Library library;
+ FT_Byte* start;
+ FT_Byte* limit;
+ FT_Byte* cursor;
+
+ FT_Byte** stack;
+ FT_Byte** top;
+ FT_UInt stackSize; /* allocated size */
- FT_Byte* stack[CFF_MAX_STACK_DEPTH + 1];
- FT_Byte** top;
+ FT_UInt object_code;
+ void* object;
- FT_UInt object_code;
- void* object;
+ FT_UShort num_designs; /* a copy of `CFF_FontRecDict->num_designs' */
+ FT_UShort num_axes; /* a copy of `CFF_FontRecDict->num_axes' */
} 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_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,
@@ -72,6 +101,7 @@ FT_BEGIN_HEADER
cff_kind_bool,
cff_kind_delta,
cff_kind_callback,
+ cff_kind_blend,
cff_kind_max /* do not remove */
};
@@ -100,7 +130,7 @@ FT_BEGIN_HEADER
FT_END_HEADER
-#endif /* __CFF_PARSE_H__ */
+#endif /* CFFPARSE_H_ */
/* END */
diff --git a/src/3rdparty/freetype/src/cff/cffpic.c b/src/3rdparty/freetype/src/cff/cffpic.c
index d40dec50e9..08b74c7cf2 100644
--- a/src/3rdparty/freetype/src/cff/cffpic.c
+++ b/src/3rdparty/freetype/src/cff/cffpic.c
@@ -4,7 +4,7 @@
/* */
/* The FreeType position independent code services for cff module. */
/* */
-/* Copyright 2009-2015 by */
+/* Copyright 2009-2018 by */
/* Oran Agra and Mickey Gabel. */
/* */
/* This file is part of the FreeType project, and may only be used, */
diff --git a/src/3rdparty/freetype/src/cff/cffpic.h b/src/3rdparty/freetype/src/cff/cffpic.h
index 9a221a7b7e..8ba4203a8d 100644
--- a/src/3rdparty/freetype/src/cff/cffpic.h
+++ b/src/3rdparty/freetype/src/cff/cffpic.h
@@ -4,7 +4,7 @@
/* */
/* The FreeType position independent code services for cff module. */
/* */
-/* Copyright 2009-2015 by */
+/* Copyright 2009-2018 by */
/* Oran Agra and Mickey Gabel. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -16,13 +16,12 @@
/***************************************************************************/
-#ifndef __CFFPIC_H__
-#define __CFFPIC_H__
+#ifndef CFFPIC_H_
+#define CFFPIC_H_
#include FT_INTERNAL_PIC_H
-
#ifndef FT_CONFIG_OPTION_PIC
#define CFF_SERVICE_PS_INFO_GET cff_service_ps_info
@@ -32,6 +31,9 @@
#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_SERVICE_CFF_LOAD_GET cff_service_cff_load
#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,27 @@
#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_Service_CFFLoadRec cff_service_cff_load;
+ FT_CMap_ClassRec cff_cmap_encoding_class_rec;
+ FT_CMap_ClassRec cff_cmap_unicode_class_rec;
} CffModulePIC;
@@ -82,6 +89,12 @@ 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_SERVICE_CFF_LOAD_GET \
+ ( GET_PIC( library )->cff_service_cff_load )
#define CFF_CMAP_ENCODING_CLASS_REC_GET \
( GET_PIC( library )->cff_cmap_encoding_class_rec )
#define CFF_CMAP_UNICODE_CLASS_REC_GET \
@@ -102,7 +115,7 @@ FT_END_HEADER
/* */
-#endif /* __CFFPIC_H__ */
+#endif /* CFFPIC_H_ */
/* END */
diff --git a/src/3rdparty/freetype/src/cff/cfftoken.h b/src/3rdparty/freetype/src/cff/cfftoken.h
index 5b32076ab8..fec1ca20bd 100644
--- a/src/3rdparty/freetype/src/cff/cfftoken.h
+++ b/src/3rdparty/freetype/src/cff/cfftoken.h
@@ -4,7 +4,7 @@
/* */
/* CFF token definitions (specification only). */
/* */
-/* Copyright 1996-2015 by */
+/* Copyright 1996-2018 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" )
@@ -38,6 +38,9 @@
CFF_FIELD_NUM ( 13, unique_id, "UniqueID" )
CFF_FIELD_CALLBACK( 5, font_bbox, "FontBBox" )
CFF_FIELD_NUM ( 0x108, stroke_width, "StrokeWidth" )
+#if 0
+ CFF_FIELD_DELTA ( 14, xuid, 16, "XUID" )
+#endif
CFF_FIELD_NUM ( 15, charset_offset, "charset" )
CFF_FIELD_NUM ( 16, encoding_offset, "Encoding" )
CFF_FIELD_NUM ( 17, charstrings_offset, "CharStrings" )
@@ -48,8 +51,13 @@
#if 0
CFF_FIELD_STRING ( 0x116, base_font_name, "BaseFontName" )
CFF_FIELD_DELTA ( 0x117, base_font_blend, 16, "BaseFontBlend" )
+#endif
+
+ /* the next two operators were removed from the Type2 specification */
+ /* in version 16-March-2000 */
CFF_FIELD_CALLBACK( 0x118, multiple_master, "MultipleMaster" )
- CFF_FIELD_CALLBACK( 0x119, blend_axis_types, "BlendAxisTypes" )
+#if 0
+ CFF_FIELD_CALLBACK( 0x11A, blend_axis_types, "BlendAxisTypes" )
#endif
CFF_FIELD_CALLBACK( 0x11E, cid_ros, "ROS" )
@@ -70,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" )
@@ -94,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/src/3rdparty/freetype/src/cff/module.mk b/src/3rdparty/freetype/src/cff/module.mk
index ba08ebcb79..8013d5dcab 100644
--- a/src/3rdparty/freetype/src/cff/module.mk
+++ b/src/3rdparty/freetype/src/cff/module.mk
@@ -3,7 +3,7 @@
#
-# Copyright 1996-2015 by
+# Copyright 1996-2018 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/src/3rdparty/freetype/src/cff/rules.mk b/src/3rdparty/freetype/src/cff/rules.mk
index 7f6e857e28..bce672927e 100644
--- a/src/3rdparty/freetype/src/cff/rules.mk
+++ b/src/3rdparty/freetype/src/cff/rules.mk
@@ -3,7 +3,7 @@
#
-# Copyright 1996-2015 by
+# Copyright 1996-2018 by
# David Turner, Robert Wilhelm, and Werner Lemberg.
#
# This file is part of the FreeType project, and may only be used, modified,
@@ -32,27 +32,14 @@ CFF_DRV_SRC := $(CFF_DIR)/cffcmap.c \
$(CFF_DIR)/cffload.c \
$(CFF_DIR)/cffobjs.c \
$(CFF_DIR)/cffparse.c \
- $(CFF_DIR)/cffpic.c \
- $(CFF_DIR)/cf2arrst.c \
- $(CFF_DIR)/cf2blues.c \
- $(CFF_DIR)/cf2error.c \
- $(CFF_DIR)/cf2font.c \
- $(CFF_DIR)/cf2ft.c \
- $(CFF_DIR)/cf2hints.c \
- $(CFF_DIR)/cf2intrp.c \
- $(CFF_DIR)/cf2read.c \
- $(CFF_DIR)/cf2stack.c
+ $(CFF_DIR)/cffpic.c
# CFF driver headers
#
CFF_DRV_H := $(CFF_DRV_SRC:%.c=%.h) \
$(CFF_DIR)/cfferrs.h \
- $(CFF_DIR)/cfftoken.h \
- $(CFF_DIR)/cfftypes.h \
- $(CFF_DIR)/cf2fixed.h \
- $(CFF_DIR)/cf2glue.h \
- $(CFF_DIR)/cf2types.h
+ $(CFF_DIR)/cfftoken.h
# CFF driver object(s)
diff --git a/src/3rdparty/freetype/src/cid/Jamfile b/src/3rdparty/freetype/src/cid/Jamfile
index 64e1523157..1c232fda3f 100644
--- a/src/3rdparty/freetype/src/cid/Jamfile
+++ b/src/3rdparty/freetype/src/cid/Jamfile
@@ -1,6 +1,6 @@
# FreeType 2 src/cid Jamfile
#
-# Copyright 2001-2015 by
+# Copyright 2001-2018 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/src/3rdparty/freetype/src/cid/ciderrs.h b/src/3rdparty/freetype/src/cid/ciderrs.h
index 5e0e776ee1..a5a86e3fc6 100644
--- a/src/3rdparty/freetype/src/cid/ciderrs.h
+++ b/src/3rdparty/freetype/src/cid/ciderrs.h
@@ -4,7 +4,7 @@
/* */
/* CID error codes (specification only). */
/* */
-/* Copyright 2001-2015 by */
+/* Copyright 2001-2018 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -22,12 +22,12 @@
/* */
/*************************************************************************/
-#ifndef __CIDERRS_H__
-#define __CIDERRS_H__
+#ifndef CIDERRS_H_
+#define CIDERRS_H_
#include FT_MODULE_ERRORS_H
-#undef __FTERRORS_H__
+#undef FTERRORS_H_
#undef FT_ERR_PREFIX
#define FT_ERR_PREFIX CID_Err_
@@ -35,7 +35,7 @@
#include FT_ERRORS_H
-#endif /* __CIDERRS_H__ */
+#endif /* CIDERRS_H_ */
/* END */
diff --git a/src/3rdparty/freetype/src/cid/cidgload.c b/src/3rdparty/freetype/src/cid/cidgload.c
index d00674fe0d..d14f9a2cc9 100644
--- a/src/3rdparty/freetype/src/cid/cidgload.c
+++ b/src/3rdparty/freetype/src/cid/cidgload.c
@@ -4,7 +4,7 @@
/* */
/* CID-keyed Type1 Glyph Loader (body). */
/* */
-/* Copyright 1996-2015 by */
+/* Copyright 1996-2018 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -24,6 +24,10 @@
#include FT_OUTLINE_H
#include FT_INTERNAL_CALC_H
+#include FT_INTERNAL_POSTSCRIPT_AUX_H
+#include FT_INTERNAL_CFF_TYPES_H
+#include FT_DRIVER_H
+
#include "ciderrs.h"
@@ -52,9 +56,11 @@
FT_ULong glyph_length = 0;
PSAux_Service psaux = (PSAux_Service)face->psaux;
+ FT_Bool force_scaling = FALSE;
+
#ifdef FT_CONFIG_OPTION_INCREMENTAL
- FT_Incremental_InterfaceRec *inc =
- face->root.internal->incremental_interface;
+ FT_Incremental_InterfaceRec *inc =
+ face->root.internal->incremental_interface;
#endif
@@ -100,7 +106,7 @@
/* and charstring offset from the CIDMap. */
{
FT_UInt entry_len = (FT_UInt)( cid->fd_bytes + cid->gd_bytes );
- FT_ULong off1;
+ FT_ULong off1, off2;
if ( FT_STREAM_SEEK( cid->data_offset + cid->cidmap_offset +
@@ -108,18 +114,23 @@
FT_FRAME_ENTER( 2 * entry_len ) )
goto Exit;
- p = (FT_Byte*)stream->cursor;
- fd_select = cid_get_offset( &p, (FT_Byte)cid->fd_bytes );
- off1 = cid_get_offset( &p, (FT_Byte)cid->gd_bytes );
- p += cid->fd_bytes;
- glyph_length = cid_get_offset( &p, (FT_Byte)cid->gd_bytes ) - off1;
+ p = (FT_Byte*)stream->cursor;
+ fd_select = cid_get_offset( &p, (FT_Byte)cid->fd_bytes );
+ off1 = cid_get_offset( &p, (FT_Byte)cid->gd_bytes );
+ p += cid->fd_bytes;
+ off2 = cid_get_offset( &p, (FT_Byte)cid->gd_bytes );
FT_FRAME_EXIT();
- if ( fd_select >= (FT_ULong)cid->num_dicts )
+ if ( fd_select >= (FT_ULong)cid->num_dicts ||
+ off2 > stream->size ||
+ off1 > off2 )
{
+ FT_TRACE0(( "cid_load_glyph: invalid glyph stream offsets\n" ));
error = FT_THROW( Invalid_Offset );
goto Exit;
}
+
+ glyph_length = off2 - off1;
if ( glyph_length == 0 )
goto Exit;
if ( FT_ALLOC( charstring, glyph_length ) )
@@ -137,9 +148,10 @@
/* Set up subrs */
- decoder->num_subrs = cid_subrs->num_subrs;
- decoder->subrs = cid_subrs->code;
- decoder->subrs_len = 0;
+ decoder->num_subrs = cid_subrs->num_subrs;
+ decoder->subrs = cid_subrs->code;
+ decoder->subrs_len = 0;
+ decoder->subrs_hash = NULL;
/* Set up font matrix */
dict = cid->font_dicts + fd_select;
@@ -152,18 +164,70 @@
/* Adjustment for seed bytes. */
cs_offset = decoder->lenIV >= 0 ? (FT_UInt)decoder->lenIV : 0;
+ if ( cs_offset > glyph_length )
+ {
+ FT_TRACE0(( "cid_load_glyph: invalid glyph stream offsets\n" ));
+ error = FT_THROW( Invalid_Offset );
+ goto Exit;
+ }
/* Decrypt only if lenIV >= 0. */
if ( decoder->lenIV >= 0 )
psaux->t1_decrypt( charstring, glyph_length, 4330 );
- error = decoder->funcs.parse_charstrings(
- decoder, charstring + cs_offset,
- glyph_length - cs_offset );
+ /* choose which renderer to use */
+#ifdef T1_CONFIG_OPTION_OLD_ENGINE
+ if ( ( (PS_Driver)FT_FACE_DRIVER( face ) )->hinting_engine ==
+ FT_HINTING_FREETYPE ||
+ decoder->builder.metrics_only )
+ error = psaux->t1_decoder_funcs->parse_charstrings_old(
+ decoder,
+ charstring + cs_offset,
+ glyph_length - cs_offset );
+#else
+ if ( decoder->builder.metrics_only )
+ error = psaux->t1_decoder_funcs->parse_metrics(
+ decoder,
+ charstring + cs_offset,
+ glyph_length - cs_offset );
+#endif
+ else
+ {
+ PS_Decoder psdecoder;
+ CFF_SubFontRec subfont;
+
+
+ psaux->ps_decoder_init( &psdecoder, decoder, TRUE );
+
+ psaux->t1_make_subfont( FT_FACE( face ),
+ &dict->private_dict,
+ &subfont );
+ psdecoder.current_subfont = &subfont;
+
+ error = psaux->t1_decoder_funcs->parse_charstrings(
+ &psdecoder,
+ charstring + cs_offset,
+ glyph_length - cs_offset );
+
+ /* Adobe's engine uses 16.16 numbers everywhere; */
+ /* as a consequence, glyphs larger than 2000ppem get rejected */
+ if ( FT_ERR_EQ( error, Glyph_Too_Big ) )
+ {
+ /* this time, we retry unhinted and scale up the glyph later on */
+ /* (the engine uses and sets the hardcoded value 0x10000 / 64 = */
+ /* 0x400 for both `x_scale' and `y_scale' in this case) */
+ ((CID_GlyphSlot)decoder->builder.glyph)->hint = FALSE;
+
+ force_scaling = TRUE;
+
+ error = psaux->t1_decoder_funcs->parse_charstrings(
+ &psdecoder,
+ charstring + cs_offset,
+ glyph_length - cs_offset );
+ }
+ }
}
- FT_FREE( charstring );
-
#ifdef FT_CONFIG_OPTION_INCREMENTAL
/* Incremental fonts can optionally override the metrics. */
@@ -188,6 +252,10 @@
#endif /* FT_CONFIG_OPTION_INCREMENTAL */
Exit:
+ FT_FREE( charstring );
+
+ ((CID_GlyphSlot)decoder->builder.glyph)->scaled = force_scaling;
+
return error;
}
@@ -276,10 +344,12 @@
T1_DecoderRec decoder;
CID_Face face = (CID_Face)cidglyph->face;
FT_Bool hinting;
+ FT_Bool scaled;
PSAux_Service psaux = (PSAux_Service)face->psaux;
FT_Matrix font_matrix;
FT_Vector font_offset;
+ FT_Bool must_finish_decoder = FALSE;
if ( glyph_index >= (FT_UInt)face->root.num_glyphs )
@@ -299,7 +369,10 @@
hinting = FT_BOOL( ( load_flags & FT_LOAD_NO_SCALE ) == 0 &&
( load_flags & FT_LOAD_NO_HINTING ) == 0 );
+ scaled = FT_BOOL( ( load_flags & FT_LOAD_NO_SCALE ) == 0 );
+ glyph->hint = hinting;
+ glyph->scaled = scaled;
cidglyph->format = FT_GLYPH_FORMAT_OUTLINE;
error = psaux->t1_decoder_funcs->init( &decoder,
@@ -317,6 +390,8 @@
/* TODO: initialize decoder.len_buildchar and decoder.buildchar */
/* if we ever support CID-keyed multiple master fonts */
+ must_finish_decoder = TRUE;
+
/* set up the decoder */
decoder.builder.no_recurse = FT_BOOL(
( ( load_flags & FT_LOAD_NO_RECURSE ) != 0 ) );
@@ -325,12 +400,18 @@
if ( error )
goto Exit;
+ /* copy flags back for forced scaling */
+ hinting = glyph->hint;
+ scaled = glyph->scaled;
+
font_matrix = decoder.font_matrix;
font_offset = decoder.font_offset;
/* save new glyph tables */
psaux->t1_decoder_funcs->done( &decoder );
+ must_finish_decoder = FALSE;
+
/* now set the metrics -- this is rather simple, as */
/* the left side bearing is the xMin, and the top side */
/* bearing the yMax */
@@ -398,7 +479,7 @@
metrics->vertAdvance += font_offset.y;
}
- if ( ( load_flags & FT_LOAD_NO_SCALE ) == 0 )
+ if ( ( load_flags & FT_LOAD_NO_SCALE ) == 0 || scaled )
{
/* scale the outline and the metrics */
FT_Int n;
@@ -439,6 +520,10 @@
}
Exit:
+
+ if ( must_finish_decoder )
+ psaux->t1_decoder_funcs->done( &decoder );
+
return error;
}
diff --git a/src/3rdparty/freetype/src/cid/cidgload.h b/src/3rdparty/freetype/src/cid/cidgload.h
index 4a10ce505c..4811852ae4 100644
--- a/src/3rdparty/freetype/src/cid/cidgload.h
+++ b/src/3rdparty/freetype/src/cid/cidgload.h
@@ -4,7 +4,7 @@
/* */
/* OpenType Glyph Loader (specification). */
/* */
-/* Copyright 1996-2015 by */
+/* Copyright 1996-2018 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -16,8 +16,8 @@
/***************************************************************************/
-#ifndef __CIDGLOAD_H__
-#define __CIDGLOAD_H__
+#ifndef CIDGLOAD_H_
+#define CIDGLOAD_H_
#include <ft2build.h>
@@ -45,7 +45,7 @@ FT_BEGIN_HEADER
FT_END_HEADER
-#endif /* __CIDGLOAD_H__ */
+#endif /* CIDGLOAD_H_ */
/* END */
diff --git a/src/3rdparty/freetype/src/cid/cidload.c b/src/3rdparty/freetype/src/cid/cidload.c
index e23b82f673..27cd09b3c3 100644
--- a/src/3rdparty/freetype/src/cid/cidload.c
+++ b/src/3rdparty/freetype/src/cid/cidload.c
@@ -4,7 +4,7 @@
/* */
/* CID-keyed Type1 font loader (body). */
/* */
-/* Copyright 1996-2015 by */
+/* Copyright 1996-2018 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -215,6 +215,7 @@
{
CID_FaceInfo cid = &face->cid;
FT_Memory memory = face->root.memory;
+ FT_Stream stream = parser->stream;
FT_Error error = FT_Err_Ok;
FT_Long num_dicts;
@@ -227,6 +228,31 @@
goto Exit;
}
+ /*
+ * A single entry in the FDArray must (at least) contain the following
+ * structure elements.
+ *
+ * %ADOBeginFontDict 18
+ * X dict begin 13
+ * /FontMatrix [X X X X] 22
+ * /Private X dict begin 22
+ * end 4
+ * end 4
+ * %ADOEndFontDict 16
+ *
+ * This needs 18+13+22+22+4+4+16=99 bytes or more. Normally, you also
+ * need a `dup X' at the very beginning and a `put' at the end, so a
+ * rough guess using 100 bytes as the minimum is justified.
+ */
+ if ( (FT_ULong)num_dicts > stream->size / 100 )
+ {
+ FT_TRACE0(( "parse_fd_array: adjusting FDArray size"
+ " (from %d to %d)\n",
+ num_dicts,
+ stream->size / 100 ));
+ num_dicts = (FT_Long)( stream->size / 100 );
+ }
+
if ( !cid->font_dicts )
{
FT_Int n;
@@ -395,7 +421,14 @@
cur = parser->root.cursor;
}
+
+ if ( !face->cid.num_dicts )
+ {
+ FT_ERROR(( "cid_parse_dict: No font dictionary found\n" ));
+ return FT_THROW( Invalid_File_Format );
+ }
}
+
return parser->root.error;
}
@@ -428,12 +461,8 @@
FT_Byte* p;
- /* Check for possible overflow. */
- if ( num_subrs == FT_UINT_MAX )
- {
- error = FT_THROW( Syntax_Error );
- goto Fail;
- }
+ if ( !num_subrs )
+ continue;
/* reallocate offsets array if needed */
if ( num_subrs + 1 > max_offsets )
@@ -467,14 +496,25 @@
/* offsets must be ordered */
for ( count = 1; count <= num_subrs; count++ )
if ( offsets[count - 1] > offsets[count] )
+ {
+ FT_ERROR(( "cid_read_subrs: offsets are not ordered\n" ));
+ error = FT_THROW( Invalid_File_Format );
goto Fail;
+ }
+
+ if ( offsets[num_subrs] > stream->size - cid->data_offset )
+ {
+ FT_ERROR(( "cid_read_subrs: too large `subrs' offsets\n" ));
+ error = FT_THROW( Invalid_File_Format );
+ goto Fail;
+ }
/* now, compute the size of subrs charstrings, */
/* allocate, and read them */
data_len = offsets[num_subrs] - offsets[0];
if ( FT_NEW_ARRAY( subr->code, num_subrs + 1 ) ||
- FT_ALLOC( subr->code[0], data_len ) )
+ FT_ALLOC( subr->code[0], data_len ) )
goto Fail;
if ( FT_STREAM_SEEK( cid->data_offset + offsets[0] ) ||
@@ -533,7 +573,7 @@
{
FT_UNUSED( face );
- FT_MEM_ZERO( loader, sizeof ( *loader ) );
+ FT_ZERO( loader );
}
@@ -654,6 +694,12 @@
CID_Parser* parser;
FT_Memory memory = face->root.memory;
FT_Error error;
+ FT_Int n;
+
+ CID_FaceInfo cid = &face->cid;
+
+ FT_ULong binary_length;
+ FT_ULong entry_len;
cid_init_loader( &loader, face );
@@ -678,22 +724,117 @@
if ( parser->binary_length )
{
+ if ( parser->binary_length >
+ face->root.stream->size - parser->data_offset )
+ {
+ FT_TRACE0(( "cid_face_open: adjusting length of binary data\n"
+ " (from %d to %d bytes)\n",
+ parser->binary_length,
+ face->root.stream->size - parser->data_offset ));
+ parser->binary_length = face->root.stream->size -
+ parser->data_offset;
+ }
+
/* 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,
face->binary_data, parser->binary_length );
- face->cid.data_offset = 0;
+ cid->data_offset = 0;
}
else
{
- *face->cid_stream = *face->root.stream;
- face->cid.data_offset = loader.parser.data_offset;
+ *face->cid_stream = *face->root.stream;
+ cid->data_offset = loader.parser.data_offset;
+ }
+
+ /* sanity tests */
+
+ if ( cid->fd_bytes < 0 || cid->gd_bytes < 1 )
+ {
+ FT_ERROR(( "cid_parse_dict:"
+ " Invalid `FDBytes' or `GDBytes' value\n" ));
+ error = FT_THROW( Invalid_File_Format );
+ goto Exit;
+ }
+
+ /* allow at most 32bit offsets */
+ if ( cid->fd_bytes > 4 || cid->gd_bytes > 4 )
+ {
+ FT_ERROR(( "cid_parse_dict:"
+ " Values of `FDBytes' or `GDBytes' larger than 4\n"
+ " "
+ " are not supported\n" ));
+ error = FT_THROW( Invalid_File_Format );
+ goto Exit;
+ }
+
+ binary_length = face->cid_stream->size - cid->data_offset;
+ entry_len = (FT_ULong)( cid->fd_bytes + cid->gd_bytes );
+
+ for ( n = 0; n < cid->num_dicts; n++ )
+ {
+ CID_FaceDict dict = cid->font_dicts + n;
+
+
+ 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 );
+ goto Exit;
+ }
+
+ if ( dict->sd_bytes > 4 )
+ {
+ FT_ERROR(( "cid_parse_dict:"
+ " Values of `SDBytes' larger than 4"
+ " are not supported\n" ));
+ error = FT_THROW( Invalid_File_Format );
+ goto Exit;
+ }
+
+ if ( dict->subrmap_offset > binary_length )
+ {
+ FT_ERROR(( "cid_parse_dict: Invalid `SubrMapOffset' value\n" ));
+ error = FT_THROW( Invalid_File_Format );
+ goto Exit;
+ }
+
+ /* `num_subrs' is scanned as a signed integer */
+ if ( (FT_Int)dict->num_subrs < 0 ||
+ ( dict->sd_bytes &&
+ dict->num_subrs > ( binary_length - dict->subrmap_offset ) /
+ (FT_UInt)dict->sd_bytes ) )
+ {
+ FT_ERROR(( "cid_parse_dict: Invalid `SubrCount' value\n" ));
+ error = FT_THROW( Invalid_File_Format );
+ goto Exit;
+ }
+ }
+
+ if ( cid->cidmap_offset > binary_length )
+ {
+ FT_ERROR(( "cid_parse_dict: Invalid `CIDMapOffset' value\n" ));
+ error = FT_THROW( Invalid_File_Format );
+ goto Exit;
+ }
+
+ if ( entry_len &&
+ cid->cid_count >
+ ( binary_length - cid->cidmap_offset ) / entry_len )
+ {
+ FT_ERROR(( "cid_parse_dict: Invalid `CIDCount' value\n" ));
+ error = FT_THROW( Invalid_File_Format );
+ goto Exit;
}
+ /* we can now safely proceed */
error = cid_read_subrs( face );
Exit:
diff --git a/src/3rdparty/freetype/src/cid/cidload.h b/src/3rdparty/freetype/src/cid/cidload.h
index d7776d2f88..3f8bd08620 100644
--- a/src/3rdparty/freetype/src/cid/cidload.h
+++ b/src/3rdparty/freetype/src/cid/cidload.h
@@ -4,7 +4,7 @@
/* */
/* CID-keyed Type1 font loader (specification). */
/* */
-/* Copyright 1996-2015 by */
+/* Copyright 1996-2018 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -16,8 +16,8 @@
/***************************************************************************/
-#ifndef __CIDLOAD_H__
-#define __CIDLOAD_H__
+#ifndef CIDLOAD_H_
+#define CIDLOAD_H_
#include <ft2build.h>
@@ -47,7 +47,7 @@ FT_BEGIN_HEADER
FT_END_HEADER
-#endif /* __CIDLOAD_H__ */
+#endif /* CIDLOAD_H_ */
/* END */
diff --git a/src/3rdparty/freetype/src/cid/cidobjs.c b/src/3rdparty/freetype/src/cid/cidobjs.c
index bf1519bc6e..77afe1c875 100644
--- a/src/3rdparty/freetype/src/cid/cidobjs.c
+++ b/src/3rdparty/freetype/src/cid/cidobjs.c
@@ -4,7 +4,7 @@
/* */
/* CID objects manager (body). */
/* */
-/* Copyright 1996-2015 by */
+/* Copyright 1996-2018 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -26,6 +26,7 @@
#include FT_SERVICE_POSTSCRIPT_CMAPS_H
#include FT_INTERNAL_POSTSCRIPT_AUX_H
#include FT_INTERNAL_POSTSCRIPT_HINTS_H
+#include FT_DRIVER_H
#include "ciderrs.h"
@@ -113,16 +114,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 +146,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 +165,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 );
@@ -463,9 +464,42 @@
/* FreeType error code. 0 means success. */
/* */
FT_LOCAL_DEF( FT_Error )
- cid_driver_init( FT_Module driver )
+ cid_driver_init( FT_Module module )
{
- FT_UNUSED( driver );
+ PS_Driver driver = (PS_Driver)module;
+
+ FT_UInt32 seed;
+
+
+ /* set default property values, cf. `ftt1drv.h' */
+#ifdef T1_CONFIG_OPTION_OLD_ENGINE
+ driver->hinting_engine = FT_HINTING_FREETYPE;
+#else
+ driver->hinting_engine = FT_HINTING_ADOBE;
+#endif
+
+ driver->no_stem_darkening = TRUE;
+
+ driver->darken_params[0] = CFF_CONFIG_OPTION_DARKENING_PARAMETER_X1;
+ driver->darken_params[1] = CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y1;
+ driver->darken_params[2] = CFF_CONFIG_OPTION_DARKENING_PARAMETER_X2;
+ driver->darken_params[3] = CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y2;
+ driver->darken_params[4] = CFF_CONFIG_OPTION_DARKENING_PARAMETER_X3;
+ driver->darken_params[5] = CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y3;
+ driver->darken_params[6] = CFF_CONFIG_OPTION_DARKENING_PARAMETER_X4;
+ driver->darken_params[7] = CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y4;
+
+ /* 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/src/3rdparty/freetype/src/cid/cidobjs.h b/src/3rdparty/freetype/src/cid/cidobjs.h
index e9095ca68e..0221f017dd 100644
--- a/src/3rdparty/freetype/src/cid/cidobjs.h
+++ b/src/3rdparty/freetype/src/cid/cidobjs.h
@@ -4,7 +4,7 @@
/* */
/* CID objects manager (specification). */
/* */
-/* Copyright 1996-2015 by */
+/* Copyright 1996-2018 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -16,8 +16,8 @@
/***************************************************************************/
-#ifndef __CIDOBJS_H__
-#define __CIDOBJS_H__
+#ifndef CIDOBJS_H_
+#define CIDOBJS_H_
#include <ft2build.h>
@@ -148,7 +148,7 @@ FT_BEGIN_HEADER
FT_END_HEADER
-#endif /* __CIDOBJS_H__ */
+#endif /* CIDOBJS_H_ */
/* END */
diff --git a/src/3rdparty/freetype/src/cid/cidparse.c b/src/3rdparty/freetype/src/cid/cidparse.c
index c276949779..b1c7f3cb2c 100644
--- a/src/3rdparty/freetype/src/cid/cidparse.c
+++ b/src/3rdparty/freetype/src/cid/cidparse.c
@@ -4,7 +4,7 @@
/* */
/* CID-keyed Type1 parser (body). */
/* */
-/* Copyright 1996-2015 by */
+/* Copyright 1996-2018 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -47,6 +47,12 @@
/*************************************************************************/
+#define STARTDATA "StartData"
+#define STARTDATA_LEN ( sizeof ( STARTDATA ) - 1 )
+#define SFNTS "/sfnts"
+#define SFNTS_LEN ( sizeof ( SFNTS ) - 1 )
+
+
FT_LOCAL_DEF( FT_Error )
cid_parser_new( CID_Parser* parser,
FT_Stream stream,
@@ -59,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;
@@ -85,9 +91,29 @@
/* now, read the rest of the file until we find */
/* `StartData' or `/sfnts' */
{
- FT_Byte buffer[256 + 10];
- FT_ULong read_len = 256 + 10;
- FT_Byte* p = buffer;
+ /*
+ * The algorithm is as follows (omitting the case with less than 256
+ * bytes to fill for simplicity).
+ *
+ * 1. Fill the buffer with 256 + STARTDATA_LEN bytes.
+ *
+ * 2. Search for the STARTDATA and SFNTS strings at positions
+ * buffer[0], buffer[1], ...,
+ * buffer[255 + STARTDATA_LEN - SFNTS_LEN].
+ *
+ * 3. Move the last STARTDATA_LEN bytes to buffer[0].
+ *
+ * 4. Fill the buffer with 256 bytes, starting at STARTDATA_LEN.
+ *
+ * 5. Repeat with step 2.
+ *
+ */
+ FT_Byte buffer[256 + STARTDATA_LEN + 1];
+
+ /* values for the first loop */
+ FT_ULong read_len = 256 + STARTDATA_LEN;
+ FT_ULong read_offset = 0;
+ FT_Byte* p = buffer;
for ( offset = FT_STREAM_POS(); ; offset += 256 )
@@ -96,40 +122,48 @@
stream_len = stream->size - FT_STREAM_POS();
- if ( stream_len == 0 )
- {
- FT_TRACE2(( "cid_parser_new: no `StartData' keyword found\n" ));
- error = FT_THROW( Invalid_File_Format );
- goto Exit;
- }
read_len = FT_MIN( read_len, stream_len );
if ( FT_STREAM_READ( p, read_len ) )
goto Exit;
- if ( read_len < 256 )
- p[read_len] = '\0';
+ /* ensure that we do not compare with data beyond the buffer */
+ p[read_len] = '\0';
- limit = p + read_len - 10;
+ limit = p + read_len - SFNTS_LEN;
for ( p = buffer; p < limit; p++ )
{
- if ( p[0] == 'S' && ft_strncmp( (char*)p, "StartData", 9 ) == 0 )
+ if ( p[0] == 'S' &&
+ ft_strncmp( (char*)p, STARTDATA, STARTDATA_LEN ) == 0 )
{
/* save offset of binary data after `StartData' */
- offset += (FT_ULong)( p - buffer + 10 );
+ offset += (FT_ULong)( p - buffer ) + STARTDATA_LEN + 1;
goto Found;
}
- else if ( p[1] == 's' && ft_strncmp( (char*)p, "/sfnts", 6 ) == 0 )
+ else if ( p[1] == 's' &&
+ ft_strncmp( (char*)p, SFNTS, SFNTS_LEN ) == 0 )
{
- offset += (FT_ULong)( p - buffer + 7 );
+ offset += (FT_ULong)( p - buffer ) + SFNTS_LEN + 1;
goto Found;
}
}
- FT_MEM_MOVE( buffer, p, 10 );
- read_len = 256;
- p = buffer + 10;
+ if ( read_offset + read_len < STARTDATA_LEN )
+ {
+ FT_TRACE2(( "cid_parser_new: no `StartData' keyword found\n" ));
+ error = FT_THROW( Invalid_File_Format );
+ goto Exit;
+ }
+
+ FT_MEM_MOVE( buffer,
+ buffer + read_offset + read_len - STARTDATA_LEN,
+ STARTDATA_LEN );
+
+ /* values for the next loop */
+ read_len = 256;
+ read_offset = STARTDATA_LEN;
+ p = buffer + read_offset;
}
}
@@ -165,7 +199,7 @@
limit = parser->root.limit;
cur = parser->root.cursor;
- while ( cur < limit )
+ while ( cur <= limit - SFNTS_LEN )
{
if ( parser->root.error )
{
@@ -173,11 +207,13 @@
goto Exit;
}
- if ( cur[0] == 'S' && ft_strncmp( (char*)cur, "StartData", 9 ) == 0 )
+ if ( cur[0] == 'S' &&
+ 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 )
@@ -191,7 +227,8 @@
goto Exit;
}
- else if ( cur[1] == 's' && ft_strncmp( (char*)cur, "/sfnts", 6 ) == 0 )
+ else if ( cur[1] == 's' &&
+ ft_strncmp( (char*)cur, SFNTS, SFNTS_LEN ) == 0 )
{
FT_TRACE2(( "cid_parser_new: cannot handle Type 11 fonts\n" ));
error = FT_THROW( Unknown_File_Format );
@@ -216,6 +253,12 @@
}
+#undef STARTDATA
+#undef STARTDATA_LEN
+#undef SFNTS
+#undef SFNTS_LEN
+
+
FT_LOCAL_DEF( void )
cid_parser_done( CID_Parser* parser )
{
diff --git a/src/3rdparty/freetype/src/cid/cidparse.h b/src/3rdparty/freetype/src/cid/cidparse.h
index f581bb43ff..61602f7674 100644
--- a/src/3rdparty/freetype/src/cid/cidparse.h
+++ b/src/3rdparty/freetype/src/cid/cidparse.h
@@ -4,7 +4,7 @@
/* */
/* CID-keyed Type1 parser (specification). */
/* */
-/* Copyright 1996-2015 by */
+/* Copyright 1996-2018 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -16,8 +16,8 @@
/***************************************************************************/
-#ifndef __CIDPARSE_H__
-#define __CIDPARSE_H__
+#ifndef CIDPARSE_H_
+#define CIDPARSE_H_
#include <ft2build.h>
@@ -117,7 +117,7 @@ FT_BEGIN_HEADER
FT_END_HEADER
-#endif /* __CIDPARSE_H__ */
+#endif /* CIDPARSE_H_ */
/* END */
diff --git a/src/3rdparty/freetype/src/cid/cidriver.c b/src/3rdparty/freetype/src/cid/cidriver.c
index 07c4cc410b..d9faf353ea 100644
--- a/src/3rdparty/freetype/src/cid/cidriver.c
+++ b/src/3rdparty/freetype/src/cid/cidriver.c
@@ -4,7 +4,7 @@
/* */
/* CID driver interface (body). */
/* */
-/* Copyright 1996-2015 by */
+/* Copyright 1996-2018 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 "cidriver.h"
#include "cidgload.h"
#include FT_INTERNAL_DEBUG_H
+#include FT_INTERNAL_POSTSCRIPT_PROPS_H
#include "ciderrs.h"
@@ -27,6 +28,10 @@
#include FT_SERVICE_FONT_FORMAT_H
#include FT_SERVICE_POSTSCRIPT_INFO_H
#include FT_SERVICE_CID_H
+#include FT_SERVICE_PROPERTIES_H
+#include FT_DRIVER_H
+
+#include FT_INTERNAL_POSTSCRIPT_AUX_H
/*************************************************************************/
@@ -59,7 +64,7 @@
static const FT_Service_PsFontNameRec cid_service_ps_name =
{
- (FT_PsName_GetFunc) cid_get_postscript_name
+ (FT_PsName_GetFunc)cid_get_postscript_name /* get_ps_font_name */
};
@@ -88,11 +93,14 @@
static const FT_Service_PsInfoRec cid_service_ps_info =
{
- (PS_GetFontInfoFunc) cid_ps_get_font_info,
- (PS_GetFontExtraFunc) cid_ps_get_font_extra,
- (PS_HasGlyphNamesFunc) NULL, /* unsupported with CID fonts */
- (PS_GetFontPrivateFunc)NULL, /* unsupported */
- (PS_GetFontValueFunc) NULL /* not implemented */
+ (PS_GetFontInfoFunc) cid_ps_get_font_info, /* ps_get_font_info */
+ (PS_GetFontExtraFunc) cid_ps_get_font_extra, /* ps_get_font_extra */
+ /* unsupported with CID fonts */
+ (PS_HasGlyphNamesFunc) NULL, /* ps_has_glyph_names */
+ /* unsupported */
+ (PS_GetFontPrivateFunc)NULL, /* ps_get_font_private */
+ /* not implemented */
+ (PS_GetFontValueFunc) NULL /* ps_get_font_value */
};
@@ -155,13 +163,28 @@
static const FT_Service_CIDRec cid_service_cid_info =
{
- (FT_CID_GetRegistryOrderingSupplementFunc)cid_get_ros,
- (FT_CID_GetIsInternallyCIDKeyedFunc) cid_get_is_cid,
- (FT_CID_GetCIDFromGlyphIndexFunc) cid_get_cid_from_glyph_index
+ (FT_CID_GetRegistryOrderingSupplementFunc)
+ cid_get_ros, /* get_ros */
+ (FT_CID_GetIsInternallyCIDKeyedFunc)
+ cid_get_is_cid, /* get_is_cid */
+ (FT_CID_GetCIDFromGlyphIndexFunc)
+ cid_get_cid_from_glyph_index /* get_cid_from_glyph_index */
};
/*
+ * PROPERTY SERVICE
+ *
+ */
+
+ FT_DEFINE_SERVICE_PROPERTIESREC(
+ cid_service_properties,
+
+ (FT_Properties_SetFunc)ps_property_set, /* set_property */
+ (FT_Properties_GetFunc)ps_property_get ) /* get_property */
+
+
+ /*
* SERVICE LIST
*
*/
@@ -172,6 +195,7 @@
{ FT_SERVICE_ID_POSTSCRIPT_FONT_NAME, &cid_service_ps_name },
{ FT_SERVICE_ID_POSTSCRIPT_INFO, &cid_service_ps_info },
{ FT_SERVICE_ID_CID, &cid_service_cid_info },
+ { FT_SERVICE_ID_PROPERTIES, &cid_service_properties },
{ NULL, NULL }
};
@@ -190,46 +214,42 @@
FT_CALLBACK_TABLE_DEF
const FT_Driver_ClassRec t1cid_driver_class =
{
- /* first of all, the FT_Module_Class fields */
{
FT_MODULE_FONT_DRIVER |
FT_MODULE_DRIVER_SCALABLE |
FT_MODULE_DRIVER_HAS_HINTER,
+ sizeof ( PS_DriverRec ),
- sizeof ( FT_DriverRec ),
"t1cid", /* module name */
0x10000L, /* version 1.0 of driver */
0x20000L, /* requires FreeType 2.0 */
- 0,
+ NULL, /* module-specific interface */
- cid_driver_init,
- cid_driver_done,
- cid_get_interface
+ cid_driver_init, /* FT_Module_Constructor module_init */
+ cid_driver_done, /* FT_Module_Destructor module_done */
+ cid_get_interface /* FT_Module_Requester get_interface */
},
- /* then the other font drivers fields */
sizeof ( CID_FaceRec ),
sizeof ( CID_SizeRec ),
sizeof ( CID_GlyphSlotRec ),
- cid_face_init,
- cid_face_done,
-
- cid_size_init,
- cid_size_done,
- cid_slot_init,
- cid_slot_done,
-
- cid_slot_load_glyph,
+ cid_face_init, /* FT_Face_InitFunc init_face */
+ cid_face_done, /* FT_Face_DoneFunc done_face */
+ cid_size_init, /* FT_Size_InitFunc init_size */
+ cid_size_done, /* FT_Size_DoneFunc done_size */
+ cid_slot_init, /* FT_Slot_InitFunc init_slot */
+ cid_slot_done, /* FT_Slot_DoneFunc done_slot */
- 0, /* FT_Face_GetKerningFunc */
- 0, /* FT_Face_AttachFunc */
+ cid_slot_load_glyph, /* FT_Slot_LoadFunc load_glyph */
- 0, /* FT_Face_GetAdvancesFunc */
+ NULL, /* FT_Face_GetKerningFunc get_kerning */
+ NULL, /* FT_Face_AttachFunc attach_file */
+ NULL, /* FT_Face_GetAdvancesFunc get_advances */
- cid_size_request,
- 0 /* FT_Size_SelectFunc */
+ cid_size_request, /* FT_Size_RequestFunc request_size */
+ NULL /* FT_Size_SelectFunc select_size */
};
diff --git a/src/3rdparty/freetype/src/cid/cidriver.h b/src/3rdparty/freetype/src/cid/cidriver.h
index e5b8678464..59d9ded901 100644
--- a/src/3rdparty/freetype/src/cid/cidriver.h
+++ b/src/3rdparty/freetype/src/cid/cidriver.h
@@ -4,7 +4,7 @@
/* */
/* High-level CID driver interface (specification). */
/* */
-/* Copyright 1996-2015 by */
+/* Copyright 1996-2018 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -16,8 +16,8 @@
/***************************************************************************/
-#ifndef __CIDRIVER_H__
-#define __CIDRIVER_H__
+#ifndef CIDRIVER_H_
+#define CIDRIVER_H_
#include <ft2build.h>
@@ -37,7 +37,7 @@ FT_BEGIN_HEADER
FT_END_HEADER
-#endif /* __CIDRIVER_H__ */
+#endif /* CIDRIVER_H_ */
/* END */
diff --git a/src/3rdparty/freetype/src/cid/cidtoken.h b/src/3rdparty/freetype/src/cid/cidtoken.h
index 82eae0ca6b..b0e2dac6aa 100644
--- a/src/3rdparty/freetype/src/cid/cidtoken.h
+++ b/src/3rdparty/freetype/src/cid/cidtoken.h
@@ -4,7 +4,7 @@
/* */
/* CID token definitions (specification only). */
/* */
-/* Copyright 1996-2015 by */
+/* Copyright 1996-2018 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
diff --git a/src/3rdparty/freetype/src/cid/module.mk b/src/3rdparty/freetype/src/cid/module.mk
index e312a3ca1a..9010e339a4 100644
--- a/src/3rdparty/freetype/src/cid/module.mk
+++ b/src/3rdparty/freetype/src/cid/module.mk
@@ -3,7 +3,7 @@
#
-# Copyright 1996-2015 by
+# Copyright 1996-2018 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/src/3rdparty/freetype/src/cid/rules.mk b/src/3rdparty/freetype/src/cid/rules.mk
index 282f2aad7a..94333bda06 100644
--- a/src/3rdparty/freetype/src/cid/rules.mk
+++ b/src/3rdparty/freetype/src/cid/rules.mk
@@ -3,7 +3,7 @@
#
-# Copyright 1996-2015 by
+# Copyright 1996-2018 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/src/3rdparty/freetype/src/cid/type1cid.c b/src/3rdparty/freetype/src/cid/type1cid.c
index 0d54ca7f44..61770e3f1e 100644
--- a/src/3rdparty/freetype/src/cid/type1cid.c
+++ b/src/3rdparty/freetype/src/cid/type1cid.c
@@ -4,7 +4,7 @@
/* */
/* FreeType OpenType driver component (body only). */
/* */
-/* Copyright 1996-2015 by */
+/* Copyright 1996-2018 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/src/3rdparty/freetype/src/gxvalid/Jamfile b/src/3rdparty/freetype/src/gxvalid/Jamfile
index d367cad77c..74f3c51ff0 100644
--- a/src/3rdparty/freetype/src/gxvalid/Jamfile
+++ b/src/3rdparty/freetype/src/gxvalid/Jamfile
@@ -1,6 +1,6 @@
# FreeType 2 src/gxvalid Jamfile
#
-# Copyright 2005-2015 by
+# Copyright 2005-2018 by
# suzuki toshiya, Masatake YAMATO and Red Hat K.K.
#
# This file is part of the FreeType project, and may only be used, modified,
diff --git a/src/3rdparty/freetype/src/gxvalid/README b/src/3rdparty/freetype/src/gxvalid/README
index 60f2fc185e..af8128e0e7 100644
--- a/src/3rdparty/freetype/src/gxvalid/README
+++ b/src/3rdparty/freetype/src/gxvalid/README
@@ -9,7 +9,7 @@ gxvalid: TrueType GX validator
additional tables in TrueType font which are used by `QuickDraw GX
Text', Apple Advanced Typography (AAT). In addition, gxvalid can
validates `kern' tables which have been extended for AAT. Like the
- otvalid module, gxvalid uses Freetype 2's validator framework
+ otvalid module, gxvalid uses FreeType 2's validator framework
(ftvalid).
You can link gxvalid with your program; before running your own layout
@@ -287,11 +287,11 @@ gxvalid: TrueType GX validator
4-5. invalid feature number (117/183)
-------------------------------------
- The GX/AAT extension can include 255 different layout features, but
- popular layout features are predefined (see
- http://developer.apple.com/fonts/Registry/index.html). Some fonts
- include feature numbers which are incompatible with the predefined
- feature registry.
+ The GX/AAT extension can include 255 different layout features,
+ but popular layout features are predefined (see
+ https://developer.apple.com/fonts/TrueType-Reference-Manual/RM09/AppendixF.html).
+ Some fonts include feature numbers which are incompatible with the
+ predefined feature registry.
In our survey, there are 140 fonts including `feat' table.
@@ -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-2015 by
+Copyright 2004-2018 by
suzuki toshiya, Masatake YAMATO, Red hat K.K.,
David Turner, Robert Wilhelm, and Werner Lemberg.
diff --git a/src/3rdparty/freetype/src/gxvalid/gxvalid.c b/src/3rdparty/freetype/src/gxvalid/gxvalid.c
index 7b5b0914db..d0577a247e 100644
--- a/src/3rdparty/freetype/src/gxvalid/gxvalid.c
+++ b/src/3rdparty/freetype/src/gxvalid/gxvalid.c
@@ -4,7 +4,7 @@
/* */
/* FreeType validator for TrueTypeGX/AAT tables (body only). */
/* */
-/* Copyright 2005-2015 by */
+/* Copyright 2005-2018 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/src/3rdparty/freetype/src/gxvalid/gxvalid.h b/src/3rdparty/freetype/src/gxvalid/gxvalid.h
index 8c227d0e0b..19f0379982 100644
--- a/src/3rdparty/freetype/src/gxvalid/gxvalid.h
+++ b/src/3rdparty/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-2015 by */
+/* Copyright 2005-2018 by */
/* suzuki toshiya, Masatake YAMATO, Red Hat K.K., */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
@@ -25,8 +25,8 @@
/***************************************************************************/
-#ifndef __GXVALID_H__
-#define __GXVALID_H__
+#ifndef GXVALID_H_
+#define GXVALID_H_
#include <ft2build.h>
#include FT_FREETYPE_H
@@ -102,7 +102,7 @@ FT_BEGIN_HEADER
FT_END_HEADER
-#endif /* __GXVALID_H__ */
+#endif /* GXVALID_H_ */
/* END */
diff --git a/src/3rdparty/freetype/src/gxvalid/gxvbsln.c b/src/3rdparty/freetype/src/gxvalid/gxvbsln.c
index 1b17a5d033..c367d38483 100644
--- a/src/3rdparty/freetype/src/gxvalid/gxvbsln.c
+++ b/src/3rdparty/freetype/src/gxvalid/gxvbsln.c
@@ -4,7 +4,7 @@
/* */
/* TrueTypeGX/AAT bsln table validation (body). */
/* */
-/* Copyright 2004-2015 by */
+/* Copyright 2004-2018 by */
/* suzuki toshiya, Masatake YAMATO, Red Hat K.K., */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
diff --git a/src/3rdparty/freetype/src/gxvalid/gxvcommn.c b/src/3rdparty/freetype/src/gxvalid/gxvcommn.c
index 93f6ffbe23..b96601108b 100644
--- a/src/3rdparty/freetype/src/gxvalid/gxvcommn.c
+++ b/src/3rdparty/freetype/src/gxvalid/gxvcommn.c
@@ -4,7 +4,7 @@
/* */
/* TrueTypeGX/AAT common tables validation (body). */
/* */
-/* Copyright 2004-2015 by */
+/* Copyright 2004-2018 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 );
@@ -900,7 +900,7 @@
for ( i = 0; i < nnames; i++ )
{
if ( FT_Get_Sfnt_Name( gxvalid->face, i, &name ) != FT_Err_Ok )
- continue ;
+ continue;
if ( name.name_id == name_index )
goto Out;
@@ -972,7 +972,7 @@
FT_UShort i;
- ft_memset( nGlyphInClass, 0, 256 );
+ FT_MEM_ZERO( nGlyphInClass, 256 );
for ( i = 0; i < nGlyphs; i++ )
@@ -1159,13 +1159,9 @@
case GXV_GLYPHOFFSET_LONG:
glyphOffset.l = FT_NEXT_LONG( p );
break;
-
- default:
- GXV_SET_ERR_IF_PARANOID( FT_INVALID_FORMAT );
- goto Exit;
}
- if ( NULL != gxvalid->statetable.entry_validate_func )
+ if ( gxvalid->statetable.entry_validate_func )
gxvalid->statetable.entry_validate_func( state,
flags,
&glyphOffset,
@@ -1174,7 +1170,6 @@
gxvalid );
}
- Exit:
*length_p = (FT_UShort)( p - table );
GXV_EXIT;
@@ -1249,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;
@@ -1477,7 +1472,7 @@
if ( ( p + ( maxEntry + 1 ) * entrySize ) > limit )
FT_INVALID_TOO_SHORT;
- for (entry = 0; entry <= maxEntry ; entry++ )
+ for (entry = 0; entry <= maxEntry; entry++ )
{
FT_UShort newState_idx;
FT_UShort flags;
@@ -1539,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,
@@ -1596,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/src/3rdparty/freetype/src/gxvalid/gxvcommn.h b/src/3rdparty/freetype/src/gxvalid/gxvcommn.h
index b24608c257..8e4ff9cafc 100644
--- a/src/3rdparty/freetype/src/gxvalid/gxvcommn.h
+++ b/src/3rdparty/freetype/src/gxvalid/gxvcommn.h
@@ -4,7 +4,7 @@
/* */
/* TrueTypeGX/AAT common tables validation (specification). */
/* */
-/* Copyright 2004-2015 by */
+/* Copyright 2004-2018 by */
/* suzuki toshiya, Masatake YAMATO, Red Hat K.K., */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
@@ -39,8 +39,8 @@
*/
-#ifndef __GXVCOMMN_H__
-#define __GXVCOMMN_H__
+#ifndef GXVCOMMN_H_
+#define GXVCOMMN_H_
#include <ft2build.h>
@@ -338,7 +338,7 @@ FT_BEGIN_HEADER
\
\
for ( b = p; b < (FT_Bytes)p + len; b++ ) \
- FT_TRACE1(("\\x%02x", *b)) ; \
+ FT_TRACE1(("\\x%02x", *b)); \
} \
FT_END_STMNT
@@ -350,9 +350,9 @@ FT_BEGIN_HEADER
\
for ( b = p; b < (FT_Bytes)p + len; b++ ) \
if ( 0x40 < *b && *b < 0x7E ) \
- FT_TRACE1(("%c", *b)) ; \
+ FT_TRACE1(("%c", *b)); \
else \
- FT_TRACE1(("\\x%02x", *b)) ; \
+ FT_TRACE1(("\\x%02x", *b)); \
} \
FT_END_STMNT
@@ -576,7 +576,7 @@ FT_BEGIN_HEADER
FT_END_HEADER
-#endif /* __GXVCOMMN_H__ */
+#endif /* GXVCOMMN_H_ */
/* END */
diff --git a/src/3rdparty/freetype/src/gxvalid/gxverror.h b/src/3rdparty/freetype/src/gxvalid/gxverror.h
index 6bbc23aa03..d1151258a9 100644
--- a/src/3rdparty/freetype/src/gxvalid/gxverror.h
+++ b/src/3rdparty/freetype/src/gxvalid/gxverror.h
@@ -4,7 +4,7 @@
/* */
/* TrueTypeGX/AAT validation module error codes (specification only). */
/* */
-/* Copyright 2004-2015 by */
+/* Copyright 2004-2018 by */
/* suzuki toshiya, Masatake YAMATO, Red Hat K.K., */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
@@ -32,12 +32,12 @@
/* */
/*************************************************************************/
-#ifndef __GXVERROR_H__
-#define __GXVERROR_H__
+#ifndef GXVERROR_H_
+#define GXVERROR_H_
#include FT_MODULE_ERRORS_H
-#undef __FTERRORS_H__
+#undef FTERRORS_H_
#undef FT_ERR_PREFIX
#define FT_ERR_PREFIX GXV_Err_
@@ -45,7 +45,7 @@
#include FT_ERRORS_H
-#endif /* __GXVERROR_H__ */
+#endif /* GXVERROR_H_ */
/* END */
diff --git a/src/3rdparty/freetype/src/gxvalid/gxvfeat.c b/src/3rdparty/freetype/src/gxvalid/gxvfeat.c
index 0da9777642..2c805d1d11 100644
--- a/src/3rdparty/freetype/src/gxvalid/gxvfeat.c
+++ b/src/3rdparty/freetype/src/gxvalid/gxvfeat.c
@@ -4,7 +4,7 @@
/* */
/* TrueTypeGX/AAT feat table validation (body). */
/* */
-/* Copyright 2004-2015 by */
+/* Copyright 2004-2018 by */
/* suzuki toshiya, Masatake YAMATO, Red Hat K.K., */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
diff --git a/src/3rdparty/freetype/src/gxvalid/gxvfeat.h b/src/3rdparty/freetype/src/gxvalid/gxvfeat.h
index b617df5d53..2d943806c1 100644
--- a/src/3rdparty/freetype/src/gxvalid/gxvfeat.h
+++ b/src/3rdparty/freetype/src/gxvalid/gxvfeat.h
@@ -4,7 +4,7 @@
/* */
/* TrueTypeGX/AAT feat table validation (specification). */
/* */
-/* Copyright 2004-2015 by */
+/* Copyright 2004-2018 by */
/* suzuki toshiya, Masatake YAMATO, Red Hat K.K., */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
@@ -25,8 +25,8 @@
/***************************************************************************/
-#ifndef __GXVFEAT_H__
-#define __GXVFEAT_H__
+#ifndef GXVFEAT_H_
+#define GXVFEAT_H_
#include "gxvalid.h"
@@ -167,7 +167,7 @@
};
-#endif /* __GXVFEAT_H__ */
+#endif /* GXVFEAT_H_ */
/* END */
diff --git a/src/3rdparty/freetype/src/gxvalid/gxvfgen.c b/src/3rdparty/freetype/src/gxvalid/gxvfgen.c
index 75c5e20d22..840c0f3524 100644
--- a/src/3rdparty/freetype/src/gxvalid/gxvfgen.c
+++ b/src/3rdparty/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-2015 by */
+/* Copyright 2004-2018 by */
/* Masatake YAMATO and Redhat K.K. */
/* */
/* This file may only be used, */
@@ -21,7 +21,7 @@
/* gxfeatreg.c */
/* */
/* Database of font features pre-defined by Apple Computer, Inc. */
-/* http://developer.apple.com/fonts/Registry/ */
+/* https://developer.apple.com/fonts/TrueType-Reference-Manual/RM09/AppendixF.html */
/* (body). */
/* */
/* Copyright 2003 by */
diff --git a/src/3rdparty/freetype/src/gxvalid/gxvjust.c b/src/3rdparty/freetype/src/gxvalid/gxvjust.c
index 55b44bc2a8..00c4293195 100644
--- a/src/3rdparty/freetype/src/gxvalid/gxvjust.c
+++ b/src/3rdparty/freetype/src/gxvalid/gxvjust.c
@@ -4,7 +4,7 @@
/* */
/* TrueTypeGX/AAT just table validation (body). */
/* */
-/* Copyright 2005-2015 by */
+/* Copyright 2005-2018 by */
/* suzuki toshiya, Masatake YAMATO, Red Hat K.K., */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
@@ -152,7 +152,7 @@
FT_Bytes limit,
GXV_Validator gxvalid )
{
- FT_Bytes p = table ;
+ FT_Bytes p = table;
FT_Bytes wdc_end = table + GXV_JUST_DATA( wdc_offset_max );
FT_UInt i;
diff --git a/src/3rdparty/freetype/src/gxvalid/gxvkern.c b/src/3rdparty/freetype/src/gxvalid/gxvkern.c
index f257c03760..9c0efd7a4f 100644
--- a/src/3rdparty/freetype/src/gxvalid/gxvkern.c
+++ b/src/3rdparty/freetype/src/gxvalid/gxvkern.c
@@ -4,7 +4,7 @@
/* */
/* TrueTypeGX/AAT kern table validation (body). */
/* */
-/* Copyright 2004-2015 by */
+/* Copyright 2004-2018 by */
/* suzuki toshiya, Masatake YAMATO, Red Hat K.K., */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
@@ -693,7 +693,7 @@
GXV_NAME_ENTER( "validating coverage" );
- GXV_TRACE(( "interprete coverage 0x%04x by Apple style\n", coverage ));
+ GXV_TRACE(( "interpret coverage 0x%04x by Apple style\n", coverage ));
if ( KERN_IS_NEW( gxvalid ) )
{
@@ -728,7 +728,7 @@
}
}
- GXV_TRACE(( "cannot interprete coverage, broken kern subtable\n" ));
+ GXV_TRACE(( "cannot interpret coverage, broken kern subtable\n" ));
Exit:
GXV_EXIT;
diff --git a/src/3rdparty/freetype/src/gxvalid/gxvlcar.c b/src/3rdparty/freetype/src/gxvalid/gxvlcar.c
index af589fdb6f..0f261a9ace 100644
--- a/src/3rdparty/freetype/src/gxvalid/gxvlcar.c
+++ b/src/3rdparty/freetype/src/gxvalid/gxvlcar.c
@@ -4,7 +4,7 @@
/* */
/* TrueTypeGX/AAT lcar table validation (body). */
/* */
-/* Copyright 2004-2015 by */
+/* Copyright 2004-2018 by */
/* suzuki toshiya, Masatake YAMATO, Red Hat K.K., */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
@@ -114,7 +114,7 @@
+------ lcar --------------------+
| |
| +===============+ |
- | | looup header | |
+ | | lookup header | |
| +===============+ |
| | BinSrchHeader | |
| +===============+ |
diff --git a/src/3rdparty/freetype/src/gxvalid/gxvmod.c b/src/3rdparty/freetype/src/gxvalid/gxvmod.c
index 17a02e7b8b..1a3c862927 100644
--- a/src/3rdparty/freetype/src/gxvalid/gxvmod.c
+++ b/src/3rdparty/freetype/src/gxvalid/gxvmod.c
@@ -4,7 +4,7 @@
/* */
/* FreeType's TrueTypeGX/AAT validation module implementation (body). */
/* */
-/* Copyright 2004-2015 by */
+/* Copyright 2004-2018 by */
/* suzuki toshiya, Masatake YAMATO, Red Hat K.K., */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
@@ -235,14 +235,14 @@
static
const FT_Service_GXvalidateRec gxvalid_interface =
{
- gxv_validate
+ gxv_validate /* validate */
};
static
const FT_Service_CKERNvalidateRec ckernvalid_interface =
{
- classic_kern_validate
+ classic_kern_validate /* validate */
};
@@ -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/src/3rdparty/freetype/src/gxvalid/gxvmod.h b/src/3rdparty/freetype/src/gxvalid/gxvmod.h
index 1ff2cfc8bb..745c62e105 100644
--- a/src/3rdparty/freetype/src/gxvalid/gxvmod.h
+++ b/src/3rdparty/freetype/src/gxvalid/gxvmod.h
@@ -5,7 +5,7 @@
/* FreeType's TrueTypeGX/AAT validation module implementation */
/* (specification). */
/* */
-/* Copyright 2004-2015 by */
+/* Copyright 2004-2018 by */
/* suzuki toshiya, Masatake YAMATO, Red Hat K.K., */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
@@ -26,8 +26,8 @@
/***************************************************************************/
-#ifndef __GXVMOD_H__
-#define __GXVMOD_H__
+#ifndef GXVMOD_H_
+#define GXVMOD_H_
#include <ft2build.h>
#include FT_MODULE_H
@@ -45,7 +45,7 @@ FT_BEGIN_HEADER
FT_END_HEADER
-#endif /* __GXVMOD_H__ */
+#endif /* GXVMOD_H_ */
/* END */
diff --git a/src/3rdparty/freetype/src/gxvalid/gxvmort.c b/src/3rdparty/freetype/src/gxvalid/gxvmort.c
index a9e7a58fea..b361cb2b9d 100644
--- a/src/3rdparty/freetype/src/gxvalid/gxvmort.c
+++ b/src/3rdparty/freetype/src/gxvalid/gxvmort.c
@@ -4,7 +4,7 @@
/* */
/* TrueTypeGX/AAT mort table validation (body). */
/* */
-/* Copyright 2005-2015 by */
+/* Copyright 2005-2018 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/src/3rdparty/freetype/src/gxvalid/gxvmort.h b/src/3rdparty/freetype/src/gxvalid/gxvmort.h
index c95391b61f..d8030645e9 100644
--- a/src/3rdparty/freetype/src/gxvalid/gxvmort.h
+++ b/src/3rdparty/freetype/src/gxvalid/gxvmort.h
@@ -4,7 +4,7 @@
/* */
/* TrueTypeGX/AAT common definition for mort table (specification). */
/* */
-/* Copyright 2004-2015 by */
+/* Copyright 2004-2018 by */
/* suzuki toshiya, Masatake YAMATO, Red Hat K.K., */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
@@ -25,8 +25,8 @@
/***************************************************************************/
-#ifndef __GXVMORT_H__
-#define __GXVMORT_H__
+#ifndef GXVMORT_H_
+#define GXVMORT_H_
#include "gxvalid.h"
#include "gxvcommn.h"
@@ -88,7 +88,7 @@
GXV_Validator gxvalid );
-#endif /* __GXVMORT_H__ */
+#endif /* GXVMORT_H_ */
/* END */
diff --git a/src/3rdparty/freetype/src/gxvalid/gxvmort0.c b/src/3rdparty/freetype/src/gxvalid/gxvmort0.c
index 0cace35ae2..95cf53d5eb 100644
--- a/src/3rdparty/freetype/src/gxvalid/gxvmort0.c
+++ b/src/3rdparty/freetype/src/gxvalid/gxvmort0.c
@@ -5,7 +5,7 @@
/* TrueTypeGX/AAT mort table validation */
/* body for type0 (Indic Script Rearrangement) subtable. */
/* */
-/* Copyright 2005-2015 by */
+/* Copyright 2005-2018 by */
/* suzuki toshiya, Masatake YAMATO, Red Hat K.K., */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
diff --git a/src/3rdparty/freetype/src/gxvalid/gxvmort1.c b/src/3rdparty/freetype/src/gxvalid/gxvmort1.c
index aa02df5a99..a7683a17b0 100644
--- a/src/3rdparty/freetype/src/gxvalid/gxvmort1.c
+++ b/src/3rdparty/freetype/src/gxvalid/gxvmort1.c
@@ -5,7 +5,7 @@
/* TrueTypeGX/AAT mort table validation */
/* body for type1 (Contextual Substitution) subtable. */
/* */
-/* Copyright 2005-2015 by */
+/* Copyright 2005-2018 by */
/* suzuki toshiya, Masatake YAMATO, Red Hat K.K., */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
@@ -192,7 +192,7 @@
GXV_NAME_ENTER( "validating contents of substitutionTable" );
- for ( i = 0; i < num_gids ; i ++ )
+ for ( i = 0; i < num_gids; i++ )
{
FT_UShort dst_gid;
diff --git a/src/3rdparty/freetype/src/gxvalid/gxvmort2.c b/src/3rdparty/freetype/src/gxvalid/gxvmort2.c
index 6f56c94ca7..c23c2775a1 100644
--- a/src/3rdparty/freetype/src/gxvalid/gxvmort2.c
+++ b/src/3rdparty/freetype/src/gxvalid/gxvmort2.c
@@ -5,7 +5,7 @@
/* TrueTypeGX/AAT mort table validation */
/* body for type2 (Ligature Substitution) subtable. */
/* */
-/* Copyright 2005-2015 by */
+/* Copyright 2005-2018 by */
/* suzuki toshiya, Masatake YAMATO, Red Hat K.K., */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
diff --git a/src/3rdparty/freetype/src/gxvalid/gxvmort4.c b/src/3rdparty/freetype/src/gxvalid/gxvmort4.c
index 535f37716d..9d21a5fc29 100644
--- a/src/3rdparty/freetype/src/gxvalid/gxvmort4.c
+++ b/src/3rdparty/freetype/src/gxvalid/gxvmort4.c
@@ -5,7 +5,7 @@
/* TrueTypeGX/AAT mort table validation */
/* body for type4 (Non-Contextual Glyph Substitution) subtable. */
/* */
-/* Copyright 2005-2015 by */
+/* Copyright 2005-2018 by */
/* suzuki toshiya, Masatake YAMATO, Red Hat K.K., */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
diff --git a/src/3rdparty/freetype/src/gxvalid/gxvmort5.c b/src/3rdparty/freetype/src/gxvalid/gxvmort5.c
index fb2f915fce..42cb428aa8 100644
--- a/src/3rdparty/freetype/src/gxvalid/gxvmort5.c
+++ b/src/3rdparty/freetype/src/gxvalid/gxvmort5.c
@@ -5,7 +5,7 @@
/* TrueTypeGX/AAT mort table validation */
/* body for type5 (Contextual Glyph Insertion) subtable. */
/* */
-/* Copyright 2005-2015 by */
+/* Copyright 2005-2018 by */
/* suzuki toshiya, Masatake YAMATO, Red Hat K.K., */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
diff --git a/src/3rdparty/freetype/src/gxvalid/gxvmorx.c b/src/3rdparty/freetype/src/gxvalid/gxvmorx.c
index 1c6b3f2973..9fd6e6b971 100644
--- a/src/3rdparty/freetype/src/gxvalid/gxvmorx.c
+++ b/src/3rdparty/freetype/src/gxvalid/gxvmorx.c
@@ -4,7 +4,7 @@
/* */
/* TrueTypeGX/AAT morx table validation (body). */
/* */
-/* Copyright 2005-2015 by */
+/* Copyright 2005-2018 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/src/3rdparty/freetype/src/gxvalid/gxvmorx.h b/src/3rdparty/freetype/src/gxvalid/gxvmorx.h
index 60efdfd0ce..6d9925e92b 100644
--- a/src/3rdparty/freetype/src/gxvalid/gxvmorx.h
+++ b/src/3rdparty/freetype/src/gxvalid/gxvmorx.h
@@ -4,7 +4,7 @@
/* */
/* TrueTypeGX/AAT common definition for morx table (specification). */
/* */
-/* Copyright 2005-2015 by */
+/* Copyright 2005-2018 by */
/* suzuki toshiya, Masatake YAMATO, Red Hat K.K., */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
@@ -25,8 +25,8 @@
/***************************************************************************/
-#ifndef __GXVMORX_H__
-#define __GXVMORX_H__
+#ifndef GXVMORX_H_
+#define GXVMORX_H_
#include "gxvalid.h"
@@ -62,7 +62,7 @@
GXV_Validator gxvalid );
-#endif /* __GXVMORX_H__ */
+#endif /* GXVMORX_H_ */
/* END */
diff --git a/src/3rdparty/freetype/src/gxvalid/gxvmorx0.c b/src/3rdparty/freetype/src/gxvalid/gxvmorx0.c
index e340baa5e4..302261b7fa 100644
--- a/src/3rdparty/freetype/src/gxvalid/gxvmorx0.c
+++ b/src/3rdparty/freetype/src/gxvalid/gxvmorx0.c
@@ -5,7 +5,7 @@
/* TrueTypeGX/AAT morx table validation */
/* body for type0 (Indic Script Rearrangement) subtable. */
/* */
-/* Copyright 2005-2015 by */
+/* Copyright 2005-2018 by */
/* suzuki toshiya, Masatake YAMATO, Red Hat K.K., */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
diff --git a/src/3rdparty/freetype/src/gxvalid/gxvmorx1.c b/src/3rdparty/freetype/src/gxvalid/gxvmorx1.c
index 7ba290914d..890ca74b1d 100644
--- a/src/3rdparty/freetype/src/gxvalid/gxvmorx1.c
+++ b/src/3rdparty/freetype/src/gxvalid/gxvmorx1.c
@@ -5,7 +5,7 @@
/* TrueTypeGX/AAT morx table validation */
/* body for type1 (Contextual Substitution) subtable. */
/* */
-/* Copyright 2005-2015 by */
+/* Copyright 2005-2018 by */
/* suzuki toshiya, Masatake YAMATO, Red Hat K.K., */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
diff --git a/src/3rdparty/freetype/src/gxvalid/gxvmorx2.c b/src/3rdparty/freetype/src/gxvalid/gxvmorx2.c
index 51e305580f..3135031d45 100644
--- a/src/3rdparty/freetype/src/gxvalid/gxvmorx2.c
+++ b/src/3rdparty/freetype/src/gxvalid/gxvmorx2.c
@@ -5,7 +5,7 @@
/* TrueTypeGX/AAT morx table validation */
/* body for type2 (Ligature Substitution) subtable. */
/* */
-/* Copyright 2005-2015 by */
+/* Copyright 2005-2018 by */
/* suzuki toshiya, Masatake YAMATO, Red Hat K.K., */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
diff --git a/src/3rdparty/freetype/src/gxvalid/gxvmorx4.c b/src/3rdparty/freetype/src/gxvalid/gxvmorx4.c
index c42677d45b..1e2397b0c5 100644
--- a/src/3rdparty/freetype/src/gxvalid/gxvmorx4.c
+++ b/src/3rdparty/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-2015 by */
+/* Copyright 2005-2018 by */
/* suzuki toshiya, Masatake YAMATO, Red Hat K.K., */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
diff --git a/src/3rdparty/freetype/src/gxvalid/gxvmorx5.c b/src/3rdparty/freetype/src/gxvalid/gxvmorx5.c
index 7ac872f9d7..db4f9290c8 100644
--- a/src/3rdparty/freetype/src/gxvalid/gxvmorx5.c
+++ b/src/3rdparty/freetype/src/gxvalid/gxvmorx5.c
@@ -5,7 +5,7 @@
/* TrueTypeGX/AAT morx table validation */
/* body for type5 (Contextual Glyph Insertion) subtable. */
/* */
-/* Copyright 2005-2015 by */
+/* Copyright 2005-2018 by */
/* suzuki toshiya, Masatake YAMATO, Red Hat K.K., */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
diff --git a/src/3rdparty/freetype/src/gxvalid/gxvopbd.c b/src/3rdparty/freetype/src/gxvalid/gxvopbd.c
index 7cd5163b17..e2c167ea59 100644
--- a/src/3rdparty/freetype/src/gxvalid/gxvopbd.c
+++ b/src/3rdparty/freetype/src/gxvalid/gxvopbd.c
@@ -4,7 +4,7 @@
/* */
/* TrueTypeGX/AAT opbd table validation (body). */
/* */
-/* Copyright 2004-2015 by */
+/* Copyright 2004-2018 by */
/* suzuki toshiya, Masatake YAMATO, Red Hat K.K., */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
diff --git a/src/3rdparty/freetype/src/gxvalid/gxvprop.c b/src/3rdparty/freetype/src/gxvalid/gxvprop.c
index ecc3c94d2c..a67b6bdd00 100644
--- a/src/3rdparty/freetype/src/gxvalid/gxvprop.c
+++ b/src/3rdparty/freetype/src/gxvalid/gxvprop.c
@@ -4,7 +4,7 @@
/* */
/* TrueTypeGX/AAT prop table validation (body). */
/* */
-/* Copyright 2004-2015 by */
+/* Copyright 2004-2018 by */
/* suzuki toshiya, Masatake YAMATO, Red Hat K.K., */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
diff --git a/src/3rdparty/freetype/src/gxvalid/gxvtrak.c b/src/3rdparty/freetype/src/gxvalid/gxvtrak.c
index c4d29e4dff..d501b5014b 100644
--- a/src/3rdparty/freetype/src/gxvalid/gxvtrak.c
+++ b/src/3rdparty/freetype/src/gxvalid/gxvtrak.c
@@ -4,7 +4,7 @@
/* */
/* TrueTypeGX/AAT trak table validation (body). */
/* */
-/* Copyright 2004-2015 by */
+/* Copyright 2004-2018 by */
/* suzuki toshiya, Masatake YAMATO, Red Hat K.K., */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
@@ -111,7 +111,7 @@
GXV_LIMIT_CHECK( nTracks * ( 4 + 2 + 2 ) );
- for ( i = 0; i < nTracks; i ++ )
+ for ( i = 0; i < nTracks; i++ )
{
p = table + i * ( 4 + 2 + 2 );
track = FT_NEXT_LONG( p );
@@ -125,7 +125,7 @@
gxv_sfntName_validate( nameIndex, 256, 32767, gxvalid );
- for ( j = i; j < nTracks; j ++ )
+ for ( j = i; j < nTracks; j++ )
{
p = table + j * ( 4 + 2 + 2 );
t = FT_NEXT_LONG( p );
diff --git a/src/3rdparty/freetype/src/gxvalid/module.mk b/src/3rdparty/freetype/src/gxvalid/module.mk
index 1d7649478e..b64879dcee 100644
--- a/src/3rdparty/freetype/src/gxvalid/module.mk
+++ b/src/3rdparty/freetype/src/gxvalid/module.mk
@@ -2,7 +2,7 @@
# FreeType 2 gxvalid module definition
#
-# Copyright 2004-2015 by
+# Copyright 2004-2018 by
# suzuki toshiya, Masatake YAMATO, Red Hat K.K.,
# David Turner, Robert Wilhelm, and Werner Lemberg.
#
diff --git a/src/3rdparty/freetype/src/gxvalid/rules.mk b/src/3rdparty/freetype/src/gxvalid/rules.mk
index 44a2d43250..3a17c030a6 100644
--- a/src/3rdparty/freetype/src/gxvalid/rules.mk
+++ b/src/3rdparty/freetype/src/gxvalid/rules.mk
@@ -3,7 +3,7 @@
#
-# Copyright 2004-2015 by
+# Copyright 2004-2018 by
# suzuki toshiya, Masatake YAMATO, Red Hat K.K.,
# David Turner, Robert Wilhelm, and Werner Lemberg.
#
diff --git a/src/3rdparty/freetype/src/gzip/Jamfile b/src/3rdparty/freetype/src/gzip/Jamfile
index 0944a5f2c4..a7b4c8c950 100644
--- a/src/3rdparty/freetype/src/gzip/Jamfile
+++ b/src/3rdparty/freetype/src/gzip/Jamfile
@@ -1,6 +1,6 @@
# FreeType 2 src/gzip Jamfile
#
-# Copyright 2001-2015 by
+# Copyright 2001-2018 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/src/3rdparty/freetype/src/gzip/ftgzip.c b/src/3rdparty/freetype/src/gzip/ftgzip.c
index 422035c00b..f8011c2dd8 100644
--- a/src/3rdparty/freetype/src/gzip/ftgzip.c
+++ b/src/3rdparty/freetype/src/gzip/ftgzip.c
@@ -8,7 +8,7 @@
/* parse compressed PCF fonts, as found with many X11 server */
/* distributions. */
/* */
-/* Copyright 2002-2015 by */
+/* Copyright 2002-2018 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -30,7 +30,7 @@
#include FT_MODULE_ERRORS_H
-#undef __FTERRORS_H__
+#undef FTERRORS_H_
#undef FT_ERR_PREFIX
#define FT_ERR_PREFIX Gzip_Err_
@@ -51,17 +51,29 @@
#else /* !FT_CONFIG_OPTION_SYSTEM_ZLIB */
- /* In this case, we include our own modified sources of the ZLib */
- /* within the "ftgzip" 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. */
+ /* 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 zutils.c */
+#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
@@ -305,7 +317,7 @@
zstream->next_in = zip->buffer;
if ( inflateInit2( zstream, -MAX_WBITS ) != Z_OK ||
- zstream->next_in == NULL )
+ !zstream->next_in )
error = FT_THROW( Invalid_File_Format );
Exit:
@@ -691,9 +703,13 @@
}
error = FT_Err_Ok;
}
+
+ if ( zip_size )
+ stream->size = zip_size;
+ else
+ stream->size = 0x7FFFFFFFL; /* don't know the real size! */
}
- stream->size = 0x7FFFFFFFL; /* don't know the real size! */
stream->pos = 0;
stream->base = NULL;
stream->read = ft_gzip_stream_io;
diff --git a/src/3rdparty/freetype/src/gzip/ftzconf.h b/src/3rdparty/freetype/src/gzip/ftzconf.h
new file mode 100644
index 0000000000..3abf0ba03b
--- /dev/null
+++ b/src/3rdparty/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/src/3rdparty/freetype/src/gzip/rules.mk b/src/3rdparty/freetype/src/gzip/rules.mk
index a8f74ec3c3..1a2e48bebd 100644
--- a/src/3rdparty/freetype/src/gzip/rules.mk
+++ b/src/3rdparty/freetype/src/gzip/rules.mk
@@ -3,7 +3,7 @@
#
-# Copyright 2002-2015 by
+# Copyright 2002-2018 by
# David Turner, Robert Wilhelm, and Werner Lemberg.
#
# This file is part of the FreeType project, and may only be used, modified,
@@ -34,12 +34,13 @@ endif
# gzip support sources
#
-# All source and header files get loaded by `ftgzip.c' only if SYTEM_ZLIB is
-# not defined (regardless whether we have a `single' or a `multi' build).
+# 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 \
@@ -50,7 +51,6 @@ GZIP_DRV_SRCS := $(GZIP_DIR)/adler32.c \
$(GZIP_DIR)/inftrees.h \
$(GZIP_DIR)/infutil.c \
$(GZIP_DIR)/infutil.h \
- $(GZIP_DIR)/zconf.h \
$(GZIP_DIR)/zlib.h \
$(GZIP_DIR)/zutil.c \
$(GZIP_DIR)/zutil.h
diff --git a/src/3rdparty/freetype/src/gzip/zlib.h b/src/3rdparty/freetype/src/gzip/zlib.h
index 50d0d3f146..a4e82c6a02 100644
--- a/src/3rdparty/freetype/src/gzip/zlib.h
+++ b/src/3rdparty/freetype/src/gzip/zlib.h
@@ -31,7 +31,7 @@
#ifndef _ZLIB_H
#define _ZLIB_H
-#include "zconf.h"
+#include "ftzconf.h"
#ifdef __cplusplus
extern "C" {
@@ -560,7 +560,7 @@ ZEXTERN(int) inflateInit2 OF((z_streamp strm,
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 current value of total_in which
+ 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.
diff --git a/src/3rdparty/freetype/src/gzip/zutil.h b/src/3rdparty/freetype/src/gzip/zutil.h
index 1949270998..c9688cd9c0 100644
--- a/src/3rdparty/freetype/src/gzip/zutil.h
+++ b/src/3rdparty/freetype/src/gzip/zutil.h
@@ -182,7 +182,7 @@ typedef unsigned long ulg;
#endif
/* Diagnostic functions */
-#if defined(DEBUG) && !defined(_WIN32_WCE)
+#ifdef DEBUG
# include <stdio.h>
extern int z_verbose;
extern void z_error OF((char *m));
diff --git a/src/3rdparty/freetype/src/lzw/Jamfile b/src/3rdparty/freetype/src/lzw/Jamfile
index 91effe20c4..cb83aa4a56 100644
--- a/src/3rdparty/freetype/src/lzw/Jamfile
+++ b/src/3rdparty/freetype/src/lzw/Jamfile
@@ -1,6 +1,6 @@
# FreeType 2 src/lzw Jamfile
#
-# Copyright 2004-2015 by
+# Copyright 2004-2018 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/src/3rdparty/freetype/src/lzw/ftlzw.c b/src/3rdparty/freetype/src/lzw/ftlzw.c
index 2f4e3b0f1d..cb46f93c68 100644
--- a/src/3rdparty/freetype/src/lzw/ftlzw.c
+++ b/src/3rdparty/freetype/src/lzw/ftlzw.c
@@ -8,7 +8,7 @@
/* be used to parse compressed PCF fonts, as found with many X11 server */
/* distributions. */
/* */
-/* Copyright 2004-2015 by */
+/* Copyright 2004-2018 by */
/* Albert Chin-A-Young. */
/* */
/* based on code in `src/gzip/ftgzip.c' */
@@ -31,7 +31,7 @@
#include FT_MODULE_ERRORS_H
-#undef __FTERRORS_H__
+#undef FTERRORS_H_
#undef FT_ERR_PREFIX
#define FT_ERR_PREFIX LZW_Err_
diff --git a/src/3rdparty/freetype/src/lzw/ftzopen.c b/src/3rdparty/freetype/src/lzw/ftzopen.c
index f96bb73d98..2b868ba9f2 100644
--- a/src/3rdparty/freetype/src/lzw/ftzopen.c
+++ b/src/3rdparty/freetype/src/lzw/ftzopen.c
@@ -8,7 +8,7 @@
/* be used to parse compressed PCF fonts, as found with many X11 server */
/* distributions. */
/* */
-/* Copyright 2005-2015 by */
+/* Copyright 2005-2018 by */
/* David Turner. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -42,7 +42,12 @@
state->buf_total += count;
state->in_eof = FT_BOOL( count < state->num_bits );
state->buf_offset = 0;
- state->buf_size = ( state->buf_size << 3 ) - ( state->num_bits - 1 );
+
+ 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;
@@ -66,7 +71,10 @@
{
if ( state->free_ent >= state->free_bits )
{
- state->num_bits = ++num_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;
@@ -366,7 +374,7 @@
{
while ( state->stack_top > 0 )
{
- --state->stack_top;
+ state->stack_top--;
if ( buffer )
buffer[result] = state->stack[state->stack_top];
diff --git a/src/3rdparty/freetype/src/lzw/ftzopen.h b/src/3rdparty/freetype/src/lzw/ftzopen.h
index d35e380595..4fd267eb90 100644
--- a/src/3rdparty/freetype/src/lzw/ftzopen.h
+++ b/src/3rdparty/freetype/src/lzw/ftzopen.h
@@ -8,7 +8,7 @@
/* be used to parse compressed PCF fonts, as found with many X11 server */
/* distributions. */
/* */
-/* Copyright 2005-2015 by */
+/* Copyright 2005-2018 by */
/* David Turner. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -19,8 +19,8 @@
/* */
/***************************************************************************/
-#ifndef __FT_ZOPEN_H__
-#define __FT_ZOPEN_H__
+#ifndef FTZOPEN_H_
+#define FTZOPEN_H_
#include <ft2build.h>
#include FT_FREETYPE_H
@@ -166,7 +166,7 @@
/* */
-#endif /* __FT_ZOPEN_H__ */
+#endif /* FTZOPEN_H_ */
/* END */
diff --git a/src/3rdparty/freetype/src/lzw/rules.mk b/src/3rdparty/freetype/src/lzw/rules.mk
index ab1c02fb50..18933c41c2 100644
--- a/src/3rdparty/freetype/src/lzw/rules.mk
+++ b/src/3rdparty/freetype/src/lzw/rules.mk
@@ -3,7 +3,7 @@
#
-# Copyright 2004-2015 by
+# Copyright 2004-2018 by
# Albert Chin-A-Young.
#
# based on `src/lzw/rules.mk'
diff --git a/src/3rdparty/freetype/src/otvalid/Jamfile b/src/3rdparty/freetype/src/otvalid/Jamfile
index 461a222174..21b8e0cb0f 100644
--- a/src/3rdparty/freetype/src/otvalid/Jamfile
+++ b/src/3rdparty/freetype/src/otvalid/Jamfile
@@ -1,6 +1,6 @@
# FreeType 2 src/otvalid Jamfile
#
-# Copyright 2004-2015 by
+# Copyright 2004-2018 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/src/3rdparty/freetype/src/otvalid/module.mk b/src/3rdparty/freetype/src/otvalid/module.mk
index 3d8c0d9f2e..34f3dab32f 100644
--- a/src/3rdparty/freetype/src/otvalid/module.mk
+++ b/src/3rdparty/freetype/src/otvalid/module.mk
@@ -3,7 +3,7 @@
#
-# Copyright 2004-2015 by
+# Copyright 2004-2018 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/src/3rdparty/freetype/src/otvalid/otvalid.c b/src/3rdparty/freetype/src/otvalid/otvalid.c
index ca597d707c..4423ca1012 100644
--- a/src/3rdparty/freetype/src/otvalid/otvalid.c
+++ b/src/3rdparty/freetype/src/otvalid/otvalid.c
@@ -4,7 +4,7 @@
/* */
/* FreeType validator for OpenType tables (body only). */
/* */
-/* Copyright 2004-2015 by */
+/* Copyright 2004-2018 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/src/3rdparty/freetype/src/otvalid/otvalid.h b/src/3rdparty/freetype/src/otvalid/otvalid.h
index 3475deb7a2..d7801abae5 100644
--- a/src/3rdparty/freetype/src/otvalid/otvalid.h
+++ b/src/3rdparty/freetype/src/otvalid/otvalid.h
@@ -4,7 +4,7 @@
/* */
/* OpenType table validation (specification only). */
/* */
-/* Copyright 2004-2015 by */
+/* Copyright 2004-2018 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -16,8 +16,8 @@
/***************************************************************************/
-#ifndef __OTVALID_H__
-#define __OTVALID_H__
+#ifndef OTVALID_H_
+#define OTVALID_H_
#include <ft2build.h>
@@ -72,7 +72,7 @@ FT_BEGIN_HEADER
FT_END_HEADER
-#endif /* __OTVALID_H__ */
+#endif /* OTVALID_H_ */
/* END */
diff --git a/src/3rdparty/freetype/src/otvalid/otvbase.c b/src/3rdparty/freetype/src/otvalid/otvbase.c
index 24038c63b7..a01d45c707 100644
--- a/src/3rdparty/freetype/src/otvalid/otvbase.c
+++ b/src/3rdparty/freetype/src/otvalid/otvbase.c
@@ -4,7 +4,7 @@
/* */
/* OpenType BASE table validation (body). */
/* */
-/* Copyright 2004-2015 by */
+/* Copyright 2004-2018 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -284,22 +284,41 @@
OTV_Validator otvalid = &otvalidrec;
FT_Bytes p = table;
FT_UInt table_size;
+ FT_UShort version;
OTV_OPTIONAL_TABLE( HorizAxis );
OTV_OPTIONAL_TABLE( VertAxis );
+ OTV_OPTIONAL_TABLE32( itemVarStore );
+
otvalid->root = ftvalid;
FT_TRACE3(( "validating BASE table\n" ));
OTV_INIT;
- OTV_LIMIT_CHECK( 6 );
+ OTV_LIMIT_CHECK( 4 );
- if ( FT_NEXT_ULONG( p ) != 0x10000UL ) /* Version */
+ if ( FT_NEXT_USHORT( p ) != 1 ) /* majorVersion */
FT_INVALID_FORMAT;
- table_size = 6;
+ version = FT_NEXT_USHORT( p ); /* minorVersion */
+
+ table_size = 8;
+ switch ( version )
+ {
+ case 0:
+ OTV_LIMIT_CHECK( 4 );
+ break;
+
+ case 1:
+ OTV_LIMIT_CHECK( 8 );
+ table_size += 4;
+ break;
+
+ default:
+ FT_INVALID_FORMAT;
+ }
OTV_OPTIONAL_OFFSET( HorizAxis );
OTV_SIZE_CHECK( HorizAxis );
@@ -311,6 +330,14 @@
if ( VertAxis )
otv_Axis_validate( table + VertAxis, otvalid );
+ if ( version > 0 )
+ {
+ OTV_OPTIONAL_OFFSET32( itemVarStore );
+ OTV_SIZE_CHECK32( itemVarStore );
+ if ( itemVarStore )
+ OTV_TRACE(( " [omitting itemVarStore validation]\n" )); /* XXX */
+ }
+
FT_TRACE4(( "\n" ));
}
diff --git a/src/3rdparty/freetype/src/otvalid/otvcommn.c b/src/3rdparty/freetype/src/otvalid/otvcommn.c
index 103ffba3e8..0ccfb03c08 100644
--- a/src/3rdparty/freetype/src/otvalid/otvcommn.c
+++ b/src/3rdparty/freetype/src/otvalid/otvcommn.c
@@ -4,7 +4,7 @@
/* */
/* OpenType common tables validation (body). */
/* */
-/* Copyright 2004-2015 by */
+/* Copyright 2004-2018 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;
@@ -313,19 +313,26 @@
OTV_NAME_ENTER( "Device" );
- OTV_LIMIT_CHECK( 8 );
+ OTV_LIMIT_CHECK( 6 );
StartSize = FT_NEXT_USHORT( p );
EndSize = FT_NEXT_USHORT( p );
DeltaFormat = FT_NEXT_USHORT( p );
- if ( DeltaFormat < 1 || DeltaFormat > 3 )
- FT_INVALID_FORMAT;
+ if ( DeltaFormat == 0x8000U )
+ {
+ /* VariationIndex, nothing to do */
+ }
+ else
+ {
+ if ( DeltaFormat < 1 || DeltaFormat > 3 )
+ FT_INVALID_FORMAT;
- if ( EndSize < StartSize )
- FT_INVALID_DATA;
+ if ( EndSize < StartSize )
+ FT_INVALID_DATA;
- count = EndSize - StartSize + 1;
- OTV_LIMIT_CHECK( ( 1 << DeltaFormat ) * count / 8 ); /* DeltaValue */
+ count = EndSize - StartSize + 1;
+ OTV_LIMIT_CHECK( ( 1 << DeltaFormat ) * count / 8 ); /* DeltaValue */
+ }
OTV_EXIT;
}
@@ -347,7 +354,7 @@
OTV_Validator otvalid )
{
FT_Bytes p = table;
- FT_UInt LookupType, SubTableCount;
+ FT_UInt LookupType, LookupFlag, SubTableCount;
OTV_Validate_Func validate;
@@ -355,7 +362,7 @@
OTV_LIMIT_CHECK( 6 );
LookupType = FT_NEXT_USHORT( p );
- p += 2; /* skip LookupFlag */
+ LookupFlag = FT_NEXT_USHORT( p );
SubTableCount = FT_NEXT_USHORT( p );
OTV_TRACE(( " (type %d)\n", LookupType ));
@@ -373,6 +380,9 @@
for ( ; SubTableCount > 0; SubTableCount-- )
validate( table + FT_NEXT_USHORT( p ), otvalid );
+ if ( LookupFlag & 0x10 )
+ OTV_LIMIT_CHECK( 2 ); /* MarkFilteringSet */
+
OTV_EXIT;
}
diff --git a/src/3rdparty/freetype/src/otvalid/otvcommn.h b/src/3rdparty/freetype/src/otvalid/otvcommn.h
index 3aebf0200d..a392784cf1 100644
--- a/src/3rdparty/freetype/src/otvalid/otvcommn.h
+++ b/src/3rdparty/freetype/src/otvalid/otvcommn.h
@@ -4,7 +4,7 @@
/* */
/* OpenType common tables validation (specification). */
/* */
-/* Copyright 2004-2015 by */
+/* Copyright 2004-2018 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -16,8 +16,8 @@
/***************************************************************************/
-#ifndef __OTVCOMMN_H__
-#define __OTVCOMMN_H__
+#ifndef OTVCOMMN_H_
+#define OTVCOMMN_H_
#include <ft2build.h>
@@ -67,29 +67,38 @@ FT_BEGIN_HEADER
#undef FT_INVALID_
-#define FT_INVALID_( _error ) \
+#define FT_INVALID_( _error ) \
ft_validator_error( otvalid->root, FT_THROW( _error ) )
#define OTV_OPTIONAL_TABLE( _table ) FT_UShort _table; \
FT_Bytes _table ## _p
+#define OTV_OPTIONAL_TABLE32( _table ) FT_ULong _table; \
+ FT_Bytes _table ## _p
+
#define OTV_OPTIONAL_OFFSET( _offset ) \
FT_BEGIN_STMNT \
_offset ## _p = p; \
_offset = FT_NEXT_USHORT( p ); \
FT_END_STMNT
-#define OTV_LIMIT_CHECK( _count ) \
- FT_BEGIN_STMNT \
+#define OTV_OPTIONAL_OFFSET32( _offset ) \
+ FT_BEGIN_STMNT \
+ _offset ## _p = p; \
+ _offset = FT_NEXT_ULONG( p ); \
+ FT_END_STMNT
+
+#define OTV_LIMIT_CHECK( _count ) \
+ FT_BEGIN_STMNT \
if ( p + (_count) > otvalid->root->limit ) \
- FT_INVALID_TOO_SHORT; \
+ FT_INVALID_TOO_SHORT; \
FT_END_STMNT
#define OTV_SIZE_CHECK( _size ) \
FT_BEGIN_STMNT \
if ( _size > 0 && _size < table_size ) \
{ \
- if ( otvalid->root->level == FT_VALIDATE_PARANOID ) \
+ if ( otvalid->root->level == FT_VALIDATE_PARANOID ) \
FT_INVALID_OFFSET; \
else \
{ \
@@ -102,12 +111,33 @@ FT_BEGIN_HEADER
" set to zero.\n" \
"\n", #_size )); \
\
- /* always assume 16bit entities */ \
_size = pp[0] = pp[1] = 0; \
} \
} \
FT_END_STMNT
+#define OTV_SIZE_CHECK32( _size ) \
+ FT_BEGIN_STMNT \
+ if ( _size > 0 && _size < table_size ) \
+ { \
+ if ( otvalid->root->level == FT_VALIDATE_PARANOID ) \
+ FT_INVALID_OFFSET; \
+ else \
+ { \
+ /* strip off `const' */ \
+ FT_Byte* pp = (FT_Byte*)_size ## _p; \
+ \
+ \
+ FT_TRACE3(( "\n" \
+ "Invalid offset to optional table `%s'" \
+ " set to zero.\n" \
+ "\n", #_size )); \
+ \
+ _size = pp[0] = pp[1] = pp[2] = pp[3] = 0; \
+ } \
+ } \
+ FT_END_STMNT
+
#define OTV_NAME_(x) #x
#define OTV_NAME(x) OTV_NAME_(x)
@@ -146,11 +176,11 @@ FT_BEGIN_HEADER
#define OTV_INIT otvalid->debug_indent = 0
-#define OTV_ENTER \
- FT_BEGIN_STMNT \
- otvalid->debug_indent += 2; \
- FT_TRACE4(( "%*.s", otvalid->debug_indent, 0 )); \
- FT_TRACE4(( "%s table\n", \
+#define OTV_ENTER \
+ FT_BEGIN_STMNT \
+ otvalid->debug_indent += 2; \
+ FT_TRACE4(( "%*.s", otvalid->debug_indent, 0 )); \
+ FT_TRACE4(( "%s table\n", \
otvalid->debug_function_name[otvalid->nesting_level] )); \
FT_END_STMNT
@@ -431,7 +461,7 @@ FT_BEGIN_HEADER
FT_END_HEADER
-#endif /* __OTVCOMMN_H__ */
+#endif /* OTVCOMMN_H_ */
/* END */
diff --git a/src/3rdparty/freetype/src/otvalid/otverror.h b/src/3rdparty/freetype/src/otvalid/otverror.h
index 214795e170..2fcf42e387 100644
--- a/src/3rdparty/freetype/src/otvalid/otverror.h
+++ b/src/3rdparty/freetype/src/otvalid/otverror.h
@@ -4,7 +4,7 @@
/* */
/* OpenType validation module error codes (specification only). */
/* */
-/* Copyright 2004-2015 by */
+/* Copyright 2004-2018 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -23,12 +23,12 @@
/* */
/*************************************************************************/
-#ifndef __OTVERROR_H__
-#define __OTVERROR_H__
+#ifndef OTVERROR_H_
+#define OTVERROR_H_
#include FT_MODULE_ERRORS_H
-#undef __FTERRORS_H__
+#undef FTERRORS_H_
#undef FT_ERR_PREFIX
#define FT_ERR_PREFIX OTV_Err_
@@ -36,7 +36,7 @@
#include FT_ERRORS_H
-#endif /* __OTVERROR_H__ */
+#endif /* OTVERROR_H_ */
/* END */
diff --git a/src/3rdparty/freetype/src/otvalid/otvgdef.c b/src/3rdparty/freetype/src/otvalid/otvgdef.c
index 8269d2f5b8..08f3171541 100644
--- a/src/3rdparty/freetype/src/otvalid/otvgdef.c
+++ b/src/3rdparty/freetype/src/otvalid/otvgdef.c
@@ -4,7 +4,7 @@
/* */
/* OpenType GDEF table validation (body). */
/* */
-/* Copyright 2004-2015 by */
+/* Copyright 2004-2018 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 );
otvalid->nesting_level++;
- func = otvalid->func[otvalid->nesting_level];
+ func = otvalid->func[otvalid->nesting_level];
otvalid->extra1 = 0;
for ( ; GlyphCount > 0; GlyphCount-- )
@@ -136,6 +136,40 @@
/*************************************************************************/
/*************************************************************************/
/***** *****/
+ /***** MARK GLYPH SETS *****/
+ /***** *****/
+ /*************************************************************************/
+ /*************************************************************************/
+
+ static void
+ otv_MarkGlyphSets_validate( FT_Bytes table,
+ OTV_Validator otvalid )
+ {
+ FT_Bytes p = table;
+ FT_UInt MarkGlyphSetCount;
+
+
+ OTV_NAME_ENTER( "MarkGlyphSets" );
+
+ p += 2; /* skip Format */
+
+ OTV_LIMIT_CHECK( 2 );
+ MarkGlyphSetCount = FT_NEXT_USHORT( p );
+
+ OTV_TRACE(( " (MarkGlyphSetCount = %d)\n", MarkGlyphSetCount ));
+
+ OTV_LIMIT_CHECK( MarkGlyphSetCount * 4 ); /* CoverageOffsets */
+
+ for ( ; MarkGlyphSetCount > 0; MarkGlyphSetCount-- )
+ otv_Coverage_validate( table + FT_NEXT_ULONG( p ), otvalid, -1 );
+
+ OTV_EXIT;
+ }
+
+
+ /*************************************************************************/
+ /*************************************************************************/
+ /***** *****/
/***** GDEF TABLE *****/
/***** *****/
/*************************************************************************/
@@ -152,14 +186,18 @@
{
OTV_ValidatorRec otvalidrec;
OTV_Validator otvalid = &otvalidrec;
- FT_Bytes p = table;
+ FT_Bytes p = table;
FT_UInt table_size;
- FT_Bool need_MarkAttachClassDef;
+ FT_UShort version;
+ FT_Bool need_MarkAttachClassDef = 1;
OTV_OPTIONAL_TABLE( GlyphClassDef );
OTV_OPTIONAL_TABLE( AttachListOffset );
OTV_OPTIONAL_TABLE( LigCaretListOffset );
OTV_OPTIONAL_TABLE( MarkAttachClassDef );
+ OTV_OPTIONAL_TABLE( MarkGlyphSetsDef );
+
+ OTV_OPTIONAL_TABLE32( itemVarStore );
otvalid->root = ftvalid;
@@ -167,24 +205,49 @@
FT_TRACE3(( "validating GDEF table\n" ));
OTV_INIT;
- OTV_LIMIT_CHECK( 12 );
+ OTV_LIMIT_CHECK( 4 );
- if ( FT_NEXT_ULONG( p ) != 0x10000UL ) /* Version */
+ if ( FT_NEXT_USHORT( p ) != 1 ) /* majorVersion */
FT_INVALID_FORMAT;
- /* MarkAttachClassDef has been added to the OpenType */
- /* specification without increasing GDEF's version, */
- /* so we use this ugly hack to find out whether the */
- /* table is needed actually. */
+ version = FT_NEXT_USHORT( p ); /* minorVersion */
- need_MarkAttachClassDef = FT_BOOL(
- otv_GSUBGPOS_have_MarkAttachmentType_flag( gsub ) ||
- otv_GSUBGPOS_have_MarkAttachmentType_flag( gpos ) );
+ table_size = 10;
+ switch ( version )
+ {
+ case 0:
+ /* MarkAttachClassDef has been added to the OpenType */
+ /* specification without increasing GDEF's version, */
+ /* so we use this ugly hack to find out whether the */
+ /* table is needed actually. */
+
+ need_MarkAttachClassDef = FT_BOOL(
+ otv_GSUBGPOS_have_MarkAttachmentType_flag( gsub ) ||
+ otv_GSUBGPOS_have_MarkAttachmentType_flag( gpos ) );
+
+ if ( need_MarkAttachClassDef )
+ {
+ OTV_LIMIT_CHECK( 8 );
+ table_size += 2;
+ }
+ else
+ OTV_LIMIT_CHECK( 6 ); /* OpenType < 1.2 */
- if ( need_MarkAttachClassDef )
- table_size = 12; /* OpenType >= 1.2 */
- else
- table_size = 10; /* OpenType < 1.2 */
+ break;
+
+ case 2:
+ OTV_LIMIT_CHECK( 10 );
+ table_size += 4;
+ break;
+
+ case 3:
+ OTV_LIMIT_CHECK( 14 );
+ table_size += 8;
+ break;
+
+ default:
+ FT_INVALID_FORMAT;
+ }
otvalid->glyph_count = glyph_count;
@@ -217,6 +280,22 @@
otv_ClassDef_validate( table + MarkAttachClassDef, otvalid );
}
+ if ( version > 0 )
+ {
+ OTV_OPTIONAL_OFFSET( MarkGlyphSetsDef );
+ OTV_SIZE_CHECK( MarkGlyphSetsDef );
+ if ( MarkGlyphSetsDef )
+ otv_MarkGlyphSets_validate( table + MarkGlyphSetsDef, otvalid );
+ }
+
+ if ( version > 2 )
+ {
+ OTV_OPTIONAL_OFFSET32( itemVarStore );
+ OTV_SIZE_CHECK32( itemVarStore );
+ if ( itemVarStore )
+ OTV_TRACE(( " [omitting itemVarStore validation]\n" )); /* XXX */
+ }
+
FT_TRACE4(( "\n" ));
}
diff --git a/src/3rdparty/freetype/src/otvalid/otvgpos.c b/src/3rdparty/freetype/src/otvalid/otvgpos.c
index 44c43c53a1..696b35cae6 100644
--- a/src/3rdparty/freetype/src/otvalid/otvgpos.c
+++ b/src/3rdparty/freetype/src/otvalid/otvgpos.c
@@ -4,7 +4,7 @@
/* */
/* OpenType GPOS table validation (body). */
/* */
-/* Copyright 2002-2015 by */
+/* Copyright 2002-2018 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 @@
otv_MarkArray_validate( table + Array1, otvalid );
otvalid->nesting_level++;
- func = otvalid->func[otvalid->nesting_level];
+ func = otvalid->func[otvalid->nesting_level];
otvalid->extra1 = ClassCount;
func( table + Array2, otvalid );
@@ -218,10 +218,6 @@
OTV_LIMIT_CHECK( 2 );
OTV_OPTIONAL_OFFSET( device );
- /* XXX: this value is usually too small, especially if the current */
- /* ValueRecord is part of an array -- getting the correct table */
- /* size is probably not worth the trouble */
-
table_size = p - otvalid->extra3;
OTV_SIZE_CHECK( device );
@@ -271,7 +267,7 @@
case 3:
{
- FT_UInt table_size;
+ FT_UInt table_size;
OTV_OPTIONAL_TABLE( XDeviceTable );
OTV_OPTIONAL_TABLE( YDeviceTable );
@@ -426,6 +422,8 @@
/*************************************************************************/
/*************************************************************************/
+ /* sets otvalid->extra3 (pointer to base table) */
+
static void
otv_PairSet_validate( FT_Bytes table,
FT_UInt format1,
@@ -438,6 +436,8 @@
OTV_NAME_ENTER( "PairSet" );
+ otvalid->extra3 = table;
+
OTV_LIMIT_CHECK( 2 );
PairValueCount = FT_NEXT_USHORT( p );
@@ -483,8 +483,6 @@
OTV_TRACE(( " (format %d)\n", PosFormat ));
- otvalid->extra3 = table;
-
switch ( PosFormat )
{
case 1: /* PairPosFormat1 */
@@ -537,7 +535,9 @@
otv_ClassDef_validate( table + ClassDef2, otvalid );
OTV_LIMIT_CHECK( ClassCount1 * ClassCount2 *
- ( len_value1 + len_value2 ) );
+ ( len_value1 + len_value2 ) );
+
+ otvalid->extra3 = table;
/* Class1Record */
for ( ; ClassCount1 > 0; ClassCount1-- )
@@ -985,20 +985,42 @@
{
OTV_ValidatorRec validrec;
OTV_Validator otvalid = &validrec;
- FT_Bytes p = table;
+ FT_Bytes p = table;
+ FT_UInt table_size;
+ FT_UShort version;
FT_UInt ScriptList, FeatureList, LookupList;
+ OTV_OPTIONAL_TABLE32( featureVariations );
+
otvalid->root = ftvalid;
FT_TRACE3(( "validating GPOS table\n" ));
OTV_INIT;
- OTV_LIMIT_CHECK( 10 );
+ OTV_LIMIT_CHECK( 4 );
- if ( FT_NEXT_ULONG( p ) != 0x10000UL ) /* Version */
+ if ( FT_NEXT_USHORT( p ) != 1 ) /* majorVersion */
FT_INVALID_FORMAT;
+ version = FT_NEXT_USHORT( p ); /* minorVersion */
+
+ table_size = 10;
+ switch ( version )
+ {
+ case 0:
+ OTV_LIMIT_CHECK( 6 );
+ break;
+
+ case 1:
+ OTV_LIMIT_CHECK( 10 );
+ table_size += 4;
+ break;
+
+ default:
+ FT_INVALID_FORMAT;
+ }
+
ScriptList = FT_NEXT_USHORT( p );
FeatureList = FT_NEXT_USHORT( p );
LookupList = FT_NEXT_USHORT( p );
@@ -1014,6 +1036,14 @@
otv_ScriptList_validate( table + ScriptList, table + FeatureList,
otvalid );
+ if ( version > 0 )
+ {
+ OTV_OPTIONAL_OFFSET32( featureVariations );
+ OTV_SIZE_CHECK32( featureVariations );
+ if ( featureVariations )
+ OTV_TRACE(( " [omitting featureVariations validation]\n" )); /* XXX */
+ }
+
FT_TRACE4(( "\n" ));
}
diff --git a/src/3rdparty/freetype/src/otvalid/otvgpos.h b/src/3rdparty/freetype/src/otvalid/otvgpos.h
index a792bd9519..95f9ac3ee8 100644
--- a/src/3rdparty/freetype/src/otvalid/otvgpos.h
+++ b/src/3rdparty/freetype/src/otvalid/otvgpos.h
@@ -4,7 +4,7 @@
/* */
/* OpenType GPOS table validator (specification). */
/* */
-/* Copyright 2004-2015 by */
+/* Copyright 2004-2018 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -16,8 +16,8 @@
/***************************************************************************/
-#ifndef __OTVGPOS_H__
-#define __OTVGPOS_H__
+#ifndef OTVGPOS_H_
+#define OTVGPOS_H_
FT_BEGIN_HEADER
@@ -30,7 +30,7 @@ FT_BEGIN_HEADER
FT_END_HEADER
-#endif /* __OTVGPOS_H__ */
+#endif /* OTVGPOS_H_ */
/* END */
diff --git a/src/3rdparty/freetype/src/otvalid/otvgsub.c b/src/3rdparty/freetype/src/otvalid/otvgsub.c
index 0f8b02cd20..d35ea67f30 100644
--- a/src/3rdparty/freetype/src/otvalid/otvgsub.c
+++ b/src/3rdparty/freetype/src/otvalid/otvgsub.c
@@ -4,7 +4,7 @@
/* */
/* OpenType GSUB table validation (body). */
/* */
-/* Copyright 2004-2015 by */
+/* Copyright 2004-2018 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -552,18 +552,40 @@
OTV_ValidatorRec otvalidrec;
OTV_Validator otvalid = &otvalidrec;
FT_Bytes p = table;
+ FT_UInt table_size;
+ FT_UShort version;
FT_UInt ScriptList, FeatureList, LookupList;
+ OTV_OPTIONAL_TABLE32( featureVariations );
+
otvalid->root = ftvalid;
FT_TRACE3(( "validating GSUB table\n" ));
OTV_INIT;
- OTV_LIMIT_CHECK( 10 );
+ OTV_LIMIT_CHECK( 4 );
+
+ if ( FT_NEXT_USHORT( p ) != 1 ) /* majorVersion */
+ FT_INVALID_FORMAT;
+
+ version = FT_NEXT_USHORT( p ); /* minorVersion */
+
+ table_size = 10;
+ switch ( version )
+ {
+ case 0:
+ OTV_LIMIT_CHECK( 6 );
+ break;
+
+ case 1:
+ OTV_LIMIT_CHECK( 10 );
+ table_size += 4;
+ break;
- if ( FT_NEXT_ULONG( p ) != 0x10000UL ) /* Version */
+ default:
FT_INVALID_FORMAT;
+ }
ScriptList = FT_NEXT_USHORT( p );
FeatureList = FT_NEXT_USHORT( p );
@@ -580,6 +602,14 @@
otv_ScriptList_validate( table + ScriptList, table + FeatureList,
otvalid );
+ if ( version > 0 )
+ {
+ OTV_OPTIONAL_OFFSET32( featureVariations );
+ OTV_SIZE_CHECK32( featureVariations );
+ if ( featureVariations )
+ OTV_TRACE(( " [omitting featureVariations validation]\n" )); /* XXX */
+ }
+
FT_TRACE4(( "\n" ));
}
diff --git a/src/3rdparty/freetype/src/otvalid/otvjstf.c b/src/3rdparty/freetype/src/otvalid/otvjstf.c
index fe68a60f60..94d4af90f6 100644
--- a/src/3rdparty/freetype/src/otvalid/otvjstf.c
+++ b/src/3rdparty/freetype/src/otvalid/otvjstf.c
@@ -4,7 +4,7 @@
/* */
/* OpenType JSTF table validation (body). */
/* */
-/* Copyright 2004-2015 by */
+/* Copyright 2004-2018 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
diff --git a/src/3rdparty/freetype/src/otvalid/otvmath.c b/src/3rdparty/freetype/src/otvalid/otvmath.c
index db3d5f8f52..b9800f60a2 100644
--- a/src/3rdparty/freetype/src/otvalid/otvmath.c
+++ b/src/3rdparty/freetype/src/otvalid/otvmath.c
@@ -4,7 +4,7 @@
/* */
/* OpenType MATH table validation (body). */
/* */
-/* Copyright 2007-2015 by */
+/* Copyright 2007-2018 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 );
@@ -88,7 +88,7 @@
FT_Int isItalic )
{
FT_Bytes p = table;
- FT_UInt i, cnt, table_size ;
+ FT_UInt i, cnt, table_size;
OTV_OPTIONAL_TABLE( Coverage );
OTV_OPTIONAL_TABLE( 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/src/3rdparty/freetype/src/otvalid/otvmod.c b/src/3rdparty/freetype/src/otvalid/otvmod.c
index 92f851398d..89ee449d16 100644
--- a/src/3rdparty/freetype/src/otvalid/otvmod.c
+++ b/src/3rdparty/freetype/src/otvalid/otvmod.c
@@ -4,7 +4,7 @@
/* */
/* FreeType's OpenType validation module implementation (body). */
/* */
-/* Copyright 2004-2015 by */
+/* Copyright 2004-2018 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -240,7 +240,7 @@
static
const FT_Service_OTvalidateRec otvalid_interface =
{
- otv_validate
+ otv_validate /* validate */
};
@@ -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/src/3rdparty/freetype/src/otvalid/otvmod.h b/src/3rdparty/freetype/src/otvalid/otvmod.h
index c3a0234e9e..6917bccee5 100644
--- a/src/3rdparty/freetype/src/otvalid/otvmod.h
+++ b/src/3rdparty/freetype/src/otvalid/otvmod.h
@@ -5,7 +5,7 @@
/* FreeType's OpenType validation module implementation */
/* (specification). */
/* */
-/* Copyright 2004-2015 by */
+/* Copyright 2004-2018 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -17,8 +17,8 @@
/***************************************************************************/
-#ifndef __OTVMOD_H__
-#define __OTVMOD_H__
+#ifndef OTVMOD_H_
+#define OTVMOD_H_
#include <ft2build.h>
@@ -37,7 +37,7 @@ FT_BEGIN_HEADER
FT_END_HEADER
-#endif /* __OTVMOD_H__ */
+#endif /* OTVMOD_H_ */
/* END */
diff --git a/src/3rdparty/freetype/src/otvalid/rules.mk b/src/3rdparty/freetype/src/otvalid/rules.mk
index 56d749cc97..d4fc723740 100644
--- a/src/3rdparty/freetype/src/otvalid/rules.mk
+++ b/src/3rdparty/freetype/src/otvalid/rules.mk
@@ -3,7 +3,7 @@
#
-# Copyright 2004-2015 by
+# Copyright 2004-2018 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/src/3rdparty/freetype/src/pcf/Jamfile b/src/3rdparty/freetype/src/pcf/Jamfile
index f4789ea625..7b92b12ddc 100644
--- a/src/3rdparty/freetype/src/pcf/Jamfile
+++ b/src/3rdparty/freetype/src/pcf/Jamfile
@@ -1,6 +1,6 @@
# FreeType 2 src/pcf Jamfile
#
-# Copyright 2001-2015 by
+# Copyright 2001-2018 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/src/3rdparty/freetype/src/pcf/README b/src/3rdparty/freetype/src/pcf/README
index 10eff15fbe..09ea970eda 100644
--- a/src/3rdparty/freetype/src/pcf/README
+++ b/src/3rdparty/freetype/src/pcf/README
@@ -41,8 +41,8 @@ value given as argument into the corresponding glyph number.
Known problems
**************
-- dealing explicitly with encodings breaks the uniformity of freetype2
- api.
+- dealing explicitly with encodings breaks the uniformity of FreeType 2
+ API.
- except for encodings properties, client applications have no
visibility of the PCF_Face object. This means that applications
diff --git a/src/3rdparty/freetype/src/pcf/pcf.c b/src/3rdparty/freetype/src/pcf/pcf.c
index 11d5b7b2a0..8ffd6e280b 100644
--- a/src/3rdparty/freetype/src/pcf/pcf.c
+++ b/src/3rdparty/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/src/3rdparty/freetype/src/pcf/pcf.h b/src/3rdparty/freetype/src/pcf/pcf.h
index c0da503412..f0390cb1eb 100644
--- a/src/3rdparty/freetype/src/pcf/pcf.h
+++ b/src/3rdparty/freetype/src/pcf/pcf.h
@@ -25,8 +25,8 @@ THE SOFTWARE.
*/
-#ifndef __PCF_H__
-#define __PCF_H__
+#ifndef PCF_H_
+#define PCF_H_
#include <ft2build.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
@@ -226,12 +235,13 @@ FT_BEGIN_HEADER
#define GLYPHPADOPTIONS 4 /* I'm not sure about this */
FT_LOCAL( FT_Error )
- pcf_load_font( FT_Stream,
- PCF_Face );
+ pcf_load_font( FT_Stream stream,
+ PCF_Face face,
+ FT_Long face_index );
FT_END_HEADER
-#endif /* __PCF_H__ */
+#endif /* PCF_H_ */
/* END */
diff --git a/src/3rdparty/freetype/src/pcf/pcfdrivr.c b/src/3rdparty/freetype/src/pcf/pcfdrivr.c
index 8d2ed7cf4d..0119d94853 100644
--- a/src/3rdparty/freetype/src/pcf/pcfdrivr.c
+++ b/src/3rdparty/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_DRIVER_H
/*************************************************************************/
@@ -271,7 +273,7 @@ THE SOFTWARE.
FT_TRACE2(( "PCF driver\n" ));
- error = pcf_load_font( stream, face );
+ error = pcf_load_font( stream, face, face_index );
if ( error )
{
PCF_Face_Done( pcfface );
@@ -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;
@@ -332,7 +337,7 @@ THE SOFTWARE.
stream = pcfface->stream;
- error = pcf_load_font( stream, face );
+ error = pcf_load_font( stream, face, face_index );
if ( error )
goto Fail;
@@ -351,7 +356,9 @@ THE SOFTWARE.
* an invalid argument error when the font could be
* opened by the specified driver.
*/
- if ( face_index > 0 && ( face_index & 0xFFFF ) > 0 )
+ if ( face_index < 0 )
+ goto Exit;
+ else if ( face_index > 0 && ( face_index & 0xFFFF ) > 0 )
{
FT_ERROR(( "PCF_Face_Init: invalid face index\n" ));
PCF_Face_Done( pcfface );
@@ -380,7 +387,11 @@ THE SOFTWARE.
if ( !ft_strcmp( s, "10646" ) ||
( !ft_strcmp( s, "8859" ) &&
!ft_strcmp( face->charset_encoding, "1" ) ) )
- unicode_charmap = 1;
+ unicode_charmap = 1;
+ /* another name for ASCII */
+ else if ( !ft_strcmp( s, "646.1991" ) &&
+ !ft_strcmp( face->charset_encoding, "IRV" ) )
+ unicode_charmap = 1;
}
}
@@ -402,12 +413,6 @@ THE SOFTWARE.
}
error = FT_CMap_New( &pcf_cmap_class, NULL, &charmap, NULL );
-
-#if 0
- /* Select default charmap */
- if ( pcfface->num_charmaps )
- pcfface->charmap = pcfface->charmaps[0];
-#endif
}
}
@@ -490,8 +495,6 @@ THE SOFTWARE.
PCF_Metric metric;
FT_ULong bytes;
- FT_UNUSED( load_flags );
-
FT_TRACE1(( "PCF_Glyph_Load: glyph index %d\n", glyph_index ));
@@ -521,11 +524,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:
@@ -548,6 +546,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;
@@ -580,21 +596,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;
}
@@ -615,7 +616,7 @@ THE SOFTWARE.
prop = pcf_find_property( face, prop_name );
- if ( prop != NULL )
+ if ( prop )
{
if ( prop->isString )
{
@@ -624,19 +625,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 );
@@ -651,17 +656,127 @@ THE SOFTWARE.
*acharset_encoding = face->charset_encoding;
*acharset_registry = face->charset_registry;
- return 0;
+ return FT_Err_Ok;
}
static const FT_Service_BDFRec pcf_service_bdf =
{
- (FT_BDF_GetCharsetIdFunc)pcf_get_charset_id,
- (FT_BDF_GetPropertyFunc) pcf_get_bdf_property
+ (FT_BDF_GetCharsetIdFunc)pcf_get_charset_id, /* get_charset_id */
+ (FT_BDF_GetPropertyFunc) pcf_get_bdf_property /* get_property */
};
+ /*
+ * 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
@@ -672,6 +787,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 }
};
@@ -686,44 +802,67 @@ 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,
+ NULL, /* module-specific interface */
- 0, /* FT_Module_Constructor */
- 0, /* FT_Module_Destructor */
- pcf_driver_requester
+ pcf_driver_init, /* FT_Module_Constructor module_init */
+ pcf_driver_done, /* FT_Module_Destructor module_done */
+ pcf_driver_requester /* FT_Module_Requester get_interface */
},
sizeof ( PCF_FaceRec ),
sizeof ( FT_SizeRec ),
sizeof ( FT_GlyphSlotRec ),
- PCF_Face_Init,
- PCF_Face_Done,
- 0, /* FT_Size_InitFunc */
- 0, /* FT_Size_DoneFunc */
- 0, /* FT_Slot_InitFunc */
- 0, /* FT_Slot_DoneFunc */
+ PCF_Face_Init, /* FT_Face_InitFunc init_face */
+ PCF_Face_Done, /* FT_Face_DoneFunc done_face */
+ 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,
+ PCF_Glyph_Load, /* FT_Slot_LoadFunc load_glyph */
- 0, /* FT_Face_GetKerningFunc */
- 0, /* FT_Face_AttachFunc */
- 0, /* FT_Face_GetAdvancesFunc */
+ NULL, /* FT_Face_GetKerningFunc get_kerning */
+ NULL, /* FT_Face_AttachFunc attach_file */
+ NULL, /* FT_Face_GetAdvancesFunc get_advances */
- PCF_Size_Request,
- PCF_Size_Select
+ PCF_Size_Request, /* FT_Size_RequestFunc request_size */
+ PCF_Size_Select /* FT_Size_SelectFunc select_size */
};
diff --git a/src/3rdparty/freetype/src/pcf/pcfdrivr.h b/src/3rdparty/freetype/src/pcf/pcfdrivr.h
index 54614951b5..29d30497cd 100644
--- a/src/3rdparty/freetype/src/pcf/pcfdrivr.h
+++ b/src/3rdparty/freetype/src/pcf/pcfdrivr.h
@@ -25,8 +25,8 @@ THE SOFTWARE.
*/
-#ifndef __PCFDRIVR_H__
-#define __PCFDRIVR_H__
+#ifndef PCFDRIVR_H_
+#define PCFDRIVR_H_
#include <ft2build.h>
#include FT_INTERNAL_DRIVER_H
@@ -42,7 +42,7 @@ FT_BEGIN_HEADER
FT_END_HEADER
-#endif /* __PCFDRIVR_H__ */
+#endif /* PCFDRIVR_H_ */
/* END */
diff --git a/src/3rdparty/freetype/src/pcf/pcferror.h b/src/3rdparty/freetype/src/pcf/pcferror.h
index e51fff8ea6..add8ef2230 100644
--- a/src/3rdparty/freetype/src/pcf/pcferror.h
+++ b/src/3rdparty/freetype/src/pcf/pcferror.h
@@ -22,12 +22,12 @@
/* */
/*************************************************************************/
-#ifndef __PCFERROR_H__
-#define __PCFERROR_H__
+#ifndef PCFERROR_H_
+#define PCFERROR_H_
#include FT_MODULE_ERRORS_H
-#undef __FTERRORS_H__
+#undef FTERRORS_H_
#undef FT_ERR_PREFIX
#define FT_ERR_PREFIX PCF_Err_
@@ -35,7 +35,7 @@
#include FT_ERRORS_H
-#endif /* __PCFERROR_H__ */
+#endif /* PCFERROR_H_ */
/* END */
diff --git a/src/3rdparty/freetype/src/pcf/pcfread.c b/src/3rdparty/freetype/src/pcf/pcfread.c
index afa1480771..537da0dc79 100644
--- a/src/3rdparty/freetype/src/pcf/pcfread.c
+++ b/src/3rdparty/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
@@ -102,13 +109,27 @@ THE SOFTWARE.
FT_STREAM_READ_FIELDS( pcf_toc_header, toc ) )
return FT_THROW( Cannot_Open_Resource );
- if ( toc->version != PCF_FILE_VERSION ||
- toc->count > FT_ARRAY_MAX( face->toc.tables ) ||
- toc->count == 0 )
+ if ( toc->version != PCF_FILE_VERSION ||
+ toc->count == 0 )
return FT_THROW( Invalid_File_Format );
+ if ( stream->size < 16 )
+ return FT_THROW( Invalid_File_Format );
+
+ /* 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,
+ 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++ )
@@ -221,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,
@@ -308,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;
@@ -332,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;
}
@@ -431,7 +463,7 @@ THE SOFTWARE.
int i;
- for ( i = 0 ; i < face->nprops && !found; i++ )
+ for ( i = 0; i < face->nprops && !found; i++ )
{
if ( !ft_strcmp( properties[i].name, prop ) )
found = 1;
@@ -450,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;
@@ -470,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 ) )
@@ -515,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 );
@@ -537,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;
@@ -559,6 +620,7 @@ THE SOFTWARE.
face->properties = properties;
+ FT_TRACE4(( "\n" ));
for ( i = 0; i < nprops; i++ )
{
FT_Long name_offset = props[i].name;
@@ -621,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,
@@ -636,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 );
@@ -643,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;
@@ -705,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;
@@ -735,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,
@@ -753,18 +831,42 @@ 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 bit%s, scanning=%d bit%s)\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_GLYPH_PAD_INDEX( format ) ) == 1 ? "" : "s",
+ 8 << PCF_SCAN_UNIT_INDEX( format ),
+ ( 8 << PCF_SCAN_UNIT_INDEX( format ) ) == 1 ? "" : "s" ));
+
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 );
@@ -772,6 +874,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 )
@@ -779,7 +882,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 )
@@ -796,17 +899,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 */
@@ -814,7 +919,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];
@@ -838,7 +943,7 @@ THE SOFTWARE.
int firstCol, lastCol;
int firstRow, lastRow;
FT_ULong nencoding;
- int encodingOffset;
+ FT_UShort encodingOffset;
int i, j;
FT_ULong k;
PCF_Encoding encoding = NULL;
@@ -878,10 +983,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 ||
@@ -890,35 +1005,36 @@ 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++ )
{
for ( j = firstCol; j <= lastCol; j++ )
{
+ /* X11's reference implementation uses the equivalent to */
+ /* `FT_GET_SHORT', however PCF fonts with more than 32768 */
+ /* characters (e.g. `unifont.pcf') clearly show that an */
+ /* unsigned value is needed. */
if ( PCF_BYTE_ORDER( format ) == MSBFirst )
- encodingOffset = FT_GET_SHORT();
+ encodingOffset = FT_GET_USHORT();
else
- encodingOffset = FT_GET_SHORT_LE();
+ encodingOffset = FT_GET_USHORT_LE();
- if ( encodingOffset > -1 )
+ if ( encodingOffset != 0xFFFFU )
{
encoding[k].enc = i * 256 + j;
- encoding[k].glyph = (FT_UShort)encodingOffset;
+ encoding[k].glyph = encodingOffset;
FT_TRACE5(( " code %d (0x%04X): idx %d\n",
encoding[k].enc, encoding[k].enc, encoding[k].glyph ));
@@ -1009,6 +1125,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;
@@ -1024,12 +1149,43 @@ 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 ));
+
+ /* sanity checks */
+ if ( FT_ABS( accel->fontAscent ) > 0x7FFF )
+ {
+ accel->fontAscent = accel->fontAscent < 0 ? -0x7FFF : 0x7FFF;
+ FT_TRACE0(( "pfc_get_accel: clamping font ascent to value %d\n",
+ accel->fontAscent ));
+ }
+ if ( FT_ABS( accel->fontDescent ) > 0x7FFF )
+ {
+ accel->fontDescent = accel->fontDescent < 0 ? -0x7FFF : 0x7FFF;
+ FT_TRACE0(( "pfc_get_accel: clamping font descent to value %d\n",
+ accel->fontDescent ));
+ }
+
+ 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) );
@@ -1038,12 +1194,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) );
@@ -1052,7 +1210,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;
}
@@ -1141,7 +1299,7 @@ THE SOFTWARE.
len = lengths[nn];
- if ( src == NULL )
+ if ( !src )
continue;
/* separate elements with a space */
@@ -1173,8 +1331,10 @@ THE SOFTWARE.
FT_LOCAL_DEF( FT_Error )
pcf_load_font( FT_Stream stream,
- PCF_Face face )
+ PCF_Face face,
+ FT_Long face_index )
{
+ FT_Face root = FT_FACE( face );
FT_Error error;
FT_Memory memory = FT_FACE( face )->memory;
FT_Bool hasBDFAccelerators;
@@ -1184,6 +1344,13 @@ THE SOFTWARE.
if ( error )
goto Exit;
+ root->num_faces = 1;
+ root->face_index = 0;
+
+ /* If we are performing a simple font format check, exit immediately. */
+ if ( face_index < 0 )
+ return FT_Err_Ok;
+
error = pcf_get_properties( stream, face );
if ( error )
goto Exit;
@@ -1226,13 +1393,9 @@ THE SOFTWARE.
/* now construct the face object */
{
- FT_Face root = FT_FACE( face );
PCF_Property prop;
- root->num_faces = 1;
- root->face_index = 0;
-
root->face_flags |= FT_FACE_FLAG_FIXED_SIZES |
FT_FACE_FLAG_HORIZONTAL |
FT_FACE_FLAG_FAST_GLYPHS;
@@ -1240,14 +1403,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;
@@ -1270,7 +1500,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 */
@@ -1282,8 +1512,16 @@ THE SOFTWARE.
if ( face->accel.fontAscent + face->accel.fontDescent < 0 )
FT_TRACE0(( "pcf_load_font: negative height\n" ));
#endif
- bsize->height = FT_ABS( (FT_Short)( face->accel.fontAscent +
- face->accel.fontDescent ) );
+ if ( FT_ABS( face->accel.fontAscent +
+ face->accel.fontDescent ) > 0x7FFF )
+ {
+ bsize->height = 0x7FFF;
+ FT_TRACE0(( "pcf_load_font: clamping height to value %d\n",
+ bsize->height ));
+ }
+ else
+ bsize->height = FT_ABS( (FT_Short)( face->accel.fontAscent +
+ face->accel.fontDescent ) );
prop = pcf_find_property( face, "AVERAGE_WIDTH" );
if ( prop )
@@ -1292,10 +1530,20 @@ THE SOFTWARE.
if ( prop->value.l < 0 )
FT_TRACE0(( "pcf_load_font: negative average width\n" ));
#endif
- bsize->width = FT_ABS( (FT_Short)( ( prop->value.l ) + 5 ) / 10 );
+ if ( ( FT_ABS( prop->value.l ) > 0x7FFFL * 10 - 5 ) )
+ {
+ bsize->width = 0x7FFF;
+ FT_TRACE0(( "pcf_load_font: clamping average width to value %d\n",
+ bsize->width ));
+ }
+ else
+ bsize->width = FT_ABS( (FT_Short)( ( prop->value.l + 5 ) / 10 ) );
}
else
+ {
+ /* this is a heuristical value */
bsize->width = (FT_Short)FT_MulDiv( bsize->height, 2, 3 );
+ }
prop = pcf_find_property( face, "POINT_SIZE" );
if ( prop )
@@ -1305,9 +1553,16 @@ THE SOFTWARE.
FT_TRACE0(( "pcf_load_font: negative point size\n" ));
#endif
/* convert from 722.7 decipoints to 72 points per inch */
- bsize->size = FT_MulDiv( FT_ABS( prop->value.l ),
- 64 * 7200,
- 72270L );
+ if ( FT_ABS( prop->value.l ) > 0x504C2L ) /* 0x7FFF * 72270/7200 */
+ {
+ bsize->size = 0x7FFF;
+ FT_TRACE0(( "pcf_load_font: clamping point size to value %d\n",
+ bsize->size ));
+ }
+ else
+ bsize->size = FT_MulDiv( FT_ABS( prop->value.l ),
+ 64 * 7200,
+ 72270L );
}
prop = pcf_find_property( face, "PIXEL_SIZE" );
@@ -1317,7 +1572,14 @@ THE SOFTWARE.
if ( prop->value.l < 0 )
FT_TRACE0(( "pcf_load_font: negative pixel size\n" ));
#endif
- bsize->y_ppem = FT_ABS( (FT_Short)prop->value.l ) << 6;
+ if ( FT_ABS( prop->value.l ) > 0x7FFF )
+ {
+ bsize->y_ppem = 0x7FFF << 6;
+ FT_TRACE0(( "pcf_load_font: clamping pixel size to value %d\n",
+ bsize->y_ppem ));
+ }
+ else
+ bsize->y_ppem = FT_ABS( (FT_Short)prop->value.l ) << 6;
}
prop = pcf_find_property( face, "RESOLUTION_X" );
@@ -1327,7 +1589,14 @@ THE SOFTWARE.
if ( prop->value.l < 0 )
FT_TRACE0(( "pcf_load_font: negative X resolution\n" ));
#endif
- resolution_x = FT_ABS( (FT_Short)prop->value.l );
+ if ( FT_ABS( prop->value.l ) > 0x7FFF )
+ {
+ resolution_x = 0x7FFF;
+ FT_TRACE0(( "pcf_load_font: clamping X resolution to value %d\n",
+ resolution_x ));
+ }
+ else
+ resolution_x = FT_ABS( (FT_Short)prop->value.l );
}
prop = pcf_find_property( face, "RESOLUTION_Y" );
@@ -1337,7 +1606,14 @@ THE SOFTWARE.
if ( prop->value.l < 0 )
FT_TRACE0(( "pcf_load_font: negative Y resolution\n" ));
#endif
- resolution_y = FT_ABS( (FT_Short)prop->value.l );
+ if ( FT_ABS( prop->value.l ) > 0x7FFF )
+ {
+ resolution_y = 0x7FFF;
+ FT_TRACE0(( "pcf_load_font: clamping Y resolution to value %d\n",
+ resolution_y ));
+ }
+ else
+ resolution_y = FT_ABS( (FT_Short)prop->value.l );
}
if ( bsize->y_ppem == 0 )
diff --git a/src/3rdparty/freetype/src/pcf/pcfread.h b/src/3rdparty/freetype/src/pcf/pcfread.h
index c9524f1346..bed30e5030 100644
--- a/src/3rdparty/freetype/src/pcf/pcfread.h
+++ b/src/3rdparty/freetype/src/pcf/pcfread.h
@@ -25,8 +25,8 @@ THE SOFTWARE.
*/
-#ifndef __PCFREAD_H__
-#define __PCFREAD_H__
+#ifndef PCFREAD_H_
+#define PCFREAD_H_
#include <ft2build.h>
@@ -39,7 +39,7 @@ FT_BEGIN_HEADER
FT_END_HEADER
-#endif /* __PCFREAD_H__ */
+#endif /* PCFREAD_H_ */
/* END */
diff --git a/src/3rdparty/freetype/src/pcf/pcfutil.h b/src/3rdparty/freetype/src/pcf/pcfutil.h
index ce10fb541d..be986e756b 100644
--- a/src/3rdparty/freetype/src/pcf/pcfutil.h
+++ b/src/3rdparty/freetype/src/pcf/pcfutil.h
@@ -25,8 +25,8 @@ THE SOFTWARE.
*/
-#ifndef __PCFUTIL_H__
-#define __PCFUTIL_H__
+#ifndef PCFUTIL_H_
+#define PCFUTIL_H_
#include <ft2build.h>
@@ -49,7 +49,7 @@ FT_BEGIN_HEADER
FT_END_HEADER
-#endif /* __PCFUTIL_H__ */
+#endif /* PCFUTIL_H_ */
/* END */
diff --git a/src/3rdparty/freetype/src/pfr/Jamfile b/src/3rdparty/freetype/src/pfr/Jamfile
index c5b35be870..cb55a7ee89 100644
--- a/src/3rdparty/freetype/src/pfr/Jamfile
+++ b/src/3rdparty/freetype/src/pfr/Jamfile
@@ -1,6 +1,6 @@
# FreeType 2 src/pfr Jamfile
#
-# Copyright 2002-2015 by
+# Copyright 2002-2018 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/src/3rdparty/freetype/src/pfr/module.mk b/src/3rdparty/freetype/src/pfr/module.mk
index 3f5a47e888..27fec8e5f6 100644
--- a/src/3rdparty/freetype/src/pfr/module.mk
+++ b/src/3rdparty/freetype/src/pfr/module.mk
@@ -3,7 +3,7 @@
#
-# Copyright 2002-2015 by
+# Copyright 2002-2018 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/src/3rdparty/freetype/src/pfr/pfr.c b/src/3rdparty/freetype/src/pfr/pfr.c
index 96e67300a5..1760882fcd 100644
--- a/src/3rdparty/freetype/src/pfr/pfr.c
+++ b/src/3rdparty/freetype/src/pfr/pfr.c
@@ -4,7 +4,7 @@
/* */
/* FreeType PFR driver component. */
/* */
-/* Copyright 2002-2015 by */
+/* Copyright 2002-2018 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/src/3rdparty/freetype/src/pfr/pfrcmap.c b/src/3rdparty/freetype/src/pfr/pfrcmap.c
index 88ff55a806..60643780a1 100644
--- a/src/3rdparty/freetype/src/pfr/pfrcmap.c
+++ b/src/3rdparty/freetype/src/pfr/pfrcmap.c
@@ -4,7 +4,7 @@
/* */
/* FreeType PFR cmap handling (body). */
/* */
-/* Copyright 2002-2015 by */
+/* Copyright 2002-2018 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 ( gchar->char_code < char_code )
- min = mid+1;
+ min = mid + 1;
else
max = mid;
}
@@ -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/src/3rdparty/freetype/src/pfr/pfrcmap.h b/src/3rdparty/freetype/src/pfr/pfrcmap.h
index 87e1e5b942..c70a0c83c5 100644
--- a/src/3rdparty/freetype/src/pfr/pfrcmap.h
+++ b/src/3rdparty/freetype/src/pfr/pfrcmap.h
@@ -4,7 +4,7 @@
/* */
/* FreeType PFR cmap handling (specification). */
/* */
-/* Copyright 2002-2015 by */
+/* Copyright 2002-2018 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -16,8 +16,8 @@
/***************************************************************************/
-#ifndef __PFRCMAP_H__
-#define __PFRCMAP_H__
+#ifndef PFRCMAP_H_
+#define PFRCMAP_H_
#include <ft2build.h>
#include FT_INTERNAL_OBJECTS_H
@@ -40,7 +40,7 @@ FT_BEGIN_HEADER
FT_END_HEADER
-#endif /* __PFRCMAP_H__ */
+#endif /* PFRCMAP_H_ */
/* END */
diff --git a/src/3rdparty/freetype/src/pfr/pfrdrivr.c b/src/3rdparty/freetype/src/pfr/pfrdrivr.c
index 875374889c..6c7e50128a 100644
--- a/src/3rdparty/freetype/src/pfr/pfrdrivr.c
+++ b/src/3rdparty/freetype/src/pfr/pfrdrivr.c
@@ -4,7 +4,7 @@
/* */
/* FreeType PFR driver interface (body). */
/* */
-/* Copyright 2002-2015 by */
+/* Copyright 2002-2018 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -139,9 +139,9 @@
static
const FT_Service_PfrMetricsRec pfr_metrics_service_rec =
{
- pfr_get_metrics,
- pfr_face_get_kerning,
- pfr_get_advance
+ pfr_get_metrics, /* get_metrics */
+ pfr_face_get_kerning, /* get_kerning */
+ pfr_get_advance /* get_advance */
};
@@ -181,31 +181,32 @@
0x10000L,
0x20000L,
- NULL,
+ NULL, /* module-specific interface */
- 0, /* FT_Module_Constructor */
- 0, /* FT_Module_Destructor */
- pfr_get_service
+ NULL, /* FT_Module_Constructor module_init */
+ NULL, /* FT_Module_Destructor module_done */
+ pfr_get_service /* FT_Module_Requester get_interface */
},
sizeof ( PFR_FaceRec ),
sizeof ( PFR_SizeRec ),
sizeof ( PFR_SlotRec ),
- pfr_face_init,
- pfr_face_done,
- 0, /* FT_Size_InitFunc */
- 0, /* FT_Size_DoneFunc */
- pfr_slot_init,
- pfr_slot_done,
+ pfr_face_init, /* FT_Face_InitFunc init_face */
+ pfr_face_done, /* FT_Face_DoneFunc done_face */
+ 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,
+ pfr_slot_load, /* FT_Slot_LoadFunc load_glyph */
- pfr_get_kerning,
- 0, /* FT_Face_AttachFunc */
- 0, /* FT_Face_GetAdvancesFunc */
- 0, /* FT_Size_RequestFunc */
- 0, /* FT_Size_SelectFunc */
+ pfr_get_kerning, /* FT_Face_GetKerningFunc get_kerning */
+ NULL, /* FT_Face_AttachFunc attach_file */
+ NULL, /* FT_Face_GetAdvancesFunc get_advances */
+
+ NULL, /* FT_Size_RequestFunc request_size */
+ NULL, /* FT_Size_SelectFunc select_size */
};
diff --git a/src/3rdparty/freetype/src/pfr/pfrdrivr.h b/src/3rdparty/freetype/src/pfr/pfrdrivr.h
index b5be4709c8..cab852789b 100644
--- a/src/3rdparty/freetype/src/pfr/pfrdrivr.h
+++ b/src/3rdparty/freetype/src/pfr/pfrdrivr.h
@@ -4,7 +4,7 @@
/* */
/* High-level Type PFR driver interface (specification). */
/* */
-/* Copyright 2002-2015 by */
+/* Copyright 2002-2018 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -16,8 +16,8 @@
/***************************************************************************/
-#ifndef __PFRDRIVR_H__
-#define __PFRDRIVR_H__
+#ifndef PFRDRIVR_H_
+#define PFRDRIVR_H_
#include <ft2build.h>
@@ -37,7 +37,7 @@ FT_BEGIN_HEADER
FT_END_HEADER
-#endif /* __PFRDRIVR_H__ */
+#endif /* PFRDRIVR_H_ */
/* END */
diff --git a/src/3rdparty/freetype/src/pfr/pfrerror.h b/src/3rdparty/freetype/src/pfr/pfrerror.h
index 978e7b2d34..7027c818e8 100644
--- a/src/3rdparty/freetype/src/pfr/pfrerror.h
+++ b/src/3rdparty/freetype/src/pfr/pfrerror.h
@@ -4,7 +4,7 @@
/* */
/* PFR error codes (specification only). */
/* */
-/* Copyright 2002-2015 by */
+/* Copyright 2002-2018 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -22,12 +22,12 @@
/* */
/*************************************************************************/
-#ifndef __PFRERROR_H__
-#define __PFRERROR_H__
+#ifndef PFRERROR_H_
+#define PFRERROR_H_
#include FT_MODULE_ERRORS_H
-#undef __FTERRORS_H__
+#undef FTERRORS_H_
#undef FT_ERR_PREFIX
#define FT_ERR_PREFIX PFR_Err_
@@ -35,7 +35,7 @@
#include FT_ERRORS_H
-#endif /* __PFRERROR_H__ */
+#endif /* PFRERROR_H_ */
/* END */
diff --git a/src/3rdparty/freetype/src/pfr/pfrgload.c b/src/3rdparty/freetype/src/pfr/pfrgload.c
index 88df06a03d..b7990196b6 100644
--- a/src/3rdparty/freetype/src/pfr/pfrgload.c
+++ b/src/3rdparty/freetype/src/pfr/pfrgload.c
@@ -4,7 +4,7 @@
/* */
/* FreeType PFR glyph loader (body). */
/* */
-/* Copyright 2002-2015 by */
+/* Copyright 2002-2018 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 @@
if ( outline->n_contours > 0 )
first = outline->contours[outline->n_contours - 1];
- /* if the last point falls on the same location than the first one */
- /* we need to delete it */
+ /* if the last point falls on the same location as the first one */
+ /* we need to delete it */
if ( last > first )
{
FT_Vector* p1 = outline->points + first;
@@ -215,8 +215,10 @@
/* check that there is space for a new contour and a new point */
error = FT_GLYPHLOADER_CHECK_POINTS( loader, 1, 1 );
if ( !error )
+ {
/* add new start point */
error = pfr_glyph_line_to( glyph, to );
+ }
return error;
}
@@ -304,8 +306,8 @@
glyph->y_control = glyph->x_control + x_count;
- mask = 0;
- x = 0;
+ mask = 0;
+ x = 0;
for ( i = 0; i < count; i++ )
{
@@ -331,10 +333,10 @@
mask >>= 1;
}
- /* XXX: for now we ignore the secondary stroke and edge definitions */
- /* since we don't want to support native PFR hinting */
- /* */
- if ( flags & PFR_GLYPH_EXTRA_ITEMS )
+ /* XXX: we ignore the secondary stroke and edge definitions */
+ /* since we don't support native PFR hinting */
+ /* */
+ if ( flags & PFR_GLYPH_SINGLE_EXTRA_ITEMS )
{
error = pfr_extra_items_skip( &p, limit );
if ( error )
@@ -366,27 +368,27 @@
switch ( format >> 4 )
{
- case 0: /* end glyph */
+ case 0: /* end glyph */
FT_TRACE6(( "- end glyph" ));
args_count = 0;
break;
- case 1: /* general line operation */
+ case 1: /* general line operation */
FT_TRACE6(( "- general line" ));
goto Line1;
- case 4: /* move to inside contour */
+ case 4: /* move to inside contour */
FT_TRACE6(( "- move to inside" ));
goto Line1;
- case 5: /* move to outside contour */
+ case 5: /* move to outside contour */
FT_TRACE6(( "- move to outside" ));
Line1:
args_format = format_low;
args_count = 1;
break;
- case 2: /* horizontal line to */
+ case 2: /* horizontal line to */
FT_TRACE6(( "- horizontal line to cx.%d", format_low ));
if ( format_low >= x_count )
goto Failure;
@@ -396,7 +398,7 @@
args_count = 0;
break;
- case 3: /* vertical line to */
+ case 3: /* vertical line to */
FT_TRACE6(( "- vertical line to cy.%d", format_low ));
if ( format_low >= y_count )
goto Failure;
@@ -406,19 +408,19 @@
args_count = 0;
break;
- case 6: /* horizontal to vertical curve */
+ case 6: /* horizontal to vertical curve */
FT_TRACE6(( "- hv curve " ));
args_format = 0xB8E;
args_count = 3;
break;
- case 7: /* vertical to horizontal curve */
+ case 7: /* vertical to horizontal curve */
FT_TRACE6(( "- vh curve" ));
args_format = 0xE2B;
args_count = 3;
break;
- default: /* general curve to */
+ default: /* general curve to */
FT_TRACE6(( "- general curve" ));
args_count = 4;
args_format = format_low;
@@ -439,14 +441,14 @@
{
case 0: /* 8-bit index */
PFR_CHECK( 1 );
- idx = PFR_NEXT_BYTE( p );
+ idx = PFR_NEXT_BYTE( p );
if ( idx >= x_count )
goto Failure;
cur->x = glyph->x_control[idx];
FT_TRACE7(( " cx#%d", idx ));
break;
- case 1: /* 16-bit value */
+ case 1: /* 16-bit absolute value */
PFR_CHECK( 2 );
cur->x = PFR_NEXT_SHORT( p );
FT_TRACE7(( " x.%d", cur->x ));
@@ -516,22 +518,22 @@
/* */
switch ( format >> 4 )
{
- case 0: /* end glyph => EXIT */
+ case 0: /* end glyph => EXIT */
pfr_glyph_end( glyph );
goto Exit;
- case 1: /* line operations */
+ case 1: /* line operations */
case 2:
case 3:
error = pfr_glyph_line_to( glyph, pos );
goto Test_Error;
- case 4: /* move to inside contour */
- case 5: /* move to outside contour */
+ case 4: /* move to inside contour */
+ case 5: /* move to outside contour */
error = pfr_glyph_move_to( glyph, pos );
goto Test_Error;
- default: /* curve operations */
+ default: /* curve operations */
error = pfr_glyph_curve_to( glyph, pos, pos + 1, pos + 2 );
Test_Error: /* test error condition */
@@ -577,10 +579,11 @@
/* ignore extra items when present */
/* */
- if ( flags & PFR_GLYPH_EXTRA_ITEMS )
+ if ( flags & PFR_GLYPH_COMPOUND_EXTRA_ITEMS )
{
error = pfr_extra_items_skip( &p, limit );
- if (error) goto Exit;
+ if ( error )
+ goto Exit;
}
/* we can't rely on the FT_GlyphLoader to load sub-glyphs, because */
@@ -753,8 +756,10 @@
count = glyph->num_subs - old_count;
- FT_TRACE4(( "compound glyph with %d elements (offset %lu):\n",
- count, offset ));
+ FT_TRACE4(( "compound glyph with %d element%s (offset %lu):\n",
+ count,
+ count == 1 ? "" : "s",
+ offset ));
/* now, load each individual glyph */
for ( n = 0; n < count; n++ )
@@ -807,7 +812,9 @@
/* proceed to next sub-glyph */
}
- FT_TRACE4(( "end compound glyph with %d elements\n", count ));
+ FT_TRACE4(( "end compound glyph with %d element%s\n",
+ count,
+ count == 1 ? "" : "s" ));
}
else
{
diff --git a/src/3rdparty/freetype/src/pfr/pfrgload.h b/src/3rdparty/freetype/src/pfr/pfrgload.h
index c7c8da15a1..01f48d7706 100644
--- a/src/3rdparty/freetype/src/pfr/pfrgload.h
+++ b/src/3rdparty/freetype/src/pfr/pfrgload.h
@@ -4,7 +4,7 @@
/* */
/* FreeType PFR glyph loader (specification). */
/* */
-/* Copyright 2002-2015 by */
+/* Copyright 2002-2018 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -16,8 +16,8 @@
/***************************************************************************/
-#ifndef __PFRGLOAD_H__
-#define __PFRGLOAD_H__
+#ifndef PFRGLOAD_H_
+#define PFRGLOAD_H_
#include "pfrtypes.h"
@@ -43,7 +43,7 @@ FT_BEGIN_HEADER
FT_END_HEADER
-#endif /* __PFRGLOAD_H__ */
+#endif /* PFRGLOAD_H_ */
/* END */
diff --git a/src/3rdparty/freetype/src/pfr/pfrload.c b/src/3rdparty/freetype/src/pfr/pfrload.c
index ec7311df56..2776da462a 100644
--- a/src/3rdparty/freetype/src/pfr/pfrload.c
+++ b/src/3rdparty/freetype/src/pfr/pfrload.c
@@ -4,7 +4,7 @@
/* */
/* FreeType PFR loader (body). */
/* */
-/* Copyright 2002-2015 by */
+/* Copyright 2002-2018 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -26,6 +26,93 @@
#define FT_COMPONENT trace_pfr
+ /*
+ * The overall structure of a PFR file is as follows.
+ *
+ * PFR header
+ * 58 bytes (contains nPhysFonts)
+ *
+ * Logical font directory (size at most 2^16 bytes)
+ * 2 bytes (nLogFonts)
+ * + nLogFonts * 5 bytes
+ *
+ * ==> nLogFonts <= 13106
+ *
+ * Logical font section (size at most 2^24 bytes)
+ * nLogFonts * logFontRecord
+ *
+ * logFontRecord (size at most 2^16 bytes)
+ * 12 bytes (fontMatrix)
+ * + 1 byte (flags)
+ * + 0-5 bytes (depending on `flags')
+ * + 0-(1+255*(2+255)) = 0-65536 (depending on `flags')
+ * + 5 bytes (physical font info)
+ * + 0-1 bytes (depending on PFR header)
+ *
+ * ==> minimum size 18 bytes
+ *
+ * Physical font section (size at most 2^24 bytes)
+ * nPhysFonts * (physFontRecord
+ * + nBitmapSizes * nBmapChars * bmapCharRecord)
+ *
+ * physFontRecord (size at most 2^24 bytes)
+ * 14 bytes (font info)
+ * + 1 byte (flags)
+ * + 0-2 (depending on `flags')
+ * + 0-? (structure too complicated to be shown here; depending on
+ * `flags'; contains `nBitmapSizes' and `nBmapChars')
+ * + 3 bytes (nAuxBytes)
+ * + nAuxBytes
+ * + 1 byte (nBlueValues)
+ * + 2 * nBlueValues
+ * + 6 bytes (hinting data)
+ * + 2 bytes (nCharacters)
+ * + nCharacters * (4-10 bytes) (depending on `flags')
+ *
+ * ==> minimum size 27 bytes
+ *
+ * bmapCharRecord
+ * 4-7 bytes
+ *
+ * Glyph program strings (three possible types: simpleGps, compoundGps,
+ * and bitmapGps; size at most 2^24 bytes)
+ * simpleGps (size at most 2^16 bytes)
+ * 1 byte (flags)
+ * 1-2 bytes (n[XY]orus, depending on `flags')
+ * 0-(64+512*2) = 0-1088 bytes (depending on `n[XY]orus')
+ * 0-? (structure too complicated to be shown here; depending on
+ * `flags')
+ * 1-? glyph data (faintly resembling PS Type 1 charstrings)
+ *
+ * ==> minimum size 3 bytes
+ *
+ * compoundGps (size at most 2^16 bytes)
+ * 1 byte (nElements <= 63, flags)
+ * + 0-(1+255*(2+255)) = 0-65536 (depending on `flags')
+ * + nElements * (6-14 bytes)
+ *
+ * bitmapGps (size at most 2^16 bytes)
+ * 1 byte (flags)
+ * 3-13 bytes (position info, depending on `flags')
+ * 0-? bitmap data
+ *
+ * ==> minimum size 4 bytes
+ *
+ * PFR trailer
+ * 8 bytes
+ *
+ *
+ * ==> minimum size of a valid PFR:
+ * 58 (header)
+ * + 2 (nLogFonts)
+ * + 27 (1 physFontRecord)
+ * + 8 (trailer)
+ * -----
+ * 95 bytes
+ *
+ */
+
+
/*************************************************************************/
/*************************************************************************/
/***** *****/
@@ -75,7 +162,8 @@
if ( extra->type == item_type )
{
error = extra->parser( p, p + item_size, item_data );
- if ( error ) goto Exit;
+ if ( error )
+ goto Exit;
break;
}
@@ -183,7 +271,8 @@
{
result = 0;
}
- return result;
+
+ return result;
}
@@ -206,8 +295,25 @@
FT_UInt result = 0;
- if ( FT_STREAM_SEEK( section_offset ) || FT_READ_USHORT( count ) )
+ if ( FT_STREAM_SEEK( section_offset ) ||
+ FT_READ_USHORT( count ) )
+ goto Exit;
+
+ /* check maximum value and a rough minimum size: */
+ /* - no more than 13106 log fonts */
+ /* - we need 5 bytes for a log header record */
+ /* - we need at least 18 bytes for a log font record */
+ /* - the overall size is at least 95 bytes plus the */
+ /* log header and log font records */
+ if ( count > ( ( 1 << 16 ) - 2 ) / 5 ||
+ 2 + count * 5 >= stream->size - section_offset ||
+ 95 + count * ( 5 + 18 ) >= stream->size )
+ {
+ FT_ERROR(( "pfr_log_font_count:"
+ " invalid number of logical fonts\n" ));
+ error = FT_THROW( Invalid_Table );
goto Exit;
+ }
result = count;
@@ -254,13 +360,14 @@
FT_UInt local;
- if ( FT_STREAM_SEEK( offset ) || FT_FRAME_ENTER( size ) )
+ if ( FT_STREAM_SEEK( offset ) ||
+ FT_FRAME_ENTER( size ) )
goto Exit;
p = stream->cursor;
limit = p + size;
- PFR_CHECK(13);
+ PFR_CHECK( 13 );
log_font->matrix[0] = PFR_NEXT_LONG( p );
log_font->matrix[1] = PFR_NEXT_LONG( p );
@@ -276,7 +383,7 @@
if ( flags & PFR_LOG_2BYTE_STROKE )
local++;
- if ( (flags & PFR_LINE_JOIN_MASK) == PFR_LINE_JOIN_MITER )
+ if ( ( flags & PFR_LINE_JOIN_MASK ) == PFR_LINE_JOIN_MITER )
local += 3;
}
if ( flags & PFR_LOG_BOLD )
@@ -308,10 +415,11 @@
if ( flags & PFR_LOG_EXTRA_ITEMS )
{
error = pfr_extra_items_skip( &p, limit );
- if (error) goto Fail;
+ if ( error )
+ goto Fail;
}
- PFR_CHECK(5);
+ PFR_CHECK( 5 );
log_font->phys_size = PFR_NEXT_USHORT( p );
log_font->phys_offset = PFR_NEXT_ULONG( p );
if ( size_increment )
@@ -358,7 +466,7 @@
PFR_CHECK( 5 );
- p += 3; /* skip bctSize */
+ p += 3; /* skip bctSize */
flags0 = PFR_NEXT_BYTE( p );
count = PFR_NEXT_BYTE( p );
@@ -434,12 +542,12 @@
}
- /* Load font ID. This is a so-called "unique" name that is rather
- * long and descriptive (like "Tiresias ScreenFont v7.51").
+ /* Load font ID. This is a so-called `unique' name that is rather
+ * long and descriptive (like `Tiresias ScreenFont v7.51').
*
* Note that a PFR font's family name is contained in an *undocumented*
- * string of the "auxiliary data" portion of a physical font record. This
- * may also contain the "real" style name!
+ * string of the `auxiliary data' portion of a physical font record. This
+ * may also contain the `real' style name!
*
* If no family name is present, the font ID is used instead for the
* family.
@@ -454,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 ) )
@@ -481,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 );
@@ -507,7 +615,7 @@
Too_Short:
error = FT_THROW( Invalid_Table );
- FT_ERROR(( "pfr_exta_item_load_stem_snaps:"
+ FT_ERROR(( "pfr_extra_item_load_stem_snaps:"
" invalid stem snaps table\n" ));
goto Exit;
}
@@ -525,8 +633,6 @@
FT_Memory memory = phy_font->memory;
- FT_TRACE2(( "pfr_extra_item_load_kerning_pairs()\n" ));
-
if ( FT_NEW( item ) )
goto Exit;
@@ -612,7 +718,6 @@
}
-
static const PFR_ExtraItemRec pfr_phy_font_extra_items[] =
{
{ 1, (PFR_ExtraItem_ParseFunc)pfr_extra_item_load_bitmap_info },
@@ -623,7 +728,8 @@
};
- /* Loads a name from the auxiliary data. Since this extracts undocumented
+ /*
+ * Load a name from the auxiliary data. Since this extracts undocumented
* strings from the font file, we need to be careful here.
*/
static FT_Error
@@ -637,12 +743,14 @@
FT_UInt n, ok;
+ if ( *astring )
+ FT_FREE( *astring );
+
if ( len > 0 && p[len - 1] == 0 )
len--;
- /* check that each character is ASCII for making sure not to
- load garbage
- */
+ /* check that each character is ASCII */
+ /* for making sure not to load garbage */
ok = ( len > 0 );
for ( n = 0; n < len; n++ )
if ( p[n] < 32 || p[n] > 127 )
@@ -659,6 +767,7 @@
FT_MEM_COPY( result, p, len );
result[len] = 0;
}
+
Exit:
*astring = result;
return error;
@@ -729,7 +838,8 @@
phy_font->kern_items = NULL;
phy_font->kern_items_tail = &phy_font->kern_items;
- if ( FT_STREAM_SEEK( offset ) || FT_FRAME_ENTER( size ) )
+ if ( FT_STREAM_SEEK( offset ) ||
+ FT_FRAME_ENTER( size ) )
goto Exit;
phy_font->cursor = stream->cursor;
@@ -757,16 +867,16 @@
/* load the extra items when present */
if ( flags & PFR_PHY_EXTRA_ITEMS )
{
- error = pfr_extra_items_parse( &p, limit,
- pfr_phy_font_extra_items, phy_font );
+ error = pfr_extra_items_parse( &p, limit,
+ pfr_phy_font_extra_items, phy_font );
if ( error )
goto Fail;
}
- /* In certain fonts, the auxiliary bytes contain interesting */
- /* information. These are not in the specification but can be */
- /* guessed by looking at the content of a few PFR0 fonts. */
+ /* In certain fonts, the auxiliary bytes contain interesting */
+ /* information. These are not in the specification but can be */
+ /* guessed by looking at the content of a few PFR0 fonts. */
PFR_CHECK( 3 );
num_aux = PFR_NEXT_ULONG( p );
@@ -776,7 +886,7 @@
FT_Byte* q2;
- PFR_CHECK( num_aux );
+ PFR_CHECK_SIZE( num_aux );
p += num_aux;
while ( num_aux > 0 )
@@ -797,9 +907,8 @@
switch ( type )
{
case 1:
- /* this seems to correspond to the font's family name,
- * padded to 16-bits with one zero when necessary
- */
+ /* this seems to correspond to the font's family name, padded to */
+ /* an even number of bytes with a zero byte appended if needed */
error = pfr_aux_name_load( q, length - 4U, memory,
&phy_font->family_name );
if ( error )
@@ -817,9 +926,8 @@
break;
case 3:
- /* this seems to correspond to the font's style name,
- * padded to 16-bits with one zero when necessary
- */
+ /* this seems to correspond to the font's style name, padded to */
+ /* an even number of bytes with a zero byte appended if needed */
error = pfr_aux_name_load( q, length - 4U, memory,
&phy_font->style_name );
if ( error )
@@ -867,9 +975,6 @@
phy_font->num_chars = count = PFR_NEXT_USHORT( p );
phy_font->chars_offset = offset + (FT_Offset)( p - stream->cursor );
- if ( FT_NEW_ARRAY( phy_font->chars, count ) )
- goto Fail;
-
Size = 1 + 1 + 2;
if ( flags & PFR_PHY_2BYTE_CHARCODE )
Size += 1;
@@ -886,7 +991,10 @@
if ( flags & PFR_PHY_3BYTE_GPS_OFFSET )
Size += 1;
- PFR_CHECK( count * Size );
+ PFR_CHECK_SIZE( count * Size );
+
+ if ( FT_NEW_ARRAY( phy_font->chars, count ) )
+ goto Fail;
for ( n = 0; n < count; n++ )
{
diff --git a/src/3rdparty/freetype/src/pfr/pfrload.h b/src/3rdparty/freetype/src/pfr/pfrload.h
index 0a512346b6..36e809a762 100644
--- a/src/3rdparty/freetype/src/pfr/pfrload.h
+++ b/src/3rdparty/freetype/src/pfr/pfrload.h
@@ -4,7 +4,7 @@
/* */
/* FreeType PFR loader (specification). */
/* */
-/* Copyright 2002-2015 by */
+/* Copyright 2002-2018 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -16,8 +16,8 @@
/***************************************************************************/
-#ifndef __PFRLOAD_H__
-#define __PFRLOAD_H__
+#ifndef PFRLOAD_H_
+#define PFRLOAD_H_
#include "pfrobjs.h"
#include FT_INTERNAL_STREAM_H
@@ -25,14 +25,19 @@
FT_BEGIN_HEADER
+ /* some size checks should be always done (mainly to prevent */
+ /* excessive allocation for malformed data), ... */
+#define PFR_CHECK_SIZE( x ) do \
+ { \
+ if ( p + (x) > limit ) \
+ goto Too_Short; \
+ } while ( 0 )
+
+ /* ... and some only if intensive checking is explicitly requested */
#ifdef PFR_CONFIG_NO_CHECKS
#define PFR_CHECK( x ) do { } while ( 0 )
#else
-#define PFR_CHECK( x ) do \
- { \
- if ( p + (x) > limit ) \
- goto Too_Short; \
- } while ( 0 )
+#define PFR_CHECK PFR_CHECK_SIZE
#endif
#define PFR_NEXT_BYTE( p ) FT_NEXT_BYTE( p )
@@ -112,7 +117,7 @@ FT_BEGIN_HEADER
FT_END_HEADER
-#endif /* __PFRLOAD_H__ */
+#endif /* PFRLOAD_H_ */
/* END */
diff --git a/src/3rdparty/freetype/src/pfr/pfrobjs.c b/src/3rdparty/freetype/src/pfr/pfrobjs.c
index b854b00ba8..737b97b5ff 100644
--- a/src/3rdparty/freetype/src/pfr/pfrobjs.c
+++ b/src/3rdparty/freetype/src/pfr/pfrobjs.c
@@ -4,7 +4,7 @@
/* */
/* FreeType PFR object methods (body). */
/* */
-/* Copyright 2002-2015 by */
+/* Copyright 2002-2018 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -118,9 +118,11 @@
/* load the face */
error = pfr_log_font_load(
- &face->log_font, stream, (FT_UInt)( face_index & 0xFFFF ),
- face->header.log_dir_offset,
- FT_BOOL( face->header.phy_font_max_size_high != 0 ) );
+ &face->log_font,
+ stream,
+ (FT_UInt)( face_index & 0xFFFF ),
+ face->header.log_dir_offset,
+ FT_BOOL( face->header.phy_font_max_size_high != 0 ) );
if ( error )
goto Exit;
@@ -141,8 +143,8 @@
pfrface->face_flags |= FT_FACE_FLAG_SCALABLE;
- /* if all characters point to the same gps_offset 0, we */
- /* assume that the font only contains bitmaps */
+ /* if gps_offset == 0 for all characters, we */
+ /* assume that the font only contains bitmaps */
{
FT_UInt nn;
@@ -164,7 +166,7 @@
}
}
- if ( (phy_font->flags & PFR_PHY_PROPORTIONAL) == 0 )
+ if ( ( phy_font->flags & PFR_PHY_PROPORTIONAL ) == 0 )
pfrface->face_flags |= FT_FACE_FLAG_FIXED_WIDTH;
if ( phy_font->flags & PFR_PHY_VERTICAL )
@@ -178,16 +180,16 @@
if ( phy_font->num_kern_pairs > 0 )
pfrface->face_flags |= FT_FACE_FLAG_KERNING;
- /* If no family name was found in the "undocumented" auxiliary
+ /* If no family name was found in the `undocumented' auxiliary
* data, use the font ID instead. This sucks but is better than
* 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,
- * probably meaning "Regular"
+ * probably meaning `Regular'
*/
pfrface->style_name = phy_font->style_name;
@@ -262,15 +264,9 @@
charmap.encoding = FT_ENCODING_UNICODE;
error = FT_CMap_New( &pfr_cmap_class_rec, NULL, &charmap, NULL );
-
-#if 0
- /* Select default charmap */
- if ( pfrface->num_charmaps )
- pfrface->charmap = pfrface->charmaps[0];
-#endif
}
- /* check whether we've loaded any kerning pairs */
+ /* check whether we have loaded any kerning pairs */
if ( phy_font->num_kern_pairs )
pfrface->face_flags |= FT_FACE_FLAG_KERNING;
}
@@ -340,8 +336,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;
}
@@ -402,7 +402,7 @@
pfrslot->linearHoriAdvance = metrics->horiAdvance;
pfrslot->linearVertAdvance = metrics->vertAdvance;
- /* make-up vertical metrics(?) */
+ /* make up vertical metrics(?) */
metrics->vertBearingX = 0;
metrics->vertBearingY = 0;
@@ -522,8 +522,8 @@
FT_UInt probe = power * size;
FT_UInt extra = count - power;
FT_Byte* base = stream->cursor;
- FT_Bool twobytes = FT_BOOL( item->flags & 1 );
- FT_Bool twobyte_adj = FT_BOOL( item->flags & 2 );
+ FT_Bool twobytes = FT_BOOL( item->flags & PFR_KERN_2BYTE_CHAR );
+ FT_Bool twobyte_adj = FT_BOOL( item->flags & PFR_KERN_2BYTE_ADJ );
FT_Byte* p;
FT_UInt32 cpair;
@@ -596,4 +596,5 @@
return error;
}
+
/* END */
diff --git a/src/3rdparty/freetype/src/pfr/pfrobjs.h b/src/3rdparty/freetype/src/pfr/pfrobjs.h
index e990b45a0a..59c709f58d 100644
--- a/src/3rdparty/freetype/src/pfr/pfrobjs.h
+++ b/src/3rdparty/freetype/src/pfr/pfrobjs.h
@@ -4,7 +4,7 @@
/* */
/* FreeType PFR object methods (specification). */
/* */
-/* Copyright 2002-2015 by */
+/* Copyright 2002-2018 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -16,8 +16,8 @@
/***************************************************************************/
-#ifndef __PFROBJS_H__
-#define __PFROBJS_H__
+#ifndef PFROBJS_H_
+#define PFROBJS_H_
#include "pfrtypes.h"
@@ -90,7 +90,7 @@ FT_BEGIN_HEADER
FT_END_HEADER
-#endif /* __PFROBJS_H__ */
+#endif /* PFROBJS_H_ */
/* END */
diff --git a/src/3rdparty/freetype/src/pfr/pfrsbit.c b/src/3rdparty/freetype/src/pfr/pfrsbit.c
index bb5df5c9f9..ba909ddca7 100644
--- a/src/3rdparty/freetype/src/pfr/pfrsbit.c
+++ b/src/3rdparty/freetype/src/pfr/pfrsbit.c
@@ -4,7 +4,7 @@
/* */
/* FreeType PFR bitmap loader (body). */
/* */
-/* Copyright 2002-2015 by */
+/* Copyright 2002-2018 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -37,11 +37,11 @@
typedef struct PFR_BitWriter_
{
- FT_Byte* line; /* current line start */
- FT_Int pitch; /* line size in bytes */
- FT_UInt width; /* width in pixels/bits */
- FT_UInt rows; /* number of remaining rows to scan */
- FT_UInt total; /* total number of bits to draw */
+ FT_Byte* line; /* current line start */
+ FT_Int pitch; /* line size in bytes */
+ FT_UInt width; /* width in pixels/bits */
+ FT_UInt rows; /* number of remaining rows to scan */
+ FT_UInt total; /* total number of bits to draw */
} PFR_BitWriterRec, *PFR_BitWriter;
@@ -277,49 +277,99 @@
pfr_lookup_bitmap_data( FT_Byte* base,
FT_Byte* limit,
FT_UInt count,
- FT_UInt flags,
+ FT_UInt* flags,
FT_UInt char_code,
FT_ULong* found_offset,
FT_ULong* found_size )
{
- FT_UInt left, right, char_len;
- FT_Bool two = FT_BOOL( flags & 1 );
+ FT_UInt min, max, char_len;
+ FT_Bool two = FT_BOOL( *flags & PFR_BITMAP_2BYTE_CHARCODE );
FT_Byte* buff;
char_len = 4;
- if ( two ) char_len += 1;
- if ( flags & 2 ) char_len += 1;
- if ( flags & 4 ) char_len += 1;
+ if ( two )
+ char_len += 1;
+ if ( *flags & PFR_BITMAP_2BYTE_SIZE )
+ char_len += 1;
+ if ( *flags & PFR_BITMAP_3BYTE_OFFSET )
+ char_len += 1;
+
+ if ( !( *flags & PFR_BITMAP_CHARCODES_VALIDATED ) )
+ {
+ FT_Byte* p;
+ FT_Byte* lim;
+ FT_UInt code;
+ FT_Long prev_code;
- left = 0;
- right = count;
- while ( left < right )
- {
- FT_UInt middle, code;
+ *flags |= PFR_BITMAP_VALID_CHARCODES;
+ prev_code = -1;
+ lim = base + count * char_len;
+ if ( lim > limit )
+ {
+ FT_TRACE0(( "pfr_lookup_bitmap_data:"
+ " number of bitmap records too large,\n"
+ " "
+ " thus ignoring all bitmaps in this strike\n" ));
+ *flags &= ~PFR_BITMAP_VALID_CHARCODES;
+ }
+ else
+ {
+ /* check whether records are sorted by code */
+ for ( p = base; p < lim; p += char_len )
+ {
+ if ( two )
+ code = FT_PEEK_USHORT( p );
+ else
+ code = *p;
- middle = ( left + right ) >> 1;
- buff = base + middle * char_len;
+ if ( (FT_Long)code <= prev_code )
+ {
+ FT_TRACE0(( "pfr_lookup_bitmap_data:"
+ " bitmap records are not sorted,\n"
+ " "
+ " thus ignoring all bitmaps in this strike\n" ));
+ *flags &= ~PFR_BITMAP_VALID_CHARCODES;
+ break;
+ }
- /* check that we are not outside of the table -- */
- /* this is possible with broken fonts... */
- if ( buff + char_len > limit )
- goto Fail;
+ prev_code = code;
+ }
+ }
+
+ *flags |= PFR_BITMAP_CHARCODES_VALIDATED;
+ }
+
+ /* ignore bitmaps in case table is not valid */
+ /* (this might be sanitized, but PFR is dead...) */
+ if ( !( *flags & PFR_BITMAP_VALID_CHARCODES ) )
+ goto Fail;
+
+ min = 0;
+ max = count;
+
+ /* binary search */
+ while ( min < max )
+ {
+ FT_UInt mid, code;
+
+
+ mid = ( min + max ) >> 1;
+ buff = base + mid * char_len;
if ( two )
code = PFR_NEXT_USHORT( buff );
else
code = PFR_NEXT_BYTE( buff );
- if ( code == char_code )
- goto Found_It;
-
- if ( code < char_code )
- left = middle;
+ if ( char_code < code )
+ max = mid;
+ else if ( char_code > code )
+ min = mid + 1;
else
- right = middle;
+ goto Found_It;
}
Fail:
@@ -329,20 +379,20 @@
return;
Found_It:
- if ( flags & 2 )
+ if ( *flags & PFR_BITMAP_2BYTE_SIZE )
*found_size = PFR_NEXT_USHORT( buff );
else
*found_size = PFR_NEXT_BYTE( buff );
- if ( flags & 4 )
+ if ( *flags & PFR_BITMAP_3BYTE_OFFSET )
*found_offset = PFR_NEXT_ULONG( buff );
else
*found_offset = PFR_NEXT_USHORT( buff );
}
- /* load bitmap metrics. "*padvance" must be set to the default value */
- /* before calling this function... */
+ /* load bitmap metrics. `*padvance' must be set to the default value */
+ /* before calling this function */
/* */
static FT_Error
pfr_load_bitmap_metrics( FT_Byte** pdata,
@@ -357,7 +407,6 @@
{
FT_Error error = FT_Err_Ok;
FT_Byte flags;
- FT_Char c;
FT_Byte b;
FT_Byte* p = *pdata;
FT_Long xpos, ypos, advance;
@@ -377,9 +426,9 @@
{
case 0:
PFR_CHECK( 1 );
- c = PFR_NEXT_INT8( p );
- xpos = c >> 4;
- ypos = ( (FT_Char)( c << 4 ) ) >> 4;
+ b = PFR_NEXT_BYTE( p );
+ xpos = (FT_Char)b >> 4;
+ ypos = ( (FT_Char)( b << 4 ) ) >> 4;
break;
case 1:
@@ -445,7 +494,7 @@
case 1:
PFR_CHECK( 1 );
- advance = PFR_NEXT_INT8( p ) << 8;
+ advance = PFR_NEXT_INT8( p ) * 256;
break;
case 2:
@@ -510,8 +559,7 @@
break;
default:
- FT_ERROR(( "pfr_read_bitmap_data: invalid image type\n" ));
- error = FT_THROW( Invalid_File_Format );
+ ;
}
}
@@ -530,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;
@@ -544,7 +593,7 @@
character = &phys->chars[glyph_index];
- /* Look-up a bitmap strike corresponding to the current */
+ /* look up a bitmap strike corresponding to the current */
/* character dimensions */
{
FT_UInt n;
@@ -555,9 +604,7 @@
{
if ( strike->x_ppm == (FT_UInt)size->root.metrics.x_ppem &&
strike->y_ppm == (FT_UInt)size->root.metrics.y_ppem )
- {
goto Found_Strike;
- }
strike++;
}
@@ -568,17 +615,20 @@
Found_Strike:
- /* Now lookup the glyph's position within the file */
+ /* now look up the glyph's position within the file */
{
FT_UInt char_len;
char_len = 4;
- if ( strike->flags & 1 ) char_len += 1;
- if ( strike->flags & 2 ) char_len += 1;
- if ( strike->flags & 4 ) char_len += 1;
-
- /* Access data directly in the frame to speed lookups */
+ if ( strike->flags & PFR_BITMAP_2BYTE_CHARCODE )
+ char_len += 1;
+ if ( strike->flags & PFR_BITMAP_2BYTE_SIZE )
+ char_len += 1;
+ if ( strike->flags & PFR_BITMAP_3BYTE_OFFSET )
+ char_len += 1;
+
+ /* access data directly in the frame to speed lookups */
if ( FT_STREAM_SEEK( phys->bct_offset + strike->bct_offset ) ||
FT_FRAME_ENTER( char_len * strike->num_bitmaps ) )
goto Exit;
@@ -586,7 +636,7 @@
pfr_lookup_bitmap_data( stream->cursor,
stream->limit,
strike->num_bitmaps,
- strike->flags,
+ &strike->flags,
character->char_code,
&gps_offset,
&gps_size );
@@ -595,7 +645,7 @@
if ( gps_size == 0 )
{
- /* Could not find a bitmap program string for this glyph */
+ /* could not find a bitmap program string for this glyph */
error = FT_THROW( Invalid_Argument );
goto Exit;
}
@@ -617,8 +667,8 @@
glyph->root.linearHoriAdvance = advance;
- /* compute default advance, i.e., scaled advance. This can be */
- /* overridden in the bitmap header of certain glyphs. */
+ /* compute default advance, i.e., scaled advance; this can be */
+ /* overridden in the bitmap header of certain glyphs */
advance = FT_MulDiv( (FT_Fixed)size->root.metrics.x_ppem << 8,
character->advance,
(FT_Long)phys->metrics_resolution );
@@ -633,6 +683,55 @@
&xpos, &ypos,
&xsize, &ysize,
&advance, &format );
+ if ( error )
+ goto Exit1;
+
+ /*
+ * Before allocating the target bitmap, we check whether the given
+ * bitmap dimensions are valid, depending on the image format.
+ *
+ * Format 0: We have a stream of pixels (with 8 pixels per byte).
+ *
+ * (xsize * ysize + 7) / 8 <= gps_size
+ *
+ * Format 1: Run-length encoding; the high nibble holds the number of
+ * white bits, the low nibble the number of black bits. In
+ * other words, a single byte can represent at most 15
+ * pixels.
+ *
+ * xsize * ysize <= 15 * gps_size
+ *
+ * Format 2: Run-length encoding; the high byte holds the number of
+ * white bits, the low byte the number of black bits. In
+ * other words, two bytes can represent at most 255 pixels.
+ *
+ * xsize * ysize <= 255 * (gps_size + 1) / 2
+ */
+ switch ( format )
+ {
+ case 0:
+ if ( ( (FT_ULong)xsize * ysize + 7 ) / 8 > gps_size )
+ error = FT_THROW( Invalid_Table );
+ break;
+ case 1:
+ if ( (FT_ULong)xsize * ysize > 15 * gps_size )
+ error = FT_THROW( Invalid_Table );
+ break;
+ case 2:
+ if ( (FT_ULong)xsize * ysize > 255 * ( ( gps_size + 1 ) / 2 ) )
+ error = FT_THROW( Invalid_Table );
+ break;
+ default:
+ FT_ERROR(( "pfr_slot_load_bitmap: invalid image type\n" ));
+ error = FT_THROW( Invalid_Table );
+ }
+
+ if ( error )
+ {
+ if ( FT_ERR_EQ( error, Invalid_Table ) )
+ FT_ERROR(( "pfr_slot_load_bitmap: invalid bitmap dimensions\n" ));
+ goto Exit1;
+ }
/*
* XXX: on 16bit systems we return an error for huge bitmaps
@@ -666,8 +765,8 @@
/* XXX: needs casts to fit FT_Glyph_Metrics.{width|height} */
glyph->root.metrics.width = (FT_Pos)xsize << 6;
glyph->root.metrics.height = (FT_Pos)ysize << 6;
- glyph->root.metrics.horiBearingX = xpos << 6;
- glyph->root.metrics.horiBearingY = ypos << 6;
+ glyph->root.metrics.horiBearingX = xpos * 64;
+ glyph->root.metrics.horiBearingY = ypos * 64;
glyph->root.metrics.horiAdvance = FT_PIX_ROUND( ( advance >> 2 ) );
glyph->root.metrics.vertBearingX = - glyph->root.metrics.width >> 1;
glyph->root.metrics.vertBearingY = 0;
@@ -677,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;
@@ -684,17 +786,17 @@
error = ft_glyphslot_alloc_bitmap( &glyph->root, len );
if ( !error )
- {
error = pfr_load_bitmap_bits(
p,
stream->limit,
format,
- FT_BOOL(face->header.color_flags & 2),
+ FT_BOOL( face->header.color_flags &
+ PFR_FLAG_INVERT_BITMAP ),
&glyph->root.bitmap );
- }
}
}
+ Exit1:
FT_FRAME_EXIT();
}
@@ -702,4 +804,5 @@
return error;
}
+
/* END */
diff --git a/src/3rdparty/freetype/src/pfr/pfrsbit.h b/src/3rdparty/freetype/src/pfr/pfrsbit.h
index 0db2cd5ebd..07b27bc06c 100644
--- a/src/3rdparty/freetype/src/pfr/pfrsbit.h
+++ b/src/3rdparty/freetype/src/pfr/pfrsbit.h
@@ -4,7 +4,7 @@
/* */
/* FreeType PFR bitmap loader (specification). */
/* */
-/* Copyright 2002-2015 by */
+/* Copyright 2002-2018 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -16,8 +16,8 @@
/***************************************************************************/
-#ifndef __PFRSBIT_H__
-#define __PFRSBIT_H__
+#ifndef PFRSBIT_H_
+#define PFRSBIT_H_
#include "pfrobjs.h"
@@ -26,11 +26,12 @@ 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
-#endif /* __PFR_SBIT_H__ */
+#endif /* PFRSBIT_H_ */
/* END */
diff --git a/src/3rdparty/freetype/src/pfr/pfrtypes.h b/src/3rdparty/freetype/src/pfr/pfrtypes.h
index 5ffb1b14ee..058d6aadc9 100644
--- a/src/3rdparty/freetype/src/pfr/pfrtypes.h
+++ b/src/3rdparty/freetype/src/pfr/pfrtypes.h
@@ -4,7 +4,7 @@
/* */
/* FreeType PFR data structures (specification only). */
/* */
-/* Copyright 2002-2015 by */
+/* Copyright 2002-2018 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -16,8 +16,8 @@
/***************************************************************************/
-#ifndef __PFRTYPES_H__
-#define __PFRTYPES_H__
+#ifndef PFRTYPES_H_
+#define PFRTYPES_H_
#include <ft2build.h>
#include FT_INTERNAL_OBJECTS_H
@@ -69,12 +69,8 @@ FT_BEGIN_HEADER
/* used in `color_flags' field of the PFR_Header */
- typedef enum PFR_HeaderFlags_
- {
- PFR_FLAG_BLACK_PIXEL = 1,
- PFR_FLAG_INVERT_BITMAP = 2
-
- } PFR_HeaderFlags;
+#define PFR_FLAG_BLACK_PIXEL 0x01U
+#define PFR_FLAG_INVERT_BITMAP 0x02U
/************************************************************************/
@@ -96,36 +92,27 @@ FT_BEGIN_HEADER
} PFR_LogFontRec, *PFR_LogFont;
- typedef enum PFR_LogFlags_
- {
- PFR_LOG_EXTRA_ITEMS = 0x40,
- PFR_LOG_2BYTE_BOLD = 0x20,
- PFR_LOG_BOLD = 0x10,
- PFR_LOG_2BYTE_STROKE = 8,
- PFR_LOG_STROKE = 4,
- PFR_LINE_JOIN_MASK = 3
+#define PFR_LINE_JOIN_MITER 0x00U
+#define PFR_LINE_JOIN_ROUND 0x01U
+#define PFR_LINE_JOIN_BEVEL 0x02U
+#define PFR_LINE_JOIN_MASK ( PFR_LINE_JOIN_ROUND | PFR_LINE_JOIN_BEVEL )
- } PFR_LogFlags;
-
-
- typedef enum PFR_LineJoinFlags_
- {
- PFR_LINE_JOIN_MITER = 0,
- PFR_LINE_JOIN_ROUND = 1,
- PFR_LINE_JOIN_BEVEL = 2
-
- } PFR_LineJoinFlags;
+#define PFR_LOG_STROKE 0x04U
+#define PFR_LOG_2BYTE_STROKE 0x08U
+#define PFR_LOG_BOLD 0x10U
+#define PFR_LOG_2BYTE_BOLD 0x20U
+#define PFR_LOG_EXTRA_ITEMS 0x40U
/************************************************************************/
- typedef enum PFR_BitmapFlags_
- {
- PFR_BITMAP_3BYTE_OFFSET = 4,
- PFR_BITMAP_2BYTE_SIZE = 2,
- PFR_BITMAP_2BYTE_CHARCODE = 1
+#define PFR_BITMAP_2BYTE_CHARCODE 0x01U
+#define PFR_BITMAP_2BYTE_SIZE 0x02U
+#define PFR_BITMAP_3BYTE_OFFSET 0x04U
- } PFR_BitmapFlags;
+ /*not part of the specification but used for implementation */
+#define PFR_BITMAP_CHARCODES_VALIDATED 0x40U
+#define PFR_BITMAP_VALID_CHARCODES 0x80U
typedef struct PFR_BitmapCharRec_
@@ -137,15 +124,11 @@ FT_BEGIN_HEADER
} PFR_BitmapCharRec, *PFR_BitmapChar;
- typedef enum PFR_StrikeFlags_
- {
- PFR_STRIKE_2BYTE_COUNT = 0x10,
- PFR_STRIKE_3BYTE_OFFSET = 0x08,
- PFR_STRIKE_3BYTE_SIZE = 0x04,
- PFR_STRIKE_2BYTE_YPPM = 0x02,
- PFR_STRIKE_2BYTE_XPPM = 0x01
-
- } PFR_StrikeFlags;
+#define PFR_STRIKE_2BYTE_XPPM 0x01U
+#define PFR_STRIKE_2BYTE_YPPM 0x02U
+#define PFR_STRIKE_3BYTE_SIZE 0x04U
+#define PFR_STRIKE_3BYTE_OFFSET 0x08U
+#define PFR_STRIKE_2BYTE_COUNT 0x10U
typedef struct PFR_StrikeRec_
@@ -266,38 +249,29 @@ FT_BEGIN_HEADER
} PFR_PhyFontRec, *PFR_PhyFont;
- typedef enum PFR_PhyFlags_
- {
- PFR_PHY_EXTRA_ITEMS = 0x80,
- PFR_PHY_3BYTE_GPS_OFFSET = 0x20,
- PFR_PHY_2BYTE_GPS_SIZE = 0x10,
- PFR_PHY_ASCII_CODE = 0x08,
- PFR_PHY_PROPORTIONAL = 0x04,
- PFR_PHY_2BYTE_CHARCODE = 0x02,
- PFR_PHY_VERTICAL = 0x01
-
- } PFR_PhyFlags;
+#define PFR_PHY_VERTICAL 0x01U
+#define PFR_PHY_2BYTE_CHARCODE 0x02U
+#define PFR_PHY_PROPORTIONAL 0x04U
+#define PFR_PHY_ASCII_CODE 0x08U
+#define PFR_PHY_2BYTE_GPS_SIZE 0x10U
+#define PFR_PHY_3BYTE_GPS_OFFSET 0x20U
+#define PFR_PHY_EXTRA_ITEMS 0x80U
- typedef enum PFR_KernFlags_
- {
- PFR_KERN_2BYTE_CHAR = 0x01,
- PFR_KERN_2BYTE_ADJ = 0x02
-
- } PFR_KernFlags;
+#define PFR_KERN_2BYTE_CHAR 0x01U
+#define PFR_KERN_2BYTE_ADJ 0x02U
/************************************************************************/
- typedef enum PFR_GlyphFlags_
- {
- PFR_GLYPH_IS_COMPOUND = 0x80,
- PFR_GLYPH_EXTRA_ITEMS = 0x08,
- PFR_GLYPH_1BYTE_XYCOUNT = 0x04,
- PFR_GLYPH_XCOUNT = 0x02,
- PFR_GLYPH_YCOUNT = 0x01
+#define PFR_GLYPH_YCOUNT 0x01U
+#define PFR_GLYPH_XCOUNT 0x02U
+#define PFR_GLYPH_1BYTE_XYCOUNT 0x04U
+
+#define PFR_GLYPH_SINGLE_EXTRA_ITEMS 0x08U
+#define PFR_GLYPH_COMPOUND_EXTRA_ITEMS 0x40U
- } PFR_GlyphFlags;
+#define PFR_GLYPH_IS_COMPOUND 0x80U
/* controlled coordinate */
@@ -321,14 +295,10 @@ FT_BEGIN_HEADER
} PFR_SubGlyphRec, *PFR_SubGlyph;
- typedef enum PFR_SubgGlyphFlags_
- {
- PFR_SUBGLYPH_3BYTE_OFFSET = 0x80,
- PFR_SUBGLYPH_2BYTE_SIZE = 0x40,
- PFR_SUBGLYPH_YSCALE = 0x20,
- PFR_SUBGLYPH_XSCALE = 0x10
-
- } PFR_SubGlyphFlags;
+#define PFR_SUBGLYPH_XSCALE 0x10U
+#define PFR_SUBGLYPH_YSCALE 0x20U
+#define PFR_SUBGLYPH_2BYTE_SIZE 0x40U
+#define PFR_SUBGLYPH_3BYTE_OFFSET 0x80U
typedef struct PFR_GlyphRec_
@@ -356,7 +326,7 @@ FT_BEGIN_HEADER
FT_END_HEADER
-#endif /* __PFRTYPES_H__ */
+#endif /* PFRTYPES_H_ */
/* END */
diff --git a/src/3rdparty/freetype/src/pfr/rules.mk b/src/3rdparty/freetype/src/pfr/rules.mk
index e665460103..3acb795696 100644
--- a/src/3rdparty/freetype/src/pfr/rules.mk
+++ b/src/3rdparty/freetype/src/pfr/rules.mk
@@ -3,7 +3,7 @@
#
-# Copyright 2002-2015 by
+# Copyright 2002-2018 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/src/3rdparty/freetype/src/psaux/Jamfile b/src/3rdparty/freetype/src/psaux/Jamfile
index 6793f0d581..a231d5974f 100644
--- a/src/3rdparty/freetype/src/psaux/Jamfile
+++ b/src/3rdparty/freetype/src/psaux/Jamfile
@@ -1,6 +1,6 @@
# FreeType 2 src/psaux Jamfile
#
-# Copyright 2001-2015 by
+# Copyright 2001-2018 by
# David Turner, Robert Wilhelm, and Werner Lemberg.
#
# This file is part of the FreeType project, and may only be used, modified,
@@ -22,6 +22,16 @@ SubDir FT2_TOP $(FT2_SRC_DIR) psaux ;
psobjs
t1cmap
t1decode
+ cffdecode
+ psarrst
+ psblues
+ pserror
+ psfont
+ psft
+ pshints
+ psintrp
+ psread
+ psstack
;
}
else
diff --git a/src/3rdparty/freetype/src/psaux/afmparse.c b/src/3rdparty/freetype/src/psaux/afmparse.c
index 3ad44ec724..0c33d5949b 100644
--- a/src/3rdparty/freetype/src/psaux/afmparse.c
+++ b/src/3rdparty/freetype/src/psaux/afmparse.c
@@ -4,7 +4,7 @@
/* */
/* AFM parser (body). */
/* */
-/* Copyright 2006-2015 by */
+/* Copyright 2006-2018 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/src/3rdparty/freetype/src/psaux/afmparse.h b/src/3rdparty/freetype/src/psaux/afmparse.h
index f922c4ebde..86f852a247 100644
--- a/src/3rdparty/freetype/src/psaux/afmparse.h
+++ b/src/3rdparty/freetype/src/psaux/afmparse.h
@@ -4,7 +4,7 @@
/* */
/* AFM parser (specification). */
/* */
-/* Copyright 2006-2015 by */
+/* Copyright 2006-2018 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -16,8 +16,8 @@
/***************************************************************************/
-#ifndef __AFMPARSE_H__
-#define __AFMPARSE_H__
+#ifndef AFMPARSE_H_
+#define AFMPARSE_H_
#include <ft2build.h>
@@ -83,7 +83,7 @@ FT_BEGIN_HEADER
FT_END_HEADER
-#endif /* __AFMPARSE_H__ */
+#endif /* AFMPARSE_H_ */
/* END */
diff --git a/src/3rdparty/freetype/src/psaux/cffdecode.c b/src/3rdparty/freetype/src/psaux/cffdecode.c
new file mode 100644
index 0000000000..80d622c0e1
--- /dev/null
+++ b/src/3rdparty/freetype/src/psaux/cffdecode.c
@@ -0,0 +1,2370 @@
+/***************************************************************************/
+/* */
+/* cffdecode.c */
+/* */
+/* PostScript CFF (Type 2) decoding routines (body). */
+/* */
+/* Copyright 2017-2018 by */
+/* David Turner, Robert Wilhelm, and Werner Lemberg. */
+/* */
+/* This file is part of the FreeType project, and may only be used, */
+/* modified, and distributed under the terms of the FreeType project */
+/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
+/* this file you indicate that you have read the license and */
+/* understand and accept it fully. */
+/* */
+/***************************************************************************/
+
+
+#include <ft2build.h>
+#include FT_FREETYPE_H
+#include FT_INTERNAL_DEBUG_H
+#include FT_INTERNAL_SERVICE_H
+#include FT_SERVICE_CFF_TABLE_LOAD_H
+
+#include "cffdecode.h"
+#include "psobjs.h"
+
+#include "psauxerr.h"
+
+
+ /*************************************************************************/
+ /* */
+ /* The macro FT_COMPONENT is used in trace mode. It is an implicit */
+ /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */
+ /* messages during execution. */
+ /* */
+#undef FT_COMPONENT
+#define FT_COMPONENT trace_cffdecode
+
+
+#ifdef CFF_CONFIG_OPTION_OLD_ENGINE
+
+ typedef enum CFF_Operator_
+ {
+ cff_op_unknown = 0,
+
+ cff_op_rmoveto,
+ cff_op_hmoveto,
+ cff_op_vmoveto,
+
+ cff_op_rlineto,
+ cff_op_hlineto,
+ cff_op_vlineto,
+
+ cff_op_rrcurveto,
+ cff_op_hhcurveto,
+ cff_op_hvcurveto,
+ cff_op_rcurveline,
+ cff_op_rlinecurve,
+ cff_op_vhcurveto,
+ cff_op_vvcurveto,
+
+ cff_op_flex,
+ cff_op_hflex,
+ cff_op_hflex1,
+ cff_op_flex1,
+
+ cff_op_endchar,
+
+ cff_op_hstem,
+ cff_op_vstem,
+ cff_op_hstemhm,
+ cff_op_vstemhm,
+
+ cff_op_hintmask,
+ cff_op_cntrmask,
+ cff_op_dotsection, /* deprecated, acts as no-op */
+
+ cff_op_abs,
+ cff_op_add,
+ cff_op_sub,
+ cff_op_div,
+ cff_op_neg,
+ cff_op_random,
+ cff_op_mul,
+ cff_op_sqrt,
+
+ cff_op_blend,
+
+ cff_op_drop,
+ cff_op_exch,
+ cff_op_index,
+ cff_op_roll,
+ cff_op_dup,
+
+ cff_op_put,
+ cff_op_get,
+ cff_op_store,
+ cff_op_load,
+
+ cff_op_and,
+ cff_op_or,
+ cff_op_not,
+ cff_op_eq,
+ cff_op_ifelse,
+
+ cff_op_callsubr,
+ cff_op_callgsubr,
+ cff_op_return,
+
+ /* Type 1 opcodes: invalid but seen in real life */
+ cff_op_hsbw,
+ cff_op_closepath,
+ cff_op_callothersubr,
+ cff_op_pop,
+ cff_op_seac,
+ cff_op_sbw,
+ cff_op_setcurrentpoint,
+
+ /* do not remove */
+ cff_op_max
+
+ } CFF_Operator;
+
+
+#define CFF_COUNT_CHECK_WIDTH 0x80
+#define CFF_COUNT_EXACT 0x40
+#define CFF_COUNT_CLEAR_STACK 0x20
+
+ /* count values which have the `CFF_COUNT_CHECK_WIDTH' flag set are */
+ /* used for checking the width and requested numbers of arguments */
+ /* only; they are set to zero afterwards */
+
+ /* the other two flags are informative only and unused currently */
+
+ static const FT_Byte cff_argument_counts[] =
+ {
+ 0, /* unknown */
+
+ 2 | CFF_COUNT_CHECK_WIDTH | CFF_COUNT_EXACT, /* rmoveto */
+ 1 | CFF_COUNT_CHECK_WIDTH | CFF_COUNT_EXACT,
+ 1 | CFF_COUNT_CHECK_WIDTH | CFF_COUNT_EXACT,
+
+ 0 | CFF_COUNT_CLEAR_STACK, /* rlineto */
+ 0 | CFF_COUNT_CLEAR_STACK,
+ 0 | CFF_COUNT_CLEAR_STACK,
+
+ 0 | CFF_COUNT_CLEAR_STACK, /* rrcurveto */
+ 0 | CFF_COUNT_CLEAR_STACK,
+ 0 | CFF_COUNT_CLEAR_STACK,
+ 0 | CFF_COUNT_CLEAR_STACK,
+ 0 | CFF_COUNT_CLEAR_STACK,
+ 0 | CFF_COUNT_CLEAR_STACK,
+ 0 | CFF_COUNT_CLEAR_STACK,
+
+ 13, /* flex */
+ 7,
+ 9,
+ 11,
+
+ 0 | CFF_COUNT_CHECK_WIDTH, /* endchar */
+
+ 2 | CFF_COUNT_CHECK_WIDTH, /* hstem */
+ 2 | CFF_COUNT_CHECK_WIDTH,
+ 2 | CFF_COUNT_CHECK_WIDTH,
+ 2 | CFF_COUNT_CHECK_WIDTH,
+
+ 0 | CFF_COUNT_CHECK_WIDTH, /* hintmask */
+ 0 | CFF_COUNT_CHECK_WIDTH, /* cntrmask */
+ 0, /* dotsection */
+
+ 1, /* abs */
+ 2,
+ 2,
+ 2,
+ 1,
+ 0,
+ 2,
+ 1,
+
+ 1, /* blend */
+
+ 1, /* drop */
+ 2,
+ 1,
+ 2,
+ 1,
+
+ 2, /* put */
+ 1,
+ 4,
+ 3,
+
+ 2, /* and */
+ 2,
+ 1,
+ 2,
+ 4,
+
+ 1, /* callsubr */
+ 1,
+ 0,
+
+ 2, /* hsbw */
+ 0,
+ 0,
+ 0,
+ 5, /* seac */
+ 4, /* sbw */
+ 2 /* setcurrentpoint */
+ };
+
+
+ static FT_Error
+ cff_operator_seac( CFF_Decoder* decoder,
+ FT_Pos asb,
+ FT_Pos adx,
+ FT_Pos ady,
+ FT_Int bchar,
+ FT_Int achar )
+ {
+ FT_Error error;
+ CFF_Builder* builder = &decoder->builder;
+ FT_Int bchar_index, achar_index;
+ TT_Face face = decoder->builder.face;
+ FT_Vector left_bearing, advance;
+ FT_Byte* charstring;
+ FT_ULong charstring_len;
+ FT_Pos glyph_width;
+
+
+ if ( decoder->seac )
+ {
+ FT_ERROR(( "cff_operator_seac: invalid nested seac\n" ));
+ return FT_THROW( Syntax_Error );
+ }
+
+ adx += decoder->builder.left_bearing.x;
+ ady += decoder->builder.left_bearing.y;
+
+#ifdef FT_CONFIG_OPTION_INCREMENTAL
+ /* Incremental fonts don't necessarily have valid charsets. */
+ /* They use the character code, not the glyph index, in this case. */
+ if ( face->root.internal->incremental_interface )
+ {
+ bchar_index = bchar;
+ achar_index = achar;
+ }
+ else
+#endif /* FT_CONFIG_OPTION_INCREMENTAL */
+ {
+ CFF_Font cff = (CFF_Font)(face->extra.data);
+
+
+ bchar_index = cff_lookup_glyph_by_stdcharcode( cff, bchar );
+ achar_index = cff_lookup_glyph_by_stdcharcode( cff, achar );
+ }
+
+ if ( bchar_index < 0 || achar_index < 0 )
+ {
+ FT_ERROR(( "cff_operator_seac:"
+ " invalid seac character code arguments\n" ));
+ return FT_THROW( Syntax_Error );
+ }
+
+ /* If we are trying to load a composite glyph, do not load the */
+ /* accent character and return the array of subglyphs. */
+ if ( builder->no_recurse )
+ {
+ FT_GlyphSlot glyph = (FT_GlyphSlot)builder->glyph;
+ FT_GlyphLoader loader = glyph->internal->loader;
+ FT_SubGlyph subg;
+
+
+ /* reallocate subglyph array if necessary */
+ error = FT_GlyphLoader_CheckSubGlyphs( loader, 2 );
+ if ( error )
+ goto Exit;
+
+ subg = loader->current.subglyphs;
+
+ /* subglyph 0 = base character */
+ subg->index = bchar_index;
+ subg->flags = FT_SUBGLYPH_FLAG_ARGS_ARE_XY_VALUES |
+ FT_SUBGLYPH_FLAG_USE_MY_METRICS;
+ subg->arg1 = 0;
+ subg->arg2 = 0;
+ subg++;
+
+ /* subglyph 1 = accent character */
+ subg->index = achar_index;
+ subg->flags = FT_SUBGLYPH_FLAG_ARGS_ARE_XY_VALUES;
+ subg->arg1 = (FT_Int)( adx >> 16 );
+ subg->arg2 = (FT_Int)( ady >> 16 );
+
+ /* set up remaining glyph fields */
+ glyph->num_subglyphs = 2;
+ glyph->subglyphs = loader->base.subglyphs;
+ glyph->format = FT_GLYPH_FORMAT_COMPOSITE;
+
+ loader->current.num_subglyphs = 2;
+ }
+
+ FT_GlyphLoader_Prepare( builder->loader );
+
+ /* First load `bchar' in builder */
+ error = decoder->get_glyph_callback( face, (FT_UInt)bchar_index,
+ &charstring, &charstring_len );
+ if ( !error )
+ {
+ /* the seac operator must not be nested */
+ decoder->seac = TRUE;
+ error = cff_decoder_parse_charstrings( decoder, charstring,
+ charstring_len, 0 );
+ decoder->seac = FALSE;
+
+ decoder->free_glyph_callback( face, &charstring, charstring_len );
+
+ if ( error )
+ goto Exit;
+ }
+
+ /* Save the left bearing, advance and glyph width of the base */
+ /* character as they will be erased by the next load. */
+
+ left_bearing = builder->left_bearing;
+ advance = builder->advance;
+ glyph_width = decoder->glyph_width;
+
+ builder->left_bearing.x = 0;
+ builder->left_bearing.y = 0;
+
+ builder->pos_x = adx - asb;
+ builder->pos_y = ady;
+
+ /* Now load `achar' on top of the base outline. */
+ error = decoder->get_glyph_callback( face, (FT_UInt)achar_index,
+ &charstring, &charstring_len );
+ if ( !error )
+ {
+ /* the seac operator must not be nested */
+ decoder->seac = TRUE;
+ error = cff_decoder_parse_charstrings( decoder, charstring,
+ charstring_len, 0 );
+ decoder->seac = FALSE;
+
+ decoder->free_glyph_callback( face, &charstring, charstring_len );
+
+ if ( error )
+ goto Exit;
+ }
+
+ /* Restore the left side bearing, advance and glyph width */
+ /* of the base character. */
+ builder->left_bearing = left_bearing;
+ builder->advance = advance;
+ decoder->glyph_width = glyph_width;
+
+ builder->pos_x = 0;
+ builder->pos_y = 0;
+
+ Exit:
+ return error;
+ }
+
+#endif /* CFF_CONFIG_OPTION_OLD_ENGINE */
+
+
+ /*************************************************************************/
+ /*************************************************************************/
+ /*************************************************************************/
+ /********** *********/
+ /********** *********/
+ /********** GENERIC CHARSTRING PARSING *********/
+ /********** *********/
+ /********** *********/
+ /*************************************************************************/
+ /*************************************************************************/
+ /*************************************************************************/
+
+ /*************************************************************************/
+ /* */
+ /* <Function> */
+ /* cff_compute_bias */
+ /* */
+ /* <Description> */
+ /* Computes the bias value in dependence of the number of glyph */
+ /* subroutines. */
+ /* */
+ /* <Input> */
+ /* in_charstring_type :: The `CharstringType' value of the top DICT */
+ /* dictionary. */
+ /* */
+ /* num_subrs :: The number of glyph subroutines. */
+ /* */
+ /* <Return> */
+ /* The bias value. */
+ static FT_Int
+ cff_compute_bias( FT_Int in_charstring_type,
+ FT_UInt num_subrs )
+ {
+ FT_Int result;
+
+
+ if ( in_charstring_type == 1 )
+ result = 0;
+ else if ( num_subrs < 1240 )
+ result = 107;
+ else if ( num_subrs < 33900U )
+ result = 1131;
+ else
+ result = 32768U;
+
+ return result;
+ }
+
+
+ FT_LOCAL_DEF( FT_Int )
+ cff_lookup_glyph_by_stdcharcode( CFF_Font cff,
+ FT_Int charcode )
+ {
+ FT_UInt n;
+ FT_UShort glyph_sid;
+
+ FT_Service_CFFLoad cffload;
+
+
+ /* CID-keyed fonts don't have glyph names */
+ if ( !cff->charset.sids )
+ return -1;
+
+ /* check range of standard char code */
+ if ( charcode < 0 || charcode > 255 )
+ return -1;
+
+#if 0
+ /* retrieve cffload from list of current modules */
+ FT_Service_CFFLoad cffload;
+
+
+ FT_FACE_FIND_GLOBAL_SERVICE( face, cffload, CFF_LOAD );
+ if ( !cffload )
+ {
+ FT_ERROR(( "cff_lookup_glyph_by_stdcharcode:"
+ " the `cffload' module is not available\n" ));
+ return FT_THROW( Unimplemented_Feature );
+ }
+#endif
+
+ cffload = (FT_Service_CFFLoad)cff->cffload;
+
+ /* Get code to SID mapping from `cff_standard_encoding'. */
+ glyph_sid = cffload->get_standard_encoding( (FT_UInt)charcode );
+
+ for ( n = 0; n < cff->num_glyphs; n++ )
+ {
+ if ( cff->charset.sids[n] == glyph_sid )
+ return (FT_Int)n;
+ }
+
+ return -1;
+ }
+
+
+#ifdef CFF_CONFIG_OPTION_OLD_ENGINE
+
+ /*************************************************************************/
+ /* */
+ /* <Function> */
+ /* cff_decoder_parse_charstrings */
+ /* */
+ /* <Description> */
+ /* Parses a given Type 2 charstrings program. */
+ /* */
+ /* <InOut> */
+ /* decoder :: The current Type 1 decoder. */
+ /* */
+ /* <Input> */
+ /* charstring_base :: The base of the charstring stream. */
+ /* */
+ /* charstring_len :: The length in bytes of the charstring stream. */
+ /* */
+ /* in_dict :: Set to 1 if function is called from top or */
+ /* private DICT (needed for Multiple Master CFFs). */
+ /* */
+ /* <Return> */
+ /* FreeType error code. 0 means success. */
+ /* */
+ FT_LOCAL_DEF( FT_Error )
+ cff_decoder_parse_charstrings( CFF_Decoder* decoder,
+ FT_Byte* charstring_base,
+ FT_ULong charstring_len,
+ FT_Bool in_dict )
+ {
+ FT_Error error;
+ CFF_Decoder_Zone* zone;
+ FT_Byte* ip;
+ FT_Byte* limit;
+ CFF_Builder* builder = &decoder->builder;
+ FT_Pos x, y;
+ FT_Fixed* stack;
+ FT_Int charstring_type =
+ decoder->cff->top_font.font_dict.charstring_type;
+ FT_UShort num_designs =
+ decoder->cff->top_font.font_dict.num_designs;
+ FT_UShort num_axes =
+ decoder->cff->top_font.font_dict.num_axes;
+
+ T2_Hints_Funcs hinter;
+
+
+ /* set default width */
+ decoder->num_hints = 0;
+ decoder->read_width = 1;
+
+ /* initialize the decoder */
+ decoder->top = decoder->stack;
+ decoder->zone = decoder->zones;
+ zone = decoder->zones;
+ stack = decoder->top;
+
+ hinter = (T2_Hints_Funcs)builder->hints_funcs;
+
+ builder->path_begun = 0;
+
+ zone->base = charstring_base;
+ limit = zone->limit = charstring_base + charstring_len;
+ ip = zone->cursor = zone->base;
+
+ error = FT_Err_Ok;
+
+ x = builder->pos_x;
+ y = builder->pos_y;
+
+ /* begin hints recording session, if any */
+ if ( hinter )
+ hinter->open( hinter->hints );
+
+ /* now execute loop */
+ while ( ip < limit )
+ {
+ CFF_Operator op;
+ FT_Byte v;
+
+
+ /********************************************************************/
+ /* */
+ /* Decode operator or operand */
+ /* */
+ v = *ip++;
+ if ( v >= 32 || v == 28 )
+ {
+ FT_Int shift = 16;
+ FT_Int32 val;
+
+
+ /* this is an operand, push it on the stack */
+
+ /* if we use shifts, all computations are done with unsigned */
+ /* values; the conversion to a signed value is the last step */
+ if ( v == 28 )
+ {
+ if ( ip + 1 >= limit )
+ goto Syntax_Error;
+ val = (FT_Short)( ( (FT_UShort)ip[0] << 8 ) | ip[1] );
+ ip += 2;
+ }
+ else if ( v < 247 )
+ val = (FT_Int32)v - 139;
+ else if ( v < 251 )
+ {
+ if ( ip >= limit )
+ goto Syntax_Error;
+ val = ( (FT_Int32)v - 247 ) * 256 + *ip++ + 108;
+ }
+ else if ( v < 255 )
+ {
+ if ( ip >= limit )
+ goto Syntax_Error;
+ val = -( (FT_Int32)v - 251 ) * 256 - *ip++ - 108;
+ }
+ else
+ {
+ if ( ip + 3 >= limit )
+ goto Syntax_Error;
+ val = (FT_Int32)( ( (FT_UInt32)ip[0] << 24 ) |
+ ( (FT_UInt32)ip[1] << 16 ) |
+ ( (FT_UInt32)ip[2] << 8 ) |
+ (FT_UInt32)ip[3] );
+ ip += 4;
+ if ( charstring_type == 2 )
+ shift = 0;
+ }
+ if ( decoder->top - stack >= CFF_MAX_OPERANDS )
+ goto Stack_Overflow;
+
+ val = (FT_Int32)( (FT_UInt32)val << shift );
+ *decoder->top++ = val;
+
+#ifdef FT_DEBUG_LEVEL_TRACE
+ if ( !( val & 0xFFFFL ) )
+ FT_TRACE4(( " %hd", (FT_Short)( (FT_UInt32)val >> 16 ) ));
+ else
+ FT_TRACE4(( " %.5f", val / 65536.0 ));
+#endif
+
+ }
+ else
+ {
+ /* The specification says that normally arguments are to be taken */
+ /* from the bottom of the stack. However, this seems not to be */
+ /* correct, at least for Acroread 7.0.8 on GNU/Linux: It pops the */
+ /* arguments similar to a PS interpreter. */
+
+ FT_Fixed* args = decoder->top;
+ FT_Int num_args = (FT_Int)( args - decoder->stack );
+ FT_Int req_args;
+
+
+ /* find operator */
+ op = cff_op_unknown;
+
+ switch ( v )
+ {
+ case 1:
+ op = cff_op_hstem;
+ break;
+ case 3:
+ op = cff_op_vstem;
+ break;
+ case 4:
+ op = cff_op_vmoveto;
+ break;
+ case 5:
+ op = cff_op_rlineto;
+ break;
+ case 6:
+ op = cff_op_hlineto;
+ break;
+ case 7:
+ op = cff_op_vlineto;
+ break;
+ case 8:
+ op = cff_op_rrcurveto;
+ break;
+ case 9:
+ op = cff_op_closepath;
+ break;
+ case 10:
+ op = cff_op_callsubr;
+ break;
+ case 11:
+ op = cff_op_return;
+ break;
+ case 12:
+ if ( ip >= limit )
+ goto Syntax_Error;
+ v = *ip++;
+
+ switch ( v )
+ {
+ case 0:
+ op = cff_op_dotsection;
+ break;
+ case 1: /* this is actually the Type1 vstem3 operator */
+ op = cff_op_vstem;
+ break;
+ case 2: /* this is actually the Type1 hstem3 operator */
+ op = cff_op_hstem;
+ break;
+ case 3:
+ op = cff_op_and;
+ break;
+ case 4:
+ op = cff_op_or;
+ break;
+ case 5:
+ op = cff_op_not;
+ break;
+ case 6:
+ op = cff_op_seac;
+ break;
+ case 7:
+ op = cff_op_sbw;
+ break;
+ case 8:
+ op = cff_op_store;
+ break;
+ case 9:
+ op = cff_op_abs;
+ break;
+ case 10:
+ op = cff_op_add;
+ break;
+ case 11:
+ op = cff_op_sub;
+ break;
+ case 12:
+ op = cff_op_div;
+ break;
+ case 13:
+ op = cff_op_load;
+ break;
+ case 14:
+ op = cff_op_neg;
+ break;
+ case 15:
+ op = cff_op_eq;
+ break;
+ case 16:
+ op = cff_op_callothersubr;
+ break;
+ case 17:
+ op = cff_op_pop;
+ break;
+ case 18:
+ op = cff_op_drop;
+ break;
+ case 20:
+ op = cff_op_put;
+ break;
+ case 21:
+ op = cff_op_get;
+ break;
+ case 22:
+ op = cff_op_ifelse;
+ break;
+ case 23:
+ op = cff_op_random;
+ break;
+ case 24:
+ op = cff_op_mul;
+ break;
+ case 26:
+ op = cff_op_sqrt;
+ break;
+ case 27:
+ op = cff_op_dup;
+ break;
+ case 28:
+ op = cff_op_exch;
+ break;
+ case 29:
+ op = cff_op_index;
+ break;
+ case 30:
+ op = cff_op_roll;
+ break;
+ case 33:
+ op = cff_op_setcurrentpoint;
+ break;
+ case 34:
+ op = cff_op_hflex;
+ break;
+ case 35:
+ op = cff_op_flex;
+ break;
+ case 36:
+ op = cff_op_hflex1;
+ break;
+ case 37:
+ op = cff_op_flex1;
+ break;
+ default:
+ FT_TRACE4(( " unknown op (12, %d)\n", v ));
+ break;
+ }
+ break;
+ case 13:
+ op = cff_op_hsbw;
+ break;
+ case 14:
+ op = cff_op_endchar;
+ break;
+ case 16:
+ op = cff_op_blend;
+ break;
+ case 18:
+ op = cff_op_hstemhm;
+ break;
+ case 19:
+ op = cff_op_hintmask;
+ break;
+ case 20:
+ op = cff_op_cntrmask;
+ break;
+ case 21:
+ op = cff_op_rmoveto;
+ break;
+ case 22:
+ op = cff_op_hmoveto;
+ break;
+ case 23:
+ op = cff_op_vstemhm;
+ break;
+ case 24:
+ op = cff_op_rcurveline;
+ break;
+ case 25:
+ op = cff_op_rlinecurve;
+ break;
+ case 26:
+ op = cff_op_vvcurveto;
+ break;
+ case 27:
+ op = cff_op_hhcurveto;
+ break;
+ case 29:
+ op = cff_op_callgsubr;
+ break;
+ case 30:
+ op = cff_op_vhcurveto;
+ break;
+ case 31:
+ op = cff_op_hvcurveto;
+ break;
+ default:
+ FT_TRACE4(( " unknown op (%d)\n", v ));
+ break;
+ }
+
+ if ( op == cff_op_unknown )
+ continue;
+
+ /* in Multiple Master CFFs, T2 charstrings can appear in */
+ /* dictionaries, but some operators are prohibited */
+ if ( in_dict )
+ {
+ switch ( op )
+ {
+ case cff_op_hstem:
+ case cff_op_vstem:
+ case cff_op_vmoveto:
+ case cff_op_rlineto:
+ case cff_op_hlineto:
+ case cff_op_vlineto:
+ case cff_op_rrcurveto:
+ case cff_op_hstemhm:
+ case cff_op_hintmask:
+ case cff_op_cntrmask:
+ case cff_op_rmoveto:
+ case cff_op_hmoveto:
+ case cff_op_vstemhm:
+ case cff_op_rcurveline:
+ case cff_op_rlinecurve:
+ case cff_op_vvcurveto:
+ case cff_op_hhcurveto:
+ case cff_op_vhcurveto:
+ case cff_op_hvcurveto:
+ case cff_op_hflex:
+ case cff_op_flex:
+ case cff_op_hflex1:
+ case cff_op_flex1:
+ case cff_op_callsubr:
+ case cff_op_callgsubr:
+ goto MM_Error;
+
+ default:
+ break;
+ }
+ }
+
+ /* check arguments */
+ req_args = cff_argument_counts[op];
+ if ( req_args & CFF_COUNT_CHECK_WIDTH )
+ {
+ if ( num_args > 0 && decoder->read_width )
+ {
+ /* If `nominal_width' is non-zero, the number is really a */
+ /* difference against `nominal_width'. Else, the number here */
+ /* is truly a width, not a difference against `nominal_width'. */
+ /* If the font does not set `nominal_width', then */
+ /* `nominal_width' defaults to zero, and so we can set */
+ /* `glyph_width' to `nominal_width' plus number on the stack */
+ /* -- for either case. */
+
+ FT_Int set_width_ok;
+
+
+ switch ( op )
+ {
+ case cff_op_hmoveto:
+ case cff_op_vmoveto:
+ set_width_ok = num_args & 2;
+ break;
+
+ case cff_op_hstem:
+ case cff_op_vstem:
+ case cff_op_hstemhm:
+ case cff_op_vstemhm:
+ case cff_op_rmoveto:
+ case cff_op_hintmask:
+ case cff_op_cntrmask:
+ set_width_ok = num_args & 1;
+ break;
+
+ case cff_op_endchar:
+ /* If there is a width specified for endchar, we either have */
+ /* 1 argument or 5 arguments. We like to argue. */
+ set_width_ok = in_dict
+ ? 0
+ : ( ( num_args == 5 ) || ( num_args == 1 ) );
+ break;
+
+ default:
+ set_width_ok = 0;
+ break;
+ }
+
+ if ( set_width_ok )
+ {
+ decoder->glyph_width = decoder->nominal_width +
+ ( stack[0] >> 16 );
+
+ if ( decoder->width_only )
+ {
+ /* we only want the advance width; stop here */
+ break;
+ }
+
+ /* Consumed an argument. */
+ num_args--;
+ }
+ }
+
+ decoder->read_width = 0;
+ req_args = 0;
+ }
+
+ req_args &= 0x000F;
+ if ( num_args < req_args )
+ goto Stack_Underflow;
+ args -= req_args;
+ num_args -= req_args;
+
+ /* At this point, `args' points to the first argument of the */
+ /* operand in case `req_args' isn't zero. Otherwise, we have */
+ /* to adjust `args' manually. */
+
+ /* Note that we only pop arguments from the stack which we */
+ /* really need and can digest so that we can continue in case */
+ /* of superfluous stack elements. */
+
+ switch ( op )
+ {
+ case cff_op_hstem:
+ case cff_op_vstem:
+ case cff_op_hstemhm:
+ case cff_op_vstemhm:
+ /* the number of arguments is always even here */
+ FT_TRACE4((
+ op == cff_op_hstem ? " hstem\n" :
+ ( op == cff_op_vstem ? " vstem\n" :
+ ( op == cff_op_hstemhm ? " hstemhm\n" : " vstemhm\n" ) ) ));
+
+ if ( hinter )
+ hinter->stems( hinter->hints,
+ ( op == cff_op_hstem || op == cff_op_hstemhm ),
+ num_args / 2,
+ args - ( num_args & ~1 ) );
+
+ decoder->num_hints += num_args / 2;
+ args = stack;
+ break;
+
+ case cff_op_hintmask:
+ case cff_op_cntrmask:
+ FT_TRACE4(( op == cff_op_hintmask ? " hintmask" : " cntrmask" ));
+
+ /* implement vstem when needed -- */
+ /* the specification doesn't say it, but this also works */
+ /* with the 'cntrmask' operator */
+ /* */
+ if ( num_args > 0 )
+ {
+ if ( hinter )
+ hinter->stems( hinter->hints,
+ 0,
+ num_args / 2,
+ args - ( num_args & ~1 ) );
+
+ decoder->num_hints += num_args / 2;
+ }
+
+ /* In a valid charstring there must be at least one byte */
+ /* after `hintmask' or `cntrmask' (e.g., for a `return' */
+ /* instruction). Additionally, there must be space for */
+ /* `num_hints' bits. */
+
+ if ( ( ip + ( ( decoder->num_hints + 7 ) >> 3 ) ) >= limit )
+ goto Syntax_Error;
+
+ if ( hinter )
+ {
+ if ( op == cff_op_hintmask )
+ hinter->hintmask( hinter->hints,
+ (FT_UInt)builder->current->n_points,
+ (FT_UInt)decoder->num_hints,
+ ip );
+ else
+ hinter->counter( hinter->hints,
+ (FT_UInt)decoder->num_hints,
+ ip );
+ }
+
+#ifdef FT_DEBUG_LEVEL_TRACE
+ {
+ FT_UInt maskbyte;
+
+
+ FT_TRACE4(( " (maskbytes:" ));
+
+ for ( maskbyte = 0;
+ maskbyte < (FT_UInt)( ( decoder->num_hints + 7 ) >> 3 );
+ maskbyte++, ip++ )
+ FT_TRACE4(( " 0x%02X", *ip ));
+
+ FT_TRACE4(( ")\n" ));
+ }
+#else
+ ip += ( decoder->num_hints + 7 ) >> 3;
+#endif
+ args = stack;
+ break;
+
+ case cff_op_rmoveto:
+ FT_TRACE4(( " rmoveto\n" ));
+
+ cff_builder_close_contour( builder );
+ builder->path_begun = 0;
+ x = ADD_LONG( x, args[-2] );
+ y = ADD_LONG( y, args[-1] );
+ args = stack;
+ break;
+
+ case cff_op_vmoveto:
+ FT_TRACE4(( " vmoveto\n" ));
+
+ cff_builder_close_contour( builder );
+ builder->path_begun = 0;
+ y = ADD_LONG( y, args[-1] );
+ args = stack;
+ break;
+
+ case cff_op_hmoveto:
+ FT_TRACE4(( " hmoveto\n" ));
+
+ cff_builder_close_contour( builder );
+ builder->path_begun = 0;
+ x = ADD_LONG( x, args[-1] );
+ args = stack;
+ break;
+
+ case cff_op_rlineto:
+ FT_TRACE4(( " rlineto\n" ));
+
+ if ( cff_builder_start_point( builder, x, y ) ||
+ cff_check_points( builder, num_args / 2 ) )
+ goto Fail;
+
+ if ( num_args < 2 )
+ goto Stack_Underflow;
+
+ args -= num_args & ~1;
+ while ( args < decoder->top )
+ {
+ x = ADD_LONG( x, args[0] );
+ y = ADD_LONG( y, args[1] );
+ cff_builder_add_point( builder, x, y, 1 );
+ args += 2;
+ }
+ args = stack;
+ break;
+
+ case cff_op_hlineto:
+ case cff_op_vlineto:
+ {
+ FT_Int phase = ( op == cff_op_hlineto );
+
+
+ FT_TRACE4(( op == cff_op_hlineto ? " hlineto\n"
+ : " vlineto\n" ));
+
+ if ( num_args < 0 )
+ goto Stack_Underflow;
+
+ /* there exist subsetted fonts (found in PDFs) */
+ /* which call `hlineto' without arguments */
+ if ( num_args == 0 )
+ break;
+
+ if ( cff_builder_start_point( builder, x, y ) ||
+ cff_check_points( builder, num_args ) )
+ goto Fail;
+
+ args = stack;
+ while ( args < decoder->top )
+ {
+ if ( phase )
+ x = ADD_LONG( x, args[0] );
+ else
+ y = ADD_LONG( y, args[0] );
+
+ if ( cff_builder_add_point1( builder, x, y ) )
+ goto Fail;
+
+ args++;
+ phase ^= 1;
+ }
+ args = stack;
+ }
+ break;
+
+ case cff_op_rrcurveto:
+ {
+ FT_Int nargs;
+
+
+ FT_TRACE4(( " rrcurveto\n" ));
+
+ if ( num_args < 6 )
+ goto Stack_Underflow;
+
+ nargs = num_args - num_args % 6;
+
+ if ( cff_builder_start_point( builder, x, y ) ||
+ cff_check_points( builder, nargs / 2 ) )
+ goto Fail;
+
+ args -= nargs;
+ while ( args < decoder->top )
+ {
+ x = ADD_LONG( x, args[0] );
+ y = ADD_LONG( y, args[1] );
+ cff_builder_add_point( builder, x, y, 0 );
+
+ x = ADD_LONG( x, args[2] );
+ y = ADD_LONG( y, args[3] );
+ cff_builder_add_point( builder, x, y, 0 );
+
+ x = ADD_LONG( x, args[4] );
+ y = ADD_LONG( y, args[5] );
+ cff_builder_add_point( builder, x, y, 1 );
+
+ args += 6;
+ }
+ args = stack;
+ }
+ break;
+
+ case cff_op_vvcurveto:
+ {
+ FT_Int nargs;
+
+
+ FT_TRACE4(( " vvcurveto\n" ));
+
+ if ( num_args < 4 )
+ goto Stack_Underflow;
+
+ /* if num_args isn't of the form 4n or 4n+1, */
+ /* we enforce it by clearing the second bit */
+
+ nargs = num_args & ~2;
+
+ if ( cff_builder_start_point( builder, x, y ) )
+ goto Fail;
+
+ args -= nargs;
+
+ if ( nargs & 1 )
+ {
+ x = ADD_LONG( x, args[0] );
+ args++;
+ nargs--;
+ }
+
+ if ( cff_check_points( builder, 3 * ( nargs / 4 ) ) )
+ goto Fail;
+
+ while ( args < decoder->top )
+ {
+ y = ADD_LONG( y, args[0] );
+ cff_builder_add_point( builder, x, y, 0 );
+
+ x = ADD_LONG( x, args[1] );
+ y = ADD_LONG( y, args[2] );
+ cff_builder_add_point( builder, x, y, 0 );
+
+ y = ADD_LONG( y, args[3] );
+ cff_builder_add_point( builder, x, y, 1 );
+
+ args += 4;
+ }
+ args = stack;
+ }
+ break;
+
+ case cff_op_hhcurveto:
+ {
+ FT_Int nargs;
+
+
+ FT_TRACE4(( " hhcurveto\n" ));
+
+ if ( num_args < 4 )
+ goto Stack_Underflow;
+
+ /* if num_args isn't of the form 4n or 4n+1, */
+ /* we enforce it by clearing the second bit */
+
+ nargs = num_args & ~2;
+
+ if ( cff_builder_start_point( builder, x, y ) )
+ goto Fail;
+
+ args -= nargs;
+ if ( nargs & 1 )
+ {
+ y = ADD_LONG( y, args[0] );
+ args++;
+ nargs--;
+ }
+
+ if ( cff_check_points( builder, 3 * ( nargs / 4 ) ) )
+ goto Fail;
+
+ while ( args < decoder->top )
+ {
+ x = ADD_LONG( x, args[0] );
+ cff_builder_add_point( builder, x, y, 0 );
+
+ x = ADD_LONG( x, args[1] );
+ y = ADD_LONG( y, args[2] );
+ cff_builder_add_point( builder, x, y, 0 );
+
+ x = ADD_LONG( x, args[3] );
+ cff_builder_add_point( builder, x, y, 1 );
+
+ args += 4;
+ }
+ args = stack;
+ }
+ break;
+
+ case cff_op_vhcurveto:
+ case cff_op_hvcurveto:
+ {
+ FT_Int phase;
+ FT_Int nargs;
+
+
+ FT_TRACE4(( op == cff_op_vhcurveto ? " vhcurveto\n"
+ : " hvcurveto\n" ));
+
+ if ( cff_builder_start_point( builder, x, y ) )
+ goto Fail;
+
+ if ( num_args < 4 )
+ goto Stack_Underflow;
+
+ /* if num_args isn't of the form 8n, 8n+1, 8n+4, or 8n+5, */
+ /* we enforce it by clearing the second bit */
+
+ nargs = num_args & ~2;
+
+ args -= nargs;
+ if ( cff_check_points( builder, ( nargs / 4 ) * 3 ) )
+ goto Stack_Underflow;
+
+ phase = ( op == cff_op_hvcurveto );
+
+ while ( nargs >= 4 )
+ {
+ nargs -= 4;
+ if ( phase )
+ {
+ x = ADD_LONG( x, args[0] );
+ cff_builder_add_point( builder, x, y, 0 );
+
+ x = ADD_LONG( x, args[1] );
+ y = ADD_LONG( y, args[2] );
+ cff_builder_add_point( builder, x, y, 0 );
+
+ y = ADD_LONG( y, args[3] );
+ if ( nargs == 1 )
+ x = ADD_LONG( x, args[4] );
+ cff_builder_add_point( builder, x, y, 1 );
+ }
+ else
+ {
+ y = ADD_LONG( y, args[0] );
+ cff_builder_add_point( builder, x, y, 0 );
+
+ x = ADD_LONG( x, args[1] );
+ y = ADD_LONG( y, args[2] );
+ cff_builder_add_point( builder, x, y, 0 );
+
+ x = ADD_LONG( x, args[3] );
+ if ( nargs == 1 )
+ y = ADD_LONG( y, args[4] );
+ cff_builder_add_point( builder, x, y, 1 );
+ }
+ args += 4;
+ phase ^= 1;
+ }
+ args = stack;
+ }
+ break;
+
+ case cff_op_rlinecurve:
+ {
+ FT_Int num_lines;
+ FT_Int nargs;
+
+
+ FT_TRACE4(( " rlinecurve\n" ));
+
+ if ( num_args < 8 )
+ goto Stack_Underflow;
+
+ nargs = num_args & ~1;
+ num_lines = ( nargs - 6 ) / 2;
+
+ if ( cff_builder_start_point( builder, x, y ) ||
+ cff_check_points( builder, num_lines + 3 ) )
+ goto Fail;
+
+ args -= nargs;
+
+ /* first, add the line segments */
+ while ( num_lines > 0 )
+ {
+ x = ADD_LONG( x, args[0] );
+ y = ADD_LONG( y, args[1] );
+ cff_builder_add_point( builder, x, y, 1 );
+
+ args += 2;
+ num_lines--;
+ }
+
+ /* then the curve */
+ x = ADD_LONG( x, args[0] );
+ y = ADD_LONG( y, args[1] );
+ cff_builder_add_point( builder, x, y, 0 );
+
+ x = ADD_LONG( x, args[2] );
+ y = ADD_LONG( y, args[3] );
+ cff_builder_add_point( builder, x, y, 0 );
+
+ x = ADD_LONG( x, args[4] );
+ y = ADD_LONG( y, args[5] );
+ cff_builder_add_point( builder, x, y, 1 );
+
+ args = stack;
+ }
+ break;
+
+ case cff_op_rcurveline:
+ {
+ FT_Int num_curves;
+ FT_Int nargs;
+
+
+ FT_TRACE4(( " rcurveline\n" ));
+
+ if ( num_args < 8 )
+ goto Stack_Underflow;
+
+ nargs = num_args - 2;
+ nargs = nargs - nargs % 6 + 2;
+ num_curves = ( nargs - 2 ) / 6;
+
+ if ( cff_builder_start_point( builder, x, y ) ||
+ cff_check_points( builder, num_curves * 3 + 2 ) )
+ goto Fail;
+
+ args -= nargs;
+
+ /* first, add the curves */
+ while ( num_curves > 0 )
+ {
+ x = ADD_LONG( x, args[0] );
+ y = ADD_LONG( y, args[1] );
+ cff_builder_add_point( builder, x, y, 0 );
+
+ x = ADD_LONG( x, args[2] );
+ y = ADD_LONG( y, args[3] );
+ cff_builder_add_point( builder, x, y, 0 );
+
+ x = ADD_LONG( x, args[4] );
+ y = ADD_LONG( y, args[5] );
+ cff_builder_add_point( builder, x, y, 1 );
+
+ args += 6;
+ num_curves--;
+ }
+
+ /* then the final line */
+ x = ADD_LONG( x, args[0] );
+ y = ADD_LONG( y, args[1] );
+ cff_builder_add_point( builder, x, y, 1 );
+
+ args = stack;
+ }
+ break;
+
+ case cff_op_hflex1:
+ {
+ FT_Pos start_y;
+
+
+ FT_TRACE4(( " hflex1\n" ));
+
+ /* adding five more points: 4 control points, 1 on-curve point */
+ /* -- make sure we have enough space for the start point if it */
+ /* needs to be added */
+ if ( cff_builder_start_point( builder, x, y ) ||
+ cff_check_points( builder, 6 ) )
+ goto Fail;
+
+ /* record the starting point's y position for later use */
+ start_y = y;
+
+ /* first control point */
+ x = ADD_LONG( x, args[0] );
+ y = ADD_LONG( y, args[1] );
+ cff_builder_add_point( builder, x, y, 0 );
+
+ /* second control point */
+ x = ADD_LONG( x, args[2] );
+ y = ADD_LONG( y, args[3] );
+ cff_builder_add_point( builder, x, y, 0 );
+
+ /* join point; on curve, with y-value the same as the last */
+ /* control point's y-value */
+ x = ADD_LONG( x, args[4] );
+ cff_builder_add_point( builder, x, y, 1 );
+
+ /* third control point, with y-value the same as the join */
+ /* point's y-value */
+ x = ADD_LONG( x, args[5] );
+ cff_builder_add_point( builder, x, y, 0 );
+
+ /* fourth control point */
+ x = ADD_LONG( x, args[6] );
+ y = ADD_LONG( y, args[7] );
+ cff_builder_add_point( builder, x, y, 0 );
+
+ /* ending point, with y-value the same as the start */
+ x = ADD_LONG( x, args[8] );
+ y = start_y;
+ cff_builder_add_point( builder, x, y, 1 );
+
+ args = stack;
+ break;
+ }
+
+ case cff_op_hflex:
+ {
+ FT_Pos start_y;
+
+
+ FT_TRACE4(( " hflex\n" ));
+
+ /* adding six more points; 4 control points, 2 on-curve points */
+ if ( cff_builder_start_point( builder, x, y ) ||
+ cff_check_points( builder, 6 ) )
+ goto Fail;
+
+ /* record the starting point's y-position for later use */
+ start_y = y;
+
+ /* first control point */
+ x = ADD_LONG( x, args[0] );
+ cff_builder_add_point( builder, x, y, 0 );
+
+ /* second control point */
+ x = ADD_LONG( x, args[1] );
+ y = ADD_LONG( y, args[2] );
+ cff_builder_add_point( builder, x, y, 0 );
+
+ /* join point; on curve, with y-value the same as the last */
+ /* control point's y-value */
+ x = ADD_LONG( x, args[3] );
+ cff_builder_add_point( builder, x, y, 1 );
+
+ /* third control point, with y-value the same as the join */
+ /* point's y-value */
+ x = ADD_LONG( x, args[4] );
+ cff_builder_add_point( builder, x, y, 0 );
+
+ /* fourth control point */
+ x = ADD_LONG( x, args[5] );
+ y = start_y;
+ cff_builder_add_point( builder, x, y, 0 );
+
+ /* ending point, with y-value the same as the start point's */
+ /* y-value -- we don't add this point, though */
+ x = ADD_LONG( x, args[6] );
+ cff_builder_add_point( builder, x, y, 1 );
+
+ args = stack;
+ break;
+ }
+
+ case cff_op_flex1:
+ {
+ FT_Pos start_x, start_y; /* record start x, y values for */
+ /* alter use */
+ FT_Fixed dx = 0, dy = 0; /* used in horizontal/vertical */
+ /* algorithm below */
+ FT_Int horizontal, count;
+ FT_Fixed* temp;
+
+
+ FT_TRACE4(( " flex1\n" ));
+
+ /* adding six more points; 4 control points, 2 on-curve points */
+ if ( cff_builder_start_point( builder, x, y ) ||
+ cff_check_points( builder, 6 ) )
+ goto Fail;
+
+ /* record the starting point's x, y position for later use */
+ start_x = x;
+ start_y = y;
+
+ /* XXX: figure out whether this is supposed to be a horizontal */
+ /* or vertical flex; the Type 2 specification is vague... */
+
+ temp = args;
+
+ /* grab up to the last argument */
+ for ( count = 5; count > 0; count-- )
+ {
+ dx = ADD_LONG( dx, temp[0] );
+ dy = ADD_LONG( dy, temp[1] );
+ temp += 2;
+ }
+
+ if ( dx < 0 )
+ dx = -dx;
+ if ( dy < 0 )
+ dy = -dy;
+
+ /* strange test, but here it is... */
+ horizontal = ( dx > dy );
+
+ for ( count = 5; count > 0; count-- )
+ {
+ x = ADD_LONG( x, args[0] );
+ y = ADD_LONG( y, args[1] );
+ cff_builder_add_point( builder, x, y,
+ (FT_Bool)( count == 3 ) );
+ args += 2;
+ }
+
+ /* is last operand an x- or y-delta? */
+ if ( horizontal )
+ {
+ x = ADD_LONG( x, args[0] );
+ y = start_y;
+ }
+ else
+ {
+ x = start_x;
+ y = ADD_LONG( y, args[0] );
+ }
+
+ cff_builder_add_point( builder, x, y, 1 );
+
+ args = stack;
+ break;
+ }
+
+ case cff_op_flex:
+ {
+ FT_UInt count;
+
+
+ FT_TRACE4(( " flex\n" ));
+
+ if ( cff_builder_start_point( builder, x, y ) ||
+ cff_check_points( builder, 6 ) )
+ goto Fail;
+
+ for ( count = 6; count > 0; count-- )
+ {
+ x = ADD_LONG( x, args[0] );
+ y = ADD_LONG( y, args[1] );
+ cff_builder_add_point( builder, x, y,
+ (FT_Bool)( count == 4 || count == 1 ) );
+ args += 2;
+ }
+
+ args = stack;
+ }
+ break;
+
+ case cff_op_seac:
+ FT_TRACE4(( " seac\n" ));
+
+ error = cff_operator_seac( decoder,
+ args[0], args[1], args[2],
+ (FT_Int)( args[3] >> 16 ),
+ (FT_Int)( args[4] >> 16 ) );
+
+ /* add current outline to the glyph slot */
+ FT_GlyphLoader_Add( builder->loader );
+
+ /* return now! */
+ FT_TRACE4(( "\n" ));
+ return error;
+
+ case cff_op_endchar:
+ /* in dictionaries, `endchar' simply indicates end of data */
+ if ( in_dict )
+ return error;
+
+ FT_TRACE4(( " endchar\n" ));
+
+ /* We are going to emulate the seac operator. */
+ if ( num_args >= 4 )
+ {
+ /* Save glyph width so that the subglyphs don't overwrite it. */
+ FT_Pos glyph_width = decoder->glyph_width;
+
+
+ error = cff_operator_seac( decoder,
+ 0L, args[-4], args[-3],
+ (FT_Int)( args[-2] >> 16 ),
+ (FT_Int)( args[-1] >> 16 ) );
+
+ decoder->glyph_width = glyph_width;
+ }
+ else
+ {
+ cff_builder_close_contour( builder );
+
+ /* close hints recording session */
+ if ( hinter )
+ {
+ if ( hinter->close( hinter->hints,
+ (FT_UInt)builder->current->n_points ) )
+ goto Syntax_Error;
+
+ /* apply hints to the loaded glyph outline now */
+ error = hinter->apply( hinter->hints,
+ builder->current,
+ (PSH_Globals)builder->hints_globals,
+ decoder->hint_mode );
+ if ( error )
+ goto Fail;
+ }
+
+ /* add current outline to the glyph slot */
+ FT_GlyphLoader_Add( builder->loader );
+ }
+
+ /* return now! */
+ FT_TRACE4(( "\n" ));
+ return error;
+
+ case cff_op_abs:
+ FT_TRACE4(( " abs\n" ));
+
+ if ( args[0] < 0 )
+ {
+ if ( args[0] == FT_LONG_MIN )
+ args[0] = FT_LONG_MAX;
+ else
+ args[0] = -args[0];
+ }
+ args++;
+ break;
+
+ case cff_op_add:
+ FT_TRACE4(( " add\n" ));
+
+ args[0] = ADD_LONG( args[0], args[1] );
+ args++;
+ break;
+
+ case cff_op_sub:
+ FT_TRACE4(( " sub\n" ));
+
+ args[0] = SUB_LONG( args[0], args[1] );
+ args++;
+ break;
+
+ case cff_op_div:
+ FT_TRACE4(( " div\n" ));
+
+ args[0] = FT_DivFix( args[0], args[1] );
+ args++;
+ break;
+
+ case cff_op_neg:
+ FT_TRACE4(( " neg\n" ));
+
+ if ( args[0] == FT_LONG_MIN )
+ args[0] = FT_LONG_MAX;
+ args[0] = -args[0];
+ args++;
+ break;
+
+ case cff_op_random:
+ FT_TRACE4(( " random\n" ));
+
+ /* 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++;
+
+ decoder->current_subfont->random =
+ cff_random( decoder->current_subfont->random );
+ break;
+
+ case cff_op_mul:
+ FT_TRACE4(( " mul\n" ));
+
+ args[0] = FT_MulFix( args[0], args[1] );
+ args++;
+ break;
+
+ case cff_op_sqrt:
+ FT_TRACE4(( " sqrt\n" ));
+
+ if ( args[0] > 0 )
+ {
+ FT_Fixed root = args[0];
+ FT_Fixed new_root;
+
+
+ for (;;)
+ {
+ new_root = ( root + FT_DivFix( args[0], root ) + 1 ) >> 1;
+ if ( new_root == root )
+ break;
+ root = new_root;
+ }
+ args[0] = new_root;
+ }
+ else
+ args[0] = 0;
+ args++;
+ break;
+
+ case cff_op_drop:
+ /* nothing */
+ FT_TRACE4(( " drop\n" ));
+
+ break;
+
+ case cff_op_exch:
+ {
+ FT_Fixed tmp;
+
+
+ FT_TRACE4(( " exch\n" ));
+
+ tmp = args[0];
+ args[0] = args[1];
+ args[1] = tmp;
+ args += 2;
+ }
+ break;
+
+ case cff_op_index:
+ {
+ FT_Int idx = (FT_Int)( args[0] >> 16 );
+
+
+ FT_TRACE4(( " index\n" ));
+
+ if ( idx < 0 )
+ idx = 0;
+ else if ( idx > num_args - 2 )
+ idx = num_args - 2;
+ args[0] = args[-( idx + 1 )];
+ args++;
+ }
+ break;
+
+ case cff_op_roll:
+ {
+ FT_Int count = (FT_Int)( args[0] >> 16 );
+ FT_Int idx = (FT_Int)( args[1] >> 16 );
+
+
+ FT_TRACE4(( " roll\n" ));
+
+ if ( count <= 0 )
+ count = 1;
+
+ args -= count;
+ if ( args < stack )
+ goto Stack_Underflow;
+
+ if ( idx >= 0 )
+ {
+ while ( idx > 0 )
+ {
+ FT_Fixed tmp = args[count - 1];
+ FT_Int i;
+
+
+ for ( i = count - 2; i >= 0; i-- )
+ args[i + 1] = args[i];
+ args[0] = tmp;
+ idx--;
+ }
+ }
+ else
+ {
+ while ( idx < 0 )
+ {
+ FT_Fixed tmp = args[0];
+ FT_Int i;
+
+
+ for ( i = 0; i < count - 1; i++ )
+ args[i] = args[i + 1];
+ args[count - 1] = tmp;
+ idx++;
+ }
+ }
+ args += count;
+ }
+ break;
+
+ case cff_op_dup:
+ FT_TRACE4(( " dup\n" ));
+
+ args[1] = args[0];
+ args += 2;
+ break;
+
+ case cff_op_put:
+ {
+ FT_Fixed val = args[0];
+ FT_Int idx = (FT_Int)( args[1] >> 16 );
+
+
+ FT_TRACE4(( " put\n" ));
+
+ /* the Type2 specification before version 16-March-2000 */
+ /* didn't give a hard-coded size limit of the temporary */
+ /* storage array; instead, an argument of the */
+ /* `MultipleMaster' operator set the size */
+ if ( idx >= 0 && idx < CFF_MAX_TRANS_ELEMENTS )
+ decoder->buildchar[idx] = val;
+ }
+ break;
+
+ case cff_op_get:
+ {
+ FT_Int idx = (FT_Int)( args[0] >> 16 );
+ FT_Fixed val = 0;
+
+
+ FT_TRACE4(( " get\n" ));
+
+ if ( idx >= 0 && idx < CFF_MAX_TRANS_ELEMENTS )
+ val = decoder->buildchar[idx];
+
+ args[0] = val;
+ args++;
+ }
+ break;
+
+ case cff_op_store:
+ /* this operator was removed from the Type2 specification */
+ /* in version 16-March-2000 */
+
+ /* since we currently don't handle interpolation of multiple */
+ /* master fonts, this is a no-op */
+ FT_TRACE4(( " store\n" ));
+ break;
+
+ case cff_op_load:
+ /* this operator was removed from the Type2 specification */
+ /* in version 16-March-2000 */
+ {
+ FT_Int reg_idx = (FT_Int)args[0];
+ FT_Int idx = (FT_Int)args[1];
+ FT_Int count = (FT_Int)args[2];
+
+
+ FT_TRACE4(( " load\n" ));
+
+ /* since we currently don't handle interpolation of multiple */
+ /* master fonts, we store a vector [1 0 0 ...] in the */
+ /* temporary storage array regardless of the Registry index */
+ if ( reg_idx >= 0 && reg_idx <= 2 &&
+ idx >= 0 && idx < CFF_MAX_TRANS_ELEMENTS &&
+ count >= 0 && count <= num_axes )
+ {
+ FT_Int end, i;
+
+
+ end = FT_MIN( idx + count, CFF_MAX_TRANS_ELEMENTS );
+
+ if ( idx < end )
+ decoder->buildchar[idx] = 1 << 16;
+
+ for ( i = idx + 1; i < end; i++ )
+ decoder->buildchar[i] = 0;
+ }
+ }
+ break;
+
+ case cff_op_blend:
+ /* this operator was removed from the Type2 specification */
+ /* in version 16-March-2000 */
+ {
+ FT_Int num_results = (FT_Int)( args[0] >> 16 );
+
+
+ FT_TRACE4(( " blend\n" ));
+
+ if ( num_results < 0 )
+ goto Syntax_Error;
+
+ if ( num_results * (FT_Int)num_designs > num_args )
+ goto Stack_Underflow;
+
+ /* since we currently don't handle interpolation of multiple */
+ /* master fonts, return the `num_results' values of the */
+ /* first master */
+ args -= num_results * ( num_designs - 1 );
+ num_args -= num_results * ( num_designs - 1 );
+ }
+ break;
+
+ case cff_op_dotsection:
+ /* this operator is deprecated and ignored by the parser */
+ FT_TRACE4(( " dotsection\n" ));
+ break;
+
+ case cff_op_closepath:
+ /* this is an invalid Type 2 operator; however, there */
+ /* exist fonts which are incorrectly converted from probably */
+ /* Type 1 to CFF, and some parsers seem to accept it */
+
+ FT_TRACE4(( " closepath (invalid op)\n" ));
+
+ args = stack;
+ break;
+
+ case cff_op_hsbw:
+ /* this is an invalid Type 2 operator; however, there */
+ /* exist fonts which are incorrectly converted from probably */
+ /* Type 1 to CFF, and some parsers seem to accept it */
+
+ FT_TRACE4(( " hsbw (invalid op)\n" ));
+
+ decoder->glyph_width =
+ ADD_LONG( decoder->nominal_width, ( args[1] >> 16 ) );
+
+ decoder->builder.left_bearing.x = args[0];
+ decoder->builder.left_bearing.y = 0;
+
+ x = ADD_LONG( decoder->builder.pos_x, args[0] );
+ y = decoder->builder.pos_y;
+ args = stack;
+ break;
+
+ case cff_op_sbw:
+ /* this is an invalid Type 2 operator; however, there */
+ /* exist fonts which are incorrectly converted from probably */
+ /* Type 1 to CFF, and some parsers seem to accept it */
+
+ FT_TRACE4(( " sbw (invalid op)\n" ));
+
+ decoder->glyph_width =
+ ADD_LONG( decoder->nominal_width, ( args[2] >> 16 ) );
+
+ decoder->builder.left_bearing.x = args[0];
+ decoder->builder.left_bearing.y = args[1];
+
+ x = ADD_LONG( decoder->builder.pos_x, args[0] );
+ y = ADD_LONG( decoder->builder.pos_y, args[1] );
+ args = stack;
+ break;
+
+ case cff_op_setcurrentpoint:
+ /* this is an invalid Type 2 operator; however, there */
+ /* exist fonts which are incorrectly converted from probably */
+ /* Type 1 to CFF, and some parsers seem to accept it */
+
+ FT_TRACE4(( " setcurrentpoint (invalid op)\n" ));
+
+ x = ADD_LONG( decoder->builder.pos_x, args[0] );
+ y = ADD_LONG( decoder->builder.pos_y, args[1] );
+ args = stack;
+ break;
+
+ case cff_op_callothersubr:
+ /* this is an invalid Type 2 operator; however, there */
+ /* exist fonts which are incorrectly converted from probably */
+ /* Type 1 to CFF, and some parsers seem to accept it */
+
+ FT_TRACE4(( " callothersubr (invalid op)\n" ));
+
+ /* subsequent `pop' operands should add the arguments, */
+ /* this is the implementation described for `unknown' other */
+ /* subroutines in the Type1 spec. */
+ /* */
+ /* XXX Fix return arguments (see discussion below). */
+ args -= 2 + ( args[-2] >> 16 );
+ if ( args < stack )
+ goto Stack_Underflow;
+ break;
+
+ case cff_op_pop:
+ /* this is an invalid Type 2 operator; however, there */
+ /* exist fonts which are incorrectly converted from probably */
+ /* Type 1 to CFF, and some parsers seem to accept it */
+
+ FT_TRACE4(( " pop (invalid op)\n" ));
+
+ /* XXX Increasing `args' is wrong: After a certain number of */
+ /* `pop's we get a stack overflow. Reason for doing it is */
+ /* code like this (actually found in a CFF font): */
+ /* */
+ /* 17 1 3 callothersubr */
+ /* pop */
+ /* callsubr */
+ /* */
+ /* Since we handle `callothersubr' as a no-op, and */
+ /* `callsubr' needs at least one argument, `pop' can't be a */
+ /* no-op too as it basically should be. */
+ /* */
+ /* The right solution would be to provide real support for */
+ /* `callothersubr' as done in `t1decode.c', however, given */
+ /* the fact that CFF fonts with `pop' are invalid, it is */
+ /* questionable whether it is worth the time. */
+ args++;
+ break;
+
+ case cff_op_and:
+ {
+ FT_Fixed cond = ( args[0] && args[1] );
+
+
+ FT_TRACE4(( " and\n" ));
+
+ args[0] = cond ? 0x10000L : 0;
+ args++;
+ }
+ break;
+
+ case cff_op_or:
+ {
+ FT_Fixed cond = ( args[0] || args[1] );
+
+
+ FT_TRACE4(( " or\n" ));
+
+ args[0] = cond ? 0x10000L : 0;
+ args++;
+ }
+ break;
+
+ case cff_op_not:
+ {
+ FT_Fixed cond = !args[0];
+
+
+ FT_TRACE4(( " not\n" ));
+
+ args[0] = cond ? 0x10000L : 0;
+ args++;
+ }
+ break;
+
+ case cff_op_eq:
+ {
+ FT_Fixed cond = ( args[0] == args[1] );
+
+
+ FT_TRACE4(( " eq\n" ));
+
+ args[0] = cond ? 0x10000L : 0;
+ args++;
+ }
+ break;
+
+ case cff_op_ifelse:
+ {
+ FT_Fixed cond = ( args[2] <= args[3] );
+
+
+ FT_TRACE4(( " ifelse\n" ));
+
+ if ( !cond )
+ args[0] = args[1];
+ args++;
+ }
+ break;
+
+ case cff_op_callsubr:
+ {
+ FT_UInt idx = (FT_UInt)( ( args[0] >> 16 ) +
+ decoder->locals_bias );
+
+
+ FT_TRACE4(( " callsubr (idx %d, entering level %d)\n",
+ idx,
+ zone - decoder->zones + 1 ));
+
+ if ( idx >= decoder->num_locals )
+ {
+ FT_ERROR(( "cff_decoder_parse_charstrings:"
+ " invalid local subr index\n" ));
+ goto Syntax_Error;
+ }
+
+ if ( zone - decoder->zones >= CFF_MAX_SUBRS_CALLS )
+ {
+ FT_ERROR(( "cff_decoder_parse_charstrings:"
+ " too many nested subrs\n" ));
+ goto Syntax_Error;
+ }
+
+ zone->cursor = ip; /* save current instruction pointer */
+
+ zone++;
+ zone->base = decoder->locals[idx];
+ zone->limit = decoder->locals[idx + 1];
+ zone->cursor = zone->base;
+
+ if ( !zone->base || zone->limit == zone->base )
+ {
+ FT_ERROR(( "cff_decoder_parse_charstrings:"
+ " invoking empty subrs\n" ));
+ goto Syntax_Error;
+ }
+
+ decoder->zone = zone;
+ ip = zone->base;
+ limit = zone->limit;
+ }
+ break;
+
+ case cff_op_callgsubr:
+ {
+ FT_UInt idx = (FT_UInt)( ( args[0] >> 16 ) +
+ decoder->globals_bias );
+
+
+ FT_TRACE4(( " callgsubr (idx %d, entering level %d)\n",
+ idx,
+ zone - decoder->zones + 1 ));
+
+ if ( idx >= decoder->num_globals )
+ {
+ FT_ERROR(( "cff_decoder_parse_charstrings:"
+ " invalid global subr index\n" ));
+ goto Syntax_Error;
+ }
+
+ if ( zone - decoder->zones >= CFF_MAX_SUBRS_CALLS )
+ {
+ FT_ERROR(( "cff_decoder_parse_charstrings:"
+ " too many nested subrs\n" ));
+ goto Syntax_Error;
+ }
+
+ zone->cursor = ip; /* save current instruction pointer */
+
+ zone++;
+ zone->base = decoder->globals[idx];
+ zone->limit = decoder->globals[idx + 1];
+ zone->cursor = zone->base;
+
+ if ( !zone->base || zone->limit == zone->base )
+ {
+ FT_ERROR(( "cff_decoder_parse_charstrings:"
+ " invoking empty subrs\n" ));
+ goto Syntax_Error;
+ }
+
+ decoder->zone = zone;
+ ip = zone->base;
+ limit = zone->limit;
+ }
+ break;
+
+ case cff_op_return:
+ FT_TRACE4(( " return (leaving level %d)\n",
+ decoder->zone - decoder->zones ));
+
+ if ( decoder->zone <= decoder->zones )
+ {
+ FT_ERROR(( "cff_decoder_parse_charstrings:"
+ " unexpected return\n" ));
+ goto Syntax_Error;
+ }
+
+ decoder->zone--;
+ zone = decoder->zone;
+ ip = zone->cursor;
+ limit = zone->limit;
+ break;
+
+ default:
+ FT_ERROR(( "Unimplemented opcode: %d", ip[-1] ));
+
+ if ( ip[-1] == 12 )
+ FT_ERROR(( " %d", ip[0] ));
+ FT_ERROR(( "\n" ));
+
+ return FT_THROW( Unimplemented_Feature );
+ }
+
+ decoder->top = args;
+
+ if ( decoder->top - stack >= CFF_MAX_OPERANDS )
+ goto Stack_Overflow;
+
+ } /* general operator processing */
+
+ } /* while ip < limit */
+
+ FT_TRACE4(( "..end..\n\n" ));
+
+ Fail:
+ return error;
+
+ MM_Error:
+ FT_TRACE4(( "cff_decoder_parse_charstrings:"
+ " invalid opcode found in top DICT charstring\n"));
+ return FT_THROW( Invalid_File_Format );
+
+ Syntax_Error:
+ FT_TRACE4(( "cff_decoder_parse_charstrings: syntax error\n" ));
+ return FT_THROW( Invalid_File_Format );
+
+ Stack_Underflow:
+ FT_TRACE4(( "cff_decoder_parse_charstrings: stack underflow\n" ));
+ return FT_THROW( Too_Few_Arguments );
+
+ Stack_Overflow:
+ FT_TRACE4(( "cff_decoder_parse_charstrings: stack overflow\n" ));
+ return FT_THROW( Stack_Overflow );
+ }
+
+#endif /* CFF_CONFIG_OPTION_OLD_ENGINE */
+
+
+ /*************************************************************************/
+ /* */
+ /* <Function> */
+ /* cff_decoder_init */
+ /* */
+ /* <Description> */
+ /* Initializes a given glyph decoder. */
+ /* */
+ /* <InOut> */
+ /* decoder :: A pointer to the glyph builder to initialize. */
+ /* */
+ /* <Input> */
+ /* face :: The current face object. */
+ /* */
+ /* size :: The current size object. */
+ /* */
+ /* slot :: The current glyph object. */
+ /* */
+ /* hinting :: Whether hinting is active. */
+ /* */
+ /* hint_mode :: The hinting mode. */
+ /* */
+ FT_LOCAL_DEF( void )
+ cff_decoder_init( CFF_Decoder* decoder,
+ TT_Face face,
+ CFF_Size size,
+ CFF_GlyphSlot slot,
+ FT_Bool hinting,
+ FT_Render_Mode hint_mode,
+ CFF_Decoder_Get_Glyph_Callback get_callback,
+ CFF_Decoder_Free_Glyph_Callback free_callback )
+ {
+ CFF_Font cff = (CFF_Font)face->extra.data;
+
+
+ /* clear everything */
+ FT_ZERO( decoder );
+
+ /* initialize builder */
+ cff_builder_init( &decoder->builder, face, size, slot, hinting );
+
+ /* initialize Type2 decoder */
+ decoder->cff = cff;
+ decoder->num_globals = cff->global_subrs_index.count;
+ decoder->globals = cff->global_subrs;
+ decoder->globals_bias = cff_compute_bias(
+ cff->top_font.font_dict.charstring_type,
+ decoder->num_globals );
+
+ decoder->hint_mode = hint_mode;
+
+ decoder->get_glyph_callback = get_callback;
+ decoder->free_glyph_callback = free_callback;
+ }
+
+
+ /* this function is used to select the subfont */
+ /* and the locals subrs array */
+ FT_LOCAL_DEF( FT_Error )
+ cff_decoder_prepare( CFF_Decoder* decoder,
+ CFF_Size size,
+ FT_UInt glyph_index )
+ {
+ CFF_Builder *builder = &decoder->builder;
+ CFF_Font cff = (CFF_Font)builder->face->extra.data;
+ CFF_SubFont sub = &cff->top_font;
+ FT_Error error = FT_Err_Ok;
+
+ FT_Service_CFFLoad cffload = (FT_Service_CFFLoad)cff->cffload;
+
+
+ /* manage CID fonts */
+ if ( cff->num_subfonts )
+ {
+ FT_Byte fd_index = cffload->fd_select_get( &cff->fd_select,
+ glyph_index );
+
+
+ if ( fd_index >= cff->num_subfonts )
+ {
+ FT_TRACE4(( "cff_decoder_prepare: invalid CID subfont index\n" ));
+ error = FT_THROW( Invalid_File_Format );
+ goto Exit;
+ }
+
+ FT_TRACE3(( " in subfont %d:\n", fd_index ));
+
+ sub = cff->subfonts[fd_index];
+
+ if ( builder->hints_funcs && size )
+ {
+ 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 */
+ builder->hints_globals = (void *)internal->subfonts[fd_index];
+ }
+ }
+
+ decoder->num_locals = sub->local_subrs_index.count;
+ decoder->locals = sub->local_subrs;
+ decoder->locals_bias = cff_compute_bias(
+ decoder->cff->top_font.font_dict.charstring_type,
+ decoder->num_locals );
+
+ decoder->glyph_width = sub->private_dict.default_width;
+ decoder->nominal_width = sub->private_dict.nominal_width;
+
+ decoder->current_subfont = sub;
+
+ Exit:
+ return error;
+ }
+
+
+/* END */
diff --git a/src/3rdparty/freetype/src/psaux/cffdecode.h b/src/3rdparty/freetype/src/psaux/cffdecode.h
new file mode 100644
index 0000000000..0d4f5fef63
--- /dev/null
+++ b/src/3rdparty/freetype/src/psaux/cffdecode.h
@@ -0,0 +1,64 @@
+/***************************************************************************/
+/* */
+/* cffdecode.h */
+/* */
+/* PostScript CFF (Type 2) decoding routines (specification). */
+/* */
+/* Copyright 2017-2018 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 CFFDECODE_H_
+#define CFFDECODE_H_
+
+
+#include <ft2build.h>
+#include FT_INTERNAL_POSTSCRIPT_AUX_H
+
+
+FT_BEGIN_HEADER
+
+ FT_LOCAL( void )
+ cff_decoder_init( CFF_Decoder* decoder,
+ TT_Face face,
+ CFF_Size size,
+ CFF_GlyphSlot slot,
+ FT_Bool hinting,
+ FT_Render_Mode hint_mode,
+ CFF_Decoder_Get_Glyph_Callback get_callback,
+ CFF_Decoder_Free_Glyph_Callback free_callback );
+
+ FT_LOCAL( FT_Error )
+ cff_decoder_prepare( CFF_Decoder* decoder,
+ CFF_Size size,
+ FT_UInt glyph_index );
+
+
+ FT_LOCAL( FT_Int )
+ cff_lookup_glyph_by_stdcharcode( CFF_Font cff,
+ FT_Int charcode );
+
+
+#ifdef CFF_CONFIG_OPTION_OLD_ENGINE
+ FT_LOCAL( FT_Error )
+ cff_decoder_parse_charstrings( CFF_Decoder* decoder,
+ FT_Byte* charstring_base,
+ FT_ULong charstring_len,
+ FT_Bool in_dict );
+#endif
+
+
+FT_END_HEADER
+
+#endif
+
+
+/* END */
diff --git a/src/3rdparty/freetype/src/psaux/module.mk b/src/3rdparty/freetype/src/psaux/module.mk
index 1d90e14ce4..6584d075a2 100644
--- a/src/3rdparty/freetype/src/psaux/module.mk
+++ b/src/3rdparty/freetype/src/psaux/module.mk
@@ -3,7 +3,7 @@
#
-# Copyright 1996-2015 by
+# Copyright 1996-2018 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/src/3rdparty/freetype/src/psaux/psarrst.c b/src/3rdparty/freetype/src/psaux/psarrst.c
new file mode 100644
index 0000000000..a8780947f9
--- /dev/null
+++ b/src/3rdparty/freetype/src/psaux/psarrst.c
@@ -0,0 +1,241 @@
+/***************************************************************************/
+/* */
+/* psarrst.c */
+/* */
+/* Adobe's code for Array Stacks (body). */
+/* */
+/* Copyright 2007-2013 Adobe Systems Incorporated. */
+/* */
+/* This software, and all works of authorship, whether in source or */
+/* object code form as indicated by the copyright notice(s) included */
+/* herein (collectively, the "Work") is made available, and may only be */
+/* used, modified, and distributed under the FreeType Project License, */
+/* LICENSE.TXT. Additionally, subject to the terms and conditions of the */
+/* FreeType Project License, each contributor to the Work hereby grants */
+/* to any individual or legal entity exercising permissions granted by */
+/* the FreeType Project License and this section (hereafter, "You" or */
+/* "Your") a perpetual, worldwide, non-exclusive, no-charge, */
+/* royalty-free, irrevocable (except as stated in this section) patent */
+/* license to make, have made, use, offer to sell, sell, import, and */
+/* otherwise transfer the Work, where such license applies only to those */
+/* patent claims licensable by such contributor that are necessarily */
+/* infringed by their contribution(s) alone or by combination of their */
+/* contribution(s) with the Work to which such contribution(s) was */
+/* submitted. If You institute patent litigation against any entity */
+/* (including a cross-claim or counterclaim in a lawsuit) alleging that */
+/* the Work or a contribution incorporated within the Work constitutes */
+/* direct or contributory patent infringement, then any patent licenses */
+/* granted to You under this License for that Work shall terminate as of */
+/* the date such litigation is filed. */
+/* */
+/* By using, modifying, or distributing the Work you indicate that you */
+/* have read and understood the terms and conditions of the */
+/* FreeType Project License as well as those provided in this section, */
+/* and you accept them fully. */
+/* */
+/***************************************************************************/
+
+
+#include "psft.h"
+#include FT_INTERNAL_DEBUG_H
+
+#include "psglue.h"
+#include "psarrst.h"
+
+#include "pserror.h"
+
+
+ /*
+ * CF2_ArrStack uses an error pointer, to enable shared errors.
+ * Shared errors are necessary when multiple objects allow the program
+ * to continue after detecting errors. Only the first error should be
+ * recorded.
+ */
+
+ FT_LOCAL_DEF( void )
+ cf2_arrstack_init( CF2_ArrStack arrstack,
+ FT_Memory memory,
+ FT_Error* error,
+ size_t sizeItem )
+ {
+ FT_ASSERT( arrstack );
+
+ /* initialize the structure */
+ arrstack->memory = memory;
+ arrstack->error = error;
+ arrstack->sizeItem = sizeItem;
+ arrstack->allocated = 0;
+ arrstack->chunk = 10; /* chunks of 10 items */
+ arrstack->count = 0;
+ arrstack->totalSize = 0;
+ arrstack->ptr = NULL;
+ }
+
+
+ FT_LOCAL_DEF( void )
+ cf2_arrstack_finalize( CF2_ArrStack arrstack )
+ {
+ FT_Memory memory = arrstack->memory; /* for FT_FREE */
+
+
+ FT_ASSERT( arrstack );
+
+ arrstack->allocated = 0;
+ arrstack->count = 0;
+ arrstack->totalSize = 0;
+
+ /* free the data buffer */
+ FT_FREE( arrstack->ptr );
+ }
+
+
+ /* allocate or reallocate the buffer size; */
+ /* return false on memory error */
+ static FT_Bool
+ cf2_arrstack_setNumElements( CF2_ArrStack arrstack,
+ size_t numElements )
+ {
+ FT_ASSERT( arrstack );
+
+ {
+ FT_Error error = FT_Err_Ok; /* for FT_REALLOC */
+ FT_Memory memory = arrstack->memory; /* for FT_REALLOC */
+
+ size_t newSize = numElements * arrstack->sizeItem;
+
+
+ if ( numElements > FT_LONG_MAX / arrstack->sizeItem )
+ goto exit;
+
+
+ FT_ASSERT( newSize > 0 ); /* avoid realloc with zero size */
+
+ if ( !FT_REALLOC( arrstack->ptr, arrstack->totalSize, newSize ) )
+ {
+ arrstack->allocated = numElements;
+ arrstack->totalSize = newSize;
+
+ if ( arrstack->count > numElements )
+ {
+ /* we truncated the list! */
+ CF2_SET_ERROR( arrstack->error, Stack_Overflow );
+ arrstack->count = numElements;
+ return FALSE;
+ }
+
+ return TRUE; /* success */
+ }
+ }
+
+ exit:
+ /* if there's not already an error, store this one */
+ CF2_SET_ERROR( arrstack->error, Out_Of_Memory );
+
+ return FALSE;
+ }
+
+
+ /* set the count, ensuring allocation is sufficient */
+ FT_LOCAL_DEF( void )
+ cf2_arrstack_setCount( CF2_ArrStack arrstack,
+ size_t numElements )
+ {
+ FT_ASSERT( arrstack );
+
+ if ( numElements > arrstack->allocated )
+ {
+ /* expand the allocation first */
+ if ( !cf2_arrstack_setNumElements( arrstack, numElements ) )
+ return;
+ }
+
+ arrstack->count = numElements;
+ }
+
+
+ /* clear the count */
+ FT_LOCAL_DEF( void )
+ cf2_arrstack_clear( CF2_ArrStack arrstack )
+ {
+ FT_ASSERT( arrstack );
+
+ arrstack->count = 0;
+ }
+
+
+ /* current number of items */
+ FT_LOCAL_DEF( size_t )
+ cf2_arrstack_size( const CF2_ArrStack arrstack )
+ {
+ FT_ASSERT( arrstack );
+
+ return arrstack->count;
+ }
+
+
+ FT_LOCAL_DEF( void* )
+ cf2_arrstack_getBuffer( const CF2_ArrStack arrstack )
+ {
+ FT_ASSERT( arrstack );
+
+ return arrstack->ptr;
+ }
+
+
+ /* return pointer to the given element */
+ FT_LOCAL_DEF( void* )
+ cf2_arrstack_getPointer( const CF2_ArrStack arrstack,
+ size_t idx )
+ {
+ void* newPtr;
+
+
+ FT_ASSERT( arrstack );
+
+ if ( idx >= arrstack->count )
+ {
+ /* overflow */
+ CF2_SET_ERROR( arrstack->error, Stack_Overflow );
+ idx = 0; /* choose safe default */
+ }
+
+ newPtr = (FT_Byte*)arrstack->ptr + idx * arrstack->sizeItem;
+
+ return newPtr;
+ }
+
+
+ /* push (append) an element at the end of the list; */
+ /* return false on memory error */
+ /* TODO: should there be a length param for extra checking? */
+ FT_LOCAL_DEF( void )
+ cf2_arrstack_push( CF2_ArrStack arrstack,
+ const void* ptr )
+ {
+ FT_ASSERT( arrstack );
+
+ if ( arrstack->count == arrstack->allocated )
+ {
+ /* grow the buffer by one chunk */
+ if ( !cf2_arrstack_setNumElements(
+ arrstack, arrstack->allocated + arrstack->chunk ) )
+ {
+ /* on error, ignore the push */
+ return;
+ }
+ }
+
+ FT_ASSERT( ptr );
+
+ {
+ size_t offset = arrstack->count * arrstack->sizeItem;
+ void* newPtr = (FT_Byte*)arrstack->ptr + offset;
+
+
+ FT_MEM_COPY( newPtr, ptr, arrstack->sizeItem );
+ arrstack->count += 1;
+ }
+ }
+
+
+/* END */
diff --git a/src/3rdparty/freetype/src/psaux/psarrst.h b/src/3rdparty/freetype/src/psaux/psarrst.h
new file mode 100644
index 0000000000..b3568eb61f
--- /dev/null
+++ b/src/3rdparty/freetype/src/psaux/psarrst.h
@@ -0,0 +1,100 @@
+/***************************************************************************/
+/* */
+/* psarrst.h */
+/* */
+/* Adobe's code for Array Stacks (specification). */
+/* */
+/* Copyright 2007-2013 Adobe Systems Incorporated. */
+/* */
+/* This software, and all works of authorship, whether in source or */
+/* object code form as indicated by the copyright notice(s) included */
+/* herein (collectively, the "Work") is made available, and may only be */
+/* used, modified, and distributed under the FreeType Project License, */
+/* LICENSE.TXT. Additionally, subject to the terms and conditions of the */
+/* FreeType Project License, each contributor to the Work hereby grants */
+/* to any individual or legal entity exercising permissions granted by */
+/* the FreeType Project License and this section (hereafter, "You" or */
+/* "Your") a perpetual, worldwide, non-exclusive, no-charge, */
+/* royalty-free, irrevocable (except as stated in this section) patent */
+/* license to make, have made, use, offer to sell, sell, import, and */
+/* otherwise transfer the Work, where such license applies only to those */
+/* patent claims licensable by such contributor that are necessarily */
+/* infringed by their contribution(s) alone or by combination of their */
+/* contribution(s) with the Work to which such contribution(s) was */
+/* submitted. If You institute patent litigation against any entity */
+/* (including a cross-claim or counterclaim in a lawsuit) alleging that */
+/* the Work or a contribution incorporated within the Work constitutes */
+/* direct or contributory patent infringement, then any patent licenses */
+/* granted to You under this License for that Work shall terminate as of */
+/* the date such litigation is filed. */
+/* */
+/* By using, modifying, or distributing the Work you indicate that you */
+/* have read and understood the terms and conditions of the */
+/* FreeType Project License as well as those provided in this section, */
+/* and you accept them fully. */
+/* */
+/***************************************************************************/
+
+
+#ifndef PSARRST_H_
+#define PSARRST_H_
+
+
+#include "pserror.h"
+
+
+FT_BEGIN_HEADER
+
+
+ /* need to define the struct here (not opaque) so it can be allocated by */
+ /* clients */
+ typedef struct CF2_ArrStackRec_
+ {
+ FT_Memory memory;
+ FT_Error* error;
+
+ size_t sizeItem; /* bytes per element */
+ size_t allocated; /* items allocated */
+ size_t chunk; /* allocation increment in items */
+ size_t count; /* number of elements allocated */
+ size_t totalSize; /* total bytes allocated */
+
+ void* ptr; /* ptr to data */
+
+ } CF2_ArrStackRec, *CF2_ArrStack;
+
+
+ FT_LOCAL( void )
+ cf2_arrstack_init( CF2_ArrStack arrstack,
+ FT_Memory memory,
+ FT_Error* error,
+ size_t sizeItem );
+ FT_LOCAL( void )
+ cf2_arrstack_finalize( CF2_ArrStack arrstack );
+
+ FT_LOCAL( void )
+ cf2_arrstack_setCount( CF2_ArrStack arrstack,
+ size_t numElements );
+ FT_LOCAL( void )
+ cf2_arrstack_clear( CF2_ArrStack arrstack );
+ FT_LOCAL( size_t )
+ cf2_arrstack_size( const CF2_ArrStack arrstack );
+
+ FT_LOCAL( void* )
+ cf2_arrstack_getBuffer( const CF2_ArrStack arrstack );
+ FT_LOCAL( void* )
+ cf2_arrstack_getPointer( const CF2_ArrStack arrstack,
+ size_t idx );
+
+ FT_LOCAL( void )
+ cf2_arrstack_push( CF2_ArrStack arrstack,
+ const void* ptr );
+
+
+FT_END_HEADER
+
+
+#endif /* PSARRST_H_ */
+
+
+/* END */
diff --git a/src/3rdparty/freetype/src/psaux/psaux.c b/src/3rdparty/freetype/src/psaux/psaux.c
index 7f1d9aa595..fb447fcdbb 100644
--- a/src/3rdparty/freetype/src/psaux/psaux.c
+++ b/src/3rdparty/freetype/src/psaux/psaux.c
@@ -4,7 +4,7 @@
/* */
/* FreeType auxiliary PostScript driver component (body only). */
/* */
-/* Copyright 1996-2015 by */
+/* Copyright 1996-2018 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -17,18 +17,25 @@
#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"
+#include "cffdecode.c"
+
+#include "psarrst.c"
+#include "psblues.c"
+#include "pserror.c"
+#include "psfont.c"
+#include "psft.c"
+#include "pshints.c"
+#include "psintrp.c"
+#include "psread.c"
+#include "psstack.c"
/* END */
diff --git a/src/3rdparty/freetype/src/psaux/psauxerr.h b/src/3rdparty/freetype/src/psaux/psauxerr.h
index 97712f0795..cc33fd2eea 100644
--- a/src/3rdparty/freetype/src/psaux/psauxerr.h
+++ b/src/3rdparty/freetype/src/psaux/psauxerr.h
@@ -4,7 +4,7 @@
/* */
/* PS auxiliary module error codes (specification only). */
/* */
-/* Copyright 2001-2015 by */
+/* Copyright 2001-2018 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -23,12 +23,12 @@
/* */
/*************************************************************************/
-#ifndef __PSAUXERR_H__
-#define __PSAUXERR_H__
+#ifndef PSAUXERR_H_
+#define PSAUXERR_H_
#include FT_MODULE_ERRORS_H
-#undef __FTERRORS_H__
+#undef FTERRORS_H_
#undef FT_ERR_PREFIX
#define FT_ERR_PREFIX PSaux_Err_
@@ -36,7 +36,7 @@
#include FT_ERRORS_H
-#endif /* __PSAUXERR_H__ */
+#endif /* PSAUXERR_H_ */
/* END */
diff --git a/src/3rdparty/freetype/src/psaux/psauxmod.c b/src/3rdparty/freetype/src/psaux/psauxmod.c
index 06fcab0c4a..ee497085cc 100644
--- a/src/3rdparty/freetype/src/psaux/psauxmod.c
+++ b/src/3rdparty/freetype/src/psaux/psauxmod.c
@@ -4,7 +4,7 @@
/* */
/* FreeType auxiliary PostScript module implementation (body). */
/* */
-/* Copyright 2000-2015 by */
+/* Copyright 2000-2018 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -21,6 +21,8 @@
#include "psobjs.h"
#include "t1decode.h"
#include "t1cmap.h"
+#include "psft.h"
+#include "cffdecode.h"
#ifndef T1_CONFIG_OPTION_NO_AFM
#include "afmparse.h"
@@ -30,52 +32,69 @@
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 PS_Builder_FuncsRec ps_builder_funcs =
+ {
+ ps_builder_init, /* init */
+ ps_builder_done /* done */
};
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 */
+#ifdef T1_CONFIG_OPTION_OLD_ENGINE
+ t1_decoder_parse_charstrings, /* parse_charstrings_old */
+#else
+ t1_decoder_parse_metrics, /* parse_metrics */
+#endif
+ cf2_decoder_parse_charstrings /* parse_charstrings */
};
@@ -83,9 +102,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
@@ -100,6 +119,34 @@
};
+ FT_CALLBACK_TABLE_DEF
+ const CFF_Builder_FuncsRec cff_builder_funcs =
+ {
+ cff_builder_init, /* init */
+ cff_builder_done, /* done */
+
+ cff_check_points, /* check_points */
+ cff_builder_add_point, /* add_point */
+ cff_builder_add_point1, /* add_point1 */
+ cff_builder_add_contour, /* add_contour */
+ cff_builder_start_point, /* start_point */
+ cff_builder_close_contour /* close_contour */
+ };
+
+
+ FT_CALLBACK_TABLE_DEF
+ const CFF_Decoder_FuncsRec cff_decoder_funcs =
+ {
+ cff_decoder_init, /* init */
+ cff_decoder_prepare, /* prepare */
+
+#ifdef CFF_CONFIG_OPTION_OLD_ENGINE
+ cff_decoder_parse_charstrings, /* parse_charstrings_old */
+#endif
+ cf2_decoder_parse_charstrings /* parse_charstrings */
+ };
+
+
static
const PSAux_Interface psaux_interface =
{
@@ -108,6 +155,9 @@
&t1_builder_funcs,
&t1_decoder_funcs,
t1_decrypt,
+ cff_random,
+ ps_decoder_init,
+ t1_make_subfont,
(const T1_CMap_ClassesRec*) &t1_cmap_classes,
@@ -116,6 +166,8 @@
#else
0,
#endif
+
+ &cff_decoder_funcs,
};
@@ -130,9 +182,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/src/3rdparty/freetype/src/psaux/psauxmod.h b/src/3rdparty/freetype/src/psaux/psauxmod.h
index ae6a8f9383..f30978f022 100644
--- a/src/3rdparty/freetype/src/psaux/psauxmod.h
+++ b/src/3rdparty/freetype/src/psaux/psauxmod.h
@@ -4,7 +4,7 @@
/* */
/* FreeType auxiliary PostScript module implementation (specification). */
/* */
-/* Copyright 2000-2015 by */
+/* Copyright 2000-2018 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -16,13 +16,15 @@
/***************************************************************************/
-#ifndef __PSAUXMOD_H__
-#define __PSAUXMOD_H__
+#ifndef PSAUXMOD_H_
+#define PSAUXMOD_H_
#include <ft2build.h>
#include FT_MODULE_H
+#include FT_INTERNAL_POSTSCRIPT_AUX_H
+
FT_BEGIN_HEADER
@@ -31,12 +33,19 @@ FT_BEGIN_HEADER
#endif
+ FT_CALLBACK_TABLE
+ const CFF_Builder_FuncsRec cff_builder_funcs;
+
+ FT_CALLBACK_TABLE
+ const PS_Builder_FuncsRec ps_builder_funcs;
+
+
FT_EXPORT_VAR( const FT_Module_Class ) psaux_driver_class;
FT_END_HEADER
-#endif /* __PSAUXMOD_H__ */
+#endif /* PSAUXMOD_H_ */
/* END */
diff --git a/src/3rdparty/freetype/src/psaux/psblues.c b/src/3rdparty/freetype/src/psaux/psblues.c
new file mode 100644
index 0000000000..ae39d03c77
--- /dev/null
+++ b/src/3rdparty/freetype/src/psaux/psblues.c
@@ -0,0 +1,582 @@
+/***************************************************************************/
+/* */
+/* psblues.c */
+/* */
+/* Adobe's code for handling Blue Zones (body). */
+/* */
+/* Copyright 2009-2014 Adobe Systems Incorporated. */
+/* */
+/* This software, and all works of authorship, whether in source or */
+/* object code form as indicated by the copyright notice(s) included */
+/* herein (collectively, the "Work") is made available, and may only be */
+/* used, modified, and distributed under the FreeType Project License, */
+/* LICENSE.TXT. Additionally, subject to the terms and conditions of the */
+/* FreeType Project License, each contributor to the Work hereby grants */
+/* to any individual or legal entity exercising permissions granted by */
+/* the FreeType Project License and this section (hereafter, "You" or */
+/* "Your") a perpetual, worldwide, non-exclusive, no-charge, */
+/* royalty-free, irrevocable (except as stated in this section) patent */
+/* license to make, have made, use, offer to sell, sell, import, and */
+/* otherwise transfer the Work, where such license applies only to those */
+/* patent claims licensable by such contributor that are necessarily */
+/* infringed by their contribution(s) alone or by combination of their */
+/* contribution(s) with the Work to which such contribution(s) was */
+/* submitted. If You institute patent litigation against any entity */
+/* (including a cross-claim or counterclaim in a lawsuit) alleging that */
+/* the Work or a contribution incorporated within the Work constitutes */
+/* direct or contributory patent infringement, then any patent licenses */
+/* granted to You under this License for that Work shall terminate as of */
+/* the date such litigation is filed. */
+/* */
+/* By using, modifying, or distributing the Work you indicate that you */
+/* have read and understood the terms and conditions of the */
+/* FreeType Project License as well as those provided in this section, */
+/* and you accept them fully. */
+/* */
+/***************************************************************************/
+
+
+#include "psft.h"
+#include FT_INTERNAL_DEBUG_H
+
+#include "psblues.h"
+#include "pshints.h"
+#include "psfont.h"
+
+
+ /*************************************************************************/
+ /* */
+ /* The macro FT_COMPONENT is used in trace mode. It is an implicit */
+ /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */
+ /* messages during execution. */
+ /* */
+#undef FT_COMPONENT
+#define FT_COMPONENT trace_cf2blues
+
+
+ /*
+ * For blue values, the FreeType parser produces an array of integers,
+ * while the Adobe CFF engine produces an array of fixed.
+ * Define a macro to convert FreeType to fixed.
+ */
+#define cf2_blueToFixed( x ) cf2_intToFixed( x )
+
+
+ FT_LOCAL_DEF( void )
+ cf2_blues_init( CF2_Blues blues,
+ CF2_Font font )
+ {
+ /* pointer to parsed font object */
+ PS_Decoder* decoder = font->decoder;
+
+ CF2_Fixed zoneHeight;
+ CF2_Fixed maxZoneHeight = 0;
+ CF2_Fixed csUnitsPerPixel;
+
+ size_t numBlueValues;
+ size_t numOtherBlues;
+ size_t numFamilyBlues;
+ size_t numFamilyOtherBlues;
+
+ FT_Pos* blueValues;
+ FT_Pos* otherBlues;
+ FT_Pos* familyBlues;
+ FT_Pos* familyOtherBlues;
+
+ size_t i;
+ CF2_Fixed emBoxBottom, emBoxTop;
+
+#if 0
+ CF2_Int unitsPerEm = font->unitsPerEm;
+
+
+ if ( unitsPerEm == 0 )
+ unitsPerEm = 1000;
+#endif
+
+ FT_ZERO( blues );
+ blues->scale = font->innerTransform.d;
+
+ cf2_getBlueMetrics( decoder,
+ &blues->blueScale,
+ &blues->blueShift,
+ &blues->blueFuzz );
+
+ cf2_getBlueValues( decoder, &numBlueValues, &blueValues );
+ cf2_getOtherBlues( decoder, &numOtherBlues, &otherBlues );
+ cf2_getFamilyBlues( decoder, &numFamilyBlues, &familyBlues );
+ cf2_getFamilyOtherBlues( decoder, &numFamilyOtherBlues, &familyOtherBlues );
+
+ /*
+ * synthetic em box hint heuristic
+ *
+ * Apply this when ideographic dictionary (LanguageGroup 1) has no
+ * real alignment zones. Adobe tools generate dummy zones at -250 and
+ * 1100 for a 1000 unit em. Fonts with ICF-based alignment zones
+ * should not enable the heuristic. When the heuristic is enabled,
+ * the font's blue zones are ignored.
+ *
+ */
+
+ /* get em box from OS/2 typoAscender/Descender */
+ /* TODO: FreeType does not parse these metrics. Skip them for now. */
+#if 0
+ FCM_getHorizontalLineMetrics( &e,
+ font->font,
+ &ascender,
+ &descender,
+ &linegap );
+ if ( ascender - descender == unitsPerEm )
+ {
+ emBoxBottom = cf2_intToFixed( descender );
+ emBoxTop = cf2_intToFixed( ascender );
+ }
+ else
+#endif
+ {
+ emBoxBottom = CF2_ICF_Bottom;
+ emBoxTop = CF2_ICF_Top;
+ }
+
+ if ( cf2_getLanguageGroup( decoder ) == 1 &&
+ ( numBlueValues == 0 ||
+ ( numBlueValues == 4 &&
+ cf2_blueToFixed( blueValues[0] ) < emBoxBottom &&
+ cf2_blueToFixed( blueValues[1] ) < emBoxBottom &&
+ cf2_blueToFixed( blueValues[2] ) > emBoxTop &&
+ cf2_blueToFixed( blueValues[3] ) > emBoxTop ) ) )
+ {
+ /*
+ * Construct hint edges suitable for synthetic ghost hints at top
+ * and bottom of em box. +-CF2_MIN_COUNTER allows for unhinted
+ * features above or below the last hinted edge. This also gives a
+ * net 1 pixel boost to the height of ideographic glyphs.
+ *
+ * Note: Adjust synthetic hints outward by epsilon (0x.0001) to
+ * avoid interference. E.g., some fonts have real hints at
+ * 880 and -120.
+ */
+
+ blues->emBoxBottomEdge.csCoord = emBoxBottom - CF2_FIXED_EPSILON;
+ blues->emBoxBottomEdge.dsCoord = cf2_fixedRound(
+ FT_MulFix(
+ blues->emBoxBottomEdge.csCoord,
+ blues->scale ) ) -
+ CF2_MIN_COUNTER;
+ blues->emBoxBottomEdge.scale = blues->scale;
+ blues->emBoxBottomEdge.flags = CF2_GhostBottom |
+ CF2_Locked |
+ CF2_Synthetic;
+
+ blues->emBoxTopEdge.csCoord = emBoxTop + CF2_FIXED_EPSILON +
+ 2 * font->darkenY;
+ blues->emBoxTopEdge.dsCoord = cf2_fixedRound(
+ FT_MulFix(
+ blues->emBoxTopEdge.csCoord,
+ blues->scale ) ) +
+ CF2_MIN_COUNTER;
+ blues->emBoxTopEdge.scale = blues->scale;
+ blues->emBoxTopEdge.flags = CF2_GhostTop |
+ CF2_Locked |
+ CF2_Synthetic;
+
+ blues->doEmBoxHints = TRUE; /* enable the heuristic */
+
+ return;
+ }
+
+ /* copy `BlueValues' and `OtherBlues' to a combined array of top and */
+ /* bottom zones */
+ for ( i = 0; i < numBlueValues; i += 2 )
+ {
+ blues->zone[blues->count].csBottomEdge =
+ cf2_blueToFixed( blueValues[i] );
+ blues->zone[blues->count].csTopEdge =
+ cf2_blueToFixed( blueValues[i + 1] );
+
+ zoneHeight = SUB_INT32( blues->zone[blues->count].csTopEdge,
+ blues->zone[blues->count].csBottomEdge );
+
+ if ( zoneHeight < 0 )
+ {
+ FT_TRACE4(( "cf2_blues_init: ignoring negative zone height\n" ));
+ continue; /* reject this zone */
+ }
+
+ if ( zoneHeight > maxZoneHeight )
+ {
+ /* take maximum before darkening adjustment */
+ /* so overshoot suppression point doesn't change */
+ maxZoneHeight = zoneHeight;
+ }
+
+ /* adjust both edges of top zone upward by twice darkening amount */
+ if ( i != 0 )
+ {
+ blues->zone[blues->count].csTopEdge += 2 * font->darkenY;
+ blues->zone[blues->count].csBottomEdge += 2 * font->darkenY;
+ }
+
+ /* first `BlueValue' is bottom zone; others are top */
+ if ( i == 0 )
+ {
+ blues->zone[blues->count].bottomZone =
+ TRUE;
+ blues->zone[blues->count].csFlatEdge =
+ blues->zone[blues->count].csTopEdge;
+ }
+ else
+ {
+ blues->zone[blues->count].bottomZone =
+ FALSE;
+ blues->zone[blues->count].csFlatEdge =
+ blues->zone[blues->count].csBottomEdge;
+ }
+
+ blues->count += 1;
+ }
+
+ for ( i = 0; i < numOtherBlues; i += 2 )
+ {
+ blues->zone[blues->count].csBottomEdge =
+ cf2_blueToFixed( otherBlues[i] );
+ blues->zone[blues->count].csTopEdge =
+ cf2_blueToFixed( otherBlues[i + 1] );
+
+ zoneHeight = SUB_INT32( blues->zone[blues->count].csTopEdge,
+ blues->zone[blues->count].csBottomEdge );
+
+ if ( zoneHeight < 0 )
+ {
+ FT_TRACE4(( "cf2_blues_init: ignoring negative zone height\n" ));
+ continue; /* reject this zone */
+ }
+
+ if ( zoneHeight > maxZoneHeight )
+ {
+ /* take maximum before darkening adjustment */
+ /* so overshoot suppression point doesn't change */
+ maxZoneHeight = zoneHeight;
+ }
+
+ /* Note: bottom zones are not adjusted for darkening amount */
+
+ /* all OtherBlues are bottom zone */
+ blues->zone[blues->count].bottomZone =
+ TRUE;
+ blues->zone[blues->count].csFlatEdge =
+ blues->zone[blues->count].csTopEdge;
+
+ blues->count += 1;
+ }
+
+ /* Adjust for FamilyBlues */
+
+ /* Search for the nearest flat edge in `FamilyBlues' or */
+ /* `FamilyOtherBlues'. According to the Black Book, any matching edge */
+ /* must be within one device pixel */
+
+ csUnitsPerPixel = FT_DivFix( cf2_intToFixed( 1 ), blues->scale );
+
+ /* loop on all zones in this font */
+ for ( i = 0; i < blues->count; i++ )
+ {
+ size_t j;
+ CF2_Fixed minDiff;
+ CF2_Fixed flatFamilyEdge, diff;
+ /* value for this font */
+ CF2_Fixed flatEdge = blues->zone[i].csFlatEdge;
+
+
+ if ( blues->zone[i].bottomZone )
+ {
+ /* In a bottom zone, the top edge is the flat edge. */
+ /* Search `FamilyOtherBlues' for bottom zones; look for closest */
+ /* Family edge that is within the one pixel threshold. */
+
+ minDiff = CF2_FIXED_MAX;
+
+ for ( j = 0; j < numFamilyOtherBlues; j += 2 )
+ {
+ /* top edge */
+ flatFamilyEdge = cf2_blueToFixed( familyOtherBlues[j + 1] );
+
+ diff = cf2_fixedAbs( SUB_INT32( flatEdge, flatFamilyEdge ) );
+
+ if ( diff < minDiff && diff < csUnitsPerPixel )
+ {
+ blues->zone[i].csFlatEdge = flatFamilyEdge;
+ minDiff = diff;
+
+ if ( diff == 0 )
+ break;
+ }
+ }
+
+ /* check the first member of FamilyBlues, which is a bottom zone */
+ if ( numFamilyBlues >= 2 )
+ {
+ /* top edge */
+ flatFamilyEdge = cf2_blueToFixed( familyBlues[1] );
+
+ diff = cf2_fixedAbs( SUB_INT32( flatEdge, flatFamilyEdge ) );
+
+ if ( diff < minDiff && diff < csUnitsPerPixel )
+ blues->zone[i].csFlatEdge = flatFamilyEdge;
+ }
+ }
+ else
+ {
+ /* In a top zone, the bottom edge is the flat edge. */
+ /* Search `FamilyBlues' for top zones; skip first zone, which is a */
+ /* bottom zone; look for closest Family edge that is within the */
+ /* one pixel threshold */
+
+ minDiff = CF2_FIXED_MAX;
+
+ for ( j = 2; j < numFamilyBlues; j += 2 )
+ {
+ /* bottom edge */
+ flatFamilyEdge = cf2_blueToFixed( familyBlues[j] );
+
+ /* adjust edges of top zone upward by twice darkening amount */
+ flatFamilyEdge += 2 * font->darkenY; /* bottom edge */
+
+ diff = cf2_fixedAbs( SUB_INT32( flatEdge, flatFamilyEdge ) );
+
+ if ( diff < minDiff && diff < csUnitsPerPixel )
+ {
+ blues->zone[i].csFlatEdge = flatFamilyEdge;
+ minDiff = diff;
+
+ if ( diff == 0 )
+ break;
+ }
+ }
+ }
+ }
+
+ /* TODO: enforce separation of zones, including BlueFuzz */
+
+ /* Adjust BlueScale; similar to AdjustBlueScale() in coretype */
+ /* `bcsetup.c'. */
+
+ if ( maxZoneHeight > 0 )
+ {
+ if ( blues->blueScale > FT_DivFix( cf2_intToFixed( 1 ),
+ maxZoneHeight ) )
+ {
+ /* clamp at maximum scale */
+ blues->blueScale = FT_DivFix( cf2_intToFixed( 1 ),
+ maxZoneHeight );
+ }
+
+ /*
+ * TODO: Revisit the bug fix for 613448. The minimum scale
+ * requirement catches a number of library fonts. For
+ * example, with default BlueScale (.039625) and 0.4 minimum,
+ * the test below catches any font with maxZoneHeight < 10.1.
+ * There are library fonts ranging from 2 to 10 that get
+ * caught, including e.g., Eurostile LT Std Medium with
+ * maxZoneHeight of 6.
+ *
+ */
+#if 0
+ if ( blueScale < .4 / maxZoneHeight )
+ {
+ tetraphilia_assert( 0 );
+ /* clamp at minimum scale, per bug 0613448 fix */
+ blueScale = .4 / maxZoneHeight;
+ }
+#endif
+
+ }
+
+ /*
+ * Suppress overshoot and boost blue zones at small sizes. Boost
+ * amount varies linearly from 0.5 pixel near 0 to 0 pixel at
+ * blueScale cutoff.
+ * Note: This boost amount is different from the coretype heuristic.
+ *
+ */
+
+ if ( blues->scale < blues->blueScale )
+ {
+ blues->suppressOvershoot = TRUE;
+
+ /* Change rounding threshold for `dsFlatEdge'. */
+ /* Note: constant changed from 0.5 to 0.6 to avoid a problem with */
+ /* 10ppem Arial */
+
+ blues->boost = cf2_doubleToFixed( .6 ) -
+ FT_MulDiv( cf2_doubleToFixed ( .6 ),
+ blues->scale,
+ blues->blueScale );
+ if ( blues->boost > 0x7FFF )
+ {
+ /* boost must remain less than 0.5, or baseline could go negative */
+ blues->boost = 0x7FFF;
+ }
+ }
+
+ /* boost and darkening have similar effects; don't do both */
+ if ( font->stemDarkened )
+ blues->boost = 0;
+
+ /* set device space alignment for each zone; */
+ /* apply boost amount before rounding flat edge */
+
+ for ( i = 0; i < blues->count; i++ )
+ {
+ if ( blues->zone[i].bottomZone )
+ blues->zone[i].dsFlatEdge = cf2_fixedRound(
+ FT_MulFix(
+ blues->zone[i].csFlatEdge,
+ blues->scale ) -
+ blues->boost );
+ else
+ blues->zone[i].dsFlatEdge = cf2_fixedRound(
+ FT_MulFix(
+ blues->zone[i].csFlatEdge,
+ blues->scale ) +
+ blues->boost );
+ }
+ }
+
+
+ /*
+ * Check whether `stemHint' is captured by one of the blue zones.
+ *
+ * Zero, one or both edges may be valid; only valid edges can be
+ * captured. For compatibility with CoolType, search top and bottom
+ * zones in the same pass (see `BlueLock'). If a hint is captured,
+ * return true and position the edge(s) in one of 3 ways:
+ *
+ * 1) If `BlueScale' suppresses overshoot, position the captured edge
+ * at the flat edge of the zone.
+ * 2) If overshoot is not suppressed and `BlueShift' requires
+ * overshoot, position the captured edge a minimum of 1 device pixel
+ * from the flat edge.
+ * 3) If overshoot is not suppressed or required, position the captured
+ * edge at the nearest device pixel.
+ *
+ */
+ FT_LOCAL_DEF( FT_Bool )
+ cf2_blues_capture( const CF2_Blues blues,
+ CF2_Hint bottomHintEdge,
+ CF2_Hint topHintEdge )
+ {
+ /* TODO: validate? */
+ CF2_Fixed csFuzz = blues->blueFuzz;
+
+ /* new position of captured edge */
+ CF2_Fixed dsNew;
+
+ /* amount that hint is moved when positioned */
+ CF2_Fixed dsMove = 0;
+
+ FT_Bool captured = FALSE;
+ CF2_UInt i;
+
+
+ /* assert edge flags are consistent */
+ FT_ASSERT( !cf2_hint_isTop( bottomHintEdge ) &&
+ !cf2_hint_isBottom( topHintEdge ) );
+
+ /* TODO: search once without blue fuzz for compatibility with coretype? */
+ for ( i = 0; i < blues->count; i++ )
+ {
+ if ( blues->zone[i].bottomZone &&
+ cf2_hint_isBottom( bottomHintEdge ) )
+ {
+ if ( SUB_INT32( blues->zone[i].csBottomEdge, csFuzz ) <=
+ bottomHintEdge->csCoord &&
+ bottomHintEdge->csCoord <=
+ ADD_INT32( blues->zone[i].csTopEdge, csFuzz ) )
+ {
+ /* bottom edge captured by bottom zone */
+
+ if ( blues->suppressOvershoot )
+ dsNew = blues->zone[i].dsFlatEdge;
+
+ else if ( SUB_INT32( blues->zone[i].csTopEdge,
+ bottomHintEdge->csCoord ) >=
+ blues->blueShift )
+ {
+ /* guarantee minimum of 1 pixel overshoot */
+ dsNew = FT_MIN(
+ cf2_fixedRound( bottomHintEdge->dsCoord ),
+ blues->zone[i].dsFlatEdge - cf2_intToFixed( 1 ) );
+ }
+
+ else
+ {
+ /* simply round captured edge */
+ dsNew = cf2_fixedRound( bottomHintEdge->dsCoord );
+ }
+
+ dsMove = SUB_INT32( dsNew, bottomHintEdge->dsCoord );
+ captured = TRUE;
+
+ break;
+ }
+ }
+
+ if ( !blues->zone[i].bottomZone && cf2_hint_isTop( topHintEdge ) )
+ {
+ if ( SUB_INT32( blues->zone[i].csBottomEdge, csFuzz ) <=
+ topHintEdge->csCoord &&
+ topHintEdge->csCoord <=
+ ADD_INT32( blues->zone[i].csTopEdge, csFuzz ) )
+ {
+ /* top edge captured by top zone */
+
+ if ( blues->suppressOvershoot )
+ dsNew = blues->zone[i].dsFlatEdge;
+
+ else if ( SUB_INT32( topHintEdge->csCoord,
+ blues->zone[i].csBottomEdge ) >=
+ blues->blueShift )
+ {
+ /* guarantee minimum of 1 pixel overshoot */
+ dsNew = FT_MAX(
+ cf2_fixedRound( topHintEdge->dsCoord ),
+ blues->zone[i].dsFlatEdge + cf2_intToFixed( 1 ) );
+ }
+
+ else
+ {
+ /* simply round captured edge */
+ dsNew = cf2_fixedRound( topHintEdge->dsCoord );
+ }
+
+ dsMove = SUB_INT32( dsNew, topHintEdge->dsCoord );
+ captured = TRUE;
+
+ break;
+ }
+ }
+ }
+
+ if ( captured )
+ {
+ /* move both edges and flag them `locked' */
+ if ( cf2_hint_isValid( bottomHintEdge ) )
+ {
+ bottomHintEdge->dsCoord = ADD_INT32( bottomHintEdge->dsCoord,
+ dsMove );
+ cf2_hint_lock( bottomHintEdge );
+ }
+
+ if ( cf2_hint_isValid( topHintEdge ) )
+ {
+ topHintEdge->dsCoord = ADD_INT32( topHintEdge->dsCoord, dsMove );
+ cf2_hint_lock( topHintEdge );
+ }
+ }
+
+ return captured;
+ }
+
+
+/* END */
diff --git a/src/3rdparty/freetype/src/psaux/psblues.h b/src/3rdparty/freetype/src/psaux/psblues.h
new file mode 100644
index 0000000000..25ef6849c7
--- /dev/null
+++ b/src/3rdparty/freetype/src/psaux/psblues.h
@@ -0,0 +1,185 @@
+/***************************************************************************/
+/* */
+/* psblues.h */
+/* */
+/* Adobe's code for handling Blue Zones (specification). */
+/* */
+/* Copyright 2009-2013 Adobe Systems Incorporated. */
+/* */
+/* This software, and all works of authorship, whether in source or */
+/* object code form as indicated by the copyright notice(s) included */
+/* herein (collectively, the "Work") is made available, and may only be */
+/* used, modified, and distributed under the FreeType Project License, */
+/* LICENSE.TXT. Additionally, subject to the terms and conditions of the */
+/* FreeType Project License, each contributor to the Work hereby grants */
+/* to any individual or legal entity exercising permissions granted by */
+/* the FreeType Project License and this section (hereafter, "You" or */
+/* "Your") a perpetual, worldwide, non-exclusive, no-charge, */
+/* royalty-free, irrevocable (except as stated in this section) patent */
+/* license to make, have made, use, offer to sell, sell, import, and */
+/* otherwise transfer the Work, where such license applies only to those */
+/* patent claims licensable by such contributor that are necessarily */
+/* infringed by their contribution(s) alone or by combination of their */
+/* contribution(s) with the Work to which such contribution(s) was */
+/* submitted. If You institute patent litigation against any entity */
+/* (including a cross-claim or counterclaim in a lawsuit) alleging that */
+/* the Work or a contribution incorporated within the Work constitutes */
+/* direct or contributory patent infringement, then any patent licenses */
+/* granted to You under this License for that Work shall terminate as of */
+/* the date such litigation is filed. */
+/* */
+/* By using, modifying, or distributing the Work you indicate that you */
+/* have read and understood the terms and conditions of the */
+/* FreeType Project License as well as those provided in this section, */
+/* and you accept them fully. */
+/* */
+/***************************************************************************/
+
+
+ /*
+ * A `CF2_Blues' object stores the blue zones (horizontal alignment
+ * zones) of a font. These are specified in the CFF private dictionary
+ * by `BlueValues', `OtherBlues', `FamilyBlues', and `FamilyOtherBlues'.
+ * Each zone is defined by a top and bottom edge in character space.
+ * Further, each zone is either a top zone or a bottom zone, as recorded
+ * by `bottomZone'.
+ *
+ * The maximum number of `BlueValues' and `FamilyBlues' is 7 each.
+ * However, these are combined to produce a total of 7 zones.
+ * Similarly, the maximum number of `OtherBlues' and `FamilyOtherBlues'
+ * is 5 and these are combined to produce an additional 5 zones.
+ *
+ * Blue zones are used to `capture' hints and force them to a common
+ * alignment point. This alignment is recorded in device space in
+ * `dsFlatEdge'. Except for this value, a `CF2_Blues' object could be
+ * constructed independently of scaling. Construction may occur once
+ * the matrix is known. Other features implemented in the Capture
+ * method are overshoot suppression, overshoot enforcement, and Blue
+ * Boost.
+ *
+ * Capture is determined by `BlueValues' and `OtherBlues', but the
+ * alignment point may be adjusted to the scaled flat edge of
+ * `FamilyBlues' or `FamilyOtherBlues'. No alignment is done to the
+ * curved edge of a zone.
+ *
+ */
+
+
+#ifndef PSBLUES_H_
+#define PSBLUES_H_
+
+
+#include "psglue.h"
+
+
+FT_BEGIN_HEADER
+
+
+ /*
+ * `CF2_Hint' is shared by `cf2hints.h' and
+ * `cf2blues.h', but `cf2blues.h' depends on
+ * `cf2hints.h', so define it here. Note: The typedef is in
+ * `cf2glue.h'.
+ *
+ */
+ enum
+ {
+ CF2_GhostBottom = 0x1, /* a single bottom edge */
+ CF2_GhostTop = 0x2, /* a single top edge */
+ CF2_PairBottom = 0x4, /* the bottom edge of a stem hint */
+ CF2_PairTop = 0x8, /* the top edge of a stem hint */
+ CF2_Locked = 0x10, /* this edge has been aligned */
+ /* by a blue zone */
+ CF2_Synthetic = 0x20 /* this edge was synthesized */
+ };
+
+
+ /*
+ * Default value for OS/2 typoAscender/Descender when their difference
+ * is not equal to `unitsPerEm'. The default is based on -250 and 1100
+ * in `CF2_Blues', assuming 1000 units per em here.
+ *
+ */
+ enum
+ {
+ CF2_ICF_Top = cf2_intToFixed( 880 ),
+ CF2_ICF_Bottom = cf2_intToFixed( -120 )
+ };
+
+
+ /*
+ * Constant used for hint adjustment and for synthetic em box hint
+ * placement.
+ */
+#define CF2_MIN_COUNTER cf2_doubleToFixed( 0.5 )
+
+
+ /* shared typedef is in cf2glue.h */
+ struct CF2_HintRec_
+ {
+ CF2_UInt flags; /* attributes of the edge */
+ size_t index; /* index in original stem hint array */
+ /* (if not synthetic) */
+ CF2_Fixed csCoord;
+ CF2_Fixed dsCoord;
+ CF2_Fixed scale;
+ };
+
+
+ typedef struct CF2_BlueRec_
+ {
+ CF2_Fixed csBottomEdge;
+ CF2_Fixed csTopEdge;
+ CF2_Fixed csFlatEdge; /* may be from either local or Family zones */
+ CF2_Fixed dsFlatEdge; /* top edge of bottom zone or bottom edge */
+ /* of top zone (rounded) */
+ FT_Bool bottomZone;
+
+ } CF2_BlueRec;
+
+
+ /* max total blue zones is 12 */
+ enum
+ {
+ CF2_MAX_BLUES = 7,
+ CF2_MAX_OTHERBLUES = 5
+ };
+
+
+ typedef struct CF2_BluesRec_
+ {
+ CF2_Fixed scale;
+ CF2_UInt count;
+ FT_Bool suppressOvershoot;
+ FT_Bool doEmBoxHints;
+
+ CF2_Fixed blueScale;
+ CF2_Fixed blueShift;
+ CF2_Fixed blueFuzz;
+
+ CF2_Fixed boost;
+
+ CF2_HintRec emBoxTopEdge;
+ CF2_HintRec emBoxBottomEdge;
+
+ CF2_BlueRec zone[CF2_MAX_BLUES + CF2_MAX_OTHERBLUES];
+
+ } CF2_BluesRec, *CF2_Blues;
+
+
+ FT_LOCAL( void )
+ cf2_blues_init( CF2_Blues blues,
+ CF2_Font font );
+ FT_LOCAL( FT_Bool )
+ cf2_blues_capture( const CF2_Blues blues,
+ CF2_Hint bottomHintEdge,
+ CF2_Hint topHintEdge );
+
+
+FT_END_HEADER
+
+
+#endif /* PSBLUES_H_ */
+
+
+/* END */
diff --git a/src/3rdparty/freetype/src/psaux/psconv.c b/src/3rdparty/freetype/src/psaux/psconv.c
index aca741204f..a03385000d 100644
--- a/src/3rdparty/freetype/src/psaux/psconv.c
+++ b/src/3rdparty/freetype/src/psaux/psconv.c
@@ -4,7 +4,7 @@
/* */
/* Some convenience conversions (body). */
/* */
-/* Copyright 2006-2015 by */
+/* Copyright 2006-2018 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -111,6 +111,10 @@
p++;
if ( p == limit )
goto Bad;
+
+ /* only a single sign is allowed */
+ if ( *p == '-' || *p == '+' )
+ return 0;
}
num_limit = 0x7FFFFFFFL / base;
@@ -215,6 +219,10 @@
p++;
if ( p == limit )
goto Bad;
+
+ /* only a single sign is allowed */
+ if ( *p == '-' || *p == '+' )
+ return 0;
}
/* read the integer part */
diff --git a/src/3rdparty/freetype/src/psaux/psconv.h b/src/3rdparty/freetype/src/psaux/psconv.h
index 10f1ff7fb1..d643ffcfc2 100644
--- a/src/3rdparty/freetype/src/psaux/psconv.h
+++ b/src/3rdparty/freetype/src/psaux/psconv.h
@@ -4,7 +4,7 @@
/* */
/* Some convenience conversions (specification). */
/* */
-/* Copyright 2006-2015 by */
+/* Copyright 2006-2018 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -16,8 +16,8 @@
/***************************************************************************/
-#ifndef __PSCONV_H__
-#define __PSCONV_H__
+#ifndef PSCONV_H_
+#define PSCONV_H_
#include <ft2build.h>
@@ -65,7 +65,7 @@ FT_BEGIN_HEADER
FT_END_HEADER
-#endif /* __PSCONV_H__ */
+#endif /* PSCONV_H_ */
/* END */
diff --git a/src/3rdparty/freetype/src/psaux/pserror.c b/src/3rdparty/freetype/src/psaux/pserror.c
new file mode 100644
index 0000000000..9169e5222d
--- /dev/null
+++ b/src/3rdparty/freetype/src/psaux/pserror.c
@@ -0,0 +1,52 @@
+/***************************************************************************/
+/* */
+/* pserror.c */
+/* */
+/* Adobe's code for error handling (body). */
+/* */
+/* Copyright 2006-2013 Adobe Systems Incorporated. */
+/* */
+/* This software, and all works of authorship, whether in source or */
+/* object code form as indicated by the copyright notice(s) included */
+/* herein (collectively, the "Work") is made available, and may only be */
+/* used, modified, and distributed under the FreeType Project License, */
+/* LICENSE.TXT. Additionally, subject to the terms and conditions of the */
+/* FreeType Project License, each contributor to the Work hereby grants */
+/* to any individual or legal entity exercising permissions granted by */
+/* the FreeType Project License and this section (hereafter, "You" or */
+/* "Your") a perpetual, worldwide, non-exclusive, no-charge, */
+/* royalty-free, irrevocable (except as stated in this section) patent */
+/* license to make, have made, use, offer to sell, sell, import, and */
+/* otherwise transfer the Work, where such license applies only to those */
+/* patent claims licensable by such contributor that are necessarily */
+/* infringed by their contribution(s) alone or by combination of their */
+/* contribution(s) with the Work to which such contribution(s) was */
+/* submitted. If You institute patent litigation against any entity */
+/* (including a cross-claim or counterclaim in a lawsuit) alleging that */
+/* the Work or a contribution incorporated within the Work constitutes */
+/* direct or contributory patent infringement, then any patent licenses */
+/* granted to You under this License for that Work shall terminate as of */
+/* the date such litigation is filed. */
+/* */
+/* By using, modifying, or distributing the Work you indicate that you */
+/* have read and understood the terms and conditions of the */
+/* FreeType Project License as well as those provided in this section, */
+/* and you accept them fully. */
+/* */
+/***************************************************************************/
+
+
+#include "psft.h"
+#include "pserror.h"
+
+
+ FT_LOCAL_DEF( void )
+ cf2_setError( FT_Error* error,
+ FT_Error value )
+ {
+ if ( error && !*error )
+ *error = value;
+ }
+
+
+/* END */
diff --git a/src/3rdparty/freetype/src/psaux/pserror.h b/src/3rdparty/freetype/src/psaux/pserror.h
new file mode 100644
index 0000000000..13d52062bf
--- /dev/null
+++ b/src/3rdparty/freetype/src/psaux/pserror.h
@@ -0,0 +1,119 @@
+/***************************************************************************/
+/* */
+/* pserror.h */
+/* */
+/* Adobe's code for error handling (specification). */
+/* */
+/* Copyright 2006-2013 Adobe Systems Incorporated. */
+/* */
+/* This software, and all works of authorship, whether in source or */
+/* object code form as indicated by the copyright notice(s) included */
+/* herein (collectively, the "Work") is made available, and may only be */
+/* used, modified, and distributed under the FreeType Project License, */
+/* LICENSE.TXT. Additionally, subject to the terms and conditions of the */
+/* FreeType Project License, each contributor to the Work hereby grants */
+/* to any individual or legal entity exercising permissions granted by */
+/* the FreeType Project License and this section (hereafter, "You" or */
+/* "Your") a perpetual, worldwide, non-exclusive, no-charge, */
+/* royalty-free, irrevocable (except as stated in this section) patent */
+/* license to make, have made, use, offer to sell, sell, import, and */
+/* otherwise transfer the Work, where such license applies only to those */
+/* patent claims licensable by such contributor that are necessarily */
+/* infringed by their contribution(s) alone or by combination of their */
+/* contribution(s) with the Work to which such contribution(s) was */
+/* submitted. If You institute patent litigation against any entity */
+/* (including a cross-claim or counterclaim in a lawsuit) alleging that */
+/* the Work or a contribution incorporated within the Work constitutes */
+/* direct or contributory patent infringement, then any patent licenses */
+/* granted to You under this License for that Work shall terminate as of */
+/* the date such litigation is filed. */
+/* */
+/* By using, modifying, or distributing the Work you indicate that you */
+/* have read and understood the terms and conditions of the */
+/* FreeType Project License as well as those provided in this section, */
+/* and you accept them fully. */
+/* */
+/***************************************************************************/
+
+
+#ifndef PSERROR_H_
+#define PSERROR_H_
+
+
+#include FT_MODULE_ERRORS_H
+
+#undef FTERRORS_H_
+
+#undef FT_ERR_PREFIX
+#define FT_ERR_PREFIX CF2_Err_
+#define FT_ERR_BASE FT_Mod_Err_CF2
+
+
+#include FT_ERRORS_H
+#include "psft.h"
+
+
+FT_BEGIN_HEADER
+
+
+ /*
+ * A poor-man error facility.
+ *
+ * This code being written in vanilla C, doesn't have the luxury of a
+ * language-supported exception mechanism such as the one available in
+ * Java. Instead, we are stuck with using error codes that must be
+ * carefully managed and preserved. However, it is convenient for us to
+ * model our error mechanism on a Java-like exception mechanism.
+ * When we assign an error code we are thus `throwing' an error.
+ *
+ * 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
+ * error to propagate and be handled at the appropriate location in
+ * the code.
+ *
+ * This allows a style of code where the error code is initialized
+ * up front and a block of calls are made with the error code only
+ * being checked after the block. If a new error occurs, the original
+ * error will be preserved and a functional no-op should result in any
+ * subsequent function that has an initial error code not equal to
+ * `FT_Err_Ok'.
+ *
+ * Errors are encoded by calling the `FT_THROW' macro. For example,
+ *
+ * {
+ * FT_Error e;
+ *
+ *
+ * ...
+ * e = FT_THROW( Out_Of_Memory );
+ * }
+ *
+ */
+
+
+ /* Set error code to a particular value. */
+ FT_LOCAL( void )
+ cf2_setError( FT_Error* error,
+ FT_Error value );
+
+
+ /*
+ * A macro that conditionally sets an error code.
+ *
+ * This macro will first check whether `error' is set;
+ * if not, it will set it to `e'.
+ *
+ */
+#define CF2_SET_ERROR( error, e ) \
+ cf2_setError( error, FT_THROW( e ) )
+
+
+FT_END_HEADER
+
+
+#endif /* PSERROR_H_ */
+
+
+/* END */
diff --git a/src/3rdparty/freetype/src/psaux/psfixed.h b/src/3rdparty/freetype/src/psaux/psfixed.h
new file mode 100644
index 0000000000..219589e7fc
--- /dev/null
+++ b/src/3rdparty/freetype/src/psaux/psfixed.h
@@ -0,0 +1,95 @@
+/***************************************************************************/
+/* */
+/* psfixed.h */
+/* */
+/* Adobe's code for Fixed Point Mathematics (specification only). */
+/* */
+/* Copyright 2007-2013 Adobe Systems Incorporated. */
+/* */
+/* This software, and all works of authorship, whether in source or */
+/* object code form as indicated by the copyright notice(s) included */
+/* herein (collectively, the "Work") is made available, and may only be */
+/* used, modified, and distributed under the FreeType Project License, */
+/* LICENSE.TXT. Additionally, subject to the terms and conditions of the */
+/* FreeType Project License, each contributor to the Work hereby grants */
+/* to any individual or legal entity exercising permissions granted by */
+/* the FreeType Project License and this section (hereafter, "You" or */
+/* "Your") a perpetual, worldwide, non-exclusive, no-charge, */
+/* royalty-free, irrevocable (except as stated in this section) patent */
+/* license to make, have made, use, offer to sell, sell, import, and */
+/* otherwise transfer the Work, where such license applies only to those */
+/* patent claims licensable by such contributor that are necessarily */
+/* infringed by their contribution(s) alone or by combination of their */
+/* contribution(s) with the Work to which such contribution(s) was */
+/* submitted. If You institute patent litigation against any entity */
+/* (including a cross-claim or counterclaim in a lawsuit) alleging that */
+/* the Work or a contribution incorporated within the Work constitutes */
+/* direct or contributory patent infringement, then any patent licenses */
+/* granted to You under this License for that Work shall terminate as of */
+/* the date such litigation is filed. */
+/* */
+/* By using, modifying, or distributing the Work you indicate that you */
+/* have read and understood the terms and conditions of the */
+/* FreeType Project License as well as those provided in this section, */
+/* and you accept them fully. */
+/* */
+/***************************************************************************/
+
+
+#ifndef PSFIXED_H_
+#define PSFIXED_H_
+
+
+FT_BEGIN_HEADER
+
+
+ /* rasterizer integer and fixed point arithmetic must be 32-bit */
+
+#define CF2_Fixed CF2_F16Dot16
+ typedef FT_Int32 CF2_Frac; /* 2.30 fixed point */
+
+
+#define CF2_FIXED_MAX ( (CF2_Fixed)0x7FFFFFFFL )
+#define CF2_FIXED_MIN ( (CF2_Fixed)0x80000000L )
+#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 */
+
+#define cf2_intToFixed( i ) \
+ ( (CF2_Fixed)( (FT_UInt32)(i) << 16 ) )
+#define cf2_fixedToInt( x ) \
+ ( (FT_Short)( ( (FT_UInt32)(x) + 0x8000U ) >> 16 ) )
+#define cf2_fixedRound( x ) \
+ ( (CF2_Fixed)( ( (FT_UInt32)(x) + 0x8000U ) & 0xFFFF0000UL ) )
+#define cf2_doubleToFixed( f ) \
+ ( (CF2_Fixed)( (f) * 65536.0 + 0.5 ) )
+#define cf2_fixedAbs( x ) \
+ ( (x) < 0 ? NEG_INT32( x ) : (x) )
+#define cf2_fixedFloor( x ) \
+ ( (CF2_Fixed)( (FT_UInt32)(x) & 0xFFFF0000UL ) )
+#define cf2_fixedFraction( x ) \
+ ( (x) - cf2_fixedFloor( x ) )
+#define cf2_fracToFixed( x ) \
+ ( (x) < 0 ? -( ( -(x) + 0x2000 ) >> 14 ) \
+ : ( ( (x) + 0x2000 ) >> 14 ) )
+
+
+ /* signed numeric types */
+ typedef enum CF2_NumberType_
+ {
+ CF2_NumberFixed, /* 16.16 */
+ CF2_NumberFrac, /* 2.30 */
+ CF2_NumberInt /* 32.0 */
+
+ } CF2_NumberType;
+
+
+FT_END_HEADER
+
+
+#endif /* PSFIXED_H_ */
+
+
+/* END */
diff --git a/src/3rdparty/freetype/src/psaux/psfont.c b/src/3rdparty/freetype/src/psaux/psfont.c
new file mode 100644
index 0000000000..dde67a739d
--- /dev/null
+++ b/src/3rdparty/freetype/src/psaux/psfont.c
@@ -0,0 +1,567 @@
+/***************************************************************************/
+/* */
+/* psfont.c */
+/* */
+/* Adobe's code for font instances (body). */
+/* */
+/* Copyright 2007-2014 Adobe Systems Incorporated. */
+/* */
+/* This software, and all works of authorship, whether in source or */
+/* object code form as indicated by the copyright notice(s) included */
+/* herein (collectively, the "Work") is made available, and may only be */
+/* used, modified, and distributed under the FreeType Project License, */
+/* LICENSE.TXT. Additionally, subject to the terms and conditions of the */
+/* FreeType Project License, each contributor to the Work hereby grants */
+/* to any individual or legal entity exercising permissions granted by */
+/* the FreeType Project License and this section (hereafter, "You" or */
+/* "Your") a perpetual, worldwide, non-exclusive, no-charge, */
+/* royalty-free, irrevocable (except as stated in this section) patent */
+/* license to make, have made, use, offer to sell, sell, import, and */
+/* otherwise transfer the Work, where such license applies only to those */
+/* patent claims licensable by such contributor that are necessarily */
+/* infringed by their contribution(s) alone or by combination of their */
+/* contribution(s) with the Work to which such contribution(s) was */
+/* submitted. If You institute patent litigation against any entity */
+/* (including a cross-claim or counterclaim in a lawsuit) alleging that */
+/* the Work or a contribution incorporated within the Work constitutes */
+/* direct or contributory patent infringement, then any patent licenses */
+/* granted to You under this License for that Work shall terminate as of */
+/* the date such litigation is filed. */
+/* */
+/* By using, modifying, or distributing the Work you indicate that you */
+/* have read and understood the terms and conditions of the */
+/* FreeType Project License as well as those provided in this section, */
+/* and you accept them fully. */
+/* */
+/***************************************************************************/
+
+
+#include <ft2build.h>
+#include FT_INTERNAL_CALC_H
+
+#include "psft.h"
+
+#include "psglue.h"
+#include "psfont.h"
+#include "pserror.h"
+#include "psintrp.h"
+
+
+ /* Compute a stem darkening amount in character space. */
+ static void
+ cf2_computeDarkening( CF2_Fixed emRatio,
+ CF2_Fixed ppem,
+ CF2_Fixed stemWidth,
+ CF2_Fixed* darkenAmount,
+ CF2_Fixed boldenAmount,
+ FT_Bool stemDarkened,
+ FT_Int* darkenParams )
+ {
+ /*
+ * Total darkening amount is computed in 1000 unit character space
+ * using the modified 5 part curve as Adobe's Avalon rasterizer.
+ * The darkening amount is smaller for thicker stems.
+ * It becomes zero when the stem is thicker than 2.333 pixels.
+ *
+ * By default, we use
+ *
+ * darkenAmount = 0.4 pixels if scaledStem <= 0.5 pixels,
+ * darkenAmount = 0.275 pixels if 1 <= scaledStem <= 1.667 pixels,
+ * darkenAmount = 0 pixel if scaledStem >= 2.333 pixels,
+ *
+ * and piecewise linear in-between:
+ *
+ *
+ * darkening
+ * ^
+ * |
+ * | (x1,y1)
+ * |--------+
+ * | \
+ * | \
+ * | \ (x3,y3)
+ * | +----------+
+ * | (x2,y2) \
+ * | \
+ * | \
+ * | +-----------------
+ * | (x4,y4)
+ * +---------------------------------------------> stem
+ * thickness
+ *
+ *
+ * This corresponds to the following values for the
+ * `darkening-parameters' property:
+ *
+ * (x1, y1) = (500, 400)
+ * (x2, y2) = (1000, 275)
+ * (x3, y3) = (1667, 275)
+ * (x4, y4) = (2333, 0)
+ *
+ */
+
+ /* Internal calculations are done in units per thousand for */
+ /* convenience. The x axis is scaled stem width in */
+ /* thousandths of a pixel. That is, 1000 is 1 pixel. */
+ /* The y axis is darkening amount in thousandths of a pixel.*/
+ /* In the code, below, dividing by ppem and */
+ /* adjusting for emRatio converts darkenAmount to character */
+ /* space (font units). */
+ CF2_Fixed stemWidthPer1000, scaledStem;
+ FT_Int logBase2;
+
+
+ *darkenAmount = 0;
+
+ if ( boldenAmount == 0 && !stemDarkened )
+ return;
+
+ /* protect against range problems and divide by zero */
+ if ( emRatio < cf2_doubleToFixed( .01 ) )
+ return;
+
+ if ( stemDarkened )
+ {
+ FT_Int x1 = darkenParams[0];
+ FT_Int y1 = darkenParams[1];
+ FT_Int x2 = darkenParams[2];
+ FT_Int y2 = darkenParams[3];
+ FT_Int x3 = darkenParams[4];
+ FT_Int y3 = darkenParams[5];
+ FT_Int x4 = darkenParams[6];
+ FT_Int y4 = darkenParams[7];
+
+
+ /* convert from true character space to 1000 unit character space; */
+ /* add synthetic emboldening effect */
+
+ /* `stemWidthPer1000' will not overflow for a legitimate font */
+
+ stemWidthPer1000 = FT_MulFix( stemWidth + boldenAmount, emRatio );
+
+ /* `scaledStem' can easily overflow, so we must clamp its maximum */
+ /* value; the test doesn't need to be precise, but must be */
+ /* conservative. The clamp value (default 2333) where */
+ /* `darkenAmount' is zero is well below the overflow value of */
+ /* 32767. */
+ /* */
+ /* FT_MSB computes the integer part of the base 2 logarithm. The */
+ /* number of bits for the product is 1 or 2 more than the sum of */
+ /* logarithms; remembering that the 16 lowest bits of the fraction */
+ /* are dropped this is correct to within a factor of almost 4. */
+ /* For example, 0x80.0000 * 0x80.0000 = 0x4000.0000 is 23+23 and */
+ /* is flagged as possible overflow because 0xFF.FFFF * 0xFF.FFFF = */
+ /* 0xFFFF.FE00 is also 23+23. */
+
+ logBase2 = FT_MSB( (FT_UInt32)stemWidthPer1000 ) +
+ FT_MSB( (FT_UInt32)ppem );
+
+ if ( logBase2 >= 46 )
+ /* possible overflow */
+ scaledStem = cf2_intToFixed( x4 );
+ else
+ scaledStem = FT_MulFix( stemWidthPer1000, ppem );
+
+ /* now apply the darkening parameters */
+
+ if ( scaledStem < cf2_intToFixed( x1 ) )
+ *darkenAmount = FT_DivFix( cf2_intToFixed( y1 ), ppem );
+
+ else if ( scaledStem < cf2_intToFixed( x2 ) )
+ {
+ FT_Int xdelta = x2 - x1;
+ FT_Int ydelta = y2 - y1;
+ FT_Int x = stemWidthPer1000 -
+ FT_DivFix( cf2_intToFixed( x1 ), ppem );
+
+
+ if ( !xdelta )
+ goto Try_x3;
+
+ *darkenAmount = FT_MulDiv( x, ydelta, xdelta ) +
+ FT_DivFix( cf2_intToFixed( y1 ), ppem );
+ }
+
+ else if ( scaledStem < cf2_intToFixed( x3 ) )
+ {
+ Try_x3:
+ {
+ FT_Int xdelta = x3 - x2;
+ FT_Int ydelta = y3 - y2;
+ FT_Int x = stemWidthPer1000 -
+ FT_DivFix( cf2_intToFixed( x2 ), ppem );
+
+
+ if ( !xdelta )
+ goto Try_x4;
+
+ *darkenAmount = FT_MulDiv( x, ydelta, xdelta ) +
+ FT_DivFix( cf2_intToFixed( y2 ), ppem );
+ }
+ }
+
+ else if ( scaledStem < cf2_intToFixed( x4 ) )
+ {
+ Try_x4:
+ {
+ FT_Int xdelta = x4 - x3;
+ FT_Int ydelta = y4 - y3;
+ FT_Int x = stemWidthPer1000 -
+ FT_DivFix( cf2_intToFixed( x3 ), ppem );
+
+
+ if ( !xdelta )
+ goto Use_y4;
+
+ *darkenAmount = FT_MulDiv( x, ydelta, xdelta ) +
+ FT_DivFix( cf2_intToFixed( y3 ), ppem );
+ }
+ }
+
+ else
+ {
+ Use_y4:
+ *darkenAmount = FT_DivFix( cf2_intToFixed( y4 ), ppem );
+ }
+
+ /* use half the amount on each side and convert back to true */
+ /* character space */
+ *darkenAmount = FT_DivFix( *darkenAmount, 2 * emRatio );
+ }
+
+ /* add synthetic emboldening effect in character space */
+ *darkenAmount += boldenAmount / 2;
+ }
+
+
+ /* 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
+ cf2_font_setup( CF2_Font font,
+ const CF2_Matrix* transform )
+ {
+ /* pointer to parsed font object */
+ PS_Decoder* decoder = font->decoder;
+
+ FT_Bool needExtraSetup = FALSE;
+
+ CFF_VStoreRec* vstore;
+ FT_Bool hasVariations = FALSE;
+
+ /* character space units */
+ CF2_Fixed boldenX = font->syntheticEmboldeningAmountX;
+ CF2_Fixed boldenY = font->syntheticEmboldeningAmountY;
+
+ CFF_SubFont subFont;
+ CF2_Fixed ppem;
+
+ CF2_UInt lenNormalizedV = 0;
+ FT_Fixed* normalizedV = NULL;
+
+ /* clear previous error */
+ font->error = FT_Err_Ok;
+
+ /* if a CID fontDict has changed, we need to recompute some cached */
+ /* data */
+ subFont = cf2_getSubfont( decoder );
+ if ( font->lastSubfont != subFont )
+ {
+ font->lastSubfont = subFont;
+ needExtraSetup = TRUE;
+ }
+
+ if ( !font->isT1 )
+ {
+ FT_Service_CFFLoad cffload = (FT_Service_CFFLoad)font->cffload;
+
+
+ /* 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 ( cffload->blend_check_vector( &subFont->blend,
+ subFont->private_dict.vsindex,
+ lenNormalizedV,
+ normalizedV ) )
+ {
+ /* blend has changed, reparse */
+ cffload->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. */
+ ppem = cf2_getPpemY( decoder );
+ if ( font->ppem != ppem )
+ {
+ font->ppem = ppem;
+ needExtraSetup = TRUE;
+ }
+
+ /* copy hinted flag on each call */
+ font->hinted = (FT_Bool)( font->renderingFlags & CF2_FlagsHinted );
+
+ /* determine if transform has changed; */
+ /* include Fontmatrix but ignore translation */
+ if ( ft_memcmp( transform,
+ &font->currentTransform,
+ 4 * sizeof ( CF2_Fixed ) ) != 0 )
+ {
+ /* save `key' information for `cache of one' matrix data; */
+ /* save client transform, without the translation */
+ font->currentTransform = *transform;
+ font->currentTransform.tx =
+ font->currentTransform.ty = cf2_intToFixed( 0 );
+
+ /* TODO: FreeType transform is simple scalar; for now, use identity */
+ /* for outer */
+ font->innerTransform = *transform;
+ font->outerTransform.a =
+ font->outerTransform.d = cf2_intToFixed( 1 );
+ font->outerTransform.b =
+ font->outerTransform.c = cf2_intToFixed( 0 );
+
+ needExtraSetup = TRUE;
+ }
+
+ /*
+ * font->darkened is set to true if there is a stem darkening request or
+ * the font is synthetic emboldened.
+ * font->darkened controls whether to adjust blue zones, winding order,
+ * and hinting.
+ *
+ */
+ if ( font->stemDarkened != ( font->renderingFlags & CF2_FlagsDarkened ) )
+ {
+ font->stemDarkened =
+ (FT_Bool)( font->renderingFlags & CF2_FlagsDarkened );
+
+ /* blue zones depend on darkened flag */
+ needExtraSetup = TRUE;
+ }
+
+ /* recompute variables that are dependent on transform or FontDict or */
+ /* darken flag */
+ if ( needExtraSetup )
+ {
+ /* StdVW is found in the private dictionary; */
+ /* recompute darkening amounts whenever private dictionary or */
+ /* transform change */
+ /* Note: a rendering flag turns darkening on or off, so we want to */
+ /* store the `on' amounts; */
+ /* darkening amount is computed in character space */
+ /* TODO: testing size-dependent darkening here; */
+ /* what to do for rotations? */
+
+ CF2_Fixed emRatio;
+ CF2_Fixed stdHW;
+ CF2_Int unitsPerEm = font->unitsPerEm;
+
+
+ if ( unitsPerEm == 0 )
+ unitsPerEm = 1000;
+
+ ppem = FT_MAX( cf2_intToFixed( 4 ),
+ font->ppem ); /* use minimum ppem of 4 */
+
+#if 0
+ /* since vstem is measured in the x-direction, we use the `a' member */
+ /* of the fontMatrix */
+ emRatio = cf2_fixedFracMul( cf2_intToFixed( 1000 ), fontMatrix->a );
+#endif
+
+ /* Freetype does not preserve the fontMatrix when parsing; use */
+ /* unitsPerEm instead. */
+ /* TODO: check precision of this */
+ emRatio = cf2_intToFixed( 1000 ) / unitsPerEm;
+ font->stdVW = cf2_getStdVW( decoder );
+
+ if ( font->stdVW <= 0 )
+ font->stdVW = FT_DivFix( cf2_intToFixed( 75 ), emRatio );
+
+ if ( boldenX > 0 )
+ {
+ /* Ensure that boldenX is at least 1 pixel for synthetic bold font */
+ /* (similar to what Avalon does) */
+ boldenX = FT_MAX( boldenX,
+ FT_DivFix( cf2_intToFixed( unitsPerEm ), ppem ) );
+
+ /* Synthetic emboldening adds at least 1 pixel to darkenX, while */
+ /* stem darkening adds at most half pixel. Since the purpose of */
+ /* stem darkening (readability at small sizes) is met with */
+ /* synthetic emboldening, no need to add stem darkening for a */
+ /* synthetic bold font. */
+ cf2_computeDarkening( emRatio,
+ ppem,
+ font->stdVW,
+ &font->darkenX,
+ boldenX,
+ FALSE,
+ font->darkenParams );
+ }
+ else
+ cf2_computeDarkening( emRatio,
+ ppem,
+ font->stdVW,
+ &font->darkenX,
+ 0,
+ font->stemDarkened,
+ font->darkenParams );
+
+#if 0
+ /* since hstem is measured in the y-direction, we use the `d' member */
+ /* of the fontMatrix */
+ /* TODO: use the same units per em as above; check this */
+ emRatio = cf2_fixedFracMul( cf2_intToFixed( 1000 ), fontMatrix->d );
+#endif
+
+ /* set the default stem width, because it must be the same for all */
+ /* family members; */
+ /* choose a constant for StdHW that depends on font contrast */
+ stdHW = cf2_getStdHW( decoder );
+
+ if ( stdHW > 0 && font->stdVW > MUL_INT32( 2, stdHW ) )
+ font->stdHW = FT_DivFix( cf2_intToFixed( 75 ), emRatio );
+ else
+ {
+ /* low contrast font gets less hstem darkening */
+ font->stdHW = FT_DivFix( cf2_intToFixed( 110 ), emRatio );
+ }
+
+ cf2_computeDarkening( emRatio,
+ ppem,
+ font->stdHW,
+ &font->darkenY,
+ boldenY,
+ font->stemDarkened,
+ font->darkenParams );
+
+ if ( font->darkenX != 0 || font->darkenY != 0 )
+ font->darkened = TRUE;
+ else
+ font->darkened = FALSE;
+
+ font->reverseWinding = FALSE; /* initial expectation is CCW */
+
+ /* compute blue zones for this instance */
+ cf2_blues_init( &font->blues, font );
+
+ } /* needExtraSetup */
+ }
+
+
+ /* equivalent to AdobeGetOutline */
+ FT_LOCAL_DEF( FT_Error )
+ cf2_getGlyphOutline( CF2_Font font,
+ CF2_Buffer charstring,
+ const CF2_Matrix* transform,
+ CF2_F16Dot16* glyphWidth )
+ {
+ FT_Error lastError = FT_Err_Ok;
+
+ FT_Vector translation;
+
+#if 0
+ FT_Vector advancePoint;
+#endif
+
+ CF2_Fixed advWidth = 0;
+ FT_Bool needWinding;
+
+
+ /* Note: use both integer and fraction for outlines. This allows bbox */
+ /* to come out directly. */
+
+ translation.x = transform->tx;
+ translation.y = transform->ty;
+
+ /* set up values based on transform */
+ cf2_font_setup( font, transform );
+ if ( font->error )
+ goto exit; /* setup encountered an error */
+
+ /* reset darken direction */
+ font->reverseWinding = FALSE;
+
+ /* winding order only affects darkening */
+ needWinding = font->darkened;
+
+ while ( 1 )
+ {
+ /* reset output buffer */
+ cf2_outline_reset( &font->outline );
+
+ /* build the outline, passing the full translation */
+ cf2_interpT2CharString( font,
+ charstring,
+ (CF2_OutlineCallbacks)&font->outline,
+ &translation,
+ FALSE,
+ 0,
+ 0,
+ &advWidth );
+
+ if ( font->error )
+ goto exit;
+
+ if ( !needWinding )
+ break;
+
+ /* check winding order */
+ if ( font->outline.root.windingMomentum >= 0 ) /* CFF is CCW */
+ break;
+
+ /* invert darkening and render again */
+ /* TODO: this should be a parameter to getOutline-computeOffset */
+ font->reverseWinding = TRUE;
+
+ needWinding = FALSE; /* exit after next iteration */
+ }
+
+ /* finish storing client outline */
+ cf2_outline_close( &font->outline );
+
+ exit:
+ /* FreeType just wants the advance width; there is no translation */
+ *glyphWidth = advWidth;
+
+ /* free resources and collect errors from objects we've used */
+ cf2_setError( &font->error, lastError );
+
+ return font->error;
+ }
+
+
+/* END */
diff --git a/src/3rdparty/freetype/src/psaux/psfont.h b/src/3rdparty/freetype/src/psaux/psfont.h
new file mode 100644
index 0000000000..e611ac4bdc
--- /dev/null
+++ b/src/3rdparty/freetype/src/psaux/psfont.h
@@ -0,0 +1,134 @@
+/***************************************************************************/
+/* */
+/* psfont.h */
+/* */
+/* Adobe's code for font instances (specification). */
+/* */
+/* Copyright 2007-2013 Adobe Systems Incorporated. */
+/* */
+/* This software, and all works of authorship, whether in source or */
+/* object code form as indicated by the copyright notice(s) included */
+/* herein (collectively, the "Work") is made available, and may only be */
+/* used, modified, and distributed under the FreeType Project License, */
+/* LICENSE.TXT. Additionally, subject to the terms and conditions of the */
+/* FreeType Project License, each contributor to the Work hereby grants */
+/* to any individual or legal entity exercising permissions granted by */
+/* the FreeType Project License and this section (hereafter, "You" or */
+/* "Your") a perpetual, worldwide, non-exclusive, no-charge, */
+/* royalty-free, irrevocable (except as stated in this section) patent */
+/* license to make, have made, use, offer to sell, sell, import, and */
+/* otherwise transfer the Work, where such license applies only to those */
+/* patent claims licensable by such contributor that are necessarily */
+/* infringed by their contribution(s) alone or by combination of their */
+/* contribution(s) with the Work to which such contribution(s) was */
+/* submitted. If You institute patent litigation against any entity */
+/* (including a cross-claim or counterclaim in a lawsuit) alleging that */
+/* the Work or a contribution incorporated within the Work constitutes */
+/* direct or contributory patent infringement, then any patent licenses */
+/* granted to You under this License for that Work shall terminate as of */
+/* the date such litigation is filed. */
+/* */
+/* By using, modifying, or distributing the Work you indicate that you */
+/* have read and understood the terms and conditions of the */
+/* FreeType Project License as well as those provided in this section, */
+/* and you accept them fully. */
+/* */
+/***************************************************************************/
+
+
+#ifndef PSFONT_H_
+#define PSFONT_H_
+
+
+#include FT_SERVICE_CFF_TABLE_LOAD_H
+
+#include "psft.h"
+#include "psblues.h"
+
+
+FT_BEGIN_HEADER
+
+
+#define CF2_OPERAND_STACK_SIZE 48
+#define CF2_MAX_SUBR 16 /* maximum subroutine nesting; */
+ /* only 10 are allowed but there exist */
+ /* fonts like `HiraKakuProN-W3.ttf' */
+ /* (Hiragino Kaku Gothic ProN W3; */
+ /* 8.2d6e1; 2014-12-19) that exceed */
+ /* this limit */
+#define CF2_STORAGE_SIZE 32
+
+
+ /* typedef is in `cf2glue.h' */
+ struct CF2_FontRec_
+ {
+ FT_Memory memory;
+ FT_Error error; /* shared error for this instance */
+
+ FT_Bool isT1;
+ FT_Bool isCFF2;
+ CF2_RenderingFlags renderingFlags;
+
+ /* variables that depend on Transform: */
+ /* the following have zero translation; */
+ /* inner * outer = font * original */
+
+ CF2_Matrix currentTransform; /* original client matrix */
+ CF2_Matrix innerTransform; /* for hinting; erect, scaled */
+ 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 */
+ CF2_Fixed syntheticEmboldeningAmountY; /* character space units */
+
+ /* FreeType related members */
+ CF2_OutlineRec outline; /* freetype glyph outline functions */
+ PS_Decoder* decoder;
+ CFF_SubFont lastSubfont; /* FreeType parsed data; */
+ /* top font or subfont */
+
+ /* these flags can vary from one call to the next */
+ FT_Bool hinted;
+ FT_Bool darkened; /* true if stemDarkened or synthetic bold */
+ /* i.e. darkenX != 0 || darkenY != 0 */
+ FT_Bool stemDarkened;
+
+ FT_Int darkenParams[8]; /* 1000 unit character space */
+
+ /* variables that depend on both FontDict and Transform */
+ CF2_Fixed stdVW; /* in character space; depends on dict entry */
+ CF2_Fixed stdHW; /* in character space; depends on dict entry */
+ CF2_Fixed darkenX; /* character space units */
+ CF2_Fixed darkenY; /* depends on transform */
+ /* and private dict (StdVW) */
+ FT_Bool reverseWinding; /* darken assuming */
+ /* counterclockwise winding */
+
+ CF2_BluesRec blues; /* computed zone data */
+
+ FT_Service_CFFLoad cffload; /* pointer to cff functions */
+ };
+
+
+ FT_LOCAL( FT_Error )
+ cf2_getGlyphOutline( CF2_Font font,
+ CF2_Buffer charstring,
+ const CF2_Matrix* transform,
+ CF2_F16Dot16* glyphWidth );
+
+
+FT_END_HEADER
+
+
+#endif /* PSFONT_H_ */
+
+
+/* END */
diff --git a/src/3rdparty/freetype/src/psaux/psft.c b/src/3rdparty/freetype/src/psaux/psft.c
new file mode 100644
index 0000000000..1f750174a1
--- /dev/null
+++ b/src/3rdparty/freetype/src/psaux/psft.c
@@ -0,0 +1,890 @@
+/***************************************************************************/
+/* */
+/* psft.c */
+/* */
+/* FreeType Glue Component to Adobe's Interpreter (body). */
+/* */
+/* Copyright 2013-2014 Adobe Systems Incorporated. */
+/* */
+/* This software, and all works of authorship, whether in source or */
+/* object code form as indicated by the copyright notice(s) included */
+/* herein (collectively, the "Work") is made available, and may only be */
+/* used, modified, and distributed under the FreeType Project License, */
+/* LICENSE.TXT. Additionally, subject to the terms and conditions of the */
+/* FreeType Project License, each contributor to the Work hereby grants */
+/* to any individual or legal entity exercising permissions granted by */
+/* the FreeType Project License and this section (hereafter, "You" or */
+/* "Your") a perpetual, worldwide, non-exclusive, no-charge, */
+/* royalty-free, irrevocable (except as stated in this section) patent */
+/* license to make, have made, use, offer to sell, sell, import, and */
+/* otherwise transfer the Work, where such license applies only to those */
+/* patent claims licensable by such contributor that are necessarily */
+/* infringed by their contribution(s) alone or by combination of their */
+/* contribution(s) with the Work to which such contribution(s) was */
+/* submitted. If You institute patent litigation against any entity */
+/* (including a cross-claim or counterclaim in a lawsuit) alleging that */
+/* the Work or a contribution incorporated within the Work constitutes */
+/* direct or contributory patent infringement, then any patent licenses */
+/* granted to You under this License for that Work shall terminate as of */
+/* the date such litigation is filed. */
+/* */
+/* By using, modifying, or distributing the Work you indicate that you */
+/* have read and understood the terms and conditions of the */
+/* FreeType Project License as well as those provided in this section, */
+/* and you accept them fully. */
+/* */
+/***************************************************************************/
+
+
+#include "psft.h"
+#include FT_INTERNAL_DEBUG_H
+
+#include "psfont.h"
+#include "pserror.h"
+#include "psobjs.h"
+#include "cffdecode.h"
+
+#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
+#include FT_MULTIPLE_MASTERS_H
+#include FT_SERVICE_MULTIPLE_MASTERS_H
+#endif
+
+#include FT_SERVICE_CFF_TABLE_LOAD_H
+
+
+#define CF2_MAX_SIZE cf2_intToFixed( 2000 ) /* max ppem */
+
+
+ /*
+ * This check should avoid most internal overflow cases. Clients should
+ * generally respond to `Glyph_Too_Big' by getting a glyph outline
+ * at EM size, scaling it and filling it as a graphics operation.
+ *
+ */
+ static FT_Error
+ cf2_checkTransform( const CF2_Matrix* transform,
+ CF2_Int unitsPerEm )
+ {
+ CF2_Fixed maxScale;
+
+
+ FT_ASSERT( unitsPerEm > 0 );
+
+ if ( transform->a <= 0 || transform->d <= 0 )
+ return FT_THROW( Invalid_Size_Handle );
+
+ FT_ASSERT( transform->b == 0 && transform->c == 0 );
+ FT_ASSERT( transform->tx == 0 && transform->ty == 0 );
+
+ if ( unitsPerEm > 0x7FFF )
+ return FT_THROW( Glyph_Too_Big );
+
+ maxScale = FT_DivFix( CF2_MAX_SIZE, cf2_intToFixed( unitsPerEm ) );
+
+ if ( transform->a > maxScale || transform->d > maxScale )
+ return FT_THROW( Glyph_Too_Big );
+
+ return FT_Err_Ok;
+ }
+
+
+ static void
+ cf2_setGlyphWidth( CF2_Outline outline,
+ CF2_Fixed width )
+ {
+ PS_Decoder* decoder = outline->decoder;
+
+
+ FT_ASSERT( decoder );
+
+ if ( !decoder->builder.is_t1 )
+ *decoder->glyph_width = cf2_fixedToInt( width );
+ }
+
+
+ /* Clean up font instance. */
+ static void
+ cf2_free_instance( void* ptr )
+ {
+ CF2_Font font = (CF2_Font)ptr;
+
+
+ if ( font )
+ {
+ FT_Memory memory = font->memory;
+
+
+ FT_FREE( font->blend.lastNDV );
+ FT_FREE( font->blend.BV );
+ }
+ }
+
+
+ /********************************************/
+ /* */
+ /* functions for handling client outline; */
+ /* FreeType uses coordinates in 26.6 format */
+ /* */
+ /********************************************/
+
+ static void
+ cf2_builder_moveTo( CF2_OutlineCallbacks callbacks,
+ const CF2_CallbackParams params )
+ {
+ /* downcast the object pointer */
+ CF2_Outline outline = (CF2_Outline)callbacks;
+ PS_Builder* builder;
+
+ (void)params; /* only used in debug mode */
+
+
+ FT_ASSERT( outline && outline->decoder );
+ FT_ASSERT( params->op == CF2_PathOpMoveTo );
+
+ builder = &outline->decoder->builder;
+
+ /* note: two successive moves simply close the contour twice */
+ ps_builder_close_contour( builder );
+ builder->path_begun = 0;
+ }
+
+
+ static void
+ cf2_builder_lineTo( CF2_OutlineCallbacks callbacks,
+ const CF2_CallbackParams params )
+ {
+ FT_Error error;
+
+ /* downcast the object pointer */
+ CF2_Outline outline = (CF2_Outline)callbacks;
+ PS_Builder* builder;
+
+
+ FT_ASSERT( outline && outline->decoder );
+ FT_ASSERT( params->op == CF2_PathOpLineTo );
+
+ builder = &outline->decoder->builder;
+
+ if ( !builder->path_begun )
+ {
+ /* record the move before the line; also check points and set */
+ /* `path_begun' */
+ error = ps_builder_start_point( builder,
+ params->pt0.x,
+ params->pt0.y );
+ if ( error )
+ {
+ if ( !*callbacks->error )
+ *callbacks->error = error;
+ return;
+ }
+ }
+
+ /* `ps_builder_add_point1' includes a check_points call for one point */
+ error = ps_builder_add_point1( builder,
+ params->pt1.x,
+ params->pt1.y );
+ if ( error )
+ {
+ if ( !*callbacks->error )
+ *callbacks->error = error;
+ return;
+ }
+ }
+
+
+ static void
+ cf2_builder_cubeTo( CF2_OutlineCallbacks callbacks,
+ const CF2_CallbackParams params )
+ {
+ FT_Error error;
+
+ /* downcast the object pointer */
+ CF2_Outline outline = (CF2_Outline)callbacks;
+ PS_Builder* builder;
+
+
+ FT_ASSERT( outline && outline->decoder );
+ FT_ASSERT( params->op == CF2_PathOpCubeTo );
+
+ builder = &outline->decoder->builder;
+
+ if ( !builder->path_begun )
+ {
+ /* record the move before the line; also check points and set */
+ /* `path_begun' */
+ error = ps_builder_start_point( builder,
+ params->pt0.x,
+ params->pt0.y );
+ if ( error )
+ {
+ if ( !*callbacks->error )
+ *callbacks->error = error;
+ return;
+ }
+ }
+
+ /* prepare room for 3 points: 2 off-curve, 1 on-curve */
+ error = ps_builder_check_points( builder, 3 );
+ if ( error )
+ {
+ if ( !*callbacks->error )
+ *callbacks->error = error;
+ return;
+ }
+
+ ps_builder_add_point( builder,
+ params->pt1.x,
+ params->pt1.y, 0 );
+ ps_builder_add_point( builder,
+ params->pt2.x,
+ params->pt2.y, 0 );
+ ps_builder_add_point( builder,
+ params->pt3.x,
+ params->pt3.y, 1 );
+ }
+
+
+ static void
+ cf2_outline_init( CF2_Outline outline,
+ FT_Memory memory,
+ FT_Error* error )
+ {
+ FT_ZERO( outline );
+
+ outline->root.memory = memory;
+ outline->root.error = error;
+
+ outline->root.moveTo = cf2_builder_moveTo;
+ outline->root.lineTo = cf2_builder_lineTo;
+ outline->root.cubeTo = cf2_builder_cubeTo;
+ }
+
+
+ /* get scaling and hint flag from GlyphSlot */
+ static void
+ cf2_getScaleAndHintFlag( PS_Decoder* decoder,
+ CF2_Fixed* x_scale,
+ CF2_Fixed* y_scale,
+ FT_Bool* hinted,
+ FT_Bool* scaled )
+ {
+ FT_ASSERT( decoder && decoder->builder.glyph );
+
+ /* note: FreeType scale includes a factor of 64 */
+ *hinted = decoder->builder.glyph->hint;
+ *scaled = decoder->builder.glyph->scaled;
+
+ if ( *hinted )
+ {
+ *x_scale = ADD_INT32( decoder->builder.glyph->x_scale, 32 ) / 64;
+ *y_scale = ADD_INT32( decoder->builder.glyph->y_scale, 32 ) / 64;
+ }
+ else
+ {
+ /* for unhinted outlines, `cff_slot_load' does the scaling, */
+ /* thus render at `unity' scale */
+
+ *x_scale = 0x0400; /* 1/64 as 16.16 */
+ *y_scale = 0x0400;
+ }
+ }
+
+
+ /* get units per em from `FT_Face' */
+ /* TODO: should handle font matrix concatenation? */
+ static FT_UShort
+ cf2_getUnitsPerEm( PS_Decoder* decoder )
+ {
+ FT_ASSERT( decoder && decoder->builder.face );
+ FT_ASSERT( decoder->builder.face->units_per_EM );
+
+ return decoder->builder.face->units_per_EM;
+ }
+
+
+ /* Main entry point: Render one glyph. */
+ FT_LOCAL_DEF( FT_Error )
+ cf2_decoder_parse_charstrings( PS_Decoder* decoder,
+ FT_Byte* charstring_base,
+ FT_ULong charstring_len )
+ {
+ FT_Memory memory;
+ FT_Error error = FT_Err_Ok;
+ CF2_Font font;
+
+ FT_Bool is_t1 = decoder->builder.is_t1;
+
+
+ FT_ASSERT( decoder &&
+ ( is_t1 || decoder->cff ) );
+
+ if ( is_t1 && !decoder->current_subfont )
+ {
+ FT_ERROR(( "cf2_decoder_parse_charstrings (Type 1): "
+ "SubFont missing. Use `t1_make_subfont' first\n" ));
+ return FT_THROW( Invalid_Table );
+ }
+
+ memory = decoder->builder.memory;
+
+ /* CF2 data is saved here across glyphs */
+ font = (CF2_Font)decoder->cf2_instance->data;
+
+ /* on first glyph, allocate instance structure */
+ if ( !decoder->cf2_instance->data )
+ {
+ decoder->cf2_instance->finalizer =
+ (FT_Generic_Finalizer)cf2_free_instance;
+
+ if ( FT_ALLOC( decoder->cf2_instance->data,
+ sizeof ( CF2_FontRec ) ) )
+ return FT_THROW( Out_Of_Memory );
+
+ font = (CF2_Font)decoder->cf2_instance->data;
+
+ font->memory = memory;
+
+ if ( !is_t1 )
+ font->cffload = (FT_Service_CFFLoad)decoder->cff->cffload;
+
+ /* initialize a client outline, to be shared by each glyph rendered */
+ cf2_outline_init( &font->outline, font->memory, &font->error );
+ }
+
+ /* save decoder; it is a stack variable and will be different on each */
+ /* call */
+ font->decoder = decoder;
+ font->outline.decoder = decoder;
+
+ {
+ /* build parameters for Adobe engine */
+
+ PS_Builder* builder = &decoder->builder;
+ PS_Driver driver = (PS_Driver)FT_FACE_DRIVER( builder->face );
+
+ FT_Bool no_stem_darkening_driver =
+ driver->no_stem_darkening;
+ FT_Char no_stem_darkening_font =
+ builder->face->internal->no_stem_darkening;
+
+ /* local error */
+ FT_Error error2 = FT_Err_Ok;
+ CF2_BufferRec buf;
+ CF2_Matrix transform;
+ CF2_F16Dot16 glyphWidth;
+
+ FT_Bool hinted;
+ FT_Bool scaled;
+
+
+ /* FreeType has already looked up the GID; convert to */
+ /* `RegionBuffer', assuming that the input has been validated */
+ FT_ASSERT( charstring_base + charstring_len >= charstring_base );
+
+ FT_ZERO( &buf );
+ buf.start =
+ buf.ptr = charstring_base;
+ buf.end = charstring_base + charstring_len;
+
+ FT_ZERO( &transform );
+
+ cf2_getScaleAndHintFlag( decoder,
+ &transform.a,
+ &transform.d,
+ &hinted,
+ &scaled );
+
+ if ( is_t1 )
+ font->isCFF2 = FALSE;
+ else
+ {
+ /* copy isCFF2 boolean from TT_Face to CF2_Font */
+ font->isCFF2 = ((TT_Face)builder->face)->is_cff2;
+ }
+ font->isT1 = is_t1;
+
+ font->renderingFlags = 0;
+ if ( hinted )
+ font->renderingFlags |= CF2_FlagsHinted;
+ 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];
+ font->darkenParams[1] = driver->darken_params[1];
+ font->darkenParams[2] = driver->darken_params[2];
+ font->darkenParams[3] = driver->darken_params[3];
+ font->darkenParams[4] = driver->darken_params[4];
+ font->darkenParams[5] = driver->darken_params[5];
+ font->darkenParams[6] = driver->darken_params[6];
+ font->darkenParams[7] = driver->darken_params[7];
+
+ /* now get an outline for this glyph; */
+ /* also get units per em to validate scale */
+ font->unitsPerEm = (CF2_Int)cf2_getUnitsPerEm( decoder );
+
+ if ( scaled )
+ {
+ error2 = cf2_checkTransform( &transform, font->unitsPerEm );
+ if ( error2 )
+ return error2;
+ }
+
+ error2 = cf2_getGlyphOutline( font, &buf, &transform, &glyphWidth );
+ if ( error2 )
+ return FT_ERR( Invalid_File_Format );
+
+ cf2_setGlyphWidth( &font->outline, glyphWidth );
+
+ return FT_Err_Ok;
+ }
+ }
+
+
+ /* get pointer to current FreeType subfont (based on current glyphID) */
+ FT_LOCAL_DEF( CFF_SubFont )
+ cf2_getSubfont( PS_Decoder* decoder )
+ {
+ FT_ASSERT( decoder && decoder->current_subfont );
+
+ return decoder->current_subfont;
+ }
+
+
+ /* get pointer to VStore structure */
+ FT_LOCAL_DEF( CFF_VStore )
+ cf2_getVStore( PS_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( PS_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( PS_Decoder* decoder,
+ CF2_UInt *len,
+ FT_Fixed* *vec )
+ {
+ TT_Face face;
+ FT_Service_MultiMasters mm;
+
+
+ FT_ASSERT( decoder && decoder->builder.face );
+ FT_ASSERT( vec && len );
+ FT_ASSERT( !decoder->builder.is_t1 );
+
+ face = (TT_Face)decoder->builder.face;
+ mm = (FT_Service_MultiMasters)face->mm;
+
+ return mm->get_var_blend( FT_FACE( face ), len, NULL, vec, NULL );
+ }
+#endif
+
+
+ /* get `y_ppem' from `CFF_Size' */
+ FT_LOCAL_DEF( CF2_Fixed )
+ cf2_getPpemY( PS_Decoder* decoder )
+ {
+ FT_ASSERT( decoder &&
+ decoder->builder.face &&
+ decoder->builder.face->size );
+
+ /*
+ * Note that `y_ppem' can be zero if there wasn't a call to
+ * `FT_Set_Char_Size' or something similar. However, this isn't a
+ * problem since we come to this place in the code only if
+ * FT_LOAD_NO_SCALE is set (the other case gets caught by
+ * `cf2_checkTransform'). The ppem value is needed to compute the stem
+ * darkening, which is disabled for getting the unscaled outline.
+ *
+ */
+ return cf2_intToFixed(
+ decoder->builder.face->size->metrics.y_ppem );
+ }
+
+
+ /* get standard stem widths for the current subfont; */
+ /* FreeType stores these as integer font units */
+ /* (note: variable names seem swapped) */
+ FT_LOCAL_DEF( CF2_Fixed )
+ cf2_getStdVW( PS_Decoder* decoder )
+ {
+ FT_ASSERT( decoder && decoder->current_subfont );
+
+ return cf2_intToFixed(
+ decoder->current_subfont->private_dict.standard_height );
+ }
+
+
+ FT_LOCAL_DEF( CF2_Fixed )
+ cf2_getStdHW( PS_Decoder* decoder )
+ {
+ FT_ASSERT( decoder && decoder->current_subfont );
+
+ return cf2_intToFixed(
+ decoder->current_subfont->private_dict.standard_width );
+ }
+
+
+ /* note: FreeType stores 1000 times the actual value for `BlueScale' */
+ FT_LOCAL_DEF( void )
+ cf2_getBlueMetrics( PS_Decoder* decoder,
+ CF2_Fixed* blueScale,
+ CF2_Fixed* blueShift,
+ CF2_Fixed* blueFuzz )
+ {
+ FT_ASSERT( decoder && decoder->current_subfont );
+
+ *blueScale = FT_DivFix(
+ decoder->current_subfont->private_dict.blue_scale,
+ cf2_intToFixed( 1000 ) );
+ *blueShift = cf2_intToFixed(
+ decoder->current_subfont->private_dict.blue_shift );
+ *blueFuzz = cf2_intToFixed(
+ decoder->current_subfont->private_dict.blue_fuzz );
+ }
+
+
+ /* get blue values counts and arrays; the FreeType parser has validated */
+ /* the counts and verified that each is an even number */
+ FT_LOCAL_DEF( void )
+ cf2_getBlueValues( PS_Decoder* decoder,
+ size_t* count,
+ FT_Pos* *data )
+ {
+ FT_ASSERT( decoder && decoder->current_subfont );
+
+ *count = decoder->current_subfont->private_dict.num_blue_values;
+ *data = (FT_Pos*)
+ &decoder->current_subfont->private_dict.blue_values;
+ }
+
+
+ FT_LOCAL_DEF( void )
+ cf2_getOtherBlues( PS_Decoder* decoder,
+ size_t* count,
+ FT_Pos* *data )
+ {
+ FT_ASSERT( decoder && decoder->current_subfont );
+
+ *count = decoder->current_subfont->private_dict.num_other_blues;
+ *data = (FT_Pos*)
+ &decoder->current_subfont->private_dict.other_blues;
+ }
+
+
+ FT_LOCAL_DEF( void )
+ cf2_getFamilyBlues( PS_Decoder* decoder,
+ size_t* count,
+ FT_Pos* *data )
+ {
+ FT_ASSERT( decoder && decoder->current_subfont );
+
+ *count = decoder->current_subfont->private_dict.num_family_blues;
+ *data = (FT_Pos*)
+ &decoder->current_subfont->private_dict.family_blues;
+ }
+
+
+ FT_LOCAL_DEF( void )
+ cf2_getFamilyOtherBlues( PS_Decoder* decoder,
+ size_t* count,
+ FT_Pos* *data )
+ {
+ FT_ASSERT( decoder && decoder->current_subfont );
+
+ *count = decoder->current_subfont->private_dict.num_family_other_blues;
+ *data = (FT_Pos*)
+ &decoder->current_subfont->private_dict.family_other_blues;
+ }
+
+
+ FT_LOCAL_DEF( CF2_Int )
+ cf2_getLanguageGroup( PS_Decoder* decoder )
+ {
+ FT_ASSERT( decoder && decoder->current_subfont );
+
+ return decoder->current_subfont->private_dict.language_group;
+ }
+
+
+ /* convert unbiased subroutine index to `CF2_Buffer' and */
+ /* return 0 on success */
+ FT_LOCAL_DEF( CF2_Int )
+ cf2_initGlobalRegionBuffer( PS_Decoder* decoder,
+ CF2_Int subrNum,
+ CF2_Buffer buf )
+ {
+ CF2_UInt idx;
+
+
+ FT_ASSERT( decoder );
+
+ FT_ZERO( buf );
+
+ idx = (CF2_UInt)( subrNum + decoder->globals_bias );
+ if ( idx >= decoder->num_globals )
+ return TRUE; /* error */
+
+ FT_ASSERT( decoder->globals );
+
+ buf->start =
+ buf->ptr = decoder->globals[idx];
+ buf->end = decoder->globals[idx + 1];
+
+ return FALSE; /* success */
+ }
+
+
+ /* convert AdobeStandardEncoding code to CF2_Buffer; */
+ /* used for seac component */
+ FT_LOCAL_DEF( FT_Error )
+ cf2_getSeacComponent( PS_Decoder* decoder,
+ CF2_Int code,
+ CF2_Buffer buf )
+ {
+ CF2_Int gid;
+ FT_Byte* charstring;
+ FT_ULong len;
+ FT_Error error;
+
+
+ FT_ASSERT( decoder );
+ FT_ASSERT( !decoder->builder.is_t1 );
+
+ FT_ZERO( buf );
+
+#ifdef FT_CONFIG_OPTION_INCREMENTAL
+ /* Incremental fonts don't necessarily have valid charsets. */
+ /* They use the character code, not the glyph index, in this case. */
+ if ( decoder->builder.face->internal->incremental_interface )
+ gid = code;
+ else
+#endif /* FT_CONFIG_OPTION_INCREMENTAL */
+ {
+ gid = cff_lookup_glyph_by_stdcharcode( decoder->cff, code );
+ if ( gid < 0 )
+ return FT_THROW( Invalid_Glyph_Format );
+ }
+
+ error = decoder->get_glyph_callback( (TT_Face)decoder->builder.face,
+ (CF2_UInt)gid,
+ &charstring,
+ &len );
+ /* TODO: for now, just pass the FreeType error through */
+ if ( error )
+ return error;
+
+ /* assume input has been validated */
+ FT_ASSERT( charstring + len >= charstring );
+
+ buf->start = charstring;
+ buf->end = charstring + len;
+ buf->ptr = buf->start;
+
+ return FT_Err_Ok;
+ }
+
+
+ FT_LOCAL_DEF( void )
+ cf2_freeSeacComponent( PS_Decoder* decoder,
+ CF2_Buffer buf )
+ {
+ FT_ASSERT( decoder );
+ FT_ASSERT( !decoder->builder.is_t1 );
+
+ decoder->free_glyph_callback( (TT_Face)decoder->builder.face,
+ (FT_Byte**)&buf->start,
+ (FT_ULong)( buf->end - buf->start ) );
+ }
+
+
+ FT_LOCAL_DEF( FT_Error )
+ cf2_getT1SeacComponent( PS_Decoder* decoder,
+ FT_UInt glyph_index,
+ CF2_Buffer buf )
+ {
+ FT_Data glyph_data;
+ FT_Error error = FT_Err_Ok;
+ T1_Face face = (T1_Face)decoder->builder.face;
+ T1_Font type1 = &face->type1;
+
+#ifdef FT_CONFIG_OPTION_INCREMENTAL
+ FT_Incremental_InterfaceRec *inc =
+ face->root.internal->incremental_interface;
+
+
+ /* For incremental fonts get the character data using the */
+ /* callback function. */
+ if ( inc )
+ error = inc->funcs->get_glyph_data( inc->object,
+ glyph_index, &glyph_data );
+ else
+#endif
+ /* For ordinary fonts get the character data stored in the face record. */
+ {
+ glyph_data.pointer = type1->charstrings[glyph_index];
+ glyph_data.length = (FT_Int)type1->charstrings_len[glyph_index];
+ }
+
+ if ( !error )
+ {
+ FT_Byte* charstring_base = (FT_Byte*)glyph_data.pointer;
+ FT_ULong charstring_len = (FT_ULong)glyph_data.length;
+
+
+ FT_ASSERT( charstring_base + charstring_len >= charstring_base );
+
+ FT_ZERO( buf );
+ buf->start =
+ buf->ptr = charstring_base;
+ buf->end = charstring_base + charstring_len;
+ }
+
+ return error;
+ }
+
+
+ FT_LOCAL_DEF( void )
+ cf2_freeT1SeacComponent( PS_Decoder* decoder,
+ CF2_Buffer buf )
+ {
+ T1_Face face;
+ FT_Data data;
+
+
+ FT_ASSERT( decoder );
+
+#ifdef FT_CONFIG_OPTION_INCREMENTAL
+ face = (T1_Face)decoder->builder.face;
+
+ data.pointer = buf->start;
+ data.length = (FT_Int)( buf->end - buf->start );
+
+ if ( face->root.internal->incremental_interface )
+ face->root.internal->incremental_interface->funcs->free_glyph_data(
+ face->root.internal->incremental_interface->object,
+ &data );
+#endif /* FT_CONFIG_OPTION_INCREMENTAL */
+ }
+
+
+ FT_LOCAL_DEF( CF2_Int )
+ cf2_initLocalRegionBuffer( PS_Decoder* decoder,
+ CF2_Int subrNum,
+ CF2_Buffer buf )
+ {
+ CF2_UInt idx;
+
+
+ FT_ASSERT( decoder );
+
+ FT_ZERO( buf );
+
+ idx = (CF2_UInt)( subrNum + decoder->locals_bias );
+ if ( idx >= decoder->num_locals )
+ return TRUE; /* error */
+
+ FT_ASSERT( decoder->locals );
+
+ buf->start = decoder->locals[idx];
+
+ if ( decoder->builder.is_t1 )
+ {
+ /* The Type 1 driver stores subroutines without the seed bytes. */
+ /* The CID driver stores subroutines with seed bytes. This */
+ /* case is taken care of when decoder->subrs_len == 0. */
+ if ( decoder->locals_len )
+ buf->end = buf->start + decoder->locals_len[idx];
+ else
+ {
+ /* We are using subroutines from a CID font. We must adjust */
+ /* for the seed bytes. */
+ buf->start += ( decoder->lenIV >= 0 ? decoder->lenIV : 0 );
+ buf->end = decoder->locals[idx + 1];
+ }
+
+ if ( !buf->start )
+ {
+ FT_ERROR(( "cf2_initLocalRegionBuffer (Type 1 mode):"
+ " invoking empty subrs\n" ));
+ }
+ }
+ else
+ {
+ buf->end = decoder->locals[idx + 1];
+ }
+
+ buf->ptr = buf->start;
+
+ return FALSE; /* success */
+ }
+
+
+ FT_LOCAL_DEF( CF2_Fixed )
+ cf2_getDefaultWidthX( PS_Decoder* decoder )
+ {
+ FT_ASSERT( decoder && decoder->current_subfont );
+
+ return cf2_intToFixed(
+ decoder->current_subfont->private_dict.default_width );
+ }
+
+
+ FT_LOCAL_DEF( CF2_Fixed )
+ cf2_getNominalWidthX( PS_Decoder* decoder )
+ {
+ FT_ASSERT( decoder && decoder->current_subfont );
+
+ return cf2_intToFixed(
+ decoder->current_subfont->private_dict.nominal_width );
+ }
+
+
+ FT_LOCAL_DEF( void )
+ cf2_outline_reset( CF2_Outline outline )
+ {
+ PS_Decoder* decoder = outline->decoder;
+
+
+ FT_ASSERT( decoder );
+
+ outline->root.windingMomentum = 0;
+
+ FT_GlyphLoader_Rewind( decoder->builder.loader );
+ }
+
+
+ FT_LOCAL_DEF( void )
+ cf2_outline_close( CF2_Outline outline )
+ {
+ PS_Decoder* decoder = outline->decoder;
+
+
+ FT_ASSERT( decoder );
+
+ ps_builder_close_contour( &decoder->builder );
+
+ FT_GlyphLoader_Add( decoder->builder.loader );
+ }
+
+
+/* END */
diff --git a/src/3rdparty/freetype/src/psaux/psft.h b/src/3rdparty/freetype/src/psaux/psft.h
new file mode 100644
index 0000000000..ab172110bb
--- /dev/null
+++ b/src/3rdparty/freetype/src/psaux/psft.h
@@ -0,0 +1,167 @@
+/***************************************************************************/
+/* */
+/* psft.h */
+/* */
+/* FreeType Glue Component to Adobe's Interpreter (specification). */
+/* */
+/* Copyright 2013 Adobe Systems Incorporated. */
+/* */
+/* This software, and all works of authorship, whether in source or */
+/* object code form as indicated by the copyright notice(s) included */
+/* herein (collectively, the "Work") is made available, and may only be */
+/* used, modified, and distributed under the FreeType Project License, */
+/* LICENSE.TXT. Additionally, subject to the terms and conditions of the */
+/* FreeType Project License, each contributor to the Work hereby grants */
+/* to any individual or legal entity exercising permissions granted by */
+/* the FreeType Project License and this section (hereafter, "You" or */
+/* "Your") a perpetual, worldwide, non-exclusive, no-charge, */
+/* royalty-free, irrevocable (except as stated in this section) patent */
+/* license to make, have made, use, offer to sell, sell, import, and */
+/* otherwise transfer the Work, where such license applies only to those */
+/* patent claims licensable by such contributor that are necessarily */
+/* infringed by their contribution(s) alone or by combination of their */
+/* contribution(s) with the Work to which such contribution(s) was */
+/* submitted. If You institute patent litigation against any entity */
+/* (including a cross-claim or counterclaim in a lawsuit) alleging that */
+/* the Work or a contribution incorporated within the Work constitutes */
+/* direct or contributory patent infringement, then any patent licenses */
+/* granted to You under this License for that Work shall terminate as of */
+/* the date such litigation is filed. */
+/* */
+/* By using, modifying, or distributing the Work you indicate that you */
+/* have read and understood the terms and conditions of the */
+/* FreeType Project License as well as those provided in this section, */
+/* and you accept them fully. */
+/* */
+/***************************************************************************/
+
+
+#ifndef PSFT_H_
+#define PSFT_H_
+
+
+#include "pstypes.h"
+
+
+ /* TODO: disable asserts for now */
+#define CF2_NDEBUG
+
+
+#include FT_SYSTEM_H
+
+#include "psglue.h"
+#include FT_INTERNAL_POSTSCRIPT_AUX_H /* for PS_Decoder */
+
+
+FT_BEGIN_HEADER
+
+
+ FT_LOCAL( FT_Error )
+ cf2_decoder_parse_charstrings( PS_Decoder* decoder,
+ FT_Byte* charstring_base,
+ FT_ULong charstring_len );
+
+ FT_LOCAL( CFF_SubFont )
+ cf2_getSubfont( PS_Decoder* decoder );
+
+ FT_LOCAL( CFF_VStore )
+ cf2_getVStore( PS_Decoder* decoder );
+
+ FT_LOCAL( FT_UInt )
+ cf2_getMaxstack( PS_Decoder* decoder );
+
+#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
+ FT_LOCAL( FT_Error )
+ cf2_getNormalizedVector( PS_Decoder* decoder,
+ CF2_UInt *len,
+ FT_Fixed* *vec );
+#endif
+
+ FT_LOCAL( CF2_Fixed )
+ cf2_getPpemY( PS_Decoder* decoder );
+ FT_LOCAL( CF2_Fixed )
+ cf2_getStdVW( PS_Decoder* decoder );
+ FT_LOCAL( CF2_Fixed )
+ cf2_getStdHW( PS_Decoder* decoder );
+
+ FT_LOCAL( void )
+ cf2_getBlueMetrics( PS_Decoder* decoder,
+ CF2_Fixed* blueScale,
+ CF2_Fixed* blueShift,
+ CF2_Fixed* blueFuzz );
+ FT_LOCAL( void )
+ cf2_getBlueValues( PS_Decoder* decoder,
+ size_t* count,
+ FT_Pos* *data );
+ FT_LOCAL( void )
+ cf2_getOtherBlues( PS_Decoder* decoder,
+ size_t* count,
+ FT_Pos* *data );
+ FT_LOCAL( void )
+ cf2_getFamilyBlues( PS_Decoder* decoder,
+ size_t* count,
+ FT_Pos* *data );
+ FT_LOCAL( void )
+ cf2_getFamilyOtherBlues( PS_Decoder* decoder,
+ size_t* count,
+ FT_Pos* *data );
+
+ FT_LOCAL( CF2_Int )
+ cf2_getLanguageGroup( PS_Decoder* decoder );
+
+ FT_LOCAL( CF2_Int )
+ cf2_initGlobalRegionBuffer( PS_Decoder* decoder,
+ CF2_Int subrNum,
+ CF2_Buffer buf );
+ FT_LOCAL( FT_Error )
+ cf2_getSeacComponent( PS_Decoder* decoder,
+ CF2_Int code,
+ CF2_Buffer buf );
+ FT_LOCAL( void )
+ cf2_freeSeacComponent( PS_Decoder* decoder,
+ CF2_Buffer buf );
+ FT_LOCAL( CF2_Int )
+ cf2_initLocalRegionBuffer( PS_Decoder* decoder,
+ CF2_Int subrNum,
+ CF2_Buffer buf );
+
+ FT_LOCAL( CF2_Fixed )
+ cf2_getDefaultWidthX( PS_Decoder* decoder );
+ FT_LOCAL( CF2_Fixed )
+ cf2_getNominalWidthX( PS_Decoder* decoder );
+
+
+ FT_LOCAL( FT_Error )
+ cf2_getT1SeacComponent( PS_Decoder* decoder,
+ FT_UInt glyph_index,
+ CF2_Buffer buf );
+ FT_LOCAL( void )
+ cf2_freeT1SeacComponent( PS_Decoder* decoder,
+ CF2_Buffer buf );
+
+ /*
+ * FreeType client outline
+ *
+ * process output from the charstring interpreter
+ */
+ typedef struct CF2_OutlineRec_
+ {
+ CF2_OutlineCallbacksRec root; /* base class must be first */
+ PS_Decoder* decoder;
+
+ } CF2_OutlineRec, *CF2_Outline;
+
+
+ FT_LOCAL( void )
+ cf2_outline_reset( CF2_Outline outline );
+ FT_LOCAL( void )
+ cf2_outline_close( CF2_Outline outline );
+
+
+FT_END_HEADER
+
+
+#endif /* PSFT_H_ */
+
+
+/* END */
diff --git a/src/3rdparty/freetype/src/psaux/psglue.h b/src/3rdparty/freetype/src/psaux/psglue.h
new file mode 100644
index 0000000000..5545e12a5b
--- /dev/null
+++ b/src/3rdparty/freetype/src/psaux/psglue.h
@@ -0,0 +1,144 @@
+/***************************************************************************/
+/* */
+/* psglue.h */
+/* */
+/* Adobe's code for shared stuff (specification only). */
+/* */
+/* Copyright 2007-2013 Adobe Systems Incorporated. */
+/* */
+/* This software, and all works of authorship, whether in source or */
+/* object code form as indicated by the copyright notice(s) included */
+/* herein (collectively, the "Work") is made available, and may only be */
+/* used, modified, and distributed under the FreeType Project License, */
+/* LICENSE.TXT. Additionally, subject to the terms and conditions of the */
+/* FreeType Project License, each contributor to the Work hereby grants */
+/* to any individual or legal entity exercising permissions granted by */
+/* the FreeType Project License and this section (hereafter, "You" or */
+/* "Your") a perpetual, worldwide, non-exclusive, no-charge, */
+/* royalty-free, irrevocable (except as stated in this section) patent */
+/* license to make, have made, use, offer to sell, sell, import, and */
+/* otherwise transfer the Work, where such license applies only to those */
+/* patent claims licensable by such contributor that are necessarily */
+/* infringed by their contribution(s) alone or by combination of their */
+/* contribution(s) with the Work to which such contribution(s) was */
+/* submitted. If You institute patent litigation against any entity */
+/* (including a cross-claim or counterclaim in a lawsuit) alleging that */
+/* the Work or a contribution incorporated within the Work constitutes */
+/* direct or contributory patent infringement, then any patent licenses */
+/* granted to You under this License for that Work shall terminate as of */
+/* the date such litigation is filed. */
+/* */
+/* By using, modifying, or distributing the Work you indicate that you */
+/* have read and understood the terms and conditions of the */
+/* FreeType Project License as well as those provided in this section, */
+/* and you accept them fully. */
+/* */
+/***************************************************************************/
+
+
+#ifndef PSGLUE_H_
+#define PSGLUE_H_
+
+
+/* common includes for other modules */
+#include "pserror.h"
+#include "psfixed.h"
+#include "psarrst.h"
+#include "psread.h"
+
+
+FT_BEGIN_HEADER
+
+
+ /* rendering parameters */
+
+ /* apply hints to rendered glyphs */
+#define CF2_FlagsHinted 1
+ /* for testing */
+#define CF2_FlagsDarkened 2
+
+ /* type for holding the flags */
+ typedef CF2_Int CF2_RenderingFlags;
+
+
+ /* elements of a glyph outline */
+ typedef enum CF2_PathOp_
+ {
+ CF2_PathOpMoveTo = 1, /* change the current point */
+ CF2_PathOpLineTo = 2, /* line */
+ CF2_PathOpQuadTo = 3, /* quadratic curve */
+ CF2_PathOpCubeTo = 4 /* cubic curve */
+
+ } CF2_PathOp;
+
+
+ /* a matrix of fixed point values */
+ typedef struct CF2_Matrix_
+ {
+ CF2_F16Dot16 a;
+ CF2_F16Dot16 b;
+ CF2_F16Dot16 c;
+ CF2_F16Dot16 d;
+ CF2_F16Dot16 tx;
+ CF2_F16Dot16 ty;
+
+ } CF2_Matrix;
+
+
+ /* these typedefs are needed by more than one header file */
+ /* and gcc compiler doesn't allow redefinition */
+ typedef struct CF2_FontRec_ CF2_FontRec, *CF2_Font;
+ typedef struct CF2_HintRec_ CF2_HintRec, *CF2_Hint;
+
+
+ /* A common structure for all callback parameters. */
+ /* */
+ /* Some members may be unused. For example, `pt0' is not used for */
+ /* `moveTo' and `pt3' is not used for `quadTo'. The initial point `pt0' */
+ /* is included for each path element for generality; curve conversions */
+ /* need it. The `op' parameter allows one function to handle multiple */
+ /* element types. */
+
+ typedef struct CF2_CallbackParamsRec_
+ {
+ FT_Vector pt0;
+ FT_Vector pt1;
+ FT_Vector pt2;
+ FT_Vector pt3;
+
+ CF2_Int op;
+
+ } CF2_CallbackParamsRec, *CF2_CallbackParams;
+
+
+ /* forward reference */
+ typedef struct CF2_OutlineCallbacksRec_ CF2_OutlineCallbacksRec,
+ *CF2_OutlineCallbacks;
+
+ /* callback function pointers */
+ typedef void
+ (*CF2_Callback_Type)( CF2_OutlineCallbacks callbacks,
+ const CF2_CallbackParams params );
+
+
+ struct CF2_OutlineCallbacksRec_
+ {
+ CF2_Callback_Type moveTo;
+ CF2_Callback_Type lineTo;
+ CF2_Callback_Type quadTo;
+ CF2_Callback_Type cubeTo;
+
+ CF2_Int windingMomentum; /* for winding order detection */
+
+ FT_Memory memory;
+ FT_Error* error;
+ };
+
+
+FT_END_HEADER
+
+
+#endif /* PSGLUE_H_ */
+
+
+/* END */
diff --git a/src/3rdparty/freetype/src/psaux/pshints.c b/src/3rdparty/freetype/src/psaux/pshints.c
new file mode 100644
index 0000000000..3615196425
--- /dev/null
+++ b/src/3rdparty/freetype/src/psaux/pshints.c
@@ -0,0 +1,1939 @@
+/***************************************************************************/
+/* */
+/* pshints.c */
+/* */
+/* Adobe's code for handling CFF hints (body). */
+/* */
+/* Copyright 2007-2014 Adobe Systems Incorporated. */
+/* */
+/* This software, and all works of authorship, whether in source or */
+/* object code form as indicated by the copyright notice(s) included */
+/* herein (collectively, the "Work") is made available, and may only be */
+/* used, modified, and distributed under the FreeType Project License, */
+/* LICENSE.TXT. Additionally, subject to the terms and conditions of the */
+/* FreeType Project License, each contributor to the Work hereby grants */
+/* to any individual or legal entity exercising permissions granted by */
+/* the FreeType Project License and this section (hereafter, "You" or */
+/* "Your") a perpetual, worldwide, non-exclusive, no-charge, */
+/* royalty-free, irrevocable (except as stated in this section) patent */
+/* license to make, have made, use, offer to sell, sell, import, and */
+/* otherwise transfer the Work, where such license applies only to those */
+/* patent claims licensable by such contributor that are necessarily */
+/* infringed by their contribution(s) alone or by combination of their */
+/* contribution(s) with the Work to which such contribution(s) was */
+/* submitted. If You institute patent litigation against any entity */
+/* (including a cross-claim or counterclaim in a lawsuit) alleging that */
+/* the Work or a contribution incorporated within the Work constitutes */
+/* direct or contributory patent infringement, then any patent licenses */
+/* granted to You under this License for that Work shall terminate as of */
+/* the date such litigation is filed. */
+/* */
+/* By using, modifying, or distributing the Work you indicate that you */
+/* have read and understood the terms and conditions of the */
+/* FreeType Project License as well as those provided in this section, */
+/* and you accept them fully. */
+/* */
+/***************************************************************************/
+
+
+#include "psft.h"
+#include FT_INTERNAL_DEBUG_H
+
+#include "psglue.h"
+#include "psfont.h"
+#include "pshints.h"
+#include "psintrp.h"
+
+
+ /*************************************************************************/
+ /* */
+ /* The macro FT_COMPONENT is used in trace mode. It is an implicit */
+ /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */
+ /* messages during execution. */
+ /* */
+#undef FT_COMPONENT
+#define FT_COMPONENT trace_cf2hints
+
+
+ typedef struct CF2_HintMoveRec_
+ {
+ size_t j; /* index of upper hint map edge */
+ CF2_Fixed moveUp; /* adjustment to optimum position */
+
+ } CF2_HintMoveRec, *CF2_HintMove;
+
+
+ /* Compute angular momentum for winding order detection. It is called */
+ /* for all lines and curves, but not necessarily in element order. */
+ static CF2_Int
+ cf2_getWindingMomentum( CF2_Fixed x1,
+ CF2_Fixed y1,
+ CF2_Fixed x2,
+ CF2_Fixed y2 )
+ {
+ /* cross product of pt1 position from origin with pt2 position from */
+ /* pt1; we reduce the precision so that the result fits into 32 bits */
+
+ return ( x1 >> 16 ) * ( SUB_INT32( y2, y1 ) >> 16 ) -
+ ( y1 >> 16 ) * ( SUB_INT32( x2, x1 ) >> 16 );
+ }
+
+
+ /*
+ * Construct from a StemHint; this is used as a parameter to
+ * `cf2_blues_capture'.
+ * `hintOrigin' is the character space displacement of a seac accent.
+ * Adjust stem hint for darkening here.
+ *
+ */
+ static void
+ cf2_hint_init( CF2_Hint hint,
+ const CF2_ArrStack stemHintArray,
+ size_t indexStemHint,
+ const CF2_Font font,
+ CF2_Fixed hintOrigin,
+ CF2_Fixed scale,
+ FT_Bool bottom )
+ {
+ CF2_Fixed width;
+ const CF2_StemHintRec* stemHint;
+
+
+ FT_ZERO( hint );
+
+ stemHint = (const CF2_StemHintRec*)cf2_arrstack_getPointer(
+ stemHintArray,
+ indexStemHint );
+
+ width = SUB_INT32( stemHint->max, stemHint->min );
+
+ if ( width == cf2_intToFixed( -21 ) )
+ {
+ /* ghost bottom */
+
+ if ( bottom )
+ {
+ hint->csCoord = stemHint->max;
+ hint->flags = CF2_GhostBottom;
+ }
+ else
+ hint->flags = 0;
+ }
+
+ else if ( width == cf2_intToFixed( -20 ) )
+ {
+ /* ghost top */
+
+ if ( bottom )
+ hint->flags = 0;
+ else
+ {
+ hint->csCoord = stemHint->min;
+ hint->flags = CF2_GhostTop;
+ }
+ }
+
+ else if ( width < 0 )
+ {
+ /* inverted pair */
+
+ /*
+ * Hints with negative widths were produced by an early version of a
+ * non-Adobe font tool. The Type 2 spec allows edge (ghost) hints
+ * with negative widths, but says
+ *
+ * All other negative widths have undefined meaning.
+ *
+ * CoolType has a silent workaround that negates the hint width; for
+ * permissive mode, we do the same here.
+ *
+ * Note: Such fonts cannot use ghost hints, but should otherwise work.
+ * Note: Some poor hints in our faux fonts can produce negative
+ * widths at some blends. For example, see a light weight of
+ * `u' in ASerifMM.
+ *
+ */
+ if ( bottom )
+ {
+ hint->csCoord = stemHint->max;
+ hint->flags = CF2_PairBottom;
+ }
+ else
+ {
+ hint->csCoord = stemHint->min;
+ hint->flags = CF2_PairTop;
+ }
+ }
+
+ else
+ {
+ /* normal pair */
+
+ if ( bottom )
+ {
+ hint->csCoord = stemHint->min;
+ hint->flags = CF2_PairBottom;
+ }
+ else
+ {
+ hint->csCoord = stemHint->max;
+ hint->flags = CF2_PairTop;
+ }
+ }
+
+ /* Now that ghost hints have been detected, adjust this edge for */
+ /* darkening. Bottoms are not changed; tops are incremented by twice */
+ /* `darkenY'. */
+ if ( cf2_hint_isTop( hint ) )
+ hint->csCoord = ADD_INT32( hint->csCoord, 2 * font->darkenY );
+
+ hint->csCoord = ADD_INT32( hint->csCoord, hintOrigin );
+ hint->scale = scale;
+ hint->index = indexStemHint; /* index in original stem hint array */
+
+ /* if original stem hint has been used, use the same position */
+ if ( hint->flags != 0 && stemHint->used )
+ {
+ if ( cf2_hint_isTop( hint ) )
+ hint->dsCoord = stemHint->maxDS;
+ else
+ hint->dsCoord = stemHint->minDS;
+
+ cf2_hint_lock( hint );
+ }
+ else
+ hint->dsCoord = FT_MulFix( hint->csCoord, scale );
+ }
+
+
+ /* initialize an invalid hint map element */
+ static void
+ cf2_hint_initZero( CF2_Hint hint )
+ {
+ FT_ZERO( hint );
+ }
+
+
+ FT_LOCAL_DEF( FT_Bool )
+ cf2_hint_isValid( const CF2_Hint hint )
+ {
+ return (FT_Bool)( hint->flags != 0 );
+ }
+
+
+ static FT_Bool
+ cf2_hint_isPair( const CF2_Hint hint )
+ {
+ return (FT_Bool)( ( hint->flags &
+ ( CF2_PairBottom | CF2_PairTop ) ) != 0 );
+ }
+
+
+ static FT_Bool
+ cf2_hint_isPairTop( const CF2_Hint hint )
+ {
+ return (FT_Bool)( ( hint->flags & CF2_PairTop ) != 0 );
+ }
+
+
+ FT_LOCAL_DEF( FT_Bool )
+ cf2_hint_isTop( const CF2_Hint hint )
+ {
+ return (FT_Bool)( ( hint->flags &
+ ( CF2_PairTop | CF2_GhostTop ) ) != 0 );
+ }
+
+
+ FT_LOCAL_DEF( FT_Bool )
+ cf2_hint_isBottom( const CF2_Hint hint )
+ {
+ return (FT_Bool)( ( hint->flags &
+ ( CF2_PairBottom | CF2_GhostBottom ) ) != 0 );
+ }
+
+
+ static FT_Bool
+ cf2_hint_isLocked( const CF2_Hint hint )
+ {
+ return (FT_Bool)( ( hint->flags & CF2_Locked ) != 0 );
+ }
+
+
+ static FT_Bool
+ cf2_hint_isSynthetic( const CF2_Hint hint )
+ {
+ return (FT_Bool)( ( hint->flags & CF2_Synthetic ) != 0 );
+ }
+
+
+ FT_LOCAL_DEF( void )
+ cf2_hint_lock( CF2_Hint hint )
+ {
+ hint->flags |= CF2_Locked;
+ }
+
+
+ FT_LOCAL_DEF( void )
+ cf2_hintmap_init( CF2_HintMap hintmap,
+ CF2_Font font,
+ CF2_HintMap initialMap,
+ CF2_ArrStack hintMoves,
+ CF2_Fixed scale )
+ {
+ FT_ZERO( hintmap );
+
+ /* copy parameters from font instance */
+ hintmap->hinted = font->hinted;
+ hintmap->scale = scale;
+ hintmap->font = font;
+ hintmap->initialHintMap = initialMap;
+ /* will clear in `cf2_hintmap_adjustHints' */
+ hintmap->hintMoves = hintMoves;
+ }
+
+
+ static FT_Bool
+ cf2_hintmap_isValid( const CF2_HintMap hintmap )
+ {
+ return hintmap->isValid;
+ }
+
+
+ static void
+ cf2_hintmap_dump( CF2_HintMap hintmap )
+ {
+#ifdef FT_DEBUG_LEVEL_TRACE
+ CF2_UInt i;
+
+
+ FT_TRACE6(( " index csCoord dsCoord scale flags\n" ));
+
+ for ( i = 0; i < hintmap->count; i++ )
+ {
+ CF2_Hint hint = &hintmap->edge[i];
+
+
+ FT_TRACE6(( " %3d %7.2f %7.2f %5d %s%s%s%s\n",
+ hint->index,
+ hint->csCoord / 65536.0,
+ hint->dsCoord / ( hint->scale * 1.0 ),
+ hint->scale,
+ ( cf2_hint_isPair( hint ) ? "p" : "g" ),
+ ( cf2_hint_isTop( hint ) ? "t" : "b" ),
+ ( cf2_hint_isLocked( hint ) ? "L" : ""),
+ ( cf2_hint_isSynthetic( hint ) ? "S" : "" ) ));
+ }
+#else
+ FT_UNUSED( hintmap );
+#endif
+ }
+
+
+ /* transform character space coordinate to device space using hint map */
+ static CF2_Fixed
+ cf2_hintmap_map( CF2_HintMap hintmap,
+ CF2_Fixed csCoord )
+ {
+ if ( hintmap->count == 0 || ! hintmap->hinted )
+ {
+ /* there are no hints; use uniform scale and zero offset */
+ return FT_MulFix( csCoord, hintmap->scale );
+ }
+ else
+ {
+ /* start linear search from last hit */
+ CF2_UInt i = hintmap->lastIndex;
+
+
+ FT_ASSERT( hintmap->lastIndex < CF2_MAX_HINT_EDGES );
+
+ /* search up */
+ while ( i < hintmap->count - 1 &&
+ csCoord >= hintmap->edge[i + 1].csCoord )
+ i += 1;
+
+ /* search down */
+ while ( i > 0 && csCoord < hintmap->edge[i].csCoord )
+ i -= 1;
+
+ hintmap->lastIndex = i;
+
+ if ( i == 0 && csCoord < hintmap->edge[0].csCoord )
+ {
+ /* special case for points below first edge: use uniform scale */
+ return ADD_INT32( FT_MulFix( SUB_INT32( csCoord,
+ hintmap->edge[0].csCoord ),
+ hintmap->scale ),
+ hintmap->edge[0].dsCoord );
+ }
+ else
+ {
+ /*
+ * Note: entries with duplicate csCoord are allowed.
+ * Use edge[i], the highest entry where csCoord >= entry[i].csCoord
+ */
+ return ADD_INT32( FT_MulFix( SUB_INT32( csCoord,
+ hintmap->edge[i].csCoord ),
+ hintmap->edge[i].scale ),
+ hintmap->edge[i].dsCoord );
+ }
+ }
+ }
+
+
+ /*
+ * This hinting policy moves a hint pair in device space so that one of
+ * its two edges is on a device pixel boundary (its fractional part is
+ * zero). `cf2_hintmap_insertHint' guarantees no overlap in CS
+ * space. Ensure here that there is no overlap in DS.
+ *
+ * In the first pass, edges are adjusted relative to adjacent hints.
+ * Those that are below have already been adjusted. Those that are
+ * above have not yet been adjusted. If a hint above blocks an
+ * adjustment to an optimal position, we will try again in a second
+ * pass. The second pass is top-down.
+ *
+ */
+
+ static void
+ cf2_hintmap_adjustHints( CF2_HintMap hintmap )
+ {
+ size_t i, j;
+
+
+ cf2_arrstack_clear( hintmap->hintMoves ); /* working storage */
+
+ /*
+ * First pass is bottom-up (font hint order) without look-ahead.
+ * Locked edges are already adjusted.
+ * Unlocked edges begin with dsCoord from `initialHintMap'.
+ * Save edges that are not optimally adjusted in `hintMoves' array,
+ * and process them in second pass.
+ */
+
+ for ( i = 0; i < hintmap->count; i++ )
+ {
+ FT_Bool isPair = cf2_hint_isPair( &hintmap->edge[i] );
+
+
+ /* index of upper edge (same value for ghost hint) */
+ j = isPair ? i + 1 : i;
+
+ FT_ASSERT( j < hintmap->count );
+ FT_ASSERT( cf2_hint_isValid( &hintmap->edge[i] ) );
+ FT_ASSERT( cf2_hint_isValid( &hintmap->edge[j] ) );
+ FT_ASSERT( cf2_hint_isLocked( &hintmap->edge[i] ) ==
+ cf2_hint_isLocked( &hintmap->edge[j] ) );
+
+ if ( !cf2_hint_isLocked( &hintmap->edge[i] ) )
+ {
+ /* hint edge is not locked, we can adjust it */
+ CF2_Fixed fracDown = cf2_fixedFraction( hintmap->edge[i].dsCoord );
+ CF2_Fixed fracUp = cf2_fixedFraction( hintmap->edge[j].dsCoord );
+
+ /* calculate all four possibilities; moves down are negative */
+ CF2_Fixed downMoveDown = 0 - fracDown;
+ CF2_Fixed upMoveDown = 0 - fracUp;
+ CF2_Fixed downMoveUp = ( fracDown == 0 )
+ ? 0
+ : cf2_intToFixed( 1 ) - fracDown;
+ CF2_Fixed upMoveUp = ( fracUp == 0 )
+ ? 0
+ : cf2_intToFixed( 1 ) - fracUp;
+
+ /* smallest move up */
+ CF2_Fixed moveUp = FT_MIN( downMoveUp, upMoveUp );
+ /* smallest move down */
+ CF2_Fixed moveDown = FT_MAX( downMoveDown, upMoveDown );
+
+ /* final amount to move edge or edge pair */
+ CF2_Fixed move;
+
+ CF2_Fixed downMinCounter = CF2_MIN_COUNTER;
+ CF2_Fixed upMinCounter = CF2_MIN_COUNTER;
+ FT_Bool saveEdge = FALSE;
+
+
+ /* minimum counter constraint doesn't apply when adjacent edges */
+ /* are synthetic */
+ /* TODO: doesn't seem a big effect; for now, reduce the code */
+#if 0
+ if ( i == 0 ||
+ cf2_hint_isSynthetic( &hintmap->edge[i - 1] ) )
+ downMinCounter = 0;
+
+ if ( j >= hintmap->count - 1 ||
+ cf2_hint_isSynthetic( &hintmap->edge[j + 1] ) )
+ upMinCounter = 0;
+#endif
+
+ /* is there room to move up? */
+ /* there is if we are at top of array or the next edge is at or */
+ /* beyond proposed move up? */
+ if ( j >= hintmap->count - 1 ||
+ hintmap->edge[j + 1].dsCoord >=
+ ADD_INT32( hintmap->edge[j].dsCoord,
+ moveUp + upMinCounter ) )
+ {
+ /* there is room to move up; is there also room to move down? */
+ if ( i == 0 ||
+ hintmap->edge[i - 1].dsCoord <=
+ ADD_INT32( hintmap->edge[i].dsCoord,
+ moveDown - downMinCounter ) )
+ {
+ /* move smaller absolute amount */
+ move = ( -moveDown < moveUp ) ? moveDown : moveUp; /* optimum */
+ }
+ else
+ move = moveUp;
+ }
+ else
+ {
+ /* is there room to move down? */
+ if ( i == 0 ||
+ hintmap->edge[i - 1].dsCoord <=
+ ADD_INT32( hintmap->edge[i].dsCoord,
+ moveDown - downMinCounter ) )
+ {
+ move = moveDown;
+ /* true if non-optimum move */
+ saveEdge = (FT_Bool)( moveUp < -moveDown );
+ }
+ else
+ {
+ /* no room to move either way without overlapping or reducing */
+ /* the counter too much */
+ move = 0;
+ saveEdge = TRUE;
+ }
+ }
+
+ /* Identify non-moves and moves down that aren't optimal, and save */
+ /* them for second pass. */
+ /* Do this only if there is an unlocked edge above (which could */
+ /* possibly move). */
+ if ( saveEdge &&
+ j < hintmap->count - 1 &&
+ !cf2_hint_isLocked( &hintmap->edge[j + 1] ) )
+ {
+ CF2_HintMoveRec savedMove;
+
+
+ savedMove.j = j;
+ /* desired adjustment in second pass */
+ savedMove.moveUp = moveUp - move;
+
+ cf2_arrstack_push( hintmap->hintMoves, &savedMove );
+ }
+
+ /* move the edge(s) */
+ hintmap->edge[i].dsCoord = ADD_INT32( hintmap->edge[i].dsCoord,
+ move );
+ if ( isPair )
+ hintmap->edge[j].dsCoord = ADD_INT32( hintmap->edge[j].dsCoord,
+ move );
+ }
+
+ /* assert there are no overlaps in device space */
+ FT_ASSERT( i == 0 ||
+ hintmap->edge[i - 1].dsCoord <= hintmap->edge[i].dsCoord );
+ FT_ASSERT( i < j ||
+ hintmap->edge[i].dsCoord <= hintmap->edge[j].dsCoord );
+
+ /* adjust the scales, avoiding divide by zero */
+ if ( i > 0 )
+ {
+ if ( hintmap->edge[i].csCoord != hintmap->edge[i - 1].csCoord )
+ hintmap->edge[i - 1].scale =
+ FT_DivFix( SUB_INT32( hintmap->edge[i].dsCoord,
+ hintmap->edge[i - 1].dsCoord ),
+ SUB_INT32( hintmap->edge[i].csCoord,
+ hintmap->edge[i - 1].csCoord ) );
+ }
+
+ if ( isPair )
+ {
+ if ( hintmap->edge[j].csCoord != hintmap->edge[j - 1].csCoord )
+ hintmap->edge[j - 1].scale =
+ FT_DivFix( SUB_INT32( hintmap->edge[j].dsCoord,
+ hintmap->edge[j - 1].dsCoord ),
+ SUB_INT32( hintmap->edge[j].csCoord,
+ hintmap->edge[j - 1].csCoord ) );
+
+ i += 1; /* skip upper edge on next loop */
+ }
+ }
+
+ /* second pass tries to move non-optimal hints up, in case there is */
+ /* room now */
+ for ( i = cf2_arrstack_size( hintmap->hintMoves ); i > 0; i-- )
+ {
+ CF2_HintMove hintMove = (CF2_HintMove)
+ cf2_arrstack_getPointer( hintmap->hintMoves, i - 1 );
+
+
+ j = hintMove->j;
+
+ /* this was tested before the push, above */
+ FT_ASSERT( j < hintmap->count - 1 );
+
+ /* is there room to move up? */
+ if ( hintmap->edge[j + 1].dsCoord >=
+ ADD_INT32( hintmap->edge[j].dsCoord,
+ hintMove->moveUp + CF2_MIN_COUNTER ) )
+ {
+ /* there is more room now, move edge up */
+ hintmap->edge[j].dsCoord = ADD_INT32( hintmap->edge[j].dsCoord,
+ hintMove->moveUp );
+
+ if ( cf2_hint_isPair( &hintmap->edge[j] ) )
+ {
+ FT_ASSERT( j > 0 );
+ hintmap->edge[j - 1].dsCoord =
+ ADD_INT32( hintmap->edge[j - 1].dsCoord, hintMove->moveUp );
+ }
+ }
+ }
+ }
+
+
+ /* insert hint edges into map, sorted by csCoord */
+ static void
+ cf2_hintmap_insertHint( CF2_HintMap hintmap,
+ CF2_Hint bottomHintEdge,
+ CF2_Hint topHintEdge )
+ {
+ CF2_UInt indexInsert;
+
+ /* set default values, then check for edge hints */
+ FT_Bool isPair = TRUE;
+ CF2_Hint firstHintEdge = bottomHintEdge;
+ CF2_Hint secondHintEdge = topHintEdge;
+
+
+ /* one or none of the input params may be invalid when dealing with */
+ /* edge hints; at least one edge must be valid */
+ FT_ASSERT( cf2_hint_isValid( bottomHintEdge ) ||
+ cf2_hint_isValid( topHintEdge ) );
+
+ /* determine how many and which edges to insert */
+ if ( !cf2_hint_isValid( bottomHintEdge ) )
+ {
+ /* insert only the top edge */
+ firstHintEdge = topHintEdge;
+ isPair = FALSE;
+ }
+ else if ( !cf2_hint_isValid( topHintEdge ) )
+ {
+ /* insert only the bottom edge */
+ isPair = FALSE;
+ }
+
+ /* paired edges must be in proper order */
+ if ( isPair &&
+ topHintEdge->csCoord < bottomHintEdge->csCoord )
+ return;
+
+ /* linear search to find index value of insertion point */
+ indexInsert = 0;
+ for ( ; indexInsert < hintmap->count; indexInsert++ )
+ {
+ if ( hintmap->edge[indexInsert].csCoord >= firstHintEdge->csCoord )
+ break;
+ }
+
+ FT_TRACE7(( " Got hint at %.2f (%.2f)\n",
+ firstHintEdge->csCoord / 65536.0,
+ firstHintEdge->dsCoord / 65536.0 ));
+ if ( isPair )
+ FT_TRACE7(( " Got hint at %.2f (%.2f)\n",
+ secondHintEdge->csCoord / 65536.0,
+ secondHintEdge->dsCoord / 65536.0 ));
+
+ /*
+ * Discard any hints that overlap in character space. Most often, this
+ * is while building the initial map, where captured hints from all
+ * zones are combined. Define overlap to include hints that `touch'
+ * (overlap zero). Hiragino Sans/Gothic fonts have numerous hints that
+ * touch. Some fonts have non-ideographic glyphs that overlap our
+ * synthetic hints.
+ *
+ * Overlap also occurs when darkening stem hints that are close.
+ *
+ */
+ if ( indexInsert < hintmap->count )
+ {
+ /* we are inserting before an existing edge: */
+ /* verify that an existing edge is not the same */
+ if ( hintmap->edge[indexInsert].csCoord == firstHintEdge->csCoord )
+ return; /* ignore overlapping stem hint */
+
+ /* verify that a new pair does not straddle the next edge */
+ if ( isPair &&
+ hintmap->edge[indexInsert].csCoord <= secondHintEdge->csCoord )
+ return; /* ignore overlapping stem hint */
+
+ /* verify that we are not inserting between paired edges */
+ if ( cf2_hint_isPairTop( &hintmap->edge[indexInsert] ) )
+ return; /* ignore overlapping stem hint */
+ }
+
+ /* recompute device space locations using initial hint map */
+ if ( cf2_hintmap_isValid( hintmap->initialHintMap ) &&
+ !cf2_hint_isLocked( firstHintEdge ) )
+ {
+ if ( isPair )
+ {
+ /* Use hint map to position the center of stem, and nominal scale */
+ /* to position the two edges. This preserves the stem width. */
+ CF2_Fixed midpoint =
+ cf2_hintmap_map(
+ hintmap->initialHintMap,
+ ADD_INT32( secondHintEdge->csCoord,
+ firstHintEdge->csCoord ) / 2 );
+ CF2_Fixed halfWidth =
+ FT_MulFix( SUB_INT32( secondHintEdge->csCoord,
+ firstHintEdge->csCoord ) / 2,
+ hintmap->scale );
+
+
+ firstHintEdge->dsCoord = SUB_INT32( midpoint, halfWidth );
+ secondHintEdge->dsCoord = ADD_INT32( midpoint, halfWidth );
+ }
+ else
+ firstHintEdge->dsCoord = cf2_hintmap_map( hintmap->initialHintMap,
+ firstHintEdge->csCoord );
+ }
+
+ /*
+ * Discard any hints that overlap in device space; this can occur
+ * because locked hints have been moved to align with blue zones.
+ *
+ * TODO: Although we might correct this later during adjustment, we
+ * don't currently have a way to delete a conflicting hint once it has
+ * been inserted. See v2.030 MinionPro-Regular, 12 ppem darkened,
+ * initial hint map for second path, glyph 945 (the perispomeni (tilde)
+ * in U+1F6E, Greek omega with psili and perispomeni). Darkening is
+ * 25. Pair 667,747 initially conflicts in design space with top edge
+ * 660. This is because 667 maps to 7.87, and the top edge was
+ * captured by a zone at 8.0. The pair is later successfully inserted
+ * in a zone without the top edge. In this zone it is adjusted to 8.0,
+ * and no longer conflicts with the top edge in design space. This
+ * means it can be included in yet a later zone which does have the top
+ * edge hint. This produces a small mismatch between the first and
+ * last points of this path, even though the hint masks are the same.
+ * The density map difference is tiny (1/256).
+ *
+ */
+
+ if ( indexInsert > 0 )
+ {
+ /* we are inserting after an existing edge */
+ if ( firstHintEdge->dsCoord < hintmap->edge[indexInsert - 1].dsCoord )
+ return;
+ }
+
+ if ( indexInsert < hintmap->count )
+ {
+ /* we are inserting before an existing edge */
+ if ( isPair )
+ {
+ if ( secondHintEdge->dsCoord > hintmap->edge[indexInsert].dsCoord )
+ return;
+ }
+ else
+ {
+ if ( firstHintEdge->dsCoord > hintmap->edge[indexInsert].dsCoord )
+ return;
+ }
+ }
+
+ /* make room to insert */
+ {
+ CF2_UInt iSrc = hintmap->count - 1;
+ CF2_UInt iDst = isPair ? hintmap->count + 1 : hintmap->count;
+
+ CF2_UInt count = hintmap->count - indexInsert;
+
+
+ if ( iDst >= CF2_MAX_HINT_EDGES )
+ {
+ FT_TRACE4(( "cf2_hintmap_insertHint: too many hintmaps\n" ));
+ return;
+ }
+
+ while ( count-- )
+ hintmap->edge[iDst--] = hintmap->edge[iSrc--];
+
+ /* insert first edge */
+ hintmap->edge[indexInsert] = *firstHintEdge; /* copy struct */
+ hintmap->count += 1;
+
+ FT_TRACE7(( " Inserting hint %.2f (%.2f)\n",
+ firstHintEdge->csCoord / 65536.0,
+ firstHintEdge->dsCoord / 65536.0 ));
+
+ if ( isPair )
+ {
+ /* insert second edge */
+ hintmap->edge[indexInsert + 1] = *secondHintEdge; /* copy struct */
+ hintmap->count += 1;
+
+ FT_TRACE7(( " Inserting hint %.2f (%.2f)\n",
+ secondHintEdge->csCoord / 65536.0,
+ secondHintEdge->dsCoord / 65536.0 ));
+
+ }
+ }
+
+ return;
+ }
+
+
+ /*
+ * Build a map from hints and mask.
+ *
+ * This function may recur one level if `hintmap->initialHintMap' is not yet
+ * valid.
+ * If `initialMap' is true, simply build initial map.
+ *
+ * Synthetic hints are used in two ways. A hint at zero is inserted, if
+ * needed, in the initial hint map, to prevent translations from
+ * propagating across the origin. If synthetic em box hints are enabled
+ * for ideographic dictionaries, then they are inserted in all hint
+ * maps, including the initial one.
+ *
+ */
+ FT_LOCAL_DEF( void )
+ cf2_hintmap_build( CF2_HintMap hintmap,
+ CF2_ArrStack hStemHintArray,
+ CF2_ArrStack vStemHintArray,
+ CF2_HintMask hintMask,
+ CF2_Fixed hintOrigin,
+ FT_Bool initialMap )
+ {
+ FT_Byte* maskPtr;
+
+ CF2_Font font = hintmap->font;
+ CF2_HintMaskRec tempHintMask;
+
+ size_t bitCount, i;
+ FT_Byte maskByte;
+
+
+ /* check whether initial map is constructed */
+ if ( !initialMap && !cf2_hintmap_isValid( hintmap->initialHintMap ) )
+ {
+ /* make recursive call with initialHintMap and temporary mask; */
+ /* temporary mask will get all bits set, below */
+ cf2_hintmask_init( &tempHintMask, hintMask->error );
+ cf2_hintmap_build( hintmap->initialHintMap,
+ hStemHintArray,
+ vStemHintArray,
+ &tempHintMask,
+ hintOrigin,
+ TRUE );
+ }
+
+ if ( !cf2_hintmask_isValid( hintMask ) )
+ {
+ /* without a hint mask, assume all hints are active */
+ cf2_hintmask_setAll( hintMask,
+ cf2_arrstack_size( hStemHintArray ) +
+ cf2_arrstack_size( vStemHintArray ) );
+ if ( !cf2_hintmask_isValid( hintMask ) )
+ {
+ if ( font->isT1 )
+ {
+ /* no error, just continue unhinted */
+ *hintMask->error = FT_Err_Ok;
+ hintmap->hinted = FALSE;
+ }
+ return; /* too many stem hints */
+ }
+ }
+
+ /* begin by clearing the map */
+ hintmap->count = 0;
+ hintmap->lastIndex = 0;
+
+ /* make a copy of the hint mask so we can modify it */
+ tempHintMask = *hintMask;
+ maskPtr = cf2_hintmask_getMaskPtr( &tempHintMask );
+
+ /* use the hStem hints only, which are first in the mask */
+ bitCount = cf2_arrstack_size( hStemHintArray );
+
+ /* Defense-in-depth. Should never return here. */
+ if ( bitCount > hintMask->bitCount )
+ return;
+
+ /* synthetic embox hints get highest priority */
+ if ( font->blues.doEmBoxHints )
+ {
+ CF2_HintRec dummy;
+
+
+ cf2_hint_initZero( &dummy ); /* invalid hint map element */
+
+ /* ghost bottom */
+ cf2_hintmap_insertHint( hintmap,
+ &font->blues.emBoxBottomEdge,
+ &dummy );
+ /* ghost top */
+ cf2_hintmap_insertHint( hintmap,
+ &dummy,
+ &font->blues.emBoxTopEdge );
+ }
+
+ /* insert hints captured by a blue zone or already locked (higher */
+ /* priority) */
+ for ( i = 0, maskByte = 0x80; i < bitCount; i++ )
+ {
+ if ( maskByte & *maskPtr )
+ {
+ /* expand StemHint into two `CF2_Hint' elements */
+ CF2_HintRec bottomHintEdge, topHintEdge;
+
+
+ cf2_hint_init( &bottomHintEdge,
+ hStemHintArray,
+ i,
+ font,
+ hintOrigin,
+ hintmap->scale,
+ TRUE /* bottom */ );
+ cf2_hint_init( &topHintEdge,
+ hStemHintArray,
+ i,
+ font,
+ hintOrigin,
+ hintmap->scale,
+ FALSE /* top */ );
+
+ if ( cf2_hint_isLocked( &bottomHintEdge ) ||
+ cf2_hint_isLocked( &topHintEdge ) ||
+ cf2_blues_capture( &font->blues,
+ &bottomHintEdge,
+ &topHintEdge ) )
+ {
+ /* insert captured hint into map */
+ cf2_hintmap_insertHint( hintmap, &bottomHintEdge, &topHintEdge );
+
+ *maskPtr &= ~maskByte; /* turn off the bit for this hint */
+ }
+ }
+
+ if ( ( i & 7 ) == 7 )
+ {
+ /* move to next mask byte */
+ maskPtr++;
+ maskByte = 0x80;
+ }
+ else
+ maskByte >>= 1;
+ }
+
+ /* initial hint map includes only captured hints plus maybe one at 0 */
+
+ /*
+ * TODO: There is a problem here because we are trying to build a
+ * single hint map containing all captured hints. It is
+ * possible for there to be conflicts between captured hints,
+ * either because of darkening or because the hints are in
+ * separate hint zones (we are ignoring hint zones for the
+ * initial map). An example of the latter is MinionPro-Regular
+ * v2.030 glyph 883 (Greek Capital Alpha with Psili) at 15ppem.
+ * A stem hint for the psili conflicts with the top edge hint
+ * for the base character. The stem hint gets priority because
+ * of its sort order. In glyph 884 (Greek Capital Alpha with
+ * Psili and Oxia), the top of the base character gets a stem
+ * hint, and the psili does not. This creates different initial
+ * maps for the two glyphs resulting in different renderings of
+ * the base character. Will probably defer this either as not
+ * worth the cost or as a font bug. I don't think there is any
+ * good reason for an accent to be captured by an alignment
+ * zone. -darnold 2/12/10
+ */
+
+ if ( initialMap )
+ {
+ /* Apply a heuristic that inserts a point for (0,0), unless it's */
+ /* already covered by a mapping. This locks the baseline for glyphs */
+ /* that have no baseline hints. */
+
+ if ( hintmap->count == 0 ||
+ hintmap->edge[0].csCoord > 0 ||
+ hintmap->edge[hintmap->count - 1].csCoord < 0 )
+ {
+ /* all edges are above 0 or all edges are below 0; */
+ /* construct a locked edge hint at 0 */
+
+ CF2_HintRec edge, invalid;
+
+
+ cf2_hint_initZero( &edge );
+
+ edge.flags = CF2_GhostBottom |
+ CF2_Locked |
+ CF2_Synthetic;
+ edge.scale = hintmap->scale;
+
+ cf2_hint_initZero( &invalid );
+ cf2_hintmap_insertHint( hintmap, &edge, &invalid );
+ }
+ }
+ else
+ {
+ /* insert remaining hints */
+
+ maskPtr = cf2_hintmask_getMaskPtr( &tempHintMask );
+
+ for ( i = 0, maskByte = 0x80; i < bitCount; i++ )
+ {
+ if ( maskByte & *maskPtr )
+ {
+ CF2_HintRec bottomHintEdge, topHintEdge;
+
+
+ cf2_hint_init( &bottomHintEdge,
+ hStemHintArray,
+ i,
+ font,
+ hintOrigin,
+ hintmap->scale,
+ TRUE /* bottom */ );
+ cf2_hint_init( &topHintEdge,
+ hStemHintArray,
+ i,
+ font,
+ hintOrigin,
+ hintmap->scale,
+ FALSE /* top */ );
+
+ cf2_hintmap_insertHint( hintmap, &bottomHintEdge, &topHintEdge );
+ }
+
+ if ( ( i & 7 ) == 7 )
+ {
+ /* move to next mask byte */
+ maskPtr++;
+ maskByte = 0x80;
+ }
+ else
+ maskByte >>= 1;
+ }
+ }
+
+ FT_TRACE6(( initialMap ? "flags: [p]air [g]host [t]op "
+ "[b]ottom [L]ocked [S]ynthetic\n"
+ "Initial hintmap\n"
+ : "Hints:\n" ));
+ cf2_hintmap_dump( hintmap );
+
+ /*
+ * Note: The following line is a convenient place to break when
+ * debugging hinting. Examine `hintmap->edge' for the list of
+ * enabled hints, then step over the call to see the effect of
+ * adjustment. We stop here first on the recursive call that
+ * creates the initial map, and then on each counter group and
+ * hint zone.
+ */
+
+ /* adjust positions of hint edges that are not locked to blue zones */
+ cf2_hintmap_adjustHints( hintmap );
+
+ FT_TRACE6(( "(adjusted)\n" ));
+ cf2_hintmap_dump( hintmap );
+
+ /* save the position of all hints that were used in this hint map; */
+ /* if we use them again, we'll locate them in the same position */
+ if ( !initialMap )
+ {
+ for ( i = 0; i < hintmap->count; i++ )
+ {
+ if ( !cf2_hint_isSynthetic( &hintmap->edge[i] ) )
+ {
+ /* Note: include both valid and invalid edges */
+ /* Note: top and bottom edges are copied back separately */
+ CF2_StemHint stemhint = (CF2_StemHint)
+ cf2_arrstack_getPointer( hStemHintArray,
+ hintmap->edge[i].index );
+
+
+ if ( cf2_hint_isTop( &hintmap->edge[i] ) )
+ stemhint->maxDS = hintmap->edge[i].dsCoord;
+ else
+ stemhint->minDS = hintmap->edge[i].dsCoord;
+
+ stemhint->used = TRUE;
+ }
+ }
+ }
+
+ /* hint map is ready to use */
+ hintmap->isValid = TRUE;
+
+ /* remember this mask has been used */
+ cf2_hintmask_setNew( hintMask, FALSE );
+ }
+
+
+ FT_LOCAL_DEF( void )
+ cf2_glyphpath_init( CF2_GlyphPath glyphpath,
+ CF2_Font font,
+ CF2_OutlineCallbacks callbacks,
+ CF2_Fixed scaleY,
+ /* CF2_Fixed hShift, */
+ CF2_ArrStack hStemHintArray,
+ CF2_ArrStack vStemHintArray,
+ CF2_HintMask hintMask,
+ CF2_Fixed hintOriginY,
+ const CF2_Blues blues,
+ const FT_Vector* fractionalTranslation )
+ {
+ FT_ZERO( glyphpath );
+
+ glyphpath->font = font;
+ glyphpath->callbacks = callbacks;
+
+ cf2_arrstack_init( &glyphpath->hintMoves,
+ font->memory,
+ &font->error,
+ sizeof ( CF2_HintMoveRec ) );
+
+ cf2_hintmap_init( &glyphpath->initialHintMap,
+ font,
+ &glyphpath->initialHintMap,
+ &glyphpath->hintMoves,
+ scaleY );
+ cf2_hintmap_init( &glyphpath->firstHintMap,
+ font,
+ &glyphpath->initialHintMap,
+ &glyphpath->hintMoves,
+ scaleY );
+ cf2_hintmap_init( &glyphpath->hintMap,
+ font,
+ &glyphpath->initialHintMap,
+ &glyphpath->hintMoves,
+ scaleY );
+
+ glyphpath->scaleX = font->innerTransform.a;
+ glyphpath->scaleC = font->innerTransform.c;
+ glyphpath->scaleY = font->innerTransform.d;
+
+ glyphpath->fractionalTranslation = *fractionalTranslation;
+
+#if 0
+ glyphpath->hShift = hShift; /* for fauxing */
+#endif
+
+ glyphpath->hStemHintArray = hStemHintArray;
+ glyphpath->vStemHintArray = vStemHintArray;
+ glyphpath->hintMask = hintMask; /* ptr to current mask */
+ glyphpath->hintOriginY = hintOriginY;
+ glyphpath->blues = blues;
+ glyphpath->darken = font->darkened; /* TODO: should we make copies? */
+ glyphpath->xOffset = font->darkenX;
+ glyphpath->yOffset = font->darkenY;
+ glyphpath->miterLimit = 2 * FT_MAX(
+ cf2_fixedAbs( glyphpath->xOffset ),
+ cf2_fixedAbs( glyphpath->yOffset ) );
+
+ /* .1 character space unit */
+ glyphpath->snapThreshold = cf2_doubleToFixed( 0.1 );
+
+ glyphpath->moveIsPending = TRUE;
+ glyphpath->pathIsOpen = FALSE;
+ glyphpath->pathIsClosing = FALSE;
+ glyphpath->elemIsQueued = FALSE;
+ }
+
+
+ FT_LOCAL_DEF( void )
+ cf2_glyphpath_finalize( CF2_GlyphPath glyphpath )
+ {
+ cf2_arrstack_finalize( &glyphpath->hintMoves );
+ }
+
+
+ /*
+ * Hint point in y-direction and apply outerTransform.
+ * Input `current' hint map (which is actually delayed by one element).
+ * Input x,y point in Character Space.
+ * Output x,y point in Device Space, including translation.
+ */
+ static void
+ cf2_glyphpath_hintPoint( CF2_GlyphPath glyphpath,
+ CF2_HintMap hintmap,
+ FT_Vector* ppt,
+ CF2_Fixed x,
+ CF2_Fixed y )
+ {
+ FT_Vector pt; /* hinted point in upright DS */
+
+
+ pt.x = ADD_INT32( FT_MulFix( glyphpath->scaleX, x ),
+ FT_MulFix( glyphpath->scaleC, y ) );
+ pt.y = cf2_hintmap_map( hintmap, y );
+
+ ppt->x = ADD_INT32(
+ FT_MulFix( glyphpath->font->outerTransform.a, pt.x ),
+ ADD_INT32(
+ FT_MulFix( glyphpath->font->outerTransform.c, pt.y ),
+ glyphpath->fractionalTranslation.x ) );
+ ppt->y = ADD_INT32(
+ FT_MulFix( glyphpath->font->outerTransform.b, pt.x ),
+ ADD_INT32(
+ FT_MulFix( glyphpath->font->outerTransform.d, pt.y ),
+ glyphpath->fractionalTranslation.y ) );
+ }
+
+
+ /*
+ * From two line segments, (u1,u2) and (v1,v2), compute a point of
+ * intersection on the corresponding lines.
+ * Return false if no intersection is found, or if the intersection is
+ * too far away from the ends of the line segments, u2 and v1.
+ *
+ */
+ static FT_Bool
+ cf2_glyphpath_computeIntersection( CF2_GlyphPath glyphpath,
+ const FT_Vector* u1,
+ const FT_Vector* u2,
+ const FT_Vector* v1,
+ const FT_Vector* v2,
+ FT_Vector* intersection )
+ {
+ /*
+ * Let `u' be a zero-based vector from the first segment, `v' from the
+ * second segment.
+ * Let `w 'be the zero-based vector from `u1' to `v1'.
+ * `perp' is the `perpendicular dot product'; see
+ * https://mathworld.wolfram.com/PerpDotProduct.html.
+ * `s' is the parameter for the parametric line for the first segment
+ * (`u').
+ *
+ * See notation in
+ * http://softsurfer.com/Archive/algorithm_0104/algorithm_0104B.htm.
+ * Calculations are done in 16.16, but must handle the squaring of
+ * line lengths in character space. We scale all vectors by 1/32 to
+ * avoid overflow. This allows values up to 4095 to be squared. The
+ * scale factor cancels in the divide.
+ *
+ * TODO: the scale factor could be computed from UnitsPerEm.
+ *
+ */
+
+#define cf2_perp( a, b ) \
+ ( FT_MulFix( a.x, b.y ) - FT_MulFix( a.y, b.x ) )
+
+ /* round and divide by 32 */
+#define CF2_CS_SCALE( x ) \
+ ( ( (x) + 0x10 ) >> 5 )
+
+ FT_Vector u, v, w; /* scaled vectors */
+ CF2_Fixed denominator, s;
+
+
+ u.x = CF2_CS_SCALE( SUB_INT32( u2->x, u1->x ) );
+ u.y = CF2_CS_SCALE( SUB_INT32( u2->y, u1->y ) );
+ v.x = CF2_CS_SCALE( SUB_INT32( v2->x, v1->x ) );
+ v.y = CF2_CS_SCALE( SUB_INT32( v2->y, v1->y ) );
+ w.x = CF2_CS_SCALE( SUB_INT32( v1->x, u1->x ) );
+ w.y = CF2_CS_SCALE( SUB_INT32( v1->y, u1->y ) );
+
+ denominator = cf2_perp( u, v );
+
+ if ( denominator == 0 )
+ return FALSE; /* parallel or coincident lines */
+
+ s = FT_DivFix( cf2_perp( w, v ), denominator );
+
+ intersection->x = ADD_INT32( u1->x,
+ FT_MulFix( s, SUB_INT32( u2->x, u1->x ) ) );
+ intersection->y = ADD_INT32( u1->y,
+ FT_MulFix( s, SUB_INT32( u2->y, u1->y ) ) );
+
+
+ /*
+ * Special case snapping for horizontal and vertical lines.
+ * This cleans up intersections and reduces problems with winding
+ * order detection.
+ * Sample case is sbc cd KozGoPr6N-Medium.otf 20 16685.
+ * Note: these calculations are in character space.
+ *
+ */
+
+ if ( u1->x == u2->x &&
+ cf2_fixedAbs( SUB_INT32( intersection->x,
+ u1->x ) ) < glyphpath->snapThreshold )
+ intersection->x = u1->x;
+ if ( u1->y == u2->y &&
+ cf2_fixedAbs( SUB_INT32( intersection->y,
+ u1->y ) ) < glyphpath->snapThreshold )
+ intersection->y = u1->y;
+
+ if ( v1->x == v2->x &&
+ cf2_fixedAbs( SUB_INT32( intersection->x,
+ v1->x ) ) < glyphpath->snapThreshold )
+ intersection->x = v1->x;
+ if ( v1->y == v2->y &&
+ cf2_fixedAbs( SUB_INT32( intersection->y,
+ v1->y ) ) < glyphpath->snapThreshold )
+ intersection->y = v1->y;
+
+ /* limit the intersection distance from midpoint of u2 and v1 */
+ if ( cf2_fixedAbs( intersection->x - ADD_INT32( u2->x, v1->x ) / 2 ) >
+ glyphpath->miterLimit ||
+ cf2_fixedAbs( intersection->y - ADD_INT32( u2->y, v1->y ) / 2 ) >
+ glyphpath->miterLimit )
+ return FALSE;
+
+ return TRUE;
+ }
+
+
+ /*
+ * Push the cached element (glyphpath->prevElem*) to the outline
+ * consumer. When a darkening offset is used, the end point of the
+ * cached element may be adjusted to an intersection point or we may
+ * synthesize a connecting line to the current element. If we are
+ * closing a subpath, we may also generate a connecting line to the start
+ * point.
+ *
+ * This is where Character Space (CS) is converted to Device Space (DS)
+ * using a hint map. This calculation must use a HintMap that was valid
+ * at the time the element was saved. For the first point in a subpath,
+ * that is a saved HintMap. For most elements, it just means the caller
+ * has delayed building a HintMap from the current HintMask.
+ *
+ * Transform each point with outerTransform and call the outline
+ * callbacks. This is a general 3x3 transform:
+ *
+ * x' = a*x + c*y + tx, y' = b*x + d*y + ty
+ *
+ * but it uses 4 elements from CF2_Font and the translation part
+ * from CF2_GlyphPath.
+ *
+ */
+ static void
+ cf2_glyphpath_pushPrevElem( CF2_GlyphPath glyphpath,
+ CF2_HintMap hintmap,
+ FT_Vector* nextP0,
+ FT_Vector nextP1,
+ FT_Bool close )
+ {
+ CF2_CallbackParamsRec params;
+
+ FT_Vector* prevP0;
+ FT_Vector* prevP1;
+
+ FT_Vector intersection = { 0, 0 };
+ FT_Bool useIntersection = FALSE;
+
+
+ FT_ASSERT( glyphpath->prevElemOp == CF2_PathOpLineTo ||
+ glyphpath->prevElemOp == CF2_PathOpCubeTo );
+
+ if ( glyphpath->prevElemOp == CF2_PathOpLineTo )
+ {
+ prevP0 = &glyphpath->prevElemP0;
+ prevP1 = &glyphpath->prevElemP1;
+ }
+ else
+ {
+ prevP0 = &glyphpath->prevElemP2;
+ prevP1 = &glyphpath->prevElemP3;
+ }
+
+ /* optimization: if previous and next elements are offset by the same */
+ /* amount, then there will be no gap, and no need to compute an */
+ /* intersection. */
+ if ( prevP1->x != nextP0->x || prevP1->y != nextP0->y )
+ {
+ /* previous element does not join next element: */
+ /* adjust end point of previous element to the intersection */
+ useIntersection = cf2_glyphpath_computeIntersection( glyphpath,
+ prevP0,
+ prevP1,
+ nextP0,
+ &nextP1,
+ &intersection );
+ if ( useIntersection )
+ {
+ /* modify the last point of the cached element (either line or */
+ /* curve) */
+ *prevP1 = intersection;
+ }
+ }
+
+ params.pt0 = glyphpath->currentDS;
+
+ switch( glyphpath->prevElemOp )
+ {
+ case CF2_PathOpLineTo:
+ params.op = CF2_PathOpLineTo;
+
+ /* note: pt2 and pt3 are unused */
+
+ if ( close )
+ {
+ /* use first hint map if closing */
+ cf2_glyphpath_hintPoint( glyphpath,
+ &glyphpath->firstHintMap,
+ &params.pt1,
+ glyphpath->prevElemP1.x,
+ glyphpath->prevElemP1.y );
+ }
+ else
+ {
+ cf2_glyphpath_hintPoint( glyphpath,
+ hintmap,
+ &params.pt1,
+ glyphpath->prevElemP1.x,
+ glyphpath->prevElemP1.y );
+ }
+
+ /* output only non-zero length lines */
+ if ( params.pt0.x != params.pt1.x || params.pt0.y != params.pt1.y )
+ {
+ glyphpath->callbacks->lineTo( glyphpath->callbacks, &params );
+
+ glyphpath->currentDS = params.pt1;
+ }
+ break;
+
+ case CF2_PathOpCubeTo:
+ params.op = CF2_PathOpCubeTo;
+
+ /* TODO: should we intersect the interior joins (p1-p2 and p2-p3)? */
+ cf2_glyphpath_hintPoint( glyphpath,
+ hintmap,
+ &params.pt1,
+ glyphpath->prevElemP1.x,
+ glyphpath->prevElemP1.y );
+ cf2_glyphpath_hintPoint( glyphpath,
+ hintmap,
+ &params.pt2,
+ glyphpath->prevElemP2.x,
+ glyphpath->prevElemP2.y );
+ cf2_glyphpath_hintPoint( glyphpath,
+ hintmap,
+ &params.pt3,
+ glyphpath->prevElemP3.x,
+ glyphpath->prevElemP3.y );
+
+ glyphpath->callbacks->cubeTo( glyphpath->callbacks, &params );
+
+ glyphpath->currentDS = params.pt3;
+
+ break;
+ }
+
+ if ( !useIntersection || close )
+ {
+ /* insert connecting line between end of previous element and start */
+ /* of current one */
+ /* note: at the end of a subpath, we might do both, so use `nextP0' */
+ /* before we change it, below */
+
+ if ( close )
+ {
+ /* if we are closing the subpath, then nextP0 is in the first */
+ /* hint zone */
+ cf2_glyphpath_hintPoint( glyphpath,
+ &glyphpath->firstHintMap,
+ &params.pt1,
+ nextP0->x,
+ nextP0->y );
+ }
+ else
+ {
+ cf2_glyphpath_hintPoint( glyphpath,
+ hintmap,
+ &params.pt1,
+ nextP0->x,
+ nextP0->y );
+ }
+
+ if ( params.pt1.x != glyphpath->currentDS.x ||
+ params.pt1.y != glyphpath->currentDS.y )
+ {
+ /* length is nonzero */
+ params.op = CF2_PathOpLineTo;
+ params.pt0 = glyphpath->currentDS;
+
+ /* note: pt2 and pt3 are unused */
+ glyphpath->callbacks->lineTo( glyphpath->callbacks, &params );
+
+ glyphpath->currentDS = params.pt1;
+ }
+ }
+
+ if ( useIntersection )
+ {
+ /* return intersection point to caller */
+ *nextP0 = intersection;
+ }
+ }
+
+
+ /* push a MoveTo element based on current point and offset of current */
+ /* element */
+ static void
+ cf2_glyphpath_pushMove( CF2_GlyphPath glyphpath,
+ FT_Vector start )
+ {
+ CF2_CallbackParamsRec params;
+
+
+ params.op = CF2_PathOpMoveTo;
+ params.pt0 = glyphpath->currentDS;
+
+ /* Test if move has really happened yet; it would have called */
+ /* `cf2_hintmap_build' to set `isValid'. */
+ if ( !cf2_hintmap_isValid( &glyphpath->hintMap ) )
+ {
+ /* we are here iff first subpath is missing a moveto operator: */
+ /* synthesize first moveTo to finish initialization of hintMap */
+ cf2_glyphpath_moveTo( glyphpath,
+ glyphpath->start.x,
+ glyphpath->start.y );
+ }
+
+ cf2_glyphpath_hintPoint( glyphpath,
+ &glyphpath->hintMap,
+ &params.pt1,
+ start.x,
+ start.y );
+
+ /* note: pt2 and pt3 are unused */
+ glyphpath->callbacks->moveTo( glyphpath->callbacks, &params );
+
+ glyphpath->currentDS = params.pt1;
+ glyphpath->offsetStart0 = start;
+ }
+
+
+ /*
+ * All coordinates are in character space.
+ * On input, (x1, y1) and (x2, y2) give line segment.
+ * On output, (x, y) give offset vector.
+ * We use a piecewise approximation to trig functions.
+ *
+ * TODO: Offset true perpendicular and proper length
+ * supply the y-translation for hinting here, too,
+ * that adds yOffset unconditionally to *y.
+ */
+ static void
+ cf2_glyphpath_computeOffset( CF2_GlyphPath glyphpath,
+ CF2_Fixed x1,
+ CF2_Fixed y1,
+ CF2_Fixed x2,
+ CF2_Fixed y2,
+ CF2_Fixed* x,
+ CF2_Fixed* y )
+ {
+ CF2_Fixed dx = SUB_INT32( x2, x1 );
+ CF2_Fixed dy = SUB_INT32( y2, y1 );
+
+
+ /* note: negative offsets don't work here; negate deltas to change */
+ /* quadrants, below */
+ if ( glyphpath->font->reverseWinding )
+ {
+ dx = NEG_INT32( dx );
+ dy = NEG_INT32( dy );
+ }
+
+ *x = *y = 0;
+
+ if ( !glyphpath->darken )
+ return;
+
+ /* add momentum for this path element */
+ glyphpath->callbacks->windingMomentum =
+ ADD_INT32( glyphpath->callbacks->windingMomentum,
+ cf2_getWindingMomentum( x1, y1, x2, y2 ) );
+
+ /* note: allow mixed integer and fixed multiplication here */
+ if ( dx >= 0 )
+ {
+ if ( dy >= 0 )
+ {
+ /* first quadrant, +x +y */
+
+ if ( dx > MUL_INT32( 2, dy ) )
+ {
+ /* +x */
+ *x = 0;
+ *y = 0;
+ }
+ else if ( dy > MUL_INT32( 2, dx ) )
+ {
+ /* +y */
+ *x = glyphpath->xOffset;
+ *y = glyphpath->yOffset;
+ }
+ else
+ {
+ /* +x +y */
+ *x = FT_MulFix( cf2_doubleToFixed( 0.7 ),
+ glyphpath->xOffset );
+ *y = FT_MulFix( cf2_doubleToFixed( 1.0 - 0.7 ),
+ glyphpath->yOffset );
+ }
+ }
+ else
+ {
+ /* fourth quadrant, +x -y */
+
+ if ( dx > MUL_INT32( -2, dy ) )
+ {
+ /* +x */
+ *x = 0;
+ *y = 0;
+ }
+ else if ( NEG_INT32( dy ) > MUL_INT32( 2, dx ) )
+ {
+ /* -y */
+ *x = NEG_INT32( glyphpath->xOffset );
+ *y = glyphpath->yOffset;
+ }
+ else
+ {
+ /* +x -y */
+ *x = FT_MulFix( cf2_doubleToFixed( -0.7 ),
+ glyphpath->xOffset );
+ *y = FT_MulFix( cf2_doubleToFixed( 1.0 - 0.7 ),
+ glyphpath->yOffset );
+ }
+ }
+ }
+ else
+ {
+ if ( dy >= 0 )
+ {
+ /* second quadrant, -x +y */
+
+ if ( NEG_INT32( dx ) > MUL_INT32( 2, dy ) )
+ {
+ /* -x */
+ *x = 0;
+ *y = MUL_INT32( 2, glyphpath->yOffset );
+ }
+ else if ( dy > MUL_INT32( -2, dx ) )
+ {
+ /* +y */
+ *x = glyphpath->xOffset;
+ *y = glyphpath->yOffset;
+ }
+ else
+ {
+ /* -x +y */
+ *x = FT_MulFix( cf2_doubleToFixed( 0.7 ),
+ glyphpath->xOffset );
+ *y = FT_MulFix( cf2_doubleToFixed( 1.0 + 0.7 ),
+ glyphpath->yOffset );
+ }
+ }
+ else
+ {
+ /* third quadrant, -x -y */
+
+ if ( NEG_INT32( dx ) > MUL_INT32( -2, dy ) )
+ {
+ /* -x */
+ *x = 0;
+ *y = MUL_INT32( 2, glyphpath->yOffset );
+ }
+ else if ( NEG_INT32( dy ) > MUL_INT32( -2, dx ) )
+ {
+ /* -y */
+ *x = NEG_INT32( glyphpath->xOffset );
+ *y = glyphpath->yOffset;
+ }
+ else
+ {
+ /* -x -y */
+ *x = FT_MulFix( cf2_doubleToFixed( -0.7 ),
+ glyphpath->xOffset );
+ *y = FT_MulFix( cf2_doubleToFixed( 1.0 + 0.7 ),
+ glyphpath->yOffset );
+ }
+ }
+ }
+ }
+
+
+ /*
+ * The functions cf2_glyphpath_{moveTo,lineTo,curveTo,closeOpenPath} are
+ * called by the interpreter with Character Space (CS) coordinates. Each
+ * path element is placed into a queue of length one to await the
+ * calculation of the following element. At that time, the darkening
+ * offset of the following element is known and joins can be computed,
+ * including possible modification of this element, before mapping to
+ * Device Space (DS) and passing it on to the outline consumer.
+ *
+ */
+ FT_LOCAL_DEF( void )
+ cf2_glyphpath_moveTo( CF2_GlyphPath glyphpath,
+ CF2_Fixed x,
+ CF2_Fixed y )
+ {
+ cf2_glyphpath_closeOpenPath( glyphpath );
+
+ /* save the parameters of the move for later, when we'll know how to */
+ /* offset it; */
+ /* also save last move point */
+ glyphpath->currentCS.x = glyphpath->start.x = x;
+ glyphpath->currentCS.y = glyphpath->start.y = y;
+
+ glyphpath->moveIsPending = TRUE;
+
+ /* ensure we have a valid map with current mask */
+ if ( !cf2_hintmap_isValid( &glyphpath->hintMap ) ||
+ cf2_hintmask_isNew( glyphpath->hintMask ) )
+ cf2_hintmap_build( &glyphpath->hintMap,
+ glyphpath->hStemHintArray,
+ glyphpath->vStemHintArray,
+ glyphpath->hintMask,
+ glyphpath->hintOriginY,
+ FALSE );
+
+ /* save a copy of current HintMap to use when drawing initial point */
+ glyphpath->firstHintMap = glyphpath->hintMap; /* structure copy */
+ }
+
+
+ FT_LOCAL_DEF( void )
+ cf2_glyphpath_lineTo( CF2_GlyphPath glyphpath,
+ CF2_Fixed x,
+ CF2_Fixed y )
+ {
+ CF2_Fixed xOffset, yOffset;
+ FT_Vector P0, P1;
+ FT_Bool newHintMap;
+
+ /*
+ * New hints will be applied after cf2_glyphpath_pushPrevElem has run.
+ * In case this is a synthesized closing line, any new hints should be
+ * delayed until this path is closed (`cf2_hintmask_isNew' will be
+ * called again before the next line or curve).
+ */
+
+ /* true if new hint map not on close */
+ newHintMap = cf2_hintmask_isNew( glyphpath->hintMask ) &&
+ !glyphpath->pathIsClosing;
+
+ /*
+ * Zero-length lines may occur in the charstring. Because we cannot
+ * compute darkening offsets or intersections from zero-length lines,
+ * it is best to remove them and avoid artifacts. However, zero-length
+ * lines in CS at the start of a new hint map can generate non-zero
+ * lines in DS due to hint substitution. We detect a change in hint
+ * map here and pass those zero-length lines along.
+ */
+
+ /*
+ * Note: Find explicitly closed paths here with a conditional
+ * breakpoint using
+ *
+ * !gp->pathIsClosing && gp->start.x == x && gp->start.y == y
+ *
+ */
+
+ if ( glyphpath->currentCS.x == x &&
+ glyphpath->currentCS.y == y &&
+ !newHintMap )
+ /*
+ * Ignore zero-length lines in CS where the hint map is the same
+ * because the line in DS will also be zero length.
+ *
+ * Ignore zero-length lines when we synthesize a closing line because
+ * the close will be handled in cf2_glyphPath_pushPrevElem.
+ */
+ return;
+
+ cf2_glyphpath_computeOffset( glyphpath,
+ glyphpath->currentCS.x,
+ glyphpath->currentCS.y,
+ x,
+ y,
+ &xOffset,
+ &yOffset );
+
+ /* construct offset points */
+ P0.x = ADD_INT32( glyphpath->currentCS.x, xOffset );
+ P0.y = ADD_INT32( glyphpath->currentCS.y, yOffset );
+ P1.x = ADD_INT32( x, xOffset );
+ P1.y = ADD_INT32( y, yOffset );
+
+ if ( glyphpath->moveIsPending )
+ {
+ /* emit offset 1st point as MoveTo */
+ cf2_glyphpath_pushMove( glyphpath, P0 );
+
+ glyphpath->moveIsPending = FALSE; /* adjust state machine */
+ glyphpath->pathIsOpen = TRUE;
+
+ glyphpath->offsetStart1 = P1; /* record second point */
+ }
+
+ if ( glyphpath->elemIsQueued )
+ {
+ FT_ASSERT( cf2_hintmap_isValid( &glyphpath->hintMap ) ||
+ glyphpath->hintMap.count == 0 );
+
+ cf2_glyphpath_pushPrevElem( glyphpath,
+ &glyphpath->hintMap,
+ &P0,
+ P1,
+ FALSE );
+ }
+
+ /* queue the current element with offset points */
+ glyphpath->elemIsQueued = TRUE;
+ glyphpath->prevElemOp = CF2_PathOpLineTo;
+ glyphpath->prevElemP0 = P0;
+ glyphpath->prevElemP1 = P1;
+
+ /* update current map */
+ if ( newHintMap )
+ cf2_hintmap_build( &glyphpath->hintMap,
+ glyphpath->hStemHintArray,
+ glyphpath->vStemHintArray,
+ glyphpath->hintMask,
+ glyphpath->hintOriginY,
+ FALSE );
+
+ glyphpath->currentCS.x = x; /* pre-offset current point */
+ glyphpath->currentCS.y = y;
+ }
+
+
+ FT_LOCAL_DEF( void )
+ cf2_glyphpath_curveTo( CF2_GlyphPath glyphpath,
+ CF2_Fixed x1,
+ CF2_Fixed y1,
+ CF2_Fixed x2,
+ CF2_Fixed y2,
+ CF2_Fixed x3,
+ CF2_Fixed y3 )
+ {
+ CF2_Fixed xOffset1, yOffset1, xOffset3, yOffset3;
+ FT_Vector P0, P1, P2, P3;
+
+
+ /* TODO: ignore zero length portions of curve?? */
+ cf2_glyphpath_computeOffset( glyphpath,
+ glyphpath->currentCS.x,
+ glyphpath->currentCS.y,
+ x1,
+ y1,
+ &xOffset1,
+ &yOffset1 );
+ cf2_glyphpath_computeOffset( glyphpath,
+ x2,
+ y2,
+ x3,
+ y3,
+ &xOffset3,
+ &yOffset3 );
+
+ /* add momentum from the middle segment */
+ glyphpath->callbacks->windingMomentum =
+ ADD_INT32( glyphpath->callbacks->windingMomentum,
+ cf2_getWindingMomentum( x1, y1, x2, y2 ) );
+
+ /* construct offset points */
+ P0.x = ADD_INT32( glyphpath->currentCS.x, xOffset1 );
+ P0.y = ADD_INT32( glyphpath->currentCS.y, yOffset1 );
+ P1.x = ADD_INT32( x1, xOffset1 );
+ P1.y = ADD_INT32( y1, yOffset1 );
+ /* note: preserve angle of final segment by using offset3 at both ends */
+ P2.x = ADD_INT32( x2, xOffset3 );
+ P2.y = ADD_INT32( y2, yOffset3 );
+ P3.x = ADD_INT32( x3, xOffset3 );
+ P3.y = ADD_INT32( y3, yOffset3 );
+
+ if ( glyphpath->moveIsPending )
+ {
+ /* emit offset 1st point as MoveTo */
+ cf2_glyphpath_pushMove( glyphpath, P0 );
+
+ glyphpath->moveIsPending = FALSE;
+ glyphpath->pathIsOpen = TRUE;
+
+ glyphpath->offsetStart1 = P1; /* record second point */
+ }
+
+ if ( glyphpath->elemIsQueued )
+ {
+ FT_ASSERT( cf2_hintmap_isValid( &glyphpath->hintMap ) ||
+ glyphpath->hintMap.count == 0 );
+
+ cf2_glyphpath_pushPrevElem( glyphpath,
+ &glyphpath->hintMap,
+ &P0,
+ P1,
+ FALSE );
+ }
+
+ /* queue the current element with offset points */
+ glyphpath->elemIsQueued = TRUE;
+ glyphpath->prevElemOp = CF2_PathOpCubeTo;
+ glyphpath->prevElemP0 = P0;
+ glyphpath->prevElemP1 = P1;
+ glyphpath->prevElemP2 = P2;
+ glyphpath->prevElemP3 = P3;
+
+ /* update current map */
+ if ( cf2_hintmask_isNew( glyphpath->hintMask ) )
+ cf2_hintmap_build( &glyphpath->hintMap,
+ glyphpath->hStemHintArray,
+ glyphpath->vStemHintArray,
+ glyphpath->hintMask,
+ glyphpath->hintOriginY,
+ FALSE );
+
+ glyphpath->currentCS.x = x3; /* pre-offset current point */
+ glyphpath->currentCS.y = y3;
+ }
+
+
+ FT_LOCAL_DEF( void )
+ cf2_glyphpath_closeOpenPath( CF2_GlyphPath glyphpath )
+ {
+ if ( glyphpath->pathIsOpen )
+ {
+ /*
+ * A closing line in Character Space line is always generated below
+ * with `cf2_glyphPath_lineTo'. It may be ignored later if it turns
+ * out to be zero length in Device Space.
+ */
+ glyphpath->pathIsClosing = TRUE;
+
+ cf2_glyphpath_lineTo( glyphpath,
+ glyphpath->start.x,
+ glyphpath->start.y );
+
+ /* empty the final element from the queue and close the path */
+ if ( glyphpath->elemIsQueued )
+ cf2_glyphpath_pushPrevElem( glyphpath,
+ &glyphpath->hintMap,
+ &glyphpath->offsetStart0,
+ glyphpath->offsetStart1,
+ TRUE );
+
+ /* reset state machine */
+ glyphpath->moveIsPending = TRUE;
+ glyphpath->pathIsOpen = FALSE;
+ glyphpath->pathIsClosing = FALSE;
+ glyphpath->elemIsQueued = FALSE;
+ }
+ }
+
+
+/* END */
diff --git a/src/3rdparty/freetype/src/psaux/pshints.h b/src/3rdparty/freetype/src/psaux/pshints.h
new file mode 100644
index 0000000000..92e37e98ae
--- /dev/null
+++ b/src/3rdparty/freetype/src/psaux/pshints.h
@@ -0,0 +1,288 @@
+/***************************************************************************/
+/* */
+/* pshints.h */
+/* */
+/* Adobe's code for handling CFF hints (body). */
+/* */
+/* Copyright 2007-2013 Adobe Systems Incorporated. */
+/* */
+/* This software, and all works of authorship, whether in source or */
+/* object code form as indicated by the copyright notice(s) included */
+/* herein (collectively, the "Work") is made available, and may only be */
+/* used, modified, and distributed under the FreeType Project License, */
+/* LICENSE.TXT. Additionally, subject to the terms and conditions of the */
+/* FreeType Project License, each contributor to the Work hereby grants */
+/* to any individual or legal entity exercising permissions granted by */
+/* the FreeType Project License and this section (hereafter, "You" or */
+/* "Your") a perpetual, worldwide, non-exclusive, no-charge, */
+/* royalty-free, irrevocable (except as stated in this section) patent */
+/* license to make, have made, use, offer to sell, sell, import, and */
+/* otherwise transfer the Work, where such license applies only to those */
+/* patent claims licensable by such contributor that are necessarily */
+/* infringed by their contribution(s) alone or by combination of their */
+/* contribution(s) with the Work to which such contribution(s) was */
+/* submitted. If You institute patent litigation against any entity */
+/* (including a cross-claim or counterclaim in a lawsuit) alleging that */
+/* the Work or a contribution incorporated within the Work constitutes */
+/* direct or contributory patent infringement, then any patent licenses */
+/* granted to You under this License for that Work shall terminate as of */
+/* the date such litigation is filed. */
+/* */
+/* By using, modifying, or distributing the Work you indicate that you */
+/* have read and understood the terms and conditions of the */
+/* FreeType Project License as well as those provided in this section, */
+/* and you accept them fully. */
+/* */
+/***************************************************************************/
+
+
+#ifndef PSHINT_H_
+#define PSHINT_H_
+
+FT_BEGIN_HEADER
+
+
+ enum
+ {
+ CF2_MAX_HINTS = 96 /* maximum # of hints */
+ };
+
+
+ /*
+ * A HintMask object stores a bit mask that specifies which hints in the
+ * charstring are active at a given time. Hints in CFF must be declared
+ * at the start, before any drawing operators, with horizontal hints
+ * preceding vertical hints. The HintMask is ordered the same way, with
+ * horizontal hints immediately followed by vertical hints. Clients are
+ * responsible for knowing how many of each type are present.
+ *
+ * The maximum total number of hints is 96, as specified by the CFF
+ * specification.
+ *
+ * A HintMask is built 0 or more times while interpreting a charstring, by
+ * the HintMask operator. There is only one HintMask, but it is built or
+ * rebuilt each time there is a hint substitution (HintMask operator) in
+ * the charstring. A default HintMask with all bits set is built if there
+ * has been no HintMask operator prior to the first drawing operator.
+ *
+ */
+
+ typedef struct CF2_HintMaskRec_
+ {
+ FT_Error* error;
+
+ FT_Bool isValid;
+ FT_Bool isNew;
+
+ size_t bitCount;
+ size_t byteCount;
+
+ FT_Byte mask[( CF2_MAX_HINTS + 7 ) / 8];
+
+ } CF2_HintMaskRec, *CF2_HintMask;
+
+
+ typedef struct CF2_StemHintRec_
+ {
+ FT_Bool used; /* DS positions are valid */
+
+ CF2_Fixed min; /* original character space value */
+ CF2_Fixed max;
+
+ CF2_Fixed minDS; /* DS position after first use */
+ CF2_Fixed maxDS;
+
+ } CF2_StemHintRec, *CF2_StemHint;
+
+
+ /*
+ * A HintMap object stores a piecewise linear function for mapping
+ * y-coordinates from character space to device space, providing
+ * appropriate pixel alignment to stem edges.
+ *
+ * The map is implemented as an array of `CF2_Hint' elements, each
+ * representing an edge. When edges are paired, as from stem hints, the
+ * bottom edge must immediately precede the top edge in the array.
+ * Element character space AND device space positions must both increase
+ * monotonically in the array. `CF2_Hint' elements are also used as
+ * parameters to `cf2_blues_capture'.
+ *
+ * The `cf2_hintmap_build' method must be called before any drawing
+ * operation (beginning with a Move operator) and at each hint
+ * substitution (HintMask operator).
+ *
+ * The `cf2_hintmap_map' method is called to transform y-coordinates at
+ * each drawing operation (move, line, curve).
+ *
+ */
+
+ /* TODO: make this a CF2_ArrStack and add a deep copy method */
+ enum
+ {
+ CF2_MAX_HINT_EDGES = CF2_MAX_HINTS * 2
+ };
+
+
+ typedef struct CF2_HintMapRec_
+ {
+ CF2_Font font;
+
+ /* initial map based on blue zones */
+ struct CF2_HintMapRec_* initialHintMap;
+
+ /* working storage for 2nd pass adjustHints */
+ CF2_ArrStack hintMoves;
+
+ FT_Bool isValid;
+ FT_Bool hinted;
+
+ CF2_Fixed scale;
+ CF2_UInt count;
+
+ /* start search from this index */
+ CF2_UInt lastIndex;
+
+ CF2_HintRec edge[CF2_MAX_HINT_EDGES]; /* 192 */
+
+ } CF2_HintMapRec, *CF2_HintMap;
+
+
+ FT_LOCAL( FT_Bool )
+ cf2_hint_isValid( const CF2_Hint hint );
+ FT_LOCAL( FT_Bool )
+ cf2_hint_isTop( const CF2_Hint hint );
+ FT_LOCAL( FT_Bool )
+ cf2_hint_isBottom( const CF2_Hint hint );
+ FT_LOCAL( void )
+ cf2_hint_lock( CF2_Hint hint );
+
+
+ FT_LOCAL( void )
+ cf2_hintmap_init( CF2_HintMap hintmap,
+ CF2_Font font,
+ CF2_HintMap initialMap,
+ CF2_ArrStack hintMoves,
+ CF2_Fixed scale );
+ FT_LOCAL( void )
+ cf2_hintmap_build( CF2_HintMap hintmap,
+ CF2_ArrStack hStemHintArray,
+ CF2_ArrStack vStemHintArray,
+ CF2_HintMask hintMask,
+ CF2_Fixed hintOrigin,
+ FT_Bool initialMap );
+
+
+ /*
+ * GlyphPath is a wrapper for drawing operations that scales the
+ * coordinates according to the render matrix and HintMap. It also tracks
+ * open paths to control ClosePath and to insert MoveTo for broken fonts.
+ *
+ */
+ typedef struct CF2_GlyphPathRec_
+ {
+ /* TODO: gather some of these into a hinting context */
+
+ CF2_Font font; /* font instance */
+ CF2_OutlineCallbacks callbacks; /* outline consumer */
+
+
+ CF2_HintMapRec hintMap; /* current hint map */
+ CF2_HintMapRec firstHintMap; /* saved copy */
+ CF2_HintMapRec initialHintMap; /* based on all captured hints */
+
+ CF2_ArrStackRec hintMoves; /* list of hint moves for 2nd pass */
+
+ CF2_Fixed scaleX; /* matrix a */
+ CF2_Fixed scaleC; /* matrix c */
+ CF2_Fixed scaleY; /* matrix d */
+
+ FT_Vector fractionalTranslation; /* including deviceXScale */
+#if 0
+ CF2_Fixed hShift; /* character space horizontal shift */
+ /* (for fauxing) */
+#endif
+
+ FT_Bool pathIsOpen; /* true after MoveTo */
+ FT_Bool pathIsClosing; /* true when synthesizing closepath line */
+ FT_Bool darken; /* true if stem darkening */
+ FT_Bool moveIsPending; /* true between MoveTo and offset MoveTo */
+
+ /* references used to call `cf2_hintmap_build', if necessary */
+ CF2_ArrStack hStemHintArray;
+ CF2_ArrStack vStemHintArray;
+ CF2_HintMask hintMask; /* ptr to the current mask */
+ CF2_Fixed hintOriginY; /* copy of current origin */
+ const CF2_BluesRec* blues;
+
+ CF2_Fixed xOffset; /* character space offsets */
+ CF2_Fixed yOffset;
+
+ /* character space miter limit threshold */
+ CF2_Fixed miterLimit;
+ /* vertical/horizontal snap distance in character space */
+ CF2_Fixed snapThreshold;
+
+ FT_Vector offsetStart0; /* first and second points of first */
+ FT_Vector offsetStart1; /* element with offset applied */
+
+ /* current point, character space, before offset */
+ FT_Vector currentCS;
+ /* current point, device space */
+ FT_Vector currentDS;
+ /* start point of subpath, character space */
+ FT_Vector start;
+
+ /* the following members constitute the `queue' of one element */
+ FT_Bool elemIsQueued;
+ CF2_Int prevElemOp;
+
+ FT_Vector prevElemP0;
+ FT_Vector prevElemP1;
+ FT_Vector prevElemP2;
+ FT_Vector prevElemP3;
+
+ } CF2_GlyphPathRec, *CF2_GlyphPath;
+
+
+ FT_LOCAL( void )
+ cf2_glyphpath_init( CF2_GlyphPath glyphpath,
+ CF2_Font font,
+ CF2_OutlineCallbacks callbacks,
+ CF2_Fixed scaleY,
+ /* CF2_Fixed hShift, */
+ CF2_ArrStack hStemHintArray,
+ CF2_ArrStack vStemHintArray,
+ CF2_HintMask hintMask,
+ CF2_Fixed hintOrigin,
+ const CF2_Blues blues,
+ const FT_Vector* fractionalTranslation );
+ FT_LOCAL( void )
+ cf2_glyphpath_finalize( CF2_GlyphPath glyphpath );
+
+ FT_LOCAL( void )
+ cf2_glyphpath_moveTo( CF2_GlyphPath glyphpath,
+ CF2_Fixed x,
+ CF2_Fixed y );
+ FT_LOCAL( void )
+ cf2_glyphpath_lineTo( CF2_GlyphPath glyphpath,
+ CF2_Fixed x,
+ CF2_Fixed y );
+ FT_LOCAL( void )
+ cf2_glyphpath_curveTo( CF2_GlyphPath glyphpath,
+ CF2_Fixed x1,
+ CF2_Fixed y1,
+ CF2_Fixed x2,
+ CF2_Fixed y2,
+ CF2_Fixed x3,
+ CF2_Fixed y3 );
+ FT_LOCAL( void )
+ cf2_glyphpath_closeOpenPath( CF2_GlyphPath glyphpath );
+
+
+FT_END_HEADER
+
+
+#endif /* PSHINT_H_ */
+
+
+/* END */
diff --git a/src/3rdparty/freetype/src/psaux/psintrp.c b/src/3rdparty/freetype/src/psaux/psintrp.c
new file mode 100644
index 0000000000..da5a8dad1d
--- /dev/null
+++ b/src/3rdparty/freetype/src/psaux/psintrp.c
@@ -0,0 +1,3040 @@
+/***************************************************************************/
+/* */
+/* psintrp.c */
+/* */
+/* Adobe's CFF Interpreter (body). */
+/* */
+/* Copyright 2007-2014 Adobe Systems Incorporated. */
+/* */
+/* This software, and all works of authorship, whether in source or */
+/* object code form as indicated by the copyright notice(s) included */
+/* herein (collectively, the "Work") is made available, and may only be */
+/* used, modified, and distributed under the FreeType Project License, */
+/* LICENSE.TXT. Additionally, subject to the terms and conditions of the */
+/* FreeType Project License, each contributor to the Work hereby grants */
+/* to any individual or legal entity exercising permissions granted by */
+/* the FreeType Project License and this section (hereafter, "You" or */
+/* "Your") a perpetual, worldwide, non-exclusive, no-charge, */
+/* royalty-free, irrevocable (except as stated in this section) patent */
+/* license to make, have made, use, offer to sell, sell, import, and */
+/* otherwise transfer the Work, where such license applies only to those */
+/* patent claims licensable by such contributor that are necessarily */
+/* infringed by their contribution(s) alone or by combination of their */
+/* contribution(s) with the Work to which such contribution(s) was */
+/* submitted. If You institute patent litigation against any entity */
+/* (including a cross-claim or counterclaim in a lawsuit) alleging that */
+/* the Work or a contribution incorporated within the Work constitutes */
+/* direct or contributory patent infringement, then any patent licenses */
+/* granted to You under this License for that Work shall terminate as of */
+/* the date such litigation is filed. */
+/* */
+/* By using, modifying, or distributing the Work you indicate that you */
+/* have read and understood the terms and conditions of the */
+/* FreeType Project License as well as those provided in this section, */
+/* and you accept them fully. */
+/* */
+/***************************************************************************/
+
+
+#include "psft.h"
+#include FT_INTERNAL_DEBUG_H
+#include FT_SERVICE_CFF_TABLE_LOAD_H
+
+#include "psglue.h"
+#include "psfont.h"
+#include "psstack.h"
+#include "pshints.h"
+#include "psintrp.h"
+
+#include "pserror.h"
+
+#include "psobjs.h" /* for cff_random */
+#include "t1decode.h" /* for t1 seac */
+
+
+ /*************************************************************************/
+ /* */
+ /* The macro FT_COMPONENT is used in trace mode. It is an implicit */
+ /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */
+ /* messages during execution. */
+ /* */
+#undef FT_COMPONENT
+#define FT_COMPONENT trace_cf2interp
+
+
+ FT_LOCAL_DEF( void )
+ cf2_hintmask_init( CF2_HintMask hintmask,
+ FT_Error* error )
+ {
+ FT_ZERO( hintmask );
+
+ hintmask->error = error;
+ }
+
+
+ FT_LOCAL_DEF( FT_Bool )
+ cf2_hintmask_isValid( const CF2_HintMask hintmask )
+ {
+ return hintmask->isValid;
+ }
+
+
+ FT_LOCAL_DEF( FT_Bool )
+ cf2_hintmask_isNew( const CF2_HintMask hintmask )
+ {
+ return hintmask->isNew;
+ }
+
+
+ FT_LOCAL_DEF( void )
+ cf2_hintmask_setNew( CF2_HintMask hintmask,
+ FT_Bool val )
+ {
+ hintmask->isNew = val;
+ }
+
+
+ /* clients call `getMaskPtr' in order to iterate */
+ /* through hint mask */
+
+ FT_LOCAL_DEF( FT_Byte* )
+ cf2_hintmask_getMaskPtr( CF2_HintMask hintmask )
+ {
+ return hintmask->mask;
+ }
+
+
+ static size_t
+ cf2_hintmask_setCounts( CF2_HintMask hintmask,
+ size_t bitCount )
+ {
+ if ( bitCount > CF2_MAX_HINTS )
+ {
+ /* total of h and v stems must be <= 96 */
+ CF2_SET_ERROR( hintmask->error, Invalid_Glyph_Format );
+ return 0;
+ }
+
+ hintmask->bitCount = bitCount;
+ hintmask->byteCount = ( hintmask->bitCount + 7 ) / 8;
+
+ hintmask->isValid = TRUE;
+ hintmask->isNew = TRUE;
+
+ return bitCount;
+ }
+
+
+ /* consume the hintmask bytes from the charstring, advancing the src */
+ /* pointer */
+ static void
+ cf2_hintmask_read( CF2_HintMask hintmask,
+ CF2_Buffer charstring,
+ size_t bitCount )
+ {
+ size_t i;
+
+#ifndef CF2_NDEBUG
+ /* these are the bits in the final mask byte that should be zero */
+ /* Note: this variable is only used in an assert expression below */
+ /* and then only if CF2_NDEBUG is not defined */
+ CF2_UInt mask = ( 1 << ( -(CF2_Int)bitCount & 7 ) ) - 1;
+#endif
+
+
+ /* initialize counts and isValid */
+ if ( cf2_hintmask_setCounts( hintmask, bitCount ) == 0 )
+ return;
+
+ FT_ASSERT( hintmask->byteCount > 0 );
+
+ FT_TRACE4(( " (maskbytes:" ));
+
+ /* set mask and advance interpreter's charstring pointer */
+ for ( i = 0; i < hintmask->byteCount; i++ )
+ {
+ hintmask->mask[i] = (FT_Byte)cf2_buf_readByte( charstring );
+ FT_TRACE4(( " 0x%02X", hintmask->mask[i] ));
+ }
+
+ FT_TRACE4(( ")\n" ));
+
+ /* assert any unused bits in last byte are zero unless there's a prior */
+ /* error */
+ /* bitCount -> mask, 0 -> 0, 1 -> 7f, 2 -> 3f, ... 6 -> 3, 7 -> 1 */
+#ifndef CF2_NDEBUG
+ FT_ASSERT( ( hintmask->mask[hintmask->byteCount - 1] & mask ) == 0 ||
+ *hintmask->error );
+#endif
+ }
+
+
+ FT_LOCAL_DEF( void )
+ cf2_hintmask_setAll( CF2_HintMask hintmask,
+ size_t bitCount )
+ {
+ size_t i;
+ CF2_UInt mask = ( 1 << ( -(CF2_Int)bitCount & 7 ) ) - 1;
+
+
+ /* initialize counts and isValid */
+ if ( cf2_hintmask_setCounts( hintmask, bitCount ) == 0 )
+ return;
+
+ FT_ASSERT( hintmask->byteCount > 0 );
+ FT_ASSERT( hintmask->byteCount <=
+ sizeof ( hintmask->mask ) / sizeof ( hintmask->mask[0] ) );
+
+ /* set mask to all ones */
+ for ( i = 0; i < hintmask->byteCount; i++ )
+ hintmask->mask[i] = 0xFF;
+
+ /* clear unused bits */
+ /* bitCount -> mask, 0 -> 0, 1 -> 7f, 2 -> 3f, ... 6 -> 3, 7 -> 1 */
+ hintmask->mask[hintmask->byteCount - 1] &= ~mask;
+ }
+
+
+ /* Type2 charstring opcodes */
+ enum
+ {
+ cf2_cmdRESERVED_0, /* 0 */
+ cf2_cmdHSTEM, /* 1 */
+ cf2_cmdRESERVED_2, /* 2 */
+ cf2_cmdVSTEM, /* 3 */
+ cf2_cmdVMOVETO, /* 4 */
+ cf2_cmdRLINETO, /* 5 */
+ cf2_cmdHLINETO, /* 6 */
+ cf2_cmdVLINETO, /* 7 */
+ cf2_cmdRRCURVETO, /* 8 */
+ cf2_cmdCLOSEPATH, /* 9 T1 only */
+ cf2_cmdCALLSUBR, /* 10 */
+ cf2_cmdRETURN, /* 11 */
+ cf2_cmdESC, /* 12 */
+ cf2_cmdHSBW, /* 13 T1 only */
+ cf2_cmdENDCHAR, /* 14 */
+ cf2_cmdVSINDEX, /* 15 */
+ cf2_cmdBLEND, /* 16 */
+ cf2_cmdRESERVED_17, /* 17 */
+ cf2_cmdHSTEMHM, /* 18 */
+ cf2_cmdHINTMASK, /* 19 */
+ cf2_cmdCNTRMASK, /* 20 */
+ cf2_cmdRMOVETO, /* 21 */
+ cf2_cmdHMOVETO, /* 22 */
+ cf2_cmdVSTEMHM, /* 23 */
+ cf2_cmdRCURVELINE, /* 24 */
+ cf2_cmdRLINECURVE, /* 25 */
+ cf2_cmdVVCURVETO, /* 26 */
+ cf2_cmdHHCURVETO, /* 27 */
+ cf2_cmdEXTENDEDNMBR, /* 28 */
+ cf2_cmdCALLGSUBR, /* 29 */
+ cf2_cmdVHCURVETO, /* 30 */
+ cf2_cmdHVCURVETO /* 31 */
+ };
+
+ enum
+ {
+ cf2_escDOTSECTION, /* 0 */
+ cf2_escVSTEM3, /* 1 T1 only */
+ cf2_escHSTEM3, /* 2 T1 only */
+ cf2_escAND, /* 3 */
+ cf2_escOR, /* 4 */
+ cf2_escNOT, /* 5 */
+ cf2_escSEAC, /* 6 T1 only */
+ cf2_escSBW, /* 7 T1 only */
+ cf2_escRESERVED_8, /* 8 */
+ cf2_escABS, /* 9 */
+ cf2_escADD, /* 10 like otherADD */
+ cf2_escSUB, /* 11 like otherSUB */
+ cf2_escDIV, /* 12 */
+ cf2_escRESERVED_13, /* 13 */
+ cf2_escNEG, /* 14 */
+ cf2_escEQ, /* 15 */
+ cf2_escCALLOTHERSUBR,/* 16 T1 only */
+ cf2_escPOP, /* 17 T1 only */
+ cf2_escDROP, /* 18 */
+ cf2_escRESERVED_19, /* 19 */
+ cf2_escPUT, /* 20 like otherPUT */
+ cf2_escGET, /* 21 like otherGET */
+ cf2_escIFELSE, /* 22 like otherIFELSE */
+ cf2_escRANDOM, /* 23 like otherRANDOM */
+ cf2_escMUL, /* 24 like otherMUL */
+ cf2_escRESERVED_25, /* 25 */
+ cf2_escSQRT, /* 26 */
+ cf2_escDUP, /* 27 like otherDUP */
+ cf2_escEXCH, /* 28 like otherEXCH */
+ cf2_escINDEX, /* 29 */
+ cf2_escROLL, /* 30 */
+ cf2_escRESERVED_31, /* 31 */
+ cf2_escRESERVED_32, /* 32 */
+ cf2_escSETCURRENTPT, /* 33 T1 only */
+ cf2_escHFLEX, /* 34 */
+ cf2_escFLEX, /* 35 */
+ cf2_escHFLEX1, /* 36 */
+ cf2_escFLEX1, /* 37 */
+ cf2_escRESERVED_38 /* 38 & all higher */
+ };
+
+
+ /* `stemHintArray' does not change once we start drawing the outline. */
+ static void
+ cf2_doStems( const CF2_Font font,
+ CF2_Stack opStack,
+ CF2_ArrStack stemHintArray,
+ CF2_Fixed* width,
+ FT_Bool* haveWidth,
+ CF2_Fixed hintOffset )
+ {
+ CF2_UInt i;
+ CF2_UInt count = cf2_stack_count( opStack );
+ FT_Bool hasWidthArg = (FT_Bool)( count & 1 );
+
+ /* variable accumulates delta values from operand stack */
+ CF2_Fixed position = hintOffset;
+
+ if ( font->isT1 && !font->decoder->flex_state && !*haveWidth )
+ FT_ERROR(( "cf2_doStems (Type 1 mode):"
+ " No width. Use hsbw/sbw as first op\n" ));
+
+ if ( !font->isT1 && hasWidthArg && !*haveWidth )
+ *width = ADD_INT32( cf2_stack_getReal( opStack, 0 ),
+ cf2_getNominalWidthX( font->decoder ) );
+
+ if ( font->decoder->width_only )
+ goto exit;
+
+ for ( i = hasWidthArg ? 1 : 0; i < count; i += 2 )
+ {
+ /* construct a CF2_StemHint and push it onto the list */
+ CF2_StemHintRec stemhint;
+
+
+ stemhint.min =
+ position = ADD_INT32( position,
+ cf2_stack_getReal( opStack, i ) );
+ stemhint.max =
+ position = ADD_INT32( position,
+ cf2_stack_getReal( opStack, i + 1 ) );
+
+ stemhint.used = FALSE;
+ stemhint.maxDS =
+ stemhint.minDS = 0;
+
+ cf2_arrstack_push( stemHintArray, &stemhint ); /* defer error check */
+ }
+
+ cf2_stack_clear( opStack );
+
+ exit:
+ /* cf2_doStems must define a width (may be default) */
+ *haveWidth = TRUE;
+ }
+
+
+ static void
+ cf2_doFlex( CF2_Stack opStack,
+ CF2_Fixed* curX,
+ CF2_Fixed* curY,
+ CF2_GlyphPath glyphPath,
+ const FT_Bool* readFromStack,
+ FT_Bool doConditionalLastRead )
+ {
+ CF2_Fixed vals[14];
+ CF2_UInt idx;
+ FT_Bool isHFlex;
+ CF2_Int top, i, j;
+
+
+ vals[0] = *curX;
+ vals[1] = *curY;
+ 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] = ADD_INT32( vals[i + 2], cf2_stack_getReal( opStack,
+ idx++ ) );
+ }
+
+ if ( isHFlex )
+ vals[9 + 2] = *curY;
+
+ if ( doConditionalLastRead )
+ {
+ FT_Bool lastIsX = (FT_Bool)(
+ cf2_fixedAbs( SUB_INT32( vals[10], *curX ) ) >
+ cf2_fixedAbs( SUB_INT32( vals[11], *curY ) ) );
+ CF2_Fixed lastVal = cf2_stack_getReal( opStack, idx );
+
+
+ if ( lastIsX )
+ {
+ vals[12] = ADD_INT32( vals[10], lastVal );
+ vals[13] = *curY;
+ }
+ else
+ {
+ vals[12] = *curX;
+ vals[13] = ADD_INT32( vals[11], lastVal );
+ }
+ }
+ else
+ {
+ if ( readFromStack[10] )
+ vals[12] = ADD_INT32( vals[10],
+ cf2_stack_getReal( opStack, idx++ ) );
+ else
+ vals[12] = *curX;
+
+ if ( readFromStack[11] )
+ vals[13] = ADD_INT32( vals[11],
+ cf2_stack_getReal( opStack, idx ) );
+ else
+ vals[13] = *curY;
+ }
+
+ for ( j = 0; j < 2; j++ )
+ cf2_glyphpath_curveTo( glyphPath, vals[j * 6 + 2],
+ vals[j * 6 + 3],
+ vals[j * 6 + 4],
+ vals[j * 6 + 5],
+ vals[j * 6 + 6],
+ vals[j * 6 + 7] );
+
+ cf2_stack_clear( opStack );
+
+ *curX = vals[12];
+ *curY = vals[13];
+ }
+
+
+ /* 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 = ADD_INT32( 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
+ * record the error in `*error'. The idea is that this shared
+ * error code will record the first error encountered. If testing
+ * for an error anyway, the cost of `goto exit' is small, so we do it,
+ * even if continuing would be safe. In this case, `lastError' is
+ * set, so the testing and storing can be done in one place, at `exit'.
+ *
+ * Continuing after an error is intended for objects which do their own
+ * testing of `*error', e.g., array stack functions. This allows us to
+ * avoid an extra test after the call.
+ *
+ * Unimplemented opcodes are ignored.
+ *
+ */
+ FT_LOCAL_DEF( void )
+ cf2_interpT2CharString( CF2_Font font,
+ CF2_Buffer buf,
+ CF2_OutlineCallbacks callbacks,
+ const FT_Vector* translation,
+ FT_Bool doingSeac,
+ CF2_Fixed curX,
+ CF2_Fixed curY,
+ CF2_Fixed* width )
+ {
+ /* lastError is used for errors that are immediately tested */
+ FT_Error lastError = FT_Err_Ok;
+
+ /* pointer to parsed font object */
+ PS_Decoder* decoder = font->decoder;
+
+ FT_Error* error = &font->error;
+ FT_Memory memory = font->memory;
+
+ CF2_Fixed scaleY = font->innerTransform.d;
+ CF2_Fixed nominalWidthX = cf2_getNominalWidthX( decoder );
+
+ /* stuff for Type 1 */
+ FT_Int known_othersubr_result_cnt = 0;
+ FT_Bool large_int = FALSE;
+ FT_Bool initial_map_ready = FALSE;
+
+#define PS_STORAGE_SIZE 3
+ CF2_F16Dot16 results[PS_STORAGE_SIZE]; /* for othersubr results */
+ FT_Int result_cnt = 0;
+
+ /* save this for hinting seac accents */
+ 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' */
+ CF2_F16Dot16 flexStore[6]; /* for Type 1 flex */
+
+ /* instruction limit; 20,000,000 matches Avalon */
+ FT_UInt32 instructionLimit = 20000000UL;
+
+ CF2_ArrStackRec subrStack;
+
+ FT_Bool haveWidth;
+ CF2_Buffer charstring = NULL;
+
+ CF2_Int charstringIndex = -1; /* initialize to empty */
+
+ /* TODO: placeholders for hint structures */
+
+ /* objects used for hinting */
+ CF2_ArrStackRec hStemHintArray;
+ CF2_ArrStackRec vStemHintArray;
+
+ CF2_HintMaskRec hintMask;
+ CF2_GlyphPathRec glyphPath;
+
+
+ FT_ZERO( &storage );
+ FT_ZERO( &results );
+ FT_ZERO( &flexStore );
+
+ /* initialize the remaining objects */
+ cf2_arrstack_init( &subrStack,
+ memory,
+ error,
+ sizeof ( CF2_BufferRec ) );
+ cf2_arrstack_init( &hStemHintArray,
+ memory,
+ error,
+ sizeof ( CF2_StemHintRec ) );
+ cf2_arrstack_init( &vStemHintArray,
+ memory,
+ error,
+ sizeof ( CF2_StemHintRec ) );
+
+ /* initialize CF2_StemHint arrays */
+ cf2_hintmask_init( &hintMask, error );
+
+ /* initialize path map to manage drawing operations */
+
+ /* Note: last 4 params are used to handle `MoveToPermissive', which */
+ /* may need to call `hintMap.Build' */
+ /* TODO: MoveToPermissive is gone; are these still needed? */
+ cf2_glyphpath_init( &glyphPath,
+ font,
+ callbacks,
+ scaleY,
+ /* hShift, */
+ &hStemHintArray,
+ &vStemHintArray,
+ &hintMask,
+ hintOriginY,
+ &font->blues,
+ translation );
+
+ /*
+ * Initialize state for width parsing. From the CFF Spec:
+ *
+ * The first stack-clearing operator, which must be one of hstem,
+ * hstemhm, vstem, vstemhm, cntrmask, hintmask, hmoveto, vmoveto,
+ * rmoveto, or endchar, takes an additional argument - the width (as
+ * described earlier), which may be expressed as zero or one numeric
+ * argument.
+ *
+ * What we implement here uses the first validly specified width, but
+ * does not detect errors for specifying more than one width.
+ *
+ * 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 = 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.
+ *
+ */
+
+ /* allocate an operand stack */
+ 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 );
+ goto exit;
+ }
+
+ /* initialize subroutine stack by placing top level charstring as */
+ /* first element (max depth plus one for the charstring) */
+ /* Note: Caller owns and must finalize the first charstring. */
+ /* Our copy of it does not change that requirement. */
+ cf2_arrstack_setCount( &subrStack, CF2_MAX_SUBR + 1 );
+
+ charstring = (CF2_Buffer)cf2_arrstack_getBuffer( &subrStack );
+ *charstring = *buf; /* structure copy */
+
+ charstringIndex = 0; /* entry is valid now */
+
+ /* catch errors so far */
+ if ( *error )
+ goto exit;
+
+ /* main interpreter loop */
+ while ( 1 )
+ {
+ if ( font->isT1 )
+ FT_ASSERT( known_othersubr_result_cnt == 0 ||
+ result_cnt == 0 );
+
+ if ( cf2_buf_isEnd( charstring ) )
+ {
+ /* 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;
+ }
+
+ if ( font->isT1 )
+ {
+ if ( !initial_map_ready &&
+ !( op1 == cf2_cmdHSTEM ||
+ op1 == cf2_cmdVSTEM ||
+ op1 == cf2_cmdHSBW ||
+ op1 == cf2_cmdCALLSUBR ||
+ op1 == cf2_cmdRETURN ||
+ op1 == cf2_cmdESC ||
+ op1 == cf2_cmdENDCHAR ||
+ op1 >= 32 /* Numbers */ ) )
+ {
+ /* Skip outline commands first time round. */
+ /* `endchar' will trigger initial hintmap build */
+ /* and rewind the charstring. */
+ cf2_stack_clear( opStack );
+ continue;
+ }
+
+ if ( result_cnt > 0 &&
+ !( op1 == cf2_cmdCALLSUBR ||
+ op1 == cf2_cmdRETURN ||
+ op1 == cf2_cmdESC ||
+ op1 >= 32 /* Numbers */ ) )
+ {
+ /* all operands have been transferred by previous pops */
+ result_cnt = 0;
+ }
+
+ if ( large_int && !( op1 >= 32 || op1 == cf2_escDIV ) )
+ {
+ FT_ERROR(( "cf2_interpT2CharString (Type 1 mode):"
+ " no `div' after large integer\n" ));
+
+ large_int = FALSE;
+ }
+ }
+
+ /* check for errors once per loop */
+ if ( *error )
+ goto exit;
+
+ instructionLimit--;
+ if ( instructionLimit == 0 )
+ {
+ lastError = FT_THROW( Invalid_Glyph_Format );
+ goto exit;
+ }
+
+ switch( op1 )
+ {
+ case cf2_cmdRESERVED_0:
+ case cf2_cmdRESERVED_2:
+ 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 ( font->cffload->blend_check_vector( &font->blend,
+ font->vsindex,
+ font->lenNDV,
+ font->NDV ) )
+ {
+ lastError = font->cffload->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" ));
+
+ if ( !font->isT1 )
+ {
+ /* never add hints after the mask is computed */
+ /* except if in Type 1 mode (no hintmask op) */
+ if ( cf2_hintmask_isValid( &hintMask ) )
+ {
+ FT_TRACE4(( "cf2_interpT2CharString:"
+ " invalid horizontal hint mask\n" ));
+ break;
+ }
+ }
+
+ /* add left-sidebearing correction in Type 1 mode */
+ cf2_doStems( font,
+ opStack,
+ &hStemHintArray,
+ width,
+ &haveWidth,
+ font->isT1 ? decoder->builder.left_bearing->y
+ : 0 );
+
+ if ( decoder->width_only )
+ goto exit;
+
+ break;
+
+ case cf2_cmdVSTEMHM:
+ case cf2_cmdVSTEM:
+ FT_TRACE4(( op1 == cf2_cmdVSTEMHM ? " vstemhm\n" : " vstem\n" ));
+
+ if ( !font->isT1 )
+ {
+ /* never add hints after the mask is computed */
+ /* except if in Type 1 mode (no hintmask op) */
+ if ( cf2_hintmask_isValid( &hintMask ) )
+ {
+ FT_TRACE4(( "cf2_interpT2CharString:"
+ " invalid vertical hint mask\n" ));
+ break;
+ }
+ }
+
+ /* add left-sidebearing correction in Type 1 mode */
+ cf2_doStems( font,
+ opStack,
+ &vStemHintArray,
+ width,
+ &haveWidth,
+ font->isT1 ? decoder->builder.left_bearing->x
+ : 0 );
+
+ if ( decoder->width_only )
+ goto exit;
+
+ break;
+
+ case cf2_cmdVMOVETO:
+ FT_TRACE4(( " vmoveto\n" ));
+
+ if ( font->isT1 && !decoder->flex_state && !haveWidth )
+ FT_ERROR(( "cf2_interpT2CharString (Type 1 mode):"
+ " No width. Use hsbw/sbw as first op\n" ));
+
+ if ( cf2_stack_count( opStack ) > 1 && !haveWidth )
+ *width = ADD_INT32( cf2_stack_getReal( opStack, 0 ),
+ nominalWidthX );
+
+ /* width is defined or default after this */
+ haveWidth = TRUE;
+
+ if ( decoder->width_only )
+ goto exit;
+
+ curY = ADD_INT32( curY, cf2_stack_popFixed( opStack ) );
+
+ if ( !decoder->flex_state )
+ cf2_glyphpath_moveTo( &glyphPath, curX, curY );
+
+ break;
+
+ case cf2_cmdRLINETO:
+ {
+ CF2_UInt idx;
+ CF2_UInt count = cf2_stack_count( opStack );
+
+
+ FT_TRACE4(( " rlineto\n" ));
+
+ for ( idx = 0; idx < count; idx += 2 )
+ {
+ curX = ADD_INT32( curX, cf2_stack_getReal( opStack,
+ idx + 0 ) );
+ curY = ADD_INT32( curY, cf2_stack_getReal( opStack,
+ idx + 1 ) );
+
+ cf2_glyphpath_lineTo( &glyphPath, curX, curY );
+ }
+
+ cf2_stack_clear( opStack );
+ }
+ continue; /* no need to clear stack again */
+
+ case cf2_cmdHLINETO:
+ case cf2_cmdVLINETO:
+ {
+ CF2_UInt idx;
+ CF2_UInt count = cf2_stack_count( opStack );
+
+ FT_Bool isX = FT_BOOL( op1 == cf2_cmdHLINETO );
+
+
+ FT_TRACE4(( isX ? " hlineto\n" : " vlineto\n" ));
+
+ for ( idx = 0; idx < count; idx++ )
+ {
+ CF2_Fixed v = cf2_stack_getReal( opStack, idx );
+
+
+ if ( isX )
+ curX = ADD_INT32( curX, v );
+ else
+ curY = ADD_INT32( curY, v );
+
+ isX = !isX;
+
+ cf2_glyphpath_lineTo( &glyphPath, curX, curY );
+ }
+
+ cf2_stack_clear( opStack );
+ }
+ continue;
+
+ case cf2_cmdRCURVELINE:
+ case cf2_cmdRRCURVETO:
+ {
+ CF2_UInt count = cf2_stack_count( opStack );
+ CF2_UInt idx = 0;
+
+
+ FT_TRACE4(( op1 == cf2_cmdRCURVELINE ? " rcurveline\n"
+ : " rrcurveto\n" ));
+
+ while ( idx + 6 <= count )
+ {
+ CF2_Fixed x1, y1, x2, y2, x3, y3;
+
+
+ x1 = ADD_INT32( cf2_stack_getReal( opStack, idx + 0 ), curX );
+ y1 = ADD_INT32( cf2_stack_getReal( opStack, idx + 1 ), curY );
+ x2 = ADD_INT32( cf2_stack_getReal( opStack, idx + 2 ), x1 );
+ y2 = ADD_INT32( cf2_stack_getReal( opStack, idx + 3 ), y1 );
+ x3 = ADD_INT32( cf2_stack_getReal( opStack, idx + 4 ), x2 );
+ y3 = ADD_INT32( cf2_stack_getReal( opStack, idx + 5 ), y2 );
+
+ cf2_glyphpath_curveTo( &glyphPath, x1, y1, x2, y2, x3, y3 );
+
+ curX = x3;
+ curY = y3;
+ idx += 6;
+ }
+
+ if ( op1 == cf2_cmdRCURVELINE )
+ {
+ curX = ADD_INT32( curX, cf2_stack_getReal( opStack,
+ idx + 0 ) );
+ curY = ADD_INT32( curY, cf2_stack_getReal( opStack,
+ idx + 1 ) );
+
+ cf2_glyphpath_lineTo( &glyphPath, curX, curY );
+ }
+
+ cf2_stack_clear( opStack );
+ }
+ continue; /* no need to clear stack again */
+
+ case cf2_cmdCLOSEPATH:
+ if ( !font->isT1 )
+ FT_TRACE4(( " unknown op (%d)\n", op1 ));
+ else
+ {
+ FT_TRACE4(( " closepath" ));
+
+ /* if there is no path, `closepath' is a no-op */
+ ps_builder_close_contour( &decoder->builder );
+
+ haveWidth = TRUE;
+ }
+ break;
+
+ case cf2_cmdCALLGSUBR:
+ case cf2_cmdCALLSUBR:
+ {
+ CF2_Int subrNum;
+
+
+ FT_TRACE4(( op1 == cf2_cmdCALLGSUBR ? " callgsubr"
+ : " callsubr" ));
+
+ if ( ( !font->isT1 && charstringIndex > CF2_MAX_SUBR ) ||
+ ( font->isT1 && charstringIndex > T1_MAX_SUBRS_CALLS ) )
+ {
+ /* max subr plus one for charstring */
+ lastError = FT_THROW( Invalid_Glyph_Format );
+ goto exit; /* overflow of stack */
+ }
+
+ /* push our current CFF charstring region on subrStack */
+ charstring = (CF2_Buffer)
+ cf2_arrstack_getPointer(
+ &subrStack,
+ (size_t)charstringIndex + 1 );
+
+ /* set up the new CFF region and pointer */
+ subrNum = cf2_stack_popInt( opStack );
+
+ if ( font->isT1 && decoder->locals_hash )
+ {
+ size_t* val = ft_hash_num_lookup( subrNum,
+ decoder->locals_hash );
+
+
+ if ( val )
+ subrNum = *val;
+ else
+ subrNum = -1;
+ }
+
+ switch ( op1 )
+ {
+ case cf2_cmdCALLGSUBR:
+ FT_TRACE4(( " (idx %d, entering level %d)\n",
+ subrNum + decoder->globals_bias,
+ charstringIndex + 1 ));
+
+ if ( cf2_initGlobalRegionBuffer( decoder,
+ subrNum,
+ charstring ) )
+ {
+ lastError = FT_THROW( Invalid_Glyph_Format );
+ goto exit; /* subroutine lookup or stream error */
+ }
+ break;
+
+ default:
+ /* cf2_cmdCALLSUBR */
+ FT_TRACE4(( " (idx %d, entering level %d)\n",
+ subrNum + decoder->locals_bias,
+ charstringIndex + 1 ));
+
+ if ( cf2_initLocalRegionBuffer( decoder,
+ subrNum,
+ charstring ) )
+ {
+ lastError = FT_THROW( Invalid_Glyph_Format );
+ goto exit; /* subroutine lookup or stream error */
+ }
+ }
+
+ charstringIndex += 1; /* entry is valid now */
+ }
+ continue; /* do not clear the stack */
+
+ case cf2_cmdRETURN:
+ FT_TRACE4(( " return (leaving level %d)\n", charstringIndex ));
+
+ if ( charstringIndex < 1 )
+ {
+ /* Note: cannot return from top charstring */
+ lastError = FT_THROW( Invalid_Glyph_Format );
+ goto exit; /* underflow of stack */
+ }
+
+ /* restore position in previous charstring */
+ charstring = (CF2_Buffer)
+ cf2_arrstack_getPointer(
+ &subrStack,
+ (CF2_UInt)--charstringIndex );
+ continue; /* do not clear the stack */
+
+ case cf2_cmdESC:
+ {
+ 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_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(( " 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(( " flex\n" ));
+
+ cf2_doFlex( opStack,
+ &curX,
+ &curY,
+ &glyphPath,
+ readFromStack,
+ FALSE /* doConditionalLastRead */ );
+ }
+ break; /* TODO: why is this not a continue? */
+
+ 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 */
+ };
+
+
+ FT_TRACE4(( " hflex1\n" ));
+
+ cf2_doFlex( opStack,
+ &curX,
+ &curY,
+ &glyphPath,
+ readFromStack,
+ FALSE /* doConditionalLastRead */ );
+ }
+ continue;
+
+ 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 */
+ };
+
+
+ FT_TRACE4(( " flex1\n" ));
+
+ cf2_doFlex( opStack,
+ &curX,
+ &curY,
+ &glyphPath,
+ readFromStack,
+ TRUE /* doConditionalLastRead */ );
+ }
+ continue;
+
+ /* these opcodes are always reserved */
+ case cf2_escRESERVED_8:
+ case cf2_escRESERVED_13:
+ case cf2_escRESERVED_19:
+ case cf2_escRESERVED_25:
+ case cf2_escRESERVED_31:
+ case cf2_escRESERVED_32:
+ FT_TRACE4(( " unknown op (12, %d)\n", op2 ));
+ break;
+
+ default:
+ {
+ if ( font->isCFF2 || op2 >= cf2_escRESERVED_38 )
+ FT_TRACE4(( " unknown op (12, %d)\n", op2 ));
+ else if ( font->isT1 && result_cnt > 0 && op2 != cf2_escPOP )
+ {
+ /* all operands have been transferred by previous pops */
+ result_cnt = 0;
+ }
+ else
+ {
+ /* second switch for 2-byte operators handles */
+ /* CFF and Type 1 */
+ switch ( op2 )
+ {
+
+ case cf2_escDOTSECTION:
+ /* something about `flip type of locking' -- ignore it */
+ FT_TRACE4(( " dotsection\n" ));
+
+ break;
+
+ case cf2_escVSTEM3:
+ case cf2_escHSTEM3:
+ /*
+ * Type 1: Type 2:
+ * x0 dx0 x1 dx1 x2 dx2 vstem3 x dx {dxa dxb}* vstem
+ * y0 dy0 y1 dy1 y2 dy2 hstem3 y dy {dya dyb}* hstem
+ * relative to lsb point relative to zero
+ *
+ */
+ {
+ if ( !font->isT1 )
+ FT_TRACE4(( " unknown op (12, %d)\n", op2 ));
+ else
+ {
+ CF2_F16Dot16 v0, v1, v2;
+
+ FT_Bool isV = FT_BOOL( op2 == cf2_escVSTEM3 );
+
+
+ FT_TRACE4(( isV ? " vstem3\n"
+ : " hstem3\n" ));
+
+ FT_ASSERT( cf2_stack_count( opStack ) == 6 );
+
+ v0 = cf2_stack_getReal( opStack, 0 );
+ v1 = cf2_stack_getReal( opStack, 2 );
+ v2 = cf2_stack_getReal( opStack, 4 );
+
+ cf2_stack_setReal(
+ opStack, 2,
+ SUB_INT32( SUB_INT32( v1, v0 ),
+ cf2_stack_getReal( opStack, 1 ) ) );
+ cf2_stack_setReal(
+ opStack, 4,
+ SUB_INT32( SUB_INT32( v2, v1 ),
+ cf2_stack_getReal( opStack, 3 ) ) );
+
+ /* add left-sidebearing correction */
+ cf2_doStems( font,
+ opStack,
+ isV ? &vStemHintArray : &hStemHintArray,
+ width,
+ &haveWidth,
+ isV ? decoder->builder.left_bearing->x
+ : decoder->builder.left_bearing->y );
+
+ if ( decoder->width_only )
+ goto exit;
+ }
+ }
+ break;
+
+ case cf2_escAND:
+ {
+ CF2_F16Dot16 arg1;
+ CF2_F16Dot16 arg2;
+
+
+ FT_TRACE4(( " and\n" ));
+
+ arg2 = cf2_stack_popFixed( opStack );
+ arg1 = cf2_stack_popFixed( opStack );
+
+ cf2_stack_pushInt( opStack, arg1 && arg2 );
+ }
+ continue; /* do not clear the stack */
+
+ case cf2_escOR:
+ {
+ CF2_F16Dot16 arg1;
+ CF2_F16Dot16 arg2;
+
+
+ FT_TRACE4(( " or\n" ));
+
+ arg2 = cf2_stack_popFixed( opStack );
+ arg1 = cf2_stack_popFixed( opStack );
+
+ cf2_stack_pushInt( opStack, arg1 || arg2 );
+ }
+ continue; /* do not clear the stack */
+
+ case cf2_escNOT:
+ {
+ CF2_F16Dot16 arg;
+
+
+ FT_TRACE4(( " not\n" ));
+
+ arg = cf2_stack_popFixed( opStack );
+
+ cf2_stack_pushInt( opStack, !arg );
+ }
+ continue; /* do not clear the stack */
+
+ case cf2_escSEAC:
+ if ( !font->isT1 )
+ FT_TRACE4(( " unknown op (12, %d)\n", op2 ));
+ else
+ {
+ FT_Error error2;
+ CF2_Int bchar_index, achar_index;
+ FT_Vector left_bearing, advance;
+
+#ifdef FT_CONFIG_OPTION_INCREMENTAL
+ T1_Face face = (T1_Face)decoder->builder.face;
+#endif
+ CF2_BufferRec component;
+ CF2_Fixed dummyWidth;
+
+ CF2_Int achar = cf2_stack_popInt( opStack );
+ CF2_Int bchar = cf2_stack_popInt( opStack );
+
+ FT_Pos ady = cf2_stack_popFixed ( opStack );
+ FT_Pos adx = cf2_stack_popFixed ( opStack );
+ FT_Pos asb = cf2_stack_popFixed ( opStack );
+
+
+ FT_TRACE4(( " seac\n" ));
+
+ if ( doingSeac )
+ {
+ FT_ERROR(( " nested seac\n" ));
+ lastError = FT_THROW( Invalid_Glyph_Format );
+ goto exit; /* nested seac */
+ }
+
+ if ( decoder->builder.metrics_only )
+ {
+ FT_ERROR(( " unexpected seac\n" ));
+ lastError = FT_THROW( Invalid_Glyph_Format );
+ goto exit; /* unexpected seac */
+ }
+
+ /* `glyph_names' is set to 0 for CID fonts which do */
+ /* not include an encoding. How can we deal with */
+ /* these? */
+#ifdef FT_CONFIG_OPTION_INCREMENTAL
+ if ( decoder->glyph_names == 0 &&
+ !face->root.internal->incremental_interface )
+#else
+ if ( decoder->glyph_names == 0 )
+#endif /* FT_CONFIG_OPTION_INCREMENTAL */
+ {
+ FT_ERROR((
+ "cf2_interpT2CharString: (Type 1 seac)"
+ " glyph names table not available in this font\n" ));
+ lastError = FT_THROW( Invalid_Glyph_Format );
+ goto exit;
+ }
+
+ /* seac weirdness */
+ adx += decoder->builder.left_bearing->x;
+
+#ifdef FT_CONFIG_OPTION_INCREMENTAL
+ if ( face->root.internal->incremental_interface )
+ {
+ /* the caller must handle the font encoding also */
+ bchar_index = bchar;
+ achar_index = achar;
+ }
+ else
+#endif
+ {
+ bchar_index = t1_lookup_glyph_by_stdcharcode_ps(
+ decoder, bchar );
+ achar_index = t1_lookup_glyph_by_stdcharcode_ps(
+ decoder, achar );
+ }
+
+ if ( bchar_index < 0 || achar_index < 0 )
+ {
+ FT_ERROR((
+ "cf2_interpT2CharString: (Type 1 seac)"
+ " invalid seac character code arguments\n" ));
+ lastError = FT_THROW( Invalid_Glyph_Format );
+ goto exit;
+ }
+
+ /* if we are trying to load a composite glyph, */
+ /* do not load the accent character and return */
+ /* the array of subglyphs. */
+ if ( decoder->builder.no_recurse )
+ {
+ FT_GlyphSlot glyph = (FT_GlyphSlot)decoder->builder.glyph;
+ FT_GlyphLoader loader = glyph->internal->loader;
+ FT_SubGlyph subg;
+
+
+ /* reallocate subglyph array if necessary */
+ error2 = FT_GlyphLoader_CheckSubGlyphs( loader, 2 );
+ if ( error2 )
+ {
+ lastError = error2; /* pass FreeType error through */
+ goto exit;
+ }
+
+ subg = loader->current.subglyphs;
+
+ /* subglyph 0 = base character */
+ subg->index = bchar_index;
+ subg->flags = FT_SUBGLYPH_FLAG_ARGS_ARE_XY_VALUES |
+ FT_SUBGLYPH_FLAG_USE_MY_METRICS;
+ subg->arg1 = 0;
+ subg->arg2 = 0;
+ subg++;
+
+ /* subglyph 1 = accent character */
+ subg->index = achar_index;
+ subg->flags = FT_SUBGLYPH_FLAG_ARGS_ARE_XY_VALUES;
+ subg->arg1 = (FT_Int)FIXED_TO_INT( adx - asb );
+ subg->arg2 = (FT_Int)FIXED_TO_INT( ady );
+
+ /* set up remaining glyph fields */
+ glyph->num_subglyphs = 2;
+ glyph->subglyphs = loader->base.subglyphs;
+ glyph->format = FT_GLYPH_FORMAT_COMPOSITE;
+
+ loader->current.num_subglyphs = 2;
+
+ goto exit;
+ }
+
+ /* First load `bchar' in builder */
+ /* now load the unscaled outline */
+
+ /* prepare loader */
+ FT_GlyphLoader_Prepare( decoder->builder.loader );
+
+ error2 = cf2_getT1SeacComponent( decoder,
+ (FT_UInt)bchar_index,
+ &component );
+ if ( error2 )
+ {
+ lastError = error2; /* pass FreeType error through */
+ goto exit;
+ }
+ cf2_interpT2CharString( font,
+ &component,
+ callbacks,
+ translation,
+ TRUE,
+ 0,
+ 0,
+ &dummyWidth );
+ cf2_freeT1SeacComponent( decoder, &component );
+
+ /* save the left bearing and width of the base */
+ /* character as they will be erased by the next load */
+
+ left_bearing = *decoder->builder.left_bearing;
+ advance = *decoder->builder.advance;
+
+ decoder->builder.left_bearing->x = 0;
+ decoder->builder.left_bearing->y = 0;
+
+ /* Now load `achar' on top of */
+ /* the base outline */
+
+ error2 = cf2_getT1SeacComponent( decoder,
+ (FT_UInt)achar_index,
+ &component );
+ if ( error2 )
+ {
+ lastError = error2; /* pass FreeType error through */
+ goto exit;
+ }
+ cf2_interpT2CharString( font,
+ &component,
+ callbacks,
+ translation,
+ TRUE,
+ adx - asb,
+ ady,
+ &dummyWidth );
+ cf2_freeT1SeacComponent( decoder, &component );
+
+ /* restore the left side bearing and */
+ /* advance width of the base character */
+
+ *decoder->builder.left_bearing = left_bearing;
+ *decoder->builder.advance = advance;
+
+ goto exit;
+ }
+ break;
+
+ case cf2_escSBW:
+ if ( !font->isT1 )
+ FT_TRACE4(( " unknown op (12, %d)\n", op2 ));
+ else
+ {
+ CF2_Fixed lsb_x, lsb_y;
+ PS_Builder* builder;
+
+
+ FT_TRACE4(( " sbw" ));
+
+ builder = &decoder->builder;
+
+ builder->advance->y = cf2_stack_popFixed( opStack );
+ builder->advance->x = cf2_stack_popFixed( opStack );
+
+ lsb_y = cf2_stack_popFixed( opStack );
+ lsb_x = cf2_stack_popFixed( opStack );
+
+ builder->left_bearing->x =
+ ADD_INT32( builder->left_bearing->x, lsb_x );
+ builder->left_bearing->y =
+ ADD_INT32( builder->left_bearing->y, lsb_y );
+
+ haveWidth = TRUE;
+
+ /* the `metrics_only' indicates that we only want */
+ /* to compute the glyph's metrics (lsb + advance */
+ /* width), not load the rest of it; so exit */
+ /* immediately */
+ if ( builder->metrics_only )
+ goto exit;
+
+ if ( initial_map_ready )
+ {
+ curX = ADD_INT32( curX, lsb_x );
+ curY = ADD_INT32( curY, lsb_y );
+ }
+ }
+ break;
+
+ case cf2_escABS:
+ {
+ CF2_F16Dot16 arg;
+
+
+ FT_TRACE4(( " abs\n" ));
+
+ arg = cf2_stack_popFixed( opStack );
+
+ if ( arg < -CF2_FIXED_MAX )
+ cf2_stack_pushFixed( opStack, CF2_FIXED_MAX );
+ else
+ cf2_stack_pushFixed( opStack, FT_ABS( arg ) );
+ }
+ continue; /* do not clear the stack */
+
+ case cf2_escADD:
+ {
+ CF2_F16Dot16 summand1;
+ CF2_F16Dot16 summand2;
+
+
+ FT_TRACE4(( " add\n" ));
+
+ summand2 = cf2_stack_popFixed( opStack );
+ summand1 = cf2_stack_popFixed( opStack );
+
+ cf2_stack_pushFixed( opStack,
+ ADD_INT32( summand1,
+ summand2 ) );
+ }
+ continue; /* do not clear the stack */
+
+ case cf2_escSUB:
+ {
+ CF2_F16Dot16 minuend;
+ CF2_F16Dot16 subtrahend;
+
+
+ FT_TRACE4(( " sub\n" ));
+
+ subtrahend = cf2_stack_popFixed( opStack );
+ minuend = cf2_stack_popFixed( opStack );
+
+ cf2_stack_pushFixed( opStack,
+ SUB_INT32( minuend, subtrahend ) );
+ }
+ continue; /* do not clear the stack */
+
+ case cf2_escDIV:
+ {
+ CF2_F16Dot16 dividend;
+ CF2_F16Dot16 divisor;
+
+
+ FT_TRACE4(( " div\n" ));
+
+ if ( font->isT1 && large_int )
+ {
+ divisor = (CF2_F16Dot16)cf2_stack_popInt( opStack );
+ dividend = (CF2_F16Dot16)cf2_stack_popInt( opStack );
+
+ large_int = FALSE;
+ }
+ else
+ {
+ divisor = cf2_stack_popFixed( opStack );
+ dividend = cf2_stack_popFixed( opStack );
+ }
+
+ cf2_stack_pushFixed( opStack,
+ FT_DivFix( dividend, divisor ) );
+
+ }
+ continue; /* do not clear the stack */
+
+ case cf2_escNEG:
+ {
+ CF2_F16Dot16 arg;
+
+
+ FT_TRACE4(( " neg\n" ));
+
+ arg = cf2_stack_popFixed( opStack );
+
+ if ( arg < -CF2_FIXED_MAX )
+ cf2_stack_pushFixed( opStack, CF2_FIXED_MAX );
+ else
+ cf2_stack_pushFixed( opStack, -arg );
+ }
+ continue; /* do not clear the stack */
+
+ case cf2_escEQ:
+ {
+ CF2_F16Dot16 arg1;
+ CF2_F16Dot16 arg2;
+
+
+ FT_TRACE4(( " eq\n" ));
+
+ arg2 = cf2_stack_popFixed( opStack );
+ arg1 = cf2_stack_popFixed( opStack );
+
+ cf2_stack_pushInt( opStack, arg1 == arg2 );
+ }
+ continue; /* do not clear the stack */
+
+ case cf2_escCALLOTHERSUBR:
+ if ( !font->isT1 )
+ FT_TRACE4(( " unknown op (12, %d)\n", op2 ));
+ else
+ {
+ CF2_Int subr_no;
+ CF2_Int arg_cnt;
+ CF2_UInt count;
+ CF2_UInt opIdx = 0;
+
+
+ FT_TRACE4(( " callothersubr\n" ));
+
+ subr_no = cf2_stack_popInt( opStack );
+ arg_cnt = cf2_stack_popInt( opStack );
+
+ /*******************************************************/
+ /* */
+ /* remove all operands to callothersubr from the stack */
+ /* */
+ /* for handled othersubrs, where we know the number of */
+ /* arguments, we increase the stack by the value of */
+ /* known_othersubr_result_cnt */
+ /* */
+ /* for unhandled othersubrs the following pops adjust */
+ /* the stack pointer as necessary */
+
+ count = cf2_stack_count( opStack );
+ FT_ASSERT( (CF2_UInt)arg_cnt <= count );
+
+ opIdx += count - (CF2_UInt)arg_cnt;
+
+ known_othersubr_result_cnt = 0;
+ result_cnt = 0;
+
+ /* XXX TODO: The checks to `arg_count == <whatever>' */
+ /* might not be correct; an othersubr expects a */
+ /* certain number of operands on the PostScript stack */
+ /* (as opposed to the T1 stack) but it doesn't have to */
+ /* put them there by itself; previous othersubrs might */
+ /* have left the operands there if they were not */
+ /* followed by an appropriate number of pops */
+ /* */
+ /* On the other hand, Adobe Reader 7.0.8 for Linux */
+ /* doesn't accept a font that contains charstrings */
+ /* like */
+ /* */
+ /* 100 200 2 20 callothersubr */
+ /* 300 1 20 callothersubr pop */
+ /* */
+ /* Perhaps this is the reason why BuildCharArray */
+ /* exists. */
+
+ switch ( subr_no )
+ {
+ case 0: /* end flex feature */
+ if ( arg_cnt != 3 )
+ goto Unexpected_OtherSubr;
+
+ if ( initial_map_ready &&
+ ( !decoder->flex_state ||
+ decoder->num_flex_vectors != 7 ) )
+ {
+ FT_ERROR(( "cf2_interpT2CharString (Type 1 mode):"
+ " unexpected flex end\n" ));
+ lastError = FT_THROW( Invalid_Glyph_Format );
+ goto exit;
+ }
+
+ /* the two `results' are popped */
+ /* by the following setcurrentpoint */
+ cf2_stack_pushFixed( opStack, curX );
+ cf2_stack_pushFixed( opStack, curY );
+ known_othersubr_result_cnt = 2;
+ break;
+
+ case 1: /* start flex feature */
+ if ( arg_cnt != 0 )
+ goto Unexpected_OtherSubr;
+
+ if ( !initial_map_ready )
+ break;
+
+ if ( ps_builder_check_points( &decoder->builder, 6 ) )
+ goto exit;
+
+ decoder->flex_state = 1;
+ decoder->num_flex_vectors = 0;
+ break;
+
+ case 2: /* add flex vectors */
+ {
+ FT_Int idx;
+ FT_Int idx2;
+
+
+ if ( arg_cnt != 0 )
+ goto Unexpected_OtherSubr;
+
+ if ( !initial_map_ready )
+ break;
+
+ if ( !decoder->flex_state )
+ {
+ FT_ERROR(( "cf2_interpT2CharString (Type 1 mode):"
+ " missing flex start\n" ));
+ lastError = FT_THROW( Invalid_Glyph_Format );
+ goto exit;
+ }
+
+ /* note that we should not add a point for */
+ /* index 0; this will move our current position */
+ /* to the flex 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 ( ps_builder_check_points( &decoder->builder,
+ 1 ) )
+ {
+ lastError = FT_THROW( Invalid_Glyph_Format );
+ goto exit;
+ }
+
+ /* map: 1->2 2->4 3->6 4->2 5->4 6->6 */
+ idx2 = ( idx > 3 ? idx - 3 : idx ) * 2;
+
+ flexStore[idx2 - 2] = curX;
+ flexStore[idx2 - 1] = curY;
+
+ if ( idx == 3 || idx == 6 )
+ cf2_glyphpath_curveTo( &glyphPath,
+ flexStore[0],
+ flexStore[1],
+ flexStore[2],
+ flexStore[3],
+ flexStore[4],
+ flexStore[5] );
+ }
+ }
+ break;
+
+ case 3: /* change hints */
+ if ( arg_cnt != 1 )
+ goto Unexpected_OtherSubr;
+
+ if ( initial_map_ready )
+ {
+ /* do not clear hints if initial hintmap */
+ /* is not ready - we need to collate all */
+ cf2_arrstack_clear( &vStemHintArray );
+ cf2_arrstack_clear( &hStemHintArray );
+
+ cf2_hintmask_init( &hintMask, error );
+ hintMask.isValid = FALSE;
+ hintMask.isNew = TRUE;
+ }
+
+ known_othersubr_result_cnt = 1;
+ break;
+
+ case 12:
+ case 13:
+ /* counter control hints, clear stack */
+ cf2_stack_clear( opStack );
+ break;
+
+ case 14:
+ case 15:
+ case 16:
+ case 17:
+ case 18: /* multiple masters */
+ {
+ PS_Blend blend = decoder->blend;
+ FT_UInt num_points, nn, mm;
+ CF2_UInt delta;
+ CF2_UInt values;
+
+
+ if ( !blend )
+ {
+ FT_ERROR((
+ "cf2_interpT2CharString:"
+ " unexpected multiple masters operator\n" ));
+ lastError = FT_THROW( Invalid_Glyph_Format );
+ goto exit;
+ }
+
+ num_points = (FT_UInt)subr_no - 13 +
+ ( subr_no == 18 );
+ if ( arg_cnt != (FT_Int)( num_points *
+ blend->num_designs ) )
+ {
+ FT_ERROR((
+ "cf2_interpT2CharString:"
+ " incorrect number of multiple masters arguments\n" ));
+ lastError = FT_THROW( Invalid_Glyph_Format );
+ goto exit;
+ }
+
+ /* We want to compute */
+ /* */
+ /* a0*w0 + a1*w1 + ... + ak*wk */
+ /* */
+ /* but we only have a0, a1-a0, a2-a0, ..., ak-a0. */
+ /* */
+ /* However, given that w0 + w1 + ... + wk == 1, we */
+ /* can rewrite it easily as */
+ /* */
+ /* a0 + (a1-a0)*w1 + (a2-a0)*w2 + ... + (ak-a0)*wk */
+ /* */
+ /* where k == num_designs-1. */
+ /* */
+ /* I guess that's why it's written in this `compact' */
+ /* form. */
+ /* */
+ delta = opIdx + num_points;
+ values = opIdx;
+ for ( nn = 0; nn < num_points; nn++ )
+ {
+ CF2_Fixed tmp = cf2_stack_getReal( opStack,
+ values );
+
+
+ for ( mm = 1; mm < blend->num_designs; mm++ )
+ tmp = ADD_INT32( tmp,
+ FT_MulFix(
+ cf2_stack_getReal( opStack,
+ delta++ ),
+ blend->weight_vector[mm] ) );
+
+ cf2_stack_setReal( opStack, values++, tmp );
+ }
+ cf2_stack_pop( opStack,
+ (CF2_UInt)arg_cnt - num_points );
+
+ known_othersubr_result_cnt = (FT_Int)num_points;
+ break;
+ }
+
+ case 19:
+ /* <idx> 1 19 callothersubr */
+ /* ==> replace elements starting from index */
+ /* cvi( <idx> ) of BuildCharArray with */
+ /* WeightVector */
+ {
+ FT_Int idx;
+ PS_Blend blend = decoder->blend;
+
+
+ if ( arg_cnt != 1 || !blend )
+ goto Unexpected_OtherSubr;
+
+ idx = cf2_stack_popInt( opStack );
+
+ if ( idx < 0 ||
+ (FT_UInt)idx + blend->num_designs >
+ decoder->len_buildchar )
+ goto Unexpected_OtherSubr;
+
+ ft_memcpy( &decoder->buildchar[idx],
+ blend->weight_vector,
+ blend->num_designs *
+ sizeof ( blend->weight_vector[0] ) );
+ }
+ break;
+
+ case 20:
+ /* <arg1> <arg2> 2 20 callothersubr pop */
+ /* ==> push <arg1> + <arg2> onto T1 stack */
+ {
+ CF2_F16Dot16 summand1;
+ CF2_F16Dot16 summand2;
+
+
+ if ( arg_cnt != 2 )
+ goto Unexpected_OtherSubr;
+
+ summand2 = cf2_stack_popFixed( opStack );
+ summand1 = cf2_stack_popFixed( opStack );
+
+ cf2_stack_pushFixed( opStack,
+ ADD_INT32( summand1,
+ summand2 ) );
+ known_othersubr_result_cnt = 1;
+ }
+ break;
+
+ case 21:
+ /* <arg1> <arg2> 2 21 callothersubr pop */
+ /* ==> push <arg1> - <arg2> onto T1 stack */
+ {
+ CF2_F16Dot16 minuend;
+ CF2_F16Dot16 subtrahend;
+
+
+ if ( arg_cnt != 2 )
+ goto Unexpected_OtherSubr;
+
+ subtrahend = cf2_stack_popFixed( opStack );
+ minuend = cf2_stack_popFixed( opStack );
+
+ cf2_stack_pushFixed( opStack,
+ SUB_INT32( minuend,
+ subtrahend ) );
+ known_othersubr_result_cnt = 1;
+ }
+ break;
+
+ case 22:
+ /* <arg1> <arg2> 2 22 callothersubr pop */
+ /* ==> push <arg1> * <arg2> onto T1 stack */
+ {
+ CF2_F16Dot16 factor1;
+ CF2_F16Dot16 factor2;
+
+
+ if ( arg_cnt != 2 )
+ goto Unexpected_OtherSubr;
+
+ factor2 = cf2_stack_popFixed( opStack );
+ factor1 = cf2_stack_popFixed( opStack );
+
+ cf2_stack_pushFixed( opStack,
+ FT_MulFix( factor1, factor2 ) );
+ known_othersubr_result_cnt = 1;
+ }
+ break;
+
+ case 23:
+ /* <arg1> <arg2> 2 23 callothersubr pop */
+ /* ==> push <arg1> / <arg2> onto T1 stack */
+ {
+ CF2_F16Dot16 dividend;
+ CF2_F16Dot16 divisor;
+
+
+ if ( arg_cnt != 2 )
+ goto Unexpected_OtherSubr;
+
+ divisor = cf2_stack_popFixed( opStack );
+ dividend = cf2_stack_popFixed( opStack );
+
+ if ( divisor == 0 )
+ goto Unexpected_OtherSubr;
+
+ cf2_stack_pushFixed( opStack,
+ FT_DivFix( dividend,
+ divisor ) );
+ known_othersubr_result_cnt = 1;
+ }
+ break;
+
+ case 24:
+ /* <val> <idx> 2 24 callothersubr */
+ /* ==> set BuildCharArray[cvi( <idx> )] = <val> */
+ {
+ CF2_Int idx;
+ PS_Blend blend = decoder->blend;
+
+
+ if ( arg_cnt != 2 || !blend )
+ goto Unexpected_OtherSubr;
+
+ idx = cf2_stack_popInt( opStack );
+
+ if ( idx < 0 ||
+ (FT_UInt)idx >= decoder->len_buildchar )
+ goto Unexpected_OtherSubr;
+
+ decoder->buildchar[idx] =
+ cf2_stack_popFixed( opStack );
+ }
+ break;
+
+ case 25:
+ /* <idx> 1 25 callothersubr pop */
+ /* ==> push BuildCharArray[cvi( idx )] */
+ /* onto T1 stack */
+ {
+ CF2_Int idx;
+ PS_Blend blend = decoder->blend;
+
+
+ if ( arg_cnt != 1 || !blend )
+ goto Unexpected_OtherSubr;
+
+ idx = cf2_stack_popInt( opStack );
+
+ if ( idx < 0 ||
+ (FT_UInt)idx >= decoder->len_buildchar )
+ goto Unexpected_OtherSubr;
+
+ cf2_stack_pushFixed( opStack,
+ decoder->buildchar[idx] );
+ known_othersubr_result_cnt = 1;
+ }
+ break;
+
+#if 0
+ case 26:
+ /* <val> mark <idx> */
+ /* ==> set BuildCharArray[cvi( <idx> )] = <val>, */
+ /* leave mark on T1 stack */
+ /* <val> <idx> */
+ /* ==> set BuildCharArray[cvi( <idx> )] = <val> */
+ XXX which routine has left its mark on the
+ XXX (PostScript) stack?;
+ break;
+#endif
+
+ case 27:
+ /* <res1> <res2> <val1> <val2> 4 27 callothersubr pop */
+ /* ==> push <res1> onto T1 stack if <val1> <= <val2>, */
+ /* otherwise push <res2> */
+ {
+ CF2_F16Dot16 arg1;
+ CF2_F16Dot16 arg2;
+ CF2_F16Dot16 cond1;
+ CF2_F16Dot16 cond2;
+
+
+ if ( arg_cnt != 4 )
+ goto Unexpected_OtherSubr;
+
+ cond2 = cf2_stack_popFixed( opStack );
+ cond1 = cf2_stack_popFixed( opStack );
+ arg2 = cf2_stack_popFixed( opStack );
+ arg1 = cf2_stack_popFixed( opStack );
+
+ cf2_stack_pushFixed( opStack,
+ cond1 <= cond2 ? arg1 : arg2 );
+ known_othersubr_result_cnt = 1;
+ }
+ break;
+
+ case 28:
+ /* 0 28 callothersubr pop */
+ /* ==> push random value from interval [0, 1) */
+ /* onto stack */
+ {
+ CF2_F16Dot16 r;
+
+
+ if ( arg_cnt != 0 )
+ goto Unexpected_OtherSubr;
+
+ /* 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 );
+
+ decoder->current_subfont->random =
+ cff_random( decoder->current_subfont->random );
+
+ cf2_stack_pushFixed( opStack, r );
+ known_othersubr_result_cnt = 1;
+ }
+ break;
+
+ default:
+ if ( arg_cnt >= 0 && subr_no >= 0 )
+ {
+ FT_Int i;
+
+
+ FT_ERROR((
+ "cf2_interpT2CharString (Type 1 mode):"
+ " unknown othersubr [%d %d], wish me luck\n",
+ arg_cnt, subr_no ));
+
+ /* store the unused args */
+ /* for this unhandled OtherSubr */
+
+ if ( arg_cnt > PS_STORAGE_SIZE )
+ arg_cnt = PS_STORAGE_SIZE;
+ result_cnt = arg_cnt;
+
+ for ( i = 1; i <= arg_cnt; i++ )
+ results[result_cnt - i] =
+ cf2_stack_popFixed( opStack );
+
+ break;
+ }
+ /* fall through */
+
+ Unexpected_OtherSubr:
+ FT_ERROR(( "cf2_interpT2CharString (Type 1 mode):"
+ " invalid othersubr [%d %d]\n",
+ arg_cnt, subr_no ));
+ lastError = FT_THROW( Invalid_Glyph_Format );
+ goto exit;
+ }
+ }
+ continue; /* do not clear the stack */
+
+ case cf2_escPOP:
+ if ( !font->isT1 )
+ FT_TRACE4(( " unknown op (12, %d)\n", op2 ));
+ else
+ {
+ FT_TRACE4(( " pop" ));
+
+ if ( known_othersubr_result_cnt > 0 )
+ {
+ known_othersubr_result_cnt--;
+ /* ignore, we pushed the operands ourselves */
+ continue;
+ }
+
+ if ( result_cnt == 0 )
+ {
+ FT_ERROR(( "cf2_interpT2CharString (Type 1 mode):"
+ " no more operands for othersubr\n" ));
+ lastError = FT_THROW( Invalid_Glyph_Format );
+ goto exit;
+ }
+
+ result_cnt--;
+ cf2_stack_pushFixed( opStack, results[result_cnt] );
+ }
+ continue; /* do not clear the stack */
+
+ case cf2_escDROP:
+ FT_TRACE4(( " drop\n" ));
+
+ (void)cf2_stack_popFixed( opStack );
+ continue; /* do not clear the stack */
+
+ case cf2_escPUT:
+ {
+ CF2_F16Dot16 val;
+ CF2_Int idx;
+
+
+ FT_TRACE4(( " put\n" ));
+
+ idx = cf2_stack_popInt( opStack );
+ val = cf2_stack_popFixed( opStack );
+
+ if ( idx >= 0 && idx < CF2_STORAGE_SIZE )
+ storage[idx] = val;
+ }
+ continue; /* do not clear the stack */
+
+ case cf2_escGET:
+ {
+ CF2_Int idx;
+
+
+ FT_TRACE4(( " get\n" ));
+
+ idx = cf2_stack_popInt( opStack );
+
+ if ( idx >= 0 && idx < CF2_STORAGE_SIZE )
+ cf2_stack_pushFixed( opStack, storage[idx] );
+ }
+ continue; /* do not clear the stack */
+
+ case cf2_escIFELSE:
+ {
+ CF2_F16Dot16 arg1;
+ CF2_F16Dot16 arg2;
+ CF2_F16Dot16 cond1;
+ CF2_F16Dot16 cond2;
+
+
+ FT_TRACE4(( " ifelse\n" ));
+
+ cond2 = cf2_stack_popFixed( opStack );
+ cond1 = cf2_stack_popFixed( opStack );
+ arg2 = cf2_stack_popFixed( opStack );
+ arg1 = cf2_stack_popFixed( opStack );
+
+ cf2_stack_pushFixed( opStack,
+ cond1 <= cond2 ? arg1 : arg2 );
+ }
+ continue; /* do not clear the stack */
+
+ case cf2_escRANDOM: /* in spec */
+ {
+ CF2_F16Dot16 r;
+
+
+ FT_TRACE4(( " random\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 );
+
+ decoder->current_subfont->random =
+ cff_random( decoder->current_subfont->random );
+
+ cf2_stack_pushFixed( opStack, r );
+ }
+ continue; /* do not clear the stack */
+
+ case cf2_escMUL:
+ {
+ CF2_F16Dot16 factor1;
+ CF2_F16Dot16 factor2;
+
+
+ FT_TRACE4(( " mul\n" ));
+
+ factor2 = cf2_stack_popFixed( opStack );
+ factor1 = cf2_stack_popFixed( opStack );
+
+ cf2_stack_pushFixed( opStack,
+ FT_MulFix( factor1, factor2 ) );
+ }
+ continue; /* do not clear the stack */
+
+ case cf2_escSQRT:
+ {
+ CF2_F16Dot16 arg;
+
+
+ FT_TRACE4(( " sqrt\n" ));
+
+ arg = cf2_stack_popFixed( opStack );
+ if ( arg > 0 )
+ {
+ /* use a start value that doesn't make */
+ /* the algorithm's addition overflow */
+ FT_Fixed root = arg < 10 ? arg : arg >> 1;
+ FT_Fixed new_root;
+
+
+ /* 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;
+
+ cf2_stack_pushFixed( opStack, arg );
+ }
+ continue; /* do not clear the stack */
+
+ case cf2_escDUP:
+ {
+ CF2_F16Dot16 arg;
+
+
+ FT_TRACE4(( " dup\n" ));
+
+ arg = cf2_stack_popFixed( opStack );
+
+ cf2_stack_pushFixed( opStack, arg );
+ cf2_stack_pushFixed( opStack, arg );
+ }
+ continue; /* do not clear the stack */
+
+ case cf2_escEXCH:
+ {
+ CF2_F16Dot16 arg1;
+ CF2_F16Dot16 arg2;
+
+
+ FT_TRACE4(( " exch\n" ));
+
+ arg2 = cf2_stack_popFixed( opStack );
+ arg1 = cf2_stack_popFixed( opStack );
+
+ 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(( " index\n" ));
+
+ 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;
+
+
+ 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 */
+
+ 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 */
+
+ case cf2_escSETCURRENTPT:
+ if ( !font->isT1 )
+ FT_TRACE4(( " unknown op (12, %d)\n", op2 ));
+ else
+ {
+ FT_TRACE4(( " setcurrentpoint" ));
+
+ if ( !initial_map_ready )
+ break;
+
+ /* From the T1 specification, section 6.4: */
+ /* */
+ /* The setcurrentpoint command is used only in */
+ /* conjunction with results from OtherSubrs */
+ /* procedures. */
+
+ /* known_othersubr_result_cnt != 0 is already handled */
+ /* above. */
+
+ /* Note, however, that both Ghostscript and Adobe */
+ /* Distiller handle this situation by silently */
+ /* ignoring the inappropriate `setcurrentpoint' */
+ /* instruction. So we do the same. */
+#if 0
+
+ if ( decoder->flex_state != 1 )
+ {
+ FT_ERROR(( "cf2_interpT2CharString:"
+ " unexpected `setcurrentpoint'\n" ));
+ goto Syntax_Error;
+ }
+ else
+ ...
+#endif
+
+ curY = cf2_stack_popFixed( opStack );
+ curX = cf2_stack_popFixed( opStack );
+
+ decoder->flex_state = 0;
+ }
+ break;
+
+ } /* end of 2nd switch checking op2 */
+ }
+ }
+ } /* end of 1st switch checking op2 */
+ } /* case cf2_cmdESC */
+
+ break;
+
+ case cf2_cmdHSBW:
+ if ( !font->isT1 )
+ FT_TRACE4(( " unknown op (%d)\n", op1 ));
+ else
+ {
+ CF2_Fixed lsb_x;
+ PS_Builder* builder;
+
+
+ FT_TRACE4(( " hsbw" ));
+
+ builder = &decoder->builder;
+
+ builder->advance->x = cf2_stack_popFixed( opStack );
+ builder->advance->y = 0;
+
+ lsb_x = cf2_stack_popFixed( opStack );
+
+ builder->left_bearing->x = ADD_INT32( builder->left_bearing->x,
+ lsb_x );
+
+ haveWidth = TRUE;
+
+ /* the `metrics_only' indicates that we only want to compute */
+ /* the glyph's metrics (lsb + advance width), not load the */
+ /* rest of it; so exit immediately */
+ if ( builder->metrics_only )
+ goto exit;
+
+ if ( initial_map_ready )
+ curX = ADD_INT32( curX, lsb_x );
+ }
+ break;
+
+ case cf2_cmdENDCHAR:
+ FT_TRACE4(( " endchar\n" ));
+
+ if ( font->isT1 && !initial_map_ready )
+ {
+ FT_TRACE5(( "cf2_interpT2CharString (Type 1 mode): "
+ "Build initial hintmap, rewinding...\n" ));
+
+ /* trigger initial hintmap build */
+ cf2_glyphpath_moveTo( &glyphPath, curX, curY );
+
+ initial_map_ready = TRUE;
+
+ /* change hints routine - clear for rewind */
+ cf2_arrstack_clear( &vStemHintArray );
+ cf2_arrstack_clear( &hStemHintArray );
+
+ cf2_hintmask_init( &hintMask, error );
+ hintMask.isValid = FALSE;
+ hintMask.isNew = TRUE;
+
+ /* rewind charstring */
+ /* some charstrings use endchar from a final subroutine call */
+ /* without returning, detect these and exit to the top level */
+ /* charstring */
+ while ( charstringIndex > 0 )
+ {
+ FT_TRACE4(( " return (leaving level %d)\n", charstringIndex ));
+
+ /* restore position in previous charstring */
+ charstring = (CF2_Buffer)
+ cf2_arrstack_getPointer(
+ &subrStack,
+ (CF2_UInt)--charstringIndex );
+ }
+ charstring->ptr = charstring->start;
+
+ break;
+ }
+
+ if ( cf2_stack_count( opStack ) == 1 ||
+ cf2_stack_count( opStack ) == 5 )
+ {
+ if ( !haveWidth )
+ *width = ADD_INT32( cf2_stack_getReal( opStack, 0 ),
+ nominalWidthX );
+ }
+
+ /* width is defined or default after this */
+ haveWidth = TRUE;
+
+ if ( decoder->width_only )
+ goto exit;
+
+ /* close path if still open */
+ cf2_glyphpath_closeOpenPath( &glyphPath );
+
+ /* disable seac for CFF2 and Type1 */
+ /* (charstring ending with args on stack) */
+ if ( !font->isCFF2 && !font->isT1 && cf2_stack_count( opStack ) > 1 )
+ {
+ /* must be either 4 or 5 -- */
+ /* this is a (deprecated) implied `seac' operator */
+
+ CF2_Int achar;
+ CF2_Int bchar;
+ CF2_BufferRec component;
+ CF2_Fixed dummyWidth; /* ignore component width */
+ FT_Error error2;
+
+
+ if ( doingSeac )
+ {
+ lastError = FT_THROW( Invalid_Glyph_Format );
+ goto exit; /* nested seac */
+ }
+
+ achar = cf2_stack_popInt( opStack );
+ bchar = cf2_stack_popInt( opStack );
+
+ curY = cf2_stack_popFixed( opStack );
+ curX = cf2_stack_popFixed( opStack );
+
+ error2 = cf2_getSeacComponent( decoder, achar, &component );
+ if ( error2 )
+ {
+ lastError = error2; /* pass FreeType error through */
+ goto exit;
+ }
+ cf2_interpT2CharString( font,
+ &component,
+ callbacks,
+ translation,
+ TRUE,
+ curX,
+ curY,
+ &dummyWidth );
+ cf2_freeSeacComponent( decoder, &component );
+
+ error2 = cf2_getSeacComponent( decoder, bchar, &component );
+ if ( error2 )
+ {
+ lastError = error2; /* pass FreeType error through */
+ goto exit;
+ }
+ cf2_interpT2CharString( font,
+ &component,
+ callbacks,
+ translation,
+ TRUE,
+ 0,
+ 0,
+ &dummyWidth );
+ cf2_freeSeacComponent( decoder, &component );
+ }
+ goto exit;
+
+ case cf2_cmdCNTRMASK:
+ case cf2_cmdHINTMASK:
+ /* the final \n in the tracing message gets added in */
+ /* `cf2_hintmask_read' (which also traces the mask bytes) */
+ FT_TRACE4(( op1 == cf2_cmdCNTRMASK ? " cntrmask" : " hintmask" ));
+
+ /* never add hints after the mask is computed */
+ if ( cf2_stack_count( opStack ) > 1 &&
+ cf2_hintmask_isValid( &hintMask ) )
+ {
+ FT_TRACE4(( "cf2_interpT2CharString: invalid hint mask\n" ));
+ break;
+ }
+
+ /* if there are arguments on the stack, there this is an */
+ /* implied cf2_cmdVSTEMHM */
+ cf2_doStems( font,
+ opStack,
+ &vStemHintArray,
+ width,
+ &haveWidth,
+ 0 );
+
+ if ( decoder->width_only )
+ goto exit;
+
+ if ( op1 == cf2_cmdHINTMASK )
+ {
+ /* consume the hint mask bytes which follow the operator */
+ cf2_hintmask_read( &hintMask,
+ charstring,
+ cf2_arrstack_size( &hStemHintArray ) +
+ cf2_arrstack_size( &vStemHintArray ) );
+ }
+ else
+ {
+ /*
+ * Consume the counter mask bytes which follow the operator:
+ * Build a temporary hint map, just to place and lock those
+ * stems participating in the counter mask. These are most
+ * likely the dominant hstems, and are grouped together in a
+ * few counter groups, not necessarily in correspondence
+ * with the hint groups. This reduces the chances of
+ * conflicts between hstems that are initially placed in
+ * separate hint groups and then brought together. The
+ * positions are copied back to `hStemHintArray', so we can
+ * discard `counterMask' and `counterHintMap'.
+ *
+ */
+ CF2_HintMapRec counterHintMap;
+ CF2_HintMaskRec counterMask;
+
+
+ cf2_hintmap_init( &counterHintMap,
+ font,
+ &glyphPath.initialHintMap,
+ &glyphPath.hintMoves,
+ scaleY );
+ cf2_hintmask_init( &counterMask, error );
+
+ cf2_hintmask_read( &counterMask,
+ charstring,
+ cf2_arrstack_size( &hStemHintArray ) +
+ cf2_arrstack_size( &vStemHintArray ) );
+ cf2_hintmap_build( &counterHintMap,
+ &hStemHintArray,
+ &vStemHintArray,
+ &counterMask,
+ 0,
+ FALSE );
+ }
+ break;
+
+ case cf2_cmdRMOVETO:
+ FT_TRACE4(( " rmoveto\n" ));
+
+ if ( font->isT1 && !decoder->flex_state && !haveWidth )
+ FT_ERROR(( "cf2_interpT2CharString (Type 1 mode):"
+ " No width. Use hsbw/sbw as first op\n" ));
+
+ if ( cf2_stack_count( opStack ) > 2 && !haveWidth )
+ *width = ADD_INT32( cf2_stack_getReal( opStack, 0 ),
+ nominalWidthX );
+
+ /* width is defined or default after this */
+ haveWidth = TRUE;
+
+ if ( decoder->width_only )
+ goto exit;
+
+ curY = ADD_INT32( curY, cf2_stack_popFixed( opStack ) );
+ curX = ADD_INT32( curX, cf2_stack_popFixed( opStack ) );
+
+ if ( !decoder->flex_state )
+ cf2_glyphpath_moveTo( &glyphPath, curX, curY );
+
+ break;
+
+ case cf2_cmdHMOVETO:
+ FT_TRACE4(( " hmoveto\n" ));
+
+ if ( font->isT1 && !decoder->flex_state && !haveWidth )
+ FT_ERROR(( "cf2_interpT2CharString (Type 1 mode):"
+ " No width. Use hsbw/sbw as first op\n" ));
+
+ if ( cf2_stack_count( opStack ) > 1 && !haveWidth )
+ *width = ADD_INT32( cf2_stack_getReal( opStack, 0 ),
+ nominalWidthX );
+
+ /* width is defined or default after this */
+ haveWidth = TRUE;
+
+ if ( decoder->width_only )
+ goto exit;
+
+ curX = ADD_INT32( curX, cf2_stack_popFixed( opStack ) );
+
+ if ( !decoder->flex_state )
+ cf2_glyphpath_moveTo( &glyphPath, curX, curY );
+
+ break;
+
+ case cf2_cmdRLINECURVE:
+ {
+ CF2_UInt count = cf2_stack_count( opStack );
+ CF2_UInt idx = 0;
+
+
+ FT_TRACE4(( " rlinecurve\n" ));
+
+ while ( idx + 6 < count )
+ {
+ curX = ADD_INT32( curX, cf2_stack_getReal( opStack,
+ idx + 0 ) );
+ curY = ADD_INT32( curY, cf2_stack_getReal( opStack,
+ idx + 1 ) );
+
+ cf2_glyphpath_lineTo( &glyphPath, curX, curY );
+ idx += 2;
+ }
+
+ while ( idx < count )
+ {
+ CF2_Fixed x1, y1, x2, y2, x3, y3;
+
+
+ x1 = ADD_INT32( cf2_stack_getReal( opStack, idx + 0 ), curX );
+ y1 = ADD_INT32( cf2_stack_getReal( opStack, idx + 1 ), curY );
+ x2 = ADD_INT32( cf2_stack_getReal( opStack, idx + 2 ), x1 );
+ y2 = ADD_INT32( cf2_stack_getReal( opStack, idx + 3 ), y1 );
+ x3 = ADD_INT32( cf2_stack_getReal( opStack, idx + 4 ), x2 );
+ y3 = ADD_INT32( cf2_stack_getReal( opStack, idx + 5 ), y2 );
+
+ cf2_glyphpath_curveTo( &glyphPath, x1, y1, x2, y2, x3, y3 );
+
+ curX = x3;
+ curY = y3;
+ idx += 6;
+ }
+
+ cf2_stack_clear( opStack );
+ }
+ continue; /* no need to clear stack again */
+
+ case cf2_cmdVVCURVETO:
+ {
+ CF2_UInt count, count1 = cf2_stack_count( opStack );
+ 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;
+ idx += count1 - count;
+
+ FT_TRACE4(( " vvcurveto\n" ));
+
+ while ( idx < count )
+ {
+ CF2_Fixed x1, y1, x2, y2, x3, y3;
+
+
+ if ( ( count - idx ) & 1 )
+ {
+ x1 = ADD_INT32( cf2_stack_getReal( opStack, idx ), curX );
+
+ idx++;
+ }
+ else
+ x1 = curX;
+
+ y1 = ADD_INT32( cf2_stack_getReal( opStack, idx + 0 ), curY );
+ x2 = ADD_INT32( cf2_stack_getReal( opStack, idx + 1 ), x1 );
+ y2 = ADD_INT32( cf2_stack_getReal( opStack, idx + 2 ), y1 );
+ x3 = x2;
+ y3 = ADD_INT32( cf2_stack_getReal( opStack, idx + 3 ), y2 );
+
+ cf2_glyphpath_curveTo( &glyphPath, x1, y1, x2, y2, x3, y3 );
+
+ curX = x3;
+ curY = y3;
+ idx += 4;
+ }
+
+ cf2_stack_clear( opStack );
+ }
+ continue; /* no need to clear stack again */
+
+ case cf2_cmdHHCURVETO:
+ {
+ CF2_UInt count, count1 = cf2_stack_count( opStack );
+ 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;
+ idx += count1 - count;
+
+ FT_TRACE4(( " hhcurveto\n" ));
+
+ while ( idx < count )
+ {
+ CF2_Fixed x1, y1, x2, y2, x3, y3;
+
+
+ if ( ( count - idx ) & 1 )
+ {
+ y1 = ADD_INT32( cf2_stack_getReal( opStack, idx ), curY );
+
+ idx++;
+ }
+ else
+ y1 = curY;
+
+ x1 = ADD_INT32( cf2_stack_getReal( opStack, idx + 0 ), curX );
+ x2 = ADD_INT32( cf2_stack_getReal( opStack, idx + 1 ), x1 );
+ y2 = ADD_INT32( cf2_stack_getReal( opStack, idx + 2 ), y1 );
+ x3 = ADD_INT32( cf2_stack_getReal( opStack, idx + 3 ), x2 );
+ y3 = y2;
+
+ cf2_glyphpath_curveTo( &glyphPath, x1, y1, x2, y2, x3, y3 );
+
+ curX = x3;
+ curY = y3;
+ idx += 4;
+ }
+
+ cf2_stack_clear( opStack );
+ }
+ continue; /* no need to clear stack again */
+
+ case cf2_cmdVHCURVETO:
+ case cf2_cmdHVCURVETO:
+ {
+ CF2_UInt count, count1 = cf2_stack_count( opStack );
+ CF2_UInt idx = 0;
+
+ 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;
+ idx += count1 - count;
+
+ FT_TRACE4(( alternate ? " hvcurveto\n" : " vhcurveto\n" ));
+
+ while ( idx < count )
+ {
+ CF2_Fixed x1, x2, x3, y1, y2, y3;
+
+
+ if ( alternate )
+ {
+ x1 = ADD_INT32( cf2_stack_getReal( opStack, idx + 0 ), curX );
+ y1 = curY;
+ x2 = ADD_INT32( cf2_stack_getReal( opStack, idx + 1 ), x1 );
+ y2 = ADD_INT32( cf2_stack_getReal( opStack, idx + 2 ), y1 );
+ y3 = ADD_INT32( cf2_stack_getReal( opStack, idx + 3 ), y2 );
+
+ if ( count - idx == 5 )
+ {
+ x3 = ADD_INT32( cf2_stack_getReal( opStack, idx + 4 ), x2 );
+
+ idx++;
+ }
+ else
+ x3 = x2;
+
+ alternate = FALSE;
+ }
+ else
+ {
+ x1 = curX;
+ y1 = ADD_INT32( cf2_stack_getReal( opStack, idx + 0 ), curY );
+ x2 = ADD_INT32( cf2_stack_getReal( opStack, idx + 1 ), x1 );
+ y2 = ADD_INT32( cf2_stack_getReal( opStack, idx + 2 ), y1 );
+ x3 = ADD_INT32( cf2_stack_getReal( opStack, idx + 3 ), x2 );
+
+ if ( count - idx == 5 )
+ {
+ y3 = ADD_INT32( cf2_stack_getReal( opStack, idx + 4 ), y2 );
+
+ idx++;
+ }
+ else
+ y3 = y2;
+
+ alternate = TRUE;
+ }
+
+ cf2_glyphpath_curveTo( &glyphPath, x1, y1, x2, y2, x3, y3 );
+
+ curX = x3;
+ curY = y3;
+ idx += 4;
+ }
+
+ cf2_stack_clear( opStack );
+ }
+ continue; /* no need to clear stack again */
+
+ case cf2_cmdEXTENDEDNMBR:
+ {
+ CF2_Int v;
+
+ CF2_Int byte1 = cf2_buf_readByte( charstring );
+ CF2_Int byte2 = cf2_buf_readByte( charstring );
+
+
+ v = (FT_Short)( ( byte1 << 8 ) |
+ byte2 );
+
+ FT_TRACE4(( " %d", v ));
+
+ cf2_stack_pushInt( opStack, v );
+ }
+ continue;
+
+ default:
+ /* numbers */
+ {
+ if ( /* op1 >= 32 && */ op1 <= 246 )
+ {
+ CF2_Int v;
+
+
+ v = op1 - 139;
+
+ FT_TRACE4(( " %d", v ));
+
+ /* -107 .. 107 */
+ cf2_stack_pushInt( opStack, v );
+ }
+
+ else if ( /* op1 >= 247 && */ op1 <= 250 )
+ {
+ CF2_Int v;
+
+
+ v = op1;
+ v -= 247;
+ v *= 256;
+ v += cf2_buf_readByte( charstring );
+ v += 108;
+
+ FT_TRACE4(( " %d", v ));
+
+ /* 108 .. 1131 */
+ cf2_stack_pushInt( opStack, v );
+ }
+
+ else if ( /* op1 >= 251 && */ op1 <= 254 )
+ {
+ CF2_Int v;
+
+
+ v = op1;
+ v -= 251;
+ v *= 256;
+ v += cf2_buf_readByte( charstring );
+ v = -v - 108;
+
+ FT_TRACE4(( " %d", v ));
+
+ /* -1131 .. -108 */
+ cf2_stack_pushInt( opStack, v );
+ }
+
+ else /* op1 == 255 */
+ {
+ CF2_Fixed v;
+
+ FT_UInt32 byte1 = (FT_UInt32)cf2_buf_readByte( charstring );
+ FT_UInt32 byte2 = (FT_UInt32)cf2_buf_readByte( charstring );
+ FT_UInt32 byte3 = (FT_UInt32)cf2_buf_readByte( charstring );
+ FT_UInt32 byte4 = (FT_UInt32)cf2_buf_readByte( charstring );
+
+
+ v = (CF2_Fixed)( ( byte1 << 24 ) |
+ ( byte2 << 16 ) |
+ ( byte3 << 8 ) |
+ byte4 );
+
+ /*
+ * For Type 1:
+ *
+ * According to the specification, values > 32000 or < -32000
+ * must be followed by a `div' operator to make the result be
+ * in the range [-32000;32000]. We expect that the second
+ * argument of `div' is not a large number. Additionally, we
+ * don't handle stuff like `<large1> <large2> <num> div <num>
+ * div' or <large1> <large2> <num> div div'. This is probably
+ * not allowed anyway.
+ *
+ * <large> <num> <num>+ div is not checked but should not be
+ * allowed as the large value remains untouched.
+ *
+ */
+ if ( font->isT1 )
+ {
+ if ( v > 32000 || v < -32000 )
+ {
+ if ( large_int )
+ FT_ERROR(( "cf2_interpT2CharString (Type 1 mode):"
+ " no `div' after large integer\n" ));
+ else
+ large_int = TRUE;
+ }
+
+ FT_TRACE4(( " %d", v ));
+
+ cf2_stack_pushInt( opStack, (CF2_Int)v );
+ }
+ else
+ {
+ FT_TRACE4(( " %.5fF", v / 65536.0 ));
+
+ cf2_stack_pushFixed( opStack, v );
+ }
+ }
+ }
+ continue; /* don't clear stack */
+
+ } /* end of switch statement checking `op1' */
+
+ cf2_stack_clear( opStack );
+
+ } /* end of main interpreter loop */
+
+ /* we get here if the charstring ends without cf2_cmdENDCHAR */
+ FT_TRACE4(( "cf2_interpT2CharString:"
+ " charstring ends without ENDCHAR\n" ));
+
+ exit:
+ /* 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 );
+ cf2_arrstack_finalize( &hStemHintArray );
+ cf2_arrstack_finalize( &subrStack );
+ cf2_stack_free( opStack );
+
+ FT_TRACE4(( "\n" ));
+
+ return;
+ }
+
+
+/* END */
diff --git a/src/3rdparty/freetype/src/psaux/psintrp.h b/src/3rdparty/freetype/src/psaux/psintrp.h
new file mode 100644
index 0000000000..4790aaa302
--- /dev/null
+++ b/src/3rdparty/freetype/src/psaux/psintrp.h
@@ -0,0 +1,83 @@
+/***************************************************************************/
+/* */
+/* psintrp.h */
+/* */
+/* Adobe's CFF Interpreter (specification). */
+/* */
+/* Copyright 2007-2013 Adobe Systems Incorporated. */
+/* */
+/* This software, and all works of authorship, whether in source or */
+/* object code form as indicated by the copyright notice(s) included */
+/* herein (collectively, the "Work") is made available, and may only be */
+/* used, modified, and distributed under the FreeType Project License, */
+/* LICENSE.TXT. Additionally, subject to the terms and conditions of the */
+/* FreeType Project License, each contributor to the Work hereby grants */
+/* to any individual or legal entity exercising permissions granted by */
+/* the FreeType Project License and this section (hereafter, "You" or */
+/* "Your") a perpetual, worldwide, non-exclusive, no-charge, */
+/* royalty-free, irrevocable (except as stated in this section) patent */
+/* license to make, have made, use, offer to sell, sell, import, and */
+/* otherwise transfer the Work, where such license applies only to those */
+/* patent claims licensable by such contributor that are necessarily */
+/* infringed by their contribution(s) alone or by combination of their */
+/* contribution(s) with the Work to which such contribution(s) was */
+/* submitted. If You institute patent litigation against any entity */
+/* (including a cross-claim or counterclaim in a lawsuit) alleging that */
+/* the Work or a contribution incorporated within the Work constitutes */
+/* direct or contributory patent infringement, then any patent licenses */
+/* granted to You under this License for that Work shall terminate as of */
+/* the date such litigation is filed. */
+/* */
+/* By using, modifying, or distributing the Work you indicate that you */
+/* have read and understood the terms and conditions of the */
+/* FreeType Project License as well as those provided in this section, */
+/* and you accept them fully. */
+/* */
+/***************************************************************************/
+
+
+#ifndef PSINTRP_H_
+#define PSINTRP_H_
+
+
+#include "psft.h"
+#include "pshints.h"
+
+
+FT_BEGIN_HEADER
+
+
+ FT_LOCAL( void )
+ cf2_hintmask_init( CF2_HintMask hintmask,
+ FT_Error* error );
+ FT_LOCAL( FT_Bool )
+ cf2_hintmask_isValid( const CF2_HintMask hintmask );
+ FT_LOCAL( FT_Bool )
+ cf2_hintmask_isNew( const CF2_HintMask hintmask );
+ FT_LOCAL( void )
+ cf2_hintmask_setNew( CF2_HintMask hintmask,
+ FT_Bool val );
+ FT_LOCAL( FT_Byte* )
+ cf2_hintmask_getMaskPtr( CF2_HintMask hintmask );
+ FT_LOCAL( void )
+ cf2_hintmask_setAll( CF2_HintMask hintmask,
+ size_t bitCount );
+
+ FT_LOCAL( void )
+ cf2_interpT2CharString( CF2_Font font,
+ CF2_Buffer charstring,
+ CF2_OutlineCallbacks callbacks,
+ const FT_Vector* translation,
+ FT_Bool doingSeac,
+ CF2_Fixed curX,
+ CF2_Fixed curY,
+ CF2_Fixed* width );
+
+
+FT_END_HEADER
+
+
+#endif /* PSINTRP_H_ */
+
+
+/* END */
diff --git a/src/3rdparty/freetype/src/psaux/psobjs.c b/src/3rdparty/freetype/src/psaux/psobjs.c
index 1d3c7e662c..f54bc7e416 100644
--- a/src/3rdparty/freetype/src/psaux/psobjs.c
+++ b/src/3rdparty/freetype/src/psaux/psobjs.c
@@ -4,7 +4,7 @@
/* */
/* Auxiliary functions for PostScript fonts (body). */
/* */
-/* Copyright 1996-2015 by */
+/* Copyright 1996-2018 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -20,11 +20,13 @@
#include FT_INTERNAL_POSTSCRIPT_AUX_H
#include FT_INTERNAL_DEBUG_H
#include FT_INTERNAL_CALC_H
+#include FT_DRIVER_H
#include "psobjs.h"
#include "psconv.h"
#include "psauxerr.h"
+#include "psauxmod.h"
/*************************************************************************/
@@ -344,7 +346,7 @@
FT_Byte c = *cur;
- ++cur;
+ cur++;
if ( c == '\\' )
{
@@ -370,17 +372,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 +457,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 +697,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 +752,7 @@
if ( !token.type )
break;
- if ( tokens != NULL && cur < limit )
+ if ( tokens && cur < limit )
*cur = token;
cur++;
@@ -815,12 +817,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 +897,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 )
@@ -1087,9 +1089,9 @@
for ( ; count > 0; count--, idx++ )
{
- FT_Byte* q = (FT_Byte*)objects[idx] + field->offset;
+ FT_Byte* q = (FT_Byte*)objects[idx] + field->offset;
FT_Long val;
- FT_String* string;
+ FT_String* string = NULL;
skip_spaces( &cur, limit );
@@ -1172,7 +1174,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 ));
@@ -1217,7 +1219,7 @@
case T1_FIELD_TYPE_MM_BBOX:
{
FT_Memory memory = parser->memory;
- FT_Fixed* temp;
+ FT_Fixed* temp = NULL;
FT_Int result;
FT_UInt i;
@@ -1551,7 +1553,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 +1720,581 @@
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 )
+ {
+ FT_Vector* p1 = outline->points + first;
+ FT_Vector* p2 = outline->points + outline->n_points - 1;
+ FT_Byte* control = (FT_Byte*)outline->tags + outline->n_points - 1;
+
+
+ /* `delete' last point only if it coincides with the first */
+ /* point and it is not a control point (which can happen). */
+ if ( p1->x == p2->x && p1->y == p2->y )
+ if ( *control == FT_CURVE_TAG_ON )
+ outline->n_points--;
+ }
+
+ if ( outline->n_contours > 0 )
+ {
+ /* Don't add contours only consisting of one point, i.e., */
+ /* check whether the first and the last point is the same. */
+ if ( first == outline->n_points - 1 )
+ {
+ outline->n_contours--;
+ outline->n_points--;
+ }
+ else
+ outline->contours[outline->n_contours - 1] =
+ (short)( outline->n_points - 1 );
+ }
+ }
+
+
+ /*************************************************************************/
+ /*************************************************************************/
+ /***** *****/
+ /***** CFF BUILDER *****/
+ /***** *****/
+ /*************************************************************************/
+ /*************************************************************************/
+
+
+ /*************************************************************************/
+ /* */
+ /* <Function> */
+ /* cff_builder_init */
+ /* */
+ /* <Description> */
+ /* Initializes a given glyph builder. */
+ /* */
+ /* <InOut> */
+ /* builder :: A pointer to the glyph builder to initialize. */
+ /* */
+ /* <Input> */
+ /* face :: The current face object. */
+ /* */
+ /* size :: The current size object. */
+ /* */
+ /* glyph :: The current glyph object. */
+ /* */
+ /* hinting :: Whether hinting is active. */
+ /* */
+ FT_LOCAL_DEF( void )
+ cff_builder_init( CFF_Builder* builder,
+ TT_Face face,
+ CFF_Size size,
+ CFF_GlyphSlot glyph,
+ FT_Bool hinting )
+ {
+ builder->path_begun = 0;
+ builder->load_points = 1;
+
+ builder->face = face;
+ builder->glyph = glyph;
+ builder->memory = face->root.memory;
+
+ if ( glyph )
+ {
+ FT_GlyphLoader loader = glyph->root.internal->loader;
+
+
+ builder->loader = loader;
+ builder->base = &loader->base.outline;
+ builder->current = &loader->current.outline;
+ FT_GlyphLoader_Rewind( loader );
+
+ builder->hints_globals = NULL;
+ builder->hints_funcs = NULL;
+
+ if ( hinting && size )
+ {
+ FT_Size ftsize = FT_SIZE( size );
+ CFF_Internal internal = (CFF_Internal)ftsize->internal->module_data;
+
+ if ( internal )
+ {
+ builder->hints_globals = (void *)internal->topfont;
+ builder->hints_funcs = glyph->root.internal->glyph_hints;
+ }
+ }
+ }
+
+ builder->pos_x = 0;
+ builder->pos_y = 0;
+
+ builder->left_bearing.x = 0;
+ builder->left_bearing.y = 0;
+ builder->advance.x = 0;
+ builder->advance.y = 0;
+
+ builder->funcs = cff_builder_funcs;
+ }
+
+
+ /*************************************************************************/
+ /* */
+ /* <Function> */
+ /* cff_builder_done */
+ /* */
+ /* <Description> */
+ /* Finalizes a given glyph builder. Its contents can still be used */
+ /* after the call, but the function saves important information */
+ /* within the corresponding glyph slot. */
+ /* */
+ /* <Input> */
+ /* builder :: A pointer to the glyph builder to finalize. */
+ /* */
+ FT_LOCAL_DEF( void )
+ cff_builder_done( CFF_Builder* builder )
+ {
+ CFF_GlyphSlot glyph = builder->glyph;
+
+
+ if ( glyph )
+ glyph->root.outline = *builder->base;
+ }
+
+
+ /* check that there is enough space for `count' more points */
+ FT_LOCAL_DEF( FT_Error )
+ cff_check_points( CFF_Builder* builder,
+ FT_Int count )
+ {
+ return FT_GLYPHLOADER_CHECK_POINTS( builder->loader, count, 0 );
+ }
+
+
+ /* add a new point, do not check space */
+ FT_LOCAL_DEF( void )
+ cff_builder_add_point( CFF_Builder* builder,
+ FT_Pos x,
+ FT_Pos y,
+ FT_Byte flag )
+ {
+ FT_Outline* outline = builder->current;
+
+
+ if ( builder->load_points )
+ {
+ FT_Vector* point = outline->points + outline->n_points;
+ FT_Byte* control = (FT_Byte*)outline->tags + outline->n_points;
+
+#ifdef CFF_CONFIG_OPTION_OLD_ENGINE
+ PS_Driver driver = (PS_Driver)FT_FACE_DRIVER( builder->face );
+
+
+ if ( driver->hinting_engine == FT_HINTING_FREETYPE )
+ {
+ point->x = x >> 16;
+ point->y = y >> 16;
+ }
+ else
+#endif
+ {
+ /* cf2_decoder_parse_charstrings uses 16.16 coordinates */
+ point->x = x >> 10;
+ point->y = y >> 10;
+ }
+ *control = (FT_Byte)( flag ? FT_CURVE_TAG_ON : FT_CURVE_TAG_CUBIC );
+ }
+
+ outline->n_points++;
+ }
+
+
+ /* check space for a new on-curve point, then add it */
+ FT_LOCAL_DEF( FT_Error )
+ cff_builder_add_point1( CFF_Builder* builder,
+ FT_Pos x,
+ FT_Pos y )
+ {
+ FT_Error error;
+
+
+ error = cff_check_points( builder, 1 );
+ if ( !error )
+ cff_builder_add_point( builder, x, y, 1 );
+
+ return error;
+ }
+
+
+ /* check space for a new contour, then add it */
+ FT_LOCAL_DEF( FT_Error )
+ cff_builder_add_contour( CFF_Builder* builder )
+ {
+ FT_Outline* outline = builder->current;
+ FT_Error error;
+
+
+ if ( !builder->load_points )
+ {
+ outline->n_contours++;
+ return FT_Err_Ok;
+ }
+
+ error = FT_GLYPHLOADER_CHECK_POINTS( builder->loader, 0, 1 );
+ if ( !error )
+ {
+ if ( outline->n_contours > 0 )
+ outline->contours[outline->n_contours - 1] =
+ (short)( outline->n_points - 1 );
+
+ outline->n_contours++;
+ }
+
+ return error;
+ }
+
+
+ /* if a path was begun, add its first on-curve point */
+ FT_LOCAL_DEF( FT_Error )
+ cff_builder_start_point( CFF_Builder* builder,
+ FT_Pos x,
+ FT_Pos y )
+ {
+ FT_Error error = FT_Err_Ok;
+
+
+ /* test whether we are building a new contour */
+ if ( !builder->path_begun )
+ {
+ builder->path_begun = 1;
+ error = cff_builder_add_contour( builder );
+ if ( !error )
+ error = cff_builder_add_point1( builder, x, y );
+ }
+
+ return error;
+ }
+
+
+ /* close the current contour */
+ FT_LOCAL_DEF( void )
+ cff_builder_close_contour( CFF_Builder* builder )
+ {
+ FT_Outline* outline = builder->current;
+ FT_Int first;
+
+
+ if ( !outline )
+ return;
+
+ first = outline->n_contours <= 1
+ ? 0 : outline->contours[outline->n_contours - 2] + 1;
+
+ /* We must not include the last point in the path if it */
+ /* is located on the first point. */
+ if ( outline->n_points > 1 )
+ {
+ FT_Vector* p1 = outline->points + first;
+ FT_Vector* p2 = outline->points + outline->n_points - 1;
+ FT_Byte* control = (FT_Byte*)outline->tags + outline->n_points - 1;
+
+
+ /* `delete' last point only if it coincides with the first */
+ /* point and if it is not a control point (which can happen). */
+ if ( p1->x == p2->x && p1->y == p2->y )
+ if ( *control == FT_CURVE_TAG_ON )
+ outline->n_points--;
+ }
+
+ if ( outline->n_contours > 0 )
+ {
+ /* Don't add contours only consisting of one point, i.e., */
+ /* check whether begin point and last point are the same. */
+ if ( first == outline->n_points - 1 )
+ {
+ outline->n_contours--;
+ outline->n_points--;
+ }
+ else
+ outline->contours[outline->n_contours - 1] =
+ (short)( outline->n_points - 1 );
+ }
+ }
+
+
+ /*************************************************************************/
+ /*************************************************************************/
+ /***** *****/
+ /***** PS BUILDER *****/
+ /***** *****/
+ /*************************************************************************/
+ /*************************************************************************/
+
+ /*************************************************************************/
+ /* */
+ /* <Function> */
+ /* ps_builder_init */
+ /* */
+ /* <Description> */
+ /* Initializes a given glyph builder. */
+ /* */
+ /* <InOut> */
+ /* builder :: A pointer to the glyph builder to initialize. */
+ /* */
+ /* <Input> */
+ /* face :: The current face object. */
+ /* */
+ /* size :: The current size object. */
+ /* */
+ /* glyph :: The current glyph object. */
+ /* */
+ /* hinting :: Whether hinting should be applied. */
+ /* */
+ FT_LOCAL_DEF( void )
+ ps_builder_init( PS_Builder* ps_builder,
+ void* builder,
+ FT_Bool is_t1 )
+ {
+ FT_ZERO( ps_builder );
+
+ if ( is_t1 )
+ {
+ T1_Builder t1builder = (T1_Builder)builder;
+
+
+ ps_builder->memory = t1builder->memory;
+ ps_builder->face = (FT_Face)t1builder->face;
+ ps_builder->glyph = (CFF_GlyphSlot)t1builder->glyph;
+ ps_builder->loader = t1builder->loader;
+ ps_builder->base = t1builder->base;
+ ps_builder->current = t1builder->current;
+
+ ps_builder->pos_x = &t1builder->pos_x;
+ ps_builder->pos_y = &t1builder->pos_y;
+
+ ps_builder->left_bearing = &t1builder->left_bearing;
+ ps_builder->advance = &t1builder->advance;
+
+ ps_builder->bbox = &t1builder->bbox;
+ ps_builder->path_begun = 0;
+ ps_builder->load_points = t1builder->load_points;
+ ps_builder->no_recurse = t1builder->no_recurse;
+
+ ps_builder->metrics_only = t1builder->metrics_only;
+ }
+ else
+ {
+ CFF_Builder* cffbuilder = (CFF_Builder*)builder;
+
+
+ ps_builder->memory = cffbuilder->memory;
+ ps_builder->face = (FT_Face)cffbuilder->face;
+ ps_builder->glyph = cffbuilder->glyph;
+ ps_builder->loader = cffbuilder->loader;
+ ps_builder->base = cffbuilder->base;
+ ps_builder->current = cffbuilder->current;
+
+ ps_builder->pos_x = &cffbuilder->pos_x;
+ ps_builder->pos_y = &cffbuilder->pos_y;
+
+ ps_builder->left_bearing = &cffbuilder->left_bearing;
+ ps_builder->advance = &cffbuilder->advance;
+
+ ps_builder->bbox = &cffbuilder->bbox;
+ ps_builder->path_begun = cffbuilder->path_begun;
+ ps_builder->load_points = cffbuilder->load_points;
+ ps_builder->no_recurse = cffbuilder->no_recurse;
+
+ ps_builder->metrics_only = cffbuilder->metrics_only;
+ }
+
+ ps_builder->is_t1 = is_t1;
+ ps_builder->funcs = ps_builder_funcs;
+ }
+
+
+ /*************************************************************************/
+ /* */
+ /* <Function> */
+ /* ps_builder_done */
+ /* */
+ /* <Description> */
+ /* Finalizes a given glyph builder. Its contents can still be used */
+ /* after the call, but the function saves important information */
+ /* within the corresponding glyph slot. */
+ /* */
+ /* <Input> */
+ /* builder :: A pointer to the glyph builder to finalize. */
+ /* */
+ FT_LOCAL_DEF( void )
+ ps_builder_done( PS_Builder* builder )
+ {
+ CFF_GlyphSlot glyph = builder->glyph;
+
+
+ if ( glyph )
+ glyph->root.outline = *builder->base;
+ }
+
+
+ /* check that there is enough space for `count' more points */
+ FT_LOCAL_DEF( FT_Error )
+ ps_builder_check_points( PS_Builder* builder,
+ FT_Int count )
+ {
+ return FT_GLYPHLOADER_CHECK_POINTS( builder->loader, count, 0 );
+ }
+
+
+ /* add a new point, do not check space */
+ FT_LOCAL_DEF( void )
+ ps_builder_add_point( PS_Builder* builder,
+ FT_Pos x,
+ FT_Pos y,
+ FT_Byte flag )
+ {
+ FT_Outline* outline = builder->current;
+
+
+ if ( builder->load_points )
+ {
+ FT_Vector* point = outline->points + outline->n_points;
+ FT_Byte* control = (FT_Byte*)outline->tags + outline->n_points;
+
+#ifdef CFF_CONFIG_OPTION_OLD_ENGINE
+ PS_Driver driver = (PS_Driver)FT_FACE_DRIVER( builder->face );
+
+
+ if ( !builder->is_t1 &&
+ driver->hinting_engine == FT_HINTING_FREETYPE )
+ {
+ point->x = x >> 16;
+ point->y = y >> 16;
+ }
+ else
+#endif
+#ifdef T1_CONFIG_OPTION_OLD_ENGINE
+#ifndef CFF_CONFIG_OPTION_OLD_ENGINE
+ PS_Driver driver = (PS_Driver)FT_FACE_DRIVER( builder->face );
+#endif
+ if ( builder->is_t1 &&
+ driver->hinting_engine == FT_HINTING_FREETYPE )
+ {
+ point->x = FIXED_TO_INT( x );
+ point->y = FIXED_TO_INT( y );
+ }
+ else
+#endif
+ {
+ /* cf2_decoder_parse_charstrings uses 16.16 coordinates */
+ point->x = x >> 10;
+ point->y = y >> 10;
+ }
+ *control = (FT_Byte)( flag ? FT_CURVE_TAG_ON : FT_CURVE_TAG_CUBIC );
+ }
+ outline->n_points++;
+ }
+
+
+ /* check space for a new on-curve point, then add it */
+ FT_LOCAL_DEF( FT_Error )
+ ps_builder_add_point1( PS_Builder* builder,
+ FT_Pos x,
+ FT_Pos y )
+ {
+ FT_Error error;
+
+
+ error = ps_builder_check_points( builder, 1 );
+ if ( !error )
+ ps_builder_add_point( builder, x, y, 1 );
+
+ return error;
+ }
+
+
+ /* check space for a new contour, then add it */
+ FT_LOCAL_DEF( FT_Error )
+ ps_builder_add_contour( PS_Builder* builder )
+ {
+ FT_Outline* outline = builder->current;
+ FT_Error error;
+
+
+ /* this might happen in invalid fonts */
+ if ( !outline )
+ {
+ FT_ERROR(( "ps_builder_add_contour: no outline to add points to\n" ));
+ return FT_THROW( Invalid_File_Format );
+ }
+
+ if ( !builder->load_points )
+ {
+ outline->n_contours++;
+ return FT_Err_Ok;
+ }
+
+ error = FT_GLYPHLOADER_CHECK_POINTS( builder->loader, 0, 1 );
+ if ( !error )
+ {
+ if ( outline->n_contours > 0 )
+ outline->contours[outline->n_contours - 1] =
+ (short)( outline->n_points - 1 );
+
+ outline->n_contours++;
+ }
+
+ return error;
+ }
+
+
+ /* if a path was begun, add its first on-curve point */
+ FT_LOCAL_DEF( FT_Error )
+ ps_builder_start_point( PS_Builder* builder,
+ FT_Pos x,
+ FT_Pos y )
+ {
+ FT_Error error = FT_Err_Ok;
+
+
+ /* test whether we are building a new contour */
+ if ( !builder->path_begun )
+ {
+ builder->path_begun = 1;
+ error = ps_builder_add_contour( builder );
+ if ( !error )
+ error = ps_builder_add_point1( builder, x, y );
+ }
+
+ return error;
+ }
+
+
+ /* close the current contour */
+ FT_LOCAL_DEF( void )
+ ps_builder_close_contour( PS_Builder* builder )
+ {
+ FT_Outline* outline = builder->current;
+ FT_Int first;
+
+
+ if ( !outline )
+ return;
+
+ 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 )
@@ -1758,6 +2335,176 @@
/*************************************************************************/
/*************************************************************************/
+
+ /*************************************************************************/
+ /* */
+ /* <Function> */
+ /* ps_decoder_init */
+ /* */
+ /* <Description> */
+ /* Creates a wrapper decoder for use in the combined */
+ /* Type 1 / CFF interpreter. */
+ /* */
+ /* <InOut> */
+ /* ps_decoder :: A pointer to the decoder to initialize. */
+ /* */
+ /* <Input> */
+ /* decoder :: A pointer to the original decoder. */
+ /* */
+ /* is_t1 :: Flag indicating Type 1 or CFF */
+ /* */
+ FT_LOCAL_DEF( void )
+ ps_decoder_init( PS_Decoder* ps_decoder,
+ void* decoder,
+ FT_Bool is_t1 )
+ {
+ FT_ZERO( ps_decoder );
+
+ if ( is_t1 )
+ {
+ T1_Decoder t1_decoder = (T1_Decoder)decoder;
+
+
+ ps_builder_init( &ps_decoder->builder,
+ &t1_decoder->builder,
+ is_t1 );
+
+ ps_decoder->cf2_instance = &t1_decoder->cf2_instance;
+ ps_decoder->psnames = t1_decoder->psnames;
+
+ ps_decoder->num_glyphs = t1_decoder->num_glyphs;
+ ps_decoder->glyph_names = t1_decoder->glyph_names;
+ ps_decoder->hint_mode = t1_decoder->hint_mode;
+ ps_decoder->blend = t1_decoder->blend;
+
+ ps_decoder->num_locals = (FT_UInt)t1_decoder->num_subrs;
+ ps_decoder->locals = t1_decoder->subrs;
+ ps_decoder->locals_len = t1_decoder->subrs_len;
+ ps_decoder->locals_hash = t1_decoder->subrs_hash;
+
+ ps_decoder->buildchar = t1_decoder->buildchar;
+ ps_decoder->len_buildchar = t1_decoder->len_buildchar;
+
+ ps_decoder->lenIV = t1_decoder->lenIV;
+ }
+ else
+ {
+ CFF_Decoder* cff_decoder = (CFF_Decoder*)decoder;
+
+
+ ps_builder_init( &ps_decoder->builder,
+ &cff_decoder->builder,
+ is_t1 );
+
+ ps_decoder->cff = cff_decoder->cff;
+ ps_decoder->cf2_instance = &cff_decoder->cff->cf2_instance;
+ ps_decoder->current_subfont = cff_decoder->current_subfont;
+
+ ps_decoder->num_globals = cff_decoder->num_globals;
+ ps_decoder->globals = cff_decoder->globals;
+ ps_decoder->globals_bias = cff_decoder->globals_bias;
+ ps_decoder->num_locals = cff_decoder->num_locals;
+ ps_decoder->locals = cff_decoder->locals;
+ ps_decoder->locals_bias = cff_decoder->locals_bias;
+
+ ps_decoder->glyph_width = &cff_decoder->glyph_width;
+ ps_decoder->width_only = cff_decoder->width_only;
+
+ ps_decoder->hint_mode = cff_decoder->hint_mode;
+
+ ps_decoder->get_glyph_callback = cff_decoder->get_glyph_callback;
+ ps_decoder->free_glyph_callback = cff_decoder->free_glyph_callback;
+ }
+ }
+
+
+ /* Synthesize a SubFont object for Type 1 fonts, for use in the */
+ /* new interpreter to access Private dict data. */
+ FT_LOCAL_DEF( void )
+ t1_make_subfont( FT_Face face,
+ PS_Private priv,
+ CFF_SubFont subfont )
+ {
+ CFF_Private cpriv = &subfont->private_dict;
+ FT_UInt n, count;
+
+
+ FT_ZERO( subfont );
+ FT_ZERO( cpriv );
+
+ count = cpriv->num_blue_values = priv->num_blue_values;
+ for ( n = 0; n < count; n++ )
+ cpriv->blue_values[n] = (FT_Pos)priv->blue_values[n];
+
+ count = cpriv->num_other_blues = priv->num_other_blues;
+ for ( n = 0; n < count; n++ )
+ cpriv->other_blues[n] = (FT_Pos)priv->other_blues[n];
+
+ count = cpriv->num_family_blues = priv->num_family_blues;
+ for ( n = 0; n < count; n++ )
+ cpriv->family_blues[n] = (FT_Pos)priv->family_blues[n];
+
+ count = cpriv->num_family_other_blues = priv->num_family_other_blues;
+ for ( n = 0; n < count; n++ )
+ cpriv->family_other_blues[n] = (FT_Pos)priv->family_other_blues[n];
+
+ cpriv->blue_scale = priv->blue_scale;
+ cpriv->blue_shift = (FT_Pos)priv->blue_shift;
+ cpriv->blue_fuzz = (FT_Pos)priv->blue_fuzz;
+
+ cpriv->standard_width = (FT_Pos)priv->standard_width[0];
+ cpriv->standard_height = (FT_Pos)priv->standard_height[0];
+
+ count = cpriv->num_snap_widths = priv->num_snap_widths;
+ for ( n = 0; n < count; n++ )
+ cpriv->snap_widths[n] = (FT_Pos)priv->snap_widths[n];
+
+ count = cpriv->num_snap_heights = priv->num_snap_heights;
+ for ( n = 0; n < count; n++ )
+ cpriv->snap_heights[n] = (FT_Pos)priv->snap_heights[n];
+
+ cpriv->force_bold = priv->force_bold;
+ cpriv->lenIV = priv->lenIV;
+ cpriv->language_group = priv->language_group;
+ cpriv->expansion_factor = priv->expansion_factor;
+
+ cpriv->subfont = subfont;
+
+
+ /* Initialize the random number generator. */
+ if ( face->internal->random_seed != -1 )
+ {
+ /* If we have a face-specific seed, use it. */
+ /* If non-zero, update it to a positive value. */
+ subfont->random = (FT_UInt32)face->internal->random_seed;
+ if ( face->internal->random_seed )
+ {
+ do
+ {
+ face->internal->random_seed = (FT_Int32)cff_random(
+ (FT_UInt32)face->internal->random_seed );
+
+ } while ( face->internal->random_seed < 0 );
+ }
+ }
+ if ( !subfont->random )
+ {
+ FT_UInt32 seed;
+
+
+ /* compute random seed from some memory addresses */
+ seed = (FT_UInt32)( (FT_Offset)(char*)&seed ^
+ (FT_Offset)(char*)&face ^
+ (FT_Offset)(char*)&subfont );
+ seed = seed ^ ( seed >> 10 ) ^ ( seed >> 20 );
+ if ( seed == 0 )
+ seed = 0x7384;
+
+ subfont->random = seed;
+ }
+ }
+
+
FT_LOCAL_DEF( void )
t1_decrypt( FT_Byte* buffer,
FT_Offset length,
@@ -1771,4 +2518,16 @@
}
+ 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;
+ }
+
+
/* END */
diff --git a/src/3rdparty/freetype/src/psaux/psobjs.h b/src/3rdparty/freetype/src/psaux/psobjs.h
index bf879c1faf..8e0fe5fa4c 100644
--- a/src/3rdparty/freetype/src/psaux/psobjs.h
+++ b/src/3rdparty/freetype/src/psaux/psobjs.h
@@ -4,7 +4,7 @@
/* */
/* Auxiliary functions for PostScript fonts (specification). */
/* */
-/* Copyright 1996-2015 by */
+/* Copyright 1996-2018 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -16,12 +16,13 @@
/***************************************************************************/
-#ifndef __PSOBJS_H__
-#define __PSOBJS_H__
+#ifndef PSOBJS_H_
+#define PSOBJS_H_
#include <ft2build.h>
#include FT_INTERNAL_POSTSCRIPT_AUX_H
+#include FT_INTERNAL_CFF_OBJECTS_TYPES_H
FT_BEGIN_HEADER
@@ -193,20 +194,120 @@ FT_BEGIN_HEADER
/*************************************************************************/
/*************************************************************************/
/***** *****/
+ /***** CFF BUILDER *****/
+ /***** *****/
+ /*************************************************************************/
+ /*************************************************************************/
+
+ FT_LOCAL( void )
+ cff_builder_init( CFF_Builder* builder,
+ TT_Face face,
+ CFF_Size size,
+ CFF_GlyphSlot glyph,
+ FT_Bool hinting );
+
+ FT_LOCAL( void )
+ cff_builder_done( CFF_Builder* builder );
+
+ FT_LOCAL( FT_Error )
+ cff_check_points( CFF_Builder* builder,
+ FT_Int count );
+
+ FT_LOCAL( void )
+ cff_builder_add_point( CFF_Builder* builder,
+ FT_Pos x,
+ FT_Pos y,
+ FT_Byte flag );
+ FT_LOCAL( FT_Error )
+ cff_builder_add_point1( CFF_Builder* builder,
+ FT_Pos x,
+ FT_Pos y );
+ FT_LOCAL( FT_Error )
+ cff_builder_start_point( CFF_Builder* builder,
+ FT_Pos x,
+ FT_Pos y );
+ FT_LOCAL( void )
+ cff_builder_close_contour( CFF_Builder* builder );
+
+ FT_LOCAL( FT_Error )
+ cff_builder_add_contour( CFF_Builder* builder );
+
+
+ /*************************************************************************/
+ /*************************************************************************/
+ /***** *****/
+ /***** PS BUILDER *****/
+ /***** *****/
+ /*************************************************************************/
+ /*************************************************************************/
+
+ FT_LOCAL( void )
+ ps_builder_init( PS_Builder* ps_builder,
+ void* builder,
+ FT_Bool is_t1 );
+
+
+ FT_LOCAL( void )
+ ps_builder_done( PS_Builder* builder );
+
+ FT_LOCAL( FT_Error )
+ ps_builder_check_points( PS_Builder* builder,
+ FT_Int count );
+
+ FT_LOCAL( void )
+ ps_builder_add_point( PS_Builder* builder,
+ FT_Pos x,
+ FT_Pos y,
+ FT_Byte flag );
+
+ FT_LOCAL( FT_Error )
+ ps_builder_add_point1( PS_Builder* builder,
+ FT_Pos x,
+ FT_Pos y );
+
+ FT_LOCAL( FT_Error )
+ ps_builder_add_contour( PS_Builder* builder );
+
+ FT_LOCAL( FT_Error )
+ ps_builder_start_point( PS_Builder* builder,
+ FT_Pos x,
+ FT_Pos y );
+
+ FT_LOCAL( void )
+ ps_builder_close_contour( PS_Builder* builder );
+
+
+ /*************************************************************************/
+ /*************************************************************************/
+ /***** *****/
/***** OTHER *****/
/***** *****/
/*************************************************************************/
/*************************************************************************/
FT_LOCAL( void )
+ ps_decoder_init( PS_Decoder* ps_decoder,
+ void* decoder,
+ FT_Bool is_t1 );
+
+ FT_LOCAL( void )
+ t1_make_subfont( FT_Face face,
+ PS_Private priv,
+ CFF_SubFont subfont );
+
+ FT_LOCAL( void )
t1_decrypt( FT_Byte* buffer,
FT_Offset length,
FT_UShort seed );
+ FT_LOCAL( FT_UInt32 )
+ cff_random( FT_UInt32 r );
+
+
FT_END_HEADER
-#endif /* __PSOBJS_H__ */
+#endif /* PSOBJS_H_ */
/* END */
diff --git a/src/3rdparty/freetype/src/psaux/psread.c b/src/3rdparty/freetype/src/psaux/psread.c
new file mode 100644
index 0000000000..719863ce17
--- /dev/null
+++ b/src/3rdparty/freetype/src/psaux/psread.c
@@ -0,0 +1,112 @@
+/***************************************************************************/
+/* */
+/* psread.c */
+/* */
+/* Adobe's code for stream handling (body). */
+/* */
+/* Copyright 2007-2013 Adobe Systems Incorporated. */
+/* */
+/* This software, and all works of authorship, whether in source or */
+/* object code form as indicated by the copyright notice(s) included */
+/* herein (collectively, the "Work") is made available, and may only be */
+/* used, modified, and distributed under the FreeType Project License, */
+/* LICENSE.TXT. Additionally, subject to the terms and conditions of the */
+/* FreeType Project License, each contributor to the Work hereby grants */
+/* to any individual or legal entity exercising permissions granted by */
+/* the FreeType Project License and this section (hereafter, "You" or */
+/* "Your") a perpetual, worldwide, non-exclusive, no-charge, */
+/* royalty-free, irrevocable (except as stated in this section) patent */
+/* license to make, have made, use, offer to sell, sell, import, and */
+/* otherwise transfer the Work, where such license applies only to those */
+/* patent claims licensable by such contributor that are necessarily */
+/* infringed by their contribution(s) alone or by combination of their */
+/* contribution(s) with the Work to which such contribution(s) was */
+/* submitted. If You institute patent litigation against any entity */
+/* (including a cross-claim or counterclaim in a lawsuit) alleging that */
+/* the Work or a contribution incorporated within the Work constitutes */
+/* direct or contributory patent infringement, then any patent licenses */
+/* granted to You under this License for that Work shall terminate as of */
+/* the date such litigation is filed. */
+/* */
+/* By using, modifying, or distributing the Work you indicate that you */
+/* have read and understood the terms and conditions of the */
+/* FreeType Project License as well as those provided in this section, */
+/* and you accept them fully. */
+/* */
+/***************************************************************************/
+
+
+#include "psft.h"
+#include FT_INTERNAL_DEBUG_H
+
+#include "psglue.h"
+
+#include "pserror.h"
+
+
+ /* Define CF2_IO_FAIL as 1 to enable random errors and random */
+ /* value errors in I/O. */
+#define CF2_IO_FAIL 0
+
+
+#if CF2_IO_FAIL
+
+ /* set the .00 value to a nonzero probability */
+ static int
+ randomError2( void )
+ {
+ /* for region buffer ReadByte (interp) function */
+ return (double)rand() / RAND_MAX < .00;
+ }
+
+ /* set the .00 value to a nonzero probability */
+ static CF2_Int
+ randomValue()
+ {
+ return (double)rand() / RAND_MAX < .00 ? rand() : 0;
+ }
+
+#endif /* CF2_IO_FAIL */
+
+
+ /* Region Buffer */
+ /* */
+ /* Can be constructed from a copied buffer managed by */
+ /* `FCM_getDatablock'. */
+ /* Reads bytes with check for end of buffer. */
+
+ /* reading past the end of the buffer sets error and returns zero */
+ FT_LOCAL_DEF( CF2_Int )
+ cf2_buf_readByte( CF2_Buffer buf )
+ {
+ if ( buf->ptr < buf->end )
+ {
+#if CF2_IO_FAIL
+ if ( randomError2() )
+ {
+ CF2_SET_ERROR( buf->error, Invalid_Stream_Operation );
+ return 0;
+ }
+
+ return *(buf->ptr)++ + randomValue();
+#else
+ return *(buf->ptr)++;
+#endif
+ }
+ else
+ {
+ CF2_SET_ERROR( buf->error, Invalid_Stream_Operation );
+ return 0;
+ }
+ }
+
+
+ /* note: end condition can occur without error */
+ FT_LOCAL_DEF( FT_Bool )
+ cf2_buf_isEnd( CF2_Buffer buf )
+ {
+ return (FT_Bool)( buf->ptr >= buf->end );
+ }
+
+
+/* END */
diff --git a/src/3rdparty/freetype/src/psaux/psread.h b/src/3rdparty/freetype/src/psaux/psread.h
new file mode 100644
index 0000000000..464b29ba74
--- /dev/null
+++ b/src/3rdparty/freetype/src/psaux/psread.h
@@ -0,0 +1,68 @@
+/***************************************************************************/
+/* */
+/* psread.h */
+/* */
+/* Adobe's code for stream handling (specification). */
+/* */
+/* Copyright 2007-2013 Adobe Systems Incorporated. */
+/* */
+/* This software, and all works of authorship, whether in source or */
+/* object code form as indicated by the copyright notice(s) included */
+/* herein (collectively, the "Work") is made available, and may only be */
+/* used, modified, and distributed under the FreeType Project License, */
+/* LICENSE.TXT. Additionally, subject to the terms and conditions of the */
+/* FreeType Project License, each contributor to the Work hereby grants */
+/* to any individual or legal entity exercising permissions granted by */
+/* the FreeType Project License and this section (hereafter, "You" or */
+/* "Your") a perpetual, worldwide, non-exclusive, no-charge, */
+/* royalty-free, irrevocable (except as stated in this section) patent */
+/* license to make, have made, use, offer to sell, sell, import, and */
+/* otherwise transfer the Work, where such license applies only to those */
+/* patent claims licensable by such contributor that are necessarily */
+/* infringed by their contribution(s) alone or by combination of their */
+/* contribution(s) with the Work to which such contribution(s) was */
+/* submitted. If You institute patent litigation against any entity */
+/* (including a cross-claim or counterclaim in a lawsuit) alleging that */
+/* the Work or a contribution incorporated within the Work constitutes */
+/* direct or contributory patent infringement, then any patent licenses */
+/* granted to You under this License for that Work shall terminate as of */
+/* the date such litigation is filed. */
+/* */
+/* By using, modifying, or distributing the Work you indicate that you */
+/* have read and understood the terms and conditions of the */
+/* FreeType Project License as well as those provided in this section, */
+/* and you accept them fully. */
+/* */
+/***************************************************************************/
+
+
+#ifndef PSREAD_H_
+#define PSREAD_H_
+
+
+FT_BEGIN_HEADER
+
+
+ typedef struct CF2_BufferRec_
+ {
+ FT_Error* error;
+ const FT_Byte* start;
+ const FT_Byte* end;
+ const FT_Byte* ptr;
+
+ } CF2_BufferRec, *CF2_Buffer;
+
+
+ FT_LOCAL( CF2_Int )
+ cf2_buf_readByte( CF2_Buffer buf );
+ FT_LOCAL( FT_Bool )
+ cf2_buf_isEnd( CF2_Buffer buf );
+
+
+FT_END_HEADER
+
+
+#endif /* PSREAD_H_ */
+
+
+/* END */
diff --git a/src/3rdparty/freetype/src/psaux/psstack.c b/src/3rdparty/freetype/src/psaux/psstack.c
new file mode 100644
index 0000000000..69d063349a
--- /dev/null
+++ b/src/3rdparty/freetype/src/psaux/psstack.c
@@ -0,0 +1,328 @@
+/***************************************************************************/
+/* */
+/* psstack.c */
+/* */
+/* Adobe's code for emulating a CFF stack (body). */
+/* */
+/* Copyright 2007-2013 Adobe Systems Incorporated. */
+/* */
+/* This software, and all works of authorship, whether in source or */
+/* object code form as indicated by the copyright notice(s) included */
+/* herein (collectively, the "Work") is made available, and may only be */
+/* used, modified, and distributed under the FreeType Project License, */
+/* LICENSE.TXT. Additionally, subject to the terms and conditions of the */
+/* FreeType Project License, each contributor to the Work hereby grants */
+/* to any individual or legal entity exercising permissions granted by */
+/* the FreeType Project License and this section (hereafter, "You" or */
+/* "Your") a perpetual, worldwide, non-exclusive, no-charge, */
+/* royalty-free, irrevocable (except as stated in this section) patent */
+/* license to make, have made, use, offer to sell, sell, import, and */
+/* otherwise transfer the Work, where such license applies only to those */
+/* patent claims licensable by such contributor that are necessarily */
+/* infringed by their contribution(s) alone or by combination of their */
+/* contribution(s) with the Work to which such contribution(s) was */
+/* submitted. If You institute patent litigation against any entity */
+/* (including a cross-claim or counterclaim in a lawsuit) alleging that */
+/* the Work or a contribution incorporated within the Work constitutes */
+/* direct or contributory patent infringement, then any patent licenses */
+/* granted to You under this License for that Work shall terminate as of */
+/* the date such litigation is filed. */
+/* */
+/* By using, modifying, or distributing the Work you indicate that you */
+/* have read and understood the terms and conditions of the */
+/* FreeType Project License as well as those provided in this section, */
+/* and you accept them fully. */
+/* */
+/***************************************************************************/
+
+
+#include "psft.h"
+#include FT_INTERNAL_DEBUG_H
+
+#include "psglue.h"
+#include "psfont.h"
+#include "psstack.h"
+
+#include "pserror.h"
+
+
+ /* Allocate and initialize an instance of CF2_Stack. */
+ /* Note: This function returns NULL on error (does not set */
+ /* `error'). */
+ FT_LOCAL_DEF( CF2_Stack )
+ cf2_stack_init( FT_Memory memory,
+ FT_Error* e,
+ FT_UInt stackSize )
+ {
+ FT_Error error = FT_Err_Ok; /* for FT_NEW */
+
+ CF2_Stack stack = NULL;
+
+
+ if ( !FT_NEW( stack ) )
+ {
+ /* initialize the structure; FT_NEW zeroes it */
+ stack->memory = memory;
+ stack->error = e;
+ }
+
+ /* 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;
+ }
+
+
+ FT_LOCAL_DEF( void )
+ cf2_stack_free( CF2_Stack stack )
+ {
+ if ( stack )
+ {
+ FT_Memory memory = stack->memory;
+
+ /* free the buffer */
+ FT_FREE( stack->buffer );
+
+ /* free the main structure */
+ FT_FREE( stack );
+ }
+ }
+
+
+ FT_LOCAL_DEF( CF2_UInt )
+ cf2_stack_count( CF2_Stack stack )
+ {
+ return (CF2_UInt)( stack->top - stack->buffer );
+ }
+
+
+ FT_LOCAL_DEF( void )
+ cf2_stack_pushInt( CF2_Stack stack,
+ CF2_Int val )
+ {
+ if ( stack->top == stack->buffer + stack->stackSize )
+ {
+ CF2_SET_ERROR( stack->error, Stack_Overflow );
+ return; /* stack overflow */
+ }
+
+ stack->top->u.i = val;
+ stack->top->type = CF2_NumberInt;
+ stack->top++;
+ }
+
+
+ FT_LOCAL_DEF( void )
+ cf2_stack_pushFixed( CF2_Stack stack,
+ CF2_Fixed val )
+ {
+ if ( stack->top == stack->buffer + stack->stackSize )
+ {
+ CF2_SET_ERROR( stack->error, Stack_Overflow );
+ return; /* stack overflow */
+ }
+
+ stack->top->u.r = val;
+ stack->top->type = CF2_NumberFixed;
+ stack->top++;
+ }
+
+
+ /* this function is only allowed to pop an integer type */
+ FT_LOCAL_DEF( CF2_Int )
+ cf2_stack_popInt( CF2_Stack stack )
+ {
+ if ( stack->top == stack->buffer )
+ {
+ CF2_SET_ERROR( stack->error, Stack_Underflow );
+ return 0; /* underflow */
+ }
+ if ( stack->top[-1].type != CF2_NumberInt )
+ {
+ CF2_SET_ERROR( stack->error, Syntax_Error );
+ return 0; /* type mismatch */
+ }
+
+ stack->top--;
+
+ return stack->top->u.i;
+ }
+
+
+ /* Note: type mismatch is silently cast */
+ /* TODO: check this */
+ FT_LOCAL_DEF( CF2_Fixed )
+ cf2_stack_popFixed( CF2_Stack stack )
+ {
+ if ( stack->top == stack->buffer )
+ {
+ CF2_SET_ERROR( stack->error, Stack_Underflow );
+ return cf2_intToFixed( 0 ); /* underflow */
+ }
+
+ stack->top--;
+
+ switch ( stack->top->type )
+ {
+ case CF2_NumberInt:
+ return cf2_intToFixed( stack->top->u.i );
+ case CF2_NumberFrac:
+ return cf2_fracToFixed( stack->top->u.f );
+ default:
+ return stack->top->u.r;
+ }
+ }
+
+
+ /* Note: type mismatch is silently cast */
+ /* TODO: check this */
+ FT_LOCAL_DEF( CF2_Fixed )
+ cf2_stack_getReal( CF2_Stack stack,
+ CF2_UInt idx )
+ {
+ FT_ASSERT( cf2_stack_count( stack ) <= stack->stackSize );
+
+ if ( idx >= cf2_stack_count( stack ) )
+ {
+ CF2_SET_ERROR( stack->error, Stack_Overflow );
+ return cf2_intToFixed( 0 ); /* bounds error */
+ }
+
+ switch ( stack->buffer[idx].type )
+ {
+ case CF2_NumberInt:
+ return cf2_intToFixed( stack->buffer[idx].u.i );
+ case CF2_NumberFrac:
+ return cf2_fracToFixed( stack->buffer[idx].u.f );
+ default:
+ return stack->buffer[idx].u.r;
+ }
+ }
+
+
+ /* 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 )
+ {
+ /* we initialize this variable to avoid compiler warnings */
+ CF2_StackNumber last = { { 0 }, CF2_NumberInt };
+
+ CF2_Int start_idx, idx, i;
+
+
+ if ( count < 2 )
+ return; /* nothing to do (values 0 and 1), or undefined value */
+
+ if ( (CF2_UInt)count > cf2_stack_count( stack ) )
+ {
+ CF2_SET_ERROR( stack->error, Stack_Overflow );
+ return;
+ }
+
+ if ( shift < 0 )
+ shift = -( ( -shift ) % count );
+ else
+ shift %= count;
+
+ if ( shift == 0 )
+ return; /* nothing to do */
+
+ /* We use the following algorithm to do the rolling, */
+ /* which needs two temporary variables only. */
+ /* */
+ /* Example: */
+ /* */
+ /* count = 8 */
+ /* shift = 2 */
+ /* */
+ /* stack indices before roll: 7 6 5 4 3 2 1 0 */
+ /* stack indices after roll: 1 0 7 6 5 4 3 2 */
+ /* */
+ /* The value of index 0 gets moved to index 2, while */
+ /* the old value of index 2 gets moved to index 4, */
+ /* and so on. We thus have the following copying */
+ /* chains for shift value 2. */
+ /* */
+ /* 0 -> 2 -> 4 -> 6 -> 0 */
+ /* 1 -> 3 -> 5 -> 7 -> 1 */
+ /* */
+ /* If `count' and `shift' are incommensurable, we */
+ /* have a single chain only. Otherwise, increase */
+ /* the start index by 1 after the first chain, then */
+ /* do the next chain until all elements in all */
+ /* chains are handled. */
+
+ start_idx = -1;
+ idx = -1;
+ for ( i = 0; i < count; i++ )
+ {
+ CF2_StackNumber tmp;
+
+
+ if ( start_idx == idx )
+ {
+ start_idx++;
+ idx = start_idx;
+ last = stack->buffer[idx];
+ }
+
+ idx += shift;
+ if ( idx >= count )
+ idx -= count;
+ else if ( idx < 0 )
+ idx += count;
+
+ tmp = stack->buffer[idx];
+ stack->buffer[idx] = last;
+ last = tmp;
+ }
+ }
+
+
+ FT_LOCAL_DEF( void )
+ cf2_stack_clear( CF2_Stack stack )
+ {
+ stack->top = stack->buffer;
+ }
+
+
+/* END */
diff --git a/src/3rdparty/freetype/src/psaux/psstack.h b/src/3rdparty/freetype/src/psaux/psstack.h
new file mode 100644
index 0000000000..38f7b41c68
--- /dev/null
+++ b/src/3rdparty/freetype/src/psaux/psstack.h
@@ -0,0 +1,121 @@
+/***************************************************************************/
+/* */
+/* psstack.h */
+/* */
+/* Adobe's code for emulating a CFF stack (specification). */
+/* */
+/* Copyright 2007-2013 Adobe Systems Incorporated. */
+/* */
+/* This software, and all works of authorship, whether in source or */
+/* object code form as indicated by the copyright notice(s) included */
+/* herein (collectively, the "Work") is made available, and may only be */
+/* used, modified, and distributed under the FreeType Project License, */
+/* LICENSE.TXT. Additionally, subject to the terms and conditions of the */
+/* FreeType Project License, each contributor to the Work hereby grants */
+/* to any individual or legal entity exercising permissions granted by */
+/* the FreeType Project License and this section (hereafter, "You" or */
+/* "Your") a perpetual, worldwide, non-exclusive, no-charge, */
+/* royalty-free, irrevocable (except as stated in this section) patent */
+/* license to make, have made, use, offer to sell, sell, import, and */
+/* otherwise transfer the Work, where such license applies only to those */
+/* patent claims licensable by such contributor that are necessarily */
+/* infringed by their contribution(s) alone or by combination of their */
+/* contribution(s) with the Work to which such contribution(s) was */
+/* submitted. If You institute patent litigation against any entity */
+/* (including a cross-claim or counterclaim in a lawsuit) alleging that */
+/* the Work or a contribution incorporated within the Work constitutes */
+/* direct or contributory patent infringement, then any patent licenses */
+/* granted to You under this License for that Work shall terminate as of */
+/* the date such litigation is filed. */
+/* */
+/* By using, modifying, or distributing the Work you indicate that you */
+/* have read and understood the terms and conditions of the */
+/* FreeType Project License as well as those provided in this section, */
+/* and you accept them fully. */
+/* */
+/***************************************************************************/
+
+
+#ifndef PSSTACK_H_
+#define PSSTACK_H_
+
+
+FT_BEGIN_HEADER
+
+
+ /* CFF operand stack; specified maximum of 48 or 192 values */
+ typedef struct CF2_StackNumber_
+ {
+ union
+ {
+ CF2_Fixed r; /* 16.16 fixed point */
+ CF2_Frac f; /* 2.30 fixed point (for font matrix) */
+ CF2_Int i;
+ } u;
+
+ CF2_NumberType type;
+
+ } CF2_StackNumber;
+
+
+ typedef struct CF2_StackRec_
+ {
+ FT_Memory memory;
+ FT_Error* error;
+ 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_UInt stackSize );
+ FT_LOCAL( void )
+ cf2_stack_free( CF2_Stack stack );
+
+ FT_LOCAL( CF2_UInt )
+ cf2_stack_count( CF2_Stack stack );
+
+ FT_LOCAL( void )
+ cf2_stack_pushInt( CF2_Stack stack,
+ CF2_Int val );
+ FT_LOCAL( void )
+ cf2_stack_pushFixed( CF2_Stack stack,
+ CF2_Fixed val );
+
+ FT_LOCAL( CF2_Int )
+ cf2_stack_popInt( CF2_Stack stack );
+ FT_LOCAL( CF2_Fixed )
+ cf2_stack_popFixed( CF2_Stack stack );
+
+ 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,
+ CF2_Int count,
+ CF2_Int idx );
+
+ FT_LOCAL( void )
+ cf2_stack_clear( CF2_Stack stack );
+
+
+FT_END_HEADER
+
+
+#endif /* PSSTACK_H_ */
+
+
+/* END */
diff --git a/src/3rdparty/freetype/src/psaux/pstypes.h b/src/3rdparty/freetype/src/psaux/pstypes.h
new file mode 100644
index 0000000000..dfbaa3d475
--- /dev/null
+++ b/src/3rdparty/freetype/src/psaux/pstypes.h
@@ -0,0 +1,78 @@
+/***************************************************************************/
+/* */
+/* pstypes.h */
+/* */
+/* Adobe's code for defining data types (specification only). */
+/* */
+/* Copyright 2011-2013 Adobe Systems Incorporated. */
+/* */
+/* This software, and all works of authorship, whether in source or */
+/* object code form as indicated by the copyright notice(s) included */
+/* herein (collectively, the "Work") is made available, and may only be */
+/* used, modified, and distributed under the FreeType Project License, */
+/* LICENSE.TXT. Additionally, subject to the terms and conditions of the */
+/* FreeType Project License, each contributor to the Work hereby grants */
+/* to any individual or legal entity exercising permissions granted by */
+/* the FreeType Project License and this section (hereafter, "You" or */
+/* "Your") a perpetual, worldwide, non-exclusive, no-charge, */
+/* royalty-free, irrevocable (except as stated in this section) patent */
+/* license to make, have made, use, offer to sell, sell, import, and */
+/* otherwise transfer the Work, where such license applies only to those */
+/* patent claims licensable by such contributor that are necessarily */
+/* infringed by their contribution(s) alone or by combination of their */
+/* contribution(s) with the Work to which such contribution(s) was */
+/* submitted. If You institute patent litigation against any entity */
+/* (including a cross-claim or counterclaim in a lawsuit) alleging that */
+/* the Work or a contribution incorporated within the Work constitutes */
+/* direct or contributory patent infringement, then any patent licenses */
+/* granted to You under this License for that Work shall terminate as of */
+/* the date such litigation is filed. */
+/* */
+/* By using, modifying, or distributing the Work you indicate that you */
+/* have read and understood the terms and conditions of the */
+/* FreeType Project License as well as those provided in this section, */
+/* and you accept them fully. */
+/* */
+/***************************************************************************/
+
+
+#ifndef PSTYPES_H_
+#define PSTYPES_H_
+
+#include <ft2build.h>
+#include FT_FREETYPE_H
+
+
+FT_BEGIN_HEADER
+
+
+ /*
+ * The data models that we expect to support are as follows:
+ *
+ * name char short int long long-long pointer example
+ * -----------------------------------------------------
+ * ILP32 8 16 32 32 64* 32 32-bit MacOS, x86
+ * LLP64 8 16 32 32 64 64 x64
+ * LP64 8 16 32 64 64 64 64-bit MacOS
+ *
+ * *) type may be supported by emulation on a 32-bit architecture
+ *
+ */
+
+
+ /* integers at least 32 bits wide */
+#define CF2_UInt FT_UFast
+#define CF2_Int FT_Fast
+
+
+ /* fixed-float numbers */
+ typedef FT_Int32 CF2_F16Dot16;
+
+
+FT_END_HEADER
+
+
+#endif /* PSTYPES_H_ */
+
+
+/* END */
diff --git a/src/3rdparty/freetype/src/psaux/rules.mk b/src/3rdparty/freetype/src/psaux/rules.mk
index 0d2118c014..a87bfe9687 100644
--- a/src/3rdparty/freetype/src/psaux/rules.mk
+++ b/src/3rdparty/freetype/src/psaux/rules.mk
@@ -3,7 +3,7 @@
#
-# Copyright 1996-2015 by
+# Copyright 1996-2018 by
# David Turner, Robert Wilhelm, and Werner Lemberg.
#
# This file is part of the FreeType project, and may only be used, modified,
@@ -33,12 +33,25 @@ PSAUX_DRV_SRC := $(PSAUX_DIR)/psobjs.c \
$(PSAUX_DIR)/t1cmap.c \
$(PSAUX_DIR)/afmparse.c \
$(PSAUX_DIR)/psconv.c \
- $(PSAUX_DIR)/psauxmod.c
+ $(PSAUX_DIR)/psauxmod.c \
+ $(PSAUX_DIR)/psarrst.c \
+ $(PSAUX_DIR)/psblues.c \
+ $(PSAUX_DIR)/pserror.c \
+ $(PSAUX_DIR)/psfont.c \
+ $(PSAUX_DIR)/psft.c \
+ $(PSAUX_DIR)/pshints.c \
+ $(PSAUX_DIR)/psintrp.c \
+ $(PSAUX_DIR)/psread.c \
+ $(PSAUX_DIR)/psstack.c \
+ $(PSAUX_DIR)/cffdecode.c
# PSAUX driver headers
#
PSAUX_DRV_H := $(PSAUX_DRV_SRC:%c=%h) \
- $(PSAUX_DIR)/psauxerr.h
+ $(PSAUX_DIR)/psauxerr.h \
+ $(PSAUX_DIR)/psfixed.h \
+ $(PSAUX_DIR)/psglue.h \
+ $(PSAUX_DIR)/pstypes.h
# PSAUX driver object(s)
diff --git a/src/3rdparty/freetype/src/psaux/t1cmap.c b/src/3rdparty/freetype/src/psaux/t1cmap.c
index 2e2d433fc4..112a7892ba 100644
--- a/src/3rdparty/freetype/src/psaux/t1cmap.c
+++ b/src/3rdparty/freetype/src/psaux/t1cmap.c
@@ -4,7 +4,7 @@
/* */
/* Type 1 character map support (body). */
/* */
-/* Copyright 2002-2015 by */
+/* Copyright 2002-2018 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/src/3rdparty/freetype/src/psaux/t1cmap.h b/src/3rdparty/freetype/src/psaux/t1cmap.h
index b8ba06cc3b..4308e31d2d 100644
--- a/src/3rdparty/freetype/src/psaux/t1cmap.h
+++ b/src/3rdparty/freetype/src/psaux/t1cmap.h
@@ -4,7 +4,7 @@
/* */
/* Type 1 character map support (specification). */
/* */
-/* Copyright 2002-2015 by */
+/* Copyright 2002-2018 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -16,8 +16,8 @@
/***************************************************************************/
-#ifndef __T1CMAP_H__
-#define __T1CMAP_H__
+#ifndef T1CMAP_H_
+#define T1CMAP_H_
#include <ft2build.h>
#include FT_INTERNAL_OBJECTS_H
@@ -99,7 +99,7 @@ FT_BEGIN_HEADER
FT_END_HEADER
-#endif /* __T1CMAP_H__ */
+#endif /* T1CMAP_H_ */
/* END */
diff --git a/src/3rdparty/freetype/src/psaux/t1decode.c b/src/3rdparty/freetype/src/psaux/t1decode.c
index 2e199286f6..6ad145661f 100644
--- a/src/3rdparty/freetype/src/psaux/t1decode.c
+++ b/src/3rdparty/freetype/src/psaux/t1decode.c
@@ -4,7 +4,7 @@
/* */
/* PostScript Type 1 decoding routines (body). */
/* */
-/* Copyright 2000-2015 by */
+/* Copyright 2000-2018 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_CALC_H
#include FT_INTERNAL_DEBUG_H
#include FT_INTERNAL_POSTSCRIPT_HINTS_H
+#include FT_INTERNAL_HASH_H
#include FT_OUTLINE_H
#include "t1decode.h"
@@ -111,6 +112,56 @@
/*************************************************************************/
/* */
/* <Function> */
+ /* t1_lookup_glyph_by_stdcharcode_ps */
+ /* */
+ /* <Description> */
+ /* Looks up a given glyph by its StandardEncoding charcode. Used to */
+ /* implement the SEAC Type 1 operator in the Adobe engine */
+ /* */
+ /* <Input> */
+ /* face :: The current face object. */
+ /* */
+ /* charcode :: The character code to look for. */
+ /* */
+ /* <Return> */
+ /* A glyph index in the font face. Returns -1 if the corresponding */
+ /* glyph wasn't found. */
+ /* */
+ FT_LOCAL_DEF( FT_Int )
+ t1_lookup_glyph_by_stdcharcode_ps( PS_Decoder* decoder,
+ FT_Int charcode )
+ {
+ FT_UInt n;
+ const FT_String* glyph_name;
+ FT_Service_PsCMaps psnames = decoder->psnames;
+
+
+ /* check range of standard char code */
+ if ( charcode < 0 || charcode > 255 )
+ return -1;
+
+ glyph_name = psnames->adobe_std_strings(
+ psnames->adobe_std_encoding[charcode]);
+
+ for ( n = 0; n < decoder->num_glyphs; n++ )
+ {
+ FT_String* name = (FT_String*)decoder->glyph_names[n];
+
+
+ if ( name &&
+ name[0] == glyph_name[0] &&
+ ft_strcmp( name, glyph_name ) == 0 )
+ return (FT_Int)n;
+ }
+
+ return -1;
+ }
+
+
+#ifdef T1_CONFIG_OPTION_OLD_ENGINE
+ /*************************************************************************/
+ /* */
+ /* <Function> */
/* t1_lookup_glyph_by_stdcharcode */
/* */
/* <Description> */
@@ -157,6 +208,15 @@
}
+ /* parse a single Type 1 glyph */
+ FT_LOCAL_DEF( FT_Error )
+ t1_decoder_parse_glyph( T1_Decoder decoder,
+ FT_UInt glyph )
+ {
+ return decoder->parse_callback( decoder, glyph );
+ }
+
+
/*************************************************************************/
/* */
/* <Function> */
@@ -404,9 +464,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" ));
@@ -512,7 +570,7 @@
break;
case 12:
- if ( ip > limit )
+ if ( ip >= limit )
{
FT_ERROR(( "t1_decoder_parse_charstrings:"
" invalid escape (12+EOF)\n" ));
@@ -667,9 +725,9 @@
#ifdef FT_DEBUG_LEVEL_TRACE
if ( large_int )
- FT_TRACE4(( " %ld", value ));
+ FT_TRACE4(( " %d", value ));
else
- FT_TRACE4(( " %ld", Fix2Int( value ) ));
+ FT_TRACE4(( " %d", value / 65536 ));
#endif
*top++ = value;
@@ -735,7 +793,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:"
@@ -753,13 +811,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 */
@@ -770,7 +827,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" ));
@@ -782,10 +839,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;
@@ -857,7 +923,9 @@
for ( mm = 1; mm < blend->num_designs; mm++ )
- tmp += FT_MulFix( *delta++, blend->weight_vector[mm] );
+ tmp = ADD_LONG( tmp,
+ FT_MulFix( *delta++,
+ blend->weight_vector[mm] ) );
*values++ = tmp;
}
@@ -875,7 +943,7 @@
PS_Blend blend = decoder->blend;
- if ( arg_cnt != 1 || blend == NULL )
+ if ( arg_cnt != 1 || !blend )
goto Unexpected_OtherSubr;
idx = Fix2Int( top[0] );
@@ -897,7 +965,7 @@
if ( arg_cnt != 2 )
goto Unexpected_OtherSubr;
- top[0] += top[1]; /* XXX (over|under)flow */
+ top[0] = ADD_LONG( top[0], top[1] );
known_othersubr_result_cnt = 1;
break;
@@ -908,7 +976,7 @@
if ( arg_cnt != 2 )
goto Unexpected_OtherSubr;
- top[0] -= top[1]; /* XXX (over|under)flow */
+ top[0] = SUB_LONG( top[0], top[1] );
known_othersubr_result_cnt = 1;
break;
@@ -943,7 +1011,7 @@
PS_Blend blend = decoder->blend;
- if ( arg_cnt != 2 || blend == NULL )
+ if ( arg_cnt != 2 || !blend )
goto Unexpected_OtherSubr;
idx = Fix2Int( top[1] );
@@ -964,7 +1032,7 @@
PS_Blend blend = decoder->blend;
- if ( arg_cnt != 1 || blend == NULL )
+ if ( arg_cnt != 1 || !blend )
goto Unexpected_OtherSubr;
idx = Fix2Int( top[0] );
@@ -1122,7 +1190,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" ));
@@ -1140,11 +1208,13 @@
builder->parse_state = T1_Parse_Have_Width;
- builder->left_bearing.x += top[0];
- builder->advance.x = top[1];
- builder->advance.y = 0;
+ builder->left_bearing.x = ADD_LONG( builder->left_bearing.x,
+ top[0] );
- orig_x = x = builder->pos_x + top[0];
+ builder->advance.x = top[1];
+ builder->advance.y = 0;
+
+ orig_x = x = ADD_LONG( builder->pos_x, top[0] );
orig_y = y = builder->pos_y;
FT_UNUSED( orig_y );
@@ -1170,13 +1240,16 @@
builder->parse_state = T1_Parse_Have_Width;
- builder->left_bearing.x += top[0];
- builder->left_bearing.y += top[1];
- builder->advance.x = top[2];
- builder->advance.y = top[3];
+ builder->left_bearing.x = ADD_LONG( builder->left_bearing.x,
+ top[0] );
+ builder->left_bearing.y = ADD_LONG( builder->left_bearing.y,
+ top[1] );
+
+ builder->advance.x = top[2];
+ builder->advance.y = top[3];
- x = builder->pos_x + top[0];
- y = builder->pos_y + top[1];
+ x = ADD_LONG( builder->pos_x, top[0] );
+ y = ADD_LONG( builder->pos_y, top[1] );
/* the `metrics_only' indicates that we only want to compute */
/* the glyph's metrics (lsb + advance width), not load the */
@@ -1200,17 +1273,17 @@
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];
+ x = ADD_LONG( x, top[0] );
goto Add_Line;
case op_hmoveto:
FT_TRACE4(( " hmoveto" ));
- x += top[0];
+ x = ADD_LONG( x, top[0] );
+
if ( !decoder->flex_state )
{
if ( builder->parse_state == T1_Parse_Start )
@@ -1222,42 +1295,41 @@
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];
+ x = ADD_LONG( x, top[0] );
t1_builder_add_point( builder, x, y, 0 );
- x += top[1];
- y += top[2];
+
+ x = ADD_LONG( x, top[1] );
+ y = ADD_LONG( y, top[2] );
t1_builder_add_point( builder, x, y, 0 );
- y += top[3];
+
+ y = ADD_LONG( y, top[3] );
t1_builder_add_point( builder, x, y, 1 );
break;
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];
+ x = ADD_LONG( x, top[0] );
+ y = ADD_LONG( 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;
case op_rmoveto:
FT_TRACE4(( " rmoveto" ));
- x += top[0];
- y += top[1];
+ x = ADD_LONG( x, top[0] );
+ y = ADD_LONG( y, top[1] );
+
if ( !decoder->flex_state )
{
if ( builder->parse_state == T1_Parse_Start )
@@ -1269,57 +1341,55 @@
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];
- y += top[1];
+ x = ADD_LONG( x, top[0] );
+ y = ADD_LONG( y, top[1] );
t1_builder_add_point( builder, x, y, 0 );
- x += top[2];
- y += top[3];
+ x = ADD_LONG( x, top[2] );
+ y = ADD_LONG( y, top[3] );
t1_builder_add_point( builder, x, y, 0 );
- x += top[4];
- y += top[5];
+ x = ADD_LONG( x, top[4] );
+ y = ADD_LONG( y, top[5] );
t1_builder_add_point( builder, x, y, 1 );
break;
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];
+ y = ADD_LONG( y, top[0] );
t1_builder_add_point( builder, x, y, 0 );
- x += top[1];
- y += top[2];
+
+ x = ADD_LONG( x, top[1] );
+ y = ADD_LONG( y, top[2] );
t1_builder_add_point( builder, x, y, 0 );
- x += top[3];
+
+ x = ADD_LONG( x, top[3] );
t1_builder_add_point( builder, x, y, 1 );
break;
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];
+ y = ADD_LONG( y, top[0] );
goto Add_Line;
case op_vmoveto:
FT_TRACE4(( " vmoveto" ));
- y += top[0];
+ y = ADD_LONG( y, top[0] );
+
if ( !decoder->flex_state )
{
if ( builder->parse_state == T1_Parse_Start )
@@ -1335,7 +1405,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;
@@ -1348,6 +1418,19 @@
FT_TRACE4(( " callsubr" ));
idx = Fix2Int( top[0] );
+
+ if ( decoder->subrs_hash )
+ {
+ size_t* val = ft_hash_num_lookup( idx,
+ decoder->subrs_hash );
+
+
+ if ( val )
+ idx = *val;
+ else
+ idx = -1;
+ }
+
if ( idx < 0 || idx >= decoder->num_subrs )
{
FT_ERROR(( "t1_decoder_parse_charstrings:"
@@ -1463,7 +1546,7 @@
/* record vertical hint */
if ( hinter )
{
- top[0] += orig_x;
+ top[0] = ADD_LONG( top[0], orig_x );
hinter->stem( hinter->hints, 0, top );
}
break;
@@ -1477,9 +1560,9 @@
FT_Pos dx = orig_x;
- top[0] += dx;
- top[2] += dx;
- top[4] += dx;
+ top[0] = ADD_LONG( top[0], dx );
+ top[2] = ADD_LONG( top[2], dx );
+ top[4] = ADD_LONG( top[4], dx );
hinter->stem3( hinter->hints, 0, top );
}
break;
@@ -1555,14 +1638,286 @@
return FT_THROW( Stack_Underflow );
}
+#else /* T1_CONFIG_OPTION_OLD_ENGINE */
- /* parse a single Type 1 glyph */
+ /*************************************************************************/
+ /* */
+ /* <Function> */
+ /* t1_decoder_parse_metrics */
+ /* */
+ /* <Description> */
+ /* Parses a given Type 1 charstrings program to extract width */
+ /* */
+ /* <Input> */
+ /* decoder :: The current Type 1 decoder. */
+ /* */
+ /* charstring_base :: The base address of the charstring stream. */
+ /* */
+ /* charstring_len :: The length in bytes of the charstring stream. */
+ /* */
+ /* <Return> */
+ /* FreeType error code. 0 means success. */
+ /* */
FT_LOCAL_DEF( FT_Error )
- t1_decoder_parse_glyph( T1_Decoder decoder,
- FT_UInt glyph )
+ t1_decoder_parse_metrics( T1_Decoder decoder,
+ FT_Byte* charstring_base,
+ FT_UInt charstring_len )
{
- return decoder->parse_callback( decoder, glyph );
+ T1_Decoder_Zone zone;
+ FT_Byte* ip;
+ FT_Byte* limit;
+ T1_Builder builder = &decoder->builder;
+
+#ifdef FT_DEBUG_LEVEL_TRACE
+ FT_Bool bol = TRUE;
+#endif
+
+
+ /* First of all, initialize the decoder */
+ decoder->top = decoder->stack;
+ decoder->zone = decoder->zones;
+ zone = decoder->zones;
+
+ builder->parse_state = T1_Parse_Start;
+
+ FT_TRACE4(( "\n"
+ "Start charstring: get width\n" ));
+
+ zone->base = charstring_base;
+ limit = zone->limit = charstring_base + charstring_len;
+ ip = zone->cursor = zone->base;
+
+ /* now, execute loop */
+ while ( ip < limit )
+ {
+ FT_Long* top = decoder->top;
+ T1_Operator op = op_none;
+ FT_Int32 value = 0;
+
+
+#ifdef FT_DEBUG_LEVEL_TRACE
+ if ( bol )
+ {
+ FT_TRACE5(( " (%d)", decoder->top - decoder->stack ));
+ bol = FALSE;
+ }
+#endif
+
+ /*********************************************************************/
+ /* */
+ /* Decode operator or operand */
+ /* */
+ /* */
+
+ /* first of all, decompress operator or value */
+ switch ( *ip++ )
+ {
+ case 1:
+ case 3:
+ case 4:
+ case 5:
+ case 6:
+ case 7:
+ case 8:
+ case 9:
+ case 10:
+ case 11:
+ case 14:
+ case 15:
+ case 21:
+ case 22:
+ case 30:
+ case 31:
+ goto No_Width;
+
+ case 13:
+ op = op_hsbw;
+ break;
+
+ case 12:
+ if ( ip >= limit )
+ {
+ FT_ERROR(( "t1_decoder_parse_metrics:"
+ " invalid escape (12+EOF)\n" ));
+ goto Syntax_Error;
+ }
+
+ switch ( *ip++ )
+ {
+ case 7:
+ op = op_sbw;
+ break;
+
+ default:
+ goto No_Width;
+ }
+ break;
+
+ case 255: /* four bytes integer */
+ if ( ip + 4 > limit )
+ {
+ FT_ERROR(( "t1_decoder_parse_metrics:"
+ " unexpected EOF in integer\n" ));
+ goto Syntax_Error;
+ }
+
+ value = (FT_Int32)( ( (FT_UInt32)ip[0] << 24 ) |
+ ( (FT_UInt32)ip[1] << 16 ) |
+ ( (FT_UInt32)ip[2] << 8 ) |
+ (FT_UInt32)ip[3] );
+ ip += 4;
+
+ /* According to the specification, values > 32000 or < -32000 must */
+ /* be followed by a `div' operator to make the result be in the */
+ /* range [-32000;32000]. We expect that the second argument of */
+ /* `div' is not a large number. Additionally, we don't handle */
+ /* stuff like `<large1> <large2> <num> div <num> div' or */
+ /* <large1> <large2> <num> div div'. This is probably not allowed */
+ /* anyway. */
+ if ( value > 32000 || value < -32000 )
+ {
+ FT_ERROR(( "t1_decoder_parse_metrics:"
+ " large integer found for width\n" ));
+ goto Syntax_Error;
+ }
+ else
+ {
+ value = (FT_Int32)( (FT_UInt32)value << 16 );
+ }
+
+ break;
+
+ default:
+ if ( ip[-1] >= 32 )
+ {
+ if ( ip[-1] < 247 )
+ value = (FT_Int32)ip[-1] - 139;
+ else
+ {
+ if ( ++ip > limit )
+ {
+ FT_ERROR(( "t1_decoder_parse_metrics:"
+ " unexpected EOF in integer\n" ));
+ goto Syntax_Error;
+ }
+
+ if ( ip[-2] < 251 )
+ value = ( ( ip[-2] - 247 ) * 256 ) + ip[-1] + 108;
+ else
+ value = -( ( ( ip[-2] - 251 ) * 256 ) + ip[-1] + 108 );
+ }
+
+ value = (FT_Int32)( (FT_UInt32)value << 16 );
+ }
+ else
+ {
+ FT_ERROR(( "t1_decoder_parse_metrics:"
+ " invalid byte (%d)\n", ip[-1] ));
+ goto Syntax_Error;
+ }
+ }
+
+ /*********************************************************************/
+ /* */
+ /* Push value on stack, or process operator */
+ /* */
+ /* */
+ if ( op == op_none )
+ {
+ if ( top - decoder->stack >= T1_MAX_CHARSTRINGS_OPERANDS )
+ {
+ FT_ERROR(( "t1_decoder_parse_metrics: stack overflow\n" ));
+ goto Syntax_Error;
+ }
+
+#ifdef FT_DEBUG_LEVEL_TRACE
+ FT_TRACE4(( " %d", value / 65536 ));
+#endif
+
+ *top++ = value;
+ decoder->top = top;
+ }
+ else /* general operator */
+ {
+ FT_Int num_args = t1_args_count[op];
+
+
+ FT_ASSERT( num_args >= 0 );
+
+ if ( top - decoder->stack < num_args )
+ goto Stack_Underflow;
+
+#ifdef FT_DEBUG_LEVEL_TRACE
+
+ if ( top - decoder->stack != num_args )
+ FT_TRACE0(( "t1_decoder_parse_metrics:"
+ " too much operands on the stack"
+ " (seen %d, expected %d)\n",
+ top - decoder->stack, num_args ));
+
+#endif /* FT_DEBUG_LEVEL_TRACE */
+
+ top -= num_args;
+
+ switch ( op )
+ {
+ case op_hsbw:
+ FT_TRACE4(( " hsbw" ));
+
+ builder->parse_state = T1_Parse_Have_Width;
+
+ builder->left_bearing.x = ADD_LONG( builder->left_bearing.x,
+ top[0] );
+
+ builder->advance.x = top[1];
+ builder->advance.y = 0;
+
+ /* we only want to compute the glyph's metrics */
+ /* (lsb + advance width), not load the rest of */
+ /* it; so exit immediately */
+ return FT_Err_Ok;
+
+ case op_sbw:
+ FT_TRACE4(( " sbw" ));
+
+ builder->parse_state = T1_Parse_Have_Width;
+
+ builder->left_bearing.x = ADD_LONG( builder->left_bearing.x,
+ top[0] );
+ builder->left_bearing.y = ADD_LONG( builder->left_bearing.y,
+ top[1] );
+
+ builder->advance.x = top[2];
+ builder->advance.y = top[3];
+
+ /* we only want to compute the glyph's metrics */
+ /* (lsb + advance width), not load the rest of */
+ /* it; so exit immediately */
+ return FT_Err_Ok;
+
+ default:
+ FT_ERROR(( "t1_decoder_parse_metrics:"
+ " unhandled opcode %d\n", op ));
+ goto Syntax_Error;
+ }
+
+ } /* general operator processing */
+
+ } /* while ip < limit */
+
+ FT_TRACE4(( "..end..\n\n" ));
+
+ No_Width:
+ FT_ERROR(( "t1_decoder_parse_metrics:"
+ " no width, found op %d instead\n",
+ ip[-1] ));
+ Syntax_Error:
+ return FT_THROW( Syntax_Error );
+
+ Stack_Underflow:
+ return FT_THROW( Stack_Underflow );
}
+#endif /* T1_CONFIG_OPTION_OLD_ENGINE */
/* initialize T1 decoder */
@@ -1577,7 +1932,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 */
{
@@ -1617,7 +1972,16 @@
FT_LOCAL_DEF( void )
t1_decoder_done( T1_Decoder decoder )
{
+ FT_Memory memory = decoder->builder.memory;
+
+
t1_builder_done( &decoder->builder );
+
+ if ( decoder->cf2_instance.finalizer )
+ {
+ decoder->cf2_instance.finalizer( decoder->cf2_instance.data );
+ FT_FREE( decoder->cf2_instance.data );
+ }
}
diff --git a/src/3rdparty/freetype/src/psaux/t1decode.h b/src/3rdparty/freetype/src/psaux/t1decode.h
index e83078f719..1d9718d678 100644
--- a/src/3rdparty/freetype/src/psaux/t1decode.h
+++ b/src/3rdparty/freetype/src/psaux/t1decode.h
@@ -4,7 +4,7 @@
/* */
/* PostScript Type 1 decoding routines (specification). */
/* */
-/* Copyright 2000-2015 by */
+/* Copyright 2000-2018 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -16,8 +16,8 @@
/***************************************************************************/
-#ifndef __T1DECODE_H__
-#define __T1DECODE_H__
+#ifndef T1DECODE_H_
+#define T1DECODE_H_
#include <ft2build.h>
@@ -31,7 +31,11 @@ FT_BEGIN_HEADER
FT_CALLBACK_TABLE
const T1_Decoder_FuncsRec t1_decoder_funcs;
+ FT_LOCAL( FT_Int )
+ t1_lookup_glyph_by_stdcharcode_ps( PS_Decoder* decoder,
+ FT_Int charcode );
+#ifdef T1_CONFIG_OPTION_OLD_ENGINE
FT_LOCAL( FT_Error )
t1_decoder_parse_glyph( T1_Decoder decoder,
FT_UInt glyph_index );
@@ -40,6 +44,12 @@ FT_BEGIN_HEADER
t1_decoder_parse_charstrings( T1_Decoder decoder,
FT_Byte* base,
FT_UInt len );
+#else
+ FT_LOCAL( FT_Error )
+ t1_decoder_parse_metrics( T1_Decoder decoder,
+ FT_Byte* charstring_base,
+ FT_UInt charstring_len );
+#endif
FT_LOCAL( FT_Error )
t1_decoder_init( T1_Decoder decoder,
@@ -58,7 +68,7 @@ FT_BEGIN_HEADER
FT_END_HEADER
-#endif /* __T1DECODE_H__ */
+#endif /* T1DECODE_H_ */
/* END */
diff --git a/src/3rdparty/freetype/src/pshinter/Jamfile b/src/3rdparty/freetype/src/pshinter/Jamfile
index 6fb3be11c7..3f5f0ae40e 100644
--- a/src/3rdparty/freetype/src/pshinter/Jamfile
+++ b/src/3rdparty/freetype/src/pshinter/Jamfile
@@ -1,6 +1,6 @@
# FreeType 2 src/pshinter Jamfile
#
-# Copyright 2001-2015 by
+# Copyright 2001-2018 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/src/3rdparty/freetype/src/pshinter/module.mk b/src/3rdparty/freetype/src/pshinter/module.mk
index 1fd8e55a33..06707be3b4 100644
--- a/src/3rdparty/freetype/src/pshinter/module.mk
+++ b/src/3rdparty/freetype/src/pshinter/module.mk
@@ -3,7 +3,7 @@
#
-# Copyright 1996-2015 by
+# Copyright 1996-2018 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/src/3rdparty/freetype/src/pshinter/pshalgo.c b/src/3rdparty/freetype/src/pshinter/pshalgo.c
index 6e654cb1ef..b98077c62e 100644
--- a/src/3rdparty/freetype/src/pshinter/pshalgo.c
+++ b/src/3rdparty/freetype/src/pshinter/pshalgo.c
@@ -4,7 +4,7 @@
/* */
/* PostScript hinting algorithm (body). */
/* */
-/* Copyright 2001-2015 by */
+/* Copyright 2001-2018 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used */
@@ -26,7 +26,7 @@
#undef FT_COMPONENT
-#define FT_COMPONENT trace_pshalgo2
+#define FT_COMPONENT trace_pshalgo
#ifdef DEBUG_HINTER
@@ -779,7 +779,7 @@
* It turns out though that minimizing the total number of lit
* pixels is also important, so position C), with one edge
* aligned with a pixel boundary is actually preferable
- * to A). There are also more possibile positions for C) than
+ * to A). There are also more possible positions for C) than
* for A) or B), so it involves less distortion of the overall
* character shape.
*/
@@ -802,7 +802,7 @@
}
/* We choose between B) and C) above based on the amount
- * of fractinal stem width; for small amounts, choose
+ * of fractional stem width; for small amounts, choose
* C) always, for large amounts, B) always, and inbetween,
* pick whichever one involves less stem movement.
*/
@@ -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/src/3rdparty/freetype/src/pshinter/pshalgo.h b/src/3rdparty/freetype/src/pshinter/pshalgo.h
index 8373e5ec29..c50683fbec 100644
--- a/src/3rdparty/freetype/src/pshinter/pshalgo.h
+++ b/src/3rdparty/freetype/src/pshinter/pshalgo.h
@@ -4,7 +4,7 @@
/* */
/* PostScript hinting algorithm (specification). */
/* */
-/* Copyright 2001-2015 by */
+/* Copyright 2001-2018 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -16,8 +16,8 @@
/***************************************************************************/
-#ifndef __PSHALGO_H__
-#define __PSHALGO_H__
+#ifndef PSHALGO_H_
+#define PSHALGO_H_
#include "pshrec.h"
@@ -235,7 +235,7 @@ FT_BEGIN_HEADER
FT_END_HEADER
-#endif /* __PSHALGO_H__ */
+#endif /* PSHALGO_H_ */
/* END */
diff --git a/src/3rdparty/freetype/src/pshinter/pshglob.c b/src/3rdparty/freetype/src/pshinter/pshglob.c
index 4616bdc6cf..accc04921d 100644
--- a/src/3rdparty/freetype/src/pshinter/pshglob.c
+++ b/src/3rdparty/freetype/src/pshinter/pshglob.c
@@ -5,7 +5,7 @@
/* PostScript hinter global hinting management (body). */
/* Inspired by the new auto-hinter module. */
/* */
-/* Copyright 2001-2015 by */
+/* Copyright 2001-2018 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used */
@@ -80,7 +80,7 @@
#if 0
- /* org_width is is font units, result in device pixels, 26.6 format */
+ /* org_width is in font units, result in device pixels, 26.6 format */
FT_LOCAL_DEF( FT_Pos )
psh_dimension_snap_width( PSH_Dimension dimension,
FT_Int org_width )
@@ -227,8 +227,8 @@
}
- /* Re-read blue zones from the original fonts and store them into out */
- /* private structure. This function re-orders, sanitizes and */
+ /* Re-read blue zones from the original fonts and store them into our */
+ /* private structure. This function re-orders, sanitizes, and */
/* fuzz-expands the zones as well. */
static void
psh_blues_set_zones( PSH_Blues target,
diff --git a/src/3rdparty/freetype/src/pshinter/pshglob.h b/src/3rdparty/freetype/src/pshinter/pshglob.h
index c376df7b9f..cf80bf40e6 100644
--- a/src/3rdparty/freetype/src/pshinter/pshglob.h
+++ b/src/3rdparty/freetype/src/pshinter/pshglob.h
@@ -4,7 +4,7 @@
/* */
/* PostScript hinter global hinting management. */
/* */
-/* Copyright 2001-2015 by */
+/* Copyright 2001-2018 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -16,8 +16,8 @@
/***************************************************************************/
-#ifndef __PSHGLOB_H__
-#define __PSHGLOB_H__
+#ifndef PSHGLOB_H_
+#define PSHGLOB_H_
#include FT_FREETYPE_H
@@ -190,7 +190,7 @@ FT_BEGIN_HEADER
FT_END_HEADER
-#endif /* __PSHGLOB_H__ */
+#endif /* PSHGLOB_H_ */
/* END */
diff --git a/src/3rdparty/freetype/src/pshinter/pshinter.c b/src/3rdparty/freetype/src/pshinter/pshinter.c
index 9e65fe2a42..0eedac452d 100644
--- a/src/3rdparty/freetype/src/pshinter/pshinter.c
+++ b/src/3rdparty/freetype/src/pshinter/pshinter.c
@@ -4,7 +4,7 @@
/* */
/* FreeType PostScript Hinting module */
/* */
-/* Copyright 2001-2015 by */
+/* Copyright 2001-2018 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/src/3rdparty/freetype/src/pshinter/pshmod.c b/src/3rdparty/freetype/src/pshinter/pshmod.c
index 961b468506..0b8f6f99b8 100644
--- a/src/3rdparty/freetype/src/pshinter/pshmod.c
+++ b/src/3rdparty/freetype/src/pshinter/pshmod.c
@@ -4,7 +4,7 @@
/* */
/* FreeType PostScript hinter module implementation (body). */
/* */
-/* Copyright 2001-2015 by */
+/* Copyright 2001-2018 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/src/3rdparty/freetype/src/pshinter/pshmod.h b/src/3rdparty/freetype/src/pshinter/pshmod.h
index a58d856533..556de2fbc0 100644
--- a/src/3rdparty/freetype/src/pshinter/pshmod.h
+++ b/src/3rdparty/freetype/src/pshinter/pshmod.h
@@ -4,7 +4,7 @@
/* */
/* PostScript hinter module interface (specification). */
/* */
-/* Copyright 2001-2015 by */
+/* Copyright 2001-2018 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -16,8 +16,8 @@
/***************************************************************************/
-#ifndef __PSHMOD_H__
-#define __PSHMOD_H__
+#ifndef PSHMOD_H_
+#define PSHMOD_H_
#include <ft2build.h>
@@ -33,7 +33,7 @@ FT_BEGIN_HEADER
FT_END_HEADER
-#endif /* __PSHMOD_H__ */
+#endif /* PSHMOD_H_ */
/* END */
diff --git a/src/3rdparty/freetype/src/pshinter/pshnterr.h b/src/3rdparty/freetype/src/pshinter/pshnterr.h
index ce790a8ef5..b9d02d2956 100644
--- a/src/3rdparty/freetype/src/pshinter/pshnterr.h
+++ b/src/3rdparty/freetype/src/pshinter/pshnterr.h
@@ -4,7 +4,7 @@
/* */
/* PS Hinter error codes (specification only). */
/* */
-/* Copyright 2003-2015 by */
+/* Copyright 2003-2018 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -22,12 +22,12 @@
/* */
/*************************************************************************/
-#ifndef __PSHNTERR_H__
-#define __PSHNTERR_H__
+#ifndef PSHNTERR_H_
+#define PSHNTERR_H_
#include FT_MODULE_ERRORS_H
-#undef __FTERRORS_H__
+#undef FTERRORS_H_
#undef FT_ERR_PREFIX
#define FT_ERR_PREFIX PSH_Err_
@@ -35,7 +35,7 @@
#include FT_ERRORS_H
-#endif /* __PSHNTERR_H__ */
+#endif /* PSHNTERR_H_ */
/* END */
diff --git a/src/3rdparty/freetype/src/pshinter/pshpic.c b/src/3rdparty/freetype/src/pshinter/pshpic.c
index afd8fb9678..465ad31885 100644
--- a/src/3rdparty/freetype/src/pshinter/pshpic.c
+++ b/src/3rdparty/freetype/src/pshinter/pshpic.c
@@ -4,7 +4,7 @@
/* */
/* The FreeType position independent code services for pshinter module. */
/* */
-/* Copyright 2009-2015 by */
+/* Copyright 2009-2018 by */
/* Oran Agra and Mickey Gabel. */
/* */
/* This file is part of the FreeType project, and may only be used, */
diff --git a/src/3rdparty/freetype/src/pshinter/pshpic.h b/src/3rdparty/freetype/src/pshinter/pshpic.h
index ca35cd6fa9..4469ba87c8 100644
--- a/src/3rdparty/freetype/src/pshinter/pshpic.h
+++ b/src/3rdparty/freetype/src/pshinter/pshpic.h
@@ -4,7 +4,7 @@
/* */
/* The FreeType position independent code services for pshinter module. */
/* */
-/* Copyright 2009-2015 by */
+/* Copyright 2009-2018 by */
/* Oran Agra and Mickey Gabel. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -16,8 +16,8 @@
/***************************************************************************/
-#ifndef __PSHPIC_H__
-#define __PSHPIC_H__
+#ifndef PSHPIC_H_
+#define PSHPIC_H_
#include FT_INTERNAL_PIC_H
@@ -57,7 +57,7 @@ FT_END_HEADER
/* */
-#endif /* __PSHPIC_H__ */
+#endif /* PSHPIC_H_ */
/* END */
diff --git a/src/3rdparty/freetype/src/pshinter/pshrec.c b/src/3rdparty/freetype/src/pshinter/pshrec.c
index f8895fc8d6..6648d13d60 100644
--- a/src/3rdparty/freetype/src/pshinter/pshrec.c
+++ b/src/3rdparty/freetype/src/pshinter/pshrec.c
@@ -4,7 +4,7 @@
/* */
/* FreeType PostScript hints recorder (body). */
/* */
-/* Copyright 2001-2015 by */
+/* Copyright 2001-2018 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/src/3rdparty/freetype/src/pshinter/pshrec.h b/src/3rdparty/freetype/src/pshinter/pshrec.h
index 2b1ad94936..7e3dfe0d53 100644
--- a/src/3rdparty/freetype/src/pshinter/pshrec.h
+++ b/src/3rdparty/freetype/src/pshinter/pshrec.h
@@ -4,7 +4,7 @@
/* */
/* Postscript (Type1/Type2) hints recorder (specification). */
/* */
-/* Copyright 2001-2015 by */
+/* Copyright 2001-2018 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -28,8 +28,8 @@
/**************************************************************************/
-#ifndef __PSHREC_H__
-#define __PSHREC_H__
+#ifndef PSHREC_H_
+#define PSHREC_H_
#include <ft2build.h>
@@ -166,7 +166,7 @@ FT_BEGIN_HEADER
FT_END_HEADER
-#endif /* __PS_HINTER_RECORD_H__ */
+#endif /* PSHREC_H_ */
/* END */
diff --git a/src/3rdparty/freetype/src/pshinter/rules.mk b/src/3rdparty/freetype/src/pshinter/rules.mk
index 7838e676ec..966690efc2 100644
--- a/src/3rdparty/freetype/src/pshinter/rules.mk
+++ b/src/3rdparty/freetype/src/pshinter/rules.mk
@@ -3,7 +3,7 @@
#
-# Copyright 2001-2015 by
+# Copyright 2001-2018 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/src/3rdparty/freetype/src/psnames/Jamfile b/src/3rdparty/freetype/src/psnames/Jamfile
index 6dcc8b8e94..a0fd37397a 100644
--- a/src/3rdparty/freetype/src/psnames/Jamfile
+++ b/src/3rdparty/freetype/src/psnames/Jamfile
@@ -1,6 +1,6 @@
# FreeType 2 src/psnames Jamfile
#
-# Copyright 2001-2015 by
+# Copyright 2001-2018 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/src/3rdparty/freetype/src/psnames/module.mk b/src/3rdparty/freetype/src/psnames/module.mk
index 3708f60362..410f48a191 100644
--- a/src/3rdparty/freetype/src/psnames/module.mk
+++ b/src/3rdparty/freetype/src/psnames/module.mk
@@ -3,7 +3,7 @@
#
-# Copyright 1996-2015 by
+# Copyright 1996-2018 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/src/3rdparty/freetype/src/psnames/psmodule.c b/src/3rdparty/freetype/src/psnames/psmodule.c
index 0f04c2fa7d..8929ebe751 100644
--- a/src/3rdparty/freetype/src/psnames/psmodule.c
+++ b/src/3rdparty/freetype/src/psnames/psmodule.c
@@ -4,7 +4,7 @@
/* */
/* PSNames module implementation (body). */
/* */
-/* Copyright 1996-2015 by */
+/* Copyright 1996-2018 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -22,6 +22,22 @@
#include FT_SERVICE_POSTSCRIPT_CMAPS_H
#include "psmodule.h"
+
+ /*
+ * The file `pstables.h' with its arrays and its function
+ * `ft_get_adobe_glyph_index' is useful for other projects also (for
+ * example, `pdfium' is using it). However, if used as a C++ header,
+ * including it in two different source files makes it necessary to use
+ * `extern const' for the declaration of its arrays, otherwise the data
+ * would be duplicated as mandated by the C++ standard.
+ *
+ * For this reason, we use `DEFINE_PS_TABLES' to guard the function
+ * definitions, and `DEFINE_PS_TABLES_DATA' to provide both proper array
+ * declarations and definitions.
+ */
+#include "pstables.h"
+#define DEFINE_PS_TABLES
+#define DEFINE_PS_TABLES_DATA
#include "pstables.h"
#include "psnamerr.h"
@@ -525,37 +541,42 @@
FT_DEFINE_SERVICE_PSCMAPSREC(
pscmaps_interface,
- (PS_Unicode_ValueFunc) ps_unicode_value,
- (PS_Unicodes_InitFunc) ps_unicodes_init,
- (PS_Unicodes_CharIndexFunc)ps_unicodes_char_index,
- (PS_Unicodes_CharNextFunc) ps_unicodes_char_next,
- (PS_Macintosh_NameFunc) ps_get_macintosh_name,
- (PS_Adobe_Std_StringsFunc) ps_get_standard_strings,
+ (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 */
+ (PS_Unicodes_CharNextFunc) ps_unicodes_char_next, /* unicodes_char_next */
+
+ (PS_Macintosh_NameFunc) ps_get_macintosh_name, /* macintosh_name */
+ (PS_Adobe_Std_StringsFunc) ps_get_standard_strings, /* adobe_std_strings */
- t1_standard_encoding,
- t1_expert_encoding )
+ t1_standard_encoding, /* adobe_std_encoding */
+ t1_expert_encoding /* adobe_expert_encoding */
+ )
#else
FT_DEFINE_SERVICE_PSCMAPSREC(
pscmaps_interface,
- NULL,
- NULL,
- NULL,
- NULL,
- (PS_Macintosh_NameFunc) ps_get_macintosh_name,
- (PS_Adobe_Std_StringsFunc) ps_get_standard_strings,
+ NULL, /* unicode_value */
+ NULL, /* unicodes_init */
+ NULL, /* unicodes_char_index */
+ NULL, /* unicodes_char_next */
- t1_standard_encoding,
- t1_expert_encoding )
+ (PS_Macintosh_NameFunc) ps_get_macintosh_name, /* macintosh_name */
+ (PS_Adobe_Std_StringsFunc) ps_get_standard_strings, /* adobe_std_strings */
+
+ t1_standard_encoding, /* adobe_std_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 +622,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/src/3rdparty/freetype/src/psnames/psmodule.h b/src/3rdparty/freetype/src/psnames/psmodule.h
index f85f322193..3e94f8b437 100644
--- a/src/3rdparty/freetype/src/psnames/psmodule.h
+++ b/src/3rdparty/freetype/src/psnames/psmodule.h
@@ -4,7 +4,7 @@
/* */
/* High-level PSNames module interface (specification). */
/* */
-/* Copyright 1996-2015 by */
+/* Copyright 1996-2018 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -16,8 +16,8 @@
/***************************************************************************/
-#ifndef __PSMODULE_H__
-#define __PSMODULE_H__
+#ifndef PSMODULE_H_
+#define PSMODULE_H_
#include <ft2build.h>
@@ -32,7 +32,7 @@ FT_BEGIN_HEADER
FT_END_HEADER
-#endif /* __PSMODULE_H__ */
+#endif /* PSMODULE_H_ */
/* END */
diff --git a/src/3rdparty/freetype/src/psnames/psnamerr.h b/src/3rdparty/freetype/src/psnames/psnamerr.h
index 09cc247b7d..14eb76c99c 100644
--- a/src/3rdparty/freetype/src/psnames/psnamerr.h
+++ b/src/3rdparty/freetype/src/psnames/psnamerr.h
@@ -4,7 +4,7 @@
/* */
/* PS names module error codes (specification only). */
/* */
-/* Copyright 2001-2015 by */
+/* Copyright 2001-2018 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -23,12 +23,12 @@
/* */
/*************************************************************************/
-#ifndef __PSNAMERR_H__
-#define __PSNAMERR_H__
+#ifndef PSNAMERR_H_
+#define PSNAMERR_H_
#include FT_MODULE_ERRORS_H
-#undef __FTERRORS_H__
+#undef FTERRORS_H_
#undef FT_ERR_PREFIX
#define FT_ERR_PREFIX PSnames_Err_
@@ -36,7 +36,7 @@
#include FT_ERRORS_H
-#endif /* __PSNAMERR_H__ */
+#endif /* PSNAMERR_H_ */
/* END */
diff --git a/src/3rdparty/freetype/src/psnames/psnames.c b/src/3rdparty/freetype/src/psnames/psnames.c
index a4385961e5..febb80d594 100644
--- a/src/3rdparty/freetype/src/psnames/psnames.c
+++ b/src/3rdparty/freetype/src/psnames/psnames.c
@@ -4,7 +4,7 @@
/* */
/* FreeType PSNames module component (body only). */
/* */
-/* Copyright 1996-2015 by */
+/* Copyright 1996-2018 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/src/3rdparty/freetype/src/psnames/pspic.c b/src/3rdparty/freetype/src/psnames/pspic.c
index 1394f977e0..85a06f3603 100644
--- a/src/3rdparty/freetype/src/psnames/pspic.c
+++ b/src/3rdparty/freetype/src/psnames/pspic.c
@@ -4,7 +4,7 @@
/* */
/* The FreeType position independent code services for psnames module. */
/* */
-/* Copyright 2009-2015 by */
+/* Copyright 2009-2018 by */
/* Oran Agra and Mickey Gabel. */
/* */
/* This file is part of the FreeType project, and may only be used, */
diff --git a/src/3rdparty/freetype/src/psnames/pspic.h b/src/3rdparty/freetype/src/psnames/pspic.h
index 443225af61..889780cc03 100644
--- a/src/3rdparty/freetype/src/psnames/pspic.h
+++ b/src/3rdparty/freetype/src/psnames/pspic.h
@@ -4,7 +4,7 @@
/* */
/* The FreeType position independent code services for psnames module. */
/* */
-/* Copyright 2009-2015 by */
+/* Copyright 2009-2018 by */
/* Oran Agra and Mickey Gabel. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -16,8 +16,8 @@
/***************************************************************************/
-#ifndef __PSPIC_H__
-#define __PSPIC_H__
+#ifndef PSPIC_H_
+#define PSPIC_H_
#include FT_INTERNAL_PIC_H
@@ -62,7 +62,7 @@ FT_END_HEADER
/* */
-#endif /* __PSPIC_H__ */
+#endif /* PSPIC_H_ */
/* END */
diff --git a/src/3rdparty/freetype/src/psnames/pstables.h b/src/3rdparty/freetype/src/psnames/pstables.h
index 3f31c31b18..79545ee039 100644
--- a/src/3rdparty/freetype/src/psnames/pstables.h
+++ b/src/3rdparty/freetype/src/psnames/pstables.h
@@ -4,7 +4,7 @@
/* */
/* PostScript glyph names. */
/* */
-/* Copyright 2005-2015 by */
+/* Copyright 2005-2018 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_DATA
+#ifdef __cplusplus
+ extern "C"
+#else
+ extern
+#endif
+#endif
+ const char ft_standard_glyph_names[3696]
+#ifdef DEFINE_PS_TABLES_DATA
+ =
{
'.','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_DATA */
+ ;
#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_DATA
+#ifdef __cplusplus
+ extern "C"
+#else
+ extern
+#endif
+#endif
+ const short ft_mac_names[FT_NUM_MAC_NAMES]
+#ifdef DEFINE_PS_TABLES_DATA
+ =
{
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_DATA */
+ ;
#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_DATA
+#ifdef __cplusplus
+ extern "C"
+#else
+ extern
+#endif
+#endif
+ const short ft_sid_names[FT_NUM_SID_NAMES]
+#ifdef DEFINE_PS_TABLES_DATA
+ =
{
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_DATA */
+ ;
/* the following are indices into the SID name table */
- static const unsigned short t1_standard_encoding[256] =
+#ifndef DEFINE_PS_TABLES_DATA
+#ifdef __cplusplus
+ extern "C"
+#else
+ extern
+#endif
+#endif
+ const unsigned short t1_standard_encoding[256]
+#ifdef DEFINE_PS_TABLES_DATA
+ =
{
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_DATA */
+ ;
/* the following are indices into the SID name table */
- static const unsigned short t1_expert_encoding[256] =
+#ifndef DEFINE_PS_TABLES_DATA
+#ifdef __cplusplus
+ extern "C"
+#else
+ extern
+#endif
+#endif
+ const unsigned short t1_expert_encoding[256]
+#ifdef DEFINE_PS_TABLES_DATA
+ =
{
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_DATA */
+ ;
/*
@@ -564,7 +619,16 @@
#ifdef FT_CONFIG_OPTION_ADOBE_GLYPH_LIST
- static const unsigned char ft_adobe_glyph_list[55997L] =
+#ifndef DEFINE_PS_TABLES_DATA
+#ifdef __cplusplus
+ extern "C"
+#else
+ extern
+#endif
+#endif
+ const unsigned char ft_adobe_glyph_list[55997L]
+#ifdef DEFINE_PS_TABLES_DATA
+ =
{
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_DATA */
+ ;
+#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/src/3rdparty/freetype/src/psnames/rules.mk b/src/3rdparty/freetype/src/psnames/rules.mk
index 3c774867fd..4d629d841c 100644
--- a/src/3rdparty/freetype/src/psnames/rules.mk
+++ b/src/3rdparty/freetype/src/psnames/rules.mk
@@ -3,7 +3,7 @@
#
-# Copyright 1996-2015 by
+# Copyright 1996-2018 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/src/3rdparty/freetype/src/raster/Jamfile b/src/3rdparty/freetype/src/raster/Jamfile
index 71df5689ee..838e7ef57e 100644
--- a/src/3rdparty/freetype/src/raster/Jamfile
+++ b/src/3rdparty/freetype/src/raster/Jamfile
@@ -1,6 +1,6 @@
# FreeType 2 src/raster Jamfile
#
-# Copyright 2001-2015 by
+# Copyright 2001-2018 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/src/3rdparty/freetype/src/raster/ftmisc.h b/src/3rdparty/freetype/src/raster/ftmisc.h
index b87e0b62b7..7e40119071 100644
--- a/src/3rdparty/freetype/src/raster/ftmisc.h
+++ b/src/3rdparty/freetype/src/raster/ftmisc.h
@@ -5,7 +5,7 @@
/* Miscellaneous macros for stand-alone rasterizer (specification */
/* only). */
/* */
-/* Copyright 2005-2015 by */
+/* Copyright 2005-2018 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used */
@@ -24,8 +24,8 @@
/* */
/***************************************************/
-#ifndef __FTMISC_H__
-#define __FTMISC_H__
+#ifndef FTMISC_H_
+#define FTMISC_H_
/* memset */
@@ -136,7 +136,7 @@
return ( s > 0 ) ? d : -d;
}
-#endif /* __FTMISC_H__ */
+#endif /* FTMISC_H_ */
/* END */
diff --git a/src/3rdparty/freetype/src/raster/ftraster.c b/src/3rdparty/freetype/src/raster/ftraster.c
index e4bab98728..4354730d54 100644
--- a/src/3rdparty/freetype/src/raster/ftraster.c
+++ b/src/3rdparty/freetype/src/raster/ftraster.c
@@ -4,7 +4,7 @@
/* */
/* The FreeType glyph rasterizer (body). */
/* */
-/* Copyright 1996-2015 by */
+/* Copyright 1996-2018 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -18,7 +18,7 @@
/*************************************************************************/
/* */
/* This file can be compiled without the rest of the FreeType engine, by */
- /* defining the _STANDALONE_ macro when compiling it. You also need to */
+ /* defining the STANDALONE_ macro when compiling it. You also need to */
/* put the files `ftimage.h' and `ftmisc.h' into the $(incdir) */
/* directory. Typically, you should do something like */
/* */
@@ -27,9 +27,9 @@
/* - copy `include/freetype/ftimage.h' and `src/raster/ftmisc.h' to your */
/* current directory */
/* */
- /* - compile `ftraster' with the _STANDALONE_ macro defined, as in */
+ /* - compile `ftraster' with the STANDALONE_ macro defined, as in */
/* */
- /* cc -c -D_STANDALONE_ ftraster.c */
+ /* cc -c -DSTANDALONE_ ftraster.c */
/* */
/* The renderer can be initialized with a call to */
/* `ft_standard_raster.raster_new'; a bitmap can be generated */
@@ -47,7 +47,7 @@
/* */
/*************************************************************************/
-#ifdef _STANDALONE_
+#ifdef STANDALONE_
/* The size in bytes of the render pool used by the scan-line converter */
/* to do all of its work. */
@@ -60,7 +60,7 @@
#include "ftmisc.h"
#include "ftimage.h"
-#else /* !_STANDALONE_ */
+#else /* !STANDALONE_ */
#include <ft2build.h>
#include "ftraster.h"
@@ -68,7 +68,7 @@
#include "rastpic.h"
-#endif /* !_STANDALONE_ */
+#endif /* !STANDALONE_ */
/*************************************************************************/
@@ -173,14 +173,12 @@
#define FT_COMPONENT trace_raster
-#ifdef _STANDALONE_
+#ifdef STANDALONE_
/* Auxiliary macros for token concatenation. */
#define FT_ERR_XCAT( x, y ) x ## y
#define FT_ERR_CAT( x, y ) FT_ERR_XCAT( x, y )
-#define FT_MAX( a, b ) ( (a) > (b) ? (a) : (b) )
-
/* This macro is used to indicate that a function parameter is unused. */
/* Its purpose is simply to reduce compiler warnings. Note also that */
/* simply defining it as `(void)x' doesn't avoid warnings with certain */
@@ -226,7 +224,7 @@
raster_done_ \
};
-#else /* !_STANDALONE_ */
+#else /* !STANDALONE_ */
#include FT_INTERNAL_OBJECTS_H
@@ -242,7 +240,7 @@
#define Raster_Err_Unsupported Raster_Err_Cannot_Render_Glyph
-#endif /* !_STANDALONE_ */
+#endif /* !STANDALONE_ */
#ifndef FT_MEM_SET
@@ -253,6 +251,10 @@
#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 */
/* typically a small value and the result of a*b is known to fit into */
/* 32 bits. */
@@ -459,6 +461,12 @@
#define IS_TOP_OVERSHOOT( x ) \
(Bool)( x - FLOOR( x ) >= ras.precision_half )
+#if FT_RENDER_POOL_SIZE > 2048
+#define FT_MAX_BLACK_POOL ( FT_RENDER_POOL_SIZE / sizeof ( Long ) )
+#else
+#define FT_MAX_BLACK_POOL ( 2048 / sizeof ( Long ) )
+#endif
+
/* The most used variables are positioned at the top of the structure. */
/* Thus, their offset can be coded with less opcodes, resulting in a */
/* smaller executable. */
@@ -1512,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 */
@@ -1648,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 */
@@ -2382,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 );
@@ -2583,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 );
@@ -3041,7 +3051,7 @@
/**** a static object. *****/
-#ifdef _STANDALONE_
+#ifdef STANDALONE_
static int
@@ -3053,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;
@@ -3068,7 +3078,7 @@
}
-#else /* !_STANDALONE_ */
+#else /* !STANDALONE_ */
static int
@@ -3102,13 +3112,13 @@
}
-#endif /* !_STANDALONE_ */
+#endif /* !STANDALONE_ */
static void
- ft_black_reset( black_PRaster raster,
- char* pool_base,
- Long pool_size )
+ ft_black_reset( FT_Raster raster,
+ PByte pool_base,
+ ULong pool_size )
{
FT_UNUSED( raster );
FT_UNUSED( pool_base );
@@ -3117,20 +3127,20 @@
static int
- ft_black_set_mode( black_PRaster raster,
- ULong mode,
- const char* palette )
+ ft_black_set_mode( FT_Raster raster,
+ ULong mode,
+ void* args )
{
FT_UNUSED( raster );
FT_UNUSED( mode );
- FT_UNUSED( palette );
+ FT_UNUSED( args );
return 0;
}
static int
- ft_black_render( black_PRaster raster,
+ ft_black_render( FT_Raster raster,
const FT_Raster_Params* params )
{
const FT_Outline* outline = (const FT_Outline*)params->source;
@@ -3138,7 +3148,7 @@
black_TWorker worker[1];
- Long buffer[FT_MAX( FT_RENDER_POOL_SIZE, 2048 ) / sizeof ( Long )];
+ Long buffer[FT_MAX_BLACK_POOL];
if ( !raster )
@@ -3175,6 +3185,20 @@
if ( !target_map->buffer )
return FT_THROW( Invalid );
+ /* reject too large outline coordinates */
+ {
+ FT_Vector* vec = outline->points;
+ FT_Vector* limit = vec + outline->n_points;
+
+
+ for ( ; vec < limit; vec++ )
+ {
+ if ( vec->x < -0x1000000L || vec->x > 0x1000000L ||
+ vec->y < -0x1000000L || vec->y > 0x1000000L )
+ return FT_THROW( Invalid );
+ }
+ }
+
ras.outline = *outline;
ras.target = *target_map;
@@ -3190,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/src/3rdparty/freetype/src/raster/ftraster.h b/src/3rdparty/freetype/src/raster/ftraster.h
index a270d487b9..40b5d6d321 100644
--- a/src/3rdparty/freetype/src/raster/ftraster.h
+++ b/src/3rdparty/freetype/src/raster/ftraster.h
@@ -4,7 +4,7 @@
/* */
/* The FreeType glyph rasterizer (specification). */
/* */
-/* Copyright 1996-2015 by */
+/* Copyright 1996-2018 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used */
@@ -16,8 +16,8 @@
/***************************************************************************/
-#ifndef __FTRASTER_H__
-#define __FTRASTER_H__
+#ifndef FTRASTER_H_
+#define FTRASTER_H_
#include <ft2build.h>
@@ -33,14 +33,14 @@ FT_BEGIN_HEADER
/* Uncomment the following line if you are using ftraster.c as a */
/* standalone module, fully independent of FreeType. */
/* */
-/* #define _STANDALONE_ */
+/* #define STANDALONE_ */
FT_EXPORT_VAR( const FT_Raster_Funcs ) ft_standard_raster;
FT_END_HEADER
-#endif /* __FTRASTER_H__ */
+#endif /* FTRASTER_H_ */
/* END */
diff --git a/src/3rdparty/freetype/src/raster/ftrend1.c b/src/3rdparty/freetype/src/raster/ftrend1.c
index f314392839..a7ce9731d7 100644
--- a/src/3rdparty/freetype/src/raster/ftrend1.c
+++ b/src/3rdparty/freetype/src/raster/ftrend1.c
@@ -4,7 +4,7 @@
/* */
/* The FreeType glyph rasterizer interface (body). */
/* */
-/* Copyright 1996-2015 by */
+/* Copyright 1996-2018 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -31,12 +31,7 @@
static FT_Error
ft_raster1_init( FT_Renderer render )
{
- FT_Library library = FT_MODULE_LIBRARY( render );
-
-
- render->clazz->raster_class->raster_reset( render->raster,
- library->raster_pool,
- library->raster_pool_size );
+ render->clazz->raster_class->raster_reset( render->raster, NULL, 0 );
return FT_Err_Ok;
}
@@ -88,7 +83,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 );
@@ -102,12 +97,12 @@
FT_Render_Mode mode,
const FT_Vector* origin )
{
- FT_Error error;
- FT_Outline* outline;
- FT_BBox cbox, cbox0;
- FT_UInt width, height, pitch;
- FT_Bitmap* bitmap;
- FT_Memory memory;
+ FT_Error error = FT_Err_Ok;
+ FT_Outline* outline = &slot->outline;
+ FT_Bitmap* bitmap = &slot->bitmap;
+ FT_Memory memory = render->root.memory;
+ FT_Pos x_shift = 0;
+ FT_Pos y_shift = 0;
FT_Raster_Params params;
@@ -126,60 +121,6 @@
return FT_THROW( Cannot_Render_Glyph );
}
- outline = &slot->outline;
-
- /* translate the outline to the new origin if needed */
- if ( origin )
- FT_Outline_Translate( outline, origin->x, origin->y );
-
- /* compute the control box, and grid fit it */
- FT_Outline_Get_CBox( outline, &cbox0 );
-
- /* undocumented but confirmed: bbox values get rounded */
-#if 1
- cbox.xMin = FT_PIX_ROUND( cbox0.xMin );
- cbox.yMin = FT_PIX_ROUND( cbox0.yMin );
- cbox.xMax = FT_PIX_ROUND( cbox0.xMax );
- cbox.yMax = FT_PIX_ROUND( cbox0.yMax );
-#else
- cbox.xMin = FT_PIX_FLOOR( cbox.xMin );
- cbox.yMin = FT_PIX_FLOOR( cbox.yMin );
- cbox.xMax = FT_PIX_CEIL( cbox.xMax );
- cbox.yMax = FT_PIX_CEIL( cbox.yMax );
-#endif
-
- /* If either `width' or `height' round to 0, try */
- /* explicitly rounding up/down. In the case of */
- /* glyphs containing only one very narrow feature, */
- /* this gives the drop-out compensation in the scan */
- /* conversion code a chance to do its stuff. */
- width = (FT_UInt)( ( cbox.xMax - cbox.xMin ) >> 6 );
- if ( width == 0 )
- {
- cbox.xMin = FT_PIX_FLOOR( cbox0.xMin );
- cbox.xMax = FT_PIX_CEIL( cbox0.xMax );
-
- width = (FT_UInt)( ( cbox.xMax - cbox.xMin ) >> 6 );
- }
-
- height = (FT_UInt)( ( cbox.yMax - cbox.yMin ) >> 6 );
- if ( height == 0 )
- {
- cbox.yMin = FT_PIX_FLOOR( cbox0.yMin );
- cbox.yMax = FT_PIX_CEIL( cbox0.yMax );
-
- height = (FT_UInt)( ( cbox.yMax - cbox.yMin ) >> 6 );
- }
-
- if ( width > FT_USHORT_MAX || height > FT_USHORT_MAX )
- {
- error = FT_THROW( Invalid_Argument );
- goto Exit;
- }
-
- bitmap = &slot->bitmap;
- memory = render->root.memory;
-
/* release old bitmap buffer */
if ( slot->internal->flags & FT_GLYPH_OWN_BITMAP )
{
@@ -187,44 +128,54 @@
slot->internal->flags &= ~FT_GLYPH_OWN_BITMAP;
}
- pitch = ( ( width + 15 ) >> 4 ) << 1;
- bitmap->pixel_mode = FT_PIXEL_MODE_MONO;
+ ft_glyphslot_preset_bitmap( slot, mode, origin );
- bitmap->width = width;
- bitmap->rows = height;
- bitmap->pitch = (int)pitch;
-
- if ( FT_ALLOC_MULT( bitmap->buffer, pitch, height ) )
+ /* allocate new one */
+ if ( FT_ALLOC_MULT( bitmap->buffer, bitmap->rows, bitmap->pitch ) )
goto Exit;
slot->internal->flags |= FT_GLYPH_OWN_BITMAP;
+ x_shift = -slot->bitmap_left * 64;
+ y_shift = ( (FT_Int)bitmap->rows - slot->bitmap_top ) * 64;
+
+ if ( origin )
+ {
+ x_shift += origin->x;
+ y_shift += origin->y;
+ }
+
/* translate outline to render it into the bitmap */
- FT_Outline_Translate( outline, -cbox.xMin, -cbox.yMin );
+ if ( x_shift || y_shift )
+ FT_Outline_Translate( outline, x_shift, y_shift );
/* set up parameters */
params.target = bitmap;
params.source = outline;
- params.flags = 0;
+ params.flags = FT_RASTER_FLAG_DEFAULT;
/* render outline into the bitmap */
error = render->raster_render( render->raster, &params );
- FT_Outline_Translate( outline, cbox.xMin, cbox.yMin );
-
- if ( error )
- goto Exit;
+ Exit:
+ if ( !error )
+ /* everything is fine; the glyph is now officially a bitmap */
+ slot->format = FT_GLYPH_FORMAT_BITMAP;
+ else if ( slot->internal->flags & FT_GLYPH_OWN_BITMAP )
+ {
+ FT_FREE( bitmap->buffer );
+ slot->internal->flags &= ~FT_GLYPH_OWN_BITMAP;
+ }
- slot->format = FT_GLYPH_FORMAT_BITMAP;
- slot->bitmap_left = (FT_Int)( cbox.xMin >> 6 );
- slot->bitmap_top = (FT_Int)( cbox.yMax >> 6 );
+ if ( x_shift || y_shift )
+ FT_Outline_Translate( outline, -x_shift, -y_shift );
- Exit:
return error;
}
- FT_DEFINE_RENDERER( ft_raster1_renderer_class,
+ FT_DEFINE_RENDERER(
+ ft_raster1_renderer_class,
FT_MODULE_RENDERER,
sizeof ( FT_RendererRec ),
@@ -233,21 +184,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/src/3rdparty/freetype/src/raster/ftrend1.h b/src/3rdparty/freetype/src/raster/ftrend1.h
index edc5d13f4c..2abdf2d703 100644
--- a/src/3rdparty/freetype/src/raster/ftrend1.h
+++ b/src/3rdparty/freetype/src/raster/ftrend1.h
@@ -4,7 +4,7 @@
/* */
/* The FreeType glyph rasterizer interface (specification). */
/* */
-/* Copyright 1996-2015 by */
+/* Copyright 1996-2018 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -16,8 +16,8 @@
/***************************************************************************/
-#ifndef __FTREND1_H__
-#define __FTREND1_H__
+#ifndef FTREND1_H_
+#define FTREND1_H_
#include <ft2build.h>
@@ -32,7 +32,7 @@ FT_BEGIN_HEADER
FT_END_HEADER
-#endif /* __FTREND1_H__ */
+#endif /* FTREND1_H_ */
/* END */
diff --git a/src/3rdparty/freetype/src/raster/module.mk b/src/3rdparty/freetype/src/raster/module.mk
index 75ea107530..b115f416b2 100644
--- a/src/3rdparty/freetype/src/raster/module.mk
+++ b/src/3rdparty/freetype/src/raster/module.mk
@@ -3,7 +3,7 @@
#
-# Copyright 1996-2015 by
+# Copyright 1996-2018 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/src/3rdparty/freetype/src/raster/raster.c b/src/3rdparty/freetype/src/raster/raster.c
index 21bb16de1e..76edd21e1e 100644
--- a/src/3rdparty/freetype/src/raster/raster.c
+++ b/src/3rdparty/freetype/src/raster/raster.c
@@ -4,7 +4,7 @@
/* */
/* FreeType monochrome rasterer module component (body only). */
/* */
-/* Copyright 1996-2015 by */
+/* Copyright 1996-2018 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/src/3rdparty/freetype/src/raster/rasterrs.h b/src/3rdparty/freetype/src/raster/rasterrs.h
index e7f00bcace..22a3e15340 100644
--- a/src/3rdparty/freetype/src/raster/rasterrs.h
+++ b/src/3rdparty/freetype/src/raster/rasterrs.h
@@ -4,7 +4,7 @@
/* */
/* monochrome renderer error codes (specification only). */
/* */
-/* Copyright 2001-2015 by */
+/* Copyright 2001-2018 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -23,12 +23,12 @@
/* */
/*************************************************************************/
-#ifndef __RASTERRS_H__
-#define __RASTERRS_H__
+#ifndef RASTERRS_H_
+#define RASTERRS_H_
#include FT_MODULE_ERRORS_H
-#undef __FTERRORS_H__
+#undef FTERRORS_H_
#undef FT_ERR_PREFIX
#define FT_ERR_PREFIX Raster_Err_
@@ -36,7 +36,7 @@
#include FT_ERRORS_H
-#endif /* __RASTERRS_H__ */
+#endif /* RASTERRS_H_ */
/* END */
diff --git a/src/3rdparty/freetype/src/raster/rastpic.c b/src/3rdparty/freetype/src/raster/rastpic.c
index 77e7ec3f90..1dc8981b8a 100644
--- a/src/3rdparty/freetype/src/raster/rastpic.c
+++ b/src/3rdparty/freetype/src/raster/rastpic.c
@@ -4,7 +4,7 @@
/* */
/* The FreeType position independent code services for raster module. */
/* */
-/* Copyright 2009-2015 by */
+/* Copyright 2009-2018 by */
/* Oran Agra and Mickey Gabel. */
/* */
/* This file is part of the FreeType project, and may only be used, */
diff --git a/src/3rdparty/freetype/src/raster/rastpic.h b/src/3rdparty/freetype/src/raster/rastpic.h
index 408996a908..6d0877c423 100644
--- a/src/3rdparty/freetype/src/raster/rastpic.h
+++ b/src/3rdparty/freetype/src/raster/rastpic.h
@@ -4,7 +4,7 @@
/* */
/* The FreeType position independent code services for raster module. */
/* */
-/* Copyright 2009-2015 by */
+/* Copyright 2009-2018 by */
/* Oran Agra and Mickey Gabel. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -16,8 +16,8 @@
/***************************************************************************/
-#ifndef __RASTPIC_H__
-#define __RASTPIC_H__
+#ifndef RASTPIC_H_
+#define RASTPIC_H_
#include FT_INTERNAL_PIC_H
@@ -57,7 +57,7 @@ FT_BEGIN_HEADER
FT_END_HEADER
-#endif /* __RASTPIC_H__ */
+#endif /* RASTPIC_H_ */
/* END */
diff --git a/src/3rdparty/freetype/src/raster/rules.mk b/src/3rdparty/freetype/src/raster/rules.mk
index c214b35d37..9aef1f0bab 100644
--- a/src/3rdparty/freetype/src/raster/rules.mk
+++ b/src/3rdparty/freetype/src/raster/rules.mk
@@ -3,7 +3,7 @@
#
-# Copyright 1996-2015 by
+# Copyright 1996-2018 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/src/3rdparty/freetype/src/sfnt/Jamfile b/src/3rdparty/freetype/src/sfnt/Jamfile
index cc98d1011e..57977fc966 100644
--- a/src/3rdparty/freetype/src/sfnt/Jamfile
+++ b/src/3rdparty/freetype/src/sfnt/Jamfile
@@ -1,6 +1,6 @@
# FreeType 2 src/sfnt Jamfile
#
-# Copyright 2001-2015 by
+# Copyright 2001-2018 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/src/3rdparty/freetype/src/sfnt/module.mk b/src/3rdparty/freetype/src/sfnt/module.mk
index 535fe22afd..51ca67e784 100644
--- a/src/3rdparty/freetype/src/sfnt/module.mk
+++ b/src/3rdparty/freetype/src/sfnt/module.mk
@@ -3,7 +3,7 @@
#
-# Copyright 1996-2015 by
+# Copyright 1996-2018 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/src/3rdparty/freetype/src/sfnt/pngshim.c b/src/3rdparty/freetype/src/sfnt/pngshim.c
index ea60452635..cd110776c8 100644
--- a/src/3rdparty/freetype/src/sfnt/pngshim.c
+++ b/src/3rdparty/freetype/src/sfnt/pngshim.c
@@ -4,7 +4,7 @@
/* */
/* PNG Bitmap glyph support. */
/* */
-/* Copyright 2013-2015 by */
+/* Copyright 2013-2018 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"
@@ -48,18 +49,86 @@
}
- /* Premultiplies data and converts RGBA bytes => native endian. */
+ /* Premultiplies data and converts RGBA bytes => BGRA. */
static void
premultiply_data( png_structp png,
png_row_infop row_info,
png_bytep data )
{
- unsigned int i;
+ unsigned int i = 0, limit;
+
+ /* The `vector_size' attribute was introduced in gcc 3.1, which */
+ /* predates clang; the `__BYTE_ORDER__' preprocessor symbol was */
+ /* introduced in gcc 4.6 and clang 3.2, respectively. */
+ /* `__builtin_shuffle' for gcc was introduced in gcc 4.7.0. */
+#if ( ( defined( __GNUC__ ) && \
+ ( ( __GNUC__ >= 5 ) || \
+ ( ( __GNUC__ == 4 ) && ( __GNUC_MINOR__ >= 7 ) ) ) ) || \
+ ( defined( __clang__ ) && \
+ ( ( __clang_major__ >= 4 ) || \
+ ( ( __clang_major__ == 3 ) && ( __clang_minor__ >= 2 ) ) ) ) ) && \
+ defined( __OPTIMIZE__ ) && \
+ !defined( __EMSCRIPTEN__ ) && \
+ __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
+
+#ifdef __clang__
+ /* the clang documentation doesn't cover the two-argument case of */
+ /* `__builtin_shufflevector'; however, it is is implemented since */
+ /* version 2.8 */
+#define vector_shuffle __builtin_shufflevector
+#else
+#define vector_shuffle __builtin_shuffle
+#endif
- FT_UNUSED( png );
+ typedef unsigned short v82 __attribute__(( vector_size( 16 ) ));
- for ( i = 0; i < row_info->rowbytes; i += 4 )
+ if ( row_info->rowbytes > 15 )
+ {
+ /* process blocks of 16 bytes in one rush, which gives a nice speed-up */
+ limit = row_info->rowbytes - 16 + 1;
+ for ( ; i < limit; i += 16 )
+ {
+ unsigned char* base = &data[i];
+
+ v82 s, s0, s1, a;
+
+ /* clang <= 3.9 can't apply scalar values to vectors */
+ /* (or rather, it needs a different syntax) */
+ v82 n0x80 = { 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 };
+ v82 n0xFF = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
+ v82 n8 = { 8, 8, 8, 8, 8, 8, 8, 8 };
+
+ v82 ma = { 1, 1, 3, 3, 5, 5, 7, 7 };
+ v82 o1 = { 0, 0xFF, 0, 0xFF, 0, 0xFF, 0, 0xFF };
+ v82 m0 = { 1, 0, 3, 2, 5, 4, 7, 6 };
+
+
+ ft_memcpy( &s, base, 16 ); /* RGBA RGBA RGBA RGBA */
+ s0 = s & n0xFF; /* R B R B R B R B */
+ s1 = s >> n8; /* G A G A G A G A */
+
+ a = vector_shuffle( s1, ma ); /* A A A A A A A A */
+ s1 |= o1; /* G 1 G 1 G 1 G 1 */
+ s0 = vector_shuffle( s0, m0 ); /* B R B R B R B R */
+
+ s0 *= a;
+ s1 *= a;
+ s0 += n0x80;
+ s1 += n0x80;
+ s0 = ( s0 + ( s0 >> n8 ) ) >> n8;
+ s1 = ( s1 + ( s1 >> n8 ) ) >> n8;
+
+ s = s0 | ( s1 << n8 );
+ ft_memcpy( base, &s, 16 );
+ }
+ }
+#endif /* use `vector_size' */
+
+ FT_UNUSED( png );
+
+ limit = row_info->rowbytes;
+ for ( ; i < limit; i += 4 )
{
unsigned char* base = &data[i];
unsigned int alpha = base[3];
@@ -169,7 +238,7 @@
return;
}
- memcpy( data, stream->cursor, length );
+ ft_memcpy( data, stream->cursor, length );
FT_FRAME_EXIT();
}
@@ -184,7 +253,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 +328,6 @@
if ( populate_map_and_metrics )
{
- FT_ULong size;
-
-
metrics->width = (FT_UShort)imgWidth;
metrics->height = (FT_UShort)imgHeight;
@@ -276,13 +343,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 +394,9 @@
goto DestroyExit;
}
+ if ( metrics_only )
+ goto DestroyExit;
+
switch ( color_type )
{
default:
@@ -349,6 +412,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 +446,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/src/3rdparty/freetype/src/sfnt/pngshim.h b/src/3rdparty/freetype/src/sfnt/pngshim.h
index 4cc5c2b3a0..194238c3a2 100644
--- a/src/3rdparty/freetype/src/sfnt/pngshim.h
+++ b/src/3rdparty/freetype/src/sfnt/pngshim.h
@@ -4,7 +4,7 @@
/* */
/* PNG Bitmap glyph support. */
/* */
-/* Copyright 2013-2015 by */
+/* Copyright 2013-2018 by */
/* Google, Inc. */
/* Written by Stuart Gill and Behdad Esfahbod. */
/* */
@@ -17,8 +17,8 @@
/***************************************************************************/
-#ifndef __PNGSHIM_H__
-#define __PNGSHIM_H__
+#ifndef PNGSHIM_H_
+#define PNGSHIM_H_
#include <ft2build.h>
@@ -38,13 +38,14 @@ 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
FT_END_HEADER
-#endif /* __PNGSHIM_H__ */
+#endif /* PNGSHIM_H_ */
/* END */
diff --git a/src/3rdparty/freetype/src/sfnt/rules.mk b/src/3rdparty/freetype/src/sfnt/rules.mk
index 3cc76b3f7a..83acc66a8f 100644
--- a/src/3rdparty/freetype/src/sfnt/rules.mk
+++ b/src/3rdparty/freetype/src/sfnt/rules.mk
@@ -3,7 +3,7 @@
#
-# Copyright 1996-2015 by
+# Copyright 1996-2018 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/src/3rdparty/freetype/src/sfnt/sfdriver.c b/src/3rdparty/freetype/src/sfnt/sfdriver.c
index 6a3f0d9933..303e1ca9f1 100644
--- a/src/3rdparty/freetype/src/sfnt/sfdriver.c
+++ b/src/3rdparty/freetype/src/sfnt/sfdriver.c
@@ -4,7 +4,7 @@
/* */
/* High-level SFNT driver interface (body). */
/* */
-/* Copyright 1996-2015 by */
+/* Copyright 1996-2018 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,
- (FT_SFNT_TableGetFunc) get_sfnt_table,
- (FT_SFNT_TableInfoFunc)sfnt_table_info )
+
+ (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 */
+ )
#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,
- (FT_GlyphDict_NameIndexFunc)sfnt_get_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,850 @@
*
*/
- 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;
- for ( n = 0; n < face->num_names; n++ )
+ 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++ )
{
- TT_NameEntryRec* name = face->name_table.names + n;
+ 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;
+ }
+ {
+ 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 );
+
+ return NULL;
+ }
+
+ r = (FT_String*)result;
+ p = (FT_Char*)stream->cursor;
- if ( FT_STREAM_SEEK( name->stringOffset ) ||
- FT_FRAME_ENTER( name->stringLength ) )
+ 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;
+
+
+ p = buf;
- goto Exit;
+ 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 ) ) &&
+ !FT_IS_VARIATION( 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 &&
+ ( FT_IS_NAMED_INSTANCE( FT_FACE( face ) ) ||
+ FT_IS_VARIATION( FT_FACE( face ) ) ) )
+ {
+ 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 )
+
+ (FT_PsName_GetFunc)sfnt_get_ps_name /* get_ps_font_name */
+ )
/*
@@ -338,7 +1077,9 @@
*/
FT_DEFINE_SERVICE_TTCMAPSREC(
tt_service_get_cmap_info,
- (TT_CMap_Info_GetFunc)tt_get_cmap_info )
+
+ (TT_CMap_Info_GetFunc)tt_get_cmap_info /* get_cmap_info */
+ )
#ifdef TT_CONFIG_OPTION_BDF
@@ -381,8 +1122,10 @@
FT_DEFINE_SERVICE_BDFRec(
sfnt_service_bdf,
- (FT_BDF_GetCharsetIdFunc)sfnt_get_charset_id,
- (FT_BDF_GetPropertyFunc) tt_face_find_bdf_prop )
+
+ (FT_BDF_GetCharsetIdFunc)sfnt_get_charset_id, /* get_charset_id */
+ (FT_BDF_GetPropertyFunc) tt_face_find_bdf_prop /* get_property */
+ )
#endif /* TT_CONFIG_OPTION_BDF */
@@ -395,6 +1138,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 +1147,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 +1155,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 +1163,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 +1206,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 +1279,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/src/3rdparty/freetype/src/sfnt/sfdriver.h b/src/3rdparty/freetype/src/sfnt/sfdriver.h
index 944119cc22..81c22d2887 100644
--- a/src/3rdparty/freetype/src/sfnt/sfdriver.h
+++ b/src/3rdparty/freetype/src/sfnt/sfdriver.h
@@ -4,7 +4,7 @@
/* */
/* High-level SFNT driver interface (specification). */
/* */
-/* Copyright 1996-2015 by */
+/* Copyright 1996-2018 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -16,8 +16,8 @@
/***************************************************************************/
-#ifndef __SFDRIVER_H__
-#define __SFDRIVER_H__
+#ifndef SFDRIVER_H_
+#define SFDRIVER_H_
#include <ft2build.h>
@@ -32,7 +32,7 @@ FT_BEGIN_HEADER
FT_END_HEADER
-#endif /* __SFDRIVER_H__ */
+#endif /* SFDRIVER_H_ */
/* END */
diff --git a/src/3rdparty/freetype/src/sfnt/sferrors.h b/src/3rdparty/freetype/src/sfnt/sferrors.h
index e3bef3f743..74003d4b38 100644
--- a/src/3rdparty/freetype/src/sfnt/sferrors.h
+++ b/src/3rdparty/freetype/src/sfnt/sferrors.h
@@ -4,7 +4,7 @@
/* */
/* SFNT error codes (specification only). */
/* */
-/* Copyright 2001-2015 by */
+/* Copyright 2001-2018 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -22,12 +22,12 @@
/* */
/*************************************************************************/
-#ifndef __SFERRORS_H__
-#define __SFERRORS_H__
+#ifndef SFERRORS_H_
+#define SFERRORS_H_
#include FT_MODULE_ERRORS_H
-#undef __FTERRORS_H__
+#undef FTERRORS_H_
#undef FT_ERR_PREFIX
#define FT_ERR_PREFIX SFNT_Err_
@@ -35,6 +35,7 @@
#include FT_ERRORS_H
-#endif /* __SFERRORS_H__ */
+#endif /* SFERRORS_H_ */
+
/* END */
diff --git a/src/3rdparty/freetype/src/sfnt/sfnt.c b/src/3rdparty/freetype/src/sfnt/sfnt.c
index 0b8b5f4578..8b9a6b345d 100644
--- a/src/3rdparty/freetype/src/sfnt/sfnt.c
+++ b/src/3rdparty/freetype/src/sfnt/sfnt.c
@@ -4,7 +4,7 @@
/* */
/* Single object library component. */
/* */
-/* Copyright 1996-2015 by */
+/* Copyright 1996-2018 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/src/3rdparty/freetype/src/sfnt/sfntpic.c b/src/3rdparty/freetype/src/sfnt/sfntpic.c
index 2aaf4bcc40..db2d816ce6 100644
--- a/src/3rdparty/freetype/src/sfnt/sfntpic.c
+++ b/src/3rdparty/freetype/src/sfnt/sfntpic.c
@@ -4,7 +4,7 @@
/* */
/* The FreeType position independent code services for sfnt module. */
/* */
-/* Copyright 2009-2015 by */
+/* Copyright 2009-2018 by */
/* Oran Agra and Mickey Gabel. */
/* */
/* This file is part of the FreeType project, and may only be used, */
diff --git a/src/3rdparty/freetype/src/sfnt/sfntpic.h b/src/3rdparty/freetype/src/sfnt/sfntpic.h
index d99be6a824..8f43122d81 100644
--- a/src/3rdparty/freetype/src/sfnt/sfntpic.h
+++ b/src/3rdparty/freetype/src/sfnt/sfntpic.h
@@ -4,7 +4,7 @@
/* */
/* The FreeType position independent code services for sfnt module. */
/* */
-/* Copyright 2009-2015 by */
+/* Copyright 2009-2018 by */
/* Oran Agra and Mickey Gabel. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -16,8 +16,8 @@
/***************************************************************************/
-#ifndef __SFNTPIC_H__
-#define __SFNTPIC_H__
+#ifndef SFNTPIC_H_
+#define SFNTPIC_H_
#include FT_INTERNAL_PIC_H
@@ -106,7 +106,7 @@ FT_END_HEADER
/* */
-#endif /* __SFNTPIC_H__ */
+#endif /* SFNTPIC_H_ */
/* END */
diff --git a/src/3rdparty/freetype/src/sfnt/sfobjs.c b/src/3rdparty/freetype/src/sfnt/sfobjs.c
index 14d3adef21..6ba8509f56 100644
--- a/src/3rdparty/freetype/src/sfnt/sfobjs.c
+++ b/src/3rdparty/freetype/src/sfnt/sfobjs.c
@@ -4,7 +4,7 @@
/* */
/* SFNT object management (base). */
/* */
-/* Copyright 1996-2015 by */
+/* Copyright 1996-2018 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_Bool is_english = 0;
+ 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;
- TT_NameEntry_ConvertFunc convert;
+ FT_Bool is_english = 0;
+
+ 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 }
@@ -451,10 +458,14 @@
woff.metaOrigLength != 0 ) ) ||
( woff.metaLength != 0 && woff.metaOrigLength == 0 ) ||
( woff.privOffset == 0 && woff.privLength != 0 ) )
+ {
+ FT_ERROR(( "woff_font_open: invalid WOFF header\n" ));
return FT_THROW( Invalid_Table );
+ }
- if ( FT_ALLOC( sfnt, woff.totalSfntSize ) ||
- FT_NEW( sfnt_stream ) )
+ /* Don't trust `totalSfntSize' before thorough checks. */
+ if ( FT_ALLOC( sfnt, 12 + woff.num_tables * 16UL ) ||
+ FT_NEW( sfnt_stream ) )
goto Exit;
sfnt_header = sfnt;
@@ -521,6 +532,8 @@
if ( table->Tag <= old_tag )
{
FT_FRAME_EXIT();
+
+ FT_ERROR(( "woff_font_open: table tags are not sorted\n" ));
error = FT_THROW( Invalid_Table );
goto Exit;
}
@@ -555,6 +568,7 @@
sfnt_offset > woff.totalSfntSize - table->OrigLength ||
table->CompLength > table->OrigLength )
{
+ FT_ERROR(( "woff_font_open: invalid table offsets\n" ));
error = FT_THROW( Invalid_Table );
goto Exit;
}
@@ -580,6 +594,8 @@
if ( woff.metaOffset != woff_offset ||
woff.metaOffset + woff.metaLength > woff.length )
{
+ FT_ERROR(( "woff_font_open:"
+ " invalid `metadata' offset or length\n" ));
error = FT_THROW( Invalid_Table );
goto Exit;
}
@@ -596,6 +612,7 @@
if ( woff.privOffset != woff_offset ||
woff.privOffset + woff.privLength > woff.length )
{
+ FT_ERROR(( "woff_font_open: invalid `private' offset or length\n" ));
error = FT_THROW( Invalid_Table );
goto Exit;
}
@@ -607,10 +624,19 @@
if ( sfnt_offset != woff.totalSfntSize ||
woff_offset != woff.length )
{
+ FT_ERROR(( "woff_font_open: invalid `sfnt' table structure\n" ));
error = FT_THROW( Invalid_Table );
goto Exit;
}
+ /* Now use `totalSfntSize'. */
+ if ( FT_REALLOC( sfnt,
+ 12 + woff.num_tables * 16UL,
+ woff.totalSfntSize ) )
+ goto Exit;
+
+ sfnt_header = sfnt + 12;
+
/* Write the tables. */
for ( nn = 0; nn < woff.num_tables; nn++ )
@@ -651,6 +677,7 @@
goto Exit;
if ( output_len != table->OrigLength )
{
+ FT_ERROR(( "woff_font_open: compressed table length mismatch\n" ));
error = FT_THROW( Invalid_Table );
goto Exit;
}
@@ -760,6 +787,8 @@
tag != TTAG_OTTO &&
tag != TTAG_true &&
tag != TTAG_typ1 &&
+ tag != TTAG_0xA5kbd &&
+ tag != TTAG_0xA5lst &&
tag != 0x00020000UL )
{
FT_TRACE2(( " not a font using the SFNT container format\n" ));
@@ -778,6 +807,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 );
@@ -852,6 +884,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 );
@@ -861,10 +918,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 )
@@ -883,9 +944,22 @@
#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
{
- FT_ULong fvar_len;
+ FT_Memory memory = face->root.memory;
+
+ FT_ULong fvar_len;
+
+ FT_ULong version;
+ FT_ULong offset;
+
+ FT_UShort num_axes;
+ FT_UShort axis_size;
FT_UShort num_instances;
- FT_Int instance_index;
+ FT_UShort instance_size;
+
+ FT_Int instance_index;
+
+ FT_Byte* default_values = NULL;
+ FT_Byte* instance_values = NULL;
instance_index = FT_ABS( face_instance_index ) >> 16;
@@ -893,19 +967,106 @@
/* test whether current face is a GX font with named instances */
if ( face->goto_table( face, TTAG_fvar, stream, &fvar_len ) ||
fvar_len < 20 ||
- FT_STREAM_SKIP( 12 ) ||
- FT_READ_USHORT( num_instances ) )
+ FT_READ_ULONG( version ) ||
+ FT_READ_USHORT( offset ) ||
+ FT_STREAM_SKIP( 2 ) /* reserved */ ||
+ FT_READ_USHORT( num_axes ) ||
+ FT_READ_USHORT( axis_size ) ||
+ FT_READ_USHORT( num_instances ) ||
+ FT_READ_USHORT( instance_size ) )
+ {
+ version = 0;
+ offset = 0;
+ num_axes = 0;
+ axis_size = 0;
num_instances = 0;
+ instance_size = 0;
+ }
+
+ /* 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 == 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 support at most 2^15 - 1 instances */
- if ( num_instances >= ( 1U << 15 ) - 1 )
+ /*
+ * 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.
+ */
+
+ 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 )
@@ -921,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;
}
@@ -983,8 +1144,10 @@
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 has_CBLC;
+ FT_Bool has_CBDT;
+ FT_Bool ignore_typographic_family = FALSE;
+ FT_Bool ignore_typographic_subfamily = FALSE;
SFNT_Service sfnt = (SFNT_Service)face->sfnt;
@@ -999,10 +1162,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;
}
}
@@ -1027,12 +1190,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;
@@ -1061,7 +1226,17 @@
goto Exit;
}
- if ( face->header.Units_Per_EM == 0 )
+ has_CBLC = !face->goto_table( face, TTAG_CBLC, stream, 0 );
+ has_CBDT = !face->goto_table( face, TTAG_CBDT, stream, 0 );
+
+ /* Ignore outlines for CBLC/CBDT fonts. */
+ if ( has_CBLC || has_CBDT )
+ has_outline = FALSE;
+
+ /* OpenType 1.8.2 introduced limits to this value; */
+ /* however, they make sense for older SFNT fonts also */
+ if ( face->header.Units_Per_EM < 16 ||
+ face->header.Units_Per_EM > 16384 )
{
error = FT_THROW( Invalid_Table );
@@ -1164,30 +1339,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 );
@@ -1203,27 +1358,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 );
}
@@ -1271,10 +1426,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;
@@ -1317,7 +1476,8 @@
/* Polish the charmaps. */
/* */
/* Try to set the charmap encoding according to the platform & */
- /* encoding ID of each charmap. */
+ /* encoding ID of each charmap. Emulate Unicode charmap if one */
+ /* is missing. */
/* */
tt_face_build_cmaps( face ); /* ignore errors */
@@ -1325,7 +1485,10 @@
/* set the encoding fields */
{
- FT_Int m;
+ FT_Int m;
+#ifdef FT_CONFIG_OPTION_POSTSCRIPT_NAMES
+ FT_Bool has_unicode = FALSE;
+#endif
for ( m = 0; m < root->num_charmaps; m++ )
@@ -1336,14 +1499,34 @@
charmap->encoding = sfnt_find_encoding( charmap->platform_id,
charmap->encoding_id );
-#if 0
- if ( root->charmap == NULL &&
- charmap->encoding == FT_ENCODING_UNICODE )
- {
- /* set 'root->charmap' to the first Unicode encoding we find */
- root->charmap = charmap;
- }
-#endif
+#ifdef FT_CONFIG_OPTION_POSTSCRIPT_NAMES
+
+ if ( charmap->encoding == FT_ENCODING_UNICODE ||
+ charmap->encoding == FT_ENCODING_MS_SYMBOL ) /* PUA */
+ has_unicode = TRUE;
+ }
+
+ /* synthesize Unicode charmap if one is missing */
+ if ( !has_unicode )
+ {
+ FT_CharMapRec cmaprec;
+
+
+ cmaprec.face = root;
+ cmaprec.platform_id = TT_PLATFORM_MICROSOFT;
+ cmaprec.encoding_id = TT_MS_ID_UNICODE_CS;
+ cmaprec.encoding = FT_ENCODING_UNICODE;
+
+
+ error = FT_CMap_New( (FT_CMap_Class)&tt_cmap_unicode_class_rec,
+ NULL, &cmaprec, NULL );
+ if ( error &&
+ FT_ERR_NEQ( error, No_Unicode_Glyph_Name ) )
+ goto Exit;
+ error = FT_Err_Ok;
+
+#endif /* FT_CONFIG_OPTION_POSTSCRIPT_NAMES */
+
}
}
@@ -1355,7 +1538,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;
@@ -1367,6 +1550,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 )
{
@@ -1374,31 +1560,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;
+ }
}
}
@@ -1488,9 +1693,9 @@
(FT_Short)( face->vertical_info ? face->vertical.advance_Height_Max
: root->height );
- /* See http://www.microsoft.com/OpenType/OTSpec/post.htm -- */
- /* Adjust underline position from top edge to centre of */
- /* stroke to convert TrueType meaning to FreeType meaning. */
+ /* See https://www.microsoft.com/typography/otspec/post.htm -- */
+ /* Adjust underline position from top edge to centre of */
+ /* stroke to convert TrueType meaning to FreeType meaning. */
root->underline_position = face->postscript.underlinePosition -
face->postscript.underlineThickness / 2;
root->underline_thickness = face->postscript.underlineThickness;
@@ -1559,18 +1764,10 @@
face->cmap_size = 0;
}
- /* freeing the horizontal metrics */
- {
- FT_Stream stream = FT_FACE_STREAM( face );
-
-
- FT_FRAME_RELEASE( face->horz_metrics );
- FT_FRAME_RELEASE( face->vert_metrics );
- face->horz_metrics_size = 0;
- face->vert_metrics_size = 0;
- }
+ 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 );
@@ -1592,9 +1789,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/src/3rdparty/freetype/src/sfnt/sfobjs.h b/src/3rdparty/freetype/src/sfnt/sfobjs.h
index 455f86772f..1b8d1be5b1 100644
--- a/src/3rdparty/freetype/src/sfnt/sfobjs.h
+++ b/src/3rdparty/freetype/src/sfnt/sfobjs.h
@@ -4,7 +4,7 @@
/* */
/* SFNT object management (specification). */
/* */
-/* Copyright 1996-2015 by */
+/* Copyright 1996-2018 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -16,8 +16,8 @@
/***************************************************************************/
-#ifndef __SFOBJS_H__
-#define __SFOBJS_H__
+#ifndef SFOBJS_H_
+#define SFOBJS_H_
#include <ft2build.h>
@@ -53,7 +53,7 @@ FT_BEGIN_HEADER
FT_END_HEADER
-#endif /* __SFDRIVER_H__ */
+#endif /* SFDRIVER_H_ */
/* END */
diff --git a/src/3rdparty/freetype/src/sfnt/ttbdf.c b/src/3rdparty/freetype/src/sfnt/ttbdf.c
index 098b781a14..534201f229 100644
--- a/src/3rdparty/freetype/src/sfnt/ttbdf.c
+++ b/src/3rdparty/freetype/src/sfnt/ttbdf.c
@@ -4,7 +4,7 @@
/* */
/* TrueType and OpenType embedded BDF properties (body). */
/* */
-/* Copyright 2005-2015 by */
+/* Copyright 2005-2018 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/src/3rdparty/freetype/src/sfnt/ttbdf.h b/src/3rdparty/freetype/src/sfnt/ttbdf.h
index fe4ba489e8..809a663001 100644
--- a/src/3rdparty/freetype/src/sfnt/ttbdf.h
+++ b/src/3rdparty/freetype/src/sfnt/ttbdf.h
@@ -4,7 +4,7 @@
/* */
/* TrueType and OpenType embedded BDF properties (specification). */
/* */
-/* Copyright 2005-2015 by */
+/* Copyright 2005-2018 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -16,8 +16,8 @@
/***************************************************************************/
-#ifndef __TTBDF_H__
-#define __TTBDF_H__
+#ifndef TTBDF_H_
+#define TTBDF_H_
#include <ft2build.h>
@@ -28,6 +28,8 @@
FT_BEGIN_HEADER
+#ifdef TT_CONFIG_OPTION_BDF
+
FT_LOCAL( void )
tt_face_free_bdf_props( TT_Face face );
@@ -37,10 +39,12 @@ FT_BEGIN_HEADER
const char* property_name,
BDF_PropertyRec *aprop );
+#endif /* TT_CONFIG_OPTION_BDF */
+
FT_END_HEADER
-#endif /* __TTBDF_H__ */
+#endif /* TTBDF_H_ */
/* END */
diff --git a/src/3rdparty/freetype/src/sfnt/ttcmap.c b/src/3rdparty/freetype/src/sfnt/ttcmap.c
index c4d9abdfe6..996e66485f 100644
--- a/src/3rdparty/freetype/src/sfnt/ttcmap.c
+++ b/src/3rdparty/freetype/src/sfnt/ttcmap.c
@@ -4,7 +4,7 @@
/* */
/* TrueType character mapping table (cmap) support (body). */
/* */
-/* Copyright 2002-2015 by */
+/* Copyright 2002-2018 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -23,8 +23,10 @@
#include FT_INTERNAL_VALIDATE_H
#include FT_INTERNAL_STREAM_H
+#include FT_SERVICE_POSTSCRIPT_CMAPS_H
#include "ttload.h"
#include "ttcmap.h"
+#include "ttpost.h"
#include "sfntpic.h"
@@ -180,22 +182,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 */
@@ -218,10 +222,10 @@
/***** The following charmap lookup and iteration functions all *****/
/***** assume that the value `charcode' fulfills the following. *****/
/***** *****/
- /***** - For one byte characters, `charcode' is simply the *****/
+ /***** - For one-byte characters, `charcode' is simply the *****/
/***** character code. *****/
/***** *****/
- /***** - For two byte characters, `charcode' is the 2-byte *****/
+ /***** - For two-byte characters, `charcode' is the 2-byte *****/
/***** character code in big endian format. More precisely: *****/
/***** *****/
/***** (charcode >> 8) is the first byte value *****/
@@ -248,11 +252,11 @@
/* subs 518 SUBHEAD[NSUBS] sub-headers array */
/* glyph_ids 518+NSUB*8 USHORT[] glyph ID array */
/* */
- /* The `keys' table is used to map charcode high-bytes to sub-headers. */
+ /* The `keys' table is used to map charcode high bytes to sub-headers. */
/* The value of `NSUBS' is the number of sub-headers defined in the */
/* table and is computed by finding the maximum of the `keys' table. */
/* */
- /* Note that for any n, `keys[n]' is a byte offset within the `subs' */
+ /* Note that for any `n', `keys[n]' is a byte offset within the `subs' */
/* table, i.e., it is the corresponding sub-header index multiplied */
/* by 8. */
/* */
@@ -265,8 +269,8 @@
/* delta 4 SHORT see below */
/* offset 6 USHORT see below */
/* */
- /* A sub-header defines, for each high-byte, the range of valid */
- /* low-bytes within the charmap. Note that the range defined by `first' */
+ /* A sub-header defines, for each high byte, the range of valid */
+ /* low bytes within the charmap. Note that the range defined by `first' */
/* and `count' must be completely included in the interval [0..255] */
/* according to the specification. */
/* */
@@ -356,7 +360,7 @@
/* check range within 0..255 */
if ( valid->level >= FT_VALIDATE_PARANOID )
{
- if ( first_code >= 256 || first_code + code_count > 256 )
+ if ( first_code >= 256 || code_count > 256 - first_code )
FT_INVALID_DATA;
}
@@ -408,7 +412,7 @@
{
FT_UInt char_lo = (FT_UInt)( char_code & 0xFF );
FT_UInt char_hi = (FT_UInt)( char_code >> 8 );
- FT_Byte* p = table + 6; /* keys table */
+ FT_Byte* p = table + 6; /* keys table */
FT_Byte* subs = table + 518; /* subheaders table */
FT_Byte* sub;
@@ -421,8 +425,8 @@
sub = subs; /* jump to first sub-header */
/* check that the sub-header for this byte is 0, which */
- /* indicates that it is really a valid one-byte value */
- /* Otherwise, return 0 */
+ /* indicates that it is really a valid one-byte value; */
+ /* otherwise, return 0 */
/* */
p += char_lo * 2;
if ( TT_PEEK_USHORT( p ) != 0 )
@@ -441,6 +445,7 @@
if ( sub == subs )
goto Exit;
}
+
result = sub;
}
@@ -513,8 +518,19 @@
FT_UInt pos, idx;
+ if ( char_lo >= start + count && charcode <= 0xFF )
+ {
+ /* this happens only for a malformed cmap */
+ charcode = 0x100;
+ continue;
+ }
+
if ( offset == 0 )
+ {
+ if ( charcode == 0x100 )
+ goto Exit; /* this happens only for a malformed cmap */
goto Next_SubHeader;
+ }
if ( char_lo < start )
{
@@ -541,11 +557,20 @@
}
}
}
+
+ /* if unsuccessful, avoid `charcode' leaving */
+ /* the current 256-character block */
+ if ( count )
+ charcode--;
}
- /* jump to next sub-header, i.e. higher byte value */
+ /* If `charcode' is <= 0xFF, retry with `charcode + 1'. */
+ /* Otherwise jump to the next 256-character block and retry. */
Next_SubHeader:
- charcode = FT_PAD_FLOOR( charcode, 256 ) + 256;
+ if ( charcode <= 0xFF )
+ charcode++;
+ else
+ charcode = FT_PAD_FLOOR( charcode, 0x100 ) + 0x100;
}
Exit:
@@ -571,22 +596,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 +790,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;
@@ -774,7 +804,7 @@
if ( charcode < cmap->cur_start )
charcode = cmap->cur_start;
- for ( ;; )
+ for (;;)
{
FT_Byte* values = cmap->cur_values;
FT_UInt end = cmap->cur_end;
@@ -788,15 +818,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 +846,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 +875,7 @@
}
}
+ Next_Segment:
/* we need to find another range */
if ( tt_cmap4_set_range( cmap, cmap->cur_range + 1 ) < 0 )
break;
@@ -1170,6 +1224,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 +1278,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;
@@ -1245,7 +1298,7 @@
mid = max + 1;
/* search in segments before the current segment */
- for ( i = max ; i > 0; i-- )
+ for ( i = max; i > 0; i-- )
{
FT_UInt prev_end;
FT_Byte* old_p;
@@ -1347,13 +1400,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 +1543,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 +1713,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 */
@@ -1891,7 +1976,10 @@
/* if `gindex' is invalid, the remaining values */
/* in this group are invalid, too */
if ( gindex >= (FT_UInt)face->num_glyphs )
+ {
+ gindex = 0;
continue;
+ }
result = char_code;
break;
@@ -1919,22 +2007,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 */
@@ -2089,22 +2179,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 */
@@ -2277,7 +2369,10 @@
/* if `gindex' is invalid, the remaining values */
/* in this group are invalid, too */
if ( gindex >= (FT_UInt)face->num_glyphs )
+ {
+ gindex = 0;
continue;
+ }
cmap->cur_charcode = char_code;
cmap->cur_gindex = gindex;
@@ -2440,22 +2535,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 */
@@ -2764,22 +2861,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 */
@@ -2870,7 +2969,7 @@
cmap->max_results = 0;
- if ( memory != NULL && cmap->results != NULL )
+ if ( memory && cmap->results )
FT_FREE( cmap->results );
}
@@ -2962,17 +3061,22 @@
/* through the normal Unicode cmap, no GIDs, just check order) */
if ( defOff != 0 )
{
- FT_Byte* defp = table + defOff;
- FT_ULong numRanges = TT_NEXT_ULONG( defp );
+ FT_Byte* defp = table + defOff;
+ FT_ULong numRanges;
FT_ULong i;
- FT_ULong lastBase = 0;
+ FT_ULong lastBase = 0;
+
+ if ( defp + 4 > valid->limit )
+ FT_INVALID_TOO_SHORT;
+
+ numRanges = TT_NEXT_ULONG( defp );
/* defp + numRanges * 4 > valid->limit ? */
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 );
@@ -2991,16 +3095,21 @@
/* and the non-default table (these glyphs are specified here) */
if ( nondefOff != 0 )
{
- FT_Byte* ndp = table + nondefOff;
- FT_ULong numMappings = TT_NEXT_ULONG( ndp );
- FT_ULong i, lastUni = 0;
+ FT_Byte* ndp = table + nondefOff;
+ FT_ULong numMappings;
+ FT_ULong i, lastUni = 0;
- /* numMappings * 4 > (FT_ULong)( valid->limit - ndp ) ? */
- if ( numMappings > ( (FT_ULong)( valid->limit - ndp ) ) / 4 )
+ if ( ndp + 4 > valid->limit )
FT_INVALID_TOO_SHORT;
- for ( i = 0; i < numMappings; ++i )
+ numMappings = TT_NEXT_ULONG( ndp );
+
+ /* numMappings * 5 > (FT_ULong)( valid->limit - ndp ) ? */
+ if ( numMappings > ( (FT_ULong)( valid->limit - ndp ) ) / 5 )
+ FT_INVALID_TOO_SHORT;
+
+ for ( i = 0; i < numMappings; i++ )
{
FT_ULong uni = TT_NEXT_UINT24( ndp );
FT_ULong gid = TT_NEXT_USHORT( ndp );
@@ -3088,7 +3197,7 @@
if ( char_code < start )
max = mid;
- else if ( char_code > start+cnt )
+ else if ( char_code > start + cnt )
min = mid + 1;
else
return TRUE;
@@ -3241,7 +3350,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;
@@ -3266,7 +3375,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 );
@@ -3325,7 +3434,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 );
@@ -3362,7 +3471,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;
@@ -3442,14 +3551,14 @@
ni = 1;
i = 0;
- for ( ;; )
+ for (;;)
{
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;
@@ -3463,7 +3572,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;
@@ -3482,7 +3591,7 @@
{
ret[i++] = (FT_UInt32)TT_NEXT_UINT24( p );
p += 2;
- ++ni;
+ ni++;
}
}
else if ( di <= numRanges )
@@ -3490,7 +3599,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 )
@@ -3498,9 +3607,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++;
}
}
@@ -3513,27 +3622,133 @@
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 */
+ /*************************************************************************/
+ /*************************************************************************/
+ /***** *****/
+ /***** SYNTHETIC UNICODE *****/
+ /***** *****/
+ /*************************************************************************/
+ /*************************************************************************/
+
+ /* This charmap is generated using postscript glyph names. */
+
+#ifdef FT_CONFIG_OPTION_POSTSCRIPT_NAMES
+
+ FT_CALLBACK_DEF( const char * )
+ tt_get_glyph_name( TT_Face face,
+ FT_UInt idx )
+ {
+ FT_String* PSname;
+
+
+ tt_face_get_ps_name( face, idx, &PSname );
+
+ return PSname;
+ }
+
+
+ FT_CALLBACK_DEF( FT_Error )
+ tt_cmap_unicode_init( PS_Unicodes unicodes,
+ FT_Pointer pointer )
+ {
+ TT_Face face = (TT_Face)FT_CMAP_FACE( unicodes );
+ FT_Memory memory = FT_FACE_MEMORY( face );
+ FT_Service_PsCMaps psnames = (FT_Service_PsCMaps)face->psnames;
+
+ FT_UNUSED( pointer );
+
+
+ return psnames->unicodes_init( memory,
+ unicodes,
+ face->root.num_glyphs,
+ (PS_GetGlyphNameFunc)&tt_get_glyph_name,
+ (PS_FreeGlyphNameFunc)NULL,
+ (FT_Pointer)face );
+ }
+
+
+ FT_CALLBACK_DEF( void )
+ tt_cmap_unicode_done( PS_Unicodes unicodes )
+ {
+ FT_Face face = FT_CMAP_FACE( unicodes );
+ FT_Memory memory = FT_FACE_MEMORY( face );
+
+
+ FT_FREE( unicodes->maps );
+ unicodes->num_maps = 0;
+ }
+
+
+ FT_CALLBACK_DEF( FT_UInt )
+ tt_cmap_unicode_char_index( PS_Unicodes unicodes,
+ FT_UInt32 char_code )
+ {
+ TT_Face face = (TT_Face)FT_CMAP_FACE( unicodes );
+ FT_Service_PsCMaps psnames = (FT_Service_PsCMaps)face->psnames;
+
+
+ return psnames->unicodes_char_index( unicodes, char_code );
+ }
+
+
+ FT_CALLBACK_DEF( FT_UInt32 )
+ tt_cmap_unicode_char_next( PS_Unicodes unicodes,
+ FT_UInt32 *pchar_code )
+ {
+ TT_Face face = (TT_Face)FT_CMAP_FACE( unicodes );
+ FT_Service_PsCMaps psnames = (FT_Service_PsCMaps)face->psnames;
+
+
+ return psnames->unicodes_char_next( unicodes, pchar_code );
+ }
+
+
+ FT_DEFINE_TT_CMAP(
+ tt_cmap_unicode_class_rec,
+
+ sizeof ( PS_UnicodesRec ),
+
+ (FT_CMap_InitFunc) tt_cmap_unicode_init, /* init */
+ (FT_CMap_DoneFunc) tt_cmap_unicode_done, /* done */
+ (FT_CMap_CharIndexFunc)tt_cmap_unicode_char_index, /* char_index */
+ (FT_CMap_CharNextFunc) tt_cmap_unicode_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 */
+
+ ~0U,
+ (TT_CMap_ValidateFunc)NULL, /* validate */
+ (TT_CMap_Info_GetFunc)NULL /* get_cmap_info */
+ )
+
+#endif /* FT_CONFIG_OPTION_POSTSCRIPT_NAMES */
+
#ifndef FT_CONFIG_OPTION_PIC
static const TT_CMap_Class tt_cmap_classes[] =
@@ -3668,7 +3883,7 @@
error = clazz->validate( cmap, FT_VALIDATOR( &valid ) );
}
- if ( valid.validator.error == 0 )
+ if ( !valid.validator.error )
{
FT_CMap ttcmap;
@@ -3694,7 +3909,7 @@
}
}
- if ( *pclazz == NULL )
+ if ( !*pclazz )
{
FT_TRACE0(( "tt_face_build_cmaps:"
" unsupported cmap sub-table ignored\n" ));
@@ -3713,8 +3928,10 @@
FT_CMap cmap = (FT_CMap)charmap;
TT_CMap_Class clazz = (TT_CMap_Class)cmap->clazz;
-
- return clazz->get_cmap_info( charmap, cmap_info );
+ if ( clazz->get_cmap_info )
+ return clazz->get_cmap_info( charmap, cmap_info );
+ else
+ return FT_THROW( Invalid_CharMap_Format );
}
diff --git a/src/3rdparty/freetype/src/sfnt/ttcmap.h b/src/3rdparty/freetype/src/sfnt/ttcmap.h
index b7ea8ee377..d264d99d2c 100644
--- a/src/3rdparty/freetype/src/sfnt/ttcmap.h
+++ b/src/3rdparty/freetype/src/sfnt/ttcmap.h
@@ -4,7 +4,7 @@
/* */
/* TrueType character mapping table (cmap) support (specification). */
/* */
-/* Copyright 2002-2015 by */
+/* Copyright 2002-2018 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -16,8 +16,8 @@
/***************************************************************************/
-#ifndef __TTCMAP_H__
-#define __TTCMAP_H__
+#ifndef TTCMAP_H_
+#define TTCMAP_H_
#include <ft2build.h>
@@ -141,6 +141,8 @@ FT_BEGIN_HEADER
#define TT_VALID_GLYPH_COUNT( x ) TT_VALIDATOR( x )->num_glyphs
+ FT_CALLBACK_TABLE const TT_CMap_ClassRec tt_cmap_unicode_class_rec;
+
FT_LOCAL( FT_Error )
tt_face_build_cmaps( TT_Face face );
@@ -152,7 +154,7 @@ FT_BEGIN_HEADER
FT_END_HEADER
-#endif /* __TTCMAP_H__ */
+#endif /* TTCMAP_H_ */
/* END */
diff --git a/src/3rdparty/freetype/src/sfnt/ttcmapc.h b/src/3rdparty/freetype/src/sfnt/ttcmapc.h
index 4a489402cf..4980e9dd3d 100644
--- a/src/3rdparty/freetype/src/sfnt/ttcmapc.h
+++ b/src/3rdparty/freetype/src/sfnt/ttcmapc.h
@@ -4,7 +4,7 @@
/* */
/* TT CMAP classes definitions (specification only). */
/* */
-/* Copyright 2009-2015 by */
+/* Copyright 2009-2018 by */
/* Oran Agra and Mickey Gabel. */
/* */
/* This file is part of the FreeType project, and may only be used, */
diff --git a/src/3rdparty/freetype/src/sfnt/ttkern.c b/src/3rdparty/freetype/src/sfnt/ttkern.c
index 4fccc535ce..68f15a2010 100644
--- a/src/3rdparty/freetype/src/sfnt/ttkern.c
+++ b/src/3rdparty/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-2015 by */
+/* Copyright 1996-2018 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -85,7 +85,7 @@
for ( nn = 0; nn < num_tables; nn++ )
{
- FT_UInt num_pairs, length, coverage;
+ FT_UInt num_pairs, length, coverage, format;
FT_Byte* p_next;
FT_UInt32 mask = (FT_UInt32)1UL << nn;
@@ -107,9 +107,15 @@
if ( p_next > p_limit ) /* handle broken table */
p_next = p_limit;
+ format = coverage >> 8;
+
+ /* we currently only support format 0 kerning tables */
+ if ( format != 0 )
+ goto NextTable;
+
/* 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 +220,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/src/3rdparty/freetype/src/sfnt/ttkern.h b/src/3rdparty/freetype/src/sfnt/ttkern.h
index 89cb24f07c..4e45d0964b 100644
--- a/src/3rdparty/freetype/src/sfnt/ttkern.h
+++ b/src/3rdparty/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-2015 by */
+/* Copyright 1996-2018 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -17,8 +17,8 @@
/***************************************************************************/
-#ifndef __TTKERN_H__
-#define __TTKERN_H__
+#ifndef TTKERN_H_
+#define TTKERN_H_
#include <ft2build.h>
@@ -46,7 +46,7 @@ FT_BEGIN_HEADER
FT_END_HEADER
-#endif /* __TTKERN_H__ */
+#endif /* TTKERN_H_ */
/* END */
diff --git a/src/3rdparty/freetype/src/sfnt/ttload.c b/src/3rdparty/freetype/src/sfnt/ttload.c
index c1bd7f0c82..a86a546c3d 100644
--- a/src/3rdparty/freetype/src/sfnt/ttload.c
+++ b/src/3rdparty/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-2015 by */
+/* Copyright 1996-2018 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -338,7 +338,7 @@
SFNT_HeaderRec sfnt;
FT_Error error;
FT_Memory memory = stream->memory;
- FT_UShort nn, valid_entries;
+ FT_UShort nn, valid_entries = 0;
static const FT_Frame_Field offset_table_fields[] =
{
@@ -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/src/3rdparty/freetype/src/sfnt/ttload.h b/src/3rdparty/freetype/src/sfnt/ttload.h
index a6d91c5b70..f94be8b7bd 100644
--- a/src/3rdparty/freetype/src/sfnt/ttload.h
+++ b/src/3rdparty/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-2015 by */
+/* Copyright 1996-2018 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -17,8 +17,8 @@
/***************************************************************************/
-#ifndef __TTLOAD_H__
-#define __TTLOAD_H__
+#ifndef TTLOAD_H_
+#define TTLOAD_H_
#include <ft2build.h>
@@ -106,7 +106,7 @@ FT_BEGIN_HEADER
FT_END_HEADER
-#endif /* __TTLOAD_H__ */
+#endif /* TTLOAD_H_ */
/* END */
diff --git a/src/3rdparty/freetype/src/sfnt/ttmtx.c b/src/3rdparty/freetype/src/sfnt/ttmtx.c
index 58309aa496..6ddda95b56 100644
--- a/src/3rdparty/freetype/src/sfnt/ttmtx.c
+++ b/src/3rdparty/freetype/src/sfnt/ttmtx.c
@@ -4,7 +4,7 @@
/* */
/* Load the metrics tables common to TTF and OTF fonts (body). */
/* */
-/* Copyright 2006-2015 by */
+/* Copyright 2006-2018 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/src/3rdparty/freetype/src/sfnt/ttmtx.h b/src/3rdparty/freetype/src/sfnt/ttmtx.h
index 096ee062cf..ab00acd795 100644
--- a/src/3rdparty/freetype/src/sfnt/ttmtx.h
+++ b/src/3rdparty/freetype/src/sfnt/ttmtx.h
@@ -4,7 +4,7 @@
/* */
/* Load the metrics tables common to TTF and OTF fonts (specification). */
/* */
-/* Copyright 2006-2015 by */
+/* Copyright 2006-2018 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -16,8 +16,8 @@
/***************************************************************************/
-#ifndef __TTMTX_H__
-#define __TTMTX_H__
+#ifndef TTMTX_H_
+#define TTMTX_H_
#include <ft2build.h>
@@ -49,7 +49,7 @@ FT_BEGIN_HEADER
FT_END_HEADER
-#endif /* __TTMTX_H__ */
+#endif /* TTMTX_H_ */
/* END */
diff --git a/src/3rdparty/freetype/src/sfnt/ttpost.c b/src/3rdparty/freetype/src/sfnt/ttpost.c
index 8d29d1e9f6..6de99ef977 100644
--- a/src/3rdparty/freetype/src/sfnt/ttpost.c
+++ b/src/3rdparty/freetype/src/sfnt/ttpost.c
@@ -2,10 +2,10 @@
/* */
/* ttpost.c */
/* */
-/* Postcript name table processing for TrueType and OpenType fonts */
+/* PostScript name table processing for TrueType and OpenType fonts */
/* (body). */
/* */
-/* Copyright 1996-2015 by */
+/* Copyright 1996-2018 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"
@@ -321,12 +325,13 @@
FT_UNUSED( post_limit );
- /* UNDOCUMENTED! This value appears only in the Apple TT specs. */
if ( FT_READ_USHORT( num_glyphs ) )
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;
@@ -402,7 +407,7 @@
/* now read postscript table */
if ( format == 0x00020000L )
error = load_format_20( face, stream, post_limit );
- else if ( format == 0x00028000L )
+ else if ( format == 0x00025000L )
error = load_format_25( face, stream, post_limit );
else
error = FT_THROW( Invalid_File_Format );
@@ -441,7 +446,7 @@
FT_FREE( table->glyph_names );
table->num_names = 0;
}
- else if ( format == 0x00028000L )
+ else if ( format == 0x00025000L )
{
TT_Post_25 table = &names->names.format_25;
@@ -468,8 +473,8 @@
/* idx :: The glyph index. */
/* */
/* <InOut> */
- /* PSname :: The address of a string pointer. Will be NULL in case */
- /* of error, otherwise it is a pointer to the glyph name. */
+ /* PSname :: The address of a string pointer. Undefined in case of */
+ /* error, otherwise it is a pointer to the glyph name. */
/* */
/* You must not modify the returned string! */
/* */
@@ -537,7 +542,7 @@
*PSname = (FT_String*)table->glyph_names[name_index - 258];
}
}
- else if ( format == 0x00028000L )
+ else if ( format == 0x00025000L )
{
TT_Post_25 table = &names->names.format_25;
@@ -559,5 +564,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/src/3rdparty/freetype/src/sfnt/ttpost.h b/src/3rdparty/freetype/src/sfnt/ttpost.h
index e3eca02c62..3bec07e445 100644
--- a/src/3rdparty/freetype/src/sfnt/ttpost.h
+++ b/src/3rdparty/freetype/src/sfnt/ttpost.h
@@ -2,10 +2,10 @@
/* */
/* ttpost.h */
/* */
-/* Postcript name table processing for TrueType and OpenType fonts */
+/* PostScript name table processing for TrueType and OpenType fonts */
/* (specification). */
/* */
-/* Copyright 1996-2015 by */
+/* Copyright 1996-2018 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -17,8 +17,8 @@
/***************************************************************************/
-#ifndef __TTPOST_H__
-#define __TTPOST_H__
+#ifndef TTPOST_H_
+#define TTPOST_H_
#include <ft2build.h>
@@ -40,7 +40,7 @@ FT_BEGIN_HEADER
FT_END_HEADER
-#endif /* __TTPOST_H__ */
+#endif /* TTPOST_H_ */
/* END */
diff --git a/src/3rdparty/freetype/src/sfnt/ttsbit.c b/src/3rdparty/freetype/src/sfnt/ttsbit.c
index 3b351ecfce..33b8640bc3 100644
--- a/src/3rdparty/freetype/src/sfnt/ttsbit.c
+++ b/src/3rdparty/freetype/src/sfnt/ttsbit.c
@@ -4,7 +4,7 @@
/* */
/* TrueType and OpenType embedded bitmap support (body). */
/* */
-/* Copyright 2005-2015 by */
+/* Copyright 2005-2018 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,7 +111,12 @@
version = FT_NEXT_LONG( p );
num_strikes = FT_NEXT_ULONG( p );
- if ( ( (FT_ULong)version & 0xFFFF0000UL ) != 0x00020000UL )
+ /* 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 & 0x0000FFFFUL ) != 0x00000200UL &&
+ ( (FT_ULong)version & 0xFFFF0000UL ) != 0x00030000UL &&
+ ( (FT_ULong)version & 0x0000FFFFUL ) != 0x00000300UL )
{
error = FT_THROW( Unknown_File_Format );
goto Exit;
@@ -189,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;
@@ -238,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 )
{
@@ -247,6 +312,8 @@
case TT_SBIT_TABLE_TYPE_CBLC:
{
FT_Byte* strike;
+ FT_Char max_before_bl;
+ FT_Char min_after_bl;
strike = face->sbit_table + 8 + strike_index * 48;
@@ -256,24 +323,91 @@
metrics->ascender = (FT_Char)strike[16] * 64; /* hori.ascender */
metrics->descender = (FT_Char)strike[17] * 64; /* hori.descender */
- metrics->height = metrics->ascender - metrics->descender;
+
+ /* Due to fuzzy wording in the EBLC documentation, we find both */
+ /* positive and negative values for `descender'. Additionally, */
+ /* many fonts have both `ascender' and `descender' set to zero */
+ /* (which is definitely wrong). MS Windows simply ignores all */
+ /* those values... For these reasons we apply some heuristics */
+ /* to get a reasonable, non-zero value for the height. */
+
+ max_before_bl = (FT_Char)strike[24];
+ min_after_bl = (FT_Char)strike[25];
+
+ if ( metrics->descender > 0 )
+ {
+ /* compare sign of descender with `min_after_bl' */
+ if ( min_after_bl < 0 )
+ metrics->descender = -metrics->descender;
+ }
+
+ else if ( metrics->descender == 0 )
+ {
+ if ( metrics->ascender == 0 )
+ {
+ FT_TRACE2(( "tt_face_load_strike_metrics:"
+ " sanitizing invalid ascender and descender\n"
+ " "
+ " values for strike %d (%dppem, %dppem)\n",
+ strike_index,
+ metrics->x_ppem, metrics->y_ppem ));
+
+ /* sanitize buggy ascender and descender values */
+ if ( max_before_bl || min_after_bl )
+ {
+ metrics->ascender = max_before_bl * 64;
+ metrics->descender = min_after_bl * 64;
+ }
+ else
+ {
+ metrics->ascender = metrics->y_ppem * 64;
+ metrics->descender = 0;
+ }
+ }
+ }
+
+#if 0
+ else
+ ; /* if we have a negative descender, simply use it */
+#endif
+
+ metrics->height = metrics->ascender - metrics->descender;
+ if ( metrics->height == 0 )
+ {
+ FT_TRACE2(( "tt_face_load_strike_metrics:"
+ " sanitizing invalid height value\n"
+ " "
+ " for strike (%d, %d)\n",
+ metrics->x_ppem, metrics->y_ppem ));
+ metrics->height = metrics->y_ppem * 64;
+ metrics->descender = metrics->ascender - metrics->height;
+ }
/* Is this correct? */
metrics->max_advance = ( (FT_Char)strike[22] + /* min_origin_SB */
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;
}
case TT_SBIT_TABLE_TYPE_SBIX:
{
FT_Stream stream = face->root.stream;
- FT_UInt offset, upem;
- FT_UShort ppem, resolution;
+ FT_UInt offset;
+ FT_UShort upem, ppem, resolution;
TT_HoriHeader *hori;
- FT_ULong table_size;
- FT_Pos ppem_, upem_; /* to reduce casts */
+ FT_Pos ppem_; /* to reduce casts */
FT_Error error;
FT_Byte* p;
@@ -282,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();
@@ -307,14 +437,25 @@
metrics->y_ppem = ppem;
ppem_ = (FT_Pos)ppem;
- upem_ = (FT_Pos)upem;
- metrics->ascender = ppem_ * hori->Ascender * 64 / upem_;
- metrics->descender = ppem_ * hori->Descender * 64 / upem_;
- metrics->height = ppem_ * ( hori->Ascender -
- hori->Descender +
- hori->Line_Gap ) * 64 / upem_;
- metrics->max_advance = ppem_ * hori->advance_Width_Max * 64 / upem_;
+ metrics->ascender =
+ FT_MulDiv( hori->Ascender, ppem_ * 64, upem );
+ metrics->descender =
+ FT_MulDiv( hori->Descender, ppem_ * 64, upem );
+ metrics->height =
+ FT_MulDiv( hori->Ascender - hori->Descender + hori->Line_Gap,
+ ppem_ * 64, upem );
+ metrics->max_advance =
+ FT_MulDiv( hori->advance_Width_Max, ppem_ * 64, upem );
+
+ /* 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 error;
}
@@ -352,17 +493,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;
@@ -373,8 +512,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;
@@ -419,7 +558,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;
@@ -482,6 +622,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;
@@ -547,13 +690,17 @@
tt_sbit_decoder_load_image( TT_SBitDecoder decoder,
FT_UInt glyph_index,
FT_Int x_pos,
- FT_Int y_pos );
+ FT_Int y_pos,
+ FT_UInt recurse_count,
+ FT_Bool metrics_only );
- typedef FT_Error (*TT_SBitDecoder_LoadFunc)( TT_SBitDecoder decoder,
- FT_Byte* p,
- FT_Byte* plimit,
- FT_Int x_pos,
- FT_Int y_pos );
+ typedef FT_Error (*TT_SBitDecoder_LoadFunc)(
+ TT_SBitDecoder decoder,
+ FT_Byte* p,
+ FT_Byte* plimit,
+ FT_Int x_pos,
+ FT_Int y_pos,
+ FT_UInt recurse_count );
static FT_Error
@@ -561,7 +708,8 @@
FT_Byte* p,
FT_Byte* limit,
FT_Int x_pos,
- FT_Int y_pos )
+ FT_Int y_pos,
+ FT_UInt recurse_count )
{
FT_Error error = FT_Err_Ok;
FT_Byte* line;
@@ -569,6 +717,8 @@
FT_UInt bit_height, bit_width;
FT_Bitmap* bitmap;
+ FT_UNUSED( recurse_count );
+
/* check that we can write the glyph into the bitmap */
bitmap = decoder->bitmap;
@@ -700,7 +850,8 @@
FT_Byte* p,
FT_Byte* limit,
FT_Int x_pos,
- FT_Int y_pos )
+ FT_Int y_pos,
+ FT_UInt recurse_count )
{
FT_Error error = FT_Err_Ok;
FT_Byte* line;
@@ -709,6 +860,8 @@
FT_Bitmap* bitmap;
FT_UShort rval;
+ FT_UNUSED( recurse_count );
+
/* check that we can write the glyph into the bitmap */
bitmap = decoder->bitmap;
@@ -738,6 +891,12 @@
goto Exit;
}
+ if ( !line_bits || !height )
+ {
+ /* nothing to do */
+ goto Exit;
+ }
+
/* now do the blit */
/* adjust `line' to point to the first byte of the bitmap */
@@ -777,7 +936,7 @@
}
*pwrite++ |= ( ( rval >> nbits ) & 0xFF ) &
- ( ~( 0xFF << w ) << ( 8 - w - x_pos ) );
+ ( ~( 0xFFU << w ) << ( 8 - w - x_pos ) );
rval <<= 8;
w = line_bits - w;
@@ -824,7 +983,8 @@
FT_Byte* p,
FT_Byte* limit,
FT_Int x_pos,
- FT_Int y_pos )
+ FT_Int y_pos,
+ FT_UInt recurse_count )
{
FT_Error error = FT_Err_Ok;
FT_UInt num_components, nn;
@@ -847,8 +1007,9 @@
goto Fail;
}
- FT_TRACE3(( "tt_sbit_decoder_load_compound: loading %d components\n",
- num_components ));
+ FT_TRACE3(( "tt_sbit_decoder_load_compound: loading %d component%s\n",
+ num_components,
+ num_components == 1 ? "" : "s" ));
for ( nn = 0; nn < num_components; nn++ )
{
@@ -858,8 +1019,13 @@
/* NB: a recursive call */
- error = tt_sbit_decoder_load_image( decoder, gindex,
- x_pos + dx, y_pos + dy );
+ error = tt_sbit_decoder_load_image( decoder,
+ gindex,
+ x_pos + dx,
+ y_pos + dy,
+ recurse_count + 1,
+ /* request full bitmap image */
+ FALSE );
if ( error )
break;
}
@@ -891,11 +1057,14 @@
FT_Byte* p,
FT_Byte* limit,
FT_Int x_pos,
- FT_Int y_pos )
+ FT_Int y_pos,
+ FT_UInt recurse_count )
{
FT_Error error = FT_Err_Ok;
FT_ULong png_len;
+ FT_UNUSED( recurse_count );
+
if ( limit - p < 4 )
{
@@ -920,6 +1089,7 @@
decoder->stream->memory,
p,
png_len,
+ FALSE,
FALSE );
Exit:
@@ -937,7 +1107,9 @@
FT_ULong glyph_start,
FT_ULong glyph_size,
FT_Int x_pos,
- FT_Int y_pos )
+ FT_Int y_pos,
+ FT_UInt recurse_count,
+ FT_Bool metrics_only )
{
FT_Error error;
FT_Stream stream = decoder->stream;
@@ -947,7 +1119,8 @@
/* seek into the EBDT table now */
- if ( glyph_start + glyph_size > decoder->ebdt_size )
+ if ( !glyph_size ||
+ glyph_start + glyph_size > decoder->ebdt_size )
{
error = FT_THROW( Invalid_Argument );
goto Exit;
@@ -1058,12 +1231,16 @@
if ( !decoder->bitmap_allocated )
{
- error = tt_sbit_decoder_alloc_bitmap( decoder );
+ error = tt_sbit_decoder_alloc_bitmap( decoder, metrics_only );
+
if ( error )
goto Fail;
}
- error = loader( decoder, p, p_limit, x_pos, y_pos );
+ if ( metrics_only )
+ goto Fail; /* this is not an error */
+
+ error = loader( decoder, p, p_limit, x_pos, y_pos, recurse_count );
}
Fail:
@@ -1078,13 +1255,10 @@
tt_sbit_decoder_load_image( TT_SBitDecoder decoder,
FT_UInt glyph_index,
FT_Int x_pos,
- FT_Int y_pos )
+ FT_Int y_pos,
+ FT_UInt recurse_count,
+ FT_Bool metrics_only )
{
- /*
- * First, we find the correct strike range that applies to this
- * glyph index.
- */
-
FT_Byte* p = decoder->eblc_base + decoder->strike_index_array;
FT_Byte* p_limit = decoder->eblc_limit;
FT_ULong num_ranges = decoder->strike_index_count;
@@ -1092,6 +1266,17 @@
FT_ULong image_start = 0, image_end = 0, image_offset;
+ /* arbitrary recursion limit */
+ if ( recurse_count > 100 )
+ {
+ FT_TRACE4(( "tt_sbit_decoder_load_image:"
+ " recursion depth exceeded\n" ));
+ goto Failure;
+ }
+
+
+ /* First, we find the correct strike range that applies to this */
+ /* glyph index. */
for ( ; num_ranges > 0; num_ranges-- )
{
start = FT_NEXT_USHORT( p );
@@ -1256,16 +1441,25 @@
image_start,
image_end,
x_pos,
- y_pos );
+ y_pos,
+ recurse_count,
+ metrics_only );
Failure:
return FT_THROW( Invalid_Table );
NoBitmap:
+ if ( recurse_count )
+ {
+ FT_TRACE4(( "tt_sbit_decoder_load_image:"
+ " missing subglyph sbit with glyph index %d\n",
+ glyph_index ));
+ return FT_THROW( Invalid_Composite );
+ }
+
FT_TRACE4(( "tt_sbit_decoder_load_image:"
" no sbit found for glyph index %d\n", glyph_index ));
-
- return FT_THROW( Invalid_Argument );
+ return FT_THROW( Missing_Bitmap );
}
@@ -1275,10 +1469,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;
@@ -1287,7 +1481,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;
@@ -1295,21 +1494,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();
@@ -1318,14 +1514,14 @@
FT_FRAME_EXIT();
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 )
+ return FT_THROW( Missing_Bitmap );
+ 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();
@@ -1356,7 +1552,8 @@
stream->memory,
stream->cursor,
glyph_end - glyph_start - 8,
- TRUE );
+ TRUE,
+ metrics_only );
#else
error = FT_THROW( Unimplemented_Feature );
#endif
@@ -1416,22 +1613,27 @@
error = tt_sbit_decoder_init( decoder, face, strike_index, metrics );
if ( !error )
{
- error = tt_sbit_decoder_load_image( decoder,
- glyph_index,
- 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:
@@ -1440,9 +1642,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;
@@ -1468,5 +1671,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/src/3rdparty/freetype/src/sfnt/ttsbit.h b/src/3rdparty/freetype/src/sfnt/ttsbit.h
index d4e13aefb8..ce2af3c162 100644
--- a/src/3rdparty/freetype/src/sfnt/ttsbit.h
+++ b/src/3rdparty/freetype/src/sfnt/ttsbit.h
@@ -4,7 +4,7 @@
/* */
/* TrueType and OpenType embedded bitmap support (specification). */
/* */
-/* Copyright 1996-2015 by */
+/* Copyright 1996-2018 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -16,8 +16,8 @@
/***************************************************************************/
-#ifndef __TTSBIT_H__
-#define __TTSBIT_H__
+#ifndef TTSBIT_H_
+#define TTSBIT_H_
#include <ft2build.h>
@@ -57,7 +57,7 @@ FT_BEGIN_HEADER
FT_END_HEADER
-#endif /* __TTSBIT_H__ */
+#endif /* TTSBIT_H_ */
/* END */
diff --git a/src/3rdparty/freetype/src/smooth/Jamfile b/src/3rdparty/freetype/src/smooth/Jamfile
index b1887c2c6e..9957d5e915 100644
--- a/src/3rdparty/freetype/src/smooth/Jamfile
+++ b/src/3rdparty/freetype/src/smooth/Jamfile
@@ -1,6 +1,6 @@
# FreeType 2 src/smooth Jamfile
#
-# Copyright 2001-2015 by
+# Copyright 2001-2018 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/src/3rdparty/freetype/src/smooth/ftgrays.c b/src/3rdparty/freetype/src/smooth/ftgrays.c
index ba2944559c..803a19e415 100644
--- a/src/3rdparty/freetype/src/smooth/ftgrays.c
+++ b/src/3rdparty/freetype/src/smooth/ftgrays.c
@@ -4,7 +4,7 @@
/* */
/* A new `perfect' anti-aliasing renderer (body). */
/* */
-/* Copyright 2000-2015 by */
+/* Copyright 2000-2018 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -18,7 +18,7 @@
/*************************************************************************/
/* */
/* This file can be compiled without the rest of the FreeType engine, by */
- /* defining the _STANDALONE_ macro when compiling it. You also need to */
+ /* defining the STANDALONE_ macro when compiling it. You also need to */
/* put the files `ftgrays.h' and `ftimage.h' into the current */
/* compilation directory. Typically, you could do something like */
/* */
@@ -27,9 +27,9 @@
/* - copy `include/freetype/ftimage.h' and `src/smooth/ftgrays.h' to the */
/* same directory */
/* */
- /* - compile `ftgrays' with the _STANDALONE_ macro defined, as in */
+ /* - compile `ftgrays' with the STANDALONE_ macro defined, as in */
/* */
- /* cc -c -D_STANDALONE_ ftgrays.c */
+ /* cc -c -DSTANDALONE_ ftgrays.c */
/* */
/* The renderer can be initialized with a call to */
/* `ft_gray_raster.raster_new'; an anti-aliased bitmap can be generated */
@@ -91,7 +91,7 @@
#define FT_COMPONENT trace_smooth
-#ifdef _STANDALONE_
+#ifdef STANDALONE_
/* The size in bytes of the render pool used by the scan-line converter */
@@ -106,6 +106,7 @@
#define FT_BEGIN_STMNT do {
#define FT_END_STMNT } while ( 0 )
+#define FT_MIN( a, b ) ( (a) < (b) ? (a) : (b) )
#define FT_MAX( a, b ) ( (a) > (b) ? (a) : (b) )
#define FT_ABS( a ) ( (a) < 0 ? -(a) : (a) )
@@ -135,8 +136,20 @@
#include <string.h>
#include <setjmp.h>
#include <limits.h>
-#define FT_UINT_MAX UINT_MAX
-#define FT_INT_MAX INT_MAX
+#define FT_CHAR_BIT CHAR_BIT
+#define FT_UINT_MAX UINT_MAX
+#define FT_INT_MAX INT_MAX
+#define FT_ULONG_MAX ULONG_MAX
+
+#define ADD_LONG( a, b ) \
+ (long)( (unsigned long)(a) + (unsigned long)(b) )
+#define SUB_LONG( a, b ) \
+ (long)( (unsigned long)(a) - (unsigned long)(b) )
+#define MUL_LONG( a, b ) \
+ (long)( (unsigned long)(a) * (unsigned long)(b) )
+#define NEG_LONG( a ) \
+ (long)( -(unsigned long)(a) )
+
#define ft_memset memset
@@ -254,13 +267,14 @@ typedef ptrdiff_t FT_PtrDist;
};
-#else /* !_STANDALONE_ */
+#else /* !STANDALONE_ */
#include <ft2build.h>
#include "ftgrays.h"
#include FT_INTERNAL_OBJECTS_H
#include FT_INTERNAL_DEBUG_H
+#include FT_INTERNAL_CALC_H
#include FT_OUTLINE_H
#include "ftsmerrs.h"
@@ -272,7 +286,7 @@ typedef ptrdiff_t FT_PtrDist;
#define ErrRaster_Memory_Overflow Smooth_Err_Out_Of_Memory
-#endif /* !_STANDALONE_ */
+#endif /* !STANDALONE_ */
#ifndef FT_MEM_SET
@@ -283,6 +297,10 @@ typedef ptrdiff_t FT_PtrDist;
#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 :-) */
#undef RAS_ARG
@@ -300,7 +318,7 @@ typedef ptrdiff_t FT_PtrDist;
#else /* FT_STATIC_RASTER */
-#define RAS_ARG /* empty */
+#define RAS_ARG void
#define RAS_ARG_ /* empty */
#define RAS_VAR /* empty */
#define RAS_VAR_ /* empty */
@@ -316,25 +334,26 @@ typedef ptrdiff_t FT_PtrDist;
#undef TRUNC
#undef SCALED
-#define ONE_PIXEL ( 1L << PIXEL_BITS )
+#define ONE_PIXEL ( 1 << PIXEL_BITS )
#define TRUNC( x ) ( (TCoord)( (x) >> PIXEL_BITS ) )
-#define SUBPIXELS( x ) ( (TPos)(x) << PIXEL_BITS )
+#define SUBPIXELS( x ) ( (TPos)(x) * ONE_PIXEL )
#define FLOOR( x ) ( (x) & -ONE_PIXEL )
#define CEILING( x ) ( ( (x) + ONE_PIXEL - 1 ) & -ONE_PIXEL )
#define ROUND( x ) ( ( (x) + ONE_PIXEL / 2 ) & -ONE_PIXEL )
#if PIXEL_BITS >= 6
-#define UPSCALE( x ) ( (x) << ( PIXEL_BITS - 6 ) )
+#define UPSCALE( x ) ( (x) * ( ONE_PIXEL >> 6 ) )
#define DOWNSCALE( x ) ( (x) >> ( PIXEL_BITS - 6 ) )
#else
#define UPSCALE( x ) ( (x) >> ( 6 - PIXEL_BITS ) )
-#define DOWNSCALE( x ) ( (x) << ( 6 - PIXEL_BITS ) )
+#define DOWNSCALE( x ) ( (x) * ( 64 >> PIXEL_BITS ) )
#endif
/* 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) ); \
@@ -351,7 +370,7 @@ typedef ptrdiff_t FT_PtrDist;
/* optimize a division and modulo operation on the same parameters */
/* into a single call to `__aeabi_idivmod'. See */
/* */
- /* http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43721 */
+ /* https://gcc.gnu.org/bugzilla/show_bug.cgi?id=43721 */
#undef FT_DIV_MOD
#define FT_DIV_MOD( type, dividend, divisor, quotient, remainder ) \
FT_BEGIN_STMNT \
@@ -366,6 +385,16 @@ typedef ptrdiff_t FT_PtrDist;
#endif /* __arm__ */
+ /* These macros speed up repetitive divisions by replacing them */
+ /* with multiplications and right shifts. */
+#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 ) )
+
+
/*************************************************************************/
/* */
/* TYPE DEFINITIONS */
@@ -375,44 +404,36 @@ typedef ptrdiff_t FT_PtrDist;
/* need to define them to "float" or "double" when experimenting with */
/* new algorithms */
- typedef long TCoord; /* integer scanline/pixel coordinate */
- typedef long TPos; /* sub-pixel coordinate */
-
- /* determine the type used to store cell areas. This normally takes at */
- /* least PIXEL_BITS*2 + 1 bits. On 16-bit systems, we need to use */
- /* `long' instead of `int', otherwise bad things happen */
-
-#if PIXEL_BITS <= 7
-
- typedef int TArea;
-
-#else /* PIXEL_BITS >= 8 */
-
- /* approximately determine the size of integers using an ANSI-C header */
-#if FT_UINT_MAX == 0xFFFFU
- typedef long TArea;
-#else
- typedef int TArea;
-#endif
-
-#endif /* PIXEL_BITS >= 8 */
-
-
- /* maximum number of gray spans in a call to the span callback */
-#define FT_MAX_GRAY_SPANS 32
+ typedef long TPos; /* subpixel coordinate */
+ typedef int TCoord; /* integer scanline/pixel coordinate */
+ typedef int TArea; /* cell areas, coordinate products */
typedef struct TCell_* PCell;
typedef struct TCell_
{
- TPos x; /* same with gray_TWorker.ex */
+ TCoord x; /* same with gray_TWorker.ex */
TCoord cover; /* same with gray_TWorker.cover */
TArea area;
PCell next;
} TCell;
+ typedef struct TPixmap_
+ {
+ unsigned char* origin; /* pixmap origin at the bottom-left */
+ int pitch; /* pitch to go down one row */
+
+ } TPixmap;
+
+ /* maximum number of gray cells in the buffer */
+#if FT_RENDER_POOL_SIZE > 2048
+#define FT_MAX_GRAY_POOL ( FT_RENDER_POOL_SIZE / sizeof ( TCell ) )
+#else
+#define FT_MAX_GRAY_POOL ( 2048 / sizeof ( TCell ) )
+#endif
+
#if defined( _MSC_VER ) /* Visual C++ (and Intel C++) */
/* We disable the warning `structure was padded due to */
@@ -427,42 +448,25 @@ typedef ptrdiff_t FT_PtrDist;
ft_jmp_buf jump_buffer;
TCoord ex, ey;
- TPos min_ex, max_ex;
- TPos min_ey, max_ey;
- TPos count_ex, count_ey;
+ TCoord min_ex, max_ex;
+ TCoord min_ey, max_ey;
TArea area;
TCoord cover;
int invalid;
+ PCell* ycells;
PCell cells;
FT_PtrDist max_cells;
FT_PtrDist num_cells;
TPos x, y;
- FT_Vector bez_stack[32 * 3 + 1];
- int lev_stack[32];
-
FT_Outline outline;
- FT_Bitmap target;
- FT_BBox clip_box;
-
- 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;
-
- int band_size;
- int band_shoot;
-
- void* buffer;
- long buffer_size;
-
- PCell* ycells;
- TPos ycount;
} gray_TWorker, *gray_PWorker;
@@ -485,95 +489,53 @@ typedef ptrdiff_t FT_PtrDist;
} gray_TRaster, *gray_PRaster;
+#ifdef FT_DEBUG_LEVEL_TRACE
- /*************************************************************************/
- /* */
- /* Initialize the cells table. */
- /* */
- static void
- gray_init_cells( RAS_ARG_ void* buffer,
- long byte_size )
- {
- ras.buffer = buffer;
- ras.buffer_size = byte_size;
-
- ras.ycells = (PCell*) buffer;
- ras.cells = NULL;
- ras.max_cells = 0;
- ras.num_cells = 0;
- ras.area = 0;
- ras.cover = 0;
- ras.invalid = 1;
- }
-
-
- /*************************************************************************/
- /* */
- /* Compute the outline bounding box. */
- /* */
+ /* to be called while in the debugger -- */
+ /* this function causes a compiler warning since it is unused otherwise */
static void
- gray_compute_cbox( RAS_ARG )
+ gray_dump_cells( RAS_ARG )
{
- FT_Outline* outline = &ras.outline;
- FT_Vector* vec = outline->points;
- FT_Vector* limit = vec + outline->n_points;
+ int y;
- if ( outline->n_points <= 0 )
+ for ( y = ras.min_ey; y < ras.max_ey; y++ )
{
- ras.min_ex = ras.max_ex = 0;
- ras.min_ey = ras.max_ey = 0;
- return;
- }
-
- ras.min_ex = ras.max_ex = vec->x;
- ras.min_ey = ras.max_ey = vec->y;
+ PCell cell = ras.ycells[y - ras.min_ey];
- vec++;
-
- for ( ; vec < limit; vec++ )
- {
- TPos x = vec->x;
- TPos y = vec->y;
+ printf( "%3d:", y );
- if ( x < ras.min_ex ) ras.min_ex = x;
- if ( x > ras.max_ex ) ras.max_ex = x;
- if ( y < ras.min_ey ) ras.min_ey = y;
- if ( y > ras.max_ey ) ras.max_ey = y;
+ for ( ; cell != NULL; cell = cell->next )
+ printf( " (%3d, c:%4d, a:%6d)",
+ cell->x, cell->cover, cell->area );
+ printf( "\n" );
}
-
- /* truncate the bounding box to integer pixels */
- ras.min_ex = ras.min_ex >> 6;
- ras.min_ey = ras.min_ey >> 6;
- ras.max_ex = ( ras.max_ex + 63 ) >> 6;
- ras.max_ey = ( ras.max_ey + 63 ) >> 6;
}
+#endif /* FT_DEBUG_LEVEL_TRACE */
+
/*************************************************************************/
/* */
/* Record the current cell in the table. */
/* */
- static PCell
- gray_find_cell( RAS_ARG )
+ static void
+ gray_record_cell( RAS_ARG )
{
PCell *pcell, cell;
- TPos x = ras.ex;
+ 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;
}
@@ -581,30 +543,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;
}
@@ -626,58 +579,24 @@ 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;
+ if ( ex < ras.min_ex )
+ ex = ras.min_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 );
+ /* record the current one if it is valid and substantial */
+ if ( !ras.invalid && ( ras.area || ras.cover ) )
+ gray_record_cell( RAS_VAR );
- ras.area = 0;
- ras.cover = 0;
- ras.ex = ex;
- ras.ey = ey;
- }
+ 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 );
+ ras.invalid = ( ey >= ras.max_ey || ey < ras.min_ey ||
+ ex >= ras.max_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 = (TCoord)( ras.max_ex );
-
- if ( ex < ras.min_ex )
- ex = (TCoord)( 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;
-
- gray_set_cell( RAS_VAR_ ex, ey );
- }
-
+#ifndef FT_LONG64
/*************************************************************************/
/* */
@@ -690,17 +609,13 @@ typedef ptrdiff_t FT_PtrDist;
TPos x2,
TCoord y2 )
{
- TCoord ex1, ex2, fx1, fx2, delta, mod;
- long p, first, dx;
+ TCoord ex1, ex2, fx1, fx2, first, dy, delta, mod;
+ TPos p, dx;
int incr;
- dx = x2 - x1;
-
ex1 = TRUNC( x1 );
ex2 = TRUNC( x2 );
- fx1 = (TCoord)( x1 - SUBPIXELS( ex1 ) );
- fx2 = (TCoord)( x2 - SUBPIXELS( ex2 ) );
/* trivial case. Happens often */
if ( y1 == y2 )
@@ -709,26 +624,29 @@ typedef ptrdiff_t FT_PtrDist;
return;
}
+ 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;
+ 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;
@@ -736,34 +654,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;
@@ -771,9 +686,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;
}
@@ -785,25 +704,22 @@ typedef ptrdiff_t FT_PtrDist;
gray_render_line( RAS_ARG_ TPos to_x,
TPos to_y )
{
- TCoord ey1, ey2, fy1, fy2, mod;
- TPos dx, dy, x, x2;
- long p, first;
- int delta, rem, lift, incr;
+ TCoord ey1, ey2, fy1, fy2, first, delta, mod;
+ TPos p, dx, dy, x, x2;
+ int incr;
ey1 = TRUNC( ras.y );
ey2 = TRUNC( to_y ); /* if (ey2 >= ras.max_ey) ey2 = ras.max_ey-1; */
- fy1 = (TCoord)( ras.y - SUBPIXELS( ey1 ) );
- fy2 = (TCoord)( to_y - SUBPIXELS( ey2 ) );
-
- dx = to_x - ras.x;
- dy = to_y - ras.y;
/* perform vertical clipping */
if ( ( ey1 >= ras.max_ey && ey2 >= ras.max_ey ) ||
( ey1 < ras.min_ey && ey2 < ras.min_ey ) )
goto End;
+ fy1 = (TCoord)( ras.y - SUBPIXELS( ey1 ) );
+ fy2 = (TCoord)( to_y - SUBPIXELS( ey2 ) );
+
/* everything is on a single scanline */
if ( ey1 == ey2 )
{
@@ -811,9 +727,10 @@ typedef ptrdiff_t FT_PtrDist;
goto End;
}
- /* vertical line - avoid calling gray_render_scanline */
- incr = 1;
+ dx = to_x - ras.x;
+ dy = to_y - ras.y;
+ /* vertical line - avoid calling gray_render_scanline */
if ( dx == 0 )
{
TCoord ex = TRUNC( ras.x );
@@ -821,21 +738,25 @@ 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;
}
- delta = (int)( first - fy1 );
+ delta = first - fy1;
ras.area += (TArea)two_fx * delta;
ras.cover += delta;
ey1 += incr;
gray_set_cell( RAS_VAR_ ex, ey1 );
- delta = (int)( first + first - ONE_PIXEL );
+ delta = first + first - ONE_PIXEL;
area = (TArea)two_fx * delta;
while ( ey1 != ey2 )
{
@@ -846,7 +767,7 @@ typedef ptrdiff_t FT_PtrDist;
gray_set_cell( RAS_VAR_ ex, ey1 );
}
- delta = (int)( fy2 - ONE_PIXEL + first );
+ delta = fy2 - ONE_PIXEL + first;
ras.area += (TArea)two_fx * delta;
ras.cover += delta;
@@ -854,11 +775,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;
@@ -866,34 +789,36 @@ typedef ptrdiff_t FT_PtrDist;
dy = -dy;
}
- FT_DIV_MOD( int, p, dy, delta, mod );
+ FT_DIV_MOD( TCoord, p, dy, delta, mod );
x = ras.x + delta;
- gray_render_scanline( RAS_VAR_ ey1, ras.x, fy1, x, (TCoord)first );
+ gray_render_scanline( RAS_VAR_ ey1, ras.x, fy1, x, first );
ey1 += incr;
gray_set_cell( RAS_VAR_ TRUNC( x ), ey1 );
if ( ey1 != ey2 )
{
- p = ONE_PIXEL * dx;
- FT_DIV_MOD( int, p, dy, lift, rem );
- mod -= (int)dy;
+ TCoord lift, rem;
+
+
+ p = ONE_PIXEL * dx;
+ FT_DIV_MOD( TCoord, p, dy, lift, rem );
do
{
delta = lift;
mod += rem;
- if ( mod >= 0 )
+ if ( mod >= (TCoord)dy )
{
- mod -= (int)dy;
+ mod -= (TCoord)dy;
delta++;
}
x2 = x + delta;
- gray_render_scanline( RAS_VAR_ ey1, x,
- (TCoord)( ONE_PIXEL - first ), x2,
- (TCoord)first );
+ gray_render_scanline( RAS_VAR_ ey1,
+ x, ONE_PIXEL - first,
+ x2, first );
x = x2;
ey1 += incr;
@@ -901,15 +826,153 @@ typedef ptrdiff_t FT_PtrDist;
} while ( ey1 != ey2 );
}
- gray_render_scanline( RAS_VAR_ ey1, x,
- (TCoord)( ONE_PIXEL - first ), to_x,
- fy2 );
+ gray_render_scanline( RAS_VAR_ ey1,
+ x, ONE_PIXEL - first,
+ to_x, fy2 );
+
+ End:
+ ras.x = to_x;
+ ras.y = to_y;
+ }
+
+#else
+
+ /*************************************************************************/
+ /* */
+ /* Render a straight line across multiple cells in any direction. */
+ /* */
+ static void
+ gray_render_line( RAS_ARG_ TPos to_x,
+ TPos to_y )
+ {
+ TPos dx, dy, fx1, fy1, fx2, fy2;
+ TCoord ex1, ex2, ey1, ey2;
+
+
+ ey1 = TRUNC( ras.y );
+ ey2 = TRUNC( to_y );
+
+ /* perform vertical clipping */
+ if ( ( ey1 >= ras.max_ey && ey2 >= ras.max_ey ) ||
+ ( ey1 < ras.min_ey && ey2 < ras.min_ey ) )
+ goto End;
+
+ ex1 = TRUNC( ras.x );
+ ex2 = TRUNC( to_x );
+
+ fx1 = ras.x - SUBPIXELS( ex1 );
+ fy1 = ras.y - SUBPIXELS( ey1 );
+
+ dx = to_x - ras.x;
+ dy = to_y - ras.y;
+
+ if ( ex1 == ex2 && ey1 == ey2 ) /* inside one cell */
+ ;
+ else if ( dy == 0 ) /* ex1 != ex2 */ /* any horizontal line */
+ {
+ ex1 = ex2;
+ gray_set_cell( RAS_VAR_ ex1, ey1 );
+ }
+ else if ( dx == 0 )
+ {
+ if ( dy > 0 ) /* vertical line up */
+ do
+ {
+ fy2 = ONE_PIXEL;
+ ras.cover += ( fy2 - fy1 );
+ ras.area += ( fy2 - fy1 ) * fx1 * 2;
+ fy1 = 0;
+ ey1++;
+ gray_set_cell( RAS_VAR_ ex1, ey1 );
+ } while ( ey1 != ey2 );
+ else /* vertical line down */
+ do
+ {
+ fy2 = 0;
+ ras.cover += ( fy2 - fy1 );
+ ras.area += ( fy2 - fy1 ) * fx1 * 2;
+ fy1 = ONE_PIXEL;
+ ey1--;
+ gray_set_cell( RAS_VAR_ ex1, ey1 );
+ } while ( ey1 != ey2 );
+ }
+ else /* any other line */
+ {
+ TPos prod = dx * fy1 - dy * fx1;
+ FT_UDIVPREP( ex1 != ex2, dx );
+ FT_UDIVPREP( ey1 != ey2, dy );
+
+
+ /* The fundamental value `prod' determines which side and the */
+ /* exact coordinate where the line exits current cell. It is */
+ /* also easily updated when moving from one cell to the next. */
+ do
+ {
+ if ( prod <= 0 &&
+ prod - dx * ONE_PIXEL > 0 ) /* left */
+ {
+ fx2 = 0;
+ fy2 = (TPos)FT_UDIV( -prod, -dx );
+ prod -= dy * ONE_PIXEL;
+ ras.cover += ( fy2 - fy1 );
+ ras.area += ( fy2 - fy1 ) * ( fx1 + fx2 );
+ fx1 = ONE_PIXEL;
+ fy1 = fy2;
+ ex1--;
+ }
+ else if ( prod - dx * ONE_PIXEL <= 0 &&
+ prod - dx * ONE_PIXEL + dy * ONE_PIXEL > 0 ) /* up */
+ {
+ prod -= dx * ONE_PIXEL;
+ fx2 = (TPos)FT_UDIV( -prod, dy );
+ fy2 = ONE_PIXEL;
+ ras.cover += ( fy2 - fy1 );
+ ras.area += ( fy2 - fy1 ) * ( fx1 + fx2 );
+ fx1 = fx2;
+ fy1 = 0;
+ ey1++;
+ }
+ else if ( prod - dx * ONE_PIXEL + dy * ONE_PIXEL <= 0 &&
+ prod + dy * ONE_PIXEL >= 0 ) /* right */
+ {
+ prod += dy * ONE_PIXEL;
+ fx2 = ONE_PIXEL;
+ fy2 = (TPos)FT_UDIV( prod, dx );
+ ras.cover += ( fy2 - fy1 );
+ ras.area += ( fy2 - fy1 ) * ( fx1 + fx2 );
+ fx1 = 0;
+ fy1 = fy2;
+ ex1++;
+ }
+ else /* ( prod + dy * ONE_PIXEL < 0 &&
+ prod > 0 ) down */
+ {
+ fx2 = (TPos)FT_UDIV( prod, -dy );
+ fy2 = 0;
+ prod += dx * ONE_PIXEL;
+ ras.cover += ( fy2 - fy1 );
+ ras.area += ( fy2 - fy1 ) * ( fx1 + fx2 );
+ fx1 = fx2;
+ fy1 = ONE_PIXEL;
+ ey1--;
+ }
+
+ gray_set_cell( RAS_VAR_ ex1, ey1 );
+ } while ( ex1 != ex2 || ey1 != ey2 );
+ }
+
+ fx2 = to_x - SUBPIXELS( ex2 );
+ fy2 = to_y - SUBPIXELS( ey2 );
+
+ ras.cover += ( fy2 - fy1 );
+ ras.area += ( fy2 - fy1 ) * ( fx1 + fx2 );
End:
ras.x = to_x;
ras.y = to_y;
}
+#endif
static void
gray_split_conic( FT_Vector* base )
@@ -935,73 +998,64 @@ typedef ptrdiff_t FT_PtrDist;
gray_render_conic( RAS_ARG_ const FT_Vector* control,
const FT_Vector* to )
{
+ FT_Vector bez_stack[16 * 2 + 1]; /* enough to accommodate bisections */
+ FT_Vector* arc = bez_stack;
TPos dx, dy;
- TPos min, max, y;
- int top, level;
- int* levels;
- FT_Vector* arc;
+ int draw, split;
- levels = ras.lev_stack;
-
- arc = ras.bez_stack;
arc[0].x = UPSCALE( to->x );
arc[0].y = UPSCALE( to->y );
arc[1].x = UPSCALE( control->x );
arc[1].y = UPSCALE( control->y );
arc[2].x = ras.x;
arc[2].y = ras.y;
- top = 0;
+
+ /* short-cut the arc that crosses the current band */
+ if ( ( TRUNC( arc[0].y ) >= ras.max_ey &&
+ TRUNC( arc[1].y ) >= ras.max_ey &&
+ TRUNC( arc[2].y ) >= ras.max_ey ) ||
+ ( TRUNC( arc[0].y ) < ras.min_ey &&
+ TRUNC( arc[1].y ) < ras.min_ey &&
+ TRUNC( arc[2].y ) < ras.min_ey ) )
+ {
+ ras.x = arc[0].x;
+ ras.y = arc[0].y;
+ return;
+ }
dx = FT_ABS( arc[2].x + arc[0].x - 2 * arc[1].x );
dy = FT_ABS( arc[2].y + arc[0].y - 2 * arc[1].y );
if ( dx < dy )
dx = dy;
- if ( dx < ONE_PIXEL / 4 )
- goto Draw;
-
- /* short-cut the arc that crosses the current band */
- min = max = arc[0].y;
-
- y = arc[1].y;
- if ( y < min ) min = y;
- if ( y > max ) max = y;
-
- y = arc[2].y;
- if ( y < min ) min = y;
- if ( y > max ) max = y;
-
- if ( TRUNC( min ) >= ras.max_ey || TRUNC( max ) < ras.min_ey )
- goto Draw;
-
- level = 0;
- do
+ /* We can calculate the number of necessary bisections because */
+ /* each bisection predictably reduces deviation exactly 4-fold. */
+ /* Even 32-bit deviation would vanish after 16 bisections. */
+ draw = 1;
+ while ( dx > ONE_PIXEL / 4 )
{
- dx >>= 2;
- level++;
- } while ( dx > ONE_PIXEL / 4 );
-
- levels[0] = level;
+ dx >>= 2;
+ draw <<= 1;
+ }
+ /* We use decrement counter to count the total number of segments */
+ /* to draw starting from 2^level. Before each draw we split as */
+ /* many times as there are trailing zeros in the counter. */
do
{
- level = levels[top];
- if ( level > 0 )
+ split = 1;
+ while ( ( draw & split ) == 0 )
{
gray_split_conic( arc );
arc += 2;
- top++;
- levels[top] = levels[top - 1] = level - 1;
- continue;
+ split <<= 1;
}
- Draw:
gray_render_line( RAS_VAR_ arc[0].x, arc[0].y );
- top--;
arc -= 2;
- } while ( top >= 0 );
+ } while ( --draw );
}
@@ -1038,11 +1092,13 @@ typedef ptrdiff_t FT_PtrDist;
const FT_Vector* control2,
const FT_Vector* to )
{
- FT_Vector* arc;
- TPos min, max, y;
+ FT_Vector bez_stack[16 * 3 + 1]; /* enough to accommodate bisections */
+ FT_Vector* arc = bez_stack;
+ TPos dx, dy, dx_, dy_;
+ TPos dx1, dy1, dx2, dy2;
+ TPos L, s, s_limit;
- arc = ras.bez_stack;
arc[0].x = UPSCALE( to->x );
arc[0].y = UPSCALE( to->y );
arc[1].x = UPSCALE( control2->x );
@@ -1052,29 +1108,20 @@ typedef ptrdiff_t FT_PtrDist;
arc[3].x = ras.x;
arc[3].y = ras.y;
- /* Short-cut the arc that crosses the current band. */
- min = max = arc[0].y;
-
- y = arc[1].y;
- if ( y < min )
- min = y;
- if ( y > max )
- max = y;
-
- y = arc[2].y;
- if ( y < min )
- min = y;
- if ( y > max )
- max = y;
-
- y = arc[3].y;
- if ( y < min )
- min = y;
- if ( y > max )
- max = y;
-
- if ( TRUNC( min ) >= ras.max_ey || TRUNC( max ) < ras.min_ey )
- goto Draw;
+ /* short-cut the arc that crosses the current band */
+ if ( ( TRUNC( arc[0].y ) >= ras.max_ey &&
+ TRUNC( arc[1].y ) >= ras.max_ey &&
+ TRUNC( arc[2].y ) >= ras.max_ey &&
+ TRUNC( arc[3].y ) >= ras.max_ey ) ||
+ ( TRUNC( arc[0].y ) < ras.min_ey &&
+ TRUNC( arc[1].y ) < ras.min_ey &&
+ TRUNC( arc[2].y ) < ras.min_ey &&
+ TRUNC( arc[3].y ) < ras.min_ey ) )
+ {
+ ras.x = arc[0].x;
+ ras.y = arc[0].y;
+ return;
+ }
for (;;)
{
@@ -1083,64 +1130,53 @@ typedef ptrdiff_t FT_PtrDist;
/* F. Hain, at */
/* http://www.cis.southalabama.edu/~hain/general/Publications/Bezier/Camera-ready%20CISST02%202.pdf */
- {
- TPos dx, dy, dx_, dy_;
- TPos dx1, dy1, dx2, dy2;
- TPos L, s, s_limit;
+ /* dx and dy are x and y components of the P0-P3 chord vector. */
+ dx = dx_ = arc[3].x - arc[0].x;
+ dy = dy_ = arc[3].y - arc[0].y;
+ L = FT_HYPOT( dx_, dy_ );
- /* dx and dy are x and y components of the P0-P3 chord vector. */
- dx = dx_ = arc[3].x - arc[0].x;
- dy = dy_ = arc[3].y - arc[0].y;
+ /* Avoid possible arithmetic overflow below by splitting. */
+ if ( L > 32767 )
+ goto Split;
- L = FT_HYPOT( dx_, dy_ );
+ /* Max deviation may be as much as (s/L) * 3/4 (if Hain's v = 1). */
+ s_limit = L * (TPos)( ONE_PIXEL / 6 );
- /* Avoid possible arithmetic overflow below by splitting. */
- if ( L > 32767 )
- goto Split;
+ /* s is L * the perpendicular distance from P1 to the line P0-P3. */
+ dx1 = arc[1].x - arc[0].x;
+ dy1 = arc[1].y - arc[0].y;
+ s = FT_ABS( SUB_LONG( MUL_LONG( dy, dx1 ), MUL_LONG( dx, dy1 ) ) );
- /* Max deviation may be as much as (s/L) * 3/4 (if Hain's v = 1). */
- s_limit = L * (TPos)( ONE_PIXEL / 6 );
+ if ( s > s_limit )
+ goto Split;
- /* s is L * the perpendicular distance from P1 to the line P0-P3. */
- dx1 = arc[1].x - arc[0].x;
- dy1 = arc[1].y - arc[0].y;
- s = FT_ABS( dy * dx1 - dx * dy1 );
+ /* s is L * the perpendicular distance from P2 to the line P0-P3. */
+ dx2 = arc[2].x - arc[0].x;
+ dy2 = arc[2].y - arc[0].y;
+ s = FT_ABS( SUB_LONG( MUL_LONG( dy, dx2 ), MUL_LONG( dx, dy2 ) ) );
- if ( s > s_limit )
- goto Split;
+ if ( s > s_limit )
+ goto Split;
- /* s is L * the perpendicular distance from P2 to the line P0-P3. */
- dx2 = arc[2].x - arc[0].x;
- dy2 = arc[2].y - arc[0].y;
- s = FT_ABS( dy * dx2 - dx * dy2 );
+ /* Split super curvy segments where the off points are so far
+ from the chord that the angles P0-P1-P3 or P0-P2-P3 become
+ acute as detected by appropriate dot products. */
+ if ( dx1 * ( dx1 - dx ) + dy1 * ( dy1 - dy ) > 0 ||
+ dx2 * ( dx2 - dx ) + dy2 * ( dy2 - dy ) > 0 )
+ goto Split;
- if ( s > s_limit )
- goto Split;
+ gray_render_line( RAS_VAR_ arc[0].x, arc[0].y );
- /* Split super curvy segments where the off points are so far
- from the chord that the angles P0-P1-P3 or P0-P2-P3 become
- acute as detected by appropriate dot products. */
- if ( dx1 * ( dx1 - dx ) + dy1 * ( dy1 - dy ) > 0 ||
- dx2 * ( dx2 - dx ) + dy2 * ( dy2 - dy ) > 0 )
- goto Split;
+ if ( arc == bez_stack )
+ return;
- /* No reason to split. */
- goto Draw;
- }
+ arc -= 3;
+ continue;
Split:
gray_split_cubic( arc );
arc += 3;
- continue;
-
- Draw:
- gray_render_line( RAS_VAR_ arc[0].x, arc[0].y );
-
- if ( arc == ras.bez_stack )
- return;
-
- arc -= 3;
}
}
@@ -1152,18 +1188,14 @@ 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 ) );
- worker->x = x;
- worker->y = y;
+ ras.x = x;
+ ras.y = y;
return 0;
}
@@ -1199,83 +1231,23 @@ 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 )
- {
- /* 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.
- */
- if ( spans->len >= 8 )
- FT_MEM_SET( p + spans->x, (unsigned char)coverage, spans->len );
- else
- {
- unsigned char* q = p + spans->x;
-
-
- switch ( spans->len )
- {
- case 7: *q++ = (unsigned char)coverage;
- case 6: *q++ = (unsigned char)coverage;
- case 5: *q++ = (unsigned char)coverage;
- case 4: *q++ = (unsigned char)coverage;
- case 3: *q++ = (unsigned char)coverage;
- case 2: *q++ = (unsigned char)coverage;
- case 1: *q = (unsigned char)coverage;
- default:
- ;
- }
- }
- }
- }
- }
-
-
- static void
gray_hline( RAS_ARG_ TCoord x,
TCoord y,
- TPos 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
{
@@ -1284,179 +1256,83 @@ typedef ptrdiff_t FT_PtrDist;
coverage = 255;
}
- y += (TCoord)ras.min_ey;
- x += (TCoord)ras.min_ex;
-
- /* FT_Span.x is a 16-bit short, so limit our coordinates appropriately */
- if ( x >= 32767 )
- x = 32767;
-
- /* FT_Span.y is an integer, so limit our coordinates appropriately */
- if ( y >= FT_INT_MAX )
- y = FT_INT_MAX;
-
- if ( coverage )
+ if ( ras.render_span ) /* for FT_RASTER_FLAG_DIRECT only */
{
- FT_Span* span;
- int count;
+ FT_Span span;
- /* see whether we can add this span to the current list */
- count = ras.num_gray_spans;
- span = ras.gray_spans + count - 1;
- if ( count > 0 &&
- ras.span_y == y &&
- (int)span->x + span->len == (int)x &&
- span->coverage == coverage )
- {
- span->len = (unsigned short)( span->len + acount );
- return;
- }
+ span.x = (short)x;
+ span.len = (unsigned short)acount;
+ span.coverage = (unsigned char)coverage;
- 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 );
-
-#ifdef FT_DEBUG_LEVEL_TRACE
-
- if ( count > 0 )
- {
- int n;
-
-
- 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.num_gray_spans = 0;
- ras.span_y = (int)y;
-
- span = ras.gray_spans;
- }
- 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++;
+ ras.render_span( y, 1, &span, ras.render_span_data );
}
- }
-
-
-#ifdef FT_DEBUG_LEVEL_TRACE
-
- /* to be called while in the debugger -- */
- /* this function causes a compiler warning since it is unused otherwise */
- static void
- gray_dump_cells( RAS_ARG )
- {
- int yindex;
-
-
- for ( yindex = 0; yindex < ras.ycount; yindex++ )
+ else
{
- PCell cell;
+ unsigned char* q = ras.target.origin - ras.target.pitch * y + x;
+ unsigned char c = (unsigned char)coverage;
- printf( "%3d:", yindex );
-
- for ( cell = ras.ycells[yindex]; cell != NULL; cell = cell->next )
- printf( " (%3ld, c:%4ld, a:%6d)", cell->x, cell->cover, cell->area );
- printf( "\n" );
+ /* 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 );
+ }
}
}
-#endif /* FT_DEBUG_LEVEL_TRACE */
-
static void
- gray_sweep( RAS_ARG_ const FT_Bitmap* target )
+ gray_sweep( RAS_ARG )
{
- int yindex;
+ int y;
- FT_UNUSED( target );
-
-
- if ( ras.num_cells == 0 )
- return;
- ras.num_gray_spans = 0;
-
- FT_TRACE7(( "gray_sweep: start\n" ));
-
- for ( yindex = 0; yindex < ras.ycount; 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 )
{
- TPos area;
+ if ( cover != 0 && cell->x > x )
+ gray_hline( RAS_VAR_ x, y, cover, cell->x - x );
+ cover += (TArea)cell->cover * ( ONE_PIXEL * 2 );
+ area = cover - cell->area;
- if ( cell->x > x && cover != 0 )
- gray_hline( RAS_VAR_ x, yindex, cover * ( ONE_PIXEL * 2 ),
- cell->x - x );
-
- cover += cell->cover;
- area = cover * ( ONE_PIXEL * 2 ) - 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, cover * ( ONE_PIXEL * 2 ),
- ras.count_ex - x );
+ gray_hline( RAS_VAR_ x, y, cover, ras.max_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" ));
- }
-
- FT_TRACE7(( "gray_sweep: end\n" ));
-
-#endif /* FT_DEBUG_LEVEL_TRACE */
-
}
-#ifdef _STANDALONE_
+#ifdef STANDALONE_
/*************************************************************************/
/* */
- /* The following function should only compile in stand-alone mode, */
+ /* The following functions should only compile in stand-alone mode, */
/* i.e., when building this component without the rest of FreeType. */
/* */
/*************************************************************************/
@@ -1727,32 +1603,102 @@ 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:
return FT_THROW( Invalid_Outline );
}
-#endif /* _STANDALONE_ */
+ /*************************************************************************/
+ /* */
+ /* <Function> */
+ /* FT_Outline_Get_CBox */
+ /* */
+ /* <Description> */
+ /* Return an outline's `control box'. The control box encloses all */
+ /* the outline's points, including Bézier control points. Though it */
+ /* coincides with the exact bounding box for most glyphs, it can be */
+ /* slightly larger in some situations (like when rotating an outline */
+ /* that contains Bézier outside arcs). */
+ /* */
+ /* Computing the control box is very fast, while getting the bounding */
+ /* box can take much more time as it needs to walk over all segments */
+ /* and arcs in the outline. To get the latter, you can use the */
+ /* `ftbbox' component, which is dedicated to this single task. */
+ /* */
+ /* <Input> */
+ /* outline :: A pointer to the source outline descriptor. */
+ /* */
+ /* <Output> */
+ /* acbox :: The outline's control box. */
+ /* */
+ /* <Note> */
+ /* See @FT_Glyph_Get_CBox for a discussion of tricky fonts. */
+ /* */
- typedef struct gray_TBand_
+ static void
+ FT_Outline_Get_CBox( const FT_Outline* outline,
+ FT_BBox *acbox )
{
- TPos min, max;
+ TPos xMin, yMin, xMax, yMax;
+
+
+ if ( outline && acbox )
+ {
+ if ( outline->n_points == 0 )
+ {
+ xMin = 0;
+ yMin = 0;
+ xMax = 0;
+ yMax = 0;
+ }
+ else
+ {
+ FT_Vector* vec = outline->points;
+ FT_Vector* limit = vec + outline->n_points;
+
- } gray_TBand;
+ xMin = xMax = vec->x;
+ yMin = yMax = vec->y;
+ vec++;
+
+ for ( ; vec < limit; vec++ )
+ {
+ TPos x, y;
+
+
+ x = vec->x;
+ if ( x < xMin ) xMin = x;
+ if ( x > xMax ) xMax = x;
+
+ y = vec->y;
+ if ( y < yMin ) yMin = y;
+ if ( y > yMax ) yMax = y;
+ }
+ }
+ acbox->xMin = xMin;
+ acbox->xMax = xMax;
+ acbox->yMin = yMin;
+ acbox->yMax = yMax;
+ }
+ }
+
+#endif /* STANDALONE_ */
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
@@ -1771,10 +1717,21 @@ typedef ptrdiff_t FT_PtrDist;
error = FT_Outline_Decompose( &ras.outline, &func_interface, &ras );
if ( !ras.invalid )
gray_record_cell( RAS_VAR );
+
+ FT_TRACE7(( "band [%d..%d]: %d cell%s\n",
+ ras.min_ey,
+ ras.max_ey,
+ ras.num_cells,
+ ras.num_cells == 1 ? "" : "s" ));
}
else
+ {
error = FT_THROW( Memory_Overflow );
+ FT_TRACE7(( "band [%d..%d]: to be bisected\n",
+ ras.min_ey, ras.max_ey ));
+ }
+
return error;
}
@@ -1782,158 +1739,108 @@ typedef ptrdiff_t FT_PtrDist;
static int
gray_convert_glyph( RAS_ARG )
{
- gray_TBand bands[40];
- gray_TBand* volatile band;
- int volatile n, num_bands;
- TPos volatile min, max, max_y;
- FT_BBox* clip;
-
-
- /* Set up state in the raster object */
- gray_compute_cbox( RAS_VAR );
-
- /* clip to target bitmap, exit if nothing to do */
- clip = &ras.clip_box;
+ const TCoord yMin = ras.min_ey;
+ const TCoord yMax = ras.max_ey;
+ const TCoord xMin = ras.min_ex;
+ const TCoord xMax = ras.max_ex;
- if ( ras.max_ex <= clip->xMin || ras.min_ex >= clip->xMax ||
- ras.max_ey <= clip->yMin || ras.min_ey >= clip->yMax )
- return 0;
-
- if ( ras.min_ex < clip->xMin ) ras.min_ex = clip->xMin;
- if ( ras.min_ey < clip->yMin ) ras.min_ey = clip->yMin;
-
- if ( ras.max_ex > clip->xMax ) ras.max_ex = clip->xMax;
- if ( ras.max_ey > clip->yMax ) ras.max_ey = clip->yMax;
+ TCell buffer[FT_MAX_GRAY_POOL];
+ size_t height = (size_t)( yMax - yMin );
+ size_t n = FT_MAX_GRAY_POOL / 8;
+ TCoord y;
+ TCoord bands[32]; /* enough to accommodate bisections */
+ TCoord* band;
- ras.count_ex = ras.max_ex - ras.min_ex;
- ras.count_ey = ras.max_ey - ras.min_ey;
/* set up vertical bands */
- num_bands = (int)( ( ras.max_ey - ras.min_ey ) / ras.band_size );
- if ( num_bands == 0 )
- num_bands = 1;
- if ( num_bands >= 39 )
- num_bands = 39;
+ if ( height > n )
+ {
+ /* two divisions rounded up */
+ n = ( height + n - 1 ) / n;
+ height = ( height + n - 1 ) / n;
+ }
- ras.band_shoot = 0;
+ /* memory management */
+ n = ( height * sizeof ( PCell ) + sizeof ( TCell ) - 1 ) / sizeof ( TCell );
- min = ras.min_ey;
- max_y = ras.max_ey;
+ ras.cells = buffer + n;
+ ras.max_cells = (FT_PtrDist)( FT_MAX_GRAY_POOL - n );
+ ras.ycells = (PCell*)buffer;
- for ( n = 0; n < num_bands; n++, min = max )
+ for ( y = yMin; y < yMax; )
{
- max = min + ras.band_size;
- if ( n == num_bands - 1 || max > max_y )
- max = max_y;
+ ras.min_ey = y;
+ y += height;
+ ras.max_ey = FT_MIN( y, yMax );
- bands[0].min = min;
- bands[0].max = max;
- band = bands;
+ band = bands;
+ band[1] = xMin;
+ band[0] = xMax;
do
{
- TPos bottom, top, middle;
- int error;
-
- {
- PCell cells_max;
- int yindex;
- long cell_start, cell_end, cell_mod;
-
-
- ras.ycells = (PCell*)ras.buffer;
- ras.ycount = band->max - band->min;
-
- cell_start = (long)sizeof ( PCell ) * ras.ycount;
- cell_mod = cell_start % (long)sizeof ( TCell );
- if ( cell_mod > 0 )
- cell_start += (long)sizeof ( TCell ) - cell_mod;
+ TCoord width = band[0] - band[1];
+ int error;
- cell_end = ras.buffer_size;
- cell_end -= cell_end % (long)sizeof ( TCell );
- cells_max = (PCell)( (char*)ras.buffer + cell_end );
- ras.cells = (PCell)( (char*)ras.buffer + cell_start );
- if ( ras.cells >= cells_max )
- goto ReduceBands;
-
- ras.max_cells = cells_max - ras.cells;
- if ( ras.max_cells < 2 )
- goto ReduceBands;
-
- for ( yindex = 0; yindex < ras.ycount; yindex++ )
- ras.ycells[yindex] = NULL;
- }
+ FT_MEM_ZERO( ras.ycells, height * sizeof ( PCell ) );
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_ex = band[1];
+ ras.max_ex = band[0];
error = gray_convert_glyph_inner( RAS_VAR );
if ( !error )
{
- gray_sweep( RAS_VAR_ &ras.target );
+ gray_sweep( RAS_VAR );
band--;
continue;
}
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 )
+ /* this should never happen even with tiny rendering pool */
+ if ( width == 0 )
{
-#ifdef FT_DEBUG_LEVEL_TRACE
FT_TRACE7(( "gray_convert_glyph: rotten glyph\n" ));
-#endif
return 1;
}
- if ( bottom-top >= ras.band_size )
- ras.band_shoot++;
-
- 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 );
}
- if ( ras.band_shoot > 8 && ras.band_size > 16 )
- ras.band_size = ras.band_size / 2;
-
return 0;
}
static int
- gray_raster_render( gray_PRaster raster,
+ 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];
-
- TCell buffer[FT_MAX( FT_RENDER_POOL_SIZE, 2048 ) / sizeof ( TCell )];
- long buffer_size = sizeof ( buffer );
- int band_size = (int)( buffer_size /
- (long)( sizeof ( TCell ) * 8 ) );
+#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 );
@@ -1948,9 +1855,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 );
@@ -1960,51 +1877,59 @@ typedef ptrdiff_t FT_PtrDist;
if ( !target_map->buffer )
return FT_THROW( Invalid_Argument );
+
+ 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;
}
- /* this version does not support monochrome rendering */
- if ( !( params->flags & FT_RASTER_FLAG_AA ) )
- return FT_THROW( Invalid_Mode );
+ FT_Outline_Get_CBox( outline, &cbox );
+
+ /* reject too large outline coordinates */
+ if ( cbox.xMin < -0x1000000L || cbox.xMax > 0x1000000L ||
+ cbox.yMin < -0x1000000L || cbox.yMax > 0x1000000L )
+ return FT_THROW( Invalid_Outline );
+
+ /* truncate the bounding box to integer pixels */
+ cbox.xMin = cbox.xMin >> 6;
+ cbox.yMin = cbox.yMin >> 6;
+ cbox.xMax = ( cbox.xMax + 63 ) >> 6;
+ cbox.yMax = ( cbox.yMax + 63 ) >> 6;
/* compute clipping box */
if ( !( params->flags & FT_RASTER_FLAG_DIRECT ) )
{
/* compute clip box from target pixmap */
- ras.clip_box.xMin = 0;
- ras.clip_box.yMin = 0;
- ras.clip_box.xMax = (FT_Pos)target_map->width;
- ras.clip_box.yMax = (FT_Pos)target_map->rows;
+ clip.xMin = 0;
+ clip.yMin = 0;
+ clip.xMax = (FT_Pos)target_map->width;
+ clip.yMax = (FT_Pos)target_map->rows;
}
else if ( params->flags & FT_RASTER_FLAG_CLIP )
- ras.clip_box = params->clip_box;
+ clip = params->clip_box;
else
{
- ras.clip_box.xMin = -32768L;
- ras.clip_box.yMin = -32768L;
- ras.clip_box.xMax = 32767L;
- ras.clip_box.yMax = 32767L;
+ clip.xMin = -32768L;
+ clip.yMin = -32768L;
+ clip.xMax = 32767L;
+ clip.yMax = 32767L;
}
- gray_init_cells( RAS_VAR_ buffer, buffer_size );
-
- ras.outline = *outline;
- ras.num_cells = 0;
- ras.invalid = 1;
- ras.band_size = band_size;
- ras.num_gray_spans = 0;
- ras.span_y = 0;
+ /* clip to target bitmap, exit if nothing to do */
+ ras.min_ex = FT_MAX( cbox.xMin, clip.xMin );
+ ras.min_ey = FT_MAX( cbox.yMin, clip.yMin );
+ ras.max_ex = FT_MIN( cbox.xMax, clip.xMax );
+ ras.max_ey = FT_MIN( cbox.yMax, clip.yMax );
- 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;
- }
+ if ( ras.max_ex <= ras.min_ex || ras.max_ey <= ras.min_ey )
+ return 0;
return gray_convert_glyph( RAS_VAR );
}
@@ -2013,7 +1938,7 @@ typedef ptrdiff_t FT_PtrDist;
/**** RASTER OBJECT CREATION: In stand-alone mode, we simply use *****/
/**** a static object. *****/
-#ifdef _STANDALONE_
+#ifdef STANDALONE_
static int
gray_raster_new( void* memory,
@@ -2025,7 +1950,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;
}
@@ -2038,7 +1963,7 @@ typedef ptrdiff_t FT_PtrDist;
FT_UNUSED( raster );
}
-#else /* !_STANDALONE_ */
+#else /* !STANDALONE_ */
static int
gray_raster_new( FT_Memory memory,
@@ -2068,13 +1993,13 @@ typedef ptrdiff_t FT_PtrDist;
FT_FREE( raster );
}
-#endif /* !_STANDALONE_ */
+#endif /* !STANDALONE_ */
static void
- gray_raster_reset( FT_Raster raster,
- char* pool_base,
- long pool_size )
+ gray_raster_reset( FT_Raster raster,
+ unsigned char* pool_base,
+ unsigned long pool_size )
{
FT_UNUSED( raster );
FT_UNUSED( pool_base );
@@ -2101,11 +2026,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/src/3rdparty/freetype/src/smooth/ftgrays.h b/src/3rdparty/freetype/src/smooth/ftgrays.h
index 1b5760330c..9e11ca675e 100644
--- a/src/3rdparty/freetype/src/smooth/ftgrays.h
+++ b/src/3rdparty/freetype/src/smooth/ftgrays.h
@@ -4,7 +4,7 @@
/* */
/* FreeType smooth renderer declaration */
/* */
-/* Copyright 1996-2015 by */
+/* Copyright 1996-2018 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -16,15 +16,15 @@
/***************************************************************************/
-#ifndef __FTGRAYS_H__
-#define __FTGRAYS_H__
+#ifndef FTGRAYS_H_
+#define FTGRAYS_H_
#ifdef __cplusplus
extern "C" {
#endif
-#ifdef _STANDALONE_
+#ifdef STANDALONE_
#include "ftimage.h"
#else
#include <ft2build.h>
@@ -52,7 +52,7 @@
}
#endif
-#endif /* __FTGRAYS_H__ */
+#endif /* FTGRAYS_H_ */
/* END */
diff --git a/src/3rdparty/freetype/src/smooth/ftsmerrs.h b/src/3rdparty/freetype/src/smooth/ftsmerrs.h
index cc38aa1996..226dc1b001 100644
--- a/src/3rdparty/freetype/src/smooth/ftsmerrs.h
+++ b/src/3rdparty/freetype/src/smooth/ftsmerrs.h
@@ -4,7 +4,7 @@
/* */
/* smooth renderer error codes (specification only). */
/* */
-/* Copyright 2001-2015 by */
+/* Copyright 2001-2018 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -23,12 +23,12 @@
/* */
/*************************************************************************/
-#ifndef __FTSMERRS_H__
-#define __FTSMERRS_H__
+#ifndef FTSMERRS_H_
+#define FTSMERRS_H_
#include FT_MODULE_ERRORS_H
-#undef __FTERRORS_H__
+#undef FTERRORS_H_
#undef FT_ERR_PREFIX
#define FT_ERR_PREFIX Smooth_Err_
@@ -36,7 +36,7 @@
#include FT_ERRORS_H
-#endif /* __FTSMERRS_H__ */
+#endif /* FTSMERRS_H_ */
/* END */
diff --git a/src/3rdparty/freetype/src/smooth/ftsmooth.c b/src/3rdparty/freetype/src/smooth/ftsmooth.c
index 3620550534..ef176bdf1e 100644
--- a/src/3rdparty/freetype/src/smooth/ftsmooth.c
+++ b/src/3rdparty/freetype/src/smooth/ftsmooth.c
@@ -4,7 +4,7 @@
/* */
/* Anti-aliasing renderer interface (body). */
/* */
-/* Copyright 2000-2015 by */
+/* Copyright 2000-2018 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -31,12 +31,7 @@
static FT_Error
ft_smooth_init( FT_Renderer render )
{
- FT_Library library = FT_MODULE_LIBRARY( render );
-
-
- render->clazz->raster_class->raster_reset( render->raster,
- library->raster_pool,
- library->raster_pool_size );
+ render->clazz->raster_class->raster_reset( render->raster, NULL, 0 );
return 0;
}
@@ -87,7 +82,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 );
@@ -102,26 +97,17 @@
const FT_Vector* origin,
FT_Render_Mode required_mode )
{
- FT_Error error;
+ FT_Error error = FT_Err_Ok;
FT_Outline* outline = &slot->outline;
FT_Bitmap* bitmap = &slot->bitmap;
FT_Memory memory = render->root.memory;
- FT_BBox cbox;
FT_Pos x_shift = 0;
FT_Pos y_shift = 0;
- FT_Pos x_left, y_top;
- FT_Pos width, height, pitch;
-#ifndef FT_CONFIG_OPTION_SUBPIXEL_RENDERING
- FT_Pos height_org, width_org;
-#endif
- FT_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;
-
/* check glyph image format */
if ( slot->format != render->glyph_format )
@@ -137,91 +123,6 @@
goto Exit;
}
- if ( origin )
- {
- x_shift = origin->x;
- y_shift = origin->y;
- }
-
- /* compute the control box, and grid fit it */
- /* taking into account the origin shift */
- FT_Outline_Get_CBox( outline, &cbox );
-
- cbox.xMin = FT_PIX_FLOOR( cbox.xMin + x_shift );
- cbox.yMin = FT_PIX_FLOOR( cbox.yMin + y_shift );
- cbox.xMax = FT_PIX_CEIL( cbox.xMax + x_shift );
- cbox.yMax = FT_PIX_CEIL( cbox.yMax + y_shift );
-
- x_shift -= cbox.xMin;
- y_shift -= cbox.yMin;
-
- x_left = cbox.xMin >> 6;
- y_top = cbox.yMax >> 6;
-
- width = (FT_ULong)( cbox.xMax - cbox.xMin ) >> 6;
- height = (FT_ULong)( cbox.yMax - cbox.yMin ) >> 6;
-
-#ifndef FT_CONFIG_OPTION_SUBPIXEL_RENDERING
- width_org = width;
- height_org = height;
-#endif
-
- pitch = width;
- if ( hmul )
- {
- width *= 3;
- pitch = FT_PAD_CEIL( width, 4 );
- }
-
- if ( vmul )
- height *= 3;
-
-#ifdef FT_CONFIG_OPTION_SUBPIXEL_RENDERING
-
- if ( slot->library->lcd_filter_func )
- {
- FT_Int extra = slot->library->lcd_extra;
-
-
- if ( hmul )
- {
- x_shift += 64 * ( extra >> 1 );
- x_left -= extra >> 1;
- width += 3 * extra;
- pitch = FT_PAD_CEIL( width, 4 );
- }
-
- if ( vmul )
- {
- y_shift += 64 * ( extra >> 1 );
- y_top += extra >> 1;
- height += 3 * extra;
- }
- }
-
-#endif
-
- /*
- * XXX: on 16bit system, we return an error for huge bitmap
- * to prevent an overflow.
- */
- if ( x_left > FT_INT_MAX || y_top > FT_INT_MAX ||
- x_left < FT_INT_MIN || y_top < FT_INT_MIN )
- {
- error = FT_THROW( Invalid_Pixel_Size );
- goto Exit;
- }
-
- /* Required check is (pitch * height < FT_ULONG_MAX), */
- /* but we care realistic cases only. Always pitch <= width. */
- if ( width > 0x7FFF || height > 0x7FFF )
- {
- FT_ERROR(( "ft_smooth_render_generic: glyph too large: %u x %u\n",
- width, height ));
- error = FT_THROW( Raster_Overflow );
- goto Exit;
- }
-
/* release old bitmap buffer */
if ( slot->internal->flags & FT_GLYPH_OWN_BITMAP )
{
@@ -229,30 +130,30 @@
slot->internal->flags &= ~FT_GLYPH_OWN_BITMAP;
}
+ ft_glyphslot_preset_bitmap( slot, mode, origin );
+
/* allocate new one */
- if ( FT_ALLOC( bitmap->buffer, (FT_ULong)( pitch * height ) ) )
+ if ( FT_ALLOC_MULT( bitmap->buffer, bitmap->rows, bitmap->pitch ) )
goto Exit;
- else
- have_buffer = TRUE;
slot->internal->flags |= FT_GLYPH_OWN_BITMAP;
- slot->format = FT_GLYPH_FORMAT_BITMAP;
- slot->bitmap_left = (FT_Int)x_left;
- slot->bitmap_top = (FT_Int)y_top;
+ x_shift = 64 * -slot->bitmap_left;
+ y_shift = 64 * -slot->bitmap_top;
+ if ( bitmap->pixel_mode == FT_PIXEL_MODE_LCD_V )
+ y_shift += 64 * (FT_Int)bitmap->rows / 3;
+ else
+ y_shift += 64 * (FT_Int)bitmap->rows;
- bitmap->pixel_mode = FT_PIXEL_MODE_GRAY;
- bitmap->num_grays = 256;
- bitmap->width = (unsigned int)width;
- bitmap->rows = (unsigned int)height;
- bitmap->pitch = pitch;
+ if ( origin )
+ {
+ x_shift += origin->x;
+ y_shift += origin->y;
+ }
/* translate outline to render it into the bitmap */
if ( x_shift || y_shift )
- {
FT_Outline_Translate( outline, x_shift, y_shift );
- have_outline_shifted = TRUE;
- }
/* set up parameters */
params.target = bitmap;
@@ -299,80 +200,143 @@
if ( error )
goto Exit;
- if ( slot->library->lcd_filter_func )
- slot->library->lcd_filter_func( bitmap, mode, slot->library );
+ /* finally apply filtering */
+ if ( hmul || vmul )
+ {
+ FT_Byte* lcd_weights;
+ FT_Bitmap_LcdFilterFunc lcd_filter_func;
-#else /* !FT_CONFIG_OPTION_SUBPIXEL_RENDERING */
- /* render outline into bitmap */
- error = render->raster_render( render->raster, &params );
- if ( error )
- goto Exit;
+ /* Per-face LCD filtering takes priority if set up. */
+ if ( slot->face && slot->face->internal->lcd_filter_func )
+ {
+ lcd_weights = slot->face->internal->lcd_weights;
+ lcd_filter_func = slot->face->internal->lcd_filter_func;
+ }
+ else
+ {
+ lcd_weights = slot->library->lcd_weights;
+ lcd_filter_func = slot->library->lcd_filter_func;
+ }
- /* expand it horizontally */
- if ( hmul )
+ if ( lcd_filter_func )
+ lcd_filter_func( bitmap, mode, lcd_weights );
+ }
+
+#else /* !FT_CONFIG_OPTION_SUBPIXEL_RENDERING */
+
+ if ( hmul ) /* lcd */
{
- FT_Byte* line = bitmap->buffer;
- FT_UInt hh;
+ FT_Byte* line;
+ FT_Byte* temp = NULL;
+ FT_UInt i, j;
+ unsigned int height = bitmap->rows;
+ unsigned int width = bitmap->width;
+ int pitch = bitmap->pitch;
- for ( hh = height_org; hh > 0; hh--, line += pitch )
- {
- FT_UInt xx;
- FT_Byte* end = line + width;
+ /* Render 3 separate monochrome bitmaps, shifting the outline */
+ /* by 1/3 pixel. */
+ width /= 3;
- for ( xx = width_org; xx > 0; xx-- )
- {
- FT_UInt pixel = line[xx-1];
+ bitmap->buffer += width;
+ error = render->raster_render( render->raster, &params );
+ if ( error )
+ goto Exit;
- end[-3] = (FT_Byte)pixel;
- end[-2] = (FT_Byte)pixel;
- end[-1] = (FT_Byte)pixel;
- end -= 3;
+ FT_Outline_Translate( outline, -21, 0 );
+ x_shift -= 21;
+ bitmap->buffer += width;
+
+ error = render->raster_render( render->raster, &params );
+ if ( error )
+ goto Exit;
+
+ FT_Outline_Translate( outline, 42, 0 );
+ x_shift += 42;
+ bitmap->buffer -= 2 * width;
+
+ error = render->raster_render( render->raster, &params );
+ if ( error )
+ goto Exit;
+
+ /* XXX: Rearrange the bytes according to FT_PIXEL_MODE_LCD. */
+ /* XXX: It is more efficient to render every third byte above. */
+
+ if ( FT_ALLOC( temp, (FT_ULong)pitch ) )
+ goto Exit;
+
+ for ( i = 0; i < height; i++ )
+ {
+ line = bitmap->buffer + i * (FT_ULong)pitch;
+ for ( j = 0; j < width; j++ )
+ {
+ temp[3 * j ] = line[j];
+ temp[3 * j + 1] = line[j + width];
+ temp[3 * j + 2] = line[j + width + width];
}
+ FT_MEM_COPY( line, temp, pitch );
}
- }
- /* expand it vertically */
- if ( vmul )
+ FT_FREE( temp );
+ }
+ else if ( vmul ) /* lcd_v */
{
- FT_Byte* read = bitmap->buffer + ( height - height_org ) * pitch;
- FT_Byte* write = bitmap->buffer;
- FT_UInt hh;
+ int pitch = bitmap->pitch;
- for ( hh = height_org; hh > 0; hh-- )
- {
- ft_memcpy( write, read, pitch );
- write += pitch;
+ /* Render 3 separate monochrome bitmaps, shifting the outline */
+ /* by 1/3 pixel. Triple the pitch to render on each third row. */
+ bitmap->pitch *= 3;
+ bitmap->rows /= 3;
- ft_memcpy( write, read, pitch );
- write += pitch;
+ bitmap->buffer += pitch;
- ft_memcpy( write, read, pitch );
- write += pitch;
- read += pitch;
- }
- }
+ error = render->raster_render( render->raster, &params );
+ if ( error )
+ goto Exit;
-#endif /* !FT_CONFIG_OPTION_SUBPIXEL_RENDERING */
+ FT_Outline_Translate( outline, 0, 21 );
+ y_shift += 21;
+ bitmap->buffer += pitch;
+
+ error = render->raster_render( render->raster, &params );
+ if ( error )
+ goto Exit;
+
+ FT_Outline_Translate( outline, 0, -42 );
+ y_shift -= 42;
+ bitmap->buffer -= 2 * pitch;
- /* everything is fine; don't deallocate buffer */
- have_buffer = FALSE;
+ error = render->raster_render( render->raster, &params );
+ if ( error )
+ goto Exit;
- error = FT_Err_Ok;
+ bitmap->pitch /= 3;
+ bitmap->rows *= 3;
+ }
+ else /* grayscale */
+ error = render->raster_render( render->raster, &params );
+
+#endif /* !FT_CONFIG_OPTION_SUBPIXEL_RENDERING */
Exit:
- if ( have_outline_shifted )
- FT_Outline_Translate( outline, -x_shift, -y_shift );
- if ( have_buffer )
+ if ( !error )
+ {
+ /* everything is fine; the glyph is now officially a bitmap */
+ slot->format = FT_GLYPH_FORMAT_BITMAP;
+ }
+ else if ( slot->internal->flags & FT_GLYPH_OWN_BITMAP )
{
FT_FREE( bitmap->buffer );
slot->internal->flags &= ~FT_GLYPH_OWN_BITMAP;
}
+ if ( x_shift || y_shift )
+ FT_Outline_Translate( outline, -x_shift, -y_shift );
+
return error;
}
@@ -399,14 +363,8 @@
FT_Render_Mode mode,
const FT_Vector* origin )
{
- FT_Error error;
-
- error = ft_smooth_render_generic( render, slot, mode, origin,
- FT_RENDER_MODE_LCD );
- if ( !error )
- slot->bitmap.pixel_mode = FT_PIXEL_MODE_LCD;
-
- return error;
+ return ft_smooth_render_generic( render, slot, mode, origin,
+ FT_RENDER_MODE_LCD );
}
@@ -417,18 +375,13 @@
FT_Render_Mode mode,
const FT_Vector* origin )
{
- FT_Error error;
-
- error = ft_smooth_render_generic( render, slot, mode, origin,
- FT_RENDER_MODE_LCD_V );
- if ( !error )
- slot->bitmap.pixel_mode = FT_PIXEL_MODE_LCD_V;
-
- return error;
+ return ft_smooth_render_generic( render, slot, mode, origin,
+ FT_RENDER_MODE_LCD_V );
}
- FT_DEFINE_RENDERER( ft_smooth_renderer_class,
+ FT_DEFINE_RENDERER(
+ ft_smooth_renderer_class,
FT_MODULE_RENDERER,
sizeof ( FT_RendererRec ),
@@ -437,25 +390,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 +417,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 +444,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/src/3rdparty/freetype/src/smooth/ftsmooth.h b/src/3rdparty/freetype/src/smooth/ftsmooth.h
index 765018c239..c76ffc5034 100644
--- a/src/3rdparty/freetype/src/smooth/ftsmooth.h
+++ b/src/3rdparty/freetype/src/smooth/ftsmooth.h
@@ -4,7 +4,7 @@
/* */
/* Anti-aliasing renderer interface (specification). */
/* */
-/* Copyright 1996-2015 by */
+/* Copyright 1996-2018 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -16,8 +16,8 @@
/***************************************************************************/
-#ifndef __FTSMOOTH_H__
-#define __FTSMOOTH_H__
+#ifndef FTSMOOTH_H_
+#define FTSMOOTH_H_
#include <ft2build.h>
@@ -27,23 +27,16 @@
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
-#endif /* __FTSMOOTH_H__ */
+#endif /* FTSMOOTH_H_ */
/* END */
diff --git a/src/3rdparty/freetype/src/smooth/ftspic.c b/src/3rdparty/freetype/src/smooth/ftspic.c
index 8e6ed57eec..10f04cf4cc 100644
--- a/src/3rdparty/freetype/src/smooth/ftspic.c
+++ b/src/3rdparty/freetype/src/smooth/ftspic.c
@@ -4,7 +4,7 @@
/* */
/* The FreeType position independent code services for smooth module. */
/* */
-/* Copyright 2009-2015 by */
+/* Copyright 2009-2018 by */
/* Oran Agra and Mickey Gabel. */
/* */
/* This file is part of the FreeType project, and may only be used, */
diff --git a/src/3rdparty/freetype/src/smooth/ftspic.h b/src/3rdparty/freetype/src/smooth/ftspic.h
index 071afcff20..80fb64cff4 100644
--- a/src/3rdparty/freetype/src/smooth/ftspic.h
+++ b/src/3rdparty/freetype/src/smooth/ftspic.h
@@ -4,7 +4,7 @@
/* */
/* The FreeType position independent code services for smooth module. */
/* */
-/* Copyright 2009-2015 by */
+/* Copyright 2009-2018 by */
/* Oran Agra and Mickey Gabel. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -16,8 +16,8 @@
/***************************************************************************/
-#ifndef __FTSPIC_H__
-#define __FTSPIC_H__
+#ifndef FTSPIC_H_
+#define FTSPIC_H_
#include FT_INTERNAL_PIC_H
@@ -69,7 +69,7 @@ FT_BEGIN_HEADER
FT_END_HEADER
-#endif /* __FTSPIC_H__ */
+#endif /* FTSPIC_H_ */
/* END */
diff --git a/src/3rdparty/freetype/src/smooth/module.mk b/src/3rdparty/freetype/src/smooth/module.mk
index 740936f5b1..5b8bc3be3b 100644
--- a/src/3rdparty/freetype/src/smooth/module.mk
+++ b/src/3rdparty/freetype/src/smooth/module.mk
@@ -3,7 +3,7 @@
#
-# Copyright 1996-2015 by
+# Copyright 1996-2018 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/src/3rdparty/freetype/src/smooth/rules.mk b/src/3rdparty/freetype/src/smooth/rules.mk
index f00ebd5f15..f30824a367 100644
--- a/src/3rdparty/freetype/src/smooth/rules.mk
+++ b/src/3rdparty/freetype/src/smooth/rules.mk
@@ -3,7 +3,7 @@
#
-# Copyright 1996-2015 by
+# Copyright 1996-2018 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/src/3rdparty/freetype/src/smooth/smooth.c b/src/3rdparty/freetype/src/smooth/smooth.c
index 4ca4344c89..5249a8931e 100644
--- a/src/3rdparty/freetype/src/smooth/smooth.c
+++ b/src/3rdparty/freetype/src/smooth/smooth.c
@@ -4,7 +4,7 @@
/* */
/* FreeType anti-aliasing rasterer module component (body only). */
/* */
-/* Copyright 1996-2015 by */
+/* Copyright 1996-2018 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/src/3rdparty/freetype/src/tools/afblue.pl b/src/3rdparty/freetype/src/tools/afblue.pl
index 56b6452348..7c6f1a7df1 100644
--- a/src/3rdparty/freetype/src/tools/afblue.pl
+++ b/src/3rdparty/freetype/src/tools/afblue.pl
@@ -5,7 +5,7 @@
#
# Process a blue zone character data file.
#
-# Copyright 2013-2015 by
+# Copyright 2013-2018 by
# David Turner, Robert Wilhelm, and Werner Lemberg.
#
# This file is part of the FreeType project, and may only be used,
@@ -38,7 +38,8 @@ my $curr_max; # Name of the current maximum value.
my $curr_enum_element; # Name of the current enumeration element.
my $curr_offset; # The offset relative to current aux. variable.
-my $curr_elem_size; # The size of the current string or block.
+my $curr_elem_size; # The number of non-space characters in the current string or
+ # the number of elements in the current block.
my $have_sections = 0; # Boolean; set if start of a section has been seen.
my $have_strings; # Boolean; set if current section contains strings.
@@ -159,12 +160,14 @@ sub convert_ascii_chars
# A series of ASCII characters in the printable range.
my $s = shift;
- # We ignore spaces.
- $s =~ s/ //g;
+ # We reduce multiple space characters to a single one.
+ $s =~ s/ +/ /g;
- my $count = $s =~ s/\G(.)/'$1', /g;
- $curr_offset += $count;
- $curr_elem_size += $count;
+ # Count all non-space characters. Note that `()' applies a list context
+ # to the capture that is used to count the elements.
+ $curr_elem_size += () = $s =~ /[^ ]/g;
+
+ $curr_offset += $s =~ s/\G(.)/'$1', /g;
return $s;
}
diff --git a/src/3rdparty/freetype/src/tools/apinames.c b/src/3rdparty/freetype/src/tools/apinames.c
index 9f81b1a6c7..06c3260430 100644
--- a/src/3rdparty/freetype/src/tools/apinames.c
+++ b/src/3rdparty/freetype/src/tools/apinames.c
@@ -22,7 +22,7 @@
#include <ctype.h>
#define PROGRAM_NAME "apinames"
-#define PROGRAM_VERSION "0.2"
+#define PROGRAM_VERSION "0.3"
#define LINEBUFF_SIZE 1024
@@ -32,7 +32,8 @@ typedef enum OutputFormat_
OUTPUT_WINDOWS_DEF, /* output a Windows .DEF file for Visual C++ or Mingw */
OUTPUT_BORLAND_DEF, /* output a Windows .DEF file for Borland C++ */
OUTPUT_WATCOM_LBC, /* output a Watcom Linker Command File */
- OUTPUT_NETWARE_IMP /* output a NetWare ImportFile */
+ OUTPUT_NETWARE_IMP, /* output a NetWare ImportFile */
+ OUTPUT_GNU_VERMAP /* output a version map for GNU or Solaris linker */
} OutputFormat;
@@ -90,14 +91,14 @@ names_add( const char* name,
max_names += (max_names >> 1) + 4;
the_names = (NameRec*)realloc( the_names,
sizeof ( the_names[0] ) * max_names );
- if ( the_names == NULL )
+ if ( !the_names )
panic( "not enough memory" );
}
nm = &the_names[num_names++];
nm->hash = h;
nm->name = (char*)malloc( len+1 );
- if ( nm->name == NULL )
+ if ( !nm->name )
panic( "not enough memory" );
memcpy( nm->name, name, len );
@@ -159,7 +160,7 @@ names_dump( FILE* out,
char temp[512];
- if ( dll_name == NULL )
+ if ( !dll_name )
{
fprintf( stderr,
"you must provide a DLL name with the -d option!\n" );
@@ -168,7 +169,7 @@ names_dump( FILE* out,
/* we must omit the .dll suffix from the library name */
dot = strchr( dll_name, '.' );
- if ( dot != NULL )
+ if ( dot )
{
int len = dot - dll_name;
@@ -190,7 +191,7 @@ names_dump( FILE* out,
case OUTPUT_NETWARE_IMP:
{
- if ( dll_name != NULL )
+ if ( dll_name )
fprintf( out, " (%s)\n", dll_name );
for ( nn = 0; nn < num_names - 1; nn++ )
fprintf( out, " %s,\n", the_names[nn].name );
@@ -198,6 +199,15 @@ names_dump( FILE* out,
}
break;
+ case OUTPUT_GNU_VERMAP:
+ {
+ fprintf( out, "{\n\tglobal:\n" );
+ for ( nn = 0; nn < num_names; nn++ )
+ fprintf( out, "\t\t%s;\n", the_names[nn].name );
+ fprintf( out, "\tlocal:\n\t\t*;\n};\n" );
+ }
+ break;
+
default: /* LIST */
for ( nn = 0; nn < num_names; nn++ )
fprintf( out, "%s\n", the_names[nn].name );
@@ -323,6 +333,7 @@ usage( void )
" -wB : output .DEF file for Borland C++\n"
" -wW : output Watcom Linker Response File\n"
" -wN : output NetWare Import File\n"
+ " -wL : output version map for GNU or Solaris linker\n"
"\n";
fprintf( stderr,
@@ -371,7 +382,7 @@ int main( int argc, const char* const* argv )
arg += 2;
out = fopen( arg, "wt" );
- if ( out == NULL )
+ if ( !out )
{
fprintf( stderr, "could not open '%s' for writing\n", argv[2] );
exit(3);
@@ -410,6 +421,10 @@ int main( int argc, const char* const* argv )
format = OUTPUT_NETWARE_IMP;
break;
+ case 'L':
+ format = OUTPUT_GNU_VERMAP;
+ break;
+
case 0:
break;
@@ -440,7 +455,7 @@ int main( int argc, const char* const* argv )
{
FILE* file = fopen( argv[0], "rb" );
- if ( file == NULL )
+ if ( !file )
fprintf( stderr, "unable to open '%s'\n", argv[0] );
else
{
diff --git a/src/3rdparty/freetype/src/tools/docmaker/content.py b/src/3rdparty/freetype/src/tools/docmaker/content.py
index 1961878a7d..198780aee4 100644
--- a/src/3rdparty/freetype/src/tools/docmaker/content.py
+++ b/src/3rdparty/freetype/src/tools/docmaker/content.py
@@ -3,7 +3,7 @@
#
# Parse comment blocks to build content blocks (library file).
#
-# Copyright 2002-2015 by
+# Copyright 2002-2018 by
# David Turner.
#
# This file is part of the FreeType project, and may only be used,
@@ -46,9 +46,26 @@ re_code_end = re.compile( r"(\s*)}\s*$" )
#
-# A regular expression to isolate identifiers from other text.
+# A regular expression to isolate identifiers from other text. Two syntax
+# forms are supported:
#
-re_identifier = re.compile( r'((?:\w|-)*)' )
+# <name>
+# <name>[<id>]
+#
+# where both `<name>' and `<id>' consist of alphanumeric characters, `_',
+# and `-'. Use `<id>' if there are multiple, valid `<name>' entries; in the
+# index, `<id>' will be appended in parentheses.
+#
+# For example,
+#
+# stem_darkening[autofit]
+#
+# becomes `stem_darkening (autofit)' in the index.
+#
+re_identifier = re.compile( r"""
+ ((?:\w|-)+
+ (?:\[(?:\w|-)+\])?)
+ """, re.VERBOSE )
#
@@ -92,7 +109,7 @@ class DocCode:
def dump( self, prefix = "", width = 60 ):
lines = self.dump_lines( 0, width )
for l in lines:
- print prefix + l
+ print( prefix + l )
def dump_lines( self, margin = 0, width = 60 ):
result = []
@@ -122,7 +139,7 @@ class DocPara:
def dump( self, prefix = "", width = 60 ):
lines = self.dump_lines( 0, width )
for l in lines:
- print prefix + l
+ print( prefix + l )
def dump_lines( self, margin = 0, width = 60 ):
cur = "" # current line
@@ -226,13 +243,13 @@ class DocField:
def dump( self, prefix = "" ):
if self.field:
- print prefix + self.field + " ::"
+ print( prefix + self.field + " ::" )
prefix = prefix + "----"
first = 1
for p in self.items:
if not first:
- print ""
+ print( "" )
p.dump( prefix )
first = 0
@@ -313,10 +330,10 @@ class DocMarkup:
return None
def dump( self, margin ):
- print " " * margin + "<" + self.tag + ">"
+ print( " " * margin + "<" + self.tag + ">" )
for f in self.fields:
f.dump( " " )
- print " " * margin + "</" + self.tag + ">"
+ print( " " * margin + "</" + self.tag + ">" )
################################################################
@@ -436,15 +453,32 @@ class ContentProcessor:
markup_lines = []
first = 1
+ margin = -1
+ in_code = 0
+
for line in content:
- found = None
- for t in re_markup_tags:
- m = t.match( line )
+ if in_code:
+ m = re_code_end.match( line )
+ if m and len( m.group( 1 ) ) <= margin:
+ in_code = 0
+ margin = -1
+ else:
+ m = re_code_start.match( line )
if m:
- found = string.lower( m.group( 1 ) )
- prefix = len( m.group( 0 ) )
- line = " " * prefix + line[prefix:] # remove markup from line
- break
+ in_code = 1
+ margin = len( m.group( 1 ) )
+
+ found = None
+
+ if not in_code:
+ for t in re_markup_tags:
+ m = t.match( line )
+ if m:
+ found = string.lower( m.group( 1 ) )
+ prefix = len( m.group( 0 ) )
+ # remove markup from line
+ line = " " * prefix + line[prefix:]
+ break
# is it the start of a new markup section ?
if found:
diff --git a/src/3rdparty/freetype/src/tools/docmaker/docbeauty.py b/src/3rdparty/freetype/src/tools/docmaker/docbeauty.py
index 3ddf4a94a1..0b021fa6c9 100644
--- a/src/3rdparty/freetype/src/tools/docmaker/docbeauty.py
+++ b/src/3rdparty/freetype/src/tools/docmaker/docbeauty.py
@@ -10,9 +10,7 @@ from sources import *
from content import *
from utils import *
-import utils
-
-import sys, os, time, string, getopt
+import sys, os, string, getopt
content_processor = ContentProcessor()
@@ -40,13 +38,13 @@ def beautify_block( block ):
def usage():
- print "\nDocBeauty 0.1 Usage information\n"
- print " docbeauty [options] file1 [file2 ...]\n"
- print "using the following options:\n"
- print " -h : print this page"
- print " -b : backup original files with the 'orig' extension"
- print ""
- print " --backup : same as -b"
+ print( "\nDocBeauty 0.1 Usage information\n" )
+ print( " docbeauty [options] file1 [file2 ...]\n" )
+ print( "using the following options:\n" )
+ print( " -h : print this page" )
+ print( " -b : backup original files with the 'orig' extension" )
+ print( "" )
+ print( " --backup : same as -b" )
def main( argv ):
diff --git a/src/3rdparty/freetype/src/tools/docmaker/docmaker.py b/src/3rdparty/freetype/src/tools/docmaker/docmaker.py
index de82d930f5..eb49afb0a0 100644
--- a/src/3rdparty/freetype/src/tools/docmaker/docmaker.py
+++ b/src/3rdparty/freetype/src/tools/docmaker/docmaker.py
@@ -4,7 +4,7 @@
#
# Convert source code markup to HTML documentation.
#
-# Copyright 2002-2015 by
+# Copyright 2002-2018 by
# David Turner.
#
# This file is part of the FreeType project, and may only be used,
@@ -31,21 +31,21 @@ from tohtml import *
import utils
-import sys, os, time, string, glob, getopt
+import sys, glob, getopt
def usage():
- print "\nDocMaker Usage information\n"
- print " docmaker [options] file1 [file2 ...]\n"
- print "using the following options:\n"
- print " -h : print this page"
- print " -t : set project title, as in '-t \"My Project\"'"
- print " -o : set output directory, as in '-o mydir'"
- print " -p : set documentation prefix, as in '-p ft2'"
- print ""
- print " --title : same as -t, as in '--title=\"My Project\"'"
- print " --output : same as -o, as in '--output=mydir'"
- print " --prefix : same as -p, as in '--prefix=ft2'"
+ print( "\nDocMaker Usage information\n" )
+ print( " docmaker [options] file1 [file2 ...]\n" )
+ print( "using the following options:\n" )
+ print( " -h : print this page" )
+ print( " -t : set project title, as in '-t \"My Project\"'" )
+ print( " -o : set output directory, as in '-o mydir'" )
+ print( " -p : set documentation prefix, as in '-p ft2'" )
+ print( "" )
+ print( " --title : same as -t, as in '--title=\"My Project\"'" )
+ print( " --output : same as -o, as in '--output=mydir'" )
+ print( " --prefix : same as -p, as in '--prefix=ft2'" )
def main( argv ):
diff --git a/src/3rdparty/freetype/src/tools/docmaker/formatter.py b/src/3rdparty/freetype/src/tools/docmaker/formatter.py
index f0a8808c47..2708fd40d6 100644
--- a/src/3rdparty/freetype/src/tools/docmaker/formatter.py
+++ b/src/3rdparty/freetype/src/tools/docmaker/formatter.py
@@ -3,7 +3,7 @@
#
# Convert parsed content blocks to a structured document (library file).
#
-# Copyright 2002-2015 by
+# Copyright 2002-2018 by
# David Turner.
#
# This file is part of the FreeType project, and may only be used,
@@ -56,6 +56,11 @@ class Formatter:
self.block_index = self.identifiers.keys()
self.block_index.sort( key = index_key )
+ # also add section names to dictionary (without making them appear
+ # in the index)
+ for section in self.sections:
+ self.add_identifier( section.name, section )
+
def add_identifier( self, name, block ):
if name in self.identifiers:
# duplicate name!
diff --git a/src/3rdparty/freetype/src/tools/docmaker/sources.py b/src/3rdparty/freetype/src/tools/docmaker/sources.py
index be38132d1d..e3b95e0faa 100644
--- a/src/3rdparty/freetype/src/tools/docmaker/sources.py
+++ b/src/3rdparty/freetype/src/tools/docmaker/sources.py
@@ -3,7 +3,7 @@
#
# Convert source code comments to multi-line blocks (library file).
#
-# Copyright 2002-2015 by
+# Copyright 2002-2018 by
# David Turner.
#
# This file is part of the FreeType project, and may only be used,
@@ -29,7 +29,7 @@
#
-import fileinput, re, sys, os, string
+import fileinput, re, string
################################################################
@@ -138,12 +138,24 @@ re_markup_tags = [re_markup_tag1, re_markup_tag2]
#
# A regular expression to detect a cross reference, after markup tags have
-# been stripped off. Group 1 is the reference, group 2 the rest of the
-# line.
+# been stripped off.
#
-# A cross reference consists of letters, digits, or characters `-' and `_'.
+# Two syntax forms are supported:
#
-re_crossref = re.compile( r'@((?:\w|-)*)(.*)' ) # @foo
+# @<name>
+# @<name>[<id>]
+#
+# where both `<name>' and `<id>' consist of alphanumeric characters, `_',
+# and `-'. Use `<id>' if there are multiple, valid `<name>' entries.
+#
+# Example: @foo[bar]
+#
+re_crossref = re.compile( r"""
+ @
+ (?P<name>(?:\w|-)+
+ (?:\[(?:\w|-)+\])?)
+ (?P<rest>.*)
+ """, re.VERBOSE )
#
# Two regular expressions to detect italic and bold markup, respectively.
@@ -159,7 +171,7 @@ re_bold = re.compile( r"\*((?:\w|-)(?:\w|'|-)*)\*(.*)" ) # *bold*
#
# This regular expression code to identify an URL has been taken from
#
-# http://mail.python.org/pipermail/tutor/2002-September/017228.html
+# https://mail.python.org/pipermail/tutor/2002-September/017228.html
#
# (with slight modifications).
#
@@ -284,10 +296,10 @@ class SourceBlock:
# debugging only -- not used in normal operations
def dump( self ):
if self.content:
- print "{{{content start---"
+ print( "{{{content start---" )
for l in self.content:
- print l
- print "---content end}}}"
+ print( l )
+ print( "---content end}}}" )
return
fmt = ""
@@ -295,7 +307,7 @@ class SourceBlock:
fmt = repr( self.format.id ) + " "
for line in self.lines:
- print line
+ print( line )
################################################################
diff --git a/src/3rdparty/freetype/src/tools/docmaker/tohtml.py b/src/3rdparty/freetype/src/tools/docmaker/tohtml.py
index bc6bcf0511..9f318a2a49 100644
--- a/src/3rdparty/freetype/src/tools/docmaker/tohtml.py
+++ b/src/3rdparty/freetype/src/tools/docmaker/tohtml.py
@@ -3,7 +3,7 @@
#
# A sub-class container of the `Formatter' class to produce HTML.
#
-# Copyright 2002-2015 by
+# Copyright 2002-2018 by
# David Turner.
#
# This file is part of the FreeType project, and may only be used,
@@ -25,7 +25,7 @@ import time
# The following strings define the HTML header used by all generated pages.
html_header_1 = """\
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
-"http://www.w3.org/TR/html4/loose.dtd">
+"https://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
@@ -164,7 +164,8 @@ html_footer = """\
"""
# The header and footer used for each section.
-section_title_header = "<h1>"
+section_title_header1 = '<h1 id="'
+section_title_header2 = '">'
section_title_footer = "</h1>"
# The header and footer used for code segments.
@@ -309,7 +310,14 @@ class HtmlFormatter( Formatter ):
def make_block_url( self, block, name = None ):
if name == None:
name = block.name
- return self.make_section_url( block.section ) + "#" + name
+
+ try:
+ section_url = self.make_section_url( block.section )
+ except:
+ # we already have a section
+ section_url = self.make_section_url( block )
+
+ return section_url + "#" + name
def make_html_word( self, word ):
"""Analyze a simple word to detect cross-references and markup."""
@@ -317,11 +325,27 @@ class HtmlFormatter( Formatter ):
m = re_crossref.match( word )
if m:
try:
- name = m.group( 1 )
- rest = m.group( 2 )
+ name = m.group( 'name' )
+ rest = m.group( 'rest' )
block = self.identifiers[name]
url = self.make_block_url( block )
- return '<a href="' + url + '">' + name + '</a>' + rest
+ # display `foo[bar]' as `foo'
+ name = re.sub( r'\[.*\]', '', name )
+ # normalize url, following RFC 3986
+ url = string.replace( url, "[", "(" )
+ url = string.replace( url, "]", ")" )
+
+ try:
+ # for sections, display title
+ url = ( '&lsquo;<a href="' + url + '">'
+ + block.title + '</a>&rsquo;'
+ + rest )
+ except:
+ url = ( '<a href="' + url + '">'
+ + name + '</a>'
+ + rest )
+
+ return url
except:
# we detected a cross-reference to an unknown item
sys.stderr.write( "WARNING: undefined cross reference"
@@ -366,7 +390,7 @@ class HtmlFormatter( Formatter ):
"""Convert a code sequence to HTML."""
line = code_header + '\n'
for l in lines:
- line = line + html_quote( l ) + '\n'
+ line = line + html_quote( l ).rstrip() + '\n'
return line + code_footer
@@ -382,7 +406,7 @@ class HtmlFormatter( Formatter ):
return string.join( lines, '\n' )
def print_html_items( self, items ):
- print self.make_html_items( items )
+ print( self.make_html_items( items ) )
def print_html_field( self, field ):
if field.name:
@@ -390,10 +414,10 @@ class HtmlFormatter( Formatter ):
+ field.name
+ "</b></td><td>" )
- print self.make_html_items( field.items )
+ print( self.make_html_items( field.items ) )
if field.name:
- print "</td></tr></table>"
+ print( "</td></tr></table>" )
def html_source_quote( self, line, block_name = None ):
result = ""
@@ -417,16 +441,22 @@ class HtmlFormatter( Formatter ):
id = block.name
# link to a field ID if possible
- for markup in block.markups:
- if markup.tag == 'values':
- for field in markup.fields:
- if field.name:
- id = name
+ try:
+ for markup in block.markups:
+ if markup.tag == 'values':
+ for field in markup.fields:
+ if field.name:
+ id = name
+
+ result = ( result + prefix
+ + '<a href="'
+ + self.make_block_url( block, id )
+ + '">' + name + '</a>' )
+ except:
+ # sections don't have `markups'; however, we don't
+ # want references to sections here anyway
+ result = result + html_quote( line[:length] )
- result = ( result + prefix
- + '<a href="'
- + self.make_block_url( block, id )
- + '">' + name + '</a>' )
else:
result = result + html_quote( line[:length] )
@@ -438,14 +468,14 @@ class HtmlFormatter( Formatter ):
return result
def print_html_field_list( self, fields ):
- print '<table class="fields">'
+ print( '<table class="fields">' )
for field in fields:
- print ( '<tr><td class="val" id="' + field.name + '">'
- + field.name
- + '</td><td class="desc">' )
+ print( '<tr><td class="val" id="' + field.name + '">'
+ + field.name
+ + '</td><td class="desc">' )
self.print_html_items( field.items )
- print "</td></tr>"
- print "</table>"
+ print( "</td></tr>" )
+ print( "</table>" )
def print_html_markup( self, markup ):
table_fields = []
@@ -469,7 +499,7 @@ class HtmlFormatter( Formatter ):
# formatting the index
#
def index_enter( self ):
- print self.html_index_header
+ print( self.html_index_header )
self.index_items = {}
def index_name_enter( self, name ):
@@ -482,7 +512,7 @@ class HtmlFormatter( Formatter ):
count = len( self.block_index )
rows = ( count + self.columns - 1 ) // self.columns
- print '<table class="index">'
+ print( '<table class="index">' )
for r in range( rows ):
line = "<tr>"
for c in range( self.columns ):
@@ -490,20 +520,26 @@ class HtmlFormatter( Formatter ):
if i < count:
bname = self.block_index[r + c * rows]
url = self.index_items[bname]
+ # display `foo[bar]' as `foo (bar)'
+ bname = string.replace( bname, "[", " (" )
+ bname = string.replace( bname, "]", ")" )
+ # normalize url, following RFC 3986
+ url = string.replace( url, "[", "(" )
+ url = string.replace( url, "]", ")" )
line = ( line + '<td><a href="' + url + '">'
+ bname + '</a></td>' )
else:
line = line + '<td></td>'
line = line + "</tr>"
- print line
+ print( line )
- print "</table>"
+ print( "</table>" )
print( index_footer_start
+ self.file_prefix + "toc.html"
+ index_footer_end )
- print self.html_footer
+ print( self.html_footer )
self.index_items = {}
@@ -517,25 +553,25 @@ class HtmlFormatter( Formatter ):
# formatting the table of contents
#
def toc_enter( self ):
- print self.html_toc_header
- print "<h1>Table of Contents</h1>"
+ print( self.html_toc_header )
+ print( "<h1>Table of Contents</h1>" )
def toc_chapter_enter( self, chapter ):
- print chapter_header + string.join( chapter.title ) + chapter_inter
- print '<table class="toc">'
+ print( chapter_header + string.join( chapter.title ) + chapter_inter )
+ print( '<table class="toc">' )
def toc_section_enter( self, section ):
- print ( '<tr><td class="link">'
- + '<a href="' + self.make_section_url( section ) + '">'
- + section.title + '</a></td><td class="desc">' )
- print self.make_html_para( section.abstract )
+ print( '<tr><td class="link">'
+ + '<a href="' + self.make_section_url( section ) + '">'
+ + section.title + '</a></td><td class="desc">' )
+ print( self.make_html_para( section.abstract ) )
def toc_section_exit( self, section ):
- print "</td></tr>"
+ print( "</td></tr>" )
def toc_chapter_exit( self, chapter ):
- print "</table>"
- print chapter_footer
+ print( "</table>" )
+ print( chapter_footer )
def toc_index( self, index_filename ):
print( chapter_header
@@ -547,7 +583,7 @@ class HtmlFormatter( Formatter ):
+ self.file_prefix + "index.html"
+ toc_footer_end )
- print self.html_footer
+ print( self.html_footer )
def toc_dump( self, toc_filename = None, index_filename = None ):
if toc_filename == None:
@@ -562,9 +598,11 @@ class HtmlFormatter( Formatter ):
# formatting sections
#
def section_enter( self, section ):
- print self.html_header
+ print( self.html_header )
- print section_title_header + section.title + section_title_footer
+ print( section_title_header1 + section.name + section_title_header2
+ + section.title
+ + section_title_footer )
maxwidth = 0
for b in section.blocks.values():
@@ -574,8 +612,8 @@ class HtmlFormatter( Formatter ):
width = 70 # XXX magic number
if maxwidth > 0:
# print section synopsis
- print section_synopsis_header
- print '<table class="synopsis">'
+ print( section_synopsis_header )
+ print( '<table class="synopsis">' )
columns = width // maxwidth
if columns < 1:
@@ -601,26 +639,38 @@ class HtmlFormatter( Formatter ):
# even omit it completely)
line = line + "&nbsp;"
else:
- line = ( line + '<a href="#' + name + '">'
+ url = name
+ # display `foo[bar]' as `foo'
+ name = re.sub( r'\[.*\]', '', name )
+ # normalize url, following RFC 3986
+ url = string.replace( url, "[", "(" )
+ url = string.replace( url, "]", ")" )
+ line = ( line + '<a href="#' + url + '">'
+ name + '</a>' )
line = line + '</td>'
line = line + "</tr>"
- print line
+ print( line )
- print "</table>"
- print section_synopsis_footer
+ print( "</table>" )
+ print( section_synopsis_footer )
- print description_header
- print self.make_html_items( section.description )
- print description_footer
+ print( description_header )
+ print( self.make_html_items( section.description ) )
+ print( description_footer )
def block_enter( self, block ):
- print block_header
+ print( block_header )
# place html anchor if needed
if block.name:
- print( '<h3 id="' + block.name + '">' + block.name + '</h3>' )
+ url = block.name
+ # display `foo[bar]' as `foo'
+ name = re.sub( r'\[.*\]', '', block.name )
+ # normalize url, following RFC 3986
+ url = string.replace( url, "[", "(" )
+ url = string.replace( url, "]", ")" )
+ print( '<h3 id="' + url + '">' + name + '</h3>' )
# dump the block C source lines now
if block.code:
@@ -636,28 +686,28 @@ class HtmlFormatter( Formatter ):
# + " '" + block.source.filename + "'.\n" )
if header:
- print ( header_location_header
- + 'Defined in ' + header + '.'
- + header_location_footer )
+ print( header_location_header
+ + 'Defined in ' + header + '.'
+ + header_location_footer )
- print source_header
+ print( source_header )
for l in block.code:
- print self.html_source_quote( l, block.name )
- print source_footer
+ print( self.html_source_quote( l, block.name ) )
+ print( source_footer )
def markup_enter( self, markup, block ):
if markup.tag == "description":
- print description_header
+ print( description_header )
else:
- print marker_header + markup.tag + marker_inter
+ print( marker_header + markup.tag + marker_inter )
self.print_html_markup( markup )
def markup_exit( self, markup, block ):
if markup.tag == "description":
- print description_footer
+ print( description_footer )
else:
- print marker_footer
+ print( marker_footer )
def block_exit( self, block ):
print( block_footer_start + self.file_prefix + "index.html"
@@ -665,7 +715,7 @@ class HtmlFormatter( Formatter ):
+ block_footer_end )
def section_exit( self, section ):
- print html_footer
+ print( html_footer )
def section_dump_all( self ):
for section in self.sections:
diff --git a/src/3rdparty/freetype/src/tools/docmaker/utils.py b/src/3rdparty/freetype/src/tools/docmaker/utils.py
index 254083e92e..f40f1674a0 100644
--- a/src/3rdparty/freetype/src/tools/docmaker/utils.py
+++ b/src/3rdparty/freetype/src/tools/docmaker/utils.py
@@ -3,7 +3,7 @@
#
# Auxiliary functions for the `docmaker' tool (library file).
#
-# Copyright 2002-2015 by
+# Copyright 2002-2018 by
# David Turner.
#
# This file is part of the FreeType project, and may only be used,
diff --git a/src/3rdparty/freetype/src/tools/ftfuzzer/README b/src/3rdparty/freetype/src/tools/ftfuzzer/README
new file mode 100644
index 0000000000..09d8e9f325
--- /dev/null
+++ b/src/3rdparty/freetype/src/tools/ftfuzzer/README
@@ -0,0 +1,81 @@
+ftfuzzer
+========
+
+
+ftfuzzer.cc
+-----------
+
+This file contains a target function for FreeType fuzzing. It can be
+used with libFuzzer (https://llvm.org/docs/LibFuzzer.html) or
+potentially any other similar fuzzer.
+
+Usage:
+
+ 1. Build `libfreetype.a' and `ftfuzzer.cc' using the most recent
+ clang compiler with these flags:
+
+ # for fuzzer coverage feedback
+ -fsanitize-coverage=edge,8bit-counters
+ # for bug checking
+ -fsanitize=address,signed-integer-overflow,shift
+
+ You also need the header files from the `libarchive' library
+ (https://www.libarchive.org/) for handling tar files (see file
+ `ftmutator.cc' below for more).
+
+ 2. Link with `libFuzzer' (it contains `main') and `libarchive'.
+
+ 3. Run the fuzzer on some test corpus.
+
+The exact flags and commands may vary.
+
+ https://github.com/google/oss-fuzz/tree/master/projects/freetype2
+
+There is a continuous fuzzing bot that runs ftfuzzer.
+
+ https://oss-fuzz.com
+
+(You need an account to be able to see coverage reports and the like
+on oss-fuzz.com.)
+
+Check the bot configuration for the most current settings.
+
+
+ftmutator.cc
+------------
+
+FreeType has the ability to `attach' auxiliary files to a font file,
+providing additional information. The main usage is to load AFM files
+for PostScript Type 1 fonts.
+
+However, libFuzzer currently only supports mutation of a single input
+file. For this reason, `ftmutator.cc' contains a custom fuzzer
+mutator that uses an uncompressed tar file archive as the input. The
+first file in such a tarball gets opened by FreeType as a font, all
+other files are treated as input for `FT_Attach_Stream'.
+
+Compilation is similar to `ftfuzzer.c'.
+
+
+runinput.cc
+-----------
+
+To run the target function on a set of input files, this file contains
+a convenience `main' function. Link it with `ftfuzzer.cc',
+`libfreetype.a', and `libarchive' and run like
+
+ ./a.out my_tests_inputs/*
+
+----------------------------------------------------------------------
+
+Copyright 2015-2018 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.
+
+
+--- end of README ---
diff --git a/src/3rdparty/freetype/src/tools/ftfuzzer/ftfuzzer.cc b/src/3rdparty/freetype/src/tools/ftfuzzer/ftfuzzer.cc
new file mode 100644
index 0000000000..acf2bc9820
--- /dev/null
+++ b/src/3rdparty/freetype/src/tools/ftfuzzer/ftfuzzer.cc
@@ -0,0 +1,428 @@
+// ftfuzzer.cc
+//
+// A fuzzing function to test FreeType with libFuzzer.
+//
+// Copyright 2015-2018 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.
+
+
+// we use `unique_ptr', `decltype', and other gimmicks defined since C++11
+#if __cplusplus < 201103L
+# error "a C++11 compiler is needed"
+#endif
+
+#include <archive.h>
+#include <archive_entry.h>
+
+#include <assert.h>
+#include <stdint.h>
+
+#include <memory>
+#include <vector>
+
+
+ using namespace std;
+
+
+#include <ft2build.h>
+
+#include FT_FREETYPE_H
+#include FT_GLYPH_H
+#include FT_CACHE_H
+#include FT_CACHE_CHARMAP_H
+#include FT_CACHE_IMAGE_H
+#include FT_CACHE_SMALL_BITMAPS_H
+#include FT_SYNTHESIS_H
+#include FT_ADVANCES_H
+#include FT_OUTLINE_H
+#include FT_BBOX_H
+#include FT_MODULE_H
+#include FT_DRIVER_H
+#include FT_MULTIPLE_MASTERS_H
+
+
+ static FT_Library library;
+ static int InitResult;
+
+
+ struct FT_Global
+ {
+ FT_Global()
+ {
+ InitResult = FT_Init_FreeType( &library );
+ if ( InitResult )
+ return;
+
+ // try to activate Adobe's CFF engine; it might not be the default
+ unsigned int cff_hinting_engine = FT_HINTING_ADOBE;
+ FT_Property_Set( library,
+ "cff",
+ "hinting-engine", &cff_hinting_engine );
+ }
+
+ ~FT_Global()
+ {
+ FT_Done_FreeType( library );
+ }
+ };
+
+ FT_Global global_ft;
+
+
+ // We want to select n values at random (without repetition),
+ // with 0 < n <= N. The algorithm is taken from TAoCP, Vol. 2
+ // (Algorithm S, selection sampling technique)
+ struct Random
+ {
+ int n;
+ int N;
+
+ int t; // total number of values so far
+ int m; // number of selected values so far
+
+ uint32_t r; // the current pseudo-random number
+
+ Random( int n_,
+ int N_ )
+ : n( n_ ),
+ N( N_ )
+ {
+ t = 0;
+ m = 0;
+
+ // Ideally, this should depend on the input file,
+ // for example, taking the sha256 as input;
+ // however, this is overkill for fuzzying tests.
+ r = 12345;
+ }
+
+ int get()
+ {
+ if ( m >= n )
+ return -1;
+
+ Redo:
+ // We can't use `rand': different C libraries might provide
+ // different implementations of this function. As a replacement,
+ // we use a 32bit version of the `xorshift' algorithm.
+ r ^= r << 13;
+ r ^= r >> 17;
+ r ^= r << 5;
+
+ double U = double( r ) / UINT32_MAX;
+
+ if ( ( N - t ) * U >= ( n - m ) )
+ {
+ t++;
+ goto Redo;
+ }
+
+ t++;
+ m++;
+
+ return t;
+ }
+ };
+
+
+ static int
+ archive_read_entry_data( struct archive *ar,
+ vector<FT_Byte> *vw )
+ {
+ int r;
+ const FT_Byte* buff;
+ size_t size;
+ int64_t offset;
+
+ for (;;)
+ {
+ r = archive_read_data_block( ar,
+ reinterpret_cast<const void**>( &buff ),
+ &size,
+ &offset );
+ if ( r == ARCHIVE_EOF )
+ return ARCHIVE_OK;
+ if ( r != ARCHIVE_OK )
+ return r;
+
+ vw->insert( vw->end(), buff, buff + size );
+ }
+ }
+
+
+ static vector<vector<FT_Byte>>
+ parse_data( const uint8_t* data,
+ size_t size )
+ {
+ struct archive_entry* entry;
+ int r;
+ vector<vector<FT_Byte>> files;
+
+ unique_ptr<struct archive,
+ decltype ( archive_read_free )*> a( archive_read_new(),
+ archive_read_free );
+
+ // activate reading of uncompressed tar archives
+ archive_read_support_format_tar( a.get() );
+
+ // the need for `const_cast' was removed with libarchive commit be4d4dd
+ if ( !( r = archive_read_open_memory(
+ a.get(),
+ const_cast<void*>(static_cast<const void*>( data ) ),
+ size ) ) )
+ {
+ unique_ptr<struct archive,
+ decltype ( archive_read_close )*> a_open( a.get(),
+ archive_read_close );
+
+ // read files contained in archive
+ for (;;)
+ {
+ r = archive_read_next_header( a_open.get(), &entry );
+ if ( r == ARCHIVE_EOF )
+ break;
+ if ( r != ARCHIVE_OK )
+ break;
+
+ vector<FT_Byte> entry_data;
+ r = archive_read_entry_data( a.get(), &entry_data );
+ if ( r != ARCHIVE_OK )
+ break;
+
+ files.push_back( move( entry_data ) );
+ }
+ }
+
+ if ( files.size() == 0 )
+ files.emplace_back( data, data + size );
+
+ return files;
+ }
+
+
+ static void
+ setIntermediateAxis( FT_Face face )
+ {
+ // only handle Multiple Masters and GX variation fonts
+ if ( !FT_HAS_MULTIPLE_MASTERS( face ) )
+ return;
+
+ // get variation data for current instance
+ FT_MM_Var* variations_ptr = nullptr;
+ if ( FT_Get_MM_Var( face, &variations_ptr ) )
+ return;
+
+ unique_ptr<FT_MM_Var,
+ decltype ( free )*> variations( variations_ptr, free );
+ vector<FT_Fixed> coords( variations->num_axis );
+
+ // select an arbitrary instance
+ for ( unsigned int i = 0; i < variations->num_axis; i++ )
+ coords[i] = ( variations->axis[i].minimum +
+ variations->axis[i].def ) / 2;
+
+ if ( FT_Set_Var_Design_Coordinates( face,
+ FT_UInt( coords.size() ),
+ coords.data() ) )
+ return;
+ }
+
+
+ // the interface function to the libFuzzer library
+ extern "C" int
+ LLVMFuzzerTestOneInput( const uint8_t* data,
+ size_t size_ )
+ {
+ assert( !InitResult );
+
+ if ( size_ < 1 )
+ return 0;
+
+ const vector<vector<FT_Byte>>& files = parse_data( data, size_ );
+
+ FT_Face face;
+ FT_Int32 load_flags = FT_LOAD_DEFAULT;
+#if 0
+ FT_Render_Mode render_mode = FT_RENDER_MODE_NORMAL;
+#endif
+
+ // We use a conservative approach here, at the cost of calling
+ // `FT_New_Face' quite often. The idea is that the fuzzer should be
+ // able to try all faces and named instances of a font, expecting that
+ // some faces don't work for various reasons, e.g., a broken subfont, or
+ // an unsupported NFNT bitmap font in a Mac dfont resource that holds
+ // more than a single font.
+
+ // get number of faces
+ if ( FT_New_Memory_Face( library,
+ files[0].data(),
+ (FT_Long)files[0].size(),
+ -1,
+ &face ) )
+ return 0;
+ long num_faces = face->num_faces;
+ FT_Done_Face( face );
+
+ // loop over up to 20 arbitrarily selected faces
+ // from index range [0;num-faces-1]
+ long max_face_cnt = num_faces < 20
+ ? num_faces
+ : 20;
+
+ Random faces_pool( (int)max_face_cnt, (int)num_faces );
+
+ for ( long face_cnt = 0;
+ face_cnt < max_face_cnt;
+ face_cnt++ )
+ {
+ long face_index = faces_pool.get() - 1;
+
+ // get number of instances
+ if ( FT_New_Memory_Face( library,
+ files[0].data(),
+ (FT_Long)files[0].size(),
+ -( face_index + 1 ),
+ &face ) )
+ continue;
+ long num_instances = face->style_flags >> 16;
+ FT_Done_Face( face );
+
+ // loop over the face without instance (index 0)
+ // and up to 20 arbitrarily selected instances
+ // from index range [1;num_instances]
+ long max_instance_cnt = num_instances < 20
+ ? num_instances
+ : 20;
+
+ Random instances_pool( (int)max_instance_cnt, (int)num_instances );
+
+ for ( long instance_cnt = 0;
+ instance_cnt <= max_instance_cnt;
+ instance_cnt++ )
+ {
+ long instance_index = 0;
+
+ if ( !instance_cnt )
+ {
+ if ( FT_New_Memory_Face( library,
+ files[0].data(),
+ (FT_Long)files[0].size(),
+ face_index,
+ &face ) )
+ continue;
+ }
+ else
+ {
+ instance_index = instances_pool.get();
+
+ if ( FT_New_Memory_Face( library,
+ files[0].data(),
+ (FT_Long)files[0].size(),
+ ( instance_index << 16 ) + face_index,
+ &face ) )
+ continue;
+ }
+
+ // if we have more than a single input file coming from an archive,
+ // attach them (starting with the second file) using the order given
+ // in the archive
+ for ( size_t files_index = 1;
+ files_index < files.size();
+ files_index++ )
+ {
+ FT_Open_Args open_args = {};
+ open_args.flags = FT_OPEN_MEMORY;
+ open_args.memory_base = files[files_index].data();
+ open_args.memory_size = (FT_Long)files[files_index].size();
+
+ // the last archive element will be eventually used as the
+ // attachment
+ FT_Attach_Stream( face, &open_args );
+ }
+
+ // loop over an arbitrary size for outlines
+ // and up to ten arbitrarily selected bitmap strike sizes
+ // from the range [0;num_fixed_sizes - 1]
+ int max_size_cnt = face->num_fixed_sizes < 10
+ ? face->num_fixed_sizes
+ : 10;
+
+ Random sizes_pool( max_size_cnt, face->num_fixed_sizes );
+
+ for ( int size_cnt = 0;
+ size_cnt <= max_size_cnt;
+ size_cnt++ )
+ {
+ FT_Int32 flags = load_flags;
+
+ int size_index = 0;
+
+ if ( !size_cnt )
+ {
+ // set up 20pt at 72dpi as an arbitrary size
+ if ( FT_Set_Char_Size( face, 20 * 64, 20 * 64, 72, 72 ) )
+ continue;
+ flags |= FT_LOAD_NO_BITMAP;
+ }
+ else
+ {
+ // bitmap strikes are not active for font variations
+ if ( instance_index )
+ continue;
+
+ size_index = sizes_pool.get() - 1;
+
+ if ( FT_Select_Size( face, size_index ) )
+ continue;
+ flags |= FT_LOAD_COLOR;
+ }
+
+ // test MM interface only for a face without a selected instance
+ // and without a selected bitmap strike
+ if ( !instance_index && !size_cnt )
+ setIntermediateAxis( face );
+
+ // loop over all glyphs
+ for ( unsigned int glyph_index = 0;
+ glyph_index < (unsigned int)face->num_glyphs;
+ glyph_index++ )
+ {
+ if ( FT_Load_Glyph( face, glyph_index, flags ) )
+ continue;
+
+ // Rendering is the most expensive and the least interesting part.
+ //
+ // if ( FT_Render_Glyph( face->glyph, render_mode) )
+ // continue;
+ // FT_GlyphSlot_Embolden( face->glyph );
+
+#if 0
+ FT_Glyph glyph;
+ if ( !FT_Get_Glyph( face->glyph, &glyph ) )
+ FT_Done_Glyph( glyph );
+
+ FT_Outline* outline = &face->glyph->outline;
+ FT_Matrix rot30 = { 0xDDB4, -0x8000, 0x8000, 0xDDB4 };
+
+ FT_Outline_Transform( outline, &rot30 );
+
+ FT_BBox bbox;
+ FT_Outline_Get_BBox( outline, &bbox );
+#endif
+ }
+ }
+ FT_Done_Face( face );
+ }
+ }
+
+ return 0;
+ }
+
+
+// END
diff --git a/src/3rdparty/freetype/src/tools/ftfuzzer/ftmutator.cc b/src/3rdparty/freetype/src/tools/ftfuzzer/ftmutator.cc
new file mode 100644
index 0000000000..ae4b140404
--- /dev/null
+++ b/src/3rdparty/freetype/src/tools/ftfuzzer/ftmutator.cc
@@ -0,0 +1,314 @@
+// ftmutator.cc
+//
+// A custom fuzzer mutator to test for FreeType with libFuzzer.
+//
+// Copyright 2015-2018 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.
+
+
+// Since `tar' is not a valid format for input to FreeType, treat any input
+// that looks like `tar' as multiple files and mutate them separately.
+//
+// In the future, a variation of this may be used to guide mutation on a
+// logically higher level.
+
+
+// we use `unique_ptr', `decltype', and other gimmicks defined since C++11
+#if __cplusplus < 201103L
+# error "a C++11 compiler is needed"
+#endif
+
+#include <cstdint>
+#include <cassert>
+#include <cstdio>
+#include <cstdlib>
+#include <cstddef>
+#include <cstring>
+#include <iostream>
+
+#include <memory>
+#include <vector>
+
+#include <archive.h>
+#include <archive_entry.h>
+
+#include "FuzzerInterface.h"
+
+
+ using namespace std;
+
+
+ // This function should be defined by `ftfuzzer.cc'.
+ extern "C" int
+ LLVMFuzzerTestOneInput( const uint8_t* Data,
+ size_t Size );
+
+
+ static void
+ check_result( struct archive* a,
+ int r )
+ {
+ if ( r == ARCHIVE_OK )
+ return;
+
+ const char* m = archive_error_string( a );
+ write( 1, m, strlen( m ) );
+ exit( 1 );
+ }
+
+
+ static int
+ archive_read_entry_data( struct archive *ar,
+ vector<uint8_t> *vw )
+ {
+ int r;
+ const uint8_t* buff;
+ size_t size;
+ int64_t offset;
+
+ for (;;)
+ {
+ r = archive_read_data_block( ar,
+ reinterpret_cast<const void**>( &buff ),
+ &size,
+ &offset );
+ if ( r == ARCHIVE_EOF )
+ return ARCHIVE_OK;
+ if ( r != ARCHIVE_OK )
+ return r;
+
+ vw->insert( vw->end(), buff, buff + size );
+ }
+ }
+
+
+ static vector<vector<uint8_t>>
+ parse_data( const uint8_t* data,
+ size_t size )
+ {
+ struct archive_entry* entry;
+ int r;
+ vector<vector<uint8_t>> files;
+
+ unique_ptr<struct archive,
+ decltype ( archive_read_free )*> a( archive_read_new(),
+ archive_read_free );
+
+ // activate reading of uncompressed tar archives
+ archive_read_support_format_tar( a.get() );
+
+ // the need for `const_cast' was removed with libarchive commit be4d4dd
+ if ( !( r = archive_read_open_memory(
+ a.get(),
+ const_cast<void*>(static_cast<const void*>( data ) ),
+ size ) ) )
+ {
+ unique_ptr<struct archive,
+ decltype ( archive_read_close )*> a_open( a.get(),
+ archive_read_close );
+
+ // read files contained in archive
+ for (;;)
+ {
+ r = archive_read_next_header( a_open.get(), &entry );
+ if ( r == ARCHIVE_EOF )
+ break;
+ if ( r != ARCHIVE_OK )
+ break;
+
+ vector<uint8_t> entry_data;
+ r = archive_read_entry_data( a.get(), &entry_data );
+ if ( entry_data.size() == 0 )
+ continue;
+
+ files.push_back( move( entry_data ) );
+ if ( r != ARCHIVE_OK )
+ break;
+ }
+ }
+
+ return files;
+ }
+
+
+ class FTFuzzer
+ : public fuzzer::UserSuppliedFuzzer
+ {
+
+ public:
+ FTFuzzer( fuzzer::FuzzerRandomBase* Rand )
+ : fuzzer::UserSuppliedFuzzer( Rand ) {}
+
+
+ int
+ TargetFunction( const uint8_t* Data,
+ size_t Size )
+ {
+ return LLVMFuzzerTestOneInput( Data, Size );
+ }
+
+
+ // Custom mutator.
+ virtual size_t
+ Mutate( uint8_t* Data,
+ size_t Size,
+ size_t MaxSize )
+ {
+ vector<vector<uint8_t>> files = parse_data( Data, Size );
+
+ // If the file was not recognized as a tar file, treat it as non-tar.
+ if ( files.size() == 0 )
+ return fuzzer::UserSuppliedFuzzer::Mutate( Data, Size, MaxSize );
+
+ // This is somewhat `white box' on tar. The tar format uses 512 byte
+ // blocks. One block as header for each file, two empty blocks of 0's
+ // at the end. File data is padded to fill its last block.
+ size_t used_blocks = files.size() + 2;
+ for ( const auto& file : files )
+ used_blocks += ( file.size() + 511 ) / 512;
+
+ size_t max_blocks = MaxSize / 512;
+
+ // If the input is big, it will need to be downsized. If the original
+ // tar file was too big, it may have been clipped to fit. In this
+ // case it may not be possible to properly write out the data, as
+ // there may not be enough space for the trailing two blocks. Start
+ // dropping file data or files from the end.
+ for ( size_t i = files.size();
+ i-- > 1 && used_blocks > max_blocks; )
+ {
+ size_t blocks_to_free = used_blocks - max_blocks;
+ size_t blocks_currently_used_by_file_data =
+ ( files[i].size() + 511 ) / 512;
+
+ if ( blocks_currently_used_by_file_data >= blocks_to_free )
+ {
+ files[i].resize( ( blocks_currently_used_by_file_data -
+ blocks_to_free ) * 512 );
+ used_blocks -= blocks_to_free;
+ continue;
+ }
+
+ files.pop_back();
+ used_blocks -= blocks_currently_used_by_file_data + 1;
+ }
+
+ // If we get down to one file, don't use tar.
+ if ( files.size() == 1 )
+ {
+ memcpy( Data, files[0].data(), files[0].size() );
+ return fuzzer::UserSuppliedFuzzer::Mutate( Data,
+ files[0].size(),
+ MaxSize );
+ }
+
+ size_t free_blocks = max_blocks - used_blocks;
+
+ // Allow each file to use up as much of the currently available space
+ // it can. If it uses or gives up blocks, add them or remove them
+ // from the pool.
+ for ( auto&& file : files )
+ {
+ size_t blocks_currently_used_by_file = ( file.size() + 511 ) / 512;
+ size_t blocks_available = blocks_currently_used_by_file +
+ free_blocks;
+ size_t max_size = blocks_available * 512;
+ size_t data_size = file.size();
+
+ file.resize( max_size );
+ file.resize( fuzzer::UserSuppliedFuzzer::Mutate( file.data(),
+ data_size,
+ max_size ) );
+
+ size_t blocks_now_used_by_file = ( file.size() + 511 ) / 512;
+ free_blocks = free_blocks +
+ blocks_currently_used_by_file -
+ blocks_now_used_by_file;
+ }
+
+ unique_ptr<struct archive,
+ decltype ( archive_write_free )*> a( archive_write_new(),
+ archive_write_free );
+
+ check_result( a.get(), archive_write_add_filter_none( a.get() ) );
+ check_result( a.get(), archive_write_set_format_ustar( a.get() ) );
+
+ // `used' may not be correct until after the archive is closed.
+ size_t used = 0xbadbeef;
+ check_result( a.get(), archive_write_open_memory( a.get(),
+ Data,
+ MaxSize,
+ &used ) );
+
+ {
+ unique_ptr<struct archive,
+ decltype ( archive_write_close )*> a_open( a.get(),
+ archive_write_close );
+
+ int file_index = 0;
+ for ( const auto& file : files )
+ {
+ unique_ptr<struct archive_entry,
+ decltype ( archive_entry_free )*>
+ e( archive_entry_new2( a_open.get() ),
+ archive_entry_free );
+
+ char name_buffer[100];
+ snprintf( name_buffer, 100, "file%d", file_index++ );
+
+ archive_entry_set_pathname( e.get(), name_buffer );
+ archive_entry_set_size( e.get(), file.size() );
+ archive_entry_set_filetype( e.get(), AE_IFREG );
+ archive_entry_set_perm( e.get(), 0644 );
+
+ check_result( a_open.get(),
+ archive_write_header( a_open.get(), e.get() ) );
+ archive_write_data( a_open.get(), file.data(), file.size() );
+ check_result( a_open.get(),
+ archive_write_finish_entry( a_open.get() ) );
+ }
+ }
+
+ return used;
+ }
+
+
+ // Cross `Data1' and `Data2', write up to `MaxOutSize' bytes into `Out',
+ // return the number of bytes written, which should be positive.
+ virtual size_t
+ CrossOver( const uint8_t* Data1,
+ size_t Size1,
+ const uint8_t* Data2,
+ size_t Size2,
+ uint8_t* Out,
+ size_t MaxOutSize )
+ {
+ return fuzzer::UserSuppliedFuzzer::CrossOver( Data1,
+ Size1,
+ Data2,
+ Size2,
+ Out,
+ MaxOutSize );
+ }
+
+ }; // end of FTFuzzer class
+
+
+ int
+ main( int argc,
+ char* *argv )
+ {
+ fuzzer::FuzzerRandomLibc Rand( 0 );
+ FTFuzzer F( &Rand );
+
+ fuzzer::FuzzerDriver( argc, argv, F );
+ }
+
+
+// END
diff --git a/src/3rdparty/freetype/src/tools/ftfuzzer/rasterfuzzer.cc b/src/3rdparty/freetype/src/tools/ftfuzzer/rasterfuzzer.cc
new file mode 100644
index 0000000000..c69b95ea0f
--- /dev/null
+++ b/src/3rdparty/freetype/src/tools/ftfuzzer/rasterfuzzer.cc
@@ -0,0 +1,129 @@
+// rasterfuzzer.cc
+//
+// A fuzzing function to test FreeType's rasterizers with libFuzzer.
+//
+// Copyright 2016-2018 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 <stdint.h>
+
+#include <vector>
+
+
+ using namespace std;
+
+
+#include <ft2build.h>
+
+#include FT_FREETYPE_H
+#include FT_IMAGE_H
+#include FT_OUTLINE_H
+
+
+ static FT_Library library;
+ static int InitResult;
+
+
+ struct FT_Global {
+ FT_Global() {
+ InitResult = FT_Init_FreeType( &library );
+ }
+ ~FT_Global() {
+ FT_Done_FreeType( library );
+ }
+ };
+
+ FT_Global global_ft;
+
+
+ extern "C" int
+ LLVMFuzzerTestOneInput( const uint8_t* data,
+ size_t size_ )
+ {
+ unsigned char pixels[4];
+
+ FT_Bitmap bitmap_mono = {
+ 1, // rows
+ 1, // width
+ 4, // pitch
+ pixels, // buffer
+ 2, // num_grays
+ FT_PIXEL_MODE_MONO, // pixel_mode
+ 0, // palette_mode
+ NULL // palette
+ };
+
+ FT_Bitmap bitmap_gray = {
+ 1, // rows
+ 1, // width
+ 4, // pitch
+ pixels, // buffer
+ 256, // num_grays
+ FT_PIXEL_MODE_GRAY, // pixel_mode
+ 0, // palette_mode
+ NULL // palette
+ };
+
+ const size_t vsize = sizeof ( FT_Vector );
+ const size_t tsize = sizeof ( char );
+
+ // we use the input data for both points and tags
+ short n_points = short( size_ / ( vsize + tsize ) );
+ if ( n_points <= 2 )
+ return 0;
+
+ FT_Vector* points = reinterpret_cast<FT_Vector*>(
+ const_cast<uint8_t*>(
+ data ) );
+ char* tags = reinterpret_cast<char*>(
+ const_cast<uint8_t*>(
+ data + size_t( n_points ) * vsize ) );
+
+ // to reduce the number of invalid outlines that are immediately
+ // rejected in `FT_Outline_Render', limit values to 2^18 pixels
+ // (i.e., 2^24 bits)
+ for ( short i = 0; i < n_points; i++ )
+ {
+ if ( points[i].x == LONG_MIN )
+ points[i].x = 0;
+ else if ( points[i].x < 0 )
+ points[i].x = -( -points[i].x & 0xFFFFFF ) - 1;
+ else
+ points[i].x = ( points[i].x & 0xFFFFFF ) + 1;
+
+ if ( points[i].y == LONG_MIN )
+ points[i].y = 0;
+ else if ( points[i].y < 0 )
+ points[i].y = -( -points[i].y & 0xFFFFFF ) - 1;
+ else
+ points[i].y = ( points[i].y & 0xFFFFFF ) + 1;
+ }
+
+ short contours[1];
+ contours[0] = n_points - 1;
+
+ FT_Outline outline =
+ {
+ 1, // n_contours
+ n_points, // n_points
+ points, // points
+ tags, // tags
+ contours, // contours
+ FT_OUTLINE_NONE // flags
+ };
+
+ FT_Outline_Get_Bitmap( library, &outline, &bitmap_mono );
+ FT_Outline_Get_Bitmap( library, &outline, &bitmap_gray );
+
+ return 0;
+ }
+
+
+// END
diff --git a/src/3rdparty/freetype/src/tools/ftfuzzer/runinput.cc b/src/3rdparty/freetype/src/tools/ftfuzzer/runinput.cc
new file mode 100644
index 0000000000..2b02f57580
--- /dev/null
+++ b/src/3rdparty/freetype/src/tools/ftfuzzer/runinput.cc
@@ -0,0 +1,58 @@
+// runinput.cc
+//
+// A `main' function for fuzzers like `ftfuzzer.cc'.
+//
+// Copyright 2015-2018 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 <assert.h>
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <stdint.h>
+
+
+ extern "C" void
+ LLVMFuzzerTestOneInput( const uint8_t* data,
+ size_t size );
+
+
+ unsigned char a[1 << 24];
+
+
+ int
+ main( int argc,
+ char* *argv )
+ {
+ assert( argc >= 2 );
+
+ for ( int i = 1; i < argc; i++ )
+ {
+ fprintf( stderr, "%s\n", argv[i] );
+
+ FILE* f = fopen( argv[i], "r" );
+ assert( f );
+
+ size_t n = fread( a, 1, sizeof ( a ), f );
+ fclose( f );
+ if ( !n )
+ continue;
+
+ unsigned char* b = (unsigned char*)malloc( n );
+ memcpy( b, a, n );
+
+ LLVMFuzzerTestOneInput( b, n );
+
+ free( b );
+ }
+ }
+
+
+// END
diff --git a/src/3rdparty/freetype/src/tools/ftrandom/Makefile b/src/3rdparty/freetype/src/tools/ftrandom/Makefile
index 2e619299cd..24dc49c563 100644
--- a/src/3rdparty/freetype/src/tools/ftrandom/Makefile
+++ b/src/3rdparty/freetype/src/tools/ftrandom/Makefile
@@ -5,7 +5,12 @@ TOP_DIR ?= ../../..
OBJ_DIR ?= $(TOP_DIR)/objs
-# The setup below is for gcc on a Unix-like platform.
+# The setup below is for gcc on a Unix-like platform,
+# where FreeType has been set up to create a static library
+# (which is the default).
+
+VPATH = $(OBJ_DIR) \
+ $(OBJ_DIR)/.libs
SRC_DIR = $(TOP_DIR)/src/tools/ftrandom
@@ -20,16 +25,21 @@ WFLAGS = -Wmissing-prototypes \
-Wchar-subscripts \
-Wsequence-point
CFLAGS = $(WFLAGS) \
- -g \
- -I $(TOP_DIR)/include
+ -g
+INCLUDES = -I $(TOP_DIR)/include
+LDFLAGS =
LIBS = -lm \
- -L $(OBJ_DIR) \
- -lfreetype \
- -lz
+ -lz \
+ -lpng \
+ -lbz2 \
+ -lharfbuzz
all: $(OBJ_DIR)/ftrandom
-$(OBJ_DIR)/ftrandom: $(SRC_DIR)/ftrandom.c $(OBJ_DIR)/libfreetype.a
- $(CC) -o $(OBJ_DIR)/ftrandom $(CFLAGS) $(SRC_DIR)/ftrandom.c $(LIBS)
+$(OBJ_DIR)/ftrandom.o: $(SRC_DIR)/ftrandom.c
+ $(CC) $(CFLAGS) $(INCLUDES) -c -o $@ $<
+
+$(OBJ_DIR)/ftrandom: $(OBJ_DIR)/ftrandom.o libfreetype.a
+ $(CC) $(LDFLAGS) -o $@ $^ $(LIBS)
# EOF
diff --git a/src/3rdparty/freetype/src/tools/ftrandom/README b/src/3rdparty/freetype/src/tools/ftrandom/README
index 71bf05323d..7c610864b6 100644
--- a/src/3rdparty/freetype/src/tools/ftrandom/README
+++ b/src/3rdparty/freetype/src/tools/ftrandom/README
@@ -1,48 +1,69 @@
ftrandom
---------
+========
This program expects a set of directories containing good fonts, and a set
of extensions of fonts to be tested. It will randomly pick a font, copy it,
-introduce and error and then test it.
+introduce an error and then test it.
-The FreeType tests are quite basic:
+The FreeType tests are quite basic; for each erroneous font ftrandom
- For each erroneous font it
- forks off a new tester;
- initializes the library;
- opens each font in the file;
- loads each glyph;
- (optionally reviewing the contours of the glyph)
- (optionally rasterizing)
- closes the face.
+ . forks off a new tester,
+ . initializes the library,
+ . opens each font in the file,
+ . loads each glyph,
+ . optionally reviews the contours of the glyph,
+ . optionally rasterizes the glyph, and
+ . closes the face.
-If the tester exits with a signal, or takes longer than 20 seconds then
-ftrandom saves the erroneous font and continues. If the tester exits
-normally or with an error, then the superstructure removes the test font and
-continues.
+If a tester takes longer than 20 seconds, ftrandom saves the erroneous font
+and continues. If the tester exits normally or with an error, then the
+superstructure removes the test font and continues.
-Arguments are:
+
+Command line options
+--------------------
--all Test every font in the directory(ies) no matter
- what its extension (some CID-keyed fonts have no
- extension).
- --check-outlines Call FT_Outline_Decompose on each glyph.
+ what its extension.
+ --check-outlines Call `FT_Outline_Decompose' on each glyph.
--dir <dir> Append <dir> to the list of directories to search
- for good fonts.
+ for good fonts. No recursive search.
--error-count <cnt> Introduce <cnt> single-byte errors into the
- erroneous fonts.
+ erroneous fonts (default: 1).
--error-fraction <frac> Multiply the file size of the font by <frac> and
introduce that many errors into the erroneous
- font file.
- --ext <ext> Add <ext> to the set of font types tested. Known
- extensions are `ttf', `otf', `ttc', `cid', `pfb',
- `pfa', `bdf', `pcf', `pfr', `fon', `otb', and
- `cff'.
+ font file. <frac> should be in the range [0;1]
+ (default: 0.0).
+ --ext <ext> Add <ext> to the set of font types tested.
--help Print out this list of options.
--nohints Specify FT_LOAD_NO_HINTING when loading glyphs.
- --rasterize Call FT_Render_Glyph as well as loading it.
+ --rasterize Call `FT_Render_Glyph' as well as loading it.
--result <dir> This is the directory in which test files are
placed.
--test <file> Run a single test on a pre-generated testcase.
- Done in the current process so it can be debugged
- more easily.
+ This is done in the current process so it can be
+ debugged more easily.
+
+The default font extensions tested by ftrandom are
+
+ .ttf .otf .ttc .cid .pfb .pfa .bdf .pcf .pfr .fon .otb .cff
+
+The default font directory is controlled by the macro `GOOD_FONTS_DIR' in
+the source code (and can be thus specified during compilation); its default
+value is
+
+ /usr/local/share/fonts
+
+The default result directory is `results' (in the current directory).
+
+
+Compilation
+-----------
+
+Two possible solutions.
+
+. Run ftrandom within a debugging tool like `valgrind' to catch various
+ memory issues.
+
+. Compile FreeType with sanitizer flags as provided by gcc or clang, for
+ example, then link it with ftrandom.
diff --git a/src/3rdparty/freetype/src/tools/ftrandom/ftrandom.c b/src/3rdparty/freetype/src/tools/ftrandom/ftrandom.c
index 9a5b632673..ab5cfc98b6 100644
--- a/src/3rdparty/freetype/src/tools/ftrandom/ftrandom.c
+++ b/src/3rdparty/freetype/src/tools/ftrandom/ftrandom.c
@@ -29,6 +29,9 @@
/* This file is now part of the FreeType library */
+#define _XOPEN_SOURCE 500 /* for `kill', `strdup', `random', and `srandom' */
+
+
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -38,7 +41,6 @@
#include <sys/wait.h>
#include <unistd.h>
#include <dirent.h>
-#include <math.h>
#include <signal.h>
#include <time.h>
@@ -56,7 +58,7 @@
static int rasterize = false;
static char* results_dir = "results";
-#define GOOD_FONTS_DIR "/home/wl/freetype-testfonts"
+#define GOOD_FONTS_DIR "/usr/local/share/fonts"
static char* default_dir_list[] =
{
@@ -81,28 +83,31 @@
NULL
};
- static int error_count = 1;
- static int error_fraction = 0;
+ static unsigned int error_count = 1;
+ static double error_fraction = 0.0;
static FT_F26Dot6 font_size = 12 * 64;
static struct fontlist
{
char* name;
- int len;
+ long len;
unsigned int isbinary: 1;
unsigned int isascii: 1;
unsigned int ishex: 1;
} *fontlist;
- static int fcnt;
+ static unsigned int fcnt;
static int
FT_MoveTo( const FT_Vector *to,
void *user )
{
+ FT_UNUSED( to );
+ FT_UNUSED( user );
+
return 0;
}
@@ -111,6 +116,9 @@
FT_LineTo( const FT_Vector *to,
void *user )
{
+ FT_UNUSED( to );
+ FT_UNUSED( user );
+
return 0;
}
@@ -120,6 +128,10 @@
const FT_Vector *to,
void *user )
{
+ FT_UNUSED( _cp );
+ FT_UNUSED( to );
+ FT_UNUSED( user );
+
return 0;
}
@@ -130,6 +142,11 @@
const FT_Vector *to,
void *user )
{
+ FT_UNUSED( cp1 );
+ FT_UNUSED( cp2 );
+ FT_UNUSED( to );
+ FT_UNUSED( user );
+
return 0;
}
@@ -147,8 +164,8 @@
static void
TestFace( FT_Face face )
{
- int gid;
- int load_flags = FT_LOAD_DEFAULT;
+ unsigned int gid;
+ int load_flags = FT_LOAD_DEFAULT;
if ( check_outlines &&
@@ -160,7 +177,7 @@
FT_Set_Char_Size( face, 0, font_size, 72, 72 );
- for ( gid = 0; gid < face->num_glyphs; ++gid )
+ for ( gid = 0; gid < face->num_glyphs; gid++ )
{
if ( check_outlines &&
FT_IS_SCALABLE( face ) )
@@ -202,19 +219,21 @@
TestFace( face );
else
{
- int i, num;
+ long i, num;
num = face->num_faces;
FT_Done_Face( face );
- for ( i = 0; i < num; ++i )
+ for ( i = 0; i < num; i++ )
{
if ( !FT_New_Face( context, testfont, i, &face ) )
TestFace( face );
}
}
+ FT_Done_FreeType( context );
+
exit( 0 );
}
@@ -227,16 +246,16 @@
char* pt;
- if ( extensions == NULL )
+ if ( !extensions )
return true;
pt = strrchr( filename, '.' );
- if ( pt == NULL )
+ if ( !pt )
return false;
if ( pt < strrchr( filename, '/' ) )
return false;
- for ( i = 0; extensions[i] != NULL; ++i )
+ for ( i = 0; extensions[i] != NULL; i++ )
if ( strcasecmp( pt + 1, extensions[i] ) == 0 ||
strcasecmp( pt, extensions[i] ) == 0 )
return true;
@@ -254,7 +273,7 @@
item->isbinary = item->isascii = item->ishex = false;
foo = fopen( item->name, "rb" );
- if ( foo != NULL )
+ if ( foo )
{
/* Try to guess the file type from the first few characters... */
int ch1 = getc( foo );
@@ -281,8 +300,8 @@
else if ( ch1 == '%' && ch2 == '!' )
{
/* Random PostScript */
- if ( strstr( item->name, ".pfa" ) != NULL ||
- strstr( item->name, ".PFA" ) != NULL )
+ if ( strstr( item->name, ".pfa" ) ||
+ strstr( item->name, ".PFA" ) )
item->ishex = true;
else
item->isascii = true;
@@ -329,22 +348,23 @@
FindFonts( char** fontdirs,
char** extensions )
{
- int i, max;
- char buffer[1025];
- struct stat statb;
+ int i;
+ unsigned int max;
+ char buffer[1025];
+ struct stat statb;
max = 0;
fcnt = 0;
- for ( i = 0; fontdirs[i] != NULL; ++i )
+ for ( i = 0; fontdirs[i] != NULL; i++ )
{
DIR* examples;
struct dirent* ent;
examples = opendir( fontdirs[i] );
- if ( examples == NULL )
+ if ( !examples )
{
fprintf( stderr,
"Can't open example font directory `%s'\n",
@@ -358,13 +378,13 @@
"%s/%s", fontdirs[i], ent->d_name );
if ( stat( buffer, &statb ) == -1 || S_ISDIR( statb.st_mode ) )
continue;
- if ( extensions == NULL || extmatch( buffer, extensions ) )
+ if ( !extensions || extmatch( buffer, extensions ) )
{
if ( fcnt >= max )
{
max += 100;
fontlist = realloc( fontlist, max * sizeof ( struct fontlist ) );
- if ( fontlist == NULL )
+ if ( !fontlist )
{
fprintf( stderr, "Can't allocate memory\n" );
exit( 1 );
@@ -375,7 +395,7 @@
fontlist[fcnt].len = statb.st_size;
figurefiletype( &fontlist[fcnt] );
- ++fcnt;
+ fcnt++;
}
}
@@ -392,13 +412,13 @@
}
- static int
+ static unsigned int
getErrorCnt( struct fontlist* item )
{
- if ( error_count == 0 && error_fraction == 0 )
+ if ( error_count == 0 && error_fraction == 0.0 )
return 0;
- return error_count + ceil( error_fraction * item->len );
+ return error_count + (unsigned int)( error_fraction * item->len );
}
@@ -417,21 +437,21 @@
copyfont( struct fontlist* item,
char* newfont )
{
- static char buffer[8096];
- FILE *good, *new;
- int len;
- int i, err_cnt;
+ static char buffer[8096];
+ FILE *good, *newf;
+ size_t len;
+ unsigned int i, err_cnt;
good = fopen( item->name, "r" );
- if ( good == NULL )
+ if ( !good )
{
fprintf( stderr, "Can't open `%s'\n", item->name );
return false;
}
- new = fopen( newfont, "w+" );
- if ( new == NULL )
+ newf = fopen( newfont, "w+" );
+ if ( !newf )
{
fprintf( stderr, "Can't create temporary output file `%s'\n",
newfont );
@@ -439,19 +459,19 @@
}
while ( ( len = fread( buffer, 1, sizeof ( buffer ), good ) ) > 0 )
- fwrite( buffer, 1, len, new );
+ fwrite( buffer, 1, len, newf );
fclose( good );
err_cnt = getErrorCnt( item );
- for ( i = 0; i < err_cnt; ++i )
+ for ( i = 0; i < err_cnt; i++ )
{
- fseek( new, getRandom( 0, item->len - 1 ), SEEK_SET );
+ fseek( newf, getRandom( 0, (int)( item->len - 1 ) ), SEEK_SET );
if ( item->isbinary )
- putc( getRandom( 0, 0xFF ), new );
+ putc( getRandom( 0, 0xFF ), newf );
else if ( item->isascii )
- putc( getRandom( 0x20, 0x7E ), new );
+ putc( getRandom( 0x20, 0x7E ), newf );
else
{
int hex = getRandom( 0, 15 );
@@ -462,18 +482,18 @@
else
hex += 'A' - 10;
- putc( hex, new );
+ putc( hex, newf );
}
}
- if ( ferror( new ) )
+ if ( ferror( newf ) )
{
- fclose( new );
+ fclose( newf );
unlink( newfont );
return false;
}
- fclose( new );
+ fclose( newf );
return true;
}
@@ -484,6 +504,8 @@
static void
abort_test( int sig )
{
+ FT_UNUSED( sig );
+
/* If a time-out happens, then kill the child */
kill( child_pid, SIGFPE );
write( 2, "Timeout... ", 11 );
@@ -493,7 +515,7 @@
static void
do_test( void )
{
- int i = getRandom( 0, fcnt - 1 );
+ int i = getRandom( 0, (int)( fcnt - 1 ) );
static int test_num = 0;
char buffer[1024];
@@ -534,22 +556,42 @@
usage( FILE* out,
char* name )
{
+ char** d = default_dir_list;
+ char** e = default_ext_list;
+
+
fprintf( out, "%s [options] -- Generate random erroneous fonts\n"
" and attempt to parse them with FreeType.\n\n", name );
fprintf( out, " --all All non-directory files are assumed to be fonts.\n" );
fprintf( out, " --check-outlines Make sure we can parse the outlines of each glyph.\n" );
- fprintf( out, " --dir <path> Append <path> to list of font search directories.\n" );
- fprintf( out, " --error-count <cnt> Introduce <cnt> single byte errors into each font.\n" );
+ fprintf( out, " --dir <path> Append <path> to list of font search directories\n"
+ " (no recursive search).\n" );
+ fprintf( out, " --error-count <cnt> Introduce <cnt> single byte errors into each font\n"
+ " (default: 1)\n" );
fprintf( out, " --error-fraction <frac> Introduce <frac>*filesize single byte errors\n"
- " into each font.\n" );
+ " into each font (default: 0.0).\n" );
fprintf( out, " --ext <ext> Add <ext> to list of extensions indicating fonts.\n" );
fprintf( out, " --help Print this.\n" );
fprintf( out, " --nohints Turn off hinting.\n" );
fprintf( out, " --rasterize Attempt to rasterize each glyph.\n" );
- fprintf( out, " --results <dir> Directory in which to place the test fonts.\n" );
+ fprintf( out, " --results <path> Place the created test fonts into <path>\n"
+ " (default: `results')\n" );
fprintf( out, " --size <float> Use the given font size for the tests.\n" );
fprintf( out, " --test <file> Run a single test on an already existing file.\n" );
+ fprintf( out, "\n" );
+
+ fprintf( out, "Default font extensions:\n" );
+ fprintf( out, " " );
+ while ( *e )
+ fprintf( out, " .%s", *e++ );
+ fprintf( out, "\n" );
+
+ fprintf( out, "Default font directories:\n" );
+ fprintf( out, " " );
+ while ( *d )
+ fprintf( out, " %s", *d++ );
+ fprintf( out, "\n" );
}
@@ -564,17 +606,17 @@
char* testfile = NULL;
- dirs = calloc( argc + 1, sizeof ( char ** ) );
- exts = calloc( argc + 1, sizeof ( char ** ) );
+ dirs = calloc( (size_t)( argc + 1 ), sizeof ( char ** ) );
+ exts = calloc( (size_t)( argc + 1 ), sizeof ( char ** ) );
- for ( i = 1; i < argc; ++i )
+ for ( i = 1; i < argc; i++ )
{
char* pt = argv[i];
char* end;
if ( pt[0] == '-' && pt[1] == '-' )
- ++pt;
+ pt++;
if ( strcmp( pt, "-all" ) == 0 )
allexts = true;
@@ -585,9 +627,9 @@
else if ( strcmp( pt, "-error-count" ) == 0 )
{
if ( !rset )
- error_fraction = 0;
+ error_fraction = 0.0;
rset = true;
- error_count = strtol( argv[++i], &end, 10 );
+ error_count = (unsigned int)strtoul( argv[++i], &end, 10 );
if ( *end != '\0' )
{
fprintf( stderr, "Bad value for error-count: %s\n", argv[i] );
@@ -605,6 +647,11 @@
fprintf( stderr, "Bad value for error-fraction: %s\n", argv[i] );
exit( 1 );
}
+ if ( error_fraction < 0.0 || error_fraction > 1.0 )
+ {
+ fprintf( stderr, "error-fraction must be in the range [0;1]\n" );
+ exit( 1 );
+ }
}
else if ( strcmp( pt, "-ext" ) == 0 )
exts[ecnt++] = argv[++i];
@@ -654,11 +701,11 @@
dirs = default_dir_list;
}
- if ( testfile != NULL )
+ if ( testfile )
ExecuteTest( testfile ); /* This should never return */
time( &now );
- srandom( now );
+ srandom( (unsigned int)now );
FindFonts( dirs, exts );
mkdir( results_dir, 0755 );
diff --git a/src/3rdparty/freetype/src/tools/glnames.py b/src/3rdparty/freetype/src/tools/glnames.py
index 0ad554c72d..b048d29364 100644
--- a/src/3rdparty/freetype/src/tools/glnames.py
+++ b/src/3rdparty/freetype/src/tools/glnames.py
@@ -6,7 +6,7 @@
#
-# Copyright 1996-2015 by
+# Copyright 1996-2018 by
# David Turner, Robert Wilhelm, and Werner Lemberg.
#
# This file is part of the FreeType project, and may only be used, modified,
@@ -151,7 +151,7 @@ mac_standard_names = \
# The list of standard `SID' glyph names. For the official list,
# see Annex A of document at
#
-# http://partners.adobe.com/public/developer/en/font/5176.CFF.pdf .
+# https://www.adobe.com/content/dam/acom/en/devnet/font/pdfs/5176.CFF.pdf .
#
sid_standard_names = \
[
@@ -415,7 +415,7 @@ t1_expert_encoding = \
# This data has been taken literally from the files `glyphlist.txt'
# and `zapfdingbats.txt' version 2.0, Sept 2002. It is available from
#
-# http://sourceforge.net/adobe/aglfn/
+# https://github.com/adobe-type-tools/agl-aglfn
#
adobe_glyph_list = """\
A;0041
@@ -4920,8 +4920,17 @@ class StringTable:
def dump( self, file ):
write = file.write
- write( " static const char " + self.master_table +
- "[" + repr( self.total ) + "] =\n" )
+ write( "#ifndef DEFINE_PS_TABLES_DATA\n" )
+ write( "#ifdef __cplusplus\n" )
+ write( ' extern "C"\n' )
+ write( "#else\n" )
+ write( " extern\n" )
+ write( "#endif\n" )
+ write( "#endif\n" )
+ write( " const char " + self.master_table +
+ "[" + repr( self.total ) + "]\n" )
+ write( "#ifdef DEFINE_PS_TABLES_DATA\n" )
+ write( " =\n" )
write( " {\n" )
line = ""
@@ -4930,7 +4939,10 @@ class StringTable:
line += string.join( ( re.findall( ".", name ) ), "','" )
line += "', 0,\n"
- write( line + " };\n\n\n" )
+ write( line )
+ write( " }\n" )
+ write( "#endif /* DEFINE_PS_TABLES_DATA */\n" )
+ write( " ;\n\n\n" )
def dump_sublist( self, file, table_name, macro_name, sublist ):
write = file.write
@@ -4938,8 +4950,17 @@ class StringTable:
write( " /* Values are offsets into the `" +
self.master_table + "' table */\n\n" )
- write( " static const short " + table_name +
- "[" + macro_name + "] =\n" )
+ write( "#ifndef DEFINE_PS_TABLES_DATA\n" )
+ write( "#ifdef __cplusplus\n" )
+ write( ' extern "C"\n' )
+ write( "#else\n" )
+ write( " extern\n" )
+ write( "#endif\n" )
+ write( "#endif\n" )
+ write( " const short " + table_name +
+ "[" + macro_name + "]\n" )
+ write( "#ifdef DEFINE_PS_TABLES_DATA\n" )
+ write( " =\n" )
write( " {\n" )
line = " "
@@ -4955,7 +4976,11 @@ class StringTable:
col = 0
comma = ",\n "
- write( line + "\n };\n\n\n" )
+ write( line )
+ write( "\n" )
+ write( " }\n" )
+ write( "#endif /* DEFINE_PS_TABLES_DATA */\n" )
+ write( " ;\n\n\n" )
# We now store the Adobe Glyph List in compressed form. The list is put
@@ -5188,8 +5213,17 @@ def dump_encoding( file, encoding_name, encoding_list ):
write = file.write
write( " /* the following are indices into the SID name table */\n" )
- write( " static const unsigned short " + encoding_name +
- "[" + repr( len( encoding_list ) ) + "] =\n" )
+ write( "#ifndef DEFINE_PS_TABLES_DATA\n" )
+ write( "#ifdef __cplusplus\n" )
+ write( ' extern "C"\n' )
+ write( "#else\n" )
+ write( " extern\n" )
+ write( "#endif\n" )
+ write( "#endif\n" )
+ write( " const unsigned short " + encoding_name +
+ "[" + repr( len( encoding_list ) ) + "]\n" )
+ write( "#ifdef DEFINE_PS_TABLES_DATA\n" )
+ write( " =\n" )
write( " {\n" )
line = " "
@@ -5204,14 +5238,27 @@ def dump_encoding( file, encoding_name, encoding_list ):
col = 0
comma = ",\n "
- write( line + "\n };\n\n\n" )
+ write( line )
+ write( "\n" )
+ write( " }\n" )
+ write( "#endif /* DEFINE_PS_TABLES_DATA */\n" )
+ write( " ;\n\n\n" )
def dump_array( the_array, write, array_name ):
"""dumps a given encoding"""
- write( " static const unsigned char " + array_name +
- "[" + repr( len( the_array ) ) + "L] =\n" )
+ write( "#ifndef DEFINE_PS_TABLES_DATA\n" )
+ write( "#ifdef __cplusplus\n" )
+ write( ' extern "C"\n' )
+ write( "#else\n" )
+ write( " extern\n" )
+ write( "#endif\n" )
+ write( "#endif\n" )
+ write( " const unsigned char " + array_name +
+ "[" + repr( len( the_array ) ) + "L]\n" )
+ write( "#ifdef DEFINE_PS_TABLES_DATA\n" )
+ write( " =\n" )
write( " {\n" )
line = ""
@@ -5232,7 +5279,11 @@ def dump_array( the_array, write, array_name ):
write( line )
line = ""
- write( line + "\n };\n\n\n" )
+ write( line )
+ write( "\n" )
+ write( " }\n" )
+ write( "#endif /* DEFINE_PS_TABLES_DATA */\n" )
+ write( " ;\n\n\n" )
def main():
@@ -5242,7 +5293,7 @@ def main():
print __doc__ % sys.argv[0]
sys.exit( 1 )
- file = open( sys.argv[1], "w\n" )
+ file = open( sys.argv[1], "wb" )
write = file.write
count_sid = len( sid_standard_names )
@@ -5267,7 +5318,7 @@ def main():
write( "/* */\n" )
write( "/* PostScript glyph names. */\n" )
write( "/* */\n" )
- write( "/* Copyright 2005-2015 by */\n" )
+ write( "/* Copyright 2005-2018 by */\n" )
write( "/* David Turner, Robert Wilhelm, and Werner Lemberg. */\n" )
write( "/* */\n" )
write( "/* This file is part of the FreeType project, and may only be used, */\n" )
@@ -5327,6 +5378,7 @@ def main():
# write the lookup routine now
#
write( """\
+#ifdef DEFINE_PS_TABLES
/*
* This function searches the compressed table efficiently.
*/
@@ -5421,6 +5473,7 @@ def main():
NotFound:
return 0;
}
+#endif /* DEFINE_PS_TABLES */
#endif /* FT_CONFIG_OPTION_ADOBE_GLYPH_LIST */
diff --git a/src/3rdparty/freetype/src/tools/no-copyright b/src/3rdparty/freetype/src/tools/no-copyright
index 5011e3fb62..d639aa4a84 100644
--- a/src/3rdparty/freetype/src/tools/no-copyright
+++ b/src/3rdparty/freetype/src/tools/no-copyright
@@ -14,6 +14,9 @@ builds/unix/pkg.m4
docs/FTL.TXT
docs/GPLv2.TXT
#
+include/freetype/internal/fthash.h
+#
+src/base/fthash.c
src/base/md5.c
src/base/md5.h
#
@@ -56,6 +59,7 @@ src/gzip/zlib.h
src/gzip/zutil.c
src/gzip/zutil.h
#
+src/tools/apinames.c
src/tools/ftrandom/ftrandom.c
#
# EOF
diff --git a/src/3rdparty/freetype/src/tools/update-copyright-year b/src/3rdparty/freetype/src/tools/update-copyright-year
index 107754183d..934f11cf02 100644
--- a/src/3rdparty/freetype/src/tools/update-copyright-year
+++ b/src/3rdparty/freetype/src/tools/update-copyright-year
@@ -2,7 +2,7 @@ eval '(exit $?0)' && eval 'exec perl -wS -i "$0" ${1+"$@"}'
& eval 'exec perl -wS -i "$0" $argv:q'
if 0;
-# Copyright 2015 by
+# Copyright 2015-2018 by
# Werner Lemberg.
#
# This file is part of the FreeType project, and may only be used, modified,
diff --git a/src/3rdparty/freetype/src/truetype/Jamfile b/src/3rdparty/freetype/src/truetype/Jamfile
index 88cc26f2b1..e321fba14a 100644
--- a/src/3rdparty/freetype/src/truetype/Jamfile
+++ b/src/3rdparty/freetype/src/truetype/Jamfile
@@ -1,6 +1,6 @@
# FreeType 2 src/truetype Jamfile
#
-# Copyright 2001-2015 by
+# Copyright 2001-2018 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/src/3rdparty/freetype/src/truetype/module.mk b/src/3rdparty/freetype/src/truetype/module.mk
index c6dc6fa6e7..16bc9c8b20 100644
--- a/src/3rdparty/freetype/src/truetype/module.mk
+++ b/src/3rdparty/freetype/src/truetype/module.mk
@@ -3,7 +3,7 @@
#
-# Copyright 1996-2015 by
+# Copyright 1996-2018 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/src/3rdparty/freetype/src/truetype/rules.mk b/src/3rdparty/freetype/src/truetype/rules.mk
index 1db16ba35f..e16113f128 100644
--- a/src/3rdparty/freetype/src/truetype/rules.mk
+++ b/src/3rdparty/freetype/src/truetype/rules.mk
@@ -3,7 +3,7 @@
#
-# Copyright 1996-2015 by
+# Copyright 1996-2018 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/src/3rdparty/freetype/src/truetype/truetype.c b/src/3rdparty/freetype/src/truetype/truetype.c
index f929437dc1..484370975c 100644
--- a/src/3rdparty/freetype/src/truetype/truetype.c
+++ b/src/3rdparty/freetype/src/truetype/truetype.c
@@ -4,7 +4,7 @@
/* */
/* FreeType TrueType driver component (body only). */
/* */
-/* Copyright 1996-2015 by */
+/* Copyright 1996-2018 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/src/3rdparty/freetype/src/truetype/ttdriver.c b/src/3rdparty/freetype/src/truetype/ttdriver.c
index 08b30c95ad..820cafbb8d 100644
--- a/src/3rdparty/freetype/src/truetype/ttdriver.c
+++ b/src/3rdparty/freetype/src/truetype/ttdriver.c
@@ -4,7 +4,7 @@
/* */
/* TrueType font driver implementation (body). */
/* */
-/* Copyright 1996-2015 by */
+/* Copyright 1996-2018 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -25,12 +25,13 @@
#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
#include FT_SERVICE_TRUETYPE_GLYF_H
#include FT_SERVICE_PROPERTIES_H
-#include FT_TRUETYPE_DRIVER_H
+#include FT_DRIVER_H
#include "ttdriver.h"
#include "ttgload.h"
@@ -61,23 +62,50 @@
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;
-#ifndef TT_CONFIG_OPTION_SUBPIXEL_HINTING
- if ( *interpreter_version != TT_INTERPRETER_VERSION_35 )
- error = FT_ERR( Unimplemented_Feature );
+#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
- driver->interpreter_version = *interpreter_version;
+ {
+ 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
+#endif
+#ifdef TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL
+ || interpreter_version == TT_INTERPRETER_VERSION_40
+#endif
+ )
+ driver->interpreter_version = interpreter_version;
+ else
+ error = FT_ERR( Unimplemented_Feature );
return error;
}
@@ -117,8 +145,10 @@
FT_DEFINE_SERVICE_PROPERTIESREC(
tt_service_properties,
- (FT_Properties_SetFunc)tt_property_set,
- (FT_Properties_GetFunc)tt_property_get )
+
+ (FT_Properties_SetFunc)tt_property_set, /* set_property */
+ (FT_Properties_GetFunc)tt_property_get /* get_property */
+ )
/*************************************************************************/
@@ -194,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 ( ( FT_IS_NAMED_INSTANCE( ttface ) || FT_IS_VARIATION( ttface ) ) &&
+ !( face->variation_support & TT_FACE_FLAG_VAR_VADVANCE ) )
+ return FT_THROW( Unimplemented_Feature );
+#endif
+
for ( nn = 0; nn < count; nn++ )
{
FT_Short tsb;
@@ -214,6 +251,13 @@
}
else
{
+#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
+ /* no fast retrieval for blended MM fonts without HVAR table */
+ if ( ( FT_IS_NAMED_INSTANCE( ttface ) || FT_IS_VARIATION( ttface ) ) &&
+ !( face->variation_support & TT_FACE_FLAG_VAR_HADVANCE ) )
+ return FT_THROW( Unimplemented_Feature );
+#endif
+
for ( nn = 0; nn < count; nn++ )
{
FT_Short lsb;
@@ -228,6 +272,7 @@
return FT_Err_Ok;
}
+
/*************************************************************************/
/*************************************************************************/
/*************************************************************************/
@@ -259,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;
}
@@ -291,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;
@@ -309,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;
@@ -392,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 );
@@ -415,24 +487,46 @@
/*************************************************************************/
#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
+
FT_DEFINE_SERVICE_MULTIMASTERSREC(
tt_service_gx_multi_masters,
- (FT_Get_MM_Func) NULL,
- (FT_Set_MM_Design_Func) NULL,
- (FT_Set_MM_Blend_Func) TT_Set_MM_Blend,
- (FT_Get_MM_Var_Func) TT_Get_MM_Var,
- (FT_Set_Var_Design_Func)TT_Set_Var_Design )
-#endif
+
+ (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 */
+ (FT_Get_Var_Design_Func)TT_Get_Var_Design, /* get_var_design */
+ (FT_Set_Instance_Func) TT_Set_Named_Instance, /* set_instance */
+
+ (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 =
{
#ifdef TT_USE_BYTECODE_INTERPRETER
-#ifdef TT_CONFIG_OPTION_UNPATENTED_HINTING
- FT_TRUETYPE_ENGINE_TYPE_UNPATENTED
-#else
FT_TRUETYPE_ENGINE_TYPE_PATENTED
-#endif
#else /* !TT_USE_BYTECODE_INTERPRETER */
@@ -441,21 +535,28 @@
#endif /* TT_USE_BYTECODE_INTERPRETER */
};
+
FT_DEFINE_SERVICE_TTGLYFREC(
tt_service_truetype_glyf,
- (TT_Glyf_GetLocationFunc)tt_face_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,
@@ -483,7 +584,7 @@
#endif
result = ft_service_list_lookup( TT_SERVICES_GET, tt_interface );
- if ( result != NULL )
+ if ( result )
return result;
#ifndef FT_CONFIG_OPTION_PIC
@@ -534,31 +635,31 @@
0x10000L, /* driver version == 1.0 */
0x20000L, /* driver requires FreeType 2.0 or above */
- (void*)0, /* driver specific interface */
+ NULL, /* module-specific interface */
- tt_driver_init,
- tt_driver_done,
- tt_get_interface,
+ tt_driver_init, /* FT_Module_Constructor module_init */
+ tt_driver_done, /* FT_Module_Destructor module_done */
+ tt_get_interface, /* FT_Module_Requester get_interface */
sizeof ( TT_FaceRec ),
sizeof ( TT_SizeRec ),
sizeof ( FT_GlyphSlotRec ),
- tt_face_init,
- tt_face_done,
- tt_size_init,
- tt_size_done,
- tt_slot_init,
- 0, /* FT_Slot_DoneFunc */
+ tt_face_init, /* FT_Face_InitFunc init_face */
+ tt_face_done, /* FT_Face_DoneFunc done_face */
+ tt_size_init, /* FT_Size_InitFunc init_size */
+ tt_size_done, /* FT_Size_DoneFunc done_size */
+ tt_slot_init, /* FT_Slot_InitFunc init_slot */
+ NULL, /* FT_Slot_DoneFunc done_slot */
- tt_glyph_load,
+ tt_glyph_load, /* FT_Slot_LoadFunc load_glyph */
- tt_get_kerning,
- 0, /* FT_Face_AttachFunc */
- tt_get_advances,
+ tt_get_kerning, /* FT_Face_GetKerningFunc get_kerning */
+ NULL, /* FT_Face_AttachFunc attach_file */
+ tt_get_advances, /* FT_Face_GetAdvancesFunc get_advances */
- tt_size_request,
- TT_SIZE_SELECT
+ tt_size_request, /* FT_Size_RequestFunc request_size */
+ TT_SIZE_SELECT /* FT_Size_SelectFunc select_size */
)
diff --git a/src/3rdparty/freetype/src/truetype/ttdriver.h b/src/3rdparty/freetype/src/truetype/ttdriver.h
index 6cacd60966..707aa68edf 100644
--- a/src/3rdparty/freetype/src/truetype/ttdriver.h
+++ b/src/3rdparty/freetype/src/truetype/ttdriver.h
@@ -4,7 +4,7 @@
/* */
/* High-level TrueType driver interface (specification). */
/* */
-/* Copyright 1996-2015 by */
+/* Copyright 1996-2018 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -16,8 +16,8 @@
/***************************************************************************/
-#ifndef __TTDRIVER_H__
-#define __TTDRIVER_H__
+#ifndef TTDRIVER_H_
+#define TTDRIVER_H_
#include <ft2build.h>
@@ -32,7 +32,7 @@ FT_BEGIN_HEADER
FT_END_HEADER
-#endif /* __TTDRIVER_H__ */
+#endif /* TTDRIVER_H_ */
/* END */
diff --git a/src/3rdparty/freetype/src/truetype/tterrors.h b/src/3rdparty/freetype/src/truetype/tterrors.h
index ba32cf744c..88bca3a04a 100644
--- a/src/3rdparty/freetype/src/truetype/tterrors.h
+++ b/src/3rdparty/freetype/src/truetype/tterrors.h
@@ -4,7 +4,7 @@
/* */
/* TrueType error codes (specification only). */
/* */
-/* Copyright 2001-2015 by */
+/* Copyright 2001-2018 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -23,12 +23,12 @@
/* */
/*************************************************************************/
-#ifndef __TTERRORS_H__
-#define __TTERRORS_H__
+#ifndef TTERRORS_H_
+#define TTERRORS_H_
#include FT_MODULE_ERRORS_H
-#undef __FTERRORS_H__
+#undef FTERRORS_H_
#undef FT_ERR_PREFIX
#define FT_ERR_PREFIX TT_Err_
@@ -36,6 +36,7 @@
#include FT_ERRORS_H
-#endif /* __TTERRORS_H__ */
+#endif /* TTERRORS_H_ */
+
/* END */
diff --git a/src/3rdparty/freetype/src/truetype/ttgload.c b/src/3rdparty/freetype/src/truetype/ttgload.c
index a792ad44a0..39d9c3f736 100644
--- a/src/3rdparty/freetype/src/truetype/ttgload.c
+++ b/src/3rdparty/freetype/src/truetype/ttgload.c
@@ -4,7 +4,7 @@
/* */
/* TrueType Glyph Loader (body). */
/* */
-/* Copyright 1996-2015 by */
+/* Copyright 1996-2018 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -18,12 +18,14 @@
#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
#include FT_TRUETYPE_TAGS_H
#include FT_OUTLINE_H
-#include FT_TRUETYPE_DRIVER_H
+#include FT_DRIVER_H
+#include FT_LIST_H
#include "ttgload.h"
#include "ttpload.h"
@@ -85,7 +87,7 @@
/*************************************************************************/
/* */
/* Return the vertical metrics in font units for a given glyph. */
- /* See macro `TT_LOADER_SET_PP' below for explanations. */
+ /* See function `tt_loader_set_pp' below for explanations. */
/* */
FT_LOCAL_DEF( void )
TT_Get_VMetrics( TT_Face face,
@@ -121,7 +123,7 @@
FT_UInt glyph_index )
{
TT_Face face = loader->face;
-#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
+#ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY
TT_Driver driver = (TT_Driver)FT_FACE_DRIVER( face );
#endif
@@ -152,7 +154,7 @@
loader->top_bearing = top_bearing;
loader->vadvance = advance_height;
-#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
+#ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY
if ( driver->interpreter_version == TT_INTERPRETER_VERSION_38 &&
loader->exec )
{
@@ -161,10 +163,10 @@
/* 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_CONFIG_OPTION_SUBPIXEL_HINTING */
+#endif /* TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY */
if ( !loader->linear_def )
{
@@ -193,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 */
@@ -331,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;
@@ -397,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 */
@@ -426,7 +430,8 @@
load->glyph->control_len = n_ins;
load->glyph->control_data = load->exec->glyphIns;
- FT_MEM_COPY( load->exec->glyphIns, p, (FT_Long)n_ins );
+ if ( n_ins )
+ FT_MEM_COPY( load->exec->glyphIns, p, (FT_Long)n_ins );
}
#endif /* TT_USE_BYTECODE_INTERPRETER */
@@ -439,7 +444,7 @@
flag = (FT_Byte*)outline->tags;
flag_limit = flag + n_points;
- FT_ASSERT( flag != NULL );
+ FT_ASSERT( flag );
while ( flag < flag_limit )
{
@@ -659,6 +664,52 @@
} while ( subglyph->flags & MORE_COMPONENTS );
gloader->current.num_subglyphs = num_subglyphs;
+ FT_TRACE5(( " %d component%s\n",
+ num_subglyphs,
+ num_subglyphs > 1 ? "s" : "" ));
+
+#ifdef FT_DEBUG_LEVEL_TRACE
+ {
+ FT_UInt i;
+
+
+ subglyph = gloader->current.subglyphs;
+
+ for ( i = 0; i < num_subglyphs; i++ )
+ {
+ if ( num_subglyphs > 1 )
+ FT_TRACE7(( " subglyph %d:\n", i ));
+
+ FT_TRACE7(( " glyph index: %d\n", subglyph->index ));
+
+ if ( subglyph->flags & ARGS_ARE_XY_VALUES )
+ FT_TRACE7(( " offset: x=%d, y=%d\n",
+ subglyph->arg1,
+ subglyph->arg2 ));
+ else
+ FT_TRACE7(( " matching points: base=%d, component=%d\n",
+ subglyph->arg1,
+ subglyph->arg2 ));
+
+ if ( subglyph->flags & WE_HAVE_A_SCALE )
+ FT_TRACE7(( " scaling: %f\n",
+ subglyph->transform.xx / 65536.0 ));
+ else if ( subglyph->flags & WE_HAVE_AN_XY_SCALE )
+ FT_TRACE7(( " scaling: x=%f, y=%f\n",
+ subglyph->transform.xx / 65536.0,
+ subglyph->transform.yy / 65536.0 ));
+ else if ( subglyph->flags & WE_HAVE_A_2X2 )
+ FT_TRACE7(( " scaling: xx=%f, yx=%f\n"
+ " xy=%f, yy=%f\n",
+ subglyph->transform.xx / 65536.0,
+ subglyph->transform.yx / 65536.0,
+ subglyph->transform.xy / 65536.0,
+ subglyph->transform.yy / 65536.0 ));
+
+ subglyph++;
+ }
+ }
+#endif /* FT_DEBUG_LEVEL_TRACE */
#ifdef TT_USE_BYTECODE_INTERPRETER
@@ -730,7 +781,8 @@
TT_Hint_Glyph( TT_Loader loader,
FT_Bool is_composite )
{
-#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
+#if defined TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY || \
+ defined TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL
TT_Face face = loader->face;
TT_Driver driver = (TT_Driver)FT_FACE_DRIVER( face );
#endif
@@ -749,7 +801,7 @@
{
FT_TRACE1(( "TT_Hint_Glyph: too long instructions" ));
FT_TRACE1(( " (0x%lx byte) is truncated\n",
- loader->glyph->control_len ));
+ loader->glyph->control_len ));
}
n_ins = loader->glyph->control_len;
@@ -771,8 +823,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
@@ -813,13 +865,23 @@
#endif
- /* save glyph phantom points */
- loader->pp1 = zone->cur[zone->n_points - 4];
- loader->pp2 = zone->cur[zone->n_points - 3];
- loader->pp3 = zone->cur[zone->n_points - 2];
- loader->pp4 = zone->cur[zone->n_points - 1];
+#ifdef TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL
+ /* 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->backward_compatibility ) )
+ {
+#endif
+ loader->pp1 = zone->cur[zone->n_points - 4];
+ loader->pp2 = zone->cur[zone->n_points - 3];
+ loader->pp3 = zone->cur[zone->n_points - 2];
+ loader->pp4 = zone->cur[zone->n_points - 1];
+#ifdef TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL
+ }
+#endif
-#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
+#ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY
if ( driver->interpreter_version == TT_INTERPRETER_VERSION_38 )
{
if ( loader->exec->sph_tweak_flags & SPH_TWEAK_DEEMBOLDEN )
@@ -828,7 +890,7 @@
else if ( loader->exec->sph_tweak_flags & SPH_TWEAK_EMBOLDEN )
FT_Outline_EmboldenXY( &loader->gloader->current.outline, 24, 0 );
}
-#endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */
+#endif /* TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY */
return FT_Err_Ok;
}
@@ -872,13 +934,24 @@
#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
- if ( loader->face->doblend )
+ if ( FT_IS_NAMED_INSTANCE( FT_FACE( loader->face ) ) ||
+ FT_IS_VARIATION( FT_FACE( loader->face ) ) )
{
/* 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;
}
@@ -894,12 +967,12 @@
}
{
-#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
+#ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY
TT_Face face = loader->face;
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
@@ -913,7 +986,7 @@
FT_Bool do_scale = FALSE;
-#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
+#ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY
if ( driver->interpreter_version == TT_INTERPRETER_VERSION_38 )
{
@@ -928,9 +1001,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 */
@@ -944,14 +1017,14 @@
}
else
-#endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */
+#endif /* TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY */
{
/* 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;
}
@@ -964,9 +1037,24 @@
vec->x = FT_MulFix( vec->x, x_scale );
vec->y = FT_MulFix( vec->y, y_scale );
}
+ }
+#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
+ /* if we have a HVAR table, `pp1' and/or `pp2' are already adjusted */
+ if ( !( loader->face->variation_support & TT_FACE_FLAG_VAR_HADVANCE ) ||
+ !IS_HINTED( loader->load_flags ) )
+#endif
+ {
loader->pp1 = outline->points[n_points - 4];
loader->pp2 = outline->points[n_points - 3];
+ }
+
+#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
+ /* if we have a VVAR table, `pp3' and/or `pp4' are already adjusted */
+ if ( !( loader->face->variation_support & TT_FACE_FLAG_VAR_VADVANCE ) ||
+ !IS_HINTED( loader->load_flags ) )
+#endif
+ {
loader->pp3 = outline->points[n_points - 2];
loader->pp4 = outline->points[n_points - 1];
}
@@ -1075,7 +1163,7 @@
: -subglyph->transform.yx;
int c = subglyph->transform.xy > 0 ? subglyph->transform.xy
: -subglyph->transform.xy;
- int d = subglyph->transform.yy > 0 ? subglyph->transform.yy
+ int d = subglyph->transform.yy > 0 ? subglyph->transform.yy
: -subglyph->transform.yy;
int m = a > b ? a : b;
int n = c > d ? c : d;
@@ -1109,8 +1197,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 );
@@ -1118,8 +1206,28 @@
if ( subglyph->flags & ROUND_XY_TO_GRID )
{
- x = FT_PIX_ROUND( x );
- y = FT_PIX_ROUND( y );
+ TT_Face face = loader->face;
+ TT_Driver driver = (TT_Driver)FT_FACE_DRIVER( face );
+
+
+ if ( IS_HINTED( loader->load_flags ) )
+ {
+ /*
+ * We round the horizontal offset only if there is hinting along
+ * the x axis; this corresponds to integer advance width values.
+ *
+ * Theoretically, a glyph's bytecode can toggle ClearType's
+ * `backward compatibility' mode, which would allow modification
+ * of the advance width. In reality, however, applications
+ * neither allow nor expect modified advance widths if subpixel
+ * rendering is active.
+ *
+ */
+ if ( driver->interpreter_version == TT_INTERPRETER_VERSION_35 )
+ x = FT_PIX_ROUND( x );
+
+ y = FT_PIX_ROUND( y );
+ }
}
}
}
@@ -1321,49 +1429,72 @@
* (3) for everything else.
*
*/
+ static void
+ tt_loader_set_pp( TT_Loader loader )
+ {
+ FT_Bool subpixel_hinting = 0;
+ FT_Bool grayscale = 0;
+ FT_Bool use_aw_2 = 0;
+
#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
+ TT_Driver driver = (TT_Driver)FT_FACE_DRIVER( loader->face );
+#endif
+
+
+#ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY
+ if ( driver->interpreter_version == TT_INTERPRETER_VERSION_38 )
+ {
+ subpixel_hinting = loader->exec ? loader->exec->subpixel_hinting
+ : 0;
+ grayscale = loader->exec ? loader->exec->grayscale
+ : 0;
+ }
+#endif
+#ifdef TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL
+ if ( driver->interpreter_version == TT_INTERPRETER_VERSION_40 )
+ {
+ subpixel_hinting = loader->exec ? loader->exec->subpixel_hinting_lean
+ : 0;
+ grayscale = loader->exec ? loader->exec->grayscale_cleartype
+ : 0;
+ }
+#endif
+
+ use_aw_2 = (FT_Bool)( subpixel_hinting && grayscale );
+
+ loader->pp1.x = loader->bbox.xMin - loader->left_bearing;
+ loader->pp1.y = 0;
+ loader->pp2.x = loader->pp1.x + loader->advance;
+ loader->pp2.y = 0;
+
+ loader->pp3.x = use_aw_2 ? loader->advance / 2 : 0;
+ loader->pp3.y = loader->bbox.yMax + loader->top_bearing;
+ loader->pp4.x = use_aw_2 ? loader->advance / 2 : 0;
+ loader->pp4.y = loader->pp3.y - loader->vadvance;
+ }
+
+
+ /* 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 idx )
+ {
+ FT_ListNode cur;
+
-#define TT_LOADER_SET_PP( loader ) \
- do \
- { \
- FT_Bool subpixel_hinting_ = loader->exec \
- ? loader->exec->subpixel_hinting \
- : 0; \
- FT_Bool grayscale_ = loader->exec \
- ? loader->exec->grayscale \
- : 0; \
- FT_Bool use_aw_2_ = (FT_Bool)( subpixel_hinting_ && \
- grayscale_ ); \
- \
- \
- (loader)->pp1.x = (loader)->bbox.xMin - (loader)->left_bearing; \
- (loader)->pp1.y = 0; \
- (loader)->pp2.x = (loader)->pp1.x + (loader)->advance; \
- (loader)->pp2.y = 0; \
- \
- (loader)->pp3.x = use_aw_2_ ? (loader)->advance / 2 : 0; \
- (loader)->pp3.y = (loader)->bbox.yMax + (loader)->top_bearing; \
- (loader)->pp4.x = use_aw_2_ ? (loader)->advance / 2 : 0; \
- (loader)->pp4.y = (loader)->pp3.y - (loader)->vadvance; \
- } while ( 0 )
-
-#else /* !TT_CONFIG_OPTION_SUBPIXEL_HINTING */
-
-#define TT_LOADER_SET_PP( loader ) \
- do \
- { \
- (loader)->pp1.x = (loader)->bbox.xMin - (loader)->left_bearing; \
- (loader)->pp1.y = 0; \
- (loader)->pp2.x = (loader)->pp1.x + (loader)->advance; \
- (loader)->pp2.y = 0; \
- \
- (loader)->pp3.x = 0; \
- (loader)->pp3.y = (loader)->bbox.yMax + (loader)->top_bearing; \
- (loader)->pp4.x = 0; \
- (loader)->pp4.y = (loader)->pp3.y - (loader)->vadvance; \
- } while ( 0 )
-
-#endif /* !TT_CONFIG_OPTION_SUBPIXEL_HINTING */
+ if ( !list )
+ return NULL;
+
+ for ( cur = list->head; cur; cur = cur->next )
+ {
+ if ( !idx )
+ return cur;
+
+ idx--;
+ }
+
+ return NULL;
+ }
/*************************************************************************/
@@ -1395,13 +1526,17 @@
#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 )
+#ifdef FT_DEBUG_LEVEL_TRACE
+ if ( recurse_count )
+ FT_TRACE5(( " nesting level: %d\n", recurse_count ));
+#endif
+
+ /* 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
@@ -1417,8 +1552,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
{
@@ -1447,7 +1582,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 );
@@ -1465,10 +1600,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" ));
@@ -1477,7 +1612,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;
@@ -1516,7 +1651,7 @@
/* must initialize points before (possibly) overriding */
/* glyph metrics from the incremental interface */
- TT_LOADER_SET_PP( loader );
+ tt_loader_set_pp( loader );
#ifdef FT_CONFIG_OPTION_INCREMENTAL
tt_get_metrics_incr_overrides( loader, glyph_index );
@@ -1524,7 +1659,8 @@
#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
- if ( loader->face->doblend )
+ if ( FT_IS_NAMED_INSTANCE( FT_FACE( face ) ) ||
+ FT_IS_VARIATION( FT_FACE( face ) ) )
{
/* a small outline structure with four elements for */
/* communication with `TT_Vary_Apply_Glyph_Deltas' */
@@ -1567,6 +1703,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 */
@@ -1591,7 +1735,7 @@
/* must initialize phantom points before (possibly) overriding */
/* glyph metrics from the incremental interface */
- TT_LOADER_SET_PP( loader );
+ tt_loader_set_pp( loader );
#ifdef FT_CONFIG_OPTION_INCREMENTAL
tt_get_metrics_incr_overrides( loader, glyph_index );
@@ -1625,12 +1769,53 @@
/***********************************************************************/
/* otherwise, load a composite! */
- else if ( loader->n_contours == -1 )
+ else if ( loader->n_contours < 0 )
{
+ FT_Memory memory = face->root.memory;
+
FT_UInt start_point;
FT_UInt start_contour;
FT_ULong ins_pos; /* position of composite instructions, if any */
+ FT_ListNode node, node2;
+
+
+ /* normalize the `n_contours' value */
+ loader->n_contours = -1;
+
+ /*
+ * We store the glyph index directly in the `node->data' pointer,
+ * following the glib solution (cf. macro `GUINT_TO_POINTER') with a
+ * double cast to make this portable. Note, however, that this needs
+ * pointers with a width of at least 32 bits.
+ */
+
+
+ /* clear the nodes filled by sibling chains */
+ node = ft_list_get_node_at( &loader->composites, recurse_count );
+ for ( node2 = node; node2; node2 = node2->next )
+ node2->data = (void*)FT_ULONG_MAX;
+
+ /* check whether we already have a composite glyph with this index */
+ if ( FT_List_Find( &loader->composites,
+ FT_UINT_TO_POINTER( glyph_index ) ) )
+ {
+ FT_TRACE1(( "TT_Load_Composite_Glyph:"
+ " infinite recursion detected\n" ));
+ error = FT_THROW( Invalid_Composite );
+ goto Exit;
+ }
+
+ else if ( node )
+ node->data = FT_UINT_TO_POINTER( glyph_index );
+
+ else
+ {
+ if ( FT_NEW( node ) )
+ goto Exit;
+ node->data = FT_UINT_TO_POINTER( glyph_index );
+ FT_List_Add( &loader->composites, node );
+ }
start_point = (FT_UInt)gloader->base.outline.n_points;
start_contour = (FT_UInt)gloader->base.outline.n_contours;
@@ -1649,7 +1834,8 @@
#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
- if ( face->doblend )
+ if ( FT_IS_NAMED_INSTANCE( FT_FACE( face ) ) ||
+ FT_IS_VARIATION( FT_FACE( face ) ) )
{
short i, limit;
FT_SubGlyph subglyph;
@@ -1659,8 +1845,6 @@
char* tags = NULL;
short* contours = NULL;
- FT_Memory memory = face->root.memory;
-
limit = (short)gloader->current.num_subglyphs;
@@ -1669,6 +1853,10 @@
outline.n_points = (short)( gloader->current.num_subglyphs + 4 );
outline.n_contours = outline.n_points;
+ outline.points = NULL;
+ outline.tags = NULL;
+ outline.contours = NULL;
+
if ( FT_NEW_ARRAY( points, outline.n_points ) ||
FT_NEW_ARRAY( tags, outline.n_points ) ||
FT_NEW_ARRAY( contours, outline.n_points ) )
@@ -1716,22 +1904,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;
@@ -1744,6 +1932,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 );
@@ -1803,6 +1998,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 */
@@ -1815,6 +2013,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,
@@ -1834,6 +2035,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;
@@ -1874,12 +2078,6 @@
}
}
}
- else
- {
- /* invalid composite count (negative but not -1) */
- error = FT_THROW( Invalid_Outline );
- goto Exit;
- }
/***********************************************************************/
/***********************************************************************/
@@ -1908,7 +2106,8 @@
FT_UInt glyph_index )
{
TT_Face face = loader->face;
-#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
+#if defined TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY || \
+ defined TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL
TT_Driver driver = (TT_Driver)FT_FACE_DRIVER( face );
#endif
@@ -1920,7 +2119,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 );
@@ -1935,20 +2134,27 @@
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 */
- if ( !face->postscript.isFixedPitch &&
- IS_HINTED( loader->load_flags ) &&
- !( loader->load_flags & FT_LOAD_COMPUTE_METRICS ) )
+ /* 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->backward_compatibility ) ) &&
+#endif
+ !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_CONFIG_OPTION_SUBPIXEL_HINTING
+#ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY
if ( driver->interpreter_version == TT_INTERPRETER_VERSION_38 )
{
@@ -1966,7 +2172,7 @@
}
else
-#endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */
+#endif /* TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY */
{
if ( widthp )
@@ -1975,8 +2181,8 @@
}
/* set glyph dimensions */
- glyph->metrics.width = bbox.xMax - bbox.xMin;
- glyph->metrics.height = bbox.yMax - bbox.yMin;
+ glyph->metrics.width = SUB_LONG( bbox.xMax, bbox.xMin );
+ glyph->metrics.height = SUB_LONG( bbox.yMax, bbox.yMin );
/* Now take care of vertical metrics. In the case where there is */
/* no vertical information within the font (relatively common), */
@@ -2012,7 +2218,8 @@
/* table in the font. Otherwise, we use the */
/* values defined in the horizontal header. */
- height = (FT_Short)FT_DivFix( bbox.yMax - bbox.yMin,
+ height = (FT_Short)FT_DivFix( SUB_LONG( bbox.yMax,
+ bbox.yMin ),
y_scale );
if ( face->os2.version != 0xFFFFU )
advance = (FT_Pos)( face->os2.sTypoAscender -
@@ -2027,7 +2234,7 @@
#ifdef FT_CONFIG_OPTION_INCREMENTAL
{
FT_Incremental_InterfaceRec* incr;
- FT_Incremental_MetricsRec metrics;
+ FT_Incremental_MetricsRec incr_metrics;
FT_Error error;
@@ -2037,19 +2244,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;
}
}
@@ -2091,7 +2298,7 @@
SFNT_Service sfnt;
FT_Stream stream;
FT_Error error;
- TT_SBit_MetricsRec metrics;
+ TT_SBit_MetricsRec sbit_metrics;
face = (TT_Face)glyph->face;
@@ -2104,34 +2311,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;
}
}
@@ -2148,19 +2355,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 );
+#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
@@ -2168,11 +2379,13 @@
if ( IS_HINTED( load_flags ) && !glyf_table_only )
{
TT_ExecContext exec;
- FT_Bool grayscale;
-
-#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
- TT_Driver driver = (TT_Driver)FT_FACE_DRIVER( face );
+ FT_Bool grayscale = TRUE;
+#ifdef TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL
+ FT_Bool subpixel_hinting_lean;
+ FT_Bool grayscale_cleartype;
+#endif
+#ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY
FT_Bool subpixel_hinting = FALSE;
#if 0
@@ -2184,7 +2397,7 @@
FT_Bool subpixel_positioned;
FT_Bool gray_cleartype;
#endif
-#endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */
+#endif /* TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY */
FT_Bool reexecute = FALSE;
@@ -2205,7 +2418,32 @@
if ( !exec )
return FT_THROW( Could_Not_Find_Context );
-#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
+#ifdef TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL
+ if ( driver->interpreter_version == TT_INTERPRETER_VERSION_40 )
+ {
+ subpixel_hinting_lean =
+ FT_BOOL( FT_LOAD_TARGET_MODE( load_flags ) !=
+ FT_RENDER_MODE_MONO );
+ grayscale_cleartype =
+ FT_BOOL( subpixel_hinting_lean &&
+ !( ( load_flags &
+ FT_LOAD_TARGET_LCD ) ||
+ ( load_flags &
+ FT_LOAD_TARGET_LCD_V ) ) );
+ exec->vertical_lcd_lean =
+ FT_BOOL( subpixel_hinting_lean &&
+ ( load_flags &
+ FT_LOAD_TARGET_LCD_V ) );
+ }
+ else
+ {
+ subpixel_hinting_lean = FALSE;
+ grayscale_cleartype = FALSE;
+ exec->vertical_lcd_lean = FALSE;
+ }
+#endif
+
+#ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY
if ( driver->interpreter_version == TT_INTERPRETER_VERSION_38 )
{
@@ -2262,18 +2500,23 @@
}
else
-#endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */
+#endif /* TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY */
- {
+#ifdef TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL
+ if ( driver->interpreter_version == TT_INTERPRETER_VERSION_40 )
+ grayscale = FT_BOOL( !subpixel_hinting_lean &&
+ FT_LOAD_TARGET_MODE( load_flags ) !=
+ FT_RENDER_MODE_MONO );
+ else
+#endif
grayscale = FT_BOOL( FT_LOAD_TARGET_MODE( load_flags ) !=
- FT_RENDER_MODE_MONO );
- }
+ FT_RENDER_MODE_MONO );
error = TT_Load_Context( exec, face, size );
if ( error )
return error;
-#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
+#ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY
if ( driver->interpreter_version == TT_INTERPRETER_VERSION_38 )
{
@@ -2301,9 +2544,37 @@
}
else
-#endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */
+#endif /* TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY */
{
+
+#ifdef TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL
+ if ( driver->interpreter_version == TT_INTERPRETER_VERSION_40 )
+ {
+ /* a change from mono to subpixel rendering (and vice versa) */
+ /* requires a re-execution of the CVT program */
+ if ( subpixel_hinting_lean != exec->subpixel_hinting_lean )
+ {
+ FT_TRACE4(( "tt_loader_init: subpixel hinting change,"
+ " re-executing `prep' table\n" ));
+
+ exec->subpixel_hinting_lean = subpixel_hinting_lean;
+ reexecute = TRUE;
+ }
+
+ /* a change from colored to grayscale subpixel rendering (and */
+ /* vice versa) requires a re-execution of the CVT program */
+ if ( grayscale_cleartype != exec->grayscale_cleartype )
+ {
+ FT_TRACE4(( "tt_loader_init: grayscale subpixel hinting change,"
+ " re-executing `prep' table\n" ));
+
+ exec->grayscale_cleartype = grayscale_cleartype;
+ reexecute = TRUE;
+ }
+ }
+#endif
+
/* a change from mono to grayscale rendering (and vice versa) */
/* requires a re-execution of the CVT program */
if ( grayscale != exec->grayscale )
@@ -2336,10 +2607,11 @@
if ( exec->GS.instruct_control & 2 )
exec->GS = tt_default_graphics_state;
-#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
+#ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY
/* check whether we have a font hinted for ClearType -- */
/* note that this flag can also be modified in a glyph's bytecode */
- if ( exec->GS.instruct_control & 4 )
+ if ( driver->interpreter_version == TT_INTERPRETER_VERSION_38 &&
+ exec->GS.instruct_control & 4 )
exec->ignore_x_mode = 0;
#endif
@@ -2350,32 +2622,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 )
{
@@ -2393,10 +2639,23 @@
loader->glyph = (FT_GlyphSlot)glyph;
loader->stream = stream;
+ loader->composites.head = NULL;
+ loader->composites.tail = NULL;
+
return FT_Err_Ok;
}
+ static void
+ tt_loader_done( TT_Loader loader )
+ {
+ FT_List_Finalize( &loader->composites,
+ NULL,
+ loader->face->root.memory,
+ NULL );
+ }
+
+
/*************************************************************************/
/* */
/* <Function> */
@@ -2433,39 +2692,108 @@
FT_Error error;
TT_LoaderRec loader;
+#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
+#define IS_DEFAULT_INSTANCE ( !( FT_IS_NAMED_INSTANCE( glyph->face ) || \
+ FT_IS_VARIATION( glyph->face ) ) )
+#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 )
{
+ FT_Fixed x_scale = size->root.metrics.x_scale;
+ FT_Fixed y_scale = size->root.metrics.y_scale;
+
+
error = load_sbit_image( size, glyph, glyph_index, load_flags );
- if ( !error )
+ if ( FT_ERR_EQ( error, Missing_Bitmap ) )
+ {
+ /* the bitmap strike is incomplete and misses the requested glyph; */
+ /* if we have a bitmap-only font, return an empty glyph */
+ if ( !FT_IS_SCALABLE( glyph->face ) )
+ {
+ TT_Face face = (TT_Face)glyph->face;
+
+ FT_Short left_bearing = 0;
+ FT_Short top_bearing = 0;
+
+ FT_UShort advance_width = 0;
+ FT_UShort advance_height = 0;
+
+
+ /* to return an empty glyph, however, we need metrics data */
+ /* from the `hmtx' (or `vmtx') table; the assumption is that */
+ /* empty glyphs are missing intentionally, representing */
+ /* whitespace - not having at least horizontal metrics is */
+ /* thus considered an error */
+ if ( !face->horz_metrics_size )
+ return error;
+
+ /* we now construct an empty bitmap glyph */
+ TT_Get_HMetrics( face, glyph_index,
+ &left_bearing,
+ &advance_width );
+ TT_Get_VMetrics( face, glyph_index,
+ 0,
+ &top_bearing,
+ &advance_height );
+
+ glyph->outline.n_points = 0;
+ glyph->outline.n_contours = 0;
+
+ glyph->metrics.width = 0;
+ glyph->metrics.height = 0;
+
+ glyph->metrics.horiBearingX = FT_MulFix( left_bearing, x_scale );
+ glyph->metrics.horiBearingY = 0;
+ glyph->metrics.horiAdvance = FT_MulFix( advance_width, x_scale );
+
+ glyph->metrics.vertBearingX = 0;
+ glyph->metrics.vertBearingY = FT_MulFix( top_bearing, y_scale );
+ glyph->metrics.vertAdvance = FT_MulFix( advance_height, y_scale );
+
+ glyph->format = FT_GLYPH_FORMAT_BITMAP;
+ glyph->bitmap.pixel_mode = FT_PIXEL_MODE_MONO;
+
+ glyph->bitmap_left = 0;
+ glyph->bitmap_top = 0;
+
+ return FT_Err_Ok;
+ }
+ }
+ else if ( error )
+ {
+ /* return error if font is not scalable */
+ if ( !FT_IS_SCALABLE( glyph->face ) )
+ return error;
+ }
+ else
{
if ( FT_IS_SCALABLE( glyph->face ) )
{
/* for the bbox we need the header only */
(void)tt_loader_init( &loader, size, glyph, load_flags, TRUE );
(void)load_truetype_glyph( &loader, glyph_index, 0, TRUE );
+ tt_loader_done( &loader );
glyph->linearHoriAdvance = loader.linear;
glyph->linearVertAdvance = loader.vadvance;
/* sanity checks: if `xxxAdvance' in the sbit metric */
/* structure isn't set, use `linearXXXAdvance' */
if ( !glyph->metrics.horiAdvance && glyph->linearHoriAdvance )
- glyph->metrics.horiAdvance =
- FT_MulFix( glyph->linearHoriAdvance,
- size->root.metrics.x_scale );
+ glyph->metrics.horiAdvance = FT_MulFix( glyph->linearHoriAdvance,
+ x_scale );
if ( !glyph->metrics.vertAdvance && glyph->linearVertAdvance )
- glyph->metrics.vertAdvance =
- FT_MulFix( glyph->linearVertAdvance,
- size->root.metrics.y_scale );
+ glyph->metrics.vertAdvance = FT_MulFix( glyph->linearVertAdvance,
+ y_scale );
}
return FT_Err_Ok;
@@ -2476,14 +2804,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;
@@ -2548,14 +2882,23 @@
error = compute_glyph_metrics( &loader, glyph_index );
}
+ tt_loader_done( &loader );
+
/* Set the `high precision' bit flag. */
/* This is _critical_ to get correct output for monochrome */
/* 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/src/3rdparty/freetype/src/truetype/ttgload.h b/src/3rdparty/freetype/src/truetype/ttgload.h
index 8e3255e106..d237cfd284 100644
--- a/src/3rdparty/freetype/src/truetype/ttgload.h
+++ b/src/3rdparty/freetype/src/truetype/ttgload.h
@@ -4,7 +4,7 @@
/* */
/* TrueType Glyph Loader (specification). */
/* */
-/* Copyright 1996-2015 by */
+/* Copyright 1996-2018 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -16,8 +16,8 @@
/***************************************************************************/
-#ifndef __TTGLOAD_H__
-#define __TTGLOAD_H__
+#ifndef TTGLOAD_H_
+#define TTGLOAD_H_
#include <ft2build.h>
@@ -56,7 +56,7 @@ FT_BEGIN_HEADER
FT_END_HEADER
-#endif /* __TTGLOAD_H__ */
+#endif /* TTGLOAD_H_ */
/* END */
diff --git a/src/3rdparty/freetype/src/truetype/ttgxvar.c b/src/3rdparty/freetype/src/truetype/ttgxvar.c
index dd9e250c94..29ab2a4efd 100644
--- a/src/3rdparty/freetype/src/truetype/ttgxvar.c
+++ b/src/3rdparty/freetype/src/truetype/ttgxvar.c
@@ -4,7 +4,7 @@
/* */
/* TrueType GX Font Variation loader */
/* */
-/* Copyright 2004-2015 by */
+/* Copyright 2004-2018 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"
@@ -62,8 +60,11 @@
#define FT_Stream_FTell( stream ) \
(FT_ULong)( (stream)->cursor - (stream)->base )
-#define FT_Stream_SeekSet( stream, off ) \
- ( (stream)->cursor = (stream)->base + (off) )
+#define FT_Stream_SeekSet( stream, off ) \
+ (stream)->cursor = \
+ ( (off) < (FT_ULong)( (stream)->limit - (stream)->base ) ) \
+ ? (stream)->base + (off) \
+ : (stream)->limit
/*************************************************************************/
@@ -112,6 +113,8 @@
/* <Input> */
/* stream :: The data stream. */
/* */
+ /* size :: The size of the table holding the data. */
+ /* */
/* <Output> */
/* point_cnt :: The number of points read. A zero value means that */
/* all points in the glyph will be affected, without */
@@ -123,6 +126,7 @@
/* */
static FT_UShort*
ft_var_readpackedpoints( FT_Stream stream,
+ FT_ULong size,
FT_UInt *point_cnt )
{
FT_UShort *points = NULL;
@@ -149,48 +153,55 @@
n |= FT_GET_BYTE();
}
- if ( FT_NEW_ARRAY( points, n ) )
+ if ( n > size )
+ {
+ FT_TRACE1(( "ft_var_readpackedpoints: number of points too large\n" ));
+ return NULL;
+ }
+
+ /* 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;
}
@@ -212,6 +223,8 @@
/* <Input> */
/* stream :: The data stream. */
/* */
+ /* size :: The size of the table holding the data. */
+ /* */
/* delta_cnt :: The number of deltas to be read. */
/* */
/* <Return> */
@@ -222,6 +235,7 @@
/* */
static FT_Short*
ft_var_readpackeddeltas( FT_Stream stream,
+ FT_ULong size,
FT_UInt delta_cnt )
{
FT_Short *deltas = NULL;
@@ -233,6 +247,12 @@
FT_UNUSED( error );
+ if ( delta_cnt > size )
+ {
+ FT_TRACE1(( "ft_var_readpackeddeltas: number of points too large\n" ));
+ return NULL;
+ }
+
if ( FT_NEW_ARRAY( deltas, delta_cnt ) )
return NULL;
@@ -303,7 +323,7 @@
FT_TRACE2(( "AVAR " ));
- blend->avar_checked = TRUE;
+ blend->avar_loaded = TRUE;
error = face->goto_table( face, TTAG_avar, stream, &table_len );
if ( error )
{
@@ -327,7 +347,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;
}
@@ -341,7 +361,8 @@
FT_TRACE5(( " axis %d:\n", i ));
segment->pairCount = FT_GET_USHORT();
- if ( FT_NEW_ARRAY( segment->correspondence, segment->pairCount ) )
+ if ( (FT_ULong)segment->pairCount * 4 > table_len ||
+ FT_NEW_ARRAY( segment->correspondence, segment->pairCount ) )
{
/* Failure. Free everything we have done so far. We must do */
/* it right now since loading the `avar' table is optional. */
@@ -360,7 +381,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 ));
}
@@ -373,6 +394,999 @@
}
+ /* some macros we need */
+#define FT_FIXED_ONE ( (FT_Fixed)0x10000 )
+
+#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 ) )
+
+
+ static FT_Error
+ 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;
+
+ FT_Error error;
+ FT_UShort format;
+ FT_ULong region_offset;
+ FT_UInt i, j, k;
+ FT_UInt shortDeltaCount;
+
+ GX_Blend blend = face->blend;
+ GX_ItemVarData varData;
+
+ FT_ULong* dataOffsetArray = NULL;
+
+
+ if ( FT_STREAM_SEEK( offset ) ||
+ FT_READ_USHORT( format ) )
+ goto Exit;
+
+ if ( format != 1 )
+ {
+ FT_TRACE2(( "ft_var_load_item_variation_store: bad store format %d\n",
+ format ));
+ error = FT_THROW( Invalid_Table );
+ goto Exit;
+ }
+
+ /* read top level fields */
+ if ( FT_READ_ULONG( region_offset ) ||
+ FT_READ_USHORT( itemStore->dataCount ) )
+ goto Exit;
+
+ /* we need at least one entry in `itemStore->varData' */
+ if ( !itemStore->dataCount )
+ {
+ FT_TRACE2(( "ft_var_load_item_variation_store: missing varData\n" ));
+ error = FT_THROW( Invalid_Table );
+ goto Exit;
+ }
+
+ /* 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;
+
+ for ( i = 0; i < itemStore->dataCount; i++ )
+ {
+ if ( FT_READ_ULONG( dataOffsetArray[i] ) )
+ goto Exit;
+ }
+
+ /* 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_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;
+ }
+
+ if ( FT_NEW_ARRAY( itemStore->varRegionList, itemStore->regionCount ) )
+ goto Exit;
+
+ for ( i = 0; i < itemStore->regionCount; i++ )
+ {
+ GX_AxisCoords axisCoords;
+
+
+ if ( FT_NEW_ARRAY( itemStore->varRegionList[i].axisList,
+ itemStore->axisCount ) )
+ goto Exit;
+
+ axisCoords = itemStore->varRegionList[i].axisList;
+
+ 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 );
+ }
+ }
+
+ /* 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++ )
+ {
+ varData = &itemStore->varData[i];
+
+ if ( FT_STREAM_SEEK( offset + dataOffsetArray[i] ) )
+ goto Exit;
+
+ if ( FT_READ_USHORT( varData->itemCount ) ||
+ FT_READ_USHORT( shortDeltaCount ) ||
+ FT_READ_USHORT( varData->regionIdxCount ) )
+ goto 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 ( varData->regionIdxCount > itemStore->regionCount )
+ {
+ FT_TRACE2(( "inconsistent regionCount %d in varData[%d]\n",
+ varData->regionIdxCount,
+ i ));
+ error = FT_THROW( Invalid_Table );
+ goto Exit;
+ }
+
+ /* parse region indices */
+ if ( FT_NEW_ARRAY( varData->regionIndices,
+ varData->regionIdxCount ) )
+ goto Exit;
+
+ for ( j = 0; j < varData->regionIdxCount; j++ )
+ {
+ if ( FT_READ_USHORT( varData->regionIndices[j] ) )
+ goto Exit;
+
+ if ( varData->regionIndices[j] >= itemStore->regionCount )
+ {
+ FT_TRACE2(( "bad region index %d\n",
+ varData->regionIndices[j] ));
+ error = FT_THROW( Invalid_Table );
+ goto Exit;
+ }
+ }
+
+ /* 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;
+
+ /* 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;
+ }
+
+
+ static FT_Error
+ ft_var_load_delta_set_index_mapping( TT_Face face,
+ FT_ULong offset,
+ GX_DeltaSetIdxMap map,
+ GX_ItemVarStore itemStore )
+ {
+ FT_Stream stream = FT_FACE_STREAM( face );
+ FT_Memory memory = stream->memory;
+
+ FT_Error error;
+
+ 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_TRACE2(( "bad map format %d\n", format ));
+ error = FT_THROW( Invalid_Table );
+ goto Exit;
+ }
+
+ /* bytes per entry: 1, 2, 3, or 4 */
+ entrySize = ( ( format & 0x0030 ) >> 4 ) + 1;
+ innerBitCount = ( format & 0x000F ) + 1;
+ innerIndexMask = ( 1 << innerBitCount ) - 1;
+
+ 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_Byte data;
+
+
+ if ( FT_READ_BYTE( data ) )
+ goto Exit;
+
+ mapData = ( mapData << 8 ) | data;
+ }
+
+ outerIndex = mapData >> innerBitCount;
+
+ if ( outerIndex >= itemStore->dataCount )
+ {
+ FT_TRACE2(( "outerIndex[%d] == %d out of range\n",
+ i,
+ outerIndex ));
+ error = FT_THROW( Invalid_Table );
+ goto Exit;
+ }
+
+ map->outerIndex[i] = outerIndex;
+
+ innerIndex = mapData & innerIndexMask;
+
+ if ( innerIndex >= itemStore->varData[outerIndex].itemCount )
+ {
+ FT_TRACE2(( "innerIndex[%d] == %d out of range\n",
+ i,
+ innerIndex ));
+ error = FT_THROW( Invalid_Table );
+ goto Exit;
+ }
+
+ 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 unit%s (%s)\n",
+ vertical ? "vertical height" : "horizontal width",
+ *avalue,
+ delta,
+ delta == 1 ? "" : "s",
+ 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 unit%s) adjusted by %d unit%s (MVAR)\n",
+ (FT_Char)( value->tag >> 24 ),
+ (FT_Char)( value->tag >> 16 ),
+ (FT_Char)( value->tag >> 8 ),
+ (FT_Char)( value->tag ),
+ value->unmodified,
+ value->unmodified == 1 ? "" : "s",
+ delta,
+ delta == 1 ? "" : "s" ));
+
+ /* 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;
@@ -434,10 +1448,10 @@
FT_TRACE2(( "GVAR " ));
- 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_TRACE2(( "is missing\n" ));
goto Exit;
@@ -447,10 +1461,6 @@
if ( FT_STREAM_READ_FIELDS( gvar_fields, &gvar_head ) )
goto Exit;
- blend->tuplecount = gvar_head.globalCoordCount;
- blend->gv_glyphcnt = gvar_head.glyphCount;
- offsetToData = gvar_start + gvar_head.offsetToData;
-
if ( gvar_head.version != 0x00010000L )
{
FT_TRACE1(( "bad table version\n" ));
@@ -458,8 +1468,6 @@
goto Exit;
}
- FT_TRACE2(( "loaded\n" ));
-
if ( gvar_head.axisCount != (FT_UShort)blend->mmvar->num_axis )
{
FT_TRACE1(( "ft_var_load_gvar: number of axes in `gvar' and `cvar'\n"
@@ -468,8 +1476,36 @@
goto Exit;
}
- FT_TRACE5(( "gvar: there are %d shared coordinates:\n",
- blend->tuplecount ));
+ /* 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 %s %d shared coordinate%s:\n",
+ blend->tuplecount == 1 ? "is" : "are",
+ blend->tuplecount,
+ blend->tuplecount == 1 ? "" : "s" ));
if ( FT_NEW_ARRAY( blend->glyphoffsets, blend->gv_glyphcnt + 1 ) )
goto Exit;
@@ -511,11 +1547,11 @@
for ( i = 0; i < blend->tuplecount; i++ )
{
FT_TRACE5(( " [ " ));
- for ( j = 0 ; j < (FT_UInt)gvar_head.axisCount; j++ )
+ 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(( "%.4f ",
+ FT_TRACE5(( "%.5f ",
blend->tuplecoords[i * gvar_head.axisCount + j] / 65536.0 ));
}
FT_TRACE5(( "]\n" ));
@@ -571,8 +1607,13 @@
for ( i = 0; i < blend->num_axis; i++ )
{
- FT_TRACE6(( " axis coordinate %d (%.4f):\n",
+ 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. */
@@ -585,68 +1626,254 @@
continue;
}
- else if ( blend->normalizedcoords[i] == 0 )
+ if ( blend->normalizedcoords[i] == 0 )
{
FT_TRACE6(( " axis coordinate is zero, stop\n" ));
apply = 0;
break;
}
- else if ( ( blend->normalizedcoords[i] < 0 && tuple_coords[i] > 0 ) ||
- ( blend->normalizedcoords[i] > 0 && tuple_coords[i] < 0 ) )
+ if ( blend->normalizedcoords[i] == tuple_coords[i] )
{
- FT_TRACE6(( " tuple coordinate value %.4f is exceeded, stop\n",
+ FT_TRACE6(( " tuple coordinate value %.5f fits perfectly\n",
tuple_coords[i] / 65536.0 ));
- apply = 0;
- break;
+ /* `apply' does not change */
+ continue;
}
- else if ( !( tupleIndex & GX_TI_INTERMEDIATE_TUPLE ) )
+ if ( !( tupleIndex & GX_TI_INTERMEDIATE_TUPLE ) )
{
- FT_TRACE6(( " tuple coordinate value %.4f fits\n",
- tuple_coords[i] / 65536.0 ));
/* not an intermediate tuple */
- apply = FT_MulFix( apply,
- blend->normalizedcoords[i] > 0
- ? blend->normalizedcoords[i]
- : -blend->normalizedcoords[i] );
- }
- else if ( blend->normalizedcoords[i] < im_start_coords[i] ||
- blend->normalizedcoords[i] > im_end_coords[i] )
+ if ( blend->normalizedcoords[i] < FT_MIN( 0, tuple_coords[i] ) ||
+ blend->normalizedcoords[i] > FT_MAX( 0, tuple_coords[i] ) )
+ {
+ FT_TRACE6(( " tuple coordinate value %.5f is exceeded, stop\n",
+ tuple_coords[i] / 65536.0 ));
+ apply = 0;
+ break;
+ }
+
+ FT_TRACE6(( " tuple coordinate value %.5f fits\n",
+ tuple_coords[i] / 65536.0 ));
+ apply = FT_MulDiv( apply,
+ blend->normalizedcoords[i],
+ tuple_coords[i] );
+ }
+ else
{
- 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;
+ /* 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 ));
- else if ( blend->normalizedcoords[i] < tuple_coords[i] )
+ 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. */
+
+ a = mmvar->axis;
+ for ( i = 0; i < num_coords; i++, a++ )
+ {
+ FT_Fixed coord = coords[i];
+
+
+ FT_TRACE5(( " %d: %.5f\n", i, coord / 65536.0 ));
+ if ( coord > a->maximum || coord < a->minimum )
{
- 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] );
+ 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( coord - a->def,
+ a->minimum - a->def );
+ else if ( coord > a->def )
+ normalized[i] = FT_DivFix( coord - a->def,
+ a->maximum - a->def );
else
+ normalized[i] = 0;
+ }
+
+ FT_TRACE5(( "\n" ));
+
+ 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++ )
{
- 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] );
+ for ( j = 1; j < (FT_UInt)av->pairCount; j++ )
+ {
+ 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;
+ }
+ }
}
}
+ }
- FT_TRACE6(( " apply factor is %.4f\n", apply / 65536.0 ));
- return apply;
+ /* 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;
+ }
+
+ for ( i = 0; i < nc; i++ )
+ design[i] = coords[i];
+
+ 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++ )
+ {
+ 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;
+ }
+ }
+ }
+ }
+
+ mmvar = blend->mmvar;
+ a = mmvar->axis;
+
+ 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;
+ }
}
@@ -663,7 +1890,6 @@
{
FT_Long version;
FT_UShort offsetToData;
- FT_UShort countSizePairs;
FT_UShort axisCount;
FT_UShort axisSize;
FT_UShort instanceCount;
@@ -691,7 +1917,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. */
@@ -708,18 +1935,33 @@
TT_Get_MM_Var( TT_Face face,
FT_MM_Var* *master )
{
- FT_Stream stream = face->root.stream;
- FT_Memory memory = face->root.memory;
+ FT_Stream stream = face->root.stream;
+ FT_Memory memory = face->root.memory;
FT_ULong table_len;
- FT_Error error = FT_Err_Ok;
- FT_ULong fvar_start;
- FT_Int i, j;
+ FT_Error error = FT_Err_Ok;
+ FT_ULong fvar_start = 0;
+ 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 = 0;
+ FT_UInt num_instances;
+ FT_UInt num_axes;
+ FT_UShort* axis_flags;
+
+ FT_Offset mmvar_size;
+ FT_Offset axis_flags_size;
+ FT_Offset axis_size;
+ FT_Offset namedstyle_size;
+ FT_Offset next_coords_size;
+ FT_Offset next_name_size;
+
+ FT_Bool need_init;
static const FT_Frame_Field fvar_fields[] =
{
@@ -728,13 +1970,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
};
@@ -758,21 +2000,28 @@
/* read the font data and set up the internal representation */
/* if not already done */
- if ( face->blend == NULL )
+ need_init = !face->blend;
+
+ if ( need_init )
{
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;
@@ -780,45 +2029,67 @@
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" ));
- FT_TRACE5(( "number of GX style axes: %d\n", fvar_head.axisCount ));
+ FT_TRACE5(( "%d variation ax%s\n",
+ fvar_head.axisCount,
+ fvar_head.axisCount == 1 ? "is" : "es" ));
if ( FT_NEW( face->blend ) )
goto Exit;
- /* cannot overflow 32-bit arithmetic because of limits above */
- 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 ) +
- 5 * fvar_head.axisCount;
+ num_axes = fvar_head.axisCount;
+ face->blend->num_axis = num_axes;
+ }
+ else
+ num_axes = face->blend->num_axis;
+
+ /* `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 = (FT_UInt)face->root.style_flags >> 16;
+
+ /* prepare storage area for MM data; this cannot overflow */
+ /* 32-bit arithmetic because of the size limits used in the */
+ /* `fvar' table validity check in `sfnt_init_face' */
+
+ /* the various `*_size' variables, which we also use as */
+ /* offsets into the `mmlen' array, must be multiples of the */
+ /* pointer size (except the last one); without such an */
+ /* alignment there might be runtime errors due to */
+ /* misaligned addresses */
+#undef ALIGN_SIZE
+#define ALIGN_SIZE( n ) \
+ ( ( (n) + sizeof (void*) - 1 ) & ~( sizeof (void*) - 1 ) )
+
+ mmvar_size = ALIGN_SIZE( sizeof ( FT_MM_Var ) );
+ axis_flags_size = ALIGN_SIZE( num_axes *
+ sizeof ( FT_UShort ) );
+ axis_size = ALIGN_SIZE( num_axes *
+ sizeof ( FT_Var_Axis ) );
+ namedstyle_size = ALIGN_SIZE( num_instances *
+ sizeof ( FT_Var_Named_Style ) );
+ next_coords_size = ALIGN_SIZE( num_instances *
+ num_axes *
+ sizeof ( FT_Fixed ) );
+ next_name_size = num_axes * 5;
+
+ if ( need_init )
+ {
+ face->blend->mmvar_len = mmvar_size +
+ axis_flags_size +
+ axis_size +
+ namedstyle_size +
+ next_coords_size +
+ next_name_size;
if ( FT_ALLOC( mmvar, face->blend->mmvar_len ) )
goto Exit;
@@ -828,28 +2099,33 @@
/* the data gets filled in later on */
mmvar->num_axis =
- fvar_head.axisCount;
+ num_axes;
mmvar->num_designs =
~0U; /* meaningless in this context; each glyph */
/* may have a different number of designs */
/* (or tuples, as called by Apple) */
mmvar->num_namedstyles =
- fvar_head.instanceCount;
+ num_instances;
+
+ /* alas, no public field in `FT_Var_Axis' for axis flags */
+ axis_flags =
+ (FT_UShort*)( (char*)mmvar + mmvar_size );
mmvar->axis =
- (FT_Var_Axis*)&( mmvar[1] );
+ (FT_Var_Axis*)( (char*)axis_flags + axis_flags_size );
mmvar->namedstyle =
- (FT_Var_Named_Style*)&( mmvar->axis[fvar_head.axisCount] );
+ (FT_Var_Named_Style*)( (char*)mmvar->axis + axis_size );
- next_coords =
- (FT_Fixed*)&( mmvar->namedstyle[fvar_head.instanceCount] );
- for ( i = 0; i < fvar_head.instanceCount; i++ )
+ next_coords = (FT_Fixed*)( (char*)mmvar->namedstyle +
+ namedstyle_size );
+ for ( i = 0; i < num_instances; i++ )
{
mmvar->namedstyle[i].coords = next_coords;
- next_coords += fvar_head.axisCount;
+ next_coords += num_axes;
}
- next_name = (FT_String*)next_coords;
- for ( i = 0; i < fvar_head.axisCount; i++ )
+ next_name = (FT_String*)( (char*)mmvar->namedstyle +
+ namedstyle_size + next_coords_size );
+ for ( i = 0; i < num_axes; i++ )
{
mmvar->axis[i].name = next_name;
next_name += 5;
@@ -861,10 +2137,14 @@
goto Exit;
a = mmvar->axis;
- for ( i = 0; i < fvar_head.axisCount; i++ )
+ for ( i = 0; i < num_axes; i++ )
{
GX_FVar_Axis axis_rec;
+#ifdef FT_DEBUG_LEVEL_TRACE
+ int invalid = 0;
+#endif
+
if ( FT_STREAM_READ_FIELDS( fvaraxis_fields, &axis_rec ) )
goto Exit;
@@ -880,36 +2160,194 @@
a->name[3] = (FT_String)( ( a->tag ) & 0xFF );
a->name[4] = '\0';
- FT_TRACE5(( " \"%s\": minimum=%.4f, default=%.4f, maximum=%.4f\n",
+ *axis_flags = axis_rec.flags;
+
+ if ( a->minimum > a->def ||
+ a->def > a->maximum )
+ {
+ a->minimum = a->def;
+ a->maximum = a->def;
+
+#ifdef FT_DEBUG_LEVEL_TRACE
+ invalid = 1;
+#endif
+ }
+
+#ifdef FT_DEBUG_LEVEL_TRACE
+ if ( i == 0 )
+ FT_TRACE5(( " idx tag "
+ /* " XXX `XXXX'" */
+ " minimum default maximum flags\n" ));
+ /* " XXXX.XXXXX XXXX.XXXXX XXXX.XXXXX 0xXXXX" */
+
+ FT_TRACE5(( " %3d `%s'"
+ " %10.5f %10.5f %10.5f 0x%04X%s\n",
+ i,
a->name,
a->minimum / 65536.0,
a->def / 65536.0,
- a->maximum / 65536.0 ));
+ a->maximum / 65536.0,
+ *axis_flags,
+ invalid ? " (invalid, disabled)" : "" ));
+#endif
a++;
+ axis_flags++;
}
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,
+ num_axes * num_instances ) )
+ goto Exit;
+
+ if ( fvar_head.instanceCount && !face->blend->avar_loaded )
+ {
+ FT_ULong offset = FT_STREAM_POS();
+
+
+ ft_var_load_avar( face );
+
+ if ( FT_STREAM_SEEK( offset ) )
+ goto Exit;
+ }
+
+ FT_TRACE5(( "%d instance%s\n",
+ fvar_head.instanceCount,
+ fvar_head.instanceCount == 1 ? "" : "s" ));
+
+ 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 * num_axes ) )
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 < num_axes; j++, c++ )
+ *c = FT_GET_LONG();
+
+ /* valid psid values are 6, [256;32767], and 0xFFFF */
+ if ( usePsName )
+ ns->psid = FT_GET_USHORT();
+ else
+ ns->psid = 0xFFFF;
+
+#ifdef FT_DEBUG_LEVEL_TRACE
+ {
+ SFNT_Service sfnt = (SFNT_Service)face->sfnt;
+
+ FT_String* strname = NULL;
+ FT_String* psname = NULL;
+
+ FT_ULong pos;
+
+
+ pos = FT_STREAM_POS();
+
+ if ( ns->strid != 0xFFFF )
+ {
+ (void)sfnt->get_name( face,
+ (FT_UShort)ns->strid,
+ &strname );
+ if ( strname && !ft_strcmp( strname, ".notdef" ) )
+ strname = NULL;
+ }
+
+ if ( ns->psid != 0xFFFF )
+ {
+ (void)sfnt->get_name( face,
+ (FT_UShort)ns->psid,
+ &psname );
+ if ( psname && !ft_strcmp( psname, ".notdef" ) )
+ psname = NULL;
+ }
+
+ (void)FT_STREAM_SEEK( pos );
+
+ FT_TRACE5(( " instance %d (%s%s%s, %s%s%s)\n",
+ i,
+ strname ? "name: `" : "",
+ strname ? strname : "unnamed",
+ strname ? "'" : "",
+ psname ? "PS name: `" : "",
+ psname ? psname : "no PS name",
+ psname ? "'" : "" ));
+
+ FT_FREE( strname );
+ FT_FREE( psname );
+ }
+#endif /* FT_DEBUG_LEVEL_TRACE */
+
+ ft_var_to_normalized( face, num_axes, ns->coords, nsc );
+ nsc += num_axes;
FT_FRAME_EXIT();
}
+
+ if ( num_instances != fvar_head.instanceCount )
+ {
+ SFNT_Service sfnt = (SFNT_Service)face->sfnt;
+
+ FT_Int found, dummy1, dummy2;
+ FT_UInt strid = ~0U;
+
+
+ /* 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 < num_axes; 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;
@@ -918,22 +2356,25 @@
goto Exit;
FT_MEM_COPY( mmvar, face->blend->mmvar, face->blend->mmvar_len );
+ axis_flags =
+ (FT_UShort*)( (char*)mmvar + mmvar_size );
mmvar->axis =
- (FT_Var_Axis*)&( mmvar[1] );
+ (FT_Var_Axis*)( (char*)axis_flags + axis_flags_size );
mmvar->namedstyle =
- (FT_Var_Named_Style*)&( mmvar->axis[mmvar->num_axis] );
- next_coords =
- (FT_Fixed*)&( mmvar->namedstyle[mmvar->num_namedstyles] );
+ (FT_Var_Named_Style*)( (char*)mmvar->axis+ axis_size );
+ next_coords = (FT_Fixed*)( (char*)mmvar->namedstyle +
+ namedstyle_size );
for ( n = 0; n < mmvar->num_namedstyles; n++ )
{
mmvar->namedstyle[n].coords = next_coords;
- next_coords += mmvar->num_axis;
+ next_coords += num_axes;
}
a = mmvar->axis;
- next_name = (FT_String*)next_coords;
- for ( n = 0; n < mmvar->num_axis; n++ )
+ next_name = (FT_String*)( (char*)mmvar->namedstyle +
+ namedstyle_size + next_coords_size );
+ for ( n = 0; n < num_axes; n++ )
{
a->name = next_name;
@@ -959,40 +2400,19 @@
}
- /*************************************************************************/
- /* */
- /* <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_Bool all_design_coords = FALSE;
+
FT_Memory memory = face->root.memory;
enum
@@ -1006,9 +2426,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;
}
@@ -1017,19 +2437,21 @@
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;
}
- FT_TRACE5(( "normalized design coordinates:\n" ));
+ FT_TRACE5(( "TT_Set_MM_Blend:\n"
+ " normalized design coordinates:\n" ));
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 );
@@ -1039,11 +2461,20 @@
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->normalizedcoords == NULL )
+ if ( !blend->coords )
+ {
+ if ( FT_NEW_ARRAY( blend->coords, mmvar->num_axis ) )
+ goto Exit;
+
+ /* the first time we have to compute all design coordinates */
+ all_design_coords = TRUE;
+ }
+
+ if ( !blend->normalizedcoords )
{
if ( FT_NEW_ARRAY( blend->normalizedcoords, mmvar->num_axis ) )
goto Exit;
@@ -1056,6 +2487,12 @@
}
else
{
+ FT_Bool have_diff = 0;
+ FT_UInt j;
+ FT_Fixed* c;
+ FT_Fixed* n;
+
+
manageCvt = mcvt_retain;
for ( i = 0; i < num_coords; i++ )
@@ -1063,10 +2500,34 @@
if ( blend->normalizedcoords[i] != coords[i] )
{
manageCvt = mcvt_load;
+ have_diff = 1;
break;
}
}
+ if ( FT_IS_NAMED_INSTANCE( FT_FACE( face ) ) )
+ {
+ FT_UInt idx = (FT_UInt)face->root.face_index >> 16;
+
+
+ c = blend->normalizedcoords + i;
+ n = blend->normalized_stylecoords + idx * mmvar->num_axis + i;
+ for ( j = i; j < mmvar->num_axis; j++, n++, c++ )
+ if ( *c != *n )
+ have_diff = 1;
+ }
+ else
+ {
+ c = blend->normalizedcoords + i;
+ for ( j = i; j < mmvar->num_axis; j++, c++ )
+ if ( *c != 0 )
+ have_diff = 1;
+ }
+
+ /* return value -1 indicates `no change' */
+ if ( !have_diff )
+ return -1;
+
for ( ; i < mmvar->num_axis; i++ )
{
if ( blend->normalizedcoords[i] != 0 )
@@ -1087,9 +2548,15 @@
coords,
num_coords * sizeof ( FT_Fixed ) );
+ if ( set_design_coords )
+ ft_var_to_design( face,
+ all_design_coords ? blend->num_axis : num_coords,
+ blend->normalizedcoords,
+ blend->coords );
+
face->doblend = TRUE;
- if ( face->cvt != NULL )
+ if ( face->cvt )
{
switch ( manageCvt )
{
@@ -1114,6 +2581,10 @@
}
}
+ /* enforce recomputation of the PostScript name; */
+ FT_FREE( face->postscript_name );
+ face->postscript_name = NULL;
+
Exit:
return error;
}
@@ -1122,6 +2593,128 @@
/*************************************************************************/
/* */
/* <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 )
+ {
+ FT_Error error;
+
+
+ error = tt_set_mm_blend( face, num_coords, coords, 1 );
+ if ( error )
+ return error;
+
+ if ( num_coords )
+ face->root.face_flags |= FT_FACE_FLAG_VARIATION;
+ else
+ face->root.face_flags &= ~FT_FACE_FLAG_VARIATION;
+
+ return FT_Err_Ok;
+ }
+
+
+ /*************************************************************************/
+ /* */
+ /* <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;
+
+
+ if ( !face->blend )
+ {
+ if ( FT_SET_ERROR( TT_Get_MM_Var( face, NULL ) ) )
+ return error;
+ }
+
+ blend = face->blend;
+
+ if ( !blend->coords )
+ {
+ /* select default instance coordinates */
+ /* if no instance is selected yet */
+ if ( FT_SET_ERROR( tt_set_mm_blend( face, 0, NULL, 1 ) ) )
+ return error;
+ }
+
+ 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;
+ }
+
+ if ( face->doblend )
+ {
+ for ( i = 0; i < nc; i++ )
+ coords[i] = blend->normalizedcoords[i];
+ }
+ else
+ {
+ for ( i = 0; i < nc; i++ )
+ coords[i] = 0;
+ }
+
+ for ( ; i < num_coords; i++ )
+ coords[i] = 0;
+
+ return FT_Err_Ok;
+ }
+
+
+ /*************************************************************************/
+ /* */
+ /* <Function> */
/* TT_Set_Var_Design */
/* */
/* <Description> */
@@ -1149,19 +2742,22 @@
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_Fixed* c;
+ FT_Fixed* n;
+ FT_Fixed* normalized = NULL;
+
+ FT_Bool have_diff = 0;
- 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;
}
@@ -1176,75 +2772,81 @@
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 ( FT_NEW_ARRAY( normalized, mmvar->num_axis ) )
- goto Exit;
-
- FT_TRACE5(( "design coordinates:\n" ));
+ if ( !blend->coords )
+ {
+ if ( FT_NEW_ARRAY( blend->coords, mmvar->num_axis ) )
+ goto Exit;
+ }
- a = mmvar->axis;
- for ( i = 0; i < num_coords; i++, a++ )
+ c = blend->coords;
+ n = coords;
+ for ( i = 0; i < num_coords; i++, n++, c++ )
{
- FT_TRACE5(( " %.4f\n", coords[i] / 65536.0 ));
- if ( coords[i] > a->maximum || coords[i] < a->minimum )
+ if ( *c != *n )
{
- 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;
+ *c = *n;
+ have_diff = 1;
}
-
- 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 );
}
- FT_TRACE5(( "\n" ));
+ if ( FT_IS_NAMED_INSTANCE( FT_FACE( face ) ) )
+ {
+ FT_UInt instance_index;
+ FT_Var_Named_Style* named_style;
- for ( ; i < mmvar->num_axis; i++ )
- normalized[i] = 0;
- if ( !blend->avar_checked )
- ft_var_load_avar( face );
+ instance_index = (FT_UInt)face->root.face_index >> 16;
+ named_style = mmvar->namedstyle + instance_index - 1;
- if ( blend->avar_segment != NULL )
+ n = named_style->coords + num_coords;
+ for ( ; i < mmvar->num_axis; i++, n++, c++ )
+ {
+ if ( *c != *n )
+ {
+ *c = *n;
+ have_diff = 1;
+ }
+ }
+ }
+ else
{
- FT_TRACE5(( "normalized design coordinates"
- " before applying `avar' data:\n" ));
+ FT_Var_Axis* a;
- av = blend->avar_segment;
- for ( i = 0; i < mmvar->num_axis; i++, av++ )
+
+ a = mmvar->axis + num_coords;
+ for ( ; i < mmvar->num_axis; i++, a++, c++ )
{
- for ( j = 1; j < (FT_UInt)av->pairCount; j++ )
+ if ( *c != a->def )
{
- 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;
- }
+ *c = a->def;
+ have_diff = 1;
}
}
}
- error = TT_Set_MM_Blend( face, mmvar->num_axis, normalized );
+ /* return value -1 indicates `no change'; */
+ /* we can exit early if `normalizedcoords' is already computed */
+ if ( blend->normalizedcoords && !have_diff )
+ return -1;
+
+ if ( FT_NEW_ARRAY( normalized, mmvar->num_axis ) )
+ goto Exit;
+
+ if ( !face->blend->avar_loaded )
+ ft_var_load_avar( face );
+
+ FT_TRACE5(( "TT_Set_Var_Design:\n"
+ " normalized design coordinates:\n" ));
+ ft_var_to_normalized( face, num_coords, blend->coords, normalized );
+
+ error = tt_set_mm_blend( face, mmvar->num_axis, normalized, 0 );
+ if ( error )
+ goto Exit;
+
+ if ( num_coords )
+ face->root.face_flags |= FT_FACE_FLAG_VARIATION;
+ else
+ face->root.face_flags &= ~FT_FACE_FLAG_VARIATION;
Exit:
FT_FREE( normalized );
@@ -1253,6 +2855,165 @@
/*************************************************************************/
+ /* */
+ /* <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 ( !face->blend )
+ {
+ if ( FT_SET_ERROR( TT_Get_MM_Var( face, NULL ) ) )
+ return error;
+ }
+
+ blend = face->blend;
+
+ if ( !blend->coords )
+ {
+ /* select default instance coordinates */
+ /* if no instance is selected yet */
+ if ( FT_SET_ERROR( tt_set_mm_blend( face, 0, NULL, 1 ) ) )
+ return error;
+ }
+
+ 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;
+ }
+
+ for ( ; i < num_coords; i++ )
+ coords[i] = 0;
+
+ return FT_Err_Ok;
+ }
+
+
+ /*************************************************************************/
+ /* */
+ /* <Function> */
+ /* TT_Set_Named_Instance */
+ /* */
+ /* <Description> */
+ /* Set the given named instance, also resetting any further */
+ /* variation. */
+ /* */
+ /* <Input> */
+ /* face :: A handle to the source face. */
+ /* */
+ /* instance_index :: The instance index, starting with value 1. */
+ /* Value 0 indicates to not use an instance. */
+ /* */
+ /* <Return> */
+ /* FreeType error code. 0~means success. */
+ /* */
+ FT_LOCAL_DEF( FT_Error )
+ TT_Set_Named_Instance( TT_Face face,
+ FT_UInt instance_index )
+ {
+ FT_Error error = FT_ERR( Invalid_Argument );
+ GX_Blend blend;
+ FT_MM_Var* mmvar;
+
+ FT_UInt num_instances;
+
+
+ if ( !face->blend )
+ {
+ if ( FT_SET_ERROR( TT_Get_MM_Var( face, NULL ) ) )
+ goto Exit;
+ }
+
+ blend = face->blend;
+ mmvar = blend->mmvar;
+
+ num_instances = (FT_UInt)face->root.style_flags >> 16;
+
+ /* `instance_index' starts with value 1, thus `>' */
+ if ( instance_index > num_instances )
+ goto Exit;
+
+ if ( instance_index > 0 && mmvar->namedstyle )
+ {
+ FT_Memory memory = face->root.memory;
+ SFNT_Service sfnt = (SFNT_Service)face->sfnt;
+
+ FT_Var_Named_Style* named_style;
+ FT_String* style_name;
+
+
+ named_style = mmvar->namedstyle + instance_index - 1;
+
+ error = sfnt->get_name( face,
+ (FT_UShort)named_style->strid,
+ &style_name );
+ if ( error )
+ goto Exit;
+
+ /* set (or replace) style name */
+ FT_FREE( face->root.style_name );
+ face->root.style_name = style_name;
+
+ /* finally, select the named instance */
+ error = TT_Set_Var_Design( face,
+ mmvar->num_axis,
+ named_style->coords );
+ if ( error )
+ goto Exit;
+ }
+ else
+ error = TT_Set_Var_Design( face, 0, NULL );
+
+ face->root.face_index = ( instance_index << 16 ) |
+ ( face->root.face_index & 0xFFFFL );
+ face->root.face_flags &= ~FT_FACE_FLAG_VARIATION;
+
+ Exit:
+ return error;
+ }
+
+
+ /*************************************************************************/
/*************************************************************************/
/***** *****/
/***** GX VAR PARSING ROUTINES *****/
@@ -1298,14 +3059,16 @@
FT_Fixed* im_start_coords = NULL;
FT_Fixed* im_end_coords = NULL;
GX_Blend blend = face->blend;
- FT_UInt point_count;
- FT_UShort* localpoints;
+ FT_UInt point_count, spoint_count = 0;
+ FT_UShort* sharedpoints = NULL;
+ FT_UShort* localpoints = NULL;
+ FT_UShort* points;
FT_Short* deltas;
FT_TRACE2(( "CVAR " ));
- if ( blend == NULL )
+ if ( !blend )
{
FT_TRACE2(( "\n"
"tt_face_vary_cvt: no blend specified\n" ));
@@ -1313,7 +3076,7 @@
goto Exit;
}
- if ( face->cvt == NULL )
+ if ( !face->cvt )
{
FT_TRACE2(( "\n"
"tt_face_vary_cvt: no `cvt ' table\n" ));
@@ -1353,13 +3116,39 @@
goto FExit;
tupleCount = FT_GET_USHORT();
- offsetToData = table_start + FT_GET_USHORT();
+ offsetToData = FT_GET_USHORT();
+
+ /* rough sanity test */
+ if ( offsetToData + ( tupleCount & GX_TC_TUPLE_COUNT_MASK ) * 4 >
+ table_len )
+ {
+ FT_TRACE2(( "tt_face_vary_cvt:"
+ " invalid CVT variation array header\n" ));
+
+ error = FT_THROW( Invalid_Table );
+ goto FExit;
+ }
- /* The documentation implies there are flags packed into the */
- /* tuplecount, but John Jenkins says that shared points don't apply */
- /* to `cvar', and no other flags are defined. */
+ offsetToData += table_start;
+
+ if ( tupleCount & GX_TC_TUPLES_SHARE_POINT_NUMBERS )
+ {
+ here = FT_Stream_FTell( stream );
+
+ FT_Stream_SeekSet( stream, offsetToData );
+
+ sharedpoints = ft_var_readpackedpoints( stream,
+ table_len,
+ &spoint_count );
+ offsetToData = FT_Stream_FTell( stream );
+
+ FT_Stream_SeekSet( stream, here );
+ }
- FT_TRACE5(( "cvar: there are %d tuples:\n", tupleCount ));
+ FT_TRACE5(( "cvar: there %s %d tuple%s:\n",
+ ( tupleCount & 0xFFF ) == 1 ? "is" : "are",
+ tupleCount & 0xFFF,
+ ( tupleCount & 0xFFF ) == 1 ? "" : "s" ));
for ( i = 0; i < ( tupleCount & 0xFFF ); i++ )
{
@@ -1373,26 +3162,25 @@
tupleDataSize = FT_GET_USHORT();
tupleIndex = FT_GET_USHORT();
- /* There is no provision here for a global tuple coordinate section, */
- /* so John says. There are no tuple indices, just embedded tuples. */
-
if ( tupleIndex & GX_TI_EMBEDDED_TUPLE_COORD )
{
for ( j = 0; j < blend->num_axis; j++ )
tuple_coords[j] = FT_GET_SHORT() * 4; /* convert from */
/* short frac to fixed */
}
- else
+ else if ( ( tupleIndex & GX_TI_TUPLE_INDEX_MASK ) >= blend->tuplecount )
{
- /* skip this tuple; it makes no sense */
+ FT_TRACE2(( "tt_face_vary_cvt:"
+ " invalid tuple index\n" ));
- if ( tupleIndex & GX_TI_INTERMEDIATE_TUPLE )
- for ( j = 0; j < 2 * blend->num_axis; j++ )
- (void)FT_GET_SHORT();
-
- offsetToData += tupleDataSize;
- continue;
+ error = FT_THROW( Invalid_Table );
+ goto Exit;
}
+ else
+ FT_MEM_COPY(
+ tuple_coords,
+ &blend->tuplecoords[( tupleIndex & 0xFFF ) * blend->num_axis],
+ blend->num_axis * sizeof ( FT_Fixed ) );
if ( tupleIndex & GX_TI_INTERMEDIATE_TUPLE )
{
@@ -1407,11 +3195,8 @@
tuple_coords,
im_start_coords,
im_end_coords );
- if ( /* tuple isn't active for our blend */
- apply == 0 ||
- /* global points not allowed, */
- /* if they aren't local, makes no sense */
- !( tupleIndex & GX_TI_PRIVATE_POINT_NUMBERS ) )
+
+ if ( apply == 0 ) /* tuple isn't active for our blend */
{
offsetToData += tupleDataSize;
continue;
@@ -1421,11 +3206,27 @@
FT_Stream_SeekSet( stream, offsetToData );
- localpoints = ft_var_readpackedpoints( stream, &point_count );
- deltas = ft_var_readpackeddeltas( stream,
- point_count == 0 ? face->cvt_size
- : point_count );
- if ( localpoints == NULL || deltas == NULL )
+ if ( tupleIndex & GX_TI_PRIVATE_POINT_NUMBERS )
+ {
+ localpoints = ft_var_readpackedpoints( stream,
+ table_len,
+ &point_count );
+ points = localpoints;
+ }
+ else
+ {
+ points = sharedpoints;
+ point_count = spoint_count;
+ }
+
+ deltas = ft_var_readpackeddeltas( stream,
+ table_len,
+ point_count == 0 ? face->cvt_size
+ : point_count );
+
+ if ( !points ||
+ !deltas ||
+ ( localpoints == ALL_POINTS && point_count != face->cvt_size ) )
; /* failure, ignore it */
else if ( localpoints == ALL_POINTS )
@@ -1473,10 +3274,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 = points[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 ) );
@@ -1511,6 +3317,8 @@
FT_FRAME_EXIT();
Exit:
+ if ( sharedpoints != ALL_POINTS )
+ FT_FREE( sharedpoints );
FT_FREE( tuple_coords );
FT_FREE( im_start_coords );
FT_FREE( im_end_coords );
@@ -1599,25 +3407,12 @@
d1 = out1 - in1;
d2 = out2 - in2;
- if ( out1 == out2 || in1 == in2 )
+ /* If the reference points have the same coordinate but different */
+ /* delta, inferred delta is zero. Otherwise interpolate. */
+ if ( in1 != in2 || out1 == out2 )
{
- 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
- {
- 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++ )
@@ -1644,12 +3439,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;
@@ -1664,8 +3458,6 @@
if ( !outline->n_contours )
return;
- out_points = outline->points;
-
contour = 0;
point = 0;
@@ -1769,6 +3561,7 @@
GX_Blend blend = face->blend;
FT_Vector* points_org = NULL;
+ FT_Vector* points_out = NULL;
FT_Bool* has_delta = NULL;
FT_Error error;
@@ -1787,7 +3580,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 ||
@@ -1800,6 +3593,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;
@@ -1811,7 +3605,6 @@
glyph_start = FT_Stream_FTell( stream );
/* each set of glyph variation data is formatted similarly to `cvar' */
- /* (except we get shared points and global tuples) */
if ( FT_NEW_ARRAY( tuple_coords, blend->num_axis ) ||
FT_NEW_ARRAY( im_start_coords, blend->num_axis ) ||
@@ -1819,7 +3612,20 @@
goto Fail2;
tupleCount = FT_GET_USHORT();
- offsetToData = glyph_start + FT_GET_USHORT();
+ offsetToData = FT_GET_USHORT();
+
+ /* rough sanity test */
+ 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" ));
+
+ error = FT_THROW( Invalid_Table );
+ goto Fail2;
+ }
+
+ offsetToData += glyph_start;
if ( tupleCount & GX_TC_TUPLES_SHARE_POINT_NUMBERS )
{
@@ -1827,13 +3633,21 @@
FT_Stream_SeekSet( stream, offsetToData );
- sharedpoints = ft_var_readpackedpoints( stream, &spoint_count );
+ sharedpoints = ft_var_readpackedpoints( stream,
+ blend->gvar_size,
+ &spoint_count );
offsetToData = FT_Stream_FTell( stream );
FT_Stream_SeekSet( stream, here );
}
- FT_TRACE5(( "gvar: there are %d tuples:\n", tupleCount ));
+ FT_TRACE5(( "gvar: there %s %d tuple%s:\n",
+ ( tupleCount & GX_TC_TUPLE_COUNT_MASK ) == 1 ? "is" : "are",
+ tupleCount & GX_TC_TUPLE_COUNT_MASK,
+ ( tupleCount & GX_TC_TUPLE_COUNT_MASK ) == 1 ? "" : "s" ));
+
+ for ( j = 0; j < n_points; j++ )
+ points_org[j] = outline->points[j];
for ( i = 0; i < ( tupleCount & GX_TC_TUPLE_COUNT_MASK ); i++ )
{
@@ -1855,6 +3669,9 @@
}
else if ( ( tupleIndex & GX_TI_TUPLE_INDEX_MASK ) >= blend->tuplecount )
{
+ FT_TRACE2(( "TT_Vary_Apply_Glyph_Deltas:"
+ " invalid tuple index\n" ));
+
error = FT_THROW( Invalid_Table );
goto Fail2;
}
@@ -1886,11 +3703,13 @@
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, &point_count );
+ localpoints = ft_var_readpackedpoints( stream,
+ blend->gvar_size,
+ &point_count );
points = localpoints;
}
else
@@ -1900,13 +3719,15 @@
}
deltas_x = ft_var_readpackeddeltas( stream,
+ blend->gvar_size,
point_count == 0 ? n_points
: point_count );
deltas_y = ft_var_readpackeddeltas( stream,
+ blend->gvar_size,
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 )
@@ -1921,22 +3742,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 - 4 )
+ {
+ 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 - 4 ) &&
+ !( face->variation_support &
+ TT_FACE_FLAG_VAR_LSB ) )
+ outline->points[j].x += delta_x;
+
+ else 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_TSB ) )
+ outline->points[j].y += delta_y;
+
+ else if ( j == ( n_points - 1 ) &&
+ !( face->variation_support &
+ TT_FACE_FLAG_VAR_VADVANCE ) )
+ 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++;
@@ -1961,13 +3808,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 )
@@ -1975,34 +3822,71 @@
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;
+
+
+ if ( j < n_points - 4 )
+ {
+ 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 - 4 ) &&
+ !( face->variation_support &
+ TT_FACE_FLAG_VAR_LSB ) )
+ outline->points[j].x += delta_x;
+
+ else 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_TSB ) )
+ outline->points[j].y += delta_y;
+
+ else if ( j == ( n_points - 1 ) &&
+ !( face->variation_support &
+ TT_FACE_FLAG_VAR_VADVANCE ) )
+ 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
@@ -2021,6 +3905,8 @@
FT_TRACE5(( "\n" ));
Fail2:
+ if ( sharedpoints != ALL_POINTS )
+ FT_FREE( sharedpoints );
FT_FREE( tuple_coords );
FT_FREE( im_start_coords );
FT_FREE( im_end_coords );
@@ -2029,6 +3915,7 @@
Fail1:
FT_FREE( points_org );
+ FT_FREE( points_out );
FT_FREE( has_delta );
return error;
@@ -2038,37 +3925,150 @@
/*************************************************************************/
/* */
/* <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> */
/* tt_done_blend */
/* */
/* <Description> */
/* 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/src/3rdparty/freetype/src/truetype/ttgxvar.h b/src/3rdparty/freetype/src/truetype/ttgxvar.h
index 060d4d60ea..a37bb90266 100644
--- a/src/3rdparty/freetype/src/truetype/ttgxvar.h
+++ b/src/3rdparty/freetype/src/truetype/ttgxvar.h
@@ -4,7 +4,7 @@
/* */
/* TrueType GX Font Variation loader (specification) */
/* */
-/* Copyright 2004-2015 by */
+/* Copyright 2004-2018 by */
/* David Turner, Robert Wilhelm, Werner Lemberg and George Williams. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -16,8 +16,8 @@
/***************************************************************************/
-#ifndef __TTGXVAR_H__
-#define __TTGXVAR_H__
+#ifndef TTGXVAR_H_
+#define TTGXVAR_H_
#include <ft2build.h>
@@ -27,6 +27,8 @@
FT_BEGIN_HEADER
+#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
+
/*************************************************************************/
/* */
/* <Struct> */
@@ -61,6 +63,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 +216,122 @@ 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. */
/* */
- /* normalizedcoords :: A normalized value (between [-1,1]) indicating */
- /* the contribution along each axis to the final */
- /* interpolated font. */
+ /* 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. */
+ /* */
+ /* 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_UInt tuplecount; /* shared tuples in `gvar' */
- FT_Fixed* tuplecoords; /* tuplecoords[tuplecount][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;
+
+ 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;
} GX_BlendRec;
@@ -147,6 +385,11 @@ FT_BEGIN_HEADER
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,
FT_Fixed* coords );
@@ -155,6 +398,14 @@ 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_Set_Named_Instance( TT_Face face,
+ FT_UInt instance_index );
FT_LOCAL( FT_Error )
tt_face_vary_cvt( TT_Face face,
@@ -167,16 +418,36 @@ 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 );
+
+#endif /* TT_CONFIG_OPTION_GX_VAR_SUPPORT */
FT_END_HEADER
-#endif /* __TTGXVAR_H__ */
+#endif /* TTGXVAR_H_ */
/* END */
diff --git a/src/3rdparty/freetype/src/truetype/ttinterp.c b/src/3rdparty/freetype/src/truetype/ttinterp.c
index ae2a82adc5..da9b595aba 100644
--- a/src/3rdparty/freetype/src/truetype/ttinterp.c
+++ b/src/3rdparty/freetype/src/truetype/ttinterp.c
@@ -4,7 +4,7 @@
/* */
/* TrueType bytecode interpreter (body). */
/* */
-/* Copyright 1996-2015 by */
+/* Copyright 1996-2018 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -25,11 +25,15 @@
#include FT_INTERNAL_CALC_H
#include FT_TRIGONOMETRY_H
#include FT_SYSTEM_H
-#include FT_TRUETYPE_DRIVER_H
+#include FT_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
@@ -45,25 +49,31 @@
#define FT_COMPONENT trace_ttinterp
- /*************************************************************************/
- /* */
- /* In order to detect infinite loops in the code, we set up a counter */
- /* within the run loop. A single stroke of interpretation is now */
- /* limited to a maximum number of opcodes defined below. */
- /* */
-#define MAX_RUNNABLE_OPCODES 1000000L
-
+#define NO_SUBPIXEL_HINTING \
+ ( ((TT_Driver)FT_FACE_DRIVER( exc->face ))->interpreter_version == \
+ TT_INTERPRETER_VERSION_35 )
-#define SUBPIXEL_HINTING \
+#ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY
+#define SUBPIXEL_HINTING_INFINALITY \
( ((TT_Driver)FT_FACE_DRIVER( exc->face ))->interpreter_version == \
TT_INTERPRETER_VERSION_38 )
+#endif
+#ifdef TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL
+#define SUBPIXEL_HINTING_MINIMAL \
+ ( ((TT_Driver)FT_FACE_DRIVER( exc->face ))->interpreter_version == \
+ TT_INTERPRETER_VERSION_40 )
+#endif
-#define PROJECT( v1, v2 ) \
- exc->func_project( exc, (v1)->x - (v2)->x, (v1)->y - (v2)->y )
+#define PROJECT( v1, v2 ) \
+ exc->func_project( exc, \
+ SUB_LONG( (v1)->x, (v2)->x ), \
+ SUB_LONG( (v1)->y, (v2)->y ) )
-#define DUALPROJ( v1, v2 ) \
- exc->func_dualproj( exc, (v1)->x - (v2)->x, (v1)->y - (v2)->y )
+#define DUALPROJ( v1, v2 ) \
+ exc->func_dualproj( exc, \
+ SUB_LONG( (v1)->x, (v2)->x ), \
+ SUB_LONG( (v1)->y, (v2)->y ) )
#define FAST_PROJECT( v ) \
exc->func_project( exc, (v)->x, (v)->y )
@@ -74,14 +84,6 @@
/*************************************************************************/
/* */
- /* Instruction dispatch function, as used by the interpreter. */
- /* */
- typedef void (*TInstruction_Function)( TT_ExecContext exc,
- FT_Long* args );
-
-
- /*************************************************************************/
- /* */
/* Two simple bounds-checking macros. */
/* */
#define BOUNDS( x, n ) ( (FT_UInt)(x) >= (FT_UInt)(n) )
@@ -94,20 +96,6 @@
#undef FAILURE
#define FAILURE 1
-#ifdef TT_CONFIG_OPTION_UNPATENTED_HINTING
-#define GUESS_VECTOR( V ) \
- do \
- { \
- if ( exc->face->unpatented_hinting ) \
- { \
- exc->GS.V.x = (FT_F2Dot14)( exc->GS.both_x_axis ? 0x4000 : 0 ); \
- exc->GS.V.y = (FT_F2Dot14)( exc->GS.both_x_axis ? 0 : 0x4000 ); \
- } \
- } while (0)
-#else
-#define GUESS_VECTOR( V ) do { } while (0)
-#endif
-
/*************************************************************************/
/* */
@@ -145,7 +133,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 */
@@ -309,8 +297,8 @@
exec->stackSize = 0;
exec->glyphSize = 0;
- exec->stack = NULL;
- exec->glyphIns = NULL;
+ exec->stack = NULL;
+ exec->glyphIns = NULL;
exec->face = NULL;
exec->size = NULL;
@@ -416,8 +404,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;
@@ -438,7 +427,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;
}
@@ -556,10 +545,6 @@
exec->GS.freeVector = exec->GS.projVector;
exec->GS.dualVector = exec->GS.projVector;
-#ifdef TT_CONFIG_OPTION_UNPATENTED_HINTING
- exec->GS.both_x_axis = TRUE;
-#endif
-
exec->GS.round_state = 1;
exec->GS.loop = 1;
@@ -586,10 +571,6 @@
{ 0x4000, 0 },
{ 0x4000, 0 },
-#ifdef TT_CONFIG_OPTION_UNPATENTED_HINTING
- TRUE,
-#endif
-
1, 64, 1,
TRUE, 68, 0, 0, 9, 3,
0, FALSE, 0, 1, 1, 1
@@ -709,17 +690,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 ),
@@ -792,7 +773,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 ),
@@ -810,8 +791,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 ),
@@ -1093,8 +1074,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",
@@ -1479,34 +1465,22 @@
{
if ( !exc->tt_metrics.ratio )
{
-#ifdef TT_CONFIG_OPTION_UNPATENTED_HINTING
- if ( exc->face->unpatented_hinting )
- {
- if ( exc->GS.both_x_axis )
- exc->tt_metrics.ratio = exc->tt_metrics.x_ratio;
- else
- exc->tt_metrics.ratio = exc->tt_metrics.y_ratio;
- }
- else
-#endif
- {
- if ( exc->GS.projVector.y == 0 )
- exc->tt_metrics.ratio = exc->tt_metrics.x_ratio;
+ if ( exc->GS.projVector.y == 0 )
+ exc->tt_metrics.ratio = exc->tt_metrics.x_ratio;
- else if ( exc->GS.projVector.x == 0 )
- exc->tt_metrics.ratio = exc->tt_metrics.y_ratio;
+ else if ( exc->GS.projVector.x == 0 )
+ exc->tt_metrics.ratio = exc->tt_metrics.y_ratio;
- else
- {
- FT_F26Dot6 x, y;
+ else
+ {
+ FT_F26Dot6 x, y;
- x = TT_MulFix14( exc->tt_metrics.x_ratio,
- exc->GS.projVector.x );
- y = TT_MulFix14( exc->tt_metrics.y_ratio,
- exc->GS.projVector.y );
- exc->tt_metrics.ratio = FT_Hypot( x, y );
- }
+ x = TT_MulFix14( exc->tt_metrics.x_ratio,
+ exc->GS.projVector.x );
+ y = TT_MulFix14( exc->tt_metrics.y_ratio,
+ exc->GS.projVector.y );
+ exc->tt_metrics.ratio = FT_Hypot( x, y );
}
}
return exc->tt_metrics.ratio;
@@ -1604,7 +1578,7 @@
static FT_Short
GetShortIns( TT_ExecContext exc )
{
- /* Reading a byte stream so there is no endianess (DaveP) */
+ /* Reading a byte stream so there is no endianness (DaveP) */
exc->IP += 2;
return (FT_Short)( ( exc->code[exc->IP - 2] << 8 ) +
exc->code[exc->IP - 1] );
@@ -1643,7 +1617,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;
@@ -1685,6 +1659,10 @@
/* <InOut> */
/* zone :: The affected glyph zone. */
/* */
+ /* <Note> */
+ /* See `ttinterp.h' for details on backward compatibility mode. */
+ /* `Touches' the point. */
+ /* */
static void
Direct_Move( TT_ExecContext exc,
TT_GlyphZone zone,
@@ -1694,20 +1672,38 @@
FT_F26Dot6 v;
-#ifdef TT_CONFIG_OPTION_UNPATENTED_HINTING
- FT_ASSERT( !exc->face->unpatented_hinting );
-#endif
-
v = exc->GS.freeVector.x;
if ( v != 0 )
{
-#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
- if ( !SUBPIXEL_HINTING ||
+#ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY
+ if ( SUBPIXEL_HINTING_INFINALITY &&
( !exc->ignore_x_mode ||
( exc->sph_tweak_flags & SPH_TWEAK_ALLOW_X_DMOVE ) ) )
-#endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */
- zone->cur[point].x += FT_MulDiv( distance, v, exc->F_dot_P );
+ zone->cur[point].x = ADD_LONG( zone->cur[point].x,
+ FT_MulDiv( distance,
+ v,
+ exc->F_dot_P ) );
+ else
+#endif /* TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY */
+
+#ifdef TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL
+ /* 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->backward_compatibility )
+ zone->cur[point].x = ADD_LONG( zone->cur[point].x,
+ FT_MulDiv( distance,
+ v,
+ exc->F_dot_P ) );
+ else
+#endif
+
+ if ( NO_SUBPIXEL_HINTING )
+ zone->cur[point].x = ADD_LONG( zone->cur[point].x,
+ FT_MulDiv( distance,
+ v,
+ exc->F_dot_P ) );
zone->tags[point] |= FT_CURVE_TAG_TOUCH_X;
}
@@ -1716,7 +1712,16 @@
if ( v != 0 )
{
- zone->cur[point].y += FT_MulDiv( distance, v, exc->F_dot_P );
+#ifdef TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL
+ if ( !( SUBPIXEL_HINTING_MINIMAL &&
+ exc->backward_compatibility &&
+ exc->iupx_called &&
+ exc->iupy_called ) )
+#endif
+ zone->cur[point].y = ADD_LONG( zone->cur[point].y,
+ FT_MulDiv( distance,
+ v,
+ exc->F_dot_P ) );
zone->tags[point] |= FT_CURVE_TAG_TOUCH_Y;
}
@@ -1749,19 +1754,21 @@
FT_F26Dot6 v;
-#ifdef TT_CONFIG_OPTION_UNPATENTED_HINTING
- FT_ASSERT( !exc->face->unpatented_hinting );
-#endif
-
v = exc->GS.freeVector.x;
if ( v != 0 )
- zone->org[point].x += FT_MulDiv( distance, v, exc->F_dot_P );
+ zone->org[point].x = ADD_LONG( zone->org[point].x,
+ FT_MulDiv( distance,
+ v,
+ exc->F_dot_P ) );
v = exc->GS.freeVector.y;
if ( v != 0 )
- zone->org[point].y += FT_MulDiv( distance, v, exc->F_dot_P );
+ zone->org[point].y = ADD_LONG( zone->org[point].y,
+ FT_MulDiv( distance,
+ v,
+ exc->F_dot_P ) );
}
@@ -1771,6 +1778,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 backward compatibility mode. */
/* */
/*************************************************************************/
@@ -1781,13 +1789,20 @@
FT_UShort point,
FT_F26Dot6 distance )
{
- FT_UNUSED( exc );
+#ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY
+ if ( SUBPIXEL_HINTING_INFINALITY && !exc->ignore_x_mode )
+ zone->cur[point].x = ADD_LONG( zone->cur[point].x, distance );
+ else
+#endif /* TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY */
-#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
- if ( !SUBPIXEL_HINTING ||
- !exc->ignore_x_mode )
-#endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */
- zone->cur[point].x += distance;
+#ifdef TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL
+ if ( SUBPIXEL_HINTING_MINIMAL && !exc->backward_compatibility )
+ zone->cur[point].x = ADD_LONG( zone->cur[point].x, distance );
+ else
+#endif
+
+ if ( NO_SUBPIXEL_HINTING )
+ zone->cur[point].x = ADD_LONG( zone->cur[point].x, distance );
zone->tags[point] |= FT_CURVE_TAG_TOUCH_X;
}
@@ -1801,8 +1816,14 @@
{
FT_UNUSED( exc );
- zone->cur[point].y += distance;
- zone->tags[point] |= FT_CURVE_TAG_TOUCH_Y;
+#ifdef TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL
+ if ( !( SUBPIXEL_HINTING_MINIMAL &&
+ exc->backward_compatibility &&
+ exc->iupx_called && exc->iupy_called ) )
+#endif
+ zone->cur[point].y = ADD_LONG( zone->cur[point].y, distance );
+
+ zone->tags[point] |= FT_CURVE_TAG_TOUCH_Y;
}
@@ -1824,7 +1845,7 @@
{
FT_UNUSED( exc );
- zone->org[point].x += distance;
+ zone->org[point].x = ADD_LONG( zone->org[point].x, distance );
}
@@ -1836,7 +1857,7 @@
{
FT_UNUSED( exc );
- zone->org[point].y += distance;
+ zone->org[point].y = ADD_LONG( zone->org[point].y, distance );
}
@@ -1874,13 +1895,13 @@
if ( distance >= 0 )
{
- val = distance + compensation;
+ val = ADD_LONG( distance, compensation );
if ( val < 0 )
val = 0;
}
else
{
- val = distance - compensation;
+ val = SUB_LONG( distance, compensation );
if ( val > 0 )
val = 0;
}
@@ -1916,13 +1937,14 @@
if ( distance >= 0 )
{
- val = FT_PIX_ROUND( distance + compensation );
+ val = FT_PIX_ROUND_LONG( ADD_LONG( distance, compensation ) );
if ( val < 0 )
val = 0;
}
else
{
- val = -FT_PIX_ROUND( compensation - distance );
+ val = NEG_LONG( FT_PIX_ROUND_LONG( SUB_LONG( compensation,
+ distance ) ) );
if ( val > 0 )
val = 0;
}
@@ -1959,13 +1981,16 @@
if ( distance >= 0 )
{
- val = FT_PIX_FLOOR( distance + compensation ) + 32;
+ val = ADD_LONG( FT_PIX_FLOOR( ADD_LONG( distance, compensation ) ),
+ 32 );
if ( val < 0 )
val = 32;
}
else
{
- val = -( FT_PIX_FLOOR( compensation - distance ) + 32 );
+ val = NEG_LONG( ADD_LONG( FT_PIX_FLOOR( SUB_LONG( compensation,
+ distance ) ),
+ 32 ) );
if ( val > 0 )
val = -32;
}
@@ -2002,13 +2027,13 @@
if ( distance >= 0 )
{
- val = FT_PIX_FLOOR( distance + compensation );
+ val = FT_PIX_FLOOR( ADD_LONG( distance, compensation ) );
if ( val < 0 )
val = 0;
}
else
{
- val = -FT_PIX_FLOOR( compensation - distance );
+ val = NEG_LONG( FT_PIX_FLOOR( SUB_LONG( compensation, distance ) ) );
if ( val > 0 )
val = 0;
}
@@ -2045,13 +2070,14 @@
if ( distance >= 0 )
{
- val = FT_PIX_CEIL( distance + compensation );
+ val = FT_PIX_CEIL_LONG( ADD_LONG( distance, compensation ) );
if ( val < 0 )
val = 0;
}
else
{
- val = -FT_PIX_CEIL( compensation - distance );
+ val = NEG_LONG( FT_PIX_CEIL_LONG( SUB_LONG( compensation,
+ distance ) ) );
if ( val > 0 )
val = 0;
}
@@ -2081,20 +2107,21 @@
FT_F26Dot6 distance,
FT_F26Dot6 compensation )
{
- FT_F26Dot6 val;
+ FT_F26Dot6 val;
FT_UNUSED( exc );
if ( distance >= 0 )
{
- val = FT_PAD_ROUND( distance + compensation, 32 );
+ val = FT_PAD_ROUND_LONG( ADD_LONG( distance, compensation ), 32 );
if ( val < 0 )
val = 0;
}
else
{
- val = -FT_PAD_ROUND( compensation - distance, 32 );
+ val = NEG_LONG( FT_PAD_ROUND_LONG( SUB_LONG( compensation, distance ),
+ 32 ) );
if ( val > 0 )
val = 0;
}
@@ -2120,7 +2147,7 @@
/* Rounded distance. */
/* */
/* <Note> */
- /* The TrueType specification says very few about the relationship */
+ /* The TrueType specification says very little about the relationship */
/* between rounding and engine compensation. However, it seems from */
/* the description of super round that we should add the compensation */
/* before rounding. */
@@ -2135,17 +2162,19 @@
if ( distance >= 0 )
{
- val = ( distance - exc->phase + exc->threshold + compensation ) &
+ val = ADD_LONG( distance,
+ exc->threshold - exc->phase + compensation ) &
-exc->period;
- val += exc->phase;
+ val = ADD_LONG( val, exc->phase );
if ( val < 0 )
val = exc->phase;
}
else
{
- val = -( ( exc->threshold - exc->phase - distance + compensation ) &
- -exc->period );
- val -= exc->phase;
+ val = NEG_LONG( SUB_LONG( exc->threshold - exc->phase + compensation,
+ distance ) &
+ -exc->period );
+ val = SUB_LONG( val, exc->phase );
if ( val > 0 )
val = -exc->phase;
}
@@ -2184,17 +2213,19 @@
if ( distance >= 0 )
{
- val = ( ( distance - exc->phase + exc->threshold + compensation ) /
+ val = ( ADD_LONG( distance,
+ exc->threshold - exc->phase + compensation ) /
exc->period ) * exc->period;
- val += exc->phase;
+ val = ADD_LONG( val, exc->phase );
if ( val < 0 )
val = exc->phase;
}
else
{
- val = -( ( ( exc->threshold - exc->phase - distance + compensation ) /
- exc->period ) * exc->period );
- val -= exc->phase;
+ val = NEG_LONG( ( SUB_LONG( exc->threshold - exc->phase + compensation,
+ distance ) /
+ exc->period ) * exc->period );
+ val = SUB_LONG( val, exc->phase );
if ( val > 0 )
val = -exc->phase;
}
@@ -2345,10 +2376,6 @@
FT_Pos dx,
FT_Pos dy )
{
-#ifdef TT_CONFIG_OPTION_UNPATENTED_HINTING
- FT_ASSERT( !exc->face->unpatented_hinting );
-#endif
-
return TT_DotFix14( dx, dy,
exc->GS.projVector.x,
exc->GS.projVector.y );
@@ -2450,51 +2477,6 @@
static void
Compute_Funcs( TT_ExecContext exc )
{
-#ifdef TT_CONFIG_OPTION_UNPATENTED_HINTING
- if ( exc->face->unpatented_hinting )
- {
- /* If both vectors point rightwards along the x axis, set */
- /* `both-x-axis' true, otherwise set it false. The x values only */
- /* need be tested because the vector has been normalised to a unit */
- /* vector of length 0x4000 = unity. */
- exc->GS.both_x_axis = (FT_Bool)( exc->GS.projVector.x == 0x4000 &&
- exc->GS.freeVector.x == 0x4000 );
-
- /* Throw away projection and freedom vector information */
- /* because the patents don't allow them to be stored. */
- /* The relevant US Patents are 5155805 and 5325479. */
- exc->GS.projVector.x = 0;
- exc->GS.projVector.y = 0;
- exc->GS.freeVector.x = 0;
- exc->GS.freeVector.y = 0;
-
- if ( exc->GS.both_x_axis )
- {
- exc->func_project = Project_x;
- exc->func_move = Direct_Move_X;
- exc->func_move_orig = Direct_Move_Orig_X;
- }
- else
- {
- exc->func_project = Project_y;
- exc->func_move = Direct_Move_Y;
- exc->func_move_orig = Direct_Move_Orig_Y;
- }
-
- if ( exc->GS.dualVector.x == 0x4000 )
- exc->func_dualproj = Project_x;
- else if ( exc->GS.dualVector.y == 0x4000 )
- exc->func_dualproj = Project_y;
- else
- exc->func_dualproj = Dual_Project;
-
- /* Force recalculation of cached aspect ratio */
- exc->tt_metrics.ratio = 0;
-
- return;
- }
-#endif /* TT_CONFIG_OPTION_UNPATENTED_HINTING */
-
if ( exc->GS.freeVector.x == 0x4000 )
exc->F_dot_P = exc->GS.projVector.x;
else if ( exc->GS.freeVector.y == 0x4000 )
@@ -2634,13 +2616,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;
+ }
}
@@ -2869,7 +2858,7 @@
static void
Ins_ADD( FT_Long* args )
{
- args[0] += args[1];
+ args[0] = ADD_LONG( args[0], args[1] );
}
@@ -2882,7 +2871,7 @@
static void
Ins_SUB( FT_Long* args )
{
- args[0] -= args[1];
+ args[0] = SUB_LONG( args[0], args[1] );
}
@@ -2925,7 +2914,8 @@
static void
Ins_ABS( FT_Long* args )
{
- args[0] = FT_ABS( args[0] );
+ if ( args[0] < 0 )
+ args[0] = NEG_LONG( args[0] );
}
@@ -2933,12 +2923,12 @@
/* */
/* NEG[]: NEGate */
/* Opcode range: 0x65 */
- /* Stack: f26.6 --> f26.6 */
+ /* Stack: f26.6 --> f26.6 */
/* */
static void
Ins_NEG( FT_Long* args )
{
- args[0] = -args[0];
+ args[0] = NEG_LONG( args[0] );
}
@@ -2964,7 +2954,7 @@
static void
Ins_CEILING( FT_Long* args )
{
- args[0] = FT_PIX_CEIL( args[0] );
+ args[0] = FT_PIX_CEIL_LONG( args[0] );
}
@@ -2978,8 +2968,6 @@
Ins_RS( TT_ExecContext exc,
FT_Long* args )
{
-#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
-
FT_ULong I = (FT_ULong)args[0];
@@ -2992,9 +2980,10 @@
}
else
{
+#ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY
/* subpixel hinting - avoid Typeman Dstroke and */
/* IStroke and Vacuform rounds */
- if ( SUBPIXEL_HINTING &&
+ if ( SUBPIXEL_HINTING_INFINALITY &&
exc->ignore_x_mode &&
( ( I == 24 &&
( exc->face->sph_found_func_flags &
@@ -3009,25 +2998,9 @@
exc->iup_called ) ) )
args[0] = 0;
else
+#endif /* TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY */
args[0] = exc->storage[I];
}
-
-#else /* !TT_CONFIG_OPTION_SUBPIXEL_HINTING */
-
- FT_ULong I = (FT_ULong)args[0];
-
-
- if ( BOUNDSL( I, exc->storeSize ) )
- {
- if ( exc->pedantic_hinting )
- ARRAY_BOUND_ERROR;
- else
- args[0] = 0;
- }
- else
- args[0] = exc->storage[I];
-
-#endif /* !TT_CONFIG_OPTION_SUBPIXEL_HINTING */
}
@@ -3190,7 +3163,7 @@
/*************************************************************************/
/* */
/* MAX[]: MAXimum */
- /* Opcode range: 0x68 */
+ /* Opcode range: 0x8B */
/* Stack: int32? int32? --> int32 */
/* */
static void
@@ -3204,7 +3177,7 @@
/*************************************************************************/
/* */
/* MIN[]: MINimum */
- /* Opcode range: 0x69 */
+ /* Opcode range: 0x8C */
/* Stack: int32? int32? --> int32 */
/* */
static void
@@ -3316,7 +3289,10 @@
if ( args[0] < 0 )
exc->error = FT_THROW( Bad_Argument );
else
- exc->GS.loop = args[0];
+ {
+ /* we heuristically limit the number of loops to 16 bits */
+ exc->GS.loop = args[0] > 0xFFFFL ? 0xFFFFL : args[0];
+ }
}
@@ -3448,13 +3424,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 );
+ }
}
@@ -3509,7 +3499,7 @@
TT_DefRecord* rec;
TT_DefRecord* limit;
-#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
+#ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY
/* arguments to opcodes are skipped by `SKIP_Code' */
FT_Byte opcode_pattern[9][12] = {
/* #0 inline delta function 1 */
@@ -3607,8 +3597,15 @@
FT_UShort opcode_pointer[9] = { 0, 0, 0, 0, 0, 0, 0, 0, 0 };
FT_UShort opcode_size[9] = { 12, 8, 8, 6, 7, 4, 5, 4, 2 };
FT_UShort i;
-#endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */
+#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. */
@@ -3652,7 +3649,7 @@
if ( n > exc->maxFunc )
exc->maxFunc = (FT_UInt16)n;
-#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
+#ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY
/* We don't know for sure these are typeman functions, */
/* however they are only active when RS 22 is called */
if ( n >= 64 && n <= 66 )
@@ -3665,9 +3662,9 @@
while ( SkipCode( exc ) == SUCCESS )
{
-#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
+#ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY
- if ( SUBPIXEL_HINTING )
+ if ( SUBPIXEL_HINTING_INFINALITY )
{
for ( i = 0; i < opcode_patterns; i++ )
{
@@ -3774,7 +3771,7 @@
( exc->face->sph_found_func_flags & SPH_FDEF_INLINE_DELTA_2 ) );
}
-#endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */
+#endif /* TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY */
switch ( exc->opcode )
{
@@ -3803,9 +3800,9 @@
TT_CallRec* pRec;
-#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
+#ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY
exc->sph_in_func_flags = 0x0000;
-#endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */
+#endif /* TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY */
if ( exc->callTop <= 0 ) /* We encountered an ENDF without a call */
{
@@ -3891,8 +3888,8 @@
if ( !def->active )
goto Fail;
-#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
- if ( SUBPIXEL_HINTING &&
+#ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY
+ if ( SUBPIXEL_HINTING_INFINALITY &&
exc->ignore_x_mode &&
( ( exc->iup_called &&
( exc->sph_tweak_flags & SPH_TWEAK_NO_CALL_AFTER_IUP ) ) ||
@@ -3900,7 +3897,7 @@
goto Fail;
else
exc->sph_in_func_flags = def->sph_fdef_flags;
-#endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */
+#endif /* TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY */
/* check the call stack */
if ( exc->callTop >= exc->callSize )
@@ -3979,14 +3976,14 @@
if ( !def->active )
goto Fail;
-#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
- if ( SUBPIXEL_HINTING &&
+#ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY
+ if ( SUBPIXEL_HINTING_INFINALITY &&
exc->ignore_x_mode &&
( def->sph_fdef_flags & SPH_FDEF_VACUFORM_ROUND_1 ) )
goto Fail;
else
exc->sph_in_func_flags = def->sph_fdef_flags;
-#endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */
+#endif /* TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY */
/* check stack */
if ( exc->callTop >= exc->callSize )
@@ -4009,6 +4006,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;
@@ -4032,6 +4033,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;
@@ -4079,6 +4087,7 @@
exc->error = FT_THROW( Nested_DEFS );
return;
case 0x2D: /* ENDF */
+ def->end = exc->IP;
return;
}
}
@@ -4238,8 +4247,8 @@
p1 = exc->zp1.cur + aIdx2;
p2 = exc->zp2.cur + aIdx1;
- A = p1->x - p2->x;
- B = p1->y - p2->y;
+ A = SUB_LONG( p1->x, p2->x );
+ B = SUB_LONG( p1->y, p2->y );
/* If p1 == p2, SPvTL and SFvTL behave the same as */
/* SPvTCA[X] and SFvTCA[X], respectively. */
@@ -4254,9 +4263,9 @@
if ( ( opcode & 1 ) != 0 )
{
- C = B; /* counter clockwise rotation */
- B = A;
- A = -C;
+ C = B; /* counter clockwise rotation */
+ B = A;
+ A = NEG_LONG( C );
}
Normalize( A, B, Vec );
@@ -4298,16 +4307,12 @@
exc->GS.dualVector.x = AA;
exc->GS.dualVector.y = BB;
}
- else
- GUESS_VECTOR( projVector );
if ( ( opcode & 2 ) == 0 )
{
exc->GS.freeVector.x = AA;
exc->GS.freeVector.y = BB;
}
- else
- GUESS_VECTOR( freeVector );
Compute_Funcs( exc );
}
@@ -4329,7 +4334,6 @@
&exc->GS.projVector ) == SUCCESS )
{
exc->GS.dualVector = exc->GS.projVector;
- GUESS_VECTOR( freeVector );
Compute_Funcs( exc );
}
}
@@ -4350,7 +4354,6 @@
(FT_UShort)args[0],
&exc->GS.freeVector ) == SUCCESS )
{
- GUESS_VECTOR( projVector );
Compute_Funcs( exc );
}
}
@@ -4365,7 +4368,6 @@
static void
Ins_SFVTPV( TT_ExecContext exc )
{
- GUESS_VECTOR( projVector );
exc->GS.freeVector = exc->GS.projVector;
Compute_Funcs( exc );
}
@@ -4394,7 +4396,6 @@
Normalize( X, Y, &exc->GS.projVector );
exc->GS.dualVector = exc->GS.projVector;
- GUESS_VECTOR( freeVector );
Compute_Funcs( exc );
}
@@ -4420,7 +4421,6 @@
X = S;
Normalize( X, Y, &exc->GS.freeVector );
- GUESS_VECTOR( projVector );
Compute_Funcs( exc );
}
@@ -4435,21 +4435,8 @@
Ins_GPV( TT_ExecContext exc,
FT_Long* args )
{
-#ifdef TT_CONFIG_OPTION_UNPATENTED_HINTING
- if ( exc->face->unpatented_hinting )
- {
- args[0] = exc->GS.both_x_axis ? 0x4000 : 0;
- args[1] = exc->GS.both_x_axis ? 0 : 0x4000;
- }
- else
- {
- args[0] = exc->GS.projVector.x;
- args[1] = exc->GS.projVector.y;
- }
-#else
args[0] = exc->GS.projVector.x;
args[1] = exc->GS.projVector.y;
-#endif
}
@@ -4463,21 +4450,8 @@
Ins_GFV( TT_ExecContext exc,
FT_Long* args )
{
-#ifdef TT_CONFIG_OPTION_UNPATENTED_HINTING
- if ( exc->face->unpatented_hinting )
- {
- args[0] = exc->GS.both_x_axis ? 0x4000 : 0;
- args[1] = exc->GS.both_x_axis ? 0 : 0x4000;
- }
- else
- {
- args[0] = exc->GS.freeVector.x;
- args[1] = exc->GS.freeVector.y;
- }
-#else
args[0] = exc->GS.freeVector.x;
args[1] = exc->GS.freeVector.y;
-#endif
}
@@ -4597,7 +4571,7 @@
/* */
/* FLIPOFF[]: Set auto-FLIP to OFF */
/* Opcode range: 0x4E */
- /* Stack: --> */
+ /* Stack: --> */
/* */
static void
Ins_FLIPOFF( TT_ExecContext exc )
@@ -4832,7 +4806,7 @@
K = FAST_PROJECT( &exc->zp2.cur[L] );
- exc->func_move( exc, &exc->zp2, L, args[1] - K );
+ exc->func_move( exc, &exc->zp2, L, SUB_LONG( args[1], K ) );
/* UNDOCUMENTED! The MS rasterizer does that with */
/* twilight points (confirmed by Greg Hitchcock) */
@@ -4916,13 +4890,13 @@
}
}
-#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
+#ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY
/* Disable Type 2 Vacuform Rounds - e.g. Arial Narrow */
- if ( SUBPIXEL_HINTING &&
- exc->ignore_x_mode &&
- FT_ABS( D ) == 64 )
+ if ( SUBPIXEL_HINTING_INFINALITY &&
+ exc->ignore_x_mode &&
+ FT_ABS( D ) == 64 )
D += 1;
-#endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */
+#endif /* TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY */
args[0] = D;
}
@@ -4956,12 +4930,12 @@
}
{
- FT_Vector* v1 = exc->zp1.org + p2;
- FT_Vector* v2 = exc->zp2.org + p1;
+ FT_Vector* v1 = exc->zp1.org + p2;
+ FT_Vector* v2 = exc->zp2.org + p1;
- A = v1->x - v2->x;
- B = v1->y - v2->y;
+ A = SUB_LONG( v1->x, v2->x );
+ B = SUB_LONG( v1->y, v2->y );
/* If v1 == v2, SDPvTL behaves the same as */
/* SVTCA[X], respectively. */
@@ -4977,9 +4951,9 @@
if ( ( opcode & 1 ) != 0 )
{
- C = B; /* counter clockwise rotation */
- B = A;
- A = -C;
+ C = B; /* counter clockwise rotation */
+ B = A;
+ A = NEG_LONG( C );
}
Normalize( A, B, &exc->GS.dualVector );
@@ -4989,8 +4963,8 @@
FT_Vector* v2 = exc->zp2.cur + p1;
- A = v1->x - v2->x;
- B = v1->y - v2->y;
+ A = SUB_LONG( v1->x, v2->x );
+ B = SUB_LONG( v1->y, v2->y );
if ( A == 0 && B == 0 )
{
@@ -5001,13 +4975,12 @@
if ( ( opcode & 1 ) != 0 )
{
- C = B; /* counter clockwise rotation */
- B = A;
- A = -C;
+ C = B; /* counter clockwise rotation */
+ B = A;
+ A = NEG_LONG( C );
}
Normalize( A, B, &exc->GS.projVector );
- GUESS_VECTOR( freeVector );
Compute_Funcs( exc );
}
@@ -5179,12 +5152,23 @@
exc->GS.instruct_control &= ~(FT_Byte)Kf;
exc->GS.instruct_control |= (FT_Byte)L;
-#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
- /* INSTCTRL modifying flag 3 also has an effect */
- /* outside of the CVT program */
if ( K == 3 )
- exc->ignore_x_mode = FT_BOOL( L == 4 );
+ {
+#ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY
+ /* INSTCTRL modifying flag 3 also has an effect */
+ /* outside of the CVT program */
+ if ( SUBPIXEL_HINTING_INFINALITY )
+ exc->ignore_x_mode = FT_BOOL( L == 4 );
#endif
+
+#ifdef TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL
+ /* 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->backward_compatibility = !FT_BOOL( L == 4 );
+#endif
+ }
}
@@ -5239,14 +5223,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;
}
@@ -5269,6 +5253,15 @@
FT_UShort point;
+#ifdef TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL
+ /* 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
+
if ( exc->top < exc->GS.loop )
{
if ( exc->pedantic_hinting )
@@ -5315,6 +5308,15 @@
FT_UShort I, K, L;
+#ifdef TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL
+ /* See `ttinterp.h' for details on backward compatibility mode. */
+ if ( SUBPIXEL_HINTING_MINIMAL &&
+ exc->backward_compatibility &&
+ exc->iupx_called &&
+ exc->iupy_called )
+ return;
+#endif
+
K = (FT_UShort)args[1];
L = (FT_UShort)args[0];
@@ -5344,6 +5346,15 @@
FT_UShort I, K, L;
+#ifdef TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL
+ /* See `ttinterp.h' for details on backward compatibility mode. */
+ if ( SUBPIXEL_HINTING_MINIMAL &&
+ exc->backward_compatibility &&
+ exc->iupx_called &&
+ exc->iupy_called )
+ return;
+#endif
+
K = (FT_UShort)args[1];
L = (FT_UShort)args[0];
@@ -5396,31 +5407,14 @@
d = PROJECT( zp.cur + p, zp.org + p );
-#ifdef TT_CONFIG_OPTION_UNPATENTED_HINTING
- if ( exc->face->unpatented_hinting )
- {
- if ( exc->GS.both_x_axis )
- {
- *x = d;
- *y = 0;
- }
- else
- {
- *x = 0;
- *y = d;
- }
- }
- else
-#endif
- {
- *x = FT_MulDiv( d, (FT_Long)exc->GS.freeVector.x, exc->F_dot_P );
- *y = FT_MulDiv( d, (FT_Long)exc->GS.freeVector.y, exc->F_dot_P );
- }
+ *x = FT_MulDiv( d, (FT_Long)exc->GS.freeVector.x, exc->F_dot_P );
+ *y = FT_MulDiv( d, (FT_Long)exc->GS.freeVector.y, exc->F_dot_P );
return SUCCESS;
}
+ /* See `ttinterp.h' for details on backward compatibility mode. */
static void
Move_Zp2_Point( TT_ExecContext exc,
FT_UShort point,
@@ -5428,35 +5422,28 @@
FT_F26Dot6 dy,
FT_Bool touch )
{
-#ifdef TT_CONFIG_OPTION_UNPATENTED_HINTING
- if ( exc->face->unpatented_hinting )
+ if ( exc->GS.freeVector.x != 0 )
{
- if ( exc->GS.both_x_axis )
- {
- exc->zp2.cur[point].x += dx;
- if ( touch )
- exc->zp2.tags[point] |= FT_CURVE_TAG_TOUCH_X;
- }
- else
- {
- exc->zp2.cur[point].y += dy;
- if ( touch )
- exc->zp2.tags[point] |= FT_CURVE_TAG_TOUCH_Y;
- }
- return;
- }
+#ifdef TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL
+ if ( !( SUBPIXEL_HINTING_MINIMAL &&
+ exc->backward_compatibility ) )
#endif
+ exc->zp2.cur[point].x = ADD_LONG( exc->zp2.cur[point].x, dx );
- if ( exc->GS.freeVector.x != 0 )
- {
- exc->zp2.cur[point].x += dx;
if ( touch )
exc->zp2.tags[point] |= FT_CURVE_TAG_TOUCH_X;
}
if ( exc->GS.freeVector.y != 0 )
{
- exc->zp2.cur[point].y += dy;
+#ifdef TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL
+ if ( !( SUBPIXEL_HINTING_MINIMAL &&
+ exc->backward_compatibility &&
+ exc->iupx_called &&
+ exc->iupy_called ) )
+#endif
+ exc->zp2.cur[point].y = ADD_LONG( exc->zp2.cur[point].y, dy );
+
if ( touch )
exc->zp2.tags[point] |= FT_CURVE_TAG_TOUCH_Y;
}
@@ -5503,13 +5490,12 @@
}
}
else
-#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
+#ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY
/* doesn't follow Cleartype spec but produces better result */
- if ( SUBPIXEL_HINTING &&
- exc->ignore_x_mode )
+ if ( SUBPIXEL_HINTING_INFINALITY && exc->ignore_x_mode )
Move_Zp2_Point( exc, point, 0, dy, TRUE );
else
-#endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */
+#endif /* TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY */
Move_Zp2_Point( exc, point, dx, dy, TRUE );
exc->GS.loop--;
@@ -5637,9 +5623,15 @@
{
FT_F26Dot6 dx, dy;
FT_UShort point;
-#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
+#ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY
FT_Int B1, B2;
#endif
+#ifdef TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL
+ FT_Bool in_twilight = FT_BOOL( exc->GS.gep0 == 0 ||
+ exc->GS.gep1 == 0 ||
+ exc->GS.gep2 == 0 );
+#endif
+
if ( exc->top < exc->GS.loop + 1 )
@@ -5649,26 +5641,8 @@
goto Fail;
}
-#ifdef TT_CONFIG_OPTION_UNPATENTED_HINTING
- if ( exc->face->unpatented_hinting )
- {
- if ( exc->GS.both_x_axis )
- {
- dx = (FT_UInt32)args[0];
- dy = 0;
- }
- else
- {
- dx = 0;
- dy = (FT_UInt32)args[0];
- }
- }
- else
-#endif
- {
- dx = TT_MulFix14( args[0], exc->GS.freeVector.x );
- dy = TT_MulFix14( args[0], exc->GS.freeVector.y );
- }
+ dx = TT_MulFix14( args[0], exc->GS.freeVector.x );
+ dy = TT_MulFix14( args[0], exc->GS.freeVector.y );
while ( exc->GS.loop > 0 )
{
@@ -5685,7 +5659,8 @@
}
}
else
-#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
+#ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY
+ if ( SUBPIXEL_HINTING_INFINALITY )
{
/* If not using ignore_x_mode rendering, allow ZP2 move. */
/* If inline deltas aren't allowed, skip ZP2 move. */
@@ -5695,8 +5670,7 @@
/* - the glyph is specifically set to allow SHPIX moves */
/* - the move is on a previously Y-touched point */
- if ( SUBPIXEL_HINTING &&
- exc->ignore_x_mode )
+ if ( exc->ignore_x_mode )
{
/* save point for later comparison */
if ( exc->GS.freeVector.y != 0 )
@@ -5719,7 +5693,11 @@
( B1 & 63 ) != 0 &&
( B2 & 63 ) != 0 &&
B1 != B2 )
- Move_Zp2_Point( exc, point, -dx, -dy, TRUE );
+ Move_Zp2_Point( exc,
+ point,
+ NEG_LONG( dx ),
+ NEG_LONG( dy ),
+ TRUE );
}
}
else if ( exc->face->sph_compatibility_mode )
@@ -5751,7 +5729,7 @@
if ( ( B1 & 63 ) == 0 &&
( B2 & 63 ) != 0 &&
B1 != B2 )
- Move_Zp2_Point( exc, point, 0, -dy, TRUE );
+ Move_Zp2_Point( exc, point, 0, NEG_LONG( dy ), TRUE );
}
}
else if ( exc->sph_in_func_flags & SPH_FDEF_TYPEMAN_DIAGENDCTRL )
@@ -5760,15 +5738,30 @@
else
Move_Zp2_Point( exc, point, dx, dy, TRUE );
}
+ else
+#endif
+#ifdef TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL
+ 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 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 ) ||
+ ( exc->zp2.tags[point] & FT_CURVE_TAG_TOUCH_Y ) ) ) )
+ Move_Zp2_Point( exc, point, 0, dy, TRUE );
+ }
+ else
+#endif
+ Move_Zp2_Point( exc, point, dx, dy, TRUE );
+#ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY
Skip:
-
-#else /* !TT_CONFIG_OPTION_SUBPIXEL_HINTING */
-
- Move_Zp2_Point( exc, point, dx, dy, TRUE );
-
-#endif /* !TT_CONFIG_OPTION_SUBPIXEL_HINTING */
-
+#endif
exc->GS.loop--;
}
@@ -5788,14 +5781,14 @@
Ins_MSIRP( TT_ExecContext exc,
FT_Long* args )
{
- FT_UShort point;
+ FT_UShort point = 0;
FT_F26Dot6 distance;
-
-#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
- FT_F26Dot6 control_value_cutin = 0; /* pacify compiler */
+#ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY
+ FT_F26Dot6 control_value_cutin = 0;
+ FT_F26Dot6 delta;
- if ( SUBPIXEL_HINTING )
+ if ( SUBPIXEL_HINTING_INFINALITY )
{
control_value_cutin = exc->GS.control_value_cutin;
@@ -5804,8 +5797,7 @@
!( exc->sph_tweak_flags & SPH_TWEAK_NORMAL_ROUND ) )
control_value_cutin = 0;
}
-
-#endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */
+#endif /* TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY */
point = (FT_UShort)args[0];
@@ -5828,16 +5820,23 @@
distance = PROJECT( exc->zp1.cur + point, exc->zp0.cur + exc->GS.rp0 );
-#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
+#ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY
+ delta = SUB_LONG( distance, args[1] );
+ if ( delta < 0 )
+ delta = NEG_LONG( delta );
+
/* subpixel hinting - make MSIRP respect CVT cut-in; */
- if ( SUBPIXEL_HINTING &&
- exc->ignore_x_mode &&
- exc->GS.freeVector.x != 0 &&
- FT_ABS( distance - args[1] ) >= control_value_cutin )
+ if ( SUBPIXEL_HINTING_INFINALITY &&
+ exc->ignore_x_mode &&
+ exc->GS.freeVector.x != 0 &&
+ delta >= control_value_cutin )
distance = args[1];
-#endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */
+#endif /* TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY */
- exc->func_move( exc, &exc->zp1, point, args[1] - distance );
+ exc->func_move( exc,
+ &exc->zp1,
+ point,
+ SUB_LONG( args[1], distance ) );
exc->GS.rp1 = exc->GS.rp0;
exc->GS.rp2 = point;
@@ -5874,20 +5873,22 @@
if ( ( exc->opcode & 1 ) != 0 )
{
cur_dist = FAST_PROJECT( &exc->zp0.cur[point] );
-#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
- if ( SUBPIXEL_HINTING &&
- exc->ignore_x_mode &&
- exc->GS.freeVector.x != 0 )
- distance = Round_None(
- exc,
- cur_dist,
- exc->tt_metrics.compensations[0] ) - cur_dist;
+#ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY
+ if ( SUBPIXEL_HINTING_INFINALITY &&
+ exc->ignore_x_mode &&
+ exc->GS.freeVector.x != 0 )
+ distance = SUB_LONG(
+ Round_None( exc,
+ cur_dist,
+ exc->tt_metrics.compensations[0] ),
+ cur_dist );
else
#endif
- distance = exc->func_round(
- exc,
- cur_dist,
- exc->tt_metrics.compensations[0] ) - cur_dist;
+ distance = SUB_LONG(
+ exc->func_round( exc,
+ cur_dist,
+ exc->tt_metrics.compensations[0] ),
+ cur_dist );
}
else
distance = 0;
@@ -5920,14 +5921,14 @@
cvtEntry = (FT_ULong)args[1];
point = (FT_UShort)args[0];
-#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
- if ( SUBPIXEL_HINTING &&
+#ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY
+ if ( SUBPIXEL_HINTING_INFINALITY &&
exc->ignore_x_mode &&
exc->GS.freeVector.x != 0 &&
exc->GS.freeVector.y == 0 &&
!( exc->sph_tweak_flags & SPH_TWEAK_NORMAL_ROUND ) )
control_value_cutin = 0;
-#endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */
+#endif /* TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY */
if ( BOUNDS( point, exc->zp0.n_points ) ||
BOUNDSL( cvtEntry, exc->cvtSize ) )
@@ -5961,39 +5962,46 @@
if ( exc->GS.gep0 == 0 ) /* If in twilight zone */
{
-#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
+#ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY
/* Only adjust if not in sph_compatibility_mode or ignore_x_mode. */
/* Determined via experimentation and may be incorrect... */
- if ( !SUBPIXEL_HINTING ||
- ( !exc->ignore_x_mode ||
- !exc->face->sph_compatibility_mode ) )
-#endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */
+ if ( !( SUBPIXEL_HINTING_INFINALITY &&
+ ( exc->ignore_x_mode &&
+ exc->face->sph_compatibility_mode ) ) )
+#endif /* TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY */
exc->zp0.org[point].x = TT_MulFix14( distance,
exc->GS.freeVector.x );
exc->zp0.org[point].y = TT_MulFix14( distance,
exc->GS.freeVector.y ),
exc->zp0.cur[point] = exc->zp0.org[point];
}
-#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
- if ( SUBPIXEL_HINTING &&
+#ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY
+ if ( SUBPIXEL_HINTING_INFINALITY &&
exc->ignore_x_mode &&
( exc->sph_tweak_flags & SPH_TWEAK_MIAP_HACK ) &&
distance > 0 &&
exc->GS.freeVector.y != 0 )
distance = 0;
-#endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */
+#endif /* TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY */
org_dist = FAST_PROJECT( &exc->zp0.cur[point] );
if ( ( exc->opcode & 1 ) != 0 ) /* rounding and control cut-in flag */
{
- if ( FT_ABS( distance - org_dist ) > control_value_cutin )
+ FT_F26Dot6 delta;
+
+
+ delta = SUB_LONG( distance, org_dist );
+ if ( delta < 0 )
+ delta = NEG_LONG( delta );
+
+ if ( delta > control_value_cutin )
distance = org_dist;
-#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
- if ( SUBPIXEL_HINTING &&
- exc->ignore_x_mode &&
- exc->GS.freeVector.x != 0 )
+#ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY
+ if ( SUBPIXEL_HINTING_INFINALITY &&
+ exc->ignore_x_mode &&
+ exc->GS.freeVector.x != 0 )
distance = Round_None( exc,
distance,
exc->tt_metrics.compensations[0] );
@@ -6004,7 +6012,7 @@
exc->tt_metrics.compensations[0] );
}
- exc->func_move( exc, &exc->zp0, point, distance - org_dist );
+ exc->func_move( exc, &exc->zp0, point, SUB_LONG( distance, org_dist ) );
Fail:
exc->GS.rp0 = point;
@@ -6022,19 +6030,19 @@
Ins_MDRP( TT_ExecContext exc,
FT_Long* args )
{
- FT_UShort point;
+ FT_UShort point = 0;
FT_F26Dot6 org_dist, distance, minimum_distance;
minimum_distance = exc->GS.minimum_distance;
-#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
- if ( SUBPIXEL_HINTING &&
+#ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY
+ if ( SUBPIXEL_HINTING_INFINALITY &&
exc->ignore_x_mode &&
exc->GS.freeVector.x != 0 &&
!( exc->sph_tweak_flags & SPH_TWEAK_NORMAL_ROUND ) )
minimum_distance = 0;
-#endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */
+#endif /* TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY */
point = (FT_UShort)args[0];
@@ -6076,8 +6084,10 @@
FT_Vector vec;
- vec.x = FT_MulFix( vec1->x - vec2->x, exc->metrics.x_scale );
- vec.y = FT_MulFix( vec1->y - vec2->y, exc->metrics.y_scale );
+ vec.x = FT_MulFix( SUB_LONG( vec1->x, vec2->x ),
+ exc->metrics.x_scale );
+ vec.y = FT_MulFix( SUB_LONG( vec1->y, vec2->y ),
+ exc->metrics.y_scale );
org_dist = FAST_DUALPROJ( &vec );
}
@@ -6085,8 +6095,12 @@
/* single width cut-in test */
- if ( FT_ABS( org_dist - exc->GS.single_width_value ) <
- exc->GS.single_width_cutin )
+ /* |org_dist - single_width_value| < single_width_cutin */
+ if ( exc->GS.single_width_cutin > 0 &&
+ org_dist < exc->GS.single_width_value +
+ exc->GS.single_width_cutin &&
+ org_dist > exc->GS.single_width_value -
+ exc->GS.single_width_cutin )
{
if ( org_dist >= 0 )
org_dist = exc->GS.single_width_value;
@@ -6098,10 +6112,10 @@
if ( ( exc->opcode & 4 ) != 0 )
{
-#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
- if ( SUBPIXEL_HINTING &&
- exc->ignore_x_mode &&
- exc->GS.freeVector.x != 0 )
+#ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY
+ if ( SUBPIXEL_HINTING_INFINALITY &&
+ exc->ignore_x_mode &&
+ exc->GS.freeVector.x != 0 )
distance = Round_None(
exc,
org_dist,
@@ -6130,8 +6144,8 @@
}
else
{
- if ( distance > -minimum_distance )
- distance = -minimum_distance;
+ if ( distance > NEG_LONG( minimum_distance ) )
+ distance = NEG_LONG( minimum_distance );
}
}
@@ -6139,7 +6153,7 @@
org_dist = PROJECT( exc->zp1.cur + point, exc->zp0.cur + exc->GS.rp0 );
- exc->func_move( exc, &exc->zp1, point, distance - org_dist );
+ exc->func_move( exc, &exc->zp1, point, SUB_LONG( distance, org_dist ) );
Fail:
exc->GS.rp1 = exc->GS.rp0;
@@ -6169,25 +6183,25 @@
org_dist,
control_value_cutin,
minimum_distance;
-#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
+#ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY
FT_Int B1 = 0; /* pacify compiler */
FT_Int B2 = 0;
FT_Bool reverse_move = FALSE;
-#endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */
+#endif /* TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY */
minimum_distance = exc->GS.minimum_distance;
control_value_cutin = exc->GS.control_value_cutin;
point = (FT_UShort)args[0];
- cvtEntry = (FT_ULong)( args[1] + 1 );
+ cvtEntry = (FT_ULong)( ADD_LONG( args[1], 1 ) );
-#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
- if ( SUBPIXEL_HINTING &&
+#ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY
+ if ( SUBPIXEL_HINTING_INFINALITY &&
exc->ignore_x_mode &&
exc->GS.freeVector.x != 0 &&
!( exc->sph_tweak_flags & SPH_TWEAK_NORMAL_ROUND ) )
control_value_cutin = minimum_distance = 0;
-#endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */
+#endif /* TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY */
/* XXX: UNDOCUMENTED! cvt[-1] = 0 always */
@@ -6240,8 +6254,8 @@
cvt_dist = -cvt_dist;
}
-#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
- if ( SUBPIXEL_HINTING &&
+#ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY
+ if ( SUBPIXEL_HINTING_INFINALITY &&
exc->ignore_x_mode &&
exc->GS.freeVector.y != 0 &&
( exc->sph_tweak_flags & SPH_TWEAK_TIMES_NEW_ROMAN_HACK ) )
@@ -6251,7 +6265,7 @@
else if ( cur_dist > 64 && cur_dist < 84 )
cvt_dist += 32;
}
-#endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */
+#endif /* TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY */
/* control value cut-in and round */
@@ -6262,6 +6276,9 @@
if ( exc->GS.gep0 == exc->GS.gep1 )
{
+ FT_F26Dot6 delta;
+
+
/* XXX: According to Greg Hitchcock, the following wording is */
/* the right one: */
/* */
@@ -6274,7 +6291,11 @@
/* `ttinst2.doc', version 1.66, is thus incorrect since */
/* it implies `>=' instead of `>'. */
- if ( FT_ABS( cvt_dist - org_dist ) > control_value_cutin )
+ delta = SUB_LONG( cvt_dist, org_dist );
+ if ( delta < 0 )
+ delta = NEG_LONG( delta );
+
+ if ( delta > control_value_cutin )
cvt_dist = org_dist;
}
@@ -6286,16 +6307,23 @@
else
{
-#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
+#ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY
/* do cvt cut-in always in MIRP for sph */
- if ( SUBPIXEL_HINTING &&
+ if ( SUBPIXEL_HINTING_INFINALITY &&
exc->ignore_x_mode &&
exc->GS.gep0 == exc->GS.gep1 )
{
- if ( FT_ABS( cvt_dist - org_dist ) > control_value_cutin )
+ FT_F26Dot6 delta;
+
+
+ delta = SUB_LONG( cvt_dist, org_dist );
+ if ( delta < 0 )
+ delta = NEG_LONG( delta );
+
+ if ( delta > control_value_cutin )
cvt_dist = org_dist;
}
-#endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */
+#endif /* TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY */
distance = Round_None(
exc,
@@ -6314,13 +6342,13 @@
}
else
{
- if ( distance > -minimum_distance )
- distance = -minimum_distance;
+ if ( distance > NEG_LONG( minimum_distance ) )
+ distance = NEG_LONG( minimum_distance );
}
}
-#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
- if ( SUBPIXEL_HINTING )
+#ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY
+ if ( SUBPIXEL_HINTING_INFINALITY )
{
B1 = exc->zp1.cur[point].y;
@@ -6337,12 +6365,15 @@
( exc->sph_tweak_flags & SPH_TWEAK_COURIER_NEW_2_HACK ) )
distance += 64;
}
-#endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */
+#endif /* TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY */
- exc->func_move( exc, &exc->zp1, point, distance - cur_dist );
+ exc->func_move( exc,
+ &exc->zp1,
+ point,
+ SUB_LONG( distance, cur_dist ) );
-#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
- if ( SUBPIXEL_HINTING )
+#ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY
+ if ( SUBPIXEL_HINTING_INFINALITY )
{
B2 = exc->zp1.cur[point].y;
@@ -6363,10 +6394,13 @@
}
if ( reverse_move )
- exc->func_move( exc, &exc->zp1, point, -( distance - cur_dist ) );
+ exc->func_move( exc,
+ &exc->zp1,
+ point,
+ SUB_LONG( cur_dist, distance ) );
}
-#endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */
+#endif /* TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY */
Fail:
exc->GS.rp1 = exc->GS.rp0;
@@ -6391,8 +6425,8 @@
FT_F26Dot6 distance;
-#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
- if ( SUBPIXEL_HINTING &&
+#ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY
+ if ( SUBPIXEL_HINTING_INFINALITY &&
exc->ignore_x_mode &&
exc->iup_called &&
( exc->sph_tweak_flags & SPH_TWEAK_NO_ALIGNRP_AFTER_IUP ) )
@@ -6400,7 +6434,7 @@
exc->error = FT_THROW( Invalid_Reference );
goto Fail;
}
-#endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */
+#endif /* TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY */
if ( exc->top < exc->GS.loop ||
BOUNDS( exc->GS.rp0, exc->zp0.n_points ) )
@@ -6429,7 +6463,7 @@
distance = PROJECT( exc->zp1.cur + point,
exc->zp0.cur + exc->GS.rp0 );
- exc->func_move( exc, &exc->zp1, point, -distance );
+ exc->func_move( exc, &exc->zp1, point, NEG_LONG( distance ) );
}
exc->GS.loop--;
@@ -6486,19 +6520,19 @@
/* Cramer's rule */
- dbx = exc->zp0.cur[b1].x - exc->zp0.cur[b0].x;
- dby = exc->zp0.cur[b1].y - exc->zp0.cur[b0].y;
+ dbx = SUB_LONG( exc->zp0.cur[b1].x, exc->zp0.cur[b0].x );
+ dby = SUB_LONG( exc->zp0.cur[b1].y, exc->zp0.cur[b0].y );
- dax = exc->zp1.cur[a1].x - exc->zp1.cur[a0].x;
- day = exc->zp1.cur[a1].y - exc->zp1.cur[a0].y;
+ dax = SUB_LONG( exc->zp1.cur[a1].x, exc->zp1.cur[a0].x );
+ day = SUB_LONG( exc->zp1.cur[a1].y, exc->zp1.cur[a0].y );
- dx = exc->zp0.cur[b0].x - exc->zp1.cur[a0].x;
- dy = exc->zp0.cur[b0].y - exc->zp1.cur[a0].y;
+ dx = SUB_LONG( exc->zp0.cur[b0].x, exc->zp1.cur[a0].x );
+ dy = SUB_LONG( exc->zp0.cur[b0].y, exc->zp1.cur[a0].y );
- discriminant = FT_MulDiv( dax, -dby, 0x40 ) +
- FT_MulDiv( day, dbx, 0x40 );
- dotproduct = FT_MulDiv( dax, dbx, 0x40 ) +
- FT_MulDiv( day, dby, 0x40 );
+ discriminant = ADD_LONG( FT_MulDiv( dax, NEG_LONG( dby ), 0x40 ),
+ FT_MulDiv( day, dbx, 0x40 ) );
+ dotproduct = ADD_LONG( FT_MulDiv( dax, dbx, 0x40 ),
+ FT_MulDiv( day, dby, 0x40 ) );
/* The discriminant above is actually a cross product of vectors */
/* da and db. Together with the dot product, they can be used as */
@@ -6508,28 +6542,29 @@
/* discriminant = |da||db|sin(angle) . */
/* We use these equations to reject grazing intersections by */
/* thresholding abs(tan(angle)) at 1/19, corresponding to 3 degrees. */
- if ( 19 * FT_ABS( discriminant ) > FT_ABS( dotproduct ) )
+ if ( MUL_LONG( 19, FT_ABS( discriminant ) ) > FT_ABS( dotproduct ) )
{
- val = FT_MulDiv( dx, -dby, 0x40 ) + FT_MulDiv( dy, dbx, 0x40 );
+ val = ADD_LONG( FT_MulDiv( dx, NEG_LONG( dby ), 0x40 ),
+ FT_MulDiv( dy, dbx, 0x40 ) );
R.x = FT_MulDiv( val, dax, discriminant );
R.y = FT_MulDiv( val, day, discriminant );
- exc->zp2.cur[point].x = exc->zp1.cur[a0].x + R.x;
- exc->zp2.cur[point].y = exc->zp1.cur[a0].y + R.y;
+ /* XXX: Block in backward_compatibility and/or post-IUP? */
+ exc->zp2.cur[point].x = ADD_LONG( exc->zp1.cur[a0].x, R.x );
+ exc->zp2.cur[point].y = ADD_LONG( exc->zp1.cur[a0].y, R.y );
}
else
{
/* else, take the middle of the middles of A and B */
- exc->zp2.cur[point].x = ( exc->zp1.cur[a0].x +
- exc->zp1.cur[a1].x +
- exc->zp0.cur[b0].x +
- exc->zp0.cur[b1].x ) / 4;
- exc->zp2.cur[point].y = ( exc->zp1.cur[a0].y +
- exc->zp1.cur[a1].y +
- exc->zp0.cur[b0].y +
- exc->zp0.cur[b1].y ) / 4;
+ /* XXX: Block in backward_compatibility and/or post-IUP? */
+ exc->zp2.cur[point].x =
+ ADD_LONG( ADD_LONG( exc->zp1.cur[a0].x, exc->zp1.cur[a1].x ),
+ ADD_LONG( exc->zp0.cur[b0].x, exc->zp0.cur[b1].x ) ) / 4;
+ exc->zp2.cur[point].y =
+ ADD_LONG( ADD_LONG( exc->zp1.cur[a0].y, exc->zp1.cur[a1].y ),
+ ADD_LONG( exc->zp0.cur[b0].y, exc->zp0.cur[b1].y ) ) / 4;
}
exc->zp2.tags[point] |= FT_CURVE_TAG_TOUCH_BOTH;
@@ -6564,7 +6599,7 @@
distance = PROJECT( exc->zp0.cur + p2, exc->zp1.cur + p1 ) / 2;
exc->func_move( exc, &exc->zp1, p1, distance );
- exc->func_move( exc, &exc->zp0, p2, -distance );
+ exc->func_move( exc, &exc->zp0, p2, NEG_LONG( distance ) );
}
@@ -6598,7 +6633,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 ) )
{
@@ -6635,9 +6672,11 @@
FT_Vector vec;
- vec.x = FT_MulFix( exc->zp1.orus[exc->GS.rp2].x - orus_base->x,
+ vec.x = FT_MulFix( SUB_LONG( exc->zp1.orus[exc->GS.rp2].x,
+ orus_base->x ),
exc->metrics.x_scale );
- vec.y = FT_MulFix( exc->zp1.orus[exc->GS.rp2].y - orus_base->y,
+ vec.y = FT_MulFix( SUB_LONG( exc->zp1.orus[exc->GS.rp2].y,
+ orus_base->y ),
exc->metrics.y_scale );
old_range = FAST_DUALPROJ( &vec );
@@ -6646,7 +6685,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;
@@ -6672,9 +6711,11 @@
FT_Vector vec;
- vec.x = FT_MulFix( exc->zp2.orus[point].x - orus_base->x,
+ vec.x = FT_MulFix( SUB_LONG( exc->zp2.orus[point].x,
+ orus_base->x ),
exc->metrics.x_scale );
- vec.y = FT_MulFix( exc->zp2.orus[point].y - orus_base->y,
+ vec.y = FT_MulFix( SUB_LONG( exc->zp2.orus[point].y,
+ orus_base->y ),
exc->metrics.y_scale );
org_dist = FAST_DUALPROJ( &vec );
@@ -6713,7 +6754,7 @@
exc->func_move( exc,
&exc->zp2,
(FT_UShort)point,
- new_dist - cur_dist );
+ SUB_LONG( new_dist, cur_dist ) );
}
Fail:
@@ -6778,14 +6819,14 @@
FT_F26Dot6 dx;
- dx = worker->curs[p].x - worker->orgs[p].x;
+ dx = SUB_LONG( worker->curs[p].x, worker->orgs[p].x );
if ( dx != 0 )
{
for ( i = p1; i < p; i++ )
- worker->curs[i].x += dx;
+ worker->curs[i].x = ADD_LONG( worker->curs[i].x, dx );
for ( i = p + 1; i <= p2; i++ )
- worker->curs[i].x += dx;
+ worker->curs[i].x = ADD_LONG( worker->curs[i].x, dx );
}
}
@@ -6830,8 +6871,8 @@
org2 = worker->orgs[ref2].x;
cur1 = worker->curs[ref1].x;
cur2 = worker->curs[ref2].x;
- delta1 = cur1 - org1;
- delta2 = cur2 - org2;
+ delta1 = SUB_LONG( cur1, org1 );
+ delta2 = SUB_LONG( cur2, org2 );
if ( cur1 == cur2 || orus1 == orus2 )
{
@@ -6843,10 +6884,10 @@
if ( x <= org1 )
- x += delta1;
+ x = ADD_LONG( x, delta1 );
else if ( x >= org2 )
- x += delta2;
+ x = ADD_LONG( x, delta2 );
else
x = cur1;
@@ -6867,20 +6908,23 @@
if ( x <= org1 )
- x += delta1;
+ x = ADD_LONG( x, delta1 );
else if ( x >= org2 )
- x += delta2;
+ x = ADD_LONG( x, delta2 );
else
{
if ( !scale_valid )
{
scale_valid = 1;
- scale = FT_DivFix( cur2 - cur1, orus2 - orus1 );
+ scale = FT_DivFix( SUB_LONG( cur2, cur1 ),
+ SUB_LONG( orus2, orus1 ) );
}
- x = cur1 + FT_MulFix( worker->orus[i].x - orus1, scale );
+ x = ADD_LONG( cur1,
+ FT_MulFix( SUB_LONG( worker->orus[i].x, orus1 ),
+ scale ) );
}
worker->curs[i].x = x;
}
@@ -6910,6 +6954,23 @@
FT_Short contour; /* current contour */
+#ifdef TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL
+ /* 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->backward_compatibility )
+ {
+ if ( exc->iupx_called && exc->iupy_called )
+ return;
+
+ if ( exc->opcode & 1 )
+ exc->iupx_called = TRUE;
+ else
+ exc->iupy_called = TRUE;
+ }
+#endif
+
/* ignore empty outlines */
if ( exc->pts.n_contours == 0 )
return;
@@ -6933,15 +6994,15 @@
contour = 0;
point = 0;
-#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
- if ( SUBPIXEL_HINTING &&
- exc->ignore_x_mode )
+#ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY
+ if ( SUBPIXEL_HINTING_INFINALITY &&
+ exc->ignore_x_mode )
{
exc->iup_called = TRUE;
if ( exc->sph_tweak_flags & SPH_TWEAK_SKIP_IUP )
return;
}
-#endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */
+#endif /* TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY */
do
{
@@ -7013,37 +7074,16 @@
FT_UShort A;
FT_ULong C, P;
FT_Long B;
-#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
+#ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY
FT_UShort B1, B2;
- if ( SUBPIXEL_HINTING &&
+ if ( SUBPIXEL_HINTING_INFINALITY &&
exc->ignore_x_mode &&
exc->iup_called &&
( exc->sph_tweak_flags & SPH_TWEAK_NO_DELTAP_AFTER_IUP ) )
goto Fail;
-#endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */
-
-
-#ifdef TT_CONFIG_OPTION_UNPATENTED_HINTING
- /* Delta hinting is covered by US Patent 5159668. */
- if ( exc->face->unpatented_hinting )
- {
- FT_Long n = args[0] * 2;
-
-
- if ( exc->args < n )
- {
- if ( exc->pedantic_hinting )
- exc->error = FT_THROW( Too_Few_Arguments );
- n = exc->args;
- }
-
- exc->args -= n;
- exc->new_top = exc->args;
- return;
- }
-#endif
+#endif /* TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY */
P = (FT_ULong)exc->func_cur_ppem( exc );
nump = (FT_ULong)args[0]; /* some points theoretically may occur more
@@ -7097,9 +7137,9 @@
B++;
B *= 1L << ( 6 - exc->GS.delta_shift );
-#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
+#ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY
- if ( SUBPIXEL_HINTING )
+ if ( SUBPIXEL_HINTING_INFINALITY )
{
/*
* Allow delta move if
@@ -7152,13 +7192,29 @@
SPH_TWEAK_SKIP_NONPIXEL_Y_MOVES_DELTAP ) &&
( B1 & 63 ) != 0 &&
( B2 & 63 ) != 0 ) ) )
- exc->func_move( exc, &exc->zp0, A, -B );
+ exc->func_move( exc, &exc->zp0, A, NEG_LONG( B ) );
}
}
else
-#endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */
+#endif /* TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY */
- exc->func_move( exc, &exc->zp0, A, B );
+ {
+
+#ifdef TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL
+ /* 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 ) ||
+ ( exc->zp0.tags[A] & FT_CURVE_TAG_TOUCH_Y ) ) )
+ exc->func_move( exc, &exc->zp0, A, B );
+ }
+ else
+#endif
+ exc->func_move( exc, &exc->zp0, A, B );
+ }
}
}
else
@@ -7186,26 +7242,6 @@
FT_Long B;
-#ifdef TT_CONFIG_OPTION_UNPATENTED_HINTING
- /* Delta hinting is covered by US Patent 5159668. */
- if ( exc->face->unpatented_hinting )
- {
- FT_Long n = args[0] * 2;
-
-
- if ( exc->args < n )
- {
- if ( exc->pedantic_hinting )
- exc->error = FT_THROW( Too_Few_Arguments );
- n = exc->args;
- }
-
- exc->args -= n;
- exc->new_top = exc->args;
- return;
- }
-#endif
-
P = (FT_ULong)exc->func_cur_ppem( exc );
nump = (FT_ULong)args[0];
@@ -7294,24 +7330,25 @@
Ins_GETINFO( TT_ExecContext exc,
FT_Long* args )
{
- FT_Long K;
+ FT_Long K;
+ TT_Driver driver = (TT_Driver)FT_FACE_DRIVER( exc->face );
K = 0;
-#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
+#ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY
/********************************/
/* RASTERIZER VERSION */
/* Selector Bit: 0 */
/* Return Bit(s): 0-7 */
/* */
- if ( SUBPIXEL_HINTING &&
- ( args[0] & 1 ) != 0 &&
- exc->subpixel_hinting )
+ if ( SUBPIXEL_HINTING_INFINALITY &&
+ ( args[0] & 1 ) != 0 &&
+ exc->subpixel_hinting )
{
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",
@@ -7321,9 +7358,9 @@
K = TT_INTERPRETER_VERSION_38;
}
else
-#endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */
+#endif /* TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY */
if ( ( args[0] & 1 ) != 0 )
- K = TT_INTERPRETER_VERSION_35;
+ K = driver->interpreter_version;
/********************************/
/* GLYPH ROTATED */
@@ -7331,7 +7368,7 @@
/* Return Bit(s): 8 */
/* */
if ( ( args[0] & 2 ) != 0 && exc->tt_metrics.rotated )
- K |= 0x80;
+ K |= 1 << 8;
/********************************/
/* GLYPH STRETCHED */
@@ -7339,19 +7376,87 @@
/* 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
/********************************/
- /* HINTING FOR GRAYSCALE */
+ /* BI-LEVEL HINTING AND */
+ /* GRAYSCALE RENDERING */
/* Selector Bit: 5 */
/* Return Bit(s): 12 */
/* */
if ( ( args[0] & 32 ) != 0 && exc->grayscale )
K |= 1 << 12;
-#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
+#ifdef TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL
+ /* Toggle the following flags only outside of monochrome mode. */
+ /* Otherwise, instructions may behave weirdly and rendering results */
+ /* may differ between v35 and v40 mode, e.g., in `Times New Roman */
+ /* Bold Italic'. */
+ if ( SUBPIXEL_HINTING_MINIMAL && exc->subpixel_hinting_lean )
+ {
+ /********************************/
+ /* HINTING FOR SUBPIXEL */
+ /* Selector Bit: 6 */
+ /* Return Bit(s): 13 */
+ /* */
+ /* v40 does subpixel hinting by default. */
+ if ( ( args[0] & 64 ) != 0 )
+ K |= 1 << 13;
+
+ /********************************/
+ /* VERTICAL LCD SUBPIXELS? */
+ /* Selector Bit: 8 */
+ /* Return Bit(s): 15 */
+ /* */
+ if ( ( args[0] & 256 ) != 0 && exc->vertical_lcd_lean )
+ K |= 1 << 15;
+
+ /********************************/
+ /* SUBPIXEL POSITIONED? */
+ /* Selector Bit: 10 */
+ /* Return Bit(s): 17 */
+ /* */
+ /* XXX: FreeType supports it, dependent on what client does? */
+ if ( ( args[0] & 1024 ) != 0 )
+ K |= 1 << 17;
+
+ /********************************/
+ /* SYMMETRICAL SMOOTHING */
+ /* Selector Bit: 11 */
+ /* Return Bit(s): 18 */
+ /* */
+ /* The only smoothing method FreeType supports unless someone sets */
+ /* FT_LOAD_TARGET_MONO. */
+ if ( ( args[0] & 2048 ) != 0 && exc->subpixel_hinting_lean )
+ K |= 1 << 18;
+
+ /********************************/
+ /* CLEARTYPE HINTING AND */
+ /* GRAYSCALE RENDERING */
+ /* Selector Bit: 12 */
+ /* Return Bit(s): 19 */
+ /* */
+ /* Grayscale rendering is what FreeType does anyway unless someone */
+ /* sets FT_LOAD_TARGET_MONO or FT_LOAD_TARGET_LCD(_V) */
+ if ( ( args[0] & 4096 ) != 0 && exc->grayscale_cleartype )
+ K |= 1 << 19;
+ }
+#endif
- if ( SUBPIXEL_HINTING &&
+#ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY
+
+ if ( SUBPIXEL_HINTING_INFINALITY &&
exc->rasterizer_version >= TT_INTERPRETER_VERSION_35 )
{
@@ -7424,12 +7529,71 @@
}
}
-#endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */
+#endif /* TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY */
args[0] = K;
}
+#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;
+ }
+
+ if ( coords )
+ {
+ for ( i = 0; i < num_axes; i++ )
+ args[i] = coords[i] >> 2; /* convert 16.16 to 2.14 format */
+ }
+ else
+ {
+ for ( i = 0; i < num_axes; i++ )
+ args[i] = 0;
+ }
+ }
+
+
+ /*************************************************************************/
+ /* */
+ /* 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 )
{
@@ -7503,10 +7667,11 @@
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_CONFIG_OPTION_SUBPIXEL_HINTING
+#ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY
FT_Byte opcode_pattern[1][2] = {
/* #8 TypeMan Talk Align */
{
@@ -7517,12 +7682,88 @@
FT_UShort opcode_patterns = 1;
FT_UShort opcode_pointer[1] = { 0 };
FT_UShort opcode_size[1] = { 1 };
-#endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */
+#endif /* TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY */
-#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
+#ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY
exc->iup_called = FALSE;
-#endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */
+#endif /* TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY */
+
+#ifdef TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL
+ /*
+ * Toggle backward compatibility according to what font wants, except
+ * when
+ *
+ * 1) we have a `tricky' font that heavily relies on the interpreter to
+ * render glyphs correctly, for example DFKai-SB, or
+ * 2) FT_RENDER_MODE_MONO (i.e, monochome rendering) is requested.
+ *
+ * In those cases, backward compatibility needs to be turned off to get
+ * correct rendering. The rendering is then completely up to the
+ * font's programming.
+ *
+ */
+ if ( SUBPIXEL_HINTING_MINIMAL &&
+ exc->subpixel_hinting_lean &&
+ !FT_IS_TRICKY( &exc->face->root ) )
+ exc->backward_compatibility = !( exc->GS.instruct_control & 4 );
+ else
+ 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 = 300 + 8 * 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;
@@ -7565,7 +7806,7 @@
? 2
: 12 - ( *opcode_name[exc->opcode] - '0' ),
"#" ));
- for ( n = 0; n < cnt; n++ )
+ for ( n = 1; n <= cnt; n++ )
FT_TRACE7(( " %d", exc->stack[exc->top - n] ));
FT_TRACE6(( "\n" ));
}
@@ -7601,7 +7842,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' */
@@ -7615,9 +7870,9 @@
exc->step_ins = TRUE;
exc->error = FT_Err_Ok;
-#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
+#ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY
- if ( SUBPIXEL_HINTING )
+ if ( SUBPIXEL_HINTING_INFINALITY )
{
for ( i = 0; i < opcode_patterns; i++ )
{
@@ -7646,7 +7901,7 @@
}
}
-#endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */
+#endif /* TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY */
{
FT_Long* args = exc->stack + exc->args;
@@ -7794,7 +8049,7 @@
Ins_ALIGNPTS( exc, args );
break;
- case 0x28: /* ???? */
+ case 0x28: /* RAW */
Ins_UNKNOWN( exc );
break;
@@ -8146,10 +8401,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 );
@@ -8230,7 +8508,7 @@
/* increment instruction counter and check if we didn't */
/* run this program for too long (e.g. infinite loops). */
- if ( ++ins_counter > MAX_RUNNABLE_OPCODES )
+ if ( ++ins_counter > TT_CONFIG_OPTION_MAX_RUNNABLE_OPCODES )
return FT_THROW( Execution_Too_Long );
LSuiteLabel_:
@@ -8247,29 +8525,27 @@
} while ( !exc->instruction_trap );
LNo_Error_:
+ FT_TRACE4(( " %d instruction%s executed\n",
+ ins_counter,
+ ins_counter == 1 ? "" : "s" ));
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/src/3rdparty/freetype/src/truetype/ttinterp.h b/src/3rdparty/freetype/src/truetype/ttinterp.h
index 32706d0760..2966439ea2 100644
--- a/src/3rdparty/freetype/src/truetype/ttinterp.h
+++ b/src/3rdparty/freetype/src/truetype/ttinterp.h
@@ -4,7 +4,7 @@
/* */
/* TrueType bytecode interpreter (specification). */
/* */
-/* Copyright 1996-2015 by */
+/* Copyright 1996-2018 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -16,8 +16,8 @@
/***************************************************************************/
-#ifndef __TTINTERP_H__
-#define __TTINTERP_H__
+#ifndef TTINTERP_H_
+#define TTINTERP_H_
#include <ft2build.h>
#include "ttobjs.h"
@@ -99,7 +99,7 @@ FT_BEGIN_HEADER
} TT_CallRec, *TT_CallStack;
-#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
+#ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY
/*************************************************************************/
/* */
@@ -138,7 +138,7 @@ FT_BEGIN_HEADER
} SPH_Font_Class;
-#endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */
+#endif /* TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY */
/*************************************************************************/
@@ -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 */
@@ -247,9 +248,151 @@ FT_BEGIN_HEADER
TT_Set_CVT_Func func_write_cvt; /* write a cvt entry (in pixels) */
TT_Set_CVT_Func func_move_cvt; /* incr a cvt entry (in pixels) */
- FT_Bool grayscale; /* are we hinting for grayscale? */
-
-#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
+ FT_Bool grayscale; /* bi-level hinting and */
+ /* grayscale rendering */
+
+#ifdef TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL
+ /*
+ * FreeType supports ClearType-like hinting of TrueType fonts through
+ * the version 40 interpreter. This is achieved through several hacks
+ * in the base (v35) interpreter, as detailed below.
+ *
+ * ClearType is an umbrella term for several rendering techniques
+ * employed by Microsoft's various GUI and rendering toolkit
+ * implementations, most importantly: subpixel rendering for using the
+ * RGB subpixels of LCDs to approximately triple the perceived
+ * resolution on the x-axis and subpixel hinting for positioning stems
+ * on subpixel borders. TrueType programming is explicit, i.e., fonts
+ * must be programmed to take advantage of ClearType's possibilities.
+ *
+ * When ClearType was introduced, it seemed unlikely that all fonts
+ * would be reprogrammed, so Microsoft decided to implement a backward
+ * compatibility mode. It employs several simple to complicated
+ * assumptions and tricks, many of them font-dependent, that modify the
+ * interpretation of the bytecode contained in these fonts to retrofit
+ * them into a ClearType-y look. The quality of the results varies.
+ * Most (web)fonts that were released since then have come to rely on
+ * these hacks to render correctly, even some of Microsoft's flagship
+ * fonts (e.g., Calibri, Cambria, Segoe UI).
+ *
+ * FreeType's minimal subpixel hinting code (interpreter version 40)
+ * employs a small list of font-agnostic hacks loosely based on the
+ * public information available on Microsoft's compatibility mode[2].
+ * The focus is on modern (web)fonts rather than legacy fonts that were
+ * made for monochrome rendering. It will not match ClearType rendering
+ * exactly. Unlike the `Infinality' code (interpreter version 38) that
+ * came before, it will not try to toggle hacks for specific fonts for
+ * performance and complexity reasons. It will fall back to version 35
+ * behavior for tricky fonts[1] or when monochrome rendering is
+ * requested.
+ *
+ * Major hacks
+ *
+ * - Any point movement on the x axis is ignored (cf. `Direct_Move' and
+ * `Direct_Move_X'). This has the smallest code footprint and single
+ * biggest effect. The ClearType way to increase resolution is
+ * supersampling the x axis, the FreeType way is ignoring instructions
+ * on the x axis, which gives the same result in the majority of
+ * cases.
+ *
+ * - Points are not moved post-IUP (neither on the x nor on the y axis),
+ * except the x component of diagonal moves post-IUP (cf.
+ * `Direct_Move', `Direct_Move_Y', `Move_Zp2_Point'). Post-IUP
+ * changes are commonly used to `fix' pixel patterns which has little
+ * use outside monochrome rendering.
+ *
+ * - SHPIX and DELTAP don't execute unless moving a composite on the
+ * y axis or moving a previously y touched point. SHPIX additionally
+ * denies movement on the x axis (cf. `Ins_SHPIX' and `Ins_DELTAP').
+ * Both instructions are commonly used to `fix' pixel patterns for
+ * monochrome or Windows's GDI rendering but make little sense for
+ * FreeType rendering. Both can distort the outline. See [2] for
+ * details.
+ *
+ * - The hdmx table and modifications to phantom points are ignored.
+ * Bearings and advance widths remain unchanged (except rounding them
+ * outside the interpreter!), cf. `compute_glyph_metrics' and
+ * `TT_Hint_Glyph'. Letting non-native-ClearType fonts modify spacing
+ * might mess up spacing.
+ *
+ * Minor hacks
+ *
+ * - FLIPRGON, FLIPRGOFF, and FLIPPT don't execute post-IUP. This
+ * prevents dents in e.g. Arial-Regular's `D' and `G' glyphs at
+ * various sizes.
+ *
+ * (Post-IUP is the state after both IUP[x] and IUP[y] have been
+ * executed.)
+ *
+ * The best results are achieved for fonts that were from the outset
+ * designed with ClearType in mind, meaning they leave the x axis mostly
+ * alone and don't mess with the `final' outline to produce more
+ * pleasing pixel patterns. The harder the designer tried to produce
+ * very specific patterns (`superhinting') for pre-ClearType-displays,
+ * the worse the results.
+ *
+ * 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 backward compatibility by default, which can be
+ * turned off the same way by executing the following in the control
+ * program (cf. `Ins_INSTCTRL').
+ *
+ * #PUSH 4,3
+ * INSTCTRL[]
+ *
+ * [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
+ * backward compatibility turned off). Cf. `TT_RunIns'.
+ *
+ * [2] Proposed by Microsoft's Greg Hitchcock in
+ * https://www.microsoft.com/typography/cleartype/truetypecleartype.aspx
+ *
+ * [3] Beat Stamm describes it in more detail:
+ * http://www.beatstamm.com/typography/RTRCh4.htm#Sec12
+ *
+ * [4] The list of `native ClearType' fonts is small at the time of this
+ * writing; I found the following on a Windows 10 Update 1511
+ * installation: Constantia, Corbel, Sitka, Malgun Gothic, Microsoft
+ * JhengHei (Bold and UI Bold), Microsoft YaHei (Bold and UI Bold),
+ * SimSun, NSimSun, and Yu Gothic.
+ *
+ */
+
+ /* Using v40 implies subpixel hinting, unless FT_RENDER_MODE_MONO has been
+ * requested. Used to detect interpreter */
+ /* version switches. `_lean' to differentiate from the Infinality */
+ /* `subpixel_hinting', which is managed differently. */
+ FT_Bool subpixel_hinting_lean;
+
+ /* Long side of a LCD subpixel is vertical (e.g., screen is rotated). */
+ /* `_lean' to differentiate from the Infinality `vertical_lcd', which */
+ /* is managed differently. */
+ FT_Bool vertical_lcd_lean;
+
+ /* 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 backward_compatibility;
+
+ /* Useful for detecting and denying post-IUP trickery that is usually */
+ /* used to fix pixel patterns (`superhinting'). */
+ FT_Bool iupx_called;
+ FT_Bool iupy_called;
+
+ /* ClearType hinting and grayscale rendering, as used by Universal */
+ /* Windows Platform apps (Windows 8 and above). Like the standard */
+ /* colorful ClearType mode, it utilizes a vastly increased virtual */
+ /* resolution on the x axis. Different from bi-level hinting and */
+ /* grayscale rendering, the old mode from Win9x days that roughly */
+ /* adheres to the physical pixel grid on both axes. */
+ FT_Bool grayscale_cleartype;
+#endif /* TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL */
+
+#ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY
TT_Round_Func func_round_sphn; /* subpixel rounding function */
FT_Bool subpixel_hinting; /* Using subpixel hinting? */
@@ -279,7 +422,15 @@ FT_BEGIN_HEADER
FT_ULong sph_in_func_flags; /* flags to indicate if in */
/* special functions */
-#endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */
+#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;
@@ -382,7 +533,7 @@ FT_BEGIN_HEADER
FT_END_HEADER
-#endif /* __TTINTERP_H__ */
+#endif /* TTINTERP_H_ */
/* END */
diff --git a/src/3rdparty/freetype/src/truetype/ttobjs.c b/src/3rdparty/freetype/src/truetype/ttobjs.c
index 6060d6f5d1..6685dc8196 100644
--- a/src/3rdparty/freetype/src/truetype/ttobjs.c
+++ b/src/3rdparty/freetype/src/truetype/ttobjs.c
@@ -4,7 +4,7 @@
/* */
/* Objects manager (body). */
/* */
-/* Copyright 1996-2015 by */
+/* Copyright 1996-2018 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -21,7 +21,7 @@
#include FT_INTERNAL_STREAM_H
#include FT_TRUETYPE_TAGS_H
#include FT_INTERNAL_SFNT_H
-#include FT_TRUETYPE_DRIVER_H
+#include FT_DRIVER_H
#include "ttgload.h"
#include "ttpload.h"
@@ -32,10 +32,6 @@
#include "ttinterp.h"
#endif
-#ifdef TT_CONFIG_OPTION_UNPATENTED_HINTING
-#include FT_TRUETYPE_UNPATENTED_H
-#endif
-
#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
#include "ttgxvar.h"
#endif
@@ -121,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 ) ||
@@ -151,20 +147,51 @@
{
#define TRICK_NAMES_MAX_CHARACTERS 19
-#define TRICK_NAMES_COUNT 9
+#define TRICK_NAMES_COUNT 26
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 */
+ "DFGothic-EB", /* DynaLab Inc. 1992-1995 */
+ "DFGyoSho-Lt", /* DynaLab Inc. 1992-1995 */
+ "DFHei-Md-HK-BF", /* maybe DynaLab Inc. */
+ "DFHSGothic-W5", /* DynaLab Inc. 1992-1995 */
+ "DFHSMincho-W3", /* DynaLab Inc. 1992-1995 */
+ "DFHSMincho-W7", /* DynaLab Inc. 1992-1995 */
"DFKaiSho-SB", /* dfkaisb.ttf */
"DFKaiShu",
- "DFKai-SB", /* kaiu.ttf */
+ "DFKaiShu-Md-HK-BF", /* maybe DynaLab Inc. */
+ "DFKai-SB", /* kaiu.ttf; version 3.00, 1998 [DFKaiShu-SB-Estd-BF] */
+ "DFMing-Bd-HK-BF", /* maybe DynaLab Inc. */
+ "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;
@@ -246,7 +273,7 @@
tt_check_trickyness_sfnt_ids( TT_Face face )
{
#define TRICK_SFNT_IDS_PER_FACE 3
-#define TRICK_SFNT_IDS_NUM_FACES 17
+#define TRICK_SFNT_IDS_NUM_FACES 29
static const tt_sfnt_id_rec sfnt_id[TRICK_SFNT_IDS_NUM_FACES]
[TRICK_SFNT_IDS_PER_FACE] = {
@@ -265,11 +292,66 @@
{ 0x28233BF1UL, 0x000087C4UL }, /* fpgm */
{ 0xA344A1EBUL, 0x000001E1UL } /* prep */
},
+ { /* DFGothic-EB */
+ { 0x12C3EBB2UL, 0x00000350UL }, /* cvt */
+ { 0xB680EE64UL, 0x000087A7UL }, /* fpgm */
+ { 0xCE939563UL, 0x00000758UL } /* prep */
+ },
+ { /* DFGyoSho-Lt */
+ { 0x11E5EAD4UL, 0x00000350UL }, /* cvt */
+ { 0xCE5956E9UL, 0x0000BC85UL }, /* fpgm */
+ { 0x8272F416UL, 0x00000045UL } /* prep */
+ },
+ { /* DFHei-Md-HK-BF */
+ { 0x1257EB46UL, 0x00000350UL }, /* cvt */
+ { 0xF699D160UL, 0x0000715FUL }, /* fpgm */
+ { 0xD222F568UL, 0x000003BCUL } /* prep */
+ },
+ { /* DFHSGothic-W5 */
+ { 0x1262EB4EUL, 0x00000350UL }, /* cvt */
+ { 0xE86A5D64UL, 0x00007940UL }, /* fpgm */
+ { 0x7850F729UL, 0x000005FFUL } /* prep */
+ },
+ { /* DFHSMincho-W3 */
+ { 0x122DEB0AUL, 0x00000350UL }, /* cvt */
+ { 0x3D16328AUL, 0x0000859BUL }, /* fpgm */
+ { 0xA93FC33BUL, 0x000002CBUL } /* prep */
+ },
+ { /* DFHSMincho-W7 */
+ { 0x125FEB26UL, 0x00000350UL }, /* cvt */
+ { 0xA5ACC982UL, 0x00007EE1UL }, /* fpgm */
+ { 0x90999196UL, 0x0000041FUL } /* prep */
+ },
{ /* DFKaiShu */
{ 0x11E5EAD4UL, 0x00000350UL }, /* cvt */
{ 0x5A30CA3BUL, 0x00009063UL }, /* fpgm */
{ 0x13A42602UL, 0x0000007EUL } /* prep */
},
+ { /* DFKaiShu, variant */
+ { 0x11E5EAD4UL, 0x00000350UL }, /* cvt */
+ { 0xA6E78C01UL, 0x00008998UL }, /* fpgm */
+ { 0x13A42602UL, 0x0000007EUL } /* prep */
+ },
+ { /* DFKaiShu-Md-HK-BF */
+ { 0x11E5EAD4UL, 0x00000360UL }, /* cvt */
+ { 0x9DB282B2UL, 0x0000C06EUL }, /* fpgm */
+ { 0x53E6D7CAUL, 0x00000082UL } /* prep */
+ },
+ { /* DFMing-Bd-HK-BF */
+ { 0x1243EB18UL, 0x00000350UL }, /* cvt */
+ { 0xBA0A8C30UL, 0x000074ADUL }, /* fpgm */
+ { 0xF3D83409UL, 0x0000037BUL } /* prep */
+ },
+ { /* DLCLiShu */
+ { 0x07DCF546UL, 0x00000308UL }, /* cvt */
+ { 0x40FE7C90UL, 0x00008E2AUL }, /* fpgm */
+ { 0x608174B5UL, 0x0000007AUL } /* prep */
+ },
+ { /* DLCHayBold */
+ { 0xEB891238UL, 0x00000308UL }, /* cvt */
+ { 0xD2E4DCD4UL, 0x0000676FUL }, /* fpgm */
+ { 0x8EA5F293UL, 0x000003B8UL } /* prep */
+ },
{ /* HuaTianKaiTi */
{ 0xFFFBFFFCUL, 0x00000008UL }, /* cvt */
{ 0x9C9E48B8UL, 0x0000BEA2UL }, /* fpgm */
@@ -339,6 +421,11 @@
{ 0x00000000UL, 0x00000000UL }, /* cvt */
{ 0xF055FC48UL, 0x000001C2UL }, /* fpgm */
{ 0x3900DED3UL, 0x00001E18UL } /* prep */
+ },
+ { /* MINGLI.TTF, 1992 */
+ { 0x00170003UL, 0x00000060UL }, /* cvt */
+ { 0xDBB4306EUL, 0x000058AAUL }, /* fpgm */
+ { 0xD643482AUL, 0x00000035UL } /* prep */
}
};
@@ -397,11 +484,11 @@
for ( j = 0; j < TRICK_SFNT_IDS_NUM_FACES; j++ )
{
if ( !has_cvt && !sfnt_id[j][TRICK_SFNT_ID_cvt].Length )
- num_matched_ids[j] ++;
+ num_matched_ids[j]++;
if ( !has_fpgm && !sfnt_id[j][TRICK_SFNT_ID_fpgm].Length )
- num_matched_ids[j] ++;
+ num_matched_ids[j]++;
if ( !has_prep && !sfnt_id[j][TRICK_SFNT_ID_prep].Length )
- num_matched_ids[j] ++;
+ num_matched_ids[j]++;
if ( num_matched_ids[j] == TRICK_SFNT_IDS_PER_FACE )
return TRUE;
}
@@ -535,6 +622,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. */
@@ -546,9 +634,11 @@
/* We must also be able to accept Mac/GX fonts, as well as OT ones. */
/* The 0x00020000 tag is completely undocumented; some fonts from */
/* Arphic made for Chinese Windows 3.1 have this. */
- if ( face->format_tag != 0x00010000L && /* MS fonts */
- face->format_tag != 0x00020000L && /* CJK fonts for Win 3.1 */
- face->format_tag != TTAG_true ) /* Mac fonts */
+ if ( face->format_tag != 0x00010000L && /* MS fonts */
+ face->format_tag != 0x00020000L && /* CJK fonts for Win 3.1 */
+ face->format_tag != TTAG_true && /* Mac fonts */
+ face->format_tag != TTAG_0xA5kbd && /* `Keyboard.dfont' (legacy Mac OS X) */
+ face->format_tag != TTAG_0xA5lst ) /* `LastResort.dfont' (legacy Mac OS X) */
{
FT_TRACE2(( " not a TTF font\n" ));
goto Bad_Format;
@@ -576,129 +666,71 @@
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
{
- FT_Int instance_index = face_index >> 16;
+ FT_UInt instance_index = (FT_UInt)face_index >> 16;
if ( FT_HAS_MULTIPLE_MASTERS( ttface ) &&
instance_index > 0 )
{
- error = TT_Get_MM_Var( face, NULL );
+ error = TT_Set_Named_Instance( face, instance_index );
if ( error )
goto Exit;
- if ( face->blend->mmvar->namedstyle )
- {
- FT_Memory memory = ttface->memory;
-
- FT_Var_Named_Style* named_style;
- FT_String* style_name;
-
-
- /* in `face_index', the instance index starts with value 1 */
- named_style = face->blend->mmvar->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 = TT_Set_Var_Design( face,
- face->blend->mmvar->num_axis,
- named_style->coords );
- if ( error )
- goto Exit;
- }
+ tt_apply_mvar( face );
}
}
#endif /* TT_CONFIG_OPTION_GX_VAR_SUPPORT */
-#if defined( TT_CONFIG_OPTION_UNPATENTED_HINTING ) && \
- !defined( TT_CONFIG_OPTION_BYTECODE_INTERPRETER )
-
- {
- FT_Bool unpatented_hinting;
- int i;
-
-
- /* Determine whether unpatented hinting is to be used for this face. */
- unpatented_hinting = FT_BOOL
- ( library->debug_hooks[FT_DEBUG_HOOK_UNPATENTED_HINTING] != NULL );
-
- for ( i = 0; i < num_params && !face->unpatented_hinting; i++ )
- if ( params[i].tag == FT_PARAM_TAG_UNPATENTED_HINTING )
- unpatented_hinting = TRUE;
-
- if ( !unpatented_hinting )
- ttface->internal->ignore_unpatented_hinter = TRUE;
- }
-
-#endif /* TT_CONFIG_OPTION_UNPATENTED_HINTING &&
- !TT_CONFIG_OPTION_BYTECODE_INTERPRETER */
-
/* initialize standard glyph loading routines */
TT_Init_Glyph_Loading( face );
@@ -761,7 +793,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
}
@@ -819,14 +851,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;
@@ -849,6 +881,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;
@@ -912,8 +949,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;
@@ -1032,17 +1073,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 */
@@ -1078,7 +1119,15 @@
}
/* Fine, now run the font program! */
+
+ /* In case of an error while executing `fpgm', we intentionally don't */
+ /* clean up immediately – bugs in the `fpgm' are so fundamental that */
+ /* all following hinting calls should fail. Additionally, `fpgm' is */
+ /* to be executed just once; calling it again is completely useless */
+ /* and might even lead to extremely slow behaviour if it is malformed */
+ /* (containing an infinite loop, for example). */
error = tt_size_run_fpgm( size, pedantic );
+ return error;
Exit:
if ( error )
@@ -1097,8 +1146,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 */
@@ -1130,6 +1181,8 @@
error = tt_size_run_prep( size, pedantic );
}
+ else
+ error = size->cvt_ready;
Exit:
return error;
@@ -1206,26 +1259,34 @@
/* 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; */
+ /* this flag is used for variation fonts where */
+ /* `tt_size_reset' is used as an iterator function. */
/* */
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 */
@@ -1234,48 +1295,66 @@
/* */
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 )
+ {
+ /* we must not recompute the scaling values here since */
+ /* `tt_size_reset' was already called (with only_height = 0) */
+ 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;
}
@@ -1301,10 +1380,12 @@
TT_Driver driver = (TT_Driver)ttdriver;
-#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
- driver->interpreter_version = TT_INTERPRETER_VERSION_38;
-#else
driver->interpreter_version = TT_INTERPRETER_VERSION_35;
+#ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY
+ driver->interpreter_version = TT_INTERPRETER_VERSION_38;
+#endif
+#ifdef TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL
+ driver->interpreter_version = TT_INTERPRETER_VERSION_40;
#endif
#else /* !TT_USE_BYTECODE_INTERPRETER */
diff --git a/src/3rdparty/freetype/src/truetype/ttobjs.h b/src/3rdparty/freetype/src/truetype/ttobjs.h
index 9396089a99..38fa30e4e9 100644
--- a/src/3rdparty/freetype/src/truetype/ttobjs.h
+++ b/src/3rdparty/freetype/src/truetype/ttobjs.h
@@ -4,7 +4,7 @@
/* */
/* Objects manager (specification). */
/* */
-/* Copyright 1996-2015 by */
+/* Copyright 1996-2018 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -16,8 +16,8 @@
/***************************************************************************/
-#ifndef __TTOBJS_H__
-#define __TTOBJS_H__
+#ifndef TTOBJS_H_
+#define TTOBJS_H_
#include <ft2build.h>
@@ -72,10 +72,6 @@ FT_BEGIN_HEADER
FT_UnitVector projVector;
FT_UnitVector freeVector;
-#ifdef TT_CONFIG_OPTION_UNPATENTED_HINTING
- FT_Bool both_x_axis;
-#endif
-
FT_Long loop;
FT_F26Dot6 minimum_distance;
FT_Int round_state;
@@ -282,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;
@@ -290,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 */
@@ -391,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 );
/*************************************************************************/
@@ -419,7 +419,7 @@ FT_BEGIN_HEADER
FT_END_HEADER
-#endif /* __TTOBJS_H__ */
+#endif /* TTOBJS_H_ */
/* END */
diff --git a/src/3rdparty/freetype/src/truetype/ttpic.c b/src/3rdparty/freetype/src/truetype/ttpic.c
index 242a6b76dd..cdbb80639e 100644
--- a/src/3rdparty/freetype/src/truetype/ttpic.c
+++ b/src/3rdparty/freetype/src/truetype/ttpic.c
@@ -4,7 +4,7 @@
/* */
/* The FreeType position independent code services for truetype module. */
/* */
-/* Copyright 2009-2015 by */
+/* Copyright 2009-2018 by */
/* Oran Agra and Mickey Gabel. */
/* */
/* This file is part of the FreeType project, and may only be used, */
diff --git a/src/3rdparty/freetype/src/truetype/ttpic.h b/src/3rdparty/freetype/src/truetype/ttpic.h
index 076ae56efa..df878ae6f1 100644
--- a/src/3rdparty/freetype/src/truetype/ttpic.h
+++ b/src/3rdparty/freetype/src/truetype/ttpic.h
@@ -4,7 +4,7 @@
/* */
/* The FreeType position independent code services for truetype module. */
/* */
-/* Copyright 2009-2015 by */
+/* Copyright 2009-2018 by */
/* Oran Agra and Mickey Gabel. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -16,8 +16,8 @@
/***************************************************************************/
-#ifndef __TTPIC_H__
-#define __TTPIC_H__
+#ifndef TTPIC_H_
+#define TTPIC_H_
#include FT_INTERNAL_PIC_H
@@ -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 \
@@ -77,7 +82,7 @@ FT_END_HEADER
/* */
-#endif /* __TTPIC_H__ */
+#endif /* TTPIC_H_ */
/* END */
diff --git a/src/3rdparty/freetype/src/truetype/ttpload.c b/src/3rdparty/freetype/src/truetype/ttpload.c
index 4647c938ae..d9526ad082 100644
--- a/src/3rdparty/freetype/src/truetype/ttpload.c
+++ b/src/3rdparty/freetype/src/truetype/ttpload.c
@@ -4,7 +4,7 @@
/* */
/* TrueType-specific tables loader (body). */
/* */
-/* Copyright 1996-2015 by */
+/* Copyright 1996-2018 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;
}
@@ -124,8 +134,9 @@
TT_Table entry = face->dir_tables;
TT_Table limit = entry + face->num_tables;
- FT_Long pos = (FT_Long)FT_STREAM_POS();
- FT_Long dist = 0x7FFFFFFFL;
+ FT_Long pos = (FT_Long)FT_STREAM_POS();
+ FT_Long dist = 0x7FFFFFFFL;
+ FT_Bool found = 0;
/* compute the distance to next table in font file */
@@ -135,10 +146,13 @@
if ( diff > 0 && diff < dist )
- dist = diff;
+ {
+ dist = diff;
+ found = 1;
+ }
}
- if ( entry == limit )
+ if ( !found )
{
/* `loca' is the last table */
dist = (FT_Long)stream->size - pos;
@@ -218,12 +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,"
- " exceeding the end of glyf table (0x%08lx)\n",
+ " too large offset (0x%08lx) found for glyph index %ld,\n"
+ " "
+ " exceeding the end of `glyf' table (0x%08lx)\n",
pos1, gindex, face->glyf_len ));
*asize = 0;
return 0;
@@ -231,11 +246,26 @@
if ( pos2 > face->glyf_len )
{
- FT_TRACE1(( "tt_face_get_location:"
- " too large offset=0x%08lx found for gid=0x%04lx,"
- " 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 - 2 )
+ {
+ FT_TRACE1(( "tt_face_get_location:"
+ " too large size (%ld bytes) found for glyph index %ld,\n"
+ " "
+ " truncating at the end of `glyf' table to %ld bytes\n",
+ pos2 - pos1, gindex, face->glyf_len - pos1 ));
+ 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 */
@@ -494,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;
@@ -511,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 );
@@ -530,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/src/3rdparty/freetype/src/truetype/ttpload.h b/src/3rdparty/freetype/src/truetype/ttpload.h
index bc92369827..fa12527247 100644
--- a/src/3rdparty/freetype/src/truetype/ttpload.h
+++ b/src/3rdparty/freetype/src/truetype/ttpload.h
@@ -4,7 +4,7 @@
/* */
/* TrueType-specific tables loader (specification). */
/* */
-/* Copyright 1996-2015 by */
+/* Copyright 1996-2018 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -16,8 +16,8 @@
/***************************************************************************/
-#ifndef __TTPLOAD_H__
-#define __TTPLOAD_H__
+#ifndef TTPLOAD_H_
+#define TTPLOAD_H_
#include <ft2build.h>
@@ -69,7 +69,7 @@ FT_BEGIN_HEADER
FT_END_HEADER
-#endif /* __TTPLOAD_H__ */
+#endif /* TTPLOAD_H_ */
/* END */
diff --git a/src/3rdparty/freetype/src/truetype/ttsubpix.c b/src/3rdparty/freetype/src/truetype/ttsubpix.c
index 0d391e95a0..d94bcc8b50 100644
--- a/src/3rdparty/freetype/src/truetype/ttsubpix.c
+++ b/src/3rdparty/freetype/src/truetype/ttsubpix.c
@@ -4,7 +4,7 @@
/* */
/* TrueType Subpixel Hinting. */
/* */
-/* Copyright 2010-2015 by */
+/* Copyright 2010-2018 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -22,12 +22,13 @@
#include FT_INTERNAL_SFNT_H
#include FT_TRUETYPE_TAGS_H
#include FT_OUTLINE_H
-#include FT_TRUETYPE_DRIVER_H
+#include FT_DRIVER_H
#include "ttsubpix.h"
-#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
+#if defined( TT_USE_BYTECODE_INTERPRETER ) && \
+ defined( TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY )
/*************************************************************************/
/* */
@@ -752,24 +753,24 @@
/* Does font name match rule family? */
- if ( strcmp( detected_font_name, rule_font_name ) == 0 )
+ if ( ft_strcmp( detected_font_name, rule_font_name ) == 0 )
return TRUE;
/* Is font name a wildcard ""? */
- if ( strcmp( rule_font_name, "" ) == 0 )
+ if ( ft_strcmp( rule_font_name, "" ) == 0 )
return TRUE;
/* Is font name contained in a class list? */
for ( i = 0; i < FAMILY_CLASS_RULES_SIZE; i++ )
{
- if ( strcmp( FAMILY_CLASS_Rules[i].name, rule_font_name ) == 0 )
+ if ( ft_strcmp( FAMILY_CLASS_Rules[i].name, rule_font_name ) == 0 )
{
for ( j = 0; j < SPH_MAX_CLASS_MEMBERS; j++ )
{
- if ( strcmp( FAMILY_CLASS_Rules[i].member[j], "" ) == 0 )
+ if ( ft_strcmp( FAMILY_CLASS_Rules[i].member[j], "" ) == 0 )
continue;
- if ( strcmp( FAMILY_CLASS_Rules[i].member[j],
- detected_font_name ) == 0 )
+ if ( ft_strcmp( FAMILY_CLASS_Rules[i].member[j],
+ detected_font_name ) == 0 )
return TRUE;
}
}
@@ -787,24 +788,24 @@
/* Does font style match rule style? */
- if ( strcmp( detected_font_style, rule_font_style ) == 0 )
+ if ( ft_strcmp( detected_font_style, rule_font_style ) == 0 )
return TRUE;
/* Is font style a wildcard ""? */
- if ( strcmp( rule_font_style, "" ) == 0 )
+ if ( ft_strcmp( rule_font_style, "" ) == 0 )
return TRUE;
/* Is font style contained in a class list? */
for ( i = 0; i < STYLE_CLASS_RULES_SIZE; i++ )
{
- if ( strcmp( STYLE_CLASS_Rules[i].name, rule_font_style ) == 0 )
+ if ( ft_strcmp( STYLE_CLASS_Rules[i].name, rule_font_style ) == 0 )
{
for ( j = 0; j < SPH_MAX_CLASS_MEMBERS; j++ )
{
- if ( strcmp( STYLE_CLASS_Rules[i].member[j], "" ) == 0 )
+ if ( ft_strcmp( STYLE_CLASS_Rules[i].member[j], "" ) == 0 )
continue;
- if ( strcmp( STYLE_CLASS_Rules[i].member[j],
- detected_font_style ) == 0 )
+ if ( ft_strcmp( STYLE_CLASS_Rules[i].member[j],
+ detected_font_style ) == 0 )
return TRUE;
}
}
@@ -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_CONFIG_OPTION_SUBPIXEL_HINTING */
+#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_CONFIG_OPTION_SUBPIXEL_HINTING */
+#endif /* !(TT_USE_BYTECODE_INTERPRETER && */
+ /* TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY) */
/* END */
diff --git a/src/3rdparty/freetype/src/truetype/ttsubpix.h b/src/3rdparty/freetype/src/truetype/ttsubpix.h
index 9151aa3250..1070bb016f 100644
--- a/src/3rdparty/freetype/src/truetype/ttsubpix.h
+++ b/src/3rdparty/freetype/src/truetype/ttsubpix.h
@@ -4,7 +4,7 @@
/* */
/* TrueType Subpixel Hinting. */
/* */
-/* Copyright 2010-2015 by */
+/* Copyright 2010-2018 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -16,8 +16,8 @@
/***************************************************************************/
-#ifndef __TTSUBPIX_H__
-#define __TTSUBPIX_H__
+#ifndef TTSUBPIX_H_
+#define TTSUBPIX_H_
#include <ft2build.h>
#include "ttobjs.h"
@@ -27,7 +27,7 @@
FT_BEGIN_HEADER
-#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
+#ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY
/*************************************************************************/
/* */
@@ -100,11 +100,12 @@ FT_BEGIN_HEADER
#define SPH_OPTION_SET_COMPATIBLE_WIDTHS FALSE
#define SPH_OPTION_SET_RASTERIZER_VERSION 38
-#endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */
+#endif /* TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY */
FT_END_HEADER
-#endif /* __TTSUBPIX_H__ */
+#endif /* TTSUBPIX_H_ */
+
/* END */
diff --git a/src/3rdparty/freetype/src/type1/Jamfile b/src/3rdparty/freetype/src/type1/Jamfile
index d1a3af57e9..b94b7d0aae 100644
--- a/src/3rdparty/freetype/src/type1/Jamfile
+++ b/src/3rdparty/freetype/src/type1/Jamfile
@@ -1,6 +1,6 @@
# FreeType 2 src/type1 Jamfile
#
-# Copyright 2001-2015 by
+# Copyright 2001-2018 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/src/3rdparty/freetype/src/type1/module.mk b/src/3rdparty/freetype/src/type1/module.mk
index feb3459d87..3fea5cc16f 100644
--- a/src/3rdparty/freetype/src/type1/module.mk
+++ b/src/3rdparty/freetype/src/type1/module.mk
@@ -3,7 +3,7 @@
#
-# Copyright 1996-2015 by
+# Copyright 1996-2018 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/src/3rdparty/freetype/src/type1/rules.mk b/src/3rdparty/freetype/src/type1/rules.mk
index fbd0543531..cb1a142860 100644
--- a/src/3rdparty/freetype/src/type1/rules.mk
+++ b/src/3rdparty/freetype/src/type1/rules.mk
@@ -3,7 +3,7 @@
#
-# Copyright 1996-2015 by
+# Copyright 1996-2018 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/src/3rdparty/freetype/src/type1/t1afm.c b/src/3rdparty/freetype/src/type1/t1afm.c
index 7f32059f85..61053d9a64 100644
--- a/src/3rdparty/freetype/src/type1/t1afm.c
+++ b/src/3rdparty/freetype/src/type1/t1afm.c
@@ -4,7 +4,7 @@
/* */
/* AFM support for Type 1 fonts (body). */
/* */
-/* Copyright 1996-2015 by */
+/* Copyright 1996-2018 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 */
@@ -197,7 +199,7 @@
/* encoding of first glyph (1 byte) */
/* encoding of second glyph (1 byte) */
/* offset (little-endian short) */
- for ( ; p < limit ; p += 4 )
+ for ( ; p < limit; p += 4 )
{
kp->index1 = FT_Get_Char_Index( t1_face, p[0] );
kp->index2 = FT_Get_Char_Index( t1_face, p[1] );
@@ -208,7 +210,7 @@
kp++;
}
- if ( oldcharmap != NULL )
+ if ( oldcharmap )
error = FT_Set_Charmap( t1_face, oldcharmap );
if ( error )
goto Exit;
@@ -239,8 +241,18 @@
AFM_ParserRec parser;
AFM_FontInfo fi = NULL;
FT_Error error = FT_ERR( Unknown_File_Format );
- T1_Font t1_font = &( (T1_Face)t1_face )->type1;
+ T1_Face face = (T1_Face)t1_face;
+ T1_Font t1_font = &face->type1;
+
+
+ if ( face->afm_data )
+ {
+ FT_TRACE1(( "T1_Read_Metrics:"
+ " Freeing previously attached metrics data.\n" ));
+ T1_Done_Metrics( memory, (AFM_FontInfo)face->afm_data );
+ face->afm_data = NULL;
+ }
if ( FT_NEW( fi ) ||
FT_FRAME_ENTER( stream->size ) )
@@ -250,7 +262,7 @@
fi->Ascender = t1_font->font_bbox.yMax;
fi->Descender = t1_font->font_bbox.yMin;
- psaux = (PSAux_Service)( (T1_Face)t1_face )->psaux;
+ psaux = (PSAux_Service)face->psaux;
if ( psaux->afm_parser_funcs )
{
error = psaux->afm_parser_funcs->init( &parser,
@@ -298,15 +310,15 @@
if ( fi->NumKernPair )
{
t1_face->face_flags |= FT_FACE_FLAG_KERNING;
- ( (T1_Face)t1_face )->afm_data = fi;
- fi = NULL;
+ face->afm_data = fi;
+ fi = NULL;
}
}
FT_FRAME_EXIT();
Exit:
- if ( fi != NULL )
+ if ( fi )
T1_Done_Metrics( memory, fi );
return error;
@@ -392,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/src/3rdparty/freetype/src/type1/t1afm.h b/src/3rdparty/freetype/src/type1/t1afm.h
index 0f42f3e3a8..cb8d302b4d 100644
--- a/src/3rdparty/freetype/src/type1/t1afm.h
+++ b/src/3rdparty/freetype/src/type1/t1afm.h
@@ -4,7 +4,7 @@
/* */
/* AFM support for Type 1 fonts (specification). */
/* */
-/* Copyright 1996-2015 by */
+/* Copyright 1996-2018 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -16,8 +16,8 @@
/***************************************************************************/
-#ifndef __T1AFM_H__
-#define __T1AFM_H__
+#ifndef T1AFM_H_
+#define T1AFM_H_
#include <ft2build.h>
#include "t1objs.h"
@@ -48,7 +48,7 @@ FT_BEGIN_HEADER
FT_END_HEADER
-#endif /* __T1AFM_H__ */
+#endif /* T1AFM_H_ */
/* END */
diff --git a/src/3rdparty/freetype/src/type1/t1driver.c b/src/3rdparty/freetype/src/type1/t1driver.c
index 571f2d2f8c..029b410b47 100644
--- a/src/3rdparty/freetype/src/type1/t1driver.c
+++ b/src/3rdparty/freetype/src/type1/t1driver.c
@@ -4,7 +4,7 @@
/* */
/* Type 1 driver interface (body). */
/* */
-/* Copyright 1996-2015 by */
+/* Copyright 1996-2018 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -29,6 +29,9 @@
#include FT_INTERNAL_DEBUG_H
#include FT_INTERNAL_STREAM_H
+#include FT_INTERNAL_HASH_H
+#include FT_INTERNAL_POSTSCRIPT_PROPS_H
+#include FT_DRIVER_H
#include FT_SERVICE_MULTIPLE_MASTERS_H
#include FT_SERVICE_GLYPH_DICT_H
@@ -36,6 +39,7 @@
#include FT_SERVICE_POSTSCRIPT_NAME_H
#include FT_SERVICE_POSTSCRIPT_CMAPS_H
#include FT_SERVICE_POSTSCRIPT_INFO_H
+#include FT_SERVICE_PROPERTIES_H
#include FT_SERVICE_KERNING_H
@@ -87,8 +91,8 @@
static const FT_Service_GlyphDictRec t1_service_glyph_dict =
{
- (FT_GlyphDict_GetNameFunc) t1_get_glyph_name,
- (FT_GlyphDict_NameIndexFunc)t1_get_name_index
+ (FT_GlyphDict_GetNameFunc) t1_get_glyph_name, /* get_name */
+ (FT_GlyphDict_NameIndexFunc)t1_get_name_index /* name_index */
};
@@ -106,7 +110,7 @@
static const FT_Service_PsFontNameRec t1_service_ps_name =
{
- (FT_PsName_GetFunc)t1_get_ps_name
+ (FT_PsName_GetFunc)t1_get_ps_name /* get_ps_font_name */
};
@@ -118,11 +122,17 @@
#ifndef T1_CONFIG_OPTION_NO_MM_SUPPORT
static const FT_Service_MultiMastersRec t1_service_multi_masters =
{
- (FT_Get_MM_Func) T1_Get_Multi_Master,
- (FT_Set_MM_Design_Func) T1_Set_MM_Design,
- (FT_Set_MM_Blend_Func) T1_Set_MM_Blend,
- (FT_Get_MM_Var_Func) T1_Get_MM_Var,
- (FT_Set_Var_Design_Func)T1_Set_Var_Design
+ (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_Get_Var_Design_Func)T1_Get_Var_Design, /* get_var_design */
+ (FT_Set_Instance_Func) T1_Reset_MM_Blend, /* set_instance */
+
+ (FT_Get_Var_Blend_Func) NULL, /* get_var_blend */
+ (FT_Done_Blend_Func) T1_Done_Blend /* done_blend */
};
#endif
@@ -329,13 +339,37 @@
break;
case PS_DICT_SUBR:
- if ( idx < (FT_UInt)type1->num_subrs )
{
- retval = type1->subrs_len[idx] + 1;
- if ( value && value_len >= retval )
+ FT_Bool ok = 0;
+
+
+ if ( type1->subrs_hash )
{
- ft_memcpy( value, (void *)( type1->subrs[idx] ), retval - 1 );
- ((FT_Char *)value)[retval - 1] = (FT_Char)'\0';
+ /* convert subr index to array index */
+ size_t* val = ft_hash_num_lookup( (FT_Int)idx,
+ type1->subrs_hash );
+
+
+ if ( val )
+ {
+ idx = *val;
+ ok = 1;
+ }
+ }
+ else
+ {
+ if ( idx < (FT_UInt)type1->num_subrs )
+ ok = 1;
+ }
+
+ if ( ok )
+ {
+ retval = type1->subrs_len[idx] + 1;
+ if ( value && value_len >= retval )
+ {
+ ft_memcpy( value, (void *)( type1->subrs[idx] ), retval - 1 );
+ ((FT_Char *)value)[retval - 1] = (FT_Char)'\0';
+ }
}
}
break;
@@ -567,23 +601,35 @@
static const FT_Service_PsInfoRec t1_service_ps_info =
{
- (PS_GetFontInfoFunc) t1_ps_get_font_info,
- (PS_GetFontExtraFunc) t1_ps_get_font_extra,
- (PS_HasGlyphNamesFunc) t1_ps_has_glyph_names,
- (PS_GetFontPrivateFunc)t1_ps_get_font_private,
- (PS_GetFontValueFunc) t1_ps_get_font_value,
+ (PS_GetFontInfoFunc) t1_ps_get_font_info, /* ps_get_font_info */
+ (PS_GetFontExtraFunc) t1_ps_get_font_extra, /* ps_get_font_extra */
+ (PS_HasGlyphNamesFunc) t1_ps_has_glyph_names, /* ps_has_glyph_names */
+ (PS_GetFontPrivateFunc)t1_ps_get_font_private, /* ps_get_font_private */
+ (PS_GetFontValueFunc) t1_ps_get_font_value, /* ps_get_font_value */
};
#ifndef T1_CONFIG_OPTION_NO_AFM
static const FT_Service_KerningRec t1_service_kerning =
{
- T1_Get_Track_Kerning,
+ T1_Get_Track_Kerning, /* get_track */
};
#endif
/*
+ * PROPERTY SERVICE
+ *
+ */
+
+ FT_DEFINE_SERVICE_PROPERTIESREC(
+ t1_service_properties,
+
+ (FT_Properties_SetFunc)ps_property_set, /* set_property */
+ (FT_Properties_GetFunc)ps_property_get ) /* get_property */
+
+
+ /*
* SERVICE LIST
*
*/
@@ -594,6 +640,7 @@
{ FT_SERVICE_ID_GLYPH_DICT, &t1_service_glyph_dict },
{ FT_SERVICE_ID_FONT_FORMAT, FT_FONT_FORMAT_TYPE_1 },
{ FT_SERVICE_ID_POSTSCRIPT_INFO, &t1_service_ps_info },
+ { FT_SERVICE_ID_PROPERTIES, &t1_service_properties },
#ifndef T1_CONFIG_OPTION_NO_AFM
{ FT_SERVICE_ID_KERNING, &t1_service_kerning },
@@ -683,42 +730,43 @@
FT_MODULE_DRIVER_SCALABLE |
FT_MODULE_DRIVER_HAS_HINTER,
- sizeof ( FT_DriverRec ),
+ sizeof ( PS_DriverRec ),
"type1",
0x10000L,
0x20000L,
- 0, /* format interface */
+ NULL, /* module-specific interface */
- T1_Driver_Init,
- T1_Driver_Done,
- Get_Interface,
+ T1_Driver_Init, /* FT_Module_Constructor module_init */
+ T1_Driver_Done, /* FT_Module_Destructor module_done */
+ Get_Interface, /* FT_Module_Requester get_interface */
},
sizeof ( T1_FaceRec ),
sizeof ( T1_SizeRec ),
sizeof ( T1_GlyphSlotRec ),
- T1_Face_Init,
- T1_Face_Done,
- T1_Size_Init,
- T1_Size_Done,
- T1_GlyphSlot_Init,
- T1_GlyphSlot_Done,
+ T1_Face_Init, /* FT_Face_InitFunc init_face */
+ T1_Face_Done, /* FT_Face_DoneFunc done_face */
+ T1_Size_Init, /* FT_Size_InitFunc init_size */
+ T1_Size_Done, /* FT_Size_DoneFunc done_size */
+ T1_GlyphSlot_Init, /* FT_Slot_InitFunc init_slot */
+ T1_GlyphSlot_Done, /* FT_Slot_DoneFunc done_slot */
- T1_Load_Glyph,
+ T1_Load_Glyph, /* FT_Slot_LoadFunc load_glyph */
#ifdef T1_CONFIG_OPTION_NO_AFM
- 0, /* FT_Face_GetKerningFunc */
- 0, /* FT_Face_AttachFunc */
+ NULL, /* FT_Face_GetKerningFunc get_kerning */
+ NULL, /* FT_Face_AttachFunc attach_file */
#else
- Get_Kerning,
- T1_Read_Metrics,
+ Get_Kerning, /* FT_Face_GetKerningFunc get_kerning */
+ T1_Read_Metrics, /* FT_Face_AttachFunc attach_file */
#endif
- T1_Get_Advances,
- T1_Size_Request,
- 0 /* FT_Size_SelectFunc */
+ T1_Get_Advances, /* FT_Face_GetAdvancesFunc get_advances */
+
+ T1_Size_Request, /* FT_Size_RequestFunc request_size */
+ NULL /* FT_Size_SelectFunc select_size */
};
diff --git a/src/3rdparty/freetype/src/type1/t1driver.h b/src/3rdparty/freetype/src/type1/t1driver.h
index 34bcf81ccf..2b1507233d 100644
--- a/src/3rdparty/freetype/src/type1/t1driver.h
+++ b/src/3rdparty/freetype/src/type1/t1driver.h
@@ -4,7 +4,7 @@
/* */
/* High-level Type 1 driver interface (specification). */
/* */
-/* Copyright 1996-2015 by */
+/* Copyright 1996-2018 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -16,8 +16,8 @@
/***************************************************************************/
-#ifndef __T1DRIVER_H__
-#define __T1DRIVER_H__
+#ifndef T1DRIVER_H_
+#define T1DRIVER_H_
#include <ft2build.h>
@@ -36,7 +36,7 @@ FT_BEGIN_HEADER
FT_END_HEADER
-#endif /* __T1DRIVER_H__ */
+#endif /* T1DRIVER_H_ */
/* END */
diff --git a/src/3rdparty/freetype/src/type1/t1errors.h b/src/3rdparty/freetype/src/type1/t1errors.h
index fc7a9bd64e..9e0151b957 100644
--- a/src/3rdparty/freetype/src/type1/t1errors.h
+++ b/src/3rdparty/freetype/src/type1/t1errors.h
@@ -4,7 +4,7 @@
/* */
/* Type 1 error codes (specification only). */
/* */
-/* Copyright 2001-2015 by */
+/* Copyright 2001-2018 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -22,12 +22,12 @@
/* */
/*************************************************************************/
-#ifndef __T1ERRORS_H__
-#define __T1ERRORS_H__
+#ifndef T1ERRORS_H_
+#define T1ERRORS_H_
#include FT_MODULE_ERRORS_H
-#undef __FTERRORS_H__
+#undef FTERRORS_H_
#undef FT_ERR_PREFIX
#define FT_ERR_PREFIX T1_Err_
@@ -35,7 +35,7 @@
#include FT_ERRORS_H
-#endif /* __T1ERRORS_H__ */
+#endif /* T1ERRORS_H_ */
/* END */
diff --git a/src/3rdparty/freetype/src/type1/t1gload.c b/src/3rdparty/freetype/src/type1/t1gload.c
index 85ada2ea6a..87d40e7566 100644
--- a/src/3rdparty/freetype/src/type1/t1gload.c
+++ b/src/3rdparty/freetype/src/type1/t1gload.c
@@ -4,7 +4,7 @@
/* */
/* Type 1 Glyph Loader (body). */
/* */
-/* Copyright 1996-2015 by */
+/* Copyright 1996-2018 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -23,6 +23,8 @@
#include FT_INTERNAL_STREAM_H
#include FT_OUTLINE_H
#include FT_INTERNAL_POSTSCRIPT_AUX_H
+#include FT_INTERNAL_CFF_TYPES_H
+#include FT_DRIVER_H
#include "t1errors.h"
@@ -37,37 +39,28 @@
#define FT_COMPONENT trace_t1gload
- /*************************************************************************/
- /*************************************************************************/
- /*************************************************************************/
- /********** *********/
- /********** COMPUTE THE MAXIMUM ADVANCE WIDTH *********/
- /********** *********/
- /********** The following code is in charge of computing *********/
- /********** the maximum advance width of the font. It *********/
- /********** quickly processes each glyph charstring to *********/
- /********** extract the value from either a `sbw' or `seac' *********/
- /********** operator. *********/
- /********** *********/
- /*************************************************************************/
- /*************************************************************************/
- /*************************************************************************/
-
-
static FT_Error
T1_Parse_Glyph_And_Get_Char_String( T1_Decoder decoder,
FT_UInt glyph_index,
- FT_Data* char_string )
+ FT_Data* char_string,
+ FT_Bool* force_scaling )
{
T1_Face face = (T1_Face)decoder->builder.face;
T1_Font type1 = &face->type1;
FT_Error error = FT_Err_Ok;
+ PSAux_Service psaux = (PSAux_Service)face->psaux;
+ const T1_Decoder_Funcs decoder_funcs = psaux->t1_decoder_funcs;
+ PS_Decoder psdecoder;
+
#ifdef FT_CONFIG_OPTION_INCREMENTAL
FT_Incremental_InterfaceRec *inc =
face->root.internal->incremental_interface;
#endif
+#ifdef T1_CONFIG_OPTION_OLD_ENGINE
+ PS_Driver driver = (PS_Driver)FT_FACE_DRIVER( face );
+#endif
decoder->font_matrix = type1->font_matrix;
decoder->font_offset = type1->font_offset;
@@ -90,9 +83,56 @@
}
if ( !error )
- error = decoder->funcs.parse_charstrings(
- decoder, (FT_Byte*)char_string->pointer,
- (FT_UInt)char_string->length );
+ {
+ /* choose which renderer to use */
+#ifdef T1_CONFIG_OPTION_OLD_ENGINE
+ if ( driver->hinting_engine == FT_HINTING_FREETYPE ||
+ decoder->builder.metrics_only )
+ error = decoder_funcs->parse_charstrings_old(
+ decoder,
+ (FT_Byte*)char_string->pointer,
+ (FT_UInt)char_string->length );
+#else
+ if ( decoder->builder.metrics_only )
+ error = decoder_funcs->parse_metrics(
+ decoder,
+ (FT_Byte*)char_string->pointer,
+ (FT_UInt)char_string->length );
+#endif
+ else
+ {
+ CFF_SubFontRec subfont;
+
+
+ psaux->ps_decoder_init( &psdecoder, decoder, TRUE );
+
+ psaux->t1_make_subfont( FT_FACE( face ),
+ &face->type1.private_dict, &subfont );
+ psdecoder.current_subfont = &subfont;
+
+ error = decoder_funcs->parse_charstrings(
+ &psdecoder,
+ (FT_Byte*)char_string->pointer,
+ (FT_ULong)char_string->length );
+
+ /* Adobe's engine uses 16.16 numbers everywhere; */
+ /* as a consequence, glyphs larger than 2000ppem get rejected */
+ if ( FT_ERR_EQ( error, Glyph_Too_Big ) )
+ {
+ /* this time, we retry unhinted and scale up the glyph later on */
+ /* (the engine uses and sets the hardcoded value 0x10000 / 64 = */
+ /* 0x400 for both `x_scale' and `y_scale' in this case) */
+ ((T1_GlyphSlot)decoder->builder.glyph)->hint = FALSE;
+
+ *force_scaling = TRUE;
+
+ error = decoder_funcs->parse_charstrings(
+ &psdecoder,
+ (FT_Byte*)char_string->pointer,
+ (FT_ULong)char_string->length );
+ }
+ }
+ }
#ifdef FT_CONFIG_OPTION_INCREMENTAL
@@ -126,8 +166,10 @@
FT_UInt glyph_index )
{
FT_Data glyph_data;
- FT_Error error = T1_Parse_Glyph_And_Get_Char_String(
- decoder, glyph_index, &glyph_data );
+ FT_Bool force_scaling = FALSE;
+ FT_Error error = T1_Parse_Glyph_And_Get_Char_String(
+ decoder, glyph_index, &glyph_data,
+ &force_scaling );
#ifdef FT_CONFIG_OPTION_INCREMENTAL
@@ -149,6 +191,23 @@
}
+ /*************************************************************************/
+ /*************************************************************************/
+ /*************************************************************************/
+ /********** *********/
+ /********** COMPUTE THE MAXIMUM ADVANCE WIDTH *********/
+ /********** *********/
+ /********** The following code is in charge of computing *********/
+ /********** the maximum advance width of the font. It *********/
+ /********** quickly processes each glyph charstring to *********/
+ /********** extract the value from either a `sbw' or `seac' *********/
+ /********** operator. *********/
+ /********** *********/
+ /*************************************************************************/
+ /*************************************************************************/
+ /*************************************************************************/
+
+
FT_LOCAL_DEF( FT_Error )
T1_Compute_Max_Advance( T1_Face face,
FT_Pos* max_advance )
@@ -183,6 +242,7 @@
decoder.num_subrs = type1->num_subrs;
decoder.subrs = type1->subrs;
decoder.subrs_len = type1->subrs_len;
+ decoder.subrs_hash = type1->subrs_hash;
decoder.buildchar = face->buildchar;
decoder.len_buildchar = face->len_buildchar;
@@ -245,9 +305,10 @@
decoder.builder.metrics_only = 1;
decoder.builder.load_points = 0;
- decoder.num_subrs = type1->num_subrs;
- decoder.subrs = type1->subrs;
- decoder.subrs_len = type1->subrs_len;
+ decoder.num_subrs = type1->num_subrs;
+ decoder.subrs = type1->subrs;
+ decoder.subrs_len = type1->subrs_len;
+ decoder.subrs_hash = type1->subrs_hash;
decoder.buildchar = face->buildchar;
decoder.len_buildchar = face->len_buildchar;
@@ -276,6 +337,8 @@
T1_DecoderRec decoder;
T1_Face face = (T1_Face)t1glyph->face;
FT_Bool hinting;
+ FT_Bool scaled;
+ FT_Bool force_scaling = FALSE;
T1_Font type1 = &face->type1;
PSAux_Service psaux = (PSAux_Service)face->psaux;
const T1_Decoder_Funcs decoder_funcs = psaux->t1_decoder_funcs;
@@ -323,7 +386,10 @@
hinting = FT_BOOL( ( load_flags & FT_LOAD_NO_SCALE ) == 0 &&
( load_flags & FT_LOAD_NO_HINTING ) == 0 );
+ scaled = FT_BOOL( ( load_flags & FT_LOAD_NO_SCALE ) == 0 );
+ glyph->hint = hinting;
+ glyph->scaled = scaled;
t1glyph->format = FT_GLYPH_FORMAT_OUTLINE;
error = decoder_funcs->init( &decoder,
@@ -346,19 +412,22 @@
decoder.num_subrs = type1->num_subrs;
decoder.subrs = type1->subrs;
decoder.subrs_len = type1->subrs_len;
+ decoder.subrs_hash = type1->subrs_hash;
decoder.buildchar = face->buildchar;
decoder.len_buildchar = face->len_buildchar;
/* now load the unscaled outline */
error = T1_Parse_Glyph_And_Get_Char_String( &decoder, glyph_index,
- &glyph_data );
+ &glyph_data,
+ &force_scaling );
if ( error )
goto Exit;
#ifdef FT_CONFIG_OPTION_INCREMENTAL
glyph_data_loaded = 1;
#endif
+ hinting = glyph->hint;
font_matrix = decoder.font_matrix;
font_offset = decoder.font_offset;
@@ -448,7 +517,7 @@
}
#endif
- if ( ( load_flags & FT_LOAD_NO_SCALE ) == 0 )
+ if ( ( load_flags & FT_LOAD_NO_SCALE ) == 0 || force_scaling )
{
/* scale the outline and the metrics */
FT_Int n;
diff --git a/src/3rdparty/freetype/src/type1/t1gload.h b/src/3rdparty/freetype/src/type1/t1gload.h
index 05f60d586a..72ef76f6ae 100644
--- a/src/3rdparty/freetype/src/type1/t1gload.h
+++ b/src/3rdparty/freetype/src/type1/t1gload.h
@@ -4,7 +4,7 @@
/* */
/* Type 1 Glyph Loader (specification). */
/* */
-/* Copyright 1996-2015 by */
+/* Copyright 1996-2018 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -16,8 +16,8 @@
/***************************************************************************/
-#ifndef __T1GLOAD_H__
-#define __T1GLOAD_H__
+#ifndef T1GLOAD_H_
+#define T1GLOAD_H_
#include <ft2build.h>
@@ -47,7 +47,7 @@ FT_BEGIN_HEADER
FT_END_HEADER
-#endif /* __T1GLOAD_H__ */
+#endif /* T1GLOAD_H_ */
/* END */
diff --git a/src/3rdparty/freetype/src/type1/t1load.c b/src/3rdparty/freetype/src/type1/t1load.c
index dbf4eafd71..9dfa637a69 100644
--- a/src/3rdparty/freetype/src/type1/t1load.c
+++ b/src/3rdparty/freetype/src/type1/t1load.c
@@ -4,7 +4,7 @@
/* */
/* Type 1 font loader (body). */
/* */
-/* Copyright 1996-2015 by */
+/* Copyright 1996-2018 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -66,6 +66,7 @@
#include FT_MULTIPLE_MASTERS_H
#include FT_INTERNAL_TYPE1_TYPES_H
#include FT_INTERNAL_CALC_H
+#include FT_INTERNAL_HASH_H
#include "t1load.h"
#include "t1errors.h"
@@ -236,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] ) +
@@ -320,22 +321,25 @@
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);
- mmvar->axis[i].maximum = INT_TO_FIXED( mmaster.axis[i].maximum);
+ mmvar->axis[i].minimum = INT_TO_FIXED( mmaster.axis[i].minimum );
+ mmvar->axis[i].maximum = INT_TO_FIXED( mmaster.axis[i].maximum );
mmvar->axis[i].def = ( mmvar->axis[i].minimum +
mmvar->axis[i].maximum ) / 2;
/* Does not apply. But this value is in range */
mmvar->axis[i].strid = ~0U; /* Does not apply */
mmvar->axis[i].tag = ~0U; /* Does not apply */
+ if ( !mmvar->axis[i].name )
+ continue;
+
if ( ft_strcmp( mmvar->axis[i].name, "Weight" ) == 0 )
mmvar->axis[i].tag = FT_MAKE_TAG( 'w', 'g', 'h', 't' );
else if ( ft_strcmp( mmvar->axis[i].name, "Width" ) == 0 )
@@ -350,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] );
}
@@ -362,14 +366,16 @@
}
- FT_LOCAL_DEF( FT_Error )
- T1_Set_MM_Blend( T1_Face face,
+ static FT_Error
+ t1_set_mm_blend( T1_Face face,
FT_UInt num_coords,
FT_Fixed* coords )
{
PS_Blend blend = face->blend;
FT_UInt n, m;
+ FT_Bool have_diff = 0;
+
if ( !blend )
return FT_THROW( Invalid_Argument );
@@ -401,9 +407,71 @@
result = FT_MulFix( result, factor );
}
- blend->weight_vector[n] = result;
+
+ if ( blend->weight_vector[n] != result )
+ {
+ blend->weight_vector[n] = result;
+ have_diff = 1;
+ }
}
+ /* return value -1 indicates `no change' */
+ return have_diff ? FT_Err_Ok : -1;
+ }
+
+
+ FT_LOCAL_DEF( FT_Error )
+ T1_Set_MM_Blend( T1_Face face,
+ FT_UInt num_coords,
+ FT_Fixed* coords )
+ {
+ FT_Error error;
+
+
+ error = t1_set_mm_blend( face, num_coords, coords );
+ if ( error )
+ return error;
+
+ if ( num_coords )
+ face->root.face_flags |= FT_FACE_FLAG_VARIATION;
+ else
+ face->root.face_flags &= ~FT_FACE_FLAG_VARIATION;
+
+ return FT_Err_Ok;
+ }
+
+
+ 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;
}
@@ -413,6 +481,7 @@
FT_UInt num_coords,
FT_Long* coords )
{
+ FT_Error error;
PS_Blend blend = face->blend;
FT_UInt n, p;
FT_Fixed final_blends[T1_MAX_MM_DESIGNS];
@@ -479,7 +548,28 @@
final_blends[n] = the_blend;
}
- return T1_Set_MM_Blend( face, blend->num_axis, final_blends );
+ error = t1_set_mm_blend( face, blend->num_axis, final_blends );
+ if ( error )
+ return error;
+
+ if ( num_coords )
+ face->root.face_flags |= FT_FACE_FLAG_VARIATION;
+ else
+ face->root.face_flags &= ~FT_FACE_FLAG_VARIATION;
+
+ return FT_Err_Ok;
+ }
+
+
+ /* MM fonts don't have named instances, so only the design is reset */
+
+ FT_LOCAL_DEF( FT_Error )
+ T1_Reset_MM_Blend( T1_Face face,
+ FT_UInt instance_index )
+ {
+ FT_UNUSED( instance_index );
+
+ return T1_Set_MM_Blend( face, 0, NULL );
}
@@ -500,13 +590,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 )
{
@@ -1191,7 +1317,7 @@
if ( ft_isdigit( *cur ) || *cur == '[' )
{
T1_Encoding encode = &face->type1.encoding;
- FT_Int count, n;
+ FT_Int count, array_size, n;
PS_Table char_table = &loader->encoding_table;
FT_Memory memory = parser->root.memory;
FT_Error error;
@@ -1208,13 +1334,12 @@
else
count = (FT_Int)T1_ToInt( parser );
- /* only composite fonts (which we don't support) */
- /* can have larger values */
+ array_size = count;
if ( count > 256 )
{
- FT_ERROR(( "parse_encoding: invalid encoding array size\n" ));
- parser->root.error = FT_THROW( Invalid_File_Format );
- return;
+ FT_TRACE2(( "parse_encoding:"
+ " only using first 256 encoding array entries\n" ));
+ array_size = 256;
}
T1_Skip_Spaces( parser );
@@ -1230,18 +1355,18 @@
}
/* we use a T1_Table to store our charnames */
- loader->num_chars = encode->num_chars = count;
- if ( FT_NEW_ARRAY( encode->char_index, count ) ||
- FT_NEW_ARRAY( encode->char_name, count ) ||
+ loader->num_chars = encode->num_chars = array_size;
+ if ( FT_NEW_ARRAY( encode->char_index, array_size ) ||
+ FT_NEW_ARRAY( encode->char_name, array_size ) ||
FT_SET_ERROR( psaux->ps_table_funcs->init(
- char_table, count, memory ) ) )
+ char_table, array_size, memory ) ) )
{
parser->root.error = error;
return;
}
/* We need to `zero' out encoding_table.elements */
- for ( n = 0; n < count; n++ )
+ for ( n = 0; n < array_size; n++ )
{
char* notdef = (char *)".notdef";
@@ -1334,11 +1459,14 @@
len = (FT_UInt)( parser->root.cursor - cur );
- parser->root.error = T1_Add_Table( char_table, charcode,
- cur, len + 1 );
- if ( parser->root.error )
- return;
- char_table->elements[charcode][len] = '\0';
+ if ( n < array_size )
+ {
+ parser->root.error = T1_Add_Table( char_table, charcode,
+ cur, len + 1 );
+ if ( parser->root.error )
+ return;
+ char_table->elements[charcode][len] = '\0';
+ }
n++;
}
@@ -1401,6 +1529,7 @@
FT_Memory memory = parser->root.memory;
FT_Error error;
FT_Int num_subrs;
+ FT_UInt count;
PSAux_Service psaux = (PSAux_Service)face->psaux;
@@ -1420,6 +1549,47 @@
}
num_subrs = (FT_Int)T1_ToInt( parser );
+ if ( num_subrs < 0 )
+ {
+ parser->root.error = FT_THROW( Invalid_File_Format );
+ return;
+ }
+
+ /* we certainly need more than 8 bytes per subroutine */
+ if ( parser->root.limit >= parser->root.cursor &&
+ num_subrs > ( parser->root.limit - parser->root.cursor ) >> 3 )
+ {
+ /*
+ * There are two possibilities. Either the font contains an invalid
+ * value for `num_subrs', or we have a subsetted font where the
+ * subroutine indices are not adjusted, e.g.
+ *
+ * /Subrs 812 array
+ * dup 0 { ... } NP
+ * dup 51 { ... } NP
+ * dup 681 { ... } NP
+ * ND
+ *
+ * In both cases, we use a number hash that maps from subr indices to
+ * actual array elements.
+ */
+
+ FT_TRACE0(( "parse_subrs: adjusting number of subroutines"
+ " (from %d to %d)\n",
+ num_subrs,
+ ( parser->root.limit - parser->root.cursor ) >> 3 ));
+ num_subrs = ( parser->root.limit - parser->root.cursor ) >> 3;
+
+ if ( !loader->subrs_hash )
+ {
+ if ( FT_NEW( loader->subrs_hash ) )
+ goto Fail;
+
+ error = ft_hash_num_init( loader->subrs_hash, memory );
+ if ( error )
+ goto Fail;
+ }
+ }
/* position the parser right before the `dup' of the first subr */
T1_Skip_PS_Token( parser ); /* `array' */
@@ -1440,7 +1610,7 @@
/* */
/* `index' + binary data */
/* */
- for (;;)
+ for ( count = 0; ; count++ )
{
FT_Long idx;
FT_ULong size;
@@ -1476,6 +1646,14 @@
T1_Skip_Spaces ( parser );
}
+ /* 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 ( loader->subrs_hash )
+ {
+ ft_hash_num_insert( idx, count, loader->subrs_hash, memory );
+ idx = count;
+ }
+
/* with synthetic fonts it is possible we get here twice */
if ( loader->num_subrs )
continue;
@@ -1487,7 +1665,7 @@
/* */
if ( face->type1.private_dict.lenIV >= 0 )
{
- FT_Byte* temp;
+ FT_Byte* temp = NULL;
/* some fonts define empty subr records -- this is not totally */
@@ -1691,7 +1869,7 @@
if ( face->type1.private_dict.lenIV >= 0 &&
n < num_glyphs + TABLE_EXTEND )
{
- FT_Byte* temp;
+ FT_Byte* temp = NULL;
if ( size <= (FT_ULong)face->type1.private_dict.lenIV )
@@ -1719,6 +1897,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. */
@@ -2047,7 +2231,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;
@@ -2086,18 +2270,7 @@
{
FT_UNUSED( face );
- FT_MEM_ZERO( loader, sizeof ( *loader ) );
- loader->num_glyphs = 0;
- loader->num_chars = 0;
-
- /* initialize the tables -- simply set their `init' field to 0 */
- loader->encoding_table.init = 0;
- loader->charstrings.init = 0;
- loader->glyph_names.init = 0;
- loader->subrs.init = 0;
- loader->swap_table.init = 0;
- loader->fontdata = 0;
- loader->keywords_encountered = 0;
+ FT_ZERO( loader );
}
@@ -2105,6 +2278,7 @@
t1_done_loader( T1_Loader loader )
{
T1_Parser parser = &loader->parser;
+ FT_Memory memory = parser->root.memory;
/* finalize tables */
@@ -2114,6 +2288,10 @@
T1_Release_Table( &loader->swap_table );
T1_Release_Table( &loader->subrs );
+ /* finalize hash */
+ ft_hash_num_free( loader->subrs_hash, memory );
+ FT_FREE( loader->subrs_hash );
+
/* finalize parser */
T1_Finalize_Parser( parser );
}
@@ -2230,11 +2408,15 @@
if ( loader.subrs.init )
{
- loader.subrs.init = 0;
type1->num_subrs = loader.num_subrs;
type1->subrs_block = loader.subrs.block;
type1->subrs = loader.subrs.elements;
type1->subrs_len = loader.subrs.lengths;
+ type1->subrs_hash = loader.subrs_hash;
+
+ /* prevent `t1_done_loader' from freeing the propagated data */
+ loader.subrs.init = 0;
+ loader.subrs_hash = NULL;
}
if ( !IS_INCREMENTAL )
@@ -2311,6 +2493,24 @@
type1->encoding.num_chars = loader.num_chars;
}
+ /* some sanitizing to avoid overflows later on; */
+ /* the upper limits are ad-hoc values */
+ if ( priv->blue_shift > 1000 || priv->blue_shift < 0 )
+ {
+ FT_TRACE2(( "T1_Open_Face:"
+ " setting unlikely BlueShift value %d to default (7)\n",
+ priv->blue_shift ));
+ priv->blue_shift = 7;
+ }
+
+ if ( priv->blue_fuzz > 1000 || priv->blue_fuzz < 0 )
+ {
+ FT_TRACE2(( "T1_Open_Face:"
+ " setting unlikely BlueFuzz value %d to default (1)\n",
+ priv->blue_fuzz ));
+ priv->blue_fuzz = 1;
+ }
+
Exit:
t1_done_loader( &loader );
return error;
diff --git a/src/3rdparty/freetype/src/type1/t1load.h b/src/3rdparty/freetype/src/type1/t1load.h
index de422e7ecd..03be3f7f93 100644
--- a/src/3rdparty/freetype/src/type1/t1load.h
+++ b/src/3rdparty/freetype/src/type1/t1load.h
@@ -4,7 +4,7 @@
/* */
/* Type 1 font loader (specification). */
/* */
-/* Copyright 1996-2015 by */
+/* Copyright 1996-2018 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -16,8 +16,8 @@
/***************************************************************************/
-#ifndef __T1LOAD_H__
-#define __T1LOAD_H__
+#ifndef T1LOAD_H_
+#define T1LOAD_H_
#include <ft2build.h>
@@ -46,6 +46,7 @@ FT_BEGIN_HEADER
FT_Int num_subrs;
PS_TableRec subrs;
+ FT_Hash subrs_hash;
FT_Bool fontdata;
FT_UInt keywords_encountered; /* T1_LOADER_ENCOUNTERED_XXX */
@@ -69,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,11 +80,25 @@ FT_BEGIN_HEADER
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_Reset_MM_Blend( T1_Face face,
+ FT_UInt instance_index );
+
+ 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 );
@@ -96,7 +111,7 @@ FT_BEGIN_HEADER
FT_END_HEADER
-#endif /* __T1LOAD_H__ */
+#endif /* T1LOAD_H_ */
/* END */
diff --git a/src/3rdparty/freetype/src/type1/t1objs.c b/src/3rdparty/freetype/src/type1/t1objs.c
index d921063eaa..7333c4c958 100644
--- a/src/3rdparty/freetype/src/type1/t1objs.c
+++ b/src/3rdparty/freetype/src/type1/t1objs.c
@@ -4,7 +4,7 @@
/* */
/* Type 1 objects manager (body). */
/* */
-/* Copyright 1996-2015 by */
+/* Copyright 1996-2018 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -21,6 +21,7 @@
#include FT_INTERNAL_DEBUG_H
#include FT_INTERNAL_STREAM_H
#include FT_TRUETYPE_IDS_H
+#include FT_DRIVER_H
#include "t1gload.h"
#include "t1load.h"
@@ -49,9 +50,6 @@
/* */
/* SIZE FUNCTIONS */
/* */
- /* note that we store the global hints in the size's "internal" root */
- /* field */
- /* */
/*************************************************************************/
@@ -67,7 +65,7 @@
"pshinter" );
return ( module && pshinter && pshinter->get_globals_funcs )
? pshinter->get_globals_funcs( module )
- : 0 ;
+ : 0;
}
@@ -77,16 +75,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 +106,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 +124,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 );
@@ -247,6 +245,9 @@
FT_FREE( type1->subrs );
FT_FREE( type1->subrs_len );
+ ft_hash_num_free( type1->subrs_hash, memory );
+ FT_FREE( type1->subrs_hash );
+
FT_FREE( type1->subrs_block );
FT_FREE( type1->charstrings_block );
FT_FREE( type1->glyph_names_block );
@@ -379,7 +380,7 @@
/* simplistic and might get some things wrong. For a full-featured */
/* algorithm you might have a look at the whitepaper given at */
/* */
- /* http://blogs.msdn.com/text/archive/2007/04/23/wpf-font-selection-model.aspx */
+ /* https://blogs.msdn.com/text/archive/2007/04/23/wpf-font-selection-model.aspx */
/* get style name -- be careful, some broken fonts only */
/* have a `/FontName' dictionary entry! */
@@ -555,12 +556,6 @@
if ( clazz )
error = FT_CMap_New( clazz, NULL, &charmap, NULL );
-
-#if 0
- /* Select default charmap */
- if (root->num_charmaps)
- root->charmap = root->charmaps[0];
-#endif
}
}
@@ -584,9 +579,42 @@
/* FreeType error code. 0 means success. */
/* */
FT_LOCAL_DEF( FT_Error )
- T1_Driver_Init( FT_Module driver )
+ T1_Driver_Init( FT_Module module )
{
- FT_UNUSED( driver );
+ PS_Driver driver = (PS_Driver)module;
+
+ FT_UInt32 seed;
+
+
+ /* set default property values, cf. `ftt1drv.h' */
+#ifdef T1_CONFIG_OPTION_OLD_ENGINE
+ driver->hinting_engine = FT_HINTING_FREETYPE;
+#else
+ driver->hinting_engine = FT_HINTING_ADOBE;
+#endif
+
+ driver->no_stem_darkening = TRUE;
+
+ driver->darken_params[0] = CFF_CONFIG_OPTION_DARKENING_PARAMETER_X1;
+ driver->darken_params[1] = CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y1;
+ driver->darken_params[2] = CFF_CONFIG_OPTION_DARKENING_PARAMETER_X2;
+ driver->darken_params[3] = CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y2;
+ driver->darken_params[4] = CFF_CONFIG_OPTION_DARKENING_PARAMETER_X3;
+ driver->darken_params[5] = CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y3;
+ driver->darken_params[6] = CFF_CONFIG_OPTION_DARKENING_PARAMETER_X4;
+ driver->darken_params[7] = CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y4;
+
+ /* 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/src/3rdparty/freetype/src/type1/t1objs.h b/src/3rdparty/freetype/src/type1/t1objs.h
index 6b4f3cb56d..8298e036f4 100644
--- a/src/3rdparty/freetype/src/type1/t1objs.h
+++ b/src/3rdparty/freetype/src/type1/t1objs.h
@@ -4,7 +4,7 @@
/* */
/* Type 1 objects manager (specification). */
/* */
-/* Copyright 1996-2015 by */
+/* Copyright 1996-2018 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -16,8 +16,8 @@
/***************************************************************************/
-#ifndef __T1OBJS_H__
-#define __T1OBJS_H__
+#ifndef T1OBJS_H_
+#define T1OBJS_H_
#include <ft2build.h>
@@ -120,12 +120,12 @@ FT_BEGIN_HEADER
FT_Bool hint;
FT_Bool scaled;
- FT_Int max_points;
- FT_Int max_contours;
-
FT_Fixed x_scale;
FT_Fixed y_scale;
+ FT_Int max_points;
+ FT_Int max_contours;
+
} T1_GlyphSlotRec;
@@ -154,7 +154,7 @@ FT_BEGIN_HEADER
FT_END_HEADER
-#endif /* __T1OBJS_H__ */
+#endif /* T1OBJS_H_ */
/* END */
diff --git a/src/3rdparty/freetype/src/type1/t1parse.c b/src/3rdparty/freetype/src/type1/t1parse.c
index 0b68502606..8e201e5ef5 100644
--- a/src/3rdparty/freetype/src/type1/t1parse.c
+++ b/src/3rdparty/freetype/src/type1/t1parse.c
@@ -4,7 +4,7 @@
/* */
/* Type 1 parser (body). */
/* */
-/* Copyright 1996-2015 by */
+/* Copyright 1996-2018 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/src/3rdparty/freetype/src/type1/t1parse.h b/src/3rdparty/freetype/src/type1/t1parse.h
index 93b02e3d31..4ac82ae913 100644
--- a/src/3rdparty/freetype/src/type1/t1parse.h
+++ b/src/3rdparty/freetype/src/type1/t1parse.h
@@ -4,7 +4,7 @@
/* */
/* Type 1 parser (specification). */
/* */
-/* Copyright 1996-2015 by */
+/* Copyright 1996-2018 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -16,8 +16,8 @@
/***************************************************************************/
-#ifndef __T1PARSE_H__
-#define __T1PARSE_H__
+#ifndef T1PARSE_H_
+#define T1PARSE_H_
#include <ft2build.h>
@@ -123,7 +123,7 @@ FT_BEGIN_HEADER
FT_END_HEADER
-#endif /* __T1PARSE_H__ */
+#endif /* T1PARSE_H_ */
/* END */
diff --git a/src/3rdparty/freetype/src/type1/t1tokens.h b/src/3rdparty/freetype/src/type1/t1tokens.h
index 3992652435..43a65d88ea 100644
--- a/src/3rdparty/freetype/src/type1/t1tokens.h
+++ b/src/3rdparty/freetype/src/type1/t1tokens.h
@@ -4,7 +4,7 @@
/* */
/* Type 1 tokenizer (specification). */
/* */
-/* Copyright 1996-2015 by */
+/* Copyright 1996-2018 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
diff --git a/src/3rdparty/freetype/src/type1/type1.c b/src/3rdparty/freetype/src/type1/type1.c
index 4c70ea7630..72eff59bfe 100644
--- a/src/3rdparty/freetype/src/type1/type1.c
+++ b/src/3rdparty/freetype/src/type1/type1.c
@@ -4,7 +4,7 @@
/* */
/* FreeType Type 1 driver component (body only). */
/* */
-/* Copyright 1996-2015 by */
+/* Copyright 1996-2018 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/src/3rdparty/freetype/src/type42/Jamfile b/src/3rdparty/freetype/src/type42/Jamfile
index 722953d37f..b98de05a74 100644
--- a/src/3rdparty/freetype/src/type42/Jamfile
+++ b/src/3rdparty/freetype/src/type42/Jamfile
@@ -1,6 +1,6 @@
# FreeType 2 src/type42 Jamfile
#
-# Copyright 2002-2015 by
+# Copyright 2002-2018 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/src/3rdparty/freetype/src/type42/module.mk b/src/3rdparty/freetype/src/type42/module.mk
index af7e651d95..3d4732bb6f 100644
--- a/src/3rdparty/freetype/src/type42/module.mk
+++ b/src/3rdparty/freetype/src/type42/module.mk
@@ -3,7 +3,7 @@
#
-# Copyright 2002-2015 by
+# Copyright 2002-2018 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/src/3rdparty/freetype/src/type42/rules.mk b/src/3rdparty/freetype/src/type42/rules.mk
index 4a8efca507..9325d3898f 100644
--- a/src/3rdparty/freetype/src/type42/rules.mk
+++ b/src/3rdparty/freetype/src/type42/rules.mk
@@ -3,7 +3,7 @@
#
-# Copyright 2002-2015 by
+# Copyright 2002-2018 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/src/3rdparty/freetype/src/type42/t42drivr.c b/src/3rdparty/freetype/src/type42/t42drivr.c
index 2907096c9f..f579b2708c 100644
--- a/src/3rdparty/freetype/src/type42/t42drivr.c
+++ b/src/3rdparty/freetype/src/type42/t42drivr.c
@@ -4,7 +4,7 @@
/* */
/* High-level Type 42 driver interface (body). */
/* */
-/* Copyright 2002-2015 by */
+/* Copyright 2002-2018 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;
@@ -90,8 +91,8 @@
static const FT_Service_GlyphDictRec t42_service_glyph_dict =
{
- (FT_GlyphDict_GetNameFunc) t42_get_glyph_name,
- (FT_GlyphDict_NameIndexFunc)t42_get_name_index
+ (FT_GlyphDict_GetNameFunc) t42_get_glyph_name, /* get_name */
+ (FT_GlyphDict_NameIndexFunc)t42_get_name_index /* name_index */
};
@@ -110,7 +111,7 @@
static const FT_Service_PsFontNameRec t42_service_ps_font_name =
{
- (FT_PsName_GetFunc)t42_get_ps_font_name
+ (FT_PsName_GetFunc)t42_get_ps_font_name /* get_ps_font_name */
};
@@ -161,11 +162,12 @@
static const FT_Service_PsInfoRec t42_service_ps_info =
{
- (PS_GetFontInfoFunc) t42_ps_get_font_info,
- (PS_GetFontExtraFunc) t42_ps_get_font_extra,
- (PS_HasGlyphNamesFunc) t42_ps_has_glyph_names,
- (PS_GetFontPrivateFunc)t42_ps_get_font_private,
- (PS_GetFontValueFunc) NULL /* not implemented */
+ (PS_GetFontInfoFunc) t42_ps_get_font_info, /* ps_get_font_info */
+ (PS_GetFontExtraFunc) t42_ps_get_font_extra, /* ps_get_font_extra */
+ (PS_HasGlyphNamesFunc) t42_ps_has_glyph_names, /* ps_has_glyph_names */
+ (PS_GetFontPrivateFunc)t42_ps_get_font_private, /* ps_get_font_private */
+ /* not implemented */
+ (PS_GetFontValueFunc) NULL /* ps_get_font_value */
};
@@ -212,32 +214,32 @@
0x10000L,
0x20000L,
- 0, /* format interface */
+ NULL, /* module-specific interface */
- T42_Driver_Init,
- T42_Driver_Done,
- T42_Get_Interface,
+ T42_Driver_Init, /* FT_Module_Constructor module_init */
+ T42_Driver_Done, /* FT_Module_Destructor module_done */
+ T42_Get_Interface, /* FT_Module_Requester get_interface */
},
sizeof ( T42_FaceRec ),
sizeof ( T42_SizeRec ),
sizeof ( T42_GlyphSlotRec ),
- T42_Face_Init,
- T42_Face_Done,
- T42_Size_Init,
- T42_Size_Done,
- T42_GlyphSlot_Init,
- T42_GlyphSlot_Done,
+ T42_Face_Init, /* FT_Face_InitFunc init_face */
+ T42_Face_Done, /* FT_Face_DoneFunc done_face */
+ T42_Size_Init, /* FT_Size_InitFunc init_size */
+ T42_Size_Done, /* FT_Size_DoneFunc done_size */
+ T42_GlyphSlot_Init, /* FT_Slot_InitFunc init_slot */
+ T42_GlyphSlot_Done, /* FT_Slot_DoneFunc done_slot */
- T42_GlyphSlot_Load,
+ T42_GlyphSlot_Load, /* FT_Slot_LoadFunc load_glyph */
- 0, /* FT_Face_GetKerningFunc */
- 0, /* FT_Face_AttachFunc */
+ NULL, /* FT_Face_GetKerningFunc get_kerning */
+ NULL, /* FT_Face_AttachFunc attach_file */
+ NULL, /* FT_Face_GetAdvancesFunc get_advances */
- 0, /* FT_Face_GetAdvancesFunc */
- T42_Size_Request,
- T42_Size_Select
+ T42_Size_Request, /* FT_Size_RequestFunc request_size */
+ T42_Size_Select /* FT_Size_SelectFunc select_size */
};
diff --git a/src/3rdparty/freetype/src/type42/t42drivr.h b/src/3rdparty/freetype/src/type42/t42drivr.h
index b4d1753a23..3667f3e066 100644
--- a/src/3rdparty/freetype/src/type42/t42drivr.h
+++ b/src/3rdparty/freetype/src/type42/t42drivr.h
@@ -4,7 +4,7 @@
/* */
/* High-level Type 42 driver interface (specification). */
/* */
-/* Copyright 2002-2015 by */
+/* Copyright 2002-2018 by */
/* Roberto Alameda. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -16,8 +16,8 @@
/***************************************************************************/
-#ifndef __T42DRIVR_H__
-#define __T42DRIVR_H__
+#ifndef T42DRIVR_H_
+#define T42DRIVR_H_
#include <ft2build.h>
@@ -37,7 +37,7 @@ FT_BEGIN_HEADER
FT_END_HEADER
-#endif /* __T42DRIVR_H__ */
+#endif /* T42DRIVR_H_ */
/* END */
diff --git a/src/3rdparty/freetype/src/type42/t42error.h b/src/3rdparty/freetype/src/type42/t42error.h
index cddaf9e9ca..e3978a7607 100644
--- a/src/3rdparty/freetype/src/type42/t42error.h
+++ b/src/3rdparty/freetype/src/type42/t42error.h
@@ -4,7 +4,7 @@
/* */
/* Type 42 error codes (specification only). */
/* */
-/* Copyright 2002-2015 by */
+/* Copyright 2002-2018 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -22,12 +22,12 @@
/* */
/*************************************************************************/
-#ifndef __T42ERROR_H__
-#define __T42ERROR_H__
+#ifndef T42ERROR_H_
+#define T42ERROR_H_
#include FT_MODULE_ERRORS_H
-#undef __FTERRORS_H__
+#undef FTERRORS_H_
#undef FT_ERR_PREFIX
#define FT_ERR_PREFIX T42_Err_
@@ -35,7 +35,7 @@
#include FT_ERRORS_H
-#endif /* __T42ERROR_H__ */
+#endif /* T42ERROR_H_ */
/* END */
diff --git a/src/3rdparty/freetype/src/type42/t42objs.c b/src/3rdparty/freetype/src/type42/t42objs.c
index 430871aced..66e5c40382 100644
--- a/src/3rdparty/freetype/src/type42/t42objs.c
+++ b/src/3rdparty/freetype/src/type42/t42objs.c
@@ -4,7 +4,7 @@
/* */
/* Type 42 objects manager (body). */
/* */
-/* Copyright 2002-2015 by */
+/* Copyright 2002-2018 by */
/* Roberto Alameda. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -231,9 +231,6 @@
if ( info->is_fixed_pitch )
root->face_flags |= FT_FACE_FLAG_FIXED_WIDTH;
- /* We only set this flag if we have the patented bytecode interpreter. */
- /* There are no known `tricky' Type42 fonts that could be loaded with */
- /* the unpatented interpreter. */
#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER
root->face_flags |= FT_FACE_FLAG_HINTER;
#endif
@@ -397,12 +394,6 @@
if ( clazz )
error = FT_CMap_New( clazz, NULL, &charmap, NULL );
-
-#if 0
- /* Select default charmap */
- if ( root->num_charmaps )
- root->charmap = root->charmaps[0];
-#endif
}
}
Exit:
@@ -593,7 +584,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;
@@ -659,8 +650,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/src/3rdparty/freetype/src/type42/t42objs.h b/src/3rdparty/freetype/src/type42/t42objs.h
index 3722c670f0..3bad5135e0 100644
--- a/src/3rdparty/freetype/src/type42/t42objs.h
+++ b/src/3rdparty/freetype/src/type42/t42objs.h
@@ -4,7 +4,7 @@
/* */
/* Type 42 objects manager (specification). */
/* */
-/* Copyright 2002-2015 by */
+/* Copyright 2002-2018 by */
/* Roberto Alameda. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -16,8 +16,8 @@
/***************************************************************************/
-#ifndef __T42OBJS_H__
-#define __T42OBJS_H__
+#ifndef T42OBJS_H_
+#define T42OBJS_H_
#include <ft2build.h>
#include FT_FREETYPE_H
@@ -118,7 +118,7 @@ FT_BEGIN_HEADER
FT_END_HEADER
-#endif /* __T42OBJS_H__ */
+#endif /* T42OBJS_H_ */
/* END */
diff --git a/src/3rdparty/freetype/src/type42/t42parse.c b/src/3rdparty/freetype/src/type42/t42parse.c
index 003b63ed77..4813d1f3f9 100644
--- a/src/3rdparty/freetype/src/type42/t42parse.c
+++ b/src/3rdparty/freetype/src/type42/t42parse.c
@@ -4,7 +4,7 @@
/* */
/* Type 42 font parser (body). */
/* */
-/* Copyright 2002-2015 by */
+/* Copyright 2002-2018 by */
/* Roberto Alameda. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -575,6 +575,9 @@
while ( parser->root.cursor < limit )
{
+ FT_ULong size;
+
+
cur = parser->root.cursor;
if ( *cur == ']' )
@@ -637,7 +640,7 @@
string_buf = parser->root.cursor + 1; /* one space after `RD' */
- if ( (FT_ULong)( limit - parser->root.cursor ) < string_size )
+ if ( (FT_ULong)( limit - parser->root.cursor ) <= string_size )
{
FT_ERROR(( "t42_parse_sfnts: too much binary data\n" ));
error = FT_THROW( Invalid_File_Format );
@@ -666,6 +669,11 @@
goto Fail;
}
+ /* The whole TTF is now loaded into `string_buf'. We are */
+ /* checking its contents while copying it to `ttf_data'. */
+
+ size = (FT_ULong)( limit - parser->root.cursor );
+
for ( n = 0; n < string_size; n++ )
{
switch ( status )
@@ -683,7 +691,7 @@
status = BEFORE_TABLE_DIR;
face->ttf_size = 12 + 16 * num_tables;
- if ( (FT_Long)( limit - parser->root.cursor ) < face->ttf_size )
+ if ( (FT_Long)size < face->ttf_size )
{
FT_ERROR(( "t42_parse_sfnts: invalid data in sfnts array\n" ));
error = FT_THROW( Invalid_File_Format );
@@ -714,6 +722,14 @@
len = FT_PEEK_ULONG( p );
+ if ( len > size ||
+ face->ttf_size > (FT_Long)( size - len ) )
+ {
+ FT_ERROR(( "t42_parse_sfnts:"
+ " invalid data in sfnts array\n" ));
+ error = FT_THROW( Invalid_File_Format );
+ goto Fail;
+ }
/* Pad to a 4-byte boundary length */
face->ttf_size += (FT_Long)( ( len + 3 ) & ~3U );
@@ -721,7 +737,6 @@
status = OTHER_TABLES;
- /* there are no more than 256 tables, so no size check here */
if ( FT_REALLOC( face->ttf_data, 12 + 16 * num_tables,
face->ttf_size + 1 ) )
goto Fail;
@@ -795,6 +810,17 @@
error = FT_THROW( Invalid_File_Format );
goto Fail;
}
+
+ /* we certainly need more than 4 bytes per glyph */
+ if ( loader->num_glyphs > ( limit - parser->root.cursor ) >> 2 )
+ {
+ FT_TRACE0(( "t42_parse_charstrings: adjusting number of glyphs"
+ " (from %d to %d)\n",
+ loader->num_glyphs,
+ ( limit - parser->root.cursor ) >> 2 ));
+ loader->num_glyphs = ( limit - parser->root.cursor ) >> 2;
+ }
+
}
else if ( *parser->root.cursor == '<' )
{
@@ -873,8 +899,13 @@
for (;;)
{
- /* The format is simple: */
- /* `/glyphname' + index [+ def] */
+ /* We support two formats. */
+ /* */
+ /* `/glyphname' + index [+ `def'] */
+ /* `(glyphname)' [+ `cvn'] + index [+ `def'] */
+ /* */
+ /* The latter format gets created by the */
+ /* LilyPond typesetting program. */
T1_Skip_Spaces( parser );
@@ -902,12 +933,13 @@
if ( parser->root.error )
return;
- if ( *cur == '/' )
+ if ( *cur == '/' || *cur == '(' )
{
FT_UInt len;
+ FT_Bool have_literal = FT_BOOL( *cur == '(' );
- if ( cur + 2 >= limit )
+ if ( cur + ( have_literal ? 3 : 2 ) >= limit )
{
FT_ERROR(( "t42_parse_charstrings: out of bounds\n" ));
error = FT_THROW( Invalid_File_Format );
@@ -916,6 +948,8 @@
cur++; /* skip `/' */
len = (FT_UInt)( parser->root.cursor - cur );
+ if ( have_literal )
+ len--;
error = T1_Add_Table( name_table, n, cur, len + 1 );
if ( error )
@@ -935,6 +969,9 @@
T1_Skip_Spaces( parser );
+ if ( have_literal )
+ T1_Skip_PS_Token( parser );
+
cur = parser->root.cursor;
(void)T1_ToInt( parser );
@@ -1231,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/src/3rdparty/freetype/src/type42/t42parse.h b/src/3rdparty/freetype/src/type42/t42parse.h
index 8ed2fde65d..f35d23de63 100644
--- a/src/3rdparty/freetype/src/type42/t42parse.h
+++ b/src/3rdparty/freetype/src/type42/t42parse.h
@@ -4,7 +4,7 @@
/* */
/* Type 42 font parser (specification). */
/* */
-/* Copyright 2002-2015 by */
+/* Copyright 2002-2018 by */
/* Roberto Alameda. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -16,8 +16,8 @@
/***************************************************************************/
-#ifndef __T42PARSE_H__
-#define __T42PARSE_H__
+#ifndef T42PARSE_H_
+#define T42PARSE_H_
#include "t42objs.h"
@@ -85,7 +85,7 @@ FT_BEGIN_HEADER
FT_END_HEADER
-#endif /* __T42PARSE_H__ */
+#endif /* T42PARSE_H_ */
/* END */
diff --git a/src/3rdparty/freetype/src/type42/t42types.h b/src/3rdparty/freetype/src/type42/t42types.h
index 01286af827..d0aa2de570 100644
--- a/src/3rdparty/freetype/src/type42/t42types.h
+++ b/src/3rdparty/freetype/src/type42/t42types.h
@@ -4,7 +4,7 @@
/* */
/* Type 42 font data types (specification only). */
/* */
-/* Copyright 2002-2015 by */
+/* Copyright 2002-2018 by */
/* Roberto Alameda. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -16,8 +16,8 @@
/***************************************************************************/
-#ifndef __T42TYPES_H__
-#define __T42TYPES_H__
+#ifndef T42TYPES_H_
+#define T42TYPES_H_
#include <ft2build.h>
@@ -51,7 +51,7 @@ FT_BEGIN_HEADER
FT_END_HEADER
-#endif /* __T42TYPES_H__ */
+#endif /* T42TYPES_H_ */
/* END */
diff --git a/src/3rdparty/freetype/src/type42/type42.c b/src/3rdparty/freetype/src/type42/type42.c
index 3332b7b7e6..6a89cfbed1 100644
--- a/src/3rdparty/freetype/src/type42/type42.c
+++ b/src/3rdparty/freetype/src/type42/type42.c
@@ -4,7 +4,7 @@
/* */
/* FreeType Type 42 driver component. */
/* */
-/* Copyright 2002-2015 by */
+/* Copyright 2002-2018 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/src/3rdparty/freetype/src/winfonts/Jamfile b/src/3rdparty/freetype/src/winfonts/Jamfile
index 86ee668196..4385e3b39f 100644
--- a/src/3rdparty/freetype/src/winfonts/Jamfile
+++ b/src/3rdparty/freetype/src/winfonts/Jamfile
@@ -1,6 +1,6 @@
# FreeType 2 src/winfonts Jamfile
#
-# Copyright 2001-2015 by
+# Copyright 2001-2018 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/src/3rdparty/freetype/src/winfonts/fnterrs.h b/src/3rdparty/freetype/src/winfonts/fnterrs.h
index 0bf4d0986d..3a86af5aac 100644
--- a/src/3rdparty/freetype/src/winfonts/fnterrs.h
+++ b/src/3rdparty/freetype/src/winfonts/fnterrs.h
@@ -4,7 +4,7 @@
/* */
/* Win FNT/FON error codes (specification only). */
/* */
-/* Copyright 2001-2015 by */
+/* Copyright 2001-2018 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -23,12 +23,12 @@
/* */
/*************************************************************************/
-#ifndef __FNTERRS_H__
-#define __FNTERRS_H__
+#ifndef FNTERRS_H_
+#define FNTERRS_H_
#include FT_MODULE_ERRORS_H
-#undef __FTERRORS_H__
+#undef FTERRORS_H_
#undef FT_ERR_PREFIX
#define FT_ERR_PREFIX FNT_Err_
@@ -36,7 +36,7 @@
#include FT_ERRORS_H
-#endif /* __FNTERRS_H__ */
+#endif /* FNTERRS_H_ */
/* END */
diff --git a/src/3rdparty/freetype/src/winfonts/module.mk b/src/3rdparty/freetype/src/winfonts/module.mk
index 8ba6d7584f..13f9077cfc 100644
--- a/src/3rdparty/freetype/src/winfonts/module.mk
+++ b/src/3rdparty/freetype/src/winfonts/module.mk
@@ -3,7 +3,7 @@
#
-# Copyright 1996-2015 by
+# Copyright 1996-2018 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/src/3rdparty/freetype/src/winfonts/rules.mk b/src/3rdparty/freetype/src/winfonts/rules.mk
index 4535f54d42..d694d1a771 100644
--- a/src/3rdparty/freetype/src/winfonts/rules.mk
+++ b/src/3rdparty/freetype/src/winfonts/rules.mk
@@ -3,7 +3,7 @@
#
-# Copyright 1996-2015 by
+# Copyright 1996-2018 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/src/3rdparty/freetype/src/winfonts/winfnt.c b/src/3rdparty/freetype/src/winfonts/winfnt.c
index 4bfa55a429..36bd3148d5 100644
--- a/src/3rdparty/freetype/src/winfonts/winfnt.c
+++ b/src/3rdparty/freetype/src/winfonts/winfnt.c
@@ -4,7 +4,7 @@
/* */
/* FreeType font driver for Windows FNT/FON files */
/* */
-/* Copyright 1996-2015 by */
+/* Copyright 1996-2018 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 */
{
@@ -851,10 +859,6 @@
NULL );
if ( error )
goto Fail;
-
- /* Select default charmap */
- if ( root->num_charmaps )
- root->charmap = root->charmaps[0];
}
/* set up remaining flags */
@@ -992,8 +996,6 @@
FT_ULong offset;
FT_Bool new_format;
- FT_UNUSED( load_flags );
-
if ( !face )
{
@@ -1047,6 +1049,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 +1080,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 );
@@ -1071,7 +1091,7 @@
/* note: since glyphs are stored in columns and not in rows we */
/* can't use ft_glyphslot_set_bitmap */
- if ( FT_ALLOC_MULT( bitmap->buffer, pitch, bitmap->rows ) )
+ if ( FT_ALLOC_MULT( bitmap->buffer, bitmap->rows, pitch ) )
goto Exit;
column = (FT_Byte*)bitmap->buffer;
@@ -1084,22 +1104,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;
@@ -1121,7 +1128,7 @@
static const FT_Service_WinFntRec winfnt_service_rec =
{
- winfnt_get_header
+ winfnt_get_header /* get_header */
};
/*
@@ -1161,32 +1168,32 @@
0x10000L,
0x20000L,
- 0,
+ NULL, /* module-specific interface */
- 0, /* FT_Module_Constructor */
- 0, /* FT_Module_Destructor */
- winfnt_get_service
+ NULL, /* FT_Module_Constructor module_init */
+ NULL, /* FT_Module_Destructor module_done */
+ winfnt_get_service /* FT_Module_Requester get_interface */
},
sizeof ( FNT_FaceRec ),
sizeof ( FT_SizeRec ),
sizeof ( FT_GlyphSlotRec ),
- FNT_Face_Init,
- FNT_Face_Done,
- 0, /* FT_Size_InitFunc */
- 0, /* FT_Size_DoneFunc */
- 0, /* FT_Slot_InitFunc */
- 0, /* FT_Slot_DoneFunc */
+ FNT_Face_Init, /* FT_Face_InitFunc init_face */
+ FNT_Face_Done, /* FT_Face_DoneFunc done_face */
+ 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,
+ FNT_Load_Glyph, /* FT_Slot_LoadFunc load_glyph */
- 0, /* FT_Face_GetKerningFunc */
- 0, /* FT_Face_AttachFunc */
- 0, /* FT_Face_GetAdvancesFunc */
+ NULL, /* FT_Face_GetKerningFunc get_kerning */
+ NULL, /* FT_Face_AttachFunc attach_file */
+ NULL, /* FT_Face_GetAdvancesFunc get_advances */
- FNT_Size_Request,
- FNT_Size_Select
+ FNT_Size_Request, /* FT_Size_RequestFunc request_size */
+ FNT_Size_Select /* FT_Size_SelectFunc select_size */
};
diff --git a/src/3rdparty/freetype/src/winfonts/winfnt.h b/src/3rdparty/freetype/src/winfonts/winfnt.h
index a39d26f449..4885c9d745 100644
--- a/src/3rdparty/freetype/src/winfonts/winfnt.h
+++ b/src/3rdparty/freetype/src/winfonts/winfnt.h
@@ -4,7 +4,7 @@
/* */
/* FreeType font driver for Windows FNT/FON files */
/* */
-/* Copyright 1996-2015 by */
+/* Copyright 1996-2018 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* Copyright 2007 Dmitry Timoshkov for Codeweavers */
/* */
@@ -17,8 +17,8 @@
/***************************************************************************/
-#ifndef __WINFNT_H__
-#define __WINFNT_H__
+#ifndef WINFNT_H_
+#define WINFNT_H_
#include <ft2build.h>
@@ -165,7 +165,7 @@ FT_BEGIN_HEADER
FT_END_HEADER
-#endif /* __WINFNT_H__ */
+#endif /* WINFNT_H_ */
/* END */